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