Commit 9fe4591d authored by Ad Schellevis's avatar Ad Schellevis

(configd) send (part of) stderr to syslog for script_output tasks

parent 6eb68e2e
......@@ -24,7 +24,6 @@
POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------------
package : configd
function: unix domain socket process worker process
"""
......@@ -457,12 +456,19 @@ class Action(object):
return 'Execute error'
elif self.type.lower() == 'script_output':
try:
with tempfile.NamedTemporaryFile() as output_stream:
subprocess.check_call(script_command, env=self.config_environment, shell=True,
stdout=output_stream, stderr=subprocess.STDOUT)
output_stream.seek(0)
script_output = output_stream.read()
return script_output
with tempfile.NamedTemporaryFile() as error_stream:
with tempfile.NamedTemporaryFile() as output_stream:
subprocess.check_call(script_command, env=self.config_environment, shell=True,
stdout=output_stream, stderr=error_stream)
output_stream.seek(0)
error_stream.seek(0)
script_output = output_stream.read()
script_error_output = error_stream.read()
if len(script_error_output) > 0:
syslog.syslog(syslog.LOG_ERR, '[%s] Script action stderr returned "%s"' % (message_uuid,
script_error_output.strip()[:255])
)
return script_output
except:
syslog.syslog(syslog.LOG_ERR, '[%s] Script action failed at %s' % (message_uuid,
traceback.format_exc()))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment