From: msweet Date: Mon, 9 Jun 2014 18:58:16 +0000 (+0000) Subject: Mirror fixes from trunk. X-Git-Tag: release-2.1.4~16^2~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0360d41094fe3e4fd058bbaebaa6b262357e596b;p=thirdparty%2Fcups.git Mirror fixes from trunk. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/branches/branch-1.7@11909 a1ca3aef-8c08-0410-bb20-df032aa958be --- diff --git a/CHANGES.txt b/CHANGES.txt index 7322454996..d6fdaca9f8 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -5,6 +5,9 @@ CHANGES IN CUPS V1.7.4 - CUPS did not compile when Avahi or mDNSResponder was not present (STR #4402, STR #4424) + - The "snmp" option did not work with the network backends (STR #4422) + - The User directive in client.conf did not override the USER + environment variable (STR #4426) CHANGES IN CUPS V1.7.3 diff --git a/backend/ipp.c b/backend/ipp.c index f36e3720f7..7919c228f8 100644 --- a/backend/ipp.c +++ b/backend/ipp.c @@ -528,8 +528,8 @@ main(int argc, /* I - Number of command-line args */ */ snmp_enabled = !value[0] || !_cups_strcasecmp(value, "on") || - _cups_strcasecmp(value, "yes") || - _cups_strcasecmp(value, "true"); + !_cups_strcasecmp(value, "yes") || + !_cups_strcasecmp(value, "true"); } else if (!_cups_strcasecmp(name, "version")) { diff --git a/backend/lpd.c b/backend/lpd.c index d73d1bcf08..faf71aff5c 100644 --- a/backend/lpd.c +++ b/backend/lpd.c @@ -393,8 +393,8 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ */ snmp_enabled = !value[0] || !_cups_strcasecmp(value, "on") || - _cups_strcasecmp(value, "yes") || - _cups_strcasecmp(value, "true"); + !_cups_strcasecmp(value, "yes") || + !_cups_strcasecmp(value, "true"); } else if (!_cups_strcasecmp(name, "timeout")) { diff --git a/backend/socket.c b/backend/socket.c index ebed1361b4..4767a2d16b 100644 --- a/backend/socket.c +++ b/backend/socket.c @@ -250,8 +250,8 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ */ snmp_enabled = !value[0] || !_cups_strcasecmp(value, "on") || - _cups_strcasecmp(value, "yes") || - _cups_strcasecmp(value, "true"); + !_cups_strcasecmp(value, "yes") || + !_cups_strcasecmp(value, "true"); } else if (!_cups_strcasecmp(name, "contimeout")) { diff --git a/cups/usersys.c b/cups/usersys.c index 4b233ee7e0..b732d4b995 100644 --- a/cups/usersys.c +++ b/cups/usersys.c @@ -3,7 +3,7 @@ * * User, system, and password routines for CUPS. * - * Copyright 2007-2013 by Apple Inc. + * Copyright 2007-2014 by Apple Inc. * Copyright 1997-2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -851,29 +851,7 @@ _cupsSetDefaults(void) cups_anyroot = getenv("CUPS_ANYROOT"); cups_expiredroot = getenv("CUPS_EXPIREDROOT"); cups_expiredcerts = getenv("CUPS_EXPIREDCERTS"); - - if ((cups_user = getenv("CUPS_USER")) == NULL) - { -#ifndef WIN32 - /* - * Try the USER environment variable... - */ - - if ((cups_user = getenv("USER")) != NULL) - { - /* - * Validate USER matches the current UID, otherwise don't allow it to - * override things... This makes sure that printing after doing su or - * sudo records the correct username. - */ - - struct passwd *pw; /* Account information */ - - if ((pw = getpwnam(cups_user)) == NULL || pw->pw_uid != getuid()) - cups_user = NULL; - } -#endif /* !WIN32 */ - } + cups_user = getenv("CUPS_USER"); /* * Then, if needed, read the ~/.cups/client.conf or /etc/cups/client.conf @@ -1089,20 +1067,30 @@ cups_read_client_conf( if (!GetUserName(cg->user, &size)) #else /* - * Get the user name corresponding to the current UID... + * Try the USER environment variable as the default username... */ - struct passwd *pwd; /* User/password entry */ + const char *envuser = getenv("USER"); + /* Default username */ + struct passwd *pw = NULL; /* Account information */ - setpwent(); - if ((pwd = getpwuid(getuid())) != NULL) + if (envuser) { /* - * Found a match! + * Validate USER matches the current UID, otherwise don't allow it to + * override things... This makes sure that printing after doing su or + * sudo records the correct username. */ - strlcpy(cg->user, pwd->pw_name, sizeof(cg->user)); + if ((pw = getpwnam(envuser)) != NULL && pw->pw_uid != getuid()) + pw = NULL; } + + if (!pw) + pw = getpwuid(getuid()); + + if (pw) + strlcpy(cg->user, pw->pw_name, sizeof(cg->user)); else #endif /* WIN32 */ {