mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
When reading and writing the key cache file, when using Python3, ensuring the file is read & written in binary mode.
This commit is contained in:
parent
6b45aad5e7
commit
ebc9a01b38
2 changed files with 12 additions and 4 deletions
|
@ -250,8 +250,12 @@ class Maintenance(salt.utils.process.SignalHandlingMultiprocessingProcess):
|
|||
keys.append(fn_)
|
||||
log.debug('Writing master key cache')
|
||||
# Write a temporary file securely
|
||||
with salt.utils.atomicfile.atomic_open(os.path.join(self.opts['pki_dir'], acc, '.key_cache')) as cache_file:
|
||||
self.serial.dump(keys, cache_file)
|
||||
if six.PY2:
|
||||
with salt.utils.atomicfile.atomic_open(os.path.join(self.opts['pki_dir'], acc, '.key_cache')) as cache_file:
|
||||
self.serial.dump(keys, cache_file)
|
||||
else:
|
||||
with salt.utils.atomicfile.atomic_open(os.path.join(self.opts['pki_dir'], acc, '.key_cache'), mode='wb') as cache_file:
|
||||
self.serial.dump(keys, cache_file)
|
||||
|
||||
def handle_key_rotate(self, now):
|
||||
'''
|
||||
|
|
|
@ -245,8 +245,12 @@ class CkMinions(object):
|
|||
try:
|
||||
if self.opts['key_cache'] and os.path.exists(pki_cache_fn):
|
||||
log.debug('Returning cached minion list')
|
||||
with salt.utils.files.fopen(pki_cache_fn) as fn_:
|
||||
return self.serial.load(fn_)
|
||||
if six.PY2:
|
||||
with salt.utils.files.fopen(pki_cache_fn) as fn_:
|
||||
return self.serial.load(fn_)
|
||||
else:
|
||||
with salt.utils.files.fopen(pki_cache_fn, mode='rb') as fn_:
|
||||
return self.serial.load(fn_)
|
||||
else:
|
||||
for fn_ in salt.utils.data.sorted_ignorecase(os.listdir(os.path.join(self.opts['pki_dir'], self.acc))):
|
||||
if not fn_.startswith('.') and os.path.isfile(os.path.join(self.opts['pki_dir'], self.acc, fn_)):
|
||||
|
|
Loading…
Add table
Reference in a new issue