From c34fcd63f05044f9034b26c52f19c91e04668da7 Mon Sep 17 00:00:00 2001 From: "Anna (navi) Figueiredo Gomes" Date: Wed, 20 Mar 2024 23:45:47 +0100 Subject: 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 --- src/librc/librc-daemon.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/librc/librc-daemon.c') diff --git a/src/librc/librc-daemon.c b/src/librc/librc-daemon.c index e23593b9..96609786 100644 --- a/src/librc/librc-daemon.c +++ b/src/librc/librc-daemon.c @@ -411,9 +411,8 @@ rc_service_daemon_set(const char *service, const char *exec, return false; } - xasprintf(&dirpath, RC_SVCDIR "/daemons/%s", basename_c(service)); - /* Regardless, erase any existing daemon info */ + xasprintf(&dirpath, "%s/daemons/%s", rc_service_dir(), basename_c(service)); if ((dp = opendir(dirpath))) { match = _match_list(exec, argv, pidfile); renamelist = rc_stringlist_new(); @@ -491,7 +490,7 @@ rc_service_started_daemon(const char *service, if (!service || !exec) return false; - xasprintf(&dirpath, RC_SVCDIR "/daemons/%s", basename_c(service)); + xasprintf(&dirpath, "%s/daemons/%s", rc_service_dir(), basename_c(service)); match = _match_list(exec, argv, NULL); if (indx > 0) { @@ -543,9 +542,8 @@ rc_service_daemons_crashed(const char *service) char *ch_root; char *spidfile; - path += snprintf(dirpath, sizeof(dirpath), RC_SVCDIR "/daemons/%s", - basename_c(service)); - + path += snprintf(dirpath, sizeof(dirpath), + "%s/daemons/%s", rc_service_dir(), basename_c(service)); if (!(dp = opendir(dirpath))) return false; -- cgit v1.2.3