On 11/04/2022 14:55, Pádraig Brady wrote:
On 11/04/2022 02:44, Bruno Haible wrote:
Pádraig Brady wrote:
FAIL: tests/install/basic-1
===========================
FAIL: tests/mv/diag
===================
These two are the same issue I think ...
diff --git a/src/system.h b/src/system.h
index c24cb4dc3..d2c473a59 100644
--- a/src/system.h
+++ b/src/system.h
@@ -140,9 +140,12 @@ target_directory_operand (char const *file)
bool is_a_dir = false;
struct stat st;
- /* On old systems like Solaris 10, check with stat first
- lest we try to open a fifo for example and hang. */
- if (!O_DIRECTORY && stat (file, &st) == 0)
+ /* On old systems without O_DIRECTORY, like Solaris 10,
+ check with stat first lest we try to open a fifo for example and hang.
+ Also check on systems with O_PATHSEARCH == O_SEARCH, like Solaris 11,
+ where open was seen to return EPERM for non directories. */
+ if (!O_DIRECTORY || (O_PATHSEARCH == O_SEARCH)
+ && stat (file, &st) == 0)
Isn't there a parenthesizing mistake here? I would write
if ((!O_DIRECTORY || (O_PATHSEARCH == O_SEARCH))
&& stat (file, &st) == 0)
This patch does not apply cleanly to the snapshot source. I tried
a similar patch, but it did not help.
Yes sorry, I had the correct parentheses in the attached patch.
Thanks for confirming the equivalent didn't address this issue.
I'll need to dig into this more.
I was able to get access to a Solaris 11.3 system,
where I confirmed that open(O_SEARCH|O_DIRECTORY) returns EACCES
for non executable files. This does seem like a bug
in that O_DIRECTORY should take precedence,
especially considering O_SEARCH is documented in the Solaris open man page
to return ENOTDIR for non directories.
The attached addresses these two test failures in my testing.
thanks,
Pádraig
From 4fd8fffad246e9eefaa5329be2718b3d226b827e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <p...@draigbrady.com>
Date: Sun, 10 Apr 2022 16:59:40 +0100
Subject: [PATCH] cp,mv,install: avoid erroneous EACCES with target dirs on
Solaris 11
* src/system.h (target_directory_operand): Also check with stat()
on systems with O_SEARCH, to avoid open("file", O_SEARCH|O_DIRECTORY)
returning EACCES rather than ENOTDIR, which was seen on Solaris 11.3
when operating on files without execute bit set.
Reported by Bruno Haible.
---
src/system.h | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/system.h b/src/system.h
index c24cb4dc3..0308b92d7 100644
--- a/src/system.h
+++ b/src/system.h
@@ -137,19 +137,22 @@ target_directory_operand (char const *file)
return AT_FDCWD;
int fd = -1;
- bool is_a_dir = false;
+ int maybe_dir = -1;
struct stat st;
- /* On old systems like Solaris 10, check with stat first
- lest we try to open a fifo for example and hang. */
- if (!O_DIRECTORY && stat (file, &st) == 0)
+ /* On old systems without O_DIRECTORY, like Solaris 10,
+ check with stat first lest we try to open a fifo for example and hang.
+ Also check on systems with O_PATHSEARCH == O_SEARCH, like Solaris 11,
+ where open was seen to return EACCES for non directories. */
+ if ((!O_DIRECTORY || (O_PATHSEARCH == O_SEARCH))
+ && stat (file, &st) == 0)
{
- is_a_dir = !!S_ISDIR (st.st_mode);
- if (! is_a_dir)
+ maybe_dir = S_ISDIR (st.st_mode);
+ if (! maybe_dir)
errno = ENOTDIR;
}
- if (O_DIRECTORY || is_a_dir)
+ if (O_DIRECTORY && maybe_dir)
fd = open (file, O_PATHSEARCH | O_DIRECTORY);
if (!O_DIRECTORY && 0 <= fd)
--
2.26.2