* NEWS, src/chage.c, man/chage.1.xml: Add --root option. Open

audit and syslog after the potential chroot. chage's usage split
	in smaller messages.
This commit is contained in:
nekral-guest 2011-11-06 18:38:57 +00:00
parent d15f2c6214
commit 0857837e64
4 changed files with 58 additions and 29 deletions

View File

@ -1,3 +1,9 @@
2011-10-30 Nicolas François <nicolas.francois@centraliens.net>
* NEWS, src/chage.c, man/chage.1.xml: Add --root option. Open
audit and syslog after the potential chroot. chage's usage split
in smaller messages.
2011-10-30 Nicolas François <nicolas.francois@centraliens.net> 2011-10-30 Nicolas François <nicolas.francois@centraliens.net>
* src/login.c: re-indent. * src/login.c: re-indent.

2
NEWS
View File

@ -16,6 +16,8 @@ shadow-4.1.4.3 -> shadow-4.1.5 UNRELEASED
configure options. configure options.
* Added diagnosis for lock failures. * Added diagnosis for lock failures.
- chage
* Add --root option.
- chgpasswd - chgpasswd
* When the gshadow file exists but there are no gshadow entries, an entry * When the gshadow file exists but there are no gshadow entries, an entry
is created if the password is changed and group requires a is created if the password is changed and group requires a

View File

@ -174,6 +174,19 @@
</para> </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>-W</option>, <option>--warndays</option> <replaceable>WARN_DAYS</replaceable> <option>-W</option>, <option>--warndays</option> <replaceable>WARN_DAYS</replaceable>

View File

@ -140,22 +140,25 @@ static /*@noreturn@*/void fail_exit (int code)
*/ */
static /*@noreturn@*/void usage (int status) static /*@noreturn@*/void usage (int status)
{ {
(void) FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
fputs (_("Usage: chage [options] LOGIN\n" (void) fprintf (usageout,
_("Usage: %s [options] LOGIN\n"
"\n" "\n"
"Options:\n" "Options:\n"),
" -d, --lastday LAST_DAY set date of last password change to LAST_DAY\n" Prog);
" -E, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE\n" (void) fputs (_(" -d, --lastday LAST_DAY set date of last password change to LAST_DAY\n"), usageout);
" -h, --help display this help message and exit\n" (void) fputs (_(" -E, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE\n"), usageout);
" -I, --inactive INACTIVE set password inactive after expiration\n" (void) fputs (_(" -h, --help display this help message and exit\n"), usageout);
" to INACTIVE\n" (void) fputs (_(" -I, --inactive INACTIVE set password inactive after expiration\n"
" -l, --list show account aging information\n" " to INACTIVE\n"), usageout);
" -m, --mindays MIN_DAYS set minimum number of days before password\n" (void) fputs (_(" -l, --list show account aging information\n"), usageout);
" change to MIN_DAYS\n" (void) fputs (_(" -m, --mindays MIN_DAYS set minimum number of days before password\n"
" -M, --maxdays MAX_DAYS set maximim number of days before password\n" " change to MIN_DAYS\n"), usageout);
" change to MAX_DAYS\n" (void) fputs (_(" -M, --maxdays MAX_DAYS set maximim number of days before password\n"
" -W, --warndays WARN_DAYS set expiration warning days to WARN_DAYS\n" " change to MAX_DAYS\n"), usageout);
"\n"), (E_SUCCESS != status) ? stderr : stdout); (void) fputs (_(" -R, --root CHROOT_DIR directory to chroot into\n"), usageout);
(void) fputs (_(" -W, --warndays WARN_DAYS set expiration warning days to WARN_DAYS\n"), usageout);
(void) fputs ("\n", usageout);
exit (status); exit (status);
} }
@ -390,11 +393,12 @@ static void process_flags (int argc, char **argv)
{"list", no_argument, NULL, 'l'}, {"list", no_argument, NULL, 'l'},
{"mindays", required_argument, NULL, 'm'}, {"mindays", required_argument, NULL, 'm'},
{"maxdays", required_argument, NULL, 'M'}, {"maxdays", required_argument, NULL, 'M'},
{"root", required_argument, NULL, 'R'},
{"warndays", required_argument, NULL, 'W'}, {"warndays", required_argument, NULL, 'W'},
{NULL, 0, NULL, '\0'} {NULL, 0, NULL, '\0'}
}; };
while ((c = getopt_long (argc, argv, "d:E:hI:lm:M:W:", while ((c = getopt_long (argc, argv, "d:E:hI:lm:M:R:W:",
long_options, NULL)) != -1) { long_options, NULL)) != -1) {
switch (c) { switch (c) {
case 'd': case 'd':
@ -453,6 +457,8 @@ static void process_flags (int argc, char **argv)
usage (E_USAGE); usage (E_USAGE);
} }
break; break;
case 'R': /* no-op, handled in process_root_flag () */
break;
case 'W': case 'W':
Wflg = true; Wflg = true;
if ( (getlong (optarg, &warndays) == 0) if ( (getlong (optarg, &warndays) == 0)
@ -788,14 +794,23 @@ int main (int argc, char **argv)
gid_t rgid; gid_t rgid;
const struct passwd *pw; const struct passwd *pw;
#ifdef WITH_AUDIT /*
audit_help_open (); * Get the program name so that error messages can use it.
#endif */
Prog = Basename (argv[0]);
sanitize_env (); sanitize_env ();
(void) setlocale (LC_ALL, ""); (void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR); (void) bindtextdomain (PACKAGE, LOCALEDIR);
(void) textdomain (PACKAGE); (void) textdomain (PACKAGE);
process_root_flag ("-R", argc, argv);
#ifdef WITH_AUDIT
audit_help_open ();
#endif
OPENLOG ("chage");
ruid = getuid (); ruid = getuid ();
rgid = getgid (); rgid = getgid ();
amroot = (ruid == 0); amroot = (ruid == 0);
@ -805,15 +820,8 @@ int main (int argc, char **argv)
} }
#endif #endif
/*
* Get the program name so that error messages can use it.
*/
Prog = Basename (argv[0]);
process_flags (argc, argv); process_flags (argc, argv);
OPENLOG ("chage");
check_perms (); check_perms ();
if (!spw_file_present ()) { if (!spw_file_present ()) {