Replace printf by puts for fixed strings. This would avoid issues caused

by formats introduced in translated strings.
This commit is contained in:
nekral-guest 2008-01-24 18:39:05 +00:00
parent f4b9f1b2e0
commit de239d9b01
5 changed files with 39 additions and 35 deletions

View File

@ -1,3 +1,9 @@
2008-01-24 Nicolas François <nicolas.francois@centraliens.net>
* src/gpasswd.c, src/chfn.c, src/chage.c, src/chsh.c: Replace
printf by puts for fixed strings. This would avoid issues caused
by formats introduced in translated strings.
2008-01-23 Nicolas François <nicolas.francois@centraliens.net>
* src/useradd.c: Strings improvement s/can't get unique/no more

View File

@ -152,7 +152,7 @@ static int isnum (const char *s)
*/
static void usage (void)
{
fprintf (stderr, _("Usage: chage [options] [LOGIN]\n"
fputs (_("Usage: chage [options] [LOGIN]\n"
"\n"
"Options:\n"
" -d, --lastday LAST_DAY set last password change to LAST_DAY\n"
@ -166,7 +166,7 @@ static void usage (void)
" -M, --maxdays MAX_DAYS set maximim number of days before password\n"
" change to MAX_DAYS\n"
" -W, --warndays WARN_DAYS set expiration warning days to WARN_DAYS\n"
"\n"));
"\n"), stderr);
exit (E_USAGE);
}
@ -197,8 +197,8 @@ static int new_fields (void)
char buf[200];
char *cp;
printf (_("Enter the new value, or press ENTER for the default\n"));
printf ("\n");
puts (_("Enter the new value, or press ENTER for the default\n"));
puts ("\n");
snprintf (buf, sizeof buf, "%ld", mindays);
change_field (buf, sizeof buf, _("Minimum Password Age"));
@ -297,11 +297,11 @@ static void list_fields (void)
* The "last change" date is either "never" or the date the password
* was last modified. The date is the number of days since 1/1/1970.
*/
printf (_("Last password change\t\t\t\t\t: "));
puts (_("Last password change\t\t\t\t\t: "));
if (lastday < 0) {
printf (_("never\n"));
puts (_("never\n"));
} else if (lastday == 0) {
printf (_("password must be changed\n"));
puts (_("password must be changed\n"));
} else {
changed = lastday * SCALE;
print_date (changed);
@ -311,10 +311,10 @@ static void list_fields (void)
* The password expiration date is determined from the last change
* date plus the number of days the password is valid for.
*/
printf (_("Password expires\t\t\t\t\t: "));
puts (_("Password expires\t\t\t\t\t: "));
if ((lastday <= 0) || (maxdays >= (10000 * (DAY / SCALE)))
|| (maxdays < 0)) {
printf (_("never\n"));
puts (_("never\n"));
} else {
expires = changed + maxdays * SCALE;
print_date (expires);
@ -326,10 +326,10 @@ static void list_fields (void)
* number of inactive days is added. The resulting date is when the
* active will be disabled.
*/
printf (_("Password inactive\t\t\t\t\t: "));
puts (_("Password inactive\t\t\t\t\t: "));
if ((lastday <= 0) || (inactdays < 0) ||
(maxdays >= (10000 * (DAY / SCALE))) || (maxdays < 0)) {
printf (_("never\n"));
puts (_("never\n"));
} else {
expires = changed + (maxdays + inactdays) * SCALE;
print_date (expires);
@ -339,9 +339,9 @@ static void list_fields (void)
* The account will expire on the given date regardless of the
* password expiring or not.
*/
printf (_("Account expires\t\t\t\t\t\t: "));
puts (_("Account expires\t\t\t\t\t\t: "));
if (expdays < 0) {
printf (_("never\n"));
puts (_("never\n"));
} else {
expires = expdays * SCALE;
print_date (expires);

View File

@ -161,7 +161,7 @@ static int may_change_field (int field)
*/
static void new_fields (void)
{
printf (_("Enter the new value, or press ENTER for the default\n"));
puts (_("Enter the new value, or press ENTER for the default\n"));
if (may_change_field ('f')) {
change_field (fullnm, sizeof fullnm, _("Full Name"));
@ -402,7 +402,7 @@ static void update_gecos (const char *user, char *gecos)
* ignored.
*/
if (setuid (0) != 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);
@ -414,15 +414,14 @@ static void update_gecos (const char *user, char *gecos)
* password file. Get a lock on the file and open it.
*/
if (pw_lock () == 0) {
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 /etc/passwd"));
closelog ();
exit (E_NOPERM);
}
if (pw_open (O_RDWR) == 0) {
fprintf (stderr, _("Cannot open the password file.\n"));
fputs (_("Cannot open the password file.\n"), stderr);
pw_unlock ();
SYSLOG ((LOG_ERR, "can't open /etc/passwd"));
closelog ();
@ -455,7 +454,7 @@ static void update_gecos (const char *user, char *gecos)
* entry as well.
*/
if (pw_update (&pwent) == 0) {
fprintf (stderr, _("Error updating the password entry.\n"));
fputs (_("Error updating the password entry.\n"), stderr);
pw_unlock ();
SYSLOG ((LOG_ERR, "error updating passwd entry"));
closelog ();
@ -466,14 +465,14 @@ static void update_gecos (const char *user, char *gecos)
* Changes have all been made, so commit them and unlock the file.
*/
if (pw_close () == 0) {
fprintf (stderr, _("Cannot commit password file changes.\n"));
fputs (_("Cannot commit password file changes.\n"), stderr);
pw_unlock ();
SYSLOG ((LOG_ERR, "can't rewrite /etc/passwd"));
closelog ();
exit (E_NOPERM);
}
if (pw_unlock () == 0) {
fprintf (stderr, _("Cannot unlock the password file.\n"));
fputs (_("Cannot unlock the password file.\n"), stderr);
SYSLOG ((LOG_ERR, "can't unlock /etc/passwd"));
closelog ();
exit (E_NOPERM);

View File

@ -82,12 +82,12 @@ static void update_shell (const char *user, char *loginsh);
*/
static void usage (void)
{
fprintf (stderr, _("Usage: chsh [options] [LOGIN]\n"
fputs (_("Usage: chsh [options] [LOGIN]\n"
"\n"
"Options:\n"
" -h, --help display this help message and exit\n"
" -s, --shell SHELL new login shell for the user account\n"
"\n"));
"\n"), stderr);
exit (E_USAGE);
}
@ -99,7 +99,7 @@ static void usage (void)
*/
static void new_fields (void)
{
printf (_("Enter the new value, or press ENTER for the default\n"));
puts (_("Enter the new value, or press ENTER for the default\n"));
change_field (loginsh, sizeof loginsh, _("Login Shell"));
}
@ -342,7 +342,7 @@ static void update_shell (const char *user, char *newshell)
if (setuid (0) != 0) {
SYSLOG ((LOG_ERR, "can't setuid(0)"));
closelog ();
fprintf (stderr, _("Cannot change ID to root.\n"));
fputs (_("Cannot change ID to root.\n"), stderr);
exit (1);
}
pwd_init ();
@ -354,15 +354,14 @@ static void update_shell (const char *user, char *newshell)
if (pw_lock () == 0) {
SYSLOG ((LOG_WARN, "can't lock /etc/passwd"));
closelog ();
fprintf (stderr,
_
("Cannot lock the password file; try again later.\n"));
fputs (_("Cannot lock the password file; try again later.\n"),
stderr);
exit (1);
}
if (pw_open (O_RDWR) == 0) {
SYSLOG ((LOG_ERR, "can't open /etc/passwd"));
closelog ();
fprintf (stderr, _("Cannot open the password file.\n"));
fputs (_("Cannot open the password file.\n"), stderr);
pw_unlock ();
exit (1);
}
@ -395,7 +394,7 @@ static void update_shell (const char *user, char *newshell)
if (pw_update (&pwent) == 0) {
SYSLOG ((LOG_ERR, "error updating passwd entry"));
closelog ();
fprintf (stderr, _("Error updating the password entry.\n"));
fputs (_("Error updating the password entry.\n"), stderr);
pw_unlock ();
exit (1);
}
@ -406,14 +405,14 @@ static void update_shell (const char *user, char *newshell)
if (pw_close () == 0) {
SYSLOG ((LOG_ERR, "can't rewrite /etc/passwd"));
closelog ();
fprintf (stderr, _("Cannot commit password file changes.\n"));
fputs (_("Cannot commit password file changes.\n"), stderr);
pw_unlock ();
exit (1);
}
if (pw_unlock () == 0) {
SYSLOG ((LOG_ERR, "can't unlock /etc/passwd"));
closelog ();
fprintf (stderr, _("Cannot unlock the password file.\n"));
fputs (_("Cannot unlock the password file.\n"), stderr);
exit (1);
}
}

View File

@ -729,7 +729,7 @@ int main (int argc, char **argv)
pw = get_my_pwent ();
if (NULL == pw) {
fprintf (stderr, _("Who are you?\n"));
fputs (_("Who are you?\n"), stderr);
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "user lookup", NULL,
bywho, 0);
@ -922,7 +922,7 @@ int main (int argc, char **argv)
*/
output:
if (setuid (0) != 0) {
fprintf (stderr, _("Cannot change ID to root.\n"));
fputs (_("Cannot change ID to root.\n"), stderr);
SYSLOG ((LOG_ERR, "can't setuid(0)"));
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "changing id to root",