[Pkg-shadow-commits] r3540 - in upstream/trunk: . man src

Nicolas FRANÇOIS nekral-guest at alioth.debian.org
Sun Nov 6 18:37:58 UTC 2011


Author: nekral-guest
Date: 2011-11-06 18:37:57 +0000 (Sun, 06 Nov 2011)
New Revision: 3540

Modified:
   upstream/trunk/ChangeLog
   upstream/trunk/NEWS
   upstream/trunk/man/groupdel.8.xml
   upstream/trunk/src/groupdel.c
Log:
	* 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.

Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog	2011-11-06 18:37:51 UTC (rev 3539)
+++ upstream/trunk/ChangeLog	2011-11-06 18:37:57 UTC (rev 3540)
@@ -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 at centraliens.net>
 

Modified: upstream/trunk/NEWS
===================================================================
--- upstream/trunk/NEWS	2011-11-06 18:37:51 UTC (rev 3539)
+++ upstream/trunk/NEWS	2011-11-06 18:37:57 UTC (rev 3540)
@@ -33,6 +33,8 @@
     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

Modified: upstream/trunk/man/groupdel.8.xml
===================================================================
--- upstream/trunk/man/groupdel.8.xml	2011-11-06 18:37:51 UTC (rev 3539)
+++ upstream/trunk/man/groupdel.8.xml	2011-11-06 18:37:57 UTC (rev 3540)
@@ -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>

Modified: upstream/trunk/src/groupdel.c
===================================================================
--- upstream/trunk/src/groupdel.c	2011-11-06 18:37:51 UTC (rev 3539)
+++ upstream/trunk/src/groupdel.c	2011-11-06 18:37:57 UTC (rev 3540)
@@ -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 @@
 #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);
 }
 
 /*
@@ -295,6 +305,42 @@
 }
 
 /*
+ * 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
  *
  *	The syntax of the groupdel command is
@@ -313,29 +359,31 @@
 #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 ();
+	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);
 	}
 
-	group_name = argv[1];
+	process_flags (argc, argv);
 
-	OPENLOG ("groupdel");
-
 #ifdef ACCT_TOOLS_SETUID
 #ifdef USE_PAM
 	{




More information about the Pkg-shadow-commits mailing list