From 5ea1f6a819ffe96937fe357f223e1fa2bcb3178f Mon Sep 17 00:00:00 2001 From: Mike Place Date: Wed, 16 Apr 2014 14:46:38 -0600 Subject: [PATCH] Set last-changed field in /etc/shadow on passwd change --- salt/modules/shadow.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/salt/modules/shadow.py b/salt/modules/shadow.py index 44c94f7a8e..3a52c63784 100644 --- a/salt/modules/shadow.py +++ b/salt/modules/shadow.py @@ -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_: