[PATCH] Don't drop setuid on directories when ownership changed by NFSd
Linux Kernel Mailing List <[email protected]> Sun, 19 Jun 2005 04:56:24 -0700
| Newsgroups | gmane.linux.kernel.commits.2-4 |
|---|---|
| Message-ID | <[email protected]> |
tree 51dc34aa96b6ef393098dfe207c3b01d8b654647 parent f68679b942671fe80db13082a88f72e7a0b0b03c author NeilBrown <[email protected]> Wed, 01 Jun 2005 11:20:26 +1000 committer Marcelo Tosatti <[email protected]> Fri, 03 Jun 2005 00:04:06 -0300 [PATCH] Don't drop setuid on directories when ownership changed by NFSd .as setuid means something totally different on directories. Signed-off-by: Neil Brown <[email protected]> diff ./fs/nfsd/vfs.c~current~ ./fs/nfsd/vfs.c fs/nfsd/vfs.c | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -280,13 +280,17 @@ nfsd_setattr(struct svc_rqst *rqstp, str } /* Revoke setuid/setgid bit on chown/chgrp */ - if ((iap->ia_valid & ATTR_UID) && (imode & S_ISUID) - && iap->ia_uid != inode->i_uid) { + if ((iap->ia_valid & ATTR_UID) + && (imode & S_ISUID) + && !S_ISDIR(imode) + && iap->ia_uid != inode->i_uid) { iap->ia_valid |= ATTR_MODE; iap->ia_mode = imode &= ~S_ISUID; } - if ((iap->ia_valid & ATTR_GID) && (imode & S_ISGID) - && iap->ia_gid != inode->i_gid) { + if ((iap->ia_valid & ATTR_GID) + && (imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP) + && !S_ISDIR(imode) + && iap->ia_gid != inode->i_gid) { iap->ia_valid |= ATTR_MODE; iap->ia_mode = imode &= ~S_ISGID; }