From 23debd5b6f27bcafd6b91149af9280f4398016df Mon Sep 17 00:00:00 2001
From: Jonas Weber <github@jonasw.de>
Date: Thu, 4 Oct 2018 19:21:59 +0200
Subject: [PATCH] Use cur_ip in jail for freebsd

---
 cdist/conf/type/__jail_freebsd10/gencode-remote | 3 +--
 cdist/conf/type/__jail_freebsd9/gencode-remote  | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/cdist/conf/type/__jail_freebsd10/gencode-remote b/cdist/conf/type/__jail_freebsd10/gencode-remote
index 8ce77768..5be04bc6 100755
--- a/cdist/conf/type/__jail_freebsd10/gencode-remote
+++ b/cdist/conf/type/__jail_freebsd10/gencode-remote
@@ -87,9 +87,8 @@ if [ $(expr "${ip}" : ".*, .*") -gt "0" ]; then
    SAVE_IFS="$IFS"
    IFS=", "
    for cur_ip in ${ip}; do
-      # TODO BUG? Why is cur_ip unused in the following line?
       # Just get the last IP address for SSH to listen on
-      mgmt_ip=$(echo "${ip}" | cut '-d ' -f1)   # In case using "ip netmask" format rather than CIDR
+      mgmt_ip=$(echo "${cur_ip}" | cut '-d ' -f1)   # In case using "ip netmask" format rather than CIDR
    done
    IFS="$SAVE_IFS"
 else
diff --git a/cdist/conf/type/__jail_freebsd9/gencode-remote b/cdist/conf/type/__jail_freebsd9/gencode-remote
index c76bb014..177bdf74 100755
--- a/cdist/conf/type/__jail_freebsd9/gencode-remote
+++ b/cdist/conf/type/__jail_freebsd9/gencode-remote
@@ -92,9 +92,8 @@ if [ $(expr "${ip}" : ".*|.*") -gt "0" ]; then
    SAVE_IFS="$IFS"
    IFS=", "
    for cur_ip in ${ip}; do
-      # TODO BUG? Why is cur_ip unused in the following line?
       # Just get the last IP address for SSH to listen on
-      mgmt_ip=$(echo "${ip}" | sed -E -e 's/^.*\|(.*)\/[0-9]+$/\1/')
+      mgmt_ip=$(echo "${cur_ip}" | sed -E -e 's/^.*\|(.*)\/[0-9]+$/\1/')
    done
    IFS="$SAVE_IFS"
 else