Skip to content

Commit

Permalink
Keep more entries from $PATH in the sandbox
Browse files Browse the repository at this point in the history
In the relaxed sandbox, we want to run executables frome everywhere
that isn't /usr. We make the implicit assumption that anything from
outside /usr doesn't depend (heavily) on what's in /usr and if it does
and a tools tree is used it should match the host sufficiently.
  • Loading branch information
DaanDeMeyer committed Jan 3, 2025
1 parent 0594682 commit a87b945
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mkosi/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,14 +614,18 @@ def sandbox_cmd(

home = None

# We leak most of the $PATH from the host into the non-relaxed sandbox as well but this shouldn't be a
# problem in practice as the directories themselves won't be in the sandbox and so we shouldn't
# accidentally pick up anything from them.

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)))
if s in ("/usr/bin", "/usr/sbin") or not s.startswith("/usr")
]

# Make sure that /usr/bin and /usr/sbin are always in $PATH.
Expand Down

0 comments on commit a87b945

Please sign in to comment.