diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2020-12-11 09:57:39 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2020-12-11 09:57:39 +0000 |
commit | 490e677058ee4443379f6b43d346c2aba02b09da (patch) | |
tree | f8eedbaf8b1f968e18595bd7bb2fd6dde57c9e7c /src/libs6 | |
parent | bba745f906d2a29ec0f619f61c746ad8cbdf5621 (diff) | |
download | s6-490e677058ee4443379f6b43d346c2aba02b09da.tar.xz |
Only realpath() if a given servicedir is not absolute
Diffstat (limited to 'src/libs6')
-rw-r--r-- | src/libs6/s6_supervise_link.c | 13 |
1 files changed, 10 insertions, 3 deletions
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) ; |