From 546e7a9695728fa205fbfe7c373762b25697b12a Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Thu, 8 Feb 2018 17:49:40 +0100 Subject: openpgp: Do not wipe the environment in isolated mode Do not wipe the complete environment when running in isolated mode as this had unintended side effect of wiping PATH. Since there is no real reasons to pursue a proper whitelist for this, just preserve the environment while overriding GNUPGHOME and TZ appropriately. --- gemato/openpgp.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gemato/openpgp.py b/gemato/openpgp.py index b4f6a27..de3139a 100644 --- a/gemato/openpgp.py +++ b/gemato/openpgp.py @@ -139,10 +139,10 @@ class OpenPGPSystemEnvironment(object): outf.write(out.decode('utf8')) - def _spawn_gpg(self, options, stdin, env=None): - if env is None: - env = os.environ.copy() + def _spawn_gpg(self, options, stdin, env_override={}): + env = os.environ.copy() env['TZ'] = 'UTC' + env.update(env_override) impls = ['gpg2', 'gpg'] if self._impl is not None: @@ -230,5 +230,6 @@ disable-scdaemon return self._home def _spawn_gpg(self, options, stdin): - env = {'GNUPGHOME': self.home} - return super(OpenPGPEnvironment, self)._spawn_gpg(options, stdin, env) + env_override = {'GNUPGHOME': self.home} + return (super(OpenPGPEnvironment, self) + ._spawn_gpg(options, stdin, env_override)) -- cgit v1.2.3