3 # Generates passwd, shadow and group files from the ldap directory.
5 # Copyright (c) 2000-2001 Jason Gunthorpe <jgg@debian.org>
6 # Copyright (c) 2003-2004 James Troup <troup@debian.org>
7 # Copyright (c) 2004-2005,7 Joey Schulze <joey@infodrom.org>
8 # Copyright (c) 2001-2007 Ryan Murray <rmurray@debian.org>
9 # Copyright (c) 2008 Peter Palfrader <peter@palfrader.org>
10 # Copyright (c) 2008 Andreas Barth <aba@not.so.argh.org>
11 # Copyright (c) 2008 Mark Hymers <mhy@debian.org>
13 # This program is free software; you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation; either version 2 of the License, or
16 # (at your option) any later version.
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write to the Free Software
25 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 import string, re, time, ldap, getopt, sys, os, pwd, posix, socket, base64, sha, shutil, errno, tarfile, grp
28 from userdir_ldap import *;
38 UUID_FORMAT = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
40 EmailCheck = re.compile("^([^ <>@]+@[^ ,<>@]+)?$");
41 BSMTPCheck = re.compile(".*mx 0 (gluck)\.debian\.org\..*",re.DOTALL);
42 DNSZone = ".debian.net"
43 Keyrings = ConfModule.sync_keyrings.split(":")
45 def safe_makedirs(dir):
49 if e.errno == errno.EEXIST:
58 if e.errno == errno.ENOENT:
64 return Str.translate(string.maketrans("\n\r\t","$$$"))
66 def DoLink(From,To,File):
67 try: posix.remove(To+File);
69 posix.link(From+File,To+File);
71 # See if this user is in the group list
72 def IsInGroup(DnRecord):
76 # See if the primary group is in the list
77 if Allowed.has_key(GetAttr(DnRecord,"gidNumber")) != 0:
80 # Check the host based ACL
81 if DnRecord[1].has_key("allowedHost") != 0:
82 for I in DnRecord[1]["allowedHost"]:
86 # See if there are supplementary groups
87 if DnRecord[1].has_key("supplementaryGid") == 0:
90 # Check the supplementary groups
91 for I in DnRecord[1]["supplementaryGid"]:
94 if len(s) == 2 and s[1] != CurrentHost:
96 if Allowed.has_key(group):
105 try: os.remove(File + ".tmp");
107 try: os.remove(File + ".tdb.tmp");
110 def Done(File,F,Fdb):
113 os.rename(File + ".tmp",File);
116 os.rename(File + ".tdb.tmp",File+".tdb");
118 # Generate the password list
119 def GenPasswd(l,File,HomePrefix,PwdMarker):
122 F = open(File + ".tdb.tmp","w");
125 # Fetch all the users
127 if PasswdAttrs == None:
131 for x in PasswdAttrs:
132 if x[1].has_key("uidNumber") == 0 or IsInGroup(x) == 0:
135 # Do not let people try to buffer overflow some busted passwd parser.
136 if len(GetAttr(x,"gecos")) > 100 or len(GetAttr(x,"loginShell")) > 50:
139 userlist[GetAttr(x, "uid")] = int(GetAttr(x, "gidNumber"))
140 Line = "%s:%s:%s:%s:%s:%s%s:%s" % (GetAttr(x,"uid"),\
142 GetAttr(x,"uidNumber"),GetAttr(x,"gidNumber"),\
143 GetAttr(x,"gecos"),HomePrefix,GetAttr(x,"uid"),\
144 GetAttr(x,"loginShell"));
146 Line = Sanitize(Line) + "\n";
147 F.write("0%u %s" % (I,Line));
148 F.write(".%s %s" % (GetAttr(x,"uid"),Line));
149 F.write("=%s %s" % (GetAttr(x,"uidNumber"),Line));
152 # Oops, something unspeakable happened.
158 # Return the list of users so we know which keys to export
161 # Generate the shadow list
162 def GenShadow(l,File):
165 OldMask = os.umask(0077);
166 F = open(File + ".tdb.tmp","w",0600);
169 # Fetch all the users
171 if PasswdAttrs == None:
175 for x in PasswdAttrs:
176 if x[1].has_key("uidNumber") == 0 or IsInGroup(x) == 0:
179 Pass = GetAttr(x,"userPassword");
180 if Pass[0:7] != "{crypt}" or len(Pass) > 50:
185 # If the account is locked, mark it as such in shadow
186 # See Debian Bug #308229 for why we set it to 1 instead of 0
187 if (GetAttr(x,"userPassword").find("*LK*") != -1) \
188 or GetAttr(x,"userPassword").startswith("!"):
191 ShadowExpire = GetAttr(x,"shadowExpire")
193 Line = "%s:%s:%s:%s:%s:%s:%s:%s:" % (GetAttr(x,"uid"),\
194 Pass,GetAttr(x,"shadowLastChange"),\
195 GetAttr(x,"shadowMin"),GetAttr(x,"shadowMax"),\
196 GetAttr(x,"shadowWarning"),GetAttr(x,"shadowInactive"),\
198 Line = Sanitize(Line) + "\n";
199 F.write("0%u %s" % (I,Line));
200 F.write(".%s %s" % (GetAttr(x,"uid"),Line));
203 # Oops, something unspeakable happened.
209 # Generate the sudo passwd file
210 def GenShadowSudo(l,File, untrusted):
213 OldMask = os.umask(0077);
214 F = open(File + ".tmp","w",0600);
217 # Fetch all the users
219 if PasswdAttrs == None:
222 for x in PasswdAttrs:
224 if x[1].has_key("uidNumber") == 0 or IsInGroup(x) == 0:
227 if x[1].has_key('sudoPassword'):
228 for entry in x[1]['sudoPassword']:
229 Match = re.compile('^('+UUID_FORMAT+') (confirmed:[0-9a-f]{40}|unconfirmed) ([a-z0-9.,*]+) ([^ ]+)$').match(entry)
232 uuid = Match.group(1)
233 status = Match.group(2)
234 hosts = Match.group(3)
235 cryptedpass = Match.group(4)
237 if status != 'confirmed:'+make_passwd_hmac('password-is-confirmed', 'sudo', x[1]['uid'][0], uuid, hosts, cryptedpass):
239 for_all = hosts == "*"
240 for_this_host = CurrentHost in hosts.split(',')
241 if not (for_all or for_this_host):
243 # ignore * passwords for untrusted hosts, but copy host specific passwords
244 if for_all and untrusted:
247 if for_this_host: # this makes sure we take a per-host entry over the for-all entry
252 Line = "%s:%s" % (GetAttr(x,"uid"), Pass)
253 Line = Sanitize(Line) + "\n";
254 F.write("%s" % (Line));
256 # Oops, something unspeakable happened.
262 # Generate the shadow list
264 # Fetch all the users
269 if PasswdAttrs == None:
272 safe_rmtree(os.path.join(GlobalDir, 'userkeys'))
273 safe_makedirs(os.path.join(GlobalDir, 'userkeys'))
275 for x in PasswdAttrs:
276 # If the account is locked, do not write it.
277 # This is a partial stop-gap. The ssh also needs to change this
278 # to ignore ~/.ssh/authorized* files.
279 if (GetAttr(x,"userPassword").find("*LK*") != -1) \
280 or GetAttr(x,"userPassword").startswith("!"):
283 if x[1].has_key("uidNumber") == 0 or \
284 x[1].has_key("sshRSAAuthKey") == 0:
286 User = GetAttr(x,"uid");
290 OldMask = os.umask(0077);
291 File = os.path.join(GlobalDir, 'userkeys', User)
292 F = open(File + ".tmp","w",0600);
295 for I in x[1]["sshRSAAuthKey"]:
296 MultipleLine = "%s" % I
297 MultipleLine = Sanitize(MultipleLine) + "\n"
298 F.write(MultipleLine)
301 userfiles.append(os.path.basename(File))
303 # Oops, something unspeakable happened.
306 Die(masterFileName,masterFile,None)
311 def GenSSHtarballs(userlist, SSHFiles, grouprevmap, target):
312 OldMask = os.umask(0077);
313 tf = tarfile.open(name=os.path.join(GlobalDir, 'ssh-keys-%s.tar.gz' % CurrentHost), mode='w:gz')
315 for f in userlist.keys():
316 if f not in SSHFiles:
318 # If we're not exporting their primary group, don't export
321 if userlist[f] in grouprevmap.keys():
322 grname = grouprevmap[userlist[f]]
325 if int(userlist[f]) <= 100:
326 # In these cases, look it up in the normal way so we
327 # deal with cases where, for instance, users are in group
328 # users as their primary group.
329 grname = grp.getgrgid(userlist[f])[0]
334 print "User %s is supposed to have their key exported to host %s but their primary group (gid: %d) isn't in LDAP" % (f, CurrentHost, userlist[f])
337 to = tf.gettarinfo(os.path.join(GlobalDir, 'userkeys', f), f)
338 # These will only be used where the username doesn't
339 # exist on the target system for some reason; hence,
340 # in those cases, the safest thing is for the file to
341 # be owned by root but group nobody. This deals with
342 # the bloody obscure case where the group fails to exist
343 # whilst the user does (in which case we want to avoid
344 # ending up with a file which is owned user:root to avoid
345 # a fairly obvious attack vector)
348 # Using the username / groupname fields avoids any need
349 # to give a shit^W^W^Wcare about the UIDoffset stuff.
353 tf.addfile(to, file(os.path.join(GlobalDir, 'userkeys', f)))
356 os.rename(os.path.join(GlobalDir, 'ssh-keys-%s.tar.gz' % CurrentHost), target)
358 # Generate the group list
359 def GenGroup(l,File):
363 F = open(File + ".tdb.tmp","w");
365 # Generate the GroupMap
367 for x in GroupIDMap.keys():
370 # Fetch all the users
372 if PasswdAttrs == None:
375 # Sort them into a list of groups having a set of users
376 for x in PasswdAttrs:
377 if x[1].has_key("uidNumber") == 0 or IsInGroup(x) == 0:
379 if x[1].has_key("supplementaryGid") == 0:
382 for I in x[1]["supplementaryGid"]:
385 if len(s) == 2 and s[1] != CurrentHost:
387 if GroupMap.has_key(group):
388 GroupMap[group].append(GetAttr(x,"uid"));
390 print "Group does not exist ",group,"but",GetAttr(x,"uid"),"is in it";
392 # Output the group file.
394 for x in GroupMap.keys():
395 grouprevmap[GroupIDMap[x]] = x
396 if GroupIDMap.has_key(x) == 0:
398 Line = "%s:x:%u:" % (x,GroupIDMap[x]);
400 for I in GroupMap[x]:
401 Line = Line + ("%s%s" % (Comma,I));
403 Line = Sanitize(Line) + "\n";
404 F.write("0%u %s" % (J,Line));
405 F.write(".%s %s" % (x,Line));
406 F.write("=%u %s" % (GroupIDMap[x],Line));
409 # Oops, something unspeakable happened.
417 # Generate the email forwarding list
418 def GenForward(l,File):
421 OldMask = os.umask(0022);
422 F = open(File + ".tmp","w",0644);
425 # Fetch all the users
427 if PasswdAttrs == None:
430 # Write out the email address for each user
431 for x in PasswdAttrs:
432 if x[1].has_key("emailForward") == 0 or IsInGroup(x) == 0:
435 # Do not allow people to try to buffer overflow busted parsers
436 if len(GetAttr(x,"emailForward")) > 200:
439 # Check the forwarding address
440 if EmailCheck.match(GetAttr(x,"emailForward")) == None:
442 Line = "%s: %s" % (GetAttr(x,"uid"),GetAttr(x,"emailForward"));
443 Line = Sanitize(Line) + "\n";
446 # Oops, something unspeakable happened.
452 def GenAllForward(l,File):
455 OldMask = os.umask(0022);
456 Fdb = os.popen("cdbmake %s %s.tmp"%(File,File),"w");
459 # Fetch all the users
461 if PasswdAttrs == None:
464 # Write out the email address for each user
465 for x in PasswdAttrs:
466 if x[1].has_key("emailForward") == 0:
469 # Do not allow people to try to buffer overflow busted parsers
470 Forward = GetAttr(x,"emailForward");
471 if len(Forward) > 200:
474 # Check the forwarding address
475 if EmailCheck.match(Forward) == None:
478 User = GetAttr(x,"uid");
479 Fdb.write("+%d,%d:%s->%s\n"%(len(User),len(Forward),User,Forward));
481 # Oops, something unspeakable happened.
485 if Fdb.close() != None:
486 raise "cdbmake gave an error";
488 # Generate the anon XEarth marker file
489 def GenMarkers(l,File):
492 F = open(File + ".tmp","w");
494 # Fetch all the users
496 if PasswdAttrs == None:
499 # Write out the position for each user
500 for x in PasswdAttrs:
501 if x[1].has_key("latitude") == 0 or x[1].has_key("longitude") == 0:
504 Line = "%8s %8s \"\""%(DecDegree(GetAttr(x,"latitude"),1),DecDegree(GetAttr(x,"longitude"),1));
505 Line = Sanitize(Line) + "\n";
510 # Oops, something unspeakable happened.
516 # Generate the debian-private subscription list
517 def GenPrivate(l,File):
520 F = open(File + ".tmp","w");
522 # Fetch all the users
524 if PasswdAttrs == None:
527 # Write out the position for each user
528 for x in PasswdAttrs:
529 if x[1].has_key("privateSub") == 0:
532 # If the account is locked, do not write it
533 if (GetAttr(x,"userPassword").find("*LK*") != -1) \
534 or GetAttr(x,"userPassword").startswith("!"):
537 # If the account has no PGP key, do not write it
538 if x[1].has_key("keyFingerPrint") == 0:
541 # Must be in the Debian group (yuk, hard coded for now)
542 if GetAttr(x,"gidNumber") != "800":
546 Line = "%s"%(GetAttr(x,"privateSub"));
547 Line = Sanitize(Line) + "\n";
552 # Oops, something unspeakable happened.
558 # Generate a list of locked accounts
559 def GenDisabledAccounts(l,File):
562 F = open(File + ".tmp","w");
564 # Fetch all the users
566 if PasswdAttrs == None:
570 for x in PasswdAttrs:
571 if x[1].has_key("uidNumber") == 0:
574 Pass = GetAttr(x,"userPassword");
576 # *LK* is the reference value for a locked account
577 # password starting with ! is also a locked account
578 if Pass.find("*LK*") != -1 or Pass.startswith("!"):
579 # Format is <login>:<reason>
580 Line = "%s:%s" % (GetAttr(x,"uid"), "Account is locked")
583 F.write(Sanitize(Line) + "\n")
585 # Oops, something unspeakable happened.
591 # Generate the list of local addresses that refuse all mail
592 def GenMailDisable(l,File):
595 F = open(File + ".tmp","w");
597 # Fetch all the users
599 if PasswdAttrs == None:
602 for x in PasswdAttrs:
605 if x[1].has_key("mailDisableMessage"):
606 Reason = GetAttr(x,"mailDisableMessage")
610 # Must be in the Debian group (yuk, hard coded for now)
611 if GetAttr(x,"gidNumber") != "800":
615 Line = "%s: %s"%(GetAttr(x,"uid"),Reason);
616 Line = Sanitize(Line) + "\n";
621 # Oops, something unspeakable happened.
627 # Generate a list of uids that should have boolean affects applied
628 def GenMailBool(l,File,Key):
631 F = open(File + ".tmp","w");
633 # Fetch all the users
635 if PasswdAttrs == None:
638 for x in PasswdAttrs:
641 if x[1].has_key(Key) == 0:
644 # Must be in the Debian group (yuk, hard coded for now)
645 if GetAttr(x,"gidNumber") != "800":
648 if GetAttr(x,Key) != "TRUE":
652 Line = "%s"%(GetAttr(x,"uid"));
653 Line = Sanitize(Line) + "\n";
658 # Oops, something unspeakable happened.
664 # Generate a list of hosts for RBL or whitelist purposes.
665 def GenMailList(l,File,Key):
668 F = open(File + ".tmp","w");
670 # Fetch all the users
672 if PasswdAttrs == None:
675 for x in PasswdAttrs:
678 if x[1].has_key(Key) == 0:
681 # Must be in the Debian group (yuk, hard coded for now)
682 if GetAttr(x,"gidNumber") != "800":
689 if Key == "mailWhitelist":
690 if re.match('^[-\w.]+(/[\d]+)?$',z) == None:
693 if re.match('^[-\w.]+$',z) == None:
697 Line = GetAttr(x,"uid")
701 if Key == "mailRHSBL":
702 Line += "/$sender_address_domain"
705 Line = Sanitize(Line) + "\n";
710 # Oops, something unspeakable happened.
716 # Generate the DNS Zone file
717 def GenDNS(l,File,HomePrefix):
720 F = open(File + ".tmp","w");
722 # Fetch all the users
724 if PasswdAttrs == None:
727 # Write out the zone file entry for each user
728 for x in PasswdAttrs:
729 if x[1].has_key("dnsZoneEntry") == 0:
732 # If the account has no PGP key, do not write it
733 if x[1].has_key("keyFingerPrint") == 0:
736 F.write("; %s\n"%(EmailAddress(x)));
737 for z in x[1]["dnsZoneEntry"]:
738 Split = z.lower().split()
739 if Split[1].lower() == 'in':
740 for y in range(0,len(Split)):
743 Line = " ".join(Split) + "\n";
746 Host = Split[0] + DNSZone;
747 if BSMTPCheck.match(Line) != None:
748 F.write("; Has BSMTP\n");
750 # Write some identification information
751 if Split[2].lower() == "a":
752 Line = "%s IN TXT \"%s\"\n"%(Split[0],EmailAddress(x));
753 for y in x[1]["keyFingerPrint"]:
754 Line = Line + "%s IN TXT \"PGP %s\"\n"%(Split[0],FormatPGPKey(y));
757 Line = "; Err %s"%(str(Split));
762 F.write("; Errors\n");
765 # Oops, something unspeakable happened.
771 # Generate the DNS SSHFP records
772 def GenSSHFP(l,File,HomePrefix):
775 F = open(File + ".tmp","w")
777 # Fetch all the hosts
779 if HostAttrs == None:
783 if x[1].has_key("hostname") == 0 or \
784 x[1].has_key("sshRSAHostKey") == 0:
786 Host = GetAttr(x,"hostname");
788 for I in x[1]["sshRSAHostKey"]:
790 if Split[0] == 'ssh-rsa':
792 if Split[0] == 'ssh-dss':
794 if Algorithm == None:
796 Fingerprint = sha.new(base64.decodestring(Split[1])).hexdigest()
797 Line = "%s. IN SSHFP %u 1 %s" % (Host,Algorithm,Fingerprint)
798 Line = Sanitize(Line) + "\n"
800 # Oops, something unspeakable happened.
806 # Generate the BSMTP file
807 def GenBSMTP(l,File,HomePrefix):
810 F = open(File + ".tmp","w");
812 # Fetch all the users
814 if PasswdAttrs == None:
817 # Write out the zone file entry for each user
818 for x in PasswdAttrs:
819 if x[1].has_key("dnsZoneEntry") == 0:
822 # If the account has no PGP key, do not write it
823 if x[1].has_key("keyFingerPrint") == 0:
826 for z in x[1]["dnsZoneEntry"]:
827 Split = z.lower().split()
828 if Split[1].lower() == 'in':
829 for y in range(0,len(Split)):
832 Line = " ".join(Split) + "\n";
834 Host = Split[0] + DNSZone;
835 if BSMTPCheck.match(Line) != None:
836 F.write("%s: user=%s group=Debian file=%s%s/bsmtp/%s\n"%(Host,
837 GetAttr(x,"uid"),HomePrefix,GetAttr(x,"uid"),Host));
840 F.write("; Errors\n");
843 # Oops, something unspeakable happened.
853 if not Host in HostToIPCache:
856 IPAdressesT = list(set([ (a[0],a[4][0]) for a in socket.getaddrinfo(Host, None)]))
857 except socket.gaierror, (code):
858 if code[0] != -2: raise
860 for addr in IPAdressesT:
861 if addr[0] == socket.AF_INET: IPAdresses += [addr[1], "::ffff:"+addr[1]]
862 else: IPAdresses += [addr[1]]
863 HostToIPCache[Host] = IPAdresses
864 return HostToIPCache[Host]
867 # Generate the ssh known hosts file
868 def GenSSHKnown(l,File,mode=None):
871 OldMask = os.umask(0022);
872 F = open(File + ".tmp","w",0644);
876 if HostAttrs == None:
880 if x[1].has_key("hostname") == 0 or \
881 x[1].has_key("sshRSAHostKey") == 0:
883 Host = GetAttr(x,"hostname");
885 SHost = Host.find(".")
886 if SHost != None: HostNames += [Host[0:SHost]]
888 for I in x[1]["sshRSAHostKey"]:
889 if mode and mode == 'authorized_keys':
890 #Line = 'command="rsync --server --sender -pr . /var/cache/userdir-ldap/hosts/%s",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,from="%s" %s' % (Host, ",".join(HNames + HostToIP(Host)), I)
891 Line = 'command="rsync --server --sender -pr . /var/cache/userdir-ldap/hosts/%s",no-port-forwarding,no-X11-forwarding,no-agent-forwarding %s' % (Host,I)
893 Line = "%s %s" %(",".join(HostNames + HostToIP(Host)), I);
894 Line = Sanitize(Line) + "\n";
896 # Oops, something unspeakable happened.
902 # Generate the debianhosts file (list of all IP addresses)
903 def GenHosts(l,File):
906 OldMask = os.umask(0022);
907 F = open(File + ".tmp","w",0644);
910 # Fetch all the hosts
911 HostNames = l.search_s(HostBaseDn,ldap.SCOPE_ONELEVEL,"hostname=*",\
914 if HostNames == None:
918 if x[1].has_key("hostname") == 0:
920 Host = GetAttr(x,"hostname");
922 Addr = socket.gethostbyname(Host);
923 F.write(Addr + "\n");
926 # Oops, something unspeakable happened.
932 def GenKeyrings(l,OutDir):
934 shutil.copy(k, OutDir)
937 # Connect to the ldap server
939 F = open(PassDir+"/pass-"+pwd.getpwuid(os.getuid())[0],"r");
940 Pass = F.readline().strip().split(" ")
942 l.simple_bind_s("uid="+Pass[0]+","+BaseDn,Pass[1]);
944 # Fetch all the groups
946 Attrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"gid=*",\
947 ["gid","gidNumber"]);
949 # Generate the GroupMap and GroupIDMap
951 if x[1].has_key("gidNumber") == 0:
953 GroupIDMap[x[1]["gid"][0]] = int(x[1]["gidNumber"][0]);
955 # Fetch all the users
956 PasswdAttrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"uid=*",\
957 ["uid","uidNumber","gidNumber","supplementaryGid",\
958 "gecos","loginShell","userPassword","shadowLastChange",\
959 "shadowMin","shadowMax","shadowWarning","shadowInactive",
960 "shadowExpire","emailForward","latitude","longitude",\
961 "allowedHost","sshRSAAuthKey","dnsZoneEntry","cn","sn",\
962 "keyFingerPrint","privateSub","mailDisableMessage",\
963 "mailGreylisting","mailCallout","mailRBL","mailRHSBL",\
964 "mailWhitelist", "sudoPassword"]);
965 # Fetch all the hosts
966 HostAttrs = l.search_s(HostBaseDn,ldap.SCOPE_ONELEVEL,"sshRSAHostKey=*",\
967 ["hostname","sshRSAHostKey"]);
969 # Open the control file
970 if len(sys.argv) == 1:
971 F = open(GenerateConf,"r");
973 F = open(sys.argv[1],"r")
975 # Generate global things
976 GlobalDir = GenerateDir+"/";
977 SSHFiles = GenSSHShadow(l);
978 GenAllForward(l,GlobalDir+"mail-forward.cdb");
979 GenMarkers(l,GlobalDir+"markers");
980 GenPrivate(l,GlobalDir+"debian-private");
981 GenDisabledAccounts(l,GlobalDir+"disabled-accounts");
982 GenSSHKnown(l,GlobalDir+"ssh_known_hosts");
983 #GenSSHKnown(l,GlobalDir+"authorized_keys", 'authorized_keys');
984 GenHosts(l,GlobalDir+"debianhosts");
985 GenMailDisable(l,GlobalDir+"mail-disable");
986 GenMailBool(l,GlobalDir+"mail-greylist","mailGreylisting");
987 GenMailBool(l,GlobalDir+"mail-callout","mailCallout");
988 GenMailList(l,GlobalDir+"mail-rbl","mailRBL");
989 GenMailList(l,GlobalDir+"mail-rhsbl","mailRHSBL");
990 GenMailList(l,GlobalDir+"mail-whitelist","mailWhitelist");
991 GenKeyrings(l,GlobalDir);
994 GenForward(l,GlobalDir+"forward-alias");
1006 Split = Line.split(" ")
1007 OutDir = GenerateDir + '/' + Split[0] + '/';
1008 try: os.mkdir(OutDir);
1011 # Get the group list and convert any named groups to numerics
1016 ExtraList[I] = None;
1018 GroupList[I] = None;
1019 if GroupIDMap.has_key(I):
1020 GroupList[str(GroupIDMap[I])] = None;
1022 Allowed = GroupList;
1025 CurrentHost = Split[0];
1027 DoLink(GlobalDir,OutDir,"debianhosts");
1028 DoLink(GlobalDir,OutDir,"ssh_known_hosts");
1029 DoLink(GlobalDir,OutDir,"disabled-accounts")
1032 if ExtraList.has_key("[NOPASSWD]"):
1033 userlist = GenPasswd(l,OutDir+"passwd",Split[1], "*");
1035 userlist = GenPasswd(l,OutDir+"passwd",Split[1], "x");
1037 grouprevmap = GenGroup(l,OutDir+"group");
1038 GenShadowSudo(l, OutDir+"sudo-passwd", ExtraList.has_key("[UNTRUSTED]") or ExtraList.has_key("[NOPASSWD]"))
1040 # Now we know who we're allowing on the machine, export
1041 # the relevant ssh keys
1042 GenSSHtarballs(userlist, SSHFiles, grouprevmap, os.path.join(OutDir, 'ssh-keys.tar.gz'))
1044 if ExtraList.has_key("[UNTRUSTED]"):
1045 print "[UNTRUSTED] tag is obsolete and may be removed in the future."
1047 if not ExtraList.has_key("[NOPASSWD]"):
1048 GenShadow(l,OutDir+"shadow");
1050 # Link in global things
1051 if not ExtraList.has_key("[NOMARKERS]"):
1052 DoLink(GlobalDir,OutDir,"markers");
1053 DoLink(GlobalDir,OutDir,"mail-forward.cdb");
1054 DoLink(GlobalDir,OutDir,"mail-disable");
1055 DoLink(GlobalDir,OutDir,"mail-greylist");
1056 DoLink(GlobalDir,OutDir,"mail-callout");
1057 DoLink(GlobalDir,OutDir,"mail-rbl");
1058 DoLink(GlobalDir,OutDir,"mail-rhsbl");
1059 DoLink(GlobalDir,OutDir,"mail-whitelist");
1062 DoLink(GlobalDir,OutDir,"forward-alias");
1064 if ExtraList.has_key("[DNS]"):
1065 GenDNS(l,OutDir+"dns-zone",Split[1]);
1066 GenSSHFP(l,OutDir+"dns-sshfp",Split[1])
1068 if ExtraList.has_key("[BSMTP]"):
1069 GenBSMTP(l,OutDir+"bsmtp",Split[1])
1071 if ExtraList.has_key("[PRIVATE]"):
1072 DoLink(GlobalDir,OutDir,"debian-private")
1074 if ExtraList.has_key("[KEYRING]"):
1076 DoLink(GlobalDir,OutDir,os.path.basename(k))
1079 try: posix.remove(OutDir+os.path.basename(k));
1084 # vim:set shiftwidth=3: