Package: coreutils Version: 5.2.1-2.1 Severity: normal Tags: patch Hi,
POSIX.1-2001 says that link() should dereference symlinks. The Linux kernel does not follow POSIX, so that calling cp with --no-dereference and --link works as expected. However on non-Linux kernel, this does not work as expected, the symlinks being dereferenced. This is even worse with symlinks pointing to non-existing paths, where contrary to Linux, cp fails in such cases. I suggest to make regular copy of the symlink in such cases, to increase portability of shell scripts. This is the purpose of the attached patch. Could you please merge it in the next upload? Thanks in advance, Aurelien -- System Information: Debian Release: testing/unstable Architecture: kfreebsd-i386 (i686) Shell: /bin/sh linked to /bin/bash Kernel: GNU/kFreeBSD 5.4-1-686 Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8) Versions of packages coreutils depends on: ii libc0.1 2.3-1+kbsd.11 GNU C Library: Shared libraries an coreutils recommends no packages. -- no debconf information
Author: aurel32 Status: in BTS --- coreutils-5.2.1.orig/debian/patches/40_cp_link_posix.patch +++ coreutils-5.2.1/debian/patches/40_cp_link_posix.patch @@ -0,0 +1,18 @@ +--- coreutils-5.2.1.orig/src/copy.c 2005-09-19 00:35:32.000000000 +0200 ++++ coreutils-5.2.1/src/copy.c 2005-09-19 00:34:53.000000000 +0200 +@@ -1411,7 +1411,15 @@ + } + } + #endif ++/* According to POSIX.1-2001, a call to link() should dereference symlinks. cp ++ called with the --no-dereference argument should not. */ ++#ifdef LINK_FOLLOWS_SYMLINKS ++ /* For kernels that do not follow POSIX, don't call link() and make a copy. */ ++ else if (x->hard_link && !(S_ISLNK (src_mode) && x->dereference == DEREF_NEVER)) ++#else ++ /* For kernels that follow POSIX, use link() in all cases. */ + else if (x->hard_link) ++#endif + { + preserve_metadata = 0; + if (link (src_path, dst_path)) --- coreutils-5.2.1.orig/debian/patches/22_kbsd_name.diff +++ coreutils-5.2.1/debian/patches/22_kbsd_name.diff @@ -0,0 +1,28 @@ +diff -Nur coreutils-5.2.1.orig/configure coreutils-5.2.1/configure +--- coreutils-5.2.1.orig/configure 2004-03-11 09:58:11.000000000 +0100 ++++ coreutils-5.2.1/configure 2005-07-26 00:42:37.000000000 +0200 +@@ -8333,8 +8333,8 @@ + nonstopux*) os='NonStop-UX';; + netbsd*-gnu*) os='GNU/NetBSD';; # NetBSD kernel+libc, GNU userland + netbsd*) os='NetBSD';; +- knetbsd*-gnu) os='GNU/KNetBSD';; # NetBSD kernel, GNU libc+userland +- kfreebsd*-gnu) os='GNU/KFreeBSD';; # FreeBSD kernel, GNU libc+userland ++ knetbsd*-gnu) os='GNU/kNetBSD';; # NetBSD kernel, GNU libc+userland ++ kfreebsd*-gnu) os='GNU/kFreeBSD';; # FreeBSD kernel, GNU libc+userland + msdosdjgpp*) os='DJGPP';; + mpeix*) os='MPE/iX';; + mint*) os='MiNT';; +diff -Nur coreutils-5.2.1.orig/m4/host-os.m4 coreutils-5.2.1/m4/host-os.m4 +--- coreutils-5.2.1.orig/m4/host-os.m4 2003-11-03 16:37:44.000000000 +0100 ++++ coreutils-5.2.1/m4/host-os.m4 2005-07-26 00:42:27.000000000 +0200 +@@ -32,8 +32,8 @@ + nonstopux*) os='NonStop-UX';; + netbsd*-gnu*) os='GNU/NetBSD';; # NetBSD kernel+libc, GNU userland + netbsd*) os='NetBSD';; +- knetbsd*-gnu) os='GNU/KNetBSD';; # NetBSD kernel, GNU libc+userland +- kfreebsd*-gnu) os='GNU/KFreeBSD';; # FreeBSD kernel, GNU libc+userland ++ knetbsd*-gnu) os='GNU/kNetBSD';; # NetBSD kernel, GNU libc+userland ++ kfreebsd*-gnu) os='GNU/kFreeBSD';; # FreeBSD kernel, GNU libc+userland + msdosdjgpp*) os='DJGPP';; + mpeix*) os='MPE/iX';; + mint*) os='MiNT';;