* NEWS, src/groupadd.c, man/groupadd.8.xml: Add --root option. Open

audit and syslog after the potential chroot.
	* src/groupmod.c: The index of long options is not used.
This commit is contained in:
nekral-guest 2011-11-06 18:37:51 +00:00
parent 057cbaa4ae
commit 9195f6085d
5 changed files with 36 additions and 16 deletions

View File

@ -11,10 +11,13 @@
in smaller messages. in smaller messages.
* NEWS, src/usermod.c, man/usermod.8.xml: Likewise * NEWS, src/usermod.c, man/usermod.8.xml: Likewise
* NEWS, src/groupadd.c, man/groupadd.8.xml: Add --root option. Open * NEWS, src/groupadd.c, man/groupadd.8.xml: Add --root option. Open
audit after the potential chroot. audit and syslog after the potential chroot.
* src/groupadd.c: Check atexit failures. * src/groupadd.c: Check atexit failures.
* src/groupadd.c: Return E_SUCCESS instead of exit'ing at the end * src/groupadd.c: Return E_SUCCESS instead of exit'ing at the end
of main(). of main().
* NEWS, src/groupadd.c, man/groupadd.8.xml: Add --root option. Open
audit and syslog after the potential chroot.
* src/groupmod.c: The 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

@ -38,6 +38,7 @@ shadow-4.1.4.3 -> shadow-4.1.5 UNRELEASED
* 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
is created if the password is changed and group requires a is created if the password is changed and group requires a
shadow entry. shadow entry.
* Add --root option.
- grpck - grpck
* NIS entries were dropped by -s (sort). * NIS entries were dropped by -s (sort).
-login -login

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
Copyright (c) 1991 , Julianne Frances Haugh Copyright (c) 1991 , Julianne Frances Haugh
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
@ -148,6 +148,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) 1991 - 1993, Julianne Frances Haugh * Copyright (c) 1991 - 1993, Julianne Frances Haugh
* Copyright (c) 1996 - 2000, Marek Michałkiewicz * Copyright (c) 1996 - 2000, Marek Michałkiewicz
* 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 bool is_shadow_grp;
#endif #endif
/* local function prototypes */ /* local function prototypes */
static void usage (int status); static /*@noreturn@*/void usage (int status);
static void new_grent (struct group *grent); static void new_grent (struct group *grent);
#ifdef SHADOWGRP #ifdef SHADOWGRP
@ -105,7 +105,7 @@ static void check_perms (void);
/* /*
* usage - display usage message and exit * usage - display usage message and exit
*/ */
static void usage (int status) static /*@noreturn@*/void usage (int status)
{ {
FILE *usageout = (E_SUCCESS != status) ? stderr : stdout; FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
(void) fprintf (usageout, (void) fprintf (usageout,
@ -414,7 +414,7 @@ static void process_flags (int argc, char **argv)
break; break;
case 'h': case 'h':
usage (E_SUCCESS); usage (E_SUCCESS);
break; /*@notreached@*/break;
case 'K': case 'K':
/* /*
* override login.defs defaults (-K name=value) * override login.defs defaults (-K name=value)

View File

@ -127,6 +127,7 @@ static void usage (int status)
(void) fputs (_(" -o, --non-unique allow to use a duplicate (non-unique) GID\n"), usageout); (void) fputs (_(" -o, --non-unique allow to use a duplicate (non-unique) GID\n"), usageout);
(void) fputs (_(" -p, --password PASSWORD change the password to this (encrypted)\n" (void) fputs (_(" -p, --password PASSWORD change the password to this (encrypted)\n"
" PASSWORD\n"), usageout); " PASSWORD\n"), usageout);
(void) fputs (_(" -R, --root CHROOT_DIR directory to chroot into\n"), usageout);
(void) fputs ("\n", usageout); (void) fputs ("\n", usageout);
exit (status); exit (status);
} }
@ -367,7 +368,6 @@ static void check_new_name (void)
*/ */
static void process_flags (int argc, char **argv) static void process_flags (int argc, char **argv)
{ {
int option_index = 0;
int c; int c;
static struct option long_options[] = { static struct option long_options[] = {
{"gid", required_argument, NULL, 'g'}, {"gid", required_argument, NULL, 'g'},
@ -375,11 +375,11 @@ static void process_flags (int argc, char **argv)
{"new-name", required_argument, NULL, 'n'}, {"new-name", required_argument, NULL, 'n'},
{"non-unique", no_argument, NULL, 'o'}, {"non-unique", no_argument, NULL, 'o'},
{"password", required_argument, NULL, 'p'}, {"password", required_argument, NULL, 'p'},
{"root", required_argument, NULL, 'R'},
{NULL, 0, NULL, '\0'} {NULL, 0, NULL, '\0'}
}; };
while ((c = while ((c = getopt_long (argc, argv, "g:hn:op:R:",
getopt_long (argc, argv, "g:hn:op:", long_options, NULL)) != -1) {
long_options, &option_index)) != -1) {
switch (c) { switch (c) {
case 'g': case 'g':
gflg = true; gflg = true;
@ -405,6 +405,8 @@ static void process_flags (int argc, char **argv)
group_passwd = optarg; group_passwd = optarg;
pflg = true; pflg = true;
break; break;
case 'R': /* no-op, handled in process_root_flag () */
break;
default: default:
usage (E_USAGE); usage (E_USAGE);
} }
@ -734,10 +736,6 @@ int main (int argc, char **argv)
#endif /* USE_PAM */ #endif /* USE_PAM */
#endif /* ACCT_TOOLS_SETUID */ #endif /* ACCT_TOOLS_SETUID */
#ifdef WITH_AUDIT
audit_help_open ();
#endif
/* /*
* Get my name so that I can use it to report errors. * Get my name so that I can use it to report errors.
*/ */
@ -747,6 +745,13 @@ int main (int argc, char **argv)
(void) bindtextdomain (PACKAGE, LOCALEDIR); (void) bindtextdomain (PACKAGE, LOCALEDIR);
(void) textdomain (PACKAGE); (void) textdomain (PACKAGE);
process_root_flag ("-R", argc, argv);
OPENLOG ("groupmod");
#ifdef WITH_AUDIT
audit_help_open ();
#endif
if (atexit (do_cleanups) != 0) { if (atexit (do_cleanups) != 0) {
fprintf (stderr, fprintf (stderr,
_("%s: Cannot setup cleanup service.\n"), _("%s: Cannot setup cleanup service.\n"),
@ -756,8 +761,6 @@ int main (int argc, char **argv)
process_flags (argc, argv); process_flags (argc, argv);
OPENLOG ("groupmod");
#ifdef ACCT_TOOLS_SETUID #ifdef ACCT_TOOLS_SETUID
#ifdef USE_PAM #ifdef USE_PAM
{ {