]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
* NEWS, src/usermod.c, man/usermod.8.xml: Add --root option. Open
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sun, 6 Nov 2011 18:37:39 +0000 (18:37 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sun, 6 Nov 2011 18:37:39 +0000 (18:37 +0000)
audit and syslog after the potential chroot. userdel's usage split
in smaller messages.

ChangeLog
NEWS
man/usermod.8.xml
src/usermod.c

index a9de9ec90d3312c23c30485977636601489eebc1..0257d6fd38a55c71f64a18285ad57089ccaea23e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,7 @@
        * NEWS, src/userdel.c, man/userdel.8.xml: Add --root option. Open
        audit and syslog after the potential chroot. userdel's usage split
        in smaller messages.
+       * NEWS, src/usermod.c, man/usermod.8.xml: Likewise
 
 2011-10-22  Nicolas François  <nicolas.francois@centraliens.net>
 
diff --git a/NEWS b/NEWS
index 1f802b6252d07ce9f5853eaf7091718b6cea91be..61f8fac1861d76336cfce077d861788507bdd4ed 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -83,6 +83,7 @@ shadow-4.1.4.3 -> shadow-4.1.5                                        UNRELEASED
   * When the shadow file exists but there are no shadow entries, an entry
     is created if the password is changed and passwd requires a
     shadow entry, or if aging features are used (-e or -f).
+  * Add --root option.
 
 *** translation
   * Updated Brazilian Portuguese translation.
index 5cfccc39fa69332aeeb05e85d23cd179aa78cc76..6a6372c28ea315c840820fe539a2f526f0f88d14 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
    Copyright (c) 1991 - 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>--shell</option>
index 51ef3c01595caf5b9bd8c582fded2d2dc78c8579..8ac7c01294fcbf6facae0e8787387cd77d2ccbfd 100644 (file)
@@ -310,38 +310,37 @@ static int get_groups (char *list)
  */
 static /*@noreturn@*/void usage (int status)
 {
-       fprintf ((E_SUCCESS != status) ? stderr : stdout,
-                _("Usage: usermod [options] LOGIN\n"
-                "\n"
-                "Options:\n"
-                "  -c, --comment COMMENT         new value of the GECOS field\n"
-                "  -d, --home HOME_DIR           new home directory for the user account\n"
-                "  -e, --expiredate EXPIRE_DATE  set account expiration date to EXPIRE_DATE\n"
-                "  -f, --inactive INACTIVE       set password inactive after expiration\n"
-                "                                to INACTIVE\n"
-                "  -g, --gid GROUP               force use GROUP as new primary group\n"
-                "  -G, --groups GROUPS           new list of supplementary GROUPS\n"
-                "  -a, --append                  append the user to the supplemental GROUPS\n"
-                "                                mentioned by the -G option without removing\n"
-                "                                him/her from other groups\n"
-                "  -h, --help                    display this help message and exit\n"
-                "  -l, --login NEW_LOGIN         new value of the login name\n"
-                "  -L, --lock                    lock the user account\n"
-                "  -m, --move-home               move contents of the home directory to the\n"
-                "                                new location (use only with -d)\n"
-                "  -o, --non-unique              allow using duplicate (non-unique) UID\n"
-                "  -p, --password PASSWORD       use encrypted password for the new password\n"
-                "  -s, --shell SHELL             new login shell for the user account\n"
-                "  -u, --uid UID                 new UID for the user account\n"
-                "  -U, --unlock                  unlock the user account\n"
-                "%s"
-                "\n"),
+       FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
+       (void) fprintf (usageout,
+                       _("Usage: %s [options] LOGIN\n"
+                         "\n"
+                         "Options:\n"),
+                       Prog);
+       (void) fputs (_("  -c, --comment COMMENT         new value of the GECOS field\n"), usageout);
+       (void) fputs (_("  -d, --home HOME_DIR           new home directory for the user account\n"), usageout);
+       (void) fputs (_("  -e, --expiredate EXPIRE_DATE  set account expiration date to EXPIRE_DATE\n"), usageout);
+       (void) fputs (_("  -f, --inactive INACTIVE       set password inactive after expiration\n"
+                       "                                to INACTIVE\n"), usageout);
+       (void) fputs (_("  -g, --gid GROUP               force use GROUP as new primary group\n"), usageout);
+       (void) fputs (_("  -G, --groups GROUPS           new list of supplementary GROUPS\n"), usageout);
+       (void) fputs (_("  -a, --append                  append the user to the supplemental GROUPS\n"
+                       "                                mentioned by the -G option without removing\n"
+                       "                                him/her from other groups\n"), usageout);
+       (void) fputs (_("  -h, --help                    display this help message and exit\n"), usageout);
+       (void) fputs (_("  -l, --login NEW_LOGIN         new value of the login name\n"), usageout);
+       (void) fputs (_("  -L, --lock                    lock the user account\n"), usageout);
+       (void) fputs (_("  -m, --move-home               move contents of the home directory to the\n"
+                       "                                new location (use only with -d)\n"), usageout);
+       (void) fputs (_("  -o, --non-unique              allow using duplicate (non-unique) UID\n"), usageout);
+       (void) fputs (_("  -p, --password PASSWORD       use encrypted password for the new password\n"), usageout);
+       (void) fputs (_("  -R, --root CHROOT_DIR         directory to chroot into\n"), usageout);
+       (void) fputs (_("  -s, --shell SHELL             new login shell for the user account\n"), usageout);
+       (void) fputs (_("  -u, --uid UID                 new UID for the user account\n"), usageout);
+       (void) fputs (_("  -U, --unlock                  unlock the user account\n"), usageout);
 #ifdef WITH_SELINUX
-                _("  -Z, --selinux-user            new SELinux user mapping for the user account\n")
-#else
-                ""
+       (void) fputs (_("  -Z, --selinux-user            new SELinux user mapping for the user account\n"), usageout);
 #endif
-                );
+       (void) fputs ("\n", usageout);
        exit (status);
 }
 
@@ -889,6 +888,7 @@ static void process_flags (int argc, char **argv)
                        {"move-home", no_argument, NULL, 'm'},
                        {"non-unique", no_argument, NULL, 'o'},
                        {"password", required_argument, NULL, 'p'},
+                       {"root", required_argument, NULL, 'R'},
 #ifdef WITH_SELINUX
                        {"selinux-user", required_argument, NULL, 'Z'},
 #endif
@@ -899,9 +899,9 @@ static void process_flags (int argc, char **argv)
                };
                while ((c = getopt_long (argc, argv,
 #ifdef WITH_SELINUX
-                                        "ac:d:e:f:g:G:hl:Lmop:s:u:UZ:",
+                                        "ac:d:e:f:g:G:hl:Lmop:R:s:u:UZ:",
 #else
-                                        "ac:d:e:f:g:G:hl:Lmop:s:u:U",
+                                        "ac:d:e:f:g:G:hl:Lmop:R:s:u:U",
 #endif
                                         long_options, NULL)) != -1) {
                        switch (c) {
@@ -996,6 +996,8 @@ static void process_flags (int argc, char **argv)
                                user_pass = optarg;
                                pflg = true;
                                break;
+                       case 'R': /* no-op, handled in process_root_flag () */
+                               break;
                        case 's':
                                if (!VALID (optarg)) {
                                        fprintf (stderr,
@@ -1788,10 +1790,6 @@ int main (int argc, char **argv)
 #endif                         /* USE_PAM */
 #endif                         /* ACCT_TOOLS_SETUID */
 
-#ifdef WITH_AUDIT
-       audit_help_open ();
-#endif
-
        /*
         * Get my name so that I can use it to report errors.
         */
@@ -1801,12 +1799,17 @@ int main (int argc, char **argv)
        (void) bindtextdomain (PACKAGE, LOCALEDIR);
        (void) textdomain (PACKAGE);
 
+       process_root_flag ("-R", argc, argv);
+
+       OPENLOG ("usermod");
+#ifdef WITH_AUDIT
+       audit_help_open ();
+#endif
+
        sys_ngroups = sysconf (_SC_NGROUPS_MAX);
        user_groups = (char **) malloc (sizeof (char *) * (1 + sys_ngroups));
        user_groups[0] = (char *) 0;
 
-       OPENLOG ("usermod");
-
        is_shadow_pwd = spw_file_present ();
 #ifdef SHADOWGRP
        is_shadow_grp = sgr_file_present ();