From f672fec4364e71c6e5a30d4026d6bdb7cf332eed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?=
Date: Sat, 23 Apr 2022 14:24:58 +0100
Subject: [PATCH] make simple backups in correct dir; broken in 9.1
From https://bugs.gnu.org/55029
---
coreutils.spec | 8 +++++++-
gnulib-simple-backup-fix.patch | 36 ++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 1 deletion(-)
create mode 100644 gnulib-simple-backup-fix.patch
diff --git a/coreutils.spec b/coreutils.spec
index 766e55b..37adee5 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: 1%{?dist}
+Release: 2%{?dist}
License: GPLv3+
Url: https://www.gnu.org/software/coreutils/
Source0: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz
@@ -17,6 +17,9 @@ Source106: coreutils-colorls.csh
# do not make coreutils-single depend on /usr/bin/coreutils
%global __requires_exclude ^%{_bindir}/coreutils$
+# Make simple backups in correct dir; broken in 9.1
+Patch1: gnulib-simple-backup-fix.patch
+
# disable the test-lock gnulib test prone to deadlock
Patch100: coreutils-8.26-test-lock.patch
@@ -262,6 +265,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir
%license COPYING
%changelog
+* Sat Apr 23 2022 Pádraig Brady
- 9.1-2
+- make simple backups in correct dir; broken in 9.1
+
* Tue Apr 19 2022 Kamil Dudka - 9.1-1
- new upstream release 9.1
diff --git a/gnulib-simple-backup-fix.patch b/gnulib-simple-backup-fix.patch
new file mode 100644
index 0000000..9c2d8a7
--- /dev/null
+++ b/gnulib-simple-backup-fix.patch
@@ -0,0 +1,36 @@
+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,
+ return s;
+
+ DIR *dirp = NULL;
+- int sdir = AT_FDCWD;
++ int sdir = dir_fd;
+ idx_t base_max = 0;
+ while (true)
+ {
+@@ -371,10 +371,9 @@ backupfile_internal (int dir_fd, char const *file,
+ 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;
+ 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)
+ break;
+ int e = errno;
+ if (! (e == EEXIST && extended))