[Pkg-shadow-commits] r1738 - in upstream/trunk: . src

nekral-guest at alioth.debian.org nekral-guest at alioth.debian.org
Thu Jan 24 18:39:05 UTC 2008


Author: nekral-guest
Date: 2008-01-24 18:39:05 +0000 (Thu, 24 Jan 2008)
New Revision: 1738

Modified:
   upstream/trunk/ChangeLog
   upstream/trunk/src/chage.c
   upstream/trunk/src/chfn.c
   upstream/trunk/src/chsh.c
   upstream/trunk/src/gpasswd.c
Log:
Replace printf by puts for fixed strings. This would avoid issues caused
by formats introduced in translated strings.


Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog	2008-01-23 23:48:39 UTC (rev 1737)
+++ upstream/trunk/ChangeLog	2008-01-24 18:39:05 UTC (rev 1738)
@@ -1,3 +1,9 @@
+2008-01-24  Nicolas François  <nicolas.francois at 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 at centraliens.net>
 
 	* src/useradd.c: Strings improvement s/can't get unique/no more

Modified: upstream/trunk/src/chage.c
===================================================================
--- upstream/trunk/src/chage.c	2008-01-23 23:48:39 UTC (rev 1737)
+++ upstream/trunk/src/chage.c	2008-01-24 18:39:05 UTC (rev 1738)
@@ -152,7 +152,7 @@
  */
 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 @@
 	                   "  -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 @@
 	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 @@
 	 * 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 @@
 	 * 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 @@
 	 * 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 @@
 	 * 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);

Modified: upstream/trunk/src/chfn.c
===================================================================
--- upstream/trunk/src/chfn.c	2008-01-23 23:48:39 UTC (rev 1737)
+++ upstream/trunk/src/chfn.c	2008-01-24 18:39:05 UTC (rev 1738)
@@ -161,7 +161,7 @@
  */
 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 @@
 	 * 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 @@
 	 * 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 @@
 	 * 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 @@
 	 * 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);

Modified: upstream/trunk/src/chsh.c
===================================================================
--- upstream/trunk/src/chsh.c	2008-01-23 23:48:39 UTC (rev 1737)
+++ upstream/trunk/src/chsh.c	2008-01-24 18:39:05 UTC (rev 1738)
@@ -82,12 +82,12 @@
  */
 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 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 @@
 	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 @@
 	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 @@
 	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 @@
 	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);
 	}
 }

Modified: upstream/trunk/src/gpasswd.c
===================================================================
--- upstream/trunk/src/gpasswd.c	2008-01-23 23:48:39 UTC (rev 1737)
+++ upstream/trunk/src/gpasswd.c	2008-01-24 18:39:05 UTC (rev 1738)
@@ -729,7 +729,7 @@
 
 	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 @@
 	 */
       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",




More information about the Pkg-shadow-commits mailing list