mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix open filehandles
This fixes two cases of filehandles being left open by failing to use a with clause.
This commit is contained in:
parent
8708096365
commit
66251263cf
1 changed files with 4 additions and 2 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Reference in a new issue