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 Mark Hymers <mhy@debian.org>
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 import string, re, time, ldap, getopt, sys, os, pwd, posix, socket, base64, sha, shutil, errno, tarfile, grp
27 from userdir_ldap import *;
37 EmailCheck = re.compile("^([^ <>@]+@[^ ,<>@]+)?$");
38 BSMTPCheck = re.compile(".*mx 0 (gluck)\.debian\.org\..*",re.DOTALL);
39 DNSZone = ".debian.net"
40 Keyrings = [ "/org/keyring.debian.org/keyrings/debian-keyring.gpg",
41 "/org/keyring.debian.org/keyrings/debian-keyring.pgp" ]
43 def safe_makedirs(dir):
47 if e.errno == errno.EEXIST:
56 if e.errno == errno.ENOENT:
62 return Str.translate(string.maketrans("\n\r\t","$$$"))
64 def DoLink(From,To,File):
65 try: posix.remove(To+File);
67 posix.link(From+File,To+File);
69 # See if this user is in the group list
70 def IsInGroup(DnRecord):
74 # See if the primary group is in the list
75 if Allowed.has_key(GetAttr(DnRecord,"gidNumber")) != 0:
78 # Check the host based ACL
79 if DnRecord[1].has_key("allowedHost") != 0:
80 for I in DnRecord[1]["allowedHost"]:
84 # See if there are supplementary groups
85 if DnRecord[1].has_key("supplementaryGid") == 0:
88 # Check the supplementary groups
89 for I in DnRecord[1]["supplementaryGid"]:
90 if Allowed.has_key(I):
99 try: os.remove(File + ".tmp");
101 try: os.remove(File + ".tdb.tmp");
104 def Done(File,F,Fdb):
107 os.rename(File + ".tmp",File);
110 os.rename(File + ".tdb.tmp",File+".tdb");
112 # Generate the password list
113 def GenPasswd(l,File,HomePrefix,PwdMarker):
116 F = open(File + ".tdb.tmp","w");
119 # Fetch all the users
121 if PasswdAttrs == None:
125 for x in PasswdAttrs:
126 if x[1].has_key("uidNumber") == 0 or IsInGroup(x) == 0:
129 # Do not let people try to buffer overflow some busted passwd parser.
130 if len(GetAttr(x,"gecos")) > 100 or len(GetAttr(x,"loginShell")) > 50:
133 userlist[GetAttr(x, "uid")] = GetAttr(x, "gidNumber")
134 Line = "%s:%s:%s:%s:%s:%s%s:%s" % (GetAttr(x,"uid"),\
136 GetAttr(x,"uidNumber"),GetAttr(x,"gidNumber"),\
137 GetAttr(x,"gecos"),HomePrefix,GetAttr(x,"uid"),\
138 GetAttr(x,"loginShell"));
140 Line = Sanitize(Line) + "\n";
141 F.write("0%u %s" % (I,Line));
142 F.write(".%s %s" % (GetAttr(x,"uid"),Line));
143 F.write("=%s %s" % (GetAttr(x,"uidNumber"),Line));
146 # Oops, something unspeakable happened.
152 # Return the list of users so we know which keys to export
155 # Generate the shadow list
156 def GenShadow(l,File):
159 OldMask = os.umask(0077);
160 F = open(File + ".tdb.tmp","w",0600);
163 # Fetch all the users
165 if PasswdAttrs == None:
169 for x in PasswdAttrs:
170 if x[1].has_key("uidNumber") == 0 or IsInGroup(x) == 0:
173 Pass = GetAttr(x,"userPassword");
174 if Pass[0:7] != "{crypt}" or len(Pass) > 50:
179 # If the account is locked, mark it as such in shadow
180 # See Debian Bug #308229 for why we set it to 1 instead of 0
181 if (GetAttr(x,"userPassword").find("*LK*") != -1) \
182 or GetAttr(x,"userPassword").startswith("!"):
185 ShadowExpire = GetAttr(x,"shadowexpire")
187 Line = "%s:%s:%s:%s:%s:%s:%s:%s:" % (GetAttr(x,"uid"),\
188 Pass,GetAttr(x,"shadowLastChange"),\
189 GetAttr(x,"shadowMin"),GetAttr(x,"shadowMax"),\
190 GetAttr(x,"shadowWarning"),GetAttr(x,"shadowinactive"),\
192 Line = Sanitize(Line) + "\n";
193 F.write("0%u %s" % (I,Line));
194 F.write(".%s %s" % (GetAttr(x,"uid"),Line));
197 # Oops, something unspeakable happened.
203 # Generate the shadow list
204 def GenSSHShadow(l,masterFileName):
205 # Fetch all the users
208 # Depending on config, we write out either a single file,
209 # multiple files, or both
212 OldMask = os.umask(0077);
213 masterFile = open(masterFileName + ".tmp","w",0600);
216 Die(masterFileName,masterFile,None)
220 if PasswdAttrs == None:
223 # If we're going to be dealing with multiple keys, empty the
224 # directory before we start to avoid old keys hanging around
226 safe_rmtree(os.path.join(GlobalDir, 'userkeys'))
227 safe_makedirs(os.path.join(GlobalDir, 'userkeys'))
229 for x in PasswdAttrs:
230 # If the account is locked, do not write it.
231 # This is a partial stop-gap. The ssh also needs to change this
232 # to ignore ~/.ssh/authorized* files.
233 if (GetAttr(x,"userPassword").find("*LK*") != -1) \
234 or GetAttr(x,"userPassword").startswith("!"):
237 if x[1].has_key("uidNumber") == 0 or \
238 x[1].has_key("sshRSAAuthKey") == 0:
240 User = GetAttr(x,"uid");
245 OldMask = os.umask(0077);
246 File = os.path.join(GlobalDir, 'userkeys', User)
247 F = open(File + ".tmp","w",0600);
250 for I in x[1]["sshRSAAuthKey"]:
252 MultipleLine = "%s" % I
253 MultipleLine = Sanitize(MultipleLine) + "\n"
254 F.write(MultipleLine)
256 SingleLine = "%s: %s" % (User, I)
257 SingleLine = Sanitize(SingleLine) + "\n"
258 masterFile.write(SingleLine)
262 userfiles.append(os.path.basename(File))
264 # Oops, something unspeakable happened.
267 Die(masterFileName,masterFile,None)
271 Done(masterFileName,masterFile,None)
272 singlefile = os.path.basename(masterFileName)
274 return singlefile, userfiles
276 # Generate the group list
277 def GenGroup(l,File):
281 F = open(File + ".tdb.tmp","w");
283 # Generate the GroupMap
285 for x in GroupIDMap.keys():
288 # Fetch all the users
290 if PasswdAttrs == None:
293 # Sort them into a list of groups having a set of users
294 for x in PasswdAttrs:
295 if x[1].has_key("uidNumber") == 0 or IsInGroup(x) == 0:
297 if x[1].has_key("supplementaryGid") == 0:
300 for I in x[1]["supplementaryGid"]:
301 if GroupMap.has_key(I):
302 GroupMap[I].append(GetAttr(x,"uid"));
304 print "Group does not exist ",I,"but",GetAttr(x,"uid"),"is in it";
306 # Output the group file.
308 for x in GroupMap.keys():
309 grouprevmap[GroupIDMap[x]] = x
310 if GroupIDMap.has_key(x) == 0:
312 Line = "%s:x:%u:" % (x,GroupIDMap[x]);
314 for I in GroupMap[x]:
315 Line = Line + ("%s%s" % (Comma,I));
317 Line = Sanitize(Line) + "\n";
318 F.write("0%u %s" % (J,Line));
319 F.write(".%s %s" % (x,Line));
320 F.write("=%u %s" % (GroupIDMap[x],Line));
323 # Oops, something unspeakable happened.
331 # Generate the email forwarding list
332 def GenForward(l,File):
335 OldMask = os.umask(0022);
336 F = open(File + ".tmp","w",0644);
339 # Fetch all the users
341 if PasswdAttrs == None:
344 # Write out the email address for each user
345 for x in PasswdAttrs:
346 if x[1].has_key("emailForward") == 0 or IsInGroup(x) == 0:
349 # Do not allow people to try to buffer overflow busted parsers
350 if len(GetAttr(x,"emailForward")) > 200:
353 # Check the forwarding address
354 if EmailCheck.match(GetAttr(x,"emailForward")) == None:
356 Line = "%s: %s" % (GetAttr(x,"uid"),GetAttr(x,"emailForward"));
357 Line = Sanitize(Line) + "\n";
360 # Oops, something unspeakable happened.
366 def GenAllForward(l,File):
369 OldMask = os.umask(0022);
370 Fdb = os.popen("cdbmake %s %s.tmp"%(File,File),"w");
373 # Fetch all the users
375 if PasswdAttrs == None:
378 # Write out the email address for each user
379 for x in PasswdAttrs:
380 if x[1].has_key("emailForward") == 0:
383 # Do not allow people to try to buffer overflow busted parsers
384 Forward = GetAttr(x,"emailForward");
385 if len(Forward) > 200:
388 # Check the forwarding address
389 if EmailCheck.match(Forward) == None:
392 User = GetAttr(x,"uid");
393 Fdb.write("+%d,%d:%s->%s\n"%(len(User),len(Forward),User,Forward));
395 # Oops, something unspeakable happened.
399 if Fdb.close() != None:
400 raise "cdbmake gave an error";
402 # Generate the anon XEarth marker file
403 def GenMarkers(l,File):
406 F = open(File + ".tmp","w");
408 # Fetch all the users
410 if PasswdAttrs == None:
413 # Write out the position for each user
414 for x in PasswdAttrs:
415 if x[1].has_key("latitude") == 0 or x[1].has_key("longitude") == 0:
418 Line = "%8s %8s \"\""%(DecDegree(GetAttr(x,"latitude"),1),DecDegree(GetAttr(x,"longitude"),1));
419 Line = Sanitize(Line) + "\n";
424 # Oops, something unspeakable happened.
430 # Generate the debian-private subscription list
431 def GenPrivate(l,File):
434 F = open(File + ".tmp","w");
436 # Fetch all the users
438 if PasswdAttrs == None:
441 # Write out the position for each user
442 for x in PasswdAttrs:
443 if x[1].has_key("privateSub") == 0:
446 # If the account is locked, do not write it
447 if (GetAttr(x,"userPassword").find("*LK*") != -1) \
448 or GetAttr(x,"userPassword").startswith("!"):
451 # If the account has no PGP key, do not write it
452 if x[1].has_key("keyFingerPrint") == 0:
455 # Must be in the Debian group (yuk, hard coded for now)
456 if GetAttr(x,"gidNumber") != "800":
460 Line = "%s"%(GetAttr(x,"privateSub"));
461 Line = Sanitize(Line) + "\n";
466 # Oops, something unspeakable happened.
472 # Generate a list of locked accounts
473 def GenDisabledAccounts(l,File):
476 F = open(File + ".tmp","w");
478 # Fetch all the users
480 if PasswdAttrs == None:
484 for x in PasswdAttrs:
485 if x[1].has_key("uidNumber") == 0:
488 Pass = GetAttr(x,"userPassword");
490 # *LK* is the reference value for a locked account
491 # password starting with ! is also a locked account
492 if Pass.find("*LK*") != -1 or Pass.startswith("!"):
493 # Format is <login>:<reason>
494 Line = "%s:%s" % (GetAttr(x,"uid"), "Account is locked")
497 F.write(Sanitize(Line) + "\n")
499 # Oops, something unspeakable happened.
505 # Generate the list of local addresses that refuse all mail
506 def GenMailDisable(l,File):
509 F = open(File + ".tmp","w");
511 # Fetch all the users
513 if PasswdAttrs == None:
516 for x in PasswdAttrs:
519 # If the account is locked, disable incoming mail
520 if (GetAttr(x,"userPassword").find("*LK*") != -1):
521 if GetAttr(x,"uid") == "luther":
524 Reason = "user account locked"
526 if x[1].has_key("mailDisableMessage"):
527 Reason = GetAttr(x,"mailDisableMessage")
531 # Must be in the Debian group (yuk, hard coded for now)
532 if GetAttr(x,"gidNumber") != "800":
536 Line = "%s: %s"%(GetAttr(x,"uid"),Reason);
537 Line = Sanitize(Line) + "\n";
542 # Oops, something unspeakable happened.
548 # Generate a list of uids that should have boolean affects applied
549 def GenMailBool(l,File,Key):
552 F = open(File + ".tmp","w");
554 # Fetch all the users
556 if PasswdAttrs == None:
559 for x in PasswdAttrs:
562 if x[1].has_key(Key) == 0:
565 # Must be in the Debian group (yuk, hard coded for now)
566 if GetAttr(x,"gidNumber") != "800":
569 if GetAttr(x,Key) != "TRUE":
573 Line = "%s"%(GetAttr(x,"uid"));
574 Line = Sanitize(Line) + "\n";
579 # Oops, something unspeakable happened.
585 # Generate a list of hosts for RBL or whitelist purposes.
586 def GenMailList(l,File,Key):
589 F = open(File + ".tmp","w");
591 # Fetch all the users
593 if PasswdAttrs == None:
596 for x in PasswdAttrs:
599 if x[1].has_key(Key) == 0:
602 # Must be in the Debian group (yuk, hard coded for now)
603 if GetAttr(x,"gidNumber") != "800":
610 if Key == "mailWhitelist":
611 if re.match('^[-\w.]+(/[\d]+)?$',z) == None:
614 if re.match('^[-\w.]+$',z) == None:
618 Line = GetAttr(x,"uid")
622 if Key == "mailRHSBL":
623 Line += "/$sender_address_domain"
626 Line = Sanitize(Line) + "\n";
631 # Oops, something unspeakable happened.
637 # Generate the DNS Zone file
638 def GenDNS(l,File,HomePrefix):
641 F = open(File + ".tmp","w");
643 # Fetch all the users
645 if PasswdAttrs == None:
648 # Write out the zone file entry for each user
649 for x in PasswdAttrs:
650 if x[1].has_key("dnsZoneEntry") == 0:
653 # If the account has no PGP key, do not write it
654 if x[1].has_key("keyFingerPrint") == 0:
657 F.write("; %s\n"%(EmailAddress(x)));
658 for z in x[1]["dnsZoneEntry"]:
659 Split = z.lower().split()
660 if Split[1].lower() == 'in':
661 for y in range(0,len(Split)):
664 Line = " ".join(Split) + "\n";
667 Host = Split[0] + DNSZone;
668 if BSMTPCheck.match(Line) != None:
669 F.write("; Has BSMTP\n");
671 # Write some identification information
672 if Split[2].lower() == "a":
673 Line = "%s IN TXT \"%s\"\n"%(Split[0],EmailAddress(x));
674 for y in x[1]["keyFingerPrint"]:
675 Line = Line + "%s IN TXT \"PGP %s\"\n"%(Split[0],FormatPGPKey(y));
678 Line = "; Err %s"%(str(Split));
683 F.write("; Errors\n");
686 # Oops, something unspeakable happened.
692 # Generate the DNS SSHFP records
693 def GenSSHFP(l,File,HomePrefix):
696 F = open(File + ".tmp","w")
698 # Fetch all the hosts
700 if HostAttrs == None:
704 if x[1].has_key("hostname") == 0 or \
705 x[1].has_key("sshRSAHostKey") == 0:
707 Host = GetAttr(x,"hostname");
709 for I in x[1]["sshRSAHostKey"]:
711 if Split[0] == 'ssh-rsa':
713 if Split[0] == 'ssh-dss':
715 if Algorithm == None:
717 Fingerprint = sha.new(base64.decodestring(Split[1])).hexdigest()
718 Line = "%s. IN SSHFP %u 1 %s" % (Host,Algorithm,Fingerprint)
719 Line = Sanitize(Line) + "\n"
721 # Oops, something unspeakable happened.
727 # Generate the BSMTP file
728 def GenBSMTP(l,File,HomePrefix):
731 F = open(File + ".tmp","w");
733 # Fetch all the users
735 if PasswdAttrs == None:
738 # Write out the zone file entry for each user
739 for x in PasswdAttrs:
740 if x[1].has_key("dnsZoneEntry") == 0:
743 # If the account has no PGP key, do not write it
744 if x[1].has_key("keyFingerPrint") == 0:
747 for z in x[1]["dnsZoneEntry"]:
748 Split = z.lower().split()
749 if Split[1].lower() == 'in':
750 for y in range(0,len(Split)):
753 Line = " ".join(Split) + "\n";
755 Host = Split[0] + DNSZone;
756 if BSMTPCheck.match(Line) != None:
757 F.write("%s: user=%s group=Debian file=%s%s/bsmtp/%s\n"%(Host,
758 GetAttr(x,"uid"),HomePrefix,GetAttr(x,"uid"),Host));
761 F.write("; Errors\n");
764 # Oops, something unspeakable happened.
770 # Generate the ssh known hosts file
771 def GenSSHKnown(l,File):
774 OldMask = os.umask(0022);
775 F = open(File + ".tmp","w",0644);
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 SHost = Host.find(".")
789 if SHost != None: HostNames += [Host[0:SHost]]
793 # get IP adresses back as "proto adress" to distinguish between v4 and v6
795 IPAdressesT = set([ (a[0],a[4][0]) for a in socket.getaddrinfo(Host, None)])
797 if code[0] != -2: raise
798 for addr in IPAdressesT:
799 if addr[0] == socket.AF_INET: IPAdresses += [addr[1], "::ffff:"+addr[1]]
800 else: IPAdresses += [addr[1]]
802 for I in x[1]["sshRSAHostKey"]:
803 Line = "%s %s" %(",".join(HostNames + IPAdresses), I);
804 Line = Sanitize(Line) + "\n";
806 # Oops, something unspeakable happened.
812 # Generate the debianhosts file (list of all IP addresses)
813 def GenHosts(l,File):
816 OldMask = os.umask(0022);
817 F = open(File + ".tmp","w",0644);
820 # Fetch all the hosts
821 HostNames = l.search_s(HostBaseDn,ldap.SCOPE_ONELEVEL,"hostname=*",\
824 if HostNames == None:
828 if x[1].has_key("hostname") == 0:
830 Host = GetAttr(x,"hostname");
832 Addr = socket.gethostbyname(Host);
833 F.write(Addr + "\n");
836 # Oops, something unspeakable happened.
842 def GenKeyrings(l,OutDir):
844 shutil.copy(k, OutDir)
846 # Connect to the ldap server
847 l = ldap.open(LDAPServer);
848 F = open(PassDir+"/pass-"+pwd.getpwuid(os.getuid())[0],"r");
849 Pass = F.readline().strip().split(" ")
851 l.simple_bind_s("uid="+Pass[0]+","+BaseDn,Pass[1]);
853 # Fetch all the groups
855 Attrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"gid=*",\
856 ["gid","gidNumber"]);
858 # Generate the GroupMap and GroupIDMap
860 if x[1].has_key("gidNumber") == 0:
862 GroupIDMap[x[1]["gid"][0]] = int(x[1]["gidNumber"][0]);
864 # Fetch all the users
865 PasswdAttrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"uid=*",\
866 ["uid","uidNumber","gidNumber","supplementaryGid",\
867 "gecos","loginShell","userPassword","shadowLastChange",\
868 "shadowMin","shadowMax","shadowWarning","shadowinactive",
869 "shadowexpire","emailForward","latitude","longitude",\
870 "allowedHost","sshRSAAuthKey","dnsZoneEntry","cn","sn",\
871 "keyFingerPrint","privateSub","mailDisableMessage",\
872 "mailGreylisting","mailCallout","mailRBL","mailRHSBL",\
874 # Fetch all the hosts
875 HostAttrs = l.search_s(HostBaseDn,ldap.SCOPE_ONELEVEL,"sshRSAHostKey=*",\
876 ["hostname","sshRSAHostKey"]);
878 # Open the control file
879 if len(sys.argv) == 1:
880 F = open(GenerateConf,"r");
882 F = open(sys.argv[1],"r")
884 # Generate global things
885 GlobalDir = GenerateDir+"/";
886 SSHGlobal, SSHFiles = GenSSHShadow(l,GlobalDir+"ssh-rsa-shadow");
887 GenAllForward(l,GlobalDir+"mail-forward.cdb");
888 GenMarkers(l,GlobalDir+"markers");
889 GenPrivate(l,GlobalDir+"debian-private");
890 GenDisabledAccounts(l,GlobalDir+"disabled-accounts");
891 GenSSHKnown(l,GlobalDir+"ssh_known_hosts");
892 GenHosts(l,GlobalDir+"debianhosts");
893 GenMailDisable(l,GlobalDir+"mail-disable");
894 GenMailBool(l,GlobalDir+"mail-greylist","mailGreylisting");
895 GenMailBool(l,GlobalDir+"mail-callout","mailCallout");
896 GenMailList(l,GlobalDir+"mail-rbl","mailRBL");
897 GenMailList(l,GlobalDir+"mail-rhsbl","mailRHSBL");
898 GenMailList(l,GlobalDir+"mail-whitelist","mailWhitelist");
899 GenKeyrings(l,GlobalDir);
902 GenForward(l,GlobalDir+"forward-alias");
914 Split = Line.split(" ")
915 OutDir = GenerateDir + '/' + Split[0] + '/';
916 try: os.mkdir(OutDir);
919 # Get the group list and convert any named groups to numerics
927 if GroupIDMap.has_key(I):
928 GroupList[str(GroupIDMap[I])] = None;
933 CurrentHost = Split[0];
935 # If we're using a single SSH file, deal with it
936 if SSHGlobal is not None:
937 DoLink(GlobalDir, OutDir, SSHGlobal)
939 DoLink(GlobalDir,OutDir,"debianhosts");
940 DoLink(GlobalDir,OutDir,"ssh_known_hosts");
941 DoLink(GlobalDir,OutDir,"disabled-accounts")
944 if ExtraList.has_key("[NOPASSWD]"):
945 userlist = GenPasswd(l,OutDir+"passwd",Split[1], "*");
947 userlist = GenPasswd(l,OutDir+"passwd",Split[1], "x");
949 grouprevmap = GenGroup(l,OutDir+"group");
950 if ExtraList.has_key("[UNTRUSTED]"):
952 if not ExtraList.has_key("[NOPASSWD]"):
953 GenShadow(l,OutDir+"shadow");
955 # Now we know who we're allowing on the machine, export
956 # the relevant ssh keys
958 tf = tarfile.open(name=os.path.join(GlobalDir, 'ssh-keys-%s.tar.gz' % CurrentHost), mode='w:gz')
959 for f in userlist.keys():
960 if f not in SSHFiles:
962 # If we're not exporting their primary group, don't export
965 if userlist[f] in grouprevmap.keys():
966 grname = grouprevmap[userlist[f]]
969 if int(userlist[f]) <= 100:
970 # In these cases, look it up in the normal way so we
971 # deal with cases where, for instance, users are in group
972 # users as their primary group.
973 grname = grp.getgrgid(int(userlist[f]))[0]
978 print "User %s is supposed to have their key exported to host %s but their primary group (gid: %s) isn't in LDAP" % (f, CurrentHost, userlist[f])
981 to = tf.gettarinfo(os.path.join(GlobalDir, 'userkeys', f), f)
982 # These will only be used where the username doesn't
983 # exist on the target system for some reason; hence,
984 # in those cases, the safest thing is for the file to
985 # be owned by root but group nobody. This deals with
986 # the bloody obscure case where the group fails to exist
987 # whilst the user does (in which case we want to avoid
988 # ending up with a file which is owned user:root to avoid
989 # a fairly obvious attack vector)
992 # Using the username / groupname fields avoids any need
993 # to give a shit^W^W^Wcare about the UIDoffset stuff.
997 tf.addfile(to, file(os.path.join(GlobalDir, 'userkeys', f)))
1000 os.rename(os.path.join(GlobalDir, 'ssh-keys-%s.tar.gz' % CurrentHost),
1001 os.path.join(OutDir, 'ssh-keys.tar.gz'))
1003 # Link in global things
1004 DoLink(GlobalDir,OutDir,"markers");
1005 DoLink(GlobalDir,OutDir,"mail-forward.cdb");
1006 DoLink(GlobalDir,OutDir,"mail-disable");
1007 DoLink(GlobalDir,OutDir,"mail-greylist");
1008 DoLink(GlobalDir,OutDir,"mail-callout");
1009 DoLink(GlobalDir,OutDir,"mail-rbl");
1010 DoLink(GlobalDir,OutDir,"mail-rhsbl");
1011 DoLink(GlobalDir,OutDir,"mail-whitelist");
1014 DoLink(GlobalDir,OutDir,"forward-alias");
1016 if ExtraList.has_key("[DNS]"):
1017 GenDNS(l,OutDir+"dns-zone",Split[1]);
1018 GenSSHFP(l,OutDir+"dns-sshfp",Split[1])
1020 if ExtraList.has_key("[BSMTP]"):
1021 GenBSMTP(l,OutDir+"bsmtp",Split[1])
1023 if ExtraList.has_key("[PRIVATE]"):
1024 DoLink(GlobalDir,OutDir,"debian-private")
1026 if ExtraList.has_key("[KEYRING]"):
1028 DoLink(GlobalDir,OutDir,os.path.basename(k))
1031 try: posix.remove(OutDir+os.path.basename(k));