From: William Lallemand Date: Sat, 7 Mar 2026 23:41:36 +0000 (+0100) Subject: BUG/MINOR: admin: haproxy-reload use explicit socat address type X-Git-Tag: v3.4-dev7~123 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=551e5f5fd46ef6a6196128ec8c91a9ec29124885;p=thirdparty%2Fhaproxy.git BUG/MINOR: admin: haproxy-reload use explicit socat address type socat was used with the ${MASTER_SOCKET} variable directly, letting it auto-detect the network protocol. However, when given a plain filename that does not point to a UNIX socket, socat would create a file at that path instead of reporting an error. To fix this, the address type is now determined explicitly: if MASTER_SOCKET points to an existing UNIX socket file (checked with -S), UNIX-CONNECT: is used; if it matches a : pattern, TCP: is used; otherwise an error is reported. The socat_addr variable is also properly scoped as local to the reload() function. Could be backported in 3.3. --- diff --git a/admin/cli/haproxy-reload b/admin/cli/haproxy-reload index 22da7bd9f..b592d98e9 100755 --- a/admin/cli/haproxy-reload +++ b/admin/cli/haproxy-reload @@ -4,7 +4,7 @@ set -e export VERBOSE=1 export TIMEOUT=90 -export MASTER_SOCKET=${MASTER_SOCKET:-/var/run/haproxy-master.sock} +export MASTER_SOCKET="${MASTER_SOCKET:-/var/run/haproxy-master.sock}" export RET= alert() { @@ -15,6 +15,19 @@ alert() { reload() { + if [ -S "$MASTER_SOCKET" ]; then + socat_addr="UNIX-CONNECT:${MASTER_SOCKET}" + else + case "$MASTER_SOCKET" in + *:[0-9]*) + socat_addr="TCP:${MASTER_SOCKET}" + ;; + *) + alert "Invalid master socket address '${MASTER_SOCKET}': expected a UNIX socket file or :" + return 1 + ;; + esac + fi while read -r line; do if [ "$line" = "Success=0" ]; then @@ -33,7 +46,7 @@ reload() { fi fi - done < <(echo "reload" | socat -t"${TIMEOUT}" "${MASTER_SOCKET}" -) + done < <(echo "reload" | socat -t"${TIMEOUT}" "$socat_addr" -) if [ -z "$RET" ]; then alert "Couldn't finish the reload before the timeout (${TIMEOUT})." @@ -52,7 +65,7 @@ usage() { echo " EXPERIMENTAL script!" echo "" echo "Options:" - echo " -S, --master-socket Use the master socket at (default: ${MASTER_SOCKET})" + echo " -S, --master-socket Unix socket path or : (default: ${MASTER_SOCKET})" echo " -d, --debug Debug mode, set -x" echo " -t, --timeout Timeout (socat -t) (default: ${TIMEOUT})" echo " -s, --silent Silent mode (no output)"