summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-06-21 23:17:14 +0200
committerChristian Breunig <christian@breunig.cc>2023-06-21 23:17:14 +0200
commit2128dc0ddf6b921f440067d7b862f30d9fad0cb2 (patch)
tree543ec7ce6f169abcf0df290bf20d7f25c0245acb
parent3f197566f957cb0e354a474bccee0aefd62b33be (diff)
downloadvyos-1x-2128dc0ddf6b921f440067d7b862f30d9fad0cb2.tar.gz
vyos-1x-2128dc0ddf6b921f440067d7b862f30d9fad0cb2.zip
tacacs: T141: support calling system-login.py from vyos-router startup script
-rwxr-xr-xsrc/conf_mode/system-login.py10
1 files changed, 7 insertions, 3 deletions
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()