From 5a1cd9545164d978ded996ac6d673fd6d480a2fe Mon Sep 17 00:00:00 2001 From: "Anna (navi) Figueiredo Gomes" Date: Fri, 9 Jun 2023 20:46:47 -0300 Subject: openrc: rework pathing functions this simplifies the allocation of path string. also fixes some memory leaks from the ealier commit also changes the log path for users to XDG_CACHE_HOME, default ~/.cache/openrc Signed-off-by: Anna (navi) Figueiredo Gomes --- src/supervise-daemon/supervise-daemon.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/supervise-daemon/supervise-daemon.c') diff --git a/src/supervise-daemon/supervise-daemon.c b/src/supervise-daemon/supervise-daemon.c index 845b118c..e3d4442e 100644 --- a/src/supervise-daemon/supervise-daemon.c +++ b/src/supervise-daemon/supervise-daemon.c @@ -817,12 +817,12 @@ 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"; + char *svcdir = rc_svcdir(); + char *pidfile_path = xstrdup("/var/run"); #ifdef RC_USER_SERVICES char *env; if (rc_is_user()) { - svcdir = rc_user_svcdir(); + free(pidfile_path); if ((env = getenv("XDG_RUNTIME_DIR"))) { pidfile_path = env; } else { @@ -1100,11 +1100,8 @@ int main(int argc, char **argv) if (!pidfile) 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 + free(svcdir); + free(pidfile_path); if (mkfifo(fifopath, 0600) == -1 && errno != EEXIST) eerrorx("%s: unable to create control fifo: %s", -- cgit v1.2.3