From 1dd38b7b1730ccef9ecb9315d1af3a232c4e3eac Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 10 Sep 2015 18:00:09 +0100 Subject: [PATCH] Fix execution of scriptlets in a dirty environment The environment will be populated with a basic set of variables and cleared from the rest. Signed-off-by: Michael Tremer --- src/pakfire/actions.py | 1 + src/pakfire/builder.py | 8 +++----- src/pakfire/constants.py | 8 ++++++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/pakfire/actions.py b/src/pakfire/actions.py index 2b044b2f8..727776169 100644 --- a/src/pakfire/actions.py +++ b/src/pakfire/actions.py @@ -145,6 +145,7 @@ class Action(object): args = { "cwd" : cwd, + "env" : MINIMAL_ENVIRONMENT, "logger" : self.get_logger(), "personality" : self.pakfire.distro.personality, "shell" : False, diff --git a/src/pakfire/builder.py b/src/pakfire/builder.py index ebb34e2f4..b961f8e0a 100644 --- a/src/pakfire/builder.py +++ b/src/pakfire/builder.py @@ -638,13 +638,11 @@ class BuildEnviron(object): @property def environ(self): - env = { + env = MINIMAL_ENVIRONMENT.copy() + env.update({ # Add HOME manually, because it is occasionally not set # and some builds get in trouble then. - "PATH" : "/usr/bin:/bin:/usr/sbin:/sbin", - "HOME" : "/root", "TERM" : os.environ.get("TERM", "vt100"), - "PS1" : "\u:\w\$ ", # Sanitize language. "LANG" : os.environ.setdefault("LANG", "en_US.UTF-8"), @@ -652,7 +650,7 @@ class BuildEnviron(object): # Set the container that we can detect, if we are inside a # chroot. "container" : "pakfire-builder", - } + }) # Inherit environment from distro env.update(self.pakfire.distro.environ) diff --git a/src/pakfire/constants.py b/src/pakfire/constants.py index 2ff3ddb73..237d8ed29 100644 --- a/src/pakfire/constants.py +++ b/src/pakfire/constants.py @@ -90,6 +90,14 @@ SHELL_SCRIPT = "/usr/lib/pakfire/chroot-shell" SHELL_PACKAGES = ["elinks", "less", "vim", SHELL_SCRIPT,] BUILD_ROOT = "/var/lib/pakfire/build" +MINIMAL_ENVIRONMENT = { + "HOME" : "/root", + "LANG" : "C", + "PATH" : "/usr/bin:/bin:/usr/sbin:/sbin", + "PS1" : "\u:\w\$ ", + "TERM" : "vt100", +} + SOURCE_DOWNLOAD_URL = "http://source.ipfire.org/source-3.x/" SOURCE_CACHE_DIR = os.path.join(CACHE_DIR, "sources") -- 2.39.5