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