* NEWS, src/faillog.c, man/faillog.8.xml: Add --root option.
* NEWS, src/lastlog.c, man/lastlog.8.xml: Likewise. * src/faillog.c: Add Prog variable, and prefix error messages with Prog rather than "faillog". * src/lastlog.c: Likewise. * src/lastlog.c: Split usage in smaller messages.
This commit is contained in:
parent
0857837e64
commit
a2d23700e4
@ -1,3 +1,12 @@
|
|||||||
|
2011-10-30 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
* NEWS, src/faillog.c, man/faillog.8.xml: Add --root option.
|
||||||
|
* NEWS, src/lastlog.c, man/lastlog.8.xml: Likewise.
|
||||||
|
* src/faillog.c: Add Prog variable, and prefix error messages with
|
||||||
|
Prog rather than "faillog".
|
||||||
|
* src/lastlog.c: Likewise.
|
||||||
|
* src/lastlog.c: Split usage in smaller messages.
|
||||||
|
|
||||||
2011-10-30 Nicolas François <nicolas.francois@centraliens.net>
|
2011-10-30 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* NEWS, src/chage.c, man/chage.1.xml: Add --root option. Open
|
* NEWS, src/chage.c, man/chage.1.xml: Add --root option. Open
|
||||||
|
3
NEWS
3
NEWS
@ -37,6 +37,7 @@ shadow-4.1.4.3 -> shadow-4.1.5 UNRELEASED
|
|||||||
- 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.
|
||||||
|
* Add --root option.
|
||||||
- gpasswd
|
- gpasswd
|
||||||
* Add --root option.
|
* Add --root option.
|
||||||
- groupadd
|
- groupadd
|
||||||
@ -58,6 +59,8 @@ shadow-4.1.4.3 -> shadow-4.1.5 UNRELEASED
|
|||||||
* Add --root option.
|
* Add --root option.
|
||||||
- grpunconv
|
- grpunconv
|
||||||
* Add --root option.
|
* Add --root option.
|
||||||
|
- lastlog
|
||||||
|
* Add --root option.
|
||||||
- login
|
- login
|
||||||
* Fixed limits support (non PAM enabled versions only)
|
* Fixed limits support (non PAM enabled versions only)
|
||||||
* Added support for infinite limits and group based limits (non PAM
|
* Added support for infinite limits and group based limits (non PAM
|
||||||
|
@ -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 - 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,6 +159,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><option>-t</option>, <option>--time</option>
|
<term><option>-t</option>, <option>--time</option>
|
||||||
<replaceable>DAYS</replaceable>
|
<replaceable>DAYS</replaceable>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<!--
|
<!--
|
||||||
Copyright (c) 1992 , Julianne Frances Haugh
|
Copyright (c) 1992 , Julianne Frances Haugh
|
||||||
Copyright (c) 1992 , Phillip Street
|
Copyright (c) 1992 , Phillip Street
|
||||||
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
|
||||||
@ -92,6 +92,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>-t</option>, <option>--time</option>
|
<option>-t</option>, <option>--time</option>
|
||||||
|
@ -61,6 +61,7 @@ static void reset (void);
|
|||||||
/*
|
/*
|
||||||
* Global variables
|
* Global variables
|
||||||
*/
|
*/
|
||||||
|
const char *Prog; /* Program name */
|
||||||
static FILE *fail; /* failure file stream */
|
static FILE *fail; /* failure file stream */
|
||||||
static time_t seconds; /* that number of days in seconds */
|
static time_t seconds; /* that number of days in seconds */
|
||||||
static unsigned long umin; /* if uflg and has_umin, only display users with uid >= umin */
|
static unsigned long umin; /* if uflg and has_umin, only display users with uid >= umin */
|
||||||
@ -87,12 +88,13 @@ static /*@noreturn@*/void usage (int status)
|
|||||||
_("Usage: %s [options]\n"
|
_("Usage: %s [options]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Options:\n"),
|
"Options:\n"),
|
||||||
"faillog");
|
Prog);
|
||||||
(void) fputs (_(" -a, --all display faillog records for all users\n"), usageout);
|
(void) fputs (_(" -a, --all display faillog records for all users\n"), usageout);
|
||||||
(void) fputs (_(" -h, --help display this help message and exit\n"), usageout);
|
(void) fputs (_(" -h, --help display this help message and exit\n"), usageout);
|
||||||
(void) fputs (_(" -l, --lock-secs SEC after failed login lock account for SEC seconds\n"), usageout);
|
(void) fputs (_(" -l, --lock-secs SEC after failed login lock account for SEC seconds\n"), usageout);
|
||||||
(void) fputs (_(" -m, --maximum MAX set maximum failed login counters to MAX\n"), usageout);
|
(void) fputs (_(" -m, --maximum MAX set maximum failed login counters to MAX\n"), usageout);
|
||||||
(void) fputs (_(" -r, --reset reset the counters of login failures\n"), usageout);
|
(void) fputs (_(" -r, --reset reset the counters of login failures\n"), usageout);
|
||||||
|
(void) fputs (_(" -R, --root CHROOT_DIR directory to chroot into\n"), usageout);
|
||||||
(void) fputs (_(" -t, --time DAYS display faillog records more recent than DAYS\n"), usageout);
|
(void) fputs (_(" -t, --time DAYS display faillog records more recent than DAYS\n"), usageout);
|
||||||
(void) fputs (_(" -u, --user LOGIN/RANGE display faillog record or maintains failure\n"
|
(void) fputs (_(" -u, --user LOGIN/RANGE display faillog record or maintains failure\n"
|
||||||
" counters and limits (if used with -r, -m,\n"
|
" counters and limits (if used with -r, -m,\n"
|
||||||
@ -129,8 +131,8 @@ static void print_one (/*@null@*/const struct passwd *pw, bool force)
|
|||||||
*/
|
*/
|
||||||
if (fread ((char *) &fl, sizeof (fl), 1, fail) != 1) {
|
if (fread ((char *) &fl, sizeof (fl), 1, fail) != 1) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("faillog: Failed to get the entry for UID %lu\n"),
|
_("%s: Failed to get the entry for UID %lu\n"),
|
||||||
(unsigned long int)pw->pw_uid);
|
Prog, (unsigned long int)pw->pw_uid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -229,8 +231,8 @@ static bool reset_one (uid_t uid)
|
|||||||
*/
|
*/
|
||||||
if (fread ((char *) &fl, sizeof (fl), 1, fail) != 1) {
|
if (fread ((char *) &fl, sizeof (fl), 1, fail) != 1) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("faillog: Failed to get the entry for UID %lu\n"),
|
_("%s: Failed to get the entry for UID %lu\n"),
|
||||||
(unsigned long int)uid);
|
Prog, (unsigned long int)uid);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -259,8 +261,8 @@ static bool reset_one (uid_t uid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("faillog: Failed to reset fail count for UID %lu\n"),
|
_("%s: Failed to reset fail count for UID %lu\n"),
|
||||||
(unsigned long int)uid);
|
Prog, (unsigned long int)uid);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,8 +345,8 @@ static bool setmax_one (uid_t uid, int max)
|
|||||||
*/
|
*/
|
||||||
if (fread ((char *) &fl, sizeof (fl), 1, fail) != 1) {
|
if (fread ((char *) &fl, sizeof (fl), 1, fail) != 1) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("faillog: Failed to get the entry for UID %lu\n"),
|
_("%s: Failed to get the entry for UID %lu\n"),
|
||||||
(unsigned long int)uid);
|
Prog, (unsigned long int)uid);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -374,8 +376,8 @@ static bool setmax_one (uid_t uid, int max)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("faillog: Failed to set max for UID %lu\n"),
|
_("%s: Failed to set max for UID %lu\n"),
|
||||||
(unsigned long int)uid);
|
Prog, (unsigned long int)uid);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -460,8 +462,8 @@ static bool set_locktime_one (uid_t uid, long locktime)
|
|||||||
*/
|
*/
|
||||||
if (fread ((char *) &fl, sizeof (fl), 1, fail) != 1) {
|
if (fread ((char *) &fl, sizeof (fl), 1, fail) != 1) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("faillog: Failed to get the entry for UID %lu\n"),
|
_("%s: Failed to get the entry for UID %lu\n"),
|
||||||
(unsigned long int)uid);
|
Prog, (unsigned long int)uid);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -491,8 +493,8 @@ static bool set_locktime_one (uid_t uid, long locktime)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("faillog: Failed to set locktime for UID %lu\n"),
|
_("%s: Failed to set locktime for UID %lu\n"),
|
||||||
(unsigned long int)uid);
|
Prog, (unsigned long int)uid);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -562,10 +564,18 @@ int main (int argc, char **argv)
|
|||||||
long fail_max;
|
long fail_max;
|
||||||
long days;
|
long days;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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) setlocale (LC_ALL, "");
|
||||||
(void) bindtextdomain (PACKAGE, LOCALEDIR);
|
(void) bindtextdomain (PACKAGE, LOCALEDIR);
|
||||||
(void) textdomain (PACKAGE);
|
(void) textdomain (PACKAGE);
|
||||||
|
|
||||||
|
process_root_flag ("-R", argc, argv);
|
||||||
|
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
@ -574,11 +584,12 @@ int main (int argc, char **argv)
|
|||||||
{"lock-secs", required_argument, NULL, 'l'},
|
{"lock-secs", required_argument, NULL, 'l'},
|
||||||
{"maximum", required_argument, NULL, 'm'},
|
{"maximum", required_argument, NULL, 'm'},
|
||||||
{"reset", no_argument, NULL, 'r'},
|
{"reset", no_argument, NULL, 'r'},
|
||||||
|
{"root", required_argument, NULL, 'R'},
|
||||||
{"time", required_argument, NULL, 't'},
|
{"time", required_argument, NULL, 't'},
|
||||||
{"user", required_argument, NULL, 'u'},
|
{"user", required_argument, NULL, 'u'},
|
||||||
{NULL, 0, NULL, '\0'}
|
{NULL, 0, NULL, '\0'}
|
||||||
};
|
};
|
||||||
while ((c = getopt_long (argc, argv, "ahl:m:rt:u:",
|
while ((c = getopt_long (argc, argv, "ahl:m:rR:t:u:",
|
||||||
long_options, NULL)) != -1) {
|
long_options, NULL)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'a':
|
case 'a':
|
||||||
@ -591,7 +602,7 @@ int main (int argc, char **argv)
|
|||||||
if (getlong (optarg, &fail_locktime) == 0) {
|
if (getlong (optarg, &fail_locktime) == 0) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: invalid numeric argument '%s'\n"),
|
_("%s: invalid numeric argument '%s'\n"),
|
||||||
"faillog", optarg);
|
Prog, optarg);
|
||||||
exit (E_BAD_ARG);
|
exit (E_BAD_ARG);
|
||||||
}
|
}
|
||||||
lflg = true;
|
lflg = true;
|
||||||
@ -600,7 +611,7 @@ int main (int argc, char **argv)
|
|||||||
if (getlong (optarg, &fail_max) == 0) {
|
if (getlong (optarg, &fail_max) == 0) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: invalid numeric argument '%s'\n"),
|
_("%s: invalid numeric argument '%s'\n"),
|
||||||
"faillog", optarg);
|
Prog, optarg);
|
||||||
exit (E_BAD_ARG);
|
exit (E_BAD_ARG);
|
||||||
}
|
}
|
||||||
mflg = true;
|
mflg = true;
|
||||||
@ -608,11 +619,13 @@ int main (int argc, char **argv)
|
|||||||
case 'r':
|
case 'r':
|
||||||
rflg = true;
|
rflg = true;
|
||||||
break;
|
break;
|
||||||
|
case 'R': /* no-op, handled in process_root_flag () */
|
||||||
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
if (getlong (optarg, &days) == 0) {
|
if (getlong (optarg, &days) == 0) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: invalid numeric argument '%s'\n"),
|
_("%s: invalid numeric argument '%s'\n"),
|
||||||
"faillog", optarg);
|
Prog, optarg);
|
||||||
exit (E_BAD_ARG);
|
exit (E_BAD_ARG);
|
||||||
}
|
}
|
||||||
seconds = (time_t) days * DAY;
|
seconds = (time_t) days * DAY;
|
||||||
@ -642,8 +655,8 @@ int main (int argc, char **argv)
|
|||||||
&umin, &has_umin,
|
&umin, &has_umin,
|
||||||
&umax, &has_umax) == 0) {
|
&umax, &has_umax) == 0) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("faillog: Unknown user or range: %s\n"),
|
_("%s: Unknown user or range: %s\n"),
|
||||||
optarg);
|
Prog, optarg);
|
||||||
exit (E_BAD_ARG);
|
exit (E_BAD_ARG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -656,8 +669,8 @@ int main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
if (argc > optind) {
|
if (argc > optind) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("faillog: unexpected argument: %s\n"),
|
_("%s: unexpected argument: %s\n"),
|
||||||
argv[optind]);
|
Prog, argv[optind]);
|
||||||
usage (EXIT_FAILURE);
|
usage (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -674,16 +687,16 @@ int main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
if (NULL == fail) {
|
if (NULL == fail) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("faillog: Cannot open %s: %s\n"),
|
_("%s: Cannot open %s: %s\n"),
|
||||||
FAILLOG_FILE, strerror (errno));
|
Prog, FAILLOG_FILE, strerror (errno));
|
||||||
exit (E_NOPERM);
|
exit (E_NOPERM);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the size of the faillog */
|
/* Get the size of the faillog */
|
||||||
if (fstat (fileno (fail), &statbuf) != 0) {
|
if (fstat (fileno (fail), &statbuf) != 0) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("faillog: Cannot get the size of %s: %s\n"),
|
_("%s: Cannot get the size of %s: %s\n"),
|
||||||
FAILLOG_FILE, strerror (errno));
|
Prog, FAILLOG_FILE, strerror (errno));
|
||||||
exit (E_NOPERM);
|
exit (E_NOPERM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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) 2000 - 2006, Tomasz Kłoczko
|
* Copyright (c) 2000 - 2006, Tomasz Kłoczko
|
||||||
* 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
|
||||||
@ -44,6 +44,8 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
|
/*@-exitarg@*/
|
||||||
|
#include "exitcodes.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Needed for MkLinux DR1/2/2.1 - J.
|
* Needed for MkLinux DR1/2/2.1 - J.
|
||||||
@ -55,6 +57,7 @@
|
|||||||
/*
|
/*
|
||||||
* Global variables
|
* Global variables
|
||||||
*/
|
*/
|
||||||
|
const char *Prog; /* Program name */
|
||||||
static FILE *lastlogfile; /* lastlog file stream */
|
static FILE *lastlogfile; /* lastlog file stream */
|
||||||
static unsigned long umin; /* if uflg and has_umin, only display users with uid >= umin */
|
static unsigned long umin; /* if uflg and has_umin, only display users with uid >= umin */
|
||||||
static bool has_umin = false;
|
static bool has_umin = false;
|
||||||
@ -73,14 +76,18 @@ static bool bflg = false; /* print excludes most recent days */
|
|||||||
|
|
||||||
static /*@noreturn@*/void usage (int status)
|
static /*@noreturn@*/void usage (int status)
|
||||||
{
|
{
|
||||||
fputs (_("Usage: lastlog [options]\n"
|
FILE *usageout = (E_SUCCESS != status) ? stderr : stdout;
|
||||||
"\n"
|
(void) fprintf (usageout,
|
||||||
"Options:\n"
|
_("Usage: %s [options]\n"
|
||||||
" -b, --before DAYS print only lastlog records older than DAYS\n"
|
"\n"
|
||||||
" -h, --help display this help message and exit\n"
|
"Options:\n"),
|
||||||
" -t, --time DAYS print only lastlog records more recent than DAYS\n"
|
Prog);
|
||||||
" -u, --user LOGIN print lastlog record of the specified LOGIN\n"
|
(void) fputs (_(" -b, --before DAYS print only lastlog records older than DAYS\n"), usageout);
|
||||||
"\n"), (EXIT_SUCCESS != status) ? stderr : stdout);
|
(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 (_(" -t, --time DAYS print only lastlog records more recent than DAYS\n"), usageout);
|
||||||
|
(void) fputs (_(" -u, --user LOGIN print lastlog record of the specified LOGIN\n"), usageout);
|
||||||
|
(void) fputs ("\n", usageout);
|
||||||
exit (status);
|
exit (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,8 +120,8 @@ static void print_one (/*@null@*/const struct passwd *pw)
|
|||||||
*/
|
*/
|
||||||
if (fread ((char *) &ll, sizeof (ll), 1, lastlogfile) != 1) {
|
if (fread ((char *) &ll, sizeof (ll), 1, lastlogfile) != 1) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("lastlog: Failed to get the entry for UID %lu\n"),
|
_("%s: Failed to get the entry for UID %lu\n"),
|
||||||
(unsigned long int)pw->pw_uid);
|
Prog, (unsigned long int)pw->pw_uid);
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -189,21 +196,30 @@ static void print (void)
|
|||||||
|
|
||||||
int main (int argc, char **argv)
|
int main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* 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) setlocale (LC_ALL, "");
|
||||||
(void) bindtextdomain (PACKAGE, LOCALEDIR);
|
(void) bindtextdomain (PACKAGE, LOCALEDIR);
|
||||||
(void) textdomain (PACKAGE);
|
(void) textdomain (PACKAGE);
|
||||||
|
|
||||||
|
process_root_flag ("-R", argc, argv);
|
||||||
|
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
static struct option const longopts[] = {
|
static struct option const longopts[] = {
|
||||||
{"help", no_argument, NULL, 'h'},
|
{"help", no_argument, NULL, 'h'},
|
||||||
{"time", required_argument, NULL, 't'},
|
{"time", required_argument, NULL, 't'},
|
||||||
{"before", required_argument, NULL, 'b'},
|
{"before", required_argument, NULL, 'b'},
|
||||||
|
{"root", required_argument, NULL, 'R'},
|
||||||
{"user", required_argument, NULL, 'u'},
|
{"user", required_argument, NULL, 'u'},
|
||||||
{NULL, 0, NULL, '\0'}
|
{NULL, 0, NULL, '\0'}
|
||||||
};
|
};
|
||||||
|
|
||||||
while ((c = getopt_long (argc, argv, "ht:b:u:", longopts,
|
while ((c = getopt_long (argc, argv, "ht:b:R:u:", longopts,
|
||||||
NULL)) != -1) {
|
NULL)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'h':
|
case 'h':
|
||||||
@ -215,7 +231,7 @@ int main (int argc, char **argv)
|
|||||||
if (getulong (optarg, &days) == 0) {
|
if (getulong (optarg, &days) == 0) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: invalid numeric argument '%s'\n"),
|
_("%s: invalid numeric argument '%s'\n"),
|
||||||
"lastlog", optarg);
|
Prog, optarg);
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
seconds = (time_t) days * DAY;
|
seconds = (time_t) days * DAY;
|
||||||
@ -228,13 +244,15 @@ int main (int argc, char **argv)
|
|||||||
if (getulong (optarg, &inverse_days) == 0) {
|
if (getulong (optarg, &inverse_days) == 0) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: invalid numeric argument '%s'\n"),
|
_("%s: invalid numeric argument '%s'\n"),
|
||||||
"lastlog", optarg);
|
Prog, optarg);
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
inverse_seconds = (time_t) inverse_days * DAY;
|
inverse_seconds = (time_t) inverse_days * DAY;
|
||||||
bflg = true;
|
bflg = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'R': /* no-op, handled in process_root_flag () */
|
||||||
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
{
|
{
|
||||||
const struct passwd *pwent;
|
const struct passwd *pwent;
|
||||||
@ -258,8 +276,8 @@ int main (int argc, char **argv)
|
|||||||
&umin, &has_umin,
|
&umin, &has_umin,
|
||||||
&umax, &has_umax) == 0) {
|
&umax, &has_umax) == 0) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("lastlog: Unknown user or range: %s\n"),
|
_("%s: Unknown user or range: %s\n"),
|
||||||
optarg);
|
Prog, optarg);
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -272,8 +290,8 @@ int main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
if (argc > optind) {
|
if (argc > optind) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("lastlog: unexpected argument: %s\n"),
|
_("%s: unexpected argument: %s\n"),
|
||||||
argv[optind]);
|
Prog, argv[optind]);
|
||||||
usage (EXIT_FAILURE);
|
usage (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -287,8 +305,8 @@ int main (int argc, char **argv)
|
|||||||
/* Get the lastlog size */
|
/* Get the lastlog size */
|
||||||
if (fstat (fileno (lastlogfile), &statbuf) != 0) {
|
if (fstat (fileno (lastlogfile), &statbuf) != 0) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("lastlog: Cannot get the size of %s: %s\n"),
|
_("%s: Cannot get the size of %s: %s\n"),
|
||||||
LASTLOG_FILE, strerror (errno));
|
Prog, LASTLOG_FILE, strerror (errno));
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user