]> andersk Git - gssapi-openssh.git/blob - openssh/configure.ac
-lkrbafs needs -lkrb4 (in --wiith-afs-krb5 configuration)
[gssapi-openssh.git] / openssh / configure.ac
1 # $Id$
2
3 AC_INIT
4 AC_CONFIG_SRCDIR([ssh.c])
5
6 AC_CONFIG_HEADER(config.h)
7 AC_PROG_CC
8 AC_CANONICAL_HOST
9 AC_C_BIGENDIAN
10
11 # Checks for programs.
12 AC_PROG_AWK
13 AC_PROG_CPP
14 AC_PROG_RANLIB
15 AC_PROG_INSTALL
16 AC_PATH_PROG(AR, ar)
17 AC_PATH_PROGS(PERL, perl5 perl)
18 AC_PATH_PROG(SED, sed)
19 AC_SUBST(PERL)
20 AC_PATH_PROG(ENT, ent)
21 AC_SUBST(ENT)
22 AC_PATH_PROG(TEST_MINUS_S_SH, bash)
23 AC_PATH_PROG(TEST_MINUS_S_SH, ksh)
24 AC_PATH_PROG(TEST_MINUS_S_SH, sh)
25 AC_PATH_PROG(SH, sh)
26
27 # System features
28 AC_SYS_LARGEFILE
29
30 if test -z "$AR" ; then
31         AC_MSG_ERROR([*** 'ar' missing, please install or fix your \$PATH ***])
32 fi
33
34 # Use LOGIN_PROGRAM from environment if possible
35 if test ! -z "$LOGIN_PROGRAM" ; then
36         AC_DEFINE_UNQUOTED(LOGIN_PROGRAM_FALLBACK, "$LOGIN_PROGRAM")
37 else
38         # Search for login
39         AC_PATH_PROG(LOGIN_PROGRAM_FALLBACK, login)
40         if test ! -z "$LOGIN_PROGRAM_FALLBACK" ; then
41                 AC_DEFINE_UNQUOTED(LOGIN_PROGRAM_FALLBACK, "$LOGIN_PROGRAM_FALLBACK")
42         fi
43 fi
44
45 AC_PATH_PROG(PATH_PASSWD_PROG, passwd)
46 if test ! -z "$PATH_PASSWD_PROG" ; then
47         AC_DEFINE_UNQUOTED(_PATH_PASSWD_PROG, "$PATH_PASSWD_PROG")
48 fi
49
50 if test -z "$LD" ; then
51         LD=$CC
52 fi
53 AC_SUBST(LD)
54         
55 AC_C_INLINE
56 if test "$GCC" = "yes" || test "$GCC" = "egcs"; then
57         CFLAGS="$CFLAGS -Wall -Wpointer-arith -Wno-uninitialized"
58 fi
59
60 AC_ARG_WITH(rpath,
61         [  --without-rpath         Disable auto-added -R linker paths],
62         [
63                 if test "x$withval" = "xno" ; then      
64                         need_dash_r=""
65                 fi
66                 if test "x$withval" = "xyes" ; then
67                         need_dash_r=1
68                 fi
69         ]
70 )
71
72 # Check for some target-specific stuff
73 case "$host" in
74 *-*-aix*)
75         AC_MSG_CHECKING([how to specify blibpath for linker ($LD)])
76         if (test -z "$blibpath"); then
77                 blibpath="/usr/lib:/lib"
78         fi
79         saved_LDFLAGS="$LDFLAGS"
80         for tryflags in -blibpath: -Wl,-blibpath: -Wl,-rpath, ;do
81                 if (test -z "$blibflags"); then
82                         LDFLAGS="$saved_LDFLAGS $tryflags$blibpath"
83                         AC_TRY_LINK([], [], [blibflags=$tryflags])
84                 fi
85         done
86         if (test -z "$blibflags"); then
87                 AC_MSG_RESULT(not found)
88                 AC_MSG_ERROR([*** must be able to specify blibpath on AIX - check config.log])
89         else
90                 AC_MSG_RESULT($blibflags)
91         fi
92         LDFLAGS="$saved_LDFLAGS"
93         dnl Check for authenticate.  Might be in libs.a on older AIXes
94         AC_CHECK_FUNC(authenticate, [AC_DEFINE(WITH_AIXAUTHENTICATE)],
95                 [AC_CHECK_LIB(s,authenticate,
96                         [ AC_DEFINE(WITH_AIXAUTHENTICATE)
97                                 LIBS="$LIBS -ls"
98                         ])
99                 ])
100         dnl Check if loginfailed is declared and takes 4 arguments (AIX >= 5.2)
101         AC_CHECK_DECL(loginfailed,
102                  [AC_MSG_CHECKING(if loginfailed takes 4 arguments)
103                   AC_TRY_COMPILE(
104                         [#include <usersec.h>],
105                         [(void)loginfailed("user","host","tty",0);],
106                         [AC_MSG_RESULT(yes)
107                          AC_DEFINE(AIX_LOGINFAILED_4ARG)],
108                         [AC_MSG_RESULT(no)]
109                 )],
110                 [],
111                 [#include <usersec.h>]
112         )
113         AC_CHECK_FUNCS(setauthdb)
114         AC_DEFINE(BROKEN_GETADDRINFO)
115         AC_DEFINE(BROKEN_REALPATH)
116         AC_DEFINE(SETEUID_BREAKS_SETUID)
117         AC_DEFINE(BROKEN_SETREUID)
118         AC_DEFINE(BROKEN_SETREGID)
119         dnl AIX handles lastlog as part of its login message
120         AC_DEFINE(DISABLE_LASTLOG)
121         AC_DEFINE(LOGIN_NEEDS_UTMPX)
122         AC_DEFINE(SPT_TYPE,SPT_REUSEARGV)
123         ;;
124 *-*-cygwin*)
125         check_for_libcrypt_later=1
126         LIBS="$LIBS /usr/lib/textmode.o"
127         AC_DEFINE(HAVE_CYGWIN)
128         AC_DEFINE(USE_PIPES)
129         AC_DEFINE(DISABLE_SHADOW)
130         AC_DEFINE(IP_TOS_IS_BROKEN)
131         AC_DEFINE(NO_X11_UNIX_SOCKETS)
132         AC_DEFINE(NO_IPPORT_RESERVED_CONCEPT)
133         AC_DEFINE(DISABLE_FD_PASSING)
134         AC_DEFINE(SETGROUPS_NOOP)
135         ;;
136 *-*-dgux*)
137         AC_DEFINE(IP_TOS_IS_BROKEN)
138         AC_DEFINE(SETEUID_BREAKS_SETUID)
139         AC_DEFINE(BROKEN_SETREUID)
140         AC_DEFINE(BROKEN_SETREGID)
141         ;;
142 *-*-darwin*)
143         AC_MSG_CHECKING(if we have working getaddrinfo)
144         AC_TRY_RUN([#include <mach-o/dyld.h>
145 main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
146                 exit(0);
147         else
148                 exit(1);
149 }], [AC_MSG_RESULT(working)],
150         [AC_MSG_RESULT(buggy)
151         AC_DEFINE(BROKEN_GETADDRINFO)],
152         [AC_MSG_RESULT(assume it is working)])
153         AC_DEFINE(SETEUID_BREAKS_SETUID)
154         AC_DEFINE(BROKEN_SETREUID)
155         AC_DEFINE(BROKEN_SETREGID)
156         AC_DEFINE_UNQUOTED(BIND_8_COMPAT, 1)
157         ;;
158 *-*-hpux10.26)
159         if test -z "$GCC"; then
160                 CFLAGS="$CFLAGS -Ae"
161         fi
162         CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
163         IPADDR_IN_DISPLAY=yes
164         AC_DEFINE(HAVE_SECUREWARE)
165         AC_DEFINE(USE_PIPES)
166         AC_DEFINE(LOGIN_NO_ENDOPT)
167         AC_DEFINE(LOGIN_NEEDS_UTMPX)
168         AC_DEFINE(LOCKED_PASSWD_STRING, "*")
169         AC_DEFINE(SPT_TYPE,SPT_PSTAT)
170         LIBS="$LIBS -lsec -lsecpw"
171         AC_CHECK_LIB(xnet, t_error, ,AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***]))
172         disable_ptmx_check=yes
173         ;;
174 *-*-hpux10*)
175         if test -z "$GCC"; then
176                 CFLAGS="$CFLAGS -Ae"
177         fi
178         CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
179         IPADDR_IN_DISPLAY=yes
180         AC_DEFINE(USE_PIPES)
181         AC_DEFINE(LOGIN_NO_ENDOPT)
182         AC_DEFINE(LOGIN_NEEDS_UTMPX)
183         AC_DEFINE(LOCKED_PASSWD_STRING, "*")
184         AC_DEFINE(SPT_TYPE,SPT_PSTAT)
185         LIBS="$LIBS -lsec"
186         AC_CHECK_LIB(xnet, t_error, ,AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***]))
187         ;;
188 *-*-hpux11*)
189         CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
190         IPADDR_IN_DISPLAY=yes
191         AC_DEFINE(PAM_SUN_CODEBASE)
192         AC_DEFINE(USE_PIPES)
193         AC_DEFINE(LOGIN_NO_ENDOPT)
194         AC_DEFINE(LOGIN_NEEDS_UTMPX)
195         AC_DEFINE(DISABLE_UTMP)
196         AC_DEFINE(LOCKED_PASSWD_STRING, "*")
197         AC_DEFINE(SPT_TYPE,SPT_PSTAT)
198         case "$host" in
199         *-*-hpux11.11*)
200                 AC_DEFINE(BROKEN_GETADDRINFO);;
201         esac
202         LIBS="$LIBS -lsec"
203         AC_CHECK_LIB(xnet, t_error, ,AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***]))
204         ;;
205 *-*-irix5*)
206         PATH="$PATH:/usr/etc"
207         AC_DEFINE(BROKEN_INET_NTOA)
208         AC_DEFINE(SETEUID_BREAKS_SETUID)
209         AC_DEFINE(BROKEN_SETREUID)
210         AC_DEFINE(BROKEN_SETREGID)
211         AC_DEFINE(WITH_ABBREV_NO_TTY)
212         AC_DEFINE(LOCKED_PASSWD_STRING, "*LK*")
213         ;;
214 *-*-irix6*)
215         PATH="$PATH:/usr/etc"
216         AC_DEFINE(WITH_IRIX_ARRAY)
217         AC_DEFINE(WITH_IRIX_PROJECT)
218         AC_DEFINE(WITH_IRIX_AUDIT)
219         AC_CHECK_FUNC(jlimit_startjob, [AC_DEFINE(WITH_IRIX_JOBS)])
220         AC_DEFINE(BROKEN_INET_NTOA)
221         AC_DEFINE(SETEUID_BREAKS_SETUID)
222         AC_DEFINE(BROKEN_SETREUID)
223         AC_DEFINE(BROKEN_SETREGID)
224         AC_DEFINE(WITH_ABBREV_NO_TTY)
225         AC_DEFINE(LOCKED_PASSWD_STRING, "*LK*")
226         ;;
227 *-*-linux*)
228         no_dev_ptmx=1
229         check_for_libcrypt_later=1
230         check_for_openpty_ctty_bug=1
231         AC_DEFINE(DONT_TRY_OTHER_AF)
232         AC_DEFINE(PAM_TTY_KLUDGE)
233         AC_DEFINE(LOCKED_PASSWD_PREFIX, "!!")
234         AC_DEFINE(SPT_TYPE,SPT_REUSEARGV)
235         inet6_default_4in6=yes
236         case `uname -r` in
237         1.*|2.0.*)
238                 AC_DEFINE(BROKEN_CMSG_TYPE)
239                 ;;
240         esac
241         ;;
242 mips-sony-bsd|mips-sony-newsos4)
243         AC_DEFINE(HAVE_NEWS4)
244         SONY=1
245         ;;
246 *-*-netbsd*)
247         check_for_libcrypt_before=1
248         if test "x$withval" != "xno" ; then     
249                 need_dash_r=1
250         fi
251         ;;
252 *-*-freebsd*)
253         check_for_libcrypt_later=1
254         ;;
255 *-*-bsdi*)
256         AC_DEFINE(SETEUID_BREAKS_SETUID)
257         AC_DEFINE(BROKEN_SETREUID)
258         AC_DEFINE(BROKEN_SETREGID)
259         ;;
260 *-next-*)
261         conf_lastlog_location="/usr/adm/lastlog"
262         conf_utmp_location=/etc/utmp
263         conf_wtmp_location=/usr/adm/wtmp
264         MAIL=/usr/spool/mail
265         AC_DEFINE(HAVE_NEXT)
266         AC_DEFINE(BROKEN_REALPATH)
267         AC_DEFINE(USE_PIPES)
268         AC_DEFINE(BROKEN_SAVED_UIDS)
269         ;;
270 *-*-solaris*)
271         AC_DEFINE(PAM_SUN_CODEBASE)
272         AC_DEFINE(LOGIN_NEEDS_UTMPX)
273         AC_DEFINE(LOGIN_NEEDS_TERM)
274         AC_DEFINE(PAM_TTY_KLUDGE)
275         AC_DEFINE(LOCKED_PASSWD_STRING, "*LK*")
276         # Pushing STREAMS modules will cause sshd to acquire a controlling tty.
277         AC_DEFINE(SSHD_ACQUIRES_CTTY)
278         external_path_file=/etc/default/login
279         # hardwire lastlog location (can't detect it on some versions)
280         conf_lastlog_location="/var/adm/lastlog"
281         AC_MSG_CHECKING(for obsolete utmp and wtmp in solaris2.x)
282         sol2ver=`echo "$host"| sed -e 's/.*[[0-9]]\.//'`
283         if test "$sol2ver" -ge 8; then
284                 AC_MSG_RESULT(yes)
285                 AC_DEFINE(DISABLE_UTMP)
286                 AC_DEFINE(DISABLE_WTMP)
287         else
288                 AC_MSG_RESULT(no)
289         fi
290         ;;
291 *-*-sunos4*)
292         CPPFLAGS="$CPPFLAGS -DSUNOS4"
293         AC_CHECK_FUNCS(getpwanam)
294         AC_DEFINE(PAM_SUN_CODEBASE)
295         conf_utmp_location=/etc/utmp
296         conf_wtmp_location=/var/adm/wtmp
297         conf_lastlog_location=/var/adm/lastlog
298         AC_DEFINE(USE_PIPES)
299         ;;
300 *-ncr-sysv*)
301         LIBS="$LIBS -lc89"
302         AC_DEFINE(USE_PIPES)
303         AC_DEFINE(SSHD_ACQUIRES_CTTY)
304         AC_DEFINE(SETEUID_BREAKS_SETUID)
305         AC_DEFINE(BROKEN_SETREUID)
306         AC_DEFINE(BROKEN_SETREGID)
307         ;;
308 *-sni-sysv*)
309         # /usr/ucblib MUST NOT be searched on ReliantUNIX
310         AC_CHECK_LIB(dl, dlsym, ,)
311         IPADDR_IN_DISPLAY=yes
312         AC_DEFINE(USE_PIPES)
313         AC_DEFINE(IP_TOS_IS_BROKEN)
314         AC_DEFINE(SETEUID_BREAKS_SETUID)
315         AC_DEFINE(BROKEN_SETREUID)
316         AC_DEFINE(BROKEN_SETREGID)
317         AC_DEFINE(SSHD_ACQUIRES_CTTY)
318         external_path_file=/etc/default/login
319         # /usr/ucblib/libucb.a no longer needed on ReliantUNIX
320         # Attention: always take care to bind libsocket and libnsl before libc,
321         # otherwise you will find lots of "SIOCGPGRP errno 22" on syslog
322         ;;
323 *-*-sysv4.2*)
324         AC_DEFINE(USE_PIPES)
325         AC_DEFINE(SETEUID_BREAKS_SETUID)
326         AC_DEFINE(BROKEN_SETREUID)
327         AC_DEFINE(BROKEN_SETREGID)
328         ;;
329 *-*-sysv5*)
330         AC_DEFINE(USE_PIPES)
331         AC_DEFINE(SETEUID_BREAKS_SETUID)
332         AC_DEFINE(BROKEN_SETREUID)
333         AC_DEFINE(BROKEN_SETREGID)
334         ;;
335 *-*-sysv*)
336         ;;
337 *-*-sco3.2v4*)
338         CPPFLAGS="$CPPFLAGS -Dftruncate=chsize"
339         LIBS="$LIBS -los -lprot -lcrypt_i -lx -ltinfo -lm"
340         RANLIB=true
341         no_dev_ptmx=1
342         AC_DEFINE(BROKEN_SYS_TERMIO_H)
343         AC_DEFINE(USE_PIPES)
344         AC_DEFINE(HAVE_SECUREWARE)
345         AC_DEFINE(DISABLE_SHADOW)
346         AC_DEFINE(BROKEN_SAVED_UIDS)
347         AC_DEFINE(WITH_ABBREV_NO_TTY)
348         AC_CHECK_FUNCS(getluid setluid)
349         MANTYPE=man
350         do_sco3_extra_lib_check=yes
351         ;;
352 *-*-sco3.2v5*)
353         if test -z "$GCC"; then
354                 CFLAGS="$CFLAGS -belf"
355         fi
356         LIBS="$LIBS -lprot -lx -ltinfo -lm"
357         no_dev_ptmx=1
358         AC_DEFINE(USE_PIPES)
359         AC_DEFINE(HAVE_SECUREWARE)
360         AC_DEFINE(DISABLE_SHADOW)
361         AC_DEFINE(DISABLE_FD_PASSING)
362         AC_DEFINE(SETEUID_BREAKS_SETUID)
363         AC_DEFINE(BROKEN_SETREUID)
364         AC_DEFINE(BROKEN_SETREGID)
365         AC_DEFINE(WITH_ABBREV_NO_TTY)
366         AC_CHECK_FUNCS(getluid setluid)
367         MANTYPE=man
368         ;;
369 *-*-unicosmk*)
370         AC_DEFINE(NO_SSH_LASTLOG)
371         AC_DEFINE(SETEUID_BREAKS_SETUID)
372         AC_DEFINE(BROKEN_SETREUID)
373         AC_DEFINE(BROKEN_SETREGID)
374         AC_DEFINE(USE_PIPES)
375         AC_DEFINE(DISABLE_FD_PASSING)
376         LDFLAGS="$LDFLAGS"
377         LIBS="$LIBS -lgen -lrsc -lshare -luex -lacm"
378         MANTYPE=cat
379         ;;
380 *-*-unicosmp*)
381         AC_DEFINE(SETEUID_BREAKS_SETUID)
382         AC_DEFINE(BROKEN_SETREUID)
383         AC_DEFINE(BROKEN_SETREGID)
384         AC_DEFINE(WITH_ABBREV_NO_TTY)
385         AC_DEFINE(USE_PIPES)
386         AC_DEFINE(DISABLE_FD_PASSING)
387         LDFLAGS="$LDFLAGS"
388         LIBS="$LIBS -lgen -lacid -ldb"
389         MANTYPE=cat
390         ;;
391 *-*-unicos*)
392         AC_DEFINE(SETEUID_BREAKS_SETUID)
393         AC_DEFINE(BROKEN_SETREUID)
394         AC_DEFINE(BROKEN_SETREGID)
395         AC_DEFINE(USE_PIPES)
396         AC_DEFINE(DISABLE_FD_PASSING)
397         AC_DEFINE(NO_SSH_LASTLOG)
398         LDFLAGS="$LDFLAGS -Wl,-Dmsglevel=334:fatal"
399         LIBS="$LIBS -lgen -lrsc -lshare -luex -lacm"
400         MANTYPE=cat
401         ;;
402 *-dec-osf*)
403         AC_MSG_CHECKING(for Digital Unix SIA)
404         no_osfsia=""
405         AC_ARG_WITH(osfsia,
406                 [  --with-osfsia           Enable Digital Unix SIA],
407                 [
408                         if test "x$withval" = "xno" ; then
409                                 AC_MSG_RESULT(disabled)
410                                 no_osfsia=1
411                         fi
412                 ],
413         )
414         if test -z "$no_osfsia" ; then
415                 if test -f /etc/sia/matrix.conf; then
416                         AC_MSG_RESULT(yes)
417                         AC_DEFINE(HAVE_OSF_SIA)
418                         AC_DEFINE(DISABLE_LOGIN)
419                         AC_DEFINE(DISABLE_FD_PASSING)
420                         LIBS="$LIBS -lsecurity -ldb -lm -laud"
421                 else
422                         AC_MSG_RESULT(no)
423                         AC_DEFINE(LOCKED_PASSWD_SUBSTR, "Nologin")
424                 fi
425         fi
426         AC_DEFINE(BROKEN_GETADDRINFO)
427         AC_DEFINE(SETEUID_BREAKS_SETUID)
428         AC_DEFINE(BROKEN_SETREUID)
429         AC_DEFINE(BROKEN_SETREGID)
430         ;;
431
432 *-*-nto-qnx)
433         AC_DEFINE(USE_PIPES)
434         AC_DEFINE(NO_X11_UNIX_SOCKETS)
435         AC_DEFINE(MISSING_NFDBITS)
436         AC_DEFINE(MISSING_HOWMANY)
437         AC_DEFINE(MISSING_FD_MASK)
438         ;;
439 esac
440
441 # Allow user to specify flags
442 AC_ARG_WITH(cflags,
443         [  --with-cflags           Specify additional flags to pass to compiler],
444         [
445                 if test "x$withval" != "xno" ; then
446                         CFLAGS="$CFLAGS $withval"
447                 fi
448         ]       
449 )
450 AC_ARG_WITH(cppflags,
451         [  --with-cppflags         Specify additional flags to pass to preprocessor] ,
452         [
453                 if test "x$withval" != "xno"; then
454                         CPPFLAGS="$CPPFLAGS $withval"
455                 fi
456         ]
457 )
458 AC_ARG_WITH(ldflags,
459         [  --with-ldflags          Specify additional flags to pass to linker],
460         [
461                 if test "x$withval" != "xno" ; then
462                         LDFLAGS="$LDFLAGS $withval"
463                 fi
464         ]       
465 )
466 AC_ARG_WITH(libs,
467         [  --with-libs             Specify additional libraries to link with],
468         [
469                 if test "x$withval" != "xno" ; then
470                         LIBS="$LIBS $withval"
471                 fi
472         ]       
473 )
474
475 AC_MSG_CHECKING(compiler and flags for sanity)
476 AC_TRY_RUN([
477 #include <stdio.h>
478 int main(){exit(0);}
479         ],
480         [       AC_MSG_RESULT(yes) ],
481         [
482                 AC_MSG_RESULT(no)
483                 AC_MSG_ERROR([*** compiler cannot create working executables, check config.log ***])
484         ]
485 )
486
487 # Checks for header files.
488 AC_CHECK_HEADERS(bstring.h crypt.h endian.h features.h floatingpoint.h \
489         getopt.h glob.h ia.h lastlog.h limits.h login.h \
490         login_cap.h maillock.h netdb.h netgroup.h \
491         netinet/in_systm.h pam/pam_appl.h paths.h pty.h readpassphrase.h \
492         rpc/types.h security/pam_appl.h shadow.h stddef.h stdint.h \
493         strings.h sys/strtio.h sys/audit.h sys/bitypes.h sys/bsdtty.h \
494         sys/cdefs.h sys/mman.h sys/pstat.h sys/ptms.h sys/select.h sys/stat.h \
495         sys/stream.h sys/stropts.h sys/sysmacros.h sys/time.h sys/timers.h \
496         sys/un.h time.h tmpdir.h ttyent.h usersec.h \
497         util.h utime.h utmp.h utmpx.h vis.h)
498
499 # Checks for libraries.
500 AC_CHECK_FUNC(yp_match, , AC_CHECK_LIB(nsl, yp_match))
501 AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt))
502
503 dnl SCO OS3 needs this for libwrap
504 if test "x$with_tcp_wrappers" != "xno" ; then
505     if test "x$do_sco3_extra_lib_check" = "xyes" ; then
506         AC_CHECK_LIB(rpc, innetgr, LIBS="-lrpc -lyp -lrpc $LIBS" , , -lyp -lrpc)
507     fi
508 fi
509
510 dnl IRIX and Solaris 2.5.1 have dirname() in libgen
511 AC_CHECK_FUNCS(dirname, [AC_CHECK_HEADERS(libgen.h)] ,[
512         AC_CHECK_LIB(gen, dirname,[
513                 AC_CACHE_CHECK([for broken dirname],
514                         ac_cv_have_broken_dirname, [
515                         save_LIBS="$LIBS"
516                         LIBS="$LIBS -lgen"
517                         AC_TRY_RUN(
518                                 [
519 #include <libgen.h>
520 #include <string.h>
521
522 int main(int argc, char **argv) {
523     char *s, buf[32];
524
525     strncpy(buf,"/etc", 32);
526     s = dirname(buf);
527     if (!s || strncmp(s, "/", 32) != 0) {
528         exit(1);
529     } else {
530         exit(0);
531     }
532 }
533                                 ],
534                                 [ ac_cv_have_broken_dirname="no" ],
535                                 [ ac_cv_have_broken_dirname="yes" ]
536                         )
537                         LIBS="$save_LIBS"
538                 ])
539                 if test "x$ac_cv_have_broken_dirname" = "xno" ; then
540                         LIBS="$LIBS -lgen"
541                         AC_DEFINE(HAVE_DIRNAME)
542                         AC_CHECK_HEADERS(libgen.h)
543                 fi
544         ])
545 ])
546
547 AC_CHECK_FUNC(getspnam, ,
548         AC_CHECK_LIB(gen, getspnam, LIBS="$LIBS -lgen"))
549 AC_SEARCH_LIBS(basename, gen, AC_DEFINE(HAVE_BASENAME))
550
551 dnl zlib is required
552 AC_ARG_WITH(zlib,
553         [  --with-zlib=PATH        Use zlib in PATH],
554         [
555                 if test "x$withval" = "xno" ; then
556                         AC_MSG_ERROR([*** zlib is required ***])
557                 fi
558                 if test -d "$withval/lib"; then
559                         if test -n "${need_dash_r}"; then
560                                 LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
561                         else
562                                 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
563                         fi
564                 else
565                         if test -n "${need_dash_r}"; then
566                                 LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
567                         else
568                                 LDFLAGS="-L${withval} ${LDFLAGS}"
569                         fi
570                 fi
571                 if test -d "$withval/include"; then
572                         CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
573                 else
574                         CPPFLAGS="-I${withval} ${CPPFLAGS}"
575                 fi
576         ]
577 )
578
579 AC_CHECK_LIB(z, deflate, ,
580         [
581                 saved_CPPFLAGS="$CPPFLAGS"
582                 saved_LDFLAGS="$LDFLAGS"
583                 save_LIBS="$LIBS"
584                 dnl Check default zlib install dir
585                 if test -n "${need_dash_r}"; then
586                         LDFLAGS="-L/usr/local/lib -R/usr/local/lib ${saved_LDFLAGS}"
587                 else
588                         LDFLAGS="-L/usr/local/lib ${saved_LDFLAGS}"
589                 fi
590                 CPPFLAGS="-I/usr/local/include ${saved_CPPFLAGS}"
591                 LIBS="$LIBS -lz"
592                 AC_TRY_LINK_FUNC(deflate, AC_DEFINE(HAVE_LIBZ),
593                         [
594                                 AC_MSG_ERROR([*** zlib missing - please install first or check config.log ***])
595                         ]
596                 )
597         ]
598 )
599 AC_CHECK_HEADER([zlib.h], ,AC_MSG_ERROR([*** zlib.h missing - please install first or check config.log ***]))
600
601 AC_ARG_WITH(zlib-version-check,
602         [  --without-zlib-version-check Disable zlib version check],
603         [  if test "x$withval" = "xno" ; then
604                 zlib_check_nonfatal=1
605            fi
606         ]
607 )
608
609 AC_MSG_CHECKING(for zlib 1.1.4 or greater)
610 AC_TRY_RUN([
611 #include <zlib.h>
612 int main()
613 {
614         int a, b, c, v;
615         if (sscanf(ZLIB_VERSION, "%d.%d.%d", &a, &b, &c) != 3)
616                 exit(1);
617         v = a*1000000 + b*1000 + c;
618         if (v >= 1001004)
619                 exit(0);
620         exit(2);
621 }
622         ],
623         AC_MSG_RESULT(yes),
624         [ AC_MSG_RESULT(no)
625           if test -z "$zlib_check_nonfatal" ; then
626                 AC_MSG_ERROR([*** zlib too old - check config.log ***
627 Your reported zlib version has known security problems.  It's possible your
628 vendor has fixed these problems without changing the version number.  If you
629 are sure this is the case, you can disable the check by running
630 "./configure --without-zlib-version-check".
631 If you are in doubt, upgrade zlib to version 1.1.4 or greater.])
632           else
633                 AC_MSG_WARN([zlib version may have security problems])
634           fi
635         ]
636 )
637
638 dnl UnixWare 2.x
639 AC_CHECK_FUNC(strcasecmp,
640         [], [ AC_CHECK_LIB(resolv, strcasecmp, LIBS="$LIBS -lresolv") ]
641 )
642 AC_CHECK_FUNC(utimes,
643         [], [ AC_CHECK_LIB(c89, utimes, [AC_DEFINE(HAVE_UTIMES)
644                                         LIBS="$LIBS -lc89"]) ]
645 )
646
647 dnl    Checks for libutil functions
648 AC_CHECK_HEADERS(libutil.h)
649 AC_SEARCH_LIBS(login, util bsd, [AC_DEFINE(HAVE_LOGIN)])
650 AC_CHECK_FUNCS(logout updwtmp logwtmp)
651
652 AC_FUNC_STRFTIME
653
654 # Check for ALTDIRFUNC glob() extension
655 AC_MSG_CHECKING(for GLOB_ALTDIRFUNC support)
656 AC_EGREP_CPP(FOUNDIT,
657         [
658                 #include <glob.h>
659                 #ifdef GLOB_ALTDIRFUNC
660                 FOUNDIT
661                 #endif
662         ],
663         [
664                 AC_DEFINE(GLOB_HAS_ALTDIRFUNC)
665                 AC_MSG_RESULT(yes)
666         ],
667         [
668                 AC_MSG_RESULT(no)
669         ]
670 )
671
672 # Check for g.gl_matchc glob() extension
673 AC_MSG_CHECKING(for gl_matchc field in glob_t)
674 AC_EGREP_CPP(FOUNDIT,
675         [
676                 #include <glob.h>
677                 int main(void){glob_t g; g.gl_matchc = 1;}
678         ],
679         [
680                 AC_DEFINE(GLOB_HAS_GL_MATCHC)
681                 AC_MSG_RESULT(yes)
682         ],
683         [
684                 AC_MSG_RESULT(no)
685         ]
686 )
687
688 AC_MSG_CHECKING([whether struct dirent allocates space for d_name])
689 AC_TRY_RUN(
690         [
691 #include <sys/types.h>
692 #include <dirent.h>
693 int main(void){struct dirent d;exit(sizeof(d.d_name)<=sizeof(char));}
694         ],
695         [AC_MSG_RESULT(yes)],
696         [
697                 AC_MSG_RESULT(no)
698                 AC_DEFINE(BROKEN_ONE_BYTE_DIRENT_D_NAME)
699         ]
700 )
701
702 # Check whether the user wants GSSAPI mechglue support
703 AC_ARG_WITH(mechglue,
704         [  --with-mechglue=PATH    Build with GSSAPI mechglue library],
705         [
706                 AC_MSG_CHECKING(for mechglue library)
707
708                 if test -e ${withval}/libgssapi.a ; then
709                     mechglue_lib=${withval}/libgssapi.a
710                 elif test -e ${withval}/lib/libgssapi.a ; then
711                     mechglue_lib=${withval}/lib/libgssapi.a
712                 else
713                     AC_MSG_ERROR("Can't find libgssapi in ${withval}");
714                 fi
715                 LIBS="$LIBS ${mechglue_lib}"
716                 AC_MSG_RESULT(${mechglue_lib})
717
718                 AC_CHECK_LIB(dl, dlopen, , )
719                 if test $ac_cv_lib_dl_dlopen = yes; then
720                    LDFLAGS="$LDFLAGS -ldl -Wl,-Bsymbolic"
721                 fi
722
723                 AC_DEFINE(GSSAPI)
724                 AC_DEFINE(MECHGLUE)
725                 GSSAPI="mechglue"
726
727         ]
728 )
729
730
731 # Check whether the user wants GSI (Globus) support
732 gsi_path="no"
733 AC_ARG_WITH(gsi,
734         [  --with-gsi              Enable Globus GSI authentication support],
735         [
736                 gsi_path="$withval"
737         ]
738 )
739
740 AC_ARG_WITH(globus,
741         [  --with-globus           Enable Globus GSI authentication support],
742         [
743                 gsi_path="$withval"
744         ]
745 )
746
747 AC_ARG_WITH(globus-static,
748         [  --with-globus-static    Link statically with Globus GSI libraries],
749         [
750                 gsi_static="-static"
751                 if test "x$gsi_path" = "xno" ; then
752                         gsi_path="$withval"
753                 fi
754         ]
755 )
756
757 # Check whether the user has a Globus flavor type
758 globus_flavor_type="no"
759 AC_ARG_WITH(globus-flavor,
760         [  --with-globus-flavor=TYPE  Specify Globus flavor type (ex: gcc32dbg)],
761         [
762                 globus_flavor_type="$withval"
763                 if test "x$gsi_path" = "xno" ; then
764                         gsi_path="yes"
765                 fi
766         ]
767 )
768
769 if test "x$gsi_path" != "xno" ; then
770         # Globus GSSAPI configuration
771         AC_MSG_CHECKING(for Globus GSI)
772         AC_DEFINE(GSI)
773
774         if test "$GSSAPI" -a "$GSSAPI" != "mechglue"; then
775                 AC_MSG_ERROR([Previously configured GSSAPI library conflicts with Globus GSI.])
776         fi
777         if test -z "$GSSAPI"; then
778                 AC_DEFINE(GSSAPI)
779                 GSSAPI="GSI"
780         fi
781
782         if test "x$gsi_path" = "xyes" ; then
783                 if test -z "$GLOBUS_LOCATION" ; then
784                         AC_MSG_ERROR(GLOBUS_LOCATION environment variable must be set.)
785                 else
786                         gsi_path="$GLOBUS_LOCATION"
787                 fi
788         fi
789         GLOBUS_LOCATION="$gsi_path"
790         export GLOBUS_LOCATION
791         if test ! -d "$GLOBUS_LOCATION" ; then
792                 AC_MSG_ERROR(Cannot find Globus installation.  Set GLOBUS_LOCATION environment variable.)
793         fi
794
795         if test "x$globus_flavor_type" = "xno" ; then
796                 AC_MSG_ERROR(--with-globus-flavor=TYPE must be specified)
797         fi
798         if test "x$globus_flavor_type" = "xyes" ; then
799                 AC_MSG_ERROR(--with-globus-flavor=TYPE must specify a flavor type)
800         fi
801
802         GLOBUS_INCLUDE="${gsi_path}/include/${globus_flavor_type}"
803         if test ! -d "$GLOBUS_INCLUDE" ; then
804                 AC_MSG_ERROR(Cannot find Globus flavor-specific include directory: ${GLOBUS_INCLUDE})
805         fi
806         GSI_CPPFLAGS="-I${GLOBUS_INCLUDE}"
807         
808         if test -x ${gsi_path}/bin/globus-makefile-header ; then
809                 GSI_LIBS=`${gsi_path}/bin/globus-makefile-header --flavor=${globus_flavor_type} ${gsi_static} globus_gss_assist | perl -n -e 'if (/GLOBUS_PKG_LIBS = (.*)/){print $1;}'`
810         elif test -x ${gsi_path}/sbin/globus-makefile-header ; then
811                 GSI_LIBS=`${gsi_path}/sbin/globus-makefile-header --flavor=${globus_flavor_type} ${gsi_static} globus_gss_assist | perl -n -e 'if (/GLOBUS_PKG_LIBS = (.*)/){print $1;}'`
812         else
813                 AC_MSG_ERROR(Cannot find globus-makefile-header: Globus installation is incomplete)
814         fi
815         if test -n "${need_dash_r}"; then
816                 GSI_LDFLAGS="-L${gsi_path}/lib -R{gsi_path}/lib"
817         else
818                 GSI_LDFLAGS="-L${gsi_path}/lib"
819         fi
820         if test -z "$GSI_LIBS" ; then
821                 AC_MSG_ERROR(globus-makefile-header failed)
822         fi
823
824         AC_DEFINE(HAVE_GSSAPI_H)
825
826         LIBS="$LIBS $GSI_LIBS"
827         LDFLAGS="$LDFLAGS $GSI_LDFLAGS"
828         CPPFLAGS="$CPPFLAGS $GSI_CPPFLAGS"
829
830         # test that we got the libraries OK
831         AC_TRY_LINK(
832                 [],
833                 [],
834                 [
835                         AC_MSG_RESULT(yes)
836                 ],
837                 [
838                         AC_MSG_ERROR(link with Globus libraries failed)
839                 ]
840         )
841         INSTALL_GSISSH="yes"
842 else
843         INSTALL_GSISSH=""
844 fi
845 AC_SUBST(INSTALL_GSISSH)
846 # End Globus/GSI section
847
848 # Check whether user wants S/Key support
849 SKEY_MSG="no"
850 AC_ARG_WITH(skey,
851         [  --with-skey[[=PATH]]      Enable S/Key support
852                             (optionally in PATH)],
853         [
854                 if test "x$withval" != "xno" ; then
855
856                         if test "x$withval" != "xyes" ; then
857                                 CPPFLAGS="$CPPFLAGS -I${withval}/include"
858                                 LDFLAGS="$LDFLAGS -L${withval}/lib"
859                         fi
860
861                         AC_DEFINE(SKEY)
862                         LIBS="-lskey $LIBS"
863                         SKEY_MSG="yes"
864         
865                         AC_MSG_CHECKING([for s/key support])
866                         AC_TRY_RUN(
867                                 [
868 #include <stdio.h>
869 #include <skey.h>
870 int main() { char *ff = skey_keyinfo(""); ff=""; exit(0); }
871                                 ],
872                                 [AC_MSG_RESULT(yes)],
873                                 [
874                                         AC_MSG_RESULT(no)
875                                         AC_MSG_ERROR([** Incomplete or missing s/key libraries.])
876                                 ])
877                 fi
878         ]
879 )
880
881 # Check whether user wants TCP wrappers support
882 TCPW_MSG="no"
883 AC_ARG_WITH(tcp-wrappers,
884         [  --with-tcp-wrappers[[=PATH]]      Enable tcpwrappers support
885                             (optionally in PATH)],
886         [
887                 if test "x$withval" != "xno" ; then
888                         saved_LIBS="$LIBS"
889                         saved_LDFLAGS="$LDFLAGS"
890                         saved_CPPFLAGS="$CPPFLAGS"
891                         if test -n "${withval}" -a "${withval}" != "yes"; then
892                                 if test -d "${withval}/lib"; then
893                                         if test -n "${need_dash_r}"; then
894                                                 LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
895                                         else
896                                                 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
897                                         fi
898                                 else
899                                         if test -n "${need_dash_r}"; then
900                                                 LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
901                                         else
902                                                 LDFLAGS="-L${withval} ${LDFLAGS}"
903                                         fi
904                                 fi
905                                 if test -d "${withval}/include"; then
906                                         CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
907                                 else
908                                         CPPFLAGS="-I${withval} ${CPPFLAGS}"
909                                 fi
910                         fi
911                         LIBWRAP="-lwrap"
912                         LIBS="$LIBWRAP $LIBS"
913                         AC_MSG_CHECKING(for libwrap)
914                         AC_TRY_LINK(
915                                 [
916 #include <tcpd.h>
917                                         int deny_severity = 0, allow_severity = 0;
918                                 ],
919                                 [hosts_access(0);],
920                                 [
921                                         AC_MSG_RESULT(yes)
922                                         AC_DEFINE(LIBWRAP)
923                                         AC_SUBST(LIBWRAP)
924                                         TCPW_MSG="yes"
925                                 ],
926                                 [
927                                         AC_MSG_ERROR([*** libwrap missing])
928                                 ]
929                         )
930                         LIBS="$saved_LIBS"
931                 fi
932         ]
933 )
934
935 dnl    Checks for library functions. Please keep in alphabetical order
936 AC_CHECK_FUNCS(\
937         arc4random __b64_ntop b64_ntop __b64_pton b64_pton \
938         bcopy bindresvport_sa clock fchmod fchown freeaddrinfo futimes \
939         getaddrinfo getcwd getgrouplist getnameinfo getopt \
940         getpeereid _getpty getrlimit getttyent glob inet_aton \
941         inet_ntoa inet_ntop innetgr login_getcapbool md5_crypt memmove \
942         mkdtemp mmap ngetaddrinfo nsleep ogetaddrinfo openlog_r openpty \
943         pstat readpassphrase realpath recvmsg rresvport_af sendmsg \
944         setdtablesize setegid setenv seteuid setgroups setlogin setpcred \
945         setproctitle setregid setreuid setrlimit \
946         setsid setvbuf sigaction sigvec snprintf socketpair strerror \
947         strlcat strlcpy strmode strnvis strtoul sysconf tcgetpgrp \
948         truncate updwtmpx utimes vhangup vsnprintf waitpid \
949 )
950
951 # IRIX has a const char return value for gai_strerror()
952 AC_CHECK_FUNCS(gai_strerror,[
953         AC_DEFINE(HAVE_GAI_STRERROR)
954         AC_TRY_COMPILE([
955 #include <sys/types.h>
956 #include <sys/socket.h>
957 #include <netdb.h>
958
959 const char *gai_strerror(int);],[
960 char *str;
961
962 str = gai_strerror(0);],[
963                 AC_DEFINE(HAVE_CONST_GAI_STRERROR_PROTO, 1,
964                 [Define if gai_strerror() returns const char *])])])
965
966 AC_SEARCH_LIBS(nanosleep, rt posix4, AC_DEFINE(HAVE_NANOSLEEP))
967
968 dnl Make sure prototypes are defined for these before using them.
969 AC_CHECK_DECL(strsep, [AC_CHECK_FUNCS(strsep)])
970 AC_CHECK_DECL(getrusage, [AC_CHECK_FUNCS(getrusage)])
971
972 dnl tcsendbreak might be a macro
973 AC_CHECK_DECL(tcsendbreak,
974         [AC_DEFINE(HAVE_TCSENDBREAK)],
975         [AC_CHECK_FUNCS(tcsendbreak)],
976         [#include <termios.h>]
977 )
978
979 AC_CHECK_FUNCS(setresuid, [
980         dnl Some platorms have setresuid that isn't implemented, test for this
981         AC_MSG_CHECKING(if setresuid seems to work)
982         AC_TRY_RUN([
983 #include <stdlib.h>
984 #include <errno.h>
985 int main(){errno=0; setresuid(0,0,0); if (errno==ENOSYS) exit(1); else exit(0);}
986                 ],
987                 [AC_MSG_RESULT(yes)],
988                 [AC_DEFINE(BROKEN_SETRESUID)
989                  AC_MSG_RESULT(not implemented)]
990         )
991 ])
992
993 AC_CHECK_FUNCS(setresgid, [
994         dnl Some platorms have setresgid that isn't implemented, test for this
995         AC_MSG_CHECKING(if setresgid seems to work)
996         AC_TRY_RUN([
997 #include <stdlib.h>
998 #include <errno.h>
999 int main(){errno=0; setresgid(0,0,0); if (errno==ENOSYS) exit(1); else exit(0);}
1000                 ],
1001                 [AC_MSG_RESULT(yes)],
1002                 [AC_DEFINE(BROKEN_SETRESGID)
1003                  AC_MSG_RESULT(not implemented)]
1004         )
1005 ])
1006
1007 dnl    Checks for time functions
1008 AC_CHECK_FUNCS(gettimeofday time)
1009 dnl    Checks for utmp functions
1010 AC_CHECK_FUNCS(endutent getutent getutid getutline pututline setutent)
1011 AC_CHECK_FUNCS(utmpname)
1012 dnl    Checks for utmpx functions
1013 AC_CHECK_FUNCS(endutxent getutxent getutxid getutxline pututxline )
1014 AC_CHECK_FUNCS(setutxent utmpxname)
1015
1016 AC_CHECK_FUNC(daemon,
1017         [AC_DEFINE(HAVE_DAEMON)],
1018         [AC_CHECK_LIB(bsd, daemon, [LIBS="$LIBS -lbsd"; AC_DEFINE(HAVE_DAEMON)])]
1019 )
1020
1021 AC_CHECK_FUNC(getpagesize,
1022         [AC_DEFINE(HAVE_GETPAGESIZE)],
1023         [AC_CHECK_LIB(ucb, getpagesize, [LIBS="$LIBS -lucb"; AC_DEFINE(HAVE_GETPAGESIZE)])]
1024 )
1025
1026 # Check for broken snprintf
1027 if test "x$ac_cv_func_snprintf" = "xyes" ; then
1028         AC_MSG_CHECKING([whether snprintf correctly terminates long strings])
1029         AC_TRY_RUN(
1030                 [
1031 #include <stdio.h>
1032 int main(void){char b[5];snprintf(b,5,"123456789");exit(b[4]!='\0');}
1033                 ],
1034                 [AC_MSG_RESULT(yes)],
1035                 [
1036                         AC_MSG_RESULT(no)
1037                         AC_DEFINE(BROKEN_SNPRINTF)
1038                         AC_MSG_WARN([****** Your snprintf() function is broken, complain to your vendor])
1039                 ]
1040         )
1041 fi
1042
1043 dnl see whether mkstemp() requires XXXXXX
1044 if test "x$ac_cv_func_mkdtemp" = "xyes" ; then
1045 AC_MSG_CHECKING([for (overly) strict mkstemp])
1046 AC_TRY_RUN(
1047         [
1048 #include <stdlib.h>
1049 main() { char template[]="conftest.mkstemp-test";
1050 if (mkstemp(template) == -1)
1051         exit(1);
1052 unlink(template); exit(0);
1053 }
1054         ],
1055         [
1056                 AC_MSG_RESULT(no)
1057         ],
1058         [
1059                 AC_MSG_RESULT(yes)
1060                 AC_DEFINE(HAVE_STRICT_MKSTEMP)
1061         ],
1062         [
1063                 AC_MSG_RESULT(yes)
1064                 AC_DEFINE(HAVE_STRICT_MKSTEMP)
1065         ]
1066 )
1067 fi
1068
1069 dnl make sure that openpty does not reacquire controlling terminal
1070 if test ! -z "$check_for_openpty_ctty_bug"; then
1071         AC_MSG_CHECKING(if openpty correctly handles controlling tty)
1072         AC_TRY_RUN(
1073                 [
1074 #include <stdio.h>
1075 #include <sys/fcntl.h>
1076 #include <sys/types.h>
1077 #include <sys/wait.h>
1078
1079 int
1080 main()
1081 {
1082         pid_t pid;
1083         int fd, ptyfd, ttyfd, status;
1084
1085         pid = fork();
1086         if (pid < 0) {          /* failed */
1087                 exit(1);
1088         } else if (pid > 0) {   /* parent */
1089                 waitpid(pid, &status, 0);
1090                 if (WIFEXITED(status))
1091                         exit(WEXITSTATUS(status));
1092                 else
1093                         exit(2);
1094         } else {                /* child */
1095                 close(0); close(1); close(2);
1096                 setsid();
1097                 openpty(&ptyfd, &ttyfd, NULL, NULL, NULL);
1098                 fd = open("/dev/tty", O_RDWR | O_NOCTTY);
1099                 if (fd >= 0)
1100                         exit(3);        /* Acquired ctty: broken */
1101                 else
1102                         exit(0);        /* Did not acquire ctty: OK */
1103         }
1104 }
1105                 ],
1106                 [
1107                         AC_MSG_RESULT(yes)
1108                 ],
1109                 [
1110                         AC_MSG_RESULT(no)
1111                         AC_DEFINE(SSHD_ACQUIRES_CTTY)
1112                 ]
1113         )
1114 fi
1115
1116 AC_FUNC_GETPGRP
1117
1118 # Check for PAM libs
1119 PAM_MSG="no"
1120 AC_ARG_WITH(pam,
1121         [  --with-pam              Enable PAM support ],
1122         [
1123                 if test "x$withval" != "xno" ; then
1124                         if test "x$ac_cv_header_security_pam_appl_h" != "xyes" && \
1125                            test "x$ac_cv_header_pam_pam_appl_h" != "xyes" ; then
1126                                 AC_MSG_ERROR([PAM headers not found])
1127                         fi
1128
1129                         AC_CHECK_LIB(dl, dlopen, , )
1130                         AC_CHECK_LIB(pam, pam_set_item, , AC_MSG_ERROR([*** libpam missing]))
1131                         AC_CHECK_FUNCS(pam_getenvlist)
1132                         AC_CHECK_FUNCS(pam_putenv)
1133
1134                         PAM_MSG="yes"
1135
1136                         AC_DEFINE(USE_PAM)
1137                         if test $ac_cv_lib_dl_dlopen = yes; then
1138                                 LIBPAM="-lpam -ldl"
1139                         else
1140                                 LIBPAM="-lpam"
1141                         fi
1142                         AC_SUBST(LIBPAM)
1143                 fi
1144         ]
1145 )
1146
1147 # Check for older PAM
1148 if test "x$PAM_MSG" = "xyes" ; then
1149         # Check PAM strerror arguments (old PAM)
1150         AC_MSG_CHECKING([whether pam_strerror takes only one argument])
1151         AC_TRY_COMPILE(
1152                 [
1153 #include <stdlib.h>
1154 #if defined(HAVE_SECURITY_PAM_APPL_H)
1155 #include <security/pam_appl.h>
1156 #elif defined (HAVE_PAM_PAM_APPL_H)
1157 #include <pam/pam_appl.h>
1158 #endif
1159                 ],
1160                 [(void)pam_strerror((pam_handle_t *)NULL, -1);],
1161                 [AC_MSG_RESULT(no)],
1162                 [
1163                         AC_DEFINE(HAVE_OLD_PAM)
1164                         AC_MSG_RESULT(yes)
1165                         PAM_MSG="yes (old library)"
1166                 ]
1167         )
1168 fi
1169
1170 # Search for OpenSSL
1171 saved_CPPFLAGS="$CPPFLAGS"
1172 saved_LDFLAGS="$LDFLAGS"
1173 AC_ARG_WITH(ssl-dir,
1174         [  --with-ssl-dir=PATH     Specify path to OpenSSL installation ],
1175         [
1176                 if test "x$withval" != "xno" ; then
1177                         if test -d "$withval/lib"; then
1178                                 if test -n "${need_dash_r}"; then
1179                                         LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
1180                                 else
1181                                         LDFLAGS="-L${withval}/lib ${LDFLAGS}"
1182                                 fi
1183                         else
1184                                 if test -n "${need_dash_r}"; then
1185                                         LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
1186                                 else
1187                                         LDFLAGS="-L${withval} ${LDFLAGS}"
1188                                 fi
1189                         fi
1190                         if test -d "$withval/include"; then
1191                                 CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
1192                         else
1193                                 CPPFLAGS="-I${withval} ${CPPFLAGS}"
1194                         fi
1195                 fi
1196         ]
1197 )
1198 if test -z "$GSI_LIBS" ; then
1199 LIBS="-lcrypto $LIBS"
1200 fi
1201 AC_TRY_LINK_FUNC(RAND_add, AC_DEFINE(HAVE_OPENSSL),
1202         [
1203                 dnl Check default openssl install dir
1204                 if test -n "${need_dash_r}"; then
1205                         LDFLAGS="-L/usr/local/ssl/lib -R/usr/local/ssl/lib ${saved_LDFLAGS}"
1206                 else
1207                         LDFLAGS="-L/usr/local/ssl/lib ${saved_LDFLAGS}"
1208                 fi
1209                 CPPFLAGS="-I/usr/local/ssl/include ${saved_CPPFLAGS}"
1210                 AC_TRY_LINK_FUNC(RAND_add, AC_DEFINE(HAVE_OPENSSL),
1211                         [
1212                                 AC_MSG_ERROR([*** Can't find recent OpenSSL libcrypto (see config.log for details) ***])
1213                         ]
1214                 )
1215         ]
1216 )
1217
1218 # Determine OpenSSL header version
1219 AC_MSG_CHECKING([OpenSSL header version])
1220 AC_TRY_RUN(
1221         [
1222 #include <stdio.h>
1223 #include <string.h>
1224 #include <openssl/opensslv.h>
1225 #define DATA "conftest.sslincver"
1226 int main(void) {
1227         FILE *fd;
1228         int rc;
1229
1230         fd = fopen(DATA,"w");
1231         if(fd == NULL)
1232                 exit(1);
1233
1234         if ((rc = fprintf(fd ,"%x (%s)\n", OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_TEXT)) <0)
1235                 exit(1);
1236
1237         exit(0);
1238 }
1239         ],
1240         [
1241                 ssl_header_ver=`cat conftest.sslincver`
1242                 AC_MSG_RESULT($ssl_header_ver)
1243         ],
1244         [
1245                 AC_MSG_RESULT(not found)
1246                 AC_MSG_ERROR(OpenSSL version header not found.)
1247         ]
1248 )
1249
1250 # Determine OpenSSL library version
1251 AC_MSG_CHECKING([OpenSSL library version])
1252 AC_TRY_RUN(
1253         [
1254 #include <stdio.h>
1255 #include <string.h>
1256 #include <openssl/opensslv.h>
1257 #include <openssl/crypto.h>
1258 #define DATA "conftest.ssllibver"
1259 int main(void) {
1260         FILE *fd;
1261         int rc;
1262
1263         fd = fopen(DATA,"w");
1264         if(fd == NULL)
1265                 exit(1);
1266
1267         if ((rc = fprintf(fd ,"%x (%s)\n", SSLeay(), SSLeay_version(SSLEAY_VERSION))) <0)
1268                 exit(1);
1269
1270         exit(0);
1271 }
1272         ],
1273         [
1274                 ssl_library_ver=`cat conftest.ssllibver`
1275                 AC_MSG_RESULT($ssl_library_ver)
1276         ],
1277         [
1278                 AC_MSG_RESULT(not found)
1279                 AC_MSG_ERROR(OpenSSL library not found.)
1280         ]
1281 )
1282
1283 # Sanity check OpenSSL headers
1284 AC_MSG_CHECKING([whether OpenSSL's headers match the library])
1285 AC_TRY_RUN(
1286         [
1287 #include <string.h>
1288 #include <openssl/opensslv.h>
1289 int main(void) { exit(SSLeay() == OPENSSL_VERSION_NUMBER ? 0 : 1); }
1290         ],
1291         [
1292                 AC_MSG_RESULT(yes)
1293         ],
1294         [
1295                 AC_MSG_RESULT(no)
1296                 AC_MSG_ERROR([Your OpenSSL headers do not match your library.
1297 Check config.log for details.
1298 Also see contrib/findssl.sh for help identifying header/library mismatches.])
1299         ]
1300 )
1301
1302 # Some systems want crypt() from libcrypt, *not* the version in OpenSSL,
1303 # because the system crypt() is more featureful.
1304 if test "x$check_for_libcrypt_before" = "x1"; then
1305         AC_CHECK_LIB(crypt, crypt)
1306 fi
1307
1308 # Some Linux systems (Slackware) need crypt() from libcrypt, *not* the
1309 # version in OpenSSL.
1310 if test "x$check_for_libcrypt_later" = "x1"; then
1311         AC_CHECK_LIB(crypt, crypt, LIBS="$LIBS -lcrypt")
1312 fi
1313
1314
1315 ### Configure cryptographic random number support
1316
1317 # Check wheter OpenSSL seeds itself
1318 AC_MSG_CHECKING([whether OpenSSL's PRNG is internally seeded])
1319 AC_TRY_RUN(
1320         [
1321 #include <string.h>
1322 #include <openssl/rand.h>
1323 int main(void) { exit(RAND_status() == 1 ? 0 : 1); }
1324         ],
1325         [
1326                 OPENSSL_SEEDS_ITSELF=yes
1327                 AC_MSG_RESULT(yes)
1328         ],
1329         [
1330                 AC_MSG_RESULT(no)
1331                 # Default to use of the rand helper if OpenSSL doesn't
1332                 # seed itself
1333                 USE_RAND_HELPER=yes
1334         ]
1335 )
1336
1337
1338 # Do we want to force the use of the rand helper?
1339 AC_ARG_WITH(rand-helper,
1340         [  --with-rand-helper      Use subprocess to gather strong randomness ],
1341         [
1342                 if test "x$withval" = "xno" ; then
1343                         # Force use of OpenSSL's internal RNG, even if
1344                         # the previous test showed it to be unseeded.
1345                         if test -z "$OPENSSL_SEEDS_ITSELF" ; then
1346                                 AC_MSG_WARN([*** Forcing use of OpenSSL's non-self-seeding PRNG])
1347                                 OPENSSL_SEEDS_ITSELF=yes
1348                                 USE_RAND_HELPER=""
1349                         fi
1350                 else
1351                         USE_RAND_HELPER=yes
1352                 fi
1353         ],
1354 )       
1355
1356 # Which randomness source do we use?
1357 if test ! -z "$OPENSSL_SEEDS_ITSELF" -a -z "$USE_RAND_HELPER" ; then
1358         # OpenSSL only
1359         AC_DEFINE(OPENSSL_PRNG_ONLY)
1360         RAND_MSG="OpenSSL internal ONLY"
1361         INSTALL_SSH_RAND_HELPER=""
1362 elif test ! -z "$USE_RAND_HELPER" ; then
1363         # install rand helper
1364         RAND_MSG="ssh-rand-helper"
1365         INSTALL_SSH_RAND_HELPER="yes"
1366 fi
1367 AC_SUBST(INSTALL_SSH_RAND_HELPER)
1368
1369 ### Configuration of ssh-rand-helper
1370
1371 # PRNGD TCP socket
1372 AC_ARG_WITH(prngd-port,
1373         [  --with-prngd-port=PORT  read entropy from PRNGD/EGD TCP localhost:PORT],
1374         [
1375                 case "$withval" in
1376                 no)
1377                         withval=""
1378                         ;;
1379                 [[0-9]]*)
1380                         ;;
1381                 *)
1382                         AC_MSG_ERROR(You must specify a numeric port number for --with-prngd-port)
1383                         ;;
1384                 esac
1385                 if test ! -z "$withval" ; then
1386                         PRNGD_PORT="$withval"
1387                         AC_DEFINE_UNQUOTED(PRNGD_PORT, $PRNGD_PORT)
1388                 fi
1389         ]
1390 )
1391
1392 # PRNGD Unix domain socket
1393 AC_ARG_WITH(prngd-socket,
1394         [  --with-prngd-socket=FILE read entropy from PRNGD/EGD socket FILE (default=/var/run/egd-pool)],
1395         [
1396                 case "$withval" in
1397                 yes)
1398                         withval="/var/run/egd-pool"
1399                         ;;
1400                 no)
1401                         withval=""
1402                         ;;
1403                 /*)
1404                         ;;
1405                 *)
1406                         AC_MSG_ERROR(You must specify an absolute path to the entropy socket)
1407                         ;;
1408                 esac
1409
1410                 if test ! -z "$withval" ; then
1411                         if test ! -z "$PRNGD_PORT" ; then
1412                                 AC_MSG_ERROR(You may not specify both a PRNGD/EGD port and socket)
1413                         fi
1414                         if test ! -r "$withval" ; then
1415                                 AC_MSG_WARN(Entropy socket is not readable)
1416                         fi
1417                         PRNGD_SOCKET="$withval"
1418                         AC_DEFINE_UNQUOTED(PRNGD_SOCKET, "$PRNGD_SOCKET")
1419                 fi
1420         ],
1421         [
1422                 # Check for existing socket only if we don't have a random device already
1423                 if test "$USE_RAND_HELPER" = yes ; then
1424                         AC_MSG_CHECKING(for PRNGD/EGD socket)
1425                         # Insert other locations here
1426                         for sock in /var/run/egd-pool /dev/egd-pool /etc/entropy; do
1427                                 if test -r $sock && $TEST_MINUS_S_SH -c "test -S $sock -o -p $sock" ; then
1428                                         PRNGD_SOCKET="$sock"
1429                                         AC_DEFINE_UNQUOTED(PRNGD_SOCKET, "$PRNGD_SOCKET")
1430                                         break;
1431                                 fi
1432                         done
1433                         if test ! -z "$PRNGD_SOCKET" ; then
1434                                 AC_MSG_RESULT($PRNGD_SOCKET)
1435                         else
1436                                 AC_MSG_RESULT(not found)
1437                         fi
1438                 fi
1439         ]
1440 )
1441
1442 # Change default command timeout for hashing entropy source
1443 entropy_timeout=200
1444 AC_ARG_WITH(entropy-timeout,
1445         [  --with-entropy-timeout  Specify entropy gathering command timeout (msec)],
1446         [
1447                 if test "x$withval" != "xno" ; then
1448                         entropy_timeout=$withval
1449                 fi
1450         ]       
1451 )
1452 AC_DEFINE_UNQUOTED(ENTROPY_TIMEOUT_MSEC, $entropy_timeout)
1453
1454 SSH_PRIVSEP_USER=sshd
1455 AC_ARG_WITH(privsep-user,
1456         [  --with-privsep-user=user Specify non-privileged user for privilege separation],
1457         [
1458                 if test -n "$withval"; then
1459                         SSH_PRIVSEP_USER=$withval
1460                 fi
1461         ]       
1462 )
1463 AC_DEFINE_UNQUOTED(SSH_PRIVSEP_USER, "$SSH_PRIVSEP_USER")
1464 AC_SUBST(SSH_PRIVSEP_USER)
1465
1466 # We do this little dance with the search path to insure
1467 # that programs that we select for use by installed programs
1468 # (which may be run by the super-user) come from trusted
1469 # locations before they come from the user's private area.
1470 # This should help avoid accidentally configuring some
1471 # random version of a program in someone's personal bin.
1472
1473 OPATH=$PATH
1474 PATH=/bin:/usr/bin
1475 test -h /bin 2> /dev/null && PATH=/usr/bin
1476 test -d /sbin && PATH=$PATH:/sbin
1477 test -d /usr/sbin && PATH=$PATH:/usr/sbin
1478 PATH=$PATH:/etc:$OPATH
1479
1480 # These programs are used by the command hashing source to gather entropy
1481 OSSH_PATH_ENTROPY_PROG(PROG_LS, ls)
1482 OSSH_PATH_ENTROPY_PROG(PROG_NETSTAT, netstat)
1483 OSSH_PATH_ENTROPY_PROG(PROG_ARP, arp)
1484 OSSH_PATH_ENTROPY_PROG(PROG_IFCONFIG, ifconfig)
1485 OSSH_PATH_ENTROPY_PROG(PROG_JSTAT, jstat)
1486 OSSH_PATH_ENTROPY_PROG(PROG_PS, ps)
1487 OSSH_PATH_ENTROPY_PROG(PROG_SAR, sar)
1488 OSSH_PATH_ENTROPY_PROG(PROG_W, w)
1489 OSSH_PATH_ENTROPY_PROG(PROG_WHO, who)
1490 OSSH_PATH_ENTROPY_PROG(PROG_LAST, last)
1491 OSSH_PATH_ENTROPY_PROG(PROG_LASTLOG, lastlog)
1492 OSSH_PATH_ENTROPY_PROG(PROG_DF, df)
1493 OSSH_PATH_ENTROPY_PROG(PROG_VMSTAT, vmstat)
1494 OSSH_PATH_ENTROPY_PROG(PROG_UPTIME, uptime)
1495 OSSH_PATH_ENTROPY_PROG(PROG_IPCS, ipcs)
1496 OSSH_PATH_ENTROPY_PROG(PROG_TAIL, tail)
1497 # restore PATH
1498 PATH=$OPATH
1499
1500 # Where does ssh-rand-helper get its randomness from?
1501 INSTALL_SSH_PRNG_CMDS=""
1502 if test ! -z "$INSTALL_SSH_RAND_HELPER" ; then
1503         if test ! -z "$PRNGD_PORT" ; then
1504                 RAND_HELPER_MSG="TCP localhost:$PRNGD_PORT"
1505         elif test ! -z "$PRNGD_SOCKET" ; then
1506                 RAND_HELPER_MSG="Unix domain socket \"$PRNGD_SOCKET\""
1507         else
1508                 RAND_HELPER_MSG="Command hashing (timeout $entropy_timeout)"
1509                 RAND_HELPER_CMDHASH=yes
1510                 INSTALL_SSH_PRNG_CMDS="yes"
1511         fi
1512 fi
1513 AC_SUBST(INSTALL_SSH_PRNG_CMDS)
1514
1515
1516 # Cheap hack to ensure NEWS-OS libraries are arranged right.
1517 if test ! -z "$SONY" ; then
1518   LIBS="$LIBS -liberty";
1519 fi
1520
1521 # Checks for data types
1522 AC_CHECK_SIZEOF(char, 1)
1523 AC_CHECK_SIZEOF(short int, 2)
1524 AC_CHECK_SIZEOF(int, 4)
1525 AC_CHECK_SIZEOF(long int, 4)
1526 AC_CHECK_SIZEOF(long long int, 8)
1527
1528 # Sanity check long long for some platforms (AIX)
1529 if test "x$ac_cv_sizeof_long_long_int" = "x4" ; then
1530         ac_cv_sizeof_long_long_int=0
1531 fi
1532
1533 # More checks for data types
1534 AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [
1535         AC_TRY_COMPILE(
1536                 [ #include <sys/types.h> ],
1537                 [ u_int a; a = 1;],
1538                 [ ac_cv_have_u_int="yes" ],
1539                 [ ac_cv_have_u_int="no" ]
1540         )
1541 ])
1542 if test "x$ac_cv_have_u_int" = "xyes" ; then
1543         AC_DEFINE(HAVE_U_INT)
1544         have_u_int=1
1545 fi
1546
1547 AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [
1548         AC_TRY_COMPILE(
1549                 [ #include <sys/types.h> ],
1550                 [ int8_t a; int16_t b; int32_t c; a = b = c = 1;],
1551                 [ ac_cv_have_intxx_t="yes" ],
1552                 [ ac_cv_have_intxx_t="no" ]
1553         )
1554 ])
1555 if test "x$ac_cv_have_intxx_t" = "xyes" ; then
1556         AC_DEFINE(HAVE_INTXX_T)
1557         have_intxx_t=1
1558 fi
1559
1560 if (test -z "$have_intxx_t" && \
1561            test "x$ac_cv_header_stdint_h" = "xyes")
1562 then
1563     AC_MSG_CHECKING([for intXX_t types in stdint.h])
1564         AC_TRY_COMPILE(
1565                 [ #include <stdint.h> ],
1566                 [ int8_t a; int16_t b; int32_t c; a = b = c = 1;],
1567                 [
1568                         AC_DEFINE(HAVE_INTXX_T)
1569                         AC_MSG_RESULT(yes)
1570                 ],
1571                 [ AC_MSG_RESULT(no) ]
1572         )
1573 fi
1574
1575 AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [
1576         AC_TRY_COMPILE(
1577                 [
1578 #include <sys/types.h>
1579 #ifdef HAVE_STDINT_H
1580 # include <stdint.h>
1581 #endif
1582 #include <sys/socket.h>
1583 #ifdef HAVE_SYS_BITYPES_H
1584 # include <sys/bitypes.h>
1585 #endif
1586                 ],
1587                 [ int64_t a; a = 1;],
1588                 [ ac_cv_have_int64_t="yes" ],
1589                 [ ac_cv_have_int64_t="no" ]
1590         )
1591 ])
1592 if test "x$ac_cv_have_int64_t" = "xyes" ; then
1593         AC_DEFINE(HAVE_INT64_T)
1594 fi
1595
1596 AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [
1597         AC_TRY_COMPILE(
1598                 [ #include <sys/types.h> ],
1599                 [ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;],
1600                 [ ac_cv_have_u_intxx_t="yes" ],
1601                 [ ac_cv_have_u_intxx_t="no" ]
1602         )
1603 ])
1604 if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
1605         AC_DEFINE(HAVE_U_INTXX_T)
1606         have_u_intxx_t=1
1607 fi
1608
1609 if test -z "$have_u_intxx_t" ; then
1610     AC_MSG_CHECKING([for u_intXX_t types in sys/socket.h])
1611         AC_TRY_COMPILE(
1612                 [ #include <sys/socket.h> ],
1613                 [ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;],
1614                 [
1615                         AC_DEFINE(HAVE_U_INTXX_T)
1616                         AC_MSG_RESULT(yes)
1617                 ],
1618                 [ AC_MSG_RESULT(no) ]
1619         )
1620 fi
1621
1622 AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [
1623         AC_TRY_COMPILE(
1624                 [ #include <sys/types.h> ],
1625                 [ u_int64_t a; a = 1;],
1626                 [ ac_cv_have_u_int64_t="yes" ],
1627                 [ ac_cv_have_u_int64_t="no" ]
1628         )
1629 ])
1630 if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
1631         AC_DEFINE(HAVE_U_INT64_T)
1632         have_u_int64_t=1
1633 fi
1634
1635 if test -z "$have_u_int64_t" ; then
1636     AC_MSG_CHECKING([for u_int64_t type in sys/bitypes.h])
1637         AC_TRY_COMPILE(
1638                 [ #include <sys/bitypes.h> ],
1639                 [ u_int64_t a; a = 1],
1640                 [
1641                         AC_DEFINE(HAVE_U_INT64_T)
1642                         AC_MSG_RESULT(yes)
1643                 ],
1644                 [ AC_MSG_RESULT(no) ]
1645         )
1646 fi
1647
1648 if test -z "$have_u_intxx_t" ; then
1649         AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [
1650                 AC_TRY_COMPILE(
1651                         [
1652 #include <sys/types.h>
1653                         ],
1654                         [ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1; ],
1655                         [ ac_cv_have_uintxx_t="yes" ],
1656                         [ ac_cv_have_uintxx_t="no" ]
1657                 )
1658         ])
1659         if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
1660                 AC_DEFINE(HAVE_UINTXX_T)
1661         fi
1662 fi
1663
1664 if test -z "$have_uintxx_t" ; then
1665     AC_MSG_CHECKING([for uintXX_t types in stdint.h])
1666         AC_TRY_COMPILE(
1667                 [ #include <stdint.h> ],
1668                 [ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;],
1669                 [
1670                         AC_DEFINE(HAVE_UINTXX_T)
1671                         AC_MSG_RESULT(yes)
1672                 ],
1673                 [ AC_MSG_RESULT(no) ]
1674         )
1675 fi
1676
1677 if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
1678            test "x$ac_cv_header_sys_bitypes_h" = "xyes")
1679 then
1680         AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
1681         AC_TRY_COMPILE(
1682                 [
1683 #include <sys/bitypes.h>
1684                 ],
1685                 [
1686                         int8_t a; int16_t b; int32_t c;
1687                         u_int8_t e; u_int16_t f; u_int32_t g;
1688                         a = b = c = e = f = g = 1;
1689                 ],
1690                 [
1691                         AC_DEFINE(HAVE_U_INTXX_T)
1692                         AC_DEFINE(HAVE_INTXX_T)
1693                         AC_MSG_RESULT(yes)
1694                 ],
1695                 [AC_MSG_RESULT(no)]
1696         )
1697 fi
1698
1699
1700 AC_CACHE_CHECK([for u_char], ac_cv_have_u_char, [
1701         AC_TRY_COMPILE(
1702                 [
1703 #include <sys/types.h>
1704                 ],
1705                 [ u_char foo; foo = 125; ],
1706                 [ ac_cv_have_u_char="yes" ],
1707                 [ ac_cv_have_u_char="no" ]
1708         )
1709 ])
1710 if test "x$ac_cv_have_u_char" = "xyes" ; then
1711         AC_DEFINE(HAVE_U_CHAR)
1712 fi
1713
1714 TYPE_SOCKLEN_T
1715
1716 AC_CHECK_TYPES(sig_atomic_t,,,[#include <signal.h>])
1717
1718 AC_CACHE_CHECK([for size_t], ac_cv_have_size_t, [
1719         AC_TRY_COMPILE(
1720                 [
1721 #include <sys/types.h>
1722                 ],
1723                 [ size_t foo; foo = 1235; ],
1724                 [ ac_cv_have_size_t="yes" ],
1725                 [ ac_cv_have_size_t="no" ]
1726         )
1727 ])
1728 if test "x$ac_cv_have_size_t" = "xyes" ; then
1729         AC_DEFINE(HAVE_SIZE_T)
1730 fi
1731
1732 AC_CACHE_CHECK([for ssize_t], ac_cv_have_ssize_t, [
1733         AC_TRY_COMPILE(
1734                 [
1735 #include <sys/types.h>
1736                 ],
1737                 [ ssize_t foo; foo = 1235; ],
1738                 [ ac_cv_have_ssize_t="yes" ],
1739                 [ ac_cv_have_ssize_t="no" ]
1740         )
1741 ])
1742 if test "x$ac_cv_have_ssize_t" = "xyes" ; then
1743         AC_DEFINE(HAVE_SSIZE_T)
1744 fi
1745
1746 AC_CACHE_CHECK([for clock_t], ac_cv_have_clock_t, [
1747         AC_TRY_COMPILE(
1748                 [
1749 #include <time.h>
1750                 ],
1751                 [ clock_t foo; foo = 1235; ],
1752                 [ ac_cv_have_clock_t="yes" ],
1753                 [ ac_cv_have_clock_t="no" ]
1754         )
1755 ])
1756 if test "x$ac_cv_have_clock_t" = "xyes" ; then
1757         AC_DEFINE(HAVE_CLOCK_T)
1758 fi
1759
1760 AC_CACHE_CHECK([for sa_family_t], ac_cv_have_sa_family_t, [
1761         AC_TRY_COMPILE(
1762                 [
1763 #include <sys/types.h>
1764 #include <sys/socket.h>
1765                 ],
1766                 [ sa_family_t foo; foo = 1235; ],
1767                 [ ac_cv_have_sa_family_t="yes" ],
1768                 [ AC_TRY_COMPILE(
1769                   [
1770 #include <sys/types.h>
1771 #include <sys/socket.h>
1772 #include <netinet/in.h>
1773                 ],
1774                 [ sa_family_t foo; foo = 1235; ],
1775                 [ ac_cv_have_sa_family_t="yes" ],
1776
1777                 [ ac_cv_have_sa_family_t="no" ]
1778         )]
1779         )
1780 ])
1781 if test "x$ac_cv_have_sa_family_t" = "xyes" ; then
1782         AC_DEFINE(HAVE_SA_FAMILY_T)
1783 fi
1784
1785 AC_CACHE_CHECK([for pid_t], ac_cv_have_pid_t, [
1786         AC_TRY_COMPILE(
1787                 [
1788 #include <sys/types.h>
1789                 ],
1790                 [ pid_t foo; foo = 1235; ],
1791                 [ ac_cv_have_pid_t="yes" ],
1792                 [ ac_cv_have_pid_t="no" ]
1793         )
1794 ])
1795 if test "x$ac_cv_have_pid_t" = "xyes" ; then
1796         AC_DEFINE(HAVE_PID_T)
1797 fi
1798
1799 AC_CACHE_CHECK([for mode_t], ac_cv_have_mode_t, [
1800         AC_TRY_COMPILE(
1801                 [
1802 #include <sys/types.h>
1803                 ],
1804                 [ mode_t foo; foo = 1235; ],
1805                 [ ac_cv_have_mode_t="yes" ],
1806                 [ ac_cv_have_mode_t="no" ]
1807         )
1808 ])
1809 if test "x$ac_cv_have_mode_t" = "xyes" ; then
1810         AC_DEFINE(HAVE_MODE_T)
1811 fi
1812
1813
1814 AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_have_struct_sockaddr_storage, [
1815         AC_TRY_COMPILE(
1816                 [
1817 #include <sys/types.h>
1818 #include <sys/socket.h>
1819                 ],
1820                 [ struct sockaddr_storage s; ],
1821                 [ ac_cv_have_struct_sockaddr_storage="yes" ],
1822                 [ ac_cv_have_struct_sockaddr_storage="no" ]
1823         )
1824 ])
1825 if test "x$ac_cv_have_struct_sockaddr_storage" = "xyes" ; then
1826         AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE)
1827 fi
1828
1829 AC_CACHE_CHECK([for struct sockaddr_in6], ac_cv_have_struct_sockaddr_in6, [
1830         AC_TRY_COMPILE(
1831                 [
1832 #include <sys/types.h>
1833 #include <netinet/in.h>
1834                 ],
1835                 [ struct sockaddr_in6 s; s.sin6_family = 0; ],
1836                 [ ac_cv_have_struct_sockaddr_in6="yes" ],
1837                 [ ac_cv_have_struct_sockaddr_in6="no" ]
1838         )
1839 ])
1840 if test "x$ac_cv_have_struct_sockaddr_in6" = "xyes" ; then
1841         AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6)
1842 fi
1843
1844 AC_CACHE_CHECK([for struct in6_addr], ac_cv_have_struct_in6_addr, [
1845         AC_TRY_COMPILE(
1846                 [
1847 #include <sys/types.h>
1848 #include <netinet/in.h>
1849                 ],
1850                 [ struct in6_addr s; s.s6_addr[0] = 0; ],
1851                 [ ac_cv_have_struct_in6_addr="yes" ],
1852                 [ ac_cv_have_struct_in6_addr="no" ]
1853         )
1854 ])
1855 if test "x$ac_cv_have_struct_in6_addr" = "xyes" ; then
1856         AC_DEFINE(HAVE_STRUCT_IN6_ADDR)
1857 fi
1858
1859 AC_CACHE_CHECK([for struct addrinfo], ac_cv_have_struct_addrinfo, [
1860         AC_TRY_COMPILE(
1861                 [
1862 #include <sys/types.h>
1863 #include <sys/socket.h>
1864 #include <netdb.h>
1865                 ],
1866                 [ struct addrinfo s; s.ai_flags = AI_PASSIVE; ],
1867                 [ ac_cv_have_struct_addrinfo="yes" ],
1868                 [ ac_cv_have_struct_addrinfo="no" ]
1869         )
1870 ])
1871 if test "x$ac_cv_have_struct_addrinfo" = "xyes" ; then
1872         AC_DEFINE(HAVE_STRUCT_ADDRINFO)
1873 fi
1874
1875 AC_CACHE_CHECK([for struct timeval], ac_cv_have_struct_timeval, [
1876         AC_TRY_COMPILE(
1877                 [ #include <sys/time.h> ],
1878                 [ struct timeval tv; tv.tv_sec = 1;],
1879                 [ ac_cv_have_struct_timeval="yes" ],
1880                 [ ac_cv_have_struct_timeval="no" ]
1881         )
1882 ])
1883 if test "x$ac_cv_have_struct_timeval" = "xyes" ; then
1884         AC_DEFINE(HAVE_STRUCT_TIMEVAL)
1885         have_struct_timeval=1
1886 fi
1887
1888 AC_CHECK_TYPES(struct timespec)
1889
1890 # We need int64_t or else certian parts of the compile will fail.
1891 if test "x$ac_cv_have_int64_t" = "xno" -a \
1892         "x$ac_cv_sizeof_long_int" != "x8" -a \
1893         "x$ac_cv_sizeof_long_long_int" = "x0" ; then
1894         echo "OpenSSH requires int64_t support.  Contact your vendor or install"
1895         echo "an alternative compiler (I.E., GCC) before continuing."
1896         echo ""
1897         exit 1;
1898 else
1899 dnl test snprintf (broken on SCO w/gcc)
1900         AC_TRY_RUN(
1901                 [
1902 #include <stdio.h>
1903 #include <string.h>
1904 #ifdef HAVE_SNPRINTF
1905 main()
1906 {
1907         char buf[50];
1908         char expected_out[50];
1909         int mazsize = 50 ;
1910 #if (SIZEOF_LONG_INT == 8)
1911         long int num = 0x7fffffffffffffff;
1912 #else
1913         long long num = 0x7fffffffffffffffll;
1914 #endif
1915         strcpy(expected_out, "9223372036854775807");
1916         snprintf(buf, mazsize, "%lld", num);
1917         if(strcmp(buf, expected_out) != 0)
1918                 exit(1);
1919         exit(0);
1920 }
1921 #else
1922 main() { exit(0); }
1923 #endif
1924                 ], [ true ], [ AC_DEFINE(BROKEN_SNPRINTF) ]
1925         )
1926 fi
1927
1928 dnl Checks for structure members
1929 OSSH_CHECK_HEADER_FOR_FIELD(ut_host, utmp.h, HAVE_HOST_IN_UTMP)
1930 OSSH_CHECK_HEADER_FOR_FIELD(ut_host, utmpx.h, HAVE_HOST_IN_UTMPX)
1931 OSSH_CHECK_HEADER_FOR_FIELD(syslen, utmpx.h, HAVE_SYSLEN_IN_UTMPX)
1932 OSSH_CHECK_HEADER_FOR_FIELD(ut_pid, utmp.h, HAVE_PID_IN_UTMP)
1933 OSSH_CHECK_HEADER_FOR_FIELD(ut_type, utmp.h, HAVE_TYPE_IN_UTMP)
1934 OSSH_CHECK_HEADER_FOR_FIELD(ut_type, utmpx.h, HAVE_TYPE_IN_UTMPX)
1935 OSSH_CHECK_HEADER_FOR_FIELD(ut_tv, utmp.h, HAVE_TV_IN_UTMP)
1936 OSSH_CHECK_HEADER_FOR_FIELD(ut_id, utmp.h, HAVE_ID_IN_UTMP)
1937 OSSH_CHECK_HEADER_FOR_FIELD(ut_id, utmpx.h, HAVE_ID_IN_UTMPX)
1938 OSSH_CHECK_HEADER_FOR_FIELD(ut_addr, utmp.h, HAVE_ADDR_IN_UTMP)
1939 OSSH_CHECK_HEADER_FOR_FIELD(ut_addr, utmpx.h, HAVE_ADDR_IN_UTMPX)
1940 OSSH_CHECK_HEADER_FOR_FIELD(ut_addr_v6, utmp.h, HAVE_ADDR_V6_IN_UTMP)
1941 OSSH_CHECK_HEADER_FOR_FIELD(ut_addr_v6, utmpx.h, HAVE_ADDR_V6_IN_UTMPX)
1942 OSSH_CHECK_HEADER_FOR_FIELD(ut_exit, utmp.h, HAVE_EXIT_IN_UTMP)
1943 OSSH_CHECK_HEADER_FOR_FIELD(ut_time, utmp.h, HAVE_TIME_IN_UTMP)
1944 OSSH_CHECK_HEADER_FOR_FIELD(ut_time, utmpx.h, HAVE_TIME_IN_UTMPX)
1945 OSSH_CHECK_HEADER_FOR_FIELD(ut_tv, utmpx.h, HAVE_TV_IN_UTMPX)
1946
1947 AC_CHECK_MEMBERS([struct stat.st_blksize])
1948
1949 AC_CACHE_CHECK([for ss_family field in struct sockaddr_storage],
1950                 ac_cv_have_ss_family_in_struct_ss, [
1951         AC_TRY_COMPILE(
1952                 [
1953 #include <sys/types.h>
1954 #include <sys/socket.h>
1955                 ],
1956                 [ struct sockaddr_storage s; s.ss_family = 1; ],
1957                 [ ac_cv_have_ss_family_in_struct_ss="yes" ],
1958                 [ ac_cv_have_ss_family_in_struct_ss="no" ],
1959         )
1960 ])
1961 if test "x$ac_cv_have_ss_family_in_struct_ss" = "xyes" ; then
1962         AC_DEFINE(HAVE_SS_FAMILY_IN_SS)
1963 fi
1964
1965 AC_CACHE_CHECK([for __ss_family field in struct sockaddr_storage],
1966                 ac_cv_have___ss_family_in_struct_ss, [
1967         AC_TRY_COMPILE(
1968                 [
1969 #include <sys/types.h>
1970 #include <sys/socket.h>
1971                 ],
1972                 [ struct sockaddr_storage s; s.__ss_family = 1; ],
1973                 [ ac_cv_have___ss_family_in_struct_ss="yes" ],
1974                 [ ac_cv_have___ss_family_in_struct_ss="no" ]
1975         )
1976 ])
1977 if test "x$ac_cv_have___ss_family_in_struct_ss" = "xyes" ; then
1978         AC_DEFINE(HAVE___SS_FAMILY_IN_SS)
1979 fi
1980
1981 AC_CACHE_CHECK([for pw_class field in struct passwd],
1982                 ac_cv_have_pw_class_in_struct_passwd, [
1983         AC_TRY_COMPILE(
1984                 [
1985 #include <pwd.h>
1986                 ],
1987                 [ struct passwd p; p.pw_class = 0; ],
1988                 [ ac_cv_have_pw_class_in_struct_passwd="yes" ],
1989                 [ ac_cv_have_pw_class_in_struct_passwd="no" ]
1990         )
1991 ])
1992 if test "x$ac_cv_have_pw_class_in_struct_passwd" = "xyes" ; then
1993         AC_DEFINE(HAVE_PW_CLASS_IN_PASSWD)
1994 fi
1995
1996 AC_CACHE_CHECK([for pw_expire field in struct passwd],
1997                 ac_cv_have_pw_expire_in_struct_passwd, [
1998         AC_TRY_COMPILE(
1999                 [
2000 #include <pwd.h>
2001                 ],
2002                 [ struct passwd p; p.pw_expire = 0; ],
2003                 [ ac_cv_have_pw_expire_in_struct_passwd="yes" ],
2004                 [ ac_cv_have_pw_expire_in_struct_passwd="no" ]
2005         )
2006 ])
2007 if test "x$ac_cv_have_pw_expire_in_struct_passwd" = "xyes" ; then
2008         AC_DEFINE(HAVE_PW_EXPIRE_IN_PASSWD)
2009 fi
2010
2011 AC_CACHE_CHECK([for pw_change field in struct passwd],
2012                 ac_cv_have_pw_change_in_struct_passwd, [
2013         AC_TRY_COMPILE(
2014                 [
2015 #include <pwd.h>
2016                 ],
2017                 [ struct passwd p; p.pw_change = 0; ],
2018                 [ ac_cv_have_pw_change_in_struct_passwd="yes" ],
2019                 [ ac_cv_have_pw_change_in_struct_passwd="no" ]
2020         )
2021 ])
2022 if test "x$ac_cv_have_pw_change_in_struct_passwd" = "xyes" ; then
2023         AC_DEFINE(HAVE_PW_CHANGE_IN_PASSWD)
2024 fi
2025
2026 dnl make sure we're using the real structure members and not defines
2027 AC_CACHE_CHECK([for msg_accrights field in struct msghdr],
2028                 ac_cv_have_accrights_in_msghdr, [
2029         AC_TRY_RUN(
2030                 [
2031 #include <sys/types.h>
2032 #include <sys/socket.h>
2033 #include <sys/uio.h>
2034 int main() {
2035 #ifdef msg_accrights
2036 exit(1);
2037 #endif
2038 struct msghdr m;
2039 m.msg_accrights = 0;
2040 exit(0);
2041 }
2042                 ],
2043                 [ ac_cv_have_accrights_in_msghdr="yes" ],
2044                 [ ac_cv_have_accrights_in_msghdr="no" ]
2045         )
2046 ])
2047 if test "x$ac_cv_have_accrights_in_msghdr" = "xyes" ; then
2048         AC_DEFINE(HAVE_ACCRIGHTS_IN_MSGHDR)
2049 fi
2050
2051 AC_CACHE_CHECK([for msg_control field in struct msghdr],
2052                 ac_cv_have_control_in_msghdr, [
2053         AC_TRY_RUN(
2054                 [
2055 #include <sys/types.h>
2056 #include <sys/socket.h>
2057 #include <sys/uio.h>
2058 int main() {
2059 #ifdef msg_control
2060 exit(1);
2061 #endif
2062 struct msghdr m;
2063 m.msg_control = 0;
2064 exit(0);
2065 }
2066                 ],
2067                 [ ac_cv_have_control_in_msghdr="yes" ],
2068                 [ ac_cv_have_control_in_msghdr="no" ]
2069         )
2070 ])
2071 if test "x$ac_cv_have_control_in_msghdr" = "xyes" ; then
2072         AC_DEFINE(HAVE_CONTROL_IN_MSGHDR)
2073 fi
2074
2075 AC_CACHE_CHECK([if libc defines __progname], ac_cv_libc_defines___progname, [
2076         AC_TRY_LINK([],
2077                 [ extern char *__progname; printf("%s", __progname); ],
2078                 [ ac_cv_libc_defines___progname="yes" ],
2079                 [ ac_cv_libc_defines___progname="no" ]
2080         )
2081 ])
2082 if test "x$ac_cv_libc_defines___progname" = "xyes" ; then
2083         AC_DEFINE(HAVE___PROGNAME)
2084 fi
2085
2086 AC_CACHE_CHECK([whether $CC implements __FUNCTION__], ac_cv_cc_implements___FUNCTION__, [
2087         AC_TRY_LINK([
2088 #include <stdio.h>
2089 ],
2090                 [ printf("%s", __FUNCTION__); ],
2091                 [ ac_cv_cc_implements___FUNCTION__="yes" ],
2092                 [ ac_cv_cc_implements___FUNCTION__="no" ]
2093         )
2094 ])
2095 if test "x$ac_cv_cc_implements___FUNCTION__" = "xyes" ; then
2096         AC_DEFINE(HAVE___FUNCTION__)
2097 fi
2098
2099 AC_CACHE_CHECK([whether $CC implements __func__], ac_cv_cc_implements___func__, [
2100         AC_TRY_LINK([
2101 #include <stdio.h>
2102 ],
2103                 [ printf("%s", __func__); ],
2104                 [ ac_cv_cc_implements___func__="yes" ],
2105                 [ ac_cv_cc_implements___func__="no" ]
2106         )
2107 ])
2108 if test "x$ac_cv_cc_implements___func__" = "xyes" ; then
2109         AC_DEFINE(HAVE___func__)
2110 fi
2111
2112 AC_CACHE_CHECK([whether getopt has optreset support],
2113                 ac_cv_have_getopt_optreset, [
2114         AC_TRY_LINK(
2115                 [
2116 #include <getopt.h>
2117                 ],
2118                 [ extern int optreset; optreset = 0; ],
2119                 [ ac_cv_have_getopt_optreset="yes" ],
2120                 [ ac_cv_have_getopt_optreset="no" ]
2121         )
2122 ])
2123 if test "x$ac_cv_have_getopt_optreset" = "xyes" ; then
2124         AC_DEFINE(HAVE_GETOPT_OPTRESET)
2125 fi
2126
2127 AC_CACHE_CHECK([if libc defines sys_errlist], ac_cv_libc_defines_sys_errlist, [
2128         AC_TRY_LINK([],
2129                 [ extern const char *const sys_errlist[]; printf("%s", sys_errlist[0]);],
2130                 [ ac_cv_libc_defines_sys_errlist="yes" ],
2131                 [ ac_cv_libc_defines_sys_errlist="no" ]
2132         )
2133 ])
2134 if test "x$ac_cv_libc_defines_sys_errlist" = "xyes" ; then
2135         AC_DEFINE(HAVE_SYS_ERRLIST)
2136 fi
2137
2138
2139 AC_CACHE_CHECK([if libc defines sys_nerr], ac_cv_libc_defines_sys_nerr, [
2140         AC_TRY_LINK([],
2141                 [ extern int sys_nerr; printf("%i", sys_nerr);],
2142                 [ ac_cv_libc_defines_sys_nerr="yes" ],
2143                 [ ac_cv_libc_defines_sys_nerr="no" ]
2144         )
2145 ])
2146 if test "x$ac_cv_libc_defines_sys_nerr" = "xyes" ; then
2147         AC_DEFINE(HAVE_SYS_NERR)
2148 fi
2149
2150 SCARD_MSG="no"
2151 # Check whether user wants sectok support
2152 AC_ARG_WITH(sectok,
2153         [  --with-sectok           Enable smartcard support using libsectok],
2154         [
2155                 if test "x$withval" != "xno" ; then
2156                         if test "x$withval" != "xyes" ; then
2157                                 CPPFLAGS="$CPPFLAGS -I${withval}"
2158                                 LDFLAGS="$LDFLAGS -L${withval}"
2159                                 if test ! -z "$need_dash_r" ; then
2160                                         LDFLAGS="$LDFLAGS -R${withval}"
2161                                 fi
2162                                 if test ! -z "$blibpath" ; then
2163                                         blibpath="$blibpath:${withval}"
2164                                 fi
2165                         fi
2166                         AC_CHECK_HEADERS(sectok.h)
2167                         if test "$ac_cv_header_sectok_h" != yes; then
2168                                 AC_MSG_ERROR(Can't find sectok.h)
2169                         fi
2170                         AC_CHECK_LIB(sectok, sectok_open)
2171                         if test "$ac_cv_lib_sectok_sectok_open" != yes; then
2172                                 AC_MSG_ERROR(Can't find libsectok)
2173                         fi
2174                         AC_DEFINE(SMARTCARD)
2175                         AC_DEFINE(USE_SECTOK)
2176                         SCARD_MSG="yes, using sectok"
2177                 fi
2178         ]
2179 )
2180
2181 # Check whether user wants OpenSC support
2182 AC_ARG_WITH(opensc,
2183         AC_HELP_STRING([--with-opensc=PFX],
2184                        [Enable smartcard support using OpenSC]),
2185         opensc_config_prefix="$withval", opensc_config_prefix="")
2186 if test x$opensc_config_prefix != x ; then
2187   OPENSC_CONFIG=$opensc_config_prefix/bin/opensc-config
2188   AC_PATH_PROG(OPENSC_CONFIG, opensc-config, no)
2189   if test "$OPENSC_CONFIG" != "no"; then
2190     LIBOPENSC_CFLAGS=`$OPENSC_CONFIG --cflags`
2191     LIBOPENSC_LIBS=`$OPENSC_CONFIG --libs`
2192     CPPFLAGS="$CPPFLAGS $LIBOPENSC_CFLAGS"
2193     LDFLAGS="$LDFLAGS $LIBOPENSC_LIBS"
2194     AC_DEFINE(SMARTCARD)
2195     AC_DEFINE(USE_OPENSC)
2196     SCARD_MSG="yes, using OpenSC"
2197   fi
2198 fi
2199
2200 # Check libraries needed by DNS fingerprint support
2201 AC_SEARCH_LIBS(getrrsetbyname, resolv,
2202         [AC_DEFINE(HAVE_GETRRSETBYNAME)],
2203         [
2204                 # Needed by our getrrsetbyname()
2205                 AC_SEARCH_LIBS(res_query, resolv)
2206                 AC_SEARCH_LIBS(dn_expand, resolv)
2207                 AC_CHECK_FUNCS(_getshort _getlong)
2208                 AC_CHECK_MEMBER(HEADER.ad,
2209                         [AC_DEFINE(HAVE_HEADER_AD)],,
2210                         [#include <arpa/nameser.h>])
2211         ])
2212
2213 # Check whether user wants Kerberos 5 support
2214 KRB5_MSG="no"
2215 AC_ARG_WITH(kerberos5,
2216         [  --with-kerberos5=PATH   Enable Kerberos 5 support],
2217         [ if test "x$withval" != "xno" ; then
2218                 if test "x$withval" = "xyes" ; then
2219                         KRB5ROOT="/usr/local"
2220                 else
2221                         KRB5ROOT=${withval}
2222                 fi
2223
2224                 AC_DEFINE(KRB5)
2225                 KRB5_MSG="yes"
2226
2227                 AC_MSG_CHECKING(for krb5-config)
2228                 if test -x  $KRB5ROOT/bin/krb5-config ; then
2229                         KRB5CONF=$KRB5ROOT/bin/krb5-config
2230                         AC_MSG_RESULT($KRB5CONF)
2231
2232                         AC_MSG_CHECKING(for gssapi support)
2233                         if $KRB5CONF | grep gssapi >/dev/null ; then
2234                                 AC_MSG_RESULT(yes)
2235                                 AC_DEFINE(GSSAPI)
2236                                 k5confopts=gssapi
2237                         else
2238                                 AC_MSG_RESULT(no)
2239                                 k5confopts=""
2240                         fi
2241                         K5CFLAGS="`$KRB5CONF --cflags $k5confopts`"
2242                         K5LIBS="`$KRB5CONF --libs $k5confopts`"
2243                         CPPFLAGS="$CPPFLAGS $K5CFLAGS"
2244                         AC_MSG_CHECKING(whether we are using Heimdal)
2245                         AC_TRY_COMPILE([ #include <krb5.h> ],
2246                                        [ char *tmp = heimdal_version; ],
2247                                        [ AC_MSG_RESULT(yes)
2248                                          AC_DEFINE(HEIMDAL) ],
2249                                          AC_MSG_RESULT(no)
2250                         )
2251                 else
2252                         AC_MSG_RESULT(no)
2253                         CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include"
2254                         LDFLAGS="$LDFLAGS -L${KRB5ROOT}/lib"
2255                         AC_MSG_CHECKING(whether we are using Heimdal)
2256                         AC_TRY_COMPILE([ #include <krb5.h> ],
2257                                        [ char *tmp = heimdal_version; ],
2258                                        [ AC_MSG_RESULT(yes)
2259                                          AC_DEFINE(HEIMDAL)
2260                                          K5LIBS="-lkrb5 -ldes -lcom_err -lasn1 -lroken"
2261                                        ],
2262                                        [ AC_MSG_RESULT(no)
2263                                          K5LIBS="-lkrb5 -lk5crypto -lcom_err"
2264                                        ]
2265                         )
2266                         AC_SEARCH_LIBS(dn_expand, resolv)
2267
2268                         AC_CHECK_LIB(gssapi,gss_init_sec_context,
2269                                 [ AC_DEFINE(GSSAPI)
2270                                   K5LIBS="-lgssapi $K5LIBS" ],
2271                                 [ AC_CHECK_LIB(gssapi_krb5,gss_init_sec_context,
2272                                         [ AC_DEFINE(GSSAPI)
2273                                           K5LIBS="-lgssapi_krb5 $K5LIBS" ],
2274                                         AC_MSG_WARN([Cannot find any suitable gss-api library - build may fail]),
2275                                         $K5LIBS)
2276                                 ],
2277                                 $K5LIBS)
2278                         
2279                         AC_CHECK_HEADER(gssapi.h, ,
2280                                 [ unset ac_cv_header_gssapi_h
2281                                   CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
2282                                   AC_CHECK_HEADERS(gssapi.h, ,
2283                                         AC_MSG_WARN([Cannot find any suitable gss-api header - build may fail])
2284                                   )
2285                                 ]
2286                         )
2287
2288                         oldCPP="$CPPFLAGS"
2289                         CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
2290                         AC_CHECK_HEADER(gssapi_krb5.h, ,
2291                                         [ CPPFLAGS="$oldCPP" ])
2292
2293                         # If we're using some other GSSAPI
2294                         if test "$GSSAPI" -a "$GSSAPI" != "mechglue"; then
2295                                 AC_MSG_ERROR([$GSSAPI GSSAPI library conflicts with Kerberos support.  Use mechglue instead.])
2296                         fi
2297
2298                         if test -z "$GSSAPI"; then
2299                                 GSSAPI="KRB5";
2300                         fi
2301
2302                         oldCPP="$CPPFLAGS"
2303                         CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
2304                         AC_CHECK_HEADER(gssapi_krb5.h, ,
2305                                         [ CPPFLAGS="$oldCPP" ])
2306
2307                 fi
2308                 if test ! -z "$need_dash_r" ; then
2309                         LDFLAGS="$LDFLAGS -R${KRB5ROOT}/lib"
2310                 fi
2311                 if test ! -z "$blibpath" ; then
2312                         blibpath="$blibpath:${KRB5ROOT}/lib"
2313                 fi
2314         fi
2315
2316         AC_CHECK_HEADERS(gssapi.h gssapi/gssapi.h)
2317         AC_CHECK_HEADERS(gssapi_krb5.h gssapi/gssapi_krb5.h)
2318         AC_CHECK_HEADERS(gssapi_generic.h gssapi/gssapi_generic.h)
2319
2320         LIBS="$LIBS $K5LIBS"
2321         AC_SEARCH_LIBS(k_hasafs, kafs, AC_DEFINE(USE_AFS))
2322         ]
2323 )
2324
2325 # Check whether user wants AFS_KRB5 support
2326 AFS_KRB5_MSG="no"
2327 AC_ARG_WITH(afs-krb5,
2328         [  --with-afs-krb5[[=AKLOG_PATH]]  Enable aklog to get token (default=/usr/bin/aklog).],
2329         [
2330                 if test "x$withval" != "xno" ; then
2331
2332                         if test "x$withval" != "xyes" ; then
2333                                 AC_DEFINE_UNQUOTED(AKLOG_PATH, "$withval")
2334                         else
2335                                 AC_DEFINE_UNQUOTED(AKLOG_PATH, "/usr/bin/aklog")
2336                         fi
2337
2338                         if test -z "$KRB5ROOT" ; then
2339                                 AC_MSG_WARN([AFS_KRB5 requires Kerberos 5 support, build may fail])
2340                         fi
2341
2342                         LIBS="-lkrbafs -lkrb4 $LIBS"
2343                         if test ! -z "$AFS_LIBS" ; then
2344                                 LIBS="$LIBS $AFS_LIBS"
2345                         fi
2346                         AC_DEFINE(AFS_KRB5)
2347                         AFS_KRB5_MSG="yes"
2348                 fi
2349         ]
2350 )
2351
2352 AC_ARG_WITH(session-hooks,
2353         [  --with-session-hooks    Enable hooks for executing external commands                                       before/after a session],
2354         [ AC_DEFINE(SESSION_HOOKS) ]
2355 )
2356
2357 # Looking for programs, paths and files
2358
2359 PRIVSEP_PATH=/var/empty
2360 AC_ARG_WITH(privsep-path,
2361         [  --with-privsep-path=xxx Path for privilege separation chroot (default=/var/empty)],
2362         [
2363                 if test "x$withval" != "$no" ; then
2364                         PRIVSEP_PATH=$withval
2365                 fi
2366         ]
2367 )
2368 AC_SUBST(PRIVSEP_PATH)
2369
2370 AC_ARG_WITH(xauth,
2371         [  --with-xauth=PATH       Specify path to xauth program ],
2372         [
2373                 if test "x$withval" != "xno" ; then
2374                         xauth_path=$withval
2375                 fi
2376         ],
2377         [
2378                 TestPath="$PATH"
2379                 TestPath="${TestPath}${PATH_SEPARATOR}/usr/X/bin"
2380                 TestPath="${TestPath}${PATH_SEPARATOR}/usr/bin/X11"
2381                 TestPath="${TestPath}${PATH_SEPARATOR}/usr/X11R6/bin"
2382                 TestPath="${TestPath}${PATH_SEPARATOR}/usr/openwin/bin"
2383                 AC_PATH_PROG(xauth_path, xauth, , $TestPath)
2384                 if (test ! -z "$xauth_path" && test -x "/usr/openwin/bin/xauth") ; then
2385                         xauth_path="/usr/openwin/bin/xauth"
2386                 fi
2387         ]
2388 )
2389
2390 STRIP_OPT=-s
2391 AC_ARG_ENABLE(strip,
2392         [  --disable-strip         Disable calling strip(1) on install],
2393         [
2394                 if test "x$enableval" = "xno" ; then
2395                         STRIP_OPT=
2396                 fi
2397         ]
2398 )
2399 AC_SUBST(STRIP_OPT)
2400
2401 if test -z "$xauth_path" ; then
2402         XAUTH_PATH="undefined"
2403         AC_SUBST(XAUTH_PATH)
2404 else
2405         AC_DEFINE_UNQUOTED(XAUTH_PATH, "$xauth_path")
2406         XAUTH_PATH=$xauth_path
2407         AC_SUBST(XAUTH_PATH)
2408 fi
2409
2410 # Check for mail directory (last resort if we cannot get it from headers)
2411 if test ! -z "$MAIL" ; then
2412         maildir=`dirname $MAIL`
2413         AC_DEFINE_UNQUOTED(MAIL_DIRECTORY, "$maildir")
2414 fi
2415
2416 if test -z "$no_dev_ptmx" ; then
2417         if test "x$disable_ptmx_check" != "xyes" ; then
2418                 AC_CHECK_FILE("/dev/ptmx",
2419                         [
2420                                 AC_DEFINE_UNQUOTED(HAVE_DEV_PTMX)
2421                                 have_dev_ptmx=1
2422                         ]
2423                 )
2424         fi
2425 fi
2426 AC_CHECK_FILE("/dev/ptc",
2427         [
2428                 AC_DEFINE_UNQUOTED(HAVE_DEV_PTS_AND_PTC)
2429                 have_dev_ptc=1
2430         ]
2431 )
2432
2433 # Options from here on. Some of these are preset by platform above
2434 AC_ARG_WITH(mantype,
2435         [  --with-mantype=man|cat|doc  Set man page type],
2436         [
2437                 case "$withval" in
2438                 man|cat|doc)
2439                         MANTYPE=$withval
2440                         ;;
2441                 *)
2442                         AC_MSG_ERROR(invalid man type: $withval)
2443                         ;;
2444                 esac
2445         ]
2446 )
2447 if test -z "$MANTYPE"; then
2448         TestPath="/usr/bin${PATH_SEPARATOR}/usr/ucb"
2449         AC_PATH_PROGS(NROFF, nroff awf, /bin/false, $TestPath)
2450         if ${NROFF} -mdoc ${srcdir}/ssh.1 >/dev/null 2>&1; then
2451                 MANTYPE=doc
2452         elif ${NROFF} -man ${srcdir}/ssh.1 >/dev/null 2>&1; then
2453                 MANTYPE=man
2454         else
2455                 MANTYPE=cat
2456         fi
2457 fi
2458 AC_SUBST(MANTYPE)
2459 if test "$MANTYPE" = "doc"; then
2460         mansubdir=man;
2461 else
2462         mansubdir=$MANTYPE;
2463 fi
2464 AC_SUBST(mansubdir)
2465
2466 # Check whether to enable MD5 passwords
2467 MD5_MSG="no"
2468 AC_ARG_WITH(md5-passwords,
2469         [  --with-md5-passwords    Enable use of MD5 passwords],
2470         [
2471                 if test "x$withval" != "xno" ; then
2472                         AC_DEFINE(HAVE_MD5_PASSWORDS)
2473                         MD5_MSG="yes"
2474                 fi
2475         ]
2476 )
2477
2478 # Whether to disable shadow password support
2479 AC_ARG_WITH(shadow,
2480         [  --without-shadow        Disable shadow password support],
2481         [
2482                 if test "x$withval" = "xno" ; then      
2483                         AC_DEFINE(DISABLE_SHADOW)
2484                         disable_shadow=yes
2485                 fi
2486         ]
2487 )
2488
2489 if test -z "$disable_shadow" ; then
2490         AC_MSG_CHECKING([if the systems has expire shadow information])
2491         AC_TRY_COMPILE(
2492         [
2493 #include <sys/types.h>
2494 #include <shadow.h>
2495         struct spwd sp;
2496         ],[ sp.sp_expire = sp.sp_lstchg = sp.sp_inact = 0; ],
2497         [ sp_expire_available=yes ], []
2498         )
2499
2500         if test "x$sp_expire_available" = "xyes" ; then
2501                 AC_MSG_RESULT(yes)
2502                 AC_DEFINE(HAS_SHADOW_EXPIRE)
2503         else
2504                 AC_MSG_RESULT(no)
2505         fi
2506 fi
2507
2508 # Use ip address instead of hostname in $DISPLAY
2509 if test ! -z "$IPADDR_IN_DISPLAY" ; then
2510         DISPLAY_HACK_MSG="yes"
2511         AC_DEFINE(IPADDR_IN_DISPLAY)
2512 else
2513         DISPLAY_HACK_MSG="no"
2514         AC_ARG_WITH(ipaddr-display,
2515                 [  --with-ipaddr-display   Use ip address instead of hostname in \$DISPLAY],
2516                 [
2517                         if test "x$withval" != "xno" ; then     
2518                                 AC_DEFINE(IPADDR_IN_DISPLAY)
2519                                 DISPLAY_HACK_MSG="yes"
2520                         fi
2521                 ]
2522         )
2523 fi
2524
2525 # check for /etc/default/login and use it if present.
2526 AC_ARG_ENABLE(etc-default-login,
2527         [  --disable-etc-default-login       Disable using PATH from /etc/default/login [no]],,
2528 [
2529 AC_CHECK_FILE("/etc/default/login", [ external_path_file=/etc/default/login ])
2530
2531 if test "x$external_path_file" = "x/etc/default/login"; then
2532         AC_DEFINE(HAVE_ETC_DEFAULT_LOGIN)
2533 fi
2534 ])
2535
2536 dnl BSD systems use /etc/login.conf so --with-default-path= has no effect
2537 if test $ac_cv_func_login_getcapbool = "yes" -a \
2538         $ac_cv_header_login_cap_h = "yes" ; then
2539         external_path_file=/etc/login.conf
2540 fi
2541
2542 # Whether to mess with the default path
2543 SERVER_PATH_MSG="(default)"
2544 AC_ARG_WITH(default-path,
2545         [  --with-default-path=    Specify default \$PATH environment for server],
2546         [
2547                 if test "x$external_path_file" = "x/etc/login.conf" ; then
2548                         AC_MSG_WARN([
2549 --with-default-path=PATH has no effect on this system.
2550 Edit /etc/login.conf instead.])
2551                 elif test "x$withval" != "xno" ; then   
2552                         if test ! -z "$external_path_file" ; then
2553                                 AC_MSG_WARN([
2554 --with-default-path=PATH will only be used if PATH is not defined in
2555 $external_path_file .])
2556                         fi
2557                         user_path="$withval"
2558                         SERVER_PATH_MSG="$withval"
2559                 fi
2560         ],
2561         [ if test "x$external_path_file" = "x/etc/login.conf" ; then
2562                 AC_MSG_WARN([Make sure the path to scp is in /etc/login.conf])
2563         else
2564                 if test ! -z "$external_path_file" ; then
2565                         AC_MSG_WARN([
2566 If PATH is defined in $external_path_file, ensure the path to scp is included,
2567 otherwise scp will not work.])
2568                 fi
2569                 AC_TRY_RUN(
2570                         [
2571 /* find out what STDPATH is */
2572 #include <stdio.h>
2573 #ifdef HAVE_PATHS_H
2574 # include <paths.h>
2575 #endif
2576 #ifndef _PATH_STDPATH
2577 # ifdef _PATH_USERPATH  /* Irix */
2578 #  define _PATH_STDPATH _PATH_USERPATH
2579 # else
2580 #  define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
2581 # endif
2582 #endif
2583 #include <sys/types.h>
2584 #include <sys/stat.h>
2585 #include <fcntl.h>
2586 #define DATA "conftest.stdpath"
2587
2588 main()
2589 {
2590         FILE *fd;
2591         int rc;
2592         
2593         fd = fopen(DATA,"w");
2594         if(fd == NULL)
2595                 exit(1);
2596         
2597         if ((rc = fprintf(fd,"%s", _PATH_STDPATH)) < 0)
2598                 exit(1);
2599
2600         exit(0);
2601 }
2602                 ], [ user_path=`cat conftest.stdpath` ],
2603                 [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ],
2604                 [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ]
2605         )
2606 # make sure $bindir is in USER_PATH so scp will work
2607                 t_bindir=`eval echo ${bindir}`
2608                 case $t_bindir in
2609                         NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$prefix~"` ;;
2610                 esac
2611                 case $t_bindir in
2612                         NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$ac_default_prefix~"` ;;
2613                 esac
2614                 echo $user_path | grep ":$t_bindir"  > /dev/null 2>&1
2615                 if test $? -ne 0  ; then
2616                         echo $user_path | grep "^$t_bindir"  > /dev/null 2>&1
2617                         if test $? -ne 0  ; then
2618                                 user_path=$user_path:$t_bindir
2619                                 AC_MSG_RESULT(Adding $t_bindir to USER_PATH so scp will work)
2620                         fi
2621                 fi
2622         fi ]
2623 )
2624 if test "x$external_path_file" != "x/etc/login.conf" ; then
2625         AC_DEFINE_UNQUOTED(USER_PATH, "$user_path")
2626         AC_SUBST(user_path)
2627 fi
2628
2629 # Set superuser path separately to user path
2630 AC_ARG_WITH(superuser-path,
2631         [  --with-superuser-path=  Specify different path for super-user],
2632         [
2633                 if test "x$withval" != "xno" ; then
2634                         AC_DEFINE_UNQUOTED(SUPERUSER_PATH, "$withval")
2635                         superuser_path=$withval
2636                 fi
2637         ]
2638 )
2639
2640
2641 AC_MSG_CHECKING([if we need to convert IPv4 in IPv6-mapped addresses])
2642 IPV4_IN6_HACK_MSG="no"
2643 AC_ARG_WITH(4in6,
2644         [  --with-4in6             Check for and convert IPv4 in IPv6 mapped addresses],
2645         [
2646                 if test "x$withval" != "xno" ; then
2647                         AC_MSG_RESULT(yes)
2648                         AC_DEFINE(IPV4_IN_IPV6)
2649                         IPV4_IN6_HACK_MSG="yes"
2650                 else
2651                         AC_MSG_RESULT(no)
2652                 fi
2653         ],[
2654                 if test "x$inet6_default_4in6" = "xyes"; then
2655                         AC_MSG_RESULT([yes (default)])
2656                         AC_DEFINE(IPV4_IN_IPV6)
2657                         IPV4_IN6_HACK_MSG="yes"
2658                 else
2659                         AC_MSG_RESULT([no (default)])
2660                 fi
2661         ]
2662 )
2663
2664 # Whether to enable BSD auth support
2665 BSD_AUTH_MSG=no
2666 AC_ARG_WITH(bsd-auth,
2667         [  --with-bsd-auth         Enable BSD auth support],
2668         [
2669                 if test "x$withval" != "xno" ; then     
2670                         AC_DEFINE(BSD_AUTH)
2671                         BSD_AUTH_MSG=yes
2672                 fi
2673         ]
2674 )
2675
2676 # Where to place sshd.pid
2677 piddir=/var/run
2678 # make sure the directory exists
2679 if test ! -d $piddir ; then     
2680         piddir=`eval echo ${sysconfdir}`
2681         case $piddir in
2682                 NONE/*) piddir=`echo $piddir | sed "s~NONE~$ac_default_prefix~"` ;;
2683         esac
2684 fi
2685
2686 AC_ARG_WITH(pid-dir,
2687         [  --with-pid-dir=PATH     Specify location of ssh.pid file],
2688         [
2689                 if test "x$withval" != "xno" ; then     
2690                         piddir=$withval
2691                         if test ! -d $piddir ; then     
2692                         AC_MSG_WARN([** no $piddir directory on this system **])
2693                         fi
2694                 fi
2695         ]
2696 )
2697
2698 AC_DEFINE_UNQUOTED(_PATH_SSH_PIDDIR, "$piddir")
2699 AC_SUBST(piddir)
2700
2701 dnl allow user to disable some login recording features
2702 AC_ARG_ENABLE(lastlog,
2703         [  --disable-lastlog       disable use of lastlog even if detected [no]],
2704         [
2705                 if test "x$enableval" = "xno" ; then
2706                         AC_DEFINE(DISABLE_LASTLOG)
2707                 fi
2708         ]
2709 )
2710 AC_ARG_ENABLE(utmp,
2711         [  --disable-utmp          disable use of utmp even if detected [no]],
2712         [
2713                 if test "x$enableval" = "xno" ; then
2714                         AC_DEFINE(DISABLE_UTMP)
2715                 fi
2716         ]
2717 )
2718 AC_ARG_ENABLE(utmpx,
2719         [  --disable-utmpx         disable use of utmpx even if detected [no]],
2720         [
2721                 if test "x$enableval" = "xno" ; then
2722                         AC_DEFINE(DISABLE_UTMPX)
2723                 fi
2724         ]
2725 )
2726 AC_ARG_ENABLE(wtmp,
2727         [  --disable-wtmp          disable use of wtmp even if detected [no]],
2728         [
2729                 if test "x$enableval" = "xno" ; then
2730                         AC_DEFINE(DISABLE_WTMP)
2731                 fi
2732         ]
2733 )
2734 AC_ARG_ENABLE(wtmpx,
2735         [  --disable-wtmpx         disable use of wtmpx even if detected [no]],
2736         [
2737                 if test "x$enableval" = "xno" ; then
2738                         AC_DEFINE(DISABLE_WTMPX)
2739                 fi
2740         ]
2741 )
2742 AC_ARG_ENABLE(libutil,
2743         [  --disable-libutil       disable use of libutil (login() etc.) [no]],
2744         [
2745                 if test "x$enableval" = "xno" ; then
2746                         AC_DEFINE(DISABLE_LOGIN)
2747                 fi
2748         ]
2749 )
2750 AC_ARG_ENABLE(pututline,
2751         [  --disable-pututline     disable use of pututline() etc. ([uw]tmp) [no]],
2752         [
2753                 if test "x$enableval" = "xno" ; then
2754                         AC_DEFINE(DISABLE_PUTUTLINE)
2755                 fi
2756         ]
2757 )
2758 AC_ARG_ENABLE(pututxline,
2759         [  --disable-pututxline    disable use of pututxline() etc. ([uw]tmpx) [no]],
2760         [
2761                 if test "x$enableval" = "xno" ; then
2762                         AC_DEFINE(DISABLE_PUTUTXLINE)
2763                 fi
2764         ]
2765 )
2766 AC_ARG_WITH(lastlog,
2767   [  --with-lastlog=FILE|DIR specify lastlog location [common locations]],
2768         [
2769                 if test "x$withval" = "xno" ; then      
2770                         AC_DEFINE(DISABLE_LASTLOG)
2771                 else
2772                         conf_lastlog_location=$withval
2773                 fi
2774         ]
2775 )
2776
2777 dnl lastlog, [uw]tmpx? detection
2778 dnl  NOTE: set the paths in the platform section to avoid the
2779 dnl   need for command-line parameters
2780 dnl lastlog and [uw]tmp are subject to a file search if all else fails
2781
2782 dnl lastlog detection
2783 dnl  NOTE: the code itself will detect if lastlog is a directory
2784 AC_MSG_CHECKING([if your system defines LASTLOG_FILE])
2785 AC_TRY_COMPILE([
2786 #include <sys/types.h>
2787 #include <utmp.h>
2788 #ifdef HAVE_LASTLOG_H
2789 #  include <lastlog.h>
2790 #endif
2791 #ifdef HAVE_PATHS_H
2792 #  include <paths.h>
2793 #endif
2794 #ifdef HAVE_LOGIN_H
2795 # include <login.h>
2796 #endif
2797         ],
2798         [ char *lastlog = LASTLOG_FILE; ],
2799         [ AC_MSG_RESULT(yes) ],
2800         [
2801                 AC_MSG_RESULT(no)
2802                 AC_MSG_CHECKING([if your system defines _PATH_LASTLOG])
2803                 AC_TRY_COMPILE([
2804 #include <sys/types.h>
2805 #include <utmp.h>
2806 #ifdef HAVE_LASTLOG_H
2807 #  include <lastlog.h>
2808 #endif
2809 #ifdef HAVE_PATHS_H
2810 #  include <paths.h>
2811 #endif
2812                 ],
2813                 [ char *lastlog = _PATH_LASTLOG; ],
2814                 [ AC_MSG_RESULT(yes) ],
2815                 [
2816                         AC_MSG_RESULT(no)
2817                         system_lastlog_path=no
2818                 ])
2819         ]
2820 )
2821
2822 if test -z "$conf_lastlog_location"; then
2823         if test x"$system_lastlog_path" = x"no" ; then
2824                 for f in /var/log/lastlog /usr/adm/lastlog /var/adm/lastlog /etc/security/lastlog ; do
2825                                 if (test -d "$f" || test -f "$f") ; then
2826                                         conf_lastlog_location=$f
2827                                 fi
2828                 done
2829                 if test -z "$conf_lastlog_location"; then
2830                         AC_MSG_WARN([** Cannot find lastlog **])
2831                         dnl Don't define DISABLE_LASTLOG - that means we don't try wtmp/wtmpx
2832                 fi
2833         fi
2834 fi
2835
2836 if test -n "$conf_lastlog_location"; then
2837         AC_DEFINE_UNQUOTED(CONF_LASTLOG_FILE, "$conf_lastlog_location")
2838 fi      
2839
2840 dnl utmp detection
2841 AC_MSG_CHECKING([if your system defines UTMP_FILE])
2842 AC_TRY_COMPILE([
2843 #include <sys/types.h>
2844 #include <utmp.h>
2845 #ifdef HAVE_PATHS_H
2846 #  include <paths.h>
2847 #endif
2848         ],
2849         [ char *utmp = UTMP_FILE; ],
2850         [ AC_MSG_RESULT(yes) ],
2851         [ AC_MSG_RESULT(no)
2852           system_utmp_path=no ]
2853 )
2854 if test -z "$conf_utmp_location"; then
2855         if test x"$system_utmp_path" = x"no" ; then
2856                 for f in /etc/utmp /usr/adm/utmp /var/run/utmp; do
2857                         if test -f $f ; then
2858                                 conf_utmp_location=$f
2859                         fi
2860                 done
2861                 if test -z "$conf_utmp_location"; then
2862                         AC_DEFINE(DISABLE_UTMP)
2863                 fi
2864         fi
2865 fi
2866 if test -n "$conf_utmp_location"; then
2867         AC_DEFINE_UNQUOTED(CONF_UTMP_FILE, "$conf_utmp_location")
2868 fi      
2869
2870 dnl wtmp detection
2871 AC_MSG_CHECKING([if your system defines WTMP_FILE])
2872 AC_TRY_COMPILE([
2873 #include <sys/types.h>
2874 #include <utmp.h>
2875 #ifdef HAVE_PATHS_H
2876 #  include <paths.h>
2877 #endif
2878         ],
2879         [ char *wtmp = WTMP_FILE; ],
2880         [ AC_MSG_RESULT(yes) ],
2881         [ AC_MSG_RESULT(no)
2882           system_wtmp_path=no ]
2883 )
2884 if test -z "$conf_wtmp_location"; then
2885         if test x"$system_wtmp_path" = x"no" ; then
2886                 for f in /usr/adm/wtmp /var/log/wtmp; do
2887                         if test -f $f ; then
2888                                 conf_wtmp_location=$f
2889                         fi
2890                 done
2891                 if test -z "$conf_wtmp_location"; then
2892                         AC_DEFINE(DISABLE_WTMP)
2893                 fi
2894         fi
2895 fi
2896 if test -n "$conf_wtmp_location"; then
2897         AC_DEFINE_UNQUOTED(CONF_WTMP_FILE, "$conf_wtmp_location")
2898 fi      
2899
2900
2901 dnl utmpx detection - I don't know any system so perverse as to require
2902 dnl  utmpx, but not define UTMPX_FILE (ditto wtmpx.) No doubt it's out
2903 dnl  there, though.
2904 AC_MSG_CHECKING([if your system defines UTMPX_FILE])
2905 AC_TRY_COMPILE([
2906 #include <sys/types.h>
2907 #include <utmp.h>
2908 #ifdef HAVE_UTMPX_H
2909 #include <utmpx.h>
2910 #endif
2911 #ifdef HAVE_PATHS_H
2912 #  include <paths.h>
2913 #endif
2914         ],
2915         [ char *utmpx = UTMPX_FILE; ],
2916         [ AC_MSG_RESULT(yes) ],
2917         [ AC_MSG_RESULT(no)
2918           system_utmpx_path=no ]
2919 )
2920 if test -z "$conf_utmpx_location"; then
2921         if test x"$system_utmpx_path" = x"no" ; then
2922                 AC_DEFINE(DISABLE_UTMPX)
2923         fi
2924 else
2925         AC_DEFINE_UNQUOTED(CONF_UTMPX_FILE, "$conf_utmpx_location")
2926 fi      
2927
2928 dnl wtmpx detection
2929 AC_MSG_CHECKING([if your system defines WTMPX_FILE])
2930 AC_TRY_COMPILE([
2931 #include <sys/types.h>
2932 #include <utmp.h>
2933 #ifdef HAVE_UTMPX_H
2934 #include <utmpx.h>
2935 #endif
2936 #ifdef HAVE_PATHS_H
2937 #  include <paths.h>
2938 #endif
2939         ],
2940         [ char *wtmpx = WTMPX_FILE; ],
2941         [ AC_MSG_RESULT(yes) ],
2942         [ AC_MSG_RESULT(no)
2943           system_wtmpx_path=no ]
2944 )
2945 if test -z "$conf_wtmpx_location"; then
2946         if test x"$system_wtmpx_path" = x"no" ; then
2947                 AC_DEFINE(DISABLE_WTMPX)
2948         fi
2949 else
2950         AC_DEFINE_UNQUOTED(CONF_WTMPX_FILE, "$conf_wtmpx_location")
2951 fi      
2952
2953
2954 if test ! -z "$blibpath" ; then
2955         LDFLAGS="$LDFLAGS $blibflags$blibpath"
2956         AC_MSG_WARN([Please check and edit blibpath in LDFLAGS in Makefile])
2957 fi
2958
2959 dnl remove pam and dl because they are in $LIBPAM
2960 if test "$PAM_MSG" = yes ; then
2961         LIBS=`echo $LIBS | sed 's/-lpam //'`
2962 fi
2963 if test "$ac_cv_lib_pam_pam_set_item" = yes ; then
2964         LIBS=`echo $LIBS | sed 's/-ldl //'`
2965 fi
2966
2967 AC_EXEEXT
2968 AC_CONFIG_FILES([Makefile openbsd-compat/Makefile scard/Makefile ssh_prng_cmds])
2969 AC_OUTPUT
2970
2971 # Print summary of options
2972
2973 # Someone please show me a better way :)
2974 A=`eval echo ${prefix}` ; A=`eval echo ${A}`
2975 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
2976 C=`eval echo ${sbindir}` ; C=`eval echo ${C}`
2977 D=`eval echo ${sysconfdir}` ; D=`eval echo ${D}`
2978 E=`eval echo ${libexecdir}/ssh-askpass` ; E=`eval echo ${E}`
2979 F=`eval echo ${mandir}/${mansubdir}X` ; F=`eval echo ${F}`
2980 G=`eval echo ${piddir}` ; G=`eval echo ${G}`
2981 H=`eval echo ${PRIVSEP_PATH}` ; H=`eval echo ${H}`
2982 I=`eval echo ${user_path}` ; I=`eval echo ${I}`
2983 J=`eval echo ${superuser_path}` ; J=`eval echo ${J}`
2984
2985 echo ""
2986 echo "OpenSSH has been configured with the following options:"
2987 echo "                     User binaries: $B"
2988 echo "                   System binaries: $C"
2989 echo "               Configuration files: $D"
2990 echo "                   Askpass program: $E"
2991 echo "                      Manual pages: $F"
2992 echo "                          PID file: $G"
2993 echo "  Privilege separation chroot path: $H"
2994 if test "x$external_path_file" = "x/etc/login.conf" ; then
2995 echo "   At runtime, sshd will use the path defined in $external_path_file"
2996 echo "   Make sure the path to scp is present, otherwise scp will not work"
2997 else
2998 echo "            sshd default user PATH: $I"
2999         if test ! -z "$external_path_file"; then
3000 echo "   (If PATH is set in $external_path_file it will be used instead. If"
3001 echo "   used, ensure the path to scp is present, otherwise scp will not work.)"
3002         fi
3003 fi
3004 if test ! -z "$superuser_path" ; then
3005 echo "          sshd superuser user PATH: $J"
3006 fi
3007 echo "                    Manpage format: $MANTYPE"
3008 echo "                       PAM support: $PAM_MSG"
3009 echo "                 KerberosV support: $KRB5_MSG"
3010 echo "                 Smartcard support: $SCARD_MSG"
3011 echo "                     S/KEY support: $SKEY_MSG"
3012 echo "              TCP Wrappers support: $TCPW_MSG"
3013 echo "              MD5 password support: $MD5_MSG"
3014 echo "       IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG"
3015 echo "           Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG"
3016 echo "                  BSD Auth support: $BSD_AUTH_MSG"
3017 echo "              Random number source: $RAND_MSG"
3018 if test ! -z "$USE_RAND_HELPER" ; then
3019 echo "     ssh-rand-helper collects from: $RAND_HELPER_MSG"
3020 fi
3021
3022 echo ""
3023
3024 echo "              Host: ${host}"
3025 echo "          Compiler: ${CC}"
3026 echo "    Compiler flags: ${CFLAGS}"
3027 echo "Preprocessor flags: ${CPPFLAGS}"
3028 echo "      Linker flags: ${LDFLAGS}"
3029 echo "         Libraries: ${LIBWRAP} ${LIBPAM} ${LIBS}"
3030
3031 echo ""
3032
3033 if test "x$PAM_MSG" = "xyes" ; then
3034         echo "PAM is enabled. You may need to install a PAM control file "
3035         echo "for sshd, otherwise password authentication may fail. "
3036         echo "Example PAM control files can be found in the contrib/ "
3037         echo "subdirectory"
3038         echo ""
3039 fi
3040
3041 if test ! -z "$RAND_HELPER_CMDHASH" ; then
3042         echo "WARNING: you are using the builtin random number collection "
3043         echo "service. Please read WARNING.RNG and request that your OS "
3044         echo "vendor includes kernel-based random number collection in "
3045         echo "future versions of your OS."
3046         echo ""
3047 fi
3048
This page took 2.159363 seconds and 5 git commands to generate.