]> git.ipfire.org Git - thirdparty/squid.git/blob - acinclude/lib-checks.m4
Bug 3816: SSL_get_certificate call inside Ssl::verifySslCertificate crashes squid...
[thirdparty/squid.git] / acinclude / lib-checks.m4
1 dnl
2 dnl AUTHOR: Squid Web Cache team
3 dnl
4 dnl SQUID Web Proxy Cache http://www.squid-cache.org/
5 dnl ----------------------------------------------------------
6 dnl Squid is the result of efforts by numerous individuals from
7 dnl the Internet community; see the CONTRIBUTORS file for full
8 dnl details. Many organizations have provided support for Squid's
9 dnl development; see the SPONSORS file for full details. Squid is
10 dnl Copyrighted (C) 2001 by the Regents of the University of
11 dnl California; see the COPYRIGHT file for full details. Squid
12 dnl incorporates software developed and/or copyrighted by other
13 dnl sources; see the CREDITS file for full details.
14 dnl
15 dnl This program is free software; you can redistribute it and/or modify
16 dnl it under the terms of the GNU General Public License as published by
17 dnl the Free Software Foundation; either version 2 of the License, or
18 dnl (at your option) any later version.
19 dnl
20 dnl This program is distributed in the hope that it will be useful,
21 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
22 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 dnl GNU General Public License for more details.
24 dnl
25 dnl You should have received a copy of the GNU General Public License
26 dnl along with this program; if not, write to the Free Software
27 dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
28
29
30 dnl checks whether dbopen needs -ldb to be added to libs
31 dnl sets ac_cv_dbopen_libdb to either "yes" or "no"
32
33 AC_DEFUN([SQUID_CHECK_DBOPEN_NEEDS_LIBDB],[
34 AC_CACHE_CHECK(if dbopen needs -ldb,ac_cv_dbopen_libdb, [
35 SQUID_STATE_SAVE(dbopen_libdb)
36 LIBS="$LIBS -ldb"
37 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
38 #if HAVE_SYS_TYPES_H
39 #include <sys/types.h>
40 #endif
41 #if HAVE_LIMITS_H
42 #include <limits.h>
43 #endif
44 #if HAVE_DB_185_H
45 #include <db_185.h>
46 #elif HAVE_DB_H
47 #include <db.h>
48 #endif]],
49 [[dbopen("", 0, 0, DB_HASH, (void *)0L)]])],
50 [ac_cv_dbopen_libdb="yes"],
51 [ac_cv_dbopen_libdb="no"])
52 SQUID_STATE_ROLLBACK(dbopen_libdb)
53 ])
54 ])
55
56
57 dnl check whether regex works by actually compiling one
58 dnl sets squid_cv_regex_works to either yes or no
59
60 AC_DEFUN([SQUID_CHECK_REGEX_WORKS],[
61 AC_CACHE_CHECK([if the system-supplied regex lib actually works],squid_cv_regex_works,[
62 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
63 #if HAVE_SYS_TYPES_H
64 #include <sys/types.h>
65 #endif
66 #if HAVE_REGEX_H
67 #include <regex.h>
68 #endif
69 ]], [[
70 regex_t t; regcomp(&t,"",0);]])],
71 [ squid_cv_regex_works=yes ],
72 [ squid_cv_regex_works=no ])
73 ])
74 ])
75
76
77 AC_DEFUN([SQUID_CHECK_LIBIPHLPAPI],[
78 AC_CACHE_CHECK([for libIpHlpApi],squid_cv_have_libiphlpapi,[
79 SQUID_STATE_SAVE(iphlpapi)
80 LIBS="$LIBS -liphlpapi"
81 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
82 #include <windows.h>
83 #include <winsock2.h>
84 #include <iphlpapi.h>
85 ]], [[
86 MIB_IPNETTABLE i;
87 unsigned long isz=sizeof(i);
88 GetIpNetTable(&i,&isz,FALSE);
89 ]])],
90 [squid_cv_have_libiphlpapi=yes
91 SQUID_STATE_COMMIT(iphlpapi)],
92 [squid_cv_have_libiphlpapi=no
93 SQUID_STATE_ROLLBACK(iphlpapi)])
94 ])
95 SQUID_STATE_ROLLBACK(iphlpapi)
96 ])
97
98 dnl Checks whether the OpenSSL SSL_get_certificate crashes squid and if a
99 dnl workaround can be used instead of using the SSL_get_certificate
100 AC_DEFUN([SQUID_CHECK_OPENSSL_GETCERTIFICATE_WORKS],[
101 AH_TEMPLATE(SQUID_SSLGETCERTIFICATE_BUGGY, "Define to 1 if the SSL_get_certificate crashes squid")
102 AH_TEMPLATE(SQUID_USE_SSLGETCERTIFICATE_HACK, "Define to 1 to use squid workaround for SSL_get_certificate")
103 SQUID_STATE_SAVE(check_SSL_get_certificate)
104 LIBS="$LIBS $SSLLIB"
105 if test "x$SSLLIBDIR" != "x"; then
106 LIBS="$LIBS -Wl,-rpath -Wl,$SSLLIBDIR"
107 fi
108
109 AC_MSG_CHECKING(whether the SSL_get_certificate is buggy)
110 AC_RUN_IFELSE([
111 AC_LANG_PROGRAM(
112 [
113 #include <openssl/ssl.h>
114 #include <openssl/err.h>
115 ],
116 [
117 SSLeay_add_ssl_algorithms();
118 SSL_CTX *sslContext = SSL_CTX_new(SSLv3_method());
119 SSL *ssl = SSL_new(sslContext);
120 X509* cert = SSL_get_certificate(ssl);
121 return 0;
122 ])
123 ],
124 [
125 AC_MSG_RESULT([no])
126 ],
127 [
128 AC_DEFINE(SQUID_SSLGETCERTIFICATE_BUGGY, 1)
129 AC_MSG_RESULT([yes])
130 ],
131 [])
132
133 AC_MSG_CHECKING(whether the workaround for SSL_get_certificate works)
134 AC_RUN_IFELSE([
135 AC_LANG_PROGRAM(
136 [
137 #include <openssl/ssl.h>
138 #include <openssl/err.h>
139 ],
140 [
141 SSLeay_add_ssl_algorithms();
142 SSL_CTX *sslContext = SSL_CTX_new(SSLv3_method());
143 X509 ***pCert = (X509 ***)sslContext->cert;
144 X509 *sslCtxCert = pCert && *pCert ? **pCert : (X509 *)0x1;
145 if (sslCtxCert != NULL)
146 return 1;
147 return 0;
148 ])
149 ],
150 [
151 AC_MSG_RESULT([yes])
152 AC_DEFINE(SQUID_USE_SSLGETCERTIFICATE_HACK, 1)
153 ],
154 [
155 AC_MSG_RESULT([no])
156 ],
157 [])
158
159 SQUID_STATE_ROLLBACK(check_SSL_get_certificate)
160 ])