]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix OpenSSL detection when an explicit path is given
authorAmos Jeffries <squid3@treenet.co.nz>
Tue, 8 Apr 2014 13:09:47 +0000 (06:09 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 8 Apr 2014 13:09:47 +0000 (06:09 -0700)
The previous OpenSSL detection was skipping the library checks when an
explicit path was presented. Resulting in no -lssl flag being passed to
the linker.

Rational for this fix:
 pkg-config presents location-neutral details.

 The explicit checks are likewise neutral provided the LIBS environment
  variable has been set with the explicit path.

 User presented path must be used regardless of which the library checks
  are used in detection.

So...

 Always perform the checks with optionally set LIBS and keep the
 user provided path explicitly separate from the pkg-config *_LIBS
 variable. Only assemble the parts into SSLLIB once all have been
 identified.

configure.ac

index d81dbaf90374930a2bcc6e2256a2cf913106a8ed..508561c400f3f9b8dd93a66bbde6636e8fb6a622 100644 (file)
@@ -1219,7 +1219,7 @@ case "$with_openssl" in
     if test ! -d "$withval" ; then
       AC_MSG_ERROR([--with-openssl path does not point to a directory])
     fi
-    LIBOPENSSL_LIBS="-L$with_openssl/lib"
+    LIBOPENSSL_PATH="-L$with_openssl/lib"
     CPPFLAGS="-I$with_openssl/include $CPPFLAGS"
     with_openssl=yes
   esac
@@ -1238,38 +1238,39 @@ if test "x$with_openssl" = "xyes"; then
   )
 
   # User may have provided a custom location for OpenSSL. Otherwise...
-  if test "x$LIBOPENSSL_LIBS" = "x" ; then
-    # auto-detect using pkg-config
-    PKG_CHECK_MODULES([LIBOPENSSL],[openssl],,[
-      ## For some OS pkg-config is broken or unavailable.
-      ## Detect libraries the hard way.
-
-      # Windows MinGW has some special libraries ...
-      if test "x$squid_host_os" = "xmingw" ; then
-        LIBOPENSSL_LIBS='-lssleay32 -leay32 -lgdi32 $LIBOPENSSL_LIBS'
-        AC_MSG_NOTICE([Windows OpenSSL library support: yes -lssleay32 -leay32 -lgdi32])
-      fi
-
-      AC_CHECK_LIB(crypto,[CRYPTO_new_ex_data],[LIBOPENSSL_LIBS="-lcrypto $LIBOPENSSL_LIBS"],[
-        AC_MSG_ERROR([library 'crypto' is required for OpenSSL])
-      ])
-      AC_CHECK_LIB(ssl,[SSL_library_init],[LIBOPENSSL_LIBS="-lssl $LIBOPENSSL_LIBS"],[
-        AC_MSG_ERROR([library 'ssl' is required for OpenSSL])
-      ])
+  SQUID_STATE_SAVE(squid_openssl_state)
+  LIBS="$LIBS $LIBOPENSSL_PATH"
+
+  # auto-detect using pkg-config
+  PKG_CHECK_MODULES([LIBOPENSSL],[openssl],,[
+    ## For some OS pkg-config is broken or unavailable.
+    ## Detect libraries the hard way.
+
+    # Windows MinGW has some special libraries ...
+    if test "x$squid_host_os" = "xmingw" ; then
+      LIBOPENSSL_LIBS='-lssleay32 -leay32 -lgdi32 $LIBOPENSSL_LIBS'
+      AC_MSG_NOTICE([Windows OpenSSL library support: yes -lssleay32 -leay32 -lgdi32])
+    fi
 
+    AC_CHECK_LIB(crypto,[CRYPTO_new_ex_data],[LIBOPENSSL_LIBS="-lcrypto $LIBOPENSSL_LIBS"],[
+      AC_MSG_ERROR([library 'crypto' is required for OpenSSL])
+    ])
+    AC_CHECK_LIB(ssl,[SSL_library_init],[LIBOPENSSL_LIBS="-lssl $LIBOPENSSL_LIBS"],[
+      AC_MSG_ERROR([library 'ssl' is required for OpenSSL])
     ])
+  ])
 
-    # This is a workaround for RedHat 9 brain damage..
-    if test -d /usr/kerberos/include -a -f /usr/include/openssl/kssl.h; then
-      AC_MSG_NOTICE([OpenSSL depends on Kerberos])
-      LIBOPENSSL_LIBS="-L/usr/kerberos/lib $LIBOPENSSL_LIBS"
-      CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
-    fi
+  # This is a workaround for RedHat 9 brain damage..
+  if test -d /usr/kerberos/include -a -f /usr/include/openssl/kssl.h; then
+    AC_MSG_NOTICE([OpenSSL depends on Kerberos])
+    LIBOPENSSL_LIBS="-L/usr/kerberos/lib $LIBOPENSSL_LIBS"
+    CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
   fi
+  SQUID_STATE_ROLLBACK(squid_openssl_state) #de-pollute LIBS
 
   if test "x$LIBOPENSSL_LIBS" != "x"; then
     CXXFLAGS="$LIBOPENSSL_CFLAGS $CXXFLAGS"
-    SSLLIB="$LIBOPENSSL_LIBS $SSLLIB"
+    SSLLIB="$LIBOPENSSL_PATH $LIBOPENSSL_LIBS $SSLLIB"
     AC_DEFINE(USE_OPENSSL,1,[OpenSSL support is available])
 
     # check for other specific broken implementations
@@ -1281,7 +1282,7 @@ if test "x$with_openssl" = "xyes"; then
     AC_MSG_ERROR([Required OpenSSL library not found])
   fi
 fi
-AC_MSG_NOTICE([OpenSSL library support: ${with_openssl:=no} ${LIBOPENSSL_LIBS}])
+AC_MSG_NOTICE([OpenSSL library support: ${with_openssl:=no} ${LIBOPENSSL_PATH} ${LIBOPENSSL_LIBS}])
 AM_CONDITIONAL(ENABLE_SSL,[ test "x$with_openssl" = "xyes" ])
 AC_SUBST(SSLLIB)