[debian-edu-commits] debian-edu/upstream/ 23/71: Calculate time for last pw change dynamically. Get test code working.

Petter Reinholdtsen pere at moszumanska.debian.org
Mon Jun 9 18:25:36 UTC 2014


This is an automated email from the git hooks/post-receive script.

pere pushed a commit to branch master
in repository libpam-mklocaluser.

commit b052790edc21c086b7153f8d1d6066be0126a876
Author: Petter Reinholdtsen <pere at hungry.com>
Date:   Mon May 3 13:20:24 2010 +0000

    Calculate time for last pw change dynamically.  Get test code working.
---
 debian/pam-python.py | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/debian/pam-python.py b/debian/pam-python.py
index 81f6046..d97dc1c 100755
--- a/debian/pam-python.py
+++ b/debian/pam-python.py
@@ -11,6 +11,8 @@ import pwd
 import grp
 import subprocess
 import shutil
+import math
+import time
 
 def runcmd(pamh, cmd):
   proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,)
@@ -30,6 +32,13 @@ def check_and_create_localuser(pamh, user):
   # File mode of new home directory
   dirmode = 0700
 
+  # Last password change, use today
+  pwlastchange = math.floor(time.time() / (60 * 60 * 24 ))
+
+  pwminage = 0
+  pwmaxage = 99999
+  pwwarn = 7
+
   # Fetch current user and group info, possibly from LDAP or NIS.
   userinfo = pwd.getpwnam(user)
   uid = userinfo[2]
@@ -66,7 +75,7 @@ def check_and_create_localuser(pamh, user):
       # Add shadow entry too.
       # XXX Should only add it if it is missing
       cmd = "/bin/echo '%s:x:%d:%d:%d:%d:::' >> /etc/shadow" \
-            % (user, 14730, 0, 99999, 7)
+            % (user, pwlastchange, pwminage, pwmaxage, pwwarn)
       runcmd(pamh, cmd)
 
       # Copy content of /etc/skel
@@ -146,6 +155,11 @@ if __name__ == '__main__':
     PAM_USER_UNKNOWN = 2
     PAM_SYSTEM_ERR = 3
     PAM_TRY_AGAIN = 4
+    PAM_TEXT_INFO = 5
+    def Message(tag, str):
+      return
+    def conversation(msg):
+      return
   pamh = pam_handler()
   user = sys.argv[1]
   check_and_create_localuser(pamh, user)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-edu/upstream/libpam-mklocaluser.git



More information about the debian-edu-commits mailing list