From 4e367ece4a9dccf89f859af217ed72e51425a4b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Thu, 4 May 2023 19:40:43 +0100 Subject: [PATCH] further fixes to backups; broken in 9.1 From https://bugs.gnu.org/55029 From https://bugs.gnu.org/62607 --- coreutils.spec | 5 ++- gnulib-simple-backup-fix.patch | 64 +++++++++++++++++++++++----------- 2 files changed, 48 insertions(+), 21 deletions(-) diff --git a/coreutils.spec b/coreutils.spec index 8c4a6b1..abe4c99 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Summary: A set of basic GNU tools commonly used in shell scripts Name: coreutils Version: 9.1 -Release: 11%{?dist} +Release: 12%{?dist} License: GPLv3+ Url: https://www.gnu.org/software/coreutils/ Source0: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz @@ -261,6 +261,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir %license COPYING %changelog +* Thu May 04 2023 Pádraig Brady - 9.1-12 +- further fixes to backups; broken in 9.1 + * Thu Jan 19 2023 Fedora Release Engineering - Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild diff --git a/gnulib-simple-backup-fix.patch b/gnulib-simple-backup-fix.patch index 9c2d8a7..090ae21 100644 --- a/gnulib-simple-backup-fix.patch +++ b/gnulib-simple-backup-fix.patch @@ -1,36 +1,60 @@ -commit 7347caeb9d902d3fca2c11f69a55a3e578d93bfe -Author: Paul Eggert -Date: Wed Apr 20 19:34:57 2022 -0700 - - backupfile: fix bug when renaming simple backups - - * lib/backupfile.c (backupfile_internal): Fix bug when RENAME - and when doing simple backups. Problem reported by Steve Ward in: - https://bugs.gnu.org/55029 - -diff --git a/lib/backupfile.c b/lib/backupfile.c -index 1e9290a187..d9f465a3e0 100644 ---- a/lib/backupfile.c -+++ b/lib/backupfile.c -@@ -332,7 +332,7 @@ backupfile_internal (int dir_fd, char const *file, +diff -Naur coreutils-9.1.orig/lib/backupfile.c coreutils-9.1/lib/backupfile.c +--- coreutils-9.1.orig/lib/backupfile.c 2022-04-08 11:22:26.000000000 +0000 ++++ coreutils-9.1/lib/backupfile.c 2023-05-04 17:07:20.784911071 +0000 +@@ -332,7 +332,7 @@ return s; DIR *dirp = NULL; - int sdir = AT_FDCWD; -+ int sdir = dir_fd; ++ int sdir = -1; idx_t base_max = 0; while (true) { -@@ -371,10 +371,9 @@ backupfile_internal (int dir_fd, char const *file, +@@ -371,10 +371,10 @@ if (! rename) break; - int olddirfd = sdir < 0 ? dir_fd : sdir; -- idx_t offset = sdir < 0 ? 0 : base_offset; -+ idx_t offset = backup_type == simple_backups ? 0 : base_offset; ++ dir_fd = sdir < 0 ? dir_fd : sdir; + idx_t offset = sdir < 0 ? 0 : base_offset; unsigned flags = backup_type == simple_backups ? 0 : RENAME_NOREPLACE; - if (renameatu (olddirfd, file + offset, sdir, s + offset, flags) == 0) -+ if (renameatu (sdir, file + offset, sdir, s + offset, flags) == 0) ++ if (renameatu (dir_fd, file + offset, dir_fd, s + offset, flags) == 0) break; int e = errno; if (! (e == EEXIST && extended)) +diff -Naur coreutils-9.1.orig/tests/cp/backup-dir.sh coreutils-9.1/tests/cp/backup-dir.sh +--- coreutils-9.1.orig/tests/cp/backup-dir.sh 2022-04-08 11:22:18.000000000 +0000 ++++ coreutils-9.1/tests/cp/backup-dir.sh 2023-05-04 17:07:24.851960384 +0000 +@@ -1,5 +1,5 @@ + #!/bin/sh +-# Ensure that cp -b doesn't back up directories. ++# Ensure that cp -b handles directories appropriately + + # Copyright (C) 2006-2022 Free Software Foundation, Inc. + +@@ -29,4 +29,10 @@ + test -d y/x || fail=1 + test -d y/x~ && fail=1 + ++# Bug 62607. ++# This would fail to backup using rename, and thus fail to replace the file ++mkdir -p src/foo dst/foo || framework_failure_ ++touch src/foo/bar dst/foo/bar || framework_failure_ ++cp --recursive --backup src/* dst || fail=1 ++ + Exit $fail +diff -Naur coreutils-9.1.orig/tests/mv/backup-dir.sh coreutils-9.1/tests/mv/backup-dir.sh +--- coreutils-9.1.orig/tests/mv/backup-dir.sh 2022-04-08 11:22:18.000000000 +0000 ++++ coreutils-9.1/tests/mv/backup-dir.sh 2023-05-04 17:03:29.593098230 +0000 +@@ -36,4 +36,10 @@ + mv -T --backup=numbered C E/ || fail=1 + mv -T --backup=numbered D E/ || fail=1 + ++# Bug#55029 ++mkdir F && echo 1 >1 && echo 2 >2 && cp 1 F/X && cp 2 X || framework_failure_ ++mv --backup=simple X F/ || fail=1 ++compare 1 F/X~ || fail=1 ++compare 2 F/X || fail=1 ++ + Exit $fail