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

Nicolas FRANÇOIS nekral-guest at alioth.debian.org
Sun Sep 18 20:24:37 UTC 2011


Author: nekral-guest
Date: 2011-09-18 20:24:36 +0000 (Sun, 18 Sep 2011)
New Revision: 3487

Modified:
   upstream/trunk/ChangeLog
   upstream/trunk/src/chage.c
Log:
	* src/chage.c: EPOCH is not needed, it's converted to -1 by
	strtoday(). But we need to support "-1" specifically.
	* src/chage.c: Fix usage: LOGIN is mandatory.
	* src/chage.c: Display disabled expiry or last change as "-1"
	instead of 1969-12-31. 1969-12-31 is still supported as input from
	the user.
	* src/chage.c: Exit cleanly with fail_exit() (lock files were not
	removed).


Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog	2011-09-18 18:00:06 UTC (rev 3486)
+++ upstream/trunk/ChangeLog	2011-09-18 20:24:36 UTC (rev 3487)
@@ -1,5 +1,16 @@
 2011-09-18  Nicolas François  <nicolas.francois at centraliens.net>
 
+	* src/chage.c: EPOCH is not needed, it's converted to -1 by
+	strtoday(). But we need to support "-1" specifically.
+	* src/chage.c: Fix usage: LOGIN is mandatory.
+	* src/chage.c: Display disabled expiry or last change as "-1"
+	instead of 1969-12-31. 1969-12-31 is still supported as input from
+	the user.
+	* src/chage.c: Exit cleanly with fail_exit() (lock files were not
+	removed).
+
+2011-09-18  Nicolas François  <nicolas.francois at centraliens.net>
+
 	* src/useradd.c: Remove def_file. It was always set to
 	USER_DEFAULTS_FILE.
 	* src/useradd.c: Fix cut&paste issue causing bad warning when

Modified: upstream/trunk/src/chage.c
===================================================================
--- upstream/trunk/src/chage.c	2011-09-18 18:00:06 UTC (rev 3486)
+++ upstream/trunk/src/chage.c	2011-09-18 20:24:36 UTC (rev 3487)
@@ -2,7 +2,7 @@
  * Copyright (c) 1989 - 1994, Julianne Frances Haugh
  * Copyright (c) 1996 - 2000, Marek Michałkiewicz
  * Copyright (c) 2000 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2009, Nicolas François
+ * Copyright (c) 2007 - 2011, Nicolas François
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -90,8 +90,6 @@
 static long inactdays;
 static long expdate;
 
-#define	EPOCH		"1969-12-31"
-
 /* local function prototypes */
 static void usage (int status);
 static void date_to_str (char *buf, size_t maxsize, time_t date);
@@ -142,7 +140,7 @@
  */
 static void usage (int status)
 {
-	fputs (_("Usage: chage [options] [LOGIN]\n"
+	fputs (_("Usage: chage [options] LOGIN\n"
 	         "\n"
 	         "Options:\n"
 	         "  -d, --lastday LAST_DAY        set date of last password change to LAST_DAY\n"
@@ -203,15 +201,19 @@
 		return 0;
 	}
 
-	date_to_str (buf, sizeof buf, lstchgdate * SCALE);
+	if (-1 == lstchgdate) {
+		strcpy (buf, "-1");
+	} else {
+		date_to_str (buf, sizeof buf, lstchgdate * SCALE);
+	}
 
 	change_field (buf, sizeof buf, _("Last Password Change (YYYY-MM-DD)"));
 
-	if (strcmp (buf, EPOCH) == 0) {
+	if (strcmp (buf, "-1") == 0) {
 		lstchgdate = -1;
 	} else {
 		lstchgdate = strtoday (buf);
-		if (lstchgdate < -1) {
+		if (lstchgdate <= -1) {
 			return 0;
 		}
 	}
@@ -230,16 +232,20 @@
 		return 0;
 	}
 
-	date_to_str (buf, sizeof buf, expdate * SCALE);
+	if (-1 == expdate) {
+		strcpy (buf, "-1");
+	} else {
+		date_to_str (buf, sizeof buf, expdate * SCALE);
+	}
 
 	change_field (buf, sizeof buf,
 	              _("Account Expiration Date (YYYY-MM-DD)"));
 
-	if (strcmp (buf, EPOCH) == 0) {
+	if (strcmp (buf, "-1") == 0) {
 		expdate = -1;
 	} else {
 		expdate = strtoday (buf);
-		if (expdate < -1) {
+		if (expdate <= -1) {
 			return 0;
 		}
 	}
@@ -833,7 +839,7 @@
 		fprintf (stderr, _("%s: user '%s' does not exist in %s\n"),
 		         Prog, argv[optind], pw_dbname ());
 		closelog ();
-		exit (E_NOPERM);
+		fail_exit (E_NOPERM);
 	}
 
 	STRFCPY (user_name, pw->pw_name);




More information about the Pkg-shadow-commits mailing list