summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2004-07-23 14:45:28 +0000
committerNarayan Desai <desai@mcs.anl.gov>2004-07-23 14:45:28 +0000
commite432db189fa8e7dd697b3624b2e5712a113a6cb2 (patch)
treeb8d86af316f44edd7ecddb558aae5f734713efe5
parent1c8fa0ada08b11cae1da9d18f47cd70e1c330334 (diff)
downloadbcfg2-e432db189fa8e7dd697b3624b2e5712a113a6cb2.tar.gz
bcfg2-e432db189fa8e7dd697b3624b2e5712a113a6cb2.tar.bz2
bcfg2-e432db189fa8e7dd697b3624b2e5712a113a6cb2.zip
update to new API
2004/07/08 14:49:43-05:00 anl.gov!desai add support for v1 host keys (Logical change 1.23) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@104 ce84e21b-d406-0410-9b95-82705330c041
-rw-r--r--generators/sshbase.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/generators/sshbase.py b/generators/sshbase.py
index 006eda31e..2a32390fc 100644
--- a/generators/sshbase.py
+++ b/generators/sshbase.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
from glob import glob
-from os import rename, stat
+from os import rename, stat, system
from socket import gethostbyname
from Types import ConfigFile
@@ -19,27 +19,31 @@ class sshbase(Generator):
'/etc/ssh/ssh_host_dsa_key':self.build_hk,
'/etc/ssh/ssh_host_rsa_key':self.build_hk,
'/etc/ssh/ssh_host_dsa_key.pub':self.build_hk,
- '/etc/ssh/ssh_host_rsa_key.pub':self.build_hk}}
+ '/etc/ssh/ssh_host_rsa_key.pub':self.build_hk,
+ '/etc/ssh/ssh_host_key':self.build_hk,
+ '/etc/ssh/ssh_host_key.pub':self.build_hk}}
- def build_skn(self,name,metadata):
+ def build_skn(self,entry,metadata):
client = metadata.hostname
filedata = self.repository.entries['ssh_known_hosts'].data
ip=gethostbyname(client)
keylist = map(lambda x:x%(client), ["ssh_host_dsa_key.pub.H_%s","ssh_host_rsa_key.pub.H_%s","ssh_host_key.pub.H_%s"])
for hostkey in keylist:
filedata += "%s,%s,%s %s"%(client,"%s.mcs.anl.gov"%(client),ip,self.repository.entries[hostkey].data)
- return ConfigFile(name,'root','root','0644',filedata)
+ entry.attrib.update({'owner':'root', 'group':'root', 'perms':'0644'})
+ entry.text = filedata
- def build_hk(self,name,metadata):
+ def build_hk(self,entry,metadata):
client = metadata.hostname
- filename = "%s.H_%s"%(name.split('/')[-1],client)
+ filename = "%s.H_%s"%(entry.attrib['name'].split('/')[-1],client)
if filename not in self.repository.entries.keys():
self.GenerateHostKeys(client)
self.GenerateKnownHosts()
keydata = self.repository.entries[filename].data
+ entry.attrib.update({'owner':'root', 'group':'root', 'perms':'0600'})
+ entry.text = keydata
if "ssh_host_key.H_" in filename:
- return ConfigFile(name,'root','root','0600',keydata,'base64')
- return ConfigFile(name,'root','root','0600',keydata)
+ entry.attrib['encoding'] = 'base64'
def GenerateKnownHosts(self):
output = ''