You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

209 lines
8.2 KiB

diff -up util-linux-2.23.2/include/pathnames.h.kzak util-linux-2.23.2/include/pathnames.h
--- util-linux-2.23.2/include/pathnames.h.kzak 2016-03-16 17:17:02.980243390 +0100
+++ util-linux-2.23.2/include/pathnames.h 2016-03-16 17:17:37.129015363 +0100
@@ -36,6 +36,7 @@
#endif
#define _PATH_MOTDFILE "/etc/motd"
#define _PATH_NOLOGIN "/etc/nologin"
+#define _PATH_VAR_NOLOGIN "/var/run/nologin"
#define _PATH_LOGIN "/bin/login"
#define _PATH_INITTAB "/etc/inittab"
diff -up util-linux-2.23.2/login-utils/lslogins.1.kzak util-linux-2.23.2/login-utils/lslogins.1
--- util-linux-2.23.2/login-utils/lslogins.1.kzak 2016-03-16 17:17:02.970243457 +0100
+++ util-linux-2.23.2/login-utils/lslogins.1 2016-03-16 17:17:37.129015363 +0100
@@ -5,7 +5,10 @@
lslogins \- display information about known users in the system
.SH SYNOPSIS
.B lslogins
-[\fIoptions\fR] [\fB-s\fR|\fB-u\fR[=\fIUID\fR]] [\fB-g \fIgroups\fR] [\fB-l \fIlogins\fR]
+[options]
+.RB [ \-s | \-u [ =\fIUID ]]
+.RB [ \-g " \fIgroups\fR]"
+.RB [ \-l " \fIlogins\fR]"
.SH DESCRIPTION
.PP
Examine the wtmp and btmp logs, /etc/shadow (if necessary) and /etc/passwd
@@ -17,7 +20,7 @@ Mandatory arguments to long options are
.TP
\fB\-a\fR, \fB\-\-acc\-expiration\fR
Display data about the date of last password change and the account expiration
-date (see \fBshadow\fR(5) for more info). (Requires root priviliges.)
+date (see \fBshadow\fR(5) for more info). (Requires root privileges.)
.TP
\fB\-\-btmp\-file \fIpath\fP
Alternate path for btmp.
@@ -31,7 +34,7 @@ Output data in the format of NAME=VALUE.
\fB\-f\fR, \fB\-\-failed\fR
Display data about the users' last failed login attempts.
.TP
-\fB\-G\fR, \fB\-\-groups\-info\fR
+\fB\-G\fR, \fB\-\-supp\-groups\fR
Show information about groups.
.TP
\fB\-g\fR, \fB\-\-groups\fR=\fIgroups\fR
@@ -48,9 +51,6 @@ Display data containing information abou
Only show data of users with a login specified in \fIlogins\fR (user names or user
IDS). More than one login may be specified; the list has to be comma-separated.
.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
@@ -71,21 +71,21 @@ Display information related to login by
\fB\-r\fR, \fB\-\-raw\fR
Raw output (no columnation).
.TP
-\fB\-s\fR, \fB\-\-system\-accs\fR[=\fIthreshold\fR]
+\fB\-s\fR, \fB\-\-system\-accs\fR
Show system accounts. These are by default all accounts with a UID below 1000
-(non-inclusive), with the exception of either nobody or nfsnobody (UID 65534). The UID
-threshold can also be specified explicitly (necessary for some distributions that
-allocate UIDs starting from 100, 500 - or an entirely different value - rather than 1000).
+(non-inclusive), with the exception of either nobody or nfsnobody (UID 65534).
+This hardcoded default maybe overwritten by parameters SYS_UID_MIN and SYS_UID_MAX in
+the file /etc/login.defs.
.TP
-\fB\-\-time-format\fR \fItype\fP
+\fB\-\-time\-format\fR \fItype\fP
Display dates in short, full or iso format. The default is short, this time
format is designed to be space efficient and human readable.
.TP
-\fB\-u\fR, \fB\-\-user\-accs\fR[=\fIthreshold\fR]
+\fB\-u\fR, \fB\-\-user\-accs\fR
Show user accounts. These are by default all accounts with UID above 1000
-(inclusive), with the exception of either nobody or nfsnobody (UID 65534). The UID
-threshold can also be specified explicitly (necessary for some distributions that
-allocate UIDs starting from 100, 500 - or an entirely different value - rather than 1000).
+(inclusive), with the exception of either nobody or nfsnobody (UID 65534).
+This hardcoded default maybe overwritten by parameters UID_MIN and UID_MAX in
+the file /etc/login.defs.
.TP
\fB\-V\fR, \fB\-\-version\fR
Display version information and exit.
diff -up util-linux-2.23.2/login-utils/lslogins.c.kzak util-linux-2.23.2/login-utils/lslogins.c
--- util-linux-2.23.2/login-utils/lslogins.c.kzak 2016-03-16 17:17:02.970243457 +0100
+++ util-linux-2.23.2/login-utils/lslogins.c 2016-03-16 17:23:47.191484521 +0100
@@ -396,7 +396,7 @@ again:
x = snprintf(p, len, "%s,", grp->gr_name);
}
- if (x < 0 || (size_t) x + 1 > len) {
+ if (x < 0 || (size_t) x >= len) {
size_t cur = p - res;
maxlen *= 2;
@@ -496,21 +496,24 @@ static int parse_btmp(struct lslogins_co
static int get_sgroups(gid_t **list, size_t *len, struct passwd *pwd)
{
size_t n = 0;
+ int ngroups = 0;
*len = 0;
*list = NULL;
/* first let's get a supp. group count */
- getgrouplist(pwd->pw_name, pwd->pw_gid, *list, (int *) len);
- if (!*len)
+ getgrouplist(pwd->pw_name, pwd->pw_gid, *list, &ngroups);
+ if (!ngroups)
return -1;
- *list = xcalloc(1, *len * sizeof(gid_t));
+ *list = xcalloc(1, ngroups * sizeof(gid_t));
/* now for the actual list of GIDs */
- if (-1 == getgrouplist(pwd->pw_name, pwd->pw_gid, *list, (int *) len))
+ if (-1 == getgrouplist(pwd->pw_name, pwd->pw_gid, *list, &ngroups))
return -1;
+ *len = (size_t) ngroups;
+
/* getgroups also returns the user's primary GID - dispose of it */
while (n < *len) {
if ((*list)[n] == pwd->pw_gid)
@@ -852,7 +855,7 @@ static int get_user(struct lslogins_cont
const char *username)
{
*user = get_user_info(ctl, username);
- if (!*user && errno)
+ if (!*user)
if (IS_REAL_ERRNO(errno))
return -1;
return 0;
@@ -1193,16 +1196,18 @@ static void __attribute__((__noreturn__)
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s [options]\n"), program_invocation_short_name);
+ fputs(USAGE_SEPARATOR, out);
+ fputs(_("Display information about known users in the system.\n"), out);
+
fputs(USAGE_OPTIONS, out);
fputs(_(" -a, --acc-expiration display info about passwords expiration\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 users' last failed logins\n"), out);
- fputs(_(" -G, --groups-info display information about groups\n"), out);
+ fputs(_(" -G, --supp-groups display information about groups\n"), out);
fputs(_(" -g, --groups=<groups> display users belonging to a group in <groups>\n"), out);
fputs(_(" -L, --last show info about the users' last login sessions\n"), out);
fputs(_(" -l, --logins=<logins> display only users from <logins>\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(_(" --noheadings don't print headings\n"), out);
fputs(_(" --notruncate don't truncate output\n"), out);
@@ -1226,7 +1231,7 @@ static void __attribute__((__noreturn__)
fprintf(out, " %14s %s\n", coldescs[i].name,
_(coldescs[i].help));
- fprintf(out, _("\nFor more details see lslogins(1).\n"));
+ fprintf(out, USAGE_MAN_TAIL("lslogins(1)"));
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
}
@@ -1241,8 +1246,7 @@ int main(int argc, char *argv[])
/* long only options. */
enum {
- OPT_VER = CHAR_MAX + 1,
- OPT_WTMP,
+ OPT_WTMP = CHAR_MAX + 1,
OPT_BTMP,
OPT_NOTRUNC,
OPT_NOHEAD,
@@ -1300,7 +1304,7 @@ int main(int argc, char *argv[])
add_column(columns, ncolumns++, COL_UID);
add_column(columns, ncolumns++, COL_USER);
- while ((c = getopt_long(argc, argv, "acfGg:hLl:no:prsuVxzZ",
+ while ((c = getopt_long(argc, argv, "acefGg:hLl:no:prsuVzZ",
longopts, NULL)) != -1) {
err_exclusive_options(c, longopts, excl, excl_st);
@@ -1397,6 +1401,7 @@ int main(int argc, char *argv[])
{
size_t i;
+ ctl->time_mode = TIME_INVALID;
for (i = 0; i < ARRAY_SIZE(timefmts); i++) {
if (strcmp(timefmts[i].name, optarg) == 0) {
ctl->time_mode = timefmts[i].val;
@@ -1404,7 +1409,7 @@ int main(int argc, char *argv[])
}
}
if (ctl->time_mode == TIME_INVALID)
- usage(stderr);
+ errx(EXIT_FAILURE, _("unknown time format: %s"), optarg);
}
break;
case 'V':
@@ -1433,7 +1438,7 @@ int main(int argc, char *argv[])
logins = argv[optind];
outmode = OUT_PRETTY;
} else if (argc != optind)
- usage(stderr);
+ errx(EXIT_FAILURE, _("Only one user may be specified. Use -l for multiple users."));
scols_init_debug(0);