On 2025-03-08 08:46, Nicolas Boos via GNU coreutils Bug Reports wrote:
It seems getlogin() is malfunctioning only with glibc.

It's the other way round: glibc is right (in the sense that it conforms to POSIX) and the other two are wrong.

Adding a permanent fix to gnulib/getlogin.c code might be a better solution.

Any such fix should work around the musl bug. (Gnulib doesn't worry about uclibc.)

I expect such a patch would be welcome if someone had the time to write and test it. In the meantime I installed the attached to Gnulib, to document the incompatibility, which also occurs with getlogin_r.
From 2a60c939bec320abe18737360bb9841595f5d8d1 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sat, 8 Mar 2025 15:36:33 -0800
Subject: [PATCH] getlogin: document musl bug

Problem reported by Nicolas Boos <https://bugs.gnu.org/76876>.
---
 ChangeLog                           | 5 +++++
 doc/posix-functions/getlogin.texi   | 3 +++
 doc/posix-functions/getlogin_r.texi | 3 +++
 3 files changed, 11 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 33a13bf438..89940ddd4c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2025-03-08  Paul Eggert  <egg...@cs.ucla.edu>
+
+	getlogin: document musl bug
+	Problem reported by Nicolas Boos <https://bugs.gnu.org/76876>.
+
 2025-03-07  Bruno Haible  <br...@clisp.org>
 
 	gocomp-script: Avoid error on native Windows.
diff --git a/doc/posix-functions/getlogin.texi b/doc/posix-functions/getlogin.texi
index ddb0b9aae1..0de026f2ee 100644
--- a/doc/posix-functions/getlogin.texi
+++ b/doc/posix-functions/getlogin.texi
@@ -20,6 +20,9 @@ mingw.
 Portability problems not fixed by Gnulib:
 @itemize
 @item
+This function returns the value of the @env{LOGNAME} environment variable:
+musl libc 1.2.5.
+@item
 This function returns an empty string even when standard input is a tty
 on some platforms:
 HP-UX 11.11.
diff --git a/doc/posix-functions/getlogin_r.texi b/doc/posix-functions/getlogin_r.texi
index f92d6c24b1..daafd9eaa0 100644
--- a/doc/posix-functions/getlogin_r.texi
+++ b/doc/posix-functions/getlogin_r.texi
@@ -28,6 +28,9 @@ Portability problems not fixed by Gnulib:
 This function has an incompatible declaration on some platforms:
 FreeBSD 12.0, MidnightBSD 2.0, Solaris 11.4 (when @code{_POSIX_PTHREAD_SEMANTICS} is not defined).
 @item
+This function returns the value of the @env{LOGNAME} environment variable:
+musl libc 1.2.5.
+@item
 This function fails even when standard input is a tty on some platforms:
 HP-UX 11.11.
 @item
-- 
2.45.2

Reply via email to