summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2014-05-16 14:04:54 +0200
committerKarel Zak2014-05-16 14:04:54 +0200
commit512abd56946224bbc588af4b5161b573462983e7 (patch)
tree590070e7ae3ec7c49d1b1e4844a406b8296672ea
parentlslogins: improve pretty output (diff)
downloadkernel-qcow2-util-linux-512abd56946224bbc588af4b5161b573462983e7.tar.gz
kernel-qcow2-util-linux-512abd56946224bbc588af4b5161b573462983e7.tar.xz
kernel-qcow2-util-linux-512abd56946224bbc588af4b5161b573462983e7.zip
lslogins: sync man page and usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--login-utils/lslogins.165
-rw-r--r--login-utils/lslogins.c95
2 files changed, 81 insertions, 79 deletions
diff --git a/login-utils/lslogins.1 b/login-utils/lslogins.1
index 2075cc494..ecd668a7d 100644
--- a/login-utils/lslogins.1
+++ b/login-utils/lslogins.1
@@ -5,7 +5,7 @@
lslogins \- display information about known users in the system
.SH SYNOPSIS
.B lslogins
-[\fI-adehmoptvx\fR] [-s|-u[\fI=UID\fR]] [-g \fIGROUPS\fR] [-l \fILOGINS\fR]
+[\fIoptions\fR] [-s|-u[\fI=UID\fR]] [-g \fIGROUPS\fR] [-l \fILOGINS\fR]
.SH DESCRIPTION
.PP
Examine the wtmp and btmp logs, /etc/shadow (if necessary) and /etc/passwd
@@ -19,56 +19,66 @@ The default action is to list info about all the users in the system.
Display info about existing users.
.TP
\fB\-a\fR, \fB\-\-acc\-expiration\fR
-Display data about the date of last password change and the account expiration date (see shadow(5) for more info).
+Display data about the date of last password change and the account expiration
+date (see shadow(5) for more info). (Requires root priviliges.)
.TP
-\fB\-c\fR, \fB\-\-colon\fR
+\fB\-c\fR, \fB\-\-colon\-separate\fR
Separate info about each user with a colon instead of a newline.
.TP
-\fB\-d\fR, \fB\-\-duplicates\fR
-Show users with duplicate UIDs.
-.TP
\fB\-e\fR, \fB\-\-export\fR
Output data in the format of NAME=VALUE.
.TP
\fB\-f\fR, \fB\-\-failed\fR
Display data about the users' last failed login attempts.
.TP
+\fB\-\-fulltimes\fR
+Show all dates in a long format.
+.TP
\fB\-g\fR, \fB\-\-groups\fR=\fIGROUPS\fR
Only show data of users belonging to \fIGROUPS\fR. More than one group may be specified; the list has to be comma-separated.
.TP
-\fB\-\-last\fR
-Display data containing information about the users' last login sessions.
-.TP
\fB\-l\fR, \fB\-\-logins\fR=\fILOGINS\fR
Only show data of users with a login specified in \fILOGINS\fR. More than one login may be specified; the list has to be comma-separated.
.TP
-\fB\-m\fR, \fB\-\-more\fR
-Show secondary groups as well.
+\fB\-\-last\fR
+Display data containing information about the users' last login sessions.
+.TP
+\fB\-m\fR, \fB\-\-supp\-groups\fR
+Show supplementary groups.
.TP
\fB\-n\fR, \fB\-\-newline\fR
Display each piece of information on a separate line.
.TP
-\fB\-p\fR, \fB\-\-no\-password\fR
-Show users without a password.
+\fB\-\-notruncate\fR
+Don't truncate output.
+.TP
+\fB\-o , \-\-output \fIlist\fP
+Specify which output columns to print. Use
+.B \-\-help
+to get a list of all supported columns.
.TP
\fB\-r\fR, \fB\-\-raw\fR
Raw output (no columnation).
.TP
-\fB\-s\fR, \fB\-\-sys\-accs\fR
+\fB\-s\fR, \fB\-\-system\-accs\fR
Show system accounts. These are by the default all accounts with UID below 1000 (non-inclusive), with the exception of either nobody or nfsnobody (UID 65534). The UID
treshold can also be specified explicitly (necessary for some distributions that allocate UIDs
starting from 100, 500 - or an entirely different value - rather than 1000).
.TP
-\fB\-t\fR, \fB\-\-sort\fR
+\fB\-t\fR, \fB\-\-sort\-name\fR
Sort by user name, rather than UID.
.TP
+\fB\-\-time-format\fR \fItype\fP
+Display dates in short, full or iso format.
+.TP
\fB\-u\fR, \fB\-\-user\-accs\fR
Show user accounts. These are by the default all accounts with UID above 1000 (inclusive), with the exception of either nobody or nfsnobody (UID 65534). The UID
treshold can also be specified explicitly (necessary for some distributions that allocate UIDs
starting from 100, 500 - or an entirely different value - rather than 1000).
.TP
\fB\-x\fR, \fB\-\-extra\fR
-Show extra information about users - home diretory, default login shell, password age and expiry information.
+Show extra information about users - home diretory, default login shell,
+password age and expiry information.(Requires root priviliges.)
.TP
\fB\-z\fR, \fB\-\-print0\fR
Delimit user entries with a nul character, instead of a newline.
@@ -76,26 +86,21 @@ Delimit user entries with a nul character, instead of a newline.
\fB\-Z\fR, \fB\-\-context\fR
Display the users' security context.
.TP
+\fB\-\-wtmp\-file \fIpath\fP
+Alternate path for wtmp.
+.TP
+\fB\-\-btmp\-file \fIpath\fP
+Alternate path for btmp.
+.TP
\fB\-h\fR, \fB\-\-help\fR
Display help information and exit.
+.TP
\fB\-v\fR, \fB\-\-version\fR
Display version information and exit.
+.SH NOTES
+The default UID tresholds are read from /etc/login.defs.
-Note that the default UID tresholds are read from /etc/login.defs.
-Note that switches -a and -x require root priviliges. Otherwise their fields will state "-" for each entry.
-.sp
-.\".SH COLORS
-.\"Implicit coloring can be disabled as follows:
-.\".RS
-
-.\".br
-.\".BI "touch /etc/terminal-colors.d/lslogins.disable"
-.\".br
-.\"
-.\".RE
-.\"For more details see
-.\".BR terminal-colors.d (5).
.SH EXIT STATUS
.TP
0
diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c
index 902f7d500..05d218611 100644
--- a/login-utils/lslogins.c
+++ b/login-utils/lslogins.c
@@ -315,50 +315,6 @@ static char *make_time(int mode, time_t time)
return xstrdup(buf);
}
-static void __attribute__((__noreturn__)) usage(FILE *out)
-{
- size_t i;
-
- fputs(USAGE_HEADER, out);
- fprintf(out, _(" %s [options]\n"), program_invocation_short_name);
-
- fputs(USAGE_OPTIONS, out);
- fputs(_(" -a, --acc-expiration Display data\n"), out);
- fputs(_(" -c, --colon-separate Display data in a format similar to /etc/passwd\n"), out);
- fputs(_(" -e, --export Display in an export-able output format\n"), out);
- fputs(_(" -f, --failed Display data about the last users' failed logins\n"), out);
- fputs(_(" --fulltimes Show dates in a long format\n"), out);
- fputs(_(" -g, --groups=<groups> Display users belonging to a group in GROUPS\n"), out);
- fputs(_(" -i, --iso Display dates in the ISO-8601 format\n"), out);
- fputs(_(" -l, --logins=<logins> Display only users from LOGINS\n"), out);
- fputs(_(" --last Show info about the users' last login sessions\n"), out);
- fputs(_(" -m, --supp-groups Display supplementary groups as well\n"), out);
- fputs(_(" -n, --newline Display each piece of information on a new line\n"), out);
- fputs(_(" --notruncate Don't truncate output\n"), out);
- fputs(_(" -o, --output[=<list>] Define the columns to output\n"), out);
- fputs(_(" -r, --raw Display the raw table\n"), out);
- fputs(_(" -s, --system-accs Display system accounts\n"), out);
- fputs(_(" -t, --sort Sort output by login instead of UID\n"), out);
- fputs(_(" --time-format=<type> Display dates in type <type>, where type is one of short|full|iso\n"), out);
- fputs(_(" -u, --user-accs Display user accounts\n"), out);
- fputs(_(" -x, --extra Display extra information\n"), out);
- fputs(_(" -z, --print0 Delimit user entries with a nul character\n"), out);
- fputs(_(" -Z, --context Display the users' security context\n"), out);
- fputs(_(" --wtmp-file Set an alternate path for wtmp\n"), out);
- fputs(_(" --btmp-file Set an alternate path for btmp\n"), out);
- fputs(USAGE_SEPARATOR, out);
- fputs(USAGE_HELP, out);
- fputs(USAGE_VERSION, out);
-
- fprintf(out, _("\nAvailable columns:\n"));
-
- for (i = 0; i < ARRAY_SIZE(coldescs); i++)
- fprintf(out, " %14s %s\n", coldescs[i].name, _(coldescs[i].help));
-
- fprintf(out, _("\nFor more details see lslogins(1).\n"));
-
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
-}
static char *uidtostr(uid_t uid)
{
@@ -1083,6 +1039,50 @@ static struct lslogins_timefmt timefmts[] = {
{ "iso", TIME_ISO },
};
+static void __attribute__((__noreturn__)) usage(FILE *out)
+{
+ size_t i;
+
+ fputs(USAGE_HEADER, out);
+ fprintf(out, _(" %s [options]\n"), program_invocation_short_name);
+
+ fputs(USAGE_OPTIONS, out);
+ fputs(_(" -a, --acc-expiration Display data\n"), out);
+ fputs(_(" -c, --colon-separate Display data in a format similar to /etc/passwd\n"), out);
+ fputs(_(" -e, --export Display in an export-able output format\n"), out);
+ fputs(_(" -f, --failed Display data about the last users' failed logins\n"), out);
+ fputs(_(" --fulltimes Show dates in a long format\n"), out);
+ fputs(_(" -g, --groups=<groups> Display users belonging to a group in <groups>\n"), out);
+ fputs(_(" -l, --logins=<logins> Display only users from <logins>\n"), out);
+ fputs(_(" --last Show info about the users' last login sessions\n"), out);
+ fputs(_(" -m, --supp-groups Display supplementary groups as well\n"), out);
+ fputs(_(" -n, --newline Display each piece of information on a new line\n"), out);
+ fputs(_(" --notruncate Don't truncate output\n"), out);
+ fputs(_(" -o, --output[=<list>] Define the columns to output\n"), out);
+ fputs(_(" -r, --raw Display the raw table\n"), out);
+ fputs(_(" -s, --system-accs Display system accounts\n"), out);
+ fputs(_(" -t, --sort-by-name Sort output by login instead of UID\n"), out);
+ fputs(_(" --time-format=<type> Display dates in type <type>, where type is one of short|full|iso\n"), out);
+ fputs(_(" -u, --user-accs Display user accounts\n"), out);
+ fputs(_(" -x, --extra Display extra information\n"), out);
+ fputs(_(" -z, --print0 Delimit user entries with a nul character\n"), out);
+ fputs(_(" -Z, --context Display the users' security context\n"), out);
+ fputs(_(" --wtmp-file <path> Set an alternate path for wtmp\n"), out);
+ fputs(_(" --btmp-file <path> Set an alternate path for btmp\n"), out);
+ fputs(USAGE_SEPARATOR, out);
+ fputs(USAGE_HELP, out);
+ fputs(USAGE_VERSION, out);
+
+ fprintf(out, _("\nAvailable columns:\n"));
+
+ for (i = 0; i < ARRAY_SIZE(coldescs); i++)
+ fprintf(out, " %14s %s\n", coldescs[i].name, _(coldescs[i].help));
+
+ fprintf(out, _("\nFor more details see lslogins(1).\n"));
+
+ exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+}
+
int main(int argc, char *argv[])
{
int c, want_wtmp = 0, want_btmp = 0;
@@ -1103,13 +1103,12 @@ int main(int argc, char *argv[])
static const struct option longopts[] = {
{ "acc-expiration", no_argument, 0, 'a' },
- { "colon", no_argument, 0, 'c' },
+ { "colon-separate", no_argument, 0, 'c' },
{ "export", no_argument, 0, 'e' },
{ "failed", no_argument, 0, 'f' },
{ "fulltimes", no_argument, 0, OPT_FULLT },
{ "groups", required_argument, 0, 'g' },
{ "help", no_argument, 0, 'h' },
- { "iso", no_argument, 0, 'i' },
{ "logins", required_argument, 0, 'l' },
{ "supp-groups", no_argument, 0, 'm' },
{ "newline", no_argument, 0, 'n' },
@@ -1150,7 +1149,7 @@ int main(int argc, char *argv[])
ctl->cmp_fn = cmp_uid;
ctl->time_mode = TIME_SHORT_RELATIVE;
- while ((c = getopt_long(argc, argv, "acefg:hil:mno:rstuxzZ",
+ while ((c = getopt_long(argc, argv, "acefg:hl:mno:rstuxzZ",
longopts, NULL)) != -1) {
err_exclusive_options(c, longopts, excl, excl_st);
@@ -1173,8 +1172,6 @@ int main(int argc, char *argv[])
break;
case 'h':
usage(stdout);
- case 'i':
- ctl->time_mode = TIME_ISO;
break;
case 'l':
logins = optarg;