Skip to content

Commit

Permalink
Don't remount /usr read-only if the output dir is inside of it
Browse files Browse the repository at this point in the history
Because some build systems use output directories in /usr, let's only remount
/usr read-only if the output directory is not relative to it.
  • Loading branch information
DaanDeMeyer authored and bluca committed Mar 12, 2024
1 parent 725de0b commit 43aaa3e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion mkosi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3975,7 +3975,13 @@ def run_build(args: Args, config: Config, *, resources: Path) -> None:
run(["mount", "--make-rslave", "/"])

# For extra safety when running as root, remount a bunch of stuff read-only.
for d in ("/usr", "/etc", "/opt", "/boot", "/efi", "/media"):
# Because some build systems use output directories in /usr, we only remount
# /usr read-only if the output directory is not relative to it.
remount = ["/etc", "/opt", "/boot", "/efi", "/media"]
if not config.output_dir_or_cwd().is_relative_to("/usr"):
remount += ["/usr"]

for d in remount:
if Path(d).exists():
run(["mount", "--rbind", d, d, "--options", "ro"])

Expand Down

0 comments on commit 43aaa3e

Please sign in to comment.