diff options
author | Pádraig Brady <P@draigBrady.com> | 2022-04-09 15:46:52 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2022-04-09 22:21:24 +0100 |
commit | cc01b8a8f43bd1e02339322595f7a20e72a8c155 (patch) | |
tree | ef417e854cc0bbc4002012ee01cefec13952e048 /tests/cp | |
parent | 54bec51754c963562378c85b0e1561b84c326785 (diff) | |
download | coreutils-cc01b8a8f43bd1e02339322595f7a20e72a8c155.tar.gz |
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.
Diffstat (limited to 'tests/cp')
-rwxr-xr-x | tests/cp/special-f.sh | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/tests/cp/special-f.sh b/tests/cp/special-f.sh index a3e7842fa..2c7bf5ea7 100755 --- a/tests/cp/special-f.sh +++ b/tests/cp/special-f.sh @@ -24,12 +24,10 @@ mkfifo_or_skip_ fifo touch e || framework-failure - -# Without -f, expect it to fail. -cp -R fifo e || fail=1 - -# With -f, it must succeed. -cp -Rf fifo e || fail=1 -test -p fifo || fail=1 +for force in '' '-f'; do + # Second time through will need to unlink fifo e + timeout 10 cp -R $force fifo e || fail=1 + test -p fifo || fail=1 +done Exit $fail |