Closes handle to temporary file before returning the path

Fixes #40417
This commit is contained in:
Loren Gordon 2017-03-30 10:29:06 -04:00
parent 7d900d31ea
commit 7baf2809cf

View File

@ -10,6 +10,7 @@ This is a thin wrapper around Pythons tempfile module
from __future__ import absolute_import
import logging
import os
import tempfile
log = logging.getLogger(__name__)
@ -40,4 +41,6 @@ def file(suffix='', prefix='tmp', parent=None):
salt '*' temp.file
salt '*' temp.file prefix='mytemp-' parent='/var/run/'
'''
return tempfile.mkstemp(suffix, prefix, parent)[1]
fh_, tmp_ = tempfile.mkstemp(suffix, prefix, parent)
os.close(fh_)
return tmp_