Due to changes to the work laptop I'm a new openconnect user and it
turns out it's not too tough to support resolvd in openconnect with a
couple new functions in vpnc-script. I don't have any idea if this is
the best way to detect if resolvd is in use, but it seems to work in my
one test case.
No idea if this patch would be welcomed upstream, but seems like an
improvement to me.
Comments, OK?
Index: Makefile
===================================================================
RCS file: /cvs/ports/net/vpnc-scripts/Makefile,v
retrieving revision 1.5
diff -u -p -r1.5 Makefile
--- Makefile 16 Aug 2020 11:36:07 -0000 1.5
+++ Makefile 30 Oct 2021 17:18:05 -0000
@@ -5,6 +5,7 @@ COMMENT= connect scripts for use with vp
C= e6a8fac7f7e8bf3c391787a3e0672f741603a9c9
DISTNAME= vpnc-scripts-${C}
PKGNAME= vpnc-scripts-20200317
+REVISION= 0
CATEGORIES= net
Index: patches/patch-vpnc-script
===================================================================
RCS file: patches/patch-vpnc-script
diff -N patches/patch-vpnc-script
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-vpnc-script 30 Oct 2021 17:18:05 -0000
@@ -0,0 +1,38 @@
+$OpenBSD$
+
+Index: vpnc-script
+--- vpnc-script.orig
++++ vpnc-script
+@@ -150,12 +150,14 @@ elif [ -x /sbin/modify_resolvconf ]; then
+ elif [ -x /usr/sbin/unbound-control ] && /usr/sbin/unbound-control status >
/dev/null 2>&1; then
+ MODIFYRESOLVCONF=modify_resolvconf_unbound
+ RESTORERESOLVCONF=restore_resolvconf_unbound
++elif [ "$OS" = OpenBSD ] && /usr/sbin/rcctl ls on | grep -q resolvd; then
++ MODIFYRESOLVCONF=modify_resolvconf_resolvd
++ RESTORERESOLVCONF=restore_resolvconf_resolvd
+ else # Generic for any OS
+ MODIFYRESOLVCONF=modify_resolvconf_generic
+ RESTORERESOLVCONF=restore_resolvconf_generic
+ fi
+
+-
+ # =========== script hooks =================================================
+
+ run_hooks() {
+@@ -768,6 +770,16 @@ restore_resolvconf_unbound() {
+ /usr/sbin/unbound-control flush_zone ${CISCO_DEF_DOMAIN}
+ /usr/sbin/unbound-control flush_requestlist
+ fi
++}
++
++# === resolv.conf handling via resolvd =========
++
++modify_resolvconf_resolvd() {
++ /sbin/route nameserver $TUNDEV $INTERNAL_IP4_DNS $INTERNAL_IP6_DNS
++}
++
++restore_resolvconf_resolvd() {
++ /sbin/route nameserver $TUNDEV
+ }
+
+ # ========= Toplevel state handling =======================================