Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 252702
b: refs/heads/master
c: 55b23bd
h: refs/heads/master
v: v3
  • Loading branch information
Andreas Gruenbacher authored and Al Viro committed May 27, 2011
1 parent 9cab7f5 commit 4d36624
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: aa38572954ade525817fe88c54faebf85e5a61c0
refs/heads/master: 55b23bde19c08f14127a27d461a4e079942c7258
16 changes: 10 additions & 6 deletions trunk/fs/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,22 @@ xattr_permission(struct inode *inode, const char *name, int mask)
return 0;

/*
* The trusted.* namespace can only be accessed by a privileged user.
* The trusted.* namespace can only be accessed by privileged users.
*/
if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN))
return (capable(CAP_SYS_ADMIN) ? 0 : -EPERM);
if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN)) {
if (!capable(CAP_SYS_ADMIN))
return (mask & MAY_WRITE) ? -EPERM : -ENODATA;
return 0;
}

/* In user.* namespace, only regular files and directories can have
/*
* In the user.* namespace, only regular files and directories can have
* extended attributes. For sticky directories, only the owner and
* privileged user can write attributes.
* privileged users can write attributes.
*/
if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode))
return -EPERM;
return (mask & MAY_WRITE) ? -EPERM : -ENODATA;
if (S_ISDIR(inode->i_mode) && (inode->i_mode & S_ISVTX) &&
(mask & MAY_WRITE) && !inode_owner_or_capable(inode))
return -EPERM;
Expand Down

0 comments on commit 4d36624

Please sign in to comment.