Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if a valid value is passed to unlyif/unless #34838

Merged
merged 1 commit into from
Jul 21, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions salt/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
# pylint: disable=import-error,no-name-in-module,redefined-builtin
import salt.ext.six as six
from salt.ext.six.moves import map, range
from salt.ext.six import string_types
# pylint: enable=import-error,no-name-in-module,redefined-builtin

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -786,6 +787,9 @@ def _run_check(self, low_data):
else:
low_data_onlyif = low_data['onlyif']
for entry in low_data_onlyif:
if not isinstance(entry, string_types):
ret.update({'comment': 'onlyif execution failed, bad type passed', 'result': False})
return ret
cmd = self.functions['cmd.retcode'](
entry, ignore_retcode=True, python_shell=True, **cmd_opts)
log.debug('Last command return code: {0}'.format(cmd))
Expand All @@ -804,6 +808,9 @@ def _run_check(self, low_data):
else:
low_data_unless = low_data['unless']
for entry in low_data_unless:
if not isinstance(entry, string_types):
ret.update({'comment': 'unless execution failed, bad type passed', 'result': False})
return ret
cmd = self.functions['cmd.retcode'](
entry, ignore_retcode=True, python_shell=True, **cmd_opts)
log.debug('Last command return code: {0}'.format(cmd))
Expand Down