coreutils/tests/cp
Paul Eggert cdec7e6e93 Correct cp's handling of destination symlinks in some cases.
* NEWS: "cp" no longer considers a destination symlink to be the
same as the referenced file when copying links or making backups.
* src/copy.c (copy_reg): When following a symlink, use the
followed name in later chown etc. requests, so that the created
file is affected, rather than the symlink.  Use O_NOFOLLOW on
source when not dereferencing symlinks; this avoids a race.
Preserve errno correctly when doing multiple open attempts on the
destination.
(copy_internal): Follow destination symlinks only when copying a
regular file and only when we don't intend to remove or rename the
destination first, regardless of whether following source
symlinks; this is because since POSIX and tradition (e.g.,
FreeBSD) say we should ordinarily follow destination symlinks if
the system calls would ordinarily do so.
* src/copy.h (struct cp_options): Add comment that 'dereference'
is only for source files.
* src/cp.c (usage): Note that --derereference etc. are only for
source files.
(make_dir_parents_private): Follow symlinks, regardless of whether
--dereference is specified, because these are destination symlinks.
* tests/cp/same-file: Adjust tests to match revised behavior.
Filter out perror output since it might vary from host to host.
Use sed alone instead of also using echo.

* doc/coreutils.texi (cp invocation): Document the behavior better when
the destination is a symlink.  Clarify source versus destination
symlinks.  Describe the new behavior for destination symlinks.

2007-06-15  Jim Meyering  <jim@meyering.net>

* src/copy.c: Include "canonicalize.h".
(copy_reg): Use canonicalize_filename_mode to follow the symlink,
so that we can always open with O_EXCL and avoid a race.
2007-06-15 22:47:16 +02:00
..
.cvsignore * aclocal.m4, config.hin, configure: 2006-08-22 18:50:24 +00:00
acl * tests/sample-test: Quote variables containing absolute build 2006-10-22 19:37:31 +02:00
backup-1 * tests/sample-test: Quote variables containing absolute build 2006-10-22 19:37:31 +02:00
backup-dir * tests/sample-test: Quote variables containing absolute build 2006-10-22 19:37:31 +02:00
backup-is-src * tests/sample-test: Quote variables containing absolute build 2006-10-22 19:37:31 +02:00
cp-a-selinux Arrange for "make check-root" to run the new root-only test. 2007-03-29 21:37:06 +02:00
cp-deref * tests/sample-test: Quote variables containing absolute build 2006-10-22 19:37:31 +02:00
cp-HL * tests/sample-test: Quote variables containing absolute build 2006-10-22 19:37:31 +02:00
cp-i * tests/sample-test: Quote variables containing absolute build 2006-10-22 19:37:31 +02:00
cp-mv-backup * tests/sample-test: Quote variables containing absolute build 2006-10-22 19:37:31 +02:00
cp-parents ls: Add support for SELinux and a slightly modified -Z option. 2007-03-29 21:37:05 +02:00
deref-slink * tests/sample-test: Quote variables containing absolute build 2006-10-22 19:37:31 +02:00
dir-rm-dest * tests/sample-test: Quote variables containing absolute build 2006-10-22 19:37:31 +02:00
dir-slash * tests/sample-test: Quote variables containing absolute build 2006-10-22 19:37:31 +02:00
dir-vs-file * tests/sample-test: Quote variables containing absolute build 2006-10-22 19:37:31 +02:00
fail-perm ls: Add support for SELinux and a slightly modified -Z option. 2007-03-29 21:37:05 +02:00
file-perm-race Make sure cp -p isn't too generous with file permissions. 2006-12-15 09:50:40 +01:00
into-self * tests/sample-test: Quote variables containing absolute build 2006-10-22 19:37:31 +02:00
link * tests/sample-test: Quote variables containing absolute build 2006-10-22 19:37:31 +02:00
link-no-deref * tests/sample-test: Quote variables containing absolute build 2006-10-22 19:37:31 +02:00
link-preserve ls: Add support for SELinux and a slightly modified -Z option. 2007-03-29 21:37:05 +02:00
Makefile.am bug-fix: cp would fail to write through a dangling symlink 2007-06-10 15:01:18 +02:00
no-deref-link1 * tests/sample-test: Quote variables containing absolute build 2006-10-22 19:37:31 +02:00
no-deref-link2 * tests/sample-test: Quote variables containing absolute build 2006-10-22 19:37:31 +02:00
no-deref-link3 * tests/sample-test: Quote variables containing absolute build 2006-10-22 19:37:31 +02:00
parent-perm-race * NEWS: Document fix for cp --preserve=mode. 2007-02-03 18:45:46 +01:00
perm * tests/sample-test: Quote variables containing absolute build 2006-10-22 19:37:31 +02:00
preserve-2 * tests/sample-test: Quote variables containing absolute build 2006-10-22 19:37:31 +02:00
r-vs-symlink * tests/sample-test: Quote variables containing absolute build 2006-10-22 19:37:31 +02:00
same-file Correct cp's handling of destination symlinks in some cases. 2007-06-15 22:47:16 +02:00
slink-2-slink * tests/sample-test: Quote variables containing absolute build 2006-10-22 19:37:31 +02:00
sparse Work around a failing test due to an NFS-based race condition. 2007-03-13 19:51:47 +01:00
special-bits cp -p now clears special bits if it fails to preserve owner or group 2006-12-07 08:10:35 +01:00
src-base-dot * tests/sample-test: Quote variables containing absolute build 2006-10-22 19:37:31 +02:00
symlink-slash * tests/sample-test: Quote variables containing absolute build 2006-10-22 19:37:31 +02:00
thru-dangling bug-fix: cp would fail to write through a dangling symlink 2007-06-10 15:01:18 +02:00
trailing-slash mv and "cp -r" no longer fail when invoked with two arguments 2006-09-08 17:08:53 +00:00