diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2020-12-05 11:31:47 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2020-12-05 11:31:47 +0000 |
commit | 1543bbf0f786628dd49eb8acb56fc7904cf54670 (patch) | |
tree | f386e3969189a9bd6f6e9fb14bdf85081cddaebf | |
parent | ce6f2000cee65d8cf3875a746815b725d4597c62 (diff) | |
download | s6-1543bbf0f786628dd49eb8acb56fc7904cf54670.tar.xz |
Fix build with nsss; fix s6_supervise_link() for logged services
-rw-r--r-- | package/deps.mak | 4 | ||||
-rw-r--r-- | src/libs6/s6_supervise_link.c | 23 | ||||
-rw-r--r-- | src/supervision/deps-exe/s6-svperms | 1 |
3 files changed, 20 insertions, 8 deletions
diff --git a/package/deps.mak b/package/deps.mak index f654105..e5394cd 100644 --- a/package/deps.mak +++ b/package/deps.mak @@ -90,7 +90,7 @@ src/libs6/s6_fdholder_setdump.o src/libs6/s6_fdholder_setdump.lo: src/libs6/s6_f src/libs6/s6_fdholder_start.o src/libs6/s6_fdholder_start.lo: src/libs6/s6_fdholder_start.c src/include/s6/s6-fdholder.h src/libs6/s6_fdholder_store.o src/libs6/s6_fdholder_store.lo: src/libs6/s6_fdholder_store.c src/include/s6/s6-fdholder.h src/libs6/s6_fdholder_store_async.o src/libs6/s6_fdholder_store_async.lo: src/libs6/s6_fdholder_store_async.c src/include/s6/s6-fdholder.h -src/libs6/s6_supervise_link.o src/libs6/s6_supervise_link.lo: src/libs6/s6_supervise_link.c src/include/s6/ftrigr.h src/include/s6/s6-supervise.h +src/libs6/s6_supervise_link.o src/libs6/s6_supervise_link.lo: src/libs6/s6_supervise_link.c src/include/s6/ftrigr.h src/include/s6/ftrigw.h src/include/s6/s6-supervise.h src/libs6/s6_supervise_unlink.o src/libs6/s6_supervise_unlink.lo: src/libs6/s6_supervise_unlink.c src/include/s6/s6-supervise.h src/libs6/s6_svc_ok.o src/libs6/s6_svc_ok.lo: src/libs6/s6_svc_ok.c src/include/s6/s6-supervise.h src/libs6/s6_svc_write.o src/libs6/s6_svc_write.lo: src/libs6/s6_svc_write.c src/include/s6/s6-supervise.h @@ -244,7 +244,7 @@ s6-svlisten1: src/supervision/s6-svlisten1.o src/supervision/s6_svlisten_signal_ s6-svok: EXTRA_LIBS := -lskarnet s6-svok: src/supervision/s6-svok.o ${LIBS6} s6-svperms: EXTRA_LIBS := -lskarnet -s6-svperms: src/supervision/s6-svperms.o +s6-svperms: src/supervision/s6-svperms.o ${LIBNSSS} s6-svscan: EXTRA_LIBS := -lskarnet ${SYSCLOCK_LIB} ${SPAWN_LIB} s6-svscan: src/supervision/s6-svscan.o s6-svscanctl: EXTRA_LIBS := -lskarnet diff --git a/src/libs6/s6_supervise_link.c b/src/libs6/s6_supervise_link.c index 4724421..7d97f4a 100644 --- a/src/libs6/s6_supervise_link.c +++ b/src/libs6/s6_supervise_link.c @@ -16,12 +16,15 @@ #include <s6/ftrigw.h> #include <s6/s6-supervise.h> -static inline void do_unlink (char const *const scandir, char const *names, size_t nameslen, uint32_t killopts) +static inline void do_unlink (char const *scandir, char const *prefix, size_t prefixlen, size_t maxlen, char const *names, size_t nameslen, uint32_t killopts) { + char fn[prefixlen + maxlen + 1] ; + memcpy(fn, prefix, prefixlen) ; while (nameslen) { size_t len = strlen(names) + 1 ; - s6_supervise_unlink(scandir, names, killopts) ; + memcpy(fn + prefixlen, names, len) ; + s6_supervise_unlink(scandir, fn, killopts) ; names += len ; nameslen -= len ; } } @@ -78,20 +81,28 @@ int s6_supervise_link (char const *scandir, char const *const *servicedirs, size int r ; uint16_t ids[ntotal] ; char lname[scandirlen + prefixlen + maxlen + 2] ; - char fn[maxlen + 1 + sizeof(S6_SUPERVISE_EVENTDIR)] ; - char *p ; + char fn[maxlen + 5 + sizeof(S6_SUPERVISE_EVENTDIR)] ; if (!ftrigr_startf(&a, deadline, stamp)) return -1 ; memcpy(lname, scandir, scandirlen) ; lname[scandirlen] = '/' ; memcpy(lname + scandirlen + 1, prefix, prefixlen) ; for (i = 0 ; i < n ; i++) if (!bitarray_peek(locked, i)) { + char *p ; size_t len = strlen(servicedirs[i]) ; memcpy(fn, servicedirs[i], len) ; memcpy(fn + len, S6_SUPERVISE_EVENTDIR, sizeof(S6_SUPERVISE_EVENTDIR)) ; if (!ftrigw_fifodir_make(fn, gid, options & 1)) goto err ; ids[m] = ftrigr_subscribe(&a, fn, "s", 0, deadline, stamp) ; if (!ids[m++]) goto err ; + if (bitarray_peek(logged, i)) + { + memcpy(fn + len, "/log/", 5) ; + memcpy(fn + len + 5, S6_SUPERVISE_EVENTDIR, sizeof(S6_SUPERVISE_EVENTDIR)) ; + if (!ftrigw_fifodir_make(fn, gid, options & 1)) goto err ; + ids[m] = ftrigr_subscribe(&a, fn, "s", 0, deadline, stamp) ; + if (!ids[m++]) goto err ; + } fn[len] = 0 ; p = basename(fn) ; len = strlen(p) ; @@ -99,7 +110,7 @@ int s6_supervise_link (char const *scandir, char const *const *servicedirs, size rpsa.len = 0 ; lstart = lnames.len ; if (!sarealpath(&rpsa, servicedirs[i]) || !stralloc_0(&rpsa)) goto err ; - if (!stralloc_catb(&lnames, lname + scandirlen + 1, prefixlen + len + 1)) goto err ; + if (!stralloc_catb(&lnames, p, len + 1)) goto err ; if (symlink(rpsa.s, lname) < 0) goto errl ; } stralloc_free(&rpsa) ; @@ -117,7 +128,7 @@ int s6_supervise_link (char const *scandir, char const *const *servicedirs, size stralloc_free(&rpsa) ; errsa: ftrigr_end(&a) ; - do_unlink(scandir, lnames.s, lnames.len, killopts) ; + do_unlink(scandir, prefix, prefixlen, maxlen, lnames.s, lnames.len, killopts) ; stralloc_free(&lnames) ; return -1 ; } diff --git a/src/supervision/deps-exe/s6-svperms b/src/supervision/deps-exe/s6-svperms index e7187fe..bbe01a8 100644 --- a/src/supervision/deps-exe/s6-svperms +++ b/src/supervision/deps-exe/s6-svperms @@ -1 +1,2 @@ +${LIBNSSS} -lskarnet |