diff --git a/letsencrypt/scripts/main.py b/letsencrypt/scripts/main.py index 0fd3f99c8..24569ac87 100755 --- a/letsencrypt/scripts/main.py +++ b/letsencrypt/scripts/main.py @@ -19,11 +19,6 @@ from letsencrypt.client.apache import configurator def main(): # pylint: disable=too-many-statements """Command line argument parsing and main script execution.""" - if not os.geteuid() == 0: - sys.exit( - "{0}Root is required to run letsencrypt. Please use sudo.{0}" - .format(os.linesep)) - parser = argparse.ArgumentParser( description="An ACME client that can update Apache configurations.") @@ -63,8 +58,15 @@ def main(): # pylint: disable=too-many-statements parser.add_argument("--test", dest="test", action="store_true", help="Run in test mode.") + # note: arg parser internally handles --help (and exits afterwards) args = parser.parse_args() + # note: check is done after arg parsing as --help should work w/o root also. + if not os.geteuid() == 0: + sys.exit( + "{0}Root is required to run letsencrypt. Please use sudo.{0}" + .format(os.linesep)) + # Set up logging logger = logging.getLogger() logger.setLevel(logging.INFO)