236 lines
8.1 KiB
Plaintext
236 lines
8.1 KiB
Plaintext
From: Jeff Mahoney <jeffm@suse.com>
|
|
Subject: richacl: Adopt 2.6.38 API
|
|
Patch-mainline: dependent on local patches
|
|
|
|
This patch addresses changes in the inode_operations->permission prototype.
|
|
|
|
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
|
|
---
|
|
fs/ext4/richacl.c | 13 +++++++------
|
|
fs/ext4/richacl.h | 4 ++--
|
|
fs/richacl_base.c | 2 +-
|
|
fs/richacl_inode.c | 34 +++++++++++++++++++---------------
|
|
include/linux/richacl.h | 16 ++++++++++------
|
|
5 files changed, 39 insertions(+), 30 deletions(-)
|
|
|
|
--- a/fs/ext4/richacl.c
|
|
+++ b/fs/ext4/richacl.c
|
|
@@ -120,7 +120,8 @@ ext4_set_richacl(handle_t *handle, struc
|
|
}
|
|
|
|
int
|
|
-ext4_richacl_permission(struct inode *inode, unsigned int mask)
|
|
+ext4_richacl_permission(struct inode *inode, unsigned int mask,
|
|
+ unsigned int flags)
|
|
{
|
|
struct richacl *acl;
|
|
int retval;
|
|
@@ -132,20 +133,20 @@ ext4_richacl_permission(struct inode *in
|
|
if (acl && IS_ERR(acl))
|
|
retval = PTR_ERR(acl);
|
|
else {
|
|
- retval = richacl_inode_permission(inode, acl, mask);
|
|
+ retval = richacl_inode_permission(inode, acl, mask, flags);
|
|
richacl_put(acl);
|
|
}
|
|
|
|
return retval;
|
|
}
|
|
|
|
-int ext4_permission(struct inode *inode, int mask)
|
|
+int ext4_permission(struct inode *inode, int mask, unsigned int flags)
|
|
{
|
|
if (IS_RICHACL(inode))
|
|
return ext4_richacl_permission(inode,
|
|
- richacl_want_to_mask(mask));
|
|
+ richacl_want_to_mask(mask), flags);
|
|
else
|
|
- return generic_permission(inode, mask, ext4_check_acl);
|
|
+ return generic_permission(inode, mask, flags, ext4_check_acl);
|
|
}
|
|
|
|
int ext4_may_create(struct inode *dir, int isdir)
|
|
@@ -260,7 +261,7 @@ ext4_xattr_set_richacl(struct dentry *de
|
|
if (strcmp(name, "") != 0)
|
|
return -EINVAL;
|
|
if (current_fsuid() != inode->i_uid &&
|
|
- ext4_richacl_permission(inode, ACE4_WRITE_ACL) &&
|
|
+ ext4_richacl_permission(inode, ACE4_WRITE_ACL, 0) &&
|
|
!capable(CAP_FOWNER))
|
|
return -EPERM;
|
|
if (value) {
|
|
--- a/fs/ext4/richacl.h
|
|
+++ b/fs/ext4/richacl.h
|
|
@@ -24,8 +24,8 @@
|
|
/* Value for i_richacl if RICHACL has not been cached */
|
|
# define EXT4_RICHACL_NOT_CACHED ((void *)-1)
|
|
|
|
-extern int ext4_permission(struct inode *, int);
|
|
-extern int ext4_richacl_permission(struct inode *, unsigned int);
|
|
+extern int ext4_permission(struct inode *, int, unsigned int);
|
|
+extern int ext4_richacl_permission(struct inode *, unsigned int, unsigned int);
|
|
extern int ext4_may_create(struct inode *, int);
|
|
extern int ext4_may_delete(struct inode *, struct inode *, int);
|
|
extern int ext4_init_richacl(handle_t *, struct inode *, struct inode *);
|
|
--- a/fs/richacl_base.c
|
|
+++ b/fs/richacl_base.c
|
|
@@ -381,7 +381,7 @@ EXPORT_SYMBOL_GPL(richacl_chmod);
|
|
*/
|
|
int
|
|
richacl_permission(struct inode *inode, const struct richacl *acl,
|
|
- unsigned int mask)
|
|
+ unsigned int mask, unsigned int flags)
|
|
{
|
|
const struct richace *ace;
|
|
unsigned int file_mask, requested = mask, denied = 0;
|
|
--- a/fs/richacl_inode.c
|
|
+++ b/fs/richacl_inode.c
|
|
@@ -23,14 +23,15 @@
|
|
*/
|
|
int
|
|
richacl_may_create(struct inode *dir, int isdir,
|
|
- int (*richacl_permission)(struct inode *, unsigned int))
|
|
+ int (*richacl_permission)(struct inode *, unsigned int,
|
|
+ unsigned int))
|
|
{
|
|
if (IS_RICHACL(dir))
|
|
return richacl_permission(dir,
|
|
ACE4_EXECUTE | (isdir ?
|
|
- ACE4_ADD_SUBDIRECTORY : ACE4_ADD_FILE));
|
|
+ ACE4_ADD_SUBDIRECTORY : ACE4_ADD_FILE), 0);
|
|
else
|
|
- return generic_permission(dir, MAY_WRITE | MAY_EXEC,
|
|
+ return generic_permission(dir, MAY_WRITE | MAY_EXEC, 0,
|
|
dir->i_op->check_acl);
|
|
}
|
|
EXPORT_SYMBOL(richacl_may_create);
|
|
@@ -52,23 +53,25 @@ check_sticky(struct inode *dir, struct i
|
|
*/
|
|
int
|
|
richacl_may_delete(struct inode *dir, struct inode *inode, int replace,
|
|
- int (*richacl_permission)(struct inode *, unsigned int))
|
|
+ int (*richacl_permission)(struct inode *, unsigned int,
|
|
+ unsigned int))
|
|
{
|
|
int error;
|
|
|
|
if (IS_RICHACL(inode)) {
|
|
error = richacl_permission(dir,
|
|
- ACE4_EXECUTE | ACE4_DELETE_CHILD);
|
|
+ ACE4_EXECUTE | ACE4_DELETE_CHILD, 0);
|
|
if (!error && check_sticky(dir, inode))
|
|
error = -EPERM;
|
|
- if (error && !richacl_permission(inode, ACE4_DELETE))
|
|
+ if (error && !richacl_permission(inode, ACE4_DELETE, 0))
|
|
error = 0;
|
|
if (!error && replace)
|
|
error = richacl_permission(dir,
|
|
ACE4_EXECUTE | (S_ISDIR(inode->i_mode) ?
|
|
- ACE4_ADD_SUBDIRECTORY : ACE4_ADD_FILE));
|
|
+ ACE4_ADD_SUBDIRECTORY : ACE4_ADD_FILE),
|
|
+ 0);
|
|
} else {
|
|
- error = generic_permission(dir, MAY_WRITE | MAY_EXEC,
|
|
+ error = generic_permission(dir, MAY_WRITE | MAY_EXEC, 0,
|
|
dir->i_op->check_acl);
|
|
if (!error && check_sticky(dir, inode))
|
|
error = -EPERM;
|
|
@@ -89,10 +92,10 @@ EXPORT_SYMBOL(richacl_may_delete);
|
|
*/
|
|
int
|
|
richacl_inode_permission(struct inode *inode, const struct richacl *acl,
|
|
- unsigned int mask)
|
|
+ unsigned int mask, unsigned int flags)
|
|
{
|
|
if (acl) {
|
|
- if (!richacl_permission(inode, acl, mask))
|
|
+ if (!richacl_permission(inode, acl, mask, flags))
|
|
return 0;
|
|
} else {
|
|
int mode = inode->i_mode;
|
|
@@ -140,7 +143,8 @@ EXPORT_SYMBOL_GPL(richacl_inode_permissi
|
|
*/
|
|
int
|
|
richacl_inode_change_ok(struct inode *inode, struct iattr *attr,
|
|
- int (*richacl_permission)(struct inode *, unsigned int))
|
|
+ int (*richacl_permission)(struct inode *, unsigned int,
|
|
+ unsigned int))
|
|
{
|
|
unsigned int ia_valid = attr->ia_valid;
|
|
|
|
@@ -153,7 +157,7 @@ richacl_inode_change_ok(struct inode *in
|
|
(current_fsuid() != inode->i_uid ||
|
|
attr->ia_uid != inode->i_uid) &&
|
|
(current_fsuid() != attr->ia_uid ||
|
|
- richacl_permission(inode, ACE4_WRITE_OWNER)) &&
|
|
+ richacl_permission(inode, ACE4_WRITE_OWNER, 0)) &&
|
|
!capable(CAP_CHOWN))
|
|
goto error;
|
|
|
|
@@ -163,7 +167,7 @@ richacl_inode_change_ok(struct inode *in
|
|
if ((current_fsuid() != inode->i_uid ||
|
|
(!in_group && attr->ia_gid != inode->i_gid)) &&
|
|
(!in_group ||
|
|
- richacl_permission(inode, ACE4_WRITE_OWNER)) &&
|
|
+ richacl_permission(inode, ACE4_WRITE_OWNER, 0)) &&
|
|
!capable(CAP_CHOWN))
|
|
goto error;
|
|
}
|
|
@@ -171,7 +175,7 @@ richacl_inode_change_ok(struct inode *in
|
|
/* Make sure a caller can chmod. */
|
|
if (ia_valid & ATTR_MODE) {
|
|
if (current_fsuid() != inode->i_uid &&
|
|
- richacl_permission(inode, ACE4_WRITE_ACL) &&
|
|
+ richacl_permission(inode, ACE4_WRITE_ACL, 0) &&
|
|
!capable(CAP_FOWNER))
|
|
goto error;
|
|
/* Also check the setgid bit! */
|
|
@@ -183,7 +187,7 @@ richacl_inode_change_ok(struct inode *in
|
|
/* Check for setting the inode time. */
|
|
if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET)) {
|
|
if (current_fsuid() != inode->i_uid &&
|
|
- richacl_permission(inode, ACE4_WRITE_ATTRIBUTES) &&
|
|
+ richacl_permission(inode, ACE4_WRITE_ATTRIBUTES, 0) &&
|
|
!capable(CAP_FOWNER))
|
|
goto error;
|
|
}
|
|
--- a/include/linux/richacl.h
|
|
+++ b/include/linux/richacl.h
|
|
@@ -294,7 +294,7 @@ extern unsigned int richacl_want_to_mask
|
|
extern void richacl_compute_max_masks(struct richacl *);
|
|
extern struct richacl *richacl_chmod(struct richacl *, mode_t);
|
|
extern int richacl_permission(struct inode *, const struct richacl *,
|
|
- unsigned int);
|
|
+ unsigned int, unsigned int);
|
|
extern struct richacl *richacl_inherit(const struct richacl *, struct inode *);
|
|
extern int richacl_equiv_mode(const struct richacl *, mode_t *);
|
|
|
|
@@ -302,18 +302,22 @@ extern int richacl_equiv_mode(const stru
|
|
|
|
#ifdef CONFIG_FS_RICHACL
|
|
extern int richacl_may_create(struct inode *, int,
|
|
- int (*)(struct inode *, unsigned int));
|
|
+ int (*)(struct inode *, unsigned int,
|
|
+ unsigned int));
|
|
extern int richacl_may_delete(struct inode *, struct inode *, int,
|
|
- int (*)(struct inode *, unsigned int));
|
|
+ int (*)(struct inode *, unsigned int,
|
|
+ unsigned int));
|
|
extern int richacl_inode_permission(struct inode *, const struct richacl *,
|
|
- unsigned int);
|
|
+ unsigned int, unsigned int);
|
|
extern int richacl_inode_change_ok(struct inode *, struct iattr *,
|
|
- int (*)(struct inode *, unsigned int));
|
|
+ int (*)(struct inode *, unsigned int,
|
|
+ unsigned int));
|
|
#else
|
|
static inline int
|
|
richacl_inode_change_ok(struct inode *inode, struct iattr *attr,
|
|
int (*richacl_permission)(struct inode *inode,
|
|
- unsigned int mask))
|
|
+ unsigned int mask,
|
|
+ unsigned int flags))
|
|
{
|
|
return -EPERM;
|
|
}
|