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