Fix race with rename-file etc. with dir NEWNAME
commit01c885f21f343045783eb9ad1ff5f9b83d6cd789
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 10 Sep 2017 22:39:24 +0000 (10 15:39 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 10 Sep 2017 22:46:51 +0000 (10 15:46 -0700)
tree366e65100af42e6583e5bbaee70f4d5e853e4f92
parent52739ffe773eb403f58a6223b7ef64175df58dd7
Fix race with rename-file etc. with dir NEWNAME

This changes the behavior of rename-file etc. slightly.
The old behavior mostly disagreed with the documentation, and had
a race condition bug that could allow attackers to modify victims'
write-protected directories (Bug#27986).
* doc/lispref/files.texi (Changing Files): Document that in
rename-file etc., NEWFILE is special if it is a directory name.
* etc/NEWS: Document the change in behavior.
* src/fileio.c (directory_like): Remove.  All uses removed.
(expand_cp_target): Test only whether NEWNAME is a directory name,
not whether it is currently a directory.  This avoids a race.
(Fcopy_file, Frename_file, Fadd_name_to_file, Fmake_symbolic_link):
Document behavior if NEWNAME is a directory name.
(Frename_file): Simplify now that the destdir behavior occurs
only when NEWNAME is a directory name.
* test/lisp/net/tramp-tests.el (tramp-test11-copy-file)
(tramp-test12-rename-file, tramp--test-check-files):
Adjust tests to match new behavior.
doc/emacs/files.texi
doc/lispref/files.texi
etc/NEWS
src/fileio.c
test/lisp/net/tramp-tests.el