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