dnl to yes if that's the case
AC_DEFUN([SQUID_CHECK_KRB5_SOLARIS_BROKEN_KRB5_H], [
AC_CACHE_CHECK([for broken Solaris krb5.h],squid_cv_broken_krb5_h, [
+ SQUID_STATE_SAVE(squid_krb5_solaris_test)
+ CPPFLAGS="-I${srcdir:-.} $CPPFLAGS"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <krb5.h>
int i;
]])], [ squid_cv_broken_krb5_h=no ], [
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-#if defined(__cplusplus)
-#define KRB5INT_BEGIN_DECLS extern "C" {
-#define KRB5INT_END_DECLS
-KRB5INT_BEGIN_DECLS
-#endif
-#include <krb5.h>
+#define HAVE_BROKEN_SOLARIS_KRB5_H 1
+#include "compat/krb5.h"
int i;
]])], [ squid_cv_broken_krb5_h=yes ], [ squid_cv_broken_krb5_h=no ])
])
+ SQUID_STATE_ROLLBACK(squid_krb5_solaris_test)
])
]) dnl SQUID_CHECK_KRB5_SOLARIS_BROKEN_KRB5_H
AC_DEFUN([SQUID_CHECK_KRB5_HEIMDAL_BROKEN_KRB5_H], [
AC_CACHE_CHECK([for broken Heimdal krb5.h],squid_cv_broken_heimdal_krb5_h, [
+ SQUID_STATE_SAVE(squid_krb5_heimdal_test)
+ CPPFLAGS="-I${srcdir:-.} $CPPFLAGS"
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <krb5.h>
int
}
]])], [ squid_cv_broken_heimdal_krb5_h=no ], [
AC_RUN_IFELSE([AC_LANG_SOURCE([[
-#if defined(__cplusplus)
-extern "C" {
-#endif
-#include <krb5.h>
-#if defined(__cplusplus)
-}
-#endif
+#define HAVE_BROKEN_HEIMDAL_KRB5_H 1
+#include "compat/krb5.h"
int
main(void)
{
}
]])], [ squid_cv_broken_heimdal_krb5_h=yes ], [ squid_cv_broken_heimdal_krb5_h=no ])
])
+ SQUID_STATE_ROLLBACK(squid_krb5_heimdal_test)
])
]) dnl SQUID_CHECK_KRB5_HEIMDAL_BROKEN_KRB5_H
AC_DEFUN([SQUID_CHECK_MAX_SKEW_IN_KRB5_CONTEXT],[
AC_CACHE_CHECK([for max_skew in struct krb5_context],
squid_cv_max_skew_context, [
+ SQUID_STATE_SAVE(squid_krb5_test)
+ CPPFLAGS="-I${srcdir:-.} $CPPFLAGS"
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
-#if HAVE_BROKEN_SOLARIS_KRB5_H
-#if defined(__cplusplus)
-#define KRB5INT_BEGIN_DECLS extern "C" {
-#define KRB5INT_END_DECLS
-KRB5INT_BEGIN_DECLS
-#endif
-#endif
-#if USE_APPLE_KRB5
-#define KERBEROS_APPLE_DEPRECATED(x)
-#endif
-#include <krb5.h>
+#include "compat/krb5.h"
krb5_context kc; kc->max_skew = 1;
]])
],[ squid_cv_max_skew_context=yes ],
[ squid_cv_max_skew_context=no ])
+ SQUID_STATE_ROLLBACK(squid_krb5_test)
])
])
dnl squid_cv_memory_cache if that's the case.
AC_DEFUN([SQUID_CHECK_KRB5_CONTEXT_MEMORY_CACHE],[
AC_CACHE_CHECK([for memory cache], squid_cv_memory_cache, [
+ SQUID_STATE_SAVE(squid_krb5_test)
+ CPPFLAGS="-I${srcdir:-.} $CPPFLAGS"
AC_RUN_IFELSE([
AC_LANG_SOURCE([[
-#if HAVE_BROKEN_SOLARIS_KRB5_H
-#if defined(__cplusplus)
-#define KRB5INT_BEGIN_DECLS extern "C" {
-#define KRB5INT_END_DECLS
-KRB5INT_BEGIN_DECLS
-#endif
-#endif
-#if USE_APPLE_KRB5
-#define KERBEROS_APPLE_DEPRECATED(x)
-#endif
-#include <krb5.h>
+#include "compat/krb5.h"
int main(int argc, char *argv[])
{
krb5_context context;
}
]])
], [ squid_cv_memory_cache=yes ], [ squid_cv_memory_cache=no ], [:])
+ SQUID_STATE_ROLLBACK(squid_krb5_test)
])
])
dnl squid_cv_memory_keytab if that's the case.
AC_DEFUN([SQUID_CHECK_KRB5_CONTEXT_MEMORY_KEYTAB],[
AC_CACHE_CHECK([for memory keytab], squid_cv_memory_keytab, [
+ SQUID_STATE_SAVE(squid_krb5_test)
+ CPPFLAGS="-I${srcdir:-.} $CPPFLAGS"
AC_RUN_IFELSE([
AC_LANG_SOURCE([[
-#if HAVE_BROKEN_SOLARIS_KRB5_H
-#if defined(__cplusplus)
-#define KRB5INT_BEGIN_DECLS extern "C" {
-#define KRB5INT_END_DECLS
-KRB5INT_BEGIN_DECLS
-#endif
-#endif
-#if USE_APPLE_KRB5
-#define KERBEROS_APPLE_DEPRECATED(x)
-#endif
-#include <krb5.h>
+#include "compat/krb5.h"
int main(int argc, char *argv[])
{
krb5_context context;
}
]])
], [ squid_cv_memory_keytab=yes ], [ squid_cv_memory_keytab=no ], [:])
+ SQUID_STATE_ROLLBACK(squid_krb5_test)
])
])
dnl checks that krb5 is functional. Sets squid_cv_working_krb5
AC_DEFUN([SQUID_CHECK_WORKING_KRB5],[
AC_CACHE_CHECK([for working krb5], squid_cv_working_krb5, [
+ SQUID_STATE_SAVE(squid_krb5_test)
+ CPPFLAGS="-I${srcdir:-.} $CPPFLAGS"
AC_RUN_IFELSE([AC_LANG_SOURCE([[
-#if USE_APPLE_KRB5
-#define KERBEROS_APPLE_DEPRECATED(x)
-#endif
-#if HAVE_KRB5_H
-#if HAVE_BROKEN_SOLARIS_KRB5_H
-#if defined(__cplusplus)
-#define KRB5INT_BEGIN_DECLS extern "C" {
-#define KRB5INT_END_DECLS
-KRB5INT_BEGIN_DECLS
-#endif
-#endif
-#if HAVE_BROKEN_HEIMDAL_KRB5_H
-extern "C" {
-#include <krb5.h>
-}
-#else
-#include <krb5.h>
-#endif
-#endif
-
+#include "compat/krb5.h"
int
main(void)
{
return 0;
}
]])], [ squid_cv_working_krb5=yes ], [ squid_cv_working_krb5=no ],[:])])
+ SQUID_STATE_ROLLBACK(squid_krb5_test)
AS_IF([test "x$squid_cv_working_krb5" = "xno" -a `echo $LIBS | grep -i -c "(-)L"` -gt 0],[
AC_MSG_NOTICE([Check Runtime library path !])
])
AC_DEFINE(HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC,1,
[Define to 1 if you have krb5_get_init_creds_opt_alloc]),)
AC_MSG_CHECKING([for krb5_get_init_creds_free requires krb5_context])
+ SQUID_STATE_SAVE(squid_krb5_test)
+ CPPFLAGS="-I${srcdir:-.} $CPPFLAGS"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
- #if USE_APPLE_KRB5
- #define KERBEROS_APPLE_DEPRECATED(x)
- #endif
- #include <krb5.h>
+#include "compat/krb5.h"
]],[[krb5_context context;
krb5_get_init_creds_opt *options;
krb5_get_init_creds_opt_free(context, options)]])],[
[Define to 1 if you krb5_get_init_creds_free requires krb5_context])
AC_MSG_RESULT(yes)
],[AC_MSG_RESULT(no)],[AC_MSG_RESULT(no)])
+ SQUID_STATE_ROLLBACK(squid_krb5_test)
AC_CHECK_FUNCS(gss_map_name_to_any,
AC_DEFINE(HAVE_GSS_MAP_ANY_TO_ANY,1,
--- /dev/null
+/*
+ * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
+#ifndef SQUID_COMPAT_KRB5_H
+#define SQUID_COMPAT_KRB5_H
+
+/*
+ * The Kerberos library krb5.h header file has various major
+ * bugs in some implementations:
+ *
+ * - MacOS marks as deprecated the POSIX compatible APIs.
+ * Apparently to encourage code to use their internal APIs.
+ *
+ * - Heimdal may lack the extern "C" syntax for building in C++
+ *
+ * - Solaris incorrectly implements its own the extern "C" replacement
+ * macros and as a result krb5.h contains a trailing '}'.
+ * see http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6837512
+ *
+ * This file exists to fix those issues the best we can and to
+ * ensure the logic is identical in Squid code, Squid helpers,
+ * and autoconf tests. See acinclude/krb5.h for the latter.
+ */
+
+#if HAVE_KRB5_H
+# if USE_APPLE_KRB5
+# define KERBEROS_APPLE_DEPRECATED(x)
+# endif
+# if HAVE_BROKEN_HEIMDAL_KRB5_H && defined(__cplusplus)
+ extern "C" {
+# include <krb5.h>
+ }
+# elif HAVE_BROKEN_SOLARIS_KRB5_H && defined(__cplusplus)
+# define KRB5INT_BEGIN_DECLS extern "C" {
+# define KRB5INT_END_DECLS
+ extern "C" {
+# include <krb5.h>
+ /* broken Solaris krb5.h contains the closing } */
+# else
+# include <krb5.h>
+# endif
+#endif /* HAVE_KRB5_H */
+
+#endif /* _SQUID__COMPAT_KRB5_H */