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:
parent
5c47ebb6c5
commit
ab632a8177
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user