Skip to content

Commit

Permalink
sasl2-sys: don't fail cross compiling on SPNEGO check
Browse files Browse the repository at this point in the history
Also rework how patches are handled, since we've accumulated quite a few
now.
  • Loading branch information
benesch committed Apr 28, 2020
1 parent a5a7669 commit 186e1b4
Show file tree
Hide file tree
Showing 9 changed files with 224 additions and 153 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ indent_size = 4

[*.yml]
indent_size = 2

[*.patch]
trim_trailing_whitespace = false
19 changes: 19 additions & 0 deletions sasl2-sys/patch/01-maintainer-mode.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Despite how this looks, this *disables* maintainer mode by default, which has
the desired effect of avoiding automatic rebuilds of autotools scripts.
(Checking autotools scripts into Git, like we do in this repository, will often
causes the outputs to look out of date relative to the inputs even when they are
not, and we don't want to force the autotools dependency on our users.)

diff --git a/configure.ac b/configure.ac
index 388f5d0..b3db52c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -69,6 +69,8 @@ AC_CANONICAL_TARGET

AM_INIT_AUTOMAKE([1.11 tar-ustar dist-bzip2 foreign -Wno-portability subdir-objects])

+AM_MAINTAINER_MODE
+
DIRS=""

AC_ARG_ENABLE(cmulocal,
41 changes: 41 additions & 0 deletions sasl2-sys/patch/02-link-krb5support.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
TODO(benesch): determine why this patch was landed upstream.

commit 811efe35b8d8961061525e47c6a2d393813384b2
Author: Nikhil Benesch <[email protected]>
Date: Tue Apr 28 16:06:30 2020 -0400

Revert "Fixes https://github.com/cyrusimap/cyrus-sasl/issues/440"

This reverts commit 19185d278cdbf02a43b1f8da1f76a97ca274e12f. Upstream
provided no justification for this patch, and parts of it are necessary
for building libkrb5 statically.

diff --git a/m4/sasl2.m4 b/m4/sasl2.m4
index 56e0504..59b1349 100644
--- a/m4/sasl2.m4
+++ b/m4/sasl2.m4
@@ -116,9 +116,12 @@ if test "$gssapi" != no; then
fi

if test "$gss_impl" = "auto" -o "$gss_impl" = "mit"; then
+ # check for libkrb5support first
+ AC_CHECK_LIB(krb5support,krb5int_getspecific,K5SUP=-lkrb5support K5SUPSTATIC=$gssapi_dir/libkrb5support.a,,${LIB_SOCKET})
+
gss_failed=0
AC_CHECK_LIB(gssapi_krb5,gss_unwrap,gss_impl="mit",gss_failed=1,
- ${GSSAPIBASE_LIBS} -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err ${LIB_SOCKET})
+ ${GSSAPIBASE_LIBS} -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err ${K5SUP} ${LIB_SOCKET})
if test "$gss_impl" != "auto" -a "$gss_failed" = "1"; then
gss_impl="failed"
fi
@@ -170,8 +173,8 @@ if test "$gssapi" != no; then
fi

if test "$gss_impl" = "mit"; then
- GSSAPIBASE_LIBS="$GSSAPIBASE_LIBS -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err"
- GSSAPIBASE_STATIC_LIBS="$GSSAPIBASE_LIBS $gssapi_dir/libgssapi_krb5.a $gssapi_dir/libkrb5.a $gssapi_dir/libk5crypto.a $gssapi_dir/libcom_err.a"
+ GSSAPIBASE_LIBS="$GSSAPIBASE_LIBS -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err ${K5SUP}"
+ GSSAPIBASE_STATIC_LIBS="$GSSAPIBASE_LIBS $gssapi_dir/libgssapi_krb5.a $gssapi_dir/libkrb5.a $gssapi_dir/libk5crypto.a $gssapi_dir/libcom_err.a ${K5SUPSTATIC}"
elif test "$gss_impl" = "heimdal"; then
CPPFLAGS="$CPPFLAGS"
GSSAPIBASE_LIBS="$GSSAPIBASE_LIBS -lgssapi -lkrb5 -lasn1 -lroken ${LIB_CRYPT} ${LIB_DES} -lcom_err"
22 changes: 22 additions & 0 deletions sasl2-sys/patch/03-link-resolv-dl.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
commit a489bd545a6f48f666a22f9668649c7ba9076633
Author: Nikhil Benesch <[email protected]>
Date: Tue Apr 28 16:14:26 2020 -0400

Link against resolv and dl when testing for libkrb5

These are required for the link to succeed if krb5 has been built
statically.

diff --git a/m4/sasl2.m4 b/m4/sasl2.m4
index 59b1349..456d121 100644
--- a/m4/sasl2.m4
+++ b/m4/sasl2.m4
@@ -121,7 +121,7 @@ if test "$gssapi" != no; then

gss_failed=0
AC_CHECK_LIB(gssapi_krb5,gss_unwrap,gss_impl="mit",gss_failed=1,
- ${GSSAPIBASE_LIBS} -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err ${K5SUP} ${LIB_SOCKET})
+ ${GSSAPIBASE_LIBS} -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err ${K5SUP} -lresolv -ldl ${LIB_SOCKET})
if test "$gss_impl" != "auto" -a "$gss_failed" = "1"; then
gss_impl="failed"
fi
31 changes: 31 additions & 0 deletions sasl2-sys/patch/04-cross-compile-spnego.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
commit e022829b6ef295bc9c86437476fc3369596f13ca
Author: Nikhil Benesch <[email protected]>
Date: Tue Apr 28 16:24:18 2020 -0400

Don't fail cross compilation on SPNEGO check

Also allow overriding the default with a cache value.

diff --git a/m4/sasl2.m4 b/m4/sasl2.m4
index 456d121..5c06b21 100644
--- a/m4/sasl2.m4
+++ b/m4/sasl2.m4
@@ -318,7 +318,7 @@ if test "$gssapi" != no; then
LIBS="$LIBS $GSSAPIBASE_LIBS"

AC_MSG_CHECKING([for SPNEGO support in GSSAPI libraries])
- AC_TRY_RUN([
+ AC_CACHE_VAL(sasl_cv_have_gss_spnego, AC_TRY_RUN([
#ifdef HAVE_GSSAPI_H
#include <gssapi.h>
#else
@@ -342,7 +342,8 @@ int main(void)
],
[ AC_DEFINE(HAVE_GSS_SPNEGO,,[Define if your GSSAPI implementation supports SPNEGO])
AC_MSG_RESULT(yes) ],
- AC_MSG_RESULT(no))
+ AC_MSG_RESULT(no),
+ AC_MSG_WARN(cannot check when cross compiling so conservatively assuming no)))
LIBS="$cmu_save_LIBS"

else
88 changes: 88 additions & 0 deletions sasl2-sys/patch/05-static-pic.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
Upstream incorrectly uses `ifdef PIC` to mean "building a shared library"
and the inverse to mean "building a static library." Rust requires that
we build static libraries with PIC, so we go fix up all these ifdefs
appropriately.

diff --git a/lib/dlopen.c b/lib/dlopen.c
index 8284cd8..cea0387 100644
--- a/lib/dlopen.c
+++ b/lib/dlopen.c
@@ -56,10 +56,8 @@
#include <sasl.h>
#include "saslint.h"

-#ifndef PIC
#include <saslplug.h>
#include "staticopen.h"
-#endif

#ifdef DO_DLOPEN
#if HAVE_DIRENT_H
@@ -414,11 +412,9 @@ int _sasl_load_plugins(const add_plugin_list_t *entrypoints,
DIR *dp;
struct dirent *dir;
#endif
-#ifndef PIC
add_plugin_t *add_plugin;
_sasl_plug_type type;
_sasl_plug_rec *p;
-#endif

if (! entrypoints
|| ! getpath_cb
@@ -429,7 +425,6 @@ int _sasl_load_plugins(const add_plugin_list_t *entrypoints,
|| ! verifyfile_cb->proc)
return SASL_BADPARAM;

-#ifndef PIC
/* do all the static plugins first */

for(cur_ep = entrypoints; cur_ep->entryname; cur_ep++) {
@@ -456,15 +451,8 @@ int _sasl_load_plugins(const add_plugin_list_t *entrypoints,
result = add_plugin(p->name, p->plug);
}
}
-#endif /* !PIC */

-/* only do the following if:
- *
- * we support dlopen()
- * AND we are not staticly compiled
- * OR we are staticly compiled and TRY_DLOPEN_WHEN_STATIC is defined
- */
-#if defined(DO_DLOPEN) && (defined(PIC) || (!defined(PIC) && defined(TRY_DLOPEN_WHEN_STATIC)))
+#if defined(TRY_DLOPEN_WHEN_STATIC)
/* get the path to the plugins */
result = ((sasl_getpath_t *)(getpath_cb->proc))(getpath_cb->context,
&path);
@@ -545,7 +533,7 @@ int _sasl_load_plugins(const add_plugin_list_t *entrypoints,
}

} while ((c!='=') && (c!=0));
-#endif /* defined(DO_DLOPEN) && (!defined(PIC) || (defined(PIC) && defined(TRY_DLOPEN_WHEN_STATIC))) */
+#endif

return SASL_OK;
}
diff --git a/lib/server.c b/lib/server.c
index 8d4c322..7cbd1cb 100644
--- a/lib/server.c
+++ b/lib/server.c
@@ -823,7 +823,7 @@ int sasl_server_init(const sasl_callback_t *callbacks,
int ret;
const sasl_callback_t *vf;
const char *pluginfile = NULL;
-#ifdef PIC
+#if false
sasl_getopt_t *getopt;
void *context;
#endif
@@ -894,7 +894,7 @@ int sasl_server_init(const sasl_callback_t *callbacks,
/* load internal plugins */
sasl_server_add_plugin("EXTERNAL", &external_server_plug_init);

-#ifdef PIC
+#if false
/* delayed loading of plugins? (DSO only, as it doesn't
* make much [any] sense to delay in the static library case) */
if (_sasl_getcallback(NULL, SASL_CB_GETOPT, (sasl_callback_ft *)&getopt, &context)
11 changes: 7 additions & 4 deletions sasl2-sys/sasl2/configure
Original file line number Diff line number Diff line change
Expand Up @@ -17757,11 +17757,12 @@ rm -f conftest*

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SPNEGO support in GSSAPI libraries" >&5
$as_echo_n "checking for SPNEGO support in GSSAPI libraries... " >&6; }
if ${sasl_cv_have_gss_spnego+:} false; then :
$as_echo_n "(cached) " >&6
else
if test "$cross_compiling" = yes; then :
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot run test program while cross compiling
See \`config.log' for more details" "$LINENO" 5; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check when cross compiling so conservatively assuming no" >&5
$as_echo "$as_me: WARNING: cannot check when cross compiling so conservatively assuming no" >&2;}
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
Expand Down Expand Up @@ -17800,6 +17801,8 @@ $as_echo "no" >&6; }
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi

fi

LIBS="$cmu_save_LIBS"
Expand Down
5 changes: 3 additions & 2 deletions sasl2-sys/sasl2/m4/sasl2.m4
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ if test "$gssapi" != no; then
LIBS="$LIBS $GSSAPIBASE_LIBS"
AC_MSG_CHECKING([for SPNEGO support in GSSAPI libraries])
AC_TRY_RUN([
AC_CACHE_VAL(sasl_cv_have_gss_spnego, AC_TRY_RUN([
#ifdef HAVE_GSSAPI_H
#include <gssapi.h>
#else
Expand All @@ -342,7 +342,8 @@ int main(void)
],
[ AC_DEFINE(HAVE_GSS_SPNEGO,,[Define if your GSSAPI implementation supports SPNEGO])
AC_MSG_RESULT(yes) ],
AC_MSG_RESULT(no))
AC_MSG_RESULT(no),
AC_MSG_WARN(cannot check when cross compiling so conservatively assuming no)))
LIBS="$cmu_save_LIBS"
else
Expand Down
Loading

0 comments on commit 186e1b4

Please sign in to comment.