X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=ud-generate;h=e2b335380efe966b0840eb63ecff7db326e72e0f;hb=89648b4805761b9df8de5c8f8ef000dc42cc5c4b;hp=f4f8b580bf841867469134c79195dc02efa96e4c;hpb=d1ad8523f8e88bf96d9c515da8c8c451a3089bea;p=mirror%2Fuserdir-ldap.git diff --git a/ud-generate b/ud-generate index f4f8b58..e2b3353 100755 --- a/ud-generate +++ b/ud-generate @@ -184,29 +184,30 @@ def GenPasswd(File, HomePrefix, PwdMarker): userlist = {} # Fetch all the users global PasswdAttrs - - I = 0 + + i = 0 for x in PasswdAttrs: - if x[1].has_key("uidNumber") == 0 or not IsInGroup(x): - continue - + a = UDLdap.Account(x[0], x[1]) + if not IsInGroup(x): continue + # Do not let people try to buffer overflow some busted passwd parser. - if len(GetAttr(x, "gecos")) > 100 or len(GetAttr(x, "loginShell")) > 50: - continue - - userlist[GetAttr(x, "uid")] = int(GetAttr(x, "gidNumber")) - Line = "%s:%s:%s:%s:%s:%s%s:%s" % (GetAttr(x, "uid"),\ - PwdMarker,\ - GetAttr(x, "uidNumber"), GetAttr(x, "gidNumber"),\ - GetAttr(x, "gecos"), HomePrefix, GetAttr(x, "uid"),\ - GetAttr(x, "loginShell")) - - Line = Sanitize(Line) + "\n" - F.write("0%u %s" % (I, Line)) - F.write(".%s %s" % (GetAttr(x, "uid"), Line)) - F.write("=%s %s" % (GetAttr(x, "uidNumber"), Line)) - I = I + 1 - + if len(a['gecos']) > 100 or len(a['loginShell']) > 50: continue + + userlist[a['uid']] = a['gidNumber'] + line = "%s:%s:%d:%d:%s:%s%s:%s" % ( + a['uid'], + PwdMarker, + a['uidNumber'], + a['gidNumber'], + a['gecos'], + HomePrefix, a['uid'], + a['loginShell']) + line = Sanitize(line) + "\n" + F.write("0%u %s" % (i, line)) + F.write(".%s %s" % (a['uid'], line)) + F.write("=%d %s" % (a['uidNumber'], line)) + i = i + 1 + # Oops, something unspeakable happened. except: Die(File, None, F)