On 10/04/2022 15:37, Bruno Haible wrote:
On Solaris 11.4 (x86_64, in 64-bit mode), there are 4 test failures:FAIL: tests/misc/stty-row-col =============================
Any of the commands like `stty rows 40 columns 80` are being silently ignored. FWIW on the Solaris 10 system I've access to, this test passes. I'd need access to investigate.
FAIL: tests/install/basic-1 =========================== FAIL: tests/mv/diag ===================
These two are the same issue I think ...
+ compare_ exp out + diff -u exp out --- exp 2022-04-10 18:00:35.334713869 +0200 +++ out 2022-04-10 18:00:35.321291561 +0200 @@ -2,5 +2,5 @@ Try 'mv --help' for more information. mv: missing destination file operand after 'no-file' Try 'mv --help' for more information. -mv: target 'f1': Not a directory -mv: target directory 'f2': Not a directory +mv: target 'f1': Permission denied +mv: target directory 'f2': Permission denied + fail=1
... I think this is due to the change in: https://git.sv.gnu.org/cgit/coreutils.git/commit/?id=v9.0-90-g57c812cc3 I've only access to Solaris 10 at present, but it seems on Solaris 11 open("file", O_SEARCH | O_DIRECTORY) is returning EPERM instead of ENOTDIR? Though I notice the 11.1 open() docs don't even mention EPERM: https://docs.oracle.com/cd/E26502_01/html/E29032/open-2.html Paul do you have access to Solaris 11? Given this is such a confusing error we should fix if possible. If open() is returning EPERM here, we should probably do a check with stat() first on such systems? I.e. something like the following on master. (Bruno I've attached the equivalent patch against the version you're testing, which you could test directly with): make TESTS=tests/mv/diag.sh VERBOSE=yes SUBDIRS=. check 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) { is_a_dir = !!S_ISDIR (st.st_mode); if (! is_a_dir)
FAIL: tests/tail-2/pipe-f =========================
The following might help here: diff --git a/src/tail.c b/src/tail.c index f1b741783..a28fa61da 100644 --- a/src/tail.c +++ b/src/tail.c @@ -356,7 +356,7 @@ check_output_alive (void) event immediately) or if using inotify (which relies on 'poll' anyway). Otherwise, use 'select' as it's more portable; 'poll' doesn't work for this application on macOS. */ -#if defined _AIX || HAVE_INOTIFY +#if defined _AIX || defined __sun || HAVE_INOTIFY struct pollfd pfd; pfd.fd = STDOUT_FILENO; pfd.events = POLLERR; thanks! Pádraig
From 64dd7f37239864893257635e2ee5923aa8385520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= <p...@draigbrady.com> Date: Sat, 9 Apr 2022 15:46:52 +0100 Subject: [PATCH] cp,mv,install: avoid opening non directory destination commit v9.0-66-ge2daa8f79 introduced an issue, for example where cp could hang when overwriting a destination fifo, when it would try to open() the fifo on systems like Solaris 10 that didn't support the O_DIRECTORY flag. This is still racy on such systems, but only in the case where a directory is replaced by a fifo in the small window between stat() and open(). * src/system.h (target_directory_operand): On systems without O_DIRECTORY, ensure the file is a directory before attempting to open(). * tests/cp/special-f.sh: Protect cp with timeout(1), as cp was seen to hang when trying to overwrite an existing fifo. * NEWS: Mention the bug fix. cp,mv,install: avoid erroneous EPERM 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 EPERM rather than ENOTDIR, which was seen on Solaris 11. Reported by Bruno Haible. --- src/system.h | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/system.h b/src/system.h index 09498a172..04c7e9faa 100644 --- a/src/system.h +++ b/src/system.h @@ -136,13 +136,29 @@ target_directory_operand (char const *file) if (must_be_working_directory (file)) return AT_FDCWD; - int fd = open (file, O_PATHSEARCH | O_DIRECTORY); + int fd = -1; + bool is_a_dir = false; + struct stat st; + + /* 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) + { + is_a_dir = !!S_ISDIR (st.st_mode); + if (! is_a_dir) + errno = ENOTDIR; + } + + if (O_DIRECTORY || is_a_dir) + fd = open (file, O_PATHSEARCH | O_DIRECTORY); if (!O_DIRECTORY && 0 <= fd) { - /* On old systems like Solaris 10 that do not support O_DIRECTORY, - check by hand whether FILE is a directory. */ - struct stat st; + /* On old systems like Solaris 10 double check type, + to ensure we've opened a directory. */ int err; if (fstat (fd, &st) != 0 ? (err = errno, true) : !S_ISDIR (st.st_mode) && (err = ENOTDIR, true)) -- 2.26.2