From 289afa2fdc9cdd3d96fab846b3fe554455061769 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sun, 20 Oct 2024 11:23:28 +0200 Subject: [PATCH 1/2] Stop assuming PATH env is defined when extra_paths is set --- systemdspawner/systemdspawner.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/systemdspawner/systemdspawner.py b/systemdspawner/systemdspawner.py index 06b3c72..d232471 100644 --- a/systemdspawner/systemdspawner.py +++ b/systemdspawner/systemdspawner.py @@ -284,12 +284,11 @@ async def start(self): properties["PrivateDevices"] = "yes" if self.extra_paths: - env["PATH"] = "{extrapath}:{curpath}".format( - curpath=env["PATH"], - extrapath=":".join( - [self._expand_user_vars(p) for p in self.extra_paths] - ), - ) + new_path_list = [self._expand_user_vars(p) for p in self.extra_paths] + current_path = env.get("PATH") + if current_path: + new_path_list.append(current_path) + env["PATH"] = ":".join(new_path_list) env["SHELL"] = self.default_shell From fbddd8636d733df564172b76ea4a40fd9bbc60e8 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sun, 20 Oct 2024 14:20:22 +0200 Subject: [PATCH 2/2] Use os.defpath as default path if extra_path is used and PATH env is unset --- systemdspawner/systemdspawner.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/systemdspawner/systemdspawner.py b/systemdspawner/systemdspawner.py index d232471..e12491a 100644 --- a/systemdspawner/systemdspawner.py +++ b/systemdspawner/systemdspawner.py @@ -285,9 +285,9 @@ async def start(self): if self.extra_paths: new_path_list = [self._expand_user_vars(p) for p in self.extra_paths] - current_path = env.get("PATH") - if current_path: - new_path_list.append(current_path) + current_or_default_path = env.get("PATH", os.defpath) + if current_or_default_path: + new_path_list.append(current_or_default_path) env["PATH"] = ":".join(new_path_list) env["SHELL"] = self.default_shell