mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Fixing an issue with the import_key method. Different results depending on which gnupg python module is installed.
This commit is contained in:
parent
f52f7e1d20
commit
80c24be4fe
@ -611,23 +611,29 @@ def import_key(user=None,
|
||||
raise SaltInvocationError('filename does not exist.')
|
||||
|
||||
imported_data = gpg.import_keys(text)
|
||||
log.debug('imported_data {0}'.format(imported_data.__dict__.keys()))
|
||||
log.debug('imported_data {0}'.format(imported_data.counts))
|
||||
|
||||
if imported_data.counts:
|
||||
if imported_data.counts['imported'] or imported_data.counts['imported_rsa']:
|
||||
if GPG_1_3_1:
|
||||
counts = imported_data.counts
|
||||
if counts.get('imported') or counts.get('imported_rsa'):
|
||||
ret['message'] = 'Successfully imported key(s).'
|
||||
elif imported_data.counts['unchanged']:
|
||||
elif counts.get('unchanged'):
|
||||
ret['message'] = 'Key(s) already exist in keychain.'
|
||||
elif imported_data.counts['not_imported']:
|
||||
elif counts.get('not_imported'):
|
||||
ret['res'] = False
|
||||
ret['message'] = 'Unable to import key.'
|
||||
elif not imported_data.counts['count']:
|
||||
elif not counts.get('count'):
|
||||
ret['res'] = False
|
||||
ret['message'] = 'Unable to import key.'
|
||||
else:
|
||||
ret['res'] = False
|
||||
ret['message'] = 'Unable to import key.'
|
||||
if imported_data.imported or imported_data.imported_rsa:
|
||||
ret['message'] = 'Successfully imported key(s).'
|
||||
elif imported_data.unchanged:
|
||||
ret['message'] = 'Key(s) already exist in keychain.'
|
||||
elif imported_data.not_imported:
|
||||
ret['res'] = False
|
||||
ret['message'] = 'Unable to import key.'
|
||||
elif not imported_data.count:
|
||||
ret['res'] = False
|
||||
ret['message'] = 'Unable to import key.'
|
||||
return ret
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user