diff options
author | Sol Jerome <solj@ices.utexas.edu> | 2009-01-29 21:36:46 +0000 |
---|---|---|
committer | Sol Jerome <solj@ices.utexas.edu> | 2009-01-29 21:36:46 +0000 |
commit | 8c2821c5134f5dfc7f78183793fcb8c1b4d92e00 (patch) | |
tree | 5efbf6fcb9a507133d842de4638f1b873822bf93 /src/lib/Server/Plugins | |
parent | 4d1544016635254d1c51ec77e3e26699d64b1d26 (diff) | |
download | bcfg2-8c2821c5134f5dfc7f78183793fcb8c1b4d92e00.tar.gz bcfg2-8c2821c5134f5dfc7f78183793fcb8c1b4d92e00.tar.bz2 bcfg2-8c2821c5134f5dfc7f78183793fcb8c1b4d92e00.zip |
Use safer alternatives to mktemp (Patch from adeason)
Signed-off-by: Sol Jerome <solj@ices.utexas.edu>
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5049 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server/Plugins')
-rw-r--r-- | src/lib/Server/Plugins/Cfg.py | 8 |
1 files changed, 6 insertions, 2 deletions
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() |