modules/vfs_aixacl_util.c

ソースコードを見る。

関数

SMB_ACL_T aixacl_to_smbacl (struct acl *file_acl)
static ushort aixacl_smb_to_aixperm (SMB_ACL_PERM_T a_perm)
acl * aixacl_smb_to_aixacl (SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl)


関数

SMB_ACL_T aixacl_to_smbacl ( struct acl *  file_acl  ) 

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

参照先 smb_acl_entry::a_permsmb_acl_entry::a_typeerrnosmb_acl_entry::gidresultSMB_ACL_GROUPSMB_ACL_GROUP_OBJSMB_ACL_OTHERSMB_ACL_USERSMB_ACL_USER_OBJsmb_acl_entry::uid.

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 }

static ushort aixacl_smb_to_aixperm ( SMB_ACL_PERM_T  a_perm  )  [static]

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

参照元 aixacl_smb_to_aixacl().

00195 {
00196         ushort ret = (ushort)0;
00197         if (a_perm & SMB_ACL_READ)
00198                 ret |= R_ACC;
00199         if (a_perm & SMB_ACL_WRITE)
00200                 ret |= W_ACC;
00201         if (a_perm & SMB_ACL_EXECUTE)
00202                 ret |= X_ACC;
00203         return ret;
00204 }

struct acl* aixacl_smb_to_aixacl ( SMB_ACL_TYPE_T  acltype,
SMB_ACL_T  theacl 
)

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

参照先 smb_acl_entry::a_permsmb_acl_entry::a_typesmb_acl_t::aclaixacl_smb_to_aixperm()smb_acl_t::counterrnosmb_acl_entry::gidSMB_ACL_GROUPSMB_ACL_GROUP_OBJSMB_ACL_MASKSMB_ACL_OTHERSMB_ACL_USERSMB_ACL_USER_OBJsmb_acl_entry::uid.

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 }


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