]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
* NEWS, src/groupmems.c, man/groupmems.8.xml: Add --root option.
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sun, 6 Nov 2011 18:38:26 +0000 (18:38 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sun, 6 Nov 2011 18:38:26 +0000 (18:38 +0000)
Open syslog after the potential chroot.
* src/groupmems.c: The getopt index of long options is not used.

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

index 4a8186169c734b0af904bc6399fa29db08f66516..61210d1016f44c2b94597035122062e81c91f12c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -36,6 +36,9 @@
        * 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.
+       * 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.
 
 2011-10-22  Nicolas François  <nicolas.francois@centraliens.net>
 
diff --git a/NEWS b/NEWS
index 98e3733a49be00b6bf9392a3b2c0d89fe0f9c773..a50af47a534d3ef0cae2b94f72efbcd9005ab075 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -39,6 +39,7 @@ shadow-4.1.4.3 -> shadow-4.1.5                                        UNRELEASED
   * Add --root option.
 - groupmems
   * Fix parsing of gshadow entries.
+  * Add --root option.
 - groupmod
   * Fixed groupmod when configured with --enable-account-tools-setuid.
   * When the gshadow file exists but there are no gshadow entries, an entry
index 01a6b8005feff5b1f42d3489707e8015971ac0bc..96964fe1511499ae9b8ce81d6bd1af3924944114 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
    Copyright (c) 2005       , Tomasz Kłoczko
-   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>
        </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>
     </variablelist>
   </refsect1>
 
index 5bb2ebe353bf9ea1904506f744288e711eab4629..0643d707c468b0a3caa8ceaa88bc71f981bcf89e 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 2000       , International Business Machines
  *                            George Kraft IV, gk4@us.ibm.com, 03/23/2000
  * 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
@@ -88,7 +88,7 @@ static void remove_user (const char *user,
                          const struct group *grp);
 static void purge_members (const struct group *grp);
 static void display_members (const char *const *members);
-static void usage (int status);
+static /*@noreturn@*/void usage (int status);
 static void process_flags (int argc, char **argv);
 static void check_perms (void);
 static void fail_exit (int code);
@@ -361,7 +361,7 @@ static void display_members (const char *const *members)
        }
 }
 
-static void usage (int status)
+static /*@noreturn@*/void usage (int status)
 {
        FILE *usageout = (EXIT_SUCCESS != status) ? stderr : stdout;
        (void) fprintf (usageout,
@@ -371,6 +371,7 @@ static void usage (int status)
                        Prog);
        (void) fputs (_("  -g, --group groupname         change groupname instead of the user's group\n"
                        "                                (root only)\n"), usageout);
+       (void) fputs (_("  -R, --root CHROOT_DIR         directory to chroot into\n"), usageout);
        (void) fputs (_("\n"), usageout);
        (void) fputs (_("Actions:\n"), usageout);
        (void) fputs (_("  -a, --add username            add username to the members of the group\n"), usageout);
@@ -386,8 +387,7 @@ static void usage (int status)
  */
 static void process_flags (int argc, char **argv)
 {
-       int arg;
-       int option_index = 0;
+       int c;
        static struct option long_options[] = {
                {"add", required_argument, NULL, 'a'},
                {"delete", required_argument, NULL, 'd'},
@@ -395,12 +395,13 @@ static void process_flags (int argc, char **argv)
                {"help", no_argument, NULL, 'h'},
                {"list", no_argument, NULL, 'l'},
                {"purge", no_argument, NULL, 'p'},
+               {"root", required_argument, NULL, 'R'},
                {NULL, 0, NULL, '\0'}
        };
 
-       while ((arg = getopt_long (argc, argv, "a:d:g:hlp", long_options,
-                                  &option_index)) != EOF) {
-               switch (arg) {
+       while ((c = getopt_long (argc, argv, "a:d:g:hlpR:",
+                                long_options, NULL)) != EOF) {
+               switch (c) {
                case 'a':
                        adduser = xstrdup (optarg);
                        ++exclusive;
@@ -414,7 +415,7 @@ static void process_flags (int argc, char **argv)
                        break;
                case 'h':
                        usage (EXIT_SUCCESS);
-                       break;
+                       /*@notreached@*/break;
                case 'l':
                        list = true;
                        ++exclusive;
@@ -423,6 +424,8 @@ static void process_flags (int argc, char **argv)
                        purge = true;
                        ++exclusive;
                        break;
+               case 'R': /* no-op, handled in process_root_flag () */
+                       break;
                default:
                        usage (EXIT_USAGE);
                }
@@ -590,12 +593,14 @@ int main (int argc, char **argv)
         */
        Prog = Basename (argv[0]);
 
-       OPENLOG ("groupmems");
-
        (void) setlocale (LC_ALL, "");
        (void) bindtextdomain (PACKAGE, LOCALEDIR);
        (void) textdomain (PACKAGE);
 
+       process_root_flag ("-R", argc, argv);
+
+       OPENLOG ("groupmems");
+
 #ifdef SHADOWGRP
        is_shadowgrp = sgr_file_present ();
 #endif