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 @@ ...@@ -24,7 +24,6 @@
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------
package : configd package : configd
function: unix domain socket process worker process function: unix domain socket process worker process
""" """
...@@ -457,11 +456,18 @@ class Action(object): ...@@ -457,11 +456,18 @@ class Action(object):
return 'Execute error' return 'Execute error'
elif self.type.lower() == 'script_output': elif self.type.lower() == 'script_output':
try: try:
with tempfile.NamedTemporaryFile() as error_stream:
with tempfile.NamedTemporaryFile() as output_stream: with tempfile.NamedTemporaryFile() as output_stream:
subprocess.check_call(script_command, env=self.config_environment, shell=True, subprocess.check_call(script_command, env=self.config_environment, shell=True,
stdout=output_stream, stderr=subprocess.STDOUT) stdout=output_stream, stderr=error_stream)
output_stream.seek(0) output_stream.seek(0)
error_stream.seek(0)
script_output = output_stream.read() 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 return script_output
except: except:
syslog.syslog(syslog.LOG_ERR, '[%s] Script action failed at %s' % (message_uuid, syslog.syslog(syslog.LOG_ERR, '[%s] Script action failed at %s' % (message_uuid,
......
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