# If any of these defaults are unsupported then this variable can
# be overridden in /etc/sysconfig/ctdb or via a file in
# /etc/ctdb/rc.local.d/.
- : ${CTDB_TCP_PORT_CHECKERS:=ctdb nmap netstat}
+ : ${CTDB_TCP_PORT_CHECKERS:=ctdb}
for _c in $CTDB_TCP_PORT_CHECKERS ; do
ctdb_check_tcp_ports_$_c "$@"
return 127
}
-ctdb_check_tcp_ports_netstat ()
-{
- _cmd='netstat -l -t -n'
- _ns=$($_cmd 2>&1)
- if [ $? -eq 127 ] ; then
- # netstat probably not installed - unlikely?
- ctdb_check_tcp_ports_debug="$_ns"
- return 127
- fi
-
- for _p ; do # process each function argument (port)
- for _a in '0\.0\.0\.0' '::' ; do
- _pat="[[:space:]]${_a}:${_p}[[:space:]]+[^[:space:]]+[[:space:]]+LISTEN"
- if echo "$_ns" | grep -E -q "$_pat" ; then
- # We matched the port, so process next port
- continue 2
- fi
- done
-
- # We didn't match the port, so flag an error.
- ctdb_check_tcp_ports_debug="$_cmd shows this output:
-$_ns"
- return 1
- done
-
- return 0
-}
-
-ctdb_check_tcp_ports_nmap ()
-{
- # nmap wants a comma-separated list of ports
- _ports=""
- for _p ; do
- _ports="${_ports}${_ports:+,}${_p}"
- done
-
- _cmd="nmap -n -oG - -PS 127.0.0.1 -p $_ports"
-
- _nmap_out=$($_cmd 2>&1)
- if [ $? -eq 127 ] ; then
- # nmap probably not installed
- ctdb_check_tcp_ports_debug="$_nmap_out"
- return 127
- fi
-
- # get the port-related output
- _port_info=$(echo "$_nmap_out" | sed -n -r -e 's@^.*Ports:[[:space:]]@@p')
-
- for _p ; do
- # looking for something like this:
- # 445/open/tcp//microsoft-ds///
- # possibly followed by a comma
- _t="$_p/open/tcp//"
- case "$_port_info" in
- # The info we're after must be either at the beginning of
- # the string or it must follow a space.
- $_t*|*\ $_t*) : ;;
- *)
- # Nope, flag an error...
- ctdb_check_tcp_ports_debug="$_cmd shows this output:
-$_nmap_out"
- return 1
- esac
- done
-
- return 0
-}
-
# Use the new "ctdb checktcpport" command to check the port.
# This is very cheap.
ctdb_check_tcp_ports_ctdb ()
+++ /dev/null
-#!/bin/sh
-
-. "${TEST_SCRIPTS_DIR}/unit.sh"
-
-define_test "port 139 down, ctdb checktcpport not implemented"
-
-# TODO: create nmap stub
-export CTDB_NOT_IMPLEMENTED="checktcpport"
-
-setup_samba
-tcp_port_down 139
-
-required_result 1 "ERROR: samba tcp port 139 is not responding"
-
-simple_test
+++ /dev/null
-#!/bin/sh
-
-. "${TEST_SCRIPTS_DIR}/unit.sh"
-
-define_test "port 139 down, ctdb checktcpport not implemented, debug"
-
-ctdb_not_implemented "checktcpport"
-
-export CTDB_SCRIPT_DEBUGLEVEL=4
-
-setup_nmap_output_filter
-
-setup_samba
-tcp_port_down 139
-
-required_result 1 <<EOF
-DEBUG: ctdb_check_ports - checker ctdb not implemented
-DEBUG: output from checker was:
-DEBUG: ctdb checktcpport 445 (exited with 1) with output:
-$ctdb_not_implemented
-ERROR: samba tcp port 139 is not responding
-DEBUG: nmap -n -oG - -PS 127.0.0.1 -p 445,139 shows this output:
-DEBUG: # Nmap 5.21 scan initiated DATE as: nmap -n -oG - -PS 127.0.0.1 -p 445,139
-DEBUG: Host: 127.0.0.1 () Status: Up
-DEBUG: Host: 127.0.0.1 () Ports: 445/open/tcp//microsoft-ds///, 139/closed/tcp//netbios-ssn///
-DEBUG: # Nmap done at DATE -- 1 IP address (1 host up) scanned in 0.04 seconds
-EOF
-
-simple_test
+++ /dev/null
-#!/bin/sh
-
-. "${TEST_SCRIPTS_DIR}/unit.sh"
-
-define_test "port 139 down, ctdb checktcpport/nmap not implemented, debug"
-
-ctdb_not_implemented "checktcpport"
-export FAKE_NMAP_NOT_FOUND="yes"
-
-export CTDB_SCRIPT_DEBUGLEVEL=4
-
-setup_nmap_output_filter
-
-setup_samba
-tcp_port_down 139
-
-required_result 1 <<EOF
-DEBUG: ctdb_check_ports - checker ctdb not implemented
-DEBUG: output from checker was:
-DEBUG: ctdb checktcpport 445 (exited with 1) with output:
-$ctdb_not_implemented
-DEBUG: ctdb_check_ports - checker nmap not implemented
-DEBUG: output from checker was:
-DEBUG: sh: nmap: command not found
-ERROR: samba tcp port 139 is not responding
-DEBUG: netstat -l -t -n shows this output:
-DEBUG: Active Internet connections (servers only)
-DEBUG: Proto Recv-Q Send-Q Local Address Foreign Address State
-DEBUG: tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN
-EOF
-
-simple_test
+++ /dev/null
-#!/bin/sh
-
-. "${TEST_SCRIPTS_DIR}/unit.sh"
-
-define_test "port 139 down, ctdb checktcpport/nmap/netstat not implemented"
-
-ctdb_not_implemented "checktcpport"
-export FAKE_NMAP_NOT_FOUND="yes"
-export FAKE_NETSTAT_NOT_FOUND="yes"
-
-setup_nmap_output_filter
-
-setup_samba
-tcp_port_down 139
-
-required_result 127 <<EOF
-INTERNAL ERROR: ctdb_check_ports - no working checkers in CTDB_TCP_PORT_CHECKERS="ctdb nmap netstat"
-EOF
-
-simple_test