From fd7a6c50204b9f3bc0dfb992b981c595bced85a3 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Thu, 18 Jan 2018 14:44:25 +0100 Subject: [PATCH] cond.c: Normalize COND_PATH, some systems have /run not /var/run On most modern Linux systems /run is a tmpfs that replaces /var/run. The latter is set up as a symlink to /run by the bootmisc.so plugin. However, Finit conditions rely on the /var/run/finit/cond prefix, which does not exist until bootmisc.so has run, which is *after* `mount -a` has run. Therefore, to have working conditions before we run `mount -a` we must normalize the path constructed by cond_path() to use either the /run or /var/run (default) prefix. Signed-off-by: Joachim Nilsson --- src/cond.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cond.c b/src/cond.c index 67e73e78..15a02088 100644 --- a/src/cond.c +++ b/src/cond.c @@ -26,6 +26,7 @@ #include "finit.h" #include "cond.h" +#include "pid.h" #include "service.h" @@ -42,11 +43,12 @@ const char *condstr(enum cond_state s) const char *cond_path(const char *name) { + char tmp[MAX_ARG_LEN]; static char file[MAX_ARG_LEN]; - snprintf(file, sizeof(file), COND_PATH "/%s", name); + snprintf(tmp, sizeof(tmp), COND_PATH "/%s", name); - return file; + return pid_runpath(tmp, file, sizeof(file)); } unsigned int cond_get_gen(const char *path)