X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;ds=inline;f=ud-generate;h=f1ed0b06313f89aa670ead1a0ba147d15257b391;hb=f484d1c2a8a3fafdee28bf346b350084be710b91;hp=5f2a4820631e5881e6a876686ae94b51c76297ce;hpb=34c5d26cd16f3e10dc9a6275068e9dc74e35c8c4;p=mirror%2Fuserdir-ldap.git diff --git a/ud-generate b/ud-generate index 5f2a482..f1ed0b0 100755 --- a/ud-generate +++ b/ud-generate @@ -10,6 +10,7 @@ # Copyright (c) 2008 Andreas Barth # Copyright (c) 2008 Mark Hymers # Copyright (c) 2008 Luk Claes +# Copyright (c) 2008 Thomas Viehmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -41,6 +42,7 @@ UUID_FORMAT = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}' EmailCheck = re.compile("^([^ <>@]+@[^ ,<>@]+)?$"); BSMTPCheck = re.compile(".*mx 0 (gluck)\.debian\.org\..*",re.DOTALL); +PurposeHostField = re.compile(r"\[\[([\*\-]?[a-z0-9.\-]*)(?:\|.*)?\]\]") DNSZone = ".debian.net" Keyrings = ConfModule.sync_keyrings.split(":") @@ -89,13 +91,10 @@ def IsInGroup(DnRecord): if DnRecord[1].has_key("supplementaryGid") == 0: return 0; - # Check the supplementary groups - for I in DnRecord[1]["supplementaryGid"]: - s = I.split('@', 1) - group = s[0] - if len(s) == 2 and s[1] != CurrentHost: - continue; - if Allowed.has_key(group): + supgroups=[] + addGroups(supgroups, DnRecord[1]["supplementaryGid"], GetAttr(DnRecord,"uid")) + for g in supgroups: + if Allowed.has_key(g): return 1; return 0; @@ -374,13 +373,13 @@ def addGroups(existingGroups, newGroups, uid): continue if not GroupIDMap.has_key(group): - print "Group does not exist ",group,"but",uid,"is in it" + print "Group", group, "does not exist but", uid, "is in it" continue existingGroups.append(group) if SubGroupMap.has_key(group): - addGroups(existingGroups, SubGroupMap[group]) + addGroups(existingGroups, SubGroupMap[group], uid) # Generate the group list def GenGroup(l,File): @@ -905,8 +904,27 @@ def GenSSHKnown(l,File,mode=None): continue; Host = GetAttr(x,"hostname"); HostNames = [ Host ] - SHost = Host.find(".") - if SHost != None: HostNames += [Host[0:SHost]] + if Host.endswith(HostDomain): + HostNames.append(Host[:-(len(HostDomain)+1)]) + + # in the purpose field [[host|some other text]] (where some other text is optional) + # makes a hyperlink on the web thing. we now also add these hosts to the ssh known_hosts + # file. But so that we don't have to add everything we link we can add an asterisk + # and say [[*... to ignore it. In order to be able to add stuff to ssh without + # http linking it we also support [[-hostname]] entries. + for i in x[1].get("purpose",[]): + m = PurposeHostField.match(i) + if m: + m = m.group(1) + # we ignore [[*..]] entries + if m.startswith('*'): + continue; + if m.startswith('-'): + m = m[1:] + if m: + HostNames.append(m) + if m.endswith(HostDomain): + HostNames.append(m[:-(len(HostDomain)+1)]) for I in x[1]["sshRSAHostKey"]: if mode and mode == 'authorized_keys': @@ -989,7 +1007,7 @@ PasswdAttrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"uid=*",\ "mailWhitelist", "sudoPassword"]); # Fetch all the hosts HostAttrs = l.search_s(HostBaseDn,ldap.SCOPE_ONELEVEL,"sshRSAHostKey=*",\ - ["hostname","sshRSAHostKey"]); + ["hostname","sshRSAHostKey","purpose"]); # Open the control file if len(sys.argv) == 1: