[Pkg-cups-devel] Bug#623743: cups-pdf: does not properly set supplementary groups when dropping privileges

Christopher Zimmermann madroach at zakweb.de
Fri Apr 22 16:24:20 UTC 2011


Package: cups-pdf
Version: 2.5.0-16
Severity: normal
Tags: upstream patch

When dropping privileges to the user who sent the print job cups-pdf
does only set euid and egid, but NOT the supplementary groups. Therefore
a common "print dump" directory only accessible by a "print" group will
only work when all printing users have a primary group of "print", but
NOT when it is only a supplementary group.

Patch is attached.

Greetings,
Christopher


-- System Information:
Debian Release: 6.0.1
  APT prefers stable
  APT policy: (990, 'stable'), (500, 'stable-updates')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-5-amd64 (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/dash

Versions of packages cups-pdf depends on:
ii  cups                        1.4.4-7      Common UNIX Printing System(tm) - 
ii  cups-client                 1.4.4-7      Common UNIX Printing System(tm) - 
ii  ghostscript                 8.71~dfsg2-9 The GPL Ghostscript PostScript/PDF
ii  libc6                       2.11.2-10    Embedded GNU C Library: Shared lib
ii  libpaper-utils              1.1.24       library for handling paper charact

cups-pdf recommends no packages.

Versions of packages cups-pdf suggests:
ii  system-config-printer         1.2.3-3    graphical interface to configure t

-- Configuration Files:
/etc/cups/cups-pdf.conf changed [not included]

-- no debconf information

*** cups-pdf.c.diff
--- a/cups-pdf.c	2009-01-26 12:56:20.000000000 +0100
+++ b/cups-pdf.c	2011-04-22 18:12:41.000000000 +0200
@@ -521,6 +521,8 @@
   int size;
   mode_t mode;
   struct passwd *passwd;
+  gid_t *groups;
+  int ngroups;
   pid_t pid;
 
   if (setuid(0)) {
@@ -550,7 +552,24 @@
     return 5;
   }  
   snprintf(user, size, "%s%s", conf.userprefix, argv[2]);
+
+  /* Get user passwd entry */
   passwd=getpwnam(user);
+
+  /* Get user groups */
+  ngroups=32;
+  groups = malloc(ngroups * sizeof(gid_t));
+  size = getgrouplist(user, passwd->pw_gid, groups, &ngroups);
+  if (size == -1) {
+    free(groups);
+    groups = malloc(ngroups * sizeof(gid_t));
+    size = getgrouplist(user, passwd->pw_gid, groups, &ngroups);
+  }
+  else if (size < 0) {
+    log_event(CPERROR, "getgrouplist failed", NULL);
+    return 5;
+  }
+
   if (passwd == NULL && conf.lowercase) {
     log_event(CPDEBUG, "unknown user", user);
     for (size=0;size<(int) strlen(argv[2]);size++) 
@@ -711,6 +730,10 @@
       log_event(CPERROR, "failed to set GID for current user", NULL);
     else 
       log_event(CPDEBUG, "GID set for current user", NULL);
+    if (setgroups(ngroups, groups))
+      log_event(CPERROR, "failed to set supplementary groups for current user", NULL);
+    else 
+      log_event(CPDEBUG, "supplementary groups set for current user", NULL);
     if (setuid(passwd->pw_uid))
       log_event(CPERROR, "failed to set UID for current user", passwd->pw_name);
     else 





More information about the Pkg-cups-devel mailing list