diff --git a/ChangeLog b/ChangeLog index 5d3f21ba..91c52c34 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,11 @@ 2008-01-24 Nicolas François * src/gpasswd.c, src/chfn.c, src/chage.c, src/chsh.c, src/grpck.c, - src/vipw.c, src/pwck.c, src/sulogin.c: Replace + src/vipw.c, src/pwck.c, src/sulogin.c, src/newgrp.c, + src/userdel.c, src/lastlog.c, src/groupmems.c, src/usermod.c, + src/expiry.c, src/groupdel.c, src/useradd.c, src/su.c, + src/groupmod.c, src/passwd.c, src/groupadd.c, src/login.c, + src/suauth.c, src/faillog.c, src/id.c: Replace printf by puts for fixed strings. This would avoid issues caused by formats introduced in translated strings. diff --git a/src/expiry.c b/src/expiry.c index 1a66d7f5..3da496c3 100644 --- a/src/expiry.c +++ b/src/expiry.c @@ -54,7 +54,7 @@ static RETSIGTYPE catch_signals (unused int sig) */ static void usage (void) { - fprintf (stderr, _("Usage: expiry {-f|-c}\n")); + fputs (_("Usage: expiry {-f|-c}\n"), stderr); exit (10); } diff --git a/src/faillog.c b/src/faillog.c index 1b3fd26e..a3120d9d 100644 --- a/src/faillog.c +++ b/src/faillog.c @@ -60,7 +60,7 @@ static struct stat statbuf; /* fstat buffer for file size */ static void usage (void) { - fprintf (stderr, _("Usage: faillog [options]\n" + fputs (_("Usage: faillog [options]\n" "\n" "Options:\n" " -a, --all display faillog records for all users\n" @@ -72,7 +72,7 @@ static void usage (void) " -u, --user LOGIN display faillog record or maintains failure\n" " counters and limits (if used with -r, -m or -l\n" " options) only for user with LOGIN\n" - "\n")); + "\n"), stderr); exit (E_USAGE); } @@ -89,8 +89,7 @@ static void print_one (const struct faillog *fl, uid_t uid) #endif if (!once) { - printf (_ - ("Login Failures Maximum Latest On\n")); + puts (_("Login Failures Maximum Latest On\n")); once++; } pwent = getpwuid (uid); /* local, no need for xgetpwuid */ diff --git a/src/groupadd.c b/src/groupadd.c index 9e4a70be..abe1f2d1 100644 --- a/src/groupadd.c +++ b/src/groupadd.c @@ -105,7 +105,7 @@ static void check_perms (void); */ static void usage (void) { - fprintf (stderr, _("Usage: groupadd [options] GROUP\n" + fputs (_("Usage: groupadd [options] GROUP\n" "\n" "Options:\n" " -f, --force force exit with success status if the\n" @@ -115,7 +115,7 @@ static void usage (void) " -K, --key KEY=VALUE overrides /etc/login.defs defaults\n" " -o, --non-unique allow create group with duplicate\n" " (non-unique) GID\n" - "\n")); + "\n"), stderr); exit (E_USAGE); } diff --git a/src/groupdel.c b/src/groupdel.c index f89f7066..4982f701 100644 --- a/src/groupdel.c +++ b/src/groupdel.c @@ -80,7 +80,7 @@ static void group_busy (gid_t); */ static void usage (void) { - fprintf (stderr, _("Usage: groupdel group\n")); + fputs (_("Usage: groupdel group\n"), stderr); exit (E_USAGE); } diff --git a/src/groupmems.c b/src/groupmems.c index 3fb982de..67cb7712 100644 --- a/src/groupmems.c +++ b/src/groupmems.c @@ -99,7 +99,7 @@ static void addtogroup (char *user, char **members) for (i = 0; NULL != members[i]; i++) { if (0 == strcmp (user, members[i])) { - fprintf (stderr, _("Member already exists\n")); + fputs (_("Member already exists\n"), stderr); exit (EXIT_MEMBER_EXISTS); } } @@ -129,7 +129,7 @@ static void rmfromgroup (char *user, char **members) } if (!found) { - fprintf (stderr, _("Member to remove could not be found\n")); + fputs (_("Member to remove could not be found\n"), stderr); exit (EXIT_NOT_MEMBER); } } @@ -160,9 +160,7 @@ static void members (char **members) static void usage (void) { - fprintf (stderr, - _ - ("Usage: groupmems -a username | -d username | -D | -l [-g groupname]\n")); + fputs (_("Usage: groupmems -a username | -d username | -D | -l [-g groupname]\n"), stderr); exit (EXIT_USAGE); } @@ -224,16 +222,16 @@ int main (int argc, char **argv) } if (!isroot () && NULL != thisgroup) { - fprintf (stderr, - _("Only root can add members to different groups\n")); + fputs (_("Only root can add members to different groups\n"), + stderr); exit (EXIT_NOT_ROOT); } else if (isroot () && NULL != thisgroup) { name = thisgroup; } else if (!isgroup ()) { - fprintf (stderr, _("Group access is required\n")); + fputs (_("Group access is required\n"), stderr); exit (EXIT_NOT_EROOT); } else if (NULL == (name = whoami ())) { - fprintf (stderr, _("Not primary owner of current group\n")); + fputs (_("Not primary owner of current group\n"), stderr); exit (EXIT_NOT_PRIMARY); } #ifdef USE_PAM @@ -267,18 +265,18 @@ int main (int argc, char **argv) } if (retval != PAM_SUCCESS) { - fprintf (stderr, _("PAM authentication failed for\n")); + fputs (_("PAM authentication failed for\n"), stderr); exit (1); } #endif if (!gr_lock ()) { - fprintf (stderr, _("Unable to lock group file\n")); + fputs (_("Unable to lock group file\n"), stderr); exit (EXIT_GROUP_FILE); } if (!gr_open (O_RDWR)) { - fprintf (stderr, _("Unable to open group file\n")); + fputs (_("Unable to open group file\n"), stderr); exit (EXIT_GROUP_FILE); } @@ -298,7 +296,7 @@ int main (int argc, char **argv) } if (!gr_close ()) { - fprintf (stderr, _("Cannot close group file\n")); + fputs (_("Cannot close group file\n"), stderr); exit (EXIT_GROUP_FILE); } diff --git a/src/groupmod.c b/src/groupmod.c index 5899048a..d689a216 100644 --- a/src/groupmod.c +++ b/src/groupmod.c @@ -100,7 +100,7 @@ static gid_t get_gid (const char *gidstr); static void usage (void) { - fprintf (stderr, _("Usage: groupmod [options] GROUP\n" + fputs (_("Usage: groupmod [options] GROUP\n" "\n" "Options:\n" " -g, --gid GID force use new GID by GROUP\n" @@ -108,7 +108,7 @@ static void usage (void) " -n, --new-name NEW_GROUP force use NEW_GROUP name by GROUP\n" " -o, --non-unique allow using duplicate (non-unique) GID by GROUP\n" " -p, --password PASSWORD use encrypted password for the new password\n" - "\n")); + "\n"), stderr); exit (E_USAGE); } diff --git a/src/id.c b/src/id.c index d26d2a63..fc0379a2 100644 --- a/src/id.c +++ b/src/id.c @@ -50,9 +50,9 @@ static void usage (void); static void usage (void) { #ifdef HAVE_GETGROUPS - fprintf (stderr, _("Usage: id [-a]\n")); + fputs (_("Usage: id [-a]\n"), stderr); #else - fprintf (stderr, _("Usage: id\n")); + fputs (_("Usage: id\n"), stderr); #endif exit (1); } @@ -164,7 +164,7 @@ static void usage (void) * where "###" is a numerical value and "aaa" is the * corresponding name for each respective numerical value. */ - printf (_(" groups=")); + puts (_(" groups=")); for (i = 0; i < ngroups; i++) { if (i) putchar (','); diff --git a/src/lastlog.c b/src/lastlog.c index 361af907..37ebeb22 100644 --- a/src/lastlog.c +++ b/src/lastlog.c @@ -68,14 +68,14 @@ static struct passwd *pwent; static void usage (void) { - fprintf (stdout, _("Usage: lastlog [options]\n" + fputs (_("Usage: lastlog [options]\n" "\n" "Options:\n" " -b, --before DAYS print only lastlog records older than DAYS\n" " -h, --help display this help message and exit\n" " -t, --time DAYS print only lastlog records more recent than DAYS\n" " -u, --user LOGIN print lastlog record of the specified LOGIN\n" - "\n")); + "\n"), stderr); exit (1); } @@ -95,10 +95,9 @@ static void print_one (const struct passwd *pw) if (!once) { #ifdef HAVE_LL_HOST - printf (_ - ("Username Port From Latest\n")); + puts (_("Username Port From Latest\n")); #else - printf (_("Username Port Latest\n")); + puts (_("Username Port Latest\n")); #endif once++; } diff --git a/src/login.c b/src/login.c index 8dcb755c..00d82e74 100644 --- a/src/login.c +++ b/src/login.c @@ -189,7 +189,7 @@ static void setup_tty (void) */ static void bad_time_notify (void) { - printf (_("Invalid login time\n")); + puts (_("Invalid login time\n")); fflush (stdout); } @@ -223,7 +223,7 @@ static void check_nologin (void) fflush (stdout); fclose (nlfp); } else - printf (_("\nSystem closed for routine maintenance\n")); + puts (_("\nSystem closed for routine maintenance\n")); /* * Non-root users must exit. Root gets the message, but * gets to login. @@ -233,7 +233,7 @@ static void check_nologin (void) closelog (); exit (0); } - printf (_("\n[Disconnect bypassed -- root login allowed.]\n")); + puts (_("\n[Disconnect bypassed -- root login allowed.]\n")); } } #endif /* !USE_PAM */ @@ -675,7 +675,7 @@ int main (int argc, char **argv) exit(0); } else if (retcode == PAM_ABORT) { /* Serious problems, quit now */ - fprintf(stderr,_("login: abort requested by PAM\n")); + fputs (_("login: abort requested by PAM\n"),stderr); SYSLOG ((LOG_ERR,"PAM_ABORT returned from pam_authenticate()")); PAM_END; exit(99); diff --git a/src/newgrp.c b/src/newgrp.c index de06dbed..c7ed8951 100644 --- a/src/newgrp.c +++ b/src/newgrp.c @@ -66,9 +66,9 @@ static void syslog_sg (const char *name, const char *group); static void usage (void) { if (is_newgrp) - fprintf (stderr, _("Usage: newgrp [-] [group]\n")); + fputs (_("Usage: newgrp [-] [group]\n"), stderr); else - fprintf (stderr, _("Usage: sg group [[-c] command]\n")); + fputs (_("Usage: sg group [[-c] command]\n"), stderr); } /* @@ -580,7 +580,7 @@ int main (int argc, char **argv) } if (i == ngroups) { if (ngroups >= sysconf (_SC_NGROUPS_MAX)) { - fprintf (stderr, _("too many groups\n")); + fputs (_("too many groups\n"), stderr); } else { grouplist[ngroups++] = gid; if (setgroups (ngroups, grouplist)) { diff --git a/src/passwd.c b/src/passwd.c index a6b5643c..cfe9d340 100644 --- a/src/passwd.c +++ b/src/passwd.c @@ -143,7 +143,7 @@ static long getnumber (const char *); */ static void usage (int status) { - fprintf (stderr, _("Usage: passwd [options] [LOGIN]\n" + fputs (_("Usage: passwd [options] [LOGIN]\n" "\n" "Options:\n" " -a, --all report password status on all accounts\n" @@ -163,7 +163,7 @@ static void usage (int status) " -w, --warndays WARN_DAYS set expiration warning days to WARN_DAYS\n" " -x, --maxdays MAX_DAYS set maximim number of days before password\n" " change to MAX_DAYS\n" - "\n")); + "\n"), stderr); exit (status); } @@ -282,7 +282,7 @@ static int new_password (const struct passwd *pw) strzero (cp); if (!amroot && (!obscure (orig, pass, pw) || reuse (pass, pw))) { - printf (_("Try again.\n")); + puts (_("Try again.\n")); continue; } @@ -293,8 +293,7 @@ static int new_password (const struct passwd *pw) */ if (amroot && !warned && getdef_bool ("PASS_ALWAYS_WARN") && (!obscure (orig, pass, pw) || reuse (pass, pw))) { - printf (_ - ("\nWarning: weak password (enter it again to use it anyway).\n")); + puts (_("\nWarning: weak password (enter it again to use it anyway).\n")); warned++; continue; } @@ -303,7 +302,7 @@ static int new_password (const struct passwd *pw) return -1; } if (strcmp (cp, pass)) - fprintf (stderr, _("They don't match; try again.\n")); + fputs (_("They don't match; try again.\n"), stderr); else { strzero (cp); break; @@ -498,14 +497,13 @@ static void update_noshadow (void) struct passwd *npw; if (!pw_lock ()) { - fprintf (stderr, - _ - ("Cannot lock the password file; try again later.\n")); + fputs (_("Cannot lock the password file; try again later.\n"), + stderr); SYSLOG ((LOG_WARN, "can't lock password file")); exit (E_PWDBUSY); } if (!pw_open (O_RDWR)) { - fprintf (stderr, _("Cannot open the password file.\n")); + fputs (_("Cannot open the password file.\n"), stderr); SYSLOG ((LOG_ERR, "can't open password file")); fail_exit (E_MISSING); } @@ -520,12 +518,12 @@ static void update_noshadow (void) oom (); npw->pw_passwd = update_crypt_pw (npw->pw_passwd); if (!pw_update (npw)) { - fprintf (stderr, _("Error updating the password entry.\n")); + fputs (_("Error updating the password entry.\n"), stderr); SYSLOG ((LOG_ERR, "error updating password entry")); fail_exit (E_FAILURE); } if (!pw_close ()) { - fprintf (stderr, _("Cannot commit password file changes.\n")); + fputs (_("Cannot commit password file changes.\n"), stderr); SYSLOG ((LOG_ERR, "can't rewrite password file")); fail_exit (E_FAILURE); } @@ -538,14 +536,13 @@ static void update_shadow (void) struct spwd *nsp; if (!spw_lock ()) { - fprintf (stderr, - _ - ("Cannot lock the password file; try again later.\n")); + fputs (_("Cannot lock the password file; try again later.\n"), + stderr); SYSLOG ((LOG_WARN, "can't lock password file")); exit (E_PWDBUSY); } if (!spw_open (O_RDWR)) { - fprintf (stderr, _("Cannot open the password file.\n")); + fputs (_("Cannot open the password file.\n"), stderr); SYSLOG ((LOG_ERR, "can't open password file")); fail_exit (E_FAILURE); } @@ -590,12 +587,12 @@ static void update_shadow (void) nsp->sp_lstchg = 0; if (!spw_update (nsp)) { - fprintf (stderr, _("Error updating the password entry.\n")); + fputs (_("Error updating the password entry.\n"), stderr); SYSLOG ((LOG_ERR, "error updating password entry")); fail_exit (E_FAILURE); } if (!spw_close ()) { - fprintf (stderr, _("Cannot commit password file changes.\n")); + fputs (_("Cannot commit password file changes.\n"), stderr); SYSLOG ((LOG_ERR, "can't rewrite password file")); fail_exit (E_FAILURE); } @@ -934,7 +931,7 @@ int main (int argc, char **argv) } #endif /* USE_PAM */ if (setuid (0)) { - fprintf (stderr, _("Cannot change ID to root.\n")); + fputs (_("Cannot change ID to root.\n"), stderr); SYSLOG ((LOG_ERR, "can't setuid(0)")); closelog (); exit (E_NOPERM); @@ -951,9 +948,9 @@ int main (int argc, char **argv) closelog (); if (!qflg) { if (!eflg) - printf (_("Password changed.\n")); + puts (_("Password changed.\n")); else - printf (_("Password set to expire.\n")); + puts (_("Password set to expire.\n")); } exit (E_SUCCESS); /* NOT REACHED */ diff --git a/src/su.c b/src/su.c index ac5e483a..849a39f5 100644 --- a/src/su.c +++ b/src/su.c @@ -274,7 +274,7 @@ static void run_shell (const char *shellstr, char *args[], int doshell, */ static void usage (void) { - fprintf (stderr, _("Usage: su [options] [LOGIN]\n" + fputs (_("Usage: su [options] [LOGIN]\n" "\n" "Options:\n" " -c, --command COMMAND pass COMMAND to the invoked shell\n" @@ -284,7 +284,7 @@ static void usage (void) " --preserve-environment do not reset environment variables, and\n" " keep the same shell\n" " -s, --shell SHELL use SHELL instead of the default in passwd\n" - "\n")); + "\n"), stderr); exit (E_USAGE); } @@ -868,7 +868,7 @@ int main (int argc, char **argv) #ifndef USE_PAM (void) execve (shellstr, &argv[-1], environ); err = errno; - (void) fprintf (stderr, _("No shell\n")); + (void) fputs (_("No shell\n"), stderr); SYSLOG ((LOG_WARN, "Cannot execute %s", shellstr)); closelog (); exit (err == ENOENT ? E_CMD_NOTFOUND : E_CMD_NOEXEC); diff --git a/src/suauth.c b/src/suauth.c index a9cab331..0a09f83b 100644 --- a/src/suauth.c +++ b/src/suauth.c @@ -100,25 +100,23 @@ int check_su_auth (const char *actual_id, const char *wanted_id) SYSLOG ((pwent.pw_uid ? LOG_NOTICE : LOG_WARN, "DENIED su from `%s' to `%s' (%s)\n", actual_id, wanted_id, SUAUTHFILE)); - fprintf (stderr, - _("Access to su to that account DENIED.\n")); + fputs (_("Access to su to that account DENIED.\n"), + stderr); fclose (authfile_fd); return DENY; } else if (!strcmp (action, "NOPASS")) { SYSLOG ((pwent.pw_uid ? LOG_INFO : LOG_NOTICE, "NO password asked for su from `%s' to `%s' (%s)\n", actual_id, wanted_id, SUAUTHFILE)); - fprintf (stderr, - _("Password authentication bypassed.\n")); + fputs (_("Password authentication bypassed.\n"),stderr); fclose (authfile_fd); return NOPWORD; } else if (!strcmp (action, "OWNPASS")) { SYSLOG ((pwent.pw_uid ? LOG_INFO : LOG_NOTICE, "su from `%s' to `%s': asking for user's own password (%s)\n", actual_id, wanted_id, SUAUTHFILE)); - fprintf (stderr, - _ - ("Please enter your OWN password as authentication.\n")); + fputs (_("Please enter your OWN password as authentication.\n"), + stderr); fclose (authfile_fd); return OWNPWORD; } else { diff --git a/src/useradd.c b/src/useradd.c index 04f37e24..d79145cd 100644 --- a/src/useradd.c +++ b/src/useradd.c @@ -611,7 +611,7 @@ static int get_groups (char *list) */ static void usage (void) { - fprintf (stderr, _("Usage: useradd [options] LOGIN\n" + fputs (_("Usage: useradd [options] LOGIN\n" "\n" "Options:\n" " -b, --base-dir BASE_DIR base directory for the new user account\n" @@ -639,7 +639,7 @@ static void usage (void) " account\n" " -s, --shell SHELL the login shell for the new user account\n" " -u, --uid UID force use the UID for the new user account\n" - "\n")); + "\n"), stderr); exit (E_USAGE); } @@ -1546,9 +1546,8 @@ static void create_mail (void) gr = getgrnam ("mail"); /* local, no need for xgetgrnam */ if (!gr) { - fprintf (stderr, - _ - ("Group 'mail' not found. Creating the user mailbox file with 0600 mode.\n")); + fputs (_("Group 'mail' not found. Creating the user mailbox file with 0600 mode.\n"), + stderr); gid = user_gid; mode = 0600; } else { diff --git a/src/userdel.c b/src/userdel.c index 759fec75..f8df2b0c 100644 --- a/src/userdel.c +++ b/src/userdel.c @@ -99,14 +99,14 @@ static void remove_mailbox (void); */ static void usage (void) { - fprintf (stderr, _("Usage: userdel [options] LOGIN\n" + fputs (_("Usage: userdel [options] LOGIN\n" "\n" "Options:\n" " -f, --force force removal of files,\n" " even if not owned by user\n" " -h, --help display this help message and exit\n" " -r, --remove remove home directory and mail spool\n" - "\n")); + "\n"), stderr); exit (E_USAGE); } diff --git a/src/usermod.c b/src/usermod.c index cc0a1243..6a63e7f7 100644 --- a/src/usermod.c +++ b/src/usermod.c @@ -276,7 +276,7 @@ static int get_groups (char *list) */ static void usage (void) { - fprintf (stderr, _("Usage: usermod [options] LOGIN\n" + fputs (_("Usage: usermod [options] LOGIN\n" "\n" "Options:\n" " -c, --comment COMMENT new value of the GECOS field\n" @@ -299,7 +299,7 @@ static void usage (void) " -s, --shell SHELL new login shell for the user account\n" " -u, --uid UID new UID for the user account\n" " -U, --unlock unlock the user account\n" - "\n")); + "\n"), stderr); exit (E_USAGE); }