aboutsummaryrefslogtreecommitdiff
path: root/src/supervise-daemon
diff options
context:
space:
mode:
authorAnna (navi) Figueiredo Gomes <navi@vlhl.dev>2024-03-20 23:45:47 +0100
committerAnna (navi) Figueiredo Gomes <navi@vlhl.dev>2024-07-19 20:40:28 +0200
commitc34fcd63f05044f9034b26c52f19c91e04668da7 (patch)
tree8ef449218cf736057197cd39fba1dac6117216c3 /src/supervise-daemon
parent917a7031d946c0b608517936fab0f54689167265 (diff)
openrc: dynamic paths for user services
add two api functions, `rc_service_dir` and `rc_sysconf_dir`, both are generate paths (and sub-paths) for resources, and meant to replace the hardcoded variables like `RC_SVCDIR`. those functions differ by dynamically switching between the system path, or the user path, set in their home folder or runtime directory. this lays out the intial support for user services. Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
Diffstat (limited to 'src/supervise-daemon')
-rw-r--r--src/supervise-daemon/supervise-daemon.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/supervise-daemon/supervise-daemon.c b/src/supervise-daemon/supervise-daemon.c
index adf35630..9bc3c029 100644
--- a/src/supervise-daemon/supervise-daemon.c
+++ b/src/supervise-daemon/supervise-daemon.c
@@ -817,6 +817,7 @@ int main(int argc, char **argv)
char **child_argv = NULL;
char *str = NULL;
char *cmdline = NULL;
+ const char *svc_dir;
applet = basename_c(argv[0]);
atexit(cleanup);
@@ -1084,9 +1085,10 @@ int main(int argc, char **argv)
ch_root = expand_home(home, ch_root);
umask(numask);
+ svc_dir = rc_service_dir();
if (!pidfile)
- xasprintf(&pidfile, "/var/run/supervise-%s.pid", svcname);
- xasprintf(&fifopath, "%s/supervise-%s.ctl", RC_SVCDIR, svcname);
+ xasprintf(&pidfile, "%s/supervise-%s.pid", rc_is_user() ? svc_dir : "/var/run", svcname); /* FIXME: improve */
+ xasprintf(&fifopath, "%s/supervise-%s.ctl", svc_dir, svcname);
if (mkfifo(fifopath, 0600) == -1 && errno != EEXIST)
eerrorx("%s: unable to create control fifo: %s",
applet, strerror(errno));