(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"
" PASSWORD\n"), usageout);
+ (void) fputs (_(" -R, --root CHROOT_DIR directory to chroot into\n"), usageout);
(void) fputs ("\n", usageout);
exit (status);
}
*/
static void process_flags (int argc, char **argv)
{
- int option_index = 0;
int c;
static struct option long_options[] = {
{"gid", required_argument, NULL, 'g'},
{"new-name", required_argument, NULL, 'n'},
{"non-unique", no_argument, NULL, 'o'},
{"password", required_argument, NULL, 'p'},
+ {"root", required_argument, NULL, 'R'},
{NULL, 0, NULL, '\0'}
};
- while ((c =
- getopt_long (argc, argv, "g:hn:op:",
- long_options, &option_index)) != -1) {
+ while ((c = getopt_long (argc, argv, "g:hn:op:R:",
+ long_options, NULL)) != -1) {
switch (c) {
case 'g':
gflg = true;
group_passwd = optarg;
pflg = true;
break;
+ case 'R': /* no-op, handled in process_root_flag () */
+ break;
default:
usage (E_USAGE);
}
#endif
(void) snprintf (info_passwd.action,
511 - strlen (info_group.audit_msg),
- "group %s/%lu", group_name, (unsigned long int) group_id);
+ "group %s/%lu",
+ group_name, (unsigned long int) group_id);
if (nflg) {
strncat (info_group.action, ", new name: ",
#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.
*/
(void) bindtextdomain (PACKAGE, LOCALEDIR);
(void) textdomain (PACKAGE);
- process_flags (argc, argv);
+ process_root_flag ("-R", argc, argv);
OPENLOG ("groupmod");
+#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