mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Handle missing source file in ssh_auth.
Added one more condition to check if source file exsists. In case source is set but source is not a file data and err variables are set to return a proper response. Fixes #29654
This commit is contained in:
parent
fe0778dad5
commit
fc024e3cf4
1 changed files with 10 additions and 0 deletions
|
@ -282,7 +282,13 @@ def present(
|
|||
)
|
||||
return ret
|
||||
|
||||
# Get only the path to the file without env referrences to check if exists
|
||||
if source != '':
|
||||
source_path = __salt__['cp.get_url'](source, None)
|
||||
|
||||
if source != '' and not source_path:
|
||||
data = 'no key'
|
||||
elif source != '' and source_path:
|
||||
key = __salt__['cp.get_file_str'](
|
||||
source,
|
||||
saltenv=__env__)
|
||||
|
@ -332,6 +338,10 @@ def present(
|
|||
ret['changes'][name] = 'New'
|
||||
ret['comment'] = ('The authorized host key {0} for user {1} was added'
|
||||
.format(name, user))
|
||||
elif data == 'no key':
|
||||
ret['result'] = False
|
||||
ret['comment'] = ('Failed to add the ssh key. Source file {0} is '
|
||||
'missing'.format(source))
|
||||
elif data == 'fail':
|
||||
ret['result'] = False
|
||||
err = sys.modules[
|
||||
|
|
Loading…
Add table
Reference in a new issue