The CI runs the Solaris 11 and Solaris 11 OmniOS tests as root, and shows these two test failures:
FAIL: test-access FAIL: test-euidaccess This occurs because although the file does not have the 'x' bit set, for root faccessat() returns 0. POSIX <https://pubs.opengroup.org/onlinepubs/9699919799/functions/access.html> says "New implementations are discouraged from returning X_OK unless at least one execution permission bit is set." — which means that Solaris counts as an "old" implementation here. So, nothing that requires a Gnulib workaround. 2024-05-21 Bruno Haible <br...@clisp.org> access, euidaccess tests: Avoid test failure for root user on Solaris. * tests/test-access.h (test_access): On Solaris, for the root user, don't expect X_OK permissions to be absent. * doc/posix-functions/access.texi: Mention the Solaris problem. * doc/glibc-functions/euidaccess.texi: Likewise. diff --git a/doc/glibc-functions/euidaccess.texi b/doc/glibc-functions/euidaccess.texi index 8caa79a740..f6217a1a5a 100644 --- a/doc/glibc-functions/euidaccess.texi +++ b/doc/glibc-functions/euidaccess.texi @@ -27,4 +27,7 @@ This function does not have an option for not following symbolic links (like @code{stat} versus @code{lstat}). If you need this option, use the Gnulib module @code{faccessat} with the @code{AT_EACCESS} flag. +@item +On Solaris, for the root user, any file is @code{X_OK} even if the file +does not have the @code{x} permission bit set. @end itemize diff --git a/doc/posix-functions/access.texi b/doc/posix-functions/access.texi index fd114d300f..0fb00275f3 100644 --- a/doc/posix-functions/access.texi +++ b/doc/posix-functions/access.texi @@ -36,6 +36,9 @@ (like @code{stat} versus @code{lstat}). If you need this option, use the Gnulib module @code{faccessat} with the @code{AT_EACCESS} flag. @item +On Solaris, for the root user, any file is @code{X_OK} even if the file +does not have the @code{x} permission bit set. +@item On native Windows, files whose basename does not contain a @samp{.} cannot be executed through @code{execlp} or @code{execvp}. Nevertheless, this function may return true for such files. diff --git a/tests/test-access.h b/tests/test-access.h index 42aee8b7e0..0f9a45fc65 100644 --- a/tests/test-access.h +++ b/tests/test-access.h @@ -88,9 +88,15 @@ test_access (int (*func) (const char * /*file*/, int /*mode*/)) /* X_OK works like R_OK. */ ASSERT (func (BASE "f2", X_OK) == 0); #else - errno = 0; - ASSERT (func (BASE "f2", X_OK) == -1); - ASSERT (errno == EACCES); + /* On Solaris, for the root user, X_OK is allowed. */ +# if defined __sun + if (geteuid () != ROOT_UID) +# endif + { + errno = 0; + ASSERT (func (BASE "f2", X_OK) == -1); + ASSERT (errno == EACCES); + } #endif }