From 7646f7e7776b361fad92069ba7f0d2e68f5e5e26 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Sun, 6 May 2012 00:58:06 +0000 Subject: FreeBSD versions before 8.0 did not know about jls -n. Use the old check for now. Thanks to Fahad. --- ezjail-admin | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/ezjail-admin b/ezjail-admin index b2b8443..06579b2 100755 --- a/ezjail-admin +++ b/ezjail-admin @@ -726,18 +726,23 @@ EOF # Add none meaning the host system. Prepare this list as argument for pgrep # by prepending -j to each jid IFS=${TIFS} - jail_ids=`( echo none= - jls -n | sed -E -n s/'.*jid=([0-9]+).*ip4\.addr=([0-9.,]+).*'/'\1=\2'/p | grep -Ee "${ezjail_ip}(,|$)" - jls -n | sed -E -n s/'.*jid=([0-9]+).*ip6\.addr=([0-9a-f:,]+).*'/'\1=\2'/p | grep -Ee "${ezjail_ip}(,|$)" - ) | cut -d= -f1 | sed s/^/-j/` + _freebsd_version=`uname -r` + if [ ${_freebsd_version%%.*} -gt 7 ]; then + jail_ids=`( echo none= + jls -n | sed -E -n s/'.*jid=([0-9]+).*ip4\.addr=([0-9.,]+).*'/'\1=\2'/p | grep -Ee "${ezjail_ip}(,|$)" + jls -n | sed -E -n s/'.*jid=([0-9]+).*ip6\.addr=([0-9a-f:,]+).*'/'\1=\2'/p | grep -Ee "${ezjail_ip}(,|$)" + ) | cut -d= -f1 | sed s/^/-j/` - # Fetch all corresponding process ids for all matching jail - jail_pids=`pgrep $jail_ids` + # Fetch all corresponding process ids for all matching jail + jail_pids=`pgrep $jail_ids` - # expand pids to form a greppable expression - jail_grep=`echo $jail_pids | sed -E -e"s/ / )|( /g" -e"s/^/( /" -e"s/$/ )/"` + # expand pids to form a greppable expression + jail_grep=`echo $jail_pids | sed -E -e"s/ / )|( /g" -e"s/^/( /" -e"s/$/ )/"` - IFS=_ + IFS=_ + else + jail_grep=. + fi ezjail_listener=`sockstat -46l | grep -E -e "\*:[[:digit:]]" | grep -E -e "${jail_grep}"` [ $? -eq 0 ] && echo -e "Warning: Some services already seem to be listening on all IP, (including ${ezjail_ip})\n This may cause some confusion, here they are:\n${ezjail_listener}" IFS=, -- cgit v1.2.3