by formats introduced in translated strings.
+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
*/
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"
" -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);
}
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"));
* 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);
* 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);
* 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);
* 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);
*/
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"));
* 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);
* 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 ();
* 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 ();
* 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);
*/
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);
}
*/
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"));
}
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 ();
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);
}
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);
}
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);
}
}
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);
*/
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",