From 197809bf77d841fe57bdcbaeeb3b078145aab140 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Tue, 9 Dec 2025 23:15:39 +0100 Subject: 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"). --- python/vyos/utils/auth.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'python') 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") -- cgit v1.2.3