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

Nicolas FRANÇOIS nekral-guest at alioth.debian.org
Sun Nov 6 18:39:03 UTC 2011


Author: nekral-guest
Date: 2011-11-06 18:39:03 +0000 (Sun, 06 Nov 2011)
New Revision: 3551

Modified:
   upstream/trunk/ChangeLog
   upstream/trunk/NEWS
   upstream/trunk/man/faillog.8.xml
   upstream/trunk/man/lastlog.8.xml
   upstream/trunk/src/faillog.c
   upstream/trunk/src/lastlog.c
Log:
	* NEWS, src/faillog.c, man/faillog.8.xml: Add --root option.
	* NEWS, src/lastlog.c, man/lastlog.8.xml: Likewise.
	* src/faillog.c: Add Prog variable, and prefix error messages with
	Prog rather than "faillog".
	* src/lastlog.c: Likewise.
	* src/lastlog.c: Split usage in smaller messages.

Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog	2011-11-06 18:38:57 UTC (rev 3550)
+++ upstream/trunk/ChangeLog	2011-11-06 18:39:03 UTC (rev 3551)
@@ -1,5 +1,14 @@
 2011-10-30  Nicolas François  <nicolas.francois at centraliens.net>
 
+	* NEWS, src/faillog.c, man/faillog.8.xml: Add --root option.
+	* NEWS, src/lastlog.c, man/lastlog.8.xml: Likewise.
+	* src/faillog.c: Add Prog variable, and prefix error messages with
+	Prog rather than "faillog".
+	* src/lastlog.c: Likewise.
+	* src/lastlog.c: Split usage in smaller messages.
+
+2011-10-30  Nicolas François  <nicolas.francois at centraliens.net>
+
 	* NEWS, src/chage.c, man/chage.1.xml: Add --root option. Open
 	audit and syslog after the potential chroot. chage's usage split
 	in smaller messages.

Modified: upstream/trunk/NEWS
===================================================================
--- upstream/trunk/NEWS	2011-11-06 18:38:57 UTC (rev 3550)
+++ upstream/trunk/NEWS	2011-11-06 18:39:03 UTC (rev 3551)
@@ -37,6 +37,7 @@
 - faillog
   * The -l, -m, -r, -t options only act on the existing users, unless -a is
     specified.
+  * Add --root option.
 - gpasswd
   * Add --root option.
 - groupadd
@@ -58,6 +59,8 @@
   * Add --root option.
 - grpunconv
   * Add --root option.
+- lastlog
+  * Add --root option.
 - login
   * Fixed limits support (non PAM enabled versions only)
   * Added support for infinite limits and group based limits (non PAM

Modified: upstream/trunk/man/faillog.8.xml
===================================================================
--- upstream/trunk/man/faillog.8.xml	2011-11-06 18:38:57 UTC (rev 3550)
+++ upstream/trunk/man/faillog.8.xml	2011-11-06 18:39:03 UTC (rev 3551)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
    Copyright (c) 1989 - 1994, Julianne Frances Haugh
-   Copyright (c) 2007 - 2010, Nicolas François
+   Copyright (c) 2007 - 2011, Nicolas François
    All rights reserved.
   
    Redistribution and use in source and binary forms, with or without
@@ -160,6 +160,19 @@
 	</listitem>
       </varlistentry>
       <varlistentry>
+	<term>
+	  <option>-R</option>, <option>--root</option>
+	  <replaceable>CHROOT_DIR</replaceable>
+	</term>
+	<listitem>
+	  <para>
+	    Apply changes in the <replaceable>CHROOT_DIR</replaceable>
+	    directory and use the configuration files from the
+	    <replaceable>CHROOT_DIR</replaceable> directory.
+	  </para>
+	</listitem>
+      </varlistentry>
+      <varlistentry>
 	<term><option>-t</option>, <option>--time</option>
 	<replaceable>DAYS</replaceable>
 	</term>

Modified: upstream/trunk/man/lastlog.8.xml
===================================================================
--- upstream/trunk/man/lastlog.8.xml	2011-11-06 18:38:57 UTC (rev 3550)
+++ upstream/trunk/man/lastlog.8.xml	2011-11-06 18:39:03 UTC (rev 3551)
@@ -2,7 +2,7 @@
 <!--
    Copyright (c) 1992       , Julianne Frances Haugh
    Copyright (c) 1992       , Phillip Street
-   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
@@ -94,6 +94,19 @@
       </varlistentry>
       <varlistentry>
 	<term>
+	  <option>-R</option>, <option>--root</option>
+	  <replaceable>CHROOT_DIR</replaceable>
+	</term>
+	<listitem>
+	  <para>
+	    Apply changes in the <replaceable>CHROOT_DIR</replaceable>
+	    directory and use the configuration files from the
+	    <replaceable>CHROOT_DIR</replaceable> directory.
+	  </para>
+	</listitem>
+      </varlistentry>
+      <varlistentry>
+	<term>
 	  <option>-t</option>, <option>--time</option>
 	  <replaceable>DAYS</replaceable>
 	</term>

Modified: upstream/trunk/src/faillog.c
===================================================================
--- upstream/trunk/src/faillog.c	2011-11-06 18:38:57 UTC (rev 3550)
+++ upstream/trunk/src/faillog.c	2011-11-06 18:39:03 UTC (rev 3551)
@@ -61,6 +61,7 @@
 /*
  * Global variables
  */
+const char *Prog;		/* Program name */
 static FILE *fail;		/* failure file stream */
 static time_t seconds;		/* that number of days in seconds */
 static unsigned long umin;	/* if uflg and has_umin, only display users with uid >= umin */
@@ -87,12 +88,13 @@
 	                _("Usage: %s [options]\n"
 	                  "\n"
 	                  "Options:\n"),
-	                "faillog");
+	                Prog);
 	(void) fputs (_("  -a, --all                     display faillog records for all users\n"), usageout);
 	(void) fputs (_("  -h, --help                    display this help message and exit\n"), usageout);
 	(void) fputs (_("  -l, --lock-secs SEC           after failed login lock account for SEC seconds\n"), usageout);
 	(void) fputs (_("  -m, --maximum MAX             set maximum failed login counters to MAX\n"), usageout);
 	(void) fputs (_("  -r, --reset                   reset the counters of login failures\n"), usageout);
+	(void) fputs (_("  -R, --root CHROOT_DIR         directory to chroot into\n"), usageout);
 	(void) fputs (_("  -t, --time DAYS               display faillog records more recent than DAYS\n"), usageout);
 	(void) fputs (_("  -u, --user LOGIN/RANGE        display faillog record or maintains failure\n"
 	                "                                counters and limits (if used with -r, -m,\n"
@@ -129,8 +131,8 @@
 		 */
 		if (fread ((char *) &fl, sizeof (fl), 1, fail) != 1) {
 			fprintf (stderr,
-			         _("faillog: Failed to get the entry for UID %lu\n"),
-			         (unsigned long int)pw->pw_uid);
+			         _("%s: Failed to get the entry for UID %lu\n"),
+			         Prog, (unsigned long int)pw->pw_uid);
 			return;
 		}
 	} else {
@@ -229,8 +231,8 @@
 		 */
 		if (fread ((char *) &fl, sizeof (fl), 1, fail) != 1) {
 			fprintf (stderr,
-			         _("faillog: Failed to get the entry for UID %lu\n"),
-			         (unsigned long int)uid);
+			         _("%s: Failed to get the entry for UID %lu\n"),
+			         Prog, (unsigned long int)uid);
 			return true;
 		}
 	} else {
@@ -259,8 +261,8 @@
 	}
 
 	fprintf (stderr,
-	         _("faillog: Failed to reset fail count for UID %lu\n"),
-	         (unsigned long int)uid);
+	         _("%s: Failed to reset fail count for UID %lu\n"),
+	         Prog, (unsigned long int)uid);
 	return true;
 }
 
@@ -343,8 +345,8 @@
 		 */
 		if (fread ((char *) &fl, sizeof (fl), 1, fail) != 1) {
 			fprintf (stderr,
-			         _("faillog: Failed to get the entry for UID %lu\n"),
-			         (unsigned long int)uid);
+			         _("%s: Failed to get the entry for UID %lu\n"),
+			         Prog, (unsigned long int)uid);
 			return true;
 		}
 	} else {
@@ -374,8 +376,8 @@
 	}
 
 	fprintf (stderr,
-	         _("faillog: Failed to set max for UID %lu\n"),
-	         (unsigned long int)uid);
+	         _("%s: Failed to set max for UID %lu\n"),
+	         Prog, (unsigned long int)uid);
 	return true;
 }
 
@@ -460,8 +462,8 @@
 		 */
 		if (fread ((char *) &fl, sizeof (fl), 1, fail) != 1) {
 			fprintf (stderr,
-			         _("faillog: Failed to get the entry for UID %lu\n"),
-			         (unsigned long int)uid);
+			         _("%s: Failed to get the entry for UID %lu\n"),
+			         Prog, (unsigned long int)uid);
 			return true;
 		}
 	} else {
@@ -491,8 +493,8 @@
 	}
 
 	fprintf (stderr,
-	         _("faillog: Failed to set locktime for UID %lu\n"),
-	         (unsigned long int)uid);
+	         _("%s: Failed to set locktime for UID %lu\n"),
+	         Prog, (unsigned long int)uid);
 	return true;
 }
 
@@ -562,10 +564,18 @@
 	long fail_max;
 	long days;
 
+	/*
+	 * Get the program name. The program name is used as a prefix to
+	 * most error messages.
+	 */
+	Prog = Basename (argv[0]);
+
 	(void) setlocale (LC_ALL, "");
 	(void) bindtextdomain (PACKAGE, LOCALEDIR);
 	(void) textdomain (PACKAGE);
 
+	process_root_flag ("-R", argc, argv);
+
 	{
 		int c;
 		static struct option long_options[] = {
@@ -574,11 +584,12 @@
 			{"lock-secs", required_argument, NULL, 'l'},
 			{"maximum", required_argument, NULL, 'm'},
 			{"reset", no_argument, NULL, 'r'},
+			{"root", required_argument, NULL, 'R'},
 			{"time", required_argument, NULL, 't'},
 			{"user", required_argument, NULL, 'u'},
 			{NULL, 0, NULL, '\0'}
 		};
-		while ((c = getopt_long (argc, argv, "ahl:m:rt:u:",
+		while ((c = getopt_long (argc, argv, "ahl:m:rR:t:u:",
 		                         long_options, NULL)) != -1) {
 			switch (c) {
 			case 'a':
@@ -591,7 +602,7 @@
 				if (getlong (optarg, &fail_locktime) == 0) {
 					fprintf (stderr,
 					         _("%s: invalid numeric argument '%s'\n"),
-					         "faillog", optarg);
+					         Prog, optarg);
 					exit (E_BAD_ARG);
 				}
 				lflg = true;
@@ -600,7 +611,7 @@
 				if (getlong (optarg, &fail_max) == 0) {
 					fprintf (stderr,
 					         _("%s: invalid numeric argument '%s'\n"),
-					         "faillog", optarg);
+					         Prog, optarg);
 					exit (E_BAD_ARG);
 				}
 				mflg = true;
@@ -608,11 +619,13 @@
 			case 'r':
 				rflg = true;
 				break;
+			case 'R': /* no-op, handled in process_root_flag () */
+				break;
 			case 't':
 				if (getlong (optarg, &days) == 0) {
 					fprintf (stderr,
 					         _("%s: invalid numeric argument '%s'\n"),
-					         "faillog", optarg);
+					         Prog, optarg);
 					exit (E_BAD_ARG);
 				}
 				seconds = (time_t) days * DAY;
@@ -642,8 +655,8 @@
 					              &umin, &has_umin,
 					              &umax, &has_umax) == 0) {
 						fprintf (stderr,
-						         _("faillog: Unknown user or range: %s\n"),
-						         optarg);
+						         _("%s: Unknown user or range: %s\n"),
+						         Prog, optarg);
 						exit (E_BAD_ARG);
 					}
 				}
@@ -656,8 +669,8 @@
 		}
 		if (argc > optind) {
 			fprintf (stderr,
-			         _("faillog: unexpected argument: %s\n"),
-			         argv[optind]);
+			         _("%s: unexpected argument: %s\n"),
+			         Prog, argv[optind]);
 			usage (EXIT_FAILURE);
 		}
 	}
@@ -674,16 +687,16 @@
 	}
 	if (NULL == fail) {
 		fprintf (stderr,
-		         _("faillog: Cannot open %s: %s\n"),
-		         FAILLOG_FILE, strerror (errno));
+		         _("%s: Cannot open %s: %s\n"),
+		         Prog, FAILLOG_FILE, strerror (errno));
 		exit (E_NOPERM);
 	}
 
 	/* Get the size of the faillog */
 	if (fstat (fileno (fail), &statbuf) != 0) {
 		fprintf (stderr,
-		         _("faillog: Cannot get the size of %s: %s\n"),
-		         FAILLOG_FILE, strerror (errno));
+		         _("%s: Cannot get the size of %s: %s\n"),
+		         Prog, FAILLOG_FILE, strerror (errno));
 		exit (E_NOPERM);
 	}
 

Modified: upstream/trunk/src/lastlog.c
===================================================================
--- upstream/trunk/src/lastlog.c	2011-11-06 18:38:57 UTC (rev 3550)
+++ upstream/trunk/src/lastlog.c	2011-11-06 18:39:03 UTC (rev 3551)
@@ -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
@@ -44,6 +44,8 @@
 #include <assert.h>
 #include "defines.h"
 #include "prototypes.h"
+/*@-exitarg@*/
+#include "exitcodes.h"
 
 /*
  * Needed for MkLinux DR1/2/2.1 - J.
@@ -55,6 +57,7 @@
 /*
  * Global variables
  */
+const char *Prog;		/* Program name */
 static FILE *lastlogfile;	/* lastlog file stream */
 static unsigned long umin;	/* if uflg and has_umin, only display users with uid >= umin */
 static bool has_umin = false;
@@ -73,14 +76,18 @@
 
 static /*@noreturn@*/void usage (int status)
 {
-	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"), (EXIT_SUCCESS != status) ? stderr : stdout);
+	FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
+	(void) fprintf (usageout,
+	                _("Usage: %s [options]\n"
+	                  "\n"
+	                  "Options:\n"),
+	                Prog);
+	(void) fputs (_("  -b, --before DAYS             print only lastlog records older than DAYS\n"), usageout);
+	(void) fputs (_("  -h, --help                    display this help message and exit\n"), usageout);
+	(void) fputs (_("  -R, --root CHROOT_DIR         directory to chroot into\n"), usageout);
+	(void) fputs (_("  -t, --time DAYS               print only lastlog records more recent than DAYS\n"), usageout);
+	(void) fputs (_("  -u, --user LOGIN              print lastlog record of the specified LOGIN\n"), usageout);
+	(void) fputs ("\n", usageout);
 	exit (status);
 }
 
@@ -113,8 +120,8 @@
 		 */
 		if (fread ((char *) &ll, sizeof (ll), 1, lastlogfile) != 1) {
 			fprintf (stderr,
-			         _("lastlog: Failed to get the entry for UID %lu\n"),
-			         (unsigned long int)pw->pw_uid);
+			         _("%s: Failed to get the entry for UID %lu\n"),
+			         Prog, (unsigned long int)pw->pw_uid);
 			exit (EXIT_FAILURE);
 		}
 	} else {
@@ -189,21 +196,30 @@
 
 int main (int argc, char **argv)
 {
+	/*
+	 * Get the program name. The program name is used as a prefix to
+	 * most error messages.
+	 */
+	Prog = Basename (argv[0]);
+
 	(void) setlocale (LC_ALL, "");
 	(void) bindtextdomain (PACKAGE, LOCALEDIR);
 	(void) textdomain (PACKAGE);
 
+	process_root_flag ("-R", argc, argv);
+
 	{
 		int c;
 		static struct option const longopts[] = {
 			{"help", no_argument, NULL, 'h'},
 			{"time", required_argument, NULL, 't'},
 			{"before", required_argument, NULL, 'b'},
+			{"root", required_argument, NULL, 'R'},
 			{"user", required_argument, NULL, 'u'},
 			{NULL, 0, NULL, '\0'}
 		};
 
-		while ((c = getopt_long (argc, argv, "ht:b:u:", longopts,
+		while ((c = getopt_long (argc, argv, "ht:b:R:u:", longopts,
 		                         NULL)) != -1) {
 			switch (c) {
 			case 'h':
@@ -215,7 +231,7 @@
 				if (getulong (optarg, &days) == 0) {
 					fprintf (stderr,
 					         _("%s: invalid numeric argument '%s'\n"),
-					         "lastlog", optarg);
+					         Prog, optarg);
 					exit (EXIT_FAILURE);
 				}
 				seconds = (time_t) days * DAY;
@@ -228,13 +244,15 @@
 				if (getulong (optarg, &inverse_days) == 0) {
 					fprintf (stderr,
 					         _("%s: invalid numeric argument '%s'\n"),
-					         "lastlog", optarg);
+					         Prog, optarg);
 					exit (EXIT_FAILURE);
 				}
 				inverse_seconds = (time_t) inverse_days * DAY;
 				bflg = true;
 				break;
 			}
+			case 'R': /* no-op, handled in process_root_flag () */
+				break;
 			case 'u':
 			{
 				const struct passwd *pwent;
@@ -258,8 +276,8 @@
 					              &umin, &has_umin,
 					              &umax, &has_umax) == 0) {
 						fprintf (stderr,
-						         _("lastlog: Unknown user or range: %s\n"),
-						         optarg);
+						         _("%s: Unknown user or range: %s\n"),
+						         Prog, optarg);
 						exit (EXIT_FAILURE);
 					}
 				}
@@ -272,8 +290,8 @@
 		}
 		if (argc > optind) {
 			fprintf (stderr,
-			         _("lastlog: unexpected argument: %s\n"),
-			         argv[optind]);
+			         _("%s: unexpected argument: %s\n"),
+			         Prog, argv[optind]);
 			usage (EXIT_FAILURE);
 		}
 	}
@@ -287,8 +305,8 @@
 	/* Get the lastlog size */
 	if (fstat (fileno (lastlogfile), &statbuf) != 0) {
 		fprintf (stderr,
-		         _("lastlog: Cannot get the size of %s: %s\n"),
-		         LASTLOG_FILE, strerror (errno));
+		         _("%s: Cannot get the size of %s: %s\n"),
+		         Prog, LASTLOG_FILE, strerror (errno));
 		exit (EXIT_FAILURE);
 	}
 




More information about the Pkg-shadow-commits mailing list