Set last-changed field in /etc/shadow on passwd change

This commit is contained in:
Mike Place 2014-04-16 14:46:38 -06:00
parent c30981e8d2
commit 5ea1f6a819

View File

@ -5,6 +5,7 @@ Manage the shadow file
# Import python libs
import os
import datetime
try:
import spwd
except ImportError:
@ -166,7 +167,9 @@ def set_password(name, password, use_usermod=False):
if comps[0] != name:
lines.append(line)
continue
changed_date = datetime.datetime.today() - datetime.datetime(1970, 1, 1)
comps[1] = password
comps[2] = str(changed_date.days)
line = ':'.join(comps)
lines.append('{0}\n'.format(line))
with salt.utils.fopen(s_file, 'w+') as fp_: