* src/groupdel.c: Add process_flags().
* src/groupdel.c, man/groupdel.8.xml: Add --help option. * NEWS, src/groupdel.c, man/groupdel.8.xml: Add --root option. Open audit and syslog after the potential chroot. * src/groupdel.c: Check atexit failures.
This commit is contained in:
parent
9195f6085d
commit
c017dd73aa
@ -18,6 +18,11 @@
|
||||
* 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.
|
||||
* src/groupdel.c: Add process_flags().
|
||||
* src/groupdel.c, man/groupdel.8.xml: Add --help option.
|
||||
* NEWS, src/groupdel.c, man/groupdel.8.xml: Add --root option. Open
|
||||
audit and syslog after the potential chroot.
|
||||
* src/groupdel.c: Check atexit failures.
|
||||
|
||||
2011-10-22 Nicolas François <nicolas.francois@centraliens.net>
|
||||
|
||||
|
2
NEWS
2
NEWS
@ -33,6 +33,8 @@ shadow-4.1.4.3 -> shadow-4.1.5 UNRELEASED
|
||||
specified.
|
||||
- groupadd
|
||||
* Add --root option.
|
||||
- groupdel
|
||||
* 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
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (c) 1991 - 1993, 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
|
||||
@ -50,20 +50,50 @@
|
||||
<refsynopsisdiv id='synopsis'>
|
||||
<cmdsynopsis>
|
||||
<command>groupdel</command>
|
||||
<arg choice='plain'>
|
||||
<replaceable>group</replaceable>
|
||||
<arg choice='opt'>
|
||||
<replaceable>options</replaceable>
|
||||
</arg>
|
||||
<arg choice='plain'><replaceable>GROUP</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1 id='description'>
|
||||
<title>DESCRIPTION</title>
|
||||
<para> The <command>groupdel</command> command modifies the system
|
||||
account files, deleting all entries that refer to <emphasis
|
||||
remap='I'>group</emphasis>. The named group must exist.
|
||||
account files, deleting all entries that refer to
|
||||
<replaceable>GROUP</replaceable>. The named group must exist.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id='options'>
|
||||
<title>OPTIONS</title>
|
||||
<para>
|
||||
The options which apply to the <command>groupdel</command> command
|
||||
are:
|
||||
</para>
|
||||
<variablelist remap='IP'>
|
||||
<varlistentry>
|
||||
<term><option>-h</option>, <option>--help</option></term>
|
||||
<listitem>
|
||||
<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>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id='caveats'>
|
||||
<title>CAVEATS</title>
|
||||
<para>
|
||||
@ -147,7 +177,8 @@
|
||||
|
||||
<refsect1 id='see_also'>
|
||||
<title>SEE ALSO</title>
|
||||
<para><citerefentry>
|
||||
<para>
|
||||
<citerefentry>
|
||||
<refentrytitle>chfn</refentrytitle><manvolnum>1</manvolnum>
|
||||
</citerefentry>,
|
||||
<citerefentry>
|
||||
@ -173,7 +204,7 @@
|
||||
</citerefentry>,
|
||||
<citerefentry>
|
||||
<refentrytitle>usermod</refentrytitle><manvolnum>8</manvolnum>
|
||||
</citerefentry>
|
||||
</citerefentry>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright (c) 1991 - 1994, Julianne Frances Haugh
|
||||
* Copyright (c) 1996 - 2000, Marek Michałkiewicz
|
||||
* Copyright (c) 2000 - 2006, 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
|
||||
@ -45,6 +45,7 @@
|
||||
#endif /* ACCT_TOOLS_SETUID */
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <getopt.h>
|
||||
#include "defines.h"
|
||||
#include "groupio.h"
|
||||
#include "nscd.h"
|
||||
@ -75,19 +76,28 @@ static bool is_shadow_grp;
|
||||
#define E_GRP_UPDATE 10 /* can't update group file */
|
||||
|
||||
/* local function prototypes */
|
||||
static void usage (void);
|
||||
static /*@noreturn@*/void usage (int status);
|
||||
static void grp_update (void);
|
||||
static void close_files (void);
|
||||
static void open_files (void);
|
||||
static void group_busy (gid_t);
|
||||
static void group_busy (gid_t gid);
|
||||
static void process_flags (int argc, char **argv);
|
||||
|
||||
/*
|
||||
* usage - display usage message and exit
|
||||
*/
|
||||
static void usage (void)
|
||||
static /*@noreturn@*/void usage (int status)
|
||||
{
|
||||
fputs (_("Usage: groupdel group\n"), stderr);
|
||||
exit (E_USAGE);
|
||||
FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
|
||||
(void) fprintf (usageout,
|
||||
_("Usage: %s [options] GROUP\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 ("\n", usageout);
|
||||
exit (status);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -294,6 +304,42 @@ static void group_busy (gid_t gid)
|
||||
exit (E_GROUP_BUSY);
|
||||
}
|
||||
|
||||
/*
|
||||
* process_flags - parse the command line options
|
||||
*
|
||||
* It will not return if an error is encountered.
|
||||
*/
|
||||
static void process_flags (int argc, char **argv)
|
||||
{
|
||||
/*
|
||||
* Parse the command line options.
|
||||
*/
|
||||
int c;
|
||||
static struct option long_options[] = {
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
{"root", required_argument, NULL, 'R'},
|
||||
{NULL, 0, NULL, '\0'}
|
||||
};
|
||||
|
||||
while ((c = getopt_long (argc, argv, "hR:",
|
||||
long_options, NULL)) != -1) {
|
||||
switch (c) {
|
||||
case 'h':
|
||||
usage (E_SUCCESS);
|
||||
/*@notreached@*/break;
|
||||
case 'R': /* no-op, handled in process_root_flag () */
|
||||
break;
|
||||
default:
|
||||
usage (E_USAGE);
|
||||
}
|
||||
}
|
||||
|
||||
if (optind != argc - 1) {
|
||||
usage (E_USAGE);
|
||||
}
|
||||
group_name = argv[optind];
|
||||
}
|
||||
|
||||
/*
|
||||
* main - groupdel command
|
||||
*
|
||||
@ -313,28 +359,30 @@ int main (int argc, char **argv)
|
||||
#endif /* USE_PAM */
|
||||
#endif /* ACCT_TOOLS_SETUID */
|
||||
|
||||
#ifdef WITH_AUDIT
|
||||
audit_help_open ();
|
||||
#endif
|
||||
atexit (do_cleanups);
|
||||
|
||||
/*
|
||||
* Get my name so that I can use it to report errors.
|
||||
*/
|
||||
|
||||
Prog = Basename (argv[0]);
|
||||
|
||||
(void) setlocale (LC_ALL, "");
|
||||
(void) bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
(void) textdomain (PACKAGE);
|
||||
|
||||
if (argc != 2) {
|
||||
usage ();
|
||||
}
|
||||
|
||||
group_name = argv[1];
|
||||
process_root_flag ("-R", argc, argv);
|
||||
|
||||
OPENLOG ("groupdel");
|
||||
#ifdef WITH_AUDIT
|
||||
audit_help_open ();
|
||||
#endif
|
||||
|
||||
if (atexit (do_cleanups) != 0) {
|
||||
fprintf (stderr,
|
||||
_("%s: Cannot setup cleanup service.\n"),
|
||||
Prog);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
process_flags (argc, argv);
|
||||
|
||||
#ifdef ACCT_TOOLS_SETUID
|
||||
#ifdef USE_PAM
|
||||
|
Loading…
Reference in New Issue
Block a user