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,12 +456,19 @@ class Action(object): ...@@ -457,12 +456,19 @@ 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 output_stream: with tempfile.NamedTemporaryFile() as error_stream:
subprocess.check_call(script_command, env=self.config_environment, shell=True, with tempfile.NamedTemporaryFile() as output_stream:
stdout=output_stream, stderr=subprocess.STDOUT) subprocess.check_call(script_command, env=self.config_environment, shell=True,
output_stream.seek(0) stdout=output_stream, stderr=error_stream)
script_output = output_stream.read() output_stream.seek(0)
return script_output 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: 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,
traceback.format_exc())) 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