diff options
author | Sol Jerome <solj@ices.utexas.edu> | 2010-03-26 00:24:16 +0000 |
---|---|---|
committer | Sol Jerome <solj@ices.utexas.edu> | 2010-03-25 19:26:27 -0500 |
commit | 8999c249ccc3d93f08060fbfb0b7598e7e15cfda (patch) | |
tree | 49718a57f01f0d4352471fd01d3be530216fcaea /src/lib/Server | |
parent | f7cdad6b141b86eeb6e52c0ba590f475d166aa65 (diff) | |
download | bcfg2-8999c249ccc3d93f08060fbfb0b7598e7e15cfda.tar.gz bcfg2-8999c249ccc3d93f08060fbfb0b7598e7e15cfda.tar.bz2 bcfg2-8999c249ccc3d93f08060fbfb0b7598e7e15cfda.zip |
SSHbase: Use shutil as per Lee's suggestion in Ticket #866
From the ticket:
---
From what I can tell, there is an os.system call (line #214 of
Bcfg2/Server/Plugins/SSHbase.py) that is supposed to fire off ssh-keygen
to generate the keys in a temporary directory. It seems that this call
isn't generating the keys correctly. Adding in some debug
os.listdir(tempdir) calls before and after the os.system call, shows
that there are no files before and after the os.system call. Running the
command manually generates valid key pairs.
---
So, while this commit won't fix the os.system call, it should at least
prevent the plugin from generating empty ssh keys.
Signed-off-by: Sol Jerome <solj@ices.utexas.edu>
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5794 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server')
-rw-r--r-- | src/lib/Server/Plugins/SSHbase.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lib/Server/Plugins/SSHbase.py b/src/lib/Server/Plugins/SSHbase.py index 4e26001c1..e5cabfbd5 100644 --- a/src/lib/Server/Plugins/SSHbase.py +++ b/src/lib/Server/Plugins/SSHbase.py @@ -4,6 +4,7 @@ __revision__ = '$Revision$' import binascii import os import socket +import shutil import tempfile from subprocess import Popen, PIPE import Bcfg2.Server.Plugin @@ -252,8 +253,8 @@ class SSHbase(Bcfg2.Server.Plugin.Plugin, temploc = "%s/%s" % (tempdir, hostkey) cmd = 'ssh-keygen -q -f %s -N "" -t %s -C root@%s < /dev/null' os.system(cmd % (temploc, keytype, client)) - open(fileloc, 'w').write(open(temploc).read()) - open(publoc, 'w').write(open("%s.pub" % temploc).read()) + shutil.copy(temploc, fileloc) + shutil.copy("%s.pub" % temploc, publoc) self.AddEntry(hostkey) self.AddEntry(".".join([hostkey.split('.')[0]]+['pub', "H_%s" \ % client])) |