File: gssapi.m4

package info (click to toggle)
dante 1.4.2+dfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 11,640 kB
  • sloc: ansic: 64,514; sh: 11,180; yacc: 3,127; lex: 1,683; makefile: 364; awk: 220
file content (276 lines) | stat: -rw-r--r-- 8,051 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
dnl gssapi.m4 -- find compiler and linker flags for GSSAPI
dnl Based on patch from Markus Moeller (markus_moeller at compuserve.com)

nogssDLIBDEPS=$DLIBDEPS
nogssSOCKDDEPS=$SOCKDDEPS
nogssCPPFLAGS=$CPPFLAGS
nogssLDFLAGS=$LDFLAGS
nogssCFLAGS=$CFLAGS
nogssLIBS=$LIBS

dnl default prefix for gssapi headers/libs
unset gssdir
unset krb5confpath

unset gssapi_default
case $host in
    #openbsd libthread is buggy; disable gssapi by default (needs pthreads)
    *-*-openbsd*)
	gssapi_default=no
	AC_DEFINE(HAVE_THREADS_EINTR_PROBLEMS, 1, [threads unstable platform])
	;;
esac

unset GSSAPI
AC_ARG_WITH(gssapi-path,
[  --with-gssapi-path=PATH specify gssapi path],
[if test -e "$withval"; then
     gssdir=$withval
     #act as if --with-gssapi is specified if path is given
     GSSAPI="yes"
 else
     AC_MSG_WARN([invalid gssapi-path: $withval])
 fi])

AC_ARG_WITH(gssapi,
[  --without-gssapi        disable gssapi support],
[GSSAPI=$withval],
[if test x"${gssapi_default}" = xno -a x"$GSSAPI" != xyes; then
     GSSAPI="no"
     AC_MSG_WARN([gssapi disabled by default on this platform])
 fi])

AC_ARG_WITH(krb5-config,
[  --with-krb5-config=PATH specify path to krb5-config @<:@default=detect@:>@],
[if test x"$withval" != xno; then
     krb5confpath=$withval
 fi])

if test x"$GSSAPI" != xno; then
   #attempt to create build environment based on prefix
   if test x"$gssdir" != x; then
      if test x"$krb5confpath" = x -a -x "$gssdir/bin/krb5-config"; then
            krb5confpath=$gssdir/bin/krb5-config
      fi
   else
      #set /usr as default gssdir
      case $host in
          *-*-aix*)
	      gssdir=/usr/krb5
	      ;;
	  *)
	      gssdir=/usr
	      ;;
      esac
   fi

   unset krb5fail
   if test x"$krb5confpath" != xno; then
       if test x"$krb5confpath" != x; then
           if ! test -x "$krb5confpath"; then
	       AC_MSG_WARN([krb5-config '$krb5confpath' not executable, ignoring])
           else
               ac_gssapi_cflags=`$krb5confpath --cflags gssapi 2>/dev/null`
	       if test $? != 0; then
		   krb5fail=t
	       fi
	       ac_gssapi_libs=`$krb5confpath --libs gssapi 2>/dev/null`
	       if test $? != 0; then
		   krb5fail=t
	       fi
           fi
       else
           AC_CHECK_PROG(ac_krb5_config, krb5-config, yes, no)
           if test x"${ac_krb5_config}" = xyes; then
	       ac_gssapi_cflags=`krb5-config --cflags gssapi 2>/dev/null`
	       if test $? != 0; then
		   krb5fail=t
	       fi
	       ac_gssapi_libs=`krb5-config --libs gssapi 2>/dev/null`
	       if test $? != 0; then
		   krb5fail=t
	       fi
           fi
       fi
   fi
   dnl working krb5-config?
   if test x"$krb5fail" = xt; then
       ac_gssapi_cflags=
       ac_gssapi_libs=
   fi

   dnl nothing from krb5-config, but gssdir specified?
   if test x"${ac_gssapi_cflags}" = x -a x"${ac_gssapi_libs}" = x -a \
           x"$gssdir" != x; then
       dnl attempt to construct environment manually
       case $host in
           *-*-aix*)
	       CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I/usr/include"
	       ;;
	   *)
	       CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$gssdir/include"
	       ;;
       esac

       LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$gssdir/lib"
       #includes under kerberosV dir on OpenBSD
       if test -d "$gssdir/include/kerberosV"; then
		  CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I${gssdir}/include/kerberosV"
       fi
   fi

   dnl any cflags values obtained from krb5-config?
   if test x"${ac_gssapi_cflags}" != x; then
       CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$ac_gssapi_cflags"
   fi

   dnl any libs obtained from krb5-config?
   if test x"${ac_gssapi_libs}" != x; then
       dnl add as dependency for sockd
       SOCKDDEPS="${SOCKDDEPS}${SOCKDDEPS:+ }$ac_gssapi_libs"

       #need to use -lpthread rather than -pthread for dlib because
       #the first will not cause -lpthread to be linked in
       #(and the application might not be linked with -lphread).
       #applications should use -pthread so keep this for SOCKDDEPS
       NDEPS=`echo $ac_gssapi_libs | sed -e 's/-pthread/-lpthread/g'`
       dnl add as dependency for libdsocks/libsocks
       DLIBDEPS="${DLIBDEPS}${DLIBDEPS:+ }$NDEPS"
   fi

   dnl look for gssapi headers
   AC_CHECK_HEADERS(gssapi.h gssapi/gssapi.h gssapi/gssapi_ext.h)
   dnl gssapi_krb5.h might depend on gssapi.h
   AC_CHECK_HEADERS([gssapi/gssapi_krb5.h], [], [], [
#if HAVE_GSSAPI_H
#include <gssapi.h>
#elif HAVE_GSSAPI_GSSAPI_H
#include <gssapi/gssapi.h>
#endif /* HAVE_GSSAPI_H */
])
   AC_CHECK_HEADERS(gssapi/gssapi_generic.h)

   dnl look for libs
   if test x"${ac_gssapi_libs}" != x; then
       _libsonly=`echo $ac_gssapi_libs | xargs -n1 | egrep '^-l' | xargs echo`
       _optsonly=`echo $ac_gssapi_libs | xargs -n1 | egrep -v '^-l' | xargs echo`
       LIBS="${LIBS}${LIBS:+ }${_libsonly}"
       LDFLAGS="${LDFLAGS}${LDFLAGS:+ }${_optsonly}"

       case $host in
	   *-*-freebsd7*)
	          #skip check, causes problems
	       ;;
	   *)
	       #wanted in case of Heimdal on FreeBSD, if the function
	       #is missing in libgssapi. not wanted if not needed for
	       #heimdal (potentially causes linking problems if
	       #multiple kerberos implementations are installed on a
	       #machine).
	       AC_SEARCH_LIBS([gsskrb5_register_acceptor_identity], [gssapi gssapi_krb5])
	       ;;
       esac
   else
       oLIBS=$LIBS
       LIBS=""

       #AC_CHECK_LIB(crypto, main) #XXX only very old mit kerberos
       AC_CHECK_LIB(des, main)
       AC_CHECK_LIB(crypt, main)
       AC_CHECK_LIB(roken, main)

       AC_CHECK_LIB(com_err, main)
       AC_CHECK_LIB(des425, main)
       AC_CHECK_LIB(k5crypto, main)

       AC_CHECK_LIB(pthread, main)

       AC_CHECK_LIB(asn1, main)
       AC_CHECK_LIB(krb5, main)
       AC_CHECK_LIB(gssapi_krb5, main)

       AC_CHECK_LIB(gssapi, main)

       AC_CHECK_LIB(gss, main)

       AC_CHECK_LIB(ksvc, main)

       dnl add as dependency for libdsocks
       if test x"${LIBS}" != x; then
	   DLIBDEPS="${DLIBDEPS}${DLIBDEPS:+ }$LIBS"
	   SOCKDDEPS="${SOCKDDEPS}${SOCKDDEPS:+ }$LIBS"
       fi
       LIBS="${oLIBS}${oLIBS:+ }$LIBS"
   fi

   unset have_heimdal
   AC_MSG_CHECKING([for heimdal])
   AC_TRY_LINK([#include "krb5.h"], [printf("%s\n", heimdal_version);],
   [AC_DEFINE(HAVE_HEIMDAL_KERBEROS, 1, [Heimdal kerberos implementation])
    AC_MSG_RESULT(yes)
    have_heimdal=t],
   [AC_MSG_RESULT(no)])

   dnl do compile check
   AC_MSG_CHECKING([for working gssapi])
   AC_TRY_RUN([
#if HAVE_GSSAPI_H
#include <gssapi.h>
#elif HAVE_GSSAPI_GSSAPI_H
#include <gssapi/gssapi.h>
#endif /* HAVE_GSSAPI_H */

#if !HAVE_HEIMDAL_KERBEROS
#if HAVE_GSSAPI_GSSAPI_EXT_H
#include <gssapi/gssapi_ext.h>
#endif /* HAVE_GSSAPI_GSSAPI_EXT_H */
#if HAVE_GSSAPI_GSSAPI_KRB5_H
#include <gssapi/gssapi_krb5.h>
#endif /* HAVE_GSSAPI_GSSAPI_KRB5_H */
#if HAVE_GSSAPI_GSSAPI_GENERIC_H
#include <gssapi/gssapi_generic.h>
#endif /* HAVE_GSSAPI_GSSAPI_GENERIC_H */
#endif /* HAVE_HEIMDAL_KERBEROS */

int
main(void)
{
    OM_uint32 val;
    gss_OID_set set;

    gss_create_empty_oid_set(&val, &set);

    return 0;
}
], [unset no_gssapi
    AC_MSG_RESULT(yes)],
   [AC_MSG_RESULT(no)],
   [dnl assume no when cross-compiling
    AC_MSG_RESULT(assuming no)])

   for file in gssapi.h gssapi/gssapi.h gssapi/gssapi_generic.h; do
       AC_EGREP_HEADER(gss_nt_service_name, [$file],
           break,
           [AC_EGREP_HEADER(gss_nt_service_name, $file,
                            GSS_C_NT_HOSTBASED_SERVICE,
		            [AC_DEFINE(gss_nt_service_name,
			     GSS_C_NT_HOSTBASED_SERVICE,
                             [gss_nt_service_name replacement])
                              break;])])
   done
fi

#restore build environment if not using gssapi
if test x"${no_gssapi}" = xt; then
    DLIBDEPS=$nogssDLIBDEPS
    SOCKDDEPS=$nogssSOCKDDEPS
    CPPFLAGS=$nogssCPPFLAGS
    LDFLAGS=$nogssLDFLAGS
    CFLAGS=$nogssCFLAGS
    LIBS=$nogssLIBS
else
    #include libs as dependencies as needed in subdirs
    LIBS="${LIBS}${LIBS:+ }$nogssLIBS"

    AC_DEFINE(HAVE_GSSAPI, 1, [GSSAPI support])
fi