Convert input values to str

If non-string values are provided to a software deployment,
os-refresh-config fails with:
  'TypeError: execve() arg 3 contains a non-string value'

Patch converts all values to strings if they should be strings.

Change-Id: Ifa442538da063e1f3034d02e9cc4f5ba6494206a
Closes-Bug: #1333992
This commit is contained in:
Steve McLellan 2014-06-24 15:45:08 -05:00 committed by Thomas Herve
parent 7d022b296c
commit a195618c94
1 changed files with 8 additions and 0 deletions

View File

@ -48,6 +48,14 @@ def invoke_hook(c, log):
log.warn('Skipping group %s with no hook script %s' % (
c['group'], hook_path))
else:
# Sanitize input values (bug 1333992). Convert all String
# inputs to strings if they're not already
hot_inputs = c.get('inputs', [])
for hot_input in hot_inputs:
if hot_input.get('type', None) == 'String' and \
not isinstance(hot_input['value'], basestring):
hot_input['value'] = str(hot_input['value'])
log.debug('Running %s' % hook_path)
subproc = subprocess.Popen([hook_path],
stdin=subprocess.PIPE,