|
|
f46785 |
From f435f80b9ae88caf9fe8af2e9b705dc8296ad6f3 Mon Sep 17 00:00:00 2001
|
|
|
f46785 |
From: Karel Zak <kzak@redhat.com>
|
|
|
f46785 |
Date: Mon, 13 Feb 2023 16:22:23 +0100
|
|
|
f46785 |
Subject: last: use full size of the username
|
|
|
f46785 |
|
|
|
f46785 |
utmp uses 32 bytes for username, last(1) truncates it to 31 when calls getpwnam().
|
|
|
f46785 |
|
|
|
f46785 |
Reported-by: Radka Skvarilova <rskvaril@redhat.com>
|
|
|
f46785 |
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
f46785 |
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2160321
|
|
|
f46785 |
Upstream: http://github.com/util-linux/util-linux/commit/4b646f01600a5efcf16e8e8991010b49b250bdfe
|
|
|
f46785 |
---
|
|
|
f46785 |
login-utils/last.1 | 4 ++++
|
|
|
f46785 |
login-utils/last.c | 6 ++++--
|
|
|
f46785 |
2 files changed, 8 insertions(+), 2 deletions(-)
|
|
|
f46785 |
|
|
|
f46785 |
diff --git a/login-utils/last.1 b/login-utils/last.1
|
|
|
f46785 |
index 94b4ed012..9169abd35 100644
|
|
|
f46785 |
--- a/login-utils/last.1
|
|
|
f46785 |
+++ b/login-utils/last.1
|
|
|
f46785 |
@@ -178,6 +178,10 @@ files to be used, they can be created with a simple
|
|
|
f46785 |
.BR touch (1)
|
|
|
f46785 |
command (for example,
|
|
|
f46785 |
.IR "touch /var/log/wtmp" ).
|
|
|
f46785 |
+
|
|
|
f46785 |
+The utmp file format uses fixed sizes of strings, which means that very long strings are
|
|
|
f46785 |
+impossible to store in the file and impossible to display by last. The usual limits are 32
|
|
|
f46785 |
+bytes for a user and line name and 256 bytes for a hostname.
|
|
|
f46785 |
.SH FILES
|
|
|
f46785 |
/var/log/wtmp
|
|
|
f46785 |
.br
|
|
|
f46785 |
diff --git a/login-utils/last.c b/login-utils/last.c
|
|
|
f46785 |
index 8f7c36984..41ce03894 100644
|
|
|
f46785 |
--- a/login-utils/last.c
|
|
|
f46785 |
+++ b/login-utils/last.c
|
|
|
f46785 |
@@ -602,12 +602,14 @@ static int is_phantom(const struct last_control *ctl, struct utmpx *ut)
|
|
|
f46785 |
{
|
|
|
f46785 |
struct passwd *pw;
|
|
|
f46785 |
char path[sizeof(ut->ut_line) + 16];
|
|
|
f46785 |
+ char user[sizeof(ut->ut_user) + 1];
|
|
|
f46785 |
int ret = 0;
|
|
|
f46785 |
|
|
|
f46785 |
if (ut->ut_tv.tv_sec < ctl->boot_time.tv_sec)
|
|
|
f46785 |
return 1;
|
|
|
f46785 |
- ut->ut_user[sizeof(ut->ut_user) - 1] = '\0';
|
|
|
f46785 |
- pw = getpwnam(ut->ut_user);
|
|
|
f46785 |
+
|
|
|
f46785 |
+ mem2strcpy(user, ut->ut_user, sizeof(ut->ut_user), sizeof(user));
|
|
|
f46785 |
+ pw = getpwnam(user);
|
|
|
f46785 |
if (!pw)
|
|
|
f46785 |
return 1;
|
|
|
f46785 |
snprintf(path, sizeof(path), "/proc/%u/loginuid", ut->ut_pid);
|
|
|
f46785 |
--
|
|
|
f46785 |
2.39.1
|
|
|
f46785 |
|