diff options
| author | Poornima G <pgurusid@redhat.com> | 2014-12-12 14:11:49 +0100 |
|---|---|---|
| committer | Günther Deschner <gd@samba.org> | 2014-12-17 14:11:07 +0100 |
| commit | 26b3544251babdfcdf5ada338a4ed39ff18bc47a (patch) | |
| tree | 00c880ab0e8c72a02eb0b8243678c543636cf899 /source3/modules | |
| parent | 770f222f333dfe51d253038e706c195623df0c0c (diff) | |
| download | samba-26b3544251babdfcdf5ada338a4ed39ff18bc47a.tar.gz samba-26b3544251babdfcdf5ada338a4ed39ff18bc47a.tar.xz samba-26b3544251babdfcdf5ada338a4ed39ff18bc47a.zip | |
vfs_glusterfs: Change sys_get_acl_file/fd to return ACLs corresponding to mode bits when there are no ACLs set.
Signed-off-by: Poornima G <pgurusid@redhat.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3/modules')
| -rw-r--r-- | source3/modules/vfs_glusterfs.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c index c22216478f..1b6304e688 100644 --- a/source3/modules/vfs_glusterfs.c +++ b/source3/modules/vfs_glusterfs.c @@ -1029,6 +1029,39 @@ static int vfs_gluster_set_offline(struct vfs_handle_struct *handle, #define GLUSTER_ACL_SIZE(n) (GLUSTER_ACL_HEADER_SIZE + (n * GLUSTER_ACL_ENTRY_SIZE)) +static SMB_ACL_T mode_to_smb_acls(const struct stat *mode, TALLOC_CTX *mem_ctx) +{ + struct smb_acl_t *result; + int count; + + count = 3; + result = sys_acl_init(mem_ctx); + if (!result) { + errno = ENOMEM; + return NULL; + } + + result->acl = talloc_array(result, struct smb_acl_entry, count); + if (!result->acl) { + errno = ENOMEM; + talloc_free(result); + return NULL; + } + + result->count = count; + + result->acl[0].a_type = SMB_ACL_USER_OBJ; + result->acl[0].a_perm = (mode->st_mode & S_IRWXU) >> 6;; + + result->acl[1].a_type = SMB_ACL_GROUP_OBJ; + result->acl[1].a_perm = (mode->st_mode & S_IRWXG) >> 3;; + + result->acl[2].a_type = SMB_ACL_OTHER; + result->acl[2].a_perm = mode->st_mode & S_IRWXO;; + + return result; +} + static SMB_ACL_T gluster_to_smb_acl(const char *buf, size_t xattr_size, TALLOC_CTX *mem_ctx) { @@ -1296,6 +1329,7 @@ static SMB_ACL_T vfs_gluster_sys_acl_get_file(struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx) { struct smb_acl_t *result; + struct stat st; char *buf; const char *key; ssize_t ret, size = GLUSTER_ACL_SIZE(20); @@ -1328,6 +1362,18 @@ static SMB_ACL_T vfs_gluster_sys_acl_get_file(struct vfs_handle_struct *handle, ret = glfs_getxattr(handle->data, path_p, key, buf, ret); } } + + /* retrieving the ACL from the xattr has finally failed, do a + * mode-to-acl mapping */ + + if (ret == -1 && errno == ENODATA) { + ret = glfs_stat(handle->data, path_p, &st); + if (ret == 0) { + result = mode_to_smb_acls(&st, mem_ctx); + return result; + } + } + if (ret <= 0) { return NULL; } @@ -1342,6 +1388,7 @@ static SMB_ACL_T vfs_gluster_sys_acl_get_fd(struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx) { struct smb_acl_t *result; + struct stat st; ssize_t ret, size = GLUSTER_ACL_SIZE(20); char *buf; glfs_fd_t *glfd; @@ -1365,6 +1412,18 @@ static SMB_ACL_T vfs_gluster_sys_acl_get_fd(struct vfs_handle_struct *handle, buf, ret); } } + + /* retrieving the ACL from the xattr has finally failed, do a + * mode-to-acl mapping */ + + if (ret == -1 && errno == ENODATA) { + ret = glfs_fstat(glfd, &st); + if (ret == 0) { + result = mode_to_smb_acls(&st, mem_ctx); + return result; + } + } + if (ret <= 0) { return NULL; } |
