Merge pull request #40424 from terminalmage/fix-open-filehandle

Fix open filehandles
This commit is contained in:
Nicole Thomas 2017-03-30 11:51:20 -06:00 committed by GitHub
commit d4fb45d9f8

View File

@ -862,7 +862,8 @@ class AsyncAuth(object):
m_pub_fn = os.path.join(self.opts['pki_dir'], self.mpub)
m_pub_exists = os.path.isfile(m_pub_fn)
if m_pub_exists and master_pub and not self.opts['open_mode']:
local_master_pub = salt.utils.fopen(m_pub_fn).read()
with salt.utils.fopen(m_pub_fn) as fp_:
local_master_pub = fp_.read()
if payload['pub_key'].replace('\n', '').replace('\r', '') != \
local_master_pub.replace('\n', '').replace('\r', ''):
@ -912,7 +913,8 @@ class AsyncAuth(object):
if not m_pub_exists:
# the minion has not received any masters pubkey yet, write
# the newly received pubkey to minion_master.pub
salt.utils.fopen(m_pub_fn, 'wb+').write(payload['pub_key'])
with salt.utils.fopen(m_pub_fn, 'wb+') as fp_:
fp_.write(payload['pub_key'])
return self.extract_aes(payload, master_pub=False)
def _finger_fail(self, finger, master_key):