dcavalca / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone
5d0c07
diff -up util-linux-2.23.2/include/pathnames.h.kzak util-linux-2.23.2/include/pathnames.h
b394b9
--- util-linux-2.23.2/include/pathnames.h.kzak	2016-03-16 15:17:42.648298525 +0100
b394b9
+++ util-linux-2.23.2/include/pathnames.h	2016-03-16 15:18:13.769055345 +0100
5d0c07
@@ -36,6 +36,7 @@
5d0c07
 #endif
5d0c07
 #define	_PATH_MOTDFILE		"/etc/motd"
5d0c07
 #define	_PATH_NOLOGIN		"/etc/nologin"
5d0c07
+#define _PATH_VAR_NOLOGIN       "/var/run/nologin"
5d0c07
 
5d0c07
 #define _PATH_LOGIN		"/bin/login"
5d0c07
 #define _PATH_INITTAB		"/etc/inittab"
5d0c07
diff -up util-linux-2.23.2/login-utils/lslogins.1.kzak util-linux-2.23.2/login-utils/lslogins.1
b394b9
--- util-linux-2.23.2/login-utils/lslogins.1.kzak	2016-03-16 15:17:42.639298595 +0100
b394b9
+++ util-linux-2.23.2/login-utils/lslogins.1	2016-03-16 15:18:13.769055345 +0100
5d0c07
@@ -5,7 +5,10 @@
5d0c07
 lslogins \- display information about known users in the system
5d0c07
 .SH SYNOPSIS
5d0c07
 .B lslogins
5d0c07
-[\fIoptions\fR] [\fB-s\fR|\fB-u\fR[=\fIUID\fR]] [\fB-g \fIgroups\fR] [\fB-l \fIlogins\fR]
5d0c07
+[options]
5d0c07
+.RB [ \-s | \-u [ =\fIUID ]]
5d0c07
+.RB [ \-g " \fIgroups\fR]"
5d0c07
+.RB [ \-l " \fIlogins\fR]"
5d0c07
 .SH DESCRIPTION
5d0c07
 .PP
5d0c07
 Examine the wtmp and btmp logs, /etc/shadow (if necessary) and /etc/passwd
5d0c07
@@ -17,7 +20,7 @@ Mandatory arguments to long options are
5d0c07
 .TP
5d0c07
 \fB\-a\fR, \fB\-\-acc\-expiration\fR
5d0c07
 Display data about the date of last password change and the account expiration
5d0c07
-date (see \fBshadow\fR(5) for more info).  (Requires root priviliges.)
5d0c07
+date (see \fBshadow\fR(5) for more info).  (Requires root privileges.)
5d0c07
 .TP
5d0c07
 \fB\-\-btmp\-file \fIpath\fP
5d0c07
 Alternate path for btmp.
5d0c07
@@ -31,7 +34,7 @@ Output data in the format of NAME=VALUE.
5d0c07
 \fB\-f\fR, \fB\-\-failed\fR
5d0c07
 Display data about the users' last failed login attempts.
5d0c07
 .TP
5d0c07
-\fB\-G\fR, \fB\-\-groups\-info\fR
5d0c07
+\fB\-G\fR, \fB\-\-supp\-groups\fR
5d0c07
 Show information about groups.
5d0c07
 .TP
5d0c07
 \fB\-g\fR, \fB\-\-groups\fR=\fIgroups\fR
5d0c07
@@ -48,9 +51,6 @@ Display data containing information abou
5d0c07
 Only show data of users with a login specified in \fIlogins\fR (user names or user
5d0c07
 IDS).  More than one login may be specified; the list has to be comma-separated.
5d0c07
 .TP
5d0c07
-\fB\-m\fR, \fB\-\-supp\-groups\fR
5d0c07
-Show supplementary groups.
5d0c07
-.TP
5d0c07
 \fB\-n\fR, \fB\-\-newline\fR
5d0c07
 Display each piece of information on a separate line.
5d0c07
 .TP
5d0c07
@@ -71,21 +71,21 @@ Display information related to login by
5d0c07
 \fB\-r\fR, \fB\-\-raw\fR
5d0c07
 Raw output (no columnation).
5d0c07
 .TP
5d0c07
-\fB\-s\fR, \fB\-\-system\-accs\fR[=\fIthreshold\fR]
5d0c07
+\fB\-s\fR, \fB\-\-system\-accs\fR
5d0c07
 Show system accounts.  These are by default all accounts with a UID below 1000
5d0c07
-(non-inclusive), with the exception of either nobody or nfsnobody (UID 65534).  The UID
5d0c07
-threshold can also be specified explicitly (necessary for some distributions that
5d0c07
-allocate UIDs starting from 100, 500 - or an entirely different value - rather than 1000).
5d0c07
+(non-inclusive), with the exception of either nobody or nfsnobody (UID 65534).
5d0c07
+This hardcoded default maybe overwritten by parameters SYS_UID_MIN and SYS_UID_MAX in
5d0c07
+the file /etc/login.defs.
5d0c07
 .TP
5d0c07
-\fB\-\-time-format\fR \fItype\fP
5d0c07
+\fB\-\-time\-format\fR \fItype\fP
5d0c07
 Display dates in short, full or iso format.  The default is short, this time
5d0c07
 format is designed to be space efficient and human readable.
5d0c07
 .TP
5d0c07
-\fB\-u\fR, \fB\-\-user\-accs\fR[=\fIthreshold\fR]
5d0c07
+\fB\-u\fR, \fB\-\-user\-accs\fR
5d0c07
 Show user accounts.  These are by default all accounts with UID above 1000
5d0c07
-(inclusive), with the exception of either nobody or nfsnobody (UID 65534).  The UID
5d0c07
-threshold can also be specified explicitly (necessary for some distributions that
5d0c07
-allocate UIDs starting from 100, 500 - or an entirely different value - rather than 1000).
5d0c07
+(inclusive), with the exception of either nobody or nfsnobody (UID 65534).
5d0c07
+This hardcoded default maybe overwritten by parameters UID_MIN and UID_MAX in
5d0c07
+the file /etc/login.defs.
5d0c07
 .TP
5d0c07
 \fB\-V\fR, \fB\-\-version\fR
5d0c07
 Display version information and exit.
5d0c07
diff -up util-linux-2.23.2/login-utils/lslogins.c.kzak util-linux-2.23.2/login-utils/lslogins.c
b394b9
--- util-linux-2.23.2/login-utils/lslogins.c.kzak	2016-03-16 15:17:42.639298595 +0100
b394b9
+++ util-linux-2.23.2/login-utils/lslogins.c	2016-03-16 15:22:49.845899268 +0100
b394b9
@@ -144,6 +144,7 @@ enum {
b394b9
 	TIME_SHORT,
b394b9
 	TIME_FULL,
b394b9
 	TIME_ISO,
b394b9
+	TIME_ISO_SHORT,
b394b9
 };
b394b9
 
b394b9
 /*
b394b9
@@ -350,6 +351,9 @@ static char *make_time(int mode, time_t
b394b9
 	case TIME_ISO:
b394b9
 		strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S%z", &tm;;
b394b9
 		break;
b394b9
+	case TIME_ISO_SHORT:
b394b9
+		strftime(buf, sizeof(buf), "%Y-%m-%d", &tm;;
b394b9
+		break;
b394b9
 	default:
b394b9
 		errx(EXIT_FAILURE, _("unsupported time type"));
b394b9
 	}
b394b9
@@ -396,7 +400,7 @@ again:
5d0c07
 			x = snprintf(p, len, "%s,", grp->gr_name);
5d0c07
 		}
5d0c07
 
5d0c07
-		if (x < 0 || (size_t) x + 1 > len) {
5d0c07
+		if (x < 0 || (size_t) x >= len) {
5d0c07
 			size_t cur = p - res;
5d0c07
 
5d0c07
 			maxlen *= 2;
b394b9
@@ -496,21 +500,24 @@ static int parse_btmp(struct lslogins_co
5d0c07
 static int get_sgroups(gid_t **list, size_t *len, struct passwd *pwd)
5d0c07
 {
5d0c07
 	size_t n = 0;
5d0c07
+	int ngroups = 0;
5d0c07
 
5d0c07
 	*len = 0;
5d0c07
 	*list = NULL;
5d0c07
 
5d0c07
 	/* first let's get a supp. group count */
5d0c07
-	getgrouplist(pwd->pw_name, pwd->pw_gid, *list, (int *) len);
5d0c07
-	if (!*len)
5d0c07
+	getgrouplist(pwd->pw_name, pwd->pw_gid, *list, &ngroups);
5d0c07
+	if (!ngroups)
5d0c07
 		return -1;
5d0c07
 
5d0c07
-	*list = xcalloc(1, *len * sizeof(gid_t));
5d0c07
+	*list = xcalloc(1, ngroups * sizeof(gid_t));
5d0c07
 
5d0c07
 	/* now for the actual list of GIDs */
5d0c07
-	if (-1 == getgrouplist(pwd->pw_name, pwd->pw_gid, *list, (int *) len))
5d0c07
+	if (-1 == getgrouplist(pwd->pw_name, pwd->pw_gid, *list, &ngroups))
5d0c07
 		return -1;
5d0c07
 
5d0c07
+	*len = (size_t) ngroups;
5d0c07
+
5d0c07
 	/* getgroups also returns the user's primary GID - dispose of it */
5d0c07
 	while (n < *len) {
5d0c07
 		if ((*list)[n] == pwd->pw_gid)
b394b9
@@ -520,6 +527,7 @@ static int get_sgroups(gid_t **list, siz
b394b9
 
b394b9
 	if (*len)
b394b9
 		(*list)[n] = (*list)[--(*len)];
b394b9
+
b394b9
 	return 0;
b394b9
 }
b394b9
 
b394b9
@@ -685,8 +693,8 @@ static struct lslogins_user *get_user_in
b394b9
 			if (strstr(pwd->pw_shell, "nologin"))
b394b9
 				user->nologin = 1;
b394b9
 			else if (pwd->pw_uid)
b394b9
-				user->nologin = access("/etc/nologin", F_OK) == 0 ||
b394b9
-						access("/var/run/nologin", F_OK) == 0;
b394b9
+				user->nologin = access(_PATH_NOLOGIN, F_OK) == 0 ||
b394b9
+						access(_PATH_VAR_NOLOGIN, F_OK) == 0;
b394b9
 			break;
b394b9
 		case COL_PWD_WARN:
b394b9
 			if (shadow && shadow->sp_warn >= 0)
b394b9
@@ -694,7 +702,8 @@ static struct lslogins_user *get_user_in
b394b9
 			break;
b394b9
 		case COL_PWD_EXPIR:
b394b9
 			if (shadow && shadow->sp_expire >= 0)
b394b9
-				user->pwd_expire = make_time(TIME_SHORT,
b394b9
+				user->pwd_expire = make_time(ctl->time_mode == TIME_ISO ?
b394b9
+						TIME_ISO_SHORT : ctl->time_mode,
b394b9
 						shadow->sp_expire * 86400);
b394b9
 			break;
b394b9
 		case COL_PWD_CTIME:
b394b9
@@ -702,7 +711,8 @@ static struct lslogins_user *get_user_in
b394b9
 			 * (especially in non-GMT timezones) would only serve
b394b9
 			 * to confuse */
b394b9
 			if (shadow)
b394b9
-				user->pwd_ctime = make_time(TIME_SHORT,
b394b9
+				user->pwd_ctime = make_time(ctl->time_mode == TIME_ISO ?
b394b9
+						TIME_ISO_SHORT : ctl->time_mode,
b394b9
 						shadow->sp_lstchg * 86400);
b394b9
 			break;
b394b9
 		case COL_PWD_CTIME_MIN:
b394b9
@@ -852,7 +862,7 @@ static int get_user(struct lslogins_cont
5d0c07
 		    const char *username)
5d0c07
 {
5d0c07
 	*user = get_user_info(ctl, username);
5d0c07
-	if (!*user && errno)
5d0c07
+	if (!*user)
5d0c07
 		if (IS_REAL_ERRNO(errno))
5d0c07
 			return -1;
5d0c07
 	return 0;
b394b9
@@ -887,33 +897,33 @@ static int create_usertree(struct lslogi
b394b9
 
b394b9
 static struct libscols_table *setup_table(struct lslogins_control *ctl)
b394b9
 {
b394b9
-	struct libscols_table *tb = scols_new_table();
b394b9
+	struct libscols_table *table = scols_new_table();
b394b9
 	int n = 0;
b394b9
 
b394b9
-	if (!tb)
b394b9
+	if (!table)
b394b9
 		errx(EXIT_FAILURE, _("failed to initialize output table"));
b394b9
 	if (ctl->noheadings)
b394b9
-		scols_table_enable_noheadings(tb, 1);
b394b9
+		scols_table_enable_noheadings(table, 1);
b394b9
 
b394b9
 	switch(outmode) {
b394b9
 	case OUT_COLON:
b394b9
-		scols_table_enable_raw(tb, 1);
b394b9
-		scols_table_set_column_separator(tb, ":");
b394b9
+		scols_table_enable_raw(table, 1);
b394b9
+		scols_table_set_column_separator(table, ":");
b394b9
 		break;
b394b9
 	case OUT_NEWLINE:
b394b9
-		scols_table_set_column_separator(tb, "\n");
b394b9
+		scols_table_set_column_separator(table, "\n");
b394b9
 		/* fallthrough */
b394b9
 	case OUT_EXPORT:
b394b9
-		scols_table_enable_export(tb, 1);
b394b9
+		scols_table_enable_export(table, 1);
b394b9
 		break;
b394b9
 	case OUT_NUL:
b394b9
-		scols_table_set_line_separator(tb, "\0");
b394b9
+		scols_table_set_line_separator(table, "\0");
b394b9
 		/* fallthrough */
b394b9
 	case OUT_RAW:
b394b9
-		scols_table_enable_raw(tb, 1);
b394b9
+		scols_table_enable_raw(table, 1);
b394b9
 		break;
b394b9
 	case OUT_PRETTY:
b394b9
-		scols_table_enable_noheadings(tb, 1);
b394b9
+		scols_table_enable_noheadings(table, 1);
b394b9
 	default:
b394b9
 		break;
b394b9
 	}
b394b9
@@ -924,7 +934,7 @@ static struct libscols_table *setup_tabl
b394b9
 		if (ctl->notrunc)
b394b9
 			flags &= ~SCOLS_FL_TRUNC;
b394b9
 
b394b9
-		if (!scols_table_new_column(tb,
b394b9
+		if (!scols_table_new_column(table,
b394b9
 				coldescs[columns[n]].name,
b394b9
 				coldescs[columns[n]].whint,
b394b9
 				flags))
b394b9
@@ -932,9 +942,9 @@ static struct libscols_table *setup_tabl
b394b9
 		++n;
b394b9
 	}
b394b9
 
b394b9
-	return tb;
b394b9
+	return table;
b394b9
 fail:
b394b9
-	scols_unref_table(tb);
b394b9
+	scols_unref_table(table);
b394b9
 	return NULL;
b394b9
 }
b394b9
 
b394b9
@@ -1050,10 +1060,10 @@ static void fill_table(const void *u, co
b394b9
 	return;
b394b9
 }
b394b9
 #ifdef HAVE_LIBSYSTEMD
b394b9
-static void print_journal_tail(const char *journal_path, uid_t uid, size_t len)
b394b9
+static void print_journal_tail(const char *journal_path, uid_t uid, size_t len, int time_mode)
b394b9
 {
b394b9
 	sd_journal *j;
b394b9
-	char *match, *buf;
b394b9
+	char *match, *timestamp;
b394b9
 	uint64_t x;
b394b9
 	time_t t;
b394b9
 	const char *identifier, *pid, *message;
b394b9
@@ -1064,7 +1074,6 @@ static void print_journal_tail(const cha
b394b9
 	else
b394b9
 		sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY);
b394b9
 
b394b9
-	buf = xmalloc(sizeof(char) * 16);
b394b9
 	xasprintf(&match, "_UID=%d", uid);
b394b9
 
b394b9
 	sd_journal_add_match(j, match, 0);
b394b9
@@ -1074,37 +1083,35 @@ static void print_journal_tail(const cha
b394b9
 	do {
b394b9
 		if (0 > sd_journal_get_data(j, "SYSLOG_IDENTIFIER",
b394b9
 				(const void **) &identifier, &identifier_len))
b394b9
-			return;
b394b9
+			goto done;
b394b9
 		if (0 > sd_journal_get_data(j, "_PID",
b394b9
 				(const void **) &pid, &pid_len))
b394b9
-			return;
b394b9
+			goto done;
b394b9
 		if (0 > sd_journal_get_data(j, "MESSAGE",
b394b9
 				(const void **) &message, &message_len))
b394b9
-			return;
b394b9
+			goto done;
b394b9
 
b394b9
 		sd_journal_get_realtime_usec(j, &x);
b394b9
 		t = x / 1000000;
b394b9
-		strftime(buf, 16, "%b %d %H:%M:%S", localtime(&t);;
b394b9
-
b394b9
-		fprintf(stdout, "%s", buf);
b394b9
-
b394b9
+		timestamp = make_time(time_mode, t);
b394b9
+		/* Get rid of journal entry field identifiers */
b394b9
 		identifier = strchr(identifier, '=') + 1;
b394b9
-		pid = strchr(pid, '=') + 1		;
b394b9
+		pid = strchr(pid, '=') + 1;
b394b9
 		message = strchr(message, '=') + 1;
b394b9
 
b394b9
-		fprintf(stdout, " %s", identifier);
b394b9
-		fprintf(stdout, "[%s]:", pid);
b394b9
-		fprintf(stdout, "%s\n", message);
b394b9
+		fprintf(stdout, "%s %s[%s]: %s\n", timestamp, identifier, pid,
b394b9
+			message);
b394b9
+		free(timestamp);
b394b9
 	} while (sd_journal_next(j));
b394b9
 
b394b9
-	free(buf);
b394b9
+done:
b394b9
 	free(match);
b394b9
 	sd_journal_flush_matches(j);
b394b9
 	sd_journal_close(j);
b394b9
 }
b394b9
 #endif
b394b9
 
b394b9
-static int print_pretty(struct libscols_table *tb)
b394b9
+static int print_pretty(struct libscols_table *table)
b394b9
 {
b394b9
 	struct libscols_iter *itr = scols_new_iter(SCOLS_ITER_FORWARD);
b394b9
 	struct libscols_column *col;
b394b9
@@ -1113,8 +1120,8 @@ static int print_pretty(struct libscols_
b394b9
 	const char *hstr, *dstr;
b394b9
 	int n = 0;
b394b9
 
b394b9
-	ln = scols_table_get_line(tb, 0);
b394b9
-	while (!scols_table_next_column(tb, itr, &col)) {
b394b9
+	ln = scols_table_get_line(table, 0);
b394b9
+	while (!scols_table_next_column(table, itr, &col)) {
b394b9
 
b394b9
 		data = scols_line_get_cell(ln, n);
b394b9
 
b394b9
@@ -1142,7 +1149,7 @@ static int print_user_table(struct lslog
b394b9
 		print_pretty(tb);
b394b9
 #ifdef HAVE_LIBSYSTEMD
b394b9
 		fprintf(stdout, _("\nLast logs:\n"));
b394b9
-		print_journal_tail(ctl->journal_path, ctl->uid, 3);
b394b9
+		print_journal_tail(ctl->journal_path, ctl->uid, 3, ctl->time_mode);
b394b9
 		fputc('\n', stdout);
b394b9
 #endif
b394b9
 	} else
b394b9
@@ -1175,16 +1182,25 @@ static void free_user(void *f)
b394b9
 	free(u);
b394b9
 }
b394b9
 
b394b9
-struct lslogins_timefmt {
b394b9
-	const char *name;
b394b9
-	int val;
b394b9
-};
b394b9
+static int parse_time_mode(const char *optarg)
b394b9
+{
b394b9
+	struct lslogins_timefmt {
b394b9
+		const char *name;
b394b9
+		const int val;
b394b9
+	};
b394b9
+	static const struct lslogins_timefmt timefmts[] = {
b394b9
+		{"iso", TIME_ISO},
b394b9
+		{"full", TIME_FULL},
b394b9
+		{"short", TIME_SHORT},
b394b9
+	};
b394b9
+	size_t i;
b394b9
 
b394b9
-static struct lslogins_timefmt timefmts[] = {
b394b9
-	{ "short", TIME_SHORT },
b394b9
-	{ "full", TIME_FULL },
b394b9
-	{ "iso", TIME_ISO },
b394b9
-};
b394b9
+	for (i = 0; i < ARRAY_SIZE(timefmts); i++) {
b394b9
+		if (strcmp(timefmts[i].name, optarg) == 0)
b394b9
+			return timefmts[i].val;
b394b9
+	}
b394b9
+	errx(EXIT_FAILURE, _("unknown time format: %s"), optarg);
b394b9
+}
b394b9
 
b394b9
 static void __attribute__((__noreturn__)) usage(FILE *out)
b394b9
 {
b394b9
@@ -1193,16 +1209,18 @@ static void __attribute__((__noreturn__)
5d0c07
 	fputs(USAGE_HEADER, out);
5d0c07
 	fprintf(out, _(" %s [options]\n"), program_invocation_short_name);
5d0c07
 
5d0c07
+	fputs(USAGE_SEPARATOR, out);
5d0c07
+	fputs(_("Display information about known users in the system.\n"), out);
5d0c07
+
5d0c07
 	fputs(USAGE_OPTIONS, out);
5d0c07
 	fputs(_(" -a, --acc-expiration     display info about passwords expiration\n"), out);
5d0c07
 	fputs(_(" -c, --colon-separate     display data in a format similar to /etc/passwd\n"), out);
5d0c07
 	fputs(_(" -e, --export             display in an export-able output format\n"), out);
5d0c07
 	fputs(_(" -f, --failed             display data about the users' last failed logins\n"), out);
5d0c07
-	fputs(_(" -G, --groups-info        display information about groups\n"), out);
5d0c07
+	fputs(_(" -G, --supp-groups        display information about groups\n"), out);
5d0c07
 	fputs(_(" -g, --groups=<groups>    display users belonging to a group in <groups>\n"), out);
5d0c07
 	fputs(_(" -L, --last               show info about the users' last login sessions\n"), out);
5d0c07
 	fputs(_(" -l, --logins=<logins>    display only users from <logins>\n"), out);
5d0c07
-	fputs(_(" -m, --supp-groups        display supplementary groups as well\n"), out);
5d0c07
 	fputs(_(" -n, --newline            display each piece of information on a new line\n"), out);
5d0c07
 	fputs(_("     --noheadings         don't print headings\n"), out);
5d0c07
 	fputs(_("     --notruncate         don't truncate output\n"), out);
b394b9
@@ -1226,7 +1244,7 @@ static void __attribute__((__noreturn__)
5d0c07
 		fprintf(out, " %14s  %s\n", coldescs[i].name,
5d0c07
 				_(coldescs[i].help));
5d0c07
 
5d0c07
-	fprintf(out, _("\nFor more details see lslogins(1).\n"));
5d0c07
+	fprintf(out, USAGE_MAN_TAIL("lslogins(1)"));
5d0c07
 
5d0c07
 	exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
5d0c07
 }
b394b9
@@ -1241,8 +1259,7 @@ int main(int argc, char *argv[])
5d0c07
 
5d0c07
 	/* long only options. */
5d0c07
 	enum {
5d0c07
-		OPT_VER = CHAR_MAX + 1,
5d0c07
-		OPT_WTMP,
5d0c07
+		OPT_WTMP = CHAR_MAX + 1,
5d0c07
 		OPT_BTMP,
5d0c07
 		OPT_NOTRUNC,
5d0c07
 		OPT_NOHEAD,
b394b9
@@ -1300,7 +1317,7 @@ int main(int argc, char *argv[])
5d0c07
 	add_column(columns, ncolumns++, COL_UID);
5d0c07
 	add_column(columns, ncolumns++, COL_USER);
5d0c07
 
5d0c07
-	while ((c = getopt_long(argc, argv, "acfGg:hLl:no:prsuVxzZ",
5d0c07
+	while ((c = getopt_long(argc, argv, "acefGg:hLl:no:prsuVzZ",
5d0c07
 				longopts, NULL)) != -1) {
5d0c07
 
5d0c07
 		err_exclusive_options(c, longopts, excl, excl_st);
b394b9
@@ -1394,18 +1411,7 @@ int main(int argc, char *argv[])
b394b9
 			ctl->noheadings = 1;
b394b9
 			break;
b394b9
 		case OPT_TIME_FMT:
b394b9
-			{
b394b9
-				size_t i;
b394b9
-
b394b9
-				for (i = 0; i < ARRAY_SIZE(timefmts); i++) {
b394b9
-					if (strcmp(timefmts[i].name, optarg) == 0) {
b394b9
-						ctl->time_mode = timefmts[i].val;
b394b9
-						break;
b394b9
-					}
b394b9
-				}
b394b9
-				if (ctl->time_mode == TIME_INVALID)
5d0c07
-					usage(stderr);
b394b9
-			}
b394b9
+			ctl->time_mode = parse_time_mode(optarg);
5d0c07
 			break;
5d0c07
 		case 'V':
b394b9
 			printf(UTIL_LINUX_VERSION);
b394b9
@@ -1433,7 +1439,7 @@ int main(int argc, char *argv[])
5d0c07
 		logins = argv[optind];
5d0c07
 		outmode = OUT_PRETTY;
5d0c07
 	} else if (argc != optind)
5d0c07
-		usage(stderr);
5d0c07
+		errx(EXIT_FAILURE, _("Only one user may be specified. Use -l for multiple users."));
5d0c07
 
5d0c07
 	scols_init_debug(0);
5d0c07