+2024-05-19 Collin Funk <collin.funk1@gmail.com>
+
+ getusershell: Work around musl bugs.
+ Reported by Bruno Haible in
+ <https://lists.gnu.org/archive/html/bug-gnulib/2024-05/msg00261.html>.
+ * doc/glibc-functions/getusershell.texi: Mention the musl bug.
+ * lib/unistd.in.h (getusershell, setusershell, endusershell): Allow the
+ functions to be declared with the rpl_ prefix.
+ * m4/getusershell.m4 (gl_FUNC_GETUSERSHELL): Prepare functions to be
+ replaced on musl systems.
+ (gl_PREREQ_GETUSERSHELL): New macro.
+ * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize
+ REPLACE_GETUSERSHELL.
+ * modules/getusershell (Depends-on): Update module conditions to account
+ for the function being available but replaced by Gnulib.
+ (configure.ac): Likewise. Invoke gl_PREREQ_GETUSERSHELL.
+
2024-05-18 Bruno Haible <bruno@clisp.org>
abort-debug: Prefer libbacktrace to execinfo.
@item
This function is missing a declaration on some platforms:
Solaris 9.
+
+@item
+This function mistakenly returns comments and empty lines on some platforms:
+@c https://www.openwall.com/lists/musl/2024/05/18/1
+musl libc 1.2.4
@end itemize
Portability problems not fixed by Gnulib:
#if @GNULIB_GETUSERSHELL@
+# if @REPLACE_GETUSERSHELL@
/* Return the next valid login shell on the system, or NULL when the end of
the list has been reached. */
-# if !@HAVE_DECL_GETUSERSHELL@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef getusershell
+# define getusershell rpl_getusershell
+# endif
+_GL_FUNCDECL_RPL (getusershell, char *, (void));
+_GL_CXXALIAS_RPL (getusershell, char *, (void));
+# else
+# if !@HAVE_DECL_GETUSERSHELL@
_GL_FUNCDECL_SYS (getusershell, char *, (void));
-# endif
+# endif
_GL_CXXALIAS_SYS (getusershell, char *, (void));
+# endif
_GL_CXXALIASWARN (getusershell);
#elif defined GNULIB_POSIXCHECK
# undef getusershell
#if @GNULIB_GETUSERSHELL@
/* Rewind to pointer that is advanced at each getusershell() call. */
-# if !@HAVE_DECL_GETUSERSHELL@
+# if @REPLACE_GETUSERSHELL@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef setusershell
+# define setusershell rpl_setusershell
+# endif
+_GL_FUNCDECL_RPL (setusershell, void, (void));
+_GL_CXXALIAS_RPL (setusershell, void, (void));
+# else
+# if !@HAVE_DECL_GETUSERSHELL@
_GL_FUNCDECL_SYS (setusershell, void, (void));
-# endif
+# endif
_GL_CXXALIAS_SYS (setusershell, void, (void));
+# endif
_GL_CXXALIASWARN (setusershell);
#elif defined GNULIB_POSIXCHECK
# undef setusershell
#if @GNULIB_GETUSERSHELL@
/* Free the pointer that is advanced at each getusershell() call and
associated resources. */
-# if !@HAVE_DECL_GETUSERSHELL@
+# if @REPLACE_GETUSERSHELL@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef endusershell
+# define endusershell rpl_endusershell
+# endif
+_GL_FUNCDECL_RPL (endusershell, void, (void));
+_GL_CXXALIAS_RPL (endusershell, void, (void));
+# else
+# if !@HAVE_DECL_GETUSERSHELL@
_GL_FUNCDECL_SYS (endusershell, void, (void));
-# endif
+# endif
_GL_CXXALIAS_SYS (endusershell, void, (void));
+# endif
_GL_CXXALIASWARN (endusershell);
#elif defined GNULIB_POSIXCHECK
# undef endusershell
# getusershell.m4
-# serial 7
+# serial 8
dnl Copyright (C) 2002-2003, 2006, 2008-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
AC_DEFUN([gl_FUNC_GETUSERSHELL],
[
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+ AC_REQUIRE([AC_CANONICAL_HOST])
dnl Persuade glibc <unistd.h> to declare {get,set,end}usershell().
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
dnl Assume that on platforms which declare it, the function exists.
HAVE_DECL_GETUSERSHELL=0
fi
+ dnl Replace the function on musl unconditionally.
+ dnl See: https://www.openwall.com/lists/musl/2024/05/18/1
+ case "$host_os" in
+ *-musl* | midipix*) REPLACE_GETUSERSHELL=1 ;;
+ esac
])
+
+# Prerequisites of lib/getusershell.c.
+AC_DEFUN([gl_PREREQ_GETUSERSHELL], [:])
# unistd_h.m4
-# serial 95
+# serial 96
dnl Copyright (C) 2006-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE])
REPLACE_GETPASS=0; AC_SUBST([REPLACE_GETPASS])
REPLACE_GETPASS_FOR_GETPASS_GNU=0; AC_SUBST([REPLACE_GETPASS_FOR_GETPASS_GNU])
+ REPLACE_GETUSERSHELL=0; AC_SUBST([REPLACE_GETUSERSHELL])
REPLACE_ISATTY=0; AC_SUBST([REPLACE_ISATTY])
REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN])
REPLACE_LINK=0; AC_SUBST([REPLACE_LINK])
Depends-on:
unistd
extensions
-fopen-safer [test $HAVE_GETUSERSHELL = 0]
-unlocked-io-internal [test $HAVE_GETUSERSHELL = 0]
-xalloc [test $HAVE_GETUSERSHELL = 0]
+fopen-safer [test $HAVE_GETUSERSHELL = 0 || test $REPLACE_GETUSERSHELL = 1]
+unlocked-io-internal [test $HAVE_GETUSERSHELL = 0 || test $REPLACE_GETUSERSHELL = 1]
+xalloc [test $HAVE_GETUSERSHELL = 0 || test $REPLACE_GETUSERSHELL = 1]
configure.ac:
gl_FUNC_GETUSERSHELL
-gl_CONDITIONAL([GL_COND_OBJ_GETUSERSHELL], [test $HAVE_GETUSERSHELL = 0])
+gl_CONDITIONAL([GL_COND_OBJ_GETUSERSHELL],
+ [test $HAVE_GETUSERSHELL = 0 || test $REPLACE_GETUSERSHELL = 1])
+AM_COND_IF([GL_COND_OBJ_GETUSERSHELL], [
+ gl_PREREQ_GETUSERSHELL
+])
gl_UNISTD_MODULE_INDICATOR([getusershell])
Makefile.am:
-e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
-e 's|@''REPLACE_GETPASS''@|$(REPLACE_GETPASS)|g' \
-e 's|@''REPLACE_GETPASS_FOR_GETPASS_GNU''@|$(REPLACE_GETPASS_FOR_GETPASS_GNU)|g' \
+ -e 's|@''REPLACE_GETUSERSHELL''@|$(REPLACE_GETUSERSHELL)|g' \
-e 's|@''REPLACE_ISATTY''@|$(REPLACE_ISATTY)|g' \
-e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \
-e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \