Source-Changes-HG archive

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

[src/trunk]: src/sys/miscfs/genfs Fix genfs_can_chtimes() to also handle the ...



details:   https://anonhg.NetBSD.org/src/rev/15c2626589a0
branches:  trunk
changeset: 373808:15c2626589a0
user:      hannken <hannken%NetBSD.org@localhost>
date:      Fri Mar 03 10:02:51 2023 +0000

description:
Fix genfs_can_chtimes() to also handle the condition:

  If the time pointer is null, then write permission
  on the file is also sufficient.

>From FreeBSD.

Should fix PR kern/57246 "NFS group permissions regression"

diffstat:

 sys/miscfs/genfs/genfs_vnops.c |  25 ++++++++-----------------
 1 files changed, 8 insertions(+), 17 deletions(-)

diffs (48 lines):

diff -r 1b9341cb0a0d -r 15c2626589a0 sys/miscfs/genfs/genfs_vnops.c
--- a/sys/miscfs/genfs/genfs_vnops.c    Fri Mar 03 10:01:31 2023 +0000
+++ b/sys/miscfs/genfs/genfs_vnops.c    Fri Mar 03 10:02:51 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: genfs_vnops.c,v 1.219 2022/03/27 17:10:55 christos Exp $       */
+/*     $NetBSD: genfs_vnops.c,v 1.220 2023/03/03 10:02:51 hannken Exp $        */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.219 2022/03/27 17:10:55 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.220 2023/03/03 10:02:51 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1315,23 +1315,14 @@
         * will be allowed to set the times [..] to the current 
         * server time.
         */
-       if ((error = VOP_ACCESSX(vp, VWRITE_ATTRIBUTES, cred)) != 0)
+       error = VOP_ACCESSX(vp, VWRITE_ATTRIBUTES, cred);
+       if (error != 0 && (vaflags & VA_UTIMES_NULL) != 0)
+               error = VOP_ACCESS(vp, VWRITE, cred);
+
+       if (error)
                return (vaflags & VA_UTIMES_NULL) == 0 ? EPERM : EACCES;
 
-       /* Must be owner, or... */
-       if (kauth_cred_geteuid(cred) == owner_uid)
-               return (0);
-
-       /* set the times to the current time, and... */
-       if ((vaflags & VA_UTIMES_NULL) == 0)
-               return (EPERM);
-
-       /* have write access. */
-       error = VOP_ACCESS(vp, VWRITE, cred);
-       if (error)
-               return (error);
-
-       return (0);
+       return 0;
 }
 
 /*



Home | Main Index | Thread Index | Old Index