Implement password aging info for all BSDs.

This commit is contained in:
Antoine Jacoutot 2014-08-27 09:43:11 +02:00
parent c40cdcf803
commit 0049a64d7a

View File

@ -50,10 +50,14 @@ def info(name):
'name': '',
'passwd': ''}
# Get password aging info on FreeBSD
# TODO: Implement this for NetBSD, OpenBSD
cmd = ""
if __salt__['cmd.has_exec']('pw'):
cmd = 'pw user show {0} | cut -f6,7 -d:'.format(name)
cmd = 'pw user show {0}'.format(name)
elif __grains__['kernel'] in ('NetBSD', 'OpenBSD'):
cmd = 'grep "^{0}:" /etc/master.passwd'.format(name)
if cmd:
cmd += '| cut -f6,7 -d:'
try:
change, expire = __salt__['cmd.run_all'](cmd)['stdout'].split(':')
except ValueError: