GNU bug report logs -
#65992
readutmp should check for sd_booted() and not if /run/utmp exists
Previous Next
To reply to this bug, email your comments to 65992 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-coreutils <at> gnu.org
:
bug#65992
; Package
coreutils
.
(Fri, 15 Sep 2023 10:02:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Thorsten Kukuk <kukuk <at> suse.com>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Fri, 15 Sep 2023 10:02:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi,
if there is no /run/utmp file, /usr/bin/who falls back correctly to the
systemd-logind interface and shows correct data.
But there are applications, which don't use the libc interface for
reading/writing utmp entries, they have their own implementation. And
this implementations create the file /run/utmp if this does not exist
(glibc does not). Which means, /usr/bin/who shows sometimes wrong/incomplete
data.
procps (especially w) and other packages don't check if /run/utmp exist
or not, but use sd_booted(). e.g.:
if (sd_booted() > 0) {
numuser = sd_get_sessions(NULL);
} else {
setutent();
while ((ut = getutent())) {
if ((ut->ut_type == USER_PROCESS) && (ut->ut_name[0] != '\0'))
numuser++;
}
endutent();
}
So if logind is running, logind is used, else /run/utmp.
I think gnulib/coreutils should do the same. It's impossible to find and
fix all the code writing utmp entries at their own, especially if this
is 3rd party software and you don't have the source code.
Thorsten
--
Thorsten Kukuk, Distinguished Engineer, Senior Architect, Future Technologies
SUSE Software Solutions Germany GmbH, Frankenstraße 146, 90461 Nuernberg, Germany
Managing Director: Ivo Totev, Andrew McDonald, Werner Knoblich
(HRB 36809, AG Nürnberg)
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#65992
; Package
coreutils
.
(Fri, 15 Sep 2023 12:32:02 GMT)
Full text and
rfc822 format available.
Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):
[CCing bug-gnulib, because the readutmp code lives in gnulib]
Thorsten Kukuk wrote:
> if there is no /run/utmp file, /usr/bin/who falls back correctly to the
> systemd-logind interface and shows correct data.
>
> But there are applications, which don't use the libc interface for
> reading/writing utmp entries, they have their own implementation. And
> this implementations create the file /run/utmp if this does not exist
> (glibc does not). Which means, /usr/bin/who shows sometimes wrong/incomplete
> data.
>
> procps (especially w) and other packages don't check if /run/utmp exist
> or not, but use sd_booted(). e.g.:
>
> if (sd_booted() > 0) {
> numuser = sd_get_sessions(NULL);
> } else {
> setutent();
> while ((ut = getutent())) {
> if ((ut->ut_type == USER_PROCESS) && (ut->ut_name[0] != '\0'))
> numuser++;
> }
> endutent();
> }
>
> So if logind is running, logind is used, else /run/utmp.
> I think gnulib/coreutils should do the same. It's impossible to find and
> fix all the code writing utmp entries at their own, especially if this
> is 3rd party software and you don't have the source code.
You are actually talking about three different things:
(A) Calling sd_booted in addition to calling sd_get_sessions.
(B) Using the /var/run/utmp file when systemd is not active.
(C) Using the /var/run/utmp file when systemd is active but some
applications use old APIs.
About (A)
=========
This is redundant, because when sd_booted() is <= 0, sd_get_sessions returns
NULL. This comes from the implementation, see
https://github.com/systemd/systemd/blob/main/src/libsystemd/sd-daemon/sd-daemon.c#L716
About (B)
=========
Is there any distro which has libsystemd installed (so that coreutils could
be built with -lsystemd) but where a different init system is used at boot time?
If not, the suggestion is pointless.
About (C)
=========
This is not the same as (B), because the existence of an "application" that uses
old APIs does not mean that sd_booted() will return <= 0.
> But there are applications, which don't use the libc interface for
> reading/writing utmp entries, they have their own implementation.
Which are these applications? The best approach is, obviously, to modernize
these applications by sending them patches. codesearch.debian.net is your
friend.
> It's impossible to find and
> fix all the code writing utmp entries at their own, especially if this
> is 3rd party software and you don't have the source code.
We should not let proprietary 3rd-party software prevent us from modernizing
the GNU system. This is the stance that the Linux kernel has taken more than
20 years ago, by defining a formal interface for kernel modules. If some
proprietary applications cause trouble, then the best approach is to ignore
it and thus increase the users' will to replace these proprietary applications
with free software.
A temporary proposal
====================
It is possible that, to get best results in the situation you describe, as
long as some applications use the old APIs, it is needed for readutmp to
combine (not choose among) the two approaches.
The best way to determine if this is true, IMO, would be to
1) turn the compile-time switch in lib/readutmp.c:942 into a run-time switch.
2) Add a '--traditional' option to 'who', 'pinky', 'uptime'.
3) Wait for users to report problems, that is, situations where `who` and
`who --traditional` disagree, with precise description of the problems.
Paul, Pádraig, what do you think?
Bruno
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#65992
; Package
coreutils
.
(Fri, 15 Sep 2023 13:03:01 GMT)
Full text and
rfc822 format available.
Message #11 received at submit <at> debbugs.gnu.org (full text, mbox):
Sorry, looks like strace confused me (since this checks the existence of
/run/utmp) and the problem is a different one.
kukuk <at> rubicon:~> ls /run/utmp
ls: cannot access '/run/utmp': No such file or directory
kukuk <at> rubicon:~> w
14:54:41 up 4 days, 4:51, 2 users, load average: 0,11, 0,13, 0,46
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
kukuk 172.17.0.109 14:54 22:57m 2:19m 0.04s sshd: kukuk [priv]
kukuk tty2 - Mo10 4days 46:26 0.07s /usr/libexec/sddm/sddm-helper --socket /tmp/sddm-auth-4209f4f2-82f8-4a75-862d-c31963792a08 --id 1 --start /usr/bin/startplasma-x11 --user kukuk
kukuk <at> rubicon:~> who
kukuk sshd pts/13 2023-09-15 14:54 (172.17.0.109)
kukuk seat0 2023-09-11 10:03 (:0)
kukuk tty2 2023-09-11 10:03 (:0)
Who creates an additional line for "seat0", which no other tools creates
and which it did not create before. Since some display manager writes
wrongly multiple utmp entries, one with the real tty, one with "seat0" as
device, and with seeing /run/utmp in the strace output, I wrongly assumed
we prefer /run/utmp over logind.
So, there are two problems:
1. I don't think who should show an additional "seat0" line other tools
and who in the past did not show. That's confusing.
2. There are reports that who/uptime seg.faults if gdm is used as display
manager. The reporter confirmed, that this does not happen with sddm,
login, sshd or so.
Since I don't use GNOME, I cannot reproduce. The seg.faults are new
reports.
Thorsten
--
Thorsten Kukuk, Distinguished Engineer, Senior Architect, Future Technologies
SUSE Software Solutions Germany GmbH, Frankenstraße 146, 90461 Nuernberg, Germany
Managing Director: Ivo Totev, Andrew McDonald, Werner Knoblich
(HRB 36809, AG Nürnberg)
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#65992
; Package
coreutils
.
(Fri, 15 Sep 2023 13:39:02 GMT)
Full text and
rfc822 format available.
Message #14 received at submit <at> debbugs.gnu.org (full text, mbox):
Thorsten Kukuk wrote:
> Who creates an additional line for "seat0", which no other tools creates
> and which it did not create before. Since some display manager writes
> wrongly multiple utmp entries
To me, that's a feature, not a bug. Systemd has introduced the concept of
seats [1], and the concept of tty is not so adequate any more for
identifying a session (because some terminal emulators / desktops put
a line into /var/run/utmp for each open terminal emulator window [2]).
It is thus natural and useful to show the association between user and seat.
Bruno
[1] https://www.freedesktop.org/wiki/Software/systemd/multiseat/
[2] https://www.thkukuk.de/blog/Y2038_glibc_utmp_64bit/
This bug report was last modified 1 year and 70 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.