]> git.ipfire.org Git - thirdparty/coreutils.git/commit
cp: fix symlink checks when overwriting files
authorPádraig Brady <P@draigBrady.com>
Mon, 14 May 2018 09:26:05 +0000 (02:26 -0700)
committerPádraig Brady <P@draigBrady.com>
Tue, 15 May 2018 16:55:19 +0000 (09:55 -0700)
commitd3daa95096e2692e5c8a0402e270b0e2ec7918e5
tree9a1a47b7811a547b11937d12c2bbaffa63a7c6b5
parenta391007511cebe4a1731d85b4808499293c67173
cp: fix symlink checks when overwriting files

Ensure this _does_ recreate the symlink
  Given "path1" and "path2" are on different devices.
  $ touch "path1/file"
  $ cd path2/; ln -s path1/file
  $ cp -dsf path1/file .

Ensure this does _not_ overwrite file
  $ touch file
  $ ln -s file l1
  $ cp -sf l1 file

* src/copy.c (same_file_ok): Remove device ids from consideration,
instead deferring to future EXDEV with --link or allowing
the first case above to work.
Also ensure that we do not exist this function too early,
when the destination file is not a symlink, which protects
against the second case.
* tests/cp/cross-dev-symlink.sh: Add a test for the first case.
* tests/cp/same-file.sh: Add a test for the second case above.
* NEWS: Mention the bug fixes.
* THANKS.in: Mention the reporters who also analyzed the code.
Fixes https://bugs.gnu.org/31364
NEWS
THANKS.in
src/copy.c
tests/cp/cross-dev-symlink.sh [new file with mode: 0755]
tests/cp/same-file.sh
tests/local.mk