s6

Mirror/fork of https://skarnet.org/software/s6/
git clone https://ccx.te2000.cz/git/s6
Log | Files | Refs | README | LICENSE

commit 490e677058ee4443379f6b43d346c2aba02b09da
parent bba745f906d2a29ec0f619f61c746ad8cbdf5621
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date:   Fri, 11 Dec 2020 09:57:39 +0000

 Only realpath() if a given servicedir is not absolute

Diffstat:
Msrc/libs6/s6_supervise_link.c | 13++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/libs6/s6_supervise_link.c b/src/libs6/s6_supervise_link.c @@ -118,11 +118,18 @@ int s6_supervise_link (char const *scdir, char const *const *servicedirs, size_t p = basename(fn) ; len = strlen(p) ; memcpy(lname + scdirlen + 1 + prefixlen, p, len + 1) ; - rpsa.len = 0 ; lstart = lnames.len ; - if (sarealpath(&rpsa, servicedirs[i]) < 0 || !stralloc_0(&rpsa)) goto err ; if (!stralloc_catb(&lnames, p, len + 1)) goto err ; - if (symlink(rpsa.s, lname) < 0) goto errl ; + if (servicedirs[i][0] == '/') + { + if (symlink(servicedirs[i], lname) < 0) goto errl ; + } + else + { + rpsa.len = 0 ; + if (sarealpath(&rpsa, servicedirs[i]) < 0 || !stralloc_0(&rpsa)) goto errl ; + if (symlink(rpsa.s, lname) < 0) goto errl ; + } } stralloc_free(&rpsa) ; r = s6_svc_writectl(scdir, S6_SVSCAN_CTLDIR, "a", 1) ;