Package: coreutils
Version: 9.7-3
Severity: normal
Tags: upstream
TLDR
$ who | wc -l
0
$ who /var/run/utmp | wc -l
0
$ who /var/run/./utmp | wc -l
10
$ alias who='who /run/utmp'
$ who /run/utmp | wc -l
10
/TLDR
In lib/readutmp.c (gnulib), read_utmp() invokes read_utmp_from_systemd()
instead of read_utmp_from_file() when the <file> parameter equals the
default utmp filename "/var/run/wtmp":
1 int
2 read_utmp (char const *file, idx_t *n_entries, STRUCT_UTMP **utmp_buf,
3 int options)
4 {
5 # if READUTMP_USE_SYSTEMD
6 if (strcmp (file, UTMP_FILE) == 0)
7 /* Imitate reading UTMP_FILE, using systemd and Linux APIs. */
8 return read_utmp_from_systemd (n_entries, utmp_buf, options);
9 # endif
In turn read_utmp_from_systemd() ignores all entries from the utmp file,
at least when no seat manager is running, and possibly also in other
scenarios.
The READUTMP_USE_SYSTEMD macro is defined during the configure phase
(m4/readutmp.m4), depending on the test program
#include <stdint.h>
#include <systemd/sd-login.h>
int main() {
uint64_t st;
sd_session_get_start_time ("1", &st);
}
which fails to compile in bookworm (because sd_session_get_start_time()
is not available in libsystemd 252.38), but unfortunately succeeds in
trixie (libsystemd 257.7).
However, line 6 above permits a workaround: use a different filename
from the predefined UTMP_FILE.
RANT
Upstream made a number of decisions that IMHO are not very brilliant:
- entangle core utilities with a library belonging to a specific
init/service-manager implementation
- change the behaviour of the (POSIX standard) "who" utility without making
the change opt-in, or at least providing an option/env-var to restore the
classic behaviour
- ignore user intent on "who <filename>" if filename happens to be the
usual one or empty (default)
- accept the fact that `"who" needs to ask seat manager', because
of course the best way to read a file is through an IPC to a daemon that
might not be running on the system.
/RANT
Best regards,
g.b. (a greybeard)
-- System Information:
Debian Release: 13.0
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 6.12.41+deb13-amd64 (SMP w/8 CPU threads; PREEMPT)
Locale: LANG=C, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: sysvinit (via /sbin/init)
LSM: AppArmor: enabled
Versions of packages coreutils depends on:
ii libacl1 2.3.2-2+b1
ii libattr1 1:2.5.2-3
ii libc6 2.41-12
ii libcap2 1:2.75-10+b1
ii libgmp10 2:6.3.0+dfsg-3
ii libselinux1 3.8.1-1
ii libssl3t64 3.5.1-1
ii libsystemd0 257.7-1
coreutils recommends no packages.
coreutils suggests no packages.
-- no debconf information