GNU bug report logs - #62607
cp --recursive --backup broken in 9.2

Previous Next

Package: coreutils;

Reported by: Kristian Klausen <kristian <at> klausen.dk>

Date: Sun, 2 Apr 2023 04:48:03 UTC

Severity: normal

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 62607 in the body.
You can then email your comments to 62607 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#62607; Package coreutils. (Sun, 02 Apr 2023 04:48:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Kristian Klausen <kristian <at> klausen.dk>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Sun, 02 Apr 2023 04:48:04 GMT) Full text and rfc822 format available.

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

From: Kristian Klausen <kristian <at> klausen.dk>
To: bug-coreutils <at> gnu.org
Subject: cp --recursive --backup broken in 9.2
Date: Sun, 2 Apr 2023 00:40:07 +0200
[Message part 1 (text/plain, inline)]
Hi

After upgrading to coreutils 9.2-2 on Arch Linux the following:
mkdir -p src dst
touch {src,dst}/bar
cp --recursive --backup src/* dst
fails with:
cp: cannot create regular file 'dst/foo/bar': File exists

Running strace on cp I noticed:
renameat2(4, "foo/bar", 4, "foo/bar~", 0) = -1 ENOENT (No such file or 
directory)

In coreutils 9.1-3 the syscall succeeds:
renameat2(4, "bar", 4, "bar~", 0)       = 0

I assume renameat2 is called with the wrong oldpath and newpath in 9.2 
and that it should just be the basename and not the full relative path.

Cheers
Kristian Klausen
[OpenPGP_signature (application/pgp-signature, attachment)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#62607; Package coreutils. (Sun, 02 Apr 2023 12:41:01 GMT) Full text and rfc822 format available.

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

From: Pádraig Brady <P <at> draigBrady.com>
To: Kristian Klausen <kristian <at> klausen.dk>, 62607 <at> debbugs.gnu.org
Subject: Re: cp --recursive --backup broken in 9.2
Date: Sun, 2 Apr 2023 13:40:44 +0100
On 01/04/2023 23:40, Kristian Klausen via GNU coreutils Bug Reports wrote:
> Hi
> 
> After upgrading to coreutils 9.2-2 on Arch Linux the following:
> mkdir -p src dst
> touch {src,dst}/bar
> cp --recursive --backup src/* dst
> fails with:
> cp: cannot create regular file 'dst/foo/bar': File exists
> 
> Running strace on cp I noticed:
> renameat2(4, "foo/bar", 4, "foo/bar~", 0) = -1 ENOENT (No such file or
> directory)
> 
> In coreutils 9.1-3 the syscall succeeds:
> renameat2(4, "bar", 4, "bar~", 0)       = 0
> 
> I assume renameat2 is called with the wrong oldpath and newpath in 9.2
> and that it should just be the basename and not the full relative path.
> 
> Cheers
> Kristian Klausen

Your analysis is correct wrt the wrong paths being given to the renameat2().
This is related to https://bugs.gnu.org/55029

For completeness the correct repro is:

  mkdir -p {src,dst}/foo
  touch {src,dst}/foo/bar
  cp --recursive --backup src/* dst

thanks,
Pádraig




Information forwarded to bug-coreutils <at> gnu.org:
bug#62607; Package coreutils. (Mon, 03 Apr 2023 17:20:02 GMT) Full text and rfc822 format available.

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

From: Pádraig Brady <P <at> draigBrady.com>
To: Kristian Klausen <kristian <at> klausen.dk>, 62607 <at> debbugs.gnu.org
Cc: bug-gnulib <bug-gnulib <at> gnu.org>
Subject: Re: bug#62607: cp --recursive --backup broken in 9.2
Date: Mon, 3 Apr 2023 18:19:44 +0100
[Message part 1 (text/plain, inline)]
On 02/04/2023 13:40, Pádraig Brady wrote:
> On 01/04/2023 23:40, Kristian Klausen via GNU coreutils Bug Reports wrote:
>> Hi
>>
>> After upgrading to coreutils 9.2-2 on Arch Linux the following:
>> mkdir -p src dst
>> touch {src,dst}/bar
>> cp --recursive --backup src/* dst
>> fails with:
>> cp: cannot create regular file 'dst/foo/bar': File exists
>>
>> Running strace on cp I noticed:
>> renameat2(4, "foo/bar", 4, "foo/bar~", 0) = -1 ENOENT (No such file or
>> directory)
>>
>> In coreutils 9.1-3 the syscall succeeds:
>> renameat2(4, "bar", 4, "bar~", 0)       = 0
>>
>> I assume renameat2 is called with the wrong oldpath and newpath in 9.2
>> and that it should just be the basename and not the full relative path.
>>
>> Cheers
>> Kristian Klausen
> 
> Your analysis is correct wrt the wrong paths being given to the renameat2().
> This is related to https://bugs.gnu.org/55029
> 
> For completeness the correct repro is:
> 
>     mkdir -p {src,dst}/foo
>     touch {src,dst}/foo/bar
>     cp --recursive --backup src/* dst

The attached two patches should address this.
The first fixes the bug in gnulib (cc'd),
while the second adds a test to coreutils.

thanks,
Pádraig
[gnulib-backupfile-62607.patch (text/x-patch, attachment)]
[coreutils-backup-62607.patch (text/x-patch, attachment)]

Reply sent to Pádraig Brady <P <at> draigBrady.com>:
You have taken responsibility. (Tue, 04 Apr 2023 11:03:02 GMT) Full text and rfc822 format available.

Notification sent to Kristian Klausen <kristian <at> klausen.dk>:
bug acknowledged by developer. (Tue, 04 Apr 2023 11:03:02 GMT) Full text and rfc822 format available.

Message #16 received at 62607-done <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Kristian Klausen <kristian <at> klausen.dk>, 62607-done <at> debbugs.gnu.org
Cc: bug-gnulib <bug-gnulib <at> gnu.org>
Subject: Re: bug#62607: cp --recursive --backup broken in 9.2
Date: Tue, 4 Apr 2023 12:02:50 +0100
On 03/04/2023 18:19, Pádraig Brady wrote:
> On 02/04/2023 13:40, Pádraig Brady wrote:
>> For completeness the correct repro is:
>>
>>      mkdir -p {src,dst}/foo
>>      touch {src,dst}/foo/bar
>>      cp --recursive --backup src/* dst
> 
> The attached two patches should address this.
> The first fixes the bug in gnulib (cc'd),
> while the second adds a test to coreutils.

Pushed.
Marking this as done.

thanks,
Pádraig





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 02 May 2023 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 110 days ago.

Previous Next


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