1
0
mirror of https://github.com/altlinux/gpupdate.git synced 2025-03-21 18:50:38 +03:00

Added function to check if a local user exist

This commit is contained in:
Valery Sinelnikov 2025-02-28 15:22:10 +04:00
parent 5c47ebb6c5
commit ab632a8177

View File

@ -243,3 +243,14 @@ def clean_data(data):
return cleaned_string
except:
return None
def check_local_user_exists(username):
"""
Checks if a local user with the given username exists on a Linux system.
"""
try:
# Try to get user information from the password database
pwd.getpwnam(username)
return True
except:
return False