Skip to content

Commit

Permalink
ocfs2: add ocfs2_check_acl
Browse files Browse the repository at this point in the history
This function is used to enhance permission checking with POSIX ACLs.

Signed-off-by: Tiger Yang <tiger.yang@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
  • Loading branch information
Tiger Yang authored and Mark Fasheh committed Jan 5, 2009
1 parent 929fb01 commit 23fc270
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
15 changes: 15 additions & 0 deletions fs/ocfs2/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,21 @@ static int ocfs2_set_acl(handle_t *handle,
return ret;
}

int ocfs2_check_acl(struct inode *inode, int mask)
{
struct posix_acl *acl = ocfs2_get_acl(inode, ACL_TYPE_ACCESS);

if (IS_ERR(acl))
return PTR_ERR(acl);
if (acl) {
int ret = posix_acl_permission(inode, acl, mask);
posix_acl_release(acl);
return ret;
}

return -EAGAIN;
}

static size_t ocfs2_xattr_list_acl_access(struct inode *inode,
char *list,
size_t list_len,
Expand Down
10 changes: 10 additions & 0 deletions fs/ocfs2/acl.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,14 @@ struct ocfs2_acl_entry {
__le32 e_id;
};

#ifdef CONFIG_OCFS2_FS_POSIX_ACL

extern int ocfs2_check_acl(struct inode *, int);

#else /* CONFIG_OCFS2_FS_POSIX_ACL*/

#define ocfs2_check_acl NULL

#endif /* CONFIG_OCFS2_FS_POSIX_ACL*/

#endif /* OCFS2_ACL_H */
3 changes: 2 additions & 1 deletion fs/ocfs2/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#include "suballoc.h"
#include "super.h"
#include "xattr.h"
#include "acl.h"

#include "buffer_head_io.h"

Expand Down Expand Up @@ -1035,7 +1036,7 @@ int ocfs2_permission(struct inode *inode, int mask)
goto out;
}

ret = generic_permission(inode, mask, NULL);
ret = generic_permission(inode, mask, ocfs2_check_acl);

ocfs2_inode_unlock(inode, 0);
out:
Expand Down

0 comments on commit 23fc270

Please sign in to comment.