cp --parents fails without reason

Bug #2017414 reported by Schlomo Schapiro
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
coreutils (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Upstream bug: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=63245

The following example of a copy command fails without reason:

# 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
#

/tmp is on the same filesystem as /. The same on Ubuntu 22.04 works without a problem:

# 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
#

Why I omit the --preservce=all then it works without a problem:

# rm -Rf /tmp/f && mkdir /tmp/f && cp --verbose -t /tmp/f -L --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-- 2 root root 2437 Apr 23 09:53 /etc/apt/sources.list
-rw-r--r-- 1 root root 2437 Apr 23 11:02 /tmp/f/etc/apt/sources.list
#

Also, when I only use --preserve=mode, then it again fails:

# rm -Rf /tmp/f && mkdir /tmp/f && cp --verbose -t /tmp/f -L --preserve=mode --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-- 2 root root 2437 Apr 23 09:53 /etc/apt/sources.list
-rw-r--r-- 1 root root 2437 Apr 23 11:02 /tmp/f/etc/apt/sources.list
#

Is this a bug in cp or something else?

I'm one of the maintainers of Relax-and-Recover (rear) and noticed this in https://github.com/rear/rear/issues/2972

OS Release Info:
PRETTY_NAME="Ubuntu 23.04"
NAME="Ubuntu"
VERSION_ID="23.04"
VERSION="23.04 (Lunar Lobster)"
VERSION_CODENAME=lunar
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=lunar
LOGO=ubuntu-logo

Coreutils version:

# cp --version
cp (GNU coreutils) 9.1

# dpkg-query -l coreutils
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-============-============-=================================
ii coreutils 9.1-1ubuntu2 amd64 GNU core utilities

ProblemType: Bug
DistroRelease: Ubuntu 23.04
Package: coreutils 9.1-1ubuntu2
ProcVersionSignature: Ubuntu 6.2.0-20.20-generic 6.2.6
Uname: Linux 6.2.0-20-generic x86_64
ApportVersion: 2.26.1-0ubuntu2
Architecture: amd64
CasperMD5CheckResult: pass
Date: Sun Apr 23 10:48:56 2023
InstallationDate: Installed on 2023-04-23 (0 days ago)
InstallationMedia: Ubuntu-Server 23.04 "Lunar Lobster" - Release amd64 (20230415)
SourcePackage: coreutils
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Schlomo Schapiro (sschapiro) wrote :
Revision history for this message
Schlomo Schapiro (sschapiro) wrote :

I reported this bug upstream and somebody even provided a patch: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=63245

summary: - cp --preserve=all or --preserve=mode fails without reason
+ cp --parents fails without reason
description: updated
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in coreutils (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.