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