From 7113c4cf792ec44ec04a54e9723fa31a97bee5a7 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Fri, 8 Sep 2023 08:38:06 +0000 Subject: Refactor s6-tls[cd] so they're ready to port to posix_spawn Signed-off-by: Laurent Bercot --- src/tls/s6-ucspitlsc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/tls/s6-ucspitlsc.c') diff --git a/src/tls/s6-ucspitlsc.c b/src/tls/s6-ucspitlsc.c index 521bb4d..2d728b5 100644 --- a/src/tls/s6-ucspitlsc.c +++ b/src/tls/s6-ucspitlsc.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "s6tls-internal.h" @@ -20,15 +21,17 @@ static inline void child (int [4][2], uint32_t, unsigned int, unsigned int, char const *, pid_t) gccattr_noreturn ; static inline void child (int p[4][2], uint32_t options, unsigned int verbosity, unsigned int kimeout, char const *servername, pid_t pid) { - int fds[3] = { p[0][0], p[1][1], p[2][1] } ; + char const *newargv[S6TLS_PREP_IO_ARGC] ; + char buf[S6TLS_PREP_IO_BUFLEN] ; 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) + if (fd_move(0, p[3][0]) == -1 || fd_move(1, p[3][1]) == -1) strerr_diefu1sys(111, "move network fds to stdin/stdout") ; + s6tls_prep_tlscio(newargv, buf, p[0][0], p[1][1], p[2][1], options, verbosity, kimeout, servername) ; r = read(p[2][1], &c, 1) ; if (r < 0) strerr_diefu1sys(111, "read from control socket") ; if (!r) @@ -59,7 +62,7 @@ static inline void child (int p[4][2], uint32_t options, unsigned int verbosity, fmt[pid_fmt(fmt, pid)] = 0 ; strerr_warni4x("pid ", fmt, " accepted", " opportunistic TLS") ; } - s6tls_exec_tlscio(fds, options, verbosity, kimeout, servername) ; + xexec(newargv) ; } int main (int argc, char const *const *argv, char const *const *envp) -- cgit v1.3.1