From 0734bbc08aa726cc371f8c0bf5e6aadce2825245 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Sat, 9 Sep 2023 20:39:58 +0000 Subject: Fix s6-tlsd fd fux Signed-off-by: Laurent Bercot --- src/tls/s6-tlsd.c | 2 +- src/tls/s6tls_io_spawn.c | 4 ++-- src/tls/s6tls_sync_and_exec_app.c | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/tls/s6-tlsd.c b/src/tls/s6-tlsd.c index 07716ea..a1c19bf 100644 --- a/src/tls/s6-tlsd.c +++ b/src/tls/s6-tlsd.c @@ -17,7 +17,7 @@ int main (int argc, char const *const *argv) unsigned int verbosity = 1 ; unsigned int kimeout = 0 ; unsigned int snilevel = 0 ; - int p[4][2] = { [3] = { [0] = -1, [1] = -1 } } ; + int p[4][2] = { [3] = { [0] = 0, [1] = 1 } } ; uint32_t coptions = 0 ; uint32_t poptions = 1 ; pid_t pid ; diff --git a/src/tls/s6tls_io_spawn.c b/src/tls/s6tls_io_spawn.c index 8e26807..252ddb5 100644 --- a/src/tls/s6tls_io_spawn.c +++ b/src/tls/s6tls_io_spawn.c @@ -11,9 +11,9 @@ pid_t s6tls_io_spawn (char const *const *argv, int const p[4][2]) { [0] = { .type = CSPAWN_FA_CLOSE, .x = { .fd = p[0][1] } }, [1] = { .type = CSPAWN_FA_CLOSE, .x = { .fd = p[1][0] } }, - [2] = { .type = CSPAWN_FA_CLOSE, .x = { .fd = p[2][1] } }, + [2] = { .type = CSPAWN_FA_CLOSE, .x = { .fd = p[2][0] } }, [3] = { .type = CSPAWN_FA_MOVE, .x = { .fd2 = { [0] = 0, [1] = p[3][0] } } }, [4] = { .type = CSPAWN_FA_MOVE, .x = { .fd2 = { [0] = 1, [1] = p[3][1] } } } } ; - return cspawn(argv[0], argv, (char const *const *)environ, 0, fa, p[3][0] >= 0 ? 5 : 3) ; + return cspawn(argv[0], argv, (char const *const *)environ, 0, fa, 5) ; } diff --git a/src/tls/s6tls_sync_and_exec_app.c b/src/tls/s6tls_sync_and_exec_app.c index 3fdd21c..56e8dc1 100644 --- a/src/tls/s6tls_sync_and_exec_app.c +++ b/src/tls/s6tls_sync_and_exec_app.c @@ -16,8 +16,7 @@ void s6tls_sync_and_exec_app (char const *const *argv, int const p[4][2], pid_t close(p[2][1]) ; close(p[1][1]) ; close(p[0][0]) ; - if ((p[3][0] >= 0 && fd_move(p[3][0], p[1][0]) == -1) - || (p[3][1] >= 0 && fd_move(p[3][1], p[0][1]) == -1)) + if (fd_move(p[3][0], p[1][0]) == -1 || fd_move(p[3][1], p[0][1]) == -1) strerr_diefu1sys(111, "move file descriptors") ; r = read(p[2][0], buf, MAXENVSIZE) ; if (r < 0) strerr_diefu1sys(111, "read from handshake notification pipe") ; -- cgit v1.2.3