]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
* NEWS, src/passwd.c, man/passwd.1.xml: Add --root option.
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sun, 6 Nov 2011 18:38:16 +0000 (18:38 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sun, 6 Nov 2011 18:38:16 +0000 (18:38 +0000)
passwd's usage split in smaller messages.
* src/passwd.c: Call sanitize_env() before setting the locales.

ChangeLog
NEWS
man/passwd.1.xml
src/passwd.c

index c37b768086ae534a98c9381a0ed8a6a116d13632..4a8186169c734b0af904bc6399fa29db08f66516 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -33,6 +33,9 @@
        man/chgpasswd.8.xml: Add --root option.
        * src/chpasswd.c, src/chgpasswd.c: The getopt index of long
        options is not used.
+       * NEWS, src/passwd.c, man/passwd.1.xml: Add --root option.
+       passwd's usage split in smaller messages.
+       * src/passwd.c: Call sanitize_env() before setting the locales.
 
 2011-10-22  Nicolas François  <nicolas.francois@centraliens.net>
 
diff --git a/NEWS b/NEWS
index f7b9eb20f926fedd4ada4c392b284ced8d3cf01d..272f8d3cce32c0c1b9e8b63d1684ee8cbaa875a4 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -37,6 +37,8 @@ shadow-4.1.4.3 -> shadow-4.1.5                                        UNRELEASED
   * Add --root option.
 - groupdel
   * Add --root option.
+- groupmems
+  * Fix parsing of gshadow entries.
 - groupmod
   * Fixed groupmod when configured with --enable-account-tools-setuid.
   * When the gshadow file exists but there are no gshadow entries, an entry
@@ -75,8 +77,10 @@ shadow-4.1.4.3 -> shadow-4.1.5                                       UNRELEASED
   * Close PAM sessions as root. This will be more friendly to PAM modules
     like pam_mount or pam_systemd.
   * Added support for PAM modules which change PAM_USER.
-- newgrp, sg, groupmems
+- newgrp, sg
   * Fix parsing of gshadow entries.
+- passwd
+  * Add --root option.
 - pwpck
   * NIS entries were dropped by -s (sort).
 - pwconv
index 30285affcbe5a474aeb1c543c80419bd6bbf2397..183166a47fe81bb59ac5f818a1c9a2f3d32d9e11 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
    Copyright (c) 1989 - 1994, Julianne Frances Haugh
-   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
          </para>
        </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>-S</option>, <option>--status</option>
index be70d51de899e269cddf3ca7483682ab3117bba7..0e5ccf8022983bab0b28ea52e780f1877bf4ef92 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 1989 - 1994, Julianne Frances Haugh
  * Copyright (c) 1996 - 2000, Marek Michałkiewicz
  * Copyright (c) 2001 - 2006, Tomasz Kłoczko
- * 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
@@ -159,28 +159,31 @@ static int check_selinux_access (const char *changed_user,
  */
 static /*@noreturn@*/void usage (int status)
 {
-       (void)
-       fputs (_("Usage: passwd [options] [LOGIN]\n"
-                "\n"
-                "Options:\n"
-                "  -a, --all                     report password status on all accounts\n"
-                "  -d, --delete                  delete the password for the named account\n"
-                "  -e, --expire                  force expire the password for the named account\n"
-                "  -h, --help                    display this help message and exit\n"
-                "  -k, --keep-tokens             change password only if expired\n"
-                "  -i, --inactive INACTIVE       set password inactive after expiration\n"
-                "                                to INACTIVE\n"
-                "  -l, --lock                    lock the password of the named account\n"
-                "  -n, --mindays MIN_DAYS        set minimum number of days before password\n"
-                "                                change to MIN_DAYS\n"
-                "  -q, --quiet                   quiet mode\n"
-                "  -r, --repository REPOSITORY   change password in REPOSITORY repository\n"
-                "  -S, --status                  report password status on the named account\n"
-                "  -u, --unlock                  unlock the password of the named account\n"
-                "  -w, --warndays WARN_DAYS      set expiration warning days to WARN_DAYS\n"
-                "  -x, --maxdays MAX_DAYS        set maximum number of days before password\n"
-                "                                change to MAX_DAYS\n"
-                "\n"), (E_SUCCESS != status) ? stderr : stdout);
+       FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
+       (void) fprintf (usageout,
+                       _("Usage: %s [options] [LOGIN]\n"
+                         "\n"
+                         "Options:\n"),
+                       Prog);
+       (void) fputs (_("  -a, --all                     report password status on all accounts\n"), usageout);
+       (void) fputs (_("  -d, --delete                  delete the password for the named account\n"), usageout);
+       (void) fputs (_("  -e, --expire                  force expire the password for the named account\n"), usageout);
+       (void) fputs (_("  -h, --help                    display this help message and exit\n"), usageout);
+       (void) fputs (_("  -k, --keep-tokens             change password only if expired\n"), usageout);
+       (void) fputs (_("  -i, --inactive INACTIVE       set password inactive after expiration\n"
+                       "                                to INACTIVE\n"), usageout);
+       (void) fputs (_("  -l, --lock                    lock the password of the named account\n"), usageout);
+       (void) fputs (_("  -n, --mindays MIN_DAYS        set minimum number of days before password\n"
+                       "                                change to MIN_DAYS\n"), usageout);
+       (void) fputs (_("  -q, --quiet                   quiet mode\n"), usageout);
+       (void) fputs (_("  -r, --repository REPOSITORY   change password in REPOSITORY repository\n"), usageout);
+       (void) fputs (_("  -R, --root CHROOT_DIR         directory to chroot into\n"), usageout);
+       (void) fputs (_("  -S, --status                  report password status on the named account\n"), usageout);
+       (void) fputs (_("  -u, --unlock                  unlock the password of the named account\n"), usageout);
+       (void) fputs (_("  -w, --warndays WARN_DAYS      set expiration warning days to WARN_DAYS\n"), usageout);
+       (void) fputs (_("  -x, --maxdays MAX_DAYS        set maximum number of days before password\n"
+                       "                                change to MAX_DAYS\n"), usageout);
+       (void) fputs ("\n", usageout);
        exit (status);
 }
 
@@ -771,31 +774,32 @@ int main (int argc, char **argv)
        const struct spwd *sp;  /* Shadow file entry for user   */
 #endif                         /* !USE_PAM */
 
+       sanitize_env ();
+
+       /*
+        * 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);
+
        /*
         * The program behaves differently when executed by root than when
         * executed by a normal user.
         */
        amroot = (getuid () == 0);
 
-       /*
-        * Get the program name. The program name is used as a prefix to
-        * most error messages.
-        */
-       Prog = Basename (argv[0]);
-
-       sanitize_env ();
-
        OPENLOG ("passwd");
 
        {
                /*
                 * Parse the command line options.
                 */
-               int option_index = 0;
                int c;
                static struct option long_options[] = {
                        {"all", no_argument, NULL, 'a'},
@@ -808,6 +812,7 @@ int main (int argc, char **argv)
                        {"mindays", required_argument, NULL, 'n'},
                        {"quiet", no_argument, NULL, 'q'},
                        {"repository", required_argument, NULL, 'r'},
+                       {"root", required_argument, NULL, 'R'},
                        {"status", no_argument, NULL, 'S'},
                        {"unlock", no_argument, NULL, 'u'},
                        {"warndays", required_argument, NULL, 'w'},
@@ -815,8 +820,8 @@ int main (int argc, char **argv)
                        {NULL, 0, NULL, '\0'}
                };
 
-               while ((c = getopt_long (argc, argv, "adehi:kln:qr:Suw:x:",
-                                        long_options, &option_index)) != -1) {
+               while ((c = getopt_long (argc, argv, "adehi:kln:qr:R:Suw:x:",
+                                        long_options, NULL)) != -1) {
                        switch (c) {
                        case 'a':
                                aflg = true;
@@ -872,6 +877,8 @@ int main (int argc, char **argv)
                                        exit (E_BAD_ARG);
                                }
                                break;
+                       case 'R': /* no-op, handled in process_root_flag () */
+                               break;
                        case 'S':
                                Sflg = true;    /* ok for users */
                                break;