- Fix not chrooting transaction file triggers

This commit is contained in:
Lubos Kardos 2016-01-15 15:18:23 +01:00
parent eb83c4215c
commit f5dbe0f5c2
2 changed files with 76 additions and 1 deletions

View File

@ -0,0 +1,71 @@
From 9aff39d0d530332e8cae376f2390b6546239a20e Mon Sep 17 00:00:00 2001
From: Lubos Kardos <lkardos@redhat.com>
Date: Thu, 14 Jan 2016 13:35:28 +0100
Subject: [PATCH] Fix not chrooting transaction file triggers
previously those filetriggers would call tools out of the chroot, which
breaks installers such as DrakX or Anaconda.
See https://bugs.mageia.org/show_bug.cgi?id=17217
Thanks Thierry Vignaud for finding and helping to solve this.
---
lib/rpmtriggers.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/lib/rpmtriggers.c b/lib/rpmtriggers.c
index 211e62f..4c6e821 100644
--- a/lib/rpmtriggers.c
+++ b/lib/rpmtriggers.c
@@ -11,6 +11,7 @@
#include "lib/rpmdb_internal.h"
#include "lib/rpmds_internal.h"
#include "lib/rpmfi_internal.h"
+#include "lib/rpmchroot.h"
#define TRIGGER_PRIORITY_BOUND 10000
@@ -157,6 +158,9 @@ int runPostUnTransFileTrigs(rpmts ts)
rpmtriggers trigs = ts->trigs2run;
int nerrors = 0;
+ if (rpmChrootIn() != 0)
+ return -1;
+
rpmtriggersSortAndUniq(trigs);
/* Iterate over stored triggers */
for (i = 0; i < trigs->count; i++) {
@@ -180,6 +184,9 @@ int runPostUnTransFileTrigs(rpmts ts)
rpmScriptFree(script);
headerFree(trigH);
}
+
+ rpmChrootOut();
+
return nerrors;
}
@@ -530,6 +537,11 @@ rpmRC runFileTriggers(rpmts ts, rpmte te, rpmsenseFlags sense,
/* Sort triggers by priority, offset, trigger index */
rpmtriggersSortAndUniq(triggers);
+ if (rpmChrootIn() != 0) {
+ rpmtriggersFree(triggers);
+ return RPMRC_FAIL;
+ }
+
/* Handle stored triggers */
for (i = 0; i < triggers->count; i++) {
if (priorityClass == 1) {
@@ -550,6 +562,8 @@ rpmRC runFileTriggers(rpmts ts, rpmte te, rpmsenseFlags sense,
headerFree(trigH);
}
rpmtriggersFree(triggers);
+ /* XXX an error here would require a full abort */
+ (void) rpmChrootOut();
return (nerrors == 0) ? RPMRC_OK : RPMRC_FAIL;
}
--
1.9.3

View File

@ -29,7 +29,7 @@
Summary: The RPM package management system
Name: rpm
Version: %{rpmver}
Release: %{?snapver:0.%{snapver}.}7%{?dist}
Release: %{?snapver:0.%{snapver}.}8%{?dist}
Group: System Environment/Base
Url: http://www.rpm.org/
Source0: http://rpm.org/releases/rpm-4.12.x/%{name}-%{srcver}.tar.bz2
@ -57,6 +57,7 @@ Patch101: rpm-4.13.0-selinux--permissive-scriptlets.patch
Patch102: rpm-4.13.0-unsupported-keys.patch
Patch103: rpm-4.13.0-ignore-sigpipe.patch
Patch104: rpm-4.13.0-fix-crash-on-corrupted.patch
Patch105: rpm-4.13.0-chroot-file-triggers.patch
# These are not yet upstream
Patch302: rpm-4.7.1-geode-i686.patch
@ -559,6 +560,9 @@ exit 0
%doc doc/librpm/html/*
%changelog
* Fri Jan 15 2016 Lubos Kardos <lkardos@redhat.com> - 4.13.0-0.rc1.8
- Fix not chrooting transaction file triggers
* Fri Nov 20 2015 Lubos Kardos <lkardos@redhat.com> - 4.13.0-0.rc1.7
- Fix crash when parsing corrupted RPM file (#1273360)