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