summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2004-01-06 05:32:45 +0000
committerNarayan Desai <desai@mcs.anl.gov>2004-01-06 05:32:45 +0000
commitacd7a13f1fa267f675f81bac33e05791ed86096a (patch)
tree172810f7921b2d12e8a9ab8501f5ddc224575261 /src
parent90238504a2dc317e37615f4094729ec573b7939e (diff)
downloadbcfg2-acd7a13f1fa267f675f81bac33e05791ed86096a.tar.gz
bcfg2-acd7a13f1fa267f675f81bac33e05791ed86096a.tar.bz2
bcfg2-acd7a13f1fa267f675f81bac33e05791ed86096a.zip
Rename: src/sshbase.py -> generators/sshbase.py
}(Logical change 1.11) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@39 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r--src/sshbase.py66
1 files changed, 0 insertions, 66 deletions
diff --git a/src/sshbase.py b/src/sshbase.py
deleted file mode 100644
index 5ab69a015..000000000
--- a/src/sshbase.py
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/usr/bin/env python
-
-from glob import glob
-from os import rename, stat
-from socket import gethostbyname
-
-from Types import ConfigFile
-from Generator import Generator
-
-class sshbase(Generator):
- __name__ = 'sshbase'
- __version__ = '$Id$'
- __author__ = 'bcfg-dev@mcs.anl.gov'
- __build__ = { '/etc/ssh/ssh_known_hosts':'build_skn',
- '/etc/ssh/ssh_host_dsa_key':'build_hk',
- '/etc/ssh/ssh_host_rsa_key':'build_hk',
- '/etc/ssh/ssh_host_dsa_key.pub':'build_hk',
- '/etc/ssh/ssh_host_rsa_key.pub':'build_hk'}
-
- def build_skn(self,name,client):
- data=file("%s/ssh_known_hosts"%(self.data)).read()
- ip=gethostbyname(client)
- for hostkey in ["ssh_host_dsa_key.pub.H_%s","ssh_host_rsa_key.pub.H_%s","ssh_host_key.pub.H_%s"]:
- filename="%s/%s"%(self.data,hostkey)%(client)
- hdata=file(filename).read()
- data+="%s,%s,%s %s"%(client,"%s.mcs.anl.gov"%(client),ip,hdata)
- return ConfigFile(name,'root','root','0644',data)
-
- def build_hk(self,name,client):
- reponame="%s/%s.H_%s"%(self.data,name.split('/')[-1],client)
- try:
- stat(reponame)
- except IOError:
- self.GenerateHostKeys(client)
- self.GenerateKnownHosts()
- # then we read the data file
- keydata=file(reponame).read()
- if "ssh_host_key.H_" in reponame:
- return ConfigFile(name,'root','root','0600',keydata,'base64')
- return ConfigFile(name,'root','root','0600',keydata)
-
- def GenerateKnownHosts(self):
- output=file("%s/ssh_known_hosts"%(self.__data__),'w')
- for f in glob("%s/ssh_host_key.pub.H_*"%(self.__data__)) + glob("%s/ssh_host_*sa_key.pub.H_*"%(self.__data__)):
- host=f.split('_')[-1]
- data=file(f).read()
- output.write("%s,%s.mcs.anl.gov,%s %s"%(host,host,gethostbyname(host),data))
- output.close()
-
- def GenerateHostKeys(self,client):
- for hostkey in ["ssh_host_dsa_key.H_%s","ssh_host_rsa_key.H_%s","ssh_host_key.H_%s"]:
- filename="%s/%s"%(self.data,hostkey)%(client)
- if "ssh_host_rsa_key.H_" in filename:
- keytype='rsa'
- elif "ssh_host_dsa_key.H_" in filename:
- keytype='dsa'
- else:
- keytype='rsa1'
-
- try:
- stat(filename)
- except:
- system('ssh-keygen -f %s -N "" -t %s -C root@%s'%(filename,keytype,client))
- rename("%s.pub"%(filename),".".join(filename.split('.')[:-1]+['pub']+filename.split('.')[-1]))
- # call the notifier for global
-