patch-2.2.0-pre2 linux/fs/open.c
Next file: linux/fs/sysv/CHANGES
Previous file: linux/fs/nfsd/vfs.c
Back to the patch index
Back to the overall index
- Lines: 35
- Date:
Tue Dec 29 11:40:35 1998
- Orig file:
v2.2.0-pre1/linux/fs/open.c
- Orig date:
Mon Dec 28 15:00:53 1998
diff -u --recursive --new-file v2.2.0-pre1/linux/fs/open.c linux/fs/open.c
@@ -523,19 +523,27 @@
newattrs.ia_gid = group;
newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
/*
- * If the owner has been changed, remove the setuid bit
+ * If the user or group of a non-directory has been changed by a
+ * non-root user, remove the setuid bit.
+ * 19981026 David C Niemi <niemi@tux.org>
+ *
*/
- if (inode->i_mode & S_ISUID) {
+ if ((inode->i_mode & S_ISUID) == S_ISUID &&
+ !S_ISDIR(inode->i_mode)
+ && current->fsuid)
+ {
newattrs.ia_mode &= ~S_ISUID;
newattrs.ia_valid |= ATTR_MODE;
}
/*
- * If the group has been changed, remove the setgid bit
- *
- * Don't remove the setgid bit if no group execute bit.
- * This is a file marked for mandatory locking.
+ * Likewise, if the user or group of a non-directory has been changed
+ * by a non-root user, remove the setgid bit UNLESS there is no group
+ * execute bit (this would be a file marked for mandatory locking).
+ * 19981026 David C Niemi <niemi@tux.org>
*/
- if (((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) {
+ if (((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
+ && !S_ISDIR(inode->i_mode) && current->fsuid)
+ {
newattrs.ia_mode &= ~S_ISGID;
newattrs.ia_valid |= ATTR_MODE;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov