From 027ef640b33b38ca257bb301bb302e9c71d43c27 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Fri, 18 Oct 2024 14:50:35 +0300 Subject: [PATCH] Fix FA_TOUCH'ed files getting removed on failed update Conflict:modify fsm.c instead of fsm.cc; don't modify testcode because the test code differs greatly, it requires the root permission to run chown. However, the current test code cannot implement chown. Manual test cases will be used to guard test cases. Reference:https://github.com/rpm-software-management/rpm/commit/027ef640b33b38ca257bb301bb302e9c71d43c27 On install/update, most files are laid down with a temporary suffix and if the update fails, removing those at the end of the loop is the right thing to do. However FA_TOUCH'ed files were already there, we only update their metadata, and we better not remove them! AFAICS this all versions since rpm >= 4.14 in one way or the other. If %_minimize_writes is enabled then it affects way more than just unmodified config files. The test is a simplified version of pam update failing in the original report. Technically, --nomtime should not be needed for the test verification but we don't even try to restore the metadata on failure, and fixing that is way out of scope here. Fixes: RHEL-54386 Fixes: #3284 --- lib/fsm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fsm.c b/lib/fsm.c index e3be219c3..ec0303400 100644 --- a/lib/fsm.c +++ b/lib/fsm.c @@ -1094,7 +1094,7 @@ setmeta: if (ensureDir(NULL, rpmfiDN(fi), 0, 0, 1, &di.dirfd)) continue; - if (fp->stage > FILE_NONE && !fp->skip) { + if (fp->stage > FILE_NONE && !fp->skip && fp->action != FA_TOUCH) { (void) fsmRemove(di.dirfd, fp->fpath, fp->sb.st_mode); } } -- 2.33.0