diff options
| author | Anna (navi) Figueiredo Gomes <navi@vlhl.dev> | 2023-06-09 20:46:47 -0300 | 
|---|---|---|
| committer | Anna (navi) Figueiredo Gomes <navi@vlhl.dev> | 2023-10-19 10:56:54 +0200 | 
| commit | 5a1cd9545164d978ded996ac6d673fd6d480a2fe (patch) | |
| tree | 1002f7bdfb5b823aa8cdbe4502ebcb61bba97e7e /src/supervise-daemon/supervise-daemon.c | |
| parent | b8613baa85965cbdf5fbe262b9464d5c0d98614f (diff) | |
| download | openrc-5a1cd9545164d978ded996ac6d673fd6d480a2fe.tar.xz | |
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 <navi@vlhl.dev>
Diffstat (limited to 'src/supervise-daemon/supervise-daemon.c')
| -rw-r--r-- | src/supervise-daemon/supervise-daemon.c | 13 | 
1 files changed, 5 insertions, 8 deletions
| 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", | 
