]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Luca Bruno's patch.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 3 Sep 2009 10:07:13 +0000 (10:07 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 3 Sep 2009 10:07:13 +0000 (10:07 +0000)
git-svn-id: file:///svn/unbound/trunk@1806 be551aaa-1e26-0410-a405-d3ace91eadb9

config.h.in
configure
configure.ac
doc/CREDITS
doc/Changelog
doc/libunbound.3.in
libunbound/libunbound.c

index 02962bac57a1e49d7298a20a1d8b8a20afcef0c6..ca10de5ab57f29f545974217e864f78942b081e5 100644 (file)
 /* if the function 'ioctlsocket' is available */
 #undef HAVE_IOCTLSOCKET
 
+/* Define to 1 if you have the <iphlpapi.h> header file. */
+#undef HAVE_IPHLPAPI_H
+
 /* Define to 1 if you have the `kill' function. */
 #undef HAVE_KILL
 
index cd17c6850b6870a0537de10e3adf7ffe02d1df31..1479b3a30e1ca47ee3d1397b5d2b6f97f53cd835 100755 (executable)
--- a/configure
+++ b/configure
@@ -13501,7 +13501,8 @@ CC="$lt_save_CC"
 
 
 
-for ac_header in stdarg.h stdbool.h netinet/in.h sys/param.h sys/socket.h sys/uio.h sys/resource.h arpa/inet.h syslog.h netdb.h sys/wait.h pwd.h glob.h grp.h login_cap.h winsock2.h ws2tcpip.h
+
+for ac_header in stdarg.h stdbool.h netinet/in.h sys/param.h sys/socket.h sys/uio.h sys/resource.h arpa/inet.h syslog.h netdb.h sys/wait.h pwd.h glob.h grp.h login_cap.h winsock2.h ws2tcpip.h iphlpapi.h
 do
 as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
@@ -20903,6 +20904,7 @@ else
   WINDRES="$ac_cv_prog_WINDRES"
 fi
 
+       LIBS="$LIBS -liphlpapi"
 fi
 if test $ac_cv_func_getaddrinfo = no; then
        case " $LIBOBJS " in
index 8728053c8bd4236c9aa09917172d8735b50a566f..e070ea6a8fd27d818ef7867a7d892900427bb587 100644 (file)
@@ -198,7 +198,7 @@ AC_CHECK_TOOL(STRIP, strip)
 ACX_LIBTOOL_C_ONLY
 
 # Checks for header files.
-AC_CHECK_HEADERS([stdarg.h stdbool.h netinet/in.h sys/param.h sys/socket.h sys/uio.h sys/resource.h arpa/inet.h syslog.h netdb.h sys/wait.h pwd.h glob.h grp.h login_cap.h winsock2.h ws2tcpip.h],,, [AC_INCLUDES_DEFAULT])
+AC_CHECK_HEADERS([stdarg.h stdbool.h netinet/in.h sys/param.h sys/socket.h sys/uio.h sys/resource.h arpa/inet.h syslog.h netdb.h sys/wait.h pwd.h glob.h grp.h login_cap.h winsock2.h ws2tcpip.h iphlpapi.h ],,, [AC_INCLUDES_DEFAULT])
 
 # check for types.  
 # Using own tests for int64* because autoconf builtin only give 32bit.
@@ -528,6 +528,7 @@ if test "$USE_WINSOCK" = 1; then
        UB_ON_WINDOWS=yes
        AC_SUBST(UB_ON_WINDOWS)
        AC_CHECK_TOOL(WINDRES, windres)
+       LIBS="$LIBS -liphlpapi"
 fi
 if test $ac_cv_func_getaddrinfo = no; then
        AC_LIBOBJ([fake-rfc2553])
index b01bc2a77755725b286468f219b007ab884d255c..499b7ba158b5adfbc652f0413b2eda6a50c24e63 100644 (file)
@@ -16,3 +16,4 @@ Alexander Gall - multihomed, anycast testing of unbound resolver server.
 Zdenek Vasicek and Marek Vavrusa - python module.
 cz.nic - sponsoring 'summer of code' development by Zdenek and Marek.
 Brett Carr - windows beta testing.
+Luca Bruno - patch for windows support in libunbound hosts and resolvconf().
index 5ec1ff2b24da683a836379dd4a1d3be043b6ec36..f6eeb105ca19fc395dfbbf5c0a5c7e0a76bcd7d3 100644 (file)
@@ -1,3 +1,7 @@
+3 September 2009: Wouter
+       - Got a patch from Luca Bruno for libunbound support on windows to
+         pick up the system resolvconf nameservers and hosts there.
+
 2 September 2009: Wouter
        - TRAFFIC keyword for testbound. Simplifies test generation.
          ${range lower val upper} to check probe timeout values.
index 6ff734d8a4551a7cf6b055f17fb5f151919a9286..ddb7eeb37d777310589f0b8fc621a7c17a105201 100644 (file)
@@ -201,14 +201,16 @@ Usually "/etc/resolv.conf". Uses those nameservers as caching proxies.
 If they do not support DNSSEC, validation may fail.
 Only nameservers are picked up, the searchdomain, ndots and other
 settings from \fIresolv.conf\fR(5) are ignored.
-If fname NULL is passed, "/etc/resolv.conf" is used.
+If fname NULL is passed, "/etc/resolv.conf" is used (if on Windows, 
+the system\-wide configured nameserver is picked instead).
 At this time it is only possible to set configuration before the
 first resolve is done.
 .TP
 .B ub_ctx_hosts
 Read list of hosts from the filename given.
 Usually "/etc/hosts". When queried for, these addresses are not marked 
-DNSSEC secure. If fname NULL is passed, "/etc/hosts" is used.
+DNSSEC secure. If fname NULL is passed, "/etc/hosts" is used 
+(if on Windows, etc/hosts from WINDIR is picked instead).
 At this time it is only possible to set configuration before the
 first resolve is done.
 .TP
index d4500e364d5a702fcd1fccc1656545815966a99b..6df145bb18807e3f633863d94033b55a6449c72c 100644 (file)
 #include "services/cache/infra.h"
 #include "services/cache/rrset.h"
 
+#if defined(UB_ON_WINDOWS) && defined (HAVE_WINDOWS_H)
+#include <windows.h>
+#include <iphlpapi.h>
+#endif /* UB_ON_WINDOWS */
+
 struct ub_ctx* 
 ub_ctx_create()
 {
@@ -788,8 +793,47 @@ ub_ctx_resolvconf(struct ub_ctx* ctx, char* fname)
        char buf[1024];
        char* parse, *addr;
        int r;
-       if(fname == NULL)
+
+       if(fname == NULL) {
+#if !defined(UB_ON_WINDOWS) || !defined(HAVE_WINDOWS_H)
                fname = "/etc/resolv.conf";
+#else
+               FIXED_INFO *info;
+               ULONG buflen = sizeof(*info);
+               IP_ADDR_STRING *ptr;
+
+               info = (FIXED_INFO *) malloc(sizeof (FIXED_INFO));
+               if (info == NULL) 
+                       return UB_READFILE;
+
+               if (GetNetworkParams(info, &buflen) == ERROR_BUFFER_OVERFLOW) {
+                       free(info);
+                       info = (FIXED_INFO *) malloc(buflen);
+                       if (info == NULL)
+                               return UB_READFILE;
+               }
+
+               if (GetNetworkParams(info, &buflen) == NO_ERROR) {
+                       int retval=0;
+                       ptr = &(info->DnsServerList);
+                       while (ptr) {
+                               numserv++;
+                               if((retval=ub_ctx_set_fwd(ctx, 
+                                       ptr->IpAddress.String)!=0)) {
+                                       free(info);
+                                       return retval;
+                               }
+                               ptr = ptr->Next;
+                       }
+                       free(info);
+                       if (numserv==0)
+                               return UB_READFILE;
+                       return UB_NOERROR;
+               }
+               free(info);
+               return UB_READFILE;
+#endif /* WINDOWS */
+       }
        in = fopen(fname, "r");
        if(!in) {
                /* error in errno! perror(fname) */
@@ -840,8 +884,31 @@ ub_ctx_hosts(struct ub_ctx* ctx, char* fname)
                return UB_AFTERFINAL;
        }
        lock_basic_unlock(&ctx->cfglock);
-       if(fname == NULL)
+       if(fname == NULL) {
+#if defined(UB_ON_WINDOWS) && defined(HAVE_WINDOWS_H)
+               /*
+                * If this is Windows NT/XP/2K it's in
+                * %WINDIR%\system32\drivers\etc\hosts.
+                * If this is Windows 95/98/Me it's in %WINDIR%\hosts.
+                */
+               name = getenv("WINDIR");
+               if (name != NULL) {
+                       int retval=0;
+                       snprintf(buf, sizeof(buf), "%s%s", name, 
+                               "\\system32\\drivers\\etc\\hosts");
+                       if((retval=ub_ctx_hosts(ctx, buf)) !=0 ) {
+                               snprintf(buf, sizeof(buf), "%s%s", name, 
+                                       "\\hosts");
+                               retval=ub_ctx_hosts(ctx, buf);
+                       }
+                       free(name);
+                       return retval;
+               }
+               return UB_READFILE;
+#else
                fname = "/etc/hosts";
+#endif /* WIN32 */
+       }
        in = fopen(fname, "r");
        if(!in) {
                /* error in errno! perror(fname) */