Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/fs/udf Clarify the sticky-bit check



details:   https://anonhg.NetBSD.org/src/rev/12ae298bb39f
branches:  trunk
changeset: 787848:12ae298bb39f
user:      reinoud <reinoud%NetBSD.org@localhost>
date:      Mon Jul 08 08:21:12 2013 +0000

description:
Clarify the sticky-bit check

diffstat:

 sys/fs/udf/udf_vnops.c |  14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diffs (44 lines):

diff -r 3f2d1481980d -r 12ae298bb39f sys/fs/udf/udf_vnops.c
--- a/sys/fs/udf/udf_vnops.c    Mon Jul 08 06:44:51 2013 +0000
+++ b/sys/fs/udf/udf_vnops.c    Mon Jul 08 08:21:12 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.83 2013/07/07 20:16:22 reinoud Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.84 2013/07/08 08:21:12 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.83 2013/07/07 20:16:22 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.84 2013/07/08 08:21:12 reinoud Exp $");
 #endif /* not lint */
 
 
@@ -792,7 +792,7 @@
        if (error)
                goto out;
 
-       /* check the permissions */
+       /* check permissions */
        if (islastcn && (cnp->cn_nameiop == DELETE ||
                         cnp->cn_nameiop == RENAME)  ) {
                error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred);
@@ -801,10 +801,14 @@
                        goto out;
                }
 
-               /* get node attributes */
+               /*
+                * Check if the directory has its sticky bit set. If so, ask
+                * for clearance since only the owner of a file or directory
+                * can remove/rename from taht directory.
+                */
                mode = udf_getaccessmode(dir_node);
-               udf_getownership(dir_node, &d_uid, &d_gid);
                if ((mode & S_ISTXT) != 0) {
+                       udf_getownership(dir_node, &d_uid, &d_gid);
                        error = kauth_authorize_vnode(cnp->cn_cred,
                            KAUTH_VNODE_DELETE, res_node->vnode,
                            dir_node->vnode, genfs_can_sticky(cnp->cn_cred,



Home | Main Index | Thread Index | Old Index