From: amosjeffries <> Date: Sun, 11 Nov 2007 09:26:58 +0000 (+0000) Subject: Solaris 10 appears to provide MD5 natively X-Git-Tag: SQUID_3_0_STABLE1~49 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3d4022faf1a2e48da63a2fab97c64a664975c055;p=thirdparty%2Fsquid.git Solaris 10 appears to provide MD5 natively * alter the MD5 logics to perform compile-time tests of whether the squid internal MD5 is needed. * OpenSSL implementation primary as before with same configure options * first backup is to use the OS-provided. * final backup is to use squid internal code. --- diff --git a/configure.in b/configure.in index 1b05ba1692..f568ffce04 100644 --- a/configure.in +++ b/configure.in @@ -1,7 +1,7 @@ dnl Configuration input file for Squid dnl -dnl $Id: configure.in,v 1.483 2007/11/07 10:20:46 amosjeffries Exp $ +dnl $Id: configure.in,v 1.484 2007/11/11 02:26:58 amosjeffries Exp $ dnl dnl dnl @@ -11,7 +11,7 @@ AM_CONFIG_HEADER(include/autoconf.h) AC_CONFIG_AUX_DIR(cfgaux) AC_CONFIG_SRCDIR([src/main.cc]) AM_INIT_AUTOMAKE([tar-ustar]) -AC_REVISION($Revision: 1.483 $)dnl +AC_REVISION($Revision: 1.484 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AM_MAINTAINER_MODE @@ -862,8 +862,10 @@ if test x$USE_HTCP = xtrue; then fi AM_CONDITIONAL(ENABLE_HTCP, [test x$USE_HTCP = xtrue]) +dnl SSL is not enabled by default. AM_CONDITIONAL(ENABLE_SSL, false) +dnl Default is to use OpenSSL when available AC_ARG_ENABLE(ssl, [ --enable-ssl Enable ssl gatewaying support using OpenSSL], [ if test "$enableval" != "no"; then @@ -883,8 +885,7 @@ AC_ARG_ENABLE(ssl, fi ]) -AM_CONDITIONAL(NEED_OWN_MD5, true) - +dnl User may specify OpenSSL is needed from a non-standard location AC_ARG_WITH(openssl, [ --with-openssl[=prefix] Compile with the OpenSSL libraries. The path to @@ -905,11 +906,9 @@ AC_ARG_WITH(openssl, USE_OPENSSL=1 esac ]) - if test -n "$USE_OPENSSL"; then echo "Using OpenSSL MD5 implementation" AC_DEFINE(USE_OPENSSL,1,[Define this to make use of the OpenSSL libraries for MD5 calculation rather than Squid's own MD5 implementation or if building with SSL encryption (USE_SSL)]) - AM_CONDITIONAL(NEED_OWN_MD5, false) if test -z "$SSLLIB"; then SSLLIB="-lcrypto" # for MD5 routines fi @@ -925,6 +924,7 @@ if test -n "$SSLLIBDIR"; then fi AC_SUBST(SSLLIB) + AC_ARG_ENABLE(forw-via-db, [ --enable-forw-via-db Enable Forw/Via database], [ if test "$enableval" = "yes" ; then @@ -1891,6 +1891,7 @@ AC_CHECK_HEADERS( \ sys/ioctl.h \ sys/param.h \ sys/prctl.h \ + sys/md5.h \ sys/msg.h \ sys/resource.h \ sys/select.h\ @@ -2273,7 +2274,11 @@ esac dnl Check for libcrypt dnl Some of our helpers use crypt(3) which may be in libc, or in dnl libcrypt (eg FreeBSD) -AC_CHECK_LIB(crypt, crypt, [CRYPTLIB="-lcrypt"]) +AC_CHECK_LIB(crypt, crypt, [CRYPTLIB=" -lcrypt "]) + +dnl Solaris10 provides MD5 natively through libmd5 +AC_CHECK_LIB(md5, MD5Init, [CRYPTLIB+=" -lmd5 "]) + AC_SUBST(CRYPTLIB) dnl Check for libdl, used by auth_modules/PAM diff --git a/include/md5.h b/include/md5.h index bf72f001fc..3dee87fa65 100644 --- a/include/md5.h +++ b/include/md5.h @@ -1,18 +1,14 @@ #ifndef SQUID_MD5_H #define SQUID_MD5_H -#if USE_OPENSSL - /* * If Squid is compiled with OpenSSL then we use the MD5 routines * from there via some wrapper macros, and the rest of this file is ignored.. */ +#define USE_SQUID_MD5 0 -#if HAVE_OPENSSL_MD5_H +#if USE_OPENSSL && HAVE_OPENSSL_MD5_H #include -#else -#error Cannot find OpenSSL headers -#endif /* Hack to adopt Squid to the OpenSSL syntax */ #define MD5_DIGEST_CHARS MD5_DIGEST_LENGTH @@ -21,7 +17,28 @@ #define MD5Update MD5_Update #define MD5Final MD5_Final -#else /* USE_OPENSSL */ +#elif USE_OPENSSL && !HAVE_OPENSSL_MD5_H +#error Cannot find OpenSSL MD5 headers + +#elif HAVE_SYS_MD5_H +/* + * Solaris 10 provides MD5 as part of the system. + */ +#include + +/* + * They also define MD5_CTX with different field names + * fortunately we do not access it directly in the squid code. + */ + +/* Hack to adopt Squid to the OpenSSL syntax */ +#define MD5_DIGEST_CHARS MD5_DIGEST_LENGTH + +#else /* NEED_OWN_MD5 */ + + /* Turn on internal MD5 code */ +#undef USE_SQUID_MD5 +#define USE_SQUID_MD5 1 /* * This is the header file for the MD5 message-digest algorithm. diff --git a/lib/Makefile.am b/lib/Makefile.am index de05a32fdc..75dce2d57c 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,6 +1,6 @@ ## Process this file with automake to produce Makefile.in # -# $Id: Makefile.am,v 1.28 2007/08/27 13:14:20 hno Exp $ +# $Id: Makefile.am,v 1.29 2007/11/11 02:26:59 amosjeffries Exp $ # DIST_SUBDIRS = libTrie @@ -33,11 +33,6 @@ STRTOLLSOURCE=strtoll.c else STRTOLLSOURCE= endif -if NEED_OWN_MD5 -MD5SOURCE=md5.c -else -MD5SOURCE= -endif if ENABLE_WIN32SPECIFIC LIBSSPWIN32=libsspwin32.a @@ -70,7 +65,7 @@ libmiscutil_a_SOURCES = \ heap.c \ html_quote.c \ iso3307.c \ - $(MD5SOURCE) \ + md5.c \ radix.c \ rfc1035.c \ rfc1123.c \ diff --git a/lib/md5.c b/lib/md5.c index 4a57367260..0b477028e6 100644 --- a/lib/md5.c +++ b/lib/md5.c @@ -26,11 +26,22 @@ */ #include "config.h" -/* MS VisualStudio Projects are monolithic, so we need the following +#include "md5.h" + +/* + * Now that we have several alternatives the MD5 files are + * passed in by default. But a header-selection decides whether + * this provided version is to be built. + * TODO: may obsolete the MSV #if below. + */ +#if USE_SQUID_MD5 + +/* MS VisualStudio Projects are monolithic, so we need USE_SSL * #if to exclude the MD5 code from compile process when we are * building the SSL support. */ #if !USE_SSL + #if HAVE_STRING_H #include /* for memcpy() */ #endif @@ -41,8 +52,6 @@ #include /* for ntohl() */ #endif -#include "md5.h" - #ifdef WORDS_BIGENDIAN void byteSwap(uint32_t *, unsigned); @@ -257,5 +266,6 @@ MD5Transform(uint32_t buf[4], uint32_t const in[16]) buf[3] += d; } -#endif -#endif +#endif /* !ASM_MD5 */ +#endif /* !USE_SSL */ +#endif /* !USE_SQUID_MD5 */