diff options
author | Lars Wirzenius <liw@liw.fi> | 2011-11-27 12:48:42 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2011-11-27 12:48:42 +0000 |
commit | 907d7df621e72ec4d87d4056dc021a7f589b4de0 (patch) | |
tree | 6474040bf754d2917be0abfeda8af60f594ffb09 | |
parent | 79ecfe38a8a78eb1b27b81f32a0465f2eaeadc2a (diff) | |
download | liw-automation-907d7df621e72ec4d87d4056dc021a7f589b4de0.tar.gz |
Add listen-check
-rw-r--r-- | debian/changelog | 6 | ||||
-rwxr-xr-x | scripts/listen-check | 37 |
2 files changed, 43 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog index 69252ea..5002114 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +liw-automation (8.21) squeeze; urgency=low + + * Add listen-check + + -- Lars Wirzenius <liw@liw.fi> Sun, 27 Nov 2011 12:48:36 +0000 + liw-automation (8.20) squeeze; urgency=low * Fix journal-note attachment feature. 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 |