diff options
| author | Christian Breunig <christian@breunig.cc> | 2025-12-09 23:15:39 +0100 |
|---|---|---|
| committer | Christian Breunig <christian@breunig.cc> | 2025-12-17 21:27:25 +0100 |
| commit | 197809bf77d841fe57bdcbaeeb3b078145aab140 (patch) | |
| tree | 6e044b10e3fa1648de2b6e8c6a3838da8e4dfa0d /python | |
| parent | 5566e6035b42e99eb874c3c5a35fe72e8435df38 (diff) | |
| download | vyos-1x-197809bf77d841fe57bdcbaeeb3b078145aab140.tar.gz vyos-1x-197809bf77d841fe57bdcbaeeb3b078145aab140.zip | |
login: T8086: replace getpwnam()/getpwuid() with get_local_passwd_entries()
Switch to our custom implementation to avoid NSS/TACACS timeouts as explained
in commit 4c9eaaa96e06 ("login: replace getpwall() user enumeration to avoid
NSS/TACACS timeouts").
Diffstat (limited to 'python')
| -rw-r--r-- | python/vyos/utils/auth.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/python/vyos/utils/auth.py b/python/vyos/utils/auth.py index 4aa446455..f9551419f 100644 --- a/python/vyos/utils/auth.py +++ b/python/vyos/utils/auth.py @@ -20,7 +20,6 @@ import string from dataclasses import dataclass from decimal import Decimal -from pwd import getpwnam from enum import StrEnum from typing import List from typing import Optional @@ -215,7 +214,9 @@ def get_local_users(min_uid=MIN_USER_UID, max_uid=MAX_USER_UID) -> list: return local_users - def get_user_home_dir(user: str) -> str: """Return user's home directory""" - return getpwnam(user).pw_dir + for u in get_local_passwd_entries(): + if u.pw_name == user: + return u.pw_dir + raise KeyError(f"User '{user}' not found in /etc/passwd") |
