|
From: | Pádraig Brady |
Subject: | bug#55029: Simple backup swaps source and destination files |
Date: | Sat, 23 Apr 2022 15:42:50 +0100 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Thunderbird/97.0 |
On 21/04/2022 03:53, Paul Eggert wrote:
On 4/19/22 16:05, Steve Ward wrote:When doing mv or cp with --backup=simple, if an existing file in DIRECTORY has the same name as SOURCE, the files appear to be swapped instead of an in-place backup of the original file in DIRECTORY being made.Thanks for the bug report. That's new to coreutils 9.1, and is a big enough fail that it suggests we'll need a 9.2 sooner rather than later. I introduced the bug when fixing an earlier bug (sorry). I installed the attached Gnulib patch, which should fix the bug in Coreutils, with the attached two Coreutils patches to update to the latest Gnulib, and to add a test case for the bug.
Thanks for the fix. For the record, another failure mode is with different file systems: $ echo 1 > /tmp/a $ echo 2 > a $ echo 3 > a~ $ src/mv -v --backup=simple a /tmp src/mv: cannot backup '/tmp/a': Invalid cross-device link In this case the failure is not silent, and no changes are made. This is a bit better, in that there is no possibility of silent data loss. For the same file system case you might lose data in a setup like: $ cd workdir $ gen_data1 > data $ mv --backup=simple data1/ $ gen_data2 > data $ mv --backup=simple data2/ In which case you'd lose the data~ backups in each of the data?/ dirs. Another case which might be more problematic is with install(1). $ install --backup=simple blah /usr/local/dir In which case we'd lose the blah~ backup upon removal of the build dir. Note --backup without a specific type will default to simple or numbered as appropriate, but this does _not_ have the issue when defaulting to simple. I've applied the fix to Fedora rawhide which had already moved to 9.1. I've reported git issue at https://bugs.archlinux.org/task/74544 This should induce a coreutils 9.2 sooner, but I don't think we need an immediate release just yet. thanks, Pádraig
[Prev in Thread] | Current Thread | [Next in Thread] |