summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2011-11-27 12:48:42 +0000
committerLars Wirzenius <liw@liw.fi>2011-11-27 12:48:42 +0000
commit907d7df621e72ec4d87d4056dc021a7f589b4de0 (patch)
tree6474040bf754d2917be0abfeda8af60f594ffb09 /scripts
parent79ecfe38a8a78eb1b27b81f32a0465f2eaeadc2a (diff)
downloadliw-automation-907d7df621e72ec4d87d4056dc021a7f589b4de0.tar.gz
Add listen-check
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/listen-check37
1 files changed, 37 insertions, 0 deletions
diff --git a/scripts/listen-check b/scripts/listen-check
new file mode 100755
index 0000000..45fe716
--- /dev/null
+++ b/scripts/listen-check
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# Check that the host only listens on ports that are acceptable.
+
+set -e
+
+ports()
+{
+ netstat -nlap |
+ awk '
+ $6 == "LISTEN" {
+ n = split($7, a, /\//)
+ printf "%-10s %-20s %-20s %s\n", $1, $4, $5, a[2]
+ }'
+}
+
+
+case "$1" in
+ list)
+ ports
+ ;;
+ report)
+ temp="$(mktemp)"
+ ports > "$temp"
+ if diff -u /etc/listen-check.ok "$temp"
+ then
+ rm -f "$temp"
+ else
+ rm -f "$temp"
+ exit 1
+ fi
+ ;;
+ *)
+ echo "EEeek. Usage, man!" 1>&2
+ exit 1
+ ;;
+esac