summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2019-12-23 13:05:25 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2019-12-23 13:05:25 +0000
commit07491df186d562d0efa6a7fca2b7f8d07dbd0652 (patch)
treed66a8709a82b4c621c5f21a7f346362e8a243a3f /src
parent8bbfc319248c0cbeb57edc45f26d1c972d32f505 (diff)
downloads6-07491df186d562d0efa6a7fca2b7f8d07dbd0652.tar.xz
Make execline dependency optional
This includes: - adding a configure option to disable execline support - duplicating el_semicolon() and el_getstrict() into the s6 library when execline is disabled at build time, making a compat shim and using it where needed (s6-svlisten, s6-ftrig-listen) - Creating alternatives for execlineb script spawning: * s6-log: '?' directive (done in the previous commit) * s6-notifyoncheck: require hardcoding the check in ./data/check * s6-ipcserver-access: no support for exec files, add a warning - Updating the relevant parts of the doc --enable-execline will remain the default, and whiners can choke on their tears.
Diffstat (limited to 'src')
-rw-r--r--src/conn-tools/s6-ipcserver-access.c13
-rw-r--r--src/daemontools-extras/s6-log.c12
-rw-r--r--src/include/s6/compat.h20
-rw-r--r--src/include/s6/s6.h1
-rw-r--r--src/libs6/deps-lib/s65
-rw-r--r--src/libs6/s6_compat_el_semicolon.c54
-rw-r--r--src/pipe-tools/deps-exe/s6-ftrig-listen2
-rw-r--r--src/pipe-tools/s6-ftrig-listen.c6
-rw-r--r--src/supervision/deps-exe/s6-svlisten2
-rw-r--r--src/supervision/s6-notifyoncheck.c33
-rw-r--r--src/supervision/s6-svlisten.c7
11 files changed, 134 insertions, 21 deletions
diff --git a/src/conn-tools/s6-ipcserver-access.c b/src/conn-tools/s6-ipcserver-access.c
index 9d78620..e3f6ac2 100644
--- a/src/conn-tools/s6-ipcserver-access.c
+++ b/src/conn-tools/s6-ipcserver-access.c
@@ -11,9 +11,14 @@
#include <skalibs/env.h>
#include <skalibs/djbunix.h>
#include <skalibs/webipc.h>
-#include <execline/config.h>
+
+#include <s6/config.h>
#include <s6/accessrules.h>
+#ifdef S6_USE_EXECLINE
+#include <execline/config.h>
+#endif
+
#define USAGE "s6-ipcserver-access [ -v verbosity ] [ -e | -E ] [ -l localname ] [ -i rulesdir | -x rulesfile ] prog..."
static unsigned int verbosity = 1 ;
@@ -204,9 +209,13 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
if (params.exec.len)
+#ifdef S6_USE_EXECLINE
{
char *specialargv[4] = { EXECLINE_EXTBINPREFIX "execlineb", "-Pc", params.exec.s, 0 } ;
xpathexec_r((char const *const *)specialargv, envp, env_len(envp), params.env.s, params.env.len) ;
}
- else xpathexec_r(argv, envp, env_len(envp), params.env.s, params.env.len) ;
+#else
+ strerr_warnw1x("exec file found but ignored because s6 was compiled without execline support!") ;
+#endif
+ xpathexec_r(argv, envp, env_len(envp), params.env.s, params.env.len) ;
}
diff --git a/src/daemontools-extras/s6-log.c b/src/daemontools-extras/s6-log.c
index 6b2035e..54b945f 100644
--- a/src/daemontools-extras/s6-log.c
+++ b/src/daemontools-extras/s6-log.c
@@ -34,7 +34,11 @@
#include <skalibs/skamisc.h>
#include <skalibs/environ.h>
+#include <s6/config.h>
+
+#ifdef S6_USE_EXECLINE
#include <execline/config.h>
+#endif
#define USAGE "s6-log [ -d notif ] [ -q | -v ] [ -b ] [ -p ] [ -t ] [ -e ] [ -l linelimit ] logging_script"
#define dieusage() strerr_dieusage(100, USAGE)
@@ -304,7 +308,11 @@ static int finish (logdir_t *ldp, char const *name, char suffix)
static inline void exec_processor (logdir_t *ldp)
{
+#ifdef S6_USE_EXECLINE
char const *cargv[4] = { ldp->flags & 4 ? "/bin/sh" : EXECLINE_EXTBINPREFIX "execlineb", ldp->flags & 4 ? "-c" : "-Pc", ldp->processor, 0 } ;
+#else
+ char const *cargv[4] = { "/bin/sh", "-c", ldp->processor, 0 } ;
+#endif
int fd ;
PROG = "s6-log (processor child)" ;
if (chdir(ldp->dir) < 0) strerr_diefu2sys(111, "chdir to ", ldp->dir) ;
@@ -713,7 +721,9 @@ static inline void script_firstpass (char const *const *argv, unsigned int *sell
case 'r' :
case 'E' :
case '^' :
+#ifdef S6_USE_EXECLINE
case '!' :
+#endif
case '?' :
break ;
case 't' :
@@ -838,10 +848,12 @@ static inline void script_secondpass (char const *const *argv, scriptelem_t *scr
case '^' :
if (!uint0_scan(*argv + 1, &status_size)) goto fail ;
break ;
+#ifdef S6_USE_EXECLINE
case '!' :
processor = (*argv)[1] ? *argv + 1 : 0 ;
flags &= ~4 ;
break ;
+#endif
case '?' :
processor = (*argv)[1] ? *argv + 1 : 0 ;
flags |= 4 ;
diff --git a/src/include/s6/compat.h b/src/include/s6/compat.h
new file mode 100644
index 0000000..151db07
--- /dev/null
+++ b/src/include/s6/compat.h
@@ -0,0 +1,20 @@
+/* ISC license. */
+
+#ifndef S6_COMPAT_H
+#define S6_COMPAT_H
+
+#include <s6/config.h>
+
+#ifdef S6_USE_EXECLINE
+
+#include <execline/execline.h>
+#define s6_el_semicolon(argv) el_semicolon(argv)
+
+#else
+
+extern int s6_compat_el_semicolon (char const **) ;
+#define s6_el_semicolon(argv) s6_compat_el_semicolon(argv)
+
+#endif
+
+#endif
diff --git a/src/include/s6/s6.h b/src/include/s6/s6.h
index 98e23e1..aabcc13 100644
--- a/src/include/s6/s6.h
+++ b/src/include/s6/s6.h
@@ -3,6 +3,7 @@
#ifndef S6_H
#define S6_H
+#include <s6/compat.h>
#include <s6/s6-supervise.h>
#include <s6/ftrigr.h>
#include <s6/ftrigw.h>
diff --git a/src/libs6/deps-lib/s6 b/src/libs6/deps-lib/s6
index 65612cc..ddd86dc 100644
--- a/src/libs6/deps-lib/s6
+++ b/src/libs6/deps-lib/s6
@@ -26,12 +26,13 @@ s6_accessrules_keycheck_uidgid.o
s6_accessrules_params_free.o
s6_accessrules_uidgid_cdb.o
s6_accessrules_uidgid_fs.o
-s6_supervise_lock.o
-s6_supervise_lock_mode.o
+s6_compat_el_semicolon.o
s6_dtally_pack.o
s6_dtally_unpack.o
s6_dtally_read.o
s6_dtally_write.o
+s6_supervise_lock.o
+s6_supervise_lock_mode.o
s6_svc_lock_take.o
s6_svc_lock_release.o
s6_svc_ok.o
diff --git a/src/libs6/s6_compat_el_semicolon.c b/src/libs6/s6_compat_el_semicolon.c
new file mode 100644
index 0000000..d6fdd06
--- /dev/null
+++ b/src/libs6/s6_compat_el_semicolon.c
@@ -0,0 +1,54 @@
+/* ISC license. */
+
+#include <s6/config.h>
+
+#ifndef S6_USE_EXECLINE
+
+#include <stdlib.h>
+
+#include <skalibs/types.h>
+#include <skalibs/strerr2.h>
+
+static unsigned int el_getstrict (void)
+{
+ static unsigned int strict = 0 ;
+ static int first = 1 ;
+ if (first)
+ {
+ char const *x = getenv("EXECLINE_STRICT") ;
+ first = 0 ;
+ if (x) uint0_scan(x, &strict) ;
+ }
+ return strict ;
+}
+
+int s6_compat_el_semicolon (char const **argv)
+{
+ static unsigned int nblock = 0 ;
+ int argc1 = 0 ;
+ nblock++ ;
+ for (;; argc1++, argv++)
+ {
+ char const *arg = *argv ;
+ if (!arg) return argc1 + 1 ;
+ if (!arg[0]) return argc1 ;
+ else if (arg[0] == ' ') ++*argv ;
+ else
+ {
+ unsigned int strict = el_getstrict() ;
+ if (strict)
+ {
+ char fmt1[UINT_FMT] ;
+ char fmt2[UINT_FMT] ;
+ fmt1[uint_fmt(fmt1, nblock)] = 0 ;
+ fmt2[uint_fmt(fmt2, (unsigned int)argc1)] = 0 ;
+ if (strict >= 2)
+ strerr_dief6x(100, "unquoted argument ", arg, " at block ", fmt1, " position ", fmt2) ;
+ else
+ strerr_warnw6x("unquoted argument ", arg, " at block ", fmt1, " position ", fmt2) ;
+ }
+ }
+ }
+}
+
+#endif
diff --git a/src/pipe-tools/deps-exe/s6-ftrig-listen b/src/pipe-tools/deps-exe/s6-ftrig-listen
index 0a30526..2d6e6d4 100644
--- a/src/pipe-tools/deps-exe/s6-ftrig-listen
+++ b/src/pipe-tools/deps-exe/s6-ftrig-listen
@@ -1,5 +1,5 @@
${LIBS6}
--lexecline
+${LIBEXECLINE}
-lskarnet
${SOCKET_LIB}
${SYSCLOCK_LIB}
diff --git a/src/pipe-tools/s6-ftrig-listen.c b/src/pipe-tools/s6-ftrig-listen.c
index 993a914..d9c4b53 100644
--- a/src/pipe-tools/s6-ftrig-listen.c
+++ b/src/pipe-tools/s6-ftrig-listen.c
@@ -4,6 +4,7 @@
#include <errno.h>
#include <signal.h>
#include <unistd.h>
+
#include <skalibs/sgetopt.h>
#include <skalibs/types.h>
#include <skalibs/strerr2.h>
@@ -12,7 +13,8 @@
#include <skalibs/djbunix.h>
#include <skalibs/sig.h>
#include <skalibs/selfpipe.h>
-#include <execline/execline.h>
+
+#include <s6/compat.h>
#include <s6/ftrigr.h>
#define USAGE "s6-ftrig-listen [ -a | -o ] [ -t timeout ] fifodir1 regexp1 ... \"\" prog..."
@@ -56,7 +58,7 @@ int main (int argc, char const **argv, char const *const *envp)
argc -= subgetopt_here.ind ; argv += subgetopt_here.ind ;
}
if (argc < 4) dieusage() ;
- argc1 = el_semicolon(argv) ;
+ argc1 = s6_el_semicolon(argv) ;
if (!argc1 || (argc1 & 1) || (argc == argc1 + 1)) dieusage() ;
if (argc1 >= argc) strerr_dief1x(100, "unterminated fifodir+regex block") ;
tain_now_set_stopwatch_g() ;
diff --git a/src/supervision/deps-exe/s6-svlisten b/src/supervision/deps-exe/s6-svlisten
index fd153b3..a7bbbfa 100644
--- a/src/supervision/deps-exe/s6-svlisten
+++ b/src/supervision/deps-exe/s6-svlisten
@@ -1,7 +1,7 @@
s6_svlisten_signal_handler.o
s6_svlisten_loop.o
${LIBS6}
--lexecline
+${LIBEXECLINE}
-lskarnet
${SOCKET_LIB}
${SYSCLOCK_LIB}
diff --git a/src/supervision/s6-notifyoncheck.c b/src/supervision/s6-notifyoncheck.c
index c8a0e19..b1ef96b 100644
--- a/src/supervision/s6-notifyoncheck.c
+++ b/src/supervision/s6-notifyoncheck.c
@@ -6,6 +6,7 @@
#include <fcntl.h>
#include <limits.h>
#include <sys/wait.h>
+
#include <skalibs/types.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/bytestr.h>
@@ -15,11 +16,18 @@
#include <skalibs/djbunix.h>
#include <skalibs/selfpipe.h>
#include <skalibs/iopause.h>
-#include <execline/config.h>
-#include <s6/s6-supervise.h>
-#include <s6/ftrigr.h>
+#include <s6/s6.h>
+
+#ifdef S6_USE_EXECLINE
+#include <execline/config.h>
#define USAGE "s6-notifyoncheck [ -d ] [ -3 fd ] [ -s initialsleep ] [ -T globaltimeout ] [ -t localtimeout ] [ -w waitingtime ] [ -n tries ] [ -c \"checkprog...\" ] prog..."
+#define OPTIONS "d3:s:T:t:w:n:c:"
+#else
+#define USAGE "s6-notifyoncheck [ -d ] [ -3 fd ] [ -s initialsleep ] [ -T globaltimeout ] [ -t localtimeout ] [ -w waitingtime ] [ -n tries ] prog..."
+#define OPTIONS "d3:s:T:t:w:n:"
+#endif
+
#define dieusage() strerr_dieusage(100, USAGE)
@@ -70,13 +78,14 @@ static int handle_event (ftrigr_t *a, uint16_t id, pid_t pid)
return 0 ;
}
-
int main (int argc, char const *const *argv, char const *const *envp)
{
ftrigr_t a = FTRIGR_ZERO ;
iopause_fd x[2] = { { .events = IOPAUSE_READ }, { .events = IOPAUSE_READ } } ;
- char const *childargv[4] = { EXECLINE_EXTBINPREFIX "execlineb", "-Pc", 0, 0 } ;
+ char const *childargv[4] = { "./data/check", 0, 0, 0 } ;
+#ifdef S6_USE_EXECLINE
char const *checkprog = 0 ;
+#endif
unsigned int fd ;
int df = 0 ;
int autodetect = 1 ;
@@ -91,7 +100,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
unsigned int initialsleep = 10, globaltimeout = 0, localtimeout = 0, waitingtime = 1000 ;
for (;;)
{
- int opt = subgetopt_r(argc, argv, "d3:s:T:t:w:n:c:", &l) ;
+ int opt = subgetopt_r(argc, argv, OPTIONS, &l) ;
if (opt == -1) break ;
switch (opt)
{
@@ -102,7 +111,9 @@ int main (int argc, char const *const *argv, char const *const *envp)
case 't' : if (!uint0_scan(l.arg, &localtimeout)) dieusage() ; break ;
case 'w' : if (!uint0_scan(l.arg, &waitingtime)) dieusage() ; break ;
case 'n' : if (!uint0_scan(l.arg, &tries)) dieusage() ; break ;
+#ifdef S6_USE_EXECLINE
case 'c' : checkprog = l.arg ; break ;
+#endif
default : dieusage() ;
}
}
@@ -124,12 +135,14 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (r < 0) strerr_diefu1sys(111, "sanity-check current service directory") ;
if (!r) strerr_dief1x(100, "s6-supervise not running.") ;
}
- if (checkprog) childargv[2] = checkprog ;
- else
+#ifdef S6_USE_EXECLINE
+ if (checkprog)
{
- childargv[0] = "./data/check" ;
- childargv[1] = 0 ;
+ childargv[0] = EXECLINE_EXTBINPREFIX "execlineb" ;
+ childargv[1] = "-Pc" ;
+ childargv[2] = checkprog ;
}
+#endif
if (autodetect)
{
diff --git a/src/supervision/s6-svlisten.c b/src/supervision/s6-svlisten.c
index c8af1f4..1364b44 100644
--- a/src/supervision/s6-svlisten.c
+++ b/src/supervision/s6-svlisten.c
@@ -1,13 +1,15 @@
/* ISC license. */
#include <stdint.h>
+
#include <skalibs/sgetopt.h>
#include <skalibs/types.h>
#include <skalibs/bitarray.h>
#include <skalibs/tai.h>
#include <skalibs/strerr2.h>
#include <skalibs/djbunix.h>
-#include <execline/execline.h>
+
+#include <s6/compat.h>
#include "s6-svlisten.h"
#define USAGE "s6-svlisten [ -U | -u | -d | -D | -r | -R ] [ -a | -o ] [ -t timeout ] servicedir... \"\" prog..."
@@ -46,8 +48,7 @@ int main (int argc, char const **argv, char const *const *envp)
if (t) tain_from_millisecs(&tto, t) ; else tto = tain_infinite_relative ;
}
if (argc < 3) dieusage() ;
-
- argc1 = el_semicolon(argv) ;
+ argc1 = s6_el_semicolon(argv) ;
if (!argc1 || argc == argc1 + 1) dieusage() ;
if (argc1 >= argc) strerr_dief1x(100, "unterminated servicedir block") ;
if (wantrestart && or)