From 078a1d0c95108e0a91dc711ce8a00bf76d73245a Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 7 Mar 2022 14:02:21 +0100 Subject: [PATCH] initctl: if the system doesn't have logs, skip it in status output On, e.g., a container based system logs may not be available so check also that the messages fallback exists instead of causing confusing error in the status output for the service. Signed-off-by: Joachim Wiberg --- src/initctl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/initctl.c b/src/initctl.c index 67e0e6a3..6b11a7fa 100644 --- a/src/initctl.c +++ b/src/initctl.c @@ -161,8 +161,11 @@ static int do_log(char *svc) if (!svc || !svc[0]) svc = "finit"; - if (!fexist(logfile)) + if (!fexist(logfile)) { logfile = "/var/log/messages"; + if (!fexist(logfile)) + return 0; /* bail out, maybe in container */ + } return systemf("cat %s | grep %s | tail -10", logfile, svc); }