From 1b8a5e9eecde6d5b715cd61a90145793fb9c98d0 Mon Sep 17 00:00:00 2001 From: Carl Date: Wed, 16 Oct 2019 18:56:24 +1000 Subject: [PATCH] Check if root after processing args Allows for the `-h/--help` argument to be used without needing to elevate privileges. --- installinstallmacos.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/installinstallmacos.py b/installinstallmacos.py index 8888068..693af33 100755 --- a/installinstallmacos.py +++ b/installinstallmacos.py @@ -459,10 +459,6 @@ def find_installer_app(mountpoint): def main(): '''Do the main thing here''' - if os.getuid() != 0: - sys.exit('This command requires root (to install packages), so please ' - 'run again with sudo or as root.') - parser = argparse.ArgumentParser() parser.add_argument('--seedprogram', default='', help='Which Seed Program catalog to use. Valid values ' @@ -488,6 +484,10 @@ def main(): help='Ignore any previously cached files.') args = parser.parse_args() + if os.getuid() != 0: + sys.exit('This command requires root (to install packages), so please ' + 'run again with sudo or as root.') + if args.catalogurl: su_catalog_url = args.catalogurl elif args.seedprogram: