On 2026-11-14 07:00, Pádraig Brady wrote:
I'm 70:30 for applying the attached gnulib patch to do this.
Thanks, I like the idea and suggest the attached patch, which does the same
thing but with nicer ifdeffery and with added commentary about musl.
From 1e4b6c87bff79ddb30680a0d694fc7c748c2b6c6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email protected]>
Date: Sat, 14 Nov 2026 14:48:58 +0000
Subject: [PATCH] fchmodat: require AT_SYMLINK_NOFOLLOW emulation on glibc
2.32-2.38
* m4/fchmodat.m4: Use our fallback which tries AT_SYMLINK_NOFOLLOW
on non-symlinks when /proc is not mounted, as the glibc /proc
emulation in these versions has no fallback.
---
ChangeLog | 7 +++++++
m4/fchmodat.m4 | 13 ++++++++++++-
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 13c42cc886..88c7ce950a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2026-11-14 Pádraig Brady <[email protected]>
+
+ fchmodat: require AT_SYMLINK_NOFOLLOW emulation on glibc 2.32-2.38
+ * m4/fchmodat.m4: Use our fallback which tries AT_SYMLINK_NOFOLLOW
+ on non-symlinks when /proc is not mounted, as the glibc /proc
+ emulation in these versions has no fallback.
+
2026-11-12 Collin Funk <[email protected]>
fts: Sync from glibc.
diff --git a/m4/fchmodat.m4 b/m4/fchmodat.m4
index e468870806..686bdcc6b1 100644
--- a/m4/fchmodat.m4
+++ b/m4/fchmodat.m4
@@ -1,5 +1,5 @@
# fchmodat.m4
-# serial 9
+# serial 10
dnl Copyright (C) 2004-2026 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -53,11 +53,22 @@ AC_DEFUN([gl_FUNC_FCHMODAT],
This test fails on AIX 7.2. */
if (fchmodat (AT_FDCWD, file "/", desired, 0) == 0)
result |= 2;
+ #if defined __linux__ && defined __GLIBC__ \
+ && __GLIBC__ == 2 && __GLIBC_MINOR__ < 39
+ /* On Linux, glibc 2.31 and earlier do not support this flag,
+ and although glibc 2.32 - 2.38 emulate it using /proc,
+ they lack gnulib's fallback when /proc is not available.
+ There is no equally simple way to work around similar bugs
+ in older musl platforms; people who use musl should use
+ musl 1.2.5+ (2024) and Linux 6.6+ (2023). */
+ result |= 4;
+ #else
/* Test whether fchmodat+AT_SYMLINK_NOFOLLOW works on non-symlinks.
This test fails on GNU/Linux with glibc 2.31 (but not on
GNU/kFreeBSD nor GNU/Hurd) and Cygwin 2.9. */
if (fchmodat (AT_FDCWD, file, desired, AT_SYMLINK_NOFOLLOW) != 0)
result |= 4;
+ #endif
if (stat (file, &st) != 0)
return 1;
if ((st.st_mode & permissive) != desired)
--
2.53.0