--- cups-2.4.0/scheduler/cups-exec.c	2021-11-29 16:19:34.235186064 +0100
+++ cups-2.4.0/scheduler/cups-exec.c.new	2021-11-29 16:25:30.764049649 +0100
@@ -134,9 +134,14 @@ main(int  argc,				/* I - Number of command-line args */
 #  if CUPS_SNAP
     if (setgroups(0, NULL))
 #  else
-    if (setgroups(1, &gid))
-#  endif /* CUPS_SNAP */
+#include <pwd.h>
+    struct passwd * pwd = getpwuid(uid);
+    if(initgroups(pwd->pw_name,pwd->pw_gid))
+    {
+      fprintf(stderr, "DEBUG: initgroups failed\n");
       exit(errno + 100);
+    }
+#  endif /* CUPS_SNAP */
 
     if (uid && setuid(uid))
       exit(errno + 100);
--- cups-2.4.0/scheduler/util.c	2021-11-29 15:27:31.000000000 +0100
+++ cups-2.4.0/scheduler/util.c.new	2021-11-29 16:29:58.810719066 +0100
@@ -296,7 +296,16 @@
     */
 
     if (!getuid() && user)
-      setuid(user);			/* Run as restricted user */
+    {
+#include <pwd.h>
+      struct passwd * pwd = getpwuid(user);
+      if(initgroups(pwd->pw_name,pwd->pw_gid))
+      {
+        fprintf(stderr, "DEBUG: initgroups failed\n");
+        exit(errno + 100);
+      }
+      setuid(user); /* Run as restricted user */
+    }
 
     if ((fd = open("/dev/null", O_RDONLY)) > 0)
     {
