From: nekral-guest Date: Sat, 30 Aug 2008 18:27:07 +0000 (+0000) Subject: * src/chfn.c, src/chsh.c, src/expiry.c, src/gpasswd.c, X-Git-Tag: 4.1.3~253 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=38a50366bc8065bc701333d94eb63ddfb186f921;p=shadow * src/chfn.c, src/chsh.c, src/expiry.c, src/gpasswd.c, src/newgrp.c, src/passwd.c, src/su.c: Use the same stderr and syslog warnings when the username cannot be determined. * src/newgrp.c: Reuse the same stderr message for groups which do not exist in the system. --- diff --git a/ChangeLog b/ChangeLog index 46a1d09a..013b2014 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-08-25 Nicolas François + + * src/chfn.c, src/chsh.c, src/expiry.c, src/gpasswd.c, + src/newgrp.c, src/passwd.c, src/su.c: Use the same stderr and + syslog warnings when the username cannot be determined. + * src/newgrp.c: Reuse the same stderr message for groups which do + not exist in the system. + 2008-08-21 Nicolas François * src/usermod.c: Log errors while *_close to syslog. diff --git a/src/chfn.c b/src/chfn.c index d614ad66..3a940d16 100644 --- a/src/chfn.c +++ b/src/chfn.c @@ -651,6 +651,8 @@ int main (int argc, char **argv) fprintf (stderr, _("%s: Cannot determine your user name.\n"), Prog); + SYSLOG ((LOG_WARN, "Cannot determine the user name of the caller (UID %lu)", + (unsigned long) getuid ())); fail_exit (E_NOPERM); } user = xstrdup (pw->pw_name); diff --git a/src/chsh.c b/src/chsh.c index ffc771b0..e2093cfc 100644 --- a/src/chsh.c +++ b/src/chsh.c @@ -472,6 +472,8 @@ int main (int argc, char **argv) fprintf (stderr, _("%s: Cannot determine your user name.\n"), Prog); + SYSLOG ((LOG_WARN, "Cannot determine the user name of the caller (UID %lu)", + (unsigned long) getuid ())); fail_exit (1); } user = xstrdup (pw->pw_name); diff --git a/src/expiry.c b/src/expiry.c index 50632be3..78d282fd 100644 --- a/src/expiry.c +++ b/src/expiry.c @@ -105,7 +105,10 @@ int main (int argc, char **argv) */ pwd = get_my_pwent (); if (NULL == pwd) { - fprintf (stderr, _("%s: unknown user\n"), Prog); + fprintf (stderr, _("%s: Cannot determine your user name.\n"), + Prog); + SYSLOG ((LOG_WARN, "Cannot determine the user name of the caller (UID %lu)", + (unsigned long) getuid ())); exit (10); } spwd = getspnam (pwd->pw_name); /* !USE_PAM, No need for xgetspnam */ diff --git a/src/gpasswd.c b/src/gpasswd.c index e79614f8..3ccd1249 100644 --- a/src/gpasswd.c +++ b/src/gpasswd.c @@ -851,12 +851,15 @@ int main (int argc, char **argv) pw = get_my_pwent (); if (NULL == pw) { - fputs (_("Who are you?\n"), stderr); + fprintf (stderr, _("%s: Cannot determine your user name.\n"), + Prog); #ifdef WITH_AUDIT audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "user lookup", NULL, (unsigned int) bywho, 0); #endif + SYSLOG ((LOG_WARN, "Cannot determine the user name of the caller (UID %lu)", + (unsigned long) getuid ())); failure (); } myname = xstrdup (pw->pw_name); diff --git a/src/newgrp.c b/src/newgrp.c index 7ae2f521..5a814ebf 100644 --- a/src/newgrp.c +++ b/src/newgrp.c @@ -421,14 +421,14 @@ int main (int argc, char **argv) pwd = get_my_pwent (); if (NULL == pwd) { - fprintf (stderr, _("unknown UID: %lu\n"), - (unsigned long) getuid ()); + fprintf (stderr, _("%s: Cannot determine your user name.\n"), + Prog); #ifdef WITH_AUDIT audit_logger (AUDIT_CHGRP_ID, Prog, "changing", NULL, (unsigned int) getuid (), 0); #endif - SYSLOG ((LOG_WARN, "unknown UID %lu", + SYSLOG ((LOG_WARN, "Cannot determine the user name of the caller (UID %lu)", (unsigned long) getuid ())); closelog (); exit (1); @@ -598,7 +598,7 @@ int main (int argc, char **argv) */ grp = getgrnam (group); /* local, no need for xgetgrnam */ if (NULL == grp) { - fprintf (stderr, _("unknown group: %s\n"), group); + fprintf (stderr, _("%s: group '%s' does not exist\n"), Prog, group); goto failure; } diff --git a/src/passwd.c b/src/passwd.c index 92873764..b4fe6da4 100644 --- a/src/passwd.c +++ b/src/passwd.c @@ -879,7 +879,9 @@ int main (int argc, char **argv) pw = get_my_pwent (); if (NULL == pw) { fprintf (stderr, - _("%s: Cannot determine your user name.\n"), Prog); + _("%s: Cannot determine your user name.\n"), Prog); + SYSLOG ((LOG_WARN, "Cannot determine the user name of the caller (UID %lu)", + (unsigned long) getuid ())); exit (E_NOPERM); } myname = xstrdup (pw->pw_name); diff --git a/src/su.c b/src/su.c index 77f864f6..d25bd134 100644 --- a/src/su.c +++ b/src/su.c @@ -468,7 +468,10 @@ int main (int argc, char **argv) */ pw = get_my_pwent (); if (NULL == pw) { - SYSLOG ((LOG_CRIT, "Unknown UID: %u", my_uid)); + fprintf (stderr, _("%s: Cannot determine your user name.\n"), + Prog); + SYSLOG ((LOG_WARN, "Cannot determine the user name of the caller (UID %lu)", + (unsigned long) my_uid)); su_failure (tty); } STRFCPY (oldname, pw->pw_name);