From b9a9cd04a1520ab696dd72ddd5609f8097b72e36 Mon Sep 17 00:00:00 2001 From: Matthias Klumpp Date: Sun, 24 Sep 2023 20:46:28 +0200 Subject: [PATCH] admin: Add some basic protection against running the CLI as root --- src/lkadmin/cli.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lkadmin/cli.py b/src/lkadmin/cli.py index c0f3cc3b..8234a085 100644 --- a/src/lkadmin/cli.py +++ b/src/lkadmin/cli.py @@ -85,7 +85,7 @@ def _register_commands(): def run(mainfile, args): from rich.traceback import install - from laniakea.utils import set_process_title + from laniakea.utils.misc import set_process_title, ensure_laniakea_master_user set_process_title('lk-admin') if len(args) == 0: @@ -95,6 +95,9 @@ def run(mainfile, args): global __mainfile __mainfile = mainfile + # some safeguarding against running as root or any other "wrong" user + ensure_laniakea_master_user(warn_only=True) + install(show_locals=True, suppress=[click]) _register_commands() cli() # pylint: disable=no-value-for-parameter