+ except:
+ Die(File,F,None);
+ Die(BSMTPFile,FB,None);
+ raise;
+ Done(File,F,None);
+ Done(BSMTPFile,FB,None);
+
+# Generate the shadow list
+def GenSSHKnown(l,File):
+ F = None;
+ Fdb = None;
+ try:
+ OldMask = os.umask(0022);
+ F = open(File + ".tmp","w",0644);
+ Fdb = os.popen("cdbmake %s.cdb %s.cdb.tmp"%(File,File),"w");
+ os.umask(OldMask);
+
+ # Fetch all the hosts
+ HostKeys = l.search_s(HostBaseDn,ldap.SCOPE_ONELEVEL,"sshrsahostkey=*",\
+ ["hostname","sshrsahostkey"]);
+
+ if HostKeys == None:
+ raise "No Hosts";
+
+ I = 0;
+ for x in HostKeys:
+ if x[1].has_key("hostname") == 0 or \
+ x[1].has_key("sshrsahostkey") == 0:
+ continue;
+ Host = GetAttr(x,"hostname");
+ SHost = string.find(Host,".");
+ for I in x[1]["sshrsahostkey"]:
+ if SHost == None:
+ Line = "%s,%s %s" %(Host,socket.gethostbyname(Host),I);
+ else:
+ Line = "%s,%s,%s %s" %(Host,Host[0:SHost],socket.gethostbyname(Host),I);
+ Line = Sanitize(Line) + "\n";
+ F.write(Line);
+ Fdb.write("+%d,%d:%s->%s\n"%(len(Host),len(I),Host,I));
+ Fdb.write("\n");
+ # Oops, something unspeakable happened.