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