From: Daan De Meyer Date: Tue, 2 Jul 2024 17:27:06 +0000 (+0200) Subject: Show proper error when using disk images as a tree without being root X-Git-Tag: v24~68 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=88f6873f9e76c77b30d0bc5ba30e406ca03ccb8e;p=thirdparty%2Fmkosi.git Show proper error when using disk images as a tree without being root Fixes #2818 --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index d1f9dda1d..fdfaa99be 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -2787,15 +2787,21 @@ def check_inputs(config: Config) -> None: if not base.exists(): die(f"Base tree {base} not found") + if base.suffix == ".raw" and os.getuid() != 0: + die("Must run as root to use disk images in base trees") + if config.tools_tree and not config.tools_tree.exists(): die(f"Tools tree {config.tools_tree} not found") - for name, trees in (("Skeleton", config.skeleton_trees), - ("Package manager", config.package_manager_trees), - ("Extra", config.extra_trees)): + for name, trees in (("skeleton", config.skeleton_trees), + ("package manager", config.package_manager_trees), + ("extra", config.extra_trees)): for tree in trees: if not tree.source.exists(): - die(f"{name} tree {tree.source} not found") + die(f"{name.capitalize()} tree {tree.source} not found") + + if tree.source.suffix == ".raw" and os.getuid() != 0: + die(f"Must run as root to use disk images in {name} trees") if config.bootable != ConfigFeature.disabled: for p in config.initrds: