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