mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix issue #50381
This commit is contained in:
parent
7ab1281a7d
commit
6493eb0945
1 changed files with 9 additions and 4 deletions
|
@ -1722,16 +1722,21 @@ class Keys(LowDataAdapter):
|
|||
priv_key_file = tarfile.TarInfo('minion.pem')
|
||||
priv_key_file.size = len(priv_key)
|
||||
|
||||
fileobj = six.StringIO()
|
||||
fileobj = BytesIO()
|
||||
tarball = tarfile.open(fileobj=fileobj, mode='w')
|
||||
tarball.addfile(pub_key_file, six.StringIO(pub_key))
|
||||
tarball.addfile(priv_key_file, six.StringIO(priv_key))
|
||||
|
||||
if six.PY3:
|
||||
pub_key = pub_key.encode(__salt_system_encoding__)
|
||||
priv_key = priv_key.encode(__salt_system_encoding__)
|
||||
|
||||
tarball.addfile(pub_key_file, BytesIO(pub_key))
|
||||
tarball.addfile(priv_key_file, BytesIO(priv_key))
|
||||
tarball.close()
|
||||
|
||||
headers = cherrypy.response.headers
|
||||
headers['Content-Disposition'] = 'attachment; filename="saltkeys-{0}.tar"'.format(lowstate[0]['id_'])
|
||||
headers['Content-Type'] = 'application/x-tar'
|
||||
headers['Content-Length'] = fileobj.len
|
||||
headers['Content-Length'] = len(fileobj.getvalue())
|
||||
headers['Cache-Control'] = 'no-cache'
|
||||
|
||||
fileobj.seek(0)
|
||||
|
|
Loading…
Add table
Reference in a new issue