diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2023-11-10 11:28:19 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2023-11-10 11:28:19 +0000 |
commit | 1e10d30b41b65dbd520e01adc5fe686cb92b0f12 (patch) | |
tree | 32af8327cb6bb9aa6bbd5e20ee7a2cc1f9c95263 /src/tls/s6-ucspitlsc.c | |
parent | c930181234bfb31fba0136d866e6e75633acafe0 (diff) | |
download | s6-networking-1e10d30b41b65dbd520e01adc5fe686cb92b0f12.tar.xz |
Prepare for 2.7.0.0. Better s6-tlsc-io interface.
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/tls/s6-ucspitlsc.c')
-rw-r--r-- | src/tls/s6-ucspitlsc.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/tls/s6-ucspitlsc.c b/src/tls/s6-ucspitlsc.c index 4f284b7..bb1a2dc 100644 --- a/src/tls/s6-ucspitlsc.c +++ b/src/tls/s6-ucspitlsc.c @@ -18,20 +18,20 @@ #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 *, 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) +static inline void child (int *, uint32_t, unsigned int, unsigned int, char const *, pid_t) gccattr_noreturn ; +static inline void child (int *p, uint32_t options, unsigned int verbosity, unsigned int kimeout, char const *servername, pid_t pid) { ssize_t r ; char const *newargv[S6TLS_PREP_IO_ARGC] ; char buf[S6TLS_PREP_IO_BUFLEN] ; char c ; PROG = "s6-ucspitlsc" ; - close(p[2][0]) ; - close(p[1][0]) ; - close(p[0][1]) ; - if (fd_move(0, p[3][0]) == -1 || fd_move(1, p[3][1]) == -1) + close(p[4]) ; + close(p[2]) ; + close(p[1]) ; + if (fd_move(0, p[0]) == -1 || fd_move(1, p[3]) == -1) strerr_diefu1sys(111, "move network fds to stdin/stdout") ; - r = read(p[2][1], &c, 1) ; + r = read(p[5], &c, 1) ; if (r < 0) strerr_diefu1sys(111, "read from control socket") ; if (!r) { @@ -46,11 +46,11 @@ static inline void child (int p[4][2], uint32_t options, unsigned int verbosity, switch (c) { case 'y' : - close(p[2][1]) ; - p[2][1] = 0 ; /* we know 0 is open so it's a suitable invalid value */ + close(p[5]) ; + p[5] = 0 ; /* we know 0 is open so it's a suitable invalid value */ break ; case 'Y' : - fd_shutdown(p[2][1], 0) ; + fd_shutdown(p[5], 0) ; break ; default : strerr_dief1x(100, "unrecognized command on control socket") ; @@ -69,11 +69,11 @@ 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] = 6, [1] = 7 } } ; uint32_t coptions = 0 ; + int p[8] = { [6] = 6, [7] = 7 } ; uint32_t poptions = 1 ; - char const *servername = 0 ; pid_t pid ; + char const *servername = 0 ; PROG = "s6-ucspitlsc (parent)" ; { @@ -97,14 +97,14 @@ int main (int argc, char const *const *argv, char const *const *envp) { unsigned int fd ; if (!uint0_scan(l.arg, &fd)) dieusage() ; - p[3][0] = fd ; + p[6] = fd ; break ; } case '7' : { unsigned int fd ; if (!uint0_scan(l.arg, &fd)) dieusage() ; - p[3][1] = fd ; + p[7] = fd ; break ; } default : dieusage() ; @@ -112,13 +112,13 @@ int main (int argc, char const *const *argv, char const *const *envp) } argc -= l.ind ; argv += l.ind ; } - if (!argc) dieusage() ; + if (!argc || p[6] == p[7]) dieusage() ; fd_sanitize() ; - if (fcntl(p[3][0], F_GETFD) == -1 || fcntl(p[3][1], F_GETFD) == -1) + if (fcntl(p[6], F_GETFD) == -1 || fcntl(p[7], F_GETFD) == -1) strerr_diefu1sys(111, "check network fds") ; - if (ipc_pair_b(p[2]) == -1) strerr_diefu1sys(111, "ipc_pair") ; - if (pipe(p[0]) == -1 || pipe(p[1]) == -1) strerr_diefu1sys(111, "pipe") ; + if (pipe(p) == -1 || pipe(p+2) == -1) strerr_diefu1sys(111, "pipe") ; + if (ipc_pair_b(p+4) == -1) strerr_diefu1sys(111, "ipc_pair") ; pid = getpid() ; switch (fork()) |