diff options
author | jh <jh@FreeBSD.org> | 2012-04-13 05:48:31 +0000 |
---|---|---|
committer | jh <jh@FreeBSD.org> | 2012-04-13 05:48:31 +0000 |
commit | 2c87a056ccd4652327011066f56d20c8f129bd63 (patch) | |
tree | 8e57a0a822b9384c62369e5f24263e46e6ab0460 | |
parent | 42aaadf5eeb85d266cf2f0809ac73741484ec1fd (diff) | |
download | FreeBSD-src-2c87a056ccd4652327011066f56d20c8f129bd63.zip FreeBSD-src-2c87a056ccd4652327011066f56d20c8f129bd63.tar.gz |
Apply changes from r234103 to ext2fs:
Return EPERM from ext2_setattr() when an user without PRIV_VFS_SYSFLAGS
privilege attempts to toggle SF_SETTABLE flags.
Flags are now stored to ip->i_flags in one place after all checks.
Also, remove SF_NOUNLINK from the checks because ext2fs doesn't support
that flag.
Reviewed by: bde
-rw-r--r-- | sys/fs/ext2fs/ext2_vnops.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/sys/fs/ext2fs/ext2_vnops.c b/sys/fs/ext2fs/ext2_vnops.c index d8270de..21b7687 100644 --- a/sys/fs/ext2fs/ext2_vnops.c +++ b/sys/fs/ext2fs/ext2_vnops.c @@ -424,21 +424,17 @@ ext2_setattr(ap) * if securelevel > 0 and any existing system flags are set. */ if (!priv_check_cred(cred, PRIV_VFS_SYSFLAGS, 0)) { - if (ip->i_flags & - (SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND)) { + if (ip->i_flags & (SF_IMMUTABLE | SF_APPEND)) { error = securelevel_gt(cred, 0); if (error) return (error); } - ip->i_flags = vap->va_flags; } else { - if (ip->i_flags & - (SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND) || - (vap->va_flags & UF_SETTABLE) != vap->va_flags) + if (ip->i_flags & (SF_IMMUTABLE | SF_APPEND) || + ((vap->va_flags ^ ip->i_flags) & SF_SETTABLE)) return (EPERM); - ip->i_flags &= SF_SETTABLE; - ip->i_flags |= (vap->va_flags & UF_SETTABLE); } + ip->i_flags = vap->va_flags; ip->i_flag |= IN_CHANGE; if (ip->i_flags & (IMMUTABLE | APPEND)) return (0); |