Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Apr 2012 05:48:31 +0000 (UTC)
From:      Jaakko Heinonen <jh@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r234203 - head/sys/fs/ext2fs
Message-ID:  <201204130548.q3D5mVkN062621@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jh
Date: Fri Apr 13 05:48:31 2012
New Revision: 234203
URL: http://svn.freebsd.org/changeset/base/234203

Log:
  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

Modified:
  head/sys/fs/ext2fs/ext2_vnops.c

Modified: head/sys/fs/ext2fs/ext2_vnops.c
==============================================================================
--- head/sys/fs/ext2fs/ext2_vnops.c	Fri Apr 13 05:40:26 2012	(r234202)
+++ head/sys/fs/ext2fs/ext2_vnops.c	Fri Apr 13 05:48:31 2012	(r234203)
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201204130548.q3D5mVkN062621>