* NEWS, src/passwd.c, man/passwd.1.xml: Add --root option.
passwd's usage split in smaller messages. * src/passwd.c: Call sanitize_env() before setting the locales.
This commit is contained in:
parent
799f30b08d
commit
ec2b9f59f7
@ -33,6 +33,9 @@
|
|||||||
man/chgpasswd.8.xml: Add --root option.
|
man/chgpasswd.8.xml: Add --root option.
|
||||||
* src/chpasswd.c, src/chgpasswd.c: The getopt index of long
|
* src/chpasswd.c, src/chgpasswd.c: The getopt index of long
|
||||||
options is not used.
|
options is not used.
|
||||||
|
* NEWS, src/passwd.c, man/passwd.1.xml: Add --root option.
|
||||||
|
passwd's usage split in smaller messages.
|
||||||
|
* src/passwd.c: Call sanitize_env() before setting the locales.
|
||||||
|
|
||||||
2011-10-22 Nicolas François <nicolas.francois@centraliens.net>
|
2011-10-22 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
6
NEWS
6
NEWS
@ -37,6 +37,8 @@ shadow-4.1.4.3 -> shadow-4.1.5 UNRELEASED
|
|||||||
* Add --root option.
|
* Add --root option.
|
||||||
- groupdel
|
- groupdel
|
||||||
* Add --root option.
|
* Add --root option.
|
||||||
|
- groupmems
|
||||||
|
* Fix parsing of gshadow entries.
|
||||||
- groupmod
|
- groupmod
|
||||||
* Fixed groupmod when configured with --enable-account-tools-setuid.
|
* Fixed groupmod when configured with --enable-account-tools-setuid.
|
||||||
* 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
|
||||||
@ -75,8 +77,10 @@ shadow-4.1.4.3 -> shadow-4.1.5 UNRELEASED
|
|||||||
* Close PAM sessions as root. This will be more friendly to PAM modules
|
* Close PAM sessions as root. This will be more friendly to PAM modules
|
||||||
like pam_mount or pam_systemd.
|
like pam_mount or pam_systemd.
|
||||||
* Added support for PAM modules which change PAM_USER.
|
* Added support for PAM modules which change PAM_USER.
|
||||||
- newgrp, sg, groupmems
|
- newgrp, sg
|
||||||
* Fix parsing of gshadow entries.
|
* Fix parsing of gshadow entries.
|
||||||
|
- passwd
|
||||||
|
* Add --root option.
|
||||||
- pwpck
|
- pwpck
|
||||||
* NIS entries were dropped by -s (sort).
|
* NIS entries were dropped by -s (sort).
|
||||||
- pwconv
|
- pwconv
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!--
|
<!--
|
||||||
Copyright (c) 1989 - 1994, Julianne Frances Haugh
|
Copyright (c) 1989 - 1994, Julianne Frances Haugh
|
||||||
Copyright (c) 2007 - 2009, 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
|
||||||
@ -278,6 +278,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>-S</option>, <option>--status</option>
|
<option>-S</option>, <option>--status</option>
|
||||||
|
79
src/passwd.c
79
src/passwd.c
@ -2,7 +2,7 @@
|
|||||||
* Copyright (c) 1989 - 1994, Julianne Frances Haugh
|
* Copyright (c) 1989 - 1994, Julianne Frances Haugh
|
||||||
* Copyright (c) 1996 - 2000, Marek Michałkiewicz
|
* Copyright (c) 1996 - 2000, Marek Michałkiewicz
|
||||||
* Copyright (c) 2001 - 2006, Tomasz Kłoczko
|
* Copyright (c) 2001 - 2006, Tomasz Kłoczko
|
||||||
* Copyright (c) 2007 - 2010, 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
|
||||||
@ -159,28 +159,31 @@ static int check_selinux_access (const char *changed_user,
|
|||||||
*/
|
*/
|
||||||
static /*@noreturn@*/void usage (int status)
|
static /*@noreturn@*/void usage (int status)
|
||||||
{
|
{
|
||||||
(void)
|
FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
|
||||||
fputs (_("Usage: passwd [options] [LOGIN]\n"
|
(void) fprintf (usageout,
|
||||||
"\n"
|
_("Usage: %s [options] [LOGIN]\n"
|
||||||
"Options:\n"
|
"\n"
|
||||||
" -a, --all report password status on all accounts\n"
|
"Options:\n"),
|
||||||
" -d, --delete delete the password for the named account\n"
|
Prog);
|
||||||
" -e, --expire force expire the password for the named account\n"
|
(void) fputs (_(" -a, --all report password status on all accounts\n"), usageout);
|
||||||
" -h, --help display this help message and exit\n"
|
(void) fputs (_(" -d, --delete delete the password for the named account\n"), usageout);
|
||||||
" -k, --keep-tokens change password only if expired\n"
|
(void) fputs (_(" -e, --expire force expire the password for the named account\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 (_(" -k, --keep-tokens change password only if expired\n"), usageout);
|
||||||
" -l, --lock lock the password of the named account\n"
|
(void) fputs (_(" -i, --inactive INACTIVE set password inactive after expiration\n"
|
||||||
" -n, --mindays MIN_DAYS set minimum number of days before password\n"
|
" to INACTIVE\n"), usageout);
|
||||||
" change to MIN_DAYS\n"
|
(void) fputs (_(" -l, --lock lock the password of the named account\n"), usageout);
|
||||||
" -q, --quiet quiet mode\n"
|
(void) fputs (_(" -n, --mindays MIN_DAYS set minimum number of days before password\n"
|
||||||
" -r, --repository REPOSITORY change password in REPOSITORY repository\n"
|
" change to MIN_DAYS\n"), usageout);
|
||||||
" -S, --status report password status on the named account\n"
|
(void) fputs (_(" -q, --quiet quiet mode\n"), usageout);
|
||||||
" -u, --unlock unlock the password of the named account\n"
|
(void) fputs (_(" -r, --repository REPOSITORY change password in REPOSITORY repository\n"), usageout);
|
||||||
" -w, --warndays WARN_DAYS set expiration warning days to WARN_DAYS\n"
|
(void) fputs (_(" -R, --root CHROOT_DIR directory to chroot into\n"), usageout);
|
||||||
" -x, --maxdays MAX_DAYS set maximum number of days before password\n"
|
(void) fputs (_(" -S, --status report password status on the named account\n"), usageout);
|
||||||
" change to MAX_DAYS\n"
|
(void) fputs (_(" -u, --unlock unlock the password of the named account\n"), usageout);
|
||||||
"\n"), (E_SUCCESS != status) ? stderr : stdout);
|
(void) fputs (_(" -w, --warndays WARN_DAYS set expiration warning days to WARN_DAYS\n"), usageout);
|
||||||
|
(void) fputs (_(" -x, --maxdays MAX_DAYS set maximum number of days before password\n"
|
||||||
|
" change to MAX_DAYS\n"), usageout);
|
||||||
|
(void) fputs ("\n", usageout);
|
||||||
exit (status);
|
exit (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -771,15 +774,7 @@ int main (int argc, char **argv)
|
|||||||
const struct spwd *sp; /* Shadow file entry for user */
|
const struct spwd *sp; /* Shadow file entry for user */
|
||||||
#endif /* !USE_PAM */
|
#endif /* !USE_PAM */
|
||||||
|
|
||||||
(void) setlocale (LC_ALL, "");
|
sanitize_env ();
|
||||||
(void) bindtextdomain (PACKAGE, LOCALEDIR);
|
|
||||||
(void) textdomain (PACKAGE);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The program behaves differently when executed by root than when
|
|
||||||
* executed by a normal user.
|
|
||||||
*/
|
|
||||||
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
|
||||||
@ -787,7 +782,17 @@ int main (int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
Prog = Basename (argv[0]);
|
Prog = Basename (argv[0]);
|
||||||
|
|
||||||
sanitize_env ();
|
(void) setlocale (LC_ALL, "");
|
||||||
|
(void) bindtextdomain (PACKAGE, LOCALEDIR);
|
||||||
|
(void) textdomain (PACKAGE);
|
||||||
|
|
||||||
|
process_root_flag ("-R", argc, argv);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The program behaves differently when executed by root than when
|
||||||
|
* executed by a normal user.
|
||||||
|
*/
|
||||||
|
amroot = (getuid () == 0);
|
||||||
|
|
||||||
OPENLOG ("passwd");
|
OPENLOG ("passwd");
|
||||||
|
|
||||||
@ -795,7 +800,6 @@ int main (int argc, char **argv)
|
|||||||
/*
|
/*
|
||||||
* Parse the command line options.
|
* Parse the command line options.
|
||||||
*/
|
*/
|
||||||
int option_index = 0;
|
|
||||||
int c;
|
int c;
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
{"all", no_argument, NULL, 'a'},
|
{"all", no_argument, NULL, 'a'},
|
||||||
@ -808,6 +812,7 @@ int main (int argc, char **argv)
|
|||||||
{"mindays", required_argument, NULL, 'n'},
|
{"mindays", required_argument, NULL, 'n'},
|
||||||
{"quiet", no_argument, NULL, 'q'},
|
{"quiet", no_argument, NULL, 'q'},
|
||||||
{"repository", required_argument, NULL, 'r'},
|
{"repository", required_argument, NULL, 'r'},
|
||||||
|
{"root", required_argument, NULL, 'R'},
|
||||||
{"status", no_argument, NULL, 'S'},
|
{"status", no_argument, NULL, 'S'},
|
||||||
{"unlock", no_argument, NULL, 'u'},
|
{"unlock", no_argument, NULL, 'u'},
|
||||||
{"warndays", required_argument, NULL, 'w'},
|
{"warndays", required_argument, NULL, 'w'},
|
||||||
@ -815,8 +820,8 @@ int main (int argc, char **argv)
|
|||||||
{NULL, 0, NULL, '\0'}
|
{NULL, 0, NULL, '\0'}
|
||||||
};
|
};
|
||||||
|
|
||||||
while ((c = getopt_long (argc, argv, "adehi:kln:qr:Suw:x:",
|
while ((c = getopt_long (argc, argv, "adehi:kln:qr:R:Suw:x:",
|
||||||
long_options, &option_index)) != -1) {
|
long_options, NULL)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'a':
|
case 'a':
|
||||||
aflg = true;
|
aflg = true;
|
||||||
@ -872,6 +877,8 @@ int main (int argc, char **argv)
|
|||||||
exit (E_BAD_ARG);
|
exit (E_BAD_ARG);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'R': /* no-op, handled in process_root_flag () */
|
||||||
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
Sflg = true; /* ok for users */
|
Sflg = true; /* ok for users */
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user