]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb:events: let 50.samba.script normalize the transports to tcp ports
authorStefan Metzmacher <metze@samba.org>
Thu, 3 Apr 2025 14:55:19 +0000 (16:55 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 18 Apr 2025 10:17:29 +0000 (10:17 +0000)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
ctdb/config/events/legacy/50.samba.script

index 41864d59e80b57b8332578ecf391a7bf9ba2f8aa..195c9259ee8ee7ebba53347492ec501a7aac3f0e 100755 (executable)
@@ -152,6 +152,17 @@ list_samba_ports()
        testparm_get "smb ports"
 }
 
+normalize_transports_to_tcp_ports()
+{
+       echo "$1" | sed \
+               -e 's!,! !g' \
+               -e 's!\<tcp\>:!!g' \
+               -e 's!\<tcp\>!445!g' \
+               -e 's!\<nbt\>:!!g' \
+               -e 's!\<nbt\>!139!g' \
+               -e 's!\<[a-zA-Z][^ ]*!!g'
+}
+
 ###########################
 
 case "$1" in
@@ -172,9 +183,11 @@ monitor)
                smb_ports=$(list_samba_ports)
                [ -n "$smb_ports" ] || die "Failed to set smb ports"
        fi
+       smb_tcp_ports=$(normalize_transports_to_tcp_ports "$smb_ports")
+       [ -n "$smb_tcp_ports" ] || die "Failed to set smb tcp ports"
        # Intentionally unquoted multi-word value here
        # shellcheck disable=SC2086
-       ctdb_check_tcp_ports $smb_ports || exit $?
+       ctdb_check_tcp_ports $smb_tcp_ports || exit $?
 
        if [ "$CTDB_SAMBA_SKIP_SHARE_CHECK" != "yes" ]; then
                list_samba_shares | ctdb_check_directories || exit $?