From 644833218122784706be7653c1016fb99702ebbd Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Feb 18 2023 00:53:10 +0000 Subject: import util-linux-2.32.1-41.el8 --- diff --git a/SOURCES/0092-last-use-full-size-of-the-username.patch b/SOURCES/0092-last-use-full-size-of-the-username.patch new file mode 100644 index 0000000..a676580 --- /dev/null +++ b/SOURCES/0092-last-use-full-size-of-the-username.patch @@ -0,0 +1,55 @@ +From f435f80b9ae88caf9fe8af2e9b705dc8296ad6f3 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Mon, 13 Feb 2023 16:22:23 +0100 +Subject: last: use full size of the username + +utmp uses 32 bytes for username, last(1) truncates it to 31 when calls getpwnam(). + +Reported-by: Radka Skvarilova +Signed-off-by: Karel Zak +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2160321 +Upstream: http://github.com/util-linux/util-linux/commit/4b646f01600a5efcf16e8e8991010b49b250bdfe +--- + login-utils/last.1 | 4 ++++ + login-utils/last.c | 6 ++++-- + 2 files changed, 8 insertions(+), 2 deletions(-) + +diff --git a/login-utils/last.1 b/login-utils/last.1 +index 94b4ed012..9169abd35 100644 +--- a/login-utils/last.1 ++++ b/login-utils/last.1 +@@ -178,6 +178,10 @@ files to be used, they can be created with a simple + .BR touch (1) + command (for example, + .IR "touch /var/log/wtmp" ). ++ ++The utmp file format uses fixed sizes of strings, which means that very long strings are ++impossible to store in the file and impossible to display by last. The usual limits are 32 ++bytes for a user and line name and 256 bytes for a hostname. + .SH FILES + /var/log/wtmp + .br +diff --git a/login-utils/last.c b/login-utils/last.c +index 8f7c36984..41ce03894 100644 +--- a/login-utils/last.c ++++ b/login-utils/last.c +@@ -602,12 +602,14 @@ static int is_phantom(const struct last_control *ctl, struct utmpx *ut) + { + struct passwd *pw; + char path[sizeof(ut->ut_line) + 16]; ++ char user[sizeof(ut->ut_user) + 1]; + int ret = 0; + + if (ut->ut_tv.tv_sec < ctl->boot_time.tv_sec) + return 1; +- ut->ut_user[sizeof(ut->ut_user) - 1] = '\0'; +- pw = getpwnam(ut->ut_user); ++ ++ mem2strcpy(user, ut->ut_user, sizeof(ut->ut_user), sizeof(user)); ++ pw = getpwnam(user); + if (!pw) + return 1; + snprintf(path, sizeof(path), "/proc/%u/loginuid", ut->ut_pid); +-- +2.39.1 + diff --git a/SPECS/util-linux.spec b/SPECS/util-linux.spec index 5f8f97f..b3bccbd 100644 --- a/SPECS/util-linux.spec +++ b/SPECS/util-linux.spec @@ -2,7 +2,7 @@ Summary: A collection of basic system utilities Name: util-linux Version: 2.32.1 -Release: 40%{?dist} +Release: 41%{?dist} License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain Group: System Environment/Base URL: http://en.wikipedia.org/wiki/Util-linux @@ -276,6 +276,7 @@ Patch89: 0089-libmount-use-generic-error-message-for-EACCES-on-umo.patch Patch90: 0090-lslogins-man-explain-password-statuses.patch # 2160321 - [last] ut->ut_user is not null terminated Patch91: 0091-last-sync-utmp-strings-use-with-upstream-code.patch +Patch92: 0092-last-use-full-size-of-the-username.patch %description @@ -1125,6 +1126,9 @@ fi %{_libdir}/python*/site-packages/libmount/ %changelog +* Mon Feb 13 2023 Karel Zak 2.32.1-41 +- improve #2160321 - [last] ut->ut_user is not null terminated + * Mon Feb 06 2023 Karel Zak 2.32.1-40 - fix #2121699 - fstrim -av fails to trim root filesystem on Red Hat Coreos - fix #2142496 - update upstream tests