diff options
Diffstat (limited to 'src/conn-tools')
-rw-r--r-- | src/conn-tools/deps-exe/s6-tlsc | 2 | ||||
-rw-r--r-- | src/conn-tools/deps-exe/s6-tlsc-io | 5 | ||||
-rw-r--r-- | src/conn-tools/deps-exe/s6-tlsclient | 1 | ||||
-rw-r--r-- | src/conn-tools/deps-exe/s6-tlsd | 2 | ||||
-rw-r--r-- | src/conn-tools/deps-exe/s6-tlsd-io | 5 | ||||
-rw-r--r-- | src/conn-tools/deps-exe/s6-tlsserver | 1 | ||||
-rw-r--r-- | src/conn-tools/deps-exe/s6-ucspitlsc | 3 | ||||
-rw-r--r-- | src/conn-tools/deps-exe/s6-ucspitlsd | 3 | ||||
-rw-r--r-- | src/conn-tools/deps-lib/s6tls | 4 | ||||
-rw-r--r-- | src/conn-tools/s6-tlsc-io.c | 128 | ||||
-rw-r--r-- | src/conn-tools/s6-tlsc.c | 94 | ||||
-rw-r--r-- | src/conn-tools/s6-tlsclient.c | 202 | ||||
-rw-r--r-- | src/conn-tools/s6-tlsd-io.c | 126 | ||||
-rw-r--r-- | src/conn-tools/s6-tlsd.c | 72 | ||||
-rw-r--r-- | src/conn-tools/s6-tlsserver.c | 255 | ||||
-rw-r--r-- | src/conn-tools/s6-ucspitlsc.c | 109 | ||||
-rw-r--r-- | src/conn-tools/s6-ucspitlsd.c | 88 | ||||
-rw-r--r-- | src/conn-tools/s6tls-internal.h | 18 | ||||
-rw-r--r-- | src/conn-tools/s6tls_exec_tlscio.c | 53 | ||||
-rw-r--r-- | src/conn-tools/s6tls_exec_tlsdio.c | 49 | ||||
-rw-r--r-- | src/conn-tools/s6tls_sync_and_exec_app.c | 43 | ||||
-rw-r--r-- | src/conn-tools/s6tls_ucspi_exec_app.c | 36 |
22 files changed, 0 insertions, 1299 deletions
diff --git a/src/conn-tools/deps-exe/s6-tlsc b/src/conn-tools/deps-exe/s6-tlsc deleted file mode 100644 index 37405fd..0000000 --- a/src/conn-tools/deps-exe/s6-tlsc +++ /dev/null @@ -1,2 +0,0 @@ -libs6tls.a.xyzzy --lskarnet diff --git a/src/conn-tools/deps-exe/s6-tlsc-io b/src/conn-tools/deps-exe/s6-tlsc-io deleted file mode 100644 index 3e2653d..0000000 --- a/src/conn-tools/deps-exe/s6-tlsc-io +++ /dev/null @@ -1,5 +0,0 @@ -${LIBCRYPTOSUPPORT} --lskarnet -${CRYPTO_LIB} -${SOCKET_LIB} -${SYSCLOCK_LIB} diff --git a/src/conn-tools/deps-exe/s6-tlsclient b/src/conn-tools/deps-exe/s6-tlsclient deleted file mode 100644 index e7187fe..0000000 --- a/src/conn-tools/deps-exe/s6-tlsclient +++ /dev/null @@ -1 +0,0 @@ --lskarnet diff --git a/src/conn-tools/deps-exe/s6-tlsd b/src/conn-tools/deps-exe/s6-tlsd deleted file mode 100644 index 37405fd..0000000 --- a/src/conn-tools/deps-exe/s6-tlsd +++ /dev/null @@ -1,2 +0,0 @@ -libs6tls.a.xyzzy --lskarnet diff --git a/src/conn-tools/deps-exe/s6-tlsd-io b/src/conn-tools/deps-exe/s6-tlsd-io deleted file mode 100644 index 3e2653d..0000000 --- a/src/conn-tools/deps-exe/s6-tlsd-io +++ /dev/null @@ -1,5 +0,0 @@ -${LIBCRYPTOSUPPORT} --lskarnet -${CRYPTO_LIB} -${SOCKET_LIB} -${SYSCLOCK_LIB} diff --git a/src/conn-tools/deps-exe/s6-tlsserver b/src/conn-tools/deps-exe/s6-tlsserver deleted file mode 100644 index e7187fe..0000000 --- a/src/conn-tools/deps-exe/s6-tlsserver +++ /dev/null @@ -1 +0,0 @@ --lskarnet diff --git a/src/conn-tools/deps-exe/s6-ucspitlsc b/src/conn-tools/deps-exe/s6-ucspitlsc deleted file mode 100644 index ac1b327..0000000 --- a/src/conn-tools/deps-exe/s6-ucspitlsc +++ /dev/null @@ -1,3 +0,0 @@ -libs6tls.a.xyzzy --lskarnet -${SOCKET_LIB} diff --git a/src/conn-tools/deps-exe/s6-ucspitlsd b/src/conn-tools/deps-exe/s6-ucspitlsd deleted file mode 100644 index ac1b327..0000000 --- a/src/conn-tools/deps-exe/s6-ucspitlsd +++ /dev/null @@ -1,3 +0,0 @@ -libs6tls.a.xyzzy --lskarnet -${SOCKET_LIB} diff --git a/src/conn-tools/deps-lib/s6tls b/src/conn-tools/deps-lib/s6tls deleted file mode 100644 index f392de5..0000000 --- a/src/conn-tools/deps-lib/s6tls +++ /dev/null @@ -1,4 +0,0 @@ -s6tls_exec_tlscio.o -s6tls_exec_tlsdio.o -s6tls_sync_and_exec_app.o -s6tls_ucspi_exec_app.o diff --git a/src/conn-tools/s6-tlsc-io.c b/src/conn-tools/s6-tlsc-io.c deleted file mode 100644 index 79dd25d..0000000 --- a/src/conn-tools/s6-tlsc-io.c +++ /dev/null @@ -1,128 +0,0 @@ -/* ISC license. */ - -#include <stdint.h> -#include <unistd.h> -#include <signal.h> - -#include <skalibs/gccattributes.h> -#include <skalibs/types.h> -#include <skalibs/sgetopt.h> -#include <skalibs/strerr2.h> -#include <skalibs/allreadwrite.h> -#include <skalibs/tai.h> -#include <skalibs/env.h> -#include <skalibs/sig.h> -#include <skalibs/djbunix.h> - -#include <s6-networking/config.h> - -#define HANDSHAKE_BANNER "SSL_PROTOCOL=TLSv1\0" - -static inline void doit (int *, tain_t const *tto, uint32_t, uint32_t, unsigned int, char const *, unsigned int) gccattr_noreturn ; - -#ifdef S6_NETWORKING_USE_TLS - -#include <s6-networking/stls.h> - -static inline void doit (int *fds, tain_t const *tto, uint32_t preoptions, uint32_t options, unsigned int verbosity, char const *servername, unsigned int notif) -{ - struct tls *ctx = stls_client_init_and_handshake(fds + 2, preoptions, servername) ; - if (notif) - { - if (allwrite(notif, HANDSHAKE_BANNER, sizeof(HANDSHAKE_BANNER)) < sizeof(HANDSHAKE_BANNER)) - strerr_diefu1sys(111, "write post-handshake data") ; - fd_close(notif) ; - } - stls_run(ctx, fds, tto, options, verbosity) ; -} - -#else -#ifdef S6_NETWORKING_USE_BEARSSL - -#include <skalibs/random.h> - -#include <s6-networking/sbearssl.h> - -static int handshake_cb_nop (br_ssl_engine_context *ctx, sbearssl_handshake_cb_context_t *cbarg) -{ - (void)ctx ; - (void)cbarg ; - return 1 ; -} - -static int handshake_cb_sendvars (br_ssl_engine_context *ctx, sbearssl_handshake_cb_context_t *cbarg) -{ - if (allwrite(cbarg->notif, HANDSHAKE_BANNER, sizeof(HANDSHAKE_BANNER)) < sizeof(HANDSHAKE_BANNER)) - return 0 ; - fd_close(cbarg->notif) ; - return 1 ; -} - -static inline void doit (int *fds, tain_t const *tto, uint32_t preoptions, uint32_t options, unsigned int verbosity, char const *servername, unsigned int notif) -{ - if (ndelay_on(fds[0]) < 0 || ndelay_on(fds[1]) < 0) - strerr_diefu1sys(111, "set local fds non-blocking") ; - if (!random_init()) strerr_diefu1sys(111, "initialize random device") ; - sbearssl_client_init_and_run(fds, tto, preoptions, options, verbosity, servername, notif ? &handshake_cb_sendvars : &handshake_cb_nop, notif) ; -} - -#else - -#error No SSL backend configured. - -#endif -#endif - - -#define USAGE "s6-tlsc-io [ -v verbosity ] [ -d notif ] [ -S | -s ] [ -Y | -y ] [ -K timeout ] [ -k servername ] fdr fdw" -#define dieusage() strerr_dieusage(100, USAGE) - -int main (int argc, char const *const *argv, char const *const *envp) -{ - char const *servername = 0 ; - tain_t tto ; - int fds[4] = { 0, 1, 0, 1 } ; - unsigned int verbosity = 1 ; - unsigned int notif = 0 ; - uint32_t preoptions = 0 ; - uint32_t options = 1 ; - - PROG = "s6-tlsc-io" ; - { - subgetopt_t l = SUBGETOPT_ZERO ; - unsigned int t = 0 ; - for (;;) - { - int opt = subgetopt_r(argc, argv, "d:SsYyv:K:k:", &l) ; - if (opt == -1) break ; - switch (opt) - { - case 'v' : if (!uint0_scan(l.arg, &verbosity)) dieusage() ; break ; - case 'd' : if (!uint0_scan(l.arg, ¬if)) dieusage() ; break ; - case 'S' : options &= ~1 ; break ; - case 's' : options |= 1 ; break ; - case 'Y' : preoptions &= ~1 ; break ; - case 'y' : preoptions |= 1 ; break ; - case 'K' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ; - case 'k' : servername = l.arg ; break ; - default : dieusage() ; - } - } - argc -= l.ind ; argv += l.ind ; - if (t) tain_from_millisecs(&tto, t) ; else tto = tain_infinite_relative ; - } - if (argc < 2) dieusage() ; - { - unsigned int u ; - if (!uint0_scan(argv[0], &u)) dieusage() ; - fds[0] = u ; - if (!uint0_scan(argv[1], &u)) dieusage() ; - fds[1] = u ; - } - - if (ndelay_on(0) < 0 || ndelay_on(1) < 0) - strerr_diefu1sys(111, "set stdin/stdout non-blocking") ; - if (sig_ignore(SIGPIPE) < 0) strerr_diefu1sys(111, "ignore SIGPIPE") ; - tain_now_set_stopwatch_g() ; - doit(fds, &tto, preoptions, options, verbosity, servername, notif) ; -} diff --git a/src/conn-tools/s6-tlsc.c b/src/conn-tools/s6-tlsc.c deleted file mode 100644 index 5b2e7dc..0000000 --- a/src/conn-tools/s6-tlsc.c +++ /dev/null @@ -1,94 +0,0 @@ -/* ISC license. */ - -#include <stdint.h> -#include <unistd.h> -#include <fcntl.h> - -#include <skalibs/gccattributes.h> -#include <skalibs/types.h> -#include <skalibs/sgetopt.h> -#include <skalibs/strerr2.h> -#include <skalibs/env.h> -#include <skalibs/djbunix.h> - -#include "s6tls-internal.h" - -#define USAGE "s6-tlsc [ -S | -s ] [ -Y | -y ] [ -v verbosity ] [ -K timeout ] [ -k servername ] [ -Z | -z ] [ -6 fdr ] [ -7 fdw ] prog..." -#define dieusage() strerr_dieusage(100, USAGE) - -static void child (int const [4][2], uint32_t, unsigned int, unsigned int, char const *) gccattr_noreturn ; -static void child (int const p[4][2], uint32_t options, unsigned int verbosity, unsigned int kimeout, char const *servername) -{ - int fds[3] = { p[0][0], p[1][1], p[2][1] } ; - PROG = "s6-tlsc (child)" ; - close(p[2][0]) ; - close(p[0][1]) ; - close(p[1][0]) ; - if (fd_move(0, p[3][0]) < 0 || fd_move(1, p[3][1]) < 0) - strerr_diefu1sys(111, "move network fds to stdin/stdout") ; - s6tls_exec_tlscio(fds, options, verbosity, kimeout, servername) ; -} - -int main (int argc, char const *const *argv) -{ - unsigned int verbosity = 1 ; - unsigned int kimeout = 0 ; - int p[4][2] ; - uint32_t coptions = 0 ; - uint32_t poptions = 1 ; - pid_t pid ; - char const *servername = 0 ; - - PROG = "s6-tlsc" ; - { - subgetopt_t l = SUBGETOPT_ZERO ; - for (;;) - { - int opt = subgetopt_r(argc, argv, "SsYyv:K:k:Zz6:7:", &l) ; - if (opt == -1) break ; - switch (opt) - { - case 'S' : coptions &= ~4 ; break ; - case 's' : coptions |= 4 ; break ; - case 'Y' : coptions &= ~1 ; break ; - case 'y' : coptions |= 1 ; break ; - case 'v' : if (!uint0_scan(l.arg, &verbosity)) dieusage() ; break ; - case 'K' : if (!uint0_scan(l.arg, &kimeout)) dieusage() ; break ; - case 'k' : servername = l.arg ; break ; - case 'Z' : poptions &= ~1 ; break ; - case 'z' : poptions |= 1 ; break ; - case '6' : - { - unsigned int fd ; - if (!uint0_scan(l.arg, &fd)) dieusage() ; - p[3][0] = fd ; - break ; - } - case '7' : - { - unsigned int fd ; - if (!uint0_scan(l.arg, &fd)) dieusage() ; - p[3][1] = fd ; - break ; - } - default : dieusage() ; - } - } - argc -= l.ind ; argv += l.ind ; - } - if (!argc) dieusage() ; - fd_sanitize() ; - if (fcntl(p[3][0], F_GETFD) < 0 || fcntl(p[3][1], F_GETFD) < 0) - strerr_diefu1sys(111, "check network fds") ; - - if (pipe(p[0]) < 0 || pipe(p[1]) < 0 || pipe(p[2]) < 0) - strerr_diefu1sys(111, "pipe") ; - pid = fork() ; - switch (pid) - { - case -1 : strerr_diefu1sys(111, "fork") ; - case 0 : child(p, coptions, verbosity, kimeout, servername) ; - default : break ; - } - s6tls_sync_and_exec_app(argv, p, pid, poptions) ; -} diff --git a/src/conn-tools/s6-tlsclient.c b/src/conn-tools/s6-tlsclient.c deleted file mode 100644 index 267f457..0000000 --- a/src/conn-tools/s6-tlsclient.c +++ /dev/null @@ -1,202 +0,0 @@ -/* ISC license. */ - -#include <string.h> -#include <stdint.h> -#include <skalibs/types.h> -#include <skalibs/sgetopt.h> -#include <skalibs/strerr2.h> -#include <skalibs/djbunix.h> -#include <skalibs/ip46.h> -#include <s6-networking/config.h> - -#define USAGE "s6-tlsclient [ options ] host port prog...\n" \ -"s6-tcpclient options: [ -q | -Q | -v ] [ -4 | -6 ] [ -d | -D ] [ -r | -R ] [ -h | -H ] [ -n | -N ] [ -t timeout ] [ -l localname ] [ -T timeoutconn ] [ -i localip ] [ -p localport ]\n" \ -"s6-tlsc options: [ -S | -s ] [ -Y | -y ] [ -K timeout ] [ -k servername ] [ -Z | -z ]" - -#define dieusage() strerr_dieusage(100, USAGE) - -typedef struct options_s options_t, *options_t_ref ; -struct options_s -{ - char const *localname ; - char const *servername ; - unsigned int timeout ; - unsigned int ximeout ; - unsigned int yimeout ; - unsigned int kimeout ; - uint16_t localport ; - ip46full_t localip ; - unsigned int verbosity : 2 ; - unsigned int flag4 : 1 ; - unsigned int flag6 : 1 ; - unsigned int flagD : 1 ; - unsigned int flagH : 1 ; - unsigned int flagr : 1 ; - unsigned int flagN : 1 ; - unsigned int flagS : 1 ; - unsigned int flagy : 1 ; - unsigned int flagZ : 1 ; - unsigned int doxy : 1 ; -} ; - -#define OPTIONS_ZERO \ -{ \ - .localname = 0, \ - .servername = 0, \ - .timeout = 0, \ - .ximeout = 2, \ - .yimeout = 58, \ - .kimeout = 0, \ - .localport = 0, \ - .localip = IP46FULL_ZERO, \ - .verbosity = 1, \ - .flag4 = 0, \ - .flag6 = 0, \ - .flagD = 0, \ - .flagH = 0, \ - .flagr = 0, \ - .flagN = 0, \ - .flagS = 0, \ - .flagy = 0, \ - .flagZ = 0, \ - .doxy = 0 \ -} - -int main (int argc, char const *const *argv, char const *const *envp) -{ - options_t o = OPTIONS_ZERO ; - PROG = "s6-tlsclient" ; - { - subgetopt_t l = SUBGETOPT_ZERO ; - for (;;) - { - int opt = subgetopt_r(argc, argv, "qQv46DdHhRrnNt:l:T:i:p:SsYyK:k:Zz", &l) ; - if (opt == -1) break ; - switch (opt) - { - case 'q' : o.verbosity = 0 ; break ; - case 'Q' : o.verbosity = 1 ; break ; - case 'v' : o.verbosity = 2 ; break ; - case '4' : o.flag4 = 1 ; break ; - case '6' : o.flag6 = 1 ; break ; - case 'D' : o.flagD = 1 ; break ; - case 'd' : o.flagD = 0 ; break ; - case 'H' : o.flagH = 1 ; break ; - case 'h' : o.flagH = 0 ; break ; - case 'R' : o.flagr = 0 ; break ; - case 'r' : o.flagr = 1 ; break ; - case 'n' : o.flagN = 0 ; break ; - case 'N' : o.flagN = 1 ; break ; - case 't' : if (!uint0_scan(l.arg, &o.timeout)) dieusage() ; break ; - case 'l' : o.localname = l.arg ; break ; - case 'T' : - { - size_t n = uint_scan(l.arg, &o.ximeout) ; - if (!n) dieusage() ; - o.doxy = 1 ; - if (!l.arg[n]) - { - o.yimeout = 0 ; - break ; - } - if (l.arg[n] != '+') dieusage() ; - if (!uint0_scan(l.arg + n + 1, &o.yimeout)) dieusage() ; - break ; - } - case 'i' : if (!ip46full_scan(l.arg, &o.localip)) dieusage() ; break ; - case 'p' : if (!uint160_scan(l.arg, &o.localport)) dieusage() ; break ; - case 'S' : o.flagS = 1 ; break ; - case 's' : o.flagS = 0 ; break ; - case 'Y' : o.flagy = 0 ; break ; - case 'y' : o.flagy = 1 ; break ; - case 'K' : if (!uint0_scan(l.arg, &o.kimeout)) dieusage() ; break ; - case 'k' : o.servername = l.arg ; break ; - case 'Z' : o.flagZ = 1 ; break ; - case 'z' : o.flagZ = 0 ; break ; - default : dieusage() ; - } - } - argc -= l.ind ; argv += l.ind ; - if (argc < 3) dieusage() ; - } - - if (!o.servername && !o.flagH) - { - ip46full_t ip ; - if (!ip46full_scan(argv[0], &ip)) - o.servername = argv[0] ; - } - - { - size_t pos = 0 ; - unsigned int m = 0 ; - char fmt[UINT_FMT * 4 + UINT16_FMT + IP46_FMT] ; - char const *newargv[29 + argc] ; - newargv[m++] = S6_NETWORKING_BINPREFIX "s6-tcpclient" ; - if (o.verbosity != 1) newargv[m++] = o.verbosity ? "-v" : "-q" ; - if (o.flag4) newargv[m++] = "-4" ; - if (o.flag6) newargv[m++] = "-6" ; - if (o.flagD) newargv[m++] = "-D" ; - if (o.flagH) newargv[m++] = "-H" ; - if (o.flagr) newargv[m++] = "-r" ; - if (o.flagN) newargv[m++] = "-N" ; - if (o.timeout) - { - newargv[m++] = "-t" ; - newargv[m++] = fmt + pos ; - pos += uint_fmt(fmt + pos, o.timeout) ; - fmt[pos++] = 0 ; - } - if (o.localname) - { - newargv[m++] = "-l" ; - newargv[m++] = o.localname ; - } - if (o.doxy) - { - newargv[m++] = "-T" ; - newargv[m++] = fmt + pos ; - pos += uint_fmt(fmt + pos, o.ximeout) ; - fmt[pos++] = '+' ; - pos += uint_fmt(fmt + pos, o.yimeout) ; - fmt[pos++] = 0 ; - } - if (memcmp(o.localip.ip, IP6_ANY, 16)) - { - newargv[m++] = "-i" ; - newargv[m++] = fmt + pos ; - pos += ip46full_fmt(fmt + pos, &o.localip) ; - fmt[pos++] = 0 ; - } - if (o.localport) - { - newargv[m++] = "-p" ; - newargv[m++] = fmt + pos ; - pos += uint16_fmt(fmt + pos, o.localport) ; - fmt[pos++] = 0 ; - } - newargv[m++] = "--" ; - newargv[m++] = *argv++ ; - newargv[m++] = *argv++ ; - newargv[m++] = S6_NETWORKING_BINPREFIX "s6-tlsc" ; - if (o.flagS) newargv[m++] = "-S" ; - if (o.flagy) newargv[m++] = "-y" ; - if (o.kimeout) - { - newargv[m++] = "-K" ; - newargv[m++] = fmt + pos ; - pos += uint_fmt(fmt + pos, o.kimeout) ; - fmt[pos++] = 0 ; - } - if (o.servername) - { - newargv[m++] = "-k" ; - newargv[m++] = o.servername ; - } - if (o.flagZ) newargv[m++] = "-Z" ; - newargv[m++] = "--" ; - while (*argv) newargv[m++] = *argv++ ; - newargv[m++] = 0 ; - xpathexec_run(newargv[0], newargv, envp) ; - } -} diff --git a/src/conn-tools/s6-tlsd-io.c b/src/conn-tools/s6-tlsd-io.c deleted file mode 100644 index 0b42b3b..0000000 --- a/src/conn-tools/s6-tlsd-io.c +++ /dev/null @@ -1,126 +0,0 @@ -/* ISC license. */ - -#include <stdint.h> -#include <unistd.h> -#include <signal.h> - -#include <skalibs/gccattributes.h> -#include <skalibs/types.h> -#include <skalibs/sgetopt.h> -#include <skalibs/strerr2.h> -#include <skalibs/allreadwrite.h> -#include <skalibs/sig.h> -#include <skalibs/tai.h> -#include <skalibs/env.h> -#include <skalibs/djbunix.h> - -#include <s6-networking/config.h> - -#define HANDSHAKE_BANNER "SSL_PROTOCOL=TLSv1\0" - -static inline void doit (int *, tain_t const *tto, uint32_t, uint32_t, unsigned int, unsigned int) gccattr_noreturn ; - -#ifdef S6_NETWORKING_USE_TLS - -#include <s6-networking/stls.h> - -static inline void doit (int *fds, tain_t const *tto, uint32_t preoptions, uint32_t options, unsigned int verbosity, unsigned int notif) -{ - struct tls *ctx = stls_server_init_and_handshake(fds + 2, preoptions) ; - if (notif) - { - if (allwrite(notif, HANDSHAKE_BANNER, sizeof(HANDSHAKE_BANNER)) < sizeof(HANDSHAKE_BANNER)) - strerr_diefu1sys(111, "write post-handshake data") ; - fd_close(notif) ; - } - stls_run(ctx, fds, tto, options, verbosity) ; -} - -#else -#ifdef S6_NETWORKING_USE_BEARSSL - -#include <skalibs/random.h> - -#include <s6-networking/sbearssl.h> - -static int handshake_cb_nop (br_ssl_engine_context *ctx, sbearssl_handshake_cb_context_t *cbarg) -{ - (void)ctx ; - (void)cbarg ; - return 1 ; -} - -static int handshake_cb_sendvars (br_ssl_engine_context *ctx, sbearssl_handshake_cb_context_t *cbarg) -{ - if (allwrite(cbarg->notif, HANDSHAKE_BANNER, sizeof(HANDSHAKE_BANNER)) < sizeof(HANDSHAKE_BANNER)) - return 0 ; - fd_close(cbarg->notif) ; - return 1 ; -} - -static inline void doit (int *fds, tain_t const *tto, uint32_t preoptions, uint32_t options, unsigned int verbosity, unsigned int notif) -{ - if (ndelay_on(fds[0]) < 0 || ndelay_on(fds[1]) < 0) - strerr_diefu1sys(111, "set local fds non-blocking") ; - if (!random_init()) strerr_diefu1sys(111, "initialize random device") ; - sbearssl_server_init_and_run(fds, tto, preoptions, options, verbosity, notif ? &handshake_cb_sendvars : &handshake_cb_nop, notif) ; -} - -#else - -#error No SSL backend configured. - -#endif -#endif - - -#define USAGE "s6-tlsd-io [ -v verbosity ] [ -d notif ] [ -S | -s ] [ -Y | -y ] [ -K timeout ] fdr fdw" -#define dieusage() strerr_dieusage(100, USAGE) - -int main (int argc, char const *const *argv, char const *const *envp) -{ - tain_t tto ; - int fds[4] = { 0, 1, 0, 1 } ; - unsigned int verbosity = 1 ; - unsigned int notif = 0 ; - uint32_t preoptions = 0 ; - uint32_t options = 1 ; - - PROG = "s6-tlsd-io" ; - { - subgetopt_t l = SUBGETOPT_ZERO ; - unsigned int t = 0 ; - for (;;) - { - int opt = subgetopt_r(argc, argv, "d:SsYyv:K:", &l) ; - if (opt == -1) break ; - switch (opt) - { - case 'v' : if (!uint0_scan(l.arg, &verbosity)) dieusage() ; break ; - case 'd' : if (!uint0_scan(l.arg, ¬if)) dieusage() ; break ; - case 'S' : options &= ~1 ; break ; - case 's' : options |= 1 ; break ; - case 'Y' : preoptions |= 1 ; preoptions &= ~2 ; break ; - case 'y' : preoptions |= 3 ; break ; - case 'K' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ; - default : dieusage() ; - } - } - argc -= l.ind ; argv += l.ind ; - if (t) tain_from_millisecs(&tto, t) ; else tto = tain_infinite_relative ; - } - if (argc < 2) dieusage() ; - { - unsigned int u ; - if (!uint0_scan(argv[0], &u)) dieusage() ; - fds[0] = u ; - if (!uint0_scan(argv[1], &u)) dieusage() ; - fds[1] = u ; - } - - if (ndelay_on(0) < 0 || ndelay_on(1) < 0) - strerr_diefu1sys(111, "set stdin/stdout non-blocking") ; - if (sig_ignore(SIGPIPE) < 0) strerr_diefu1sys(111, "ignore SIGPIPE") ; - tain_now_set_stopwatch_g() ; - doit(fds, &tto, preoptions, options, verbosity, notif) ; -} diff --git a/src/conn-tools/s6-tlsd.c b/src/conn-tools/s6-tlsd.c deleted file mode 100644 index 361502e..0000000 --- a/src/conn-tools/s6-tlsd.c +++ /dev/null @@ -1,72 +0,0 @@ -/* ISC license. */ - -#include <stdint.h> -#include <unistd.h> - -#include <skalibs/gccattributes.h> -#include <skalibs/types.h> -#include <skalibs/sgetopt.h> -#include <skalibs/strerr2.h> -#include <skalibs/env.h> -#include <skalibs/djbunix.h> - -#include "s6tls-internal.h" - -#define USAGE "s6-tlsd [ -S | -s ] [ -Y | -y ] [ -v verbosity ] [ -K timeout ] [ -Z | -z ] prog..." -#define dieusage() strerr_dieusage(100, USAGE) - -static void child (int const [4][2], uint32_t, unsigned int, unsigned int) gccattr_noreturn ; -static void child (int const p[4][2], uint32_t options, unsigned int verbosity, unsigned int kimeout) -{ - int fds[3] = { p[0][0], p[1][1], p[2][1] } ; - PROG = "s6-tlsd (child)" ; - close(p[2][0]) ; - close(p[0][1]) ; - close(p[1][0]) ; - s6tls_exec_tlsdio(fds, options, verbosity, kimeout) ; -} - -int main (int argc, char const *const *argv) -{ - unsigned int verbosity = 1 ; - unsigned int kimeout = 0 ; - int p[4][2] = { [3] = { 0, 1 } } ; - uint32_t coptions = 0 ; - uint32_t poptions = 1 ; - pid_t pid ; - - PROG = "s6-tlsd (parent)" ; - { - subgetopt_t l = SUBGETOPT_ZERO ; - for (;;) - { - int opt = subgetopt_r(argc, argv, "SsYyv:K:Zz", &l) ; - if (opt == -1) break ; - switch (opt) - { - case 'S' : coptions |= 4 ; break ; - case 's' : coptions &= ~4 ; break ; - case 'Y' : coptions |= 1 ; coptions &= ~2 ; break ; - case 'y' : coptions |= 3 ; break ; - case 'v' : if (!uint0_scan(l.arg, &verbosity)) dieusage() ; break ; - case 'K' : if (!uint0_scan(l.arg, &kimeout)) dieusage() ; break ; - case 'Z' : poptions &= ~1 ; break ; - case 'z' : poptions |= 1 ; break ; - default : dieusage() ; - } - } - argc -= l.ind ; argv += l.ind ; - } - if (!argc) dieusage() ; - - if (pipe(p[0]) < 0 || pipe(p[1]) < 0 || pipe(p[2]) < 0) - strerr_diefu1sys(111, "pipe") ; - pid = fork() ; - switch (pid) - { - case -1 : strerr_diefu1sys(111, "fork") ; - case 0 : child(p, coptions, verbosity, kimeout) ; - default : break ; - } - s6tls_sync_and_exec_app(argv, p, pid, poptions) ; -} diff --git a/src/conn-tools/s6-tlsserver.c b/src/conn-tools/s6-tlsserver.c deleted file mode 100644 index fb899eb..0000000 --- a/src/conn-tools/s6-tlsserver.c +++ /dev/null @@ -1,255 +0,0 @@ -/* ISC license. */ - -#include <sys/types.h> -#include <limits.h> -#include <skalibs/types.h> -#include <skalibs/sgetopt.h> -#include <skalibs/strerr2.h> -#include <skalibs/djbunix.h> -#include <s6/config.h> -#include <s6-networking/config.h> - -#define USAGE "s6-tlsserver [ -e ] [ options ] ip port prog...\n" \ -"s6-tcpserver options: [ -q | -Q | -v ] [ -4 | -6 ] [ -1 ] [ -c maxconn ] [ -C localmaxconn ] [ -b backlog ] [ -G gidlist ] [ -g gid ] [ -u uid ] [ -U ]\n" \ -"s6-tcpserver-access options: [ -W | -w ] [ -D | -d ] [ -H | -h ] [ -R | -r ] [ -P | -p ] [ -l localname ] [ -B banner ] [ -t timeout ] [ -i rulesdir | -x rulesfile ]\n" \ -"s6-tlsd options: [ -S | -s ] [ -Y | -y ] [ -K timeout ] [ -Z | -z ]" - -#define dieusage() strerr_dieusage(100, USAGE) - -typedef struct options_s options_t, *options_t_ref ; -struct options_s -{ - char const *localname ; - char const *banner ; - char const *rules ; - gid_t gids[NGROUPS_MAX] ; - size_t gidn ; - uid_t uid ; - gid_t gid ; - unsigned int maxconn ; - unsigned int localmaxconn ; - unsigned int backlog ; - unsigned int timeout ; - unsigned int kimeout ; - unsigned int verbosity : 2 ; - unsigned int flag46 : 2 ; - unsigned int flag1 : 1 ; - unsigned int flagU : 1 ; - unsigned int flagw : 1 ; - unsigned int flagD : 1 ; - unsigned int flagH : 1 ; - unsigned int flagr : 1 ; - unsigned int flagp : 1 ; - unsigned int ruleswhat : 2 ; - unsigned int flagS : 1 ; - unsigned int flagy : 1 ; - unsigned int flagZ : 1 ; - unsigned int onlyvars : 1 ; - unsigned int doaccess : 1 ; - unsigned int doapply : 1 ; -} ; - -#define OPTIONS_ZERO \ -{ \ - .localname = 0, \ - .banner = 0, \ - .rules = 0, \ - .backlog = (unsigned int)-1, \ - .gidn = (size_t)-1, \ - .uid = 0, \ - .gid = 0, \ - .maxconn = 0, \ - .localmaxconn = 0, \ - .timeout = 0, \ - .kimeout = 0, \ - .verbosity = 1, \ - .flag46 = 0, \ - .flag1 = 0, \ - .flagU = 0, \ - .flagw = 0, \ - .flagD = 0, \ - .flagH = 0, \ - .flagr = 0, \ - .flagp = 0, \ - .ruleswhat = 0, \ - .flagS = 0, \ - .flagy = 0, \ - .flagZ = 0, \ - .onlyvars = 0, \ - .doaccess = 0, \ - .doapply = 0 \ -} - -int main (int argc, char const *const *argv, char const *const *envp) -{ - options_t o = OPTIONS_ZERO ; - PROG = "s6-tlsserver" ; - { - subgetopt_t l = SUBGETOPT_ZERO ; - for (;;) - { - int opt = subgetopt_r(argc, argv, "qQv461c:C:b:G:g:u:UWwDdHhRrPpleB:t:i:x:SsYyK:Zz", &l) ; - if (opt == -1) break ; - switch (opt) - { - case 'q' : o.verbosity = 0 ; break ; - case 'Q' : o.verbosity = 1 ; break ; - case 'v' : o.verbosity = 2 ; break ; - case '4' : o.flag46 = 1 ; break ; - case '6' : o.flag46 = 2 ; break ; - case '1' : o.flag1 = 1 ; break ; - case 'c' : if (!uint0_scan(l.arg, &o.maxconn)) dieusage() ; if (!o.maxconn) o.maxconn = 1 ; break ; - case 'C' : if (!uint0_scan(l.arg, &o.localmaxconn)) dieusage() ; if (!o.localmaxconn) o.localmaxconn = 1 ; break ; - case 'b' : if (!uint0_scan(l.arg, &o.backlog)) dieusage() ; break ; - case 'G' : if (!gid_scanlist(o.gids, NGROUPS_MAX, l.arg, &o.gidn) && *l.arg) dieusage() ; o.doapply = 1 ; break ; - case 'g' : if (!gid0_scan(l.arg, &o.gid)) dieusage() ; o.doapply = 1 ; break ; - case 'u' : if (!uid0_scan(l.arg, &o.uid)) dieusage() ; o.doapply = 1 ; break ; - case 'U' : o.flagU = 1 ; o.uid = 0 ; o.gid = 0 ; o.gidn = (size_t)-1 ; o.doapply = 1 ; break ; - case 'W' : o.flagw = 0 ; break ; - case 'w' : o.flagw = 1 ; break ; - case 'D' : o.flagD = 1 ; o.doaccess = 1 ; break ; - case 'd' : o.flagD = 0 ; break ; - case 'H' : o.flagH = 1 ; o.doaccess = 1 ; break ; - case 'h' : o.flagH = 0 ; break ; - case 'R' : o.flagr = 0 ; break ; - case 'r' : o.flagr = 1 ; o.doaccess = 1 ; break ; - case 'P' : o.flagp = 0 ; break ; - case 'p' : o.flagp = 1 ; o.doaccess = 1 ; break ; - case 'l' : o.localname = l.arg ; o.doaccess = 1 ; break ; - case 'e' : o.onlyvars = 1 ; o.doaccess = 1 ; break ; - case 'B' : o.banner = l.arg ; o.doaccess = 1 ; break ; - case 't' : if (!uint0_scan(l.arg, &o.timeout)) dieusage() ; break ; - case 'i' : o.rules = l.arg ; o.ruleswhat = 1 ; o.doaccess = 1 ; break ; - case 'x' : o.rules = l.arg ; o.ruleswhat = 2 ; o.doaccess = 1 ; break ; - case 'S' : o.flagS = 1 ; break ; - case 's' : o.flagS = 0 ; break ; - case 'Y' : o.flagy = 0 ; break ; - case 'y' : o.flagy = 1 ; break ; - case 'K' : if (!uint0_scan(l.arg, &o.kimeout)) dieusage() ; break ; - case 'Z' : o.flagZ = 1 ; break ; - case 'z' : o.flagZ = 0 ; break ; - default : dieusage() ; - } - } - argc -= l.ind ; argv += l.ind ; - if (argc < 3) dieusage() ; - } - - { - size_t pos = 0 ; - unsigned int m = 0 ; - char fmt[UINT_FMT * 5 + UID_FMT + GID_FMT * (NGROUPS_MAX + 1)] ; - char const *newargv[45 + argc] ; - newargv[m++] = S6_NETWORKING_BINPREFIX "s6-tcpserver" ; - if (o.verbosity != 1) newargv[m++] = o.verbosity ? "-v" : "-q" ; - if (o.flag46) newargv[m++] = o.flag46 == 1 ? "-4" : "-6" ; - if (o.flag1) newargv[m++] = "-1" ; - if (o.maxconn) - { - newargv[m++] = "-c" ; - newargv[m++] = fmt + pos ; - pos += uint_fmt(fmt + pos, o.maxconn) ; - fmt[pos++] = 0 ; - } - if (o.localmaxconn) - { - newargv[m++] = "-C" ; - newargv[m++] = fmt + pos ; - pos += uint_fmt(fmt + pos, o.localmaxconn) ; - fmt[pos++] = 0 ; - } - if (o.backlog != (unsigned int)-1) - { - newargv[m++] = "-b" ; - newargv[m++] = fmt + pos ; - pos += uint_fmt(fmt + pos, o.backlog) ; - fmt[pos++] = 0 ; - } - newargv[m++] = "--" ; - newargv[m++] = *argv++ ; - newargv[m++] = *argv++ ; - if (o.doaccess) - { - newargv[m++] = S6_NETWORKING_BINPREFIX "s6-tcpserver-access" ; - if (o.verbosity) - { - if (o.verbosity > 1 && (!o.onlyvars || o.ruleswhat)) - newargv[m++] = "-v2" ; - } - else newargv[m++] = "-v0" ; - - if (o.flagw) newargv[m++] = "-w" ; - if (o.flagD) newargv[m++] = "-D" ; - if (o.flagH) newargv[m++] = "-H" ; - if (o.flagr) newargv[m++] = "-r" ; - if (o.flagp) newargv[m++] = "-p" ; - if (o.localname) - { - newargv[m++] = "-l" ; - newargv[m++] = o.localname ; - } - if (o.banner) - { - newargv[m++] = "-B" ; - newargv[m++] = o.banner ; - } - if (o.timeout) - { - newargv[m++] = "-t" ; - newargv[m++] = fmt + pos ; - pos += uint_fmt(fmt + pos, o.timeout) ; - fmt[pos++] = 0 ; - } - if (o.ruleswhat) - { - newargv[m++] = o.ruleswhat == 1 ? "-i" : "-x" ; - newargv[m++] = o.rules ; - } - newargv[m++] = "--" ; - } - newargv[m++] = S6_NETWORKING_BINPREFIX "s6-tlsd" ; - if (o.verbosity != 1) - newargv[m++] = o.verbosity ? "-v2" : "-v0" ; - if (o.flagS) newargv[m++] = "-S" ; - if (o.flagy) newargv[m++] = "-y" ; - if (o.kimeout) - { - newargv[m++] = "-K" ; - newargv[m++] = fmt + pos ; - pos += uint_fmt(fmt + pos, o.kimeout) ; - fmt[pos++] = 0 ; - } - if (o.flagZ) newargv[m++] = "-Z" ; - newargv[m++] = "--" ; - if (o.doapply) - { - newargv[m++] = S6_EXTBINPREFIX "s6-applyuidgid" ; - if (o.gidn != (size_t)-1) - { - newargv[m++] = "-G" ; - newargv[m++] = fmt + pos ; - pos += gid_fmtlist(fmt + pos, o.gids, o.gidn) ; - fmt[pos++] = 0 ; - } - if (o.gid) - { - newargv[m++] = "-g" ; - newargv[m++] = fmt + pos ; - pos += gid_fmt(fmt + pos, o.gid) ; - fmt[pos++] = 0 ; - } - if (o.uid) - { - newargv[m++] = "-u" ; - newargv[m++] = fmt + pos ; - pos += uid_fmt(fmt + pos, o.uid) ; - fmt[pos++] = 0 ; - } - if (o.flagU) newargv[m++] = "-Uz" ; - newargv[m++] = "--" ; - } - while (*argv) newargv[m++] = *argv++ ; - newargv[m++] = 0 ; - xpathexec_run(newargv[0], newargv, envp) ; - } -} diff --git a/src/conn-tools/s6-ucspitlsc.c b/src/conn-tools/s6-ucspitlsc.c deleted file mode 100644 index 92660eb..0000000 --- a/src/conn-tools/s6-ucspitlsc.c +++ /dev/null @@ -1,109 +0,0 @@ -/* ISC license. */ - -#include <fcntl.h> -#include <stdint.h> -#include <unistd.h> - -#include <skalibs/gccattributes.h> -#include <skalibs/types.h> -#include <skalibs/sgetopt.h> -#include <skalibs/strerr2.h> -#include <skalibs/djbunix.h> -#include <skalibs/webipc.h> - -#include <s6-networking/config.h> -#include "s6tls-internal.h" - -#define USAGE "s6-ucspitlsc [ -S | -s ] [ -Y | -y ] [ -v verbosity ] [ -K timeout ] [ -Z | -z ] [ -k servername ] [ -6 fdr ] [ -7 fdw ] prog..." -#define dieusage() strerr_dieusage(100, USAGE) - -static inline void child (int [4][2], uint32_t, unsigned int, unsigned int, char const *) gccattr_noreturn ; -static inline void child (int p[4][2], uint32_t options, unsigned int verbosity, unsigned int kimeout, char const *servername) -{ - int fds[3] = { p[0][0], p[1][1], p[2][1] } ; - ssize_t r ; - char c ; - PROG = "s6-ucspitlsc" ; - close(p[2][0]) ; - close(p[0][1]) ; - close(p[1][0]) ; - if (fd_move(0, p[3][0]) < 0 || fd_move(1, p[3][1]) < 0) - strerr_diefu1sys(111, "move network fds to stdin/stdout") ; - r = read(p[2][1], &c, 1) ; - if (r < 0) strerr_diefu1sys(111, "read from control socket") ; - if (!r) _exit(0) ; - switch (c) - { - case 'y' : - close(p[2][1]) ; - p[2][1] = 0 ; /* we know 0 is open so it's a correct invalid value */ - case 'Y' : - fd_shutdown(p[2][1], 0) ; - break ; - default : - strerr_dief1x(100, "unrecognized command on control socket") ; - } - s6tls_exec_tlscio(fds, options, verbosity, kimeout, servername) ; -} - -int main (int argc, char const *const *argv, char const *const *envp) -{ - unsigned int verbosity = 1 ; - unsigned int kimeout = 0 ; - int p[4][2] = { [3] = { 6, 7 } } ; - uint32_t coptions = 0 ; - uint32_t poptions = 1 ; - char const *servername = 0 ; - - PROG = "s6-ucspitlsc (parent)" ; - { - subgetopt_t l = SUBGETOPT_ZERO ; - for (;;) - { - int opt = subgetopt_r(argc, argv, "SsYyv:K:Zzk:6:7:", &l) ; - if (opt == -1) break ; - switch (opt) - { - case 'S' : coptions |= 4 ; break ; - case 's' : coptions &= ~4 ; break ; - case 'Y' : coptions |= 1 ; coptions &= ~2 ; break ; - case 'y' : coptions |= 3 ; break ; - case 'v' : if (!uint0_scan(l.arg, &verbosity)) dieusage() ; break ; - case 'K' : if (!uint0_scan(l.arg, &kimeout)) dieusage() ; break ; - case 'Z' : poptions &= ~1 ; break ; - case 'z' : poptions |= 1 ; break ; - case 'k' : servername = l.arg ; break ; - case '6' : - { - unsigned int fd ; - if (!uint0_scan(l.arg, &fd)) dieusage() ; - p[3][0] = fd ; - break ; - } - case '7' : - { - unsigned int fd ; - if (!uint0_scan(l.arg, &fd)) dieusage() ; - p[3][1] = fd ; - break ; - } - default : dieusage() ; - } - } - argc -= l.ind ; argv += l.ind ; - } - if (!argc) dieusage() ; - fd_sanitize() ; - if (fcntl(p[3][0], F_GETFD) < 0 || fcntl(p[3][1], F_GETFD) < 0) - strerr_diefu1sys(111, "check network fds") ; - - if (ipc_pair_b(p[2]) < 0) strerr_diefu1sys(111, "ipc_pair") ; - if (pipe(p[0]) < 0 || pipe(p[1]) < 0) strerr_diefu1sys(111, "pipe") ; - switch (fork()) - { - case -1 : strerr_diefu1sys(111, "fork") ; - case 0 : child(p, coptions, verbosity, kimeout, servername) ; - default : break ; - } - s6tls_ucspi_exec_app(argv, p, poptions) ; -} diff --git a/src/conn-tools/s6-ucspitlsd.c b/src/conn-tools/s6-ucspitlsd.c deleted file mode 100644 index 4bfa253..0000000 --- a/src/conn-tools/s6-ucspitlsd.c +++ /dev/null @@ -1,88 +0,0 @@ -/* ISC license. */ - -#include <stdint.h> -#include <unistd.h> - -#include <skalibs/gccattributes.h> -#include <skalibs/types.h> -#include <skalibs/sgetopt.h> -#include <skalibs/strerr2.h> -#include <skalibs/djbunix.h> -#include <skalibs/webipc.h> - -#include <s6-networking/config.h> -#include "s6tls-internal.h" - -#define USAGE "s6-ucspitlsd [ -S | -s ] [ -Y | -y ] [ -v verbosity ] [ -K timeout ] [ -Z | -z ] prog..." -#define dieusage() strerr_dieusage(100, USAGE) - -static inline void child (int [4][2], uint32_t, unsigned int, unsigned int) gccattr_noreturn ; -static inline void child (int p[4][2], uint32_t options, unsigned int verbosity, unsigned int kimeout) -{ - int fds[3] = { p[0][0], p[1][1], p[2][1] } ; - ssize_t r ; - char c ; - PROG = "s6-ucspitlsd" ; - close(p[2][0]) ; - close(p[0][1]) ; - close(p[1][0]) ; - r = read(p[2][1], &c, 1) ; - if (r < 0) strerr_diefu1sys(111, "read from control socket") ; - if (!r) _exit(0) ; - switch (c) - { - case 'y' : - close(p[2][1]) ; - p[2][1] = 0 ; /* we know 0 is open so it's a correct invalid value */ - case 'Y' : - fd_shutdown(p[2][1], 0) ; - break ; - default : - strerr_dief1x(100, "unrecognized command on control socket") ; - } - s6tls_exec_tlsdio(fds, options, verbosity, kimeout) ; -} - -int main (int argc, char const *const *argv, char const *const *envp) -{ - unsigned int verbosity = 1 ; - unsigned int kimeout = 0 ; - int p[4][2] = { [3] = { 0, 1 } } ; - uint32_t coptions = 0 ; - uint32_t poptions = 1 ; - - PROG = "s6-ucspitlsd (parent)" ; - { - subgetopt_t l = SUBGETOPT_ZERO ; - for (;;) - { - int opt = subgetopt_r(argc, argv, "SsYyv:K:Zz", &l) ; - if (opt == -1) break ; - switch (opt) - { - case 'S' : coptions |= 4 ; break ; - case 's' : coptions &= ~4 ; break ; - case 'Y' : coptions |= 1 ; coptions &= ~2 ; break ; - case 'y' : coptions |= 3 ; break ; - case 'v' : if (!uint0_scan(l.arg, &verbosity)) dieusage() ; break ; - case 'K' : if (!uint0_scan(l.arg, &kimeout)) dieusage() ; break ; - case 'Z' : poptions &= ~1 ; break ; - case 'z' : poptions |= 1 ; break ; - default : dieusage() ; - } - } - argc -= l.ind ; argv += l.ind ; - } - if (!argc) dieusage() ; - - if (ipc_pair_b(p[2]) < 0) strerr_diefu1sys(111, "ipc_pair") ; - if (pipe(p[0]) < 0 || pipe(p[1]) < 0) strerr_diefu1sys(111, "pipe") ; - - switch (fork()) - { - case -1 : strerr_diefu1sys(111, "fork") ; - case 0 : child(p, coptions, verbosity, kimeout) ; - default : break ; - } - s6tls_ucspi_exec_app(argv, p, poptions) ; -} diff --git a/src/conn-tools/s6tls-internal.h b/src/conn-tools/s6tls-internal.h deleted file mode 100644 index 09be544..0000000 --- a/src/conn-tools/s6tls-internal.h +++ /dev/null @@ -1,18 +0,0 @@ -/* ISC license */ - -#ifndef S6TLS_INTERNAL_H -#define S6TLS_INTERNAL_H - -#include <stdint.h> -#include <unistd.h> - -#include <skalibs/gccattributes.h> - -#define s6tls_envvars "CADIR\0CAFILE\0KEYFILE\0CERTFILE\0TLS_UID\0TLS_GID" - -extern void s6tls_exec_tlscio (int const *, uint32_t, unsigned int, unsigned int, char const *) gccattr_noreturn ; -extern void s6tls_exec_tlsdio (int const *, uint32_t, unsigned int, unsigned int) gccattr_noreturn ; -extern void s6tls_sync_and_exec_app (char const *const *, int const [4][2], pid_t, uint32_t) gccattr_noreturn ; -extern void s6tls_ucspi_exec_app (char const *const *, int const [4][2], uint32_t) gccattr_noreturn ; - -#endif diff --git a/src/conn-tools/s6tls_exec_tlscio.c b/src/conn-tools/s6tls_exec_tlscio.c deleted file mode 100644 index ad00ecd..0000000 --- a/src/conn-tools/s6tls_exec_tlscio.c +++ /dev/null @@ -1,53 +0,0 @@ -/* ISC license. */ - -#include <skalibs/posixplz.h> -#include <skalibs/types.h> -#include <skalibs/djbunix.h> - -#include <s6-networking/config.h> -#include "s6tls-internal.h" - -void s6tls_exec_tlscio (int const *fds, uint32_t options, unsigned int verbosity, unsigned int kimeout, char const *servername) -{ - char const *newargv[15] ; - unsigned int m = 0 ; - char fmtv[UINT_FMT] ; - char fmtd[UINT_FMT] ; - char fmtk[UINT_FMT] ; - char fmtr[UINT_FMT] ; - char fmtw[UINT_FMT] ; - - newargv[m++] = S6_NETWORKING_BINPREFIX "s6-tlsc-io" ; - if (verbosity != 1) - { - newargv[m++] = "-v" ; - newargv[m++] = fmtv ; - fmtv[uint_fmt(fmtv, verbosity)] = 0 ; - } - if (fds[2]) - { - newargv[m++] = "-d" ; - newargv[m++] = fmtd ; - fmtd[uint_fmt(fmtd, fds[2])] = 0 ; - } - newargv[m++] = options & 4 ? "-S" : "-s" ; - newargv[m++] = options & 1 ? "-y" : "-Y" ; - if (kimeout) - { - newargv[m++] = "-K" ; - newargv[m++] = fmtk ; - fmtk[uint_fmt(fmtk, kimeout)] = 0 ; - } - if (servername) - { - newargv[m++] = "-k" ; - newargv[m++] = servername ; - } - newargv[m++] = "--" ; - newargv[m++] = fmtr ; - fmtr[uint_fmt(fmtr, fds[0])] = 0 ; - newargv[m++] = fmtw ; - fmtw[uint_fmt(fmtw, fds[1])] = 0 ; - newargv[m++] = 0 ; - xpathexec_run(newargv[0], newargv, (char const *const *)environ) ; -} diff --git a/src/conn-tools/s6tls_exec_tlsdio.c b/src/conn-tools/s6tls_exec_tlsdio.c deleted file mode 100644 index b00adb2..0000000 --- a/src/conn-tools/s6tls_exec_tlsdio.c +++ /dev/null @@ -1,49 +0,0 @@ -/* ISC license. */ - -#include <skalibs/posixplz.h> -#include <skalibs/types.h> -#include <skalibs/djbunix.h> - -#include <s6-networking/config.h> -#include "s6tls-internal.h" - -void s6tls_exec_tlsdio (int const *fds, uint32_t options, unsigned int verbosity, unsigned int kimeout) -{ - char const *newargv[13] ; - unsigned int m = 0 ; - char fmtv[UINT_FMT] ; - char fmtd[UINT_FMT] ; - char fmtk[UINT_FMT] ; - char fmtr[UINT_FMT] ; - char fmtw[UINT_FMT] ; - - newargv[m++] = S6_NETWORKING_BINPREFIX "s6-tlsd-io" ; - if (verbosity != 1) - { - newargv[m++] = "-v" ; - newargv[m++] = fmtv ; - fmtv[uint_fmt(fmtv, verbosity)] = 0 ; - } - if (fds[2]) - { - newargv[m++] = "-d" ; - newargv[m++] = fmtd ; - fmtd[uint_fmt(fmtd, fds[2])] = 0 ; - } - newargv[m++] = options & 4 ? "-S" : "-s" ; - if (options & 1) - newargv[m++] = options & 2 ? "-y" : "-Y" ; - if (kimeout) - { - newargv[m++] = "-K" ; - newargv[m++] = fmtk ; - fmtk[uint_fmt(fmtk, kimeout)] = 0 ; - } - newargv[m++] = "--" ; - newargv[m++] = fmtr ; - fmtr[uint_fmt(fmtr, fds[0])] = 0 ; - newargv[m++] = fmtw ; - fmtw[uint_fmt(fmtw, fds[1])] = 0 ; - newargv[m++] = 0 ; - xpathexec_run(newargv[0], newargv, (char const *const *)environ) ; -} diff --git a/src/conn-tools/s6tls_sync_and_exec_app.c b/src/conn-tools/s6tls_sync_and_exec_app.c deleted file mode 100644 index 4ae63fa..0000000 --- a/src/conn-tools/s6tls_sync_and_exec_app.c +++ /dev/null @@ -1,43 +0,0 @@ -/* ISC license. */ - -#include <stdint.h> -#include <unistd.h> - -#include <skalibs/posixplz.h> -#include <skalibs/strerr2.h> -#include <skalibs/env.h> -#include <skalibs/djbunix.h> - -#include "s6tls-internal.h" - -#define MAXENVSIZE 2048 - -void s6tls_sync_and_exec_app (char const *const *argv, int const p[4][2], pid_t pid, uint32_t options) -{ - char buf[sizeof(s6tls_envvars) + MAXENVSIZE] ; - size_t m = 0 ; - ssize_t r ; - close(p[2][1]) ; - close(p[1][1]) ; - close(p[0][0]) ; - if (fd_move(p[3][0], p[1][0]) < 0 || fd_move(p[3][1], p[0][1]) < 0) - strerr_diefu1sys(111, "move file descriptors") ; - if (options & 1) - { - memcpy(buf + m, s6tls_envvars, sizeof(s6tls_envvars)) ; - m += sizeof(s6tls_envvars) ; - } - r = read(p[2][0], buf + m, MAXENVSIZE) ; - if (r < 0) strerr_diefu1sys(111, "read from handshake notification pipe") ; - if (!r) - { - int wstat ; - if (wait_pid(pid, &wstat) < 0) - strerr_diefu1sys(111, "wait") ; - _exit(wait_estatus(wstat)) ; - } - if (r >= MAXENVSIZE) - strerr_dief1x(100, "SSL data too large") ; - m += r - 1 ; - xpathexec_r(argv, (char const *const *)environ, env_len((char const *const *)environ), buf, m) ; -} diff --git a/src/conn-tools/s6tls_ucspi_exec_app.c b/src/conn-tools/s6tls_ucspi_exec_app.c deleted file mode 100644 index f4b52ef..0000000 --- a/src/conn-tools/s6tls_ucspi_exec_app.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ISC license. */ - -#include <stdint.h> -#include <string.h> -#include <unistd.h> - -#include <skalibs/posixplz.h> -#include <skalibs/types.h> -#include <skalibs/env.h> -#include <skalibs/djbunix.h> - -#include "s6tls-internal.h" - -void s6tls_ucspi_exec_app (char const *const *argv, int const p[4][2], uint32_t options) -{ - size_t m = 0 ; - char modif[sizeof(s6tls_envvars) + 33 + 3 * UINT_FMT] ; - close(p[2][1]) ; - close(p[1][1]) ; - close(p[0][0]) ; - if (options & 1) - { - memcpy(modif + m, s6tls_envvars, sizeof(s6tls_envvars)) ; - m += sizeof(s6tls_envvars) ; - } - memcpy(modif + m, "SSLCTLFD=", 9) ; m += 9 ; - m += uint_fmt(modif + m, p[2][0]) ; - modif[m++] = 0 ; - memcpy(modif + m, "SSLREADFD=", 10) ; m += 10 ; - m += uint_fmt(modif + m, p[1][0]) ; - modif[m++] = 0 ; - memcpy(modif + m, "SSLWRITEFD=", 11) ; m += 11 ; - m += uint_fmt(modif + m, p[0][1]) ; - modif[m++] = 0 ; - xpathexec_r(argv, (char const *const *)environ, env_len((char const* const *)environ), modif, m) ; -} |