mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
check for pwd on linux and BSD user exec mods
This commit is contained in:
parent
679dc089c0
commit
26f5b466f5
2 changed files with 8 additions and 5 deletions
|
@ -6,8 +6,9 @@ Manage users with the useradd command
|
|||
# Import python libs
|
||||
try:
|
||||
import pwd
|
||||
HAS_PWD = True
|
||||
except ImportError:
|
||||
pass
|
||||
HAS_PWD = False
|
||||
import logging
|
||||
import copy
|
||||
|
||||
|
@ -26,7 +27,9 @@ def __virtual__():
|
|||
'''
|
||||
Set the user module if the kernel is FreeBSD
|
||||
'''
|
||||
return __virtualname__ if __grains__['kernel'] == 'FreeBSD' else False
|
||||
if HAS_PWD and __grains__['kernel'] == 'FreeBSD':
|
||||
return __virtualname__
|
||||
return False
|
||||
|
||||
|
||||
def _get_gecos(name):
|
||||
|
|
|
@ -9,8 +9,9 @@ import re
|
|||
|
||||
try:
|
||||
import pwd
|
||||
HAS_PWD = True
|
||||
except ImportError:
|
||||
pass
|
||||
HAS_PWD = False
|
||||
import logging
|
||||
import copy
|
||||
|
||||
|
@ -32,10 +33,9 @@ __virtualname__ = 'user'
|
|||
def __virtual__():
|
||||
'''
|
||||
Set the user module if the kernel is Linux, OpenBSD or NetBSD
|
||||
and remove some of the functionality on OS X
|
||||
'''
|
||||
|
||||
if __grains__['kernel'] in ('Linux', 'OpenBSD', 'NetBSD'):
|
||||
if HAS_PWD and __grains__['kernel'] in ('Linux', 'OpenBSD', 'NetBSD'):
|
||||
return __virtualname__
|
||||
return False
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue