mirror of
https://github.com/valitydev/salt.git
synced 2024-11-06 16:45:27 +00:00
Add in the unpackage function and tie to it
This commit is contained in:
parent
077386b3c4
commit
26b4aa45b7
@ -105,7 +105,7 @@ class Auth(object):
|
||||
socket.connect(self.opts['master_uri'])
|
||||
payload = salt.payload.package(self.minion_sign_in_payload())
|
||||
socket.send(payload)
|
||||
ret = salt.utils.unpackage(socket.recv())
|
||||
ret = salt.payload.unpackage(socket.recv())
|
||||
if not self.verify_master(ret['pub_key'], ret['token']):
|
||||
return auth
|
||||
auth['aes'] = self.decrypt_master_aes(ret['aes'])
|
||||
|
@ -20,6 +20,23 @@ def package(payload, form='pickle', protocol=2):
|
||||
package = pickle.dumps(payload, protocol)
|
||||
return package
|
||||
|
||||
def unpackage(package):
|
||||
'''
|
||||
Unpackages a payload
|
||||
'''
|
||||
# yes, this is dirty for json support, I know it needs some love
|
||||
payload = None
|
||||
try:
|
||||
payload = pickle.loads(package)
|
||||
except:
|
||||
pass
|
||||
if not payload:
|
||||
try:
|
||||
payload = json.loads(package)
|
||||
except ValueError:
|
||||
pass
|
||||
return payload
|
||||
|
||||
def aes(payload, key):
|
||||
'''
|
||||
Encrypt the payload with AES encryption.
|
||||
|
Loading…
Reference in New Issue
Block a user