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