From 976cbc63d5713b634a26c3662539ed528404e1fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20R.=20Sede=C3=B1o?= Date: Sun, 7 Feb 2010 17:56:51 -0500 Subject: [PATCH 12/13] Allow builds to link against either libdl or a gssapi lib If we can find libdl, use it and drop the dependecies on gssapi. If we can't find libdl, look for a gssapi library and the relevant build prereqs. If we can't find either, don't build with gssapi support. --- pgssapi.c | 6 +++++- pgssapi.h | 10 +++++++++- unix/configure.ac | 19 +++++++++++++++++-- unix/uxgss.c | 7 +++++++ 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/pgssapi.c b/pgssapi.c index bdde486..88bb1a2 100644 --- a/pgssapi.c +++ b/pgssapi.c @@ -8,6 +8,8 @@ #define GSS_DEFINE_FN #include "pgssapi.h" +#ifndef NO_LIBDL + /* Reserved static storage for GSS_oids. Comments are quotes from RFC 2744. */ static const gss_OID_desc oids[] = { /* The implementation must reserve static storage for a @@ -94,9 +96,11 @@ const_gss_OID GSS_C_NT_HOSTBASED_SERVICE = oids+4; const_gss_OID GSS_C_NT_ANONYMOUS = oids+5; const_gss_OID GSS_C_NT_EXPORT_NAME = oids+6; +#endif /* NO_LIBDL */ + static gss_OID_desc gss_mech_krb5_desc = { 9, (void *)"\x2a\x86\x48\x86\xf7\x12\x01\x02\x02" }; /* iso(1) member-body(2) United States(840) mit(113554) infosys(1) gssapi(2) krb5(2)*/ -const_gss_OID GSS_MECH_KRB5 = &gss_mech_krb5_desc; +const gss_OID GSS_MECH_KRB5 = &gss_mech_krb5_desc; #endif /* NO_GSSAPI */ diff --git a/pgssapi.h b/pgssapi.h index 4c6cc8a..86cbebe 100644 --- a/pgssapi.h +++ b/pgssapi.h @@ -4,6 +4,7 @@ #include "putty.h" #ifndef NO_GSSAPI +#ifndef NO_LIBDL /******************************************************************************* * GSSAPI Definitions, taken from RFC 2744 ******************************************************************************/ @@ -280,7 +281,14 @@ extern const_gss_OID GSS_C_NT_HOSTBASED_SERVICE_X; extern const_gss_OID GSS_C_NT_HOSTBASED_SERVICE; extern const_gss_OID GSS_C_NT_ANONYMOUS; extern const_gss_OID GSS_C_NT_EXPORT_NAME; -extern const_gss_OID GSS_MECH_KRB5; + +#else /* NO_LIBDL */ + +#include + +#endif /* NO_LIBDL */ + +extern const gss_OID GSS_MECH_KRB5; #endif /* NO_GSSAPI */ diff --git a/unix/configure.ac b/unix/configure.ac index 108b09f..339c640 100644 --- a/unix/configure.ac +++ b/unix/configure.ac @@ -51,7 +51,17 @@ fi AC_SUBST([all_targets]) AC_SEARCH_LIBS([socket], [xnet]) -AC_SEARCH_LIBS([dlopen], [dl]) + +AS_IF([test "x$with_gssapi" != xno], + [AC_SEARCH_LIBS( + [dlopen],[dl], + [], + [AC_DEFINE([NO_LIBDL], [1], [Define if we could not find libdl.]) + AC_CHECK_HEADERS([gssapi/gssapi.h]) + AC_SEARCH_LIBS( + [gss_init_sec_context],[gssapi gssapi_krb5 gss], + [], + [AC_DEFINE([NO_GSSAPI_LIB], [1], [Define if we could not find a gssapi library])])])]) AC_CHECK_FUNCS([getaddrinfo ptsname setresuid strsignal updwtmpx]) @@ -84,7 +94,12 @@ AH_BOTTOM([ #ifndef HAVE_PANGO_FONT_MAP_LIST_FAMILIES # define PANGO_PRE_1POINT6 #endif -#ifndef WITH_GSSAPI +#if !defined(WITH_GSSAPI) # define NO_GSSAPI #endif +#if !defined(NO_GSSAPI) && defined(NO_LIBDL) +# if !defined(HAVE_GSSAPI_GSSAPI_H) || defined(NO_GSSAPI_LIB) +# define NO_GSSAPI +# endif +#endif ]) diff --git a/unix/uxgss.c b/unix/uxgss.c index ae970ee..fea0833 100644 --- a/unix/uxgss.c +++ b/unix/uxgss.c @@ -7,9 +7,12 @@ /* Unix specific GSSAPI code */ /* Library loading */ +#ifndef NO_LIBDL static void *gsslib = NULL; +#endif /* NO_LIBDL */ int ssh_gss_init(void) { +#ifndef NO_LIBDL if (gsslib) return 1; /* Dynamically load gssapi lib here. */ /* 1) Heimdal's GSSAPI Library */ @@ -36,6 +39,10 @@ int ssh_gss_init(void) return 1; } return 0; +#else /* NO_LIBDL */ + ssh_gssapi_bind_fns(); + return 1; +#endif /* NO_LIBDL */ } #endif /* NO_GSSAPI */ -- 1.6.6