diff options
author | Anna (navi) Figueiredo Gomes <navi@vlhl.dev> | 2023-03-14 19:03:52 -0300 |
---|---|---|
committer | Anna (navi) Figueiredo Gomes <navi@vlhl.dev> | 2023-10-19 10:56:54 +0200 |
commit | 9efa44579fd1f60a4c9ace264bb0b968ccb0f7ea (patch) | |
tree | 71f6d00e0fe41ae3ac338c6dba21c75f7cb74528 /src/supervise-daemon | |
parent | b80971ce08dd080529efaf694afc67846e0748b8 (diff) |
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 <navi@vlhl.dev>
Diffstat (limited to 'src/supervise-daemon')
-rw-r--r-- | src/supervise-daemon/supervise-daemon.c | 23 |
1 files changed, 21 insertions, 2 deletions
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)); |