]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/auth.c
The scheduler now uses the getgrouplist function when available (Issue #4611)
[thirdparty/cups.git] / scheduler / auth.c
index 4a0ece175b17eb70c575a2ae88a8a4a518eadf32..9ffc06a5b573876ec7d501fcb0539474873625fd 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Authorization routines for the CUPS scheduler.
  *
- * Copyright 2007-2015 by Apple Inc.
+ * Copyright 2007-2016 by Apple Inc.
  * Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  * This file contains Kerberos support code, copyright 2006 by
@@ -1176,6 +1176,21 @@ cupsdCheckGroup(
     * Group exists, check it...
     */
 
+#ifdef HAVE_GETGROUPLIST
+    if (user)
+    {
+      int      ngroups,                /* Number of groups */
+               groups[2048];           /* Groups that user belongs to */
+
+      ngroups = (int)(sizeof(groups) / sizeof(groups[0]));
+      getgrouplist(username, (int)user->pw_gid, groups, &ngroups);
+
+      for (i = 0; i < ngroups; i ++)
+        if ((int)group->gr_gid == groups[i])
+         return (1);
+    }
+#endif /* HAVE_GETGROUPLIST */
+
     for (i = 0; group->gr_mem[i]; i ++)
       if (!_cups_strcasecmp(username, group->gr_mem[i]))
        return (1);