On 17/04/2026 14:54, Bruno Haible wrote:
I wrote:
The same failure also occurs on Arch Linux 24.04.
Reproducible as
   $ unshare -U src/logname
   bruno
Both of these distros use glibc version 2.39.

Here are the results of "unshare -U logname" in various distros with
various glibc versions:

glibc   Distro       GUI/Console   unshare -U logname        unshare -U logname 
< /dev/null
                  (KDE/GNOME/Mate/LXQt/Pantheon)

2.24    ubuntu1704              K  bruno                     logname: no login 
name
2.26    Fedora27                G  logname: no login name
2.26    opensuse152             K  bruno                     logname: no login 
name
2.26    ubuntu1710              K  bruno                     logname: no login 
name
2.27    ElementaryOS50          P  logname: no login name
2.27    ubuntu1804              K  bruno                     logname: no login 
name
2.28    centos8-64              G  logname: no login name
2.30    arch1911                C  logname: no login name
2.31    opensuse155             K  logname: no login name
2.32    ubuntu2010              K  logname: no login name
2.33    slackware15             C  logname: no login name
2.33    guix14                  M  logname: no login name
2.34    alma9                   G  logname: no login name
2.34    centos9                 G  logname: no login name
2.34    ubuntu2110              K  logname: no login name
2.35    ubuntu2204              K  logname: no login name
2.35    popos2204               G  logname: no login name
2.36    Fedora37                G  logname: no login name
2.36    ubuntu2210              K  logname: no login name
2.36    debian12                G  logname: no login name
2.37    ubuntu2304              K  logname: no login name
2.38    ubuntu2310              K  logname: no login name
2.38    openeuler2403           C  bruno                     logname: no login 
name
2.39    arch2404                C  bruno                     logname: no login 
name
2.39    manjaro23               K  bruno                     logname: no login 
name
2.39    ubuntu2404              K  logname: no login name
2.39    openmandriva50          K  bruno                     logname: no login 
name
2.39    alma10                  G  logname: no login name
2.40    openmamba               L  logname: no login name
2.40    opensuse160             K  logname: no login name
2.41    Fedora42                K  bruno                     logname: no login 
name
2.41    ubuntu2504              G  logname: no login name
2.42    Fedora43                C  bruno                     logname: no login 
name

In summary:
1) The problem of "unshare -U logname" returning the previous user name
    existed in glibc < 2.28 and starts again in glibc 2.38.
2) 'strace' shows that glibc determines this previous user name by
    resolving the /proc/self/fd/0 link to a tty, then doing some lookup
    in the utmp / utmpx database.
3) Therefore "unshare -U logname </dev/null" provides a workaround.
4) The difference between distros (openeuler, arch, manjaro, openmandriva,
    Fedora on one side, Ubuntu, openSUSE, RHEL, openmamba on the other side)
    in glibc >= 2.38 is probably due to differences in the utmp / utmpx lookup.
    I cannot find glibc patches regarding getlogin in Fedora nor Ubuntu.

If so, perhaps our replacement is falling back to a method that works.

It could be related to this glibc bug from 2023:
https://sourceware.org/bugzilla/show_bug.cgi?id=30235
https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=0d83b349fa7340475406b2fe933c7467e4584091

Indeed:
The change between glibc 2.27 and 2.28
https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=cc8a1620eb97ccddd337d157263c13c57b39ab71
unintentionally broke the old behaviour, and
the change between glibc 2.37 and 2.38
https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=0d83b349fa7340475406b2fe933c7467e4584091
restored it.

I'll comment out the problematic part of the test for now.

The attached proposed patch restores the test in a way that succeeds.
Tested on Manjaro 23.


Excellent.

I'll apply that.

thanks,
Padraig

Reply via email to