* 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.
This commit is contained in:
nekral-guest 2011-11-06 18:38:26 +00:00
parent fc5cd8840e
commit 1aa30ba551
4 changed files with 34 additions and 12 deletions

View File

@ -36,6 +36,9 @@
* NEWS, src/passwd.c, man/passwd.1.xml: Add --root option. * NEWS, src/passwd.c, man/passwd.1.xml: Add --root option.
passwd's usage split in smaller messages. passwd's usage split in smaller messages.
* src/passwd.c: Call sanitize_env() before setting the locales. * 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> 2011-10-22 Nicolas François <nicolas.francois@centraliens.net>

1
NEWS
View File

@ -39,6 +39,7 @@ shadow-4.1.4.3 -> shadow-4.1.5 UNRELEASED
* Add --root option. * Add --root option.
- groupmems - groupmems
* Fix parsing of gshadow entries. * Fix parsing of gshadow entries.
* Add --root option.
- groupmod - groupmod
* Fixed groupmod when configured with --enable-account-tools-setuid. * Fixed groupmod when configured with --enable-account-tools-setuid.
* When the gshadow file exists but there are no gshadow entries, an entry * When the gshadow file exists but there are no gshadow entries, an entry

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
Copyright (c) 2005 , Tomasz Kłoczko Copyright (c) 2005 , Tomasz Kłoczko
Copyright (c) 2007 - 2008, Nicolas François Copyright (c) 2007 - 2011, Nicolas François
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
@ -139,6 +139,19 @@
</para> </para>
</listitem> </listitem>
</varlistentry> </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> </variablelist>
</refsect1> </refsect1>

View File

@ -2,7 +2,7 @@
* Copyright (c) 2000 , International Business Machines * Copyright (c) 2000 , International Business Machines
* George Kraft IV, gk4@us.ibm.com, 03/23/2000 * George Kraft IV, gk4@us.ibm.com, 03/23/2000
* Copyright (c) 2000 - 2006, Tomasz Kłoczko * Copyright (c) 2000 - 2006, Tomasz Kłoczko
* Copyright (c) 2007 - 2009, Nicolas François * Copyright (c) 2007 - 2011, Nicolas François
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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); const struct group *grp);
static void purge_members (const struct group *grp); static void purge_members (const struct group *grp);
static void display_members (const char *const *members); 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 process_flags (int argc, char **argv);
static void check_perms (void); static void check_perms (void);
static void fail_exit (int code); 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; FILE *usageout = (EXIT_SUCCESS != status) ? stderr : stdout;
(void) fprintf (usageout, (void) fprintf (usageout,
@ -371,6 +371,7 @@ static void usage (int status)
Prog); Prog);
(void) fputs (_(" -g, --group groupname change groupname instead of the user's group\n" (void) fputs (_(" -g, --group groupname change groupname instead of the user's group\n"
" (root only)\n"), usageout); " (root only)\n"), usageout);
(void) fputs (_(" -R, --root CHROOT_DIR directory to chroot into\n"), usageout);
(void) fputs (_("\n"), usageout); (void) fputs (_("\n"), usageout);
(void) fputs (_("Actions:\n"), usageout); (void) fputs (_("Actions:\n"), usageout);
(void) fputs (_(" -a, --add username add username to the members of the group\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) static void process_flags (int argc, char **argv)
{ {
int arg; int c;
int option_index = 0;
static struct option long_options[] = { static struct option long_options[] = {
{"add", required_argument, NULL, 'a'}, {"add", required_argument, NULL, 'a'},
{"delete", required_argument, NULL, 'd'}, {"delete", required_argument, NULL, 'd'},
@ -395,12 +395,13 @@ static void process_flags (int argc, char **argv)
{"help", no_argument, NULL, 'h'}, {"help", no_argument, NULL, 'h'},
{"list", no_argument, NULL, 'l'}, {"list", no_argument, NULL, 'l'},
{"purge", no_argument, NULL, 'p'}, {"purge", no_argument, NULL, 'p'},
{"root", required_argument, NULL, 'R'},
{NULL, 0, NULL, '\0'} {NULL, 0, NULL, '\0'}
}; };
while ((arg = getopt_long (argc, argv, "a:d:g:hlp", long_options, while ((c = getopt_long (argc, argv, "a:d:g:hlpR:",
&option_index)) != EOF) { long_options, NULL)) != EOF) {
switch (arg) { switch (c) {
case 'a': case 'a':
adduser = xstrdup (optarg); adduser = xstrdup (optarg);
++exclusive; ++exclusive;
@ -414,7 +415,7 @@ static void process_flags (int argc, char **argv)
break; break;
case 'h': case 'h':
usage (EXIT_SUCCESS); usage (EXIT_SUCCESS);
break; /*@notreached@*/break;
case 'l': case 'l':
list = true; list = true;
++exclusive; ++exclusive;
@ -423,6 +424,8 @@ static void process_flags (int argc, char **argv)
purge = true; purge = true;
++exclusive; ++exclusive;
break; break;
case 'R': /* no-op, handled in process_root_flag () */
break;
default: default:
usage (EXIT_USAGE); usage (EXIT_USAGE);
} }
@ -590,12 +593,14 @@ int main (int argc, char **argv)
*/ */
Prog = Basename (argv[0]); Prog = Basename (argv[0]);
OPENLOG ("groupmems");
(void) setlocale (LC_ALL, ""); (void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR); (void) bindtextdomain (PACKAGE, LOCALEDIR);
(void) textdomain (PACKAGE); (void) textdomain (PACKAGE);
process_root_flag ("-R", argc, argv);
OPENLOG ("groupmems");
#ifdef SHADOWGRP #ifdef SHADOWGRP
is_shadowgrp = sgr_file_present (); is_shadowgrp = sgr_file_present ();
#endif #endif