From 92b3f879f27a986a8dab0a838d7223d1fbbeed32 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Dec 08 2016 16:00:14 +0000 Subject: import haproxy-1.5.18-3.el7_3.1 --- diff --git a/SOURCES/haproxy-systemd-wrapper-exit-code.patch b/SOURCES/haproxy-systemd-wrapper-exit-code.patch new file mode 100644 index 0000000..f5215e6 --- /dev/null +++ b/SOURCES/haproxy-systemd-wrapper-exit-code.patch @@ -0,0 +1,69 @@ +From 8c8c86d008da636d208ddeb8ac9cf9c06c4164a3 Mon Sep 17 00:00:00 2001 +From: Willy Tarreau +Date: Thu, 3 Nov 2016 20:31:40 +0100 +Subject: [PATCH] BUG/MEDIUM: systemd-wrapper: return correct exit codes + +Gabriele Cerami reported the the exit codes of the systemd-wrapper are +wrong. In short, it directly returns the output of the wait syscall's +status, which is a composite value made of error code an signal numbers. +In general it contains the signal number on the lower bits and the error +code on the higher bits, but exit() truncates it to the lowest 8 bits, +causing config validations to incorrectly report a success. Example : + + $ ./haproxy-systemd-wrapper -c -f /dev/null + <7>haproxy-systemd-wrapper: executing /tmp/haproxy -c -f /dev/null -Ds + Configuration file has no error but will not start (no listener) => exit(2). + <5>haproxy-systemd-wrapper: exit, haproxy RC=512 + $ echo $? + 0 + +If the process is killed however, the signal number is directly reported +in the exit code. + +Let's fix all this to ensure that the exit code matches what the shell does, +which means that codes 0..127 are for exit codes, codes 128..254 for signals, +and code 255 for unknown exit code. Now the return code is correct : + + $ ./haproxy-systemd-wrapper -c -f /dev/null + <7>haproxy-systemd-wrapper: executing /tmp/haproxy -c -f /dev/null -Ds + Configuration file has no error but will not start (no listener) => exit(2). + <5>haproxy-systemd-wrapper: exit, haproxy RC=2 + $ echo $? + 2 + + $ ./haproxy-systemd-wrapper -f /tmp/cfg.conf + <7>haproxy-systemd-wrapper: executing /tmp/haproxy -f /dev/null -Ds + ^C + <5>haproxy-systemd-wrapper: exit, haproxy RC=130 + $ echo $? + 130 + +This fix must be backported to 1.6 and 1.5. +--- + src/haproxy-systemd-wrapper.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/src/haproxy-systemd-wrapper.c b/src/haproxy-systemd-wrapper.c +index 4e4d039..86520ca 100644 +--- a/src/haproxy-systemd-wrapper.c ++++ b/src/haproxy-systemd-wrapper.c +@@ -215,6 +215,16 @@ int main(int argc, char **argv) + } + } + ++ /* return either exit code or signal+128 */ ++ if (WIFEXITED(status)) ++ status = WEXITSTATUS(status); ++ else if (WIFSIGNALED(status)) ++ status = 128 + WTERMSIG(status); ++ else if (WIFSTOPPED(status)) ++ status = 128 + WSTOPSIG(status); ++ else ++ status = 255; ++ + fprintf(stderr, SD_NOTICE "haproxy-systemd-wrapper: exit, haproxy RC=%d\n", + status); + return status; +-- +2.7.4 + diff --git a/SPECS/haproxy.spec b/SPECS/haproxy.spec index 88699bb..89b1fb1 100644 --- a/SPECS/haproxy.spec +++ b/SPECS/haproxy.spec @@ -8,7 +8,7 @@ Name: haproxy Version: 1.5.18 -Release: 3%{?dist} +Release: 3%{?dist}.1 Summary: TCP/HTTP proxy and load balancer for high availability environments Group: System Environment/Daemons @@ -25,6 +25,7 @@ Source5: halog.1 Patch0: halog-unused-variables.patch Patch1: iprange-return-type.patch Patch2: haproxy-tcp-user-timeout.patch +Patch3: haproxy-systemd-wrapper-exit-code.patch BuildRequires: pcre-devel BuildRequires: zlib-devel @@ -55,6 +56,7 @@ availability environments. Indeed, it can: %patch0 -p0 %patch1 -p0 %patch2 -p1 +%patch3 -p1 %build regparm_opts= @@ -140,6 +142,9 @@ exit 0 %attr(-,%{haproxy_user},%{haproxy_group}) %dir %{haproxy_home} %changelog +* Fri Nov 18 2016 Ryan O'Hara - 1.5.18-3.1 +- Return correct exit codes from systemd-wrapper (#1396219) + * Tue Jun 21 2016 Ryan O'Hara - 1.5.18-3 - Fix TCP user timeout patch for 1.5.18 release