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: Bruno Haible <bruno <at> clisp.org>
To: 76876 <at> debbugs.gnu.org, nicolas.boos <at> wanadoo.fr
Cc: eggert <at> cs.ucla.edu, bug-gnulib <at> gnu.org, dalias <at> libc.org
Subject: bug#76876: logname output is often wrong when linked with glibc
Date: Mon, 10 Mar 2025 06:24:45 +0100
I wrote:
> Thus, on Linux systems, a correct implementation of getlogin() can not
> distinguish different users with the same uid (with reasonable effort).
> This applies to both glibc and the new code in gnulib.

Let me document this limitation.


2025-03-10  Bruno Haible  <bruno <at> clisp.org>

	getlogin, getlogin_r: Document limitation.
	Reported by Nicolas Boos <nicolas.boos <at> wanadoo.fr> in
	<https://lists.gnu.org/archive/html/bug-gnulib/2025-03/msg00033.html>.
	* doc/posix-functions/getlogin.texi: Mention the "different user names
	with same uid" limitation.
	* doc/posix-functions/getlogin_r.texi: Likewise.

diff --git a/doc/posix-functions/getlogin.texi b/doc/posix-functions/getlogin.texi
index 0ccce336ce..b0b8da73ae 100644
--- a/doc/posix-functions/getlogin.texi
+++ b/doc/posix-functions/getlogin.texi
@@ -16,7 +16,8 @@
 This function is not declared unless @code{_POSIX} is defined on some platforms:
 mingw.
 @item
-This function returns the value of the @env{LOGNAME} environment variable:
+This function returns the value of the @env{LOGNAME} environment variable
+and this therefore arbitrarily fakeable:
 musl libc 1.2.5.
 @end itemize
 
@@ -26,4 +27,9 @@
 This function returns an empty string even when standard input is a tty
 on some platforms:
 HP-UX 11.11.
+@item
+When there are several user names with the same user ID,
+this function may return, instead of the user name that logged in,
+another user name that has the same user ID, on some platforms:
+Linux and others.
 @end itemize
diff --git a/doc/posix-functions/getlogin_r.texi b/doc/posix-functions/getlogin_r.texi
index df145ecfe2..0e3b7968db 100644
--- a/doc/posix-functions/getlogin_r.texi
+++ b/doc/posix-functions/getlogin_r.texi
@@ -21,7 +21,8 @@
 @code{ERANGE}, when the buffer is not large enough, on some platforms:
 macOS 14.
 @item
-This function returns the value of the @env{LOGNAME} environment variable:
+This function returns the value of the @env{LOGNAME} environment variable
+and this therefore arbitrarily fakeable:
 musl libc 1.2.5.
 @end itemize
 
@@ -42,4 +43,9 @@
 some platforms:
 @c https://dev.haiku-os.org/ticket/18349
 Haiku.
+@item
+When there are several user names with the same user ID,
+this function may return, instead of the user name that logged in,
+another user name that has the same user ID, on some platforms:
+Linux and others.
 @end itemize







This bug report was last modified 117 days ago.

Previous Next


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