]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
* NEWS, src/chsh.c, man/chsh.1.xml: Add --root option.
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sun, 6 Nov 2011 18:38:32 +0000 (18:38 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sun, 6 Nov 2011 18:38:32 +0000 (18:38 +0000)
chsh's usage split in smaller messages.
* src/chsh.c: The getopt index of long options is not used.

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

index 61210d1016f44c2b94597035122062e81c91f12c..533ec062feeaee83c427b0194bacf32a229e8e20 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -39,6 +39,9 @@
        * NEWS, src/groupmems.c, man/groupmems.8.xml: Add --root option.
        Open syslog after the potential chroot.
        * src/groupmems.c: The getopt index of long options is not used.
+       * NEWS, src/chsh.c, man/chsh.1.xml: Add --root option.
+       chsh's usage split in smaller messages.
+       * src/chsh.c: The getopt index of long options is not used.
 
 2011-10-22  Nicolas François  <nicolas.francois@centraliens.net>
 
diff --git a/NEWS b/NEWS
index a50af47a534d3ef0cae2b94f72efbcd9005ab075..eba10609cfd842ae8e76190854e82ba77c536ed3 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -30,6 +30,8 @@ shadow-4.1.4.3 -> shadow-4.1.5                                        UNRELEASED
     is created if the password is changed and passwd requires a
     shadow entry.
   * Add --root option.
+- chsh
+  * Add --root option.
 - faillog
   * The -l, -m, -r, -t options only act on the existing users, unless -a is
     specified.
index e93c6f9d49b35a7ff33ce30fedf21e69903ae1dd..f53d8aa9f951b567265d4687c780cdc1ccd5ff0e 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
    Copyright (c) 1990       , Julianne Frances Haugh
-   Copyright (c) 2007 - 2008, 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>Display help message and exit.</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> <replaceable>SHELL</replaceable>
index a2e8fe7f974451d1d4af241ed9f0d39a7f4d9cfd..75171d82ab0b82278c4ab90fc928c49cfa2ad354 100644 (file)
@@ -103,12 +103,16 @@ static void fail_exit (int code)
  */
 static void usage (int status)
 {
-       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"), (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 (_("  -h, --help                    display this help message and exit\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 ("\n", usageout);
        exit (status);
 }
 
@@ -200,21 +204,22 @@ static bool shell_is_listed (const char *sh)
  */
 static void process_flags (int argc, char **argv)
 {
-       int option_index = 0;
        int c;
        static struct option long_options[] = {
                {"help", no_argument, NULL, 'h'},
+               {"root", required_argument, NULL, 'R'},
                {"shell", required_argument, NULL, 's'},
                {NULL, 0, NULL, '\0'}
        };
 
-       while ((c =
-               getopt_long (argc, argv, "hs:", long_options,
-                            &option_index)) != -1) {
+       while ((c = getopt_long (argc, argv, "hR:s:",
+                                long_options, NULL)) != -1) {
                switch (c) {
                case 'h':
                        usage (E_SUCCESS);
                        break;
+               case 'R': /* no-op, handled in process_root_flag () */
+                       break;
                case 's':
                        sflg = true;
                        STRFCPY (loginsh, optarg);
@@ -432,21 +437,23 @@ int main (int argc, char **argv)
 
        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);
+
        /*
         * This command behaves different for root and non-root users.
         */
        amroot = (getuid () == 0);
 
-       /*
-        * Get the program name. The program name is used as a prefix to
-        * most error messages.
-        */
-       Prog = Basename (argv[0]);
-
        OPENLOG ("chsh");
 
        /* parse the command line options */