* NEWS, src/userdel.c, src/lastlog.c, src/gpasswd.c,

src/newusers.c, src/chpasswd.c, src/groupmems.c, src/usermod.c,
	src/chgpasswd.c, src/vipw.c, src/su.c, src/useradd.c,
	src/groupmod.c, src/passwd.c, src/groupadd.c, src/chage.c,
	src/faillog.c, src/chsh.c: If someone uses the -h/--help options,
	the usage should not go to stderr nor should the utility exit with
	non-zero status. All of the shadow utils do just this
	unfortunately, so convert them over to sanity.
	* man/groupmems.8.xml, man/gpasswd.1.xml: Added option -h/--help.
This commit is contained in:
nekral-guest
2009-09-04 23:02:33 +00:00
parent 3d10e75117
commit 91b60a955c
21 changed files with 271 additions and 205 deletions

View File

@ -93,7 +93,7 @@ static bool
pflg = false; /* new encrypted password */
/* local function prototypes */
static void usage (void);
static void usage (int status);
static void new_grent (struct group *);
#ifdef SHADOWGRP
@ -113,21 +113,22 @@ static void update_primary_groups (gid_t ogid, gid_t ngid);
* usage - display usage message and exit
*/
static void usage (void)
static void usage (int status)
{
(void) fprintf (stderr,
FILE *usageout = status ? stderr : stdout;
(void) fprintf (usageout,
_("Usage: %s [options] GROUP\n"
"\n"
"Options:\n"),
Prog);
(void) fputs (_(" -g, --gid GID change the group ID to GID\n"), stderr);
(void) fputs (_(" -h, --help display this help message and exit\n"), stderr);
(void) fputs (_(" -n, --new-name NEW_GROUP change the name to NEW_GROUP\n"), stderr);
(void) fputs (_(" -o, --non-unique allow to use a duplicate (non-unique) GID\n"), stderr);
(void) fputs (_(" -g, --gid GID change the group ID to GID\n"), usageout);
(void) fputs (_(" -h, --help display this help message and exit\n"), usageout);
(void) fputs (_(" -n, --new-name NEW_GROUP change the name to NEW_GROUP\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"
" PASSWORD\n"), stderr);
(void) fputs ("\n", stderr);
exit (E_USAGE);
" PASSWORD\n"), usageout);
(void) fputs ("\n", usageout);
exit (status);
}
/*
@ -362,6 +363,8 @@ static void process_flags (int argc, char **argv)
exit (E_BAD_ARG);
}
break;
case 'h':
usage (E_SUCCESS);
case 'n':
nflg = true;
group_newname = optarg;
@ -374,16 +377,16 @@ static void process_flags (int argc, char **argv)
pflg = true;
break;
default:
usage ();
usage (E_USAGE);
}
}
if (oflg && !gflg) {
usage ();
usage (E_USAGE);
}
if (optind != (argc - 1)) {
usage ();
usage (E_USAGE);
}
group_name = argv[argc - 1];