diff options
author | Dwight Engen <dwight.engen@oracle.com> | 2013-08-15 14:07:59 -0400 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2013-08-15 15:18:31 -0400 |
commit | 288bbe0eeb3da7238482ca586c6fb029801336be (patch) | |
tree | a5af810265278672af29a90ae578ee7aa66a6974 /fs/xfs/xfs_acl.c | |
parent | c5eeb7ec3e1bb9884e97066bc293792ab57fb4ab (diff) |
xfs: convert kuid_t to/from uid_t in ACLs
Change permission check for setting ACL to use inode_owner_or_capable()
which will additionally allow a CAP_FOWNER user in a user namespace to
be able to set an ACL on an inode covered by the user namespace mapping.
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Gao feng <gaofeng@cn.fujitsu.com>
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_acl.c')
-rw-r--r-- | fs/xfs/xfs_acl.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c index 2f77db865ad9..69518960b2ba 100644 --- a/fs/xfs/xfs_acl.c +++ b/fs/xfs/xfs_acl.c | |||
@@ -70,14 +70,15 @@ xfs_acl_from_disk( | |||
70 | 70 | ||
71 | switch (acl_e->e_tag) { | 71 | switch (acl_e->e_tag) { |
72 | case ACL_USER: | 72 | case ACL_USER: |
73 | acl_e->e_uid = xfs_uid_to_kuid(be32_to_cpu(ace->ae_id)); | ||
74 | break; | ||
73 | case ACL_GROUP: | 75 | case ACL_GROUP: |
74 | acl_e->e_id = be32_to_cpu(ace->ae_id); | 76 | acl_e->e_gid = xfs_gid_to_kgid(be32_to_cpu(ace->ae_id)); |
75 | break; | 77 | break; |
76 | case ACL_USER_OBJ: | 78 | case ACL_USER_OBJ: |
77 | case ACL_GROUP_OBJ: | 79 | case ACL_GROUP_OBJ: |
78 | case ACL_MASK: | 80 | case ACL_MASK: |
79 | case ACL_OTHER: | 81 | case ACL_OTHER: |
80 | acl_e->e_id = ACL_UNDEFINED_ID; | ||
81 | break; | 82 | break; |
82 | default: | 83 | default: |
83 | goto fail; | 84 | goto fail; |
@@ -103,7 +104,18 @@ xfs_acl_to_disk(struct xfs_acl *aclp, const struct posix_acl *acl) | |||
103 | acl_e = &acl->a_entries[i]; | 104 | acl_e = &acl->a_entries[i]; |
104 | 105 | ||
105 | ace->ae_tag = cpu_to_be32(acl_e->e_tag); | 106 | ace->ae_tag = cpu_to_be32(acl_e->e_tag); |
106 | ace->ae_id = cpu_to_be32(acl_e->e_id); | 107 | switch (acl_e->e_tag) { |
108 | case ACL_USER: | ||
109 | ace->ae_id = cpu_to_be32(xfs_kuid_to_uid(acl_e->e_uid)); | ||
110 | break; | ||
111 | case ACL_GROUP: | ||
112 | ace->ae_id = cpu_to_be32(xfs_kgid_to_gid(acl_e->e_gid)); | ||
113 | break; | ||
114 | default: | ||
115 | ace->ae_id = cpu_to_be32(ACL_UNDEFINED_ID); | ||
116 | break; | ||
117 | } | ||
118 | |||
107 | ace->ae_perm = cpu_to_be16(acl_e->e_perm); | 119 | ace->ae_perm = cpu_to_be16(acl_e->e_perm); |
108 | } | 120 | } |
109 | } | 121 | } |
@@ -362,7 +374,7 @@ xfs_xattr_acl_set(struct dentry *dentry, const char *name, | |||
362 | return -EINVAL; | 374 | return -EINVAL; |
363 | if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode)) | 375 | if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode)) |
364 | return value ? -EACCES : 0; | 376 | return value ? -EACCES : 0; |
365 | if ((current_fsuid() != inode->i_uid) && !capable(CAP_FOWNER)) | 377 | if (!inode_owner_or_capable(inode)) |
366 | return -EPERM; | 378 | return -EPERM; |
367 | 379 | ||
368 | if (!value) | 380 | if (!value) |