HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/src/glibc/debian/patches/kfreebsd/local-initgroups-order.diff
 setgroups(size, groups) changes egid on kfreebsd, 
 precisely groups[0] is the new egid

 initgroups(user, gid) prepares the "groups" list
 via internal_getgrouplist(). 
 It puts supplied gid as the first entry in all but NSCD cases.
 Fix the remaining NSCD case, see #698102, #699593.


--- a/nscd/nscd_initgroups.c
+++ b/nscd/nscd_initgroups.c
@@ -145,15 +145,23 @@
     }
 
   /* Check whether GROUP is part of the mix.  If not, add it.  */
+  /* The GROUP have to be in the first entry */
   if (retval >= 0)
     {
       int cnt;
+      gid_t sg, tg;
+      sg = group;
       for (cnt = 0; cnt < retval; ++cnt)
-	if ((*groupsp)[cnt] == group)
+      {
+        tg = (*groupsp)[cnt];
+        (*groupsp)[cnt] = sg;
+        if (tg == group)
 	  break;
+        sg = tg;
+      }  
 
       if (cnt == retval)
-	(*groupsp)[retval++] = group;
+	(*groupsp)[retval++] = sg;
     }
 
  out_close: