From e62cb285434cde3672c41761ff6e0d8f298244d8 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Wed, 28 Jun 2023 09:55:16 +0300 Subject: [PATCH] Fix a couple of <= 4.18 regressions --- ...an-error-in-parseScript-if-parsing-f.patch | 49 +++++++++++++++++++ ...gin-hook-regression-introduced-in-4..patch | 33 +++++++++++++ rpm.spec | 8 ++- 3 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 0001-Actually-return-an-error-in-parseScript-if-parsing-f.patch create mode 100644 0001-Fix-per-file-plugin-hook-regression-introduced-in-4..patch diff --git a/0001-Actually-return-an-error-in-parseScript-if-parsing-f.patch b/0001-Actually-return-an-error-in-parseScript-if-parsing-f.patch new file mode 100644 index 0000000..0f3ddf6 --- /dev/null +++ b/0001-Actually-return-an-error-in-parseScript-if-parsing-f.patch @@ -0,0 +1,49 @@ +From 911a4f253c7213a8570028a7dc2a20b045de8e9e Mon Sep 17 00:00:00 2001 +Message-ID: <911a4f253c7213a8570028a7dc2a20b045de8e9e.1687934951.git.pmatilai@redhat.com> +From: Fabian Vogt +Date: Mon, 26 Jun 2023 16:28:07 +0200 +Subject: [PATCH] Actually return an error in parseScript if parsing fails + +The return value is stored in the "res" variable which is set to the return +value of parseLines early in the function. Past that point, any "goto exit;" +caused the function to return success. This was introduced by 52ce88851abb +("Port parseScript() to use parseLines(), no functional changes"). To fix it, +reintroduce the nextPart variable. +--- + build/parseScript.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/build/parseScript.c b/build/parseScript.c +index f8b693ac6..6f3dc2fe8 100644 +--- a/build/parseScript.c ++++ b/build/parseScript.c +@@ -95,7 +95,7 @@ int parseScript(rpmSpec spec, int parsePart) + int index; + char * reqargs = NULL; + +- int res = PART_ERROR; /* assume failure */ ++ int nextPart, res = PART_ERROR; /* assume failure */ + int rc, argc; + int arg; + const char **argv = NULL; +@@ -367,7 +367,7 @@ int parseScript(rpmSpec spec, int parsePart) + goto exit; + } + +- if ((res = parseLines(spec, STRIP_NOTHING, NULL, &sb)) == PART_ERROR) ++ if ((nextPart = parseLines(spec, STRIP_NOTHING, NULL, &sb)) == PART_ERROR) + goto exit; + + if (sb) { +@@ -479,6 +479,8 @@ int parseScript(rpmSpec spec, int parsePart) + } + } + ++ res = nextPart; ++ + exit: + free(reqargs); + freeStringBuf(sb); +-- +2.41.0 + diff --git a/0001-Fix-per-file-plugin-hook-regression-introduced-in-4..patch b/0001-Fix-per-file-plugin-hook-regression-introduced-in-4..patch new file mode 100644 index 0000000..d394904 --- /dev/null +++ b/0001-Fix-per-file-plugin-hook-regression-introduced-in-4..patch @@ -0,0 +1,33 @@ +From 7072b2d2b92e4d2731451bdcca8d83ab6b945016 Mon Sep 17 00:00:00 2001 +Message-ID: <7072b2d2b92e4d2731451bdcca8d83ab6b945016.1687934969.git.pmatilai@redhat.com> +From: Panu Matilainen +Date: Tue, 20 Jun 2023 10:11:20 +0300 +Subject: [PATCH] Fix per-file plugin hook regression introduced in 4.18 + +Commit 6dd62720fe84f7e2ad902c915b952fc0b29e3dcd neglected to update +rpmpluginsCallFsmFilePost() to pass the absolute path in the case +of unowned directories. Because in that case there's no rpmfi to +pass to the plugin in that case, there's simply no way for the plugin +to know what path is being manipulated. Oops. + +Fixes: #2543 +--- + lib/fsm.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/fsm.c b/lib/fsm.c +index 747ed2b09..c44f6313c 100644 +--- a/lib/fsm.c ++++ b/lib/fsm.c +@@ -360,7 +360,7 @@ static int fsmDoMkDir(rpmPlugins plugins, int dirfd, const char *dn, + } + + /* Run fsm file post hook for all plugins */ +- rpmpluginsCallFsmFilePost(plugins, NULL, dn, mode, op, rc); ++ rpmpluginsCallFsmFilePost(plugins, NULL, apath, mode, op, rc); + + if (!rc) { + rpmlog(RPMLOG_DEBUG, +-- +2.41.0 + diff --git a/rpm.spec b/rpm.spec index e6d0012..e45bc88 100644 --- a/rpm.spec +++ b/rpm.spec @@ -32,7 +32,7 @@ %global rpmver 4.18.91 #global snapver rc1 -%global baserelease 5 +%global baserelease 6 %global sover 10 %global srcver %{rpmver}%{?snapver:-%{snapver}} @@ -150,6 +150,8 @@ rpm-4.18.90-weak-user-group.patch # Patches already upstream: 0001-Don-t-muck-with-per-process-global-sqlite-configurat.patch +0001-Actually-return-an-error-in-parseScript-if-parsing-f.patch +0001-Fix-per-file-plugin-hook-regression-introduced-in-4..patch # ... # These are not yet upstream @@ -622,6 +624,10 @@ fi %doc %{_defaultdocdir}/rpm/API/ %changelog +* Wed Jun 28 2023 Panu Matilainen - 4.18.91-6 +- Fix a spec parsing error handling regression +- Fix a per-file plugin hook regression + * Tue Jun 27 2023 Panu Matilainen - 4.18.91-5 - Fix potential crash with multiple in-process sqlite uses