1cf0d7a5f1058ec258b671b3cb69b07b7f0b24dd
[debian/amanda] / config / amanda / krb5-security.m4
1 # SYNOPSIS
2 #
3 #   AMANDA_KRB5_SECURITY
4 #
5 # OVERVIEW
6 #
7 #   Handle configuration for KRB5 security, implementing the --with-krb5-security
8 #   option.  If libraries are found, they are added to the relevant compiler flags.
9 #
10 #   Defines KRB5_SECURITY, and sets AM_CONDITIONAL WANT_KRB5_SECURITY,
11 #   if the user has selected this mechanism.  Also, the following parameters
12 #   are taken from options and defined:
13 #
14 #    - SERVER_HOST_PRINCIPAL
15 #    - SERVER_HOST_INSTANCE
16 #    - SERVER_HOST_KEY_FILE
17 #    - CLIENT_HOST_PRINCIPAL
18 #    - CLIENT_HOST_INSTANCE
19 #    - CLIENT_HOST_KEY_FILE
20 #    - TICKET_LIFETIME
21 #
22 AC_DEFUN([AMANDA_KRB5_SECURITY],
23 [
24     # Specify --with-krb5-security if Kerberos software is in somewhere
25     # other than the listed KRB5_SPOTS.  We only compile kerberos support in
26     # if the right files are there.
27
28     KRB5_SECURITY="no"
29     : ${KRB5_SPOTS="/usr/kerberos /usr/cygnus /usr /opt/kerberos"}
30
31     AC_ARG_WITH(krb5-security,
32         AS_HELP_STRING([--with-krb5-security=DIR],
33             [Location of Kerberos V software @<:@/usr/kerberos /usr/cygnus /usr /opt/kerberos@:>@]),
34         [
35             case "$withval" in
36                 n | no) KRB5_SECURITY=no ;;
37                 y | ye | yes) KRB5_SECURITY=yes ;;
38                 *) KRB5_SPOTS="$KRB5_SECURITY"
39                    KRB5_SECURITY=yes
40                    ;;
41             esac
42         ]
43     )
44
45     if test "x$KRB5_SECURITY" = "xyes"; then
46         # if found, force the static versions of these libs (.a) by linking directly
47         # with the .a files.  I don't know how to get -R dependancies checked
48         # in autoconf at this time. -kashmir
49         AC_MSG_CHECKING(for Kerberos V libraries)
50         KRB5_DIR_FOUND=""
51         for dir in $KRB5_SPOTS; do
52           for lib in lib lib64; do
53             k5libdir=${dir}/${lib}
54             if test \( -f ${k5libdir}/libkrb5.a -o -f ${k5libdir}/libkrb5.so \) -a \( -f ${k5libdir}/libgssapi_krb5.so -o -f ${k5libdir}/libgssapi_krb5.a \) -a \( -f ${k5libdir}/libcom_err.a -o -f ${k5libdir}/libcom_err.so \); then
55                 if test -f ${k5libdir}/libk5crypto.a -o -f ${k5libdir}/libk5crypto.so; then
56                     K5CRYPTO=-lk5crypto
57                 elif test -f ${k5libdir}/libcrypto.a -o -f ${k5libdir}/libcrypto.so; then
58                     K5CRYPTO=-lcrypto
59                 else
60                     K5CRYPTO=""
61                 fi
62                 if test -f ${k5libdir}/libkrb5support.a -o -f ${k5libdir}/libkrb5support.so; then
63                     K5SUPPORT=-lkrb5support
64                 else
65                     K5SUPPORT=""
66                 fi
67                 KRB5_DIR_FOUND=$dir
68                 KRB5_LIBDIR_FOUND=$k5libdir
69                 AMANDA_ADD_LIBS([-lgssapi_krb5 -lkrb5 $K5CRYPTO $K5SUPPORT -lcom_err])
70                 break
71             elif test \( -f ${k5libdir}/libkrb5.a -o -f ${k5libdir}/libkrb5.so \) -a \( -f ${k5libdir}/libasn1.a -o -f ${k5libdir}/libasn1.so \) -a \( -f ${k5libdir}/libgssapi.a -o -f ${k5libdir}/libgssapi.so \); then
72                 AMANDA_ADD_LIBS([-lgssapi -lkrb5 -lasn1])
73                 AMANDA_ADD_CPPFLAGS([-DKRB5_HEIMDAL_INCLUDES])
74                 break
75             fi
76           done
77         done
78
79         if test "$KRB5_DIR_FOUND"; then
80             AC_MSG_RESULT(found in $KRB5_DIR_FOUND)
81             #
82             # some OS's, such as NetBSD, stick krb5 includes out of the way...
83             # should probably just use autoconf to look for various include
84             # options and set them, but don't quite want to do that until I've
85             # dug into it a bit more.
86             #
87             if test -d "$KRB5_DIR_FOUND/krb5" ; then
88                 AMANDA_ADD_CPPFLAGS([-I$KRB5_DIR_FOUND/include/krb5])
89             else
90                 AMANDA_ADD_CPPFLAGS([-I$KRB5_DIR_FOUND/include])
91             fi
92                 AC_CHECK_LIB(krb5support,main)
93             AMANDA_ADD_LDFLAGS([-L$KRB5_LIBDIR_FOUND])
94
95             AC_DEFINE(KRB5_SECURITY,1,
96                 [Define if Kerberos 5 security is to be enabled. ])
97         else
98             AC_MSG_RESULT(no krb5 system libraries found)
99             AC_MSG_ERROR([No Kerberos V libraries were found on your system; krb5-security cannot be enabled])
100             KRB5_SECURITY="no"
101         fi
102     fi
103
104     AM_CONDITIONAL(WANT_KRB5_SECURITY, test x"$KRB5_SECURITY" = x"yes")
105 ])