diff --git a/subiquitycore/tests/test_utils.py b/subiquitycore/tests/test_utils.py index 686c962b..108ce6fb 100644 --- a/subiquitycore/tests/test_utils.py +++ b/subiquitycore/tests/test_utils.py @@ -40,10 +40,16 @@ class TestOrigEnviron(SubiTestCase): expected = {} self.assertEqual(expected, orig_environ(env)) + def test_no_ld_library_path(self): + env = {'LD_LIBRARY_PATH': 'a'} + expected = {} + self.assertEqual(expected, orig_environ(env)) + def test_practical(self): snap = '/snap/subiquity/1234' env = { 'TERM': 'linux', + 'LD_LIBRARY_PATH': '/var/lib/snapd/lib/gl', 'PYTHONIOENCODING_ORIG': '', 'PYTHONIOENCODING': 'utf-8', 'SUBIQUITY_ROOT_ORIG': '', diff --git a/subiquitycore/utils.py b/subiquitycore/utils.py index 415131cc..40307c81 100644 --- a/subiquitycore/utils.py +++ b/subiquitycore/utils.py @@ -36,6 +36,8 @@ def _clean_env(env, *, locale=True): def orig_environ(env): + """Generate an environment dict that is suitable for use for running + programs that live outside the snap.""" if env is None: env = os.environ ret = env.copy() @@ -47,6 +49,7 @@ def orig_environ(env): else: del ret[key_to_restore] del ret[key] + ret.pop('LD_LIBRARY_PATH', None) return ret