diff -r 3e2a61e4832c -r 0fa973130581 src/lib/Server/Plugins/SSHbase.py
a
|
b
|
|
1 | 1 | '''This module manages ssh key files for bcfg2''' |
2 | 2 | __revision__ = '$Revision: 4680 $' |
3 | 3 | |
4 | | import binascii, os, socket |
| 4 | import binascii, os, socket, tempfile |
5 | 5 | import Bcfg2.Server.Plugin |
6 | 6 | |
7 | 7 | class SSHbase(Bcfg2.Server.Plugin.GeneratorPlugin, Bcfg2.Server.Plugin.DirectoryBacked): |
… |
… |
|
176 | 176 | if hostkey not in self.entries.keys(): |
177 | 177 | fileloc = "%s/%s" % (self.data, hostkey) |
178 | 178 | publoc = self.data + '/' + ".".join([hostkey.split('.')[0]]+['pub', "H_%s" % client]) |
179 | | temploc = "/tmp/%s" % hostkey |
| 179 | tempdir = tempfile.mkdtemp() |
| 180 | temploc = "%s/%s" % (tempdir, hostkey) |
180 | 181 | os.system('ssh-keygen -q -f %s -N "" -t %s -C [email protected]%s < /dev/null' % |
181 | 182 | (temploc, keytype, client)) |
182 | 183 | open(fileloc, 'w').write(open(temploc).read()) |
… |
… |
|
186 | 187 | try: |
187 | 188 | os.unlink(temploc) |
188 | 189 | os.unlink("%s.pub" % temploc) |
| 190 | os.rmdir(tempdir) |
189 | 191 | except OSError: |
190 | 192 | self.logger.error("Failed to unlink temporary ssh keys") |
191 | 193 | |