[PATCH 1/1] fixup! Added OpenSSL crypto backend



Legacy libnm-glib/libnm-util also uses the crypto code.
Somehow this needs to work together.

I don't think it's worth the effort to also support openssl for
the legacy library.

How about adding a separate configuration option which allows
to specify a different crypto library for libnm-utils?
---
 configure.ac           | 51 ++++++++++++++++++++++++++++++++++++++++++++++----
 libnm-util/Makefile.am | 12 ++++++------
 2 files changed, 53 insertions(+), 10 deletions(-)

diff --git a/configure.ac b/configure.ac
index 5651faa..15be3c2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -605,16 +605,12 @@ if test x"$ac_crypto" = xnss; then
   if test x"$?" != "x0"; then
     AC_MSG_ERROR([No usable NSS found])
   fi
-
-  AC_DEFINE(HAVE_NSS, 1, [Define if you have NSS])
   with_nss=yes
 elif test x"$ac_crypto" = xgnutls; then
   PKG_CHECK_MODULES(GNUTLS, [gnutls >= 2.12])
-  AC_DEFINE(HAVE_GNUTLS, 1, [Define if you have libgnutls])
   with_gnutls=yes
 elif test x"$ac_crypto" = xopenssl; then
   PKG_CHECK_MODULES(OPENSSL, [libcrypto >= 1.0.1a])
-  AC_DEFINE(HAVE_OPENSSL, 1, [Define if you have OpenSSL])
   with_openssl=yes
 else
   AC_MSG_ERROR([Please choose either 'nss', 'gnutls', 'openssl' for certificate and crypto operations])
@@ -623,6 +619,53 @@ AM_CONDITIONAL(WITH_NSS, test x"$with_nss" != xno)
 AM_CONDITIONAL(WITH_GNUTLS, test x"$with_gnutls" != xno)
 AM_CONDITIONAL(WITH_OPENSSL, test x"$with_openssl" != xno)
 
+
+# openssl is not supported for legacy libnm-glib library. Allow specifing
+# a different crypto library that is used for libnm-glib.
+AC_ARG_WITH(crypto-libnm-glib, AS_HELP_STRING([--with-crypto-libnm-glib=nss|gnutls],
+    [Cryptography library to use for certificate and key operations for legacy-libnm-glib library]), 
ac_crypto_libnm_glib=$withval, ac_crypto_libnm_glib=)
+
+with_nss_libnm_glib=no
+with_gnutls_libnm_glib=no
+if test "$with_libnm_glib" != "no"; then
+    if test "$ac_crypto_libnm_glib" == ""; then
+        if test "$ac_crypto" != openssl; then
+            ac_crypto_libnm_glib="$ac_crypto"
+        else
+            ac_crypto_libnm_glib="nss"
+        fi
+    fi
+
+    if test x"$ac_crypto_libnm_glib" = xnss; then
+        if test "$with_nss" != yes; then
+            PKG_CHECK_MODULES(NSS, [nss >= 3.11], :,
+                [AC_MSG_FAILURE([$NSS_PKG_ERRORS
+
+Configure with --without-libnm-glib if you do not need the legacy libraries])])
+
+            # Work around a pkg-config bug (fdo #29801) where exists != usable
+            FOO=`$PKG_CONFIG --cflags --libs nss`
+            if test x"$?" != "x0"; then
+                AC_MSG_ERROR([No usable NSS found. Configure with --without-libnm-glib if you do not need 
the legacy libraries])
+            fi
+        fi
+        with_nss_libnm_glib=yes
+    elif test x"$ac_crypto_libnm_glib" = xgnutls; then
+        if test "$with_gnutls" != yes; then
+            PKG_CHECK_MODULES(GNUTLS, [gnutls >= 2.12], :,
+                [AC_MSG_FAILURE([$NSS_PKG_ERRORS
+
+Configure with --without-libnm-glib if you do not need the legacy libraries])])
+        fi
+        with_gnutls_libnm_glib=yes
+    else
+        AC_MSG_ERROR([Please choose either 'nss' or 'gnutls' for certificate and crypto operation for 
libnm-glib (--with-crypto-libnm-glib)])
+    fi
+fi
+AM_CONDITIONAL(WITH_NSS_LIBNM_GLIB, test x"$with_nss_libnm_glib" != xno)
+AM_CONDITIONAL(WITH_GNUTLS_LIBNM_GLIB, test x"$with_gnutls_libnm_glib" != xno)
+
+
 GLIB_MAKEFILE='$(top_srcdir)/Makefile.glib'
 AC_SUBST(GLIB_MAKEFILE)
 GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0`
diff --git a/libnm-util/Makefile.am b/libnm-util/Makefile.am
index 29c83f0..bb75ef3 100644
--- a/libnm-util/Makefile.am
+++ b/libnm-util/Makefile.am
@@ -14,11 +14,11 @@ AM_CPPFLAGS = \
        $(DBUS_CFLAGS) \
        $(UUID_CFLAGS)
 
-if WITH_GNUTLS
+if WITH_GNUTLS_LIBNM_GLIB
 AM_CPPFLAGS += $(GNUTLS_CFLAGS)
 endif
 
-if WITH_NSS
+if WITH_NSS_LIBNM_GLIB
 AM_CPPFLAGS += $(NSS_CFLAGS)
 endif
 
@@ -122,12 +122,12 @@ SYMBOL_VIS_FILE=$(srcdir)/libnm-util.ver
 libnm_util_la_LDFLAGS = -Wl,--version-script=$(SYMBOL_VIS_FILE) \
        -version-info "9:0:7"
 
-if WITH_GNUTLS
+if WITH_GNUTLS_LIBNM_GLIB
 libnm_util_la_SOURCES += crypto_gnutls.c
 libnm_util_la_LIBADD += $(GNUTLS_LIBS)
 endif
 
-if WITH_NSS
+if WITH_NSS_LIBNM_GLIB
 libnm_util_la_SOURCES += crypto_nss.c
 libnm_util_la_LIBADD += $(NSS_LIBS)
 endif
@@ -146,12 +146,12 @@ libtest_crypto_la_SOURCES = crypto.c
 libtest_crypto_la_LIBADD = \
        $(GLIB_LIBS)
 
-if WITH_GNUTLS
+if WITH_GNUTLS_LIBNM_GLIB
 libtest_crypto_la_SOURCES += crypto_gnutls.c
 libtest_crypto_la_LIBADD += $(GNUTLS_LIBS)
 endif
 
-if WITH_NSS
+if WITH_NSS_LIBNM_GLIB
 libtest_crypto_la_SOURCES += crypto_nss.c
 libtest_crypto_la_LIBADD += $(NSS_LIBS)
 endif
-- 
2.5.0



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]