mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge branch '2017.7' into bugs/43447_syndic_events_forwarding
This commit is contained in:
commit
64d6109654
1 changed files with 7 additions and 4 deletions
|
@ -740,10 +740,13 @@ def set_auth_key(
|
|||
with salt.utils.fopen(fconfig, 'ab+') as _fh:
|
||||
if new_file is False:
|
||||
# Let's make sure we have a new line at the end of the file
|
||||
_fh.seek(1024, 2)
|
||||
if not _fh.read(1024).rstrip(six.b(' ')).endswith(six.b('\n')):
|
||||
_fh.seek(0, 2)
|
||||
_fh.write(six.b('\n'))
|
||||
_fh.seek(0, 2)
|
||||
if _fh.tell() > 0:
|
||||
# File isn't empty, check if last byte is a newline
|
||||
# If not, add one
|
||||
_fh.seek(-1, 2)
|
||||
if _fh.read(1) != six.b('\n'):
|
||||
_fh.write(six.b('\n'))
|
||||
if six.PY3:
|
||||
auth_line = auth_line.encode(__salt_system_encoding__)
|
||||
_fh.write(auth_line)
|
||||
|
|
Loading…
Add table
Reference in a new issue