| 1 |
dnl |
| 2 |
dnl Copyright (C) 1996-2026 Free Software Foundation, Inc. |
| 3 |
dnl |
| 4 |
dnl This file is part of GNU Inetutils. |
| 5 |
dnl |
| 6 |
dnl GNU Inetutils is free software: you can redistribute it and/or modify |
| 7 |
dnl it under the terms of the GNU General Public License as published by |
| 8 |
dnl the Free Software Foundation, either version 3 of the License, or (at |
| 9 |
dnl your option) any later version. |
| 10 |
dnl |
| 11 |
dnl GNU Inetutils is distributed in the hope that it will be useful, but |
| 12 |
dnl WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 |
dnl General Public License for more details. |
| 15 |
dnl |
| 16 |
dnl You should have received a copy of the GNU General Public License |
| 17 |
dnl along with this program. If not, see `http://www.gnu.org/licenses/'. |
| 18 |
|
| 19 |
dnl Written by Miles Bader. |
| 20 |
|
| 21 |
dnl IU_CHECK_KRB5(VERSION,PREFIX) |
| 22 |
dnl Search for a Kerberos implementation in the standard locations |
| 23 |
dnl plus PREFIX, if it is set and is not "yes". |
| 24 |
dnl VERSION should be either 4 or 5. |
| 25 |
dnl |
| 26 |
dnl Defines KRB5_CFLAGS and KRB5_LIBS if found. |
| 27 |
dnl Defines KRB5_IMPL to "krb5-config", "Heimdal", "MIT", |
| 28 |
dnl "OpenBSD-Heimdal", or "OldMIT", if found, and to "none" |
| 29 |
dnl otherwise. |
| 30 |
|
| 31 |
AC_DEFUN([IU_CHECK_KRB5], |
| 32 |
[ |
| 33 |
if test "x$iu_cv_lib_krb5_libs" = x; then |
| 34 |
cache="" |
| 35 |
## Make sure we have res_query |
| 36 |
AC_SEARCH_LIBS([res_query], [resolv]) |
| 37 |
KRB5_PREFIX=[$2] |
| 38 |
KRB5_IMPL="none" |
| 39 |
# First try krb5-config |
| 40 |
if test "$KRB5_PREFIX" != "yes"; then |
| 41 |
krb5_path="$KRB5_PREFIX/bin" |
| 42 |
else |
| 43 |
krb5_path="$PATH" |
| 44 |
fi |
| 45 |
AC_PATH_PROG(KRB5CFGPATH, krb5-config, none, $krb5_path) |
| 46 |
if test "$KRB5CFGPATH" != "none"; then |
| 47 |
KRB5_CFLAGS="$CPPFLAGS `$KRB5CFGPATH --cflags krb$1`" |
| 48 |
KRB5_LIBS="$LDFLAGS `$KRB5CFGPATH --libs krb$1`" |
| 49 |
KRB5_IMPL="krb5-config" |
| 50 |
else |
| 51 |
## OK, try the old code |
| 52 |
saved_CPPFLAGS="$CPPFLAGS" |
| 53 |
saved_LDFLAGS="$LDFLAGS" |
| 54 |
saved_LIBS="$LIBS" |
| 55 |
if test "$KRB5_PREFIX" != "yes"; then |
| 56 |
KRB5_CFLAGS="-I$KRB5_PREFIX/include" |
| 57 |
KRB5_LDFLAGS="-L$KRB5_PREFIX/lib" |
| 58 |
LDFLAGS="$LDFLAGS $KRB5_LDFLAGS" |
| 59 |
else |
| 60 |
## A very common location in recent times. |
| 61 |
KRB5_CFLAGS="-I/usr/include/krb5" |
| 62 |
fi |
| 63 |
CPPFLAGS="$CPPFLAGS $KRB5_CFLAGS" |
| 64 |
KRB4_LIBS="-lkrb4 -ldes425" |
| 65 |
|
| 66 |
## Check for new MIT kerberos V support |
| 67 |
LIBS="$saved_LIBS -lkrb5 -lk5crypto -lcom_err" |
| 68 |
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[return krb5_init_context((void *) 0); ]])],[KRB5_IMPL="MIT" |
| 69 |
KRB5_LIBS="$KRB5_LDFLAGS -lkrb5 -lk5crypto -lcom_err"],[]) |
| 70 |
|
| 71 |
## Heimdal kerberos V support |
| 72 |
if test "$KRB5_IMPL" = "none"; then |
| 73 |
LIBS="$saved_LIBS -lkrb5 -ldes -lasn1 -lroken -lcrypt -lcom_err" |
| 74 |
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[return krb5_init_context((void *) 0); ]])],[KRB5_IMPL="Heimdal" |
| 75 |
KRB5_LIBS="$KRB5_LDFLAGS -lkrb5 -ldes -lasn1 -lroken -lcrypt -lcom_err" |
| 76 |
],[]) |
| 77 |
fi |
| 78 |
|
| 79 |
### FIXME: Implement a robust distinction between |
| 80 |
### Heimdal a la OpenBSD and Old MIT Kerberos V. |
| 81 |
### Presently the first will catch all, since it |
| 82 |
### is readily available on contemporary systems. |
| 83 |
|
| 84 |
## OpenBSD variant of Heimdal |
| 85 |
if test "$KRB5_IMPL" = "none"; then |
| 86 |
LIBS="$saved_LIBS -lkrb5 -lcrypto" |
| 87 |
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[return krb5_init_context((void *) 0); ]])],[KRB5_IMPL="OpenBSD-Heimdal" |
| 88 |
KRB5_CFLAGS="-I/usr/include/kerberosV" |
| 89 |
KRB5_LIBS="$KRB5_LDFLAGS -lkrb5 -lcrypto -lasn1 -ldes"],[]) |
| 90 |
fi |
| 91 |
|
| 92 |
## Old MIT Kerberos V |
| 93 |
## Note: older krb5 distributions use -lcrypto instead of |
| 94 |
## -lk5crypto. This may conflict with OpenSSL. |
| 95 |
if test "$KRB5_IMPL" = "none"; then |
| 96 |
LIBS="$saved_LIBS -lkrb5 -lcrypto -lcom_err" |
| 97 |
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[return krb5_init_context((void *) 0); ]])],[KRB5_IMPL="OldMIT" |
| 98 |
KRB5_LIBS="$KRB5_LDFLAGS $KRB4_LIBS -lkrb5 -lcrypto -lcom_err"],[]) |
| 99 |
fi |
| 100 |
|
| 101 |
LDFLAGS="$saved_LDFLAGS" |
| 102 |
LIBS="$saved_LIBS" |
| 103 |
fi |
| 104 |
|
| 105 |
iu_cv_lib_krb5_cflags="$KRB5_CFLAGS" |
| 106 |
iu_cv_lib_krb5_libs="$KRB5_LIBS" |
| 107 |
iu_cv_lib_krb5_impl="$KRB5_IMPL" |
| 108 |
else |
| 109 |
cached=" (cached) " |
| 110 |
KRB5_CFLAGS="$iu_cv_lib_krb5_cflags" |
| 111 |
KRB5_LIBS="$iu_cv_lib_krb5_libs" |
| 112 |
KRB5_IMPL="$iu_cv_lib_krb5_impl" |
| 113 |
fi |
| 114 |
AC_MSG_CHECKING(krb5 implementation) |
| 115 |
AC_MSG_RESULT(${cached}$KRB5_IMPL) |
| 116 |
]) |