if config.runtime_network == Network.user:
cmdline += ["--resolv-conf=auto"]
elif config.runtime_network == Network.interface:
- if os.getuid() != 0:
- die("RuntimeNetwork=interface requires root privileges")
-
cmdline += ["--private-network", "--network-veth"]
elif config.runtime_network == Network.none:
cmdline += ["--private-network"]
stdout=sys.stdout,
env=os.environ | config.environment,
log=False,
- sandbox=config.sandbox(binary="systemd-nspawn", devices=True, network=True, relaxed=True),
+ sandbox=config.sandbox(
+ binary="systemd-nspawn",
+ devices=True,
+ network=True,
+ relaxed=True,
+ setup=["run0"] if os.getuid() != 0 else [],
+ ),
)
and not config.forward_journal
and os.getuid() != 0
):
- die(f"Must be root to run the {args.verb} command")
+ need_root = True
+ else:
+ need_root = False
if (tool_path := config.find_binary(tool)) is None:
die(f"Failed to find {tool}")
network=True,
devices=config.output_format == OutputFormat.disk,
relaxed=True,
+ setup=["run0"] if need_root else [],
),
)
def run_verb(args: Args, images: Sequence[Config], *, resources: Path) -> None:
images = list(images)
- if args.verb.needs_root() and os.getuid() != 0:
- die(f"Must be root to run the {args.verb} command")
-
if args.verb == Verb.completion:
return print_completion(args, resources=resources)
if len(args.cmdline) != 1:
die("Expected device argument.")
- device = args.cmdline[0]
-
cmd = [
"systemd-repart",
"--no-pager",
"--dry-run=no",
"--definitions=/",
f"--copy-from={fname}",
- device,
+ *args.cmdline,
]
with complete_step("Burning 🔥🔥🔥 to medium…", "Burnt. 🔥🔥🔥"):
stdout=sys.stdout,
env=os.environ | config.environment,
log=False,
- sandbox=config.sandbox(binary="systemd-repart", devices=True, network=True, relaxed=True),
+ sandbox=config.sandbox(
+ binary="systemd-repart",
+ devices=True,
+ network=True,
+ relaxed=True,
+ setup=["run0"] if os.getuid() != 0 else [],
+ ),
)
devices=True,
network=True,
relaxed=True,
+ setup=["run0"] if os.getuid() != 0 else [],
options=[
*(["--bind", "/boot", "/boot"] if Path("/boot").exists() else []),
*(["--bind", "/efi", "/efi"] if Path("/efi").exists() else []),