From 9efa44579fd1f60a4c9ace264bb0b968ccb0f7ea Mon Sep 17 00:00:00 2001 From: "Anna (navi) Figueiredo Gomes" Date: Tue, 14 Mar 2023 19:03:52 -0300 Subject: openrc: Add support for user services. Modifies many functions where filesystem paths were hardcoded. In non-user-services mode, they still are. In user-services mode, they are allocated, since XDG_ dirs are to be set via environment variables. Signed-off-by: Anna (navi) Figueiredo Gomes --- src/supervise-daemon/supervise-daemon.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/supervise-daemon') diff --git a/src/supervise-daemon/supervise-daemon.c b/src/supervise-daemon/supervise-daemon.c index adf35630..845b118c 100644 --- a/src/supervise-daemon/supervise-daemon.c +++ b/src/supervise-daemon/supervise-daemon.c @@ -817,6 +817,19 @@ int main(int argc, char **argv) char **child_argv = NULL; char *str = NULL; char *cmdline = NULL; + char *svcdir = RC_SVCDIR; + char *pidfile_path = "/var/run"; +#ifdef RC_USER_SERVICES + char *env; + if (rc_is_user()) { + svcdir = rc_user_svcdir(); + if ((env = getenv("XDG_RUNTIME_DIR"))) { + pidfile_path = env; + } else { + pidfile_path = "/tmp/" + } + } +#endif applet = basename_c(argv[0]); atexit(cleanup); @@ -1085,8 +1098,14 @@ int main(int argc, char **argv) umask(numask); 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", pidfile_path, svcname); + xasprintf(&fifopath, "%s/supervise-%s.ctl", svcdir, svcname); +#ifdef RC_USER_SERVICES + if (rc_is_user()) { + free(svcdir); + } +#endif + if (mkfifo(fifopath, 0600) == -1 && errno != EEXIST) eerrorx("%s: unable to create control fifo: %s", applet, strerror(errno)); -- cgit v1.2.3