From: Emanuel Haupt Date: Mon, 28 Jan 2013 15:33:38 +0000 (+0000) Subject: Fix various issues on FreeBSD X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=dc607d5fbb8eab9e11ac24ab0adf80340cf4ab63;p=users%2Fdwmw2%2Fvpnc-scripts.git Fix various issues on FreeBSD - duplicate creation of tun devices - cleanup of created tun device - deadlock of vpnc holding an open file descriptor on /dev/tunN - properly restoring /etc/resolv.conf Signed-off-by: Emanuel Haupt Signed-off-by: David Woodhouse --- diff --git a/vpnc-script b/vpnc-script index 934e044..c2391cd 100755 --- a/vpnc-script +++ b/vpnc-script @@ -121,7 +121,7 @@ if [ -r /etc/openwrt_release ] && [ -n "$OPENWRT_INTERFACE" ]; then include /lib/network MODIFYRESOLVCONF=modify_resolvconf_openwrt RESTORERESOLVCONF=restore_resolvconf_openwrt -elif [ -x /sbin/resolvconf ]; then # Optional tool on Debian, Ubuntu, Gentoo +elif [ -x /sbin/resolvconf ] && [ "$OS" != "FreeBSD" ]; then # Optional tool on Debian, Ubuntu, Gentoo - but not FreeBSD, it seems to work different MODIFYRESOLVCONF=modify_resolvconf_manager RESTORERESOLVCONF=restore_resolvconf_manager elif [ -x /sbin/netconfig ]; then # tool on Suse after 11.1 @@ -198,9 +198,12 @@ do_ifconfig() { destroy_tun_device() { case "$OS" in - NetBSD|FreeBSD|OpenBSD) # and probably others... + NetBSD|OpenBSD) # and probably others... ifconfig "$TUNDEV" destroy ;; + FreeBSD) + ifconfig "$TUNDEV" destroy > /dev/null 2>&1 & + ;; esac } @@ -593,9 +596,13 @@ do_pre_init() { fi fi elif [ "$OS" = "FreeBSD" ]; then - if [ ! -e /dev/tun ]; then + if ! kldstat -q -m if_tun > /dev/null; then kldload if_tun fi + + if ! ifconfig $TUNDEV > /dev/null; then + ifconfig $TUNDEV create + fi elif [ "$OS" = "GNU/kFreeBSD" ]; then if [ ! -e /dev/tun ]; then kldload if_tun