]> git.ipfire.org Git - people/ms/pakfire.git/commitdiff
Fix execution of scriptlets in a dirty environment
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 10 Sep 2015 17:00:09 +0000 (18:00 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 10 Sep 2015 17:46:38 +0000 (18:46 +0100)
The environment will be populated with a basic set of
variables and cleared from the rest.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/actions.py
src/pakfire/builder.py
src/pakfire/constants.py

index 2b044b2f88b8009e9dfea26681dc9102d8e126e8..7277761693b69695befedd06fdf7ff8730df38e1 100644 (file)
@@ -145,6 +145,7 @@ class Action(object):
 
                args = {
                        "cwd"         : cwd,
+                       "env"         : MINIMAL_ENVIRONMENT,
                        "logger"      : self.get_logger(),
                        "personality" : self.pakfire.distro.personality,
                        "shell"       : False,
index ebb34e2f4137d5138264dcaabc04ae502d32aecd..b961f8e0acebede55a379ccb688bfba2f7af2543 100644 (file)
@@ -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)
index 2ff3ddb739ef6f6e84002f778761f594cce7900c..237d8ed2984e1c6394ff43e5a41fef7dd226abd8 100644 (file)
@@ -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")