raise "cdbmake gave an error";
Done(File,F,None);
-def GenSSH2Shadow(l,File):
- F = None;
- Fdb = None;
- try:
- OldMask = os.umask(0077);
- F = open(File + ".tmp","w",0600);
- Fdb = os.popen("cdbmake %s.cdb %s.cdb.tmp"%(File,File),"w");
- os.umask(OldMask);
-
- # Fetch all the users
- global PasswdAttrs;
- if PasswdAttrs == None:
- raise "No Users";
-
- I = 0;
- for x in PasswdAttrs:
- if x[1].has_key("uidnumber") == 0 or \
- x[1].has_key("sshdsaauthkey") == 0:
- continue;
- for I in x[1]["sshdsaauthkey"]:
- User = GetAttr(x,"uid");
- Line = "%s: %s" %(User,I);
- Line = Sanitize(Line) + "\n";
- F.write(Line);
- Fdb.write("+%d,%d:%s->%s\n"%(len(User),len(I),User,I));
- Fdb.write("\n");
- # Oops, something unspeakable happened.
- except:
- Die(File,F,Fdb);
- raise;
- if Fdb.close() != None:
- raise "cdbmake gave an error";
- Done(File,F,None);
-
# Generate the group list
def GenGroup(l,File):
F = None;
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" %(Host,I);
+ else:
+ Line = "%s,%s %s" %(Host,Host[0:SHost],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.
+ except:
+ Die(File,F,Fdb);
+ raise;
+ if Fdb.close() != None:
+ raise "cdbmake gave an error";
+ Done(File,F,None);
+
+
# Connect to the ldap server
l = ldap.open(LDAPServer);
F = open(PassDir+"/pass-"+pwd.getpwuid(os.getuid())[0],"r");
"shadowmin","shadowmax","shadowwarning","shadowinactive",
"shadowexpire","emailforward","latitude","longitude",\
"allowedhosts","sshrsaauthkey","dnszoneentry","cn","sn",\
- "keyfingerprint","privatesub","sshdsaauthkey"]);
+ "keyfingerprint","privatesub"]);
# Open the control file
if len(sys.argv) == 1:
# Generate global things
GlobalDir = GenerateDir+"/";
-GenSSH2Shadow(l,GlobalDir+"ssh-dsa-shadow");
GenSSHShadow(l,GlobalDir+"ssh-rsa-shadow");
GenAllForward(l,GlobalDir+"mail-forward.cdb");
GenMarkers(l,GlobalDir+"markers");
GenPrivate(l,GlobalDir+"debian-private");
+GenSSHKnown(l,GlobalDir+"ssh_known_hosts");
# Compatibility.
GenForward(l,GlobalDir+"forward-alias");
DoLink(GlobalDir,OutDir,"ssh-rsa-shadow.cdb");
DoLink(GlobalDir,OutDir,"markers");
DoLink(GlobalDir,OutDir,"mail-forward.cdb");
+ DoLink(GlobalDir,OutDir,"ssh_known_hosts");
# Compatibility.
DoLink(GlobalDir,OutDir,"forward-alias");