create ssh_known_hosts file
authorrmurray <>
Mon, 3 Dec 2001 07:54:11 +0000 (07:54 +0000)
committerrmurray <>
Mon, 3 Dec 2001 07:54:11 +0000 (07:54 +0000)
ud-generate
ud-host
userdir_ldap.py

index f9f8841..a379826 100755 (executable)
@@ -181,40 +181,6 @@ def GenSSHShadow(l,File):
      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;
@@ -471,6 +437,48 @@ def GenDNS(l,File,BSMTPFile,HomePrefix):
   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");
@@ -496,7 +504,7 @@ PasswdAttrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"uid=*",\
                  "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:
@@ -506,11 +514,11 @@ else:
 
 # 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");
@@ -556,6 +564,7 @@ while(1):
    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");
diff --git a/ud-host b/ud-host
index 09a91ec..0c8d12f 100755 (executable)
--- a/ud-host
+++ b/ud-host
@@ -26,8 +26,8 @@ AttrInfo = {"description": ["Machine Descr.", 1],
             "machine": ["Machine Hardware", 10],
             "memory": ["Memory", 11],
             "disk": ["Disk", 12],
-            "sshrsahostkey": ["SSH RSA", 14],
-            "bandwidth": ["Bandwidth", 16]};
+            "sshrsahostkey": ["SSH Host Keys", 14],
+            "bandwidth": ["Bandwidth", 15]};
 
 AttrPrompt = {"description": ["Purpose of the machine"],
               "hostname": ["The hostnames for the box (ipv4/ipv6)"],
index 827d8b1..2511c71 100644 (file)
@@ -11,7 +11,7 @@ File.close();
 
 # Cheap hack
 BaseDn = ConfModule.basedn;
-BaseDn = ConfModule.basedn;
+HostBaseDn = ConfModule.hostbasedn;
 LDAPServer = ConfModule.ldaphost;
 EmailAppend = ConfModule.emailappend;
 AdminUser = ConfModule.adminuser;