160
160
static /*@noreturn@*/void usage (int status)
163
fputs (_("Usage: passwd [options] [LOGIN]\n"
166
" -a, --all report password status on all accounts\n"
167
" -d, --delete delete the password for the named account\n"
168
" -e, --expire force expire the password for the named account\n"
169
" -h, --help display this help message and exit\n"
170
" -k, --keep-tokens change password only if expired\n"
171
" -i, --inactive INACTIVE set password inactive after expiration\n"
173
" -l, --lock lock the password of the named account\n"
174
" -n, --mindays MIN_DAYS set minimum number of days before password\n"
175
" change to MIN_DAYS\n"
176
" -q, --quiet quiet mode\n"
177
" -r, --repository REPOSITORY change password in REPOSITORY repository\n"
178
" -S, --status report password status on the named account\n"
179
" -u, --unlock unlock the password of the named account\n"
180
" -w, --warndays WARN_DAYS set expiration warning days to WARN_DAYS\n"
181
" -x, --maxdays MAX_DAYS set maximum number of days before password\n"
182
" change to MAX_DAYS\n"
183
"\n"), (E_SUCCESS != status) ? stderr : stdout);
162
FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
163
(void) fprintf (usageout,
164
_("Usage: %s [options] [LOGIN]\n"
168
(void) fputs (_(" -a, --all report password status on all accounts\n"), usageout);
169
(void) fputs (_(" -d, --delete delete the password for the named account\n"), usageout);
170
(void) fputs (_(" -e, --expire force expire the password for the named account\n"), usageout);
171
(void) fputs (_(" -h, --help display this help message and exit\n"), usageout);
172
(void) fputs (_(" -k, --keep-tokens change password only if expired\n"), usageout);
173
(void) fputs (_(" -i, --inactive INACTIVE set password inactive after expiration\n"
174
" to INACTIVE\n"), usageout);
175
(void) fputs (_(" -l, --lock lock the password of the named account\n"), usageout);
176
(void) fputs (_(" -n, --mindays MIN_DAYS set minimum number of days before password\n"
177
" change to MIN_DAYS\n"), usageout);
178
(void) fputs (_(" -q, --quiet quiet mode\n"), usageout);
179
(void) fputs (_(" -r, --repository REPOSITORY change password in REPOSITORY repository\n"), usageout);
180
(void) fputs (_(" -R, --root CHROOT_DIR directory to chroot into\n"), usageout);
181
(void) fputs (_(" -S, --status report password status on the named account\n"), usageout);
182
(void) fputs (_(" -u, --unlock unlock the password of the named account\n"), usageout);
183
(void) fputs (_(" -w, --warndays WARN_DAYS set expiration warning days to WARN_DAYS\n"), usageout);
184
(void) fputs (_(" -x, --maxdays MAX_DAYS set maximum number of days before password\n"
185
" change to MAX_DAYS\n"), usageout);
186
(void) fputs ("\n", usageout);
459
464
sp = getspnam (pw->pw_name); /* local, no need for xgetspnam */
460
465
if (NULL != sp) {
461
(void) printf ("%s %s %s %ld %ld %ld %ld\n",
466
(void) printf ("%s %s %s %lld %lld %lld %lld\n",
463
468
pw_status (sp->sp_pwdp),
464
469
date_to_str (sp->sp_lstchg * SCALE),
465
(sp->sp_min * SCALE) / DAY,
466
(sp->sp_max * SCALE) / DAY,
467
(sp->sp_warn * SCALE) / DAY,
468
(sp->sp_inact * SCALE) / DAY);
470
((long long)sp->sp_min * SCALE) / DAY,
471
((long long)sp->sp_max * SCALE) / DAY,
472
((long long)sp->sp_warn * SCALE) / DAY,
473
((long long)sp->sp_inact * SCALE) / DAY);
470
475
(void) printf ("%s %s\n",
471
476
pw->pw_name, pw_status (pw->pw_passwd));
771
776
const struct spwd *sp; /* Shadow file entry for user */
772
777
#endif /* !USE_PAM */
782
* Get the program name. The program name is used as a prefix to
783
* most error messages.
785
Prog = Basename (argv[0]);
774
787
(void) setlocale (LC_ALL, "");
775
788
(void) bindtextdomain (PACKAGE, LOCALEDIR);
776
789
(void) textdomain (PACKAGE);
791
process_root_flag ("-R", argc, argv);
779
794
* The program behaves differently when executed by root than when
780
795
* executed by a normal user.
782
797
amroot = (getuid () == 0);
785
* Get the program name. The program name is used as a prefix to
786
* most error messages.
788
Prog = Basename (argv[0]);
792
799
OPENLOG ("passwd");
796
803
* Parse the command line options.
798
int option_index = 0;
800
806
static struct option long_options[] = {
801
{"all", no_argument, NULL, 'a'},
802
{"delete", no_argument, NULL, 'd'},
803
{"expire", no_argument, NULL, 'e'},
804
{"help", no_argument, NULL, 'h'},
805
{"inactive", required_argument, NULL, 'i'},
806
{"keep-tokens", no_argument, NULL, 'k'},
807
{"lock", no_argument, NULL, 'l'},
808
{"mindays", required_argument, NULL, 'n'},
809
{"quiet", no_argument, NULL, 'q'},
810
{"repository", required_argument, NULL, 'r'},
811
{"status", no_argument, NULL, 'S'},
812
{"unlock", no_argument, NULL, 'u'},
813
{"warndays", required_argument, NULL, 'w'},
814
{"maxdays", required_argument, NULL, 'x'},
807
{"all", no_argument, NULL, 'a'},
808
{"delete", no_argument, NULL, 'd'},
809
{"expire", no_argument, NULL, 'e'},
810
{"help", no_argument, NULL, 'h'},
811
{"inactive", required_argument, NULL, 'i'},
812
{"keep-tokens", no_argument, NULL, 'k'},
813
{"lock", no_argument, NULL, 'l'},
814
{"mindays", required_argument, NULL, 'n'},
815
{"quiet", no_argument, NULL, 'q'},
816
{"repository", required_argument, NULL, 'r'},
817
{"root", required_argument, NULL, 'R'},
818
{"status", no_argument, NULL, 'S'},
819
{"unlock", no_argument, NULL, 'u'},
820
{"warndays", required_argument, NULL, 'w'},
821
{"maxdays", required_argument, NULL, 'x'},
815
822
{NULL, 0, NULL, '\0'}
818
while ((c = getopt_long (argc, argv, "adehi:kln:qr:Suw:x:",
819
long_options, &option_index)) != -1) {
825
while ((c = getopt_long (argc, argv, "adehi:kln:qr:R:Suw:x:",
826
long_options, NULL)) != -1) {