global PasswdAttrs
for x in PasswdAttrs:
+ a = UDLdap.Account(x[0], x[1])
Pass = '*'
- if x[1].has_key("uidNumber") == 0 or not IsInGroup(x):
- continue
+ if not IsInGroup(x): continue
- if x[1].has_key('sudoPassword'):
- for entry in x[1]['sudoPassword']:
+ if 'sudoPassword' in a:
+ for entry in a['sudoPassword']:
Match = re.compile('^('+UUID_FORMAT+') (confirmed:[0-9a-f]{40}|unconfirmed) ([a-z0-9.,*]+) ([^ ]+)$').match(entry)
if Match == None:
continue
hosts = Match.group(3)
cryptedpass = Match.group(4)
- if status != 'confirmed:'+make_passwd_hmac('password-is-confirmed', 'sudo', x[1]['uid'][0], uuid, hosts, cryptedpass):
+ if status != 'confirmed:'+make_passwd_hmac('password-is-confirmed', 'sudo', a['uid'], uuid, hosts, cryptedpass):
continue
for_all = hosts == "*"
for_this_host = CurrentHost in hosts.split(',')
if len(Pass) > 50:
Pass = '*'
- Line = "%s:%s" % (GetAttr(x, "uid"), Pass)
+ Line = "%s:%s" % (a['uid'], Pass)
Line = Sanitize(Line) + "\n"
F.write("%s" % (Line))
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)
# Sort them into a list of groups having a set of users
for x in PasswdAttrs:
- uid = GetAttr(x, "uid")
- if 'gidNumber' in x[1]:
- GroupHasPrimaryMembers[ int(x[1]["gidNumber"][0]) ] = True
- if x[1].has_key("uidNumber") == 0 or not IsInGroup(x):
- continue
- if x[1].has_key("supplementaryGid") == 0:
- continue
-
+ a = UDLdap.Account(x[0], x[1])
+ GroupHasPrimaryMembers[ a['gidNumber'] ] = True
+ if not IsInGroup(x): continue
+ if not 'supplementaryGid' in a: continue
+
supgroups=[]
- addGroups(supgroups, x[1]["supplementaryGid"], uid)
+ addGroups(supgroups, a['supplementaryGid'], a['uid'])
for g in supgroups:
- GroupMap[g].append(uid)
-
+ GroupMap[g].append(a['uid'])
+
# Output the group file.
J = 0
for x in GroupMap.keys():
# Write out the email address for each user
for x in PasswdAttrs:
- if x[1].has_key("emailForward") == 0:
- continue
-
- Line = "%s: %s" % (GetAttr(x, "uid"), GetAttr(x, "emailForward"))
+ a = UDLdap.Account(x[0], x[1])
+ if not 'emailForward' in a: continue
+ Line = "%s: %s" % (a['uid'], a['emailForward'])
Line = Sanitize(Line) + "\n"
F.write(Line)