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