GNU bug report logs - #76876
logname output is often wrong when linked with glibc

Previous Next

Package: coreutils;

Reported by: Nicolas Boos <nicolas.boos <at> wanadoo.fr>

Date: Sat, 8 Mar 2025 23:08:03 UTC

Severity: normal

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Nicolas Boos <nicolas.boos <at> wanadoo.fr>
To: 76876 <at> debbugs.gnu.org
Cc: bug-gnulib <at> gnu.org, eggert <at> cs.ucla.edu, bruno <at> clisp.org, dalias <at> libc.org
Subject: bug#76876: logname output is often wrong when linked with glibc
Date: Sun, 9 Mar 2025 14:43:29 +0100
This page says that the result of the logname command and the LOGNAME
variable must be the same:
https://www.ibm.com/docs/en/aix/7.3?topic=l-logname-command

Thus, getlogin() implementations that use the LOGNAME or login_name
variables such as musl, uclibc or even gnulib WIN32 seems fine.

What to believe?


Anyway, using a UID to get a login name like glibc's getlogin() function
does, we sometimes get incorrect results.

Here is a third test case, allowed by posix:
$ cat /etc/passwd
nicolas:x:1000:2001::/home/nicolas:/bin/bash
claude:x:1000:2002::/home/claude:/bin/zsh

localhost login: claude
Password:
$ echo $LOGNAME
claude
$ logname (glibc)
nicolas
$ logname (musl)
claude
$ logname (uclibc)
claude

I'm not really convinced that these fixes make things better.

NB


> I wrote:
> > With this, coreutils should be fine, since it already imports the 'getlogin'
> > module from gnulib.
> 
> Verified by comparing coreutils-9.5 with coreutils-HEAD on Alpine Linux 3.20:
> 
> With coreutils-9.5:
> 
> $ logname
> bruno
> $ su -
> Password:
> # logname
> root
> 
> Now:
> 
> $ logname
> bruno
> $ su -
> Password:
> # logname
> bruno
> 
> Paul, Pádraig: How about adding a coreutils/NEWS entry for this bug fix?
> 
> Bruno
> 
> 
> 
> 
> 
> 




This bug report was last modified 119 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.