Bug#721082: The patch (take 2)

2013-09-05 Thread Thomas Hood
Attached is a second version of the patch with a bug removed that was
noticed by Nathan Stratton Treadway. The bug was that I had used
'echo' instead of 'exit' in two instances at the top of the script.
Thanks to Nathan and my apologies for the bug.
-- 
Thomas


etc-openvpn-update-resolv-conf_20130905th1.patch
Description: Binary data


Bug#721082: The patch

2013-09-04 Thread Alberto Gonzalez Iniesta
On Tue, Sep 03, 2013 at 09:17:12PM +0200, Thomas Hood wrote:
 Attached is the patch for /etc/openvpn/update-resolv-conf.  Below is the
 patch with my commentary.

Thanks Thomas! I'll include it in the next upload.

Regards,

Alberto

-- 
Alberto Gonzalez Iniesta| Formación, consultoría y soporte técnico
agi@(inittab.org|debian.org)| en GNU/Linux y software libre
Encrypted mail preferred| http://inittab.com

Key fingerprint = 5347 CBD8 3E30 A9EB 4D7D  4BF2 009B 3375 6B9A AA55


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#721082: The patch

2013-09-03 Thread Thomas Hood
Attached is the patch for /etc/openvpn/update-resolv-conf.  Below is the
patch with my commentary.
-- 
Thomas

--- update-resolv-conf_ORIG2012-03-30 21:01:54.0 +0200
+++ update-resolv-conf 2013-09-03 20:17:15.653120813 +0200
@@ -5,50 +5,54 @@
 # up /etc/openvpn/update-resolv-conf
 # down /etc/openvpn/update-resolv-conf
 #
-# Used snippets of resolvconf script by Thomas Hood jdth...@yahoo.co.uk
-# and Chris Hanson
+# Used snippets of resolvconf script by Thomas Hood and Chris Hanson.


Thomas Hood's e-mail address has changed.


 # Licensed under the GNU GPL.  See /usr/share/common-licenses/GPL.
-#
-# 05/2006 chlau...@bnc.ch


That e-mail address is not longer active. We don't want a changelog in
every file anyway.


 #
 # Example envs set from openvpn:
-# foreign_option_1='dhcp-option DNS 193.43.27.132'
-# foreign_option_2='dhcp-option DNS 193.43.27.133'
-# foreign_option_3='dhcp-option DOMAIN be.bnc.ch'
+#
+# foreign_option_1='dhcp-option DNS 193.43.27.132'
+# foreign_option_2='dhcp-option DNS 193.43.27.133'
+# foreign_option_3='dhcp-option DOMAIN be.bnc.ch'
+#


Indent.


 [ -x /sbin/resolvconf ] || exit 0
+[ $script_type ] || echo 0
+[ $dev ] || echo 0


Exit if certain variables aren't set, otherwise the script will
simply screw up later.


+split_into_parts()
+{
+  part1=$1
+  part2=$2
+  part3=$3
+}


Create a function to split up a string at space boundaries.


-case $script_type in
-up)
-  for optionname in ${!foreign_option_*} ; do
-  option=${!optionname}
-  echo $option
-  part1=$(echo $option | cut -d   -f 1)
-  if [ $part1 == dhcp-option ] ; then
-  part2=$(echo $option | cut -d   -f 2)
-  part3=$(echo $option | cut -d   -f 3)
-  if [ $part2 == DNS ] ; then
-  IF_DNS_NAMESERVERS=$IF_DNS_NAMESERVERS $part3
-  fi
-  if [ $part2 == DOMAIN ] ; then
-  IF_DNS_SEARCH=$IF_DNS_SEARCH $part3
+case $script_type in
+  up)
+  NMSRVRS=
+  SRCHS=
+  for optionvarname in ${!foreign_option_*} ; do
+  option=${!optionvarname}
+  echo $option
+  split_into_parts $option
+  if [ $part1 = dhcp-option ] ; then
+  if [ $part2 = DNS ] ; then
+  NMSRVRS=${NMSRVRS:+$NMSRVRS }$part3
+  elif [ $part2 = DOMAIN ] ; then
+  SRCHS=${SRCHS:+$SRCHS }$part3


Indent pattern. Initialize lists to null strings. Rename variable
'optionname' to 'optionvarname' for accuracy. Use quotation marks
unless it's necessary to omit them in order to obtain word splitting.
Split using our function instead of external programs. Compose list
without a leading space. Don't use IF_DNS* variable names which come
from ifupdown's resolvconf hook script.


   fi
   fi
   done
   R=
-  for SS in $IF_DNS_SEARCH ; do
-  R=${R}search $SS
+  [ $SRCHS ]  R=search $SRCHS
 
-  done


Don't write multiple search options into the record since only
one is allowed. All domains should go on one line.



-  for NS in $IF_DNS_NAMESERVERS ; do
+  for NS in $NMSRVRS ; do
   R=${R}nameserver $NS
 
   done
-  echo -n $R | /sbin/resolvconf -a ${dev}.inet
+  echo -n $R | /sbin/resolvconf -a ${dev}.openvpn
   ;;
-down)
-  /sbin/resolvconf -d ${dev}.inet
+  down)
+  /sbin/resolvconf -d ${dev}.openvpn
   ;;
 esac


Use openvpn as the record name suffix and not inet which
belongs to ifupdown.

-- 
Thomas Hood



etc-openvpn-update-resolv-conf_20130903th1.patch
Description: Binary data