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
> 
> 
> 
> 
> 
> 



Reply via email to