From owner-svn-src-all@FreeBSD.ORG Mon Apr 16 18:10:35 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B484E106566B; Mon, 16 Apr 2012 18:10:35 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 86DC78FC1A; Mon, 16 Apr 2012 18:10:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q3GIAZ7m044531; Mon, 16 Apr 2012 18:10:35 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q3GIAZJe044529; Mon, 16 Apr 2012 18:10:35 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201204161810.q3GIAZJe044529@svn.freebsd.org> From: Jaakko Heinonen Date: Mon, 16 Apr 2012 18:10:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r234347 - head/sys/fs/tmpfs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Apr 2012 18:10:35 -0000 Author: jh Date: Mon Apr 16 18:10:34 2012 New Revision: 234347 URL: http://svn.freebsd.org/changeset/base/234347 Log: Sync tmpfs_chflags() with the recent changes to UFS: - Add a check for unsupported file flags. - Return EPERM when an user without PRIV_VFS_SYSFLAGS privilege attempts to toggle SF_SETTABLE flags. Modified: head/sys/fs/tmpfs/tmpfs_subr.c Modified: head/sys/fs/tmpfs/tmpfs_subr.c ============================================================================== --- head/sys/fs/tmpfs/tmpfs_subr.c Mon Apr 16 18:07:42 2012 (r234346) +++ head/sys/fs/tmpfs/tmpfs_subr.c Mon Apr 16 18:10:34 2012 (r234347) @@ -1078,6 +1078,11 @@ tmpfs_chflags(struct vnode *vp, int flag node = VP_TO_TMPFS_NODE(vp); + if ((flags & ~(UF_NODUMP | UF_IMMUTABLE | UF_APPEND | UF_OPAQUE | + UF_NOUNLINK | SF_ARCHIVED | SF_IMMUTABLE | SF_APPEND | + SF_NOUNLINK | SF_SNAPSHOT)) != 0) + return (EOPNOTSUPP); + /* Disallow this operation if the file system is mounted read-only. */ if (vp->v_mount->mnt_flag & MNT_RDONLY) return EROFS; @@ -1093,27 +1098,22 @@ tmpfs_chflags(struct vnode *vp, int flag * flags, or modify flags if any system flags are set. */ if (!priv_check_cred(cred, PRIV_VFS_SYSFLAGS, 0)) { - if (node->tn_flags - & (SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND)) { + if (node->tn_flags & + (SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND)) { error = securelevel_gt(cred, 0); if (error) return (error); } - /* Snapshot flag cannot be set or cleared */ - if (((flags & SF_SNAPSHOT) != 0 && - (node->tn_flags & SF_SNAPSHOT) == 0) || - ((flags & SF_SNAPSHOT) == 0 && - (node->tn_flags & SF_SNAPSHOT) != 0)) + /* The snapshot flag cannot be toggled. */ + if ((flags ^ node->tn_flags) & SF_SNAPSHOT) return (EPERM); - node->tn_flags = flags; } else { - if (node->tn_flags - & (SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND) || - (flags & UF_SETTABLE) != flags) + if (node->tn_flags & + (SF_NOUNLINK | SF_IMMUTABLE | SF_APPEND) || + ((flags ^ node->tn_flags) & SF_SETTABLE)) return (EPERM); - node->tn_flags &= SF_SETTABLE; - node->tn_flags |= (flags & UF_SETTABLE); } + node->tn_flags = flags; node->tn_status |= TMPFS_NODE_CHANGED; MPASS(VOP_ISLOCKED(vp));