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