diff options
author | jh <jh@FreeBSD.org> | 2012-04-02 16:33:21 +0000 |
---|---|---|
committer | jh <jh@FreeBSD.org> | 2012-04-02 16:33:21 +0000 |
commit | b0414ca2214d8e5575608268fbf0abe96c3063a0 (patch) | |
tree | 36de1f5ee73420476e92631553c78fa6ee572fab /sys/ufs | |
parent | 7201e740201fd2198901c22ac85552d1095dc922 (diff) | |
download | FreeBSD-src-b0414ca2214d8e5575608268fbf0abe96c3063a0.zip FreeBSD-src-b0414ca2214d8e5575608268fbf0abe96c3063a0.tar.gz |
- Use more natural ip->i_flags instead of vap->va_flags in the final
flags check.
- Add a comment for the immutable/append check done after handling of
the flags.
- Style improvements.
No functional change intended.
Submitted by: bde
MFC after: 2 weeks
Diffstat (limited to 'sys/ufs')
-rw-r--r-- | sys/ufs/ufs/ufs_vnops.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index 861b67d..a333c58 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -545,8 +545,8 @@ ufs_setattr(ap) * processes. */ if (!priv_check_cred(cred, PRIV_VFS_SYSFLAGS, 0)) { - if (ip->i_flags - & (SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND)) { + if (ip->i_flags & + (SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND)) { error = securelevel_gt(cred, 0); if (error) return (error); @@ -560,8 +560,8 @@ ufs_setattr(ap) ip->i_flags = vap->va_flags; DIP_SET(ip, i_flags, vap->va_flags); } else { - if (ip->i_flags - & (SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND) || + if (ip->i_flags & + (SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND) || (vap->va_flags & UF_SETTABLE) != vap->va_flags) return (EPERM); ip->i_flags &= SF_SETTABLE; @@ -570,9 +570,15 @@ ufs_setattr(ap) } ip->i_flag |= IN_CHANGE; error = UFS_UPDATE(vp, 0); - if (vap->va_flags & (IMMUTABLE | APPEND)) + if (ip->i_flags & (IMMUTABLE | APPEND)) return (error); } + /* + * If immutable or append, no one can change any of its attributes + * except the ones already handled (exec atime and, in some cases + * for the superuser, file flags including the immutability flags + * themselves). + */ if (ip->i_flags & (IMMUTABLE | APPEND)) return (EPERM); /* |