svn commit: r233787 - head/sys/ufs/ufs
Jaakko Heinonen
jh at FreeBSD.org
Mon Apr 2 16:33:22 UTC 2012
Author: jh
Date: Mon Apr 2 16:33:21 2012
New Revision: 233787
URL: http://svn.freebsd.org/changeset/base/233787
Log:
- 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
Modified:
head/sys/ufs/ufs/ufs_vnops.c
Modified: head/sys/ufs/ufs/ufs_vnops.c
==============================================================================
--- head/sys/ufs/ufs/ufs_vnops.c Mon Apr 2 16:33:07 2012 (r233786)
+++ head/sys/ufs/ufs/ufs_vnops.c Mon Apr 2 16:33:21 2012 (r233787)
@@ -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);
/*
More information about the svn-src-all
mailing list