summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIrina Muchnik <imuchnik@users.noreply.github.com>2016-12-10 06:33:34 -0800
committerToshio Kuratomi <a.badger@gmail.com>2016-12-12 10:19:28 -0800
commitc116898ac5aa08c7af44733631adb5aa44e677ad (patch)
tree5c4a0a159c63399344cc13b8ec24b52584d453d8
parent9c5fa68ff77a523349a2ecf3e6824742051aeed5 (diff)
downloadansible-modules-extras-c116898ac5aa08c7af44733631adb5aa44e677ad.tar.gz
Fix secure temp file creation (#19096)
* For realz this time * Fix tempfile.mkstemp (#2) * back to square one, removing temp file from the mix * Adding temp back * Adding tuple back * Adding another tuple back * Trying to get around weird Jenkins behavior of blowing up when both .hpi and jpi file found * Incorporating PR feedback * Delete .hpi file instead of backing it up, some basic clean up * Moving file deletion to the right location * Blank lines. They always get me. (cherry picked from 9f58e69d63264574d3ad3704749fb86e50859f77)
-rw-r--r--web_infrastructure/jenkins_plugin.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/web_infrastructure/jenkins_plugin.py b/web_infrastructure/jenkins_plugin.py
index af5adb46..43f5a1a4 100644
--- a/web_infrastructure/jenkins_plugin.py
+++ b/web_infrastructure/jenkins_plugin.py
@@ -438,6 +438,13 @@ class JenkinsPlugin(object):
msg_exception="Plugin installation has failed.",
data=data)
+ hpi_file = '%s/plugins/%s.hpi' % (
+ self.params['jenkins_home'],
+ self.params['name'])
+
+ if os.path.isfile(hpi_file):
+ os.remove(hpi_file)
+
changed = True
else:
# Check if the plugin directory exists
@@ -563,7 +570,7 @@ class JenkinsPlugin(object):
msg_exception="Updates download failed.")
# Write the updates file
- updates_file = tempfile.mkstemp()
+ update_fd, updates_file = tempfile.mkstemp()
try:
fd = open(updates_file, 'wb')
@@ -640,7 +647,7 @@ class JenkinsPlugin(object):
def _write_file(self, f, data):
# Store the plugin into a temp file and then move it
- tmp_f = tempfile.mkstemp()
+ tmp_f_tuple, tmp_f = tempfile.mkstemp()
try:
fd = open(tmp_f, 'wb')