X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=ud-generate;h=18c008b61284032ec892a811822899c83b777a1c;hb=268b4bb0d628223d7bb04a501d651d7d4bd7cb12;hp=b8e3d747d9999624ef8d302902649e89053fb254;hpb=5e6055914f08d834f63ea7c5f16a1faa78f63012;p=mirror%2Fuserdir-ldap.git diff --git a/ud-generate b/ud-generate index b8e3d74..18c008b 100755 --- a/ud-generate +++ b/ud-generate @@ -36,7 +36,6 @@ global CurrentHost PasswdAttrs = None DisabledUsers = [] -RetiredUsers = [] GroupIDMap = {} SubGroupMap = {} Allowed = None @@ -108,6 +107,12 @@ def IsRetired(DnRecord): return False +def IsGidDebian(x): + try: + return int(GetAttr(x, "gidNumber", 0)) == 800 + except ValueError: + return False + # See if this user is in the group list def IsInGroup(DnRecord): if Allowed == None: @@ -461,8 +466,8 @@ def GenGroup(File): return grouprevmap def CheckForward(): - global PasswdAttrs - for x in PasswdAttrs: + global DebianUsers + for x in DebianUsers: if x[1].has_key("emailForward") == 0: continue @@ -488,10 +493,10 @@ def GenForward(File): os.umask(OldMask) # Fetch all the users - global PasswdAttrs + global DebianUsers # Write out the email address for each user - for x in PasswdAttrs: + for x in DebianUsers: if x[1].has_key("emailForward") == 0: continue @@ -513,10 +518,10 @@ def GenAllForward(File): os.umask(OldMask) # Fetch all the users - global PasswdAttrs + global DebianUsers # Write out the email address for each user - for x in PasswdAttrs: + for x in DebianUsers: if x[1].has_key("emailForward") == 0: continue @@ -541,10 +546,10 @@ def GenMarkers(File): F = open(File + ".tmp", "w") # Fetch all the users - global PasswdAttrs + global DebianUsers # Write out the position for each user - for x in PasswdAttrs: + for x in DebianUsers: if x[1].has_key("latitude") == 0 or x[1].has_key("longitude") == 0: continue try: @@ -567,10 +572,10 @@ def GenPrivate(File): F = open(File + ".tmp", "w") # Fetch all the users - global PasswdAttrs + global DebianUsers # Write out the position for each user - for x in PasswdAttrs: + for x in DebianUsers: if x[1].has_key("privateSub") == 0: continue @@ -578,10 +583,6 @@ def GenPrivate(File): if x[1].has_key("keyFingerPrint") == 0: continue - # Must be in the Debian group (yuk, hard coded for now) - if GetAttr(x, "gidNumber") != "800": - continue - try: Line = "%s"%(GetAttr(x, "privateSub")) Line = Sanitize(Line) + "\n" @@ -636,9 +637,9 @@ def GenMailDisable(File): F = open(File + ".tmp", "w") # Fetch all the users - global PasswdAttrs + global DebianUsers - for x in PasswdAttrs: + for x in DebianUsers: Reason = None if x[1].has_key("mailDisableMessage"): @@ -646,10 +647,6 @@ def GenMailDisable(File): else: continue - # Must be in the Debian group (yuk, hard coded for now) - if GetAttr(x, "gidNumber") != "800": - continue - try: Line = "%s: %s"%(GetAttr(x, "uid"), Reason) Line = Sanitize(Line) + "\n" @@ -670,18 +667,14 @@ def GenMailBool(File, Key): F = open(File + ".tmp", "w") # Fetch all the users - global PasswdAttrs + global DebianUsers - for x in PasswdAttrs: + for x in DebianUsers: Reason = None if x[1].has_key(Key) == 0: continue - # Must be in the Debian group (yuk, hard coded for now) - if GetAttr(x, "gidNumber") != "800": - continue - if GetAttr(x, Key) != "TRUE": continue @@ -705,18 +698,14 @@ def GenMailList(File, Key): F = open(File + ".tmp", "w") # Fetch all the users - global PasswdAttrs + global DebianUsers - for x in PasswdAttrs: + for x in DebianUsers: Reason = None if x[1].has_key(Key) == 0: continue - # Must be in the Debian group (yuk, hard coded for now) - if GetAttr(x, "gidNumber") != "800": - continue - try: found = 0 Line = None @@ -853,10 +842,10 @@ def GenBSMTP(File, HomePrefix): F = open(File + ".tmp", "w") # Fetch all the users - global PasswdAttrs + global DebianUsers # Write out the zone file entry for each user - for x in PasswdAttrs: + for x in DebianUsers: if x[1].has_key("dnsZoneEntry") == 0: continue @@ -1056,11 +1045,8 @@ else: GlobalDir = GenerateDir + "/" GenDisabledAccounts(GlobalDir + "disabled-accounts") -for x in PasswdAttrs: - if IsRetired(x): - RetiredUsers.append(x) - -PasswdAttrs = filter(lambda x: not x in RetiredUsers, PasswdAttrs) +PasswdAttrs = filter(not IsRetired, PasswdAttrs) +DebianUsers = filter(IsGidDebian, PasswdAttrs) CheckForward()