GenSSHShadow
authorPeter Palfrader <peter@palfrader.org>
Mon, 2 Aug 2010 21:31:04 +0000 (21:31 +0000)
committerPeter Palfrader <peter@palfrader.org>
Mon, 2 Aug 2010 21:31:04 +0000 (21:31 +0000)
UDLdap.py
ud-generate

index 6494c0d..f11c8b3 100644 (file)
--- a/UDLdap.py
+++ b/UDLdap.py
@@ -3,7 +3,7 @@ import time
 import userdir_ldap
 
 class Account:
-    array_values = ['keyFingerPrint', 'mailWhitelist', 'mailRBL', 'mailRHSBL', 'supplementaryGid']
+    array_values = ['keyFingerPrint', 'mailWhitelist', 'mailRBL', 'mailRHSBL', 'supplementaryGid', 'sshRSAAuthKey']
     int_values = ['shadowExpire', 'gidNumber']
     defaults = {
                  'accountStatus': 'active',
index 490376a..412e210 100755 (executable)
@@ -324,21 +324,17 @@ def GenSSHShadow():
    safe_makedirs(os.path.join(GlobalDir, 'userkeys'))
 
    for x in PasswdAttrs:
+      a = UDLdap.Account(x[0], x[1])
+      if not 'sshRSAAuthKey' in a: continue
 
-      if x[1].has_key("uidNumber") == 0 or \
-         x[1].has_key("sshRSAAuthKey") == 0:
-         continue
-
-      User = GetAttr(x, "uid")
       F = None
-
       try:
          OldMask = os.umask(0077)
-         File = os.path.join(GlobalDir, 'userkeys', User)
+         File = os.path.join(GlobalDir, 'userkeys', a['uid'])
          F = open(File + ".tmp", "w", 0600)
          os.umask(OldMask)
 
-         for I in x[1]["sshRSAAuthKey"]:
+         for I in a['sshRSAAuthKey']:
             MultipleLine = "%s" % I
             MultipleLine = Sanitize(MultipleLine) + "\n"
             F.write(MultipleLine)