From 0c928fedbb65fb62a1646aa18453e5e11a2a6387 Mon Sep 17 00:00:00 2001 From: Josh Tway Date: Thu, 8 Feb 2018 17:22:22 -0500 Subject: [PATCH] Fixed issue in sslh-fork.c where the parent was being used instead of the child after forking. This was breaking multiple unit tests (on CentOS 7 at least) --- sslh-fork.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sslh-fork.c b/sslh-fork.c index 5ed91d8..2c0b595 100644 --- a/sslh-fork.c +++ b/sslh-fork.c @@ -150,11 +150,11 @@ void main_loop(int listen_sockets[], int num_addr_listen) for (i = 0; i < num_addr_listen; i++) { listener_pid[i] = fork(); switch(listener_pid[i]) { - case 0: break; + // Log if fork() fails for some reason case -1: log_message(LOG_ERR, "fork failed: err %d: %s\n", errno, strerror(errno)); break; - - default: + // We're in the child, we have work to do + case 0: /* Listening process just accepts a connection, forks, and goes * back to listening */ while (1) @@ -178,6 +178,10 @@ void main_loop(int listen_sockets[], int num_addr_listen) } close(in_socket); } + break; + // We're in the parent, we don't need to do anything + default: + break; } }