From 2128dc0ddf6b921f440067d7b862f30d9fad0cb2 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Wed, 21 Jun 2023 23:17:14 +0200 Subject: tacacs: T141: support calling system-login.py from vyos-router startup script --- src/conf_mode/system-login.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/conf_mode') diff --git a/src/conf_mode/system-login.py b/src/conf_mode/system-login.py index fbb013cf3..aefab8401 100755 --- a/src/conf_mode/system-login.py +++ b/src/conf_mode/system-login.py @@ -107,9 +107,13 @@ def get_config(config=None): def verify(login): if 'rm_users' in login: - cur_user = os.environ['SUDO_USER'] - if cur_user in login['rm_users']: - raise ConfigError(f'Attempting to delete current user: {cur_user}') + # This check is required as the script is also executed from vyos-router + # init script and there is no SUDO_USER environment variable available + # during system boot. + if 'SUDO_USER' in os.environ: + cur_user = os.environ['SUDO_USER'] + if cur_user in login['rm_users']: + raise ConfigError(f'Attempting to delete current user: {cur_user}') if 'user' in login: system_users = getpwall() -- cgit v1.2.3