Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Richacl #109

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d5d1fb4
vfs: Indicate that the permission functions take all the MAY_* flags
Oct 18, 2011
0f69c40
vfs: Add hex format for MAY_* flag values
kvaneesh Oct 18, 2011
bf56180
vfs: Pass all mask flags down to iop->check_acl
Oct 18, 2011
518cbba
vfs: Add a comment to inode_permission()
Oct 18, 2011
89e1033
vfs: Add generic IS_ACL() test for acl support
Oct 18, 2011
45481f1
vfs: Add IS_RICHACL() test for richacl support
Oct 18, 2011
c684918
vfs: Optimize out IS_RICHACL() if CONFIG_FS_RICHACL is not defined
Oct 18, 2011
004723e
vfs: Add new file and directory create permission flags
Oct 18, 2011
1654a09
vfs: Add delete child and delete self permission flags
Oct 18, 2011
3437a82
vfs: Make the inode passed to inode_change_ok non-const
Oct 18, 2011
e963a4c
vfs: Add permission flags for setting file attributes
Oct 18, 2011
26dc449
vfs: Make acl_permission_check() work for richacls
Oct 18, 2011
e210ab8
richacl: In-memory representation and helper functions
Oct 18, 2011
36ee026
richacl: Permission mapping functions
Oct 18, 2011
dc240c0
richacl: Compute maximum file masks from an acl
Oct 18, 2011
6be646b
richacl: Update the file masks in chmod()
Oct 18, 2011
61bf134
richacl: Permission check algorithm
Oct 18, 2011
9d9bef3
richacl: Create-time inheritance
Oct 18, 2011
8013f16
richacl: Check if an acl is equivalent to a file mode
Oct 18, 2011
5882a81
richacl: Automatic Inheritance
Oct 18, 2011
862d861
richacl: xattr mapping functions
Oct 18, 2011
69d9df5
vfs: Cache richacl in struct inode
Oct 18, 2011
e86e410
vfs: Add richacl permission check
kvaneesh Oct 18, 2011
434e398
ext4: Use IS_POSIXACL() to check for POSIX ACL support
kvaneesh Oct 18, 2011
69b47fd
ext4: Implement rich acl for ext4
kvaneesh Oct 18, 2011
e17ad31
ext4: Add Ext4 compat richacl feature flag
kvaneesh Oct 18, 2011
13fc237
ext4: Add temporary richacl mount option for ext4
kvaneesh Oct 18, 2011
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
richacl: Check if an acl is equivalent to a file mode
This function is used to avoid storing richacls on disk if the acl can
be computed from the file permission bits.

Acked-by: J. Bruce Fields <[email protected]>
Acked-by: David Howells <[email protected]>
Signed-off-by: Andreas Gruenbacher <[email protected]>
Signed-off-by: Aneesh Kumar K.V <[email protected]>
  • Loading branch information
Andreas Gruenbacher authored and kvaneesh committed Oct 23, 2011
commit 8013f16c484b839a57e3c9864628db68db5588b3
54 changes: 54 additions & 0 deletions fs/richacl_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,3 +520,57 @@ richacl_inherit(const struct richacl *dir_acl, int isdir)

return acl;
}

/**
* richacl_equiv_mode - check if @acl is equivalent to file permission bits
* @mode_p: the file mode (including the file type)
*
* If @acl can be fully represented by file permission bits, this function
* returns 0, and the file permission bits in @mode_p are set to the equivalent
* of @acl.
*
* This function is used to avoid storing richacls on disk if the acl can be
* computed from the file permission bits. It allows user-space to make sure
* that a file has no explicit richacl set.
*/
int
richacl_equiv_mode(const struct richacl *acl, mode_t *mode_p)
{
const struct richace *ace = acl->a_entries;
unsigned int x;
mode_t mode;

if (acl->a_count != 1 ||
acl->a_flags != ACL4_MASKED ||
!richace_is_everyone(ace) ||
!richace_is_allow(ace) ||
ace->e_flags & ~ACE4_SPECIAL_WHO)
return -1;

/*
* Figure out the permissions we care about: ACE4_DELETE_CHILD is
* meaningless for non-directories, so we ignore it.
*/
x = ~ACE4_POSIX_ALWAYS_ALLOWED;
if (!S_ISDIR(*mode_p))
x &= ~ACE4_DELETE_CHILD;

mode = richacl_masks_to_mode(acl);
if ((acl->a_group_mask & x) != (richacl_mode_to_mask(mode >> 3) & x) ||
(acl->a_other_mask & x) != (richacl_mode_to_mask(mode) & x))
return -1;

/*
* Ignore permissions which the owner is always allowed.
*/
x &= ~ACE4_POSIX_OWNER_ALLOWED;
if ((acl->a_owner_mask & x) != (richacl_mode_to_mask(mode >> 6) & x))
return -1;

if ((ace->e_mask & x) != (ACE4_POSIX_MODE_ALL & x))
return -1;

*mode_p = (*mode_p & ~S_IRWXUGO) | mode;
return 0;
}
EXPORT_SYMBOL_GPL(richacl_equiv_mode);
1 change: 1 addition & 0 deletions include/linux/richacl.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ extern struct richacl *richacl_chmod(struct richacl *, mode_t);
extern int richacl_permission(struct inode *, const struct richacl *,
unsigned int);
extern struct richacl *richacl_inherit(const struct richacl *, int);
extern int richacl_equiv_mode(const struct richacl *, mode_t *);

/* richacl_inode.c */
extern struct richacl *richacl_inherit_inode(const struct richacl *,
Expand Down