1AC_INIT(Kerberos 5 applications)
2AC_CONFIG_SRCDIR(k5-platform.h)
3AC_CONFIG_HEADERS(autoconf.h)
4
5# Find the krb5 library installation.
6AC_ARG_WITH(krb5, [AS_HELP_STRING([--with-krb5=path],[where krb5 resides])])
7if test "$with_krb5" = no; then
8    AC_MSG_ERROR([This package requires krb5])
9elif test -z "$with_krb5" -o "$with_krb5" = yes; then
10    krb5_config=krb5-config
11elif test -x "$with_krb5/bin/krb5-config"; then
12    # Assume krb5 exec prefix specified.
13    krb5_config=$with_krb5/bin/krb5-config
14elif test -f "$with_krb5" -a -x "$with_krb5"; then
15    # Assume path to krb5-config specified.
16    krb5_config=$with_krb5
17fi
18if test -z "$krb5_config" || test -z "`$krb5_config --prefix`"; then
19  AC_MSG_ERROR([Specify -with-krb5= krb5 exec-prefix or path to krb5-config])
20fi
21KRB5_CFLAGS=`$krb5_config --cflags`
22KRB5_BASE_LIBS=`$krb5_config --libs krb5`
23GSS_LIBS=`$krb5_config --libs gssapi`
24KRB5_BINDIR=`$krb5_config --exec-prefix`/bin
25KRB5_SBINDIR=`$krb5_config --exec-prefix`/sbin
26AC_SUBST(KRB5_CFLAGS)
27AC_SUBST(KRB5_BASE_LIBS)
28AC_SUBST(GSS_LIBS)
29AC_SUBST(KRB5_BINDIR)
30AC_SUBST(KRB5_SBINDIR)
31
32AC_CANONICAL_HOST
33WITH_CC
34if test -z "$LD" ; then LD=$CC; fi
35AC_ARG_VAR(LD,[linker command [CC]])
36AC_SUBST(LDFLAGS)
37AC_C_CONST
38AC_ARG_PROGRAM
39AC_PROG_LN_S
40AC_PROG_RANLIB
41AC_PROG_ARCHIVE
42AC_PROG_ARCHIVE_ADD
43AC_PROG_INSTALL
44AC_PROG_YACC
45AC_CHECK_PROG(AR, ar, ar, false)
46AC_FUNC_FORK
47AC_TYPE_MODE_T
48AC_TYPE_SIGNAL
49AC_CHECK_TYPES([socklen_t, struct sockaddr_storage],,,
50[#include <sys/types.h>
51#include <sys/socket.h>
52])
53
54AC_PATH_PROG(UCB_RLOGIN,rlogin,/usr/ucb/rlogin)
55AC_PATH_PROG(UCB_RSH,rsh,/usr/ucb/rsh)
56AC_PATH_PROG(UCB_RCP,rcp,/usr/ucb/rcp)
57
58# Enables system protoypes for extended functions (such as asprintf)
59# on most Linux systems.
60AC_DEFINE(_GNU_SOURCE, 1, [Enable extended glibc prototypes])
61
62# We could rely on krb5-config to provide this, except that some of
63# the later tests (particularly those in KRB5_AC_INET6) rely on
64# -lsocket -lnsl being in LIBS on platforms which need them.  This is
65# a very simplified test, aimed mainly at Solaris, and may break on
66# some older or more obscure operating systems.
67AC_CHECK_FUNC(socket, [],
68  [AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", [], -lnsl)])
69
70AC_HEADER_STDARG
71AC_HEADER_TIME
72CHECK_DIRENT
73CHECK_SETJMP
74CHECK_SIGNALS
75CHECK_SIGPROCMASK
76CHECK_WAIT_TYPE
77DECLARE_SYS_ERRLIST
78KRB5_AC_MAINTAINER_MODE
79KRB5_AC_INET6
80KRB5_AC_LIBUTIL
81KRB5_SIGTYPE
82KRB5_GETSOCKNAME_ARGS
83
84AC_CHECK_HEADERS(curses.h lastlog.h libutil.h memory.h paths.h pty.h stdlib.h)
85AC_CHECK_HEADERS(string.h ttyent.h util.h sac.h unistd.h utmp.h utmpx.h)
86AC_CHECK_HEADERS(arpa/inet.h arpa/nameser.h)
87AC_CHECK_HEADERS(sys/filio.h sys/ioctl_compat.h sys/label.h sys/param.h)
88AC_CHECK_HEADERS(sys/ptyvar.h sys/select.h sys/sockio.h sys/stream.h)
89AC_CHECK_HEADERS(sys/time.h sys/tty.h sys/uio.h sys/utsname.h sys/wait.h)
90# On some systems, term.h requires curses.h inclusion
91AC_CHECK_HEADERS(term.h,,,
92[#ifdef HAVE_CURSES_H
93#include <curses.h>
94#endif
95])
96
97case $host in
98*-*-solaris*)
99    if test "$ac_cv_c_compiler_gnu" = yes; then
100        # Solaris 8 at least has curses.h that is noisy under gcc
101        ac_cv_header_curses_h=yes
102    fi
103    ;;
104esac
105
106AC_CHECK_FUNCS(_getpty cgetent getcwd getenv gethostbyname_r getservbyname_r)
107AC_CHECK_FUNCS(gettosbyname getusershell getutmp getutmpx grantpt inet_aton)
108AC_CHECK_FUNCS(initgroups isatty killpg killpg line_push ptsname revoke)
109AC_CHECK_FUNCS(rmufile rresvport_af seteuid setlogin setpgid setpriority)
110AC_CHECK_FUNCS(setresuid setreuid setutent setutsent setutxent strsave)
111AC_CHECK_FUNCS(tcgetpgrp tcsetpgrp ttyname unsetenv updwtmp updwtmpx utimes)
112AC_CHECK_FUNCS(utmpname utmpxname vasprintf vhangup waitpid)
113
114# Check for functions found in libutil.
115old_LIBS="$LIBS"
116LIBS="$UTIL_LIB $LIBS"
117AC_CHECK_FUNCS(logwtmp openpty)
118LIBS="$old_LIBS"
119
120# Determine which functions to define in libmissing.
121AC_REPLACE_FUNCS(daemon getdtablesize getopt herror parsetos setenv setsid)
122AC_REPLACE_FUNCS(strcasecmp strdup strerror strftime strlcpy asprintf)
123
124# Determine libraries for login and ftpd.
125LOGINLIBS=
126FTPD_LIBS=
127AC_ARG_WITH([afs],
128[  --without-afs        don't have afs libraries to build against (default)
129  --with-afs=AFSDIR    use preinstalled AFS library tree],
130,with_afs=no)
131if test $with_afs != no; then
132    AC_DEFINE(SETPAG,1,[Define if setpag should be used])
133    LOGINLIBS="$LOGINLIBS -L$with_afs/lib -L$with_afs/lib/afs"
134    LOGINLIBS="$LOGINLIBS -lauth -lsys -lrx -llwp"
135fi
136AC_CHECK_LIB(crypt,crypt,
137             [LOGINLIBS="$LOGINLIBS -lcrypt"
138              FTPD_LIBS="$FTPD_LIBS -lcrypt"])
139# AIX has all three of these; SCO might too.
140AC_CHECK_LIB(odm,main,
141    AC_CHECK_LIB(s,main,
142        AC_CHECK_LIB(cfg,main,
143        [LOGINLIBS="$LOGINLIBS -lodm -ls -lcfg"])))
144KRSHDLIBS="$LOGINLIBS"
145AC_SUBST(KRSHDLIBS)
146AC_SUBST(LOGINLIBS)
147AC_SUBST(FTPD_LIBS)
148
149# Determine libraries for telnet and telnetd.
150old_LIBS="$LIBS"
151AC_CHECK_LIB(termcap,main,
152             [AC_DEFINE(TERMCAP,1,[Define if termcap library is available])
153              LIBS="$LIBS -ltermcap"])
154AC_CHECK_LIB(curses,setupterm,LIBS="$LIBS -lcurses",
155             [AC_CHECK_LIB(ncurses,setupterm,LIBS="$LIBS -lncurses")])
156AC_CHECK_FUNCS(setupterm)
157TELNET_LIBS="$LIBS"
158TELNETD_LIBS="$LIBS"
159AC_SUBST(TELNET_LIBS)
160AC_SUBST(TELNETD_LIBS)
161AC_CHECK_FUNC(tgetent, ,
162              [AC_MSG_ERROR([Could not find tgetent; are you missing a curses/ncurses library?])])
163LIBS="$old_LIBS"
164
165# Make our operating system-specific security checks and definitions
166# for libpty, login, and ftpd.  The following code decides what
167# streams modules will be pushed onto a pty.  In particular, if
168# HAVE_STREAMS is defined and HAVE_LINE_PUSH is not defined, modules
169# may be pushed by inserting an appropriate generic ifdef for each
170# module in init_slave.c and AC_DEFINES for the operating systems that
171# need the modules.  Each OS that supports streams has a different
172# idea of what you want to push.
173case $host in
174*-*-ultrix*)
175    echo "Disabling initial vhangup and setsid because they break under Ultrix"
176    AC_DEFINE([OPEN_CTTY_ONLY_ONCE],[1],
177              [Define on Ultrix where an initial vhangup breaks])
178    ac_cv_func_setsid=no # setsid doesn't do the right thing under Ultrix
179    ;;
180*-*-aix3*)
181    # AIX has streams include files but not streams TTY
182    # Moreover, strops.h trashes sys/ioctl.h
183    krb5_cv_has_streams=no
184    ;;
185alpha*-dec-osf*)
186    AC_MSG_RESULT(will open ctty prior to revoke due to OSF/1 lossage)
187    AC_DEFINE(REVOKE_NEEDS_OPEN,1,
188              [Define if ctty needs to be opened before revoke as on OSF/1])
189    AC_CHECK_LIB(security,setluid,
190                 AC_DEFINE(HAVE_SETLUID,1,
191                 [Define if setluid is supplied by the OSF/1 security library])
192                 LOGINLIBS="$LOGINLIBS -lsecurity"
193                 FTPD_LIBS="$FTPD_LIBS -lsecurity")
194    ;;
195*-*-solaris*)
196    AC_DEFINE(PUSH_PTEM,1,[push ptem?])
197    AC_DEFINE(PUSH_LDTERM,1,[push ldterm?])
198    AC_DEFINE(PUSH_TTCOMPAT,1,[push ttcompat?])
199    ;;
200*-*-hpux*|*-*-linux*|*-*-irix*)
201    krb5_cv_has_streams=no
202    ;;
203esac
204
205AC_MSG_CHECKING([streams interface])
206AC_CACHE_VAL(krb5_cv_has_streams,
207[AC_TRY_COMPILE(
208[#include <sys/stream.h>
209#include <sys/stropts.h>], [],
210krb5_cv_has_streams=yes, krb5_cv_has_streams=no)])
211AC_MSG_RESULT($krb5_cv_has_streams)
212if test $krb5_cv_has_streams = yes; then
213AC_DEFINE(HAVE_STREAMS,1,[Define if have streams])
214fi
215
216# telnet checks for STREAMSPTY to indicate streams and grantpt.
217if test "$krb5_cv_has_streams" = yes -a "$ac_cv_func_grantpt" = yes; then
218    AC_DEFINE(STREAMSPTY,1,[Define if streams pty interface should be used])
219fi
220
221# ----- utmp stuff -----
222
223AC_CHECK_MEMBERS([struct utmp.ut_host, struct utmp.ut_syslen, struct utmp.ut_addr, struct utmp.ut_id, struct utmp.ut_pid, struct utmp.ut_type, struct utmp.ut_exit],,,
224[#include <sys/types.h>
225#include <utmp.h>])
226
227AC_CHECK_MEMBERS([struct utmpx.ut_host, struct utmpx.ut_syslen, struct utmpx.ut_addr, struct utmpx.ut_id, struct utmpx.ut_pid, struct utmpx.ut_type, struct utmpx.ut_exit],,,
228[#include <sys/types.h>
229#include <utmpx.h>])
230
231AC_DEFUN(K5_CHECK_UT_EXIT_MEMBER,
232[AC_MSG_CHECKING([for ut_exit.$2 in struct $1])
233AC_CACHE_VAL([krb5_cv_struct_$1_ut_exit_$2],
234[AC_TRY_COMPILE([#include <sys/types.h>
235#include <$1.h>], [struct $1 u; u.ut_exit.$2;],
236eval "krb5_cv_struct_$1_ut_exit_$2=yes",
237eval "krb5_cv_struct_$1_ut_exit_$2=no")])
238if eval "test \"`echo '$krb5_cv_struct_'$1'_ut_exit_'$2`\" = yes"; then
239  AC_MSG_RESULT(yes)
240  ifelse([$3], , :, [$3])
241else
242  AC_MSG_RESULT(no)
243  ifelse([$4], , :, [$4])
244fi])
245
246if test "$ac_cv_member_struct_utmp_ut_exit" = yes; then
247  AC_MSG_RESULT(checking for working ut_exit.e_exit in struct utmp)
248  for krb5_mem in __e_exit ut_e_exit ut_exit e_exit; do
249    K5_CHECK_UT_EXIT_MEMBER(utmp, $krb5_mem,
250[krb5_utmp_e_exit=$krb5_mem
251krb5_utmp_e_termination=`echo $krb5_mem|sed -e 's%_exit$%_termination%'`], )
252  done
253  if test "${krb5_utmp_e_exit+set}" = set; then
254    AC_MSG_RESULT([working ut_exit.e_exit in utmp is $krb5_utmp_e_exit])
255    AC_DEFINE_UNQUOTED(PTY_UTMP_E_EXIT, $krb5_utmp_e_exit,[Define to utmp exit field name])
256    AC_DEFINE_UNQUOTED(PTY_UTMP_E_TERMINATION, $krb5_utmp_e_termination,[Define to utmp termination field name])
257  else
258    AC_MSG_RESULT([cannot find working ut_exit.e_exit in utmp])
259  fi
260fi
261
262if test "$ac_cv_member_struct_utmpx_ut_exit" = yes; then
263  AC_MSG_RESULT(checking for working ut_exit.e_exit in struct utmpx)
264  for krb5_mem in __e_exit ut_e_exit ut_exit e_exit; do
265    K5_CHECK_UT_EXIT_MEMBER(utmpx, $krb5_mem,
266[krb5_utmpx_e_exit=$krb5_mem
267krb5_utmpx_e_termination=`echo $krb5_mem|sed -e 's%_exit$%_termination%'`], )
268  done
269  if test "${krb5_utmpx_e_exit+set}" = set; then
270    AC_MSG_RESULT([working ut_exit.e_exit in utmpx is $krb5_utmpx_e_exit])
271    AC_DEFINE_UNQUOTED(PTY_UTMPX_E_EXIT, $krb5_utmpx_e_exit,[Define to utmpx exit field name])
272    AC_DEFINE_UNQUOTED(PTY_UTMPX_E_TERMINATION, $krb5_utmpx_e_termination,[Define to utmpx termination field name])
273  else
274    AC_MSG_RESULT([cannot find working ut_exit.e_exit in utmpx])
275  fi
276fi
277
278if test "$ac_cv_header_utmpx_h" = yes; then
279  AC_MSG_CHECKING(consistency of utmpx API)
280  if test "$ac_cv_func_setutxent" = yes; then
281    if test "$ac_cv_member_struct_utmpx_ut_id" = yes \
282      && test "$ac_cv_member_struct_utmpx_ut_type" = yes \
283      && test "$ac_cv_member_struct_utmpx_ut_pid" = yes; then
284      AC_MSG_RESULT(ok)
285    else
286      AC_MSG_RESULT(not ok)
287      AC_MSG_ERROR([have setutxent but no ut_id, ut_type, or ut_pid in utmpx])
288    fi
289  else
290    AC_MSG_RESULT(not ok)
291    AC_MSG_ERROR([have utmpx.h but no setutxent])
292  fi
293fi
294
295if test "$ac_cv_func_setutent" = yes && \
296  test "$ac_cv_header_utmpx_h" = no; then
297  AC_MSG_CHECKING(consistency of sysV-ish utmp API)
298  if test "$ac_cv_header_utmp_h" = yes; then
299    if test "$ac_cv_member_struct_utmp_ut_id" = yes \
300      && test "$ac_cv_member_struct_utmp_ut_type" = yes \
301      && test "$ac_cv_member_struct_utmp_ut_pid" = yes; then
302      AC_MSG_RESULT(ok)
303    else
304      AC_MSG_RESULT(not ok)
305      AC_MSG_ERROR([have setutent but no ut_id, ut_type, or ut_pid in utmp])
306    fi
307  else
308    AC_MSG_RESULT(not ok)
309    AC_MSG_ERROR([have setutent but no utmp.h])
310  fi
311fi
312
313# ----- End of utmp stuff -----
314
315AC_MSG_CHECKING([arguments to getpgrp])
316AC_CACHE_VAL(krb5_cv_getpgrp_args,
317[AC_TRY_COMPILE(
318[#ifndef __STDC__
319#define __STDC__ 1
320#endif
321#include <unistd.h>
322#include <sys/types.h>], [pid_t pid = getpgrp(getpid())],
323krb5_cv_getpgrp_args=pid, krb5_cv_getpgrp_args=void)])
324AC_MSG_RESULT($krb5_cv_getpgrp_args)
325if test $krb5_cv_getpgrp_args = pid; then
326AC_DEFINE(GETPGRP_ONEARG,1,[Define if getpgrp takes one arg])
327fi
328
329AC_MSG_CHECKING([if setpgrp takes two arguments])
330AC_CACHE_VAL(krb5_cv_sys_setpgrp_two,
331[AC_TRY_COMPILE(
332[#include <unistd.h>],[setpgrp(0,0)],
333krb5_cv_sys_setpgrp_two=yes,krb5_cv_sys_setpgrp_two=no)])
334AC_MSG_RESULT($krb5_cv_sys_setpgrp_two)
335if test $krb5_cv_sys_setpgrp_two = yes; then
336  AC_DEFINE(SETPGRP_TWOARG,1,[Define if setpgrp takes two arguments])
337fi
338
339AC_MSG_CHECKING([F_SETOWN])
340AC_CACHE_VAL(krb5_cv_f_setown,
341[AC_TRY_COMPILE(
342[#include <sys/types.h>
343#include <fcntl.h>], [1+F_SETOWN;],
344krb5_cv_f_setown=yes,krb5_cv_f_setown=no)])
345AC_MSG_RESULT($krb5_cv_f_setown)
346if test $krb5_cv_f_setown = yes; then
347AC_DEFINE(HAVE_SETOWN,1,[Define if F_SETOWN is available])
348fi
349
350AC_MSG_CHECKING([shadow password support])
351AC_CACHE_VAL(krb5_cv_shadow_pwd,
352[AC_TRY_LINK(
353[#include <sys/types.h>
354#include <pwd.h>
355#include <shadow.h>],
356[struct spwd *sp = getspnam("root")],
357krb5_cv_shadow_pwd=yes, krb5_cv_shadow_pwd=no)])
358AC_MSG_RESULT($krb5_cv_shadow_pwd)
359if test $krb5_cv_shadow_pwd = yes; then
360AC_DEFINE(HAVE_SHADOW,1,[Define if shadow password interface is available])
361fi
362AC_CHECK_FILES(/etc/environment /etc/TIMEZONE)
363
364# bsd and libpty check POSIX_TERMIOS; telnet checks USE_TERMIO.
365AC_CHECK_HEADER(termios.h,
366    [AC_CHECK_FUNC(cfsetispeed,
367        [AC_DEFINE(POSIX_TERMIOS,1,[Define for POSIX termios interface])
368         AC_DEFINE(USE_TERMIO,1,[Define if termio should be used])
369         ac_termio=1])])
370if test -z "$ac_termio"; then
371    AC_CHECK_HEADER(termio.h,
372                    [AC_DEFINE(SYSV_TERMIO,1,
373                               [Define if SysV termio interface is found])
374                     ac_sysv_termio=1])
375    if test -n "$ac_sysv_termio"; then
376        AC_MSG_CHECKING([for cc_t in termio.h])
377        AC_CACHE_VAL(krb_cv_type_cc_t,
378                     [AC_TRY_LINK([cc_t],[#include <termio.h>],[cc_t foo;],
379                                  [krb_cv_type_cc_t=yes],
380                                  [krb_cv_type_cc_t=no])])
381        AC_MSG_RESULT($krb_cv_type_cc_t)
382        if test $krb_cv_type_cc_t = no; then
383            AC_DEFINE(NO_CC_T,1,[Define if termio.h does not define type cc_t])
384        fi
385    fi
386fi
387
388AC_CACHE_CHECK([if speed_t is defined], krb5_cv_type_speed_t,
389[AC_TRY_COMPILE(dnl
390[#include <sys/types.h>
391#if STDC_HEADERS
392#include <stdlib.h>
393#include <stddef.h>
394#endif
395#ifndef	USE_TERMIO
396#include <sgtty.h>
397#else
398# ifdef	SYSV_TERMIO
399# include <termio.h>
400# else
401# include <termios.h>
402# endif
403#endif
404],[speed_t termspeed],krb5_cv_type_speed_t=yes, krb5_cv_type_speed_t=no)])
405if test $krb5_cv_type_speed_t = no; then
406   AC_DEFINE(speed_t, int,
407             [Define if system termios interface doesn't define speed_t])
408fi
409
410# For dejagnu tests
411AC_CHECK_PROG(RUNTEST,runtest,runtest)
412if test x"$RUNTEST" != x; then
413    HAVE_RUNTEST=yes
414else
415    HAVE_RUNTEST=no
416fi
417AC_SUBST(HAVE_RUNTEST)
418
419V5_AC_OUTPUT_MAKEFILE(. bsd libmissing libpty
420                      gssftp gssftp/ftp gssftp/ftpd
421                      telnet telnet/libtelnet telnet/telnet telnet/telnetd
422                      tests tests/resolve)
423