diff options
-rw-r--r-- | src/lib/Client/Tools/Blast.py | 5 | ||||
-rw-r--r-- | src/lib/Client/Tools/SYSV.py | 5 | ||||
-rw-r--r-- | src/lib/Server/Plugins/Cfg.py | 8 | ||||
-rwxr-xr-x | src/sbin/bcfg2 | 4 |
4 files changed, 15 insertions, 7 deletions
diff --git a/src/lib/Client/Tools/Blast.py b/src/lib/Client/Tools/Blast.py index 6eb330c60..cd926accd 100644 --- a/src/lib/Client/Tools/Blast.py +++ b/src/lib/Client/Tools/Blast.py @@ -16,9 +16,10 @@ class Blast(Bcfg2.Client.Tools.SYSV.SYSV): def __init__(self, logger, setup, config): # dont use the sysv constructor Bcfg2.Client.Tools.PkgTool.__init__(self, logger, setup, config) - self.noaskname = tempfile.mktemp() + noaskfile = tempfile.NamedTemporaryFile() + self.noaskname = noaskfile.name try: - open(self.noaskname, 'w+').write(Bcfg2.Client.Tools.SYSV.noask) + noaskfile.write(Bcfg2.Client.Tools.SYSV.noask) except: pass diff --git a/src/lib/Client/Tools/SYSV.py b/src/lib/Client/Tools/SYSV.py index 22acb91ad..23875d4f9 100644 --- a/src/lib/Client/Tools/SYSV.py +++ b/src/lib/Client/Tools/SYSV.py @@ -31,9 +31,10 @@ class SYSV(Bcfg2.Client.Tools.PkgTool): def __init__(self, logger, setup, config): Bcfg2.Client.Tools.PkgTool.__init__(self, logger, setup, config) - self.noaskname = tempfile.mktemp() + noaskfile = tempfile.NamedTemporaryFile() + self.noaskname = noaskfile.name try: - open(self.noaskname, 'w+').write(noask) + noaskfile.write(noask) self.pkgtool = (self.pkgtool[0] % ("-a %s" % (self.noaskname)), \ self.pkgtool[1]) except: diff --git a/src/lib/Server/Plugins/Cfg.py b/src/lib/Server/Plugins/Cfg.py index f9a2f737d..1c283b041 100644 --- a/src/lib/Server/Plugins/Cfg.py +++ b/src/lib/Server/Plugins/Cfg.py @@ -20,12 +20,16 @@ def process_delta(data, delta): datalines.remove(line[1:]) return "\n".join(datalines) elif delta.op == 'diff': - basefile = open(tempfile.mktemp(), 'w') + basehandle, basename = tempfile.mkstemp() + basefile = open(basename, 'w') basefile.write(data) basefile.close() - dfile = open(tempfile.mktemp(), 'w') + os.close(basehandle) + dhandle, dname = tempfile.mkstemp() + dfile = open(dname, 'w') dfile.write(delta.data) dfile.close() + os.close(dhandle) ret = os.system("patch -uf %s < %s > /dev/null 2>&1" \ % (basefile.name, dfile.name)) output = open(basefile.name, 'r').read() diff --git a/src/sbin/bcfg2 b/src/sbin/bcfg2 index 0a4092b7f..039f5387a 100755 --- a/src/sbin/bcfg2 +++ b/src/sbin/bcfg2 @@ -166,12 +166,14 @@ class Client: self.logger.info("Running probe %s" % name) ret = Bcfg2.Client.XML.Element("probe-data", name=name, source=probe.get('source')) try: - script = open(tempfile.mktemp(), 'w+') + scripthandle, scriptname = tempfile.mkstemp() + script = open(scriptname, 'w+') try: script.write("#!%s\n" % (probe.attrib.get('interpreter', '/bin/sh'))) script.write(probe.text) script.close() + os.close(scripthandle) os.chmod(script.name, 0755) ret.text = os.popen(script.name).read().strip() self.logger.info("Probe %s has result:\n%s" % (name, ret.text)) |