Browse code

configure: use getaddrinfo() whenever available (can be disabled with --disable-getaddrinfo); --disable-ipv6 now only disables support for IPv6 addresses in getaddrinfo() (bb#1165)

git-svn: trunk@4171

Tomasz Kojm authored on 2008/09/11 03:11:00
Showing 7 changed files
... ...
@@ -1,3 +1,9 @@
1
+Wed Sep 10 20:05:27 CEST 2008 (tk)
2
+----------------------------------
3
+  * configure: use getaddrinfo() whenever available (can be disabled
4
+	       with --disable-getaddrinfo); --disable-ipv6 now only
5
+	       disables support for IPv6 addresses in getaddrinfo() (bb#1165)
6
+
1 7
 Wed Sep 10 18:10:47 CEST 2008 (acab)
2 8
 ------------------------------------
3 9
   * build system: libtool updated to 2.2.6 
... ...
@@ -129,6 +129,9 @@
129 129
 /* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
130 130
 #undef HAVE_FSEEKO
131 131
 
132
+/* have getaddrinfo() */
133
+#undef HAVE_GETADDRINFO
134
+
132 135
 /* gethostbyname_r takes 3 arguments */
133 136
 #undef HAVE_GETHOSTBYNAME_R_3
134 137
 
... ...
@@ -371,7 +374,7 @@
371 371
 /* Define to 1 if you have the ANSI C header files. */
372 372
 #undef STDC_HEADERS
373 373
 
374
-/* Use IPv6 aware code */
374
+/* Support for IPv6 */
375 375
 #undef SUPPORT_IPv6
376 376
 
377 377
 /* use syslog */
... ...
@@ -1527,6 +1527,7 @@ Optional Features:
1527 1527
   --disable-bzip2	  disable bzip2 support
1528 1528
   --disable-rpath         do not hardcode runtime library paths
1529 1529
   --disable-unrar	  don't build libclamunrar and libclamunrar_iface
1530
+  --disable-getaddrinfo          disable support for getaddrinfo
1530 1531
   --disable-ipv6          disable IPv6 support
1531 1532
   --disable-dns           disable support for database verification through
1532 1533
                           DNS
... ...
@@ -4759,13 +4760,13 @@ if test "${lt_cv_nm_interface+set}" = set; then
4759 4759
 else
4760 4760
   lt_cv_nm_interface="BSD nm"
4761 4761
   echo "int some_variable = 0;" > conftest.$ac_ext
4762
-  (eval echo "\"\$as_me:4762: $ac_compile\"" >&5)
4762
+  (eval echo "\"\$as_me:4763: $ac_compile\"" >&5)
4763 4763
   (eval "$ac_compile" 2>conftest.err)
4764 4764
   cat conftest.err >&5
4765
-  (eval echo "\"\$as_me:4765: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
4765
+  (eval echo "\"\$as_me:4766: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
4766 4766
   (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
4767 4767
   cat conftest.err >&5
4768
-  (eval echo "\"\$as_me:4768: output\"" >&5)
4768
+  (eval echo "\"\$as_me:4769: output\"" >&5)
4769 4769
   cat conftest.out >&5
4770 4770
   if $GREP 'External.*some_variable' conftest.out > /dev/null; then
4771 4771
     lt_cv_nm_interface="MS dumpbin"
... ...
@@ -5976,7 +5977,7 @@ ia64-*-hpux*)
5976 5976
   ;;
5977 5977
 *-*-irix6*)
5978 5978
   # Find out which ABI we are using.
5979
-  echo '#line 5979 "configure"' > conftest.$ac_ext
5979
+  echo '#line 5980 "configure"' > conftest.$ac_ext
5980 5980
   if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
5981 5981
   (eval $ac_compile) 2>&5
5982 5982
   ac_status=$?
... ...
@@ -7827,11 +7828,11 @@ else
7827 7827
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
7828 7828
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
7829 7829
    -e 's:$: $lt_compiler_flag:'`
7830
-   (eval echo "\"\$as_me:7830: $lt_compile\"" >&5)
7830
+   (eval echo "\"\$as_me:7831: $lt_compile\"" >&5)
7831 7831
    (eval "$lt_compile" 2>conftest.err)
7832 7832
    ac_status=$?
7833 7833
    cat conftest.err >&5
7834
-   echo "$as_me:7834: \$? = $ac_status" >&5
7834
+   echo "$as_me:7835: \$? = $ac_status" >&5
7835 7835
    if (exit $ac_status) && test -s "$ac_outfile"; then
7836 7836
      # The compiler can only warn and ignore the option if not recognized
7837 7837
      # So say no if there are warnings other than the usual output.
... ...
@@ -8166,11 +8167,11 @@ else
8166 8166
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
8167 8167
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
8168 8168
    -e 's:$: $lt_compiler_flag:'`
8169
-   (eval echo "\"\$as_me:8169: $lt_compile\"" >&5)
8169
+   (eval echo "\"\$as_me:8170: $lt_compile\"" >&5)
8170 8170
    (eval "$lt_compile" 2>conftest.err)
8171 8171
    ac_status=$?
8172 8172
    cat conftest.err >&5
8173
-   echo "$as_me:8173: \$? = $ac_status" >&5
8173
+   echo "$as_me:8174: \$? = $ac_status" >&5
8174 8174
    if (exit $ac_status) && test -s "$ac_outfile"; then
8175 8175
      # The compiler can only warn and ignore the option if not recognized
8176 8176
      # So say no if there are warnings other than the usual output.
... ...
@@ -8271,11 +8272,11 @@ else
8271 8271
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
8272 8272
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
8273 8273
    -e 's:$: $lt_compiler_flag:'`
8274
-   (eval echo "\"\$as_me:8274: $lt_compile\"" >&5)
8274
+   (eval echo "\"\$as_me:8275: $lt_compile\"" >&5)
8275 8275
    (eval "$lt_compile" 2>out/conftest.err)
8276 8276
    ac_status=$?
8277 8277
    cat out/conftest.err >&5
8278
-   echo "$as_me:8278: \$? = $ac_status" >&5
8278
+   echo "$as_me:8279: \$? = $ac_status" >&5
8279 8279
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
8280 8280
    then
8281 8281
      # The compiler can only warn and ignore the option if not recognized
... ...
@@ -8326,11 +8327,11 @@ else
8326 8326
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
8327 8327
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
8328 8328
    -e 's:$: $lt_compiler_flag:'`
8329
-   (eval echo "\"\$as_me:8329: $lt_compile\"" >&5)
8329
+   (eval echo "\"\$as_me:8330: $lt_compile\"" >&5)
8330 8330
    (eval "$lt_compile" 2>out/conftest.err)
8331 8331
    ac_status=$?
8332 8332
    cat out/conftest.err >&5
8333
-   echo "$as_me:8333: \$? = $ac_status" >&5
8333
+   echo "$as_me:8334: \$? = $ac_status" >&5
8334 8334
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
8335 8335
    then
8336 8336
      # The compiler can only warn and ignore the option if not recognized
... ...
@@ -11082,7 +11083,7 @@ else
11082 11082
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
11083 11083
   lt_status=$lt_dlunknown
11084 11084
   cat > conftest.$ac_ext <<_LT_EOF
11085
-#line 11085 "configure"
11085
+#line 11086 "configure"
11086 11086
 #include "confdefs.h"
11087 11087
 
11088 11088
 #if HAVE_DLFCN_H
... ...
@@ -11178,7 +11179,7 @@ else
11178 11178
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
11179 11179
   lt_status=$lt_dlunknown
11180 11180
   cat > conftest.$ac_ext <<_LT_EOF
11181
-#line 11181 "configure"
11181
+#line 11182 "configure"
11182 11182
 #include "confdefs.h"
11183 11183
 
11184 11184
 #if HAVE_DLFCN_H
... ...
@@ -15956,15 +15957,20 @@ else
15956 15956
 fi
15957 15957
 
15958 15958
 
15959
-# Check whether --enable-ipv6 was given.
15960
-if test "${enable_ipv6+set}" = set; then
15961
-  enableval=$enable_ipv6; want_ipv6=$enableval
15959
+# Check whether --enable-getaddrinfo was given.
15960
+if test "${enable_getaddrinfo+set}" = set; then
15961
+  enableval=$enable_getaddrinfo; want_getaddrinfo=$enableval
15962 15962
 else
15963
-  want_ipv6="yes"
15963
+  want_getaddrinfo="yes"
15964 15964
 fi
15965 15965
 
15966 15966
 
15967
-if test "$want_ipv6" = "yes"
15967
+
15968
+cat >>confdefs.h <<\_ACEOF
15969
+#define HAVE_GETHOSTBYNAME_R_6 1
15970
+_ACEOF
15971
+
15972
+if test "$want_getaddrinfo" = "yes"
15968 15973
 then
15969 15974
     { echo "$as_me:$LINENO: checking for getaddrinfo" >&5
15970 15975
 echo $ECHO_N "checking for getaddrinfo... $ECHO_C" >&6; }
... ...
@@ -15989,13 +15995,16 @@ cat >>conftest.$ac_ext <<_ACEOF
15989 15989
 		    #include <sys/types.h>
15990 15990
 		    #include <sys/socket.h>
15991 15991
 		    #include <netdb.h>
15992
+		    #include <unistd.h>
15992 15993
 		    int main(int argc, char **argv)
15993 15994
 		    {
15994 15995
 			    struct addrinfo *res;
15996
+			    int sd;
15995 15997
 
15996 15998
 			if(getaddrinfo("127.0.0.1", NULL, NULL, &res) < 0)
15997 15999
 			    return 1;
15998 16000
 			freeaddrinfo(res);
16001
+
15999 16002
 			return 0;
16000 16003
 		    }
16001 16004
 
... ...
@@ -16041,6 +16050,97 @@ echo "${ECHO_T}$have_gai" >&6; }
16041 16041
     if test "$have_gai" = yes; then
16042 16042
 
16043 16043
 cat >>confdefs.h <<\_ACEOF
16044
+#define HAVE_GETADDRINFO 1
16045
+_ACEOF
16046
+
16047
+    fi
16048
+fi
16049
+
16050
+# Check whether --enable-ipv6 was given.
16051
+if test "${enable_ipv6+set}" = set; then
16052
+  enableval=$enable_ipv6; want_ipv6=$enableval
16053
+else
16054
+  want_ipv6="yes"
16055
+fi
16056
+
16057
+
16058
+if test "$want_ipv6" = "yes"
16059
+then
16060
+    { echo "$as_me:$LINENO: checking for IPv6 support" >&5
16061
+echo $ECHO_N "checking for IPv6 support... $ECHO_C" >&6; }
16062
+    if test "${have_ipv6+set}" = set; then
16063
+  echo $ECHO_N "(cached) $ECHO_C" >&6
16064
+else
16065
+
16066
+		if test "$cross_compiling" = yes; then
16067
+  { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
16068
+See \`config.log' for more details." >&5
16069
+echo "$as_me: error: cannot run test program while cross compiling
16070
+See \`config.log' for more details." >&2;}
16071
+   { (exit 1); exit 1; }; }
16072
+else
16073
+  cat >conftest.$ac_ext <<_ACEOF
16074
+/* confdefs.h.  */
16075
+_ACEOF
16076
+cat confdefs.h >>conftest.$ac_ext
16077
+cat >>conftest.$ac_ext <<_ACEOF
16078
+/* end confdefs.h.  */
16079
+
16080
+		    #include <sys/types.h>
16081
+		    #include <sys/socket.h>
16082
+		    #include <unistd.h>
16083
+		    int main(int argc, char **argv)
16084
+		    {
16085
+			    int sd;
16086
+
16087
+			if((sd = socket(AF_INET6, SOCK_STREAM, 0)) < 0)
16088
+			    return 1;
16089
+			close(sd);
16090
+			return 0;
16091
+		    }
16092
+
16093
+_ACEOF
16094
+rm -f conftest$ac_exeext
16095
+if { (ac_try="$ac_link"
16096
+case "(($ac_try" in
16097
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
16098
+  *) ac_try_echo=$ac_try;;
16099
+esac
16100
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
16101
+  (eval "$ac_link") 2>&5
16102
+  ac_status=$?
16103
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
16104
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
16105
+  { (case "(($ac_try" in
16106
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
16107
+  *) ac_try_echo=$ac_try;;
16108
+esac
16109
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
16110
+  (eval "$ac_try") 2>&5
16111
+  ac_status=$?
16112
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
16113
+  (exit $ac_status); }; }; then
16114
+  have_ipv6=yes
16115
+else
16116
+  echo "$as_me: program exited with status $ac_status" >&5
16117
+echo "$as_me: failed program was:" >&5
16118
+sed 's/^/| /' conftest.$ac_ext >&5
16119
+
16120
+( exit $ac_status )
16121
+have_ipv6=no
16122
+fi
16123
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
16124
+fi
16125
+
16126
+
16127
+
16128
+fi
16129
+
16130
+    { echo "$as_me:$LINENO: result: $have_ipv6" >&5
16131
+echo "${ECHO_T}$have_ipv6" >&6; }
16132
+    if test "$have_ipv6" = yes; then
16133
+
16134
+cat >>confdefs.h <<\_ACEOF
16044 16135
 #define SUPPORT_IPv6 1
16045 16136
 _ACEOF
16046 16137
 
... ...
@@ -491,11 +491,12 @@ AC_ARG_ENABLE([unrar],
491 491
 [  --disable-unrar	  don't build libclamunrar and libclamunrar_iface ],
492 492
 want_unrar=$enableval, want_unrar="yes")
493 493
 
494
-AC_ARG_ENABLE([ipv6],
495
-[  --disable-ipv6          disable IPv6 support],
496
-want_ipv6=$enableval, want_ipv6="yes")
494
+AC_ARG_ENABLE([getaddrinfo],
495
+[  --disable-getaddrinfo          disable support for getaddrinfo],
496
+want_getaddrinfo=$enableval, want_getaddrinfo="yes")
497 497
 
498
-if test "$want_ipv6" = "yes"
498
+	AC_DEFINE([HAVE_GETHOSTBYNAME_R_6],1,[gethostbyname_r takes 6 arguments])
499
+if test "$want_getaddrinfo" = "yes"
499 500
 then
500 501
     AC_MSG_CHECKING([for getaddrinfo])
501 502
     AC_CACHE_VAL([have_gai],[
... ...
@@ -503,13 +504,16 @@ then
503 503
 		    #include <sys/types.h>
504 504
 		    #include <sys/socket.h>
505 505
 		    #include <netdb.h>
506
+		    #include <unistd.h>
506 507
 		    int main(int argc, char **argv)
507 508
 		    {
508 509
 			    struct addrinfo *res;
510
+			    int sd;
509 511
 
510 512
 			if(getaddrinfo("127.0.0.1", NULL, NULL, &res) < 0)
511 513
 			    return 1;
512 514
 			freeaddrinfo(res);
515
+
513 516
 			return 0;
514 517
 		    }
515 518
 		],
... ...
@@ -518,7 +522,38 @@ then
518 518
 		])
519 519
     AC_MSG_RESULT([$have_gai])
520 520
     if test "$have_gai" = yes; then
521
-	AC_DEFINE(SUPPORT_IPv6, 1, [Use IPv6 aware code])
521
+	AC_DEFINE(HAVE_GETADDRINFO, 1, [have getaddrinfo()])
522
+    fi
523
+fi
524
+
525
+AC_ARG_ENABLE([ipv6],
526
+[  --disable-ipv6          disable IPv6 support],
527
+want_ipv6=$enableval, want_ipv6="yes")
528
+
529
+if test "$want_ipv6" = "yes"
530
+then
531
+    AC_MSG_CHECKING([for IPv6 support])
532
+    AC_CACHE_VAL([have_ipv6],[
533
+		AC_TRY_RUN([
534
+		    #include <sys/types.h>
535
+		    #include <sys/socket.h>
536
+		    #include <unistd.h>
537
+		    int main(int argc, char **argv)
538
+		    {
539
+			    int sd;
540
+
541
+			if((sd = socket(AF_INET6, SOCK_STREAM, 0)) < 0)
542
+			    return 1;
543
+			close(sd);
544
+			return 0;
545
+		    }
546
+		],
547
+		[have_ipv6=yes],
548
+		[have_ipv6=no])
549
+		])
550
+    AC_MSG_RESULT([$have_ipv6])
551
+    if test "$have_ipv6" = yes; then
552
+	AC_DEFINE(SUPPORT_IPv6, 1, [Support for IPv6])
522 553
     fi
523 554
 fi
524 555
 
... ...
@@ -89,7 +89,7 @@
89 89
 	if(chdir(x) == -1)			\
90 90
 	    logg("!Can't chdir to %s\n", x);
91 91
 
92
-#ifndef SUPPORT_IPv6
92
+#ifndef HAVE_GETADDRINFO
93 93
 static const char *ghbn_err(int err) /* hstrerror() */
94 94
 {
95 95
     switch(err) {
... ...
@@ -115,7 +115,7 @@ static int getclientsock(const char *localip, int prot)
115 115
 {
116 116
 	int socketfd = -1;
117 117
 
118
-#ifdef SUPPORT_IPv6
118
+#ifdef HAVE_GETADDRINFO
119 119
     if(prot == PF_INET6)
120 120
 	socketfd = socket(PF_INET6, SOCK_STREAM, 0);
121 121
     else
... ...
@@ -130,7 +130,7 @@ static int getclientsock(const char *localip, int prot)
130 130
     }
131 131
 
132 132
     if(localip) {
133
-#ifdef SUPPORT_IPv6
133
+#ifdef HAVE_GETADDRINFO
134 134
 	    struct addrinfo *res;
135 135
 	    int ret;
136 136
 
... ...
@@ -191,7 +191,7 @@ static int wwwconnect(const char *server, const char *proxy, int pport, char *ip
191 191
 {
192 192
 	int socketfd, port, ret;
193 193
 	unsigned int ips = 0, ignored = 0;
194
-#ifdef SUPPORT_IPv6
194
+#ifdef HAVE_GETADDRINFO
195 195
 	struct addrinfo hints, *res = NULL, *rp, *loadbal_rp = NULL;
196 196
 	char port_s[6], loadbal_ipaddr[46];
197 197
 	uint32_t loadbal = 1, minsucc = 0xffffffff, minfail = 0xffffffff;
... ...
@@ -229,9 +229,13 @@ static int wwwconnect(const char *server, const char *proxy, int pport, char *ip
229 229
 	port = 80;
230 230
     }
231 231
 
232
-#ifdef SUPPORT_IPv6
232
+#ifdef HAVE_GETADDRINFO
233 233
     memset(&hints, 0, sizeof(hints));
234
+#ifdef SUPPORT_IPv6
234 235
     hints.ai_family = AF_UNSPEC;
236
+#else
237
+    hints.ai_family = AF_INET;
238
+#endif
235 239
     hints.ai_socktype = SOCK_STREAM;
236 240
     snprintf(port_s, sizeof(port_s), "%d", port);
237 241
     port_s[sizeof(port_s) - 1] = 0;
... ...
@@ -1374,7 +1378,7 @@ int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, c
1374 1374
 
1375 1375
     time(&currtime);
1376 1376
     logg("ClamAV update process started at %s", ctime(&currtime));
1377
-#ifdef SUPPORT_IPv6
1377
+#ifdef HAVE_GETADDRINFO
1378 1378
     logg("*Using IPv6 aware code\n");
1379 1379
 #endif
1380 1380
 
... ...
@@ -56,7 +56,7 @@
56 56
 #define O_BINARY    0
57 57
 #endif
58 58
 
59
-#ifndef SUPPORT_IPv6
59
+#ifndef HAVE_GETADDRINFO
60 60
 #ifndef AF_INET6
61 61
 #define AF_INET6    0xbeef  /* foo */
62 62
 #endif
... ...
@@ -222,7 +222,7 @@ void mirman_list(const struct mirdat *mdat)
222 222
 
223 223
     for(i = 0; i < mdat->num; i++) {
224 224
 	printf("Mirror #%u\n", i + 1);
225
-#ifdef SUPPORT_IPv6
225
+#ifdef HAVE_GETADDRINFO
226 226
 	if(mdat->mirtab[i].ip4)
227 227
 	    printf("IP: %s\n", inet_ntop(AF_INET, &mdat->mirtab[i].ip4, ip, sizeof(ip)));
228 228
 	else
... ...
@@ -55,7 +55,7 @@ int notify(const char *cfgfile)
55 55
 #ifndef	C_WINDOWS
56 56
 	struct sockaddr_un server;
57 57
 #endif
58
-#ifdef SUPPORT_IPv6
58
+#ifdef HAVE_GETADDRINFO
59 59
 	struct addrinfo hints, *res;
60 60
 	char port[6];
61 61
 	const char *addr;
... ...
@@ -102,9 +102,13 @@ int notify(const char *cfgfile)
102 102
     if((cpt = cfgopt(copt, "TCPSocket"))->enabled) {
103 103
 	socktype = "TCP";
104 104
 
105
-#ifdef SUPPORT_IPv6
105
+#ifdef HAVE_GETADDRINFO
106 106
 	memset(&hints, 0, sizeof(hints));
107
+#ifdef SUPPORT_IPv6
107 108
 	hints.ai_family = AF_UNSPEC;
109
+#else
110
+	hints.ai_family = AF_INET;
111
+#endif
108 112
 	hints.ai_socktype = SOCK_STREAM;
109 113
 	snprintf(port, 5, "%d", cpt->numarg);
110 114
 	port[5] = 0;