diff options
Diffstat (limited to 'src/sshbase.py')
-rw-r--r-- | src/sshbase.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/sshbase.py b/src/sshbase.py index 14ddb45c0..5ab69a015 100644 --- a/src/sshbase.py +++ b/src/sshbase.py @@ -1,7 +1,7 @@ #!/usr/bin/env python from glob import glob -from os import rename +from os import rename, stat from socket import gethostbyname from Types import ConfigFile @@ -9,23 +9,25 @@ from Generator import Generator class sshbase(Generator): __name__ = 'sshbase' - __version__ = '$Id: $' + __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'} - __build__ = { '/etc/ssh/ssh_known_hosts':build_skn, - '/etc/ssh/ssh_host_key':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,"%.mcs.anl.gov"%(client),ip,hdata) + 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) + reponame="%s/%s.H_%s"%(self.data,name.split('/')[-1],client) try: stat(reponame) except IOError: @@ -61,3 +63,4 @@ class sshbase(Generator): 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 + |