On 03/05/2023 10:27, Schlomo Schapiro wrote:
> Hello,
>
> I'm a maintainer of the Relax-and-Recover (https://relax-and-recover.org/)
> Open Source project and think that I might have found a major regression in
> cp, starting somewhere with version 9.
>
> Please see https://bugs.launchpad.net/ubuntu/+source/coreutils/+bug/2017414
> and https://github.com/rear/rear/issues/2972 for how I found out about this.
>
> Problem:
>
> We use a cp call like the following to copy various files and directory
> into a destination path with preserving the structure:
>
> cp --verbose -t DESTINATION -L --preserve=all --parents SOURCE...
>
> Over the last 10+ years that worked well on all Linux distros (ReaR is
> build for and tested on nearly all distros), but I recently found out that
> on Ubuntu 23.04 this fails like this:
>
> # rm -Rf /tmp/f && mkdir /tmp/f && cp --verbose -t /tmp/f -L --preserve=all
> --parents /etc/apt/sources.list && echo yes ; ls -lR
> /tmp/f/etc/apt/sources.list
> /etc/apt/sources.list
> /etc -> /tmp/f/etc
> /etc/apt -> /tmp/f/etc/apt
> '/etc/apt/sources.list' -> '/tmp/f/etc/apt/sources.list'
> cp: ‘etc/apt’: No such file or directory
> -rw-r--r-- 1 root root 2437 Apr 23 09:53 /etc/apt/sources.list
> -rw-r--r-- 1 root root 2437 Apr 23 09:53 /tmp/f/etc/apt/sources.list
> #
>
> Ubuntu 23.04 uses cp (GNU coreutils) 9.1
>
> On Ubuntu 22.04 there is cp (GNU coreutils) 8.32 and the same example works
> as expected:
>
> # rm -Rf /tmp/f && mkdir /tmp/f && cp --verbose -t /tmp/f -L --preserve=all
> --parents /etc/apt/sources.list && echo yes ; ls -lR
> /tmp/f/etc/apt/sources.list /etc/apt/sources.list
> /etc -> /tmp/f/etc
> /etc/apt -> /tmp/f/etc/apt
> '/etc/apt/sources.list' -> '/tmp/f/etc/apt/sources.list'
> yes
> -rw-r--r-- 1 root root 263 Mär 26 15:20 /etc/apt/sources.list
> -rw-r--r-- 1 root root 263 Mär 26 15:20 /tmp/f/etc/apt/sources.list
> #
>
> BTW, I checked also on many other distros that ReaR supports and all
> distros with cp version 9.1 fail in the same way.
>
> Can you please have a look and advise how to proceed? We at the ReaR
> project can of course change our code to use tar for example, but I won't
> be surprised if other users will also meet this changed behaviour and maybe
> it is indeed a bug.
Looks like a bug indeed.
The attached patch should address this in coreutils.
Any deployments of coreutils 9.1-9.3 inclusive would need to apply this.
thanks,
Pádraig