diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2015-01-14 00:48:32 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2015-01-14 00:48:32 +0000 |
commit | d73a8330016fbf172f8e3521b879502b9139a970 (patch) | |
tree | 9368926e55d67bf565cc0f2275e203f464cf193a /src | |
parent | a6395bee8b2b696c0c74ff23a11944a491c83cc1 (diff) | |
download | s6-d73a8330016fbf172f8e3521b879502b9139a970.tar.xz |
- Parallel build fixv2.0.1.0
- Complete readiness notification via supervise/ready
- Version updated to 2.0.1.0, release candidate
Diffstat (limited to 'src')
-rw-r--r-- | src/daemontools-extras/deps-exe/s6-notifywhenup | 2 | ||||
-rw-r--r-- | src/daemontools-extras/s6-notifywhenup.c | 5 | ||||
-rw-r--r-- | src/daemontools-extras/s6-setuidgid.c | 30 | ||||
-rw-r--r-- | src/include/s6/s6-supervise.h | 1 | ||||
-rw-r--r-- | src/pipe-tools/deps-exe/s6-cleanfifodir | 2 | ||||
-rw-r--r-- | src/pipe-tools/deps-exe/s6-ftrig-listen | 2 | ||||
-rw-r--r-- | src/pipe-tools/deps-exe/s6-ftrig-listen1 | 2 | ||||
-rw-r--r-- | src/pipe-tools/deps-exe/s6-ftrig-notify | 2 | ||||
-rw-r--r-- | src/pipe-tools/deps-exe/s6-ftrig-wait | 2 | ||||
-rw-r--r-- | src/pipe-tools/deps-exe/s6-mkfifodir | 2 | ||||
-rw-r--r-- | src/supervision/deps-exe/s6-supervise | 2 | ||||
-rw-r--r-- | src/supervision/deps-exe/s6-svc | 2 | ||||
-rw-r--r-- | src/supervision/deps-exe/s6-svscan | 2 | ||||
-rw-r--r-- | src/supervision/deps-exe/s6-svscanctl | 2 | ||||
-rw-r--r-- | src/supervision/deps-exe/s6-svstat | 2 | ||||
-rw-r--r-- | src/supervision/deps-exe/s6-svwait | 2 | ||||
-rw-r--r-- | src/supervision/s6-supervise.c | 20 | ||||
-rw-r--r-- | src/supervision/s6-svwait.c | 19 |
18 files changed, 62 insertions, 39 deletions
diff --git a/src/daemontools-extras/deps-exe/s6-notifywhenup b/src/daemontools-extras/deps-exe/s6-notifywhenup index 58a34e0..077e863 100644 --- a/src/daemontools-extras/deps-exe/s6-notifywhenup +++ b/src/daemontools-extras/deps-exe/s6-notifywhenup @@ -1,3 +1,3 @@ --ls6 +${LIBS6} -lskarnet ${TAINNOW_LIB} diff --git a/src/daemontools-extras/s6-notifywhenup.c b/src/daemontools-extras/s6-notifywhenup.c index 37f6de1..e1c02b7 100644 --- a/src/daemontools-extras/s6-notifywhenup.c +++ b/src/daemontools-extras/s6-notifywhenup.c @@ -11,6 +11,7 @@ #include <skalibs/iopause.h> #include <skalibs/djbunix.h> #include <s6/ftrigw.h> +#include <s6/s6-supervise.h> #define USAGE "s6-notifywhenup [ -d fd ] [ -e fifodir ] [ -f ] [ -t timeout ] prog..." #define dieusage() strerr_dieusage(100, USAGE) @@ -36,6 +37,10 @@ static int run_child (int fd, char const *fifodir, unsigned int timeout) else if (r) if (byte_chr(dummy, r, '\n') < r) break ; } + close(fd) ; + fd = open_create(S6_SUPERVISE_READY_FILENAME) ; + if (fd < 0) strerr_warnwu1sys("touch " S6_SUPERVISE_READY_FILENAME) ; + else close(fd) ; ftrigw_notify(fifodir, 'U') ; return 0 ; } diff --git a/src/daemontools-extras/s6-setuidgid.c b/src/daemontools-extras/s6-setuidgid.c index d2e7361..cc7f21a 100644 --- a/src/daemontools-extras/s6-setuidgid.c +++ b/src/daemontools-extras/s6-setuidgid.c @@ -1,30 +1,26 @@ /* ISC license. */ -#include <unistd.h> -#include <skalibs/bytestr.h> -#include <skalibs/uint.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> +#include <s6/config.h> #define USAGE "s6-setuidgid username prog..." #define dieusage() strerr_dieusage(100, USAGE) int main (int argc, char const *const *argv, char const *const *envp) { - unsigned int pos ; + char const *newargv[argc + 4] ; + unsigned int m = 5 ; PROG = "s6-setuidgid" ; if (argc < 3) dieusage() ; - pos = str_chr(argv[1], ':') ; - if (argv[1][pos]) - { - unsigned int uid = 0, gid = 0, len = uint_scan(argv[1], &uid) ; - if (len != pos) dieusage() ; - if (argv[1][pos+1] && !uint0_scan(argv[1]+pos+1, &gid)) dieusage() ; - if (gid && setgid(gid)) strerr_diefu1sys(111, "setgid") ; - if (uid && setuid(uid)) strerr_diefu1sys(111, "setuid") ; - } - else if (!prot_setuidgid(argv[1])) - strerr_diefu2sys(111, "change identity to ", argv[1]) ; - pathexec_run(argv[2], argv+2, envp) ; - strerr_dieexec(111, argv[2]) ; + argv++ ; + newargv[0] = S6_BINPREFIX "s6-envuidgid" ; + newargv[1] = *argv++ ; + newargv[2] = S6_BINPREFIX "s6-applyuidgid" ; + newargv[3] = "-Uz" ; + newargv[4] = "--" ; + while (*argv) newargv[m++] = *argv++ ; + newargv[m++] = 0 ; + pathexec_run(newargv[0], newargv, envp) ; + strerr_dieexec(111, newargv[0]) ; } diff --git a/src/include/s6/s6-supervise.h b/src/include/s6/s6-supervise.h index 2a39393..c8d72d7 100644 --- a/src/include/s6/s6-supervise.h +++ b/src/include/s6/s6-supervise.h @@ -9,6 +9,7 @@ #define S6_SUPERVISE_EVENTDIR "event" #define S6_SVSCAN_CTLDIR ".s6-svscan" #define S6_SVSTATUS_FILENAME S6_SUPERVISE_CTLDIR "/status" +#define S6_SUPERVISE_READY_FILENAME S6_SUPERVISE_CTLDIR "/ready" #define S6_SVSTATUS_SIZE 18 extern int s6_svc_write (char const *, char const *, unsigned int) ; diff --git a/src/pipe-tools/deps-exe/s6-cleanfifodir b/src/pipe-tools/deps-exe/s6-cleanfifodir index 83cec1e..08815d9 100644 --- a/src/pipe-tools/deps-exe/s6-cleanfifodir +++ b/src/pipe-tools/deps-exe/s6-cleanfifodir @@ -1,2 +1,2 @@ --ls6 +${LIBS6} -lskarnet diff --git a/src/pipe-tools/deps-exe/s6-ftrig-listen b/src/pipe-tools/deps-exe/s6-ftrig-listen index 3ad9adf..3bbf778 100644 --- a/src/pipe-tools/deps-exe/s6-ftrig-listen +++ b/src/pipe-tools/deps-exe/s6-ftrig-listen @@ -1,4 +1,4 @@ --ls6 +${LIBS6} -lexecline -lskarnet ${SOCKET_LIB} diff --git a/src/pipe-tools/deps-exe/s6-ftrig-listen1 b/src/pipe-tools/deps-exe/s6-ftrig-listen1 index ac0cace..f3a3143 100644 --- a/src/pipe-tools/deps-exe/s6-ftrig-listen1 +++ b/src/pipe-tools/deps-exe/s6-ftrig-listen1 @@ -1,4 +1,4 @@ --ls6 +${LIBS6} -lskarnet ${SOCKET_LIB} ${TAINNOW_LIB} diff --git a/src/pipe-tools/deps-exe/s6-ftrig-notify b/src/pipe-tools/deps-exe/s6-ftrig-notify index 83cec1e..08815d9 100644 --- a/src/pipe-tools/deps-exe/s6-ftrig-notify +++ b/src/pipe-tools/deps-exe/s6-ftrig-notify @@ -1,2 +1,2 @@ --ls6 +${LIBS6} -lskarnet diff --git a/src/pipe-tools/deps-exe/s6-ftrig-wait b/src/pipe-tools/deps-exe/s6-ftrig-wait index ac0cace..f3a3143 100644 --- a/src/pipe-tools/deps-exe/s6-ftrig-wait +++ b/src/pipe-tools/deps-exe/s6-ftrig-wait @@ -1,4 +1,4 @@ --ls6 +${LIBS6} -lskarnet ${SOCKET_LIB} ${TAINNOW_LIB} diff --git a/src/pipe-tools/deps-exe/s6-mkfifodir b/src/pipe-tools/deps-exe/s6-mkfifodir index 83cec1e..08815d9 100644 --- a/src/pipe-tools/deps-exe/s6-mkfifodir +++ b/src/pipe-tools/deps-exe/s6-mkfifodir @@ -1,2 +1,2 @@ --ls6 +${LIBS6} -lskarnet diff --git a/src/supervision/deps-exe/s6-supervise b/src/supervision/deps-exe/s6-supervise index 58a34e0..077e863 100644 --- a/src/supervision/deps-exe/s6-supervise +++ b/src/supervision/deps-exe/s6-supervise @@ -1,3 +1,3 @@ --ls6 +${LIBS6} -lskarnet ${TAINNOW_LIB} diff --git a/src/supervision/deps-exe/s6-svc b/src/supervision/deps-exe/s6-svc index 83cec1e..08815d9 100644 --- a/src/supervision/deps-exe/s6-svc +++ b/src/supervision/deps-exe/s6-svc @@ -1,2 +1,2 @@ --ls6 +${LIBS6} -lskarnet diff --git a/src/supervision/deps-exe/s6-svscan b/src/supervision/deps-exe/s6-svscan index 58a34e0..077e863 100644 --- a/src/supervision/deps-exe/s6-svscan +++ b/src/supervision/deps-exe/s6-svscan @@ -1,3 +1,3 @@ --ls6 +${LIBS6} -lskarnet ${TAINNOW_LIB} diff --git a/src/supervision/deps-exe/s6-svscanctl b/src/supervision/deps-exe/s6-svscanctl index 83cec1e..08815d9 100644 --- a/src/supervision/deps-exe/s6-svscanctl +++ b/src/supervision/deps-exe/s6-svscanctl @@ -1,2 +1,2 @@ --ls6 +${LIBS6} -lskarnet diff --git a/src/supervision/deps-exe/s6-svstat b/src/supervision/deps-exe/s6-svstat index 7065b26..b1e57e4 100644 --- a/src/supervision/deps-exe/s6-svstat +++ b/src/supervision/deps-exe/s6-svstat @@ -1,3 +1,3 @@ --ls6 +${LIBS6} -lskarnet ${SYSCLOCK_LIB} diff --git a/src/supervision/deps-exe/s6-svwait b/src/supervision/deps-exe/s6-svwait index ac0cace..f3a3143 100644 --- a/src/supervision/deps-exe/s6-svwait +++ b/src/supervision/deps-exe/s6-svwait @@ -1,4 +1,4 @@ --ls6 +${LIBS6} -lskarnet ${SOCKET_LIB} ${TAINNOW_LIB} diff --git a/src/supervision/s6-supervise.c b/src/supervision/s6-supervise.c index de9b6ea..65cbd9d 100644 --- a/src/supervision/s6-supervise.c +++ b/src/supervision/s6-supervise.c @@ -161,6 +161,8 @@ static void trystart (void) PROG = "s6-supervise (child)" ; selfpipe_finish() ; fd_close(p[0]) ; + if (unlink(S6_SUPERVISE_READY_FILENAME) < 0 && errno != ENOENT) + strerr_warnwu1sys("unlink " S6_SUPERVISE_READY_FILENAME) ; if (flagsetsid) setsid() ; execve("./run", (char *const *)cargv, (char *const *)environ) ; fd_write(p[1], "", 1) ; @@ -264,14 +266,21 @@ static void uptimeout (void) strerr_warnw1x("can't happen: timeout while the service is up!") ; } -static void up_z (void) +static void uplastup_z (int islast) { int wstat = status.pid ; status.pid = 0 ; tain_copynow(&status.stamp) ; announce() ; ftrigw_notify(S6_SUPERVISE_EVENTDIR, 'd') ; - tryfinish(wstat, 0) ; + if (unlink(S6_SUPERVISE_READY_FILENAME) < 0 && errno != ENOENT) + strerr_warnwu1sys("unlink " S6_SUPERVISE_READY_FILENAME) ; + tryfinish(wstat, islast) ; +} + +static void up_z (void) +{ + uplastup_z(0) ; } static void up_o (void) @@ -346,12 +355,7 @@ static void finish_x (void) static void lastup_z (void) { - int wstat = status.pid ; - status.pid = 0 ; - tain_copynow(&status.stamp) ; - announce() ; - ftrigw_notify(S6_SUPERVISE_EVENTDIR, 'd') ; - tryfinish(wstat, 1) ; + uplastup_z(1) ; } static action_t_ref const actions[5][23] = diff --git a/src/supervision/s6-svwait.c b/src/supervision/s6-svwait.c index 0d7c96c..a6dc410 100644 --- a/src/supervision/s6-svwait.c +++ b/src/supervision/s6-svwait.c @@ -1,5 +1,7 @@ /* ISC license. */ +#include <unistd.h> +#include <errno.h> #include <skalibs/sgetopt.h> #include <skalibs/bytestr.h> #include <skalibs/uint16.h> @@ -77,8 +79,23 @@ int main (int argc, char const *const *argv) for (i = 0 ; i < (unsigned int)argc ; i++) { s6_svstatus_t st = S6_SVSTATUS_ZERO ; + int isup ; if (!s6_svstatus_read(argv[i], &st)) strerr_diefu1sys(111, "s6_svstatus_read") ; - bitarray_poke(states, i, !!st.pid) ; + isup = !!st.pid ; + if (re[0] == 'U' && isup) + { + unsigned int len = str_len(argv[i]) ; + char s[len + 1 + sizeof(S6_SUPERVISE_READY_FILENAME)] ; + byte_copy(s, len, argv[i]) ; + s[len] = '/' ; + byte_copy(s + len + 1, sizeof(S6_SUPERVISE_READY_FILENAME), S6_SUPERVISE_READY_FILENAME) ; + if (access(s, F_OK) < 0) + { + if (errno == ENOENT) isup = 0 ; + else strerr_warnwu2sys("check ", s) ; + } + } + bitarray_poke(states, i, isup) ; } for (;;) |