Blame SOURCES/cups-str4327.patch

87cf9a
diff -up cups-1.7.0/cups/usersys.c.str4327 cups-1.7.0/cups/usersys.c
87cf9a
--- cups-1.7.0/cups/usersys.c.str4327	2013-07-10 15:08:39.000000000 +0100
87cf9a
+++ cups-1.7.0/cups/usersys.c	2014-01-08 16:30:40.443026913 +0000
87cf9a
@@ -875,7 +875,25 @@ _cupsSetDefaults(void)
87cf9a
   cups_expiredcerts   = getenv("CUPS_EXPIREDCERTS");
87cf9a
 
87cf9a
   if ((cups_user = getenv("CUPS_USER")) == NULL)
87cf9a
-    cups_user = getenv("USER");
87cf9a
+  {
87cf9a
+   /*
87cf9a
+    * Try the USER environment variable...
87cf9a
+    */
87cf9a
+
87cf9a
+    if ((cups_user = getenv("USER")) != NULL)
87cf9a
+    {
87cf9a
+     /*
87cf9a
+      * Validate USER matches the current UID, otherwise don't allow it to
87cf9a
+      * override things...  This makes sure that printing after doing su or
87cf9a
+      * sudo records the correct username.
87cf9a
+      */
87cf9a
+
87cf9a
+      struct passwd	*pw;		/* Account information */
87cf9a
+
87cf9a
+      if ((pw = getpwnam(cups_user)) == NULL || pw->pw_uid != getuid())
87cf9a
+        cups_user = NULL;
87cf9a
+    }
87cf9a
+  }
87cf9a
 
87cf9a
  /*
87cf9a
   * Then, if needed, read the ~/.cups/client.conf or /etc/cups/client.conf