]> www.infradead.org Git - users/dwmw2/vpnc-scripts.git/commitdiff
Fix various issues on FreeBSD
authorEmanuel Haupt <ehaupt@FreeBSD.org>
Mon, 28 Jan 2013 15:33:38 +0000 (15:33 +0000)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Mon, 28 Jan 2013 15:33:38 +0000 (15:33 +0000)
- 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 <ehaupt@FreeBSD.org>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
vpnc-script

index 934e044af1538d142e3ba0f937a31fc886439fc5..c2391cd979b325824d5f746142327a6881555f9b 100755 (executable)
@@ -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