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