modules/vfs_aixacl.c

ソースコードを見る。

関数

SMB_ACL_T aixacl_to_smbacl (struct acl *file_acl)
acl * aixacl_smb_to_aixacl (SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl)
SMB_ACL_T aixacl_sys_acl_get_file (vfs_handle_struct *handle, const char *path_p, SMB_ACL_TYPE_T type)
SMB_ACL_T aixacl_sys_acl_get_fd (vfs_handle_struct *handle, files_struct *fsp, int fd)
int aixacl_sys_acl_set_file (vfs_handle_struct *handle, const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T theacl)
int aixacl_sys_acl_set_fd (vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_ACL_T theacl)
int aixacl_sys_acl_delete_def_file (vfs_handle_struct *handle, const char *path)
NTSTATUS vfs_aixacl_init (void)

変数

static vfs_op_tuple aixacl_op_tuples []


関数

SMB_ACL_T aixacl_to_smbacl ( struct acl *  file_acl  ) 

vfs_aixacl_util.c23 行で定義されています。

参照元 aixacl_sys_acl_get_fd()aixacl_sys_acl_get_file()aixjfs2_get_posix_acl().

00024 {
00025         struct acl_entry *acl_entry;
00026         struct ace_id *idp;
00027         
00028         struct smb_acl_t *result = SMB_MALLOC_P(struct smb_acl_t);
00029         struct smb_acl_entry *ace;
00030         int i;
00031         
00032         if (result == NULL) {
00033                 return NULL;
00034         }
00035         ZERO_STRUCTP(result);
00036         
00037         /* Point to the first acl entry in the acl */
00038         acl_entry =  file_acl->acl_ext;
00039 
00040 
00041         
00042         DEBUG(10,("acl_entry is %d\n",acl_entry));
00043         DEBUG(10,("acl_last(file_acl) id %d\n",acl_last(file_acl)));
00044 
00045         /* Check if the extended acl bit is on.   *
00046          * If it isn't, do not show the           *
00047          * contents of the acl since AIX intends *
00048          * the extended info to remain unused     */
00049 
00050         if(file_acl->acl_mode & S_IXACL){
00051                 /* while we are not pointing to the very end */
00052                 while(acl_entry < acl_last(file_acl)) {
00053                         /* before we malloc anything, make sure this is  */
00054                         /* a valid acl entry and one that we want to map */
00055                         idp = id_nxt(acl_entry->ace_id);
00056                         if((acl_entry->ace_type == ACC_SPECIFY ||
00057                                 (acl_entry->ace_type == ACC_PERMIT)) && (idp != id_last(acl_entry))) {
00058                                         acl_entry = acl_nxt(acl_entry);
00059                                         continue;
00060                         }
00061 
00062                         idp = acl_entry->ace_id;
00063                         DEBUG(10,("idp->id_data is %d\n",idp->id_data[0]));
00064                         
00065                         result = SMB_REALLOC(result, sizeof(struct smb_acl_t) +
00066                                      (sizeof(struct smb_acl_entry) *
00067                                       (result->count+1)));
00068                         if (result == NULL) {
00069                                 DEBUG(0, ("SMB_REALLOC failed\n"));
00070                                 errno = ENOMEM;
00071                                 return NULL;
00072                         }
00073                         
00074 
00075                         DEBUG(10,("idp->id_type is %d\n",idp->id_type));
00076                         ace = &result->acl[result->count];
00077                         
00078                         ace->a_type = idp->id_type;
00079                                                         
00080                         switch(ace->a_type) {
00081                         case ACEID_USER: {
00082                         ace->uid = idp->id_data[0];
00083                         DEBUG(10,("case ACEID_USER ace->uid is %d\n",ace->uid));
00084                         ace->a_type = SMB_ACL_USER;
00085                         break;
00086                         }
00087                 
00088                         case ACEID_GROUP: {
00089                         ace->gid = idp->id_data[0];
00090                         DEBUG(10,("case ACEID_GROUP ace->gid is %d\n",ace->gid));
00091                         ace->a_type = SMB_ACL_GROUP;
00092                         break;
00093                         }
00094                         default:
00095                                 break;
00096                         }
00097                         /* The access in the acl entries must be left shifted by *
00098                          * three bites, because they will ultimately be compared *
00099                          * to S_IRUSR, S_IWUSR, and S_IXUSR.                  */
00100 
00101                         switch(acl_entry->ace_type){
00102                         case ACC_PERMIT:
00103                         case ACC_SPECIFY:
00104                                 ace->a_perm = acl_entry->ace_access;
00105                                 ace->a_perm <<= 6;
00106                                 DEBUG(10,("ace->a_perm is %d\n",ace->a_perm));
00107                                 break;
00108                         case ACC_DENY:
00109                                 /* Since there is no way to return a DENY acl entry *
00110                                  * change to PERMIT and then shift.                 */
00111                                 DEBUG(10,("acl_entry->ace_access is %d\n",acl_entry->ace_access));
00112                                 ace->a_perm = ~acl_entry->ace_access & 7;
00113                                 DEBUG(10,("ace->a_perm is %d\n",ace->a_perm));
00114                                 ace->a_perm <<= 6;
00115                                 break;
00116                         default:
00117                                 DEBUG(0, ("unknown ace->type\n"));
00118                                 SAFE_FREE(result);
00119                                 return(0);
00120                         }
00121                 
00122                         result->count++;
00123                         ace->a_perm |= (ace->a_perm & S_IRUSR) ? SMB_ACL_READ : 0;
00124                         ace->a_perm |= (ace->a_perm & S_IWUSR) ? SMB_ACL_WRITE : 0;
00125                         ace->a_perm |= (ace->a_perm & S_IXUSR) ? SMB_ACL_EXECUTE : 0;
00126                         DEBUG(10,("ace->a_perm is %d\n",ace->a_perm));
00127                         
00128                         DEBUG(10,("acl_entry = %d\n",acl_entry));
00129                         DEBUG(10,("The ace_type is %d\n",acl_entry->ace_type));
00130  
00131                         acl_entry = acl_nxt(acl_entry);
00132                 }
00133         } /* end of if enabled */
00134 
00135         /* Since owner, group, other acl entries are not *
00136          * part of the acl entries in an acl, they must  *
00137          * be dummied up to become part of the list.     */
00138 
00139         for( i = 1; i < 4; i++) {
00140                 DEBUG(10,("i is %d\n",i));
00141 
00142                         result = SMB_REALLOC(result, sizeof(struct smb_acl_t) +
00143                                      (sizeof(struct smb_acl_entry) *
00144                                       (result->count+1)));
00145                         if (result == NULL) {
00146                                 DEBUG(0, ("SMB_REALLOC failed\n"));
00147                                 errno = ENOMEM;
00148                                 DEBUG(0,("Error in AIX sys_acl_get_file is %d\n",errno));
00149                                 return NULL;
00150                         }
00151                         
00152                 ace = &result->acl[result->count];
00153                 
00154                 ace->uid = 0;
00155                 ace->gid = 0;
00156                 DEBUG(10,("ace->uid = %d\n",ace->uid));
00157                 
00158                 switch(i) {
00159                 case 2:
00160                         ace->a_perm = file_acl->g_access << 6;
00161                         ace->a_type = SMB_ACL_GROUP_OBJ;
00162                         break;
00163 
00164                 case 3:
00165                         ace->a_perm = file_acl->o_access << 6;
00166                         ace->a_type = SMB_ACL_OTHER;
00167                         break;
00168  
00169                 case 1:
00170                         ace->a_perm = file_acl->u_access << 6;
00171                         ace->a_type = SMB_ACL_USER_OBJ;
00172                         break;
00173  
00174                 default:
00175                         return(NULL);
00176 
00177                 }
00178                 ace->a_perm |= ((ace->a_perm & S_IRUSR) ? SMB_ACL_READ : 0);
00179                 ace->a_perm |= ((ace->a_perm & S_IWUSR) ? SMB_ACL_WRITE : 0);
00180                 ace->a_perm |= ((ace->a_perm & S_IXUSR) ? SMB_ACL_EXECUTE : 0);
00181                 
00182                 memcpy(&result->acl[result->count],ace,sizeof(struct smb_acl_entry));
00183                 result->count++;
00184                 DEBUG(10,("ace->a_perm = %d\n",ace->a_perm));
00185                 DEBUG(10,("ace->a_type = %d\n",ace->a_type));
00186         }
00187 
00188 
00189         return result;
00190 
00191 
00192 }

struct acl* aixacl_smb_to_aixacl ( SMB_ACL_TYPE_T  acltype,
SMB_ACL_T  theacl 
)

vfs_aixacl_util.c206 行で定義されています。

参照元 aixacl_sys_acl_set_fd()aixacl_sys_acl_set_file()aixjfs2_sys_acl_set_fd()aixjfs2_sys_acl_set_file().

00207 {
00208         struct smb_acl_entry *smb_entry = NULL;
00209         struct acl *file_acl = NULL;
00210         struct acl *file_acl_temp = NULL;
00211         struct acl_entry *acl_entry = NULL;
00212         struct ace_id *ace_id = NULL;
00213         uint id_type;
00214         uint user_id;
00215         uint acl_length;
00216         int     i;
00217  
00218         DEBUG(10,("Entering aixacl_smb_to_aixacl\n"));
00219         /* AIX has no default ACL */
00220         if(acltype == SMB_ACL_TYPE_DEFAULT)
00221                 return NULL;
00222 
00223         acl_length = BUFSIZ;
00224         file_acl = (struct acl *)SMB_MALLOC(BUFSIZ);
00225         if(file_acl == NULL) {
00226                 errno = ENOMEM;
00227                 DEBUG(0,("Error in aixacl_smb_to_aixacl is %d\n",errno));
00228                 return NULL;
00229         }
00230 
00231         memset(file_acl,0,BUFSIZ);
00232  
00233         file_acl->acl_len = ACL_SIZ;
00234         file_acl->acl_mode = S_IXACL;
00235 
00236         for(i=0; i<theacl->count; i++ ) {
00237                 smb_entry = &(theacl->acl[i]);
00238                 id_type = smb_entry->a_type;
00239                 DEBUG(10,("The id_type is %d\n",id_type));
00240 
00241                 switch(id_type) {
00242                         case SMB_ACL_USER_OBJ:
00243                                 file_acl->u_access = aixacl_smb_to_aixperm(smb_entry->a_perm);
00244                                 continue;
00245                         case SMB_ACL_GROUP_OBJ:
00246                                 file_acl->g_access = aixacl_smb_to_aixperm(smb_entry->a_perm);
00247                                 continue;
00248                         case SMB_ACL_OTHER:
00249                                 file_acl->o_access = aixacl_smb_to_aixperm(smb_entry->a_perm);
00250                                 continue;
00251                         case SMB_ACL_MASK:
00252                                 continue;
00253                         case SMB_ACL_GROUP:
00254                                 break; /* process this */
00255                         case SMB_ACL_USER:
00256                                 break; /* process this */
00257                         default: /* abnormal case */
00258                                 DEBUG(10,("The id_type is unknown !\n"));
00259                                 continue;
00260                 }
00261 
00262                 if((file_acl->acl_len + sizeof(struct acl_entry)) > acl_length) {
00263                         acl_length += sizeof(struct acl_entry);
00264                         file_acl_temp = (struct acl *)SMB_MALLOC(acl_length);
00265                         if(file_acl_temp == NULL) {
00266                                 SAFE_FREE(file_acl);
00267                                 errno = ENOMEM;
00268                                 DEBUG(0,("Error in aixacl_smb_to_aixacl is %d\n",errno));
00269                                 return NULL;
00270                         }
00271 
00272                         memcpy(file_acl_temp,file_acl,file_acl->acl_len);
00273                         SAFE_FREE(file_acl);
00274                         file_acl = file_acl_temp;
00275                 }
00276 
00277                 acl_entry = (struct acl_entry *)((char *)file_acl + file_acl->acl_len);
00278                 file_acl->acl_len += sizeof(struct acl_entry);
00279                 acl_entry->ace_len = sizeof(struct acl_entry); /* contains 1 ace_id */
00280                 acl_entry->ace_access = aixacl_smb_to_aixperm(smb_entry->a_perm);
00281 
00282                 /* In order to use this, we'll need to wait until we can get denies */
00283                 /* if(!acl_entry->ace_access && acl_entry->ace_type == ACC_PERMIT)
00284                 acl_entry->ace_type = ACC_SPECIFY; */
00285 
00286                 acl_entry->ace_type = ACC_SPECIFY;
00287 
00288                 ace_id = acl_entry->ace_id;
00289 
00290                 ace_id->id_type = (smb_entry->a_type==SMB_ACL_GROUP) ? ACEID_GROUP : ACEID_USER;
00291                 DEBUG(10,("The id type is %d\n",ace_id->id_type));
00292                 ace_id->id_len = sizeof(struct ace_id); /* contains 1 id_data */
00293                 ace_id->id_data[0] = (smb_entry->a_type==SMB_ACL_GROUP) ? smb_entry->gid : smb_entry->uid;
00294         }
00295 
00296         return file_acl;
00297 }

SMB_ACL_T aixacl_sys_acl_get_file ( vfs_handle_struct handle,
const char *  path_p,
SMB_ACL_TYPE_T  type 
)

vfs_aixacl.c26 行で定義されています。

参照先 aixacl_to_smbacl()errnoresult.

00029 {
00030         struct acl *file_acl = (struct acl *)NULL;
00031         struct smb_acl_t *result = (struct smb_acl_t *)NULL;
00032         
00033         int rc = 0;
00034         uid_t user_id;
00035 
00036         /* AIX has no DEFAULT */
00037         if  ( type == SMB_ACL_TYPE_DEFAULT )
00038                 return NULL;
00039 
00040         /* Get the acl using statacl */
00041  
00042         DEBUG(10,("Entering AIX sys_acl_get_file\n"));
00043         DEBUG(10,("path_p is %s\n",path_p));
00044 
00045         file_acl = (struct acl *)SMB_MALLOC(BUFSIZ);
00046  
00047         if(file_acl == NULL) {
00048                 errno=ENOMEM;
00049                 DEBUG(0,("Error in AIX sys_acl_get_file: %d\n",errno));
00050                 return(NULL);
00051         }
00052 
00053         memset(file_acl,0,BUFSIZ);
00054 
00055         rc = statacl((char *)path_p,0,file_acl,BUFSIZ);
00056         if( (rc == -1) && (errno == ENOSPC)) {
00057                 struct acl *new_acl = SMB_MALLOC(file_acl->acl_len + sizeof(struct acl));
00058                 if( new_acl == NULL) {
00059                         SAFE_FREE(file_acl);
00060                         errno = ENOMEM;
00061                         return NULL;
00062                 }
00063                 file_acl = new_acl;
00064                 rc = statacl((char *)path_p,0,file_acl,file_acl->acl_len+sizeof(struct acl));
00065                 if( rc == -1) {
00066                         DEBUG(0,("statacl returned %d with errno %d\n",rc,errno));
00067                         SAFE_FREE(file_acl);
00068                         return(NULL);
00069                 }
00070         }
00071 
00072         DEBUG(10,("Got facl and returned it\n"));
00073 
00074         
00075         result = aixacl_to_smbacl(file_acl);
00076         SAFE_FREE(file_acl);
00077         return result;
00078         
00079         /*errno = ENOTSUP;
00080         return NULL;*/
00081 }

SMB_ACL_T aixacl_sys_acl_get_fd ( vfs_handle_struct handle,
files_struct fsp,
int  fd 
)

vfs_aixacl.c83 行で定義されています。

参照先 aixacl_to_smbacl()errnoresult.

00086 {
00087 
00088         struct acl *file_acl = (struct acl *)NULL;
00089         struct smb_acl_t *result = (struct smb_acl_t *)NULL;
00090         
00091         int rc = 0;
00092         uid_t user_id;
00093 
00094         /* Get the acl using fstatacl */
00095    
00096         DEBUG(10,("Entering AIX sys_acl_get_fd\n"));
00097         DEBUG(10,("fd is %d\n",fd));
00098         file_acl = (struct acl *)SMB_MALLOC(BUFSIZ);
00099 
00100         if(file_acl == NULL) {
00101                 errno=ENOMEM;
00102                 DEBUG(0,("Error in AIX sys_acl_get_fd is %d\n",errno));
00103                 return(NULL);
00104         }
00105 
00106         memset(file_acl,0,BUFSIZ);
00107 
00108         rc = fstatacl(fd,0,file_acl,BUFSIZ);
00109         if( (rc == -1) && (errno == ENOSPC)) {
00110                 struct acl *new_acl = SMB_MALLOC(file_acl->acl_len + sizeof(struct acl));
00111                 if( new_acl == NULL) {
00112                         SAFE_FREE(file_acl);
00113                         errno = ENOMEM;
00114                         return NULL;
00115                 }
00116                 file_acl = new_acl;
00117                 rc = fstatacl(fd,0,file_acl,file_acl->acl_len + sizeof(struct acl));
00118                 if( rc == -1) {
00119                         DEBUG(0,("fstatacl returned %d with errno %d\n",rc,errno));
00120                         SAFE_FREE(file_acl);
00121                         return(NULL);
00122                 }
00123         }
00124 
00125         DEBUG(10,("Got facl and returned it\n"));
00126 
00127         result = aixacl_to_smbacl(file_acl);
00128         SAFE_FREE(file_acl);
00129         return result;
00130         
00131         /*errno = ENOTSUP;
00132         return NULL;*/
00133 }

int aixacl_sys_acl_set_file ( vfs_handle_struct handle,
const char *  name,
SMB_ACL_TYPE_T  type,
SMB_ACL_T  theacl 
)

vfs_aixacl.c135 行で定義されています。

参照先 aixacl_smb_to_aixacl()errno.

00139 {
00140         struct acl *file_acl = NULL;
00141         uint rc;
00142         
00143         file_acl = aixacl_smb_to_aixacl(type, theacl);
00144         if (!file_acl)
00145                 return -1;
00146 
00147         rc = chacl((char *)name,file_acl,file_acl->acl_len);
00148         DEBUG(10,("errno is %d\n",errno));
00149         DEBUG(10,("return code is %d\n",rc));
00150         SAFE_FREE(file_acl);
00151         DEBUG(10,("Exiting the aixacl_sys_acl_set_file\n"));
00152 
00153         return rc;
00154 }

int aixacl_sys_acl_set_fd ( vfs_handle_struct handle,
files_struct fsp,
int  fd,
SMB_ACL_T  theacl 
)

vfs_aixacl.c156 行で定義されています。

参照先 aixacl_smb_to_aixacl()errno.

00159 {
00160         struct acl *file_acl = NULL;
00161         uint rc;
00162 
00163         file_acl = aixacl_smb_to_aixacl(SMB_ACL_TYPE_ACCESS, theacl);
00164         if (!file_acl)
00165                 return -1;
00166 
00167         rc = fchacl(fd,file_acl,file_acl->acl_len);
00168         DEBUG(10,("errno is %d\n",errno));
00169         DEBUG(10,("return code is %d\n",rc));
00170         SAFE_FREE(file_acl);
00171         DEBUG(10,("Exiting aixacl_sys_acl_set_fd\n"));
00172 
00173         return rc;
00174 }

int aixacl_sys_acl_delete_def_file ( vfs_handle_struct handle,
const char *  path 
)

vfs_aixacl.c176 行で定義されています。

00178 {
00179         return 0; /* otherwise you can't set acl at upper level */
00180 }

NTSTATUS vfs_aixacl_init ( void   ) 

vfs_aixacl.c212 行で定義されています。

参照先 aixacl_op_tuplessmb_register_vfs().

00213 {
00214         return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "aixacl",
00215                                 aixacl_op_tuples);
00216 }


変数

vfs_op_tuple aixacl_op_tuples[] [static]

初期値:

 {
        
  {SMB_VFS_OP(aixacl_sys_acl_get_file),
   SMB_VFS_OP_SYS_ACL_GET_FILE,
   SMB_VFS_LAYER_TRANSPARENT},

  {SMB_VFS_OP(aixacl_sys_acl_get_fd),
   SMB_VFS_OP_SYS_ACL_GET_FD,
   SMB_VFS_LAYER_TRANSPARENT},

  {SMB_VFS_OP(aixacl_sys_acl_set_file),
   SMB_VFS_OP_SYS_ACL_SET_FILE,
   SMB_VFS_LAYER_TRANSPARENT},

  {SMB_VFS_OP(aixacl_sys_acl_set_fd),
   SMB_VFS_OP_SYS_ACL_SET_FD,
   SMB_VFS_LAYER_TRANSPARENT},

  {SMB_VFS_OP(aixacl_sys_acl_delete_def_file),
   SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE,
   SMB_VFS_LAYER_TRANSPARENT},

  {SMB_VFS_OP(NULL),
   SMB_VFS_OP_NOOP,
   SMB_VFS_LAYER_NOOP}
}

vfs_aixacl.c184 行で定義されています。

参照元 vfs_aixacl_init().


Sambaに対してSat Aug 29 21:23:51 2009に生成されました。  doxygen 1.4.7