From: Alejandro Colomar Date: Sun, 13 Jul 2025 14:57:17 +0000 (+0200) Subject: lib/, src/: Use eprintf() instead of its pattern X-Git-Tag: 4.20.0-rc3~4 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=8534fc587e9a499d2cefbcf55ce75122a45af0b0;p=thirdparty%2Fshadow.git lib/, src/: Use eprintf() instead of its pattern Reviewed-by: Serge Hallyn Signed-off-by: Alejandro Colomar --- diff --git a/src/chage.c b/src/chage.c index 5511394a7..22ea049f3 100644 --- a/src/chage.c +++ b/src/chage.c @@ -97,14 +97,14 @@ fail_exit (int code, bool process_selinux) { if (spw_locked) { if (spw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", spw_dbname()); /* continue */ } } if (pw_locked) { if (pw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname()); /* continue */ } @@ -349,8 +349,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) dflg = true; lstchgdate = strtoday (optarg); if (lstchgdate < -1) { - fprintf (stderr, - _("%s: invalid date '%s'\n"), + eprintf(_("%s: invalid date '%s'\n"), Prog, optarg); usage (E_USAGE); } @@ -359,8 +358,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) Eflg = true; expdate = strtoday (optarg); if (expdate < -1) { - fprintf (stderr, - _("%s: invalid date '%s'\n"), + eprintf(_("%s: invalid date '%s'\n"), Prog, optarg); usage (E_USAGE); } @@ -374,8 +372,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) case 'I': Iflg = true; if (a2sl(&inactdays, optarg, NULL, 0, -1, LONG_MAX) == -1) { - fprintf (stderr, - _("%s: invalid numeric argument '%s'\n"), + eprintf(_("%s: invalid numeric argument '%s'\n"), Prog, optarg); usage (E_USAGE); } @@ -386,8 +383,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) case 'M': Mflg = true; if (a2sl(&maxdays, optarg, NULL, 0, -1, LONG_MAX) == -1) { - fprintf (stderr, - _("%s: invalid numeric argument '%s'\n"), + eprintf(_("%s: invalid numeric argument '%s'\n"), Prog, optarg); usage (E_USAGE); } @@ -401,8 +397,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) case 'W': Wflg = true; if (a2sl(&warndays, optarg, NULL, 0, -1, LONG_MAX) == -1) { - fprintf (stderr, - _("%s: invalid numeric argument '%s'\n"), + eprintf(_("%s: invalid numeric argument '%s'\n"), Prog, optarg); usage (E_USAGE); } @@ -432,9 +427,7 @@ static void check_flags (int argc, int opt_index) } if (lflg && (Mflg || dflg || Wflg || Iflg || Eflg)) { - fprintf (stderr, - _("%s: do not include \"l\" with other flags\n"), - Prog); + eprintf(_("%s: do not include \"l\" with other flags\n"), Prog); usage (E_USAGE); } } @@ -461,7 +454,7 @@ static void check_perms(const struct option_flags *flags) */ if (!amroot && !lflg) { - fprintf (stderr, _("%s: Permission denied.\n"), Prog); + eprintf(_("%s: Permission denied.\n"), Prog); fail_exit (E_NOPERM, process_selinux); } } @@ -485,15 +478,14 @@ static void open_files(bool readonly, const struct option_flags *flags) */ if (!readonly) { if (pw_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, pw_dbname ()); fail_exit (E_NOPERM, process_selinux); } pw_locked = true; } if (pw_open (readonly ? O_RDONLY: O_CREAT | O_RDWR) == 0) { - fprintf (stderr, _("%s: cannot open %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, pw_dbname()); SYSLOG(LOG_WARN, "cannot open %s", pw_dbname()); fail_exit (E_NOPERM, process_selinux); } @@ -506,16 +498,14 @@ static void open_files(bool readonly, const struct option_flags *flags) */ if (!readonly) { if (spw_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, spw_dbname ()); fail_exit (E_NOPERM, process_selinux); } spw_locked = true; } if (spw_open (readonly ? O_RDONLY: O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), Prog, spw_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, spw_dbname()); SYSLOG(LOG_WARN, "cannot open %s", spw_dbname()); fail_exit (E_NOPERM, process_selinux); } @@ -535,8 +525,7 @@ static void close_files(const struct option_flags *flags) * entries to be re-written. */ if (spw_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), Prog, spw_dbname ()); + eprintf(_("%s: failure while writing changes to %s\n"), Prog, spw_dbname()); SYSLOG(LOG_ERR, "failure while writing changes to %s", spw_dbname()); fail_exit (E_NOPERM, process_selinux); } @@ -546,18 +535,18 @@ static void close_files(const struct option_flags *flags) * will be re-written. */ if (pw_close (process_selinux) == 0) { - fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: failure while writing changes to %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failure while writing changes to %s", pw_dbname()); fail_exit (E_NOPERM, process_selinux); } if (spw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", spw_dbname()); /* continue */ } spw_locked = false; if (pw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname()); /* continue */ } @@ -590,8 +579,7 @@ static void update_age (/*@null@*/const struct spwd *sp, pwent.pw_passwd = SHADOW_PASSWD_STRING; /* XXX warning: const */ if (pw_update (&pwent) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), Prog, pw_dbname (), pwent.pw_name); + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, pw_dbname(), pwent.pw_name); fail_exit (E_NOPERM, process_selinux); } } else { @@ -613,8 +601,7 @@ static void update_age (/*@null@*/const struct spwd *sp, spwent.sp_expire = expdate; if (spw_update (&spwent) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), Prog, spw_dbname (), spwent.sp_namp); + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, spw_dbname(), spwent.sp_namp); fail_exit (E_NOPERM, process_selinux); } @@ -730,9 +717,7 @@ int main (int argc, char **argv) check_perms (&flags); if (!spw_file_present ()) { - fprintf (stderr, - _("%s: the shadow password file is not present\n"), - Prog); + eprintf(_("%s: the shadow password file is not present\n"), Prog); SYSLOG(LOG_WARN, "can't find the shadow password file"); closelog (); exit (E_SHADOW_NOTFOUND); @@ -748,7 +733,7 @@ int main (int argc, char **argv) pw = pw_locate (argv[optind]); if (NULL == pw) { - fprintf (stderr, _("%s: user '%s' does not exist in %s\n"), + eprintf(_("%s: user '%s' does not exist in %s\n"), Prog, argv[optind], pw_dbname ()); closelog (); fail_exit (E_NOPERM, process_selinux); @@ -771,7 +756,7 @@ int main (int argc, char **argv) */ if (lflg) { if (!amroot && (ruid != user_uid)) { - fprintf (stderr, _("%s: Permission denied.\n"), Prog); + eprintf(_("%s: Permission denied.\n"), Prog); fail_exit (E_NOPERM, process_selinux); } /* Displaying fields is not of interest to audit */ @@ -787,8 +772,7 @@ int main (int argc, char **argv) printf (_("Changing the aging information for %s\n"), user_name); if (new_fields () == 0) { - fprintf (stderr, _("%s: error changing fields\n"), - Prog); + eprintf(_("%s: error changing fields\n"), Prog); fail_exit (E_NOPERM, process_selinux); } #ifdef WITH_AUDIT diff --git a/src/chfn.c b/src/chfn.c index 6be7b2bd9..3029f1521 100644 --- a/src/chfn.c +++ b/src/chfn.c @@ -25,6 +25,7 @@ #include "exitcodes.h" #include "fields.h" #include "getdef.h" +#include "io/fprintf.h" #include "nscd.h" #ifdef USE_PAM #include "pam_defs.h" @@ -83,7 +84,7 @@ static void fail_exit (int code, bool process_selinux) { if (pw_locked) { if (pw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname()); /* continue */ } @@ -239,8 +240,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) switch (c) { case 'f': if (!may_change_field ('f')) { - fprintf (stderr, - _("%s: Permission denied.\n"), Prog); + eprintf(_("%s: Permission denied.\n"), Prog); exit (E_NOPERM); } fflg = true; @@ -248,8 +248,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) break; case 'h': if (!may_change_field ('h')) { - fprintf (stderr, - _("%s: Permission denied.\n"), Prog); + eprintf(_("%s: Permission denied.\n"), Prog); exit (E_NOPERM); } hflg = true; @@ -257,22 +256,19 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) break; case 'o': if (!amroot) { - fprintf (stderr, - _("%s: Permission denied.\n"), Prog); + eprintf(_("%s: Permission denied.\n"), Prog); exit (E_NOPERM); } oflg = true; if (strlen (optarg) > (unsigned int) 80) { - fprintf (stderr, - _("%s: fields too long\n"), Prog); + eprintf(_("%s: fields too long\n"), Prog); exit (E_NOPERM); } strtcpy_a(slop, optarg); break; case 'r': if (!may_change_field ('r')) { - fprintf (stderr, - _("%s: Permission denied.\n"), Prog); + eprintf(_("%s: Permission denied.\n"), Prog); exit (E_NOPERM); } rflg = true; @@ -286,8 +282,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) /*@notreached@*/break; case 'w': if (!may_change_field ('w')) { - fprintf (stderr, - _("%s: Permission denied.\n"), Prog); + eprintf(_("%s: Permission denied.\n"), Prog); exit (E_NOPERM); } wflg = true; @@ -322,7 +317,7 @@ static void check_perms (const struct passwd *pw) * if the UID of the user matches the current real UID. */ if (!amroot && pw->pw_uid != getuid ()) { - fprintf (stderr, _("%s: Permission denied.\n"), Prog); + eprintf(_("%s: Permission denied.\n"), Prog); closelog (); exit (E_NOPERM); } @@ -333,7 +328,7 @@ static void check_perms (const struct passwd *pw) */ if ((pw->pw_uid != getuid ()) && (check_selinux_permit (Prog) != 0)) { - fprintf (stderr, _("%s: Permission denied.\n"), Prog); + eprintf(_("%s: Permission denied.\n"), Prog); closelog (); exit (E_NOPERM); } @@ -353,9 +348,7 @@ static void check_perms (const struct passwd *pw) #else /* !USE_PAM */ pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */ if (NULL == pampw) { - fprintf (stderr, - _("%s: Cannot determine your user name.\n"), - Prog); + eprintf(_("%s: Cannot determine your user name.\n"), Prog); exit (E_NOPERM); } @@ -370,8 +363,7 @@ static void check_perms (const struct passwd *pw) } if (PAM_SUCCESS != retval) { - fprintf (stderr, _("%s: PAM: %s\n"), - Prog, pam_strerror (pamh, retval)); + eprintf(_("%s: PAM: %s\n"), Prog, pam_strerror(pamh, retval)); SYSLOG(LOG_ERR, "%s", pam_strerror(pamh, retval)); if (NULL != pamh) { (void) pam_end (pamh, retval); @@ -413,15 +405,13 @@ static void update_gecos(const char *user, char *gecos, const struct option_flag * password file. Get a lock on the file and open it. */ if (pw_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, pw_dbname ()); fail_exit (E_NOPERM, process_selinux); } pw_locked = true; if (pw_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, pw_dbname()); fail_exit (E_NOPERM, process_selinux); } @@ -433,8 +423,7 @@ static void update_gecos(const char *user, char *gecos, const struct option_flag */ pw = pw_locate (user); if (NULL == pw) { - fprintf (stderr, - _("%s: user '%s' does not exist in %s\n"), + eprintf(_("%s: user '%s' does not exist in %s\n"), Prog, user, pw_dbname ()); fail_exit (E_NOPERM, process_selinux); } @@ -451,8 +440,7 @@ static void update_gecos(const char *user, char *gecos, const struct option_flag * entry as well. */ if (pw_update (&pwent) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, pw_dbname (), pwent.pw_name); fail_exit (E_NOPERM, process_selinux); } @@ -461,12 +449,12 @@ static void update_gecos(const char *user, char *gecos, const struct option_flag * Changes have all been made, so commit them and unlock the file. */ if (pw_close (process_selinux) == 0) { - fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: failure while writing changes to %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failure while writing changes to %s", pw_dbname()); fail_exit (E_NOPERM, process_selinux); } if (pw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname()); /* continue */ } @@ -517,36 +505,31 @@ static void check_fields (bool process_selinux) int err; err = valid_field (fullnm, ":,=\n"); if (err > 0) { - fprintf (stderr, _("%s: name with non-ASCII characters: '%s'\n"), Prog, fullnm); + eprintf(_("%s: name with non-ASCII characters: '%s'\n"), Prog, fullnm); } else if (err < 0) { - fprintf (stderr, _("%s: invalid name: '%s'\n"), Prog, fullnm); fail_exit (E_NOPERM, process_selinux); + eprintf(_("%s: invalid name: '%s'\n"), Prog, fullnm); } err = valid_field (roomno, ":,=\n"); if (err > 0) { - fprintf (stderr, _("%s: room number with non-ASCII characters: '%s'\n"), Prog, roomno); + eprintf(_("%s: room number with non-ASCII characters: '%s'\n"), Prog, roomno); } else if (err < 0) { - fprintf (stderr, _("%s: invalid room number: '%s'\n"), - Prog, roomno); + eprintf(_("%s: invalid room number: '%s'\n"), Prog, roomno); fail_exit (E_NOPERM, process_selinux); } if (valid_field (workph, ":,=\n") != 0) { - fprintf (stderr, _("%s: invalid work phone: '%s'\n"), - Prog, workph); + eprintf(_("%s: invalid work phone: '%s'\n"), Prog, workph); fail_exit (E_NOPERM, process_selinux); } if (valid_field (homeph, ":,=\n") != 0) { - fprintf (stderr, _("%s: invalid home phone: '%s'\n"), - Prog, homeph); + eprintf(_("%s: invalid home phone: '%s'\n"), Prog, homeph); fail_exit (E_NOPERM, process_selinux); } err = valid_field (slop, ":\n"); if (err > 0) { - fprintf (stderr, _("%s: '%s' contains non-ASCII characters\n"), Prog, slop); + eprintf(_("%s: '%s' contains non-ASCII characters\n"), Prog, slop); } else if (err < 0) { - fprintf (stderr, - _("%s: '%s' contains illegal characters\n"), - Prog, slop); + eprintf(_("%s: '%s' contains illegal characters\n"), Prog, slop); fail_exit (E_NOPERM, process_selinux); } } @@ -605,21 +588,19 @@ int main (int argc, char **argv) */ if (optind < argc) { if (!is_valid_user_name(argv[optind], true)) { - fprintf (stderr, _("%s: Provided user name is not a valid name\n"), Prog); + eprintf(_("%s: Provided user name is not a valid name\n"), Prog); fail_exit (E_NOPERM, process_selinux); } user = argv[optind]; pw = xgetpwnam (user); if (NULL == pw) { - fprintf (stderr, _("%s: user '%s' does not exist\n"), Prog, - user); + eprintf(_("%s: user '%s' does not exist\n"), Prog, user); fail_exit (E_NOPERM, process_selinux); } } else { pw = get_my_pwent (); if (NULL == pw) { - fprintf (stderr, - _("%s: Cannot determine your user name.\n"), + eprintf(_("%s: Cannot determine your user name.\n"), Prog); SYSLOG(LOG_WARN, "Cannot determine the user name of the caller (UID %lu)", (unsigned long) getuid()); @@ -661,7 +642,7 @@ int main (int argc, char **argv) p = seprintf(p, e, ",%s", slop); if (p == e || p == NULL) { - fprintf (stderr, _("%s: fields too long\n"), Prog); + eprintf(_("%s: fields too long\n"), Prog); fail_exit (E_NOPERM, process_selinux); } diff --git a/src/chgpasswd.c b/src/chgpasswd.c index ea8cdd2a5..c218cf67b 100644 --- a/src/chgpasswd.c +++ b/src/chgpasswd.c @@ -81,7 +81,7 @@ static void fail_exit (int code, bool process_selinux) { if (gr_locked) { if (gr_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, gr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", gr_dbname()); /* continue */ } @@ -90,7 +90,7 @@ static void fail_exit (int code, bool process_selinux) #ifdef SHADOWGRP if (sgr_locked) { if (sgr_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sgr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sgr_dbname()); /* continue */ } @@ -171,8 +171,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) bad_s = 0; if (!crypt_method) { - fprintf (stderr, - _("%s: no crypt method defined\n"), + eprintf(_("%s: no crypt method defined\n"), Prog); usage (E_USAGE); } @@ -193,8 +192,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) } #endif /* USE_YESCRYPT */ if (bad_s != 0) { - fprintf (stderr, - _("%s: invalid numeric argument '%s'\n"), + eprintf(_("%s: invalid numeric argument '%s'\n"), Prog, optarg); usage (E_USAGE); } @@ -217,16 +215,13 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) static void check_flags (void) { if (sflg && !cflg) { - fprintf (stderr, - _("%s: %s flag is only allowed with the %s flag\n"), + eprintf(_("%s: %s flag is only allowed with the %s flag\n"), Prog, "-s", "-c"); usage (E_USAGE); } if (eflg && cflg) { - fprintf (stderr, - _("%s: the -c and -e flags are exclusive\n"), - Prog); + eprintf(_("%s: the -c and -e flags are exclusive\n"), Prog); usage (E_USAGE); } @@ -241,8 +236,7 @@ static void check_flags (void) && !streq(crypt_method, "YESCRYPT") #endif /* USE_YESCRYPT */ ) { - fprintf (stderr, - _("%s: unsupported crypt method: %s\n"), + eprintf(_("%s: unsupported crypt method: %s\n"), Prog, crypt_method); usage (E_USAGE); } @@ -259,15 +253,13 @@ static void open_files (bool process_selinux) * bring all of the entries into memory where they may be updated. */ if (gr_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, gr_dbname ()); fail_exit (1, process_selinux); } gr_locked = true; if (gr_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), Prog, gr_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, gr_dbname()); fail_exit (1, process_selinux); } @@ -275,15 +267,13 @@ static void open_files (bool process_selinux) /* Do the same for the shadowed database, if it exist */ if (is_shadow_grp) { if (sgr_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, sgr_dbname ()); fail_exit (1, process_selinux); } sgr_locked = true; if (sgr_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, _("%s: cannot open %s\n"), - Prog, sgr_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, sgr_dbname()); fail_exit (1, process_selinux); } } @@ -301,14 +291,13 @@ static void close_files(const struct option_flags *flags) #ifdef SHADOWGRP if (is_shadow_grp) { if (sgr_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, sgr_dbname ()); SYSLOG(LOG_ERR, "failure while writing changes to %s", sgr_dbname()); fail_exit (1, process_selinux); } if (sgr_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sgr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sgr_dbname()); /* continue */ } @@ -317,14 +306,13 @@ static void close_files(const struct option_flags *flags) #endif if (gr_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, gr_dbname ()); SYSLOG(LOG_ERR, "failure while writing changes to %s", gr_dbname()); fail_exit (1, process_selinux); } if (gr_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, gr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", gr_dbname()); /* continue */ } @@ -384,8 +372,7 @@ int main (int argc, char **argv) while (fgets_a(buf, stdin) != NULL) { line++; if (stpsep(buf, "\n") == NULL) { - fprintf (stderr, _("%s: line %jd: line too long\n"), - Prog, line); + eprintf(_("%s: line %jd: line too long\n"), Prog, line); errors = true; continue; } @@ -402,8 +389,7 @@ int main (int argc, char **argv) name = buf; cp = stpsep(name, ":"); if (cp == NULL) { - fprintf (stderr, - _("%s: line %jd: missing new password\n"), + eprintf(_("%s: line %jd: missing new password\n"), Prog, line); errors = true; continue; @@ -445,8 +431,7 @@ int main (int argc, char **argv) */ gr = gr_locate (name); if (NULL == gr) { - fprintf (stderr, - _("%s: line %jd: group '%s' does not exist\n"), Prog, + eprintf(_("%s: line %jd: group '%s' does not exist\n"), Prog, line, name); errors = true; continue; @@ -505,8 +490,7 @@ int main (int argc, char **argv) #ifdef SHADOWGRP if (NULL != sg) { if (sgr_update (&newsg) == 0) { - fprintf (stderr, - _("%s: line %jd: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: line %jd: failed to prepare the new %s entry '%s'\n"), Prog, line, sgr_dbname (), newsg.sg_namp); errors = true; continue; @@ -517,8 +501,7 @@ int main (int argc, char **argv) #endif { if (gr_update (&newgr) == 0) { - fprintf (stderr, - _("%s: line %jd: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: line %jd: failed to prepare the new %s entry '%s'\n"), Prog, line, gr_dbname (), newgr.gr_name); errors = true; continue; @@ -534,8 +517,7 @@ int main (int argc, char **argv) * afterwards. */ if (errors) { - fprintf (stderr, - _("%s: error detected, changes ignored\n"), Prog); + eprintf(_("%s: error detected, changes ignored\n"), Prog); fail_exit (1, process_selinux); } diff --git a/src/chpasswd.c b/src/chpasswd.c index 5c0cbdf3a..63a8ed98b 100644 --- a/src/chpasswd.c +++ b/src/chpasswd.c @@ -85,7 +85,7 @@ static void fail_exit (int code, bool process_selinux) { if (pw_locked) { if (pw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname()); /* continue */ } @@ -93,7 +93,7 @@ static void fail_exit (int code, bool process_selinux) if (spw_locked) { if (spw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", spw_dbname()); /* continue */ } @@ -194,8 +194,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) } #endif /* USE_YESCRYPT */ if (bad_s != 0) { - fprintf (stderr, - _("%s: invalid numeric argument '%s'\n"), + eprintf(_("%s: invalid numeric argument '%s'\n"), Prog, optarg); usage (E_USAGE); } @@ -218,16 +217,13 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) static void check_flags (void) { if (sflg && !cflg) { - fprintf (stderr, - _("%s: %s flag is only allowed with the %s flag\n"), + eprintf(_("%s: %s flag is only allowed with the %s flag\n"), Prog, "-s", "-c"); usage (E_USAGE); } if (eflg && cflg) { - fprintf (stderr, - _("%s: the -c and -e flags are exclusive\n"), - Prog); + eprintf(_("%s: the -c and -e flags are exclusive\n"), Prog); usage (E_USAGE); } @@ -242,8 +238,7 @@ static void check_flags (void) &&(!IS_CRYPT_METHOD("YESCRYPT")) #endif /* USE_YESCRYPT */ ) { - fprintf (stderr, - _("%s: unsupported crypt method: %s\n"), + eprintf(_("%s: unsupported crypt method: %s\n"), Prog, crypt_method); usage (E_USAGE); } @@ -264,31 +259,26 @@ static void open_files(const struct option_flags *flags) * will bring all of the entries into memory where they may be updated. */ if (pw_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, pw_dbname ()); fail_exit (1, process_selinux); } pw_locked = true; if (pw_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, pw_dbname()); fail_exit (1, process_selinux); } /* Do the same for the shadowed database, if it exist */ if (is_shadow_pwd) { if (spw_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, spw_dbname ()); fail_exit (1, process_selinux); } spw_locked = true; if (spw_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), - Prog, spw_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, spw_dbname()); fail_exit (1, process_selinux); } } @@ -305,14 +295,13 @@ static void close_files(const struct option_flags *flags) if (is_shadow_pwd) { if (spw_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, spw_dbname ()); SYSLOG(LOG_ERR, "failure while writing changes to %s", spw_dbname()); fail_exit (1, process_selinux); } if (spw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", spw_dbname()); /* continue */ } @@ -320,14 +309,13 @@ static void close_files(const struct option_flags *flags) } if (pw_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, pw_dbname ()); SYSLOG(LOG_ERR, "failure while writing changes to %s", pw_dbname()); fail_exit (1, process_selinux); } if (pw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname()); /* continue */ } @@ -433,8 +421,7 @@ int main (int argc, char **argv) break; } - fprintf (stderr, - _("%s: line %jd: line too long\n"), + eprintf(_("%s: line %jd: line too long\n"), Prog, line); errors = true; continue; @@ -453,8 +440,7 @@ int main (int argc, char **argv) name = buf; cp = stpsep(name, ":"); if (cp == NULL) { - fprintf (stderr, - _("%s: line %jd: missing new password\n"), + eprintf(_("%s: line %jd: missing new password\n"), Prog, line); errors = true; continue; @@ -464,8 +450,7 @@ int main (int argc, char **argv) #ifdef USE_PAM if (use_pam) { if (do_pam_passwd_non_interactive (Prog, name, newpwd) != 0) { - fprintf (stderr, - _("%s: (line %jd, user %s) password not changed\n"), + eprintf(_("%s: (line %jd, user %s) password not changed\n"), Prog, line, name); errors = true; } @@ -507,8 +492,7 @@ int main (int argc, char **argv) */ pw = pw_locate (name); if (NULL == pw) { - fprintf (stderr, - _("%s: line %jd: user '%s' does not exist\n"), Prog, + eprintf(_("%s: line %jd: user '%s' does not exist\n"), Prog, line, name); errors = true; continue; @@ -573,8 +557,7 @@ int main (int argc, char **argv) */ if (NULL != sp) { if (spw_update (&newsp) == 0) { - fprintf (stderr, - _("%s: line %jd: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: line %jd: failed to prepare the new %s entry '%s'\n"), Prog, line, spw_dbname (), newsp.sp_namp); errors = true; continue; @@ -583,8 +566,7 @@ int main (int argc, char **argv) if ( (NULL == sp) || !streq(pw->pw_passwd, SHADOW_PASSWD_STRING)) { if (pw_update (&newpw) == 0) { - fprintf (stderr, - _("%s: line %jd: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: line %jd: failed to prepare the new %s entry '%s'\n"), Prog, line, pw_dbname (), newpw.pw_name); errors = true; continue; @@ -608,8 +590,7 @@ int main (int argc, char **argv) if (!use_pam) #endif /* USE_PAM */ { - fprintf (stderr, - _("%s: error detected, changes ignored\n"), + eprintf(_("%s: error detected, changes ignored\n"), Prog); } fail_exit (1, process_selinux); diff --git a/src/chsh.c b/src/chsh.c index 53ef783a1..4fd6bd2e0 100644 --- a/src/chsh.c +++ b/src/chsh.c @@ -23,6 +23,7 @@ #include "exitcodes.h" #include "fields.h" #include "getdef.h" +#include "io/fprintf.h" #include "nscd.h" #include "prototypes.h" #include "pwauth.h" @@ -83,7 +84,7 @@ fail_exit (int code, bool process_selinux) { if (pw_locked) { if (pw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname()); /* continue */ } @@ -169,16 +170,14 @@ static bool shell_is_listed (const char *sh, bool process_selinux) "", /* key only */ "#" /* comment */); if (error) { - fprintf (stderr, - _("Cannot parse shell files: %s"), + eprintf(_("Cannot parse shell files: %s"), econf_errString(error)); fail_exit (1, process_selinux); } error = econf_getKeys(key_file, NULL, &size, &keys); if (error) { - fprintf (stderr, - _("Cannot evaluate entries in shell files: %s"), + eprintf(_("Cannot evaluate entries in shell files: %s"), econf_errString(error)); econf_free (key_file); fail_exit (1, process_selinux); @@ -285,9 +284,7 @@ static void check_perms(const struct passwd *pw, const struct option_flags *flag */ if (!amroot && pw->pw_uid != getuid ()) { SYSLOG(LOG_WARN, "can't change shell for '%s'", pw->pw_name); - fprintf (stderr, - _("You may not change the shell for '%s'.\n"), - pw->pw_name); + eprintf(_("You may not change the shell for '%s'.\n"), pw->pw_name); fail_exit (1, process_selinux); } @@ -297,9 +294,7 @@ static void check_perms(const struct passwd *pw, const struct option_flags *flag */ if (!amroot && is_restricted_shell (pw->pw_shell, process_selinux)) { SYSLOG(LOG_WARN, "can't change shell for '%s'", pw->pw_name); - fprintf (stderr, - _("You may not change the shell for '%s'.\n"), - pw->pw_name); + eprintf(_("You may not change the shell for '%s'.\n"), pw->pw_name); fail_exit (1, process_selinux); } #ifdef WITH_SELINUX @@ -310,9 +305,7 @@ static void check_perms(const struct passwd *pw, const struct option_flags *flag if ((pw->pw_uid != getuid ()) && (check_selinux_permit(Prog) != 0)) { SYSLOG(LOG_WARN, "can't change shell for '%s'", pw->pw_name); - fprintf (stderr, - _("You may not change the shell for '%s'.\n"), - pw->pw_name); + eprintf(_("You may not change the shell for '%s'.\n"), pw->pw_name); fail_exit (1, process_selinux); } #endif @@ -331,9 +324,7 @@ static void check_perms(const struct passwd *pw, const struct option_flags *flag #else /* !USE_PAM */ pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */ if (NULL == pampw) { - fprintf (stderr, - _("%s: Cannot determine your user name.\n"), - Prog); + eprintf(_("%s: Cannot determine your user name.\n"), Prog); exit (E_NOPERM); } @@ -348,8 +339,7 @@ static void check_perms(const struct passwd *pw, const struct option_flags *flag } if (PAM_SUCCESS != retval) { - fprintf (stderr, _("%s: PAM: %s\n"), - Prog, pam_strerror (pamh, retval)); + eprintf(_("%s: PAM: %s\n"), Prog, pam_strerror(pamh, retval)); SYSLOG(LOG_ERR, "%s", pam_strerror(pamh, retval)); if (NULL != pamh) { (void) pam_end (pamh, retval); @@ -393,13 +383,13 @@ static void update_shell (const char *user, char *newshell, const struct option_ * the password file. Get a lock on the file and open it. */ if (pw_lock () == 0) { - fprintf (stderr, _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, pw_dbname ()); fail_exit (1, process_selinux); } pw_locked = true; if (pw_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, _("%s: cannot open %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, pw_dbname()); SYSLOG(LOG_WARN, "cannot open %s", pw_dbname()); fail_exit (1, process_selinux); } @@ -412,8 +402,7 @@ static void update_shell (const char *user, char *newshell, const struct option_ */ pw = pw_locate (user); if (NULL == pw) { - fprintf (stderr, - _("%s: user '%s' does not exist in %s\n"), + eprintf(_("%s: user '%s' does not exist in %s\n"), Prog, user, pw_dbname ()); fail_exit (1, process_selinux); } @@ -430,8 +419,7 @@ static void update_shell (const char *user, char *newshell, const struct option_ * that entry as well. */ if (pw_update (&pwent) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, pw_dbname (), pwent.pw_name); fail_exit (1, process_selinux); } @@ -440,12 +428,12 @@ static void update_shell (const char *user, char *newshell, const struct option_ * Changes have all been made, so commit them and unlock the file. */ if (pw_close (process_selinux) == 0) { - fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: failure while writing changes to %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failure while writing changes to %s", pw_dbname()); fail_exit (1, process_selinux); } if (pw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname()); /* continue */ } @@ -494,21 +482,19 @@ int main (int argc, char **argv) */ if (optind < argc) { if (!is_valid_user_name(argv[optind], true)) { - fprintf (stderr, _("%s: Provided user name is not a valid name\n"), Prog); + eprintf(_("%s: Provided user name is not a valid name\n"), Prog); fail_exit (1, process_selinux); } user = argv[optind]; pw = xgetpwnam (user); if (NULL == pw) { - fprintf (stderr, - _("%s: user '%s' does not exist\n"), Prog, user); + eprintf(_("%s: user '%s' does not exist\n"), Prog, user); fail_exit (1, process_selinux); } } else { pw = get_my_pwent (); if (NULL == pw) { - fprintf (stderr, - _("%s: Cannot determine your user name.\n"), + eprintf(_("%s: Cannot determine your user name.\n"), Prog); SYSLOG(LOG_WARN, "Cannot determine the user name of the caller (UID %lu)", (unsigned long) getuid()); @@ -543,7 +529,7 @@ int main (int argc, char **argv) * The shell must be executable by the user. */ if (valid_field (loginsh, ":,=\n") != 0) { - fprintf (stderr, _("%s: Invalid entry: %s\n"), Prog, loginsh); + eprintf(_("%s: Invalid entry: %s\n"), Prog, loginsh); fail_exit (1, process_selinux); } if (!streq(loginsh, "") @@ -552,9 +538,9 @@ int main (int argc, char **argv) || (access (loginsh, X_OK) != 0))) { if (amroot) { - fprintf (stderr, _("%s: Warning: %s is an invalid shell\n"), Prog, loginsh); + eprintf(_("%s: Warning: %s is an invalid shell\n"), Prog, loginsh); } else { - fprintf (stderr, _("%s: %s is an invalid shell\n"), Prog, loginsh); + eprintf(_("%s: %s is an invalid shell\n"), Prog, loginsh); fail_exit (1, process_selinux); } } @@ -563,9 +549,9 @@ int main (int argc, char **argv) if (!streq(loginsh, "")) { /* But not if an empty string is given, documented as meaning the default shell */ if (access (loginsh, F_OK) != 0) { - fprintf (stderr, _("%s: Warning: %s does not exist\n"), Prog, loginsh); + eprintf(_("%s: Warning: %s does not exist\n"), Prog, loginsh); } else if (access (loginsh, X_OK) != 0) { - fprintf (stderr, _("%s: Warning: %s is not executable\n"), Prog, loginsh); + eprintf(_("%s: Warning: %s is not executable\n"), Prog, loginsh); } } diff --git a/src/faillog.c b/src/faillog.c index 027f315c3..5cd793f52 100644 --- a/src/faillog.c +++ b/src/faillog.c @@ -101,8 +101,7 @@ static off_t lookup_faillog(struct faillog *fl, uid_t uid) /* Ensure multiplication does not overflow and retrieving a wrong entry */ if (__builtin_mul_overflow(uid, sizeof(*fl), &offset)) { - fprintf(stderr, - _("%s: Failed to get the entry for UID %lu\n"), + eprintf(_("%s: Failed to get the entry for UID %lu\n"), Prog, (unsigned long)uid); return -1; } @@ -117,8 +116,7 @@ static off_t lookup_faillog(struct faillog *fl, uid_t uid) * empty entry in this case. */ if (fread(fl, sizeof(*fl), 1, fail) != 1) { - fprintf(stderr, - _("%s: Failed to get the entry for UID %lu\n"), + eprintf(_("%s: Failed to get the entry for UID %lu\n"), Prog, (unsigned long)uid); return -1; } @@ -171,7 +169,7 @@ static void print_one (/*@null@*/const struct passwd *pw, bool force) tm = localtime (&fl.fail_time); if (!tm) { - fprintf (stderr, "Cannot read time from faillog.\n"); + eprintf("Cannot read time from faillog.\n"); return; } strftime_a(ptime, "%D %H:%M:%S %z", tm); @@ -251,8 +249,7 @@ static bool reset_one (uid_t uid) return false; } - fprintf (stderr, - _("%s: Failed to reset fail count for UID %lu\n"), + eprintf(_("%s: Failed to reset fail count for UID %lu\n"), Prog, (unsigned long)uid); return true; } @@ -347,8 +344,7 @@ static bool setmax_one (uid_t uid, short max) return false; } - fprintf (stderr, - _("%s: Failed to set max for UID %lu\n"), + eprintf(_("%s: Failed to set max for UID %lu\n"), Prog, (unsigned long)uid); return true; } @@ -445,8 +441,7 @@ static bool set_locktime_one (uid_t uid, long locktime) return false; } - fprintf (stderr, - _("%s: Failed to set locktime for UID %lu\n"), + eprintf(_("%s: Failed to set locktime for UID %lu\n"), Prog, (unsigned long)uid); return true; } @@ -550,8 +545,7 @@ int main (int argc, char **argv) /*@notreached@*/break; case 'l': if (str2sl(&fail_locktime, optarg) == -1) { - fprintf (stderr, - _("%s: invalid numeric argument '%s'\n"), + eprintf(_("%s: invalid numeric argument '%s'\n"), Prog, optarg); exit (E_BAD_ARG); } @@ -560,8 +554,7 @@ int main (int argc, char **argv) case 'm': { if (str2sh(&fail_max, optarg) == -1) { - fprintf (stderr, - _("%s: invalid numeric argument '%s'\n"), + eprintf(_("%s: invalid numeric argument '%s'\n"), Prog, optarg); exit (E_BAD_ARG); } @@ -575,8 +568,7 @@ int main (int argc, char **argv) break; case 't': if (str2sl(&days, optarg) == -1) { - fprintf (stderr, - _("%s: invalid numeric argument '%s'\n"), + eprintf(_("%s: invalid numeric argument '%s'\n"), Prog, optarg); exit (E_BAD_ARG); } @@ -606,8 +598,7 @@ int main (int argc, char **argv) if (getrange(optarg, &umin, &has_umin, &umax, &has_umax) == -1) { - fprintf (stderr, - _("%s: Unknown user or range: %s\n"), + eprintf(_("%s: Unknown user or range: %s\n"), Prog, optarg); exit (E_BAD_ARG); } @@ -620,8 +611,7 @@ int main (int argc, char **argv) } } if (argc > optind) { - fprintf (stderr, - _("%s: unexpected argument: %s\n"), + eprintf(_("%s: unexpected argument: %s\n"), Prog, argv[optind]); usage (EXIT_FAILURE); } diff --git a/src/free_subid_range.c b/src/free_subid_range.c index 5dca40d43..933837c98 100644 --- a/src/free_subid_range.c +++ b/src/free_subid_range.c @@ -16,8 +16,8 @@ static const char Prog[] = "free_subid_range"; static void usage(void) { - fprintf(stderr, "Usage: %s [-g] user start count\n", Prog); - fprintf(stderr, " Release a user's subuid (or with -g, subgid) range\n"); + eprintf("Usage: %s [-g] user start count\n", Prog); + eprintf(" Release a user's subuid (or with -g, subgid) range\n"); exit(EXIT_FAILURE); } @@ -49,7 +49,7 @@ int main(int argc, char *argv[]) ok = subid_ungrant_uid_range(&range); if (!ok) { - fprintf(stderr, "Failed freeing id range\n"); + eprintf("Failed freeing id range\n"); exit(EXIT_FAILURE); } diff --git a/src/get_subid_owners.c b/src/get_subid_owners.c index 49d1ce1a3..776ce0341 100644 --- a/src/get_subid_owners.c +++ b/src/get_subid_owners.c @@ -39,7 +39,7 @@ int main(int argc, char *argv[]) n = subid_get_uid_owners(u, &uids); } if (n < 0) { - fprintf(stderr, "No owners found\n"); + eprintf("No owners found\n"); exit(1); } for (i = 0; i < n; i++) { @@ -53,8 +53,8 @@ int main(int argc, char *argv[]) static void usage(void) { - fprintf(stderr, "Usage: [-g] %s subuid\n", Prog); - fprintf(stderr, " list uids who own the given subuid\n"); - fprintf(stderr, " pass -g to query a subgid\n"); + eprintf("Usage: [-g] %s subuid\n", Prog); + eprintf(" list uids who own the given subuid\n"); + eprintf(" pass -g to query a subgid\n"); exit(EXIT_FAILURE); } diff --git a/src/getsubids.c b/src/getsubids.c index 622e44b84..cab760963 100644 --- a/src/getsubids.c +++ b/src/getsubids.c @@ -36,7 +36,7 @@ int main(int argc, char *argv[]) count = subid_get_uid_ranges(owner, &ranges); } if (!ranges) { - fprintf(stderr, "Error fetching ranges\n"); + eprintf("Error fetching ranges\n"); exit(1); } for (i = 0; i < count; i++) { @@ -51,8 +51,8 @@ int main(int argc, char *argv[]) static void usage(void) { - fprintf(stderr, "Usage: %s [-g] user\n", Prog); - fprintf(stderr, " list subuid ranges for user\n"); - fprintf(stderr, " pass -g to list subgid ranges\n"); + eprintf("Usage: %s [-g] user\n", Prog); + eprintf(" list subuid ranges for user\n"); + eprintf(" pass -g to list subgid ranges\n"); exit(EXIT_FAILURE); } diff --git a/src/gpasswd.c b/src/gpasswd.c index 1e207c34c..9d6154b01 100644 --- a/src/gpasswd.c +++ b/src/gpasswd.c @@ -196,8 +196,7 @@ static bool is_valid_user_list (const char *users) /* local, no need for xgetpwnam */ if (getpwnam(u) == NULL) { - fprintf (stderr, _("%s: user '%s' does not exist\n"), - Prog, u); + eprintf(_("%s: user '%s' does not exist\n"), Prog, u); is_valid = false; } } @@ -209,7 +208,7 @@ static bool is_valid_user_list (const char *users) static void failure(void) { - fprintf(stderr, _("%s: Permission denied.\n"), Prog); + eprintf(_("%s: Permission denied.\n"), Prog); log_gpasswd_failure(": Permission denied"); exit(E_NOPERM); } @@ -240,8 +239,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) user = optarg; /* local, no need for xgetpwnam */ if (getpwnam (user) == NULL) { - fprintf (stderr, - _("%s: user '%s' does not exist\n"), + eprintf(_("%s: user '%s' does not exist\n"), Prog, user); exit (E_BAD_ARG); } @@ -249,8 +247,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) #ifdef SHADOWGRP case 'A': /* set the list of administrators */ if (!is_shadowgrp) { - fprintf (stderr, - _("%s: shadow group passwords required for -A\n"), + eprintf(_("%s: shadow group passwords required for -A\n"), Prog); exit (E_GSHADOW_NOTFOUND); } @@ -345,8 +342,7 @@ static void open_files(const struct option_flags *flags) process_selinux = !flags->chroot; if (gr_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, gr_dbname ()); exit (E_NOPERM); } @@ -355,8 +351,7 @@ static void open_files(const struct option_flags *flags) #ifdef SHADOWGRP if (is_shadowgrp) { if (sgr_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, sgr_dbname ()); exit (E_NOPERM); } @@ -367,9 +362,7 @@ static void open_files(const struct option_flags *flags) add_cleanup (log_gpasswd_failure_system, NULL); if (gr_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), - Prog, gr_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, gr_dbname()); SYSLOG(LOG_WARN, "cannot open %s", gr_dbname()); exit (E_NOPERM); } @@ -377,9 +370,7 @@ static void open_files(const struct option_flags *flags) #ifdef SHADOWGRP if (is_shadowgrp) { if (sgr_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), - Prog, sgr_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, sgr_dbname()); SYSLOG(LOG_WARN, "cannot open %s", sgr_dbname()); exit (E_NOPERM); } @@ -602,8 +593,7 @@ static void close_files(const struct option_flags *flags) process_selinux = !flags->chroot; if (gr_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, gr_dbname ()); exit (E_NOPERM); } @@ -616,8 +606,7 @@ static void close_files(const struct option_flags *flags) #ifdef SHADOWGRP if (is_shadowgrp) { if (sgr_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, sgr_dbname ()); exit (E_NOPERM); } @@ -679,15 +668,13 @@ static void update_group (struct group *gr) #endif { if (gr_update (gr) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, gr_dbname (), gr->gr_name); exit (1); } #ifdef SHADOWGRP if (is_shadowgrp && (sgr_update (sg) == 0)) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, sgr_dbname (), sg->sg_namp); exit (1); } @@ -717,15 +704,14 @@ static void get_group(struct group *gr, const struct option_flags *flags) process_selinux = !flags->chroot; if (gr_open (O_RDONLY) == 0) { - fprintf (stderr, _("%s: cannot open %s\n"), Prog, gr_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, gr_dbname()); SYSLOG(LOG_WARN, "cannot open %s", gr_dbname()); exit (E_NOPERM); } tmpgr = gr_locate (group); if (NULL == tmpgr) { - fprintf (stderr, - _("%s: group '%s' does not exist in %s\n"), + eprintf(_("%s: group '%s' does not exist in %s\n"), Prog, group, gr_dbname ()); exit (E_BAD_ARG); } @@ -736,8 +722,7 @@ static void get_group(struct group *gr, const struct option_flags *flags) gr->gr_mem = dup_list (tmpgr->gr_mem); if (gr_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while closing read-only %s\n"), + eprintf(_("%s: failure while closing read-only %s\n"), Prog, gr_dbname ()); SYSLOG(LOG_ERR, "failure while closing read-only %s", gr_dbname()); exit (E_NOPERM); @@ -746,9 +731,7 @@ static void get_group(struct group *gr, const struct option_flags *flags) #ifdef SHADOWGRP if (is_shadowgrp) { if (sgr_open (O_RDONLY) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), - Prog, sgr_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, sgr_dbname()); SYSLOG(LOG_WARN, "cannot open %s", sgr_dbname()); exit (E_NOPERM); } @@ -772,8 +755,7 @@ static void get_group(struct group *gr, const struct option_flags *flags) } if (sgr_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while closing read-only %s\n"), + eprintf(_("%s: failure while closing read-only %s\n"), Prog, sgr_dbname ()); SYSLOG(LOG_ERR, "failure while closing read-only %s", sgr_dbname()); @@ -838,7 +820,7 @@ static void change_passwd (struct group *gr) } if (retries == RETRIES) { - fprintf (stderr, _("%s: Try again later\n"), Prog); + eprintf(_("%s: Try again later\n"), Prog); exit (1); } @@ -912,8 +894,7 @@ int main (int argc, char **argv) */ pw = get_my_pwent (); if (NULL == pw) { - fprintf (stderr, _("%s: Cannot determine your user name.\n"), - Prog); + eprintf(_("%s: Cannot determine your user name.\n"), Prog); SYSLOG(LOG_WARN, "Cannot determine the user name of the caller (UID %lu)", (unsigned long) getuid()); @@ -926,7 +907,7 @@ int main (int argc, char **argv) * could create. */ if (atexit (do_cleanups) != 0) { - fprintf(stderr, "%s: cannot set exit function\n", Prog); + eprintf("%s: cannot set exit function\n", Prog); exit (1); } @@ -1020,8 +1001,7 @@ int main (int argc, char **argv) } #endif if (!removed) { - fprintf (stderr, - _("%s: user '%s' is not a member of '%s'\n"), + eprintf(_("%s: user '%s' is not a member of '%s'\n"), Prog, user, group); exit (E_BAD_ARG); } @@ -1060,7 +1040,7 @@ int main (int argc, char **argv) * modes can be restored. */ if ((isatty (0) == 0) || (isatty (1) == 0)) { - fprintf (stderr, _("%s: Not a tty\n"), Prog); + eprintf(_("%s: Not a tty\n"), Prog); exit (E_NOPERM); } diff --git a/src/groupadd.c b/src/groupadd.c index ff1219a29..3403ebbcb 100644 --- a/src/groupadd.c +++ b/src/groupadd.c @@ -218,7 +218,7 @@ grp_update(void) ul = user_list; while (NULL != (u = strsep(&ul, ","))) { if (prefix_getpwnam(u) == NULL) { - fprintf(stderr, _("Invalid member username %s\n"), u); + eprintf(_("Invalid member username %s\n"), u); exit (E_GRP_UPDATE); } @@ -234,8 +234,7 @@ grp_update(void) * Write out the new group file entry. */ if (gr_update (&grp) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, gr_dbname (), grp.gr_name); fail_exit (E_GRP_UPDATE); } @@ -244,8 +243,7 @@ grp_update(void) * Write out the new shadow group entries as well. */ if (is_shadow_grp && (sgr_update (&sgrp) == 0)) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, sgr_dbname (), sgrp.sg_namp); fail_exit (E_GRP_UPDATE); } @@ -262,7 +260,7 @@ static void check_new_name(void) { if (!is_valid_group_name(group_name)) { - fprintf(stderr, _("%s: '%s' is not a valid group name\n"), + eprintf(_("%s: '%s' is not a valid group name\n"), Prog, group_name); fail_exit (E_BAD_ARG); @@ -285,8 +283,7 @@ static void close_files(const struct option_flags *flags) /* First, write the changes in the regular group database */ if (gr_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, gr_dbname ()); fail_exit (E_GRP_UPDATE); } @@ -306,8 +303,7 @@ static void close_files(const struct option_flags *flags) #ifdef SHADOWGRP if (is_shadow_grp) { if (sgr_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, sgr_dbname ()); fail_exit (E_GRP_UPDATE); } @@ -344,8 +340,7 @@ static void open_files(const struct option_flags *flags) /* First, lock the databases */ if (gr_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, gr_dbname ()); fail_exit (E_GRP_UPDATE); } @@ -354,8 +349,7 @@ static void open_files(const struct option_flags *flags) #ifdef SHADOWGRP if (is_shadow_grp) { if (sgr_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, sgr_dbname ()); fail_exit (E_GRP_UPDATE); } @@ -430,8 +424,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) gflg = true; if ( (get_gid(optarg, &group_id) == -1) || (group_id == (gid_t)-1)) { - fprintf (stderr, - _("%s: invalid group ID '%s'\n"), + eprintf(_("%s: invalid group ID '%s'\n"), Prog, optarg); exit (E_BAD_ARG); } @@ -447,8 +440,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) */ cp = stpsep(optarg, "="); if (NULL == cp) { - fprintf (stderr, - _("%s: -K requires KEY=VALUE\n"), + eprintf(_("%s: -K requires KEY=VALUE\n"), Prog); exit (E_BAD_ARG); } @@ -515,8 +507,7 @@ static void check_flags (void) /* OK, no need to do anything */ exit (E_SUCCESS); } - fprintf (stderr, - _("%s: group '%s' already exists\n"), + eprintf(_("%s: group '%s' already exists\n"), Prog, group_name); fail_exit (E_NAME_IN_USE); } @@ -534,8 +525,7 @@ static void check_flags (void) /* Turn off -g, we can use any GID */ gflg = false; } else { - fprintf (stderr, - _("%s: GID '%lu' already exists\n"), + eprintf(_("%s: GID '%lu' already exists\n"), Prog, (unsigned long) group_id); fail_exit (E_GID_IN_USE); } @@ -565,9 +555,7 @@ int main (int argc, char **argv) #endif if (atexit (do_cleanups) != 0) { - fprintf (stderr, - _("%s: Cannot setup cleanup service.\n"), - Prog); + eprintf(_("%s: Cannot setup cleanup service.\n"), Prog); fail_exit (1); } diff --git a/src/groupdel.c b/src/groupdel.c index 0df511719..19d67fc31 100644 --- a/src/groupdel.c +++ b/src/groupdel.c @@ -18,8 +18,10 @@ #include #include #include + #include "defines.h" #include "groupio.h" +#include "io/fprintf.h" #include "nscd.h" #include "sssd.h" #include "prototypes.h" @@ -120,8 +122,7 @@ static void grp_update (void) * Delete the group entry. */ if (gr_remove (group_name) == 0) { - fprintf (stderr, - _("%s: cannot remove entry '%s' from %s\n"), + eprintf(_("%s: cannot remove entry '%s' from %s\n"), Prog, group_name, gr_dbname ()); fail_exit (E_GRP_UPDATE); } @@ -132,8 +133,7 @@ static void grp_update (void) */ if (is_shadow_grp && (sgr_locate (group_name) != NULL)) { if (sgr_remove (group_name) == 0) { - fprintf (stderr, - _("%s: cannot remove entry '%s' from %s\n"), + eprintf(_("%s: cannot remove entry '%s' from %s\n"), Prog, group_name, sgr_dbname ()); fail_exit (E_GRP_UPDATE); } @@ -155,8 +155,7 @@ static void close_files(const struct option_flags *flags) /* First, write the changes in the regular group database */ if (gr_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, gr_dbname ()); fail_exit (E_GRP_UPDATE); } @@ -177,8 +176,7 @@ static void close_files(const struct option_flags *flags) #ifdef SHADOWGRP if (is_shadow_grp) { if (sgr_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, sgr_dbname ()); fail_exit (E_GRP_UPDATE); } @@ -213,8 +211,7 @@ static void open_files(const struct option_flags *flags) /* First, lock the databases */ if (gr_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, gr_dbname ()); fail_exit (E_GRP_UPDATE); } @@ -222,8 +219,7 @@ static void open_files(const struct option_flags *flags) #ifdef SHADOWGRP if (is_shadow_grp) { if (sgr_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, sgr_dbname ()); fail_exit (E_GRP_UPDATE); } @@ -239,18 +235,14 @@ static void open_files(const struct option_flags *flags) /* An now open the databases */ if (gr_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), - Prog, gr_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, gr_dbname()); SYSLOG(LOG_WARN, "cannot open %s", gr_dbname()); fail_exit (E_GRP_UPDATE); } #ifdef SHADOWGRP if (is_shadow_grp) { if (sgr_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), - Prog, sgr_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, sgr_dbname()); SYSLOG(LOG_WARN, "cannot open %s", sgr_dbname()); fail_exit (E_GRP_UPDATE); } @@ -290,8 +282,7 @@ static void group_busy (gid_t gid) /* * Can't remove the group. */ - fprintf (stderr, - _("%s: cannot remove the primary group of user '%s'\n"), + eprintf(_("%s: cannot remove the primary group of user '%s'\n"), Prog, pwd->pw_name); fail_exit (E_GROUP_BUSY); } @@ -371,9 +362,7 @@ int main (int argc, char **argv) #endif if (atexit (do_cleanups) != 0) { - fprintf (stderr, - _("%s: Cannot setup cleanup service.\n"), - Prog); + eprintf(_("%s: Cannot setup cleanup service.\n"), Prog); fail_exit (1); } @@ -391,8 +380,7 @@ int main (int argc, char **argv) */ grp = prefix_getgrnam (group_name); /* local, no need for xgetgrnam */ if (NULL == grp) { - fprintf (stderr, - _("%s: group '%s' does not exist\n"), + eprintf(_("%s: group '%s' does not exist\n"), Prog, group_name); fail_exit (E_NOTFOUND); } diff --git a/src/groupmod.c b/src/groupmod.c index 0ad7a3073..f847c9939 100644 --- a/src/groupmod.c +++ b/src/groupmod.c @@ -26,6 +26,7 @@ #include "chkname.h" #include "defines.h" #include "groupio.h" +#include "io/fprintf.h" #include "nscd.h" #include "prototypes.h" #include "pwio.h" @@ -215,8 +216,7 @@ grp_update(void) */ ogrp = gr_locate (group_name); if (NULL == ogrp) { - fprintf (stderr, - _("%s: group '%s' does not exist in %s\n"), + eprintf(_("%s: group '%s' does not exist in %s\n"), Prog, group_name, gr_dbname ()); exit (E_GRP_UPDATE); } @@ -280,7 +280,7 @@ grp_update(void) ul = user_list; while (NULL != (u = strsep(&ul, ","))) { if (prefix_getpwnam(u) == NULL) { - fprintf(stderr, _("Invalid member username %s\n"), u); + eprintf(_("Invalid member username %s\n"), u); exit(E_GRP_UPDATE); } @@ -297,14 +297,12 @@ grp_update(void) * Write out the new group file entry. */ if (gr_update (&grp) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, gr_dbname (), grp.gr_name); exit (E_GRP_UPDATE); } if (nflg && (gr_remove (group_name) == 0)) { - fprintf (stderr, - _("%s: cannot remove entry '%s' from %s\n"), + eprintf(_("%s: cannot remove entry '%s' from %s\n"), Prog, grp.gr_name, gr_dbname ()); exit (E_GRP_UPDATE); } @@ -318,14 +316,12 @@ grp_update(void) * Write out the new shadow group entries as well. */ if (sgr_update (&sgrp) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, sgr_dbname (), sgrp.sg_namp); exit (E_GRP_UPDATE); } if (nflg && (sgr_remove (group_name) == 0)) { - fprintf (stderr, - _("%s: cannot remove entry '%s' from %s\n"), + eprintf(_("%s: cannot remove entry '%s' from %s\n"), Prog, group_name, sgr_dbname ()); exit (E_GRP_UPDATE); } @@ -359,8 +355,7 @@ static void check_new_gid (void) /* * Tell the user what they did wrong. */ - fprintf (stderr, - _("%s: GID '%lu' already exists\n"), + eprintf(_("%s: GID '%lu' already exists\n"), Prog, (unsigned long) group_newid); exit (E_GID_IN_USE); } @@ -383,17 +378,13 @@ check_new_name(void) } if (!is_valid_group_name(group_newname)) { - fprintf(stderr, - _("%s: invalid group name '%s'\n"), - Prog, group_newname); + eprintf(_("%s: invalid group name '%s'\n"), Prog, group_newname); exit(E_BAD_ARG); } /* local, no need for xgetgrnam */ if (prefix_getgrnam(group_newname) != NULL) { - fprintf(stderr, - _("%s: group '%s' already exists\n"), - Prog, group_newname); + eprintf(_("%s: group '%s' already exists\n"), Prog, group_newname); exit(E_NAME_IN_USE); } @@ -432,8 +423,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) gflg = true; if ( (get_gid(optarg, &group_newid) == -1) || (group_newid == (gid_t)-1)) { - fprintf (stderr, - _("%s: invalid group ID '%s'\n"), + eprintf(_("%s: invalid group ID '%s'\n"), Prog, optarg); exit (E_BAD_ARG); } @@ -490,8 +480,7 @@ static void close_files(const struct option_flags *flags) process_selinux = !flags->chroot && !flags->prefix; if (gr_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, gr_dbname ()); exit (E_GRP_UPDATE); } @@ -511,8 +500,7 @@ static void close_files(const struct option_flags *flags) if ( is_shadow_grp && (pflg || nflg || user_list)) { if (sgr_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, sgr_dbname ()); exit (E_GRP_UPDATE); } @@ -540,8 +528,7 @@ static void close_files(const struct option_flags *flags) if (gflg) { if (pw_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, pw_dbname ()); exit (E_GRP_UPDATE); } @@ -665,8 +652,7 @@ static void lock_files(const struct option_flags *flags) process_selinux = !flags->chroot && !flags->prefix; if (gr_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, gr_dbname ()); exit (E_GRP_UPDATE); } @@ -676,8 +662,7 @@ static void lock_files(const struct option_flags *flags) if ( is_shadow_grp && (pflg || nflg || user_list)) { if (sgr_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, sgr_dbname ()); exit (E_GRP_UPDATE); } @@ -687,8 +672,7 @@ static void lock_files(const struct option_flags *flags) if (gflg) { if (pw_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, pw_dbname ()); exit (E_GRP_UPDATE); } @@ -705,7 +689,7 @@ static void lock_files(const struct option_flags *flags) static void open_files (void) { if (gr_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, _("%s: cannot open %s\n"), Prog, gr_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, gr_dbname()); SYSLOG(LOG_WARN, "cannot open %s", gr_dbname()); exit (E_GRP_UPDATE); } @@ -714,9 +698,7 @@ static void open_files (void) if ( is_shadow_grp && (pflg || nflg || user_list)) { if (sgr_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), - Prog, sgr_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, sgr_dbname()); SYSLOG(LOG_WARN, "cannot open %s", sgr_dbname()); exit (E_GRP_UPDATE); } @@ -725,9 +707,7 @@ static void open_files (void) if (gflg) { if (pw_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), - Prog, pw_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, pw_dbname()); SYSLOG(LOG_WARN, "cannot open %s", gr_dbname()); exit (E_GRP_UPDATE); } @@ -745,16 +725,14 @@ void update_primary_groups (gid_t ogid, gid_t ngid) struct passwd npwd; lpwd = pw_locate (pwd->pw_name); if (NULL == lpwd) { - fprintf (stderr, - _("%s: user '%s' does not exist in %s\n"), + eprintf(_("%s: user '%s' does not exist in %s\n"), Prog, pwd->pw_name, pw_dbname ()); exit (E_GRP_UPDATE); } else { npwd = *lpwd; npwd.pw_gid = ngid; if (pw_update (&npwd) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, pw_dbname (), npwd.pw_name); exit (E_GRP_UPDATE); } @@ -788,9 +766,7 @@ int main (int argc, char **argv) #endif if (atexit (do_cleanups) != 0) { - fprintf (stderr, - _("%s: Cannot setup cleanup service.\n"), - Prog); + eprintf(_("%s: Cannot setup cleanup service.\n"), Prog); exit (E_CLEANUP_SERVICE); } @@ -806,8 +782,7 @@ int main (int argc, char **argv) */ grp = prefix_getgrnam (group_name); /* local, no need for xgetgrnam */ if (NULL == grp) { - fprintf (stderr, - _("%s: group '%s' does not exist\n"), + eprintf(_("%s: group '%s' does not exist\n"), Prog, group_name); exit (E_NOTFOUND); } else { diff --git a/src/grpck.c b/src/grpck.c index 170980053..73469201a 100644 --- a/src/grpck.c +++ b/src/grpck.c @@ -21,6 +21,7 @@ #include "commonio.h" #include "defines.h" #include "groupio.h" +#include "io/fprintf.h" #include "nscd.h" #include "prototypes.h" #include "shadow/gshadow/gshadow.h" @@ -105,7 +106,7 @@ static void fail_exit (int status, bool process_selinux) { if (gr_locked) { if (gr_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, gr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", gr_dbname()); /* continue */ } @@ -114,7 +115,7 @@ static void fail_exit (int status, bool process_selinux) #ifdef SHADOWGRP if (sgr_locked) { if (sgr_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sgr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sgr_dbname()); /* continue */ } @@ -227,7 +228,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) } if (sort_mode && read_only) { - fprintf (stderr, _("%s: -s and -r are incompatible\n"), Prog); + eprintf(_("%s: -s and -r are incompatible\n"), Prog); exit (E_USAGE); } @@ -277,8 +278,7 @@ static void open_files (bool process_selinux) */ if (!read_only) { if (gr_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, grp_file); fail_exit (E_CANT_LOCK, process_selinux); } @@ -286,8 +286,7 @@ static void open_files (bool process_selinux) #ifdef SHADOWGRP if (is_shadow) { if (sgr_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, sgr_file); fail_exit (E_CANT_LOCK, process_selinux); } @@ -301,8 +300,7 @@ static void open_files (bool process_selinux) * O_RDWR otherwise. */ if (gr_open (read_only ? O_RDONLY : O_CREAT | O_RDWR) == 0) { - fprintf (stderr, _("%s: cannot open %s\n"), Prog, - grp_file); + eprintf(_("%s: cannot open %s\n"), Prog, grp_file); if (use_system_grp_file) { SYSLOG(LOG_WARN, "cannot open %s", grp_file); } @@ -310,8 +308,7 @@ static void open_files (bool process_selinux) } #ifdef SHADOWGRP if (is_shadow && (sgr_open (read_only ? O_RDONLY : O_CREAT | O_RDWR) == 0)) { - fprintf (stderr, _("%s: cannot open %s\n"), Prog, - sgr_file); + eprintf(_("%s: cannot open %s\n"), Prog, sgr_file); if (use_system_sgr_file) { SYSLOG(LOG_WARN, "cannot open %s", sgr_file); } @@ -339,13 +336,13 @@ static void close_files(bool changed, const struct option_flags *flags) */ if (changed) { if (gr_close (process_selinux) == 0) { - fprintf (stderr, _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, grp_file); fail_exit (E_CANT_UPDATE, process_selinux); } #ifdef SHADOWGRP if (is_shadow && (sgr_close (process_selinux) == 0)) { - fprintf (stderr, _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, sgr_file); fail_exit (E_CANT_UPDATE, process_selinux); } @@ -358,7 +355,7 @@ static void close_files(bool changed, const struct option_flags *flags) #ifdef SHADOWGRP if (sgr_locked) { if (sgr_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sgr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sgr_dbname()); /* continue */ } @@ -367,7 +364,7 @@ static void close_files(bool changed, const struct option_flags *flags) #endif if (gr_locked) { if (gr_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, gr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", gr_dbname()); /* continue */ } @@ -642,8 +639,7 @@ static void check_grp_file(bool *errors, bool *changed, const struct option_flag *changed = true; if (sgr_update (&sg) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, sgr_dbname (), sg.sg_namp); fail_exit (E_CANT_UPDATE, process_selinux); } @@ -651,8 +647,7 @@ static void check_grp_file(bool *errors, bool *changed, const struct option_flag gr = *grp; gr.gr_passwd = SHADOW_PASSWD_STRING; /* XXX warning: const */ if (gr_update (&gr) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, gr_dbname (), gr.gr_name); fail_exit (E_CANT_UPDATE, process_selinux); } diff --git a/src/grpconv.c b/src/grpconv.c index 840a8c2d0..eface473a 100644 --- a/src/grpconv.c +++ b/src/grpconv.c @@ -29,6 +29,7 @@ #include "attr.h" /*@-exitarg@*/ #include "exitcodes.h" +#include "io/fprintf.h" #include "nscd.h" #include "prototypes.h" #include "string/strcmp/streq.h" @@ -64,7 +65,7 @@ static void fail_exit (int status, bool process_selinux) { if (gr_locked) { if (gr_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, gr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", gr_dbname()); /* continue */ } @@ -72,7 +73,7 @@ static void fail_exit (int status, bool process_selinux) if (sgr_locked) { if (sgr_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sgr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sgr_dbname()); /* continue */ } @@ -155,26 +156,24 @@ int main (int argc, char **argv) process_selinux = !flags.chroot; if (gr_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, gr_dbname ()); fail_exit (5, process_selinux); } gr_locked = true; if (gr_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, _("%s: cannot open %s\n"), Prog, gr_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, gr_dbname()); fail_exit (1, process_selinux); } if (sgr_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, sgr_dbname ()); fail_exit (5, process_selinux); } sgr_locked = true; if (sgr_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, _("%s: cannot open %s\n"), Prog, sgr_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, sgr_dbname()); fail_exit (1, process_selinux); } @@ -191,8 +190,7 @@ int main (int argc, char **argv) /* * This shouldn't happen (the entry exists) but... */ - fprintf (stderr, - _("%s: cannot remove entry '%s' from %s\n"), + eprintf(_("%s: cannot remove entry '%s' from %s\n"), Prog, sg->sg_namp, sgr_dbname ()); fail_exit (3, process_selinux); } @@ -229,8 +227,7 @@ int main (int argc, char **argv) sgent.sg_mem = gr->gr_mem; if (sgr_update (&sgent) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, sgr_dbname (), sgent.sg_namp); fail_exit (3, process_selinux); } @@ -238,34 +235,31 @@ int main (int argc, char **argv) grent = *gr; grent.gr_passwd = SHADOW_PASSWD_STRING; /* XXX warning: const */ if (gr_update (&grent) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, gr_dbname (), grent.gr_name); fail_exit (3, process_selinux); } } if (sgr_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, sgr_dbname ()); SYSLOG(LOG_ERR, "failure while writing changes to %s", sgr_dbname()); fail_exit (3, process_selinux); } if (gr_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, gr_dbname ()); SYSLOG(LOG_ERR, "failure while writing changes to %s", gr_dbname()); fail_exit (3, process_selinux); } if (sgr_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sgr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sgr_dbname()); /* continue */ } if (gr_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, gr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", gr_dbname()); /* continue */ } @@ -279,8 +273,7 @@ int main (int argc, char **argv) int main(MAYBE_UNUSED int _1, char **argv) { - fprintf (stderr, - "%s: not configured for shadow group support.\n", argv[0]); + eprintf("%s: not configured for shadow group support.\n", argv[0]); exit (1); } #endif /* !SHADOWGRP */ diff --git a/src/grpunconv.c b/src/grpunconv.c index 8f17398fd..c11a35bc8 100644 --- a/src/grpunconv.c +++ b/src/grpunconv.c @@ -27,6 +27,7 @@ #include "attr.h" /*@-exitarg@*/ #include "exitcodes.h" +#include "io/fprintf.h" #include "nscd.h" #include "prototypes.h" #include "sssd.h" @@ -63,7 +64,7 @@ static void fail_exit (int status, bool process_selinux) { if (gr_locked) { if (gr_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, gr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", gr_dbname()); /* continue */ } @@ -71,7 +72,7 @@ static void fail_exit (int status, bool process_selinux) if (sgr_locked) { if (sgr_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sgr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sgr_dbname()); /* continue */ } @@ -157,28 +158,24 @@ int main (int argc, char **argv) } if (gr_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, gr_dbname ()); fail_exit (5, process_selinux); } gr_locked = true; if (gr_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), Prog, gr_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, gr_dbname()); fail_exit (1, process_selinux); } if (sgr_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, sgr_dbname ()); fail_exit (5, process_selinux); } sgr_locked = true; if (sgr_open (O_RDONLY) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), Prog, sgr_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, sgr_dbname()); fail_exit (1, process_selinux); } @@ -194,8 +191,7 @@ int main (int argc, char **argv) grent = *gr; grent.gr_passwd = sg->sg_passwd; if (gr_update (&grent) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, gr_dbname (), grent.gr_name); fail_exit (3, process_selinux); } @@ -205,29 +201,26 @@ int main (int argc, char **argv) (void) sgr_close (process_selinux); /* was only open O_RDONLY */ if (gr_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, gr_dbname ()); SYSLOG(LOG_ERR, "failure while writing changes to %s", gr_dbname()); fail_exit (3, process_selinux); } if (unlink(_PATH_GSHADOW) != 0) { - fprintf (stderr, - _("%s: cannot delete %s\n"), - Prog, _PATH_GSHADOW); + eprintf(_("%s: cannot delete %s\n"), Prog, _PATH_GSHADOW); SYSLOG(LOG_ERR, "cannot delete %s", _PATH_GSHADOW); fail_exit (3, process_selinux); } if (gr_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, gr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", gr_dbname()); /* continue */ } if (sgr_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sgr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sgr_dbname()); /* continue */ } @@ -241,8 +234,7 @@ int main (int argc, char **argv) int main(MAYBE_UNUSED int _1, char **argv) { - fprintf (stderr, - "%s: not configured for shadow group support.\n", argv[0]); + eprintf("%s: not configured for shadow group support.\n", argv[0]); exit (1); } #endif /* !SHADOWGRP */ diff --git a/src/lastlog.c b/src/lastlog.c index 97ad355da..2cab4212f 100644 --- a/src/lastlog.c +++ b/src/lastlog.c @@ -122,8 +122,7 @@ static void print_one (/*@null@*/const struct passwd *pw) * empty entry in this case. */ if (fread(&ll, sizeof(ll), 1, lastlogfile) != 1) { - fprintf (stderr, - _("%s: Failed to get the entry for UID %lu\n"), + eprintf(_("%s: Failed to get the entry for UID %lu\n"), Prog, (unsigned long)pw->pw_uid); exit (EXIT_FAILURE); } @@ -187,8 +186,8 @@ static void print (void) lastlog_uid_max = getdef_ulong ("LASTLOG_UID_MAX", 0xFFFFFFFFUL); if ( (has_umin && umin > lastlog_uid_max) || (has_umax && umax > lastlog_uid_max)) { - fprintf (stderr, _("%s: Selected uid(s) are higher than LASTLOG_UID_MAX (%lu),\n" - "\tthe output might be incorrect.\n"), Prog, lastlog_uid_max); + eprintf(_("%s: Selected uid(s) are higher than LASTLOG_UID_MAX (%lu),\n" + "\tthe output might be incorrect.\n"), Prog, lastlog_uid_max); } if (uflg && has_umin && has_umax && (umin == umax)) { @@ -247,8 +246,7 @@ static void update_one (/*@null@*/const struct passwd *pw) #endif if (fwrite(&ll, sizeof(ll), 1, lastlogfile) != 1) { - fprintf (stderr, - _("%s: Failed to update the entry for UID %lu\n"), + eprintf(_("%s: Failed to update the entry for UID %lu\n"), Prog, (unsigned long)pw->pw_uid); exit (EXIT_FAILURE); } @@ -265,8 +263,8 @@ static void update (void) lastlog_uid_max = getdef_ulong ("LASTLOG_UID_MAX", 0xFFFFFFFFUL); if ( (has_umin && umin > lastlog_uid_max) || (has_umax && umax > lastlog_uid_max)) { - fprintf (stderr, _("%s: Selected uid(s) are higher than LASTLOG_UID_MAX (%lu),\n" - "\tthey will not be updated.\n"), Prog, lastlog_uid_max); + eprintf(_("%s: Selected uid(s) are higher than LASTLOG_UID_MAX (%lu),\n" + "\tthey will not be updated.\n"), Prog, lastlog_uid_max); return; } @@ -285,8 +283,7 @@ static void update (void) } if (fflush (lastlogfile) != 0 || fsync (fileno (lastlogfile)) != 0) { - fprintf (stderr, - _("%s: Failed to update the lastlog file\n"), + eprintf(_("%s: Failed to update the lastlog file\n"), Prog); exit (EXIT_FAILURE); } @@ -332,8 +329,7 @@ int main (int argc, char **argv) { unsigned long inverse_days; if (str2ul(&inverse_days, optarg) == -1) { - fprintf (stderr, - _("%s: invalid numeric argument '%s'\n"), + eprintf(_("%s: invalid numeric argument '%s'\n"), Prog, optarg); exit (EXIT_FAILURE); } @@ -360,8 +356,7 @@ int main (int argc, char **argv) { unsigned long days; if (str2ul(&days, optarg) == -1) { - fprintf (stderr, - _("%s: invalid numeric argument '%s'\n"), + eprintf(_("%s: invalid numeric argument '%s'\n"), Prog, optarg); exit (EXIT_FAILURE); } @@ -391,8 +386,7 @@ int main (int argc, char **argv) if (getrange(optarg, &umin, &has_umin, &umax, &has_umax) == -1) { - fprintf (stderr, - _("%s: Unknown user or range: %s\n"), + eprintf(_("%s: Unknown user or range: %s\n"), Prog, optarg); exit (EXIT_FAILURE); } @@ -410,20 +404,17 @@ int main (int argc, char **argv) } } if (argc > optind) { - fprintf (stderr, - _("%s: unexpected argument: %s\n"), + eprintf(_("%s: unexpected argument: %s\n"), Prog, argv[optind]); usage (EXIT_FAILURE); } if (Cflg && Sflg) { - fprintf (stderr, - _("%s: Option -C cannot be used together with option -S\n"), + eprintf(_("%s: Option -C cannot be used together with option -S\n"), Prog); usage (EXIT_FAILURE); } if ((Cflg || Sflg) && !uflg) { - fprintf (stderr, - _("%s: Options -C and -S require option -u to specify the user\n"), + eprintf(_("%s: Options -C and -S require option -u to specify the user\n"), Prog); usage (EXIT_FAILURE); } diff --git a/src/login.c b/src/login.c index 57ddaa66c..324be11e6 100644 --- a/src/login.c +++ b/src/login.c @@ -62,7 +62,7 @@ static pam_handle_t *pamh = NULL; #define PAM_FAIL_CHECK if (retcode != PAM_SUCCESS) { \ - fprintf(stderr,"\n%s\n",pam_strerror(pamh, retcode)); \ + eprintf("\n%s\n",pam_strerror(pamh, retcode)); \ SYSLOG(LOG_ERR,"%s",pam_strerror(pamh, retcode)); \ (void) pam_end(pamh, retcode); \ exit(1); \ @@ -136,11 +136,11 @@ static void exit_handler (int); */ static void usage (void) { - fprintf (stderr, _("Usage: %s [-p] [name]\n"), Prog); + eprintf(_("Usage: %s [-p] [name]\n"), Prog); if (!amroot) { exit (1); } - fprintf (stderr, _(" %s [-p] [-h host] [-f name]\n"), Prog); + eprintf(_(" %s [-p] [-h host] [-f name]\n"), Prog); exit (1); } @@ -177,14 +177,12 @@ static void setup_tty (void) * getdef_num cannot validate this. */ if (erasechar != (int) termio.c_cc[VERASE]) { - fprintf (stderr, - _("configuration error - cannot parse %s value: '%d'"), + eprintf(_("configuration error - cannot parse %s value: '%d'"), "ERASECHAR", erasechar); exit (1); } if (killchar != (int) termio.c_cc[VKILL]) { - fprintf (stderr, - _("configuration error - cannot parse %s value: '%d'"), + eprintf(_("configuration error - cannot parse %s value: '%d'"), "KILLCHAR", killchar); exit (1); } @@ -303,7 +301,7 @@ static void process_flags (int argc, char *const *argv) */ if ((fflg || hflg) && !amroot) { - fprintf (stderr, _("%s: Permission denied.\n"), Prog); + eprintf(_("%s: Permission denied.\n"), Prog); exit (1); } @@ -496,7 +494,7 @@ int main (int argc, char **argv) log_set_logfd(stderr); if (geteuid() != 0) { - fprintf (stderr, _("%s: Cannot possibly work without effective root\n"), Prog); + eprintf(_("%s: Cannot possibly work without effective root\n"), Prog); exit (1); } @@ -618,8 +616,7 @@ int main (int argc, char **argv) #ifdef USE_PAM retcode = pam_start (Prog, username, &conv, &pamh); if (retcode != PAM_SUCCESS) { - fprintf (stderr, - _("login: PAM Failure, aborting: %s\n"), + eprintf(_("login: PAM Failure, aborting: %s\n"), pam_strerror (pamh, retcode)); SYSLOG(LOG_ERR, "Couldn't initialize PAM: %s", pam_strerror(pamh, retcode)); exit (99); @@ -694,8 +691,7 @@ int main (int argc, char **argv) SYSLOG(LOG_NOTICE, "TOO MANY LOGIN TRIES (%u)%s FOR '%s'", failcount, fromhost, failent_user); - fprintf (stderr, - _("Maximum number of tries exceeded (%u)\n"), + eprintf(_("Maximum number of tries exceeded (%u)\n"), failcount); pam_end(pamh, retcode); exit(0); @@ -738,8 +734,7 @@ int main (int argc, char **argv) SYSLOG(LOG_NOTICE, "TOO MANY LOGIN TRIES (%u)%s FOR '%s'", failcount, fromhost, failent_user); - fprintf (stderr, - _("Maximum number of tries exceeded (%u)\n"), + eprintf(_("Maximum number of tries exceeded (%u)\n"), failcount); pam_end(pamh, retcode); exit(0); @@ -779,9 +774,7 @@ int main (int argc, char **argv) pwd = xgetpwnam (username); if (NULL == pwd) { SYSLOG(LOG_ERR, "cannot find user %s", failent_user); - fprintf (stderr, - _("Cannot find user (%s)\n"), - username); + eprintf(_("Cannot find user (%s)\n"), username); exit (1); } @@ -1115,7 +1108,7 @@ int main (int argc, char **argv) if (1 == initial_pid) { setsid(); if (ioctl(0, TIOCSCTTY, 1) != 0) { - fprintf (stderr, _("TIOCSCTTY failed on %s"), tty); + eprintf(_("TIOCSCTTY failed on %s"), tty); } } diff --git a/src/new_subid_range.c b/src/new_subid_range.c index 699014d1b..49aa160d4 100644 --- a/src/new_subid_range.c +++ b/src/new_subid_range.c @@ -16,10 +16,10 @@ static const char Prog[] = "new_subid_range"; static void usage(void) { - fprintf(stderr, "Usage: %s [-g] [-n] user count\n", Prog); - fprintf(stderr, " Find a subuid (or with -g, subgid) range for user\n"); - fprintf(stderr, " If -n is given, a new range will be created even if one exists\n"); - fprintf(stderr, " count defaults to 65536\n"); + eprintf("Usage: %s [-g] [-n] user count\n", Prog); + eprintf(" Find a subuid (or with -g, subgid) range for user\n"); + eprintf(" If -n is given, a new range will be created even if one exists\n"); + eprintf(" count defaults to 65536\n"); exit(EXIT_FAILURE); } @@ -55,7 +55,7 @@ int main(int argc, char *argv[]) ok = subid_grant_uid_range(&range, !makenew); if (!ok) { - fprintf(stderr, "Failed creating new id range\n"); + eprintf("Failed creating new id range\n"); exit(EXIT_FAILURE); } printf("Subuid range %lu:%lu\n", range.start, range.count); diff --git a/src/newgidmap.c b/src/newgidmap.c index 1faca380f..9442f2321 100644 --- a/src/newgidmap.c +++ b/src/newgidmap.c @@ -60,7 +60,7 @@ static void verify_ranges(struct passwd *pw, int ranges, mapping = mappings; for (idx = 0; idx < ranges; idx++, mapping++) { if (!verify_range(pw, mapping, allow_setgroups)) { - fprintf(stderr, _( "%s: gid range [%lu-%lu) -> [%lu-%lu) not allowed\n"), + eprintf(_( "%s: gid range [%lu-%lu) -> [%lu-%lu) not allowed\n"), Prog, mapping->upper, mapping->upper + mapping->count, @@ -73,7 +73,7 @@ static void verify_ranges(struct passwd *pw, int ranges, static void usage(void) { - fprintf(stderr, _("usage: %s [] [ ] ... \n"), Prog); + eprintf(_("usage: %s [] [ ] ... \n"), Prog); exit(EXIT_FAILURE); } @@ -100,7 +100,7 @@ static void write_setgroups(int proc_dir_fd, bool allow_setgroups) * code to exist. Emit a warning and bail on this. */ if (ENOENT == errno) { - fprintf(stderr, _("%s: kernel doesn't support setgroups restrictions\n"), Prog); + eprintf(_("%s: kernel doesn't support setgroups restrictions\n"), Prog); goto out; } fprinte(stderr, _("%s: couldn't open process setgroups"), Prog); @@ -175,9 +175,7 @@ int main(int argc, char **argv) /* Who am I? */ pw = get_my_pwent (); if (NULL == pw) { - fprintf (stderr, - _("%s: Cannot determine your user name.\n"), - Prog); + eprintf(_("%s: Cannot determine your user name.\n"), Prog); SYSLOG(LOG_WARN, "Cannot determine the user name of the caller (UID %lu)", (unsigned long) getuid()); return EXIT_FAILURE; @@ -197,7 +195,7 @@ int main(int argc, char **argv) (!getdef_bool("GRANT_AUX_GROUP_SUBIDS") && (getgid() != pw->pw_gid)) || (pw->pw_uid != st.st_uid) || (getgid() != st.st_gid)) { - fprintf(stderr, _( "%s: Target process is owned by a different user: uid:%lu pw_uid:%lu st_uid:%lu, gid:%lu pw_gid:%lu st_gid:%lu\n" ), + eprintf(_( "%s: Target process is owned by a different user: uid:%lu pw_uid:%lu st_uid:%lu, gid:%lu pw_gid:%lu st_gid:%lu\n" ), Prog, (unsigned long)getuid(), (unsigned long)pw->pw_uid, (unsigned long)st.st_uid, (unsigned long)getgid(), (unsigned long)pw->pw_gid, (unsigned long)st.st_gid); diff --git a/src/newgrp.c b/src/newgrp.c index b8f2e37f2..a2e63dd99 100644 --- a/src/newgrp.c +++ b/src/newgrp.c @@ -436,8 +436,7 @@ int main (int argc, char **argv) pwd = get_my_pwent (); if (NULL == pwd) { - fprintf (stderr, _("%s: Cannot determine your user name.\n"), - Prog); + eprintf(_("%s: Cannot determine your user name.\n"), Prog); #ifdef WITH_AUDIT audit_logger (AUDIT_CHGRP_ID, "changing", NULL, getuid (), SHADOW_AUDIT_FAILURE); @@ -480,8 +479,7 @@ int main (int argc, char **argv) */ if ((argc > 0) && (argv[0][0] != '-')) { if (!is_valid_group_name(argv[0])) { - fprintf ( - stderr, _("%s: provided group is not a valid group name\n"), + eprintf(_("%s: provided group is not a valid group name\n"), Prog); goto failure; } @@ -516,8 +514,7 @@ int main (int argc, char **argv) goto failure; } else if (argv[0] != NULL) { if (!is_valid_group_name(argv[0])) { - fprintf ( - stderr, _("%s: provided group is not a valid group name\n"), + eprintf(_("%s: provided group is not a valid group name\n"), Prog); goto failure; } @@ -532,8 +529,7 @@ int main (int argc, char **argv) */ grp = xgetgrgid (pwd->pw_gid); if (NULL == grp) { - fprintf (stderr, - _("%s: GID '%lu' does not exist\n"), + eprintf(_("%s: GID '%lu' does not exist\n"), Prog, (unsigned long) pwd->pw_gid); SYSLOG(LOG_CRIT, "GID '%lu' does not exist", (unsigned long) pwd->pw_gid); @@ -607,7 +603,7 @@ int main (int argc, char **argv) */ grp = getgrnam (group); /* local, no need for xgetgrnam */ if (NULL == grp) { - fprintf (stderr, _("%s: group '%s' does not exist\n"), Prog, group); + eprintf(_("%s: group '%s' does not exist\n"), Prog, group); goto failure; } diff --git a/src/newuidmap.c b/src/newuidmap.c index bf3b8730e..1867a73ce 100644 --- a/src/newuidmap.c +++ b/src/newuidmap.c @@ -55,7 +55,7 @@ static void verify_ranges(struct passwd *pw, int ranges, mapping = mappings; for (idx = 0; idx < ranges; idx++, mapping++) { if (!verify_range(pw, mapping)) { - fprintf(stderr, _( "%s: uid range [%lu-%lu) -> [%lu-%lu) not allowed\n"), + eprintf(_( "%s: uid range [%lu-%lu) -> [%lu-%lu) not allowed\n"), Prog, mapping->upper, mapping->upper + mapping->count, @@ -68,7 +68,7 @@ static void verify_ranges(struct passwd *pw, int ranges, static void usage(void) { - fprintf(stderr, _("usage: %s [|fd:] [ ] ... \n"), Prog); + eprintf(_("usage: %s [|fd:] [ ] ... \n"), Prog); exit(EXIT_FAILURE); } @@ -113,9 +113,7 @@ int main(int argc, char **argv) /* Who am I? */ pw = get_my_pwent (); if (NULL == pw) { - fprintf (stderr, - _("%s: Cannot determine your user name.\n"), - Prog); + eprintf(_("%s: Cannot determine your user name.\n"), Prog); SYSLOG(LOG_WARN, "Cannot determine the user name of the caller (UID %lu)", (unsigned long) getuid()); return EXIT_FAILURE; @@ -135,7 +133,7 @@ int main(int argc, char **argv) (!getdef_bool("GRANT_AUX_GROUP_SUBIDS") && (getgid() != pw->pw_gid)) || (pw->pw_uid != st.st_uid) || (getgid() != st.st_gid)) { - fprintf(stderr, _( "%s: Target process is owned by a different user: uid:%lu pw_uid:%lu st_uid:%lu, gid:%lu pw_gid:%lu st_gid:%lu\n" ), + eprintf(_( "%s: Target process is owned by a different user: uid:%lu pw_uid:%lu st_uid:%lu, gid:%lu pw_gid:%lu st_gid:%lu\n" ), Prog, (unsigned long)getuid(), (unsigned long)pw->pw_uid, (unsigned long)st.st_uid, (unsigned long)getgid(), (unsigned long)pw->pw_gid, (unsigned long)st.st_gid); diff --git a/src/newusers.c b/src/newusers.c index 094f26cd7..faed13f71 100644 --- a/src/newusers.c +++ b/src/newusers.c @@ -161,21 +161,21 @@ static void fail_exit (int code, bool process_selinux) { if (spw_locked) { if (spw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", spw_dbname()); /* continue */ } } if (pw_locked) { if (pw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname()); /* continue */ } } if (gr_locked) { if (gr_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, gr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", gr_dbname()); /* continue */ } @@ -183,7 +183,7 @@ static void fail_exit (int code, bool process_selinux) #ifdef SHADOWGRP if (sgr_locked) { if (sgr_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sgr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sgr_dbname()); /* continue */ } @@ -192,14 +192,14 @@ static void fail_exit (int code, bool process_selinux) #ifdef ENABLE_SUBIDS if (sub_uid_locked) { if (sub_uid_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sub_uid_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sub_uid_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sub_uid_dbname()); /* continue */ } } if (sub_gid_locked) { if (sub_gid_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sub_gid_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sub_gid_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sub_gid_dbname()); /* continue */ } @@ -243,9 +243,7 @@ static int add_group (const char *name, const char *gid, gid_t *ngid, uid_t uid) */ if (get_gid(gid, &grent.gr_gid) == -1) { - fprintf (stderr, - _("%s: invalid group ID '%s'\n"), - Prog, gid); + eprintf(_("%s: invalid group ID '%s'\n"), Prog, gid); return -1; } @@ -262,9 +260,7 @@ static int add_group (const char *name, const char *gid, gid_t *ngid, uid_t uid) /* Do not create groups with GID == (gid_t)-1 */ if (grent.gr_gid == (gid_t)-1) { - fprintf (stderr, - _("%s: invalid group ID '%s'\n"), - Prog, gid); + eprintf(_("%s: invalid group ID '%s'\n"), Prog, gid); return -1; } } else { @@ -289,9 +285,7 @@ static int add_group (const char *name, const char *gid, gid_t *ngid, uid_t uid) /* Check if this is a valid group name */ if (!is_valid_group_name(grent.gr_name)) { - fprintf (stderr, - _("%s: invalid group name '%s'\n"), - Prog, grent.gr_name); + eprintf(_("%s: invalid group name '%s'\n"), Prog, grent.gr_name); free (grent.gr_name); return -1; } @@ -307,8 +301,7 @@ static int add_group (const char *name, const char *gid, gid_t *ngid, uid_t uid) sg = sgr_locate (grent.gr_name); if (NULL != sg) { - fprintf (stderr, - _("%s: group '%s' is a shadow group, but does not exist in /etc/group\n"), + eprintf(_("%s: group '%s' is a shadow group, but does not exist in /etc/group\n"), Prog, grent.gr_name); return -1; } @@ -347,9 +340,7 @@ static int get_user_id (const char *uid, uid_t *nuid) { */ if (!streq(uid, "") && strisdigit_c(uid)) { if ((get_uid(uid, nuid) == -1) || (*nuid == (uid_t)-1)) { - fprintf (stderr, - _("%s: invalid user ID '%s'\n"), - Prog, uid); + eprintf(_("%s: invalid user ID '%s'\n"), Prog, uid); return -1; } } else { @@ -361,8 +352,7 @@ static int get_user_id (const char *uid, uid_t *nuid) { pwd = pw_locate (uid); if (pwd == NULL) { - fprintf (stderr, - _("%s: user '%s' does not exist\n"), + eprintf(_("%s: user '%s' does not exist\n"), Prog, uid); return -1; } @@ -387,13 +377,10 @@ static int add_user (const char *name, uid_t uid, gid_t gid) /* Check if this is a valid user name */ if (!is_valid_user_name(name, bflg)) { if (errno == EILSEQ) { - fprintf(stderr, - _("%s: invalid user name '%s': use --badname to ignore\n"), + eprintf(_("%s: invalid user name '%s': use --badname to ignore\n"), Prog, name); } else { - fprintf(stderr, - _("%s: invalid user name '%s'\n"), - Prog, name); + eprintf(_("%s: invalid user name '%s'\n"), Prog, name); } return -1; } @@ -664,8 +651,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) bad_s = 0; if (!crypt_method){ - fprintf(stderr, - _("%s: Provide '--crypt-method' before number of rounds\n"), + eprintf(_("%s: Provide '--crypt-method' before number of rounds\n"), Prog); usage (EXIT_FAILURE); } @@ -686,8 +672,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) } #endif /* USE_YESCRYPT */ if (bad_s != 0) { - fprintf (stderr, - _("%s: invalid numeric argument '%s'\n"), + eprintf(_("%s: invalid numeric argument '%s'\n"), Prog, optarg); usage (EXIT_FAILURE); } @@ -727,8 +712,7 @@ static void check_flags (void) { #ifndef USE_PAM if (sflg && !cflg) { - fprintf (stderr, - _("%s: %s flag is only allowed with the %s flag\n"), + eprintf(_("%s: %s flag is only allowed with the %s flag\n"), Prog, "-s", "-c"); usage (EXIT_FAILURE); } @@ -744,8 +728,7 @@ static void check_flags (void) && !streq(crypt_method, "YESCRYPT") #endif /* USE_YESCRYPT */ ) { - fprintf (stderr, - _("%s: unsupported crypt method: %s\n"), + eprintf(_("%s: unsupported crypt method: %s\n"), Prog, crypt_method); usage (EXIT_FAILURE); } @@ -765,24 +748,21 @@ static void open_files (bool process_selinux) * it gets locked, assume the others can be locked right away. */ if (pw_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, pw_dbname ()); fail_exit (EXIT_FAILURE, process_selinux); } pw_locked = true; if (is_shadow) { if (spw_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, spw_dbname ()); fail_exit (EXIT_FAILURE, process_selinux); } spw_locked = true; } if (gr_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, gr_dbname ()); fail_exit (EXIT_FAILURE, process_selinux); } @@ -790,8 +770,7 @@ static void open_files (bool process_selinux) #ifdef SHADOWGRP if (is_shadow_grp) { if (sgr_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, sgr_dbname ()); fail_exit (EXIT_FAILURE, process_selinux); } @@ -801,8 +780,7 @@ static void open_files (bool process_selinux) #ifdef ENABLE_SUBIDS if (is_sub_uid) { if (sub_uid_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, sub_uid_dbname ()); fail_exit (EXIT_FAILURE, process_selinux); } @@ -810,8 +788,7 @@ static void open_files (bool process_selinux) } if (is_sub_gid) { if (sub_gid_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, sub_gid_dbname ()); fail_exit (EXIT_FAILURE, process_selinux); } @@ -820,37 +797,33 @@ static void open_files (bool process_selinux) #endif /* ENABLE_SUBIDS */ if (pw_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, _("%s: cannot open %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, pw_dbname()); fail_exit (EXIT_FAILURE, process_selinux); } if (is_shadow && (spw_open (O_CREAT | O_RDWR) == 0)) { - fprintf (stderr, _("%s: cannot open %s\n"), Prog, spw_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, spw_dbname()); fail_exit (EXIT_FAILURE, process_selinux); } if (gr_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, _("%s: cannot open %s\n"), Prog, gr_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, gr_dbname()); fail_exit (EXIT_FAILURE, process_selinux); } #ifdef SHADOWGRP if (is_shadow_grp && (sgr_open (O_CREAT | O_RDWR) == 0)) { - fprintf (stderr, _("%s: cannot open %s\n"), Prog, sgr_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, sgr_dbname()); fail_exit (EXIT_FAILURE, process_selinux); } #endif #ifdef ENABLE_SUBIDS if (is_sub_uid) { if (sub_uid_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), - Prog, sub_uid_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, sub_uid_dbname()); fail_exit (EXIT_FAILURE, process_selinux); } } if (is_sub_gid) { if (sub_gid_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), - Prog, sub_gid_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, sub_gid_dbname()); fail_exit (EXIT_FAILURE, process_selinux); } } @@ -867,12 +840,12 @@ static void close_files(const struct option_flags *flags) process_selinux = !flags->chroot; if (pw_close (process_selinux) == 0) { - fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: failure while writing changes to %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failure while writing changes to %s", pw_dbname()); fail_exit (EXIT_FAILURE, process_selinux); } if (pw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname()); /* continue */ } @@ -880,16 +853,13 @@ static void close_files(const struct option_flags *flags) if (is_shadow) { if (spw_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, spw_dbname ()); SYSLOG(LOG_ERR, "failure while writing changes to %s", spw_dbname()); fail_exit (EXIT_FAILURE, process_selinux); } if (spw_unlock (process_selinux) == 0) { - fprintf (stderr, - _("%s: failed to unlock %s\n"), - Prog, spw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", spw_dbname()); /* continue */ } @@ -897,31 +867,26 @@ static void close_files(const struct option_flags *flags) } if (gr_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, gr_dbname ()); SYSLOG(LOG_ERR, "failure while writing changes to %s", gr_dbname()); fail_exit (EXIT_FAILURE, process_selinux); } #ifdef ENABLE_SUBIDS if (is_sub_uid && (sub_uid_close (process_selinux) == 0)) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), Prog, sub_uid_dbname ()); + eprintf(_("%s: failure while writing changes to %s\n"), Prog, sub_uid_dbname()); SYSLOG(LOG_ERR, "failure while writing changes to %s", sub_uid_dbname()); fail_exit (EXIT_FAILURE, process_selinux); } if (is_sub_gid && (sub_gid_close (process_selinux) == 0)) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), Prog, sub_gid_dbname ()); + eprintf(_("%s: failure while writing changes to %s\n"), Prog, sub_gid_dbname()); SYSLOG(LOG_ERR, "failure while writing changes to %s", sub_gid_dbname()); fail_exit (EXIT_FAILURE, process_selinux); } #endif /* ENABLE_SUBIDS */ if (gr_unlock (process_selinux) == 0) { - fprintf (stderr, - _("%s: failed to unlock %s\n"), - Prog, gr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, gr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", gr_dbname()); /* continue */ } @@ -930,16 +895,13 @@ static void close_files(const struct option_flags *flags) #ifdef SHADOWGRP if (is_shadow_grp) { if (sgr_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, sgr_dbname ()); SYSLOG(LOG_ERR, "failure while writing changes to %s", sgr_dbname()); fail_exit (EXIT_FAILURE, process_selinux); } if (sgr_unlock (process_selinux) == 0) { - fprintf (stderr, - _("%s: failed to unlock %s\n"), - Prog, sgr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sgr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sgr_dbname()); /* continue */ } @@ -949,7 +911,7 @@ static void close_files(const struct option_flags *flags) #ifdef ENABLE_SUBIDS if (is_sub_uid) { if (sub_uid_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sub_uid_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sub_uid_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sub_uid_dbname()); /* continue */ } @@ -957,7 +919,7 @@ static void close_files(const struct option_flags *flags) } if (is_sub_gid) { if (sub_gid_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sub_gid_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sub_gid_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sub_gid_dbname()); /* continue */ } @@ -1023,14 +985,12 @@ int main (int argc, char **argv) while (fgets_a(buf, stdin) != NULL) { line++; if (stpsep(buf, "\n") == NULL && feof(stdin) == 0) { - fprintf (stderr, _("%s: line %jd: line too long\n"), - Prog, line); + eprintf(_("%s: line %jd: line too long\n"), Prog, line); fail_exit (EXIT_FAILURE, process_selinux); } if (strsep2arr_a(buf, ":", fields) == -1) { - fprintf (stderr, _("%s: line %jd: invalid line\n"), - Prog, line); + eprintf(_("%s: line %jd: invalid line\n"), Prog, line); fail_exit (EXIT_FAILURE, process_selinux); } @@ -1040,15 +1000,13 @@ int main (int argc, char **argv) pw = pw_locate (fields[0]); /* local, no need for xgetpwnam */ if (NULL == pw && getpwnam(fields[0]) != NULL) { - fprintf (stderr, - _("%s: cannot update the entry of user %s (not in the passwd database)\n"), + eprintf(_("%s: cannot update the entry of user %s (not in the passwd database)\n"), Prog, fields[0]); fail_exit (EXIT_FAILURE, process_selinux); } if (NULL == pw && get_user_id(fields[2], &uid) != 0) { - fprintf (stderr, - _("%s: line %jd: can't create user\n"), + eprintf(_("%s: line %jd: can't create user\n"), Prog, line); fail_exit (EXIT_FAILURE, process_selinux); } @@ -1067,8 +1025,7 @@ int main (int argc, char **argv) */ if ( (NULL == pw) && (add_group (fields[0], fields[3], &gid, uid) != 0)) { - fprintf (stderr, - _("%s: line %jd: can't create group\n"), + eprintf(_("%s: line %jd: can't create group\n"), Prog, line); fail_exit (EXIT_FAILURE, process_selinux); } @@ -1082,8 +1039,7 @@ int main (int argc, char **argv) */ if ( (NULL == pw) && (add_user (fields[0], uid, gid) != 0)) { - fprintf (stderr, - _("%s: line %jd: can't create user\n"), + eprintf(_("%s: line %jd: can't create user\n"), Prog, line); fail_exit (EXIT_FAILURE, process_selinux); } @@ -1094,8 +1050,7 @@ int main (int argc, char **argv) */ pw = pw_locate (fields[0]); if (NULL == pw) { - fprintf (stderr, - _("%s: line %jd: user '%s' does not exist in %s\n"), + eprintf(_("%s: line %jd: user '%s' does not exist in %s\n"), Prog, line, fields[0], pw_dbname ()); fail_exit (EXIT_FAILURE, process_selinux); } @@ -1116,8 +1071,7 @@ int main (int argc, char **argv) passwords[nusers-1] = xstrdup(fields[1]); #endif /* USE_PAM */ if (!streq(fields[1], "") && add_passwd(&newpw, fields[1]) != 0) { - fprintf (stderr, - _("%s: line %jd: can't update password\n"), + eprintf(_("%s: line %jd: can't update password\n"), Prog, line); fail_exit (EXIT_FAILURE, process_selinux); } @@ -1139,8 +1093,7 @@ int main (int argc, char **argv) mode_t mode = getdef_num ("HOME_MODE", 0777 & ~getdef_num ("UMASK", GETDEF_DEFAULT_UMASK)); if (newpw.pw_dir[0] != '/') { - fprintf(stderr, - _("%s: line %jd: homedir must be an absolute path\n"), + eprintf(_("%s: line %jd: homedir must be an absolute path\n"), Prog, line); fail_exit (EXIT_FAILURE, process_selinux); } @@ -1163,8 +1116,7 @@ int main (int argc, char **argv) * Update the password entry with the new changes made. */ if (pw_update (&newpw) == 0) { - fprintf (stderr, - _("%s: line %jd: can't update entry\n"), + eprintf(_("%s: line %jd: can't update entry\n"), Prog, line); fail_exit (EXIT_FAILURE, process_selinux); } @@ -1178,16 +1130,13 @@ int main (int argc, char **argv) unsigned long sub_uid_count = 0; if (find_new_sub_uids(newpw.pw_uid, &sub_uid_start, &sub_uid_count) != 0) { - fprinte(stderr, - _("%s: can't find subordinate user range"), - Prog); + eprinte(_("%s: can't find subordinate user range"), Prog); SYSLOGE(LOG_WARN, "can't find subordinate user range"); fail_exit (EXIT_FAILURE, process_selinux); } if (sub_uid_add(fields[0], sub_uid_start, sub_uid_count) == 0) { - fprintf (stderr, - _("%s: failed to prepare new %s entry\n"), + eprintf(_("%s: failed to prepare new %s entry\n"), Prog, sub_uid_dbname ()); fail_exit (EXIT_FAILURE, process_selinux); } @@ -1200,15 +1149,12 @@ int main (int argc, char **argv) gid_t sub_gid_start = 0; unsigned long sub_gid_count = 0; if (find_new_sub_gids(newpw.pw_uid, &sub_gid_start, &sub_gid_count) != 0) { - fprinte(stderr, - _("%s: can't find subordinate group range"), - Prog); + eprinte(_("%s: can't find subordinate group range"), Prog); SYSLOGE(LOG_WARN, "can't find subordinate group range"); fail_exit (EXIT_FAILURE, process_selinux); } if (sub_gid_add(fields[0], sub_gid_start, sub_gid_count) == 0) { - fprintf (stderr, - _("%s: failed to prepare new %s entry\n"), + eprintf(_("%s: failed to prepare new %s entry\n"), Prog, sub_uid_dbname ()); fail_exit (EXIT_FAILURE, process_selinux); } @@ -1235,8 +1181,7 @@ int main (int argc, char **argv) if (streq(passwords[i], "")) continue; if (do_pam_passwd_non_interactive ("newusers", usernames[i], passwords[i]) != 0) { - fprintf (stderr, - _("%s: (line %jd, user %s) password not changed\n"), + eprintf(_("%s: (line %jd, user %s) password not changed\n"), Prog, lines[i], usernames[i]); exit (EXIT_FAILURE); } diff --git a/src/passwd.c b/src/passwd.c index 2dee1e006..67f2cb91f 100644 --- a/src/passwd.c +++ b/src/passwd.c @@ -220,8 +220,7 @@ static int new_password (const struct passwd *pw) strzero (cipher); SYSLOG(LOG_WARN, "incorrect password for %s", pw->pw_name); (void) sleep (1); - (void) fprintf (stderr, - _("Incorrect password for %s.\n"), + (void) eprintf(_("Incorrect password for %s.\n"), pw->pw_name); return -1; } @@ -371,8 +370,7 @@ static void check_password (const struct passwd *pw, const struct spwd *sp, bool */ if ( strprefix(sp->sp_pwdp, "!") || (exp_status > 1)) { - (void) fprintf (stderr, - _("The password for %s cannot be changed.\n"), + eprintf(_("The password for %s cannot be changed.\n"), sp->sp_namp); SYSLOG(LOG_WARN, "password locked for '%s'", sp->sp_namp); closelog (); @@ -413,7 +411,7 @@ static void print_status (const struct passwd *pw) (void) printf ("%s %s\n", pw->pw_name, pw_status (pw->pw_passwd)); } else { - (void) fprintf(stderr, _("%s: malformed password data obtained for user %s\n"), + (void) eprintf(_("%s: malformed password data obtained for user %s\n"), Prog, pw->pw_name); } } @@ -425,7 +423,7 @@ fail_exit (int status, bool process_selinux) { if (spw_locked) { if (spw_unlock (process_selinux) == 0) { - (void) fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", spw_dbname()); /* continue */ } @@ -433,7 +431,7 @@ fail_exit (int status, bool process_selinux) if (pw_locked) { if (pw_unlock (process_selinux) == 0) { - (void) fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname()); /* continue */ } @@ -446,7 +444,7 @@ NORETURN static void oom (bool process_selinux) { - (void) fprintf (stderr, _("%s: out of memory\n"), Prog); + eprintf(_("%s: out of memory\n"), Prog); fail_exit (E_FAILURE, process_selinux); } @@ -458,16 +456,12 @@ oom (bool process_selinux) static void open_files(bool process_selinux) { if (pw_lock () == 0) { - (void) fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), - Prog, pw_dbname ()); + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, pw_dbname()); exit (E_PWDBUSY); } pw_locked = true; if (pw_open (O_CREAT | O_RDWR) == 0) { - (void) fprintf (stderr, - _("%s: cannot open %s\n"), - Prog, pw_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, pw_dbname()); SYSLOG(LOG_WARN, "cannot open %s", pw_dbname()); fail_exit (E_MISSING, process_selinux); } @@ -475,16 +469,12 @@ static void open_files(bool process_selinux) if (!spw_file_present ()) return; if (spw_lock () == 0) { - (void) fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), - Prog, spw_dbname ()); + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, spw_dbname()); fail_exit (E_PWDBUSY, process_selinux); } spw_locked = true; if (spw_open (O_CREAT | O_RDWR) == 0) { - (void) fprintf (stderr, - _("%s: cannot open %s\n"), - Prog, spw_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, spw_dbname()); SYSLOG(LOG_WARN, "cannot open %s", spw_dbname()); fail_exit (E_FAILURE, process_selinux); } @@ -500,32 +490,24 @@ static void close_files(bool process_selinux) { if (spw_locked) { if (spw_close (process_selinux) == 0) { - (void) fprintf (stderr, - _("%s: failure while writing changes to %s\n"), - Prog, spw_dbname ()); + eprintf(_("%s: failure while writing changes to %s\n"), Prog, spw_dbname()); SYSLOG(LOG_ERR, "failure while writing changes to %s", spw_dbname()); fail_exit (E_FAILURE, process_selinux); } if (spw_unlock (process_selinux) == 0) { - (void) fprintf (stderr, - _("%s: failed to unlock %s\n"), - Prog, spw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", spw_dbname()); /* continue */ } spw_locked = false; } if (pw_close (process_selinux) == 0) { - (void) fprintf (stderr, - _("%s: failure while writing changes to %s\n"), - Prog, pw_dbname ()); + eprintf(_("%s: failure while writing changes to %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failure while writing changes to %s", pw_dbname()); fail_exit (E_FAILURE, process_selinux); } if (pw_unlock (process_selinux) == 0) { - (void) fprintf (stderr, - _("%s: failed to unlock %s\n"), - Prog, pw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname()); /* continue */ } @@ -546,9 +528,8 @@ static char *update_crypt_pw (char *cp, bool process_selinux) if (uflg && strprefix(cp, "!")) { if (cp[1] == '\0') { - (void) fprintf (stderr, - _("%s: unlocking the password would result in a passwordless account.\n" - "You should set a password with usermod -p to unlock the password of this account.\n"), + (void) eprintf(_("%s: unlocking the password would result in a passwordless account.\n" + "You should set a password with usermod -p to unlock the password of this account.\n"), Prog); fail_exit (E_FAILURE, process_selinux); } else { @@ -580,8 +561,7 @@ static void update_noshadow(bool process_selinux) pw = pw_locate (name); if (NULL == pw) { - (void) fprintf (stderr, - _("%s: user '%s' does not exist in %s\n"), + (void) eprintf(_("%s: user '%s' does not exist in %s\n"), Prog, name, pw_dbname ()); fail_exit (E_NOPERM, process_selinux); } @@ -613,8 +593,7 @@ static void update_noshadow(bool process_selinux) } #endif /* WITH_AUDIT */ if (ret == 0) { - (void) fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + (void) eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, pw_dbname (), npw->pw_name); fail_exit (E_FAILURE, process_selinux); } @@ -716,8 +695,7 @@ static void update_shadow(bool process_selinux) } #endif /* WITH_AUDIT */ if (ret == 0) { - (void) fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + (void) eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, spw_dbname (), nsp->sp_namp); fail_exit (E_FAILURE, process_selinux); } @@ -836,8 +814,7 @@ main(int argc, char **argv) if (a2sl(&inact, optarg, NULL, 0, -1, LONG_MAX) == -1) { - fprintf (stderr, - _("%s: invalid numeric argument '%s'\n"), + eprintf(_("%s: invalid numeric argument '%s'\n"), Prog, optarg); usage (E_BAD_ARG); } @@ -859,8 +836,7 @@ main(int argc, char **argv) /* -r repository (files|nis|nisplus) */ /* only "files" supported for now */ if (!streq(optarg, "files")) { - fprintf (stderr, - _("%s: repository %s not supported\n"), + eprintf(_("%s: repository %s not supported\n"), Prog, optarg); exit (E_BAD_ARG); } @@ -882,8 +858,7 @@ main(int argc, char **argv) if (a2sl(&warn, optarg, NULL, 0, -1, LONG_MAX) == -1) { - (void) fprintf (stderr, - _("%s: invalid numeric argument '%s'\n"), + (void) eprintf(_("%s: invalid numeric argument '%s'\n"), Prog, optarg); usage (E_BAD_ARG); } @@ -894,8 +869,7 @@ main(int argc, char **argv) if (a2sl(&age_max, optarg, NULL, 0, -1, LONG_MAX) == -1) { - (void) fprintf (stderr, - _("%s: invalid numeric argument '%s'\n"), + (void) eprintf(_("%s: invalid numeric argument '%s'\n"), Prog, optarg); usage (E_BAD_ARG); } @@ -904,8 +878,7 @@ main(int argc, char **argv) break; case 's': if (!amroot) { - (void) fprintf (stderr, - _("%s: only root can use --stdin/-s option\n"), + (void) eprintf(_("%s: only root can use --stdin/-s option\n"), Prog); usage (E_BAD_ARG); } @@ -925,9 +898,7 @@ main(int argc, char **argv) */ pw = get_my_pwent (); if (NULL == pw) { - (void) fprintf (stderr, - _("%s: Cannot determine your user name.\n"), - Prog); + (void) eprintf(_("%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); @@ -935,7 +906,7 @@ main(int argc, char **argv) myname = xstrdup (pw->pw_name); if (optind < argc) { if (!is_valid_user_name(argv[optind], true) && !is_valid_upn(argv[optind], true)) { - fprintf (stderr, _("%s: Provided user name is not a valid name\n"), Prog); + eprintf(_("%s: Provided user name is not a valid name\n"), Prog); fail_exit (E_NOPERM, process_selinux); } name = argv[optind]; @@ -959,9 +930,7 @@ main(int argc, char **argv) usage (E_USAGE); } if (!amroot) { - (void) fprintf (stderr, - _("%s: Permission denied.\n"), - Prog); + (void) eprintf(_("%s: Permission denied.\n"), Prog); exit (E_NOPERM); } prefix_setpwent (); @@ -1007,15 +976,13 @@ main(int argc, char **argv) NULL, getuid(), SHADOW_AUDIT_FAILURE); #endif /* WITH_AUDIT */ - (void) fprintf (stderr, _("%s: Permission denied.\n"), Prog); + (void) eprintf(_("%s: Permission denied.\n"), Prog); exit (E_NOPERM); } pw = xprefix_getpwnam (name); if (NULL == pw) { - (void) fprintf (stderr, - _("%s: user '%s' does not exist\n"), - Prog, name); + (void) eprintf(_("%s: user '%s' does not exist\n"), Prog, name); exit (E_NOPERM); } #ifdef WITH_SELINUX @@ -1031,8 +998,7 @@ main(int argc, char **argv) SYSLOG(LOG_ALERT, "root is not authorized by SELinux to change the password of %s", name); - (void) fprintf(stderr, - _("%s: root is not authorized by SELinux to change the password of %s\n"), + (void) eprintf(_("%s: root is not authorized by SELinux to change the password of %s\n"), Prog, name); exit (E_NOPERM); } @@ -1049,8 +1015,7 @@ main(int argc, char **argv) NULL, pw->pw_uid, SHADOW_AUDIT_FAILURE); #endif /* WITH_AUDIT */ - (void) fprintf (stderr, - _("%s: You may not view or modify password information for %s.\n"), + (void) eprintf(_("%s: You may not view or modify password information for %s.\n"), Prog, name); SYSLOG(LOG_WARN, "can't view or modify password information for %s", @@ -1071,8 +1036,7 @@ main(int argc, char **argv) sp = prefix_getspnam (name); /* !use_pam, no need for xprefix_getspnam */ if (NULL == sp) { if (errno == EACCES) { - (void) fprintf (stderr, - _("%s: Permission denied.\n"), + (void) eprintf(_("%s: Permission denied.\n"), Prog); exit (E_NOPERM); } @@ -1101,8 +1065,7 @@ main(int argc, char **argv) } if (new_password (pw) != 0) { - (void) fprintf (stderr, - _("The password for %s is unchanged.\n"), + (void) eprintf(_("The password for %s is unchanged.\n"), name); closelog (); exit (E_NOPERM); diff --git a/src/pwck.c b/src/pwck.c index 954cf3a8a..3f1dec5f1 100644 --- a/src/pwck.c +++ b/src/pwck.c @@ -22,6 +22,7 @@ #include "commonio.h" #include "defines.h" #include "getdef.h" +#include "io/fprintf.h" #include "nscd.h" #include "prototypes.h" #include "pwio.h" @@ -91,7 +92,7 @@ static void fail_exit (int code, bool process_selinux) { if (spw_locked) { if (spw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname()); if (use_system_spw_file) { SYSLOG(LOG_ERR, "failed to unlock %s", spw_dbname()); } @@ -101,7 +102,7 @@ static void fail_exit (int code, bool process_selinux) if (pw_locked) { if (pw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname()); if (use_system_pw_file) { SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname()); } @@ -202,7 +203,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) } if (sort_mode && read_only) { - fprintf (stderr, _("%s: -s and -r are incompatible\n"), Prog); + eprintf(_("%s: -s and -r are incompatible\n"), Prog); exit (E_USAGE); } @@ -224,8 +225,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) if ((optind + 2) == argc) { #ifdef WITH_TCB if (getdef_bool ("USE_TCB")) { - fprintf (stderr, - _("%s: no alternative shadow file allowed when USE_TCB is enabled.\n"), + eprintf(_("%s: no alternative shadow file allowed when USE_TCB is enabled.\n"), Prog); usage (E_USAGE); } @@ -259,16 +259,14 @@ static void open_files(const struct option_flags *flags) */ if (!read_only) { if (pw_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, pw_dbname ()); fail_exit (E_CANTLOCK, process_selinux); } pw_locked = true; if (is_shadow && !use_tcb) { if (spw_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, spw_dbname ()); fail_exit (E_CANTLOCK, process_selinux); } @@ -281,8 +279,7 @@ static void open_files(const struct option_flags *flags) * otherwise. */ if (pw_open (read_only ? O_RDONLY : O_RDWR) == 0) { - fprintf (stderr, _("%s: cannot open %s\n"), - Prog, pw_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, pw_dbname()); if (use_system_pw_file) { SYSLOG(LOG_WARN, "cannot open %s", pw_dbname()); } @@ -290,8 +287,7 @@ static void open_files(const struct option_flags *flags) } if (is_shadow && !use_tcb) { if (spw_open (read_only ? O_RDONLY : O_RDWR) == 0) { - fprintf (stderr, _("%s: cannot open %s\n"), - Prog, spw_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, spw_dbname()); if (use_system_spw_file) { SYSLOG(LOG_WARN, "cannot open %s", spw_dbname()); } @@ -320,8 +316,7 @@ static void close_files(bool changed, const struct option_flags *flags) */ if (changed) { if (pw_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, pw_dbname ()); if (use_system_pw_file) { SYSLOG(LOG_ERR, @@ -331,8 +326,7 @@ static void close_files(bool changed, const struct option_flags *flags) fail_exit (E_CANTUPDATE, process_selinux); } if (spw_opened && (spw_close (process_selinux) == 0)) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, spw_dbname ()); if (use_system_spw_file) { SYSLOG(LOG_ERR, @@ -349,8 +343,7 @@ static void close_files(bool changed, const struct option_flags *flags) */ if (spw_locked) { if (spw_unlock (process_selinux) == 0) { - fprintf (stderr, - _("%s: failed to unlock %s\n"), + eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname ()); if (use_system_spw_file) { SYSLOG(LOG_ERR, "failed to unlock %s", spw_dbname()); @@ -361,8 +354,7 @@ static void close_files(bool changed, const struct option_flags *flags) spw_locked = false; if (pw_locked) { if (pw_unlock (process_selinux) == 0) { - fprintf (stderr, - _("%s: failed to unlock %s\n"), + eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname ()); if (use_system_pw_file) { SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname()); @@ -581,20 +573,17 @@ static void check_pw_file(bool *errors, bool *changed, const struct option_flags } if (spw_lock () == 0) { *errors = true; - fprintf (stderr, - _("%s: cannot lock %s.\n"), + eprintf(_("%s: cannot lock %s.\n"), Prog, spw_dbname ()); continue; } spw_locked = true; if (spw_open (read_only ? O_RDONLY : O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), + eprintf(_("%s: cannot open %s\n"), Prog, spw_dbname ()); *errors = true; if (spw_unlock (process_selinux) == 0) { - fprintf (stderr, - _("%s: failed to unlock %s\n"), + eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname ()); if (use_system_spw_file) { SYSLOG(LOG_ERR, @@ -638,8 +627,7 @@ static void check_pw_file(bool *errors, bool *changed, const struct option_flags *changed = true; if (spw_update (&sp) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, spw_dbname (), sp.sp_namp); fail_exit (E_CANTUPDATE, process_selinux); } @@ -647,8 +635,7 @@ static void check_pw_file(bool *errors, bool *changed, const struct option_flags pw = *pwd; pw.pw_passwd = SHADOW_PASSWD_STRING; /* XXX warning: const */ if (pw_update (&pw) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, pw_dbname (), pw.pw_name); fail_exit (E_CANTUPDATE, process_selinux); } @@ -668,8 +655,7 @@ static void check_pw_file(bool *errors, bool *changed, const struct option_flags #ifdef WITH_TCB if (getdef_bool ("USE_TCB") && spw_locked) { if (spw_opened && (spw_close (process_selinux) == 0)) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, spw_dbname ()); if (use_system_spw_file) { SYSLOG(LOG_ERR, @@ -680,8 +666,7 @@ static void check_pw_file(bool *errors, bool *changed, const struct option_flags spw_opened = false; } if (spw_unlock (process_selinux) == 0) { - fprintf (stderr, - _("%s: failed to unlock %s\n"), + eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname ()); if (use_system_spw_file) { SYSLOG(LOG_ERR, "failed to unlock %s", @@ -872,15 +857,13 @@ int main (int argc, char **argv) if (sort_mode) { if (pw_sort () != 0) { - fprintf (stderr, - _("%s: cannot sort entries in %s\n"), + eprintf(_("%s: cannot sort entries in %s\n"), Prog, pw_dbname ()); fail_exit (E_CANTSORT, process_selinux); } if (is_shadow) { if (spw_sort () != 0) { - fprintf (stderr, - _("%s: cannot sort entries in %s\n"), + eprintf(_("%s: cannot sort entries in %s\n"), Prog, spw_dbname ()); fail_exit (E_CANTSORT, process_selinux); } diff --git a/src/pwconv.c b/src/pwconv.c index d6fefdedd..99ad5a1cc 100644 --- a/src/pwconv.c +++ b/src/pwconv.c @@ -47,6 +47,7 @@ #include "defines.h" #include "getdef.h" +#include "io/fprintf.h" #include "nscd.h" #include "prototypes.h" #include "pwio.h" @@ -89,7 +90,7 @@ static void fail_exit (int status, bool process_selinux) { if (pw_locked) { if (pw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname()); /* continue */ } @@ -97,7 +98,7 @@ static void fail_exit (int status, bool process_selinux) if (spw_locked) { if (spw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", spw_dbname()); /* continue */ } @@ -181,34 +182,30 @@ int main (int argc, char **argv) #ifdef WITH_TCB if (getdef_bool("USE_TCB")) { - fprintf (stderr, _("%s: can't work with tcb enabled\n"), Prog); + eprintf(_("%s: can't work with tcb enabled\n"), Prog); exit (E_FAILURE); } #endif /* WITH_TCB */ if (pw_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, pw_dbname ()); fail_exit (E_PWDBUSY, process_selinux); } pw_locked = true; if (pw_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, pw_dbname()); fail_exit (E_MISSING, process_selinux); } if (spw_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, spw_dbname ()); fail_exit (E_PWDBUSY, process_selinux); } spw_locked = true; if (spw_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), Prog, spw_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, spw_dbname()); fail_exit (E_FAILURE, process_selinux); } @@ -225,8 +222,7 @@ int main (int argc, char **argv) /* * This shouldn't happen (the entry exists) but... */ - fprintf (stderr, - _("%s: cannot remove entry '%s' from %s\n"), + eprintf(_("%s: cannot remove entry '%s' from %s\n"), Prog, sp->sp_namp, spw_dbname ()); fail_exit (E_FAILURE, process_selinux); } @@ -266,8 +262,7 @@ int main (int argc, char **argv) spent.sp_lstchg = -1; } if (spw_update (&spent) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, spw_dbname (), spent.sp_namp); fail_exit (E_FAILURE, process_selinux); } @@ -276,23 +271,20 @@ int main (int argc, char **argv) pwent = *pw; pwent.pw_passwd = SHADOW_PASSWD_STRING; /* XXX warning: const */ if (pw_update (&pwent) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, pw_dbname (), pwent.pw_name); fail_exit (E_FAILURE, process_selinux); } } if (spw_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, spw_dbname ()); SYSLOG(LOG_ERR, "failure while writing changes to %s", spw_dbname()); fail_exit (E_FAILURE, process_selinux); } if (pw_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, pw_dbname ()); SYSLOG(LOG_ERR, "failure while writing changes to %s", pw_dbname()); fail_exit (E_FAILURE, process_selinux); @@ -301,21 +293,20 @@ int main (int argc, char **argv) /* /etc/passwd- (backup file) */ errno = 0; if ((chmod (PASSWD_FILE "-", 0600) != 0) && (errno != ENOENT)) { - fprintf (stderr, - _("%s: failed to change the mode of %s to 0600\n"), + eprintf(_("%s: failed to change the mode of %s to 0600\n"), Prog, PASSWD_FILE "-"); SYSLOG(LOG_ERR, "failed to change the mode of %s to 0600", PASSWD_FILE "-"); /* continue */ } if (pw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname()); /* continue */ } if (spw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", spw_dbname()); /* continue */ } diff --git a/src/pwunconv.c b/src/pwunconv.c index a78417432..4a42344f5 100644 --- a/src/pwunconv.c +++ b/src/pwunconv.c @@ -22,6 +22,7 @@ /*@-exitarg@*/ #include "exitcodes.h" #include "getdef.h" +#include "io/fprintf.h" #include "nscd.h" #include "prototypes.h" #include "pwio.h" @@ -51,14 +52,14 @@ static void fail_exit (int status, bool process_selinux) { if (spw_locked) { if (spw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", spw_dbname()); /* continue */ } } if (pw_locked) { if (pw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname()); /* continue */ } @@ -140,7 +141,7 @@ int main (int argc, char **argv) #ifdef WITH_TCB if (getdef_bool("USE_TCB")) { - fprintf (stderr, _("%s: can't work with tcb enabled\n"), Prog); + eprintf(_("%s: can't work with tcb enabled\n"), Prog); exit (1); } #endif /* WITH_TCB */ @@ -151,30 +152,24 @@ int main (int argc, char **argv) } if (pw_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, pw_dbname ()); fail_exit (5, process_selinux); } pw_locked = true; if (pw_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), - Prog, pw_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, pw_dbname()); fail_exit (1, process_selinux); } if (spw_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, spw_dbname ()); fail_exit (5, process_selinux); } spw_locked = true; if (spw_open (O_RDONLY) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), - Prog, spw_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, spw_dbname()); fail_exit (1, process_selinux); } @@ -195,8 +190,7 @@ int main (int argc, char **argv) } if (pw_update (&pwent) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, pw_dbname (), pwent.pw_name); fail_exit (3, process_selinux); } @@ -205,27 +199,25 @@ int main (int argc, char **argv) (void) spw_close (process_selinux); /* was only open O_RDONLY */ if (pw_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, pw_dbname ()); SYSLOG(LOG_ERR, "failure while writing changes to %s", pw_dbname()); fail_exit (3, process_selinux); } if (unlink (SHADOW) != 0) { - fprintf (stderr, - _("%s: cannot delete %s\n"), Prog, SHADOW); + eprintf(_("%s: cannot delete %s\n"), Prog, SHADOW); SYSLOG(LOG_ERR, "cannot delete %s", SHADOW); fail_exit (3, process_selinux); } if (spw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", spw_dbname()); /* continue */ } if (pw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname()); /* continue */ } diff --git a/src/su.c b/src/su.c index e4dc72098..cc74ab3a7 100644 --- a/src/su.c +++ b/src/su.c @@ -53,6 +53,7 @@ /*@-exitarg@*/ #include "exitcodes.h" #include "getdef.h" +#include "io/fprintf.h" #ifdef USE_PAM #include "pam_defs.h" #endif /* USE_PAM */ @@ -294,9 +295,7 @@ static void prepare_pam_close_session (void) sigemptyset (&action.sa_mask); action.sa_flags = 0; if (0 == caught && sigaction (SIGCHLD, &action, NULL) != 0) { - fprintf (stderr, - _("%s: signal masking malfunction\n"), - Prog); + eprintf(_("%s: signal masking malfunction\n"), Prog); SYSLOG(LOG_WARN, "Will not execute %s", shellstr); closelog (); exit (1); @@ -307,9 +306,7 @@ static void prepare_pam_close_session (void) if (pid_child == 0) { /* child shell */ return; /* Only the child will return from pam_create_session */ } else if ((pid_t)-1 == pid_child) { - (void) fprintf (stderr, - _("%s: Cannot fork user shell\n"), - Prog); + (void) eprintf(_("%s: Cannot fork user shell\n"), Prog); SYSLOG(LOG_WARN, "Cannot execute %s", shellstr); closelog (); exit (1); @@ -319,9 +316,7 @@ static void prepare_pam_close_session (void) /* parent only */ sigfillset (&ourset); if (sigprocmask (SIG_BLOCK, &ourset, NULL) != 0) { - (void) fprintf (stderr, - _("%s: signal malfunction\n"), - Prog); + (void) eprintf(_("%s: signal malfunction\n"), Prog); caught = SIGTERM; } if (0 == caught) { @@ -344,9 +339,7 @@ static void prepare_pam_close_session (void) || (sigaction (SIGTSTP, &action, NULL) != 0))) || (sigprocmask (SIG_UNBLOCK, &ourset, NULL) != 0) ) { - fprintf (stderr, - _("%s: signal masking malfunction\n"), - Prog); + eprintf(_("%s: signal masking malfunction\n"), Prog); caught = SIGTERM; } } @@ -401,7 +394,7 @@ static void prepare_pam_close_session (void) * so it's time to block all of them. */ sigfillset (&ourset); if (sigprocmask (SIG_BLOCK, &ourset, NULL) != 0) { - fprintf (stderr, _("%s: signal masking malfunction\n"), Prog); + eprintf(_("%s: signal masking malfunction\n"), Prog); kill_child(pid_child); /* Never reached (exit called). */ } @@ -430,7 +423,7 @@ static void prepare_pam_close_session (void) ret = pam_close_session (pamh, 0); if (PAM_SUCCESS != ret) { SYSLOG(LOG_ERR, "pam_close_session: %s", pam_strerror(pamh, ret)); - fprintf (stderr, _("%s: %s\n"), Prog, pam_strerror (pamh, ret)); + eprintf(_("%s: %s\n"), Prog, pam_strerror(pamh, ret)); } (void) pam_setcred (pamh, PAM_DELETE_CRED); @@ -475,7 +468,7 @@ static void check_perms_pam (const struct passwd *pw) if (PAM_SUCCESS != ret) { SYSLOG(pw->pw_uid ? LOG_NOTICE : LOG_WARN, "pam_authenticate: %s", pam_strerror(pamh, ret)); - fprintf (stderr, _("%s: %s\n"), Prog, pam_strerror (pamh, ret)); + eprintf(_("%s: %s\n"), Prog, pam_strerror(pamh, ret)); (void) pam_end (pamh, ret); su_failure (caller_tty, 0 == pw->pw_uid); } @@ -483,25 +476,21 @@ static void check_perms_pam (const struct passwd *pw) ret = pam_acct_mgmt (pamh, 0); if (PAM_SUCCESS != ret) { if (caller_is_root) { - fprintf (stderr, - _("%s: %s\n(Ignored)\n"), + eprintf(_("%s: %s\n(Ignored)\n"), Prog, pam_strerror (pamh, ret)); } else if (PAM_NEW_AUTHTOK_REQD == ret) { ret = pam_chauthtok (pamh, PAM_CHANGE_EXPIRED_AUTHTOK); if (PAM_SUCCESS != ret) { SYSLOG(LOG_ERR, "pam_chauthtok: %s", pam_strerror(pamh, ret)); - fprintf (stderr, - _("%s: %s\n"), + eprintf(_("%s: %s\n"), Prog, pam_strerror (pamh, ret)); (void) pam_end (pamh, ret); su_failure (caller_tty, 0 == pw->pw_uid); } } else { SYSLOG(LOG_ERR, "pam_acct_mgmt: %s", pam_strerror(pamh, ret)); - fprintf (stderr, - _("%s: %s\n"), - Prog, pam_strerror (pamh, ret)); + eprintf(_("%s: %s\n"), Prog, pam_strerror(pamh, ret)); (void) pam_end (pamh, ret); su_failure (caller_tty, 0 == pw->pw_uid); } @@ -525,11 +514,11 @@ static void check_perms_nopam (const struct passwd *pw) prevent_no_auth = "superuser"; } if (streq(prevent_no_auth, "yes")) { - fprintf(stderr, _("Password field is empty, this is forbidden for all accounts.\n")); + eprintf(_("Password field is empty, this is forbidden for all accounts.\n")); exit(1); } else if ((pw->pw_uid == 0) && streq(prevent_no_auth, "superuser")) { - fprintf(stderr, _("Password field is empty, this is forbidden for super-user.\n")); + eprintf(_("Password field is empty, this is forbidden for super-user.\n")); exit(1); } } @@ -555,9 +544,7 @@ static void check_perms_nopam (const struct passwd *pw) if ( (0 == pw->pw_uid) && getdef_bool ("SU_WHEEL_ONLY") && !iswheel (caller_name)) { - fprintf (stderr, - _("You are not authorized to su %s\n"), - name); + eprintf(_("You are not authorized to su %s\n"), name); exit (1); } spwd = getspnam (name); /* !USE_PAM, no need for xgetspnam */ @@ -579,9 +566,7 @@ static void check_perms_nopam (const struct passwd *pw) password = caller_pass; break; default: /* access denied (-1) or unexpected value */ - fprintf (stderr, - _("You are not authorized to su %s\n"), - name); + eprintf(_("You are not authorized to su %s\n"), name); exit (1); } #endif /* SU_ACCESS */ @@ -599,7 +584,7 @@ static void check_perms_nopam (const struct passwd *pw) if (pw_auth(password, name) != 0) { SYSLOG(pw->pw_uid ? LOG_NOTICE : LOG_WARN, "Authentication failed for %s", name); - fprintf(stderr, _("%s: Authentication failure\n"), Prog); + eprintf(_("%s: Authentication failure\n"), Prog); su_failure (caller_tty, 0 == pw->pw_uid); } (void) signal (SIGQUIT, oldsig); @@ -622,8 +607,7 @@ static void check_perms_nopam (const struct passwd *pw) if (!isttytime (name, "SU", time (NULL))) { SYSLOG(pw->pw_uid ? LOG_WARN : LOG_CRIT, "SU by %s to restricted account %s", caller_name, name); - fprintf (stderr, - _("%s: You are not authorized to su at that time\n"), + eprintf(_("%s: You are not authorized to su at that time\n"), Prog); su_failure (caller_tty, 0 == pw->pw_uid); } @@ -664,8 +648,7 @@ static /*@only@*/struct passwd * do_check_perms (void) */ struct passwd *pw = xgetpwnam (name); if (NULL == pw) { - (void) fprintf (stderr, - _("No passwd entry for user '%s'\n"), name); + (void) eprintf(_("No passwd entry for user '%s'\n"), name); SYSLOG(LOG_NOTICE, "No passwd entry for user '%s'", name); su_failure (caller_tty, true); } @@ -679,8 +662,7 @@ static /*@only@*/struct passwd * do_check_perms (void) ret = pam_get_item(pamh, PAM_USER, &item); if (ret != PAM_SUCCESS) { SYSLOG(LOG_ERR, "pam_get_item: internal PAM error\n"); - (void) fprintf (stderr, - "%s: Internal PAM error retrieving username\n", + (void) eprintf("%s: Internal PAM error retrieving username\n", Prog); (void) pam_end (pamh, ret); su_failure (caller_tty, 0 == pw->pw_uid); @@ -691,15 +673,13 @@ static /*@only@*/struct passwd * do_check_perms (void) "Change user from '%s' to '%s' as requested by PAM", name, tmp_name); if (strtcpy_a(name, tmp_name) == -1) { - fprintf (stderr, _("Overlong user name '%s'\n"), - tmp_name); + eprintf(_("Overlong user name '%s'\n"), tmp_name); SYSLOG(LOG_NOTICE, "Overlong user name '%s'", tmp_name); su_failure (caller_tty, true); } pw = xgetpwnam (name); if (NULL == pw) { - (void) fprintf (stderr, - _("No passwd entry for user '%s'\n"), + (void) eprintf(_("No passwd entry for user '%s'\n"), name); SYSLOG(LOG_NOTICE, "No passwd entry for user '%s'", name); su_failure (caller_tty, true); @@ -766,9 +746,7 @@ save_caller_context(void) * Be more paranoid, like su from SimplePAMApps. --marekm */ if (!caller_is_root) { - fprintf (stderr, - _("%s: must be run from a terminal\n"), - Prog); + eprintf(_("%s: must be run from a terminal\n"), Prog); exit (1); } caller_tty = "???"; @@ -780,9 +758,7 @@ save_caller_context(void) */ pw = get_my_pwent (); if (NULL == pw) { - fprintf (stderr, - _("%s: Cannot determine your user name.\n"), - Prog); + eprintf(_("%s: Cannot determine your user name.\n"), Prog); SYSLOG(LOG_WARN, "Cannot determine the user name of the caller (UID %lu)", (unsigned long) caller_uid); su_failure (caller_tty, true); /* unknown target UID*/ @@ -1055,7 +1031,7 @@ int main (int argc, char **argv) ret = pam_start (Prog, name, &conv, &pamh); if (PAM_SUCCESS != ret) { SYSLOG(LOG_ERR, "pam_start: error %d", ret); - fprintf(stderr, _("%s: pam_start: error %d\n"), Prog, ret); + eprintf(_("%s: pam_start: error %d\n"), Prog, ret); exit (1); } @@ -1065,7 +1041,7 @@ int main (int argc, char **argv) } if (PAM_SUCCESS != ret) { SYSLOG(LOG_ERR, "pam_set_item: %s", pam_strerror(pamh, ret)); - fprintf (stderr, _("%s: %s\n"), Prog, pam_strerror (pamh, ret)); + eprintf(_("%s: %s\n"), Prog, pam_strerror(pamh, ret)); pam_end (pamh, ret); exit (1); } @@ -1126,7 +1102,7 @@ int main (int argc, char **argv) ret = pam_setcred (pamh, PAM_ESTABLISH_CRED); if (PAM_SUCCESS != ret) { SYSLOG(LOG_ERR, "pam_setcred: %s", pam_strerror(pamh, ret)); - fprintf (stderr, _("%s: %s\n"), Prog, pam_strerror (pamh, ret)); + eprintf(_("%s: %s\n"), Prog, pam_strerror(pamh, ret)); (void) pam_end (pamh, ret); exit (1); } @@ -1134,7 +1110,7 @@ int main (int argc, char **argv) ret = pam_open_session (pamh, 0); if (PAM_SUCCESS != ret) { SYSLOG(LOG_ERR, "pam_open_session: %s", pam_strerror(pamh, ret)); - fprintf (stderr, _("%s: %s\n"), Prog, pam_strerror (pamh, ret)); + eprintf(_("%s: %s\n"), Prog, pam_strerror(pamh, ret)); pam_setcred (pamh, PAM_DELETE_CRED); (void) pam_end (pamh, ret); exit (1); @@ -1197,8 +1173,7 @@ int main (int argc, char **argv) #endif /* USE_PAM */ if (-1 == err) { - (void) fprintf (stderr, - _("%s: Cannot drop the controlling terminal\n"), + (void) eprintf(_("%s: Cannot drop the controlling terminal\n"), Prog); exit (1); } @@ -1250,8 +1225,7 @@ int main (int argc, char **argv) argv[-1] = const_cast(char *, cp); execve_shell (shellstr, &argv[-1], environ); err = errno; - (void) fprintf (stderr, - _("Cannot execute %s\n"), shellstr); + (void) eprintf(_("Cannot execute %s\n"), shellstr); errno = err; } else { (void) shell (shellstr, cp, environ); diff --git a/src/useradd.c b/src/useradd.c index d6c12eaf9..2d1791c8d 100644 --- a/src/useradd.c +++ b/src/useradd.c @@ -267,42 +267,41 @@ static void fail_exit (int code, bool process_selinux) #endif if (home_added && rmdir(prefix_user_home) != 0) { - fprintf(stderr, - _("%s: %s was created, but could not be removed\n"), + eprintf(_("%s: %s was created, but could not be removed\n"), Prog, prefix_user_home); SYSLOG(LOG_ERR, "failed to remove %s", prefix_user_home); } if (spw_locked && spw_unlock(process_selinux) == 0) { - fprintf(stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname()); + eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", spw_dbname()); /* continue */ } if (pw_locked && pw_unlock(process_selinux) == 0) { - fprintf(stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname()); + eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname()); /* continue */ } if (gr_locked && gr_unlock(process_selinux) == 0) { - fprintf(stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname()); + eprintf(_("%s: failed to unlock %s\n"), Prog, gr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", gr_dbname()); /* continue */ } #ifdef SHADOWGRP if (sgr_locked && sgr_unlock(process_selinux) == 0) { - fprintf(stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sgr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sgr_dbname()); /* continue */ } #endif #ifdef ENABLE_SUBIDS if (sub_uid_locked && sub_uid_unlock(process_selinux) == 0) { - fprintf(stderr, _("%s: failed to unlock %s\n"), Prog, sub_uid_dbname()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sub_uid_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sub_uid_dbname()); /* continue */ } if (sub_gid_locked && sub_gid_unlock(process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sub_gid_dbname()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sub_gid_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sub_gid_dbname()); /* continue */ } @@ -370,11 +369,9 @@ get_defaults(const struct option_flags *flags) if (streq(buf, DGROUP)) { const struct group *grp = prefix_getgr_nam_gid (cp); if (NULL == grp) { - fprintf (stderr, - _("%s: group '%s' does not exist\n"), + eprintf(_("%s: group '%s' does not exist\n"), Prog, cp); - fprintf (stderr, - _("%s: the %s= configuration in %s will be ignored\n"), + eprintf(_("%s: the %s= configuration in %s will be ignored\n"), Prog, DGROUP, default_file); } else { def_group = grp->gr_gid; @@ -386,8 +383,7 @@ get_defaults(const struct option_flags *flags) if (streq(buf, DGROUPS)) { if (get_groups (cp, flags) != 0) { - fprintf (stderr, - _("%s: the '%s=' configuration in %s has an invalid group, ignoring the bad group\n"), + eprintf(_("%s: the '%s=' configuration in %s has an invalid group, ignoring the bad group\n"), Prog, DGROUPS, default_file); } if (user_groups[0] != NULL) { @@ -414,11 +410,9 @@ get_defaults(const struct option_flags *flags) */ else if (streq(buf, DINACT)) { if (a2sl(&def_inactive, ccp, NULL, 0, -1, LONG_MAX) == -1) { - fprintf (stderr, - _("%s: invalid numeric argument '%s'\n"), + eprintf(_("%s: invalid numeric argument '%s'\n"), Prog, ccp); - fprintf (stderr, - _("%s: the %s= configuration in %s will be ignored\n"), + eprintf(_("%s: the %s= configuration in %s will be ignored\n"), Prog, DINACT, default_file); def_inactive = -1; } @@ -561,8 +555,7 @@ set_defaults(void) new_file_dup = strdup(new_file); if (new_file_dup == NULL) { - fprintf (stderr, - _("%s: cannot create directory for defaults file\n"), + eprintf(_("%s: cannot create directory for defaults file\n"), Prog); goto err_free_def; } @@ -570,8 +563,7 @@ set_defaults(void) ret = mkdir(dirname(new_file_dup), 0755); free(new_file_dup); if (-1 == ret && EEXIST != errno) { - fprintf (stderr, - _("%s: cannot create directory for defaults file\n"), + eprintf(_("%s: cannot create directory for defaults file\n"), Prog); goto err_free_def; } @@ -581,8 +573,7 @@ set_defaults(void) */ ofp = fmkomstemp(new_file, 0, 0644); if (NULL == ofp) { - fprintf (stderr, - _("%s: cannot open new defaults file\n"), + eprintf(_("%s: cannot open new defaults file\n"), Prog); goto err_free_def; } @@ -606,8 +597,7 @@ set_defaults(void) * at the end of the file. */ if (feof (ifp) == 0) { - fprintf (stderr, - _("%s: line too long in %s: %s..."), + eprintf(_("%s: line too long in %s: %s..."), Prog, default_file, buf); fclose(ifp); fclose(ofp); @@ -802,9 +792,7 @@ static int get_groups(char *list, const struct option_flags *flags) * otherwise, we can't change its members */ if (NULL == grp) { - fprintf (stderr, - _("%s: group '%s' does not exist\n"), - Prog, g); + eprintf(_("%s: group '%s' does not exist\n"), Prog, g); errors = true; } @@ -817,8 +805,7 @@ static int get_groups(char *list, const struct option_flags *flags) } if (ngroups == sys_ngroups) { - fprintf (stderr, - _("%s: too many groups specified (max %zu).\n"), + eprintf(_("%s: too many groups specified (max %zu).\n"), Prog, ngroups); gr_free(grp); break; @@ -867,8 +854,7 @@ static struct group * get_local_group(char * grp_name, bool process_selinux) if (grp != NULL) { result_grp = __gr_dup (grp); if (NULL == result_grp) { - fprintf (stderr, - _("%s: Out of memory. Cannot find group '%s'.\n"), + eprintf(_("%s: Out of memory. Cannot find group '%s'.\n"), Prog, grp_name); fail_exit (E_GRP_UPDATE, process_selinux); } @@ -1033,8 +1019,7 @@ static void grp_update (bool process_selinux) */ ngrp = __gr_dup (grp); if (NULL == ngrp) { - fprintf (stderr, - _("%s: Out of memory. Cannot update %s.\n"), + eprintf(_("%s: Out of memory. Cannot update %s.\n"), Prog, gr_dbname ()); SYSLOG(LOG_ERR, "failed to prepare the new %s entry '%s'", gr_dbname(), user_name); fail_exit (E_GRP_UPDATE, process_selinux); /* XXX */ @@ -1046,8 +1031,7 @@ static void grp_update (bool process_selinux) */ ngrp->gr_mem = add_list (ngrp->gr_mem, user_name); if (gr_update (ngrp) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, gr_dbname (), ngrp->gr_name); SYSLOG(LOG_ERR, "failed to prepare the new %s entry '%s'", gr_dbname(), user_name); fail_exit (E_GRP_UPDATE, process_selinux); @@ -1094,8 +1078,7 @@ static void grp_update (bool process_selinux) */ nsgrp = __sgr_dup (sgrp); if (NULL == nsgrp) { - fprintf (stderr, - _("%s: Out of memory. Cannot update %s.\n"), + eprintf(_("%s: Out of memory. Cannot update %s.\n"), Prog, sgr_dbname ()); SYSLOG(LOG_ERR, "failed to prepare the new %s entry '%s'", sgr_dbname(), user_name); fail_exit (E_GRP_UPDATE, process_selinux); /* XXX */ @@ -1107,8 +1090,7 @@ static void grp_update (bool process_selinux) */ nsgrp->sg_mem = add_list (nsgrp->sg_mem, user_name); if (sgr_update (nsgrp) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, sgr_dbname (), nsgrp->sg_namp); SYSLOG(LOG_ERR, "failed to prepare the new %s entry '%s'", sgr_dbname(), user_name); @@ -1196,8 +1178,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) case 'b': if ( ( !VALID (optarg) ) || ( optarg[0] != '/' )) { - fprintf (stderr, - _("%s: invalid base directory '%s'\n"), + eprintf(_("%s: invalid base directory '%s'\n"), Prog, optarg); exit (E_BAD_ARG); } @@ -1212,8 +1193,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) break; case 'c': if (!VALID (optarg)) { - fprintf (stderr, - _("%s: invalid comment '%s'\n"), + eprintf(_("%s: invalid comment '%s'\n"), Prog, optarg); exit (E_BAD_ARG); } @@ -1223,8 +1203,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) case 'd': if ( ( !VALID (optarg) ) || ( optarg[0] != '/' )) { - fprintf (stderr, - _("%s: invalid home directory '%s'\n"), + eprintf(_("%s: invalid home directory '%s'\n"), Prog, optarg); exit (E_BAD_ARG); } @@ -1241,8 +1220,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) if (!streq(optarg, "")) { user_expire = strtoday (optarg); if (user_expire < -1) { - fprintf (stderr, - _("%s: invalid date '%s'\n"), + eprintf(_("%s: invalid date '%s'\n"), Prog, optarg); exit (E_BAD_ARG); } @@ -1255,8 +1233,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) * (it's a no-op in such case) */ if ((-1 != user_expire) && !is_shadow_pwd) { - fprintf (stderr, - _("%s: shadow passwords required for -e\n"), + eprintf(_("%s: shadow passwords required for -e\n"), Prog); exit (E_USAGE); } @@ -1269,8 +1246,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) if (a2sl(&def_inactive, optarg, NULL, 0, -1, LONG_MAX) == -1) { - fprintf (stderr, - _("%s: invalid numeric argument '%s'\n"), + eprintf(_("%s: invalid numeric argument '%s'\n"), Prog, optarg); exit (E_BAD_ARG); } @@ -1279,8 +1255,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) * it's a no-op without /etc/shadow */ if ((-1 != def_inactive) && !is_shadow_pwd) { - fprintf (stderr, - _("%s: shadow passwords required for -f\n"), + eprintf(_("%s: shadow passwords required for -f\n"), Prog); exit (E_USAGE); } @@ -1294,8 +1269,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) case 'g': grp = prefix_getgr_nam_gid (optarg); if (NULL == grp) { - fprintf (stderr, - _("%s: group '%s' does not exist\n"), + eprintf(_("%s: group '%s' does not exist\n"), Prog, optarg); exit (E_NOTFOUND); } @@ -1331,8 +1305,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) */ cp = stpsep(optarg, "="); if (NULL == cp) { - fprintf (stderr, - _("%s: -K requires KEY=VALUE\n"), + eprintf(_("%s: -K requires KEY=VALUE\n"), Prog); exit (E_BAD_ARG); } @@ -1357,8 +1330,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) break; case 'p': /* set encrypted password */ if (!VALID (optarg)) { - fprintf (stderr, - _("%s: invalid field '%s'\n"), + eprintf(_("%s: invalid field '%s'\n"), Prog, optarg); exit (E_BAD_ARG); } @@ -1378,8 +1350,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) || ( !streq(optarg, "") && ('/' != optarg[0]) && ('*' != optarg[0]) )) { - fprintf (stderr, - _("%s: invalid shell '%s'\n"), + eprintf(_("%s: invalid shell '%s'\n"), Prog, optarg); exit (E_BAD_ARG); } @@ -1390,8 +1361,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) && ( stat(optarg, &st) != 0 || S_ISDIR(st.st_mode) || access(optarg, X_OK) != 0)) { - fprintf (stderr, - _("%s: Warning: missing or non-executable shell '%s'\n"), + eprintf(_("%s: Warning: missing or non-executable shell '%s'\n"), Prog, optarg); } user_shell = optarg; @@ -1401,8 +1371,7 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) case 'u': if ( (get_uid(optarg, &user_id) == -1) || (user_id == (gid_t)-1)) { - fprintf (stderr, - _("%s: invalid user ID '%s'\n"), + eprintf(_("%s: invalid user ID '%s'\n"), Prog, optarg); exit (E_BAD_ARG); } @@ -1414,16 +1383,14 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) #ifdef WITH_SELINUX case 'Z': if (prefix[0]) { - fprintf (stderr, - _("%s: -Z cannot be used with --prefix\n"), + eprintf(_("%s: -Z cannot be used with --prefix\n"), Prog); exit (E_BAD_ARG); } if (is_selinux_enabled () > 0) { user_selinux = optarg; } else { - fprintf (stderr, - _("%s: -Z requires SELinux enabled kernel\n"), + eprintf(_("%s: -Z requires SELinux enabled kernel\n"), Prog); exit (E_BAD_ARG); @@ -1453,39 +1420,33 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) * Check it here so that they can be specified in any order. */ if (oflg && !uflg) { - fprintf (stderr, - _("%s: %s flag is only allowed with the %s flag\n"), + eprintf(_("%s: %s flag is only allowed with the %s flag\n"), Prog, "-o", "-u"); usage (E_USAGE); } if (kflg && !mflg) { - fprintf (stderr, - _("%s: %s flag is only allowed with the %s flag\n"), + eprintf(_("%s: %s flag is only allowed with the %s flag\n"), Prog, "-k", "-m"); usage (E_USAGE); } if (Uflg && gflg) { - fprintf (stderr, - _("%s: options %s and %s conflict\n"), + eprintf(_("%s: options %s and %s conflict\n"), Prog, "-U", "-g"); usage (E_USAGE); } if (Uflg && Nflg) { - fprintf (stderr, - _("%s: options %s and %s conflict\n"), + eprintf(_("%s: options %s and %s conflict\n"), Prog, "-U", "-N"); usage (E_USAGE); } if (mflg && Mflg) { - fprintf (stderr, - _("%s: options %s and %s conflict\n"), + eprintf(_("%s: options %s and %s conflict\n"), Prog, "-m", "-M"); usage (E_USAGE); } #ifdef WITH_SELINUX if (user_selinux_range && !Zflg) { - fprintf (stderr, - _("%s: %s flag is only allowed with the %s flag\n"), + eprintf(_("%s: %s flag is only allowed with the %s flag\n"), Prog, "--selinux-range", "--selinux-user"); usage (E_USAGE); } @@ -1511,12 +1472,10 @@ static void process_flags (int argc, char **argv, struct option_flags *flags) user_name = argv[optind]; if (!is_valid_user_name(user_name, badnameflg)) { if (errno == EILSEQ) { - fprintf(stderr, - _("%s: invalid user name '%s': use --badname to ignore\n"), + eprintf(_("%s: invalid user name '%s': use --badname to ignore\n"), Prog, user_name); } else { - fprintf(stderr, - _("%s: invalid user name '%s'\n"), + eprintf(_("%s: invalid user name '%s'\n"), Prog, user_name); } #ifdef WITH_AUDIT @@ -1592,13 +1551,12 @@ static void close_files(const struct option_flags *flags) process_selinux = !flags->chroot && !flags->prefix; if (pw_close (process_selinux) == 0) { - fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: failure while writing changes to %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failure while writing changes to %s", pw_dbname()); fail_exit (E_PW_UPDATE, process_selinux); } if (is_shadow_pwd && (spw_close (process_selinux) == 0)) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), Prog, spw_dbname ()); + eprintf(_("%s: failure while writing changes to %s\n"), Prog, spw_dbname()); SYSLOG(LOG_ERR, "failure while writing changes to %s", spw_dbname()); fail_exit (E_PW_UPDATE, process_selinux); } @@ -1607,21 +1565,19 @@ static void close_files(const struct option_flags *flags) #ifdef ENABLE_SUBIDS if (is_sub_uid && (sub_uid_close (process_selinux) == 0)) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), Prog, sub_uid_dbname ()); + eprintf(_("%s: failure while writing changes to %s\n"), Prog, sub_uid_dbname()); SYSLOG(LOG_ERR, "failure while writing changes to %s", sub_uid_dbname()); fail_exit (E_SUB_UID_UPDATE, process_selinux); } if (is_sub_gid && (sub_gid_close (process_selinux) == 0)) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), Prog, sub_gid_dbname ()); + eprintf(_("%s: failure while writing changes to %s\n"), Prog, sub_gid_dbname()); SYSLOG(LOG_ERR, "failure while writing changes to %s", sub_gid_dbname()); fail_exit (E_SUB_GID_UPDATE, process_selinux); } #endif /* ENABLE_SUBIDS */ if (is_shadow_pwd) { if (spw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", spw_dbname()); #ifdef WITH_AUDIT audit_logger (AUDIT_ADD_USER, @@ -1634,7 +1590,7 @@ static void close_files(const struct option_flags *flags) spw_locked = false; } if (pw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname()); #ifdef WITH_AUDIT audit_logger (AUDIT_ADD_USER, @@ -1651,7 +1607,7 @@ static void close_files(const struct option_flags *flags) #ifdef ENABLE_SUBIDS if (is_sub_uid) { if (sub_uid_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sub_uid_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sub_uid_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sub_uid_dbname()); #ifdef WITH_AUDIT audit_logger (AUDIT_ADD_USER, @@ -1665,7 +1621,7 @@ static void close_files(const struct option_flags *flags) } if (is_sub_gid) { if (sub_gid_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sub_gid_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sub_gid_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sub_gid_dbname()); #ifdef WITH_AUDIT audit_logger (AUDIT_ADD_USER, @@ -1692,16 +1648,14 @@ static void close_group_files (bool process_selinux) return; if (gr_close(process_selinux) == 0) { - fprintf(stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, gr_dbname()); SYSLOG(LOG_ERR, "failure while writing changes to %s", gr_dbname()); fail_exit(E_GRP_UPDATE, process_selinux); } #ifdef SHADOWGRP if (is_shadow_grp && sgr_close(process_selinux) == 0) { - fprintf(stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, sgr_dbname()); SYSLOG(LOG_ERR, "failure while writing changes to %s", sgr_dbname()); fail_exit(E_GRP_UPDATE, process_selinux); @@ -1718,7 +1672,7 @@ static void close_group_files (bool process_selinux) static void unlock_group_files (bool process_selinux) { if (gr_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, gr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", gr_dbname()); #ifdef WITH_AUDIT audit_logger (AUDIT_ADD_USER, @@ -1732,7 +1686,7 @@ static void unlock_group_files (bool process_selinux) #ifdef SHADOWGRP if (is_shadow_grp) { if (sgr_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sgr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sgr_dbname()); #ifdef WITH_AUDIT audit_logger (AUDIT_ADD_USER, @@ -1755,14 +1709,13 @@ static void unlock_group_files (bool process_selinux) static void open_files (bool process_selinux) { if (pw_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, pw_dbname ()); exit (E_PW_UPDATE); } pw_locked = true; if (pw_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, _("%s: cannot open %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, pw_dbname()); fail_exit (E_PW_UPDATE, process_selinux); } @@ -1776,30 +1729,26 @@ static void open_subid_files (bool process_selinux) { if (is_sub_uid) { if (sub_uid_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, sub_uid_dbname ()); fail_exit (E_SUB_UID_UPDATE, process_selinux); } sub_uid_locked = true; if (sub_uid_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), + eprintf(_("%s: cannot open %s\n"), Prog, sub_uid_dbname ()); fail_exit (E_SUB_UID_UPDATE, process_selinux); } } if (is_sub_gid) { if (sub_gid_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, sub_gid_dbname ()); fail_exit (E_SUB_GID_UPDATE, process_selinux); } sub_gid_locked = true; if (sub_gid_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), + eprintf(_("%s: cannot open %s\n"), Prog, sub_gid_dbname ()); fail_exit (E_SUB_GID_UPDATE, process_selinux); } @@ -1810,30 +1759,26 @@ static void open_subid_files (bool process_selinux) static void open_group_files (bool process_selinux) { if (gr_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, gr_dbname ()); fail_exit (E_GRP_UPDATE, process_selinux); } gr_locked = true; if (gr_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, _("%s: cannot open %s\n"), Prog, gr_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, gr_dbname()); fail_exit (E_GRP_UPDATE, process_selinux); } #ifdef SHADOWGRP if (is_shadow_grp) { if (sgr_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, sgr_dbname ()); fail_exit (E_GRP_UPDATE, process_selinux); } sgr_locked = true; if (sgr_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), - Prog, sgr_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, sgr_dbname()); fail_exit (E_GRP_UPDATE, process_selinux); } } @@ -1846,16 +1791,13 @@ static void open_shadow (bool process_selinux) return; } if (spw_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, spw_dbname ()); fail_exit (E_PW_UPDATE, process_selinux); } spw_locked = true; if (spw_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), - Prog, spw_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, spw_dbname()); fail_exit (E_PW_UPDATE, process_selinux); } } @@ -1930,8 +1872,7 @@ static void grp_add (bool process_selinux) * Write out the new group file entry. */ if (gr_update (&grp) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, gr_dbname (), grp.gr_name); #ifdef WITH_AUDIT audit_logger (AUDIT_ADD_GROUP, @@ -1946,8 +1887,7 @@ static void grp_add (bool process_selinux) * Write out the new shadow group entries as well. */ if (is_shadow_grp && (sgr_update (&sgrp) == 0)) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, sgr_dbname (), sgrp.sg_namp); #ifdef WITH_AUDIT audit_logger (AUDIT_ADD_GROUP, @@ -2083,8 +2023,7 @@ static void tallylog_reset (const char *user_name) if (failed) { - fprintf (stderr, - _("%s: failed to reset the tallylog entry of user \"%s\"\n"), + eprintf(_("%s: failed to reset the tallylog entry of user \"%s\"\n"), Prog, user_name); SYSLOG(LOG_WARN, "failed to reset the tallylog entry of user \"%s\"", user_name); } @@ -2145,8 +2084,7 @@ usr_update (unsigned long subuid_count, unsigned long subgid_count, * Put the new (struct passwd) in the table. */ if (pw_update (&pwent) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, pw_dbname (), pwent.pw_name); fail_exit (E_PW_UPDATE, process_selinux); } @@ -2155,23 +2093,20 @@ usr_update (unsigned long subuid_count, unsigned long subgid_count, * Put the new (struct spwd) in the table. */ if (is_shadow_pwd && (spw_update (&spent) == 0)) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, spw_dbname (), spent.sp_namp); fail_exit (E_PW_UPDATE, process_selinux); } #ifdef ENABLE_SUBIDS if (is_sub_uid && !local_sub_uid_assigned(user_name) && (sub_uid_add(user_name, sub_uid_start, subuid_count) == 0)) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry\n"), + eprintf(_("%s: failed to prepare the new %s entry\n"), Prog, sub_uid_dbname ()); fail_exit (E_SUB_UID_UPDATE, process_selinux); } if (is_sub_gid && !local_sub_gid_assigned(user_name) && (sub_gid_add(user_name, sub_gid_start, subgid_count) == 0)) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry\n"), + eprintf(_("%s: failed to prepare the new %s entry\n"), Prog, sub_uid_dbname ()); fail_exit (E_SUB_GID_UPDATE, process_selinux); } @@ -2218,8 +2153,7 @@ static void create_home(const struct option_flags *flags) strcpy(path, ""); bhome = strdup(prefix_user_home); if (!bhome) { - fprintf(stderr, - _("%s: error while duplicating string %s\n"), + eprintf(_("%s: error while duplicating string %s\n"), Prog, user_home); fail_exit(E_HOMEDIR, process_selinux); } @@ -2227,8 +2161,7 @@ static void create_home(const struct option_flags *flags) #ifdef WITH_SELINUX if (process_selinux) { if (set_selinux_file_context(prefix_user_home, S_IFDIR) != 0) { - fprintf(stderr, - _("%s: cannot set SELinux context for home directory %s\n"), + eprintf(_("%s: cannot set SELinux context for home directory %s\n"), Prog, user_home); fail_exit(E_HOMEDIR, process_selinux); } @@ -2258,8 +2191,7 @@ static void create_home(const struct option_flags *flags) struct statfs sfs; if (!btrfs_check) { - fprintf(stderr, - _("%s: error while duplicating string in BTRFS check %s\n"), + eprintf(_("%s: error while duplicating string in BTRFS check %s\n"), Prog, path); fail_exit(E_HOMEDIR, process_selinux); } @@ -2270,13 +2202,11 @@ static void create_home(const struct option_flags *flags) } free(btrfs_check); if (!is_btrfs(&sfs)) { - fprintf(stderr, - _("%s: warning: \"%s\" is not on BTRFS; creating regular directory instead of subvolume\n"), + eprintf(_("%s: warning: \"%s\" is not on BTRFS; creating regular directory instead of subvolume\n"), Prog, prefix_user_home); } else { if (btrfs_create_subvolume(path)) { - fprintf(stderr, - _("%s: failed to create BTRFS subvolume: %s\n"), + eprintf(_("%s: failed to create BTRFS subvolume: %s\n"), Prog, path); fail_exit(E_HOMEDIR, process_selinux); } @@ -2286,7 +2216,7 @@ static void create_home(const struct option_flags *flags) #endif if (!dir_created) { if (mkdir(path, 0) != 0) { - fprintf(stderr, _("%s: cannot create directory %s\n"), + eprintf(_("%s: cannot create directory %s\n"), Prog, path); fail_exit(E_HOMEDIR, process_selinux); } @@ -2317,8 +2247,7 @@ static void create_home(const struct option_flags *flags) if (process_selinux) { /* Reset SELinux to create files with default contexts */ if (reset_selinux_file_context() != 0) { - fprintf(stderr, - _("%s: cannot reset SELinux file creation context\n"), + eprintf(_("%s: cannot reset SELinux file creation context\n"), Prog); fail_exit(E_HOMEDIR, process_selinux); } @@ -2365,9 +2294,8 @@ static void create_mail(const struct option_flags *flags) #ifdef WITH_SELINUX if (process_selinux) { if (set_selinux_file_context(file, S_IFREG) != 0) { - fprintf(stderr, - _("%s: cannot set SELinux context for mailbox file %s\n"), - Prog, file); + eprintf(_("%s: cannot set SELinux context for mailbox file %s\n"), + Prog, file); fail_exit(E_MAILBOXFILE, process_selinux); } } @@ -2408,9 +2336,8 @@ static void create_mail(const struct option_flags *flags) if (process_selinux) { /* Reset SELinux to create files with default contexts */ if (reset_selinux_file_context() != 0) { - fprintf(stderr, - _("%s: cannot reset SELinux file creation context\n"), - Prog); + eprintf(_("%s: cannot reset SELinux file creation context\n"), + Prog); fail_exit(E_MAILBOXFILE, process_selinux); } } @@ -2424,14 +2351,14 @@ static void check_uid_range(int rflg, uid_t user_id) if (rflg) { uid_max = getdef_ulong("SYS_UID_MAX",getdef_ulong("UID_MIN",1000UL)-1); if (user_id > uid_max) { - fprintf(stderr, _("%s warning: %s's uid %d is greater than SYS_UID_MAX %d\n"), Prog, user_name, user_id, uid_max); + eprintf(_("%s warning: %s's uid %d is greater than SYS_UID_MAX %d\n"), Prog, user_name, user_id, uid_max); } }else{ uid_min = getdef_ulong("UID_MIN", 1000UL); uid_max = getdef_ulong("UID_MAX", 6000UL); if (uid_min <= uid_max) { if (user_id < uid_min || user_id >uid_max) - fprintf(stderr, _("%s warning: %s's uid %d outside of the UID_MIN %d and UID_MAX %d range.\n"), Prog, user_name, user_id, uid_min, uid_max); + eprintf(_("%s warning: %s's uid %d outside of the UID_MIN %d and UID_MAX %d range.\n"), Prog, user_name, user_id, uid_min, uid_max); } } @@ -2563,7 +2490,7 @@ int main (int argc, char **argv) * Start with a quick check to see if the user exists. */ if (prefix_getpwnam (user_name) != NULL) { /* local, no need for xgetpwnam */ - fprintf (stderr, _("%s: user '%s' already exists\n"), Prog, user_name); + eprintf(_("%s: user '%s' already exists\n"), Prog, user_name); fail_exit (E_NAME_IN_USE, process_selinux); } @@ -2576,8 +2503,7 @@ int main (int argc, char **argv) if (Uflg) { /* local, no need for xgetgrnam */ if (prefix_getgrnam (user_name) != NULL) { - fprintf (stderr, - _("%s: group %s exists - if you want to add this user to that group, use -g.\n"), + eprintf(_("%s: group %s exists - if you want to add this user to that group, use -g.\n"), Prog, user_name); fail_exit (E_NAME_IN_USE, process_selinux); } @@ -2600,13 +2526,12 @@ int main (int argc, char **argv) * gid too ... --gafton */ if (!uflg) { if (find_new_uid (rflg, &user_id, NULL) < 0) { - fprintf (stderr, _("%s: can't create user\n"), Prog); + eprintf(_("%s: can't create user\n"), Prog); fail_exit (E_UID_IN_USE, process_selinux); } } else { if (prefix_getpwuid (user_id) != NULL) { - fprintf (stderr, - _("%s: UID %lu is not unique\n"), + eprintf(_("%s: UID %lu is not unique\n"), Prog, (unsigned long) user_id); fail_exit (E_UID_IN_USE, process_selinux); } @@ -2627,8 +2552,7 @@ int main (int argc, char **argv) #ifdef WITH_TCB if (getdef_bool ("USE_TCB")) { if (shadowtcb_create (user_name, user_id) == SHADOWTCB_FAILURE) { - fprintf (stderr, - _("%s: Failed to create tcb directory for %s\n"), + eprintf(_("%s: Failed to create tcb directory for %s\n"), Prog, user_name); fail_exit (E_UID_IN_USE, process_selinux); } @@ -2640,9 +2564,7 @@ int main (int argc, char **argv) * open the group files in the open_files() function --gafton */ if (Uflg) { if (find_new_gid (rflg, &user_gid, &user_id) < 0) { - fprintf (stderr, - _("%s: can't create group\n"), - Prog); + eprintf(_("%s: can't create group\n"), Prog); fail_exit (4, process_selinux); } grp_add (process_selinux); @@ -2651,18 +2573,14 @@ int main (int argc, char **argv) #ifdef ENABLE_SUBIDS if (is_sub_uid && subuid_count != 0) { if (find_new_sub_uids(user_id, &sub_uid_start, &subuid_count) < 0) { - fprinte(stderr, - _("%s: can't create subordinate user IDs"), - Prog); + eprinte(_("%s: can't create subordinate user IDs"), Prog); SYSLOGE(LOG_WARN, "can't create subordinate user IDs"); fail_exit(E_SUB_UID_UPDATE, process_selinux); } } if (is_sub_gid && subgid_count != 0) { if (find_new_sub_gids(user_id, &sub_gid_start, &subgid_count) < 0) { - fprinte(stderr, - _("%s: can't create subordinate group IDs"), - Prog); + eprinte(_("%s: can't create subordinate group IDs"), Prog); SYSLOGE(LOG_WARN, "can't create subordinate group IDs"); fail_exit(E_SUB_GID_UPDATE, process_selinux); } @@ -2689,8 +2607,7 @@ int main (int argc, char **argv) #ifdef WITH_SELINUX if (Zflg) { if (set_seuser (user_name, user_selinux, user_selinux_range) != 0) { - fprintf (stderr, - _("%s: warning: the user name %s to %s SELinux user mapping failed.\n"), + eprintf(_("%s: warning: the user name %s to %s SELinux user mapping failed.\n"), Prog, user_name, user_selinux); #ifdef WITH_AUDIT audit_logger (AUDIT_ROLE_ASSIGN, @@ -2710,9 +2627,8 @@ int main (int argc, char **argv) copy_tree (def_usrtemplate, prefix_user_home, false, (uid_t)-1, user_id, (gid_t)-1, user_gid); } else { - fprintf (stderr, - _("%s: warning: the home directory %s already exists.\n" - "%s: Not copying any file from skel directory into it.\n"), + eprintf(_("%s: warning: the home directory %s already exists.\n" + "%s: Not copying any file from skel directory into it.\n"), Prog, user_home, Prog); } diff --git a/src/userdel.c b/src/userdel.c index 3e1efa3ec..0e9c9a01a 100644 --- a/src/userdel.c +++ b/src/userdel.c @@ -197,15 +197,13 @@ static void update_groups (bool process_selinux) */ ngrp = __gr_dup (grp); if (NULL == ngrp) { - fprintf (stderr, - _("%s: Out of memory. Cannot update %s.\n"), + eprintf(_("%s: Out of memory. Cannot update %s.\n"), Prog, gr_dbname ()); exit (13); /* XXX */ } ngrp->gr_mem = del_list (ngrp->gr_mem, user_name); if (gr_update (ngrp) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, gr_dbname (), ngrp->gr_name); exit (E_GRP_UPDATE); } @@ -255,8 +253,7 @@ static void update_groups (bool process_selinux) nsgrp = __sgr_dup (sgrp); if (NULL == nsgrp) { - fprintf (stderr, - _("%s: Out of memory. Cannot update %s.\n"), + eprintf(_("%s: Out of memory. Cannot update %s.\n"), Prog, sgr_dbname ()); exit (13); /* XXX */ } @@ -270,8 +267,7 @@ static void update_groups (bool process_selinux) } if (sgr_update (nsgrp) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, sgr_dbname (), nsgrp->sg_namp); exit (E_GRP_UPDATE); } @@ -308,16 +304,14 @@ static void remove_usergroup (bool process_selinux) } if (grp->gr_gid != user_gid) { - fprintf (stderr, - _("%s: group %s not removed because it is not the primary group of user %s.\n"), + eprintf(_("%s: group %s not removed because it is not the primary group of user %s.\n"), Prog, grp->gr_name, user_name); return; } if (NULL != grp->gr_mem[0]) { /* The usergroup has other members. */ - fprintf (stderr, - _("%s: group %s not removed because it has other members.\n"), + eprintf(_("%s: group %s not removed because it has other members.\n"), Prog, grp->gr_name); return; } @@ -333,8 +327,7 @@ static void remove_usergroup (bool process_selinux) continue; } if (pwd->pw_gid == grp->gr_gid) { - fprintf (stderr, - _("%s: group %s is the primary group of another user and is not removed.\n"), + eprintf(_("%s: group %s is the primary group of another user and is not removed.\n"), Prog, grp->gr_name); break; } @@ -348,8 +341,7 @@ static void remove_usergroup (bool process_selinux) * group of any remaining user. */ if (gr_remove (user_name) == 0) { - fprintf (stderr, - _("%s: cannot remove entry '%s' from %s\n"), + eprintf(_("%s: cannot remove entry '%s' from %s\n"), Prog, user_name, gr_dbname ()); fail_exit (E_GRP_UPDATE, process_selinux); } @@ -366,8 +358,7 @@ static void remove_usergroup (bool process_selinux) #ifdef SHADOWGRP if (sgr_locate (user_name) != NULL) { if (sgr_remove (user_name) == 0) { - fprintf (stderr, - _("%s: cannot remove entry '%s' from %s\n"), + eprintf(_("%s: cannot remove entry '%s' from %s\n"), Prog, user_name, sgr_dbname ()); fail_exit (E_GRP_UPDATE, process_selinux); } @@ -398,12 +389,12 @@ static void close_files(const struct option_flags *flags) process_selinux = !flags->chroot && !flags->prefix; if (pw_close (process_selinux) == 0) { - fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: failure while writing changes to %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failure while writing changes to %s", pw_dbname()); fail_exit (E_PW_UPDATE, process_selinux); } if (pw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname()); /* continue */ } @@ -411,13 +402,12 @@ static void close_files(const struct option_flags *flags) if (is_shadow_pwd) { if (spw_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), Prog, spw_dbname ()); + eprintf(_("%s: failure while writing changes to %s\n"), Prog, spw_dbname()); SYSLOG(LOG_ERR, "failure while writing changes to %s", spw_dbname()); fail_exit (E_PW_UPDATE, process_selinux); } if (spw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", spw_dbname()); /* continue */ } @@ -425,12 +415,12 @@ static void close_files(const struct option_flags *flags) } if (gr_close (process_selinux) == 0) { - fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, gr_dbname ()); + eprintf(_("%s: failure while writing changes to %s\n"), Prog, gr_dbname()); SYSLOG(LOG_ERR, "failure while writing changes to %s", gr_dbname()); fail_exit (E_GRP_UPDATE, process_selinux); } if (gr_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, gr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", gr_dbname()); /* continue */ } @@ -439,14 +429,13 @@ static void close_files(const struct option_flags *flags) #ifdef SHADOWGRP if (is_shadow_grp) { if (sgr_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), Prog, sgr_dbname ()); + eprintf(_("%s: failure while writing changes to %s\n"), Prog, sgr_dbname()); SYSLOG(LOG_ERR, "failure while writing changes to %s", sgr_dbname()); fail_exit (E_GRP_UPDATE, process_selinux); } if (sgr_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sgr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sgr_dbname()); /* continue */ } @@ -457,12 +446,12 @@ static void close_files(const struct option_flags *flags) #ifdef ENABLE_SUBIDS if (is_sub_uid) { if (sub_uid_close (process_selinux) == 0) { - fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, sub_uid_dbname ()); + eprintf(_("%s: failure while writing changes to %s\n"), Prog, sub_uid_dbname()); SYSLOG(LOG_ERR, "failure while writing changes to %s", sub_uid_dbname()); fail_exit (E_SUB_UID_UPDATE, process_selinux); } if (sub_uid_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sub_uid_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sub_uid_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sub_uid_dbname()); /* continue */ } @@ -471,12 +460,12 @@ static void close_files(const struct option_flags *flags) if (is_sub_gid) { if (sub_gid_close (process_selinux) == 0) { - fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, sub_gid_dbname ()); + eprintf(_("%s: failure while writing changes to %s\n"), Prog, sub_gid_dbname()); SYSLOG(LOG_ERR, "failure while writing changes to %s", sub_gid_dbname()); fail_exit (E_SUB_GID_UPDATE, process_selinux); } if (sub_gid_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sub_gid_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sub_gid_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sub_gid_dbname()); /* continue */ } @@ -492,21 +481,21 @@ static void fail_exit (int code, bool process_selinux) { if (pw_locked) { if (pw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname()); /* continue */ } } if (gr_locked) { if (gr_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, gr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", gr_dbname()); /* continue */ } } if (spw_locked) { if (spw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", spw_dbname()); /* continue */ } @@ -514,7 +503,7 @@ static void fail_exit (int code, bool process_selinux) #ifdef SHADOWGRP if (sgr_locked) { if (sgr_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sgr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sgr_dbname()); /* continue */ } @@ -523,14 +512,14 @@ static void fail_exit (int code, bool process_selinux) #ifdef ENABLE_SUBIDS if (sub_uid_locked) { if (sub_uid_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sub_uid_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sub_uid_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sub_uid_dbname()); /* continue */ } } if (sub_gid_locked) { if (sub_gid_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sub_gid_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sub_gid_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sub_gid_dbname()); /* continue */ } @@ -555,55 +544,47 @@ static void fail_exit (int code, bool process_selinux) static void open_files (bool process_selinux) { if (pw_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, pw_dbname ()); fail_exit (E_PW_UPDATE, process_selinux); } pw_locked = true; if (pw_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, pw_dbname()); fail_exit (E_PW_UPDATE, process_selinux); } if (is_shadow_pwd) { if (spw_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, spw_dbname ()); fail_exit (E_PW_UPDATE, process_selinux); } spw_locked = true; if (spw_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), - Prog, spw_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, spw_dbname()); fail_exit (E_PW_UPDATE, process_selinux); } } if (gr_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, gr_dbname ()); fail_exit (E_GRP_UPDATE, process_selinux); } gr_locked = true; if (gr_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, _("%s: cannot open %s\n"), Prog, gr_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, gr_dbname()); fail_exit (E_GRP_UPDATE, process_selinux); } #ifdef SHADOWGRP if (is_shadow_grp) { if (sgr_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, sgr_dbname ()); fail_exit (E_GRP_UPDATE, process_selinux); } sgr_locked= true; if (sgr_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, _("%s: cannot open %s\n"), - Prog, sgr_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, sgr_dbname()); fail_exit (E_GRP_UPDATE, process_selinux); } } @@ -611,29 +592,25 @@ static void open_files (bool process_selinux) #ifdef ENABLE_SUBIDS if (is_sub_uid) { if (sub_uid_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, sub_uid_dbname ()); fail_exit (E_SUB_UID_UPDATE, process_selinux); } sub_uid_locked = true; if (sub_uid_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), Prog, sub_uid_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, sub_uid_dbname()); fail_exit (E_SUB_UID_UPDATE, process_selinux); } } if (is_sub_gid) { if (sub_gid_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, sub_gid_dbname ()); fail_exit (E_SUB_GID_UPDATE, process_selinux); } sub_gid_locked = true; if (sub_gid_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), Prog, sub_gid_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, sub_gid_dbname()); fail_exit (E_SUB_GID_UPDATE, process_selinux); } } @@ -649,29 +626,25 @@ static void open_files (bool process_selinux) static void update_user (bool process_selinux) { if (pw_remove (user_name) == 0) { - fprintf (stderr, - _("%s: cannot remove entry '%s' from %s\n"), + eprintf(_("%s: cannot remove entry '%s' from %s\n"), Prog, user_name, pw_dbname ()); fail_exit (E_PW_UPDATE, process_selinux); } if ( is_shadow_pwd && (spw_locate (user_name) != NULL) && (spw_remove (user_name) == 0)) { - fprintf (stderr, - _("%s: cannot remove entry '%s' from %s\n"), + eprintf(_("%s: cannot remove entry '%s' from %s\n"), Prog, user_name, spw_dbname ()); fail_exit (E_PW_UPDATE, process_selinux); } #ifdef ENABLE_SUBIDS if (is_sub_uid && sub_uid_remove(user_name, 0, ULONG_MAX) == 0) { - fprintf (stderr, - _("%s: cannot remove entry %lu from %s\n"), + eprintf(_("%s: cannot remove entry %lu from %s\n"), Prog, (unsigned long)user_id, sub_uid_dbname ()); fail_exit (E_SUB_UID_UPDATE, process_selinux); } if (is_sub_gid && sub_gid_remove(user_name, 0, ULONG_MAX) == 0) { - fprintf (stderr, - _("%s: cannot remove entry %lu from %s\n"), + eprintf(_("%s: cannot remove entry %lu from %s\n"), Prog, (unsigned long)user_id, sub_gid_dbname ()); fail_exit (E_SUB_GID_UPDATE, process_selinux); } @@ -765,8 +738,7 @@ static bool remove_mailbox (void) if (access (mailfile, F_OK) != 0) { if (ENOENT == errno) { - fprintf (stderr, - _("%s: %s mail spool (%s) not found\n"), + eprintf(_("%s: %s mail spool (%s) not found\n"), Prog, user_name, mailfile); free(mailfile); return 0; @@ -808,8 +780,7 @@ static bool remove_mailbox (void) } i = is_owner (user_id, mailfile); if (i == 0) { - fprintf (stderr, - _("%s: %s not owned by %s, not removing\n"), + eprintf(_("%s: %s not owned by %s, not removing\n"), Prog, mailfile, user_name); SYSLOG(LOG_ERR, "%s not owned by %s, not removed", mailfile, user_name); #ifdef WITH_AUDIT @@ -858,8 +829,7 @@ static int remove_tcbdir (const char *user_name, uid_t user_id) buf = aprintf(TCB_DIR "/%s", user_name); if (buf == NULL) { - fprintf(stderr, - _("%s: Can't allocate memory, tcb entry for %s not removed.\n"), + eprintf(_("%s: Can't allocate memory, tcb entry for %s not removed.\n"), Prog, user_name); return 1; } @@ -954,16 +924,14 @@ int main (int argc, char **argv) #ifdef WITH_SELINUX case 'Z': if (prefix[0]) { - fprintf (stderr, - _("%s: -Z cannot be used with --prefix\n"), + eprintf(_("%s: -Z cannot be used with --prefix\n"), Prog); exit (E_BAD_ARG); } if (is_selinux_enabled () > 0) { Zflg = true; } else { - fprintf (stderr, - _("%s: -Z requires SELinux enabled kernel\n"), + eprintf(_("%s: -Z requires SELinux enabled kernel\n"), Prog); exit (E_BAD_ARG); @@ -1005,7 +973,7 @@ int main (int argc, char **argv) pwd = pw_locate (user_name); /* we care only about local users */ if (NULL == pwd) { pw_close(process_selinux); - fprintf (stderr, _("%s: user '%s' does not exist\n"), + eprintf(_("%s: user '%s' does not exist\n"), Prog, user_name); #ifdef WITH_AUDIT audit_logger (AUDIT_DEL_USER, @@ -1063,13 +1031,11 @@ int main (int argc, char **argv) if (rflg) { int home_owned = is_owner (user_id, user_home); if (-1 == home_owned) { - fprintf (stderr, - _("%s: %s home directory (%s) not found\n"), + eprintf(_("%s: %s home directory (%s) not found\n"), Prog, user_name, user_home); rflg = 0; } else if ((0 == home_owned) && !fflg) { - fprintf (stderr, - _("%s: %s not owned by %s, not removing\n"), + eprintf(_("%s: %s not owned by %s, not removing\n"), Prog, user_home, user_name); rflg = 0; errors = true; @@ -1094,8 +1060,7 @@ int main (int argc, char **argv) continue; } if (path_prefix (user_home, pwd->pw_dir)) { - fprintf (stderr, - _("%s: not removing directory %s (would remove home of user %s)\n"), + eprintf(_("%s: not removing directory %s (would remove home of user %s)\n"), Prog, user_home, pwd->pw_name); rflg = false; errors = true; @@ -1116,8 +1081,7 @@ int main (int argc, char **argv) } else if (is_subvolume > 0) { if (btrfs_remove_subvolume (user_home)) { - fprintf (stderr, - _("%s: error removing subvolume %s\n"), + eprintf(_("%s: error removing subvolume %s\n"), Prog, user_home); errors = true; /* continue */ @@ -1126,8 +1090,7 @@ int main (int argc, char **argv) else #endif if (remove_tree (user_home, true) != 0) { - fprintf (stderr, - _("%s: error removing directory %s\n"), + eprintf(_("%s: error removing directory %s\n"), Prog, user_home); errors = true; /* continue */ @@ -1153,8 +1116,7 @@ int main (int argc, char **argv) #ifdef WITH_SELINUX if (Zflg) { if (del_seuser (user_name) != 0) { - fprintf (stderr, - _("%s: warning: the user name %s to SELinux user mapping removal failed.\n"), + eprintf(_("%s: warning: the user name %s to SELinux user mapping removal failed.\n"), Prog, user_name); #ifdef WITH_AUDIT audit_logger (AUDIT_ROLE_REMOVE, diff --git a/src/usermod.c b/src/usermod.c index d6692260d..95a85ba09 100644 --- a/src/usermod.c +++ b/src/usermod.c @@ -274,8 +274,7 @@ static int get_groups (char *list) * string name. */ if (NULL == grp) { - fprintf (stderr, _("%s: group '%s' does not exist\n"), - Prog, g); + eprintf(_("%s: group '%s' does not exist\n"), Prog, g); errors = true; } @@ -288,8 +287,7 @@ static int get_groups (char *list) } if (ngroups == sys_ngroups) { - fprintf (stderr, - _("%s: too many groups specified (max %zu).\n"), + eprintf(_("%s: too many groups specified (max %zu).\n"), Prog, ngroups); gr_free (grp); break; @@ -480,9 +478,8 @@ new_pw_passwd(char *pw_pass, bool process_selinux) pw_pass = xaprintf("!%s", pw_pass); } else if (Uflg && strprefix(pw_pass, "!")) { if (pw_pass[1] == '\0') { - fprintf (stderr, - _("%s: unlocking the user's password would result in a passwordless account.\n" - "You should set a password with usermod -p to unlock this user's password.\n"), + eprintf(_("%s: unlocking the user's password would result in a passwordless account.\n" + "You should set a password with usermod -p to unlock this user's password.\n"), Prog); fail_exit(E_PASSWORDLESS, process_selinux); } @@ -518,8 +515,7 @@ static void new_pwent (struct passwd *pwent, bool process_selinux) * It was already checked that the user doesn't * exist on the system. */ - fprintf (stderr, - _("%s: user '%s' already exists in %s\n"), + eprintf(_("%s: user '%s' already exists in %s\n"), Prog, user_newname, pw_dbname ()); fail_exit (E_NAME_IN_USE, process_selinux); } @@ -604,8 +600,7 @@ static void new_spent (struct spwd *spent, bool process_selinux) { if (lflg) { if (spw_locate (user_newname) != NULL) { - fprintf (stderr, - _("%s: user '%s' already exists in %s\n"), + eprintf(_("%s: user '%s' already exists in %s\n"), Prog, user_newname, spw_dbname ()); fail_exit (E_NAME_IN_USE, process_selinux); } @@ -669,14 +664,14 @@ fail_exit (int code, bool process_selinux) #ifdef ENABLE_SUBIDS if (sub_gid_locked) { if (sub_gid_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sub_gid_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sub_gid_dbname ()); SYSLOG(LOG_ERR, "failed to unlock %s", sub_gid_dbname()); /* continue */ } } if (sub_uid_locked) { if (sub_uid_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sub_uid_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sub_uid_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sub_uid_dbname()); /* continue */ } @@ -685,7 +680,7 @@ fail_exit (int code, bool process_selinux) #ifdef SHADOWGRP if (sgr_locked) { if (sgr_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sgr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sgr_dbname()); /* continue */ } @@ -693,21 +688,21 @@ fail_exit (int code, bool process_selinux) #endif if (gr_locked) { if (gr_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, gr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", gr_dbname()); /* continue */ } } if (spw_locked) { if (spw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", spw_dbname()); /* continue */ } } if (pw_locked) { if (pw_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname()); /* continue */ } @@ -767,8 +762,7 @@ update_group(const struct group *grp, bool process_selinux) ngrp = __gr_dup (grp); if (NULL == ngrp) { - fprintf (stderr, - _("%s: Out of memory. Cannot update %s.\n"), + eprintf(_("%s: Out of memory. Cannot update %s.\n"), Prog, gr_dbname ()); fail_exit (E_GRP_UPDATE, process_selinux); } @@ -834,8 +828,7 @@ update_group(const struct group *grp, bool process_selinux) goto free_ngrp; if (gr_update (ngrp) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, gr_dbname (), ngrp->gr_name); SYSLOG(LOG_WARN, "failed to prepare the new %s entry '%s'", gr_dbname(), ngrp->gr_name); fail_exit (E_GRP_UPDATE, process_selinux); @@ -904,8 +897,7 @@ update_gshadow(const struct sgrp *sgrp, bool process_selinux) nsgrp = __sgr_dup (sgrp); if (NULL == nsgrp) { - fprintf (stderr, - _("%s: Out of memory. Cannot update %s.\n"), + eprintf(_("%s: Out of memory. Cannot update %s.\n"), Prog, sgr_dbname ()); fail_exit (E_GRP_UPDATE, process_selinux); } @@ -986,8 +978,7 @@ update_gshadow(const struct sgrp *sgrp, bool process_selinux) * Update the group entry to reflect the changes. */ if (sgr_update (nsgrp) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, sgr_dbname (), nsgrp->sg_namp); SYSLOG(LOG_WARN, "failed to prepare the new %s entry '%s'", sgr_dbname(), nsgrp->sg_namp); @@ -1087,8 +1078,7 @@ process_flags(int argc, char **argv, struct option_flags *flags) break; case 'c': if (!VALID (optarg)) { - fprintf (stderr, - _("%s: invalid field '%s'\n"), + eprintf(_("%s: invalid field '%s'\n"), Prog, optarg); exit (E_BAD_ARG); } @@ -1097,16 +1087,14 @@ process_flags(int argc, char **argv, struct option_flags *flags) break; case 'd': if (!VALID (optarg)) { - fprintf (stderr, - _("%s: invalid field '%s'\n"), + eprintf(_("%s: invalid field '%s'\n"), Prog, optarg); exit (E_BAD_ARG); } dflg = true; user_newhome = optarg; if ((user_newhome[0] != '/') && !streq(user_newhome, "")) { - fprintf (stderr, - _("%s: homedir must be an absolute path\n"), + eprintf(_("%s: homedir must be an absolute path\n"), Prog); exit (E_BAD_ARG); } @@ -1114,8 +1102,7 @@ process_flags(int argc, char **argv, struct option_flags *flags) case 'e': user_newexpire = strtoday (optarg); if (user_newexpire < -1) { - fprintf (stderr, - _("%s: invalid date '%s'\n"), + eprintf(_("%s: invalid date '%s'\n"), Prog, optarg); exit (E_BAD_ARG); } @@ -1125,8 +1112,7 @@ process_flags(int argc, char **argv, struct option_flags *flags) if (a2sl(&user_newinactive, optarg, NULL, 0, -1, LONG_MAX) == -1) { - fprintf (stderr, - _("%s: invalid numeric argument '%s'\n"), + eprintf(_("%s: invalid numeric argument '%s'\n"), Prog, optarg); exit (E_BAD_ARG); } @@ -1138,8 +1124,7 @@ process_flags(int argc, char **argv, struct option_flags *flags) grp = prefix_getgr_nam_gid (optarg); if (NULL == grp) { - fprintf (stderr, - _("%s: group '%s' does not exist\n"), + eprintf(_("%s: group '%s' does not exist\n"), Prog, optarg); exit (E_NOTFOUND); } @@ -1160,12 +1145,10 @@ process_flags(int argc, char **argv, struct option_flags *flags) case 'l': if (!is_valid_user_name(optarg, bflg)) { if (errno == EILSEQ) { - fprintf(stderr, - _("%s: invalid user name '%s': use --badname to ignore\n"), + eprintf(_("%s: invalid user name '%s': use --badname to ignore\n"), Prog, optarg); } else { - fprintf(stderr, - _("%s: invalid user name '%s'\n"), + eprintf(_("%s: invalid user name '%s'\n"), Prog, optarg); } exit (E_BAD_ARG); @@ -1200,8 +1183,7 @@ process_flags(int argc, char **argv, struct option_flags *flags) || ( !streq(optarg, "") && ('/' != optarg[0]) && ('*' != optarg[0]) )) { - fprintf (stderr, - _("%s: invalid shell '%s'\n"), + eprintf(_("%s: invalid shell '%s'\n"), Prog, optarg); exit (E_BAD_ARG); } @@ -1212,8 +1194,7 @@ process_flags(int argc, char **argv, struct option_flags *flags) && ( stat(optarg, &st) != 0 || S_ISDIR(st.st_mode) || access(optarg, X_OK) != 0)) { - fprintf (stderr, - _("%s: Warning: missing or non-executable shell '%s'\n"), + eprintf(_("%s: Warning: missing or non-executable shell '%s'\n"), Prog, optarg); } user_newshell = optarg; @@ -1222,8 +1203,7 @@ process_flags(int argc, char **argv, struct option_flags *flags) case 'u': if ( (get_uid(optarg, &user_newid) == -1) || (user_newid == (uid_t)-1)) { - fprintf (stderr, - _("%s: invalid user ID '%s'\n"), + eprintf(_("%s: invalid user ID '%s'\n"), Prog, optarg); exit (E_BAD_ARG); } @@ -1235,8 +1215,7 @@ process_flags(int argc, char **argv, struct option_flags *flags) #ifdef ENABLE_SUBIDS case 'v': if (prepend_range (optarg, &add_sub_uids) == 0) { - fprintf (stderr, - _("%s: invalid subordinate uid range '%s'\n"), + eprintf(_("%s: invalid subordinate uid range '%s'\n"), Prog, optarg); exit(E_BAD_ARG); } @@ -1244,8 +1223,7 @@ process_flags(int argc, char **argv, struct option_flags *flags) break; case 'V': if (prepend_range (optarg, &del_sub_uids) == 0) { - fprintf (stderr, - _("%s: invalid subordinate uid range '%s'\n"), + eprintf(_("%s: invalid subordinate uid range '%s'\n"), Prog, optarg); exit(E_BAD_ARG); } @@ -1253,8 +1231,7 @@ process_flags(int argc, char **argv, struct option_flags *flags) break; case 'w': if (prepend_range (optarg, &add_sub_gids) == 0) { - fprintf (stderr, - _("%s: invalid subordinate gid range '%s'\n"), + eprintf(_("%s: invalid subordinate gid range '%s'\n"), Prog, optarg); exit(E_BAD_ARG); } @@ -1262,8 +1239,7 @@ process_flags(int argc, char **argv, struct option_flags *flags) break; case 'W': if (prepend_range (optarg, &del_sub_gids) == 0) { - fprintf (stderr, - _("%s: invalid subordinate gid range '%s'\n"), + eprintf(_("%s: invalid subordinate gid range '%s'\n"), Prog, optarg); exit(E_BAD_ARG); } @@ -1279,8 +1255,7 @@ process_flags(int argc, char **argv, struct option_flags *flags) #ifdef WITH_SELINUX case 'Z': if (prefix[0]) { - fprintf (stderr, - _("%s: -Z cannot be used with --prefix\n"), + eprintf(_("%s: -Z cannot be used with --prefix\n"), Prog); exit (E_BAD_ARG); } @@ -1288,8 +1263,7 @@ process_flags(int argc, char **argv, struct option_flags *flags) user_selinux = optarg; Zflg = true; } else { - fprintf (stderr, - _("%s: -Z requires SELinux enabled kernel\n"), + eprintf(_("%s: -Z requires SELinux enabled kernel\n"), Prog); exit (E_BAD_ARG); } @@ -1316,8 +1290,7 @@ process_flags(int argc, char **argv, struct option_flags *flags) /* local, no need for xgetpwnam */ pwd = prefix_getpwnam (user_name); if (NULL == pwd) { - fprintf (stderr, - _("%s: user '%s' does not exist\n"), + eprintf(_("%s: user '%s' does not exist\n"), Prog, user_name); exit (E_NOTFOUND); } @@ -1361,56 +1334,49 @@ process_flags(int argc, char **argv, struct option_flags *flags) } if (!anyflag) { - fprintf (stderr, _("%s: no options\n"), Prog); + eprintf(_("%s: no options\n"), Prog); usage (E_USAGE); } if (aflg && (!Gflg)) { - fprintf (stderr, - _("%s: %s flag is only allowed with the %s flag\n"), + eprintf(_("%s: %s flag is only allowed with the %s flag\n"), Prog, "-a", "-G"); usage (E_USAGE); } if (rflg && (!Gflg)) { - fprintf (stderr, - _("%s: %s flag is only allowed with the %s flag\n"), + eprintf(_("%s: %s flag is only allowed with the %s flag\n"), Prog, "-r", "-G"); usage (E_USAGE); } if (rflg && aflg) { - fprintf (stderr, - _("%s: %s and %s are mutually exclusive flags\n"), + eprintf(_("%s: %s and %s are mutually exclusive flags\n"), Prog, "-r", "-a"); usage (E_USAGE); } if ((Lflg && (pflg || Uflg)) || (pflg && Uflg)) { - fprintf (stderr, - _("%s: the -L, -p, and -U flags are exclusive\n"), + eprintf(_("%s: the -L, -p, and -U flags are exclusive\n"), Prog); usage (E_USAGE); } if (oflg && !uflg) { - fprintf (stderr, - _("%s: %s flag is only allowed with the %s flag\n"), + eprintf(_("%s: %s flag is only allowed with the %s flag\n"), Prog, "-o", "-u"); usage (E_USAGE); } if (mflg && !dflg) { - fprintf (stderr, - _("%s: %s flag is only allowed with the %s flag\n"), + eprintf(_("%s: %s flag is only allowed with the %s flag\n"), Prog, "-m", "-d"); usage (E_USAGE); } #ifdef WITH_SELINUX if (user_selinux_range && !Zflg) { - fprintf (stderr, - _("%s: %s flag is only allowed with the %s flag\n"), + eprintf(_("%s: %s flag is only allowed with the %s flag\n"), Prog, "--selinux-range", "--selinux-user"); usage (E_USAGE); } @@ -1459,24 +1425,19 @@ process_flags(int argc, char **argv, struct option_flags *flags) } if (!is_shadow_pwd && (eflg || fflg)) { - fprintf (stderr, - _("%s: shadow passwords required for -e and -f\n"), - Prog); + eprintf(_("%s: shadow passwords required for -e and -f\n"), Prog); exit (E_USAGE); } /* local, no need for xgetpwnam */ if (lflg && (prefix_getpwnam (user_newname) != NULL)) { - fprintf (stderr, - _("%s: user '%s' already exists\n"), - Prog, user_newname); + eprintf(_("%s: user '%s' already exists\n"), Prog, user_newname); exit (E_NAME_IN_USE); } /* local, no need for xgetpwuid */ if (uflg && !oflg && (prefix_getpwuid (user_newid) != NULL)) { - fprintf (stderr, - _("%s: UID '%lu' already exists\n"), + eprintf(_("%s: UID '%lu' already exists\n"), Prog, (unsigned long) user_newid); exit (E_UID_IN_USE); } @@ -1484,16 +1445,14 @@ process_flags(int argc, char **argv, struct option_flags *flags) #ifdef ENABLE_SUBIDS if ( (vflg || Vflg) && !is_sub_uid) { - fprintf (stderr, - _("%s: %s does not exist, you cannot use the flags %s or %s\n"), + eprintf(_("%s: %s does not exist, you cannot use the flags %s or %s\n"), Prog, sub_uid_dbname (), "-v", "-V"); exit (E_USAGE); } if ( (wflg || Wflg) && !is_sub_gid) { - fprintf (stderr, - _("%s: %s does not exist, you cannot use the flags %s or %s\n"), + eprintf(_("%s: %s does not exist, you cannot use the flags %s or %s\n"), Prog, sub_gid_dbname (), "-w", "-W"); exit (E_USAGE); } @@ -1515,12 +1474,12 @@ static void close_files(const struct option_flags *flags) #ifdef ENABLE_SUBIDS if (sub_gid_locked) { if (sub_gid_close (process_selinux) == 0) { - fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, sub_gid_dbname ()); + eprintf(_("%s: failure while writing changes to %s\n"), Prog, sub_gid_dbname()); SYSLOG(LOG_ERR, "failure while writing changes to %s", sub_gid_dbname()); fail_exit (E_SUB_GID_UPDATE, process_selinux); } if (sub_gid_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sub_gid_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sub_gid_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sub_gid_dbname()); /* continue */ } @@ -1528,12 +1487,12 @@ static void close_files(const struct option_flags *flags) } if (sub_uid_locked) { if (sub_uid_close (process_selinux) == 0) { - fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, sub_uid_dbname ()); + eprintf(_("%s: failure while writing changes to %s\n"), Prog, sub_uid_dbname()); SYSLOG(LOG_ERR, "failure while writing changes to %s", sub_uid_dbname()); fail_exit (E_SUB_UID_UPDATE, process_selinux); } if (sub_uid_unlock (process_selinux) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sub_uid_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sub_uid_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sub_uid_dbname()); /* continue */ } @@ -1545,17 +1504,14 @@ static void close_files(const struct option_flags *flags) #ifdef SHADOWGRP if (is_shadow_grp) { if (sgr_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, sgr_dbname ()); SYSLOG(LOG_ERR, "failure while writing changes to %s", sgr_dbname()); fail_exit (E_GRP_UPDATE, process_selinux); } if (sgr_unlock (process_selinux) == 0) { - fprintf (stderr, - _("%s: failed to unlock %s\n"), - Prog, sgr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, sgr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", sgr_dbname()); /* continue */ } @@ -1563,17 +1519,14 @@ static void close_files(const struct option_flags *flags) } #endif if (gr_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, gr_dbname ()); SYSLOG(LOG_ERR, "failure while writing changes to %s", gr_dbname()); fail_exit (E_GRP_UPDATE, process_selinux); } if (gr_unlock (process_selinux) == 0) { - fprintf (stderr, - _("%s: failed to unlock %s\n"), - Prog, gr_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, gr_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", gr_dbname()); /* continue */ } @@ -1581,32 +1534,25 @@ static void close_files(const struct option_flags *flags) } if (spw_locked) { if (spw_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), + eprintf(_("%s: failure while writing changes to %s\n"), Prog, spw_dbname ()); SYSLOG(LOG_ERR, "failure while writing changes to %s", spw_dbname()); fail_exit (E_PW_UPDATE, process_selinux); } if (spw_unlock (process_selinux) == 0) { - fprintf (stderr, - _("%s: failed to unlock %s\n"), - Prog, spw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, spw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", spw_dbname()); /* continue */ } spw_locked = false; } if (pw_close (process_selinux) == 0) { - fprintf (stderr, - _("%s: failure while writing changes to %s\n"), - Prog, pw_dbname ()); + eprintf(_("%s: failure while writing changes to %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failure while writing changes to %s", pw_dbname()); fail_exit (E_PW_UPDATE, process_selinux); } if (pw_unlock (process_selinux) == 0) { - fprintf (stderr, - _("%s: failed to unlock %s\n"), - Prog, pw_dbname ()); + eprintf(_("%s: failed to unlock %s\n"), Prog, pw_dbname()); SYSLOG(LOG_ERR, "failed to unlock %s", pw_dbname()); /* continue */ } @@ -1631,30 +1577,24 @@ static void close_files(const struct option_flags *flags) static void open_files (bool process_selinux) { if (pw_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, pw_dbname ()); fail_exit (E_PW_UPDATE, process_selinux); } pw_locked = true; if (pw_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), - Prog, pw_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, pw_dbname()); fail_exit (E_PW_UPDATE, process_selinux); } if (is_shadow_pwd && (lflg || pflg || eflg || fflg || Lflg || Uflg)) { if (spw_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, spw_dbname ()); fail_exit (E_PW_UPDATE, process_selinux); } spw_locked = true; if (is_shadow_pwd && (spw_open (O_CREAT | O_RDWR) == 0)) { - fprintf (stderr, - _("%s: cannot open %s\n"), - Prog, spw_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, spw_dbname()); fail_exit (E_PW_UPDATE, process_selinux); } } @@ -1665,30 +1605,24 @@ static void open_files (bool process_selinux) * group entries. */ if (gr_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, gr_dbname ()); fail_exit (E_GRP_UPDATE, process_selinux); } gr_locked = true; if (gr_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), - Prog, gr_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, gr_dbname()); fail_exit (E_GRP_UPDATE, process_selinux); } #ifdef SHADOWGRP if (is_shadow_grp && (sgr_lock () == 0)) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, sgr_dbname ()); fail_exit (E_GRP_UPDATE, process_selinux); } sgr_locked = true; if (is_shadow_grp && (sgr_open (O_CREAT | O_RDWR) == 0)) { - fprintf (stderr, - _("%s: cannot open %s\n"), - Prog, sgr_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, sgr_dbname()); fail_exit (E_GRP_UPDATE, process_selinux); } #endif @@ -1696,31 +1630,25 @@ static void open_files (bool process_selinux) #ifdef ENABLE_SUBIDS if (vflg || Vflg) { if (sub_uid_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, sub_uid_dbname ()); fail_exit (E_SUB_UID_UPDATE, process_selinux); } sub_uid_locked = true; if (sub_uid_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), - Prog, sub_uid_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, sub_uid_dbname()); fail_exit (E_SUB_UID_UPDATE, process_selinux); } } if (wflg || Wflg) { if (sub_gid_lock () == 0) { - fprintf (stderr, - _("%s: cannot lock %s; try again later.\n"), + eprintf(_("%s: cannot lock %s; try again later.\n"), Prog, sub_gid_dbname ()); fail_exit (E_SUB_GID_UPDATE, process_selinux); } sub_gid_locked = true; if (sub_gid_open (O_CREAT | O_RDWR) == 0) { - fprintf (stderr, - _("%s: cannot open %s\n"), - Prog, sub_gid_dbname ()); + eprintf(_("%s: cannot open %s\n"), Prog, sub_gid_dbname()); fail_exit (E_SUB_GID_UPDATE, process_selinux); } } @@ -1748,8 +1676,7 @@ static void usr_update(const struct option_flags *flags) */ pwd = pw_locate (user_name); if (NULL == pwd) { - fprintf (stderr, - _("%s: user '%s' does not exist in %s\n"), + eprintf(_("%s: user '%s' does not exist in %s\n"), Prog, user_name, pw_dbname ()); fail_exit (E_NOTFOUND, process_selinux); } @@ -1802,28 +1729,24 @@ static void usr_update(const struct option_flags *flags) if (lflg || uflg || gflg || cflg || dflg || sflg || pflg || Lflg || Uflg || spwd == &spent) { if (pw_update (&pwent) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, pw_dbname (), pwent.pw_name); fail_exit (E_PW_UPDATE, process_selinux); } if (lflg && (pw_remove (user_name) == 0)) { - fprintf (stderr, - _("%s: cannot remove entry '%s' from %s\n"), + eprintf(_("%s: cannot remove entry '%s' from %s\n"), Prog, user_name, pw_dbname ()); fail_exit (E_PW_UPDATE, process_selinux); } } if ((NULL != spwd) && (lflg || eflg || fflg || pflg || Lflg || Uflg)) { if (spw_update (&spent) == 0) { - fprintf (stderr, - _("%s: failed to prepare the new %s entry '%s'\n"), + eprintf(_("%s: failed to prepare the new %s entry '%s'\n"), Prog, spw_dbname (), spent.sp_namp); fail_exit (E_PW_UPDATE, process_selinux); } if (lflg && (spw_remove (user_name) == 0)) { - fprintf (stderr, - _("%s: cannot remove entry '%s' from %s\n"), + eprintf(_("%s: cannot remove entry '%s' from %s\n"), Prog, user_name, spw_dbname ()); fail_exit (E_PW_UPDATE, process_selinux); } @@ -1845,9 +1768,7 @@ static void move_home (bool process_selinux) * If the new home directory already exists, the user * should not use -m. */ - fprintf (stderr, - _("%s: directory %s exists\n"), - Prog, user_newhome); + eprintf(_("%s: directory %s exists\n"), Prog, user_newhome); fail_exit (E_HOMEDIR, process_selinux); } @@ -1857,10 +1778,9 @@ static void move_home (bool process_selinux) * (but /dev/null for example). --marekm */ if (!S_ISDIR (sb.st_mode)) { - fprintf (stderr, - _("%s: The previous home directory (%s) was " - "not a directory. It is not removed and no " - "home directories are created.\n"), + eprintf(_("%s: The previous home directory (%s) was " + "not a directory. It is not removed and no " + "home directories are created.\n"), Prog, user_home); fail_exit (E_HOMEDIR, process_selinux); } @@ -1880,8 +1800,7 @@ static void move_home (bool process_selinux) if (chown_tree (prefix_user_newhome, user_id, uflg ? user_newid : (uid_t)-1, user_gid, gflg ? user_newgid : (gid_t)-1) != 0) { - fprintf (stderr, - _("%s: Failed to change ownership of the home directory"), + eprintf(_("%s: Failed to change ownership of the home directory"), Prog); fail_exit (E_HOMEDIR, process_selinux); } @@ -1895,8 +1814,7 @@ static void move_home (bool process_selinux) if (EXDEV == errno) { #ifdef WITH_BTRFS if (btrfs_is_subvolume (prefix_user_home) > 0) { - fprintf (stderr, - _("%s: error: cannot move subvolume from %s to %s - different device\n"), + eprintf(_("%s: error: cannot move subvolume from %s to %s - different device\n"), Prog, prefix_user_home, prefix_user_newhome); fail_exit (E_HOMEDIR, process_selinux); } @@ -1908,8 +1826,7 @@ static void move_home (bool process_selinux) user_gid, gflg ? user_newgid : (gid_t)-1) == 0) { if (remove_tree (prefix_user_home, true) != 0) { - fprintf (stderr, - _("%s: warning: failed to completely remove old home directory %s"), + eprintf(_("%s: warning: failed to completely remove old home directory %s"), Prog, prefix_user_home); } #ifdef WITH_AUDIT @@ -1924,15 +1841,13 @@ static void move_home (bool process_selinux) (void) remove_tree (prefix_user_newhome, true); } - fprintf (stderr, - _("%s: cannot rename directory %s to %s\n"), + eprintf(_("%s: cannot rename directory %s to %s\n"), Prog, prefix_user_home, prefix_user_newhome); fail_exit (E_HOMEDIR, process_selinux); } } else { - fprintf (stderr, - _("%s: The previous home directory (%s) does not " - "exist or is inaccessible. Move cannot be completed.\n"), + eprintf(_("%s: The previous home directory (%s) does not " + "exist or is inaccessible. Move cannot be completed.\n"), Prog, prefix_user_home); } } @@ -2118,7 +2033,7 @@ static void move_mailbox (void) } if (st.st_uid != user_id) { /* better leave it alone */ - fprintf (stderr, _("%s: warning: %s not owned by %s\n"), + eprintf(_("%s: warning: %s not owned by %s\n"), Prog, mailfile, user_name); (void) close (fd); free(mailfile); @@ -2241,16 +2156,12 @@ int main (int argc, char **argv) #ifdef ENABLE_SUBIDS if (Sflg) { if (find_range (&add_sub_uids, user_id, find_new_sub_uids) == 0) { - fprinte(stderr, - _("%s: unable to find new subordinate uid range"), - Prog); + eprinte(_("%s: unable to find new subordinate uid range"), Prog); SYSLOGE(LOG_WARN, "unable to find new subordinate uid range"); fail_exit (E_SUB_UID_UPDATE, process_selinux); } if (find_range (&add_sub_gids, user_id, find_new_sub_gids) == 0) { - fprinte(stderr, - _("%s: unable to find new subordinate gid range"), - Prog); + eprinte(_("%s: unable to find new subordinate gid range"), Prog); SYSLOGE(LOG_WARN, "unable to find new subordinate gid range"); fail_exit (E_SUB_GID_UPDATE, process_selinux); } @@ -2263,8 +2174,7 @@ int main (int argc, char **argv) id_t count = ptr->range.last - ptr->range.first + 1; if (sub_uid_remove(user_name, ptr->range.first, count) == 0) { - fprintf(stderr, - _("%s: failed to remove uid range %ju-%ju from '%s'\n"), + eprintf(_("%s: failed to remove uid range %ju-%ju from '%s'\n"), Prog, (uintmax_t) ptr->range.first, (uintmax_t) ptr->range.last, @@ -2280,8 +2190,7 @@ int main (int argc, char **argv) id_t count = ptr->range.last - ptr->range.first + 1; if (sub_uid_add(user_name, ptr->range.first, count) == 0) { - fprintf(stderr, - _("%s: failed to add uid range %ju-%ju to '%s'\n"), + eprintf(_("%s: failed to add uid range %ju-%ju to '%s'\n"), Prog, (uintmax_t) ptr->range.first, (uintmax_t) ptr->range.last, @@ -2297,8 +2206,7 @@ int main (int argc, char **argv) id_t count = ptr->range.last - ptr->range.first + 1; if (sub_gid_remove(user_name, ptr->range.first, count) == 0) { - fprintf(stderr, - _("%s: failed to remove gid range %ju-%ju from '%s'\n"), + eprintf(_("%s: failed to remove gid range %ju-%ju from '%s'\n"), Prog, (uintmax_t) ptr->range.first, (uintmax_t) ptr->range.last, @@ -2314,8 +2222,7 @@ int main (int argc, char **argv) id_t count = ptr->range.last - ptr->range.first + 1; if (sub_gid_add(user_name, ptr->range.first, count) == 0) { - fprintf(stderr, - _("%s: failed to add gid range %ju-%ju to '%s'\n"), + eprintf(_("%s: failed to add gid range %ju-%ju to '%s'\n"), Prog, (uintmax_t) ptr->range.first, (uintmax_t) ptr->range.last, @@ -2342,8 +2249,7 @@ int main (int argc, char **argv) if (Zflg) { if (!streq(user_selinux, "")) { if (set_seuser (user_name, user_selinux, user_selinux_range) != 0) { - fprintf (stderr, - _("%s: warning: the user name %s to %s SELinux user mapping failed.\n"), + eprintf(_("%s: warning: the user name %s to %s SELinux user mapping failed.\n"), Prog, user_name, user_selinux); #ifdef WITH_AUDIT audit_logger (AUDIT_ROLE_ASSIGN, @@ -2355,8 +2261,7 @@ int main (int argc, char **argv) } } else { if (del_seuser (user_name) != 0) { - fprintf (stderr, - _("%s: warning: the user name %s to SELinux user mapping removal failed.\n"), + eprintf(_("%s: warning: the user name %s to SELinux user mapping removal failed.\n"), Prog, user_name); #ifdef WITH_AUDIT audit_logger (AUDIT_ROLE_REMOVE, @@ -2413,8 +2318,7 @@ int main (int argc, char **argv) uflg ? user_newid : (uid_t)-1, user_gid, gflg ? user_newgid : (gid_t)-1) != 0) { - fprintf (stderr, - _("%s: Failed to change ownership of the home directory"), + eprintf(_("%s: Failed to change ownership of the home directory"), Prog); fail_exit (E_HOMEDIR, process_selinux); } diff --git a/src/vipw.c b/src/vipw.c index 0b0643d71..9978484d6 100644 --- a/src/vipw.c +++ b/src/vipw.c @@ -159,22 +159,22 @@ static void vipwexit (const char *msg, int syserr, int ret) if (createedit) { if (unlink (fileeditname) != 0) { - fprintf (stderr, _("%s: failed to remove %s\n"), Prog, fileeditname); + eprintf(_("%s: failed to remove %s\n"), Prog, fileeditname); /* continue */ } } if (filelocked) { if ((*unlock) (true) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, fileeditname); + eprintf(_("%s: failed to unlock %s\n"), Prog, fileeditname); SYSLOG(LOG_ERR, "failed to unlock %s", fileeditname); /* continue */ } } if (NULL != msg) { - fprintf (stderr, "%s: %s", Prog, msg); + eprintf("%s: %s", Prog, msg); } if (0 != syserr) { - fprintf (stderr, ": %s", strerror (err)); + eprintf(": %s", strerror(err)); } if ( (NULL != msg) || (0 != syserr)) { @@ -318,12 +318,12 @@ vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool)) exit (1); } else if ( WIFEXITED (status) && (WEXITSTATUS (status) != 0)) { - fprintf(stderr, "%s: %s: WEXITSTATUS(): %d\n", - Prog, editor, WEXITSTATUS (status)); + eprintf("%s: %s: WEXITSTATUS(): %d\n", + Prog, editor, WEXITSTATUS(status)); exit (WEXITSTATUS (status)); } else if (WIFSIGNALED (status)) { - fprintf(stderr, "%s: %s: WTERMSIG(): %d\n", - Prog, editor, WTERMSIG (status)); + eprintf("%s: %s: WTERMSIG(): %d\n", + Prog, editor, WTERMSIG(status)); exit (1); } else { exit (0); @@ -382,7 +382,7 @@ vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool)) && (WEXITSTATUS (status) != 0)) { vipwexit (NULL, 0, WEXITSTATUS (status)); } else if (WIFSIGNALED (status)) { - fprintf (stderr, _("%s: %s killed by signal %d\n"), + eprintf(_("%s: %s killed by signal %d\n"), Prog, editor, WTERMSIG(status)); vipwexit (NULL, 0, 1); } @@ -461,7 +461,7 @@ vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool)) #endif /* WITH_TCB */ if ((*file_unlock) (true) == 0) { - fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, fileeditname); + eprintf(_("%s: failed to unlock %s\n"), Prog, fileeditname); SYSLOG(LOG_ERR, "failed to unlock %s", fileeditname); /* continue */ } @@ -569,8 +569,7 @@ int main (int argc, char **argv) #ifdef WITH_TCB if (getdef_bool ("USE_TCB") && (NULL != user)) { if (shadowtcb_set_user (user) == SHADOWTCB_FAILURE) { - fprintf (stderr, - _("%s: failed to find tcb directory for %s\n"), + eprintf(_("%s: failed to find tcb directory for %s\n"), Prog, user); return E_SHADOW_NOTFOUND; }