From acba0c4a1089f228d1c839c0ca2829a7409fe570 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 7 Nov 2019 12:25:19 +0100 Subject: [PATCH] Use a proper subprocess for conf test instead of dirty os.system + store errors if there are --- src/yunohost/service.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/yunohost/service.py b/src/yunohost/service.py index 253e87d78..e3a584c41 100644 --- a/src/yunohost/service.py +++ b/src/yunohost/service.py @@ -334,8 +334,17 @@ def service_status(names=[]): # 'test-status' is an optional field to test the status of the service using a custom command if "test-conf" in services[name]: - conf = os.system(services[name]["test-conf"] + " &>/dev/null") - result[name]["configuration"] = "valid" if conf == 0 else "broken" + p = subprocess.Popen(services[name]["test-conf"], + shell=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + + out, _ = p.communicate() + if p.returncode == 0: + result[name]["configuration"] = "valid" + else: + result[name]["configuration"] = "broken" + result[name]["configuration-details"] = out.strip().split("\n") if len(names) == 1: return result[names[0]]