modules/vfs_aixacl.c

説明を見る。
00001 /*
00002    Unix SMB/Netbios implementation.
00003    VFS module to get and set posix acls
00004    Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2006
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010 
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015 
00016    You should have received a copy of the GNU General Public License
00017    along with this program; if not, write to the Free Software
00018    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019 */
00020 
00021 #include "includes.h"
00022 
00023 extern SMB_ACL_T aixacl_to_smbacl( struct acl *file_acl);
00024 extern struct acl *aixacl_smb_to_aixacl(SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl);
00025 
00026 SMB_ACL_T aixacl_sys_acl_get_file(vfs_handle_struct *handle,
00027                                     const char *path_p,
00028                                     SMB_ACL_TYPE_T type)
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 }
00082 
00083 SMB_ACL_T aixacl_sys_acl_get_fd(vfs_handle_struct *handle,
00084                                   files_struct *fsp,
00085                                   int fd)
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 }
00134 
00135 int aixacl_sys_acl_set_file(vfs_handle_struct *handle,
00136                               const char *name,
00137                               SMB_ACL_TYPE_T type,
00138                               SMB_ACL_T theacl)
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 }
00155 
00156 int aixacl_sys_acl_set_fd(vfs_handle_struct *handle,
00157                             files_struct *fsp,
00158                             int fd, SMB_ACL_T theacl)
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 }
00175 
00176 int aixacl_sys_acl_delete_def_file(vfs_handle_struct *handle,
00177                                      const char *path)
00178 {
00179         return 0; /* otherwise you can't set acl at upper level */
00180 }
00181 
00182 /* VFS operations structure */
00183 
00184 static vfs_op_tuple aixacl_op_tuples[] = {
00185         /* Disk operations */
00186   {SMB_VFS_OP(aixacl_sys_acl_get_file),
00187    SMB_VFS_OP_SYS_ACL_GET_FILE,
00188    SMB_VFS_LAYER_TRANSPARENT},
00189 
00190   {SMB_VFS_OP(aixacl_sys_acl_get_fd),
00191    SMB_VFS_OP_SYS_ACL_GET_FD,
00192    SMB_VFS_LAYER_TRANSPARENT},
00193 
00194   {SMB_VFS_OP(aixacl_sys_acl_set_file),
00195    SMB_VFS_OP_SYS_ACL_SET_FILE,
00196    SMB_VFS_LAYER_TRANSPARENT},
00197 
00198   {SMB_VFS_OP(aixacl_sys_acl_set_fd),
00199    SMB_VFS_OP_SYS_ACL_SET_FD,
00200    SMB_VFS_LAYER_TRANSPARENT},
00201 
00202   {SMB_VFS_OP(aixacl_sys_acl_delete_def_file),
00203    SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE,
00204    SMB_VFS_LAYER_TRANSPARENT},
00205 
00206   {SMB_VFS_OP(NULL),
00207    SMB_VFS_OP_NOOP,
00208    SMB_VFS_LAYER_NOOP}
00209 };
00210 
00211 NTSTATUS vfs_aixacl_init(void);
00212 NTSTATUS vfs_aixacl_init(void)
00213 {
00214         return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "aixacl",
00215                                 aixacl_op_tuples);
00216 }

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