* NEWS, src/chsh.c, man/chsh.1.xml: Add --root option.
chsh's usage split in smaller messages. * src/chsh.c: The getopt index of long options is not used.
This commit is contained in:
parent
1aa30ba551
commit
4beca611fb
@ -39,6 +39,9 @@
|
||||
* NEWS, src/groupmems.c, man/groupmems.8.xml: Add --root option.
|
||||
Open syslog after the potential chroot.
|
||||
* src/groupmems.c: The getopt index of long options is not used.
|
||||
* NEWS, src/chsh.c, man/chsh.1.xml: Add --root option.
|
||||
chsh's usage split in smaller messages.
|
||||
* src/chsh.c: The getopt index of long options is not used.
|
||||
|
||||
2011-10-22 Nicolas François <nicolas.francois@centraliens.net>
|
||||
|
||||
|
2
NEWS
2
NEWS
@ -30,6 +30,8 @@ shadow-4.1.4.3 -> shadow-4.1.5 UNRELEASED
|
||||
is created if the password is changed and passwd requires a
|
||||
shadow entry.
|
||||
* Add --root option.
|
||||
- chsh
|
||||
* Add --root option.
|
||||
- faillog
|
||||
* The -l, -m, -r, -t options only act on the existing users, unless -a is
|
||||
specified.
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (c) 1990 , 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
|
||||
@ -84,6 +84,19 @@
|
||||
<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>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>-s</option>, <option>--shell</option> <replaceable>SHELL</replaceable>
|
||||
|
45
src/chsh.c
45
src/chsh.c
@ -103,12 +103,16 @@ static void fail_exit (int code)
|
||||
*/
|
||||
static void usage (int status)
|
||||
{
|
||||
fputs (_("Usage: chsh [options] [LOGIN]\n"
|
||||
"\n"
|
||||
"Options:\n"
|
||||
" -h, --help display this help message and exit\n"
|
||||
" -s, --shell SHELL new login shell for the user account\n"
|
||||
"\n"), (E_SUCCESS != status) ? stderr : stdout);
|
||||
FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
|
||||
(void) fprintf (usageout,
|
||||
_("Usage: %s [options] [LOGIN]\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 (_(" -s, --shell SHELL new login shell for the user account\n"), usageout);
|
||||
(void) fputs ("\n", usageout);
|
||||
exit (status);
|
||||
}
|
||||
|
||||
@ -200,21 +204,22 @@ static bool shell_is_listed (const char *sh)
|
||||
*/
|
||||
static void process_flags (int argc, char **argv)
|
||||
{
|
||||
int option_index = 0;
|
||||
int c;
|
||||
static struct option long_options[] = {
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
{"root", required_argument, NULL, 'R'},
|
||||
{"shell", required_argument, NULL, 's'},
|
||||
{NULL, 0, NULL, '\0'}
|
||||
};
|
||||
|
||||
while ((c =
|
||||
getopt_long (argc, argv, "hs:", long_options,
|
||||
&option_index)) != -1) {
|
||||
while ((c = getopt_long (argc, argv, "hR:s:",
|
||||
long_options, NULL)) != -1) {
|
||||
switch (c) {
|
||||
case 'h':
|
||||
usage (E_SUCCESS);
|
||||
break;
|
||||
case 'R': /* no-op, handled in process_root_flag () */
|
||||
break;
|
||||
case 's':
|
||||
sflg = true;
|
||||
STRFCPY (loginsh, optarg);
|
||||
@ -432,21 +437,23 @@ int main (int argc, char **argv)
|
||||
|
||||
sanitize_env ();
|
||||
|
||||
(void) setlocale (LC_ALL, "");
|
||||
(void) bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
(void) textdomain (PACKAGE);
|
||||
|
||||
/*
|
||||
* This command behaves different for root and non-root users.
|
||||
*/
|
||||
amroot = (getuid () == 0);
|
||||
|
||||
/*
|
||||
* Get the program name. The program name is used as a prefix to
|
||||
* most error messages.
|
||||
*/
|
||||
Prog = Basename (argv[0]);
|
||||
|
||||
(void) setlocale (LC_ALL, "");
|
||||
(void) bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
(void) textdomain (PACKAGE);
|
||||
|
||||
process_root_flag ("-R", argc, argv);
|
||||
|
||||
/*
|
||||
* This command behaves different for root and non-root users.
|
||||
*/
|
||||
amroot = (getuid () == 0);
|
||||
|
||||
OPENLOG ("chsh");
|
||||
|
||||
/* parse the command line options */
|
||||
|
Loading…
Reference in New Issue
Block a user