summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2020-12-18 23:31:41 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2020-12-18 23:31:41 +0000
commit26067f0ad8c5e2f57c81d0bef8d126d50b112fb6 (patch)
tree56c4a97f2885ebd5e571b84ad163cc75f334fe41 /src
parent7d4f117642a8c026cb708e48506694c6b8090f1e (diff)
downloads6-26067f0ad8c5e2f57c81d0bef8d126d50b112fb6.tar.xz
More fixes to s6_supervise_link
Diffstat (limited to 'src')
-rw-r--r--src/libs6/s6_supervise_link.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/libs6/s6_supervise_link.c b/src/libs6/s6_supervise_link.c
index ff4bb1f..f525820 100644
--- a/src/libs6/s6_supervise_link.c
+++ b/src/libs6/s6_supervise_link.c
@@ -101,35 +101,38 @@ int s6_supervise_link (char const *scdir, char const *const *servicedirs, size_t
memcpy(lname, scdir, scdirlen) ;
lname[scdirlen] = '/' ;
memcpy(lname + scdirlen + 1, prefix, prefixlen) ;
- for (i = 0 ; i < n ; i++) if (!bitarray_peek(locked, i))
+ for (i = 0 ; i < n ; i++)
{
char *p ;
+ char const *src ;
size_t len = strlen(servicedirs[i]) ;
+ int h = bitarray_peek(locked, i) ;
memcpy(fn, servicedirs[i], len) ;
- ids[m] = registerit(&a, fn, len, gid, options, deadline, stamp) ;
- if (!ids[m++]) goto err ;
- if (bitarray_peek(logged, i))
+ if (!h)
{
- memcpy(fn + len, "/log", 4) ;
- ids[m] = registerit(&a, fn, len + 4, gid, options, deadline, stamp) ;
+ ids[m] = registerit(&a, fn, len, gid, options, deadline, stamp) ;
if (!ids[m++]) goto err ;
+ if (bitarray_peek(logged, i))
+ {
+ memcpy(fn + len, "/log", 4) ;
+ ids[m] = registerit(&a, fn, len + 4, gid, options, deadline, stamp) ;
+ if (!ids[m++]) goto err ;
+ }
}
fn[len] = 0 ;
p = basename(fn) ;
len = strlen(p) ;
memcpy(lname + scdirlen + 1 + prefixlen, p, len + 1) ;
lstart = lnames.len ;
- if (!stralloc_catb(&lnames, p, len + 1)) goto err ;
- if (servicedirs[i][0] == '/')
- {
- if (symlink(servicedirs[i], lname) < 0) goto errl ;
- }
+ if (!h && !stralloc_catb(&lnames, p, len + 1)) goto err ;
+ if (servicedirs[i][0] == '/') src = servicedirs[i] ;
else
{
rpsa.len = 0 ;
if (sarealpath(&rpsa, servicedirs[i]) < 0 || !stralloc_0(&rpsa)) goto errl ;
- if (symlink(rpsa.s, lname) < 0) goto errl ;
+ src = rpsa.s ;
}
+ if (symlink(src, lname) < 0 && (!h || errno != EEXIST)) goto errl ;
}
stralloc_free(&rpsa) ;
r = s6_svc_writectl(scdir, S6_SVSCAN_CTLDIR, "a", 1) ;