* 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:
parent
3d10e75117
commit
91b60a955c
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
|||||||
|
2009-09-05 Mike Frysinger <vapier@gentoo.org>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
2009-09-05 Nicolas François <nicolas.francois@centraliens.net>
|
2009-09-05 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* src/useradd.c: Fixed wrong format string.
|
* src/useradd.c: Fixed wrong format string.
|
||||||
|
6
NEWS
6
NEWS
@ -1,5 +1,11 @@
|
|||||||
$Id$
|
$Id$
|
||||||
|
|
||||||
|
shadow-4.1.4.1 -> shadow-4.1.4.2 UNRELEASED
|
||||||
|
|
||||||
|
- general
|
||||||
|
* report usage error to stderr, but report usage help to stdout (and return
|
||||||
|
zero) when explicitly requested (e.g. with --help).
|
||||||
|
|
||||||
shadow-4.1.4.1 -> shadow-4.1.4.2 2009-07-24
|
shadow-4.1.4.1 -> shadow-4.1.4.2 2009-07-24
|
||||||
|
|
||||||
- general
|
- general
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!--
|
<!--
|
||||||
Copyright (c) 1996 , Rafal Maszkowski
|
Copyright (c) 1996 , Rafal Maszkowski
|
||||||
Copyright (c) 2007 - 2008, Nicolas François
|
Copyright (c) 2007 - 2009, 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
|
||||||
@ -146,6 +146,14 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
<variablelist remap='IP'>
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>-h</option>, <option>--help</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>Display help message and exit.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
<variablelist remap='IP'>
|
<variablelist remap='IP'>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
|
@ -113,6 +113,12 @@
|
|||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>-h</option>, <option>--help</option></term>
|
||||||
|
<listitem>
|
||||||
|
<para>Display help message and exit.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>-l</option>, <option>--list</option></term>
|
<term><option>-l</option>, <option>--list</option></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
28
src/chage.c
28
src/chage.c
@ -91,7 +91,7 @@ static long expdate;
|
|||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
static bool isnum (const char *s);
|
static bool isnum (const char *s);
|
||||||
static void usage (void);
|
static void usage (int status);
|
||||||
static void date_to_str (char *buf, size_t maxsize, time_t date);
|
static void date_to_str (char *buf, size_t maxsize, time_t date);
|
||||||
static int new_fields (void);
|
static int new_fields (void);
|
||||||
static void print_date (time_t date);
|
static void print_date (time_t date);
|
||||||
@ -152,7 +152,7 @@ static bool isnum (const char *s)
|
|||||||
/*
|
/*
|
||||||
* usage - print command line syntax and exit
|
* usage - print command line syntax and exit
|
||||||
*/
|
*/
|
||||||
static void usage (void)
|
static void usage (int status)
|
||||||
{
|
{
|
||||||
fputs (_("Usage: chage [options] [LOGIN]\n"
|
fputs (_("Usage: chage [options] [LOGIN]\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -168,8 +168,8 @@ static void usage (void)
|
|||||||
" -M, --maxdays MAX_DAYS set maximim number of days before password\n"
|
" -M, --maxdays MAX_DAYS set maximim number of days before password\n"
|
||||||
" change to MAX_DAYS\n"
|
" change to MAX_DAYS\n"
|
||||||
" -W, --warndays WARN_DAYS set expiration warning days to WARN_DAYS\n"
|
" -W, --warndays WARN_DAYS set expiration warning days to WARN_DAYS\n"
|
||||||
"\n"), stderr);
|
"\n"), status ? stderr : stdout);
|
||||||
exit (E_USAGE);
|
exit (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void date_to_str (char *buf, size_t maxsize, time_t date)
|
static void date_to_str (char *buf, size_t maxsize, time_t date)
|
||||||
@ -413,7 +413,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: invalid date '%s'\n"),
|
_("%s: invalid date '%s'\n"),
|
||||||
Prog, optarg);
|
Prog, optarg);
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'E':
|
case 'E':
|
||||||
@ -425,11 +425,11 @@ static void process_flags (int argc, char **argv)
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: invalid date '%s'\n"),
|
_("%s: invalid date '%s'\n"),
|
||||||
Prog, optarg);
|
Prog, optarg);
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
usage ();
|
usage (E_SUCCESS);
|
||||||
break;
|
break;
|
||||||
case 'I':
|
case 'I':
|
||||||
Iflg = true;
|
Iflg = true;
|
||||||
@ -438,7 +438,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: invalid numeric argument '%s'\n"),
|
_("%s: invalid numeric argument '%s'\n"),
|
||||||
Prog, optarg);
|
Prog, optarg);
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
@ -451,7 +451,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: invalid numeric argument '%s'\n"),
|
_("%s: invalid numeric argument '%s'\n"),
|
||||||
Prog, optarg);
|
Prog, optarg);
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'M':
|
case 'M':
|
||||||
@ -461,7 +461,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: invalid numeric argument '%s'\n"),
|
_("%s: invalid numeric argument '%s'\n"),
|
||||||
Prog, optarg);
|
Prog, optarg);
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'W':
|
case 'W':
|
||||||
@ -471,11 +471,11 @@ static void process_flags (int argc, char **argv)
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: invalid numeric argument '%s'\n"),
|
_("%s: invalid numeric argument '%s'\n"),
|
||||||
Prog, optarg);
|
Prog, optarg);
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,14 +495,14 @@ static void check_flags (int argc, int opt_index)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (argc != opt_index + 1) {
|
if (argc != opt_index + 1) {
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lflg && (mflg || Mflg || dflg || Wflg || Iflg || Eflg)) {
|
if (lflg && (mflg || Mflg || dflg || Wflg || Iflg || Eflg)) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: do not include \"l\" with other flags\n"),
|
_("%s: do not include \"l\" with other flags\n"),
|
||||||
Prog);
|
Prog);
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ static bool gr_locked = false;
|
|||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
static void fail_exit (int code);
|
static void fail_exit (int code);
|
||||||
static void usage (void);
|
static void usage (int status);
|
||||||
static void process_flags (int argc, char **argv);
|
static void process_flags (int argc, char **argv);
|
||||||
static void check_flags (void);
|
static void check_flags (void);
|
||||||
static void check_perms (void);
|
static void check_perms (void);
|
||||||
@ -114,9 +114,10 @@ static void fail_exit (int code)
|
|||||||
/*
|
/*
|
||||||
* usage - display usage message and exit
|
* usage - display usage message and exit
|
||||||
*/
|
*/
|
||||||
static void usage (void)
|
static void usage (int status)
|
||||||
{
|
{
|
||||||
fprintf (stderr, _("Usage: %s [options]\n"
|
fprintf (status ? stderr : stdout,
|
||||||
|
_("Usage: %s [options]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" -c, --crypt-method the crypt method (one of %s)\n"
|
" -c, --crypt-method the crypt method (one of %s)\n"
|
||||||
@ -135,7 +136,7 @@ static void usage (void)
|
|||||||
" crypt algorithms\n")
|
" crypt algorithms\n")
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
exit (E_USAGE);
|
exit (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -174,7 +175,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
eflg = true;
|
eflg = true;
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
usage ();
|
usage (E_SUCCESS);
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
md5flg = true;
|
md5flg = true;
|
||||||
@ -186,12 +187,12 @@ static void process_flags (int argc, char **argv)
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: invalid numeric argument '%s'\n"),
|
_("%s: invalid numeric argument '%s'\n"),
|
||||||
Prog, optarg);
|
Prog, optarg);
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -212,7 +213,7 @@ static void check_flags (void)
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: %s flag is only allowed with the %s flag\n"),
|
_("%s: %s flag is only allowed with the %s flag\n"),
|
||||||
Prog, "-s", "-c");
|
Prog, "-s", "-c");
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -221,7 +222,7 @@ static void check_flags (void)
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: the -c, -e, and -m flags are exclusive\n"),
|
_("%s: the -c, -e, and -m flags are exclusive\n"),
|
||||||
Prog);
|
Prog);
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cflg) {
|
if (cflg) {
|
||||||
@ -236,7 +237,7 @@ static void check_flags (void)
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: unsupported crypt method: %s\n"),
|
_("%s: unsupported crypt method: %s\n"),
|
||||||
Prog, crypt_method);
|
Prog, crypt_method);
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ static bool spw_locked = false;
|
|||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
static void fail_exit (int code);
|
static void fail_exit (int code);
|
||||||
static void usage (void);
|
static void usage (int status);
|
||||||
static void process_flags (int argc, char **argv);
|
static void process_flags (int argc, char **argv);
|
||||||
static void check_flags (void);
|
static void check_flags (void);
|
||||||
static void check_perms (void);
|
static void check_perms (void);
|
||||||
@ -112,15 +112,16 @@ static void fail_exit (int code)
|
|||||||
/*
|
/*
|
||||||
* usage - display usage message and exit
|
* 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]\n"
|
_("Usage: %s [options]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Options:\n"),
|
"Options:\n"),
|
||||||
Prog);
|
Prog);
|
||||||
#ifndef USE_PAM
|
#ifndef USE_PAM
|
||||||
(void) fprintf (stderr,
|
(void) fprintf (usageout,
|
||||||
_(" -c, --crypt-method the crypt method (one of %s)\n"),
|
_(" -c, --crypt-method the crypt method (one of %s)\n"),
|
||||||
#ifndef USE_SHA_CRYPT
|
#ifndef USE_SHA_CRYPT
|
||||||
"NONE DES MD5"
|
"NONE DES MD5"
|
||||||
@ -128,22 +129,22 @@ static void usage (void)
|
|||||||
"NONE DES MD5 SHA256 SHA512"
|
"NONE DES MD5 SHA256 SHA512"
|
||||||
#endif /* USE_SHA_CRYPT */
|
#endif /* USE_SHA_CRYPT */
|
||||||
);
|
);
|
||||||
(void) fputs (_(" -e, --encrypted supplied passwords are encrypted\n"), stderr);
|
(void) fputs (_(" -e, --encrypted supplied passwords are encrypted\n"), usageout);
|
||||||
#endif /* !USE_PAM */
|
#endif /* !USE_PAM */
|
||||||
(void) fputs (_(" -h, --help display this help message and exit\n"), stderr);
|
(void) fputs (_(" -h, --help display this help message and exit\n"), usageout);
|
||||||
#ifndef USE_PAM
|
#ifndef USE_PAM
|
||||||
(void) fputs (_(" -m, --md5 encrypt the clear text password using\n"
|
(void) fputs (_(" -m, --md5 encrypt the clear text password using\n"
|
||||||
" the MD5 algorithm\n"),
|
" the MD5 algorithm\n"),
|
||||||
stderr);
|
usageout);
|
||||||
#ifdef USE_SHA_CRYPT
|
#ifdef USE_SHA_CRYPT
|
||||||
(void) fputs (_(" -s, --sha-rounds number of SHA rounds for the SHA*\n"
|
(void) fputs (_(" -s, --sha-rounds number of SHA rounds for the SHA*\n"
|
||||||
" crypt algorithms\n"),
|
" crypt algorithms\n"),
|
||||||
stderr);
|
usageout);
|
||||||
#endif /* USE_SHA_CRYPT */
|
#endif /* USE_SHA_CRYPT */
|
||||||
#endif /* !USE_PAM */
|
#endif /* !USE_PAM */
|
||||||
(void) fputs ("\n", stderr);
|
(void) fputs ("\n", usageout);
|
||||||
|
|
||||||
exit (E_USAGE);
|
exit (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -181,7 +182,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
long_options, &option_index)) != -1) {
|
long_options, &option_index)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'h':
|
case 'h':
|
||||||
usage ();
|
usage (E_SUCCESS);
|
||||||
break;
|
break;
|
||||||
#ifndef USE_PAM
|
#ifndef USE_PAM
|
||||||
case 'c':
|
case 'c':
|
||||||
@ -201,13 +202,13 @@ static void process_flags (int argc, char **argv)
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: invalid numeric argument '%s'\n"),
|
_("%s: invalid numeric argument '%s'\n"),
|
||||||
Prog, optarg);
|
Prog, optarg);
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif /* USE_SHA_CRYPT */
|
#endif /* USE_SHA_CRYPT */
|
||||||
#endif /* !USE_PAM */
|
#endif /* !USE_PAM */
|
||||||
default:
|
default:
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -229,7 +230,7 @@ static void check_flags (void)
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: %s flag is only allowed with the %s flag\n"),
|
_("%s: %s flag is only allowed with the %s flag\n"),
|
||||||
Prog, "-s", "-c");
|
Prog, "-s", "-c");
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -238,7 +239,7 @@ static void check_flags (void)
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: the -c, -e, and -m flags are exclusive\n"),
|
_("%s: the -c, -e, and -m flags are exclusive\n"),
|
||||||
Prog);
|
Prog);
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cflg) {
|
if (cflg) {
|
||||||
@ -253,7 +254,7 @@ static void check_flags (void)
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: unsupported crypt method: %s\n"),
|
_("%s: unsupported crypt method: %s\n"),
|
||||||
Prog, crypt_method);
|
Prog, crypt_method);
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* USE_PAM */
|
#endif /* USE_PAM */
|
||||||
|
14
src/chsh.c
14
src/chsh.c
@ -72,7 +72,7 @@ static bool pw_locked = false;
|
|||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
static void fail_exit (int code);
|
static void fail_exit (int code);
|
||||||
static void usage (void);
|
static void usage (int status);
|
||||||
static void new_fields (void);
|
static void new_fields (void);
|
||||||
static bool shell_is_listed (const char *);
|
static bool shell_is_listed (const char *);
|
||||||
static bool is_restricted_shell (const char *);
|
static bool is_restricted_shell (const char *);
|
||||||
@ -101,15 +101,15 @@ static void fail_exit (int code)
|
|||||||
/*
|
/*
|
||||||
* usage - print command line syntax and exit
|
* usage - print command line syntax and exit
|
||||||
*/
|
*/
|
||||||
static void usage (void)
|
static void usage (int status)
|
||||||
{
|
{
|
||||||
fputs (_("Usage: chsh [options] [LOGIN]\n"
|
fputs (_("Usage: chsh [options] [LOGIN]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" -h, --help display this help message and exit\n"
|
" -h, --help display this help message and exit\n"
|
||||||
" -s, --shell SHELL new login shell for the user account\n"
|
" -s, --shell SHELL new login shell for the user account\n"
|
||||||
"\n"), stderr);
|
"\n"), status ? stderr : stdout);
|
||||||
exit (E_USAGE);
|
exit (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -217,14 +217,14 @@ static void process_flags (int argc, char **argv)
|
|||||||
&option_index)) != -1) {
|
&option_index)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'h':
|
case 'h':
|
||||||
usage ();
|
usage (E_SUCCESS);
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
sflg = true;
|
sflg = true;
|
||||||
STRFCPY (loginsh, optarg);
|
STRFCPY (loginsh, optarg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
* be the user's name.
|
* be the user's name.
|
||||||
*/
|
*/
|
||||||
if (argc > (optind + 1)) {
|
if (argc > (optind + 1)) {
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +47,17 @@
|
|||||||
/*@-exitarg@*/
|
/*@-exitarg@*/
|
||||||
#include "exitcodes.h"
|
#include "exitcodes.h"
|
||||||
|
|
||||||
|
/* local function prototypes */
|
||||||
|
static void usage (int status);
|
||||||
|
static void print_one (/*@null@*/const struct passwd *pw, bool force);
|
||||||
|
static void set_locktime (long locktime);
|
||||||
|
static bool set_locktime_one (uid_t uid, long locktime);
|
||||||
|
static void setmax (int max);
|
||||||
|
static bool setmax_one (uid_t uid, int max);
|
||||||
|
static void print (void);
|
||||||
|
static bool reset_one (uid_t uid);
|
||||||
|
static void reset (void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Global variables
|
* Global variables
|
||||||
*/
|
*/
|
||||||
@ -69,24 +80,25 @@ static struct stat statbuf; /* fstat buffer for file size */
|
|||||||
|
|
||||||
#define NOW (time((time_t *) 0))
|
#define NOW (time((time_t *) 0))
|
||||||
|
|
||||||
static void usage (void)
|
static void usage (int status)
|
||||||
{
|
{
|
||||||
(void) fprintf (stderr,
|
FILE *usageout = status ? stderr : stdout;
|
||||||
|
(void) fprintf (usageout,
|
||||||
_("Usage: %s [options]\n"
|
_("Usage: %s [options]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Options:\n"),
|
"Options:\n"),
|
||||||
"faillog");
|
"faillog");
|
||||||
(void) fputs (_(" -a, --all display faillog records for all users\n"), stderr);
|
(void) fputs (_(" -a, --all display faillog records for all users\n"), usageout);
|
||||||
(void) fputs (_(" -h, --help display this help message and exit\n"), stderr);
|
(void) fputs (_(" -h, --help display this help message and exit\n"), usageout);
|
||||||
(void) fputs (_(" -l, --lock-time SEC after failed login lock account for SEC seconds\n"), stderr);
|
(void) fputs (_(" -l, --lock-time SEC after failed login lock account for SEC seconds\n"), usageout);
|
||||||
(void) fputs (_(" -m, --maximum MAX set maximum failed login counters to MAX\n"), stderr);
|
(void) fputs (_(" -m, --maximum MAX set maximum failed login counters to MAX\n"), usageout);
|
||||||
(void) fputs (_(" -r, --reset reset the counters of login failures\n"), stderr);
|
(void) fputs (_(" -r, --reset reset the counters of login failures\n"), usageout);
|
||||||
(void) fputs (_(" -t, --time DAYS display faillog records more recent than DAYS\n"), stderr);
|
(void) fputs (_(" -t, --time DAYS display faillog records more recent than DAYS\n"), usageout);
|
||||||
(void) fputs (_(" -u, --user LOGIN/RANGE display faillog record or maintains failure\n"
|
(void) fputs (_(" -u, --user LOGIN/RANGE display faillog record or maintains failure\n"
|
||||||
" counters and limits (if used with -r, -m,\n"
|
" counters and limits (if used with -r, -m,\n"
|
||||||
" or -l) only for the specified LOGIN(s)\n"), stderr);
|
" or -l) only for the specified LOGIN(s)\n"), usageout);
|
||||||
(void) fputs ("\n", stderr);
|
(void) fputs ("\n", usageout);
|
||||||
exit (E_USAGE);
|
exit (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_one (/*@null@*/const struct passwd *pw, bool force)
|
static void print_one (/*@null@*/const struct passwd *pw, bool force)
|
||||||
@ -495,7 +507,7 @@ int main (int argc, char **argv)
|
|||||||
aflg = true;
|
aflg = true;
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
usage ();
|
usage (E_SUCCESS);
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
if (getlong (optarg, &fail_locktime) == 0) {
|
if (getlong (optarg, &fail_locktime) == 0) {
|
||||||
@ -561,16 +573,16 @@ int main (int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aflg && uflg) {
|
if (aflg && uflg) {
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
if (tflg && (lflg || mflg || rflg)) {
|
if (tflg && (lflg || mflg || rflg)) {
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Open the faillog database */
|
/* Open the faillog database */
|
||||||
|
@ -94,7 +94,7 @@ static uid_t bywho;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
static void usage (void);
|
static void usage (int status);
|
||||||
static RETSIGTYPE catch_signals (int killed);
|
static RETSIGTYPE catch_signals (int killed);
|
||||||
static bool is_valid_user_list (const char *users);
|
static bool is_valid_user_list (const char *users);
|
||||||
static void process_flags (int argc, char **argv);
|
static void process_flags (int argc, char **argv);
|
||||||
@ -128,14 +128,15 @@ static void log_gpasswd_success_gshadow (unused void *arg);
|
|||||||
/*
|
/*
|
||||||
* usage - display usage message
|
* usage - display usage message
|
||||||
*/
|
*/
|
||||||
static void usage (void)
|
static void usage (int status)
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (status ? stderr : stdout,
|
||||||
_("Usage: %s [option] GROUP\n"
|
_("Usage: %s [option] GROUP\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" -a, --add USER add USER to GROUP\n"
|
" -a, --add USER add USER to GROUP\n"
|
||||||
" -d, --delete USER remove USER from GROUP\n"
|
" -d, --delete USER remove USER from GROUP\n"
|
||||||
|
" -h, --help display this help message and exit\n"
|
||||||
" -r, --remove-password remove the GROUP's password\n"
|
" -r, --remove-password remove the GROUP's password\n"
|
||||||
" -R, --restrict restrict access to GROUP to its members\n"
|
" -R, --restrict restrict access to GROUP to its members\n"
|
||||||
" -M, --members USER,... set the list of members of GROUP\n"
|
" -M, --members USER,... set the list of members of GROUP\n"
|
||||||
@ -150,7 +151,7 @@ static void usage (void)
|
|||||||
_("The options cannot be combined.\n")
|
_("The options cannot be combined.\n")
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
exit (E_USAGE);
|
exit (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -235,6 +236,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
{"add", required_argument, NULL, 'a'},
|
{"add", required_argument, NULL, 'a'},
|
||||||
{"delete", required_argument, NULL, 'd'},
|
{"delete", required_argument, NULL, 'd'},
|
||||||
|
{"help", no_argument, NULL, 'h'},
|
||||||
{"remove-password", no_argument, NULL, 'r'},
|
{"remove-password", no_argument, NULL, 'r'},
|
||||||
{"restrict", no_argument, NULL, 'R'},
|
{"restrict", no_argument, NULL, 'R'},
|
||||||
{"administrators", required_argument, NULL, 'A'},
|
{"administrators", required_argument, NULL, 'A'},
|
||||||
@ -242,7 +244,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
{NULL, 0, NULL, '\0'}
|
{NULL, 0, NULL, '\0'}
|
||||||
};
|
};
|
||||||
|
|
||||||
while ((flag = getopt_long (argc, argv, "a:A:d:gM:rR", long_options, &option_index)) != -1) {
|
while ((flag = getopt_long (argc, argv, "a:A:d:ghM:rR", long_options, &option_index)) != -1) {
|
||||||
switch (flag) {
|
switch (flag) {
|
||||||
case 'a': /* add a user */
|
case 'a': /* add a user */
|
||||||
aflg = true;
|
aflg = true;
|
||||||
@ -276,6 +278,8 @@ static void process_flags (int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
case 'g': /* no-op from normal password */
|
case 'g': /* no-op from normal password */
|
||||||
break;
|
break;
|
||||||
|
case 'h':
|
||||||
|
usage (E_SUCCESS);
|
||||||
case 'M': /* set the list of members */
|
case 'M': /* set the list of members */
|
||||||
members = optarg;
|
members = optarg;
|
||||||
if (!is_valid_user_list (members)) {
|
if (!is_valid_user_list (members)) {
|
||||||
@ -290,7 +294,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
Rflg = true;
|
Rflg = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,14 +329,14 @@ static void check_flags (int argc, int opt_index)
|
|||||||
exclusive++;
|
exclusive++;
|
||||||
}
|
}
|
||||||
if (exclusive > 1) {
|
if (exclusive > 1) {
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure one (and only one) group was provided
|
* Make sure one (and only one) group was provided
|
||||||
*/
|
*/
|
||||||
if ((argc != (opt_index+1)) || (NULL == group)) {
|
if ((argc != (opt_index+1)) || (NULL == group)) {
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ static bool is_shadow_grp;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
static void usage (void);
|
static void usage (int status);
|
||||||
static void new_grent (struct group *grent);
|
static void new_grent (struct group *grent);
|
||||||
|
|
||||||
#ifdef SHADOWGRP
|
#ifdef SHADOWGRP
|
||||||
@ -105,24 +105,25 @@ static void check_perms (void);
|
|||||||
/*
|
/*
|
||||||
* usage - display usage message and exit
|
* 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"
|
_("Usage: %s [options] GROUP\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Options:\n"),
|
"Options:\n"),
|
||||||
Prog);
|
Prog);
|
||||||
(void) fputs (_(" -f, --force exit successfully if the group already exists,\n"
|
(void) fputs (_(" -f, --force exit successfully if the group already exists,\n"
|
||||||
" and cancel -g if the GID is already used\n"), stderr);
|
" and cancel -g if the GID is already used\n"), usageout);
|
||||||
(void) fputs (_(" -g, --gid GID use GID for the new group\n"), stderr);
|
(void) fputs (_(" -g, --gid GID use GID for the new group\n"), usageout);
|
||||||
(void) fputs (_(" -h, --help display this help message and exit\n"), stderr);
|
(void) fputs (_(" -h, --help display this help message and exit\n"), usageout);
|
||||||
(void) fputs (_(" -K, --key KEY=VALUE override /etc/login.defs defaults\n"), stderr);
|
(void) fputs (_(" -K, --key KEY=VALUE override /etc/login.defs defaults\n"), usageout);
|
||||||
(void) fputs (_(" -o, --non-unique allow to create groups with duplicate\n"
|
(void) fputs (_(" -o, --non-unique allow to create groups with duplicate\n"
|
||||||
" (non-unique) GID\n"), stderr);
|
" (non-unique) GID\n"), usageout);
|
||||||
(void) fputs (_(" -p, --password PASSWORD use this encrypted password for the new group\n"), stderr);
|
(void) fputs (_(" -p, --password PASSWORD use this encrypted password for the new group\n"), usageout);
|
||||||
(void) fputs (_(" -r, --system create a system account\n"), stderr);
|
(void) fputs (_(" -r, --system create a system account\n"), usageout);
|
||||||
(void) fputs ("\n", stderr);
|
(void) fputs ("\n", usageout);
|
||||||
exit (E_USAGE);
|
exit (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -412,7 +413,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
usage ();
|
usage (E_SUCCESS);
|
||||||
break;
|
break;
|
||||||
case 'K':
|
case 'K':
|
||||||
/*
|
/*
|
||||||
@ -444,7 +445,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
rflg = true;
|
rflg = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -452,7 +453,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
* Check the flags consistency
|
* Check the flags consistency
|
||||||
*/
|
*/
|
||||||
if (optind != argc - 1) {
|
if (optind != argc - 1) {
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
group_name = argv[optind];
|
group_name = argv[optind];
|
||||||
|
|
||||||
@ -468,7 +469,7 @@ static void check_flags (void)
|
|||||||
{
|
{
|
||||||
/* -o does not make sense without -g */
|
/* -o does not make sense without -g */
|
||||||
if (oflg && !gflg) {
|
if (oflg && !gflg) {
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
check_new_name ();
|
check_new_name ();
|
||||||
|
@ -88,7 +88,7 @@ static void remove_user (const char *user,
|
|||||||
const struct group *grp);
|
const struct group *grp);
|
||||||
static void purge_members (const struct group *grp);
|
static void purge_members (const struct group *grp);
|
||||||
static void display_members (const char *const *members);
|
static void display_members (const char *const *members);
|
||||||
static void usage (void);
|
static void usage (int status);
|
||||||
static void process_flags (int argc, char **argv);
|
static void process_flags (int argc, char **argv);
|
||||||
static void check_perms (void);
|
static void check_perms (void);
|
||||||
static void fail_exit (int code);
|
static void fail_exit (int code);
|
||||||
@ -361,7 +361,7 @@ static void display_members (const char *const *members)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void usage (void)
|
static void usage (int status)
|
||||||
{
|
{
|
||||||
(void) fputs (_("Usage: groupmems [options] [action]\n"
|
(void) fputs (_("Usage: groupmems [options] [action]\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -372,10 +372,11 @@ static void usage (void)
|
|||||||
"Actions:\n"
|
"Actions:\n"
|
||||||
" -a, --add username add username to the members of the group\n"
|
" -a, --add username add username to the members of the group\n"
|
||||||
" -d, --delete username remove username from the members of the group\n"
|
" -d, --delete username remove username from the members of the group\n"
|
||||||
|
" -h, --help display this help message and exit\n"
|
||||||
" -p, --purge purge all members from the group\n"
|
" -p, --purge purge all members from the group\n"
|
||||||
" -l, --list list the members of the group\n"
|
" -l, --list list the members of the group\n"
|
||||||
"\n"), stderr);
|
"\n"), status ? stderr : stdout);
|
||||||
fail_exit (EXIT_USAGE);
|
fail_exit (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -389,12 +390,13 @@ static void process_flags (int argc, char **argv)
|
|||||||
{"add", required_argument, NULL, 'a'},
|
{"add", required_argument, NULL, 'a'},
|
||||||
{"delete", required_argument, NULL, 'd'},
|
{"delete", required_argument, NULL, 'd'},
|
||||||
{"group", required_argument, NULL, 'g'},
|
{"group", required_argument, NULL, 'g'},
|
||||||
|
{"help", no_argument, NULL, 'h'},
|
||||||
{"list", no_argument, NULL, 'l'},
|
{"list", no_argument, NULL, 'l'},
|
||||||
{"purge", no_argument, NULL, 'p'},
|
{"purge", no_argument, NULL, 'p'},
|
||||||
{NULL, 0, NULL, '\0'}
|
{NULL, 0, NULL, '\0'}
|
||||||
};
|
};
|
||||||
|
|
||||||
while ((arg = getopt_long (argc, argv, "a:d:g:lp", long_options,
|
while ((arg = getopt_long (argc, argv, "a:d:g:hlp", long_options,
|
||||||
&option_index)) != EOF) {
|
&option_index)) != EOF) {
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
case 'a':
|
case 'a':
|
||||||
@ -408,6 +410,8 @@ static void process_flags (int argc, char **argv)
|
|||||||
case 'g':
|
case 'g':
|
||||||
thisgroup = xstrdup (optarg);
|
thisgroup = xstrdup (optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'h':
|
||||||
|
usage (EXIT_SUCCESS);
|
||||||
case 'l':
|
case 'l':
|
||||||
list = true;
|
list = true;
|
||||||
++exclusive;
|
++exclusive;
|
||||||
@ -417,12 +421,12 @@ static void process_flags (int argc, char **argv)
|
|||||||
++exclusive;
|
++exclusive;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage ();
|
usage (EXIT_USAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((exclusive > 1) || (optind < argc)) {
|
if ((exclusive > 1) || (optind < argc)) {
|
||||||
usage ();
|
usage (EXIT_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* local, no need for xgetpwnam */
|
/* local, no need for xgetpwnam */
|
||||||
|
@ -93,7 +93,7 @@ static bool
|
|||||||
pflg = false; /* new encrypted password */
|
pflg = false; /* new encrypted password */
|
||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
static void usage (void);
|
static void usage (int status);
|
||||||
static void new_grent (struct group *);
|
static void new_grent (struct group *);
|
||||||
|
|
||||||
#ifdef SHADOWGRP
|
#ifdef SHADOWGRP
|
||||||
@ -113,21 +113,22 @@ static void update_primary_groups (gid_t ogid, gid_t ngid);
|
|||||||
* usage - display usage message and exit
|
* 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"
|
_("Usage: %s [options] GROUP\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Options:\n"),
|
"Options:\n"),
|
||||||
Prog);
|
Prog);
|
||||||
(void) fputs (_(" -g, --gid GID change the group ID to 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"), stderr);
|
(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"), stderr);
|
(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"), stderr);
|
(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"), stderr);
|
" PASSWORD\n"), usageout);
|
||||||
(void) fputs ("\n", stderr);
|
(void) fputs ("\n", usageout);
|
||||||
exit (E_USAGE);
|
exit (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -362,6 +363,8 @@ static void process_flags (int argc, char **argv)
|
|||||||
exit (E_BAD_ARG);
|
exit (E_BAD_ARG);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'h':
|
||||||
|
usage (E_SUCCESS);
|
||||||
case 'n':
|
case 'n':
|
||||||
nflg = true;
|
nflg = true;
|
||||||
group_newname = optarg;
|
group_newname = optarg;
|
||||||
@ -374,16 +377,16 @@ static void process_flags (int argc, char **argv)
|
|||||||
pflg = true;
|
pflg = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oflg && !gflg) {
|
if (oflg && !gflg) {
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optind != (argc - 1)) {
|
if (optind != (argc - 1)) {
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
group_name = argv[argc - 1];
|
group_name = argv[argc - 1];
|
||||||
|
@ -71,7 +71,7 @@ static bool bflg = false; /* print excludes most recent days */
|
|||||||
|
|
||||||
#define NOW (time ((time_t *) 0))
|
#define NOW (time ((time_t *) 0))
|
||||||
|
|
||||||
static void usage (void)
|
static void usage (int status)
|
||||||
{
|
{
|
||||||
fputs (_("Usage: lastlog [options]\n"
|
fputs (_("Usage: lastlog [options]\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -80,8 +80,8 @@ static void usage (void)
|
|||||||
" -h, --help display this help message and exit\n"
|
" -h, --help display this help message and exit\n"
|
||||||
" -t, --time DAYS print only lastlog records more recent than DAYS\n"
|
" -t, --time DAYS print only lastlog records more recent than DAYS\n"
|
||||||
" -u, --user LOGIN print lastlog record of the specified LOGIN\n"
|
" -u, --user LOGIN print lastlog record of the specified LOGIN\n"
|
||||||
"\n"), stderr);
|
"\n"), status ? stderr : stdout);
|
||||||
exit (EXIT_FAILURE);
|
exit (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_one (/*@null@*/const struct passwd *pw)
|
static void print_one (/*@null@*/const struct passwd *pw)
|
||||||
@ -208,7 +208,7 @@ int main (int argc, char **argv)
|
|||||||
NULL)) != -1) {
|
NULL)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'h':
|
case 'h':
|
||||||
usage ();
|
usage (EXIT_SUCCESS);
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
{
|
{
|
||||||
@ -267,7 +267,7 @@ int main (int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
usage ();
|
usage (EXIT_FAILURE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -275,7 +275,7 @@ int main (int argc, char **argv)
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("lastlog: unexpected argument: %s\n"),
|
_("lastlog: unexpected argument: %s\n"),
|
||||||
argv[optind]);
|
argv[optind]);
|
||||||
usage();
|
usage (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ static bool gr_locked = false;
|
|||||||
static bool spw_locked = false;
|
static bool spw_locked = false;
|
||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
static void usage (void);
|
static void usage (int status);
|
||||||
static void fail_exit (int);
|
static void fail_exit (int);
|
||||||
static int add_group (const char *, const char *, gid_t *, gid_t);
|
static int add_group (const char *, const char *, gid_t *, gid_t);
|
||||||
static int get_user_id (const char *, uid_t *);
|
static int get_user_id (const char *, uid_t *);
|
||||||
@ -110,15 +110,16 @@ static void close_files (void);
|
|||||||
/*
|
/*
|
||||||
* usage - display usage message and exit
|
* 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]\n"
|
_("Usage: %s [options]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Options:\n"),
|
"Options:\n"),
|
||||||
Prog);
|
Prog);
|
||||||
#ifndef USE_PAM
|
#ifndef USE_PAM
|
||||||
(void) fprintf (stderr,
|
(void) fprintf (usageout,
|
||||||
_(" -c, --crypt-method the crypt method (one of %s)\n"),
|
_(" -c, --crypt-method the crypt method (one of %s)\n"),
|
||||||
#ifndef USE_SHA_CRYPT
|
#ifndef USE_SHA_CRYPT
|
||||||
"NONE DES MD5"
|
"NONE DES MD5"
|
||||||
@ -127,18 +128,18 @@ static void usage (void)
|
|||||||
#endif /* USE_SHA_CRYPT */
|
#endif /* USE_SHA_CRYPT */
|
||||||
);
|
);
|
||||||
#endif /* !USE_PAM */
|
#endif /* !USE_PAM */
|
||||||
(void) fputs (_(" -h, --help display this help message and exit\n"), stderr);
|
(void) fputs (_(" -h, --help display this help message and exit\n"), usageout);
|
||||||
(void) fputs (_(" -r, --system create system accounts\n"), stderr);
|
(void) fputs (_(" -r, --system create system accounts\n"), usageout);
|
||||||
#ifndef USE_PAM
|
#ifndef USE_PAM
|
||||||
#ifdef USE_SHA_CRYPT
|
#ifdef USE_SHA_CRYPT
|
||||||
(void) fputs (_(" -s, --sha-rounds number of SHA rounds for the SHA*\n"
|
(void) fputs (_(" -s, --sha-rounds number of SHA rounds for the SHA*\n"
|
||||||
" crypt algorithms\n"),
|
" crypt algorithms\n"),
|
||||||
stderr);
|
usageout);
|
||||||
#endif /* USE_SHA_CRYPT */
|
#endif /* USE_SHA_CRYPT */
|
||||||
#endif /* !USE_PAM */
|
#endif /* !USE_PAM */
|
||||||
(void) fputs ("\n", stderr);
|
(void) fputs ("\n", usageout);
|
||||||
|
|
||||||
exit (EXIT_FAILURE);
|
exit (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -548,7 +549,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
long_options, &option_index)) != -1) {
|
long_options, &option_index)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'h':
|
case 'h':
|
||||||
usage ();
|
usage (EXIT_SUCCESS);
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
rflg = true;
|
rflg = true;
|
||||||
@ -565,13 +566,13 @@ static void process_flags (int argc, char **argv)
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: invalid numeric argument '%s'\n"),
|
_("%s: invalid numeric argument '%s'\n"),
|
||||||
Prog, optarg);
|
Prog, optarg);
|
||||||
usage ();
|
usage (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif /* USE_SHA_CRYPT */
|
#endif /* USE_SHA_CRYPT */
|
||||||
#endif /* !USE_PAM */
|
#endif /* !USE_PAM */
|
||||||
default:
|
default:
|
||||||
usage ();
|
usage (EXIT_FAILURE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -602,7 +603,7 @@ static void check_flags (void)
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: %s flag is only allowed with the %s flag\n"),
|
_("%s: %s flag is only allowed with the %s flag\n"),
|
||||||
Prog, "-s", "-c");
|
Prog, "-s", "-c");
|
||||||
usage ();
|
usage (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
#endif /* USE_SHA_CRYPT */
|
#endif /* USE_SHA_CRYPT */
|
||||||
|
|
||||||
@ -618,7 +619,7 @@ static void check_flags (void)
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: unsupported crypt method: %s\n"),
|
_("%s: unsupported crypt method: %s\n"),
|
||||||
Prog, crypt_method);
|
Prog, crypt_method);
|
||||||
usage ();
|
usage (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* !USE_PAM */
|
#endif /* !USE_PAM */
|
||||||
|
@ -180,7 +180,7 @@ static void usage (int status)
|
|||||||
" -w, --warndays WARN_DAYS set expiration warning days to WARN_DAYS\n"
|
" -w, --warndays WARN_DAYS set expiration warning days to WARN_DAYS\n"
|
||||||
" -x, --maxdays MAX_DAYS set maximum number of days before password\n"
|
" -x, --maxdays MAX_DAYS set maximum number of days before password\n"
|
||||||
" change to MAX_DAYS\n"
|
" change to MAX_DAYS\n"
|
||||||
"\n"), stderr);
|
"\n"), status ? stderr : stdout);
|
||||||
exit (status);
|
exit (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -811,7 +811,7 @@ int main (int argc, char **argv)
|
|||||||
{NULL, 0, NULL, '\0'}
|
{NULL, 0, NULL, '\0'}
|
||||||
};
|
};
|
||||||
|
|
||||||
while ((c = getopt_long (argc, argv, "adei:kln:qr:Suw:x:",
|
while ((c = getopt_long (argc, argv, "adehi:kln:qr:Suw:x:",
|
||||||
long_options, &option_index)) != -1) {
|
long_options, &option_index)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'a':
|
case 'a':
|
||||||
@ -897,6 +897,8 @@ int main (int argc, char **argv)
|
|||||||
xflg = true;
|
xflg = true;
|
||||||
anyflag = true;
|
anyflag = true;
|
||||||
break;
|
break;
|
||||||
|
case 'h':
|
||||||
|
usage (E_SUCCESS);
|
||||||
default:
|
default:
|
||||||
usage (E_BAD_ARG);
|
usage (E_BAD_ARG);
|
||||||
}
|
}
|
||||||
|
10
src/su.c
10
src/su.c
@ -323,7 +323,7 @@ static void run_shell (const char *shellstr, char *args[], bool doshell,
|
|||||||
/*
|
/*
|
||||||
* usage - print command line syntax and exit
|
* usage - print command line syntax and exit
|
||||||
*/
|
*/
|
||||||
static void usage (void)
|
static void usage (int status)
|
||||||
{
|
{
|
||||||
fputs (_("Usage: su [options] [LOGIN]\n"
|
fputs (_("Usage: su [options] [LOGIN]\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -335,8 +335,8 @@ static void usage (void)
|
|||||||
" --preserve-environment do not reset environment variables, and\n"
|
" --preserve-environment do not reset environment variables, and\n"
|
||||||
" keep the same shell\n"
|
" keep the same shell\n"
|
||||||
" -s, --shell SHELL use SHELL instead of the default in passwd\n"
|
" -s, --shell SHELL use SHELL instead of the default in passwd\n"
|
||||||
"\n"), stderr);
|
"\n"), status ? stderr : stdout);
|
||||||
exit (E_USAGE);
|
exit (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -421,7 +421,7 @@ int main (int argc, char **argv)
|
|||||||
command = optarg;
|
command = optarg;
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
usage ();
|
usage (E_SUCCESS);
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
fakelogin = true;
|
fakelogin = true;
|
||||||
@ -438,7 +438,7 @@ int main (int argc, char **argv)
|
|||||||
shellstr = optarg;
|
shellstr = optarg;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage (); /* NOT REACHED */
|
usage (E_USAGE); /* NOT REACHED */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ static void get_defaults (void);
|
|||||||
static void show_defaults (void);
|
static void show_defaults (void);
|
||||||
static int set_defaults (void);
|
static int set_defaults (void);
|
||||||
static int get_groups (char *);
|
static int get_groups (char *);
|
||||||
static void usage (void);
|
static void usage (int status);
|
||||||
static void new_pwent (struct passwd *);
|
static void new_pwent (struct passwd *);
|
||||||
#ifdef WITH_SELINUX
|
#ifdef WITH_SELINUX
|
||||||
static void selinux_update_mapping (void);
|
static void selinux_update_mapping (void);
|
||||||
@ -681,45 +681,46 @@ static int get_groups (char *list)
|
|||||||
/*
|
/*
|
||||||
* usage - display usage message and exit
|
* 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] LOGIN\n"
|
_("Usage: %s [options] LOGIN\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Options:\n"),
|
"Options:\n"),
|
||||||
Prog);
|
Prog);
|
||||||
(void) fputs (_(" -b, --base-dir BASE_DIR base directory for the home directory of the\n"
|
(void) fputs (_(" -b, --base-dir BASE_DIR base directory for the home directory of the\n"
|
||||||
" new account\n"), stderr);
|
" new account\n"), usageout);
|
||||||
(void) fputs (_(" -c, --comment COMMENT GECOS field of the new account\n"), stderr);
|
(void) fputs (_(" -c, --comment COMMENT GECOS field of the new account\n"), usageout);
|
||||||
(void) fputs (_(" -d, --home-dir HOME_DIR home directory of the new account\n"), stderr);
|
(void) fputs (_(" -d, --home-dir HOME_DIR home directory of the new account\n"), usageout);
|
||||||
(void) fputs (_(" -D, --defaults print or change default useradd configuration\n"), stderr);
|
(void) fputs (_(" -D, --defaults print or change default useradd configuration\n"), usageout);
|
||||||
(void) fputs (_(" -e, --expiredate EXPIRE_DATE expiration date of the new account\n"), stderr);
|
(void) fputs (_(" -e, --expiredate EXPIRE_DATE expiration date of the new account\n"), usageout);
|
||||||
(void) fputs (_(" -f, --inactive INACTIVE password inactivity period of the new account\n"), stderr);
|
(void) fputs (_(" -f, --inactive INACTIVE password inactivity period of the new account\n"), usageout);
|
||||||
(void) fputs (_(" -g, --gid GROUP name or ID of the primary group of the new\n"
|
(void) fputs (_(" -g, --gid GROUP name or ID of the primary group of the new\n"
|
||||||
" account\n"), stderr);
|
" account\n"), usageout);
|
||||||
(void) fputs (_(" -G, --groups GROUPS list of supplementary groups of the new\n"
|
(void) fputs (_(" -G, --groups GROUPS list of supplementary groups of the new\n"
|
||||||
" account\n"), stderr);
|
" account\n"), usageout);
|
||||||
(void) fputs (_(" -h, --help display this help message and exit\n"), stderr);
|
(void) fputs (_(" -h, --help display this help message and exit\n"), usageout);
|
||||||
(void) fputs (_(" -k, --skel SKEL_DIR use this alternative skeleton directory\n"), stderr);
|
(void) fputs (_(" -k, --skel SKEL_DIR use this alternative skeleton directory\n"), usageout);
|
||||||
(void) fputs (_(" -K, --key KEY=VALUE override /etc/login.defs defaults\n"), stderr);
|
(void) fputs (_(" -K, --key KEY=VALUE override /etc/login.defs defaults\n"), usageout);
|
||||||
(void) fputs (_(" -l, --no-log-init do not add the user to the lastlog and\n"
|
(void) fputs (_(" -l, --no-log-init do not add the user to the lastlog and\n"
|
||||||
" faillog databases\n"), stderr);
|
" faillog databases\n"), usageout);
|
||||||
(void) fputs (_(" -m, --create-home create the user's home directory\n"), stderr);
|
(void) fputs (_(" -m, --create-home create the user's home directory\n"), usageout);
|
||||||
(void) fputs (_(" -M, --no-create-home do not create the user's home directory\n"), stderr);
|
(void) fputs (_(" -M, --no-create-home do not create the user's home directory\n"), usageout);
|
||||||
(void) fputs (_(" -N, --no-user-group do not create a group with the same name as\n"
|
(void) fputs (_(" -N, --no-user-group do not create a group with the same name as\n"
|
||||||
" the user\n"), stderr);
|
" the user\n"), usageout);
|
||||||
(void) fputs (_(" -o, --non-unique allow to create users with duplicate\n"
|
(void) fputs (_(" -o, --non-unique allow to create users with duplicate\n"
|
||||||
" (non-unique) UID\n"), stderr);
|
" (non-unique) UID\n"), usageout);
|
||||||
(void) fputs (_(" -p, --password PASSWORD encrypted password of the new account\n"), stderr);
|
(void) fputs (_(" -p, --password PASSWORD encrypted password of the new account\n"), usageout);
|
||||||
(void) fputs (_(" -r, --system create a system account\n"), stderr);
|
(void) fputs (_(" -r, --system create a system account\n"), usageout);
|
||||||
(void) fputs (_(" -s, --shell SHELL login shell of the new account\n"), stderr);
|
(void) fputs (_(" -s, --shell SHELL login shell of the new account\n"), usageout);
|
||||||
(void) fputs (_(" -u, --uid UID user ID of the new account\n"), stderr);
|
(void) fputs (_(" -u, --uid UID user ID of the new account\n"), usageout);
|
||||||
(void) fputs (_(" -U, --user-group create a group with the same name as the user\n"), stderr);
|
(void) fputs (_(" -U, --user-group create a group with the same name as the user\n"), usageout);
|
||||||
#ifdef WITH_SELINUX
|
#ifdef WITH_SELINUX
|
||||||
(void) fputs (_(" -Z, --selinux-user SEUSER use a specific SEUSER for the SELinux user mapping\n"), stderr);
|
(void) fputs (_(" -Z, --selinux-user SEUSER use a specific SEUSER for the SELinux user mapping\n"), usageout);
|
||||||
#endif
|
#endif
|
||||||
(void) fputs ("\n", stderr);
|
(void) fputs ("\n", usageout);
|
||||||
exit (E_USAGE);
|
exit (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -989,9 +990,9 @@ static void process_flags (int argc, char **argv)
|
|||||||
};
|
};
|
||||||
while ((c = getopt_long (argc, argv,
|
while ((c = getopt_long (argc, argv,
|
||||||
#ifdef WITH_SELINUX
|
#ifdef WITH_SELINUX
|
||||||
"b:c:d:De:f:g:G:k:K:lmMNop:rs:u:UZ:",
|
"b:c:d:De:f:g:G:hk:K:lmMNop:rs:u:UZ:",
|
||||||
#else
|
#else
|
||||||
"b:c:d:De:f:g:G:k:K:lmMNop:rs:u:U",
|
"b:c:d:De:f:g:G:hk:K:lmMNop:rs:u:U",
|
||||||
#endif
|
#endif
|
||||||
long_options, NULL)) != -1) {
|
long_options, NULL)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
@ -1029,7 +1030,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
if (anyflag) {
|
if (anyflag) {
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
Dflg = true;
|
Dflg = true;
|
||||||
break;
|
break;
|
||||||
@ -1066,7 +1067,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: invalid numeric argument '%s'\n"),
|
_("%s: invalid numeric argument '%s'\n"),
|
||||||
Prog, optarg);
|
Prog, optarg);
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* -f -1 is allowed
|
* -f -1 is allowed
|
||||||
@ -1106,7 +1107,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
Gflg = true;
|
Gflg = true;
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
usage ();
|
usage (E_SUCCESS);
|
||||||
break;
|
break;
|
||||||
case 'k':
|
case 'k':
|
||||||
def_template = optarg;
|
def_template = optarg;
|
||||||
@ -1201,7 +1202,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
anyflag = true;
|
anyflag = true;
|
||||||
}
|
}
|
||||||
@ -1220,31 +1221,31 @@ static void process_flags (int argc, char **argv)
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: %s flag is only allowed with the %s flag\n"),
|
_("%s: %s flag is only allowed with the %s flag\n"),
|
||||||
Prog, "-o", "-u");
|
Prog, "-o", "-u");
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
if (kflg && !mflg) {
|
if (kflg && !mflg) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: %s flag is only allowed with the %s flag\n"),
|
_("%s: %s flag is only allowed with the %s flag\n"),
|
||||||
Prog, "-k", "-m");
|
Prog, "-k", "-m");
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
if (Uflg && gflg) {
|
if (Uflg && gflg) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: options %s and %s conflict\n"),
|
_("%s: options %s and %s conflict\n"),
|
||||||
Prog, "-U", "-g");
|
Prog, "-U", "-g");
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
if (Uflg && Nflg) {
|
if (Uflg && Nflg) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: options %s and %s conflict\n"),
|
_("%s: options %s and %s conflict\n"),
|
||||||
Prog, "-U", "-N");
|
Prog, "-U", "-N");
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
if (mflg && Mflg) {
|
if (mflg && Mflg) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: options %s and %s conflict\n"),
|
_("%s: options %s and %s conflict\n"),
|
||||||
Prog, "-m", "-M");
|
Prog, "-m", "-M");
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1253,15 +1254,15 @@ static void process_flags (int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
if (Dflg) {
|
if (Dflg) {
|
||||||
if (optind != argc) {
|
if (optind != argc) {
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uflg || oflg || Gflg || dflg || cflg || mflg) {
|
if (uflg || oflg || Gflg || dflg || cflg || mflg) {
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (optind != argc - 1) {
|
if (optind != argc - 1) {
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
user_name = argv[optind];
|
user_name = argv[optind];
|
||||||
|
@ -94,7 +94,7 @@ static bool gr_locked = false;
|
|||||||
static bool spw_locked = false;
|
static bool spw_locked = false;
|
||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
static void usage (void);
|
static void usage (int status);
|
||||||
static void update_groups (void);
|
static void update_groups (void);
|
||||||
static void close_files (void);
|
static void close_files (void);
|
||||||
static void fail_exit (int);
|
static void fail_exit (int);
|
||||||
@ -111,7 +111,7 @@ static int remove_mailbox (void);
|
|||||||
/*
|
/*
|
||||||
* usage - display usage message and exit
|
* usage - display usage message and exit
|
||||||
*/
|
*/
|
||||||
static void usage (void)
|
static void usage (int status)
|
||||||
{
|
{
|
||||||
fputs (_("Usage: userdel [options] LOGIN\n"
|
fputs (_("Usage: userdel [options] LOGIN\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -120,8 +120,8 @@ static void usage (void)
|
|||||||
" even if not owned by user\n"
|
" even if not owned by user\n"
|
||||||
" -h, --help display this help message and exit\n"
|
" -h, --help display this help message and exit\n"
|
||||||
" -r, --remove remove home directory and mail spool\n"
|
" -r, --remove remove home directory and mail spool\n"
|
||||||
"\n"), stderr);
|
"\n"), status ? stderr : stdout);
|
||||||
exit (E_USAGE);
|
exit (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -774,17 +774,19 @@ int main (int argc, char **argv)
|
|||||||
case 'f': /* force remove even if not owned by user */
|
case 'f': /* force remove even if not owned by user */
|
||||||
fflg = true;
|
fflg = true;
|
||||||
break;
|
break;
|
||||||
|
case 'h':
|
||||||
|
usage (E_SUCCESS);
|
||||||
case 'r': /* remove home dir and mailbox */
|
case 'r': /* remove home dir and mailbox */
|
||||||
rflg = true;
|
rflg = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((optind + 1) != argc) {
|
if ((optind + 1) != argc) {
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
OPENLOG ("userdel");
|
OPENLOG ("userdel");
|
||||||
|
@ -149,7 +149,7 @@ static bool sgr_locked = false;
|
|||||||
static void date_to_str (char *buf, size_t maxsize,
|
static void date_to_str (char *buf, size_t maxsize,
|
||||||
long int date, const char *negativ);
|
long int date, const char *negativ);
|
||||||
static int get_groups (char *);
|
static int get_groups (char *);
|
||||||
static void usage (void);
|
static void usage (int status);
|
||||||
static void new_pwent (struct passwd *);
|
static void new_pwent (struct passwd *);
|
||||||
#ifdef WITH_SELINUX
|
#ifdef WITH_SELINUX
|
||||||
static void selinux_update_mapping (void);
|
static void selinux_update_mapping (void);
|
||||||
@ -300,9 +300,9 @@ static int get_groups (char *list)
|
|||||||
/*
|
/*
|
||||||
* usage - display usage message and exit
|
* usage - display usage message and exit
|
||||||
*/
|
*/
|
||||||
static void usage (void)
|
static void usage (int status)
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (status ? stderr : stdout,
|
||||||
_("Usage: usermod [options] LOGIN\n"
|
_("Usage: usermod [options] LOGIN\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
@ -334,7 +334,7 @@ static void usage (void)
|
|||||||
""
|
""
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
exit (E_USAGE);
|
exit (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -815,7 +815,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
bool anyflag = false;
|
bool anyflag = false;
|
||||||
|
|
||||||
if ((1 == argc) || ('-' == argv[argc - 1][0])) {
|
if ((1 == argc) || ('-' == argv[argc - 1][0])) {
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -955,7 +955,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: invalid numeric argument '%s'\n"),
|
_("%s: invalid numeric argument '%s'\n"),
|
||||||
Prog, optarg);
|
Prog, optarg);
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
fflg = true;
|
fflg = true;
|
||||||
break;
|
break;
|
||||||
@ -976,6 +976,8 @@ static void process_flags (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
Gflg = true;
|
Gflg = true;
|
||||||
break;
|
break;
|
||||||
|
case 'h':
|
||||||
|
usage (E_SUCCESS);
|
||||||
case 'l':
|
case 'l':
|
||||||
if (!is_valid_user_name (optarg)) {
|
if (!is_valid_user_name (optarg)) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
@ -1036,7 +1038,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
anyflag = true;
|
anyflag = true;
|
||||||
}
|
}
|
||||||
@ -1092,14 +1094,14 @@ static void process_flags (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (optind != argc - 1) {
|
if (optind != argc - 1) {
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aflg && (!Gflg)) {
|
if (aflg && (!Gflg)) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: %s flag is only allowed with the %s flag\n"),
|
_("%s: %s flag is only allowed with the %s flag\n"),
|
||||||
Prog, "-a", "-G");
|
Prog, "-a", "-G");
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
exit (E_USAGE);
|
exit (E_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1107,7 +1109,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: the -L, -p, and -U flags are exclusive\n"),
|
_("%s: the -L, -p, and -U flags are exclusive\n"),
|
||||||
Prog);
|
Prog);
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
exit (E_USAGE);
|
exit (E_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1115,7 +1117,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: %s flag is only allowed with the %s flag\n"),
|
_("%s: %s flag is only allowed with the %s flag\n"),
|
||||||
Prog, "-o", "-u");
|
Prog, "-o", "-u");
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
exit (E_USAGE);
|
exit (E_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1123,7 +1125,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: %s flag is only allowed with the %s flag\n"),
|
_("%s: %s flag is only allowed with the %s flag\n"),
|
||||||
Prog, "-m", "-d");
|
Prog, "-m", "-d");
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
exit (E_USAGE);
|
exit (E_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
src/vipw.c
12
src/vipw.c
@ -64,7 +64,7 @@ static int (*unlock) (void);
|
|||||||
static bool quiet = false;
|
static bool quiet = false;
|
||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
static void usage (void);
|
static void usage (int status);
|
||||||
static int create_backup_file (FILE *, const char *, struct stat *);
|
static int create_backup_file (FILE *, const char *, struct stat *);
|
||||||
static void vipwexit (const char *msg, int syserr, int ret);
|
static void vipwexit (const char *msg, int syserr, int ret);
|
||||||
static void vipwedit (const char *, int (*)(void), int (*)(void));
|
static void vipwedit (const char *, int (*)(void), int (*)(void));
|
||||||
@ -72,7 +72,7 @@ static void vipwedit (const char *, int (*)(void), int (*)(void));
|
|||||||
/*
|
/*
|
||||||
* usage - display usage message and exit
|
* usage - display usage message and exit
|
||||||
*/
|
*/
|
||||||
static void usage (void)
|
static void usage (int status)
|
||||||
{
|
{
|
||||||
(void)
|
(void)
|
||||||
fputs (_("Usage: vipw [options]\n"
|
fputs (_("Usage: vipw [options]\n"
|
||||||
@ -83,8 +83,8 @@ static void usage (void)
|
|||||||
" -p, --passwd edit passwd database\n"
|
" -p, --passwd edit passwd database\n"
|
||||||
" -q, --quiet quiet mode\n"
|
" -q, --quiet quiet mode\n"
|
||||||
" -s, --shadow edit shadow or gshadow database\n"
|
" -s, --shadow edit shadow or gshadow database\n"
|
||||||
"\n"), stderr);
|
"\n"), status ? stderr : stdout);
|
||||||
exit (E_USAGE);
|
exit (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -353,7 +353,7 @@ int main (int argc, char **argv)
|
|||||||
do_vipw = false;
|
do_vipw = false;
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
usage ();
|
usage (E_SUCCESS);
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
do_vipw = true;
|
do_vipw = true;
|
||||||
@ -365,7 +365,7 @@ int main (int argc, char **argv)
|
|||||||
editshadow = true;
|
editshadow = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage ();
|
usage (E_USAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user