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