Skip to content

Commit

Permalink
Don't put /usr/bin and /usr/sbin in front of extra search paths in $PATH
Browse files Browse the repository at this point in the history
Currently extra search paths don't get used because we always add /usr/bin
and /usr/sbin earlier in $PATH.
  • Loading branch information
DaanDeMeyer committed Nov 4, 2024
1 parent af20716 commit c1766d1
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions mkosi/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,22 +565,22 @@ def sandbox_cmd(

home = None

cmdline += [
"--setenv",
"PATH",
":".join(
[
*(["/scripts"] if scripts else []),
"/usr/bin",
"/usr/sbin",
*(
[s for s in os.environ["PATH"].split(":") if home and s.startswith(os.fspath(home))]
if tools != Path("/")
else [os.environ["PATH"]]
),
]
),
]
path = []
if scripts:
path += ["/scripts"]
if tools != Path("/"):
path += [
s
for s in os.environ["PATH"].split(":")
if s in ("/usr/bin", "/usr/sbin") or (home and s.startswith(os.fspath(home)))
]

# Make sure that /usr/bin and /usr/sbin are always in $PATH.
path += [s for s in ("/usr/bin", "/usr/sbin") if s not in path]
else:
path += os.environ["PATH"].split(":")

cmdline += ["--setenv", "PATH", ":".join(path)]

if scripts:
cmdline += ["--ro-bind", scripts, "/scripts"]
Expand Down

0 comments on commit c1766d1

Please sign in to comment.