GNU bug report logs - #76702
coreutils 9.1 cp --parents --preserve /dir/file fstat relative dir

Previous Next

Package: coreutils;

Reported by: "Alan J. Goalby" <alan.j.goalby <at> gmail.com>

Date: Mon, 3 Mar 2025 04:33:01 UTC

Severity: normal

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Alan J. Goalby" <alan.j.goalby <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: coreutils 9.1 cp --parents --preserve /dir/file fstat relative dir
Date: Sun, 2 Mar 2025 15:18:17 +0000
[Message part 1 (text/plain, inline)]
When "cp --parents --preserve /dir/file /target/" needs to create
/target/dir/, it appears to try to Fstat information from relative
path "dir", not the actual parent path "/dir".

E.g., "cd /tmp && mkdir NewDir && cp -a --parents /etc/passwd NewDir"
will fail, as (1) below - unless (2) /tmp/etc exists, or (3) use "cd
/", or (4) omit "--preserve".

My enclosed cp-par-pres-demo.sh shows that:

(1) Cp  --parents --preserve /dir/file /target/" will

 * log ENOENT for relative "dir" for a missing /target/dir;

 * create that missing parent /target/dir with mode 700;

 * create a missing non-parent output correctly; and

 * return error status 1.

(2) If ./dir exists, Cp takes /target/dir mode from it, not /dir.

(3) With "cd /", this works normally, since "dir" is /dir.

(4) Without --preserve, there is no error.

This happens for Debian 12.9 coreutils 9.1-1, under linux 6.1.115
amd64, on an ext4 partition, for root and other users, e.g. nobody.
And for an ext3 copy Chroot under linux 5.10.226.

(md5sum --check verifies coreutils.md5sums lib*.msd5sums et al.)

This does not happen for Debian 11.11 coreutils 8.32-4+b1, under linux
5.10.226 amd64 on ext4, nor for earlier versions on i386 ext3.

I enclose logs from those good Debian 11 and wrong Debian 12 runs.

My other tests show this not happening for relative input paths.

Hope this helps.

Alan J. Goalby
[cp-par-pres-demo.sh (application/x-sh, attachment)]
[fail-deb12p9-demo.log (text/plain, attachment)]
[good-deb11p11-demo.log (text/plain, attachment)]

This bug report was last modified 160 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.