kerberos.m4 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. # BEGIN COPYRIGHT BLOCK
  2. # Copyright (C) 2008 Red Hat, Inc.
  3. # All rights reserved.
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; either version 2
  8. # of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. #
  19. # END COPYRIGHT BLOCK
  20. # -*- tab-width: 4; -*-
  21. # Configure paths for Kerberos
  22. dnl ========================================================
  23. dnl = Kerberos is used directly for server to server SASL/GSSAPI
  24. dnl = authentication (replication, chaining, etc.)
  25. dnl = This allows us to authenticate using a keytab without
  26. dnl = having to call kinit outside the process
  27. dnl ========================================================
  28. AC_CHECKING(for kerberos)
  29. if test -z "$with_kerberos" ; then
  30. with_kerberos=yes # if not set on cmdline, set default
  31. fi
  32. AC_MSG_CHECKING(for --with-kerberos)
  33. AC_ARG_WITH(kerberos,
  34. AS_HELP_STRING([--with-kerberos[=PATH]], [Use the kerberos API in the server directly - allows the server to authenticate directly with a keytab - otherwise, SASL/GSSAPI auth depends on underlying SASL libraries and external kinit with a keytab - if PATH is not specified, look for kerberos in the system locations. This will attempt to use krb5-config from the PATH to find the libs and include dirs - you can specify KRB5_CONFIG_BIN to specify a different filename or absolute path. If krb5-config does not work, this will attempt to look in various system directories]),
  35. [
  36. if test "x$withval" = "xyes"; then
  37. AC_MSG_RESULT(yes)
  38. elif test "x$withval" = "xno"; then
  39. AC_MSG_RESULT(no)
  40. with_kerberos=
  41. elif test -d "$withval" -a -d "$withval/lib" -a -d "$withval/include" ; then
  42. AC_MSG_RESULT([using $withval])
  43. kerberos_incdir="$withval/include"
  44. kerberos_libdir="$withval/lib"
  45. else
  46. AC_MSG_RESULT(yes)
  47. AC_MSG_ERROR([kerberos not found in $withval])
  48. fi
  49. ],
  50. [
  51. AC_MSG_RESULT(no)
  52. with_kerberos=
  53. ]
  54. )
  55. AC_MSG_CHECKING(for --with-kerberos-inc)
  56. AC_ARG_WITH(kerberos-inc,
  57. AS_HELP_STRING([--with-kerberos-inc=PATH], [Allows you to explicitly set the directory containing the kerberos include files - implies use of kerberos]),
  58. [
  59. if test -f "$withval"/krb5.h; then
  60. AC_MSG_RESULT([using $withval])
  61. kerberos_incdir="$withval"
  62. with_kerberos=yes # implies use of kerberos
  63. else
  64. echo
  65. AC_MSG_ERROR([$withval/krb5.h not found])
  66. fi
  67. ],
  68. AC_MSG_RESULT(no)
  69. )
  70. AC_MSG_CHECKING(for --with-kerberos-lib)
  71. AC_ARG_WITH(kerberos-lib,
  72. AS_HELP_STRING([--with-kerberos-lib=PATH], [Allows you to explicitly set the directory containing the kerberos libraries - implies use of kerberos]),
  73. [
  74. if test -d "$withval"; then
  75. AC_MSG_RESULT([using $withval])
  76. kerberos_libdir="$withval"
  77. with_kerberos=yes # implies use of kerberos
  78. else
  79. echo
  80. AC_MSG_ERROR([$withval not found])
  81. fi
  82. ],
  83. AC_MSG_RESULT(no)
  84. )
  85. if test -n "$with_kerberos" ; then
  86. if test -z "$kerberos_incdir" -o -z "$kerberos_libdir" ; then
  87. dnl look for these using the krb5-config script
  88. dnl user can define KRB5_CONFIG_BIN to the full path
  89. dnl and filename of the script if it cannot or will not
  90. dnl be found in PATH
  91. if test -z "$KRB5_CONFIG_BIN" ; then
  92. AC_PATH_PROG(KRB5_CONFIG_BIN, krb5-config)
  93. fi
  94. if test -n "$KRB5_CONFIG_BIN" ; then
  95. AC_MSG_CHECKING(for kerberos with $KRB5_CONFIG_BIN)
  96. if test -z "$kerberos_libdir" ; then
  97. kerberos_lib=`$KRB5_CONFIG_BIN --libs krb5`
  98. fi
  99. if test -z "$kerberos_incdir" ; then
  100. kerberos_inc=`$KRB5_CONFIG_BIN --cflags krb5`
  101. fi
  102. dnl if using system includes, inc will be empty - ok
  103. if test -n "$kerberos_lib" ; then
  104. AC_MSG_RESULT([using kerberos found with $KRB5_CONFIG_BIN])
  105. have_krb5=yes
  106. fi
  107. fi
  108. fi
  109. fi
  110. if test -n "$with_kerberos" -a -z "$kerberos_lib" ; then
  111. # save these in order to set them to use the check macros below
  112. # like AC_CHECK_HEADERS, AC_CHECK_LIB, and AC_CHECK_FUNCS
  113. save_CPPFLAGS="$CPPFLAGS"
  114. if test -n "$kerberos_incdir" ; then
  115. CPPFLAGS="-I$kerberos_incdir $CPPFLAGS"
  116. fi
  117. save_LDFLAGS="$LDFLAGS"
  118. if test -n "$kerberos_libdir" ; then
  119. LDFLAGS="-L$kerberos_libdir $LDFLAGS"
  120. fi
  121. krb5_impl=mit
  122. dnl check for Heimdal Kerberos
  123. AC_CHECK_HEADERS(heim_err.h)
  124. if test $ac_cv_header_heim_err_h = yes ; then
  125. krb5_impl=heimdal
  126. fi
  127. if test "x$krb5_impl" = "xmit"; then
  128. AC_CHECK_LIB(k5crypto, main,
  129. [krb5crypto=k5crypto],
  130. [krb5crypto=crypto])
  131. AC_CHECK_LIB(krb5, main,
  132. [have_krb5=yes
  133. kerberos_lib="-lkrb5 -l$krb5crypto -lcom_err"],
  134. [have_krb5=no],
  135. [-l$krb5crypto -lcom_err])
  136. elif test "x$krb5_impl" = "xheimdal"; then
  137. AC_CHECK_LIB(des, main,
  138. [krb5crypto=des],
  139. [krb5crypto=crypto])
  140. AC_CHECK_LIB(krb5, main,
  141. [have_krb5=yes
  142. kerberos_lib="-lkrb5 -l$krb5crypto -lasn1 -lroken -lcom_err"],
  143. [have_krb5=no],
  144. [-l$krb5crypto -lasn1 -lroken -lcom_err])
  145. AC_DEFINE(HAVE_HEIMDAL_KERBEROS, 1,
  146. [define if you have HEIMDAL Kerberos])
  147. else
  148. have_krb5=no
  149. AC_MSG_WARN([Unrecognized Kerberos5 Implementation])
  150. fi
  151. # reset to original values
  152. CPPFLAGS="$save_CPPFLAGS"
  153. LDFLAGS="$save_LDFLAGS"
  154. if test -n "$kerberos_incdir" ; then
  155. kerberos_inc="-I$kerberos_incdir"
  156. fi
  157. if test -n "$kerberos_libdir" ; then
  158. kerberos_lib="-L$kerberos_libdir $kerberos_lib"
  159. fi
  160. fi
  161. dnl at this point kerberos_lib and kerberos_inc should be set
  162. if test -n "$with_kerberos" ; then
  163. if test "x$have_krb5" = "xyes" ; then
  164. AC_DEFINE(HAVE_KRB5, 1,
  165. [define if you have Kerberos V])
  166. else
  167. AC_MSG_ERROR([Required Kerberos 5 support not available])
  168. fi
  169. dnl look for the wonderfully time saving function krb5_cc_new_unique
  170. save_LIBS="$LIBS"
  171. LIBS="$kerberos_lib"
  172. save_CPPFLAGS="$CPPFLAGS"
  173. CPPFLAGS="$kerberos_inc $CPPFLAGS"
  174. AC_CHECK_FUNCS([krb5_cc_new_unique])
  175. LIBS="$save_LIBS"
  176. CPPFLAGS="$save_CPPFLAGS"
  177. fi
  178. AC_SUBST(kerberos_inc)
  179. AC_SUBST(kerberos_lib)
  180. AC_SUBST(kerberos_libdir)