From 90576182493cf2677769e77eb6ad0a22f8357619 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 21 May 2024 15:32:06 +0200 Subject: [PATCH] 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. --- ChangeLog | 8 ++++++++ doc/glibc-functions/euidaccess.texi | 3 +++ doc/posix-functions/access.texi | 3 +++ tests/test-access.h | 12 +++++++++--- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index f1e5051559..2a9b847dbd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2024-05-21 Bruno Haible + + 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. + 2024-05-21 Collin Funk fnmatch tests: Avoid test failure on OmniOS. 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, especially in a set-uid or set-gid program. 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 @@ 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. +@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 } -- 2.39.5