s3:vfs_gpfs: add "gpfs:posixacl" per share option
authorStefan Metzmacher <metze@samba.org>
Thu, 22 Dec 2011 16:48:11 +0000 (17:48 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 10 May 2012 16:47:05 +0000 (18:47 +0200)
Based on a patch from Hans-Dieter Schuster <hans-dieter.schuster@ts.fujitsu.com>

metze

source3/modules/vfs_gpfs.c

index 4b0f9ebaf724c564f7eb2beb4c7262b363fb0d8a..9eb35f3f018a29a6255e9637e15513720394c7b8 100644 (file)
@@ -45,6 +45,7 @@ struct gpfs_config_data {
        bool getrealfilename;
        bool dfreequota;
        bool prealloc;
+       bool posixacl;
 };
 
 
@@ -350,8 +351,19 @@ static NTSTATUS gpfsacl_fget_nt_acl(vfs_handle_struct *handle,
 {
        SMB4ACL_T *pacl = NULL;
        int     result;
+       struct gpfs_config_data *config;
 
        *ppdesc = NULL;
+
+       SMB_VFS_HANDLE_GET_DATA(handle, config,
+                               struct gpfs_config_data,
+                               return NT_STATUS_INTERNAL_ERROR);
+
+       if (config->posixacl) {
+               DEBUG(10, ("gpfs:posixacl -> using posix_fget_nt_acl()...\n"));
+               return posix_fget_nt_acl(fsp, security_info, ppdesc);
+       }
+
        result = gpfs_get_nfs4_acl(fsp->fsp_name->base_name, &pacl);
 
        if (result == 0)
@@ -372,8 +384,19 @@ static NTSTATUS gpfsacl_get_nt_acl(vfs_handle_struct *handle,
 {
        SMB4ACL_T *pacl = NULL;
        int     result;
+       struct gpfs_config_data *config;
 
        *ppdesc = NULL;
+
+       SMB_VFS_HANDLE_GET_DATA(handle, config,
+                               struct gpfs_config_data,
+                               return NT_STATUS_INTERNAL_ERROR);
+
+       if (config->posixacl) {
+               DEBUG(10, ("gpfs:posixacl -> posix_get_nt_acl()...\n"));
+               return posix_get_nt_acl(handle->conn, name, security_info, ppdesc);
+       }
+
        result = gpfs_get_nfs4_acl(name, &pacl);
 
        if (result == 0)
@@ -514,6 +537,17 @@ static NTSTATUS gpfsacl_set_nt_acl_internal(files_struct *fsp, uint32 security_i
 
 static NTSTATUS gpfsacl_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, const struct security_descriptor *psd)
 {
+       struct gpfs_config_data *config;
+
+       SMB_VFS_HANDLE_GET_DATA(handle, config,
+                               struct gpfs_config_data,
+                               return NT_STATUS_INTERNAL_ERROR);
+
+       if (config->posixacl) {
+               DEBUG(10, ("gpfs:posixacl -> set_nt_acl()...\n"));
+               return set_nt_acl(fsp, security_info_sent, psd);
+       }
+
        return gpfsacl_set_nt_acl_internal(fsp, security_info_sent, psd);
 }
 
@@ -627,6 +661,16 @@ static SMB_ACL_T gpfsacl_sys_acl_get_file(vfs_handle_struct *handle,
                                          SMB_ACL_TYPE_T type)
 {
        gpfs_aclType_t gpfs_type;
+       struct gpfs_config_data *config;
+
+       SMB_VFS_HANDLE_GET_DATA(handle, config,
+                               struct gpfs_config_data,
+                               return NULL);
+
+       if (config->posixacl) {
+               DEBUG(10, ("gpfs:posixacl -> using posixacl_sys_acl_get_file()...\n"));
+               return posixacl_sys_acl_get_file(handle, path_p, type);
+       }
 
        switch(type) {
        case SMB_ACL_TYPE_ACCESS:
@@ -646,6 +690,17 @@ static SMB_ACL_T gpfsacl_sys_acl_get_file(vfs_handle_struct *handle,
 static SMB_ACL_T gpfsacl_sys_acl_get_fd(vfs_handle_struct *handle,
                                        files_struct *fsp)
 {
+       struct gpfs_config_data *config;
+
+       SMB_VFS_HANDLE_GET_DATA(handle, config,
+                               struct gpfs_config_data,
+                               return NULL);
+
+       if (config->posixacl) {
+               DEBUG(10, ("gpfs:posixacl -> using posixacl_sys_acl_get_fd()...\n"));
+               return posixacl_sys_acl_get_fd(handle, fsp);
+       }
+
        return gpfsacl_get_posix_acl(fsp->fsp_name->base_name,
                                     GPFS_ACL_TYPE_ACCESS);
 }
@@ -744,6 +799,16 @@ static int gpfsacl_sys_acl_set_file(vfs_handle_struct *handle,
 {
        struct gpfs_acl *gpfs_acl;
        int result;
+       struct gpfs_config_data *config;
+
+       SMB_VFS_HANDLE_GET_DATA(handle, config,
+                               struct gpfs_config_data,
+                               return -1);
+
+       if (config->posixacl) {
+               DEBUG(10, ("gpfs:posixacl -> using posixacl_sys_acl_set_file()...\n"));
+               return posixacl_sys_acl_set_file(handle, name, type, theacl);
+       }
 
        gpfs_acl = smb2gpfs_acl(theacl, type);
        if (gpfs_acl == NULL) {
@@ -760,6 +825,17 @@ static int gpfsacl_sys_acl_set_fd(vfs_handle_struct *handle,
                                  files_struct *fsp,
                                  SMB_ACL_T theacl)
 {
+       struct gpfs_config_data *config;
+
+       SMB_VFS_HANDLE_GET_DATA(handle, config,
+                               struct gpfs_config_data,
+                               return -1);
+
+       if (config->posixacl) {
+               DEBUG(10, ("gpfs:posixacl -> using posixacl_sys_acl_set_fd()...\n"));
+               return posixacl_sys_acl_set_fd(handle, fsp, theacl);
+       }
+
        return gpfsacl_sys_acl_set_file(handle, fsp->fsp_name->base_name,
                                        SMB_ACL_TYPE_ACCESS, theacl);
 }
@@ -767,6 +843,17 @@ static int gpfsacl_sys_acl_set_fd(vfs_handle_struct *handle,
 static int gpfsacl_sys_acl_delete_def_file(vfs_handle_struct *handle,
                                           const char *path)
 {
+       struct gpfs_config_data *config;
+
+       SMB_VFS_HANDLE_GET_DATA(handle, config,
+                               struct gpfs_config_data,
+                               return -1);
+
+       if (config->posixacl) {
+               DEBUG(10, ("gpfs:posixacl -> using posixacl_sys_acl_delete_def_file()...\n"));
+               return posixacl_sys_acl_delete_def_file(handle, path);
+       }
+
        errno = ENOTSUP;
        return -1;
 }
@@ -1425,6 +1512,9 @@ static int vfs_gpfs_connect(struct vfs_handle_struct *handle,
        config->prealloc = lp_parm_bool(SNUM(handle->conn), "gpfs",
                                   "prealloc", true);
 
+       config->posixacl = lp_parm_bool(SNUM(handle->conn), "gpfs",
+                                       "posixacl", false);
+
        SMB_VFS_HANDLE_SET_DATA(handle, config,
                                NULL, struct gpfs_config_data,
                                return -1);