summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2007-11-16 09:31:15 +0100
committerJim Meyering <meyering@redhat.com>2007-11-22 00:19:06 +0100
commit2bdc48121916ab0d7bb7d0cb5cee25549c3705c9 (patch)
tree8a808a3c99c29aa7f5e958f7bac4f274f8eb753c /doc
parentfa636dcf6a298a4935ba950d433c33a07d0f8504 (diff)
downloadcoreutils-2bdc48121916ab0d7bb7d0cb5cee25549c3705c9.tar.xz
cp: by default, refuse to copy through a dangling destination symlink
* NEWS: Mention this change. * doc/coreutils.texi (cp invocation): Describe the new behavior. * src/copy.c: No longer include "canonicalize.h". (copy_reg): Upon failure to open a dangling destination symlink, don't canonicalize the name, but rather fail (default) or, with POSIXLY_CORRECT, repeat the open call without O_EXCL (potentially dangerous). * src/copy.h (struct cp_options) [open_dangling_dest_symlink]: New member. Reorder the others, grouping "bool" and "enum" members together. * tests/cp/thru-dangling: Test for changed and new behavior. * src/cp.c (cp_option_init): Initialize new member. * src/install.c (cp_option_init): Likewise. * src/mv.c (cp_option_init): Likewise. Signed-off-by: Jim Meyering <meyering@redhat.com>
Diffstat (limited to 'doc')
-rw-r--r--doc/coreutils.texi13
1 files changed, 9 insertions, 4 deletions
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 136a3f7fa..6ed1171de 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -6920,10 +6920,15 @@ recursively. This default can be overridden with the
@option{-H} options. If more than one of these options is specified,
the last one silently overrides the others.
-When copying to a symbolic link, @command{cp} normally follows the
-link when creating or copying to a regular file, even if the link is
-dangling. However, @command{cp} does not follow these links when
-creating directories or special files. Also, when an option like
+When copying to a symbolic link, @command{cp} follows the
+link only when it refers to an existing regular file.
+However, when copying to a dangling symbolic link, @command{cp}
+refuses by default, and fails with a diagnostic, since the operation
+is inherently dangerous. This behavior is contrary to historical
+practice and to @acronym{POSIX}.
+Set @env{POSIXLY_CORRECT} to make @command{cp} attempt to create
+the target of a dangling destination symlink, in spite of the possible risk.
+Also, when an option like
@option{--backup} or @option{--link} acts to rename or remove the
destination before copying, @command{cp} renames or removes the
symbolic link rather than the file it points to.