diff --git a/pmb/__init__.py b/pmb/__init__.py index 10469050..29f11c61 100644 --- a/pmb/__init__.py +++ b/pmb/__init__.py @@ -57,7 +57,7 @@ def print_log_hint() -> None: print(log_hint) -def main(*, original_uid: int) -> int: +def main() -> int: # Wrap everything to display nice error messages args: PmbArgs @@ -72,8 +72,6 @@ def main(*, original_uid: int) -> int: # Sanity checks other.check_grsec() - if not args.as_root and original_uid == 0: - raise RuntimeError("Do not run pmbootstrap as root!") # Check for required programs (and find their absolute paths) require_programs() diff --git a/pmbootstrap.py b/pmbootstrap.py index 3208d9b8..ead78714 100755 --- a/pmbootstrap.py +++ b/pmbootstrap.py @@ -11,7 +11,8 @@ from pmb.init import sandbox # Sanitise environment a bit os.environ["SHELL"] = "/bin/sh" if os.path.exists("/bin/sh") else "/bin/bash" -original_uid = os.geteuid() +if os.geteuid() == 0: + raise RuntimeError("pmbootstrap can't be run as root, please run it as a regular user.") sandbox.acquire_privileges(become_root=False) # Unshare mount and PID namespaces. We create a new PID namespace so @@ -64,4 +65,4 @@ os.chdir(os.environ["PWD"]) # A convenience wrapper for running pmbootstrap from the git repository. This # script is not part of the python packaging, so don't add more logic here! if __name__ == "__main__": - sys.exit(pmb.main(original_uid=original_uid)) + sys.exit(pmb.main())