[PATCH] strip commas from dns search paths

Joe Barnett jbarnett at marinsoftware.com
Tue Jun 16 11:31:07 PDT 2015


Hello there,

A juniper / pulse secure VPN that I connect to gives back multiple DNS 
search paths.  Using the openconnect 7.06 release, they end up in 
/etc/resolv.conf comma separated, which makes resolution by nonfully 
qualified name not work.

here's a quick patch i put together to fix for my use case:

Signed-off-by: Joe Barnett <jbarnett at marinsoftware.com>
diff -u openconnect-7.06/oncp.c openconnect-7.06-delta/oncp.c
--- openconnect-7.06/oncp.c    2015-03-17 06:29:49.000000000 -0700
+++ openconnect-7.06-delta/oncp.c    2015-06-16 10:44:01.050488424 -0700
@@ -165,8 +165,8 @@
  static int process_attr(struct openconnect_info *vpninfo, int group, 
int attr,
              unsigned char *data, int attrlen)
  {
-    char buf[80];
-    int i;
+    char buf[256];
+    int i,j;

      switch(GRP_ATTR(group, attr)) {
      case GRP_ATTR(6, 2):
@@ -199,9 +199,17 @@
          break;

      case GRP_ATTR(2, 2):
-        vpn_progress(vpninfo, PRG_DEBUG, _("Received DNS search domain 
%.*s\n"),
-                 attrlen, (char *)data);
-        vpninfo->ip_info.domain = add_option(vpninfo, "search", (char 
*)data, attrlen);
+        j = 0;
+        for (i = 0; i < attrlen && i < sizeof(buf); i++) {
+            if ( ((char*)data)[i] != ',') {
+                buf[j] = ((char*)data)[i] ;
+                j++;
+            }
+        }
+        buf[j]=0;
+        vpn_progress(vpninfo, PRG_INFO, _("Received DNS search domain 
%.*s\n"),j,buf);
+        //         attrlen, (char *)data);
+        vpninfo->ip_info.domain = add_option(vpninfo, "search", 
buf,j);//(char *)data, attrlen);
          break;

      case GRP_ATTR(1, 1):




More information about the openconnect-devel mailing list