[PATCH] 2.2 vs. CAP_CHOWN and CAP_FOWNER

From: Chip Salzenberg (chip@valinux.com)
Date: Tue Aug 29 2000 - 20:08:36 EST


CAP_CHOWN relaxes the BSD-style restrictions on chowning a file to a
user id other than yourself (a restriction instituted to enforce
quotas).

CAP_FOWNER relaxes the normal restriction on performing operations on
files that belong to someone other than yourself.

This patch corrects the implementation of these capabilities.

Index: fs/attr.c
--- fs/attr.c.prev
+++ fs/attr.c Tue Aug 29 18:02:40 2000
@@ -23,18 +23,22 @@ int inode_change_ok(struct inode *inode,
 
         /* Make sure a caller can chown. */
- if ((ia_valid & ATTR_UID) &&
- (current->fsuid != inode->i_uid ||
- attr->ia_uid != inode->i_uid) && !capable(CAP_CHOWN))
- goto error;
+ if ((ia_valid & ATTR_UID) && attr->ia_uid != inode->i_uid) {
+ if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
+ goto error;
+ if (current->fsuid != attr->ia_uid && !capable(CAP_CHOWN))
+ goto error;
+ }
 
         /* Make sure caller can chgrp. */
- if ((ia_valid & ATTR_GID) &&
- (!in_group_p(attr->ia_gid) && attr->ia_gid != inode->i_gid) &&
- !capable(CAP_CHOWN))
- goto error;
+ if ((ia_valid & ATTR_GID) && attr->ia_gid != inode->i_gid) {
+ if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
+ goto error;
+ if (!in_group_p(attr->ia_gid) && !capable(CAP_CHOWN))
+ goto error;
+ }
 
         /* Make sure a caller can chmod. */
         if (ia_valid & ATTR_MODE) {
- if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
+ if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER))
                         goto error;
                 /* Also check the setgid bit! */

-- 
Chip Salzenberg              - a.k.a. -              <chip@valinux.com>
"I wanted to play hopscotch with the impenetrable mystery of existence,
    but he stepped in a wormhole and had to go in early."  // MST3K
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Aug 31 2000 - 21:00:24 EST