Skip to content

PHPC-1185: Revert GSSAPI support and fix sasl_client_done check #836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 17 additions & 41 deletions scripts/autotools/libmongoc/CheckSasl.m4
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
PHP_ARG_WITH([mongodb-sasl],
[whether to enable SASL for Kerberos authentication],
[AS_HELP_STRING([--with-mongodb-sasl=@<:@auto/no/cyrus/gssapi@:>@],
[AS_HELP_STRING([--with-mongodb-sasl=@<:@auto/no/cyrus@:>@],
[MongoDB: Enable SASL for Kerberos authentication [default=auto]])],
[auto],
[no])

AS_IF([test "$os_darwin" = "yes" -a \( "$PHP_MONGODB_SASL" = "gssapi" -o "$PHP_MONGODB_SASL" = "auto" \)],[
dnl PHP_FRAMEWORKS is only used for SAPI builds, so use MONGODB_SHARED_LIBADD for shared builds
if test "$ext_shared" = "yes"; then
MONGODB_SHARED_LIBADD="-framework GSS $MONGODB_SHARED_LIBADD"
else
PHP_ADD_FRAMEWORK([GSS])
fi
PHP_MONGODB_SASL="gssapi"
])
Copy link
Member Author

@jmikola jmikola May 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kvwalker found another bug with the original implementation. Although this added the GSS framework on macOS, it didn't stop the subsequent PKG_CHECK_MODULES check for krb5-gssapi and still resulted in an error if that library wasn't found. Had we kept this, we would want to ensure that the AS_IF([test "$PHP_MONGODB_SASL" = "gssapi" -o "$PHP_MONGODB_SASL" = "auto"],[ block later on never runs.

This is a moot point since we're deleting the code, but I wanted to make a note of it for future reference.


AS_IF([test "$PHP_MONGODB_SASL" = "cyrus" -o "$PHP_MONGODB_SASL" = "auto"],[
found_cyrus="no"

Expand All @@ -40,23 +30,16 @@ AS_IF([test "$PHP_MONGODB_SASL" = "cyrus" -o "$PHP_MONGODB_SASL" = "auto"],[
fi
])

if test "$PHP_MONGODB_SASL" = "cyrus" -a "$found_cyrus" != "yes"; then
AC_MSG_ERROR([Cyrus SASL libraries and development headers could not be found])
if test "$found_cyrus" = "yes"; then
PHP_CHECK_LIBRARY([sasl2],
[sasl_client_done],
[have_sasl_client_done=yes],
[have_sasl_client_done=no],
$MONGODB_SHARED_LIBADD)
fi
])

AS_IF([test "$PHP_MONGODB_SASL" = "gssapi" -o "$PHP_MONGODB_SASL" = "auto"],[
found_gssapi="no"

PKG_CHECK_MODULES([PHP_MONGODB_SASL],[krb5-gssapi],[
PHP_MONGODB_MONGOC_CFLAGS="$PHP_MONGODB_MONGOC_CFLAGS $PHP_MONGODB_SASL_CFLAGS"
PHP_EVAL_LIBLINE([$PHP_MONGODB_SASL_LIBS],[MONGODB_SHARED_LIBADD])
PHP_MONGODB_SASL="gssapi"
found_gssapi="yes"
])

if test "$PHP_MONGODB_SASL" = "gssapi" -a "$found_gssapi" != "yes"; then
AC_MSG_ERROR([GSSAPI libraries and development headers could not be found])
if test "$PHP_MONGODB_SASL" = "cyrus" -a "$found_cyrus" != "yes"; then
AC_MSG_ERROR([Cyrus SASL libraries and development headers could not be found])
fi
])

Expand All @@ -65,34 +48,27 @@ AS_IF([test "$PHP_MONGODB_SASL" = "auto"],[
])

dnl Warn for unsupported values (e.g. Cyrus SASL search path)
if test ! \( "$PHP_MONGODB_SASL" = "cyrus" -o "$PHP_MONGODB_SASL" = "gssapi" -o "$PHP_MONGODB_SASL" = "no" \); then
if test ! \( "$PHP_MONGODB_SASL" = "cyrus" -o "$PHP_MONGODB_SASL" = "no" \); then
AC_MSG_WARN([unsupported --with-mongodb-sasl value: $PHP_MONGODB_SASL])
fi

AC_MSG_CHECKING([which SASL library to use])
AC_MSG_RESULT([$PHP_MONGODB_SASL])

dnl Disable Windows SSPI
dnl Disable Windows SSPI and GSSAPI
AC_SUBST(MONGOC_ENABLE_SASL_SSPI, 0)
AC_SUBST(MONGOC_ENABLE_SASL_GSSAPI, 0)

if test "$PHP_MONGODB_SASL" = "cyrus" -o "$PHP_MONGODB_SASL" = "gssapi"; then
if test "$PHP_MONGODB_SASL" = "cyrus"; then
AC_SUBST(MONGOC_ENABLE_SASL, 1)
if test "$PHP_MONGODB_SASL" = "cyrus" ; then
AC_SUBST(MONGOC_ENABLE_SASL_CYRUS, 1)
AC_SUBST(MONGOC_ENABLE_SASL_GSSAPI, 0)
if test "x$have_sasl_client_done" = "xyes"; then
AC_SUBST(MONGOC_HAVE_SASL_CLIENT_DONE, 1)
else
AC_SUBST(MONGOC_HAVE_SASL_CLIENT_DONE, 0)
fi
elif test "$PHP_MONGODB_SASL" = "gssapi"; then
AC_SUBST(MONGOC_ENABLE_SASL_CYRUS, 0)
AC_SUBST(MONGOC_ENABLE_SASL_GSSAPI, 1)
AC_SUBST(MONGOC_ENABLE_SASL_CYRUS, 1)
if test "x$have_sasl_client_done" = "xyes"; then
AC_SUBST(MONGOC_HAVE_SASL_CLIENT_DONE, 1)
else
AC_SUBST(MONGOC_HAVE_SASL_CLIENT_DONE, 0)
fi
else
AC_SUBST(MONGOC_ENABLE_SASL, 0)
AC_SUBST(MONGOC_ENABLE_SASL_CYRUS, 0)
AC_SUBST(MONGOC_ENABLE_SASL_GSSAPI, 0)
AC_SUBST(MONGOC_HAVE_SASL_CLIENT_DONE, 0)
fi