Normalize the 'pwd' field in shadow.info output

This makes this field match the corresponding field in user.info.
This commit is contained in:
Erik Johnson 2013-06-26 00:27:39 -05:00
parent 7681dc4a6a
commit 62391367df

View File

@ -1,5 +1,5 @@
'''
Manage the shadow file
Manage the password database on Solaris systems
'''
# Import python libs
@ -20,7 +20,7 @@ def __virtual__():
'''
Only work on POSIX-like systems
'''
return 'shadow' if __grains__['kernel'] == 'SunOS' else False
return 'shadow' if __grains__.get('kernel', '') == 'SunOS' else False
def info(name):
@ -36,7 +36,7 @@ def info(name):
data = spwd.getspnam(name)
ret = {
'name': data.sp_nam,
'pwd': data.sp_pwd,
'passwd': data.sp_pwd if data.sp_pwd != '!' else '',
'lstchg': data.sp_lstchg,
'min': data.sp_min,
'max': data.sp_max,
@ -46,7 +46,7 @@ def info(name):
except KeyError:
ret = {
'name': '',
'pwd': '',
'passwd': '',
'lstchg': '',
'min': '',
'max': '',
@ -59,7 +59,7 @@ def info(name):
# Return what we can know
ret = {
'name': '',
'pwd': '',
'passwd': '',
'lstchg': '',
'min': '',
'max': '',
@ -71,7 +71,7 @@ def info(name):
data = pwd.getpwnam(name)
ret.update({
'name': name,
'pwd': data.pw_dir
'passwd': data.pw_dir
})
except KeyError:
return ret
@ -104,7 +104,7 @@ def info(name):
# buildbot L 05/09/2013 0 99999 7
ret.update({
'name': data.pw_name,
'pwd': data.pw_dir,
'passwd': data.pw_dir,
'lstchg': fields[2],
'min': int(fields[3]),
'max': int(fields[4]),
@ -180,7 +180,7 @@ def set_password(name, password):
with salt.utils.fopen(s_file, 'w+') as ofile:
ofile.writelines(lines)
uinfo = info(name)
return uinfo['pwd'] == password
return uinfo['passwd'] == password
def set_warndays(name, warndays):