From: Linda K. <lin...@hp...> - 2011-03-11 22:14:23
|
>From 3b9fe54684a41c2e59047de2487bd90c2605f57e Mon Sep 17 00:00:00 2001 Message-Id: <3b9...@hp...> In-Reply-To: <cov...@hp...> References: <cov...@hp...> From: Linda Knippers <lin...@hp...> Date: Thu, 10 Mar 2011 16:57:45 -0500 Subject: [PATCH 1/3] Fix ipv6 address manipulation The code that extracts ipv6 interfaces and addresses was trying to only look for interfaces with the appropriate address prefix but was doing it wrong and not getting the interfaces or the addresses right. I've only tested this on a system with one active ethernet interface but it works there and seems to be the right fix for systems with multiple interfaces. Signed-off-by: Linda Knippers <lin...@hp...> --- audit/network/addr_filter.bash | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/audit/network/addr_filter.bash b/audit/network/addr_filter.bash index cc8cf40..b923b73 100755 --- a/audit/network/addr_filter.bash +++ b/audit/network/addr_filter.bash @@ -27,13 +27,15 @@ function get_ipv6_prefix { if [[ -n $LBLNET_SVR_IPV6 ]]; then ip -f inet6 route show to match $LBLNET_SVR_IPV6 | \ - grep -v default | cut -d'/' -f 1 + grep -v default | cut -d'/' -f 1 | \ + awk 'BEGIN { FS = ":" } { print $1":"$2":"$3":" }' | \ + head -n 1 elif [[ -n $LBLNET_PREFIX_IPV6 ]]; then echo $LBLNET_PREFIX_IPV6 | sed 's/:\/[0-9]*//;s/:0*/:/g;' else ip -o -f inet6 addr show scope global | \ awk 'BEGIN { FS = "[ \t]*|[ \t\\/]+" } { print $4 }' | \ - awk 'BEGIN { FS = ":" } { print $1":"$2":"$3":"$4":" }' | \ + awk 'BEGIN { FS = ":" } { print $1":"$2":"$3":" }' | \ head -n 1 fi } @@ -41,8 +43,9 @@ function get_ipv6_prefix { function get_ipv6_iface { declare prefix=$(get_ipv6_prefix) ip -o -f inet6 addr show scope global | \ + grep $prefix | \ awk 'BEGIN { FS = "[ \t]*|[ \t\\/]+" } { print $2 }' | \ - grep $prefix | head -n 1 + head -n 1 } function get_ipv4_addr { @@ -53,8 +56,9 @@ function get_ipv4_addr { function get_ipv6_addr { declare prefix=$(get_ipv6_prefix) ip -o -f inet6 addr show scope global | \ + grep $prefix | \ awk 'BEGIN { FS = "[ \t]*|[ \t\\/]+" } { print $4 }' | \ - grep $prefix | head -n 1 + head -n 1 } #### -- 1.7.4 |