From 490e677058ee4443379f6b43d346c2aba02b09da Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Fri, 11 Dec 2020 09:57:39 +0000 Subject: Only realpath() if a given servicedir is not absolute --- src/libs6/s6_supervise_link.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/libs6') diff --git a/src/libs6/s6_supervise_link.c b/src/libs6/s6_supervise_link.c index 491a2aa..ff4bb1f 100644 --- 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) ; -- cgit v1.2.3