From 4d5e6ed01e080075bc262f37b21e8f9bd6596531 Mon Sep 17 00:00:00 2001
From: Guillem Jover <gjover@sipwise.com>
Date: Mon, 21 Aug 2017 19:11:53 +0200
Subject: [PATCH] TT#20088 Handle changes in ifconfig output in Debian stretch
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The output now contains a colon after the interface name which trips
over several of the codepaths that parse the «ifconfig -a» output.

Change-Id: If394a5a9e908ecc8631f4873321baa2c87996b0b
---
 resources/OCF/IPaddr    | 5 ++++-
 resources/OCF/IPsrcaddr | 3 +++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/resources/OCF/IPaddr b/resources/OCF/IPaddr
index 626949b..f862a36 100644
--- a/resources/OCF/IPaddr
+++ b/resources/OCF/IPaddr
@@ -327,6 +327,9 @@ find_interface_generic() {
 	    *:*)	;;
 	    *)	continue;;
 	esac
+
+	: Remove trailing : from ifname from newer ifconfig
+	ifname=${ifname%%:}
 	
 	: "comparing $ipaddr to $addr (from ifconfig)"
 	case $addr in
@@ -384,7 +387,7 @@ find_free_interface() {
 	*)
 		j=0
 		IFLIST=`$IFCONFIG $IFCONFIG_A_OPT | \
-			grep "^$NIC:[0-9]" | sed 's% .*%%'`
+			grep "^$NIC:[0-9]" | sed 's%:* .*%%'`
                 TRYADRCNT=`ls "${NICBASE}:"* 2>/dev/null | wc -w | tr -d ' '`
 		if [ -f "${NICBASE}:${TRYADRCNT}" ]; then
 		  : OK
diff --git a/resources/OCF/IPsrcaddr b/resources/OCF/IPsrcaddr
index 8dd8869..c3e0744 100644
--- a/resources/OCF/IPsrcaddr
+++ b/resources/OCF/IPsrcaddr
@@ -296,6 +296,9 @@ find_interface_generic() {
       : Nothing
     done
 
+    : Remove trailing : from ifname from newer ifconfig
+    ifname=${ifname%%:}
+
     case "$SYSTYPE" in
       *BSD)
 		$IFCONFIG | grep "$BASEIP" -B`$IFCONFIG | grep -c inet` | grep "UP," | cut -d ":" -f 1
-- 
2.14.1

