diff --git a/manage.py b/manage.py index d61be1e1d6..1a2af68cd2 100755 --- a/manage.py +++ b/manage.py @@ -6,10 +6,10 @@ import types BASE_DIR = os.path.dirname(os.path.abspath(__file__)) sys.path.append(BASE_DIR) import scripts.lib.setup_path_on_import -from scripts.lib.zulip_tools import script_should_not_be_root +from scripts.lib.zulip_tools import assert_not_running_as_root if __name__ == "__main__": - script_should_not_be_root() + assert_not_running_as_root() if (os.access('/etc/zulip/zulip.conf', os.R_OK) and not os.access('/etc/zulip/zulip-secrets.conf', os.R_OK)): # The best way to detect running manage.py as another user in diff --git a/scripts/lib/upgrade-zulip b/scripts/lib/upgrade-zulip index 1c40495d18..b1e92bf10b 100755 --- a/scripts/lib/upgrade-zulip +++ b/scripts/lib/upgrade-zulip @@ -11,9 +11,9 @@ os.environ["PYTHONUNBUFFERED"] = "y" sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..')) from scripts.lib.zulip_tools import DEPLOYMENTS_DIR, FAIL, WARNING, ENDC, \ - su_to_zulip, get_deployment_lock, release_deployment_lock, script_should_be_root + su_to_zulip, get_deployment_lock, release_deployment_lock, assert_running_as_root -script_should_be_root(strip_lib_from_paths=True) +assert_running_as_root(strip_lib_from_paths=True) logging.Formatter.converter = time.gmtime logging.basicConfig(format="%(asctime)s upgrade-zulip: %(message)s", diff --git a/scripts/lib/upgrade-zulip-from-git b/scripts/lib/upgrade-zulip-from-git index 9904cf61d7..e208926d75 100755 --- a/scripts/lib/upgrade-zulip-from-git +++ b/scripts/lib/upgrade-zulip-from-git @@ -24,9 +24,9 @@ os.environ["PYTHONUNBUFFERED"] = "y" sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..')) from scripts.lib.zulip_tools import DEPLOYMENTS_DIR, FAIL, WARNING, ENDC, make_deploy_path, \ - get_deployment_lock, release_deployment_lock, su_to_zulip, script_should_be_root + get_deployment_lock, release_deployment_lock, su_to_zulip, assert_running_as_root -script_should_be_root(strip_lib_from_paths=True) +assert_running_as_root(strip_lib_from_paths=True) logging.Formatter.converter = time.gmtime logging.basicConfig(format="%(asctime)s upgrade-zulip-from-git: %(message)s", diff --git a/scripts/lib/upgrade-zulip-stage-2 b/scripts/lib/upgrade-zulip-stage-2 index 33e0e8c514..a7bd58ddda 100755 --- a/scripts/lib/upgrade-zulip-stage-2 +++ b/scripts/lib/upgrade-zulip-stage-2 @@ -20,9 +20,9 @@ os.environ["LANG"] = "en_US.UTF-8" os.environ["LANGUAGE"] = "en_US.UTF-8" sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..')) -from scripts.lib.zulip_tools import DEPLOYMENTS_DIR, FAIL, WARNING, ENDC, su_to_zulip, script_should_be_root +from scripts.lib.zulip_tools import DEPLOYMENTS_DIR, FAIL, WARNING, ENDC, su_to_zulip, assert_running_as_root -script_should_be_root() +assert_running_as_root() logging.Formatter.converter = time.gmtime logging.basicConfig(format="%(asctime)s upgrade-zulip-stage-2: %(message)s", diff --git a/scripts/lib/zulip_tools.py b/scripts/lib/zulip_tools.py index 75d4a7e089..02db7619b4 100755 --- a/scripts/lib/zulip_tools.py +++ b/scripts/lib/zulip_tools.py @@ -365,7 +365,7 @@ def is_root() -> bool: return True return False -def script_should_not_be_root() -> None: +def assert_not_running_as_root() -> None: script_name = os.path.abspath(sys.argv[0]) if is_root(): msg = ("{shortname} should not be run as root. Use `su zulip` to switch to the 'zulip'\n" @@ -376,7 +376,7 @@ def script_should_not_be_root() -> None: print(msg) sys.exit(1) -def script_should_be_root(strip_lib_from_paths: bool=False) -> None: +def assert_running_as_root(strip_lib_from_paths: bool=False) -> None: script_name = os.path.abspath(sys.argv[0]) # Since these Python scripts are run inside a thin shell wrapper, # we need to replace the paths in order to ensure we instruct diff --git a/scripts/zulip-puppet-apply b/scripts/zulip-puppet-apply index c9e875b26f..2116d8dbb2 100755 --- a/scripts/zulip-puppet-apply +++ b/scripts/zulip-puppet-apply @@ -5,9 +5,9 @@ import sys import subprocess import configparser import re -from lib.zulip_tools import parse_lsb_release, script_should_be_root +from lib.zulip_tools import parse_lsb_release, assert_running_as_root -script_should_be_root() +assert_running_as_root() force = False extra_args = sys.argv[1:]