[elbe-devel] [PATCH 05/20] asciidoclog: instead of messing with os.environ in chroot(), use do(env_add=)
Torben Hohn
torben.hohn at linutronix.de
Fri Oct 12 11:27:51 CEST 2018
changing os.environ needs to be avoided, as it poses race conditions.
use the new "env_add" keyword parameter to set the child process
environment in a safe way.
Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
elbepack/asciidoclog.py | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/elbepack/asciidoclog.py b/elbepack/asciidoclog.py
index f49f9888..0c0f3da6 100644
--- a/elbepack/asciidoclog.py
+++ b/elbepack/asciidoclog.py
@@ -62,12 +62,13 @@ class LogBase(object):
raise CommandError(cmd, ret)
def chroot(self, directory, cmd, allow_fail=False):
- os.environ["LANG"] = "C"
- os.environ["LANGUAGE"] = "C"
- os.environ["LC_ALL"] = "C"
+
+ chroot_default_env = {"LANG": "C",
+ "LANGUAGE": "C",
+ "LC_ALL": "C"}
chcmd = "chroot %s %s" % (directory, cmd)
- self.do(chcmd, allow_fail=allow_fail)
+ self.do(chcmd, allow_fail=allow_fail, env_add=chroot_default_env)
def get_command_out(self, cmd, allow_fail=False):
--
2.11.0
More information about the elbe-devel
mailing list