]> Savannah Git Hosting - gnulib.git/commitdiff
access, euidaccess tests: Avoid test failure for root user on Solaris.
authorBruno Haible <bruno@clisp.org>
Tue, 21 May 2024 13:32:06 +0000 (15:32 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 21 May 2024 13:42:30 +0000 (15:42 +0200)
* 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
doc/glibc-functions/euidaccess.texi
doc/posix-functions/access.texi
tests/test-access.h

index f1e50515596c722b1f7a923d5d86b02ef68d2acb..2a9b847dbd8444c0e568fc86e9777683c5d937a7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-05-21  Bruno Haible  <bruno@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.
+
 2024-05-21  Collin Funk  <collin.funk1@gmail.com>
 
        fnmatch tests: Avoid test failure on OmniOS.
index 8caa79a740345f78bafff9d8a2ee67cc5f23dd12..f6217a1a5af3f5b3d932ddcc953f41559cc5a2d8 100644 (file)
@@ -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
index fd114d300f239e97542db770af65e1cc77179faf..0fb00275f32940991aefeb650857c16387353298 100644 (file)
@@ -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.
index 42aee8b7e0ad964d9e461ebb18ce6978cb8fc96c..0f9a45fc65fa675eca4ce7f8fdffa1c156f49c1a 100644 (file)
@@ -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
   }