* 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>
<?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
<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>
*/
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);
}
*/
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);
sanitize_env ();
+ /*
+ * 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);
- /*
- * Get the program name. The program name is used as a prefix to
- * most error messages.
- */
- Prog = Basename (argv[0]);
-
OPENLOG ("chsh");
/* parse the command line options */