[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patch] ezjail displays a spurious warning for ip6 addresses



Hello list,

`ezjail-admin create' displays a spurious warning for jails that use
ip6 addresses, because ping(8) can't reach those addresses. [1] fixes
that. There are still issues; the first is that the first ping will
print that it can't resolve an hostname. I neiter wanted to either
parse ip4|6 addresses nor to redirect ping's stderr to /dev/null, so
live with that. A second problem is that I just saw that ping6(8) has
no timeout option.

Actually, I think it should be better to check against the output of
ifconfig(8), since some people disable ICMP ECHO REQUEST. Not that I
agree with this approach, but well... [2] parses the output of
ifconfig(8). It seems to me that [2] is a better approach than [1].

[1]
--- ezjail-admin.orig   2010-04-23 21:04:38.000000000 +0200
+++ ezjail-admin        2010-04-23 21:19:27.000000000 +0200
@@ -702,11 +702,13 @@
 
   TIFS=${IFS}; IFS=,
   for ezjail_ip in ${ezjail_ips}; do
-    # check, whether IP is configured on a local interface, warn if it isnt
+    # check whether IP is configured on a local interface, warn if it isnt
     ping -c 1 -m 1 -t 1 -q ${ezjail_ip} > /dev/null
+    # if ping over ip4 failed, try again with ip6
+    [ $? -eq 0 ] || ping6 -c 1 -h 1 -q ${ezjail_ip} > /dev/null
     [ $? -eq 0 ] || echo "Warning: IP ${ezjail_ip} not configured on a local interface."
 
-    # check, whether some host system services do listen on the Jails IP
+    # check whether some host system services do listen on the Jails IP
     IFS=_
     ezjail_listener=`sockstat -4 -l | grep "${ezjail_ip}:[[:digit:]]"`
     [ $? -eq 0 ] && echo -e "Warning: Some services already seem to be listening on IP ${ezjail_ip}\n  This may cause some confusion, here they are:\n${ezjail_listener}"

[2]
--- ezjail-admin.orig   2010-04-23 21:04:38.000000000 +0200
+++ ezjail-admin        2010-04-23 21:32:30.000000000 +0200
@@ -702,11 +702,11 @@
 
   TIFS=${IFS}; IFS=,
   for ezjail_ip in ${ezjail_ips}; do
-    # check, whether IP is configured on a local interface, warn if it isnt
-    ping -c 1 -m 1 -t 1 -q ${ezjail_ip} > /dev/null
+    # check whether IP is configured on a local interface, warn if it isnt
+    ifconfig | grep "inet6? ${ezjail_ip} " &>/dev/null
     [ $? -eq 0 ] || echo "Warning: IP ${ezjail_ip} not configured on a local interface."
 
-    # check, whether some host system services do listen on the Jails IP
+    # check whether some host system services do listen on the Jails IP
     IFS=_
     ezjail_listener=`sockstat -4 -l | grep "${ezjail_ip}:[[:digit:]]"`

-- 
Fred