Module Name:    src
Committed By:   ad
Date:           Mon Oct  2 20:59:12 UTC 2023

Modified Files:
        src/sys/kern: kern_auth.c

Log Message:
kauth_cred_groupmember(): check egid before a tedious scan of groups.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/kern/kern_auth.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/kern_auth.c
diff -u src/sys/kern/kern_auth.c:1.82 src/sys/kern/kern_auth.c:1.83
--- src/sys/kern/kern_auth.c:1.82	Fri Feb 24 11:02:27 2023
+++ src/sys/kern/kern_auth.c	Mon Oct  2 20:59:12 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_auth.c,v 1.82 2023/02/24 11:02:27 riastradh Exp $ */
+/* $NetBSD: kern_auth.c,v 1.83 2023/10/02 20:59:12 ad Exp $ */
 
 /*-
  * Copyright (c) 2005, 2006 Elad Efrat <e...@netbsd.org>
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_auth.c,v 1.82 2023/02/24 11:02:27 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_auth.c,v 1.83 2023/10/02 20:59:12 ad Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -409,14 +409,14 @@ kauth_cred_groupmember(kauth_cred_t cred
 	KASSERT(cred != NOCRED);
 	KASSERT(cred != FSCRED);
 
+	if (kauth_cred_getegid(cred) == gid)
+		return 0;
+
 	error = kauth_cred_ismember_gid(cred, gid, &ismember);
 	if (error)
 		return error;
 
-	if (kauth_cred_getegid(cred) == gid || ismember)
-		return 0;
-
-	return -1;
+	return ismember ? 0 : -1;
 }
 
 u_int

Reply via email to