kerberos.m4 6.3 KB

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