teknoraver / rpms / rpm

Forked from rpms/rpm 5 months ago
Clone

Blame 0002-Fix-FA_TOUCH-ed-files-getting-removed-on-failed-upda.patch

Michal Domonkos 9caa0d
From 9eedcd6b770154a8d853db30b49d411823d64c44 Mon Sep 17 00:00:00 2001
Michal Domonkos 9caa0d
From: Panu Matilainen <pmatilai@redhat.com>
Michal Domonkos 9caa0d
Date: Fri, 18 Oct 2024 14:50:35 +0300
Michal Domonkos 9caa0d
Subject: [PATCH 2/2] Fix FA_TOUCH'ed files getting removed on failed update
Michal Domonkos 9caa0d
Michal Domonkos 9caa0d
On install/update, most files are laid down with a temporary suffix
Michal Domonkos 9caa0d
and if the update fails, removing those at the end of the loop is
Michal Domonkos 9caa0d
the right thing to do. However FA_TOUCH'ed files were already there,
Michal Domonkos 9caa0d
we only update their metadata, and we better not remove them!
Michal Domonkos 9caa0d
Michal Domonkos 9caa0d
AFAICS this all versions since rpm >= 4.14 in one way or the other.
Michal Domonkos 9caa0d
If %_minimize_writes is enabled then it affects way more than just
Michal Domonkos 9caa0d
unmodified config files.
Michal Domonkos 9caa0d
Michal Domonkos 9caa0d
The test is a simplified version of pam update failing in the original
Michal Domonkos 9caa0d
report. Technically, --nomtime should not be needed for the test
Michal Domonkos 9caa0d
verification but we don't even try to restore the metadata on failure,
Michal Domonkos 9caa0d
and fixing that is way out of scope here.
Michal Domonkos 9caa0d
Michal Domonkos 9caa0d
Backported from commits:
Michal Domonkos 9caa0d
027ef640b33b38ca257bb301bb302e9c71d43c27
Michal Domonkos 9caa0d
Michal Domonkos 9caa0d
Tests are excluded from this backport since they would need significant
Michal Domonkos 9caa0d
rework, the use case will be covered by Beaker.
Michal Domonkos 9caa0d
Michal Domonkos 9caa0d
Fixes: RHEL-63070
Michal Domonkos 9caa0d
---
Michal Domonkos 9caa0d
 lib/fsm.c | 2 +-
Michal Domonkos 9caa0d
 1 file changed, 1 insertion(+), 1 deletion(-)
Michal Domonkos 9caa0d
Michal Domonkos 9caa0d
diff --git a/lib/fsm.c b/lib/fsm.c
Michal Domonkos 9caa0d
index 720d4a2ec..91155c13c 100644
Michal Domonkos 9caa0d
--- a/lib/fsm.c
Michal Domonkos 9caa0d
+++ b/lib/fsm.c
Michal Domonkos 9caa0d
@@ -1093,7 +1093,7 @@ setmeta:
Michal Domonkos 9caa0d
 	    if (ensureDir(NULL, rpmfiDN(fi), 0, 0, 1, &di.dirfd))
Michal Domonkos 9caa0d
 		continue;
Michal Domonkos 9caa0d
 
Michal Domonkos 9caa0d
-	    if (fp->stage > FILE_NONE && !fp->skip) {
Michal Domonkos 9caa0d
+	    if (fp->stage > FILE_NONE && !fp->skip && fp->action != FA_TOUCH) {
Michal Domonkos 9caa0d
 		(void) fsmRemove(di.dirfd, fp->fpath, fp->sb.st_mode);
Michal Domonkos 9caa0d
 	    }
Michal Domonkos 9caa0d
 	}
Michal Domonkos 9caa0d
-- 
Michal Domonkos 9caa0d
2.47.1
Michal Domonkos 9caa0d