From c61e14d3a8412cd50d98aab604e607692c844c8a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 21:33:30 +0200 Subject: Adding upstream version 2.40. Signed-off-by: Daniel Baumann --- login-utils/chfn.1 | 6 +- login-utils/chsh.1 | 6 +- login-utils/chsh.c | 18 +--- login-utils/last.1 | 11 ++- login-utils/last.1.adoc | 3 + login-utils/last.c | 51 ++++++++---- login-utils/login.1 | 18 +++- login-utils/login.1.adoc | 10 ++- login-utils/login.c | 108 +++++++++++++++--------- login-utils/lslogins.1 | 6 +- login-utils/lslogins.c | 14 ++-- login-utils/newgrp.1 | 6 +- login-utils/newgrp.1.adoc | 6 +- login-utils/newgrp.c | 4 +- login-utils/nologin.8 | 6 +- login-utils/nologin.c | 4 +- login-utils/runuser.1 | 22 +++-- login-utils/runuser.1.adoc | 10 ++- login-utils/su-common.c | 19 +++-- login-utils/su.1 | 27 ++++-- login-utils/su.1.adoc | 23 ++++-- login-utils/sulogin-consoles.c | 4 + login-utils/sulogin-consoles.h | 4 + login-utils/sulogin.8 | 6 +- login-utils/sulogin.c | 184 +++++++++++++++++++++++++++++++++-------- login-utils/utmpdump.1 | 6 +- login-utils/utmpdump.c | 6 +- login-utils/vipw.8 | 6 +- login-utils/vipw.c | 4 +- 29 files changed, 417 insertions(+), 181 deletions(-) (limited to 'login-utils') diff --git a/login-utils/chfn.1 b/login-utils/chfn.1 index 0792231..71cc157 100644 --- a/login-utils/chfn.1 +++ b/login-utils/chfn.1 @@ -2,12 +2,12 @@ .\" Title: chfn .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.20 -.\" Date: 2023-11-21 +.\" Date: 2024-01-31 .\" Manual: User Commands -.\" Source: util-linux 2.39.3 +.\" Source: util-linux 2.40 .\" Language: English .\" -.TH "CHFN" "1" "2023-11-21" "util\-linux 2.39.3" "User Commands" +.TH "CHFN" "1" "2024-01-31" "util\-linux 2.40" "User Commands" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 diff --git a/login-utils/chsh.1 b/login-utils/chsh.1 index f4f6025..33cd793 100644 --- a/login-utils/chsh.1 +++ b/login-utils/chsh.1 @@ -2,12 +2,12 @@ .\" Title: chsh .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.20 -.\" Date: 2023-11-21 +.\" Date: 2024-01-31 .\" Manual: User Commands -.\" Source: util-linux 2.39.3 +.\" Source: util-linux 2.40 .\" Language: English .\" -.TH "CHSH" "1" "2023-11-21" "util\-linux 2.39.3" "User Commands" +.TH "CHSH" "1" "2024-01-31" "util\-linux 2.40" "User Commands" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 diff --git a/login-utils/chsh.c b/login-utils/chsh.c index 31750d5..19f0915 100644 --- a/login-utils/chsh.c +++ b/login-utils/chsh.c @@ -77,24 +77,12 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_(" -l, --list-shells print list of shells and exit\n"), fp); fputs(USAGE_SEPARATOR, fp); - printf(USAGE_HELP_OPTIONS(22)); + fprintf(fp, USAGE_HELP_OPTIONS(22)); - printf(USAGE_MAN_TAIL("chsh(1)")); + fprintf(fp, USAGE_MAN_TAIL("chsh(1)")); exit(EXIT_SUCCESS); } -/* - * print_shells () -- /etc/shells is outputted to stdout. - */ -static void print_shells(void) -{ - char *s; - - while ((s = getusershell())) - printf("%s\n", s); - endusershell(); -} - /* * parse_argv () -- * parse the command line arguments, and fill in "pinfo" with any @@ -120,7 +108,7 @@ static void parse_argv(int argc, char **argv, struct sinfo *pinfo) case 'h': usage(); case 'l': - print_shells(); + print_shells(stdout, "%s\n"); exit(EXIT_SUCCESS); case 's': pinfo->shell = optarg; diff --git a/login-utils/last.1 b/login-utils/last.1 index 0689f62..1f01d71 100644 --- a/login-utils/last.1 +++ b/login-utils/last.1 @@ -2,12 +2,12 @@ .\" Title: last .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.20 -.\" Date: 2023-12-01 +.\" Date: 2024-03-20 .\" Manual: User Commands -.\" Source: util-linux 2.39.3 +.\" Source: util-linux 2.40 .\" Language: English .\" -.TH "LAST" "1" "2023-12-01" "util\-linux 2.39.3" "User Commands" +.TH "LAST" "1" "2024-03-20" "util\-linux 2.40" "User Commands" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 @@ -95,6 +95,11 @@ Display the state of logins since the specified \fItime\fP. This is useful, e.g. Display the state of logins until the specified \fItime\fP. .RE .sp +\fB\-T\fP, \fB\-\-tab\-separated\fP +.RS 4 +Use ASCII \fBtab\fP characters to separate the columns in the output instead of spaces. +.RE +.sp \fB\-\-time\-format\fP \fIformat\fP .RS 4 Define the output timestamp \fIformat\fP to be one of \fInotime\fP, \fIshort\fP, \fIfull\fP, or \fIiso\fP. The \fInotime\fP variant will not print any timestamps at all, \fIshort\fP is the default, and \fIfull\fP is the same as the \fB\-\-fulltimes\fP option. The \fIiso\fP variant will display the timestamp in ISO\-8601 format. The ISO format contains timezone information, making it preferable when printouts are investigated outside of the system. diff --git a/login-utils/last.1.adoc b/login-utils/last.1.adoc index 1d26ae1..a3b8afe 100644 --- a/login-utils/last.1.adoc +++ b/login-utils/last.1.adoc @@ -75,6 +75,9 @@ Display the state of logins since the specified _time_. This is useful, e.g., to *-t*, *--until* _time_:: Display the state of logins until the specified _time_. +*-T*, *--tab-separated*:: +Use ASCII *tab* characters to separate the columns in the output instead of spaces. + *--time-format* _format_:: Define the output timestamp _format_ to be one of _notime_, _short_, _full_, or _iso_. The _notime_ variant will not print any timestamps at all, _short_ is the default, and _full_ is the same as the *--fulltimes* option. The _iso_ variant will display the timestamp in ISO-8601 format. The ISO format contains timezone information, making it preferable when printouts are investigated outside of the system. diff --git a/login-utils/last.c b/login-utils/last.c index 37c6abe..f5a9fec 100644 --- a/login-utils/last.c +++ b/login-utils/last.c @@ -95,6 +95,7 @@ struct last_control { time_t until; /* at what time to stop displaying the file */ time_t present; /* who where present at time_t */ unsigned int time_fmt; /* time format */ + char separator; /* output separator */ }; /* Double linked list of struct utmp's */ @@ -111,6 +112,7 @@ enum { R_NORMAL, /* Normal */ R_NOW, /* Still logged in */ R_REBOOT, /* Reboot record. */ + R_REBOOT_CRASH, /* Reboot record without matching shutdown */ R_PHANTOM, /* No logout record but session is stale. */ R_TIMECHANGE /* NEW_TIME or OLD_TIME */ }; @@ -349,7 +351,10 @@ static int time_formatter(int fmt, char *dst, size_t dlen, time_t *when) { char buf[CTIME_BUFSIZ]; - ctime_r(when, buf); + if (!ctime_r(when, buf)) { + ret = -1; + break; + } snprintf(dst, dlen, "%s", buf); ret = rtrim_whitespace((unsigned char *) dst); break; @@ -469,6 +474,7 @@ static int list(const struct last_control *ctl, struct utmpx *p, time_t logout_t switch(what) { case R_CRASH: + case R_REBOOT_CRASH: snprintf(logouttime, sizeof(logouttime), "- crash"); break; case R_DOWN: @@ -518,24 +524,24 @@ static int list(const struct last_control *ctl, struct utmpx *p, time_t logout_t if (ctl->showhost) { if (!ctl->altlist) { len = snprintf(final, sizeof(final), - "%-8.*s %-12.12s %-16.*s %-*.*s %-*.*s %s\n", - ctl->name_len, p->ut_user, utline, - ctl->domain_len, domain, - fmt->in_len, fmt->in_len, logintime, fmt->out_len, fmt->out_len, - logouttime, length); + "%-8.*s%c%-12.12s%c%-16.*s%c%-*.*s%c%-*.*s%c%s\n", + ctl->name_len, p->ut_user, ctl->separator, utline, ctl->separator, + ctl->domain_len, domain, ctl->separator, + fmt->in_len, fmt->in_len, logintime, ctl->separator, fmt->out_len, fmt->out_len, + logouttime, ctl->separator, length); } else { len = snprintf(final, sizeof(final), - "%-8.*s %-12.12s %-*.*s %-*.*s %-12.12s %s\n", - ctl->name_len, p->ut_user, utline, - fmt->in_len, fmt->in_len, logintime, fmt->out_len, fmt->out_len, - logouttime, length, domain); + "%-8.*s%c%-12.12s%c%-*.*s%c%-*.*s%c%-12.12s%c%s\n", + ctl->name_len, p->ut_user, ctl->separator, utline, ctl->separator, + fmt->in_len, fmt->in_len, logintime, ctl->separator, fmt->out_len, fmt->out_len, + logouttime, ctl->separator, length, ctl->separator, domain); } } else len = snprintf(final, sizeof(final), - "%-8.*s %-12.12s %-*.*s %-*.*s %s\n", - ctl->name_len, p->ut_user, utline, - fmt->in_len, fmt->in_len, logintime, fmt->out_len, fmt->out_len, - logouttime, length); + "%-8.*s%c%-12.12s%c%-*.*s%c%-*.*s%c%s\n", + ctl->name_len, p->ut_user, ctl->separator, utline, ctl->separator, + fmt->in_len, fmt->in_len, logintime, ctl->separator, fmt->out_len, fmt->out_len, + logouttime, ctl->separator, length); #if defined(__GLIBC__) # if (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0) @@ -582,6 +588,7 @@ static void __attribute__((__noreturn__)) usage(const struct last_control *ctl) fputs(_(" -R, --nohostname don't display the hostname field\n"), out); fputs(_(" -s, --since