[cpp-sp] 13/17: Use pkg-config for GSSAPI

Scott Cantor cantor.2 at osu.edu
Wed Jun 27 20:35:54 EDT 2018


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch master
in repository cpp-sp.

View the commit online:
http://git.shibboleth.net/view/?p=cpp-sp.git;a=commit;h=b5476b4069d31c5a6e5e841046178579dd684b22

commit b5476b4069d31c5a6e5e841046178579dd684b22
Author: Ferenc Wágner <wferi at niif.hu>
AuthorDate: Tue Jul 19 16:54:35 2016 +0200

    Use pkg-config for GSSAPI
---
 apache/Makefile.am                     |   6 ++
 configure.ac                           | 181 ++++-----------------------------
 plugins/GSSAPIAttributeExtractor.cpp   |   4 +-
 plugins/Makefile.am                    |   2 +
 plugins/plugins.cpp                    |   4 +-
 shibsp/Makefile.am                     |   4 +
 shibsp/handler/impl/RemotedHandler.cpp |   6 +-
 7 files changed, 39 insertions(+), 168 deletions(-)

diff --git a/apache/Makefile.am b/apache/Makefile.am
index 2b8e44a..5e21102 100644
--- a/apache/Makefile.am
+++ b/apache/Makefile.am
@@ -27,11 +27,13 @@ mod_shib_20_la_CXXFLAGS = \
   $(APXS2_CFLAGS) -I$(APXS2_INCLUDE) \
   $(BOOST_CPPFLAGS) \
   $(PTHREAD_CFLAGS) \
+  $(gss_CFLAGS) $(gnu_gss_CFLAGS) \
   $(xerces_CFLAGS) \
   $(xmltooling_lite_CFLAGS)
 mod_shib_20_la_LIBADD = \
   $(top_builddir)/shibsp/libshibsp-lite.la \
   $(PTHREAD_LIBS) \
+  $(gss_LIBS) $(gnu_gss_LIBS) \
   $(xerces_LIBS) \
   $(xmltooling_lite_LIBS)
 endif
@@ -45,11 +47,13 @@ mod_shib_22_la_CXXFLAGS = \
   $(APXS22_CFLAGS) -I$(APXS22_INCLUDE) \
   $(BOOST_CPPFLAGS) \
   $(PTHREAD_CFLAGS) \
+  $(gss_CFLAGS) $(gnu_gss_CFLAGS) \
   $(xerces_CFLAGS) \
   $(xmltooling_lite_CFLAGS)
 mod_shib_22_la_LIBADD = \
   $(top_builddir)/shibsp/libshibsp-lite.la \
   $(PTHREAD_LIBS) \
+  $(gss_LIBS) $(gnu_gss_LIBS) \
   $(xerces_LIBS) \
   $(xmltooling_lite_LIBS)
 endif
@@ -63,11 +67,13 @@ mod_shib_24_la_CXXFLAGS = \
   $(APXS24_CFLAGS) -I$(APXS24_INCLUDE) \
   $(BOOST_CPPFLAGS) \
   $(PTHREAD_CFLAGS) \
+  $(gss_CFLAGS) $(gnu_gss_CFLAGS) \
   $(xerces_CFLAGS) \
   $(xmltooling_lite_CFLAGS)
 mod_shib_24_la_LIBADD = \
   $(top_builddir)/shibsp/libshibsp-lite.la \
   $(PTHREAD_LIBS) \
+  $(gss_LIBS) $(gnu_gss_LIBS) \
   $(xerces_LIBS) \
   $(xmltooling_lite_LIBS)
 endif
diff --git a/configure.ac b/configure.ac
index 905ae62..cc87730 100644
--- a/configure.ac
+++ b/configure.ac
@@ -911,154 +911,22 @@ if test "$have_odbc_libs" = yes ; then
    AC_SUBST(ODBC_LIBS)
 fi
 
-# GSS-API checking
-
-GSSAPI_ROOT="/usr"
-AC_ARG_WITH(gssapi-includes,
-  AS_HELP_STRING([--with-gssapi-includes=DIR],[Specify location of GSSAPI header]),
-  [ GSSAPI_INCS="-I$withval"
-    want_gss="yes" ]
-)
-
-AC_ARG_WITH(gssapi-libs,
-  AS_HELP_STRING([--with-gssapi-libs=DIR],[Specify location of GSSAPI libs]),
-  [ GSSAPI_LIB_DIR="-L$withval"
-    want_gss="yes" ]
-)
-
-AC_ARG_WITH(gssapi,
-  AS_HELP_STRING([--with-gssapi=DIR],[Where to look for GSSAPI]),
-  [ GSSAPI_ROOT="$withval"
-  if test x"$GSSAPI_ROOT" != xno; then
-    want_gss="yes"
-    if test x"$GSSAPI_ROOT" = xyes; then
-      dnl if yes, then use default root
-      GSSAPI_ROOT="/usr"
-    fi
-  fi
-])
-
-save_CPPFLAGS="$CPPFLAGS"
-AC_MSG_CHECKING([if GSSAPI support is requested])
-if test x"$want_gss" = xyes; then
-  AC_MSG_RESULT(yes)
-
-  if test -z "$GSSAPI_INCS"; then
-     if test -f "$GSSAPI_ROOT/bin/krb5-config"; then
-        GSSAPI_INCS=`$GSSAPI_ROOT/bin/krb5-config --cflags gssapi`
-     elif test "$GSSAPI_ROOT" != "yes"; then
-        GSSAPI_INCS="-I$GSSAPI_ROOT/include"
-     fi
-  fi
-
-  CPPFLAGS="$CPPFLAGS $GSSAPI_INCS"
-
-  AC_CHECK_HEADER(gss.h,
-    [
-      dnl found in the given dirs
-      AC_DEFINE([SHIBSP_HAVE_GSSGNU],[1],[if you have the GNU gssapi libraries])
-      gnu_gss=yes
-    ],
-    [
-      dnl not found, check Heimdal or MIT
-      AC_CHECK_HEADERS([gssapi/gssapi.h], [], [not_mit=1])
-      AC_CHECK_HEADERS(
-        [gssapi/gssapi_generic.h gssapi/gssapi_krb5.h],
-        [],
-        [not_mit=1],
-        [
-AC_INCLUDES_DEFAULT
-#ifdef HAVE_GSSAPI_GSSAPI_H
-#include <gssapi/gssapi.h>
-#endif
-        ])
-      if test "x$not_mit" = "x1"; then
-        dnl MIT not found, check for Heimdal
-        AC_CHECK_HEADER([gssapi.h],
-            [
-              dnl found
-              AC_DEFINE([SHIBSP_HAVE_GSSHEIMDAL],[1],[if you have the Heimdal gssapi libraries])
-            ],
-            [
-              dnl no header found, disabling GSS
-              want_gss=no
-              AC_MSG_WARN([disabling GSSAPI since no header files was found])
-            ]
-          )
-      else
-        dnl MIT found
-        AC_DEFINE([SHIBSP_HAVE_GSSMIT],[1],[if you have the MIT gssapi libraries])
-        dnl check if we have a really old MIT kerberos (<= 1.2)
-        AC_MSG_CHECKING([if gssapi headers declare GSS_C_NT_HOSTBASED_SERVICE])
-        AC_COMPILE_IFELSE([
-          AC_LANG_PROGRAM([[
-#include <gssapi/gssapi.h>
-#include <gssapi/gssapi_generic.h>
-#include <gssapi/gssapi_krb5.h>
-          ]],[[
-            gss_import_name(
-                            (OM_uint32 *)0,
-                            (gss_buffer_t)0,
-                            GSS_C_NT_HOSTBASED_SERVICE,
-                            (gss_name_t *)0);
-          ]])
-        ],[
-          AC_MSG_RESULT([yes])
-        ],[
-          AC_MSG_RESULT([no])
-          AC_DEFINE([HAVE_OLD_GSSMIT],[1],[if you have an old MIT gssapi library, lacking GSS_C_NT_HOSTBASED_SERVICE])
-        ])
-      fi
-    ]
-  )
-else
-  AC_MSG_RESULT(no)
-fi
-if test x"$want_gss" = xyes; then
-  AC_DEFINE([SHIBSP_HAVE_GSSAPI],[1],[if you have the gssapi libraries])
-
-  if test -n "$gnu_gss"; then
-    LDFLAGS="$LDFLAGS $GSSAPI_LIB_DIR"
-    LIBS="$LIBS -lgss"
-  else
-    if test -z "$GSSAPI_LIB_DIR"; then
-      GSSAPI_LIB_DIR="$GSSAPI_ROOT/lib$libsuff"
-    fi
-    if test "$GSSAPI_ROOT" != "yes"; then
-       LDFLAGS="$LDFLAGS -L$GSSAPI_ROOT/lib$libsuff"
-    fi
-    if test -f "$GSSAPI_ROOT/bin/krb5-config"; then
-      dnl krb5-config doesn't have --libs-only-L or similar, put everything
-      dnl into LIBS
-      gss_libs=`$GSSAPI_ROOT/bin/krb5-config --libs gssapi`
-    else
-      if test "x$not_mit" = "x1"; then
-        gss_libs="-lgssapi"
-      else
-        gss_libs="-lgssapi_krb5"
-      fi
-    fi
-    LIBS="$LIBS $gss_libs"
-  fi
-
-  AC_MSG_CHECKING([whether GSS-API naming extensions are available])
-  AC_COMPILE_IFELSE(
-    [AC_LANG_PROGRAM([[
-#ifdef SHIBSP_HAVE_GSSGNU
-# include <gss.h>
-#elif defined SHIBSP_HAVE_GSSMIT
-# include <gssapi/gssapi.h>
-# include <gssapi/gssapi_ext.h>
-#else
-# include <gssapi.h>
-#endif]],
-    [[gss_get_name_attribute(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);]])],
-    [AC_MSG_RESULT([yes])AC_DEFINE([HAVE_GSSAPI_NAMINGEXTS],[1],[Define to 1 if GSS-API naming extensions are available.])],
-    [AC_MSG_RESULT([no])])
-
-  AC_MSG_CHECKING([whether GSS-API composite name import is available])
-  AC_COMPILE_IFELSE(
-    [AC_LANG_PROGRAM([[
+AC_ARG_WITH([gssapi],
+  [AS_HELP_STRING([--with-gssapi],[include GSSAPI support])],,[with_gssapi=check])
+AS_IF([test "x$with_gssapi" != xno],
+  [AX_PKG_CHECK_MODULES([gss],,[krb5-gssapi],
+     [PKG_CHECK_VAR([GSS_VENDOR],[krb5-gssapi],[vendor])
+      AS_CASE(["$GSS_VENDOR"],
+        [Heimdal],[AC_DEFINE([SHIBSP_HAVE_GSSHEIMDAL],[1],[if you have the Heimdal gssapi libraries])],
+        [MIT],[AC_DEFINE([SHIBSP_HAVE_GSSMIT],[1],[if you have the MIT gssapi libraries])])],
+     [AX_PKG_CHECK_MODULES([gnu_gss],,[gss],
+        [AC_DEFINE([SHIBSP_HAVE_GSSGNU],[1],[if you have the GNU gssapi libraries])],
+        [with_gssapi=no],
+        [SHIBSP_LITE_REQUIRES],[SHIBSP_LITE_REQUIRES_PRIVATE])],
+     [SHIBSP_LITE_REQUIRES],[SHIBSP_LITE_REQUIRES_PRIVATE])
+   AS_IF([test "x$with_gssapi" != xno],
+     [AC_DEFINE([SHIBSP_HAVE_GSSAPI],[1],[if you have the gssapi libraries])
+      AC_CHECK_DECLS([gss_get_name_attribute,GSS_C_NT_EXPORT_NAME_COMPOSITE],,,[[
 #ifdef SHIBSP_HAVE_GSSGNU
 # include <gss.h>
 #elif defined SHIBSP_HAVE_GSSMIT
@@ -1066,19 +934,10 @@ if test x"$want_gss" = xyes; then
 # include <gssapi/gssapi_ext.h>
 #else
 # include <gssapi.h>
-#endif]],
-    [[
-    OM_uint32 minor;
-    gss_name_t srcname;
-    gss_buffer_desc importbuf;
-    gss_import_name(&minor, &importbuf, GSS_C_NT_EXPORT_NAME_COMPOSITE, &srcname);
-    ]])],
-    [AC_MSG_RESULT([yes])AC_DEFINE([HAVE_GSSAPI_COMPOSITE_NAME],[1],[Define to 1 if GSS-API composite name import is available.])],
-    [AC_MSG_RESULT([no])])
-    
-else
-  CPPFLAGS="$save_CPPFLAGS"
-fi
+#endif
+]])
+     ])
+  ])
 
 # Check for unit test support
 AC_CONFIG_FILES([unittests/Makefile])
diff --git a/plugins/GSSAPIAttributeExtractor.cpp b/plugins/GSSAPIAttributeExtractor.cpp
index c6adda3..e1650b0 100644
--- a/plugins/GSSAPIAttributeExtractor.cpp
+++ b/plugins/GSSAPIAttributeExtractor.cpp
@@ -26,7 +26,7 @@
 
 #include "internal.h"
 
-#ifdef HAVE_GSSAPI_NAMINGEXTS
+#if HAVE_DECL_GSS_GET_NAME_ATTRIBUTE
 
 #include <shibsp/exceptions.h>
 #include <shibsp/Application.h>
@@ -355,7 +355,7 @@ void GSSAPIExtractor::extractAttributes(
         importbuf.length = x;
         importbuf.value = decoded;
         if (XMLString::equals(xmlObject.getElementQName().getLocalPart(), _GSSAPIName)) {
-#ifdef HAVE_GSSAPI_COMPOSITE_NAME
+#if HAVE_DECL_GSS_C_NT_EXPORT_NAME_COMPOSITE
             major = gss_import_name(&minor, &importbuf, GSS_C_NT_EXPORT_NAME_COMPOSITE, &srcname);
 #else
             major = gss_import_name(&minor, &importbuf, GSS_C_NT_EXPORT_NAME, &srcname);
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index a21f512..b039dd2 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -23,12 +23,14 @@ plugins_lite_la_SOURCES = \
 
 plugins_la_CXXFLAGS = \
 	$(PTHREAD_CFLAGS) \
+	$(gss_CFLAGS) $(gnu_gss_CFLAGS) \
 	$(opensaml_CFLAGS) \
 	$(xerces_CFLAGS) \
 	$(xmltooling_CFLAGS)
 plugins_la_LIBADD = \
 	$(top_builddir)/shibsp/libshibsp.la \
 	$(PTHREAD_LIBS) \
+	$(gss_LIBS) $(gnu_gss_LIBS) \
 	$(opensaml_LIBS) \
 	$(xerces_LIBS) \
 	$(xmltooling_LIBS)
diff --git a/plugins/plugins.cpp b/plugins/plugins.cpp
index e212a3d..5235e4b 100644
--- a/plugins/plugins.cpp
+++ b/plugins/plugins.cpp
@@ -45,7 +45,7 @@ namespace shibsp {
     PluginManager< Handler,string,pair<const DOMElement*,const char*> >::Factory AttributeResolverHandlerFactory;
     
 #ifndef SHIBSP_LITE
-# ifdef HAVE_GSSAPI_NAMINGEXTS
+# if HAVE_DECL_GSS_GET_NAME_ATTRIBUTE
     PluginManager<AttributeExtractor,string,const DOMElement*>::Factory GSSAPIExtractorFactory;
 # endif
     PluginManager<AttributeResolver,string,const DOMElement*>::Factory TemplateAttributeResolverFactory;
@@ -61,7 +61,7 @@ extern "C" int PLUGINS_EXPORTS xmltooling_extension_init(void*)
     conf.AccessControlManager.registerFactory("Time", TimeAccessControlFactory);
     conf.HandlerManager.registerFactory("AttributeResolver", AttributeResolverHandlerFactory);
 #ifndef SHIBSP_LITE
-# ifdef HAVE_GSSAPI_NAMINGEXTS
+# if HAVE_DECL_GSS_GET_NAME_ATTRIBUTE
     conf.AttributeExtractorManager.registerFactory("GSSAPI", GSSAPIExtractorFactory);
     static const XMLCh _GSSAPIName[] = UNICODE_LITERAL_10(G,S,S,A,P,I,N,a,m,e);
     static const XMLCh _GSSAPIContext[] = UNICODE_LITERAL_13(G,S,S,A,P,I,C,o,n,t,e,x,t);
diff --git a/shibsp/Makefile.am b/shibsp/Makefile.am
index da3c778..8bb732f 100644
--- a/shibsp/Makefile.am
+++ b/shibsp/Makefile.am
@@ -246,6 +246,7 @@ libshibsp_la_LDFLAGS = -version-info 8:0:0
 libshibsp_la_CXXFLAGS = \
     $(BOOST_CPPFLAGS) \
     $(PTHREAD_CFLAGS) \
+    $(gss_CFLAGS) $(gnu_gss_CFLAGS) \
     $(log4shib_CFLAGS) $(log4cpp_CFLAGS) \
     $(opensaml_CFLAGS) \
     $(xerces_CFLAGS) \
@@ -253,6 +254,7 @@ libshibsp_la_CXXFLAGS = \
     $(xmltooling_CFLAGS)
 libshibsp_la_LIBADD = \
     $(PTHREAD_LIBS) \
+    $(gss_LIBS) $(gnu_gss_LIBS) \
     $(log4shib_LIBS) $(log4cpp_LIBS) \
     $(opensaml_LIBS) \
     $(xerces_LIBS) \
@@ -262,11 +264,13 @@ libshibsp_lite_la_LDFLAGS = -version-info 8:0:0
 libshibsp_lite_la_CXXFLAGS = -DSHIBSP_LITE \
     $(BOOST_CPPFLAGS) \
     $(PTHREAD_CFLAGS) \
+    $(gss_CFLAGS) $(gnu_gss_CFLAGS) \
     $(log4shib_CFLAGS) $(log4cpp_CFLAGS) \
     $(xerces_CFLAGS) \
     $(xmltooling_lite_CFLAGS)
 libshibsp_lite_la_LIBADD = \
     $(PTHREAD_LIBS) \
+    $(gss_LIBS) $(gnu_gss_LIBS) \
     $(log4shib_LIBS) $(log4cpp_LIBS) \
     $(xerces_LIBS) \
     $(xmltooling_lite_LIBS)
diff --git a/shibsp/handler/impl/RemotedHandler.cpp b/shibsp/handler/impl/RemotedHandler.cpp
index 348d0c4..2b7ba68 100644
--- a/shibsp/handler/impl/RemotedHandler.cpp
+++ b/shibsp/handler/impl/RemotedHandler.cpp
@@ -45,7 +45,7 @@
 # include <xsec/framework/XSECProvider.hpp>
 #endif
 
-#ifdef HAVE_GSSAPI_NAMINGEXTS
+#if HAVE_DECL_GSS_GET_NAME_ATTRIBUTE
 # ifdef SHIBSP_HAVE_GSSMIT
 #  include <gssapi/gssapi_ext.h>
 # endif
@@ -255,7 +255,7 @@ gss_name_t RemotedRequest::getGSSName() const
             importbuf.length = x;
             importbuf.value = decoded;
             OM_uint32 major,minor;
-#ifdef HAVE_GSSAPI_COMPOSITE_NAME
+#if HAVE_DECL_GSS_C_NT_EXPORT_NAME_COMPOSITE
             major = gss_import_name(&minor, &importbuf, GSS_C_NT_EXPORT_NAME_COMPOSITE, &m_gssname);
 #else
             major = gss_import_name(&minor, &importbuf, GSS_C_NT_EXPORT_NAME, &m_gssname);
@@ -453,7 +453,7 @@ DDF RemotedHandler::wrap(const SPRequest& request, const vector<string>* headers
                 request.log(SPRequest::SPError, "error while exporting GSS context");
             }
         }
-#ifdef HAVE_GSSAPI_NAMINGEXTS
+#if HAVE_DECL_GSS_GET_NAME_ATTRIBUTE
         else {
             gss_name_t name = gss->getGSSName();
             if (name != GSS_C_NO_NAME) {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list