diff options
Diffstat (limited to 'fs/inode.c')
-rw-r--r-- | fs/inode.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/fs/inode.c b/fs/inode.c index 16fefd373fc2..a21d5a938a17 100644 --- a/fs/inode.c +++ b/fs/inode.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/async.h> | 25 | #include <linux/async.h> |
26 | #include <linux/posix_acl.h> | 26 | #include <linux/posix_acl.h> |
27 | #include <linux/ima.h> | 27 | #include <linux/ima.h> |
28 | #include <linux/cred.h> | ||
28 | 29 | ||
29 | /* | 30 | /* |
30 | * This is needed for the following functions: | 31 | * This is needed for the following functions: |
@@ -1733,3 +1734,19 @@ void inode_init_owner(struct inode *inode, const struct inode *dir, | |||
1733 | inode->i_mode = mode; | 1734 | inode->i_mode = mode; |
1734 | } | 1735 | } |
1735 | EXPORT_SYMBOL(inode_init_owner); | 1736 | EXPORT_SYMBOL(inode_init_owner); |
1737 | |||
1738 | /* | ||
1739 | * return true if current either has CAP_FOWNER to the | ||
1740 | * file, or owns the file. | ||
1741 | */ | ||
1742 | bool is_owner_or_cap(const struct inode *inode) | ||
1743 | { | ||
1744 | struct user_namespace *ns = inode_userns(inode); | ||
1745 | |||
1746 | if (current_user_ns() == ns && current_fsuid() == inode->i_uid) | ||
1747 | return true; | ||
1748 | if (ns_capable(ns, CAP_FOWNER)) | ||
1749 | return true; | ||
1750 | return false; | ||
1751 | } | ||
1752 | EXPORT_SYMBOL(is_owner_or_cap); | ||