mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Merge pull request #12050 from cachedout/11994
Set last-changed field in /etc/shadow on passwd change
This commit is contained in:
commit
a91ea9c5fb
@ -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_:
|
||||
|
Loading…
Reference in New Issue
Block a user