X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=ud-generate;h=b7482a6fb3fd1b84a8bcc96e8cb2e583bc18cef7;hb=619506fcec54daf0af7a605c4dc6963031bdc9a6;hp=7ee1d2271e8d105cb8071b98fa705f7320c192f1;hpb=e0b19005ac3c2a0d6112f76af67e5de434ce5458;p=mirror%2Fuserdir-ldap.git diff --git a/ud-generate b/ud-generate index 7ee1d22..b7482a6 100755 --- a/ud-generate +++ b/ud-generate @@ -582,8 +582,7 @@ def GenMarkers(File): # Write out the position for each user for x in PasswdAttrs: a = UDLdap.Account(x[0], x[1]) - if not ('latitude' in a and 'longitude' in a): - continue + if not ('latitude' in a and 'longitude' in a): continue try: Line = "%8s %8s \"\""%(a.latitude_dec(True), a.longitude_dec(True)) Line = Sanitize(Line) + "\n" @@ -609,10 +608,8 @@ def GenPrivate(File): # Write out the position for each user for x in DebianDDUsers: a = UDLdap.Account(x[0], x[1]) - if not a.is_active_user(): - continue - if not 'privateSub' in a: - continue + if not a.is_active_user(): continue + if not 'privateSub' in a: continue try: Line = "%s"%(a['privateSub']) Line = Sanitize(Line) + "\n" @@ -639,8 +636,7 @@ def GenDisabledAccounts(File): I = 0 for x in PasswdAttrs: a = UDLdap.Account(x[0], x[1]) - if a.pw_active(): - continue + if a.pw_active(): continue Line = "%s:%s" % (a['uid'], "Account is locked") DisabledUsers.append(x) F.write(Sanitize(Line) + "\n") @@ -662,8 +658,7 @@ def GenMailDisable(File): for x in PasswdAttrs: a = UDLdap.Account(x[0], x[1]) - if not 'mailDisableMessage' in a: - continue + if not 'mailDisableMessage' in a: continue Line = "%s: %s"%(a['uid'], a['mailDisableMessage']) Line = Sanitize(Line) + "\n" F.write(Line) @@ -698,7 +693,7 @@ def GenMailBool(File, key): Done(File, F, None) # Generate a list of hosts for RBL or whitelist purposes. -def GenMailList(File, Key): +def GenMailList(File, key): F = None try: F = open(File + ".tmp", "w") @@ -706,37 +701,20 @@ def GenMailList(File, Key): # Fetch all the users global PasswdAttrs + if key == "mailWhitelist": validregex = re.compile('^[-\w.]+(/[\d]+)?$') + else: validregex = re.compile('^[-\w.]+$') + for x in PasswdAttrs: - Reason = None - - if x[1].has_key(Key) == 0: - continue - - try: - found = 0 - Line = None - for z in x[1][Key]: - if Key == "mailWhitelist": - if re.match('^[-\w.]+(/[\d]+)?$', z) == None: - continue - else: - if re.match('^[-\w.]+$', z) == None: - continue - if found == 0: - found = 1 - Line = GetAttr(x, "uid") - else: - Line += " " - Line += ": " + z - if Key == "mailRHSBL": - Line += "/$sender_address_domain" - - if Line != None: - Line = Sanitize(Line) + "\n" - F.write(Line) - except: - pass - + a = UDLdap.Account(x[0], x[1]) + if not key in a: continue + + filtered = filter(lambda z: validregex.match(z), a[key]) + if len(filtered) == 0: continue + if key == "mailRHSBL": filtered = map(lambda z: z+"/$sender_address_domain", filtered) + line = a['uid'] + ': ' + ' : '.join(filtered) + line = Sanitize(line) + "\n" + F.write(line) + # Oops, something unspeakable happened. except: Die(File, F, None)