]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-scripts: Use ss -H option to simplify
authorMartin Schwenke <mschwenke@ddn.com>
Mon, 16 Sep 2024 02:26:53 +0000 (12:26 +1000)
committerJule Anger <janger@samba.org>
Mon, 25 Nov 2024 12:39:11 +0000 (12:39 +0000)
This option has been available since ~2018 and has been implemented in
the stub since then.  I guess we didn't use it because CentOS 7?

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15320
RN: Update CTDB to track all TCP connections to public IP addresses

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
(cherry picked from commit 0505d06b12a04a5c5e813fb3f4799278f9e5b7eb)

ctdb/config/functions

index 34382c465e0d334c07ce0f8ce03d583ba17ffb7c..521f0cdfacc5744a8b5902b440e84b9e5d676f02 100755 (executable)
@@ -499,7 +499,7 @@ ctdb_check_unix_socket()
                return 1
        fi
 
-       _out=$(ss -l -x "src ${_sockpath}" | tail -n +2)
+       _out=$(ss -l -xH "src ${_sockpath}")
        if [ -z "$_out" ]; then
                echo "ERROR: ${service_name} not listening on ${_sockpath}"
                return 1
@@ -602,7 +602,7 @@ get_tcp_connections_for_ip()
 {
        _ip="$1"
 
-       ss -tn state established "src [$_ip]" | awk 'NR > 1 {print $3, $4}'
+       ss -tnH state established "src [$_ip]" | awk '{print $3, $4}'
 }
 
 ########################################################
@@ -1173,10 +1173,10 @@ update_tickles()
        _my_connections="${tickledir}/${_port}.connections.$$"
        # Parentheses are needed around the filters for precedence but
        # the parentheses can't be empty!
-       ss -tn state established \
+       ss -tnH state established \
                "${_ip_filter:+( ${_ip_filter} )}" \
                "${_port_filter:+( ${_port_filter} )}" |
-               awk 'NR > 1 {print $4, $3}' |
+               awk '{print $4, $3}' |
                sort >"$_my_connections"
 
        # Record our current tickles in a temporary file