- (dtucker) [configure.ac] Put the check for the existence of getaddrinfo
[openssh-git.git] / configure.ac
blob0a0e2ea15d0cb97a6730bc0f20cb36794e45b72a
1 # $Id: configure.ac,v 1.449 2010/04/10 12:58:01 dtucker Exp $
3 # Copyright (c) 1999-2004 Damien Miller
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 AC_INIT(OpenSSH, Portable, openssh-unix-dev@mindrot.org)
18 AC_REVISION($Revision: 1.449 $)
19 AC_CONFIG_SRCDIR([ssh.c])
21 AC_CONFIG_HEADER(config.h)
22 AC_PROG_CC
23 AC_CANONICAL_HOST
24 AC_C_BIGENDIAN
26 # Checks for programs.
27 AC_PROG_AWK
28 AC_PROG_CPP
29 AC_PROG_RANLIB
30 AC_PROG_INSTALL
31 AC_PROG_EGREP
32 AC_PATH_PROG(AR, ar)
33 AC_PATH_PROG(CAT, cat)
34 AC_PATH_PROG(KILL, kill)
35 AC_PATH_PROGS(PERL, perl5 perl)
36 AC_PATH_PROG(SED, sed)
37 AC_SUBST(PERL)
38 AC_PATH_PROG(ENT, ent)
39 AC_SUBST(ENT)
40 AC_PATH_PROG(TEST_MINUS_S_SH, bash)
41 AC_PATH_PROG(TEST_MINUS_S_SH, ksh)
42 AC_PATH_PROG(TEST_MINUS_S_SH, sh)
43 AC_PATH_PROG(SH, sh)
44 AC_SUBST(TEST_SHELL,sh)
46 dnl for buildpkg.sh
47 AC_PATH_PROG(PATH_GROUPADD_PROG, groupadd, groupadd,
48         [/usr/sbin${PATH_SEPARATOR}/etc])
49 AC_PATH_PROG(PATH_USERADD_PROG, useradd, useradd,
50         [/usr/sbin${PATH_SEPARATOR}/etc])
51 AC_CHECK_PROG(MAKE_PACKAGE_SUPPORTED, pkgmk, yes, no)
52 if test -x /sbin/sh; then
53         AC_SUBST(STARTUP_SCRIPT_SHELL,/sbin/sh)
54 else
55         AC_SUBST(STARTUP_SCRIPT_SHELL,/bin/sh)
58 # System features
59 AC_SYS_LARGEFILE
61 if test -z "$AR" ; then
62         AC_MSG_ERROR([*** 'ar' missing, please install or fix your \$PATH ***])
65 # Use LOGIN_PROGRAM from environment if possible
66 if test ! -z "$LOGIN_PROGRAM" ; then
67         AC_DEFINE_UNQUOTED(LOGIN_PROGRAM_FALLBACK, "$LOGIN_PROGRAM",
68                 [If your header files don't define LOGIN_PROGRAM,
69                 then use this (detected) from environment and PATH])
70 else
71         # Search for login
72         AC_PATH_PROG(LOGIN_PROGRAM_FALLBACK, login)
73         if test ! -z "$LOGIN_PROGRAM_FALLBACK" ; then
74                 AC_DEFINE_UNQUOTED(LOGIN_PROGRAM_FALLBACK, "$LOGIN_PROGRAM_FALLBACK")
75         fi
78 AC_PATH_PROG(PATH_PASSWD_PROG, passwd)
79 if test ! -z "$PATH_PASSWD_PROG" ; then
80         AC_DEFINE_UNQUOTED(_PATH_PASSWD_PROG, "$PATH_PASSWD_PROG",
81                 [Full path of your "passwd" program])
84 if test -z "$LD" ; then
85         LD=$CC
87 AC_SUBST(LD)
89 AC_C_INLINE
91 AC_CHECK_DECL(LLONG_MAX, have_llong_max=1, , [#include <limits.h>])
93 use_stack_protector=1
94 AC_ARG_WITH(stackprotect,
95     [  --without-stackprotect  Don't use compiler's stack protection], [
96     if test "x$withval" = "xno"; then
97         use_stack_protector=0
98     fi ])
100 if test "$GCC" = "yes" || test "$GCC" = "egcs"; then
101         CFLAGS="$CFLAGS -Wall -Wpointer-arith -Wuninitialized"
102         GCC_VER=`$CC -v 2>&1 | $AWK '/gcc version /{print $3}'`
103         case $GCC_VER in
104                 1.*) no_attrib_nonnull=1 ;;
105                 2.8* | 2.9*)
106                      CFLAGS="$CFLAGS -Wsign-compare"
107                      no_attrib_nonnull=1
108                      ;;
109                 2.*) no_attrib_nonnull=1 ;;
110                 3.*) CFLAGS="$CFLAGS -Wsign-compare -Wformat-security" ;;
111                 4.*) CFLAGS="$CFLAGS -Wsign-compare -Wno-pointer-sign -Wformat-security -fno-strict-aliasing" ;;
112                 *) ;;
113         esac
115         AC_MSG_CHECKING(if $CC accepts -fno-builtin-memset)
116         saved_CFLAGS="$CFLAGS"
117         CFLAGS="$CFLAGS -fno-builtin-memset"
118         AC_LINK_IFELSE( [AC_LANG_SOURCE([[
119 #include <string.h>
120 int main(void){char b[10]; memset(b, 0, sizeof(b));}
121                 ]])],
122                 [ AC_MSG_RESULT(yes) ],
123                 [ AC_MSG_RESULT(no)
124                   CFLAGS="$saved_CFLAGS" ]
127         # -fstack-protector-all doesn't always work for some GCC versions
128         # and/or platforms, so we test if we can.  If it's not supported
129         # on a given platform gcc will emit a warning so we use -Werror.
130         if test "x$use_stack_protector" = "x1"; then
131             for t in -fstack-protector-all -fstack-protector; do
132                 AC_MSG_CHECKING(if $CC supports $t)
133                 saved_CFLAGS="$CFLAGS"
134                 saved_LDFLAGS="$LDFLAGS"
135                 CFLAGS="$CFLAGS $t -Werror"
136                 LDFLAGS="$LDFLAGS $t -Werror"
137                 AC_LINK_IFELSE(
138                         [AC_LANG_SOURCE([
139 #include <stdio.h>
140 int main(void){char x[[256]]; snprintf(x, sizeof(x), "XXX"); return 0;}
141                          ])],
142                     [ AC_MSG_RESULT(yes)
143                       CFLAGS="$saved_CFLAGS $t"
144                       LDFLAGS="$saved_LDFLAGS $t"
145                       AC_MSG_CHECKING(if $t works)
146                       AC_RUN_IFELSE(
147                         [AC_LANG_SOURCE([
148 #include <stdio.h>
149 int main(void){char x[[256]]; snprintf(x, sizeof(x), "XXX"); return 0;}
150                         ])],
151                         [ AC_MSG_RESULT(yes)
152                           break ],
153                         [ AC_MSG_RESULT(no) ],
154                         [ AC_MSG_WARN([cross compiling: cannot test])
155                           break ]
156                       )
157                     ],
158                     [ AC_MSG_RESULT(no) ]
159                 )
160                 CFLAGS="$saved_CFLAGS"
161                 LDFLAGS="$saved_LDFLAGS"
162             done
163         fi
165         if test -z "$have_llong_max"; then
166                 # retry LLONG_MAX with -std=gnu99, needed on some Linuxes
167                 unset ac_cv_have_decl_LLONG_MAX
168                 saved_CFLAGS="$CFLAGS"
169                 CFLAGS="$CFLAGS -std=gnu99"
170                 AC_CHECK_DECL(LLONG_MAX,
171                     [have_llong_max=1],
172                     [CFLAGS="$saved_CFLAGS"],
173                     [#include <limits.h>]
174                 )
175         fi
178 if test "x$no_attrib_nonnull" != "x1" ; then
179         AC_DEFINE(HAVE_ATTRIBUTE__NONNULL__, 1, [Have attribute nonnull])
182 AC_ARG_WITH(rpath,
183         [  --without-rpath         Disable auto-added -R linker paths],
184         [
185                 if test "x$withval" = "xno" ; then
186                         need_dash_r=""
187                 fi
188                 if test "x$withval" = "xyes" ; then
189                         need_dash_r=1
190                 fi
191         ]
194 # Allow user to specify flags
195 AC_ARG_WITH(cflags,
196         [  --with-cflags           Specify additional flags to pass to compiler],
197         [
198                 if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
199                     test "x${withval}" != "xyes"; then
200                         CFLAGS="$CFLAGS $withval"
201                 fi
202         ]
204 AC_ARG_WITH(cppflags,
205         [  --with-cppflags         Specify additional flags to pass to preprocessor] ,
206         [
207                 if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
208                     test "x${withval}" != "xyes"; then
209                         CPPFLAGS="$CPPFLAGS $withval"
210                 fi
211         ]
213 AC_ARG_WITH(ldflags,
214         [  --with-ldflags          Specify additional flags to pass to linker],
215         [
216                 if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
217                     test "x${withval}" != "xyes"; then
218                         LDFLAGS="$LDFLAGS $withval"
219                 fi
220         ]
222 AC_ARG_WITH(libs,
223         [  --with-libs             Specify additional libraries to link with],
224         [
225                 if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
226                     test "x${withval}" != "xyes"; then
227                         LIBS="$LIBS $withval"
228                 fi
229         ]
231 AC_ARG_WITH(Werror,
232         [  --with-Werror           Build main code with -Werror],
233         [
234                 if test -n "$withval"  &&  test "x$withval" != "xno"; then
235                         werror_flags="-Werror"
236                         if test "x${withval}" != "xyes"; then
237                                 werror_flags="$withval"
238                         fi
239                 fi
240         ]
243 AC_CHECK_HEADERS( \
244         bstring.h \
245         crypt.h \
246         crypto/sha2.h \
247         dirent.h \
248         endian.h \
249         features.h \
250         fcntl.h \
251         floatingpoint.h \
252         getopt.h \
253         glob.h \
254         ia.h \
255         iaf.h \
256         limits.h \
257         login.h \
258         maillock.h \
259         ndir.h \
260         net/if_tun.h \
261         netdb.h \
262         netgroup.h \
263         pam/pam_appl.h \
264         paths.h \
265         poll.h \
266         pty.h \
267         readpassphrase.h \
268         rpc/types.h \
269         security/pam_appl.h \
270         sha2.h \
271         shadow.h \
272         stddef.h \
273         stdint.h \
274         string.h \
275         strings.h \
276         sys/audit.h \
277         sys/bitypes.h \
278         sys/bsdtty.h \
279         sys/cdefs.h \
280         sys/dir.h \
281         sys/mman.h \
282         sys/ndir.h \
283         sys/poll.h \
284         sys/prctl.h \
285         sys/pstat.h \
286         sys/select.h \
287         sys/stat.h \
288         sys/stream.h \
289         sys/stropts.h \
290         sys/strtio.h \
291         sys/statvfs.h \
292         sys/sysmacros.h \
293         sys/time.h \
294         sys/timers.h \
295         sys/un.h \
296         time.h \
297         tmpdir.h \
298         ttyent.h \
299         ucred.h \
300         unistd.h \
301         usersec.h \
302         util.h \
303         utime.h \
304         utmp.h \
305         utmpx.h \
306         vis.h \
309 # lastlog.h requires sys/time.h to be included first on Solaris
310 AC_CHECK_HEADERS(lastlog.h, [], [], [
311 #ifdef HAVE_SYS_TIME_H
312 # include <sys/time.h>
313 #endif
316 # sys/ptms.h requires sys/stream.h to be included first on Solaris
317 AC_CHECK_HEADERS(sys/ptms.h, [], [], [
318 #ifdef HAVE_SYS_STREAM_H
319 # include <sys/stream.h>
320 #endif
323 # login_cap.h requires sys/types.h on NetBSD
324 AC_CHECK_HEADERS(login_cap.h, [], [], [
325 #include <sys/types.h>
328 # older BSDs need sys/param.h before sys/mount.h
329 AC_CHECK_HEADERS(sys/mount.h, [], [], [
330 #include <sys/param.h>
333 # Messages for features tested for in target-specific section
334 SIA_MSG="no"
335 SPC_MSG="no"
337 # Check for some target-specific stuff
338 case "$host" in
339 *-*-aix*)
340         # Some versions of VAC won't allow macro redefinitions at
341         # -qlanglevel=ansi, and autoconf 2.60 sometimes insists on using that
342         # particularly with older versions of vac or xlc.
343         # It also throws errors about null macro argments, but these are
344         # not fatal.
345         AC_MSG_CHECKING(if compiler allows macro redefinitions)
346         AC_COMPILE_IFELSE(
347             [AC_LANG_SOURCE([[
348 #define testmacro foo
349 #define testmacro bar
350 int main(void) { exit(0); }
351             ]])],
352             [ AC_MSG_RESULT(yes) ],
353             [ AC_MSG_RESULT(no)
354               CC="`echo $CC | sed 's/-qlanglvl\=ansi//g'`"
355               LD="`echo $LD | sed 's/-qlanglvl\=ansi//g'`"
356               CFLAGS="`echo $CFLAGS | sed 's/-qlanglvl\=ansi//g'`"
357               CPPFLAGS="`echo $CPPFLAGS | sed 's/-qlanglvl\=ansi//g'`"
358             ]
359         )
361         AC_MSG_CHECKING([how to specify blibpath for linker ($LD)])
362         if (test -z "$blibpath"); then
363                 blibpath="/usr/lib:/lib"
364         fi
365         saved_LDFLAGS="$LDFLAGS"
366         if test "$GCC" = "yes"; then
367                 flags="-Wl,-blibpath: -Wl,-rpath, -blibpath:"
368         else
369                 flags="-blibpath: -Wl,-blibpath: -Wl,-rpath,"
370         fi
371         for tryflags in $flags ;do
372                 if (test -z "$blibflags"); then
373                         LDFLAGS="$saved_LDFLAGS $tryflags$blibpath"
374                         AC_TRY_LINK([], [], [blibflags=$tryflags])
375                 fi
376         done
377         if (test -z "$blibflags"); then
378                 AC_MSG_RESULT(not found)
379                 AC_MSG_ERROR([*** must be able to specify blibpath on AIX - check config.log])
380         else
381                 AC_MSG_RESULT($blibflags)
382         fi
383         LDFLAGS="$saved_LDFLAGS"
384         dnl Check for authenticate.  Might be in libs.a on older AIXes
385         AC_CHECK_FUNC(authenticate, [AC_DEFINE(WITH_AIXAUTHENTICATE, 1,
386                 [Define if you want to enable AIX4's authenticate function])],
387                 [AC_CHECK_LIB(s,authenticate,
388                         [ AC_DEFINE(WITH_AIXAUTHENTICATE)
389                                 LIBS="$LIBS -ls"
390                         ])
391                 ])
392         dnl Check for various auth function declarations in headers.
393         AC_CHECK_DECLS([authenticate, loginrestrictions, loginsuccess,
394             passwdexpired, setauthdb], , , [#include <usersec.h>])
395         dnl Check if loginfailed is declared and takes 4 arguments (AIX >= 5.2)
396         AC_CHECK_DECLS(loginfailed,
397                  [AC_MSG_CHECKING(if loginfailed takes 4 arguments)
398                   AC_TRY_COMPILE(
399                         [#include <usersec.h>],
400                         [(void)loginfailed("user","host","tty",0);],
401                         [AC_MSG_RESULT(yes)
402                          AC_DEFINE(AIX_LOGINFAILED_4ARG, 1,
403                                 [Define if your AIX loginfailed() function
404                                 takes 4 arguments (AIX >= 5.2)])],
405                         [AC_MSG_RESULT(no)]
406                 )],
407                 [],
408                 [#include <usersec.h>]
409         )
410         AC_CHECK_FUNCS(getgrset setauthdb)
411         AC_CHECK_DECL(F_CLOSEM,
412             AC_DEFINE(HAVE_FCNTL_CLOSEM, 1, [Use F_CLOSEM fcntl for closefrom]),
413             [],
414             [ #include <limits.h>
415               #include <fcntl.h> ]
416         )
417         check_for_aix_broken_getaddrinfo=1
418         AC_DEFINE(BROKEN_REALPATH, 1, [Define if you have a broken realpath.])
419         AC_DEFINE(SETEUID_BREAKS_SETUID, 1,
420             [Define if your platform breaks doing a seteuid before a setuid])
421         AC_DEFINE(BROKEN_SETREUID, 1, [Define if your setreuid() is broken])
422         AC_DEFINE(BROKEN_SETREGID, 1, [Define if your setregid() is broken])
423         dnl AIX handles lastlog as part of its login message
424         AC_DEFINE(DISABLE_LASTLOG, 1, [Define if you don't want to use lastlog])
425         AC_DEFINE(LOGIN_NEEDS_UTMPX, 1,
426                 [Some systems need a utmpx entry for /bin/login to work])
427         AC_DEFINE(SPT_TYPE,SPT_REUSEARGV,
428                 [Define to a Set Process Title type if your system is
429                 supported by bsd-setproctitle.c])
430         AC_DEFINE(SSHPAM_CHAUTHTOK_NEEDS_RUID, 1,
431             [AIX 5.2 and 5.3 (and presumably newer) require this])
432         AC_DEFINE(PTY_ZEROREAD, 1, [read(1) can return 0 for a non-closed fd])
433         ;;
434 *-*-cygwin*)
435         check_for_libcrypt_later=1
436         LIBS="$LIBS /usr/lib/textreadmode.o"
437         AC_DEFINE(HAVE_CYGWIN, 1, [Define if you are on Cygwin])
438         AC_DEFINE(USE_PIPES, 1, [Use PIPES instead of a socketpair()])
439         AC_DEFINE(DISABLE_SHADOW, 1,
440                 [Define if you want to disable shadow passwords])
441         AC_DEFINE(NO_X11_UNIX_SOCKETS, 1,
442                 [Define if X11 doesn't support AF_UNIX sockets on that system])
443         AC_DEFINE(NO_IPPORT_RESERVED_CONCEPT, 1,
444                 [Define if the concept of ports only accessible to
445                 superusers isn't known])
446         AC_DEFINE(DISABLE_FD_PASSING, 1,
447                 [Define if your platform needs to skip post auth
448                 file descriptor passing])
449         AC_DEFINE(SSH_IOBUFSZ, 65535, [Windows is sensitive to read buffer size])
450         ;;
451 *-*-dgux*)
452         AC_DEFINE(IP_TOS_IS_BROKEN, 1,
453                 [Define if your system choked on IP TOS setting])
454         AC_DEFINE(SETEUID_BREAKS_SETUID)
455         AC_DEFINE(BROKEN_SETREUID)
456         AC_DEFINE(BROKEN_SETREGID)
457         ;;
458 *-*-darwin*)
459         AC_MSG_CHECKING(if we have working getaddrinfo)
460         AC_TRY_RUN([#include <mach-o/dyld.h>
461 main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
462                 exit(0);
463         else
464                 exit(1);
465 }], [AC_MSG_RESULT(working)],
466         [AC_MSG_RESULT(buggy)
467         AC_DEFINE(BROKEN_GETADDRINFO, 1, [getaddrinfo is broken (if present)])],
468         [AC_MSG_RESULT(assume it is working)])
469         AC_DEFINE(SETEUID_BREAKS_SETUID)
470         AC_DEFINE(BROKEN_SETREUID)
471         AC_DEFINE(BROKEN_SETREGID)
472         AC_DEFINE(BROKEN_GLOB, 1, [OS X glob does not do what we expect])
473         AC_DEFINE_UNQUOTED(BIND_8_COMPAT, 1,
474                 [Define if your resolver libs need this for getrrsetbyname])
475         AC_DEFINE(SSH_TUN_FREEBSD, 1, [Open tunnel devices the FreeBSD way])
476         AC_DEFINE(SSH_TUN_COMPAT_AF, 1,
477             [Use tunnel device compatibility to OpenBSD])
478         AC_DEFINE(SSH_TUN_PREPEND_AF, 1,
479             [Prepend the address family to IP tunnel traffic])
480         m4_pattern_allow(AU_IPv)
481         AC_CHECK_DECL(AU_IPv4, [], 
482             AC_DEFINE(AU_IPv4, 0, [System only supports IPv4 audit records])
483             [#include <bsm/audit.h>]
484         AC_DEFINE(LASTLOG_WRITE_PUTUTXLINE, 1,
485             [Define if pututxline updates lastlog too])
486         )
487         ;;
488 *-*-dragonfly*)
489         SSHDLIBS="$SSHDLIBS -lcrypt"
490         ;;
491 *-*-haiku*) 
492     LIBS="$LIBS -lbsd "
493     AC_CHECK_LIB(network, socket)
494     AC_DEFINE(HAVE_U_INT64_T)
495     MANTYPE=man 
496     ;; 
497 *-*-hpux*)
498         # first we define all of the options common to all HP-UX releases
499         CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
500         IPADDR_IN_DISPLAY=yes
501         AC_DEFINE(USE_PIPES)
502         AC_DEFINE(LOGIN_NO_ENDOPT, 1,
503             [Define if your login program cannot handle end of options ("--")])
504         AC_DEFINE(LOGIN_NEEDS_UTMPX)
505         AC_DEFINE(LOCKED_PASSWD_STRING, "*",
506                 [String used in /etc/passwd to denote locked account])
507         AC_DEFINE(SPT_TYPE,SPT_PSTAT)
508         MAIL="/var/mail/username"
509         LIBS="$LIBS -lsec"
510         AC_CHECK_LIB(xnet, t_error, ,
511             AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***]))
513         # next, we define all of the options specific to major releases
514         case "$host" in
515         *-*-hpux10*)
516                 if test -z "$GCC"; then
517                         CFLAGS="$CFLAGS -Ae"
518                 fi
519                 ;;
520         *-*-hpux11*)
521                 AC_DEFINE(PAM_SUN_CODEBASE, 1,
522                         [Define if you are using Solaris-derived PAM which
523                         passes pam_messages to the conversation function
524                         with an extra level of indirection])
525                 AC_DEFINE(DISABLE_UTMP, 1,
526                         [Define if you don't want to use utmp])
527                 AC_DEFINE(USE_BTMP, 1, [Use btmp to log bad logins])
528                 check_for_hpux_broken_getaddrinfo=1
529                 check_for_conflicting_getspnam=1
530                 ;;
531         esac
533         # lastly, we define options specific to minor releases
534         case "$host" in
535         *-*-hpux10.26)
536                 AC_DEFINE(HAVE_SECUREWARE, 1,
537                         [Define if you have SecureWare-based
538                         protected password database])
539                 disable_ptmx_check=yes
540                 LIBS="$LIBS -lsecpw"
541                 ;;
542         esac
543         ;;
544 *-*-irix5*)
545         PATH="$PATH:/usr/etc"
546         AC_DEFINE(BROKEN_INET_NTOA, 1,
547                 [Define if you system's inet_ntoa is busted
548                 (e.g. Irix gcc issue)])
549         AC_DEFINE(SETEUID_BREAKS_SETUID)
550         AC_DEFINE(BROKEN_SETREUID)
551         AC_DEFINE(BROKEN_SETREGID)
552         AC_DEFINE(WITH_ABBREV_NO_TTY, 1,
553                 [Define if you shouldn't strip 'tty' from your
554                 ttyname in [uw]tmp])
555         AC_DEFINE(LOCKED_PASSWD_STRING, "*LK*")
556         ;;
557 *-*-irix6*)
558         PATH="$PATH:/usr/etc"
559         AC_DEFINE(WITH_IRIX_ARRAY, 1,
560                 [Define if you have/want arrays
561                 (cluster-wide session managment, not C arrays)])
562         AC_DEFINE(WITH_IRIX_PROJECT, 1,
563                 [Define if you want IRIX project management])
564         AC_DEFINE(WITH_IRIX_AUDIT, 1,
565                 [Define if you want IRIX audit trails])
566         AC_CHECK_FUNC(jlimit_startjob, [AC_DEFINE(WITH_IRIX_JOBS, 1,
567                 [Define if you want IRIX kernel jobs])])
568         AC_DEFINE(BROKEN_INET_NTOA)
569         AC_DEFINE(SETEUID_BREAKS_SETUID)
570         AC_DEFINE(BROKEN_SETREUID)
571         AC_DEFINE(BROKEN_SETREGID)
572         AC_DEFINE(BROKEN_UPDWTMPX, 1, [updwtmpx is broken (if present)])
573         AC_DEFINE(WITH_ABBREV_NO_TTY)
574         AC_DEFINE(LOCKED_PASSWD_STRING, "*LK*")
575         ;;
576 *-*-k*bsd*-gnu | *-*-kopensolaris*-gnu)
577         check_for_libcrypt_later=1
578         AC_DEFINE(PAM_TTY_KLUDGE)
579         AC_DEFINE(LOCKED_PASSWD_PREFIX, "!")
580         AC_DEFINE(SPT_TYPE,SPT_REUSEARGV)
581         AC_DEFINE(_PATH_BTMP, "/var/log/btmp", [log for bad login attempts])
582         AC_DEFINE(USE_BTMP, 1, [Use btmp to log bad logins])
583         ;;
584 *-*-linux*)
585         no_dev_ptmx=1
586         check_for_libcrypt_later=1
587         check_for_openpty_ctty_bug=1
588         AC_DEFINE(PAM_TTY_KLUDGE, 1,
589                 [Work around problematic Linux PAM modules handling of PAM_TTY])
590         AC_DEFINE(LOCKED_PASSWD_PREFIX, "!",
591                 [String used in /etc/passwd to denote locked account])
592         AC_DEFINE(SPT_TYPE,SPT_REUSEARGV)
593         AC_DEFINE(LINK_OPNOTSUPP_ERRNO, EPERM,
594                 [Define to whatever link() returns for "not supported"
595                 if it doesn't return EOPNOTSUPP.])
596         AC_DEFINE(_PATH_BTMP, "/var/log/btmp", [log for bad login attempts])
597         AC_DEFINE(USE_BTMP)
598         AC_DEFINE(LINUX_OOM_ADJUST, 1, [Adjust Linux out-of-memory killer])
599         inet6_default_4in6=yes
600         case `uname -r` in
601         1.*|2.0.*)
602                 AC_DEFINE(BROKEN_CMSG_TYPE, 1,
603                         [Define if cmsg_type is not passed correctly])
604                 ;;
605         esac
606         # tun(4) forwarding compat code
607         AC_CHECK_HEADERS(linux/if_tun.h)
608         if test "x$ac_cv_header_linux_if_tun_h" = "xyes" ; then
609                 AC_DEFINE(SSH_TUN_LINUX, 1,
610                     [Open tunnel devices the Linux tun/tap way])
611                 AC_DEFINE(SSH_TUN_COMPAT_AF, 1,
612                     [Use tunnel device compatibility to OpenBSD])
613                 AC_DEFINE(SSH_TUN_PREPEND_AF, 1,
614                     [Prepend the address family to IP tunnel traffic])
615         fi
616         ;;
617 mips-sony-bsd|mips-sony-newsos4)
618         AC_DEFINE(NEED_SETPGRP, 1, [Need setpgrp to acquire controlling tty])
619         SONY=1
620         ;;
621 *-*-netbsd*)
622         check_for_libcrypt_before=1
623         if test "x$withval" != "xno" ; then
624                 need_dash_r=1
625         fi
626         AC_DEFINE(SSH_TUN_FREEBSD, 1, [Open tunnel devices the FreeBSD way])
627         AC_CHECK_HEADER([net/if_tap.h], ,
628             AC_DEFINE(SSH_TUN_NO_L2, 1, [No layer 2 tunnel support]))
629         AC_DEFINE(SSH_TUN_PREPEND_AF, 1,
630             [Prepend the address family to IP tunnel traffic])
631         ;;
632 *-*-freebsd*)
633         check_for_libcrypt_later=1
634         AC_DEFINE(LOCKED_PASSWD_PREFIX, "*LOCKED*", [Account locked with pw(1)])
635         AC_DEFINE(SSH_TUN_FREEBSD, 1, [Open tunnel devices the FreeBSD way])
636         AC_CHECK_HEADER([net/if_tap.h], ,
637             AC_DEFINE(SSH_TUN_NO_L2, 1, [No layer 2 tunnel support]))
638         AC_DEFINE(BROKEN_GLOB, 1, [FreeBSD glob does not do what we need])
639         ;;
640 *-*-bsdi*)
641         AC_DEFINE(SETEUID_BREAKS_SETUID)
642         AC_DEFINE(BROKEN_SETREUID)
643         AC_DEFINE(BROKEN_SETREGID)
644         ;;
645 *-next-*)
646         conf_lastlog_location="/usr/adm/lastlog"
647         conf_utmp_location=/etc/utmp
648         conf_wtmp_location=/usr/adm/wtmp
649         MAIL=/usr/spool/mail
650         AC_DEFINE(HAVE_NEXT, 1, [Define if you are on NeXT])
651         AC_DEFINE(BROKEN_REALPATH)
652         AC_DEFINE(USE_PIPES)
653         AC_DEFINE(BROKEN_SAVED_UIDS, 1, [Needed for NeXT])
654         ;;
655 *-*-openbsd*)
656         AC_DEFINE(HAVE_ATTRIBUTE__SENTINEL__, 1, [OpenBSD's gcc has sentinel])
657         AC_DEFINE(HAVE_ATTRIBUTE__BOUNDED__, 1, [OpenBSD's gcc has bounded])
658         AC_DEFINE(SSH_TUN_OPENBSD, 1, [Open tunnel devices the OpenBSD way])
659         AC_DEFINE(SYSLOG_R_SAFE_IN_SIGHAND, 1,
660             [syslog_r function is safe to use in in a signal handler])
661         ;;
662 *-*-solaris*)
663         if test "x$withval" != "xno" ; then
664                 need_dash_r=1
665         fi
666         AC_DEFINE(PAM_SUN_CODEBASE)
667         AC_DEFINE(LOGIN_NEEDS_UTMPX)
668         AC_DEFINE(LOGIN_NEEDS_TERM, 1,
669                 [Some versions of /bin/login need the TERM supplied
670                 on the commandline])
671         AC_DEFINE(PAM_TTY_KLUDGE)
672         AC_DEFINE(SSHPAM_CHAUTHTOK_NEEDS_RUID, 1,
673                 [Define if pam_chauthtok wants real uid set
674                 to the unpriv'ed user])
675         AC_DEFINE(LOCKED_PASSWD_STRING, "*LK*")
676         # Pushing STREAMS modules will cause sshd to acquire a controlling tty.
677         AC_DEFINE(SSHD_ACQUIRES_CTTY, 1,
678                 [Define if sshd somehow reacquires a controlling TTY
679                 after setsid()])
680         AC_DEFINE(PASSWD_NEEDS_USERNAME, 1, [must supply username to passwd
681                 in case the name is longer than 8 chars])
682         AC_DEFINE(BROKEN_TCGETATTR_ICANON, 1, [tcgetattr with ICANON may hang])
683         external_path_file=/etc/default/login
684         # hardwire lastlog location (can't detect it on some versions)
685         conf_lastlog_location="/var/adm/lastlog"
686         AC_MSG_CHECKING(for obsolete utmp and wtmp in solaris2.x)
687         sol2ver=`echo "$host"| sed -e 's/.*[[0-9]]\.//'`
688         if test "$sol2ver" -ge 8; then
689                 AC_MSG_RESULT(yes)
690                 AC_DEFINE(DISABLE_UTMP)
691                 AC_DEFINE(DISABLE_WTMP, 1,
692                         [Define if you don't want to use wtmp])
693         else
694                 AC_MSG_RESULT(no)
695         fi
696         AC_ARG_WITH(solaris-contracts,
697                 [  --with-solaris-contracts Enable Solaris process contracts (experimental)],
698                 [
699                 AC_CHECK_LIB(contract, ct_tmpl_activate,
700                         [ AC_DEFINE(USE_SOLARIS_PROCESS_CONTRACTS, 1,
701                                 [Define if you have Solaris process contracts])
702                           SSHDLIBS="$SSHDLIBS -lcontract"
703                           AC_SUBST(SSHDLIBS)
704                           SPC_MSG="yes" ], )
705                 ],
706         )
707         ;;
708 *-*-sunos4*)
709         CPPFLAGS="$CPPFLAGS -DSUNOS4"
710         AC_CHECK_FUNCS(getpwanam)
711         AC_DEFINE(PAM_SUN_CODEBASE)
712         conf_utmp_location=/etc/utmp
713         conf_wtmp_location=/var/adm/wtmp
714         conf_lastlog_location=/var/adm/lastlog
715         AC_DEFINE(USE_PIPES)
716         ;;
717 *-ncr-sysv*)
718         LIBS="$LIBS -lc89"
719         AC_DEFINE(USE_PIPES)
720         AC_DEFINE(SSHD_ACQUIRES_CTTY)
721         AC_DEFINE(SETEUID_BREAKS_SETUID)
722         AC_DEFINE(BROKEN_SETREUID)
723         AC_DEFINE(BROKEN_SETREGID)
724         ;;
725 *-sni-sysv*)
726         # /usr/ucblib MUST NOT be searched on ReliantUNIX
727         AC_CHECK_LIB(dl, dlsym, ,)
728         # -lresolv needs to be at the end of LIBS or DNS lookups break
729         AC_CHECK_LIB(resolv, res_query, [ LIBS="$LIBS -lresolv" ])
730         IPADDR_IN_DISPLAY=yes
731         AC_DEFINE(USE_PIPES)
732         AC_DEFINE(IP_TOS_IS_BROKEN)
733         AC_DEFINE(SETEUID_BREAKS_SETUID)
734         AC_DEFINE(BROKEN_SETREUID)
735         AC_DEFINE(BROKEN_SETREGID)
736         AC_DEFINE(SSHD_ACQUIRES_CTTY)
737         external_path_file=/etc/default/login
738         # /usr/ucblib/libucb.a no longer needed on ReliantUNIX
739         # Attention: always take care to bind libsocket and libnsl before libc,
740         # otherwise you will find lots of "SIOCGPGRP errno 22" on syslog
741         ;;
742 # UnixWare 1.x, UnixWare 2.x, and others based on code from Univel.
743 *-*-sysv4.2*)
744         AC_DEFINE(USE_PIPES)
745         AC_DEFINE(SETEUID_BREAKS_SETUID)
746         AC_DEFINE(BROKEN_SETREUID)
747         AC_DEFINE(BROKEN_SETREGID)
748         AC_DEFINE(PASSWD_NEEDS_USERNAME, 1, [must supply username to passwd])
749         AC_DEFINE(LOCKED_PASSWD_STRING, "*LK*")
750         ;;
751 # UnixWare 7.x, OpenUNIX 8
752 *-*-sysv5*)
753         CPPFLAGS="$CPPFLAGS -Dvsnprintf=_xvsnprintf -Dsnprintf=_xsnprintf"
754         AC_DEFINE(UNIXWARE_LONG_PASSWORDS, 1, [Support passwords > 8 chars])
755         AC_DEFINE(USE_PIPES)
756         AC_DEFINE(SETEUID_BREAKS_SETUID)
757         AC_DEFINE(BROKEN_GETADDRINFO)
758         AC_DEFINE(BROKEN_SETREUID)
759         AC_DEFINE(BROKEN_SETREGID)
760         AC_DEFINE(PASSWD_NEEDS_USERNAME)
761         case "$host" in
762         *-*-sysv5SCO_SV*)       # SCO OpenServer 6.x
763                 TEST_SHELL=/u95/bin/sh
764                 AC_DEFINE(BROKEN_LIBIAF, 1,
765                         [ia_uinfo routines not supported by OS yet])
766                 AC_DEFINE(BROKEN_UPDWTMPX)
767                 AC_CHECK_LIB(prot, getluid,[ LIBS="$LIBS -lprot"
768                         AC_CHECK_FUNCS(getluid setluid,,,-lprot)
769                         AC_DEFINE(HAVE_SECUREWARE)
770                         AC_DEFINE(DISABLE_SHADOW)
771                         ],,)
772                 ;;
773         *)      AC_DEFINE(LOCKED_PASSWD_STRING, "*LK*")
774                 check_for_libcrypt_later=1
775                 ;;
776         esac
777         ;;
778 *-*-sysv*)
779         ;;
780 # SCO UNIX and OEM versions of SCO UNIX
781 *-*-sco3.2v4*)
782         AC_MSG_ERROR("This Platform is no longer supported.")
783         ;;
784 # SCO OpenServer 5.x
785 *-*-sco3.2v5*)
786         if test -z "$GCC"; then
787                 CFLAGS="$CFLAGS -belf"
788         fi
789         LIBS="$LIBS -lprot -lx -ltinfo -lm"
790         no_dev_ptmx=1
791         AC_DEFINE(USE_PIPES)
792         AC_DEFINE(HAVE_SECUREWARE)
793         AC_DEFINE(DISABLE_SHADOW)
794         AC_DEFINE(DISABLE_FD_PASSING)
795         AC_DEFINE(SETEUID_BREAKS_SETUID)
796         AC_DEFINE(BROKEN_GETADDRINFO)
797         AC_DEFINE(BROKEN_SETREUID)
798         AC_DEFINE(BROKEN_SETREGID)
799         AC_DEFINE(WITH_ABBREV_NO_TTY)
800         AC_DEFINE(BROKEN_UPDWTMPX)
801         AC_DEFINE(PASSWD_NEEDS_USERNAME)
802         AC_CHECK_FUNCS(getluid setluid)
803         MANTYPE=man
804         TEST_SHELL=ksh
805         ;;
806 *-*-unicosmk*)
807         AC_DEFINE(NO_SSH_LASTLOG, 1,
808                 [Define if you don't want to use lastlog in session.c])
809         AC_DEFINE(SETEUID_BREAKS_SETUID)
810         AC_DEFINE(BROKEN_SETREUID)
811         AC_DEFINE(BROKEN_SETREGID)
812         AC_DEFINE(USE_PIPES)
813         AC_DEFINE(DISABLE_FD_PASSING)
814         LDFLAGS="$LDFLAGS"
815         LIBS="$LIBS -lgen -lrsc -lshare -luex -lacm"
816         MANTYPE=cat
817         ;;
818 *-*-unicosmp*)
819         AC_DEFINE(SETEUID_BREAKS_SETUID)
820         AC_DEFINE(BROKEN_SETREUID)
821         AC_DEFINE(BROKEN_SETREGID)
822         AC_DEFINE(WITH_ABBREV_NO_TTY)
823         AC_DEFINE(USE_PIPES)
824         AC_DEFINE(DISABLE_FD_PASSING)
825         LDFLAGS="$LDFLAGS"
826         LIBS="$LIBS -lgen -lacid -ldb"
827         MANTYPE=cat
828         ;;
829 *-*-unicos*)
830         AC_DEFINE(SETEUID_BREAKS_SETUID)
831         AC_DEFINE(BROKEN_SETREUID)
832         AC_DEFINE(BROKEN_SETREGID)
833         AC_DEFINE(USE_PIPES)
834         AC_DEFINE(DISABLE_FD_PASSING)
835         AC_DEFINE(NO_SSH_LASTLOG)
836         LDFLAGS="$LDFLAGS -Wl,-Dmsglevel=334:fatal"
837         LIBS="$LIBS -lgen -lrsc -lshare -luex -lacm"
838         MANTYPE=cat
839         ;;
840 *-dec-osf*)
841         AC_MSG_CHECKING(for Digital Unix SIA)
842         no_osfsia=""
843         AC_ARG_WITH(osfsia,
844                 [  --with-osfsia           Enable Digital Unix SIA],
845                 [
846                         if test "x$withval" = "xno" ; then
847                                 AC_MSG_RESULT(disabled)
848                                 no_osfsia=1
849                         fi
850                 ],
851         )
852         if test -z "$no_osfsia" ; then
853                 if test -f /etc/sia/matrix.conf; then
854                         AC_MSG_RESULT(yes)
855                         AC_DEFINE(HAVE_OSF_SIA, 1,
856                                 [Define if you have Digital Unix Security
857                                 Integration Architecture])
858                         AC_DEFINE(DISABLE_LOGIN, 1,
859                                 [Define if you don't want to use your
860                                 system's login() call])
861                         AC_DEFINE(DISABLE_FD_PASSING)
862                         LIBS="$LIBS -lsecurity -ldb -lm -laud"
863                         SIA_MSG="yes"
864                 else
865                         AC_MSG_RESULT(no)
866                         AC_DEFINE(LOCKED_PASSWD_SUBSTR, "Nologin",
867                           [String used in /etc/passwd to denote locked account])
868                 fi
869         fi
870         AC_DEFINE(BROKEN_GETADDRINFO)
871         AC_DEFINE(SETEUID_BREAKS_SETUID)
872         AC_DEFINE(BROKEN_SETREUID)
873         AC_DEFINE(BROKEN_SETREGID)
874         AC_DEFINE(BROKEN_READV_COMPARISON, 1, [Can't do comparisons on readv])
875         ;;
877 *-*-nto-qnx*)
878         AC_DEFINE(USE_PIPES)
879         AC_DEFINE(NO_X11_UNIX_SOCKETS)
880         AC_DEFINE(MISSING_NFDBITS, 1, [Define on *nto-qnx systems])
881         AC_DEFINE(MISSING_HOWMANY, 1, [Define on *nto-qnx systems])
882         AC_DEFINE(MISSING_FD_MASK, 1, [Define on *nto-qnx systems])
883         AC_DEFINE(DISABLE_LASTLOG)
884         AC_DEFINE(SSHD_ACQUIRES_CTTY)
885         AC_DEFINE(BROKEN_SHADOW_EXPIRE, 1, [QNX shadow support is broken])
886         enable_etc_default_login=no     # has incompatible /etc/default/login
887         case "$host" in
888         *-*-nto-qnx6*)
889                 AC_DEFINE(DISABLE_FD_PASSING)
890                 ;;
891         esac
892         ;;
894 *-*-ultrix*)
895         AC_DEFINE(BROKEN_GETGROUPS, 1, [getgroups(0,NULL) will return -1])
896         AC_DEFINE(BROKEN_MMAP, 1, [Ultrix mmap can't map files])
897         AC_DEFINE(NEED_SETPGRP)
898         AC_DEFINE(HAVE_SYS_SYSLOG_H, 1, [Force use of sys/syslog.h on Ultrix])
899         ;;
901 *-*-lynxos)
902         CFLAGS="$CFLAGS -D__NO_INCLUDE_WARN__"
903         AC_DEFINE(MISSING_HOWMANY)
904         AC_DEFINE(BROKEN_SETVBUF, 1, [LynxOS has broken setvbuf() implementation])
905         ;;
906 esac
908 AC_MSG_CHECKING(compiler and flags for sanity)
909 AC_RUN_IFELSE(
910         [AC_LANG_SOURCE([
911 #include <stdio.h>
912 int main(){exit(0);}
913         ])],
914         [       AC_MSG_RESULT(yes) ],
915         [
916                 AC_MSG_RESULT(no)
917                 AC_MSG_ERROR([*** compiler cannot create working executables, check config.log ***])
918         ],
919         [       AC_MSG_WARN([cross compiling: not checking compiler sanity]) ]
922 dnl Checks for header files.
923 # Checks for libraries.
924 AC_CHECK_FUNC(yp_match, , AC_CHECK_LIB(nsl, yp_match))
925 AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt))
927 dnl IRIX and Solaris 2.5.1 have dirname() in libgen
928 AC_CHECK_FUNCS(dirname, [AC_CHECK_HEADERS(libgen.h)] ,[
929         AC_CHECK_LIB(gen, dirname,[
930                 AC_CACHE_CHECK([for broken dirname],
931                         ac_cv_have_broken_dirname, [
932                         save_LIBS="$LIBS"
933                         LIBS="$LIBS -lgen"
934                         AC_RUN_IFELSE(
935                                 [AC_LANG_SOURCE([[
936 #include <libgen.h>
937 #include <string.h>
939 int main(int argc, char **argv) {
940     char *s, buf[32];
942     strncpy(buf,"/etc", 32);
943     s = dirname(buf);
944     if (!s || strncmp(s, "/", 32) != 0) {
945         exit(1);
946     } else {
947         exit(0);
948     }
950                                 ]])],
951                                 [ ac_cv_have_broken_dirname="no" ],
952                                 [ ac_cv_have_broken_dirname="yes" ],
953                                 [ ac_cv_have_broken_dirname="no" ],
954                         )
955                         LIBS="$save_LIBS"
956                 ])
957                 if test "x$ac_cv_have_broken_dirname" = "xno" ; then
958                         LIBS="$LIBS -lgen"
959                         AC_DEFINE(HAVE_DIRNAME)
960                         AC_CHECK_HEADERS(libgen.h)
961                 fi
962         ])
965 AC_CHECK_FUNC(getspnam, ,
966         AC_CHECK_LIB(gen, getspnam, LIBS="$LIBS -lgen"))
967 AC_SEARCH_LIBS(basename, gen, AC_DEFINE(HAVE_BASENAME, 1,
968         [Define if you have the basename function.]))
970 dnl zlib is required
971 AC_ARG_WITH(zlib,
972         [  --with-zlib=PATH        Use zlib in PATH],
973         [ if test "x$withval" = "xno" ; then
974                 AC_MSG_ERROR([*** zlib is required ***])
975           elif test "x$withval" != "xyes"; then
976                 if test -d "$withval/lib"; then
977                         if test -n "${need_dash_r}"; then
978                                 LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
979                         else
980                                 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
981                         fi
982                 else
983                         if test -n "${need_dash_r}"; then
984                                 LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
985                         else
986                                 LDFLAGS="-L${withval} ${LDFLAGS}"
987                         fi
988                 fi
989                 if test -d "$withval/include"; then
990                         CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
991                 else
992                         CPPFLAGS="-I${withval} ${CPPFLAGS}"
993                 fi
994         fi ]
997 AC_CHECK_HEADER([zlib.h], ,AC_MSG_ERROR([*** zlib.h missing - please install first or check config.log ***]))
998 AC_CHECK_LIB(z, deflate, ,
999         [
1000                 saved_CPPFLAGS="$CPPFLAGS"
1001                 saved_LDFLAGS="$LDFLAGS"
1002                 save_LIBS="$LIBS"
1003                 dnl Check default zlib install dir
1004                 if test -n "${need_dash_r}"; then
1005                         LDFLAGS="-L/usr/local/lib -R/usr/local/lib ${saved_LDFLAGS}"
1006                 else
1007                         LDFLAGS="-L/usr/local/lib ${saved_LDFLAGS}"
1008                 fi
1009                 CPPFLAGS="-I/usr/local/include ${saved_CPPFLAGS}"
1010                 LIBS="$LIBS -lz"
1011                 AC_TRY_LINK_FUNC(deflate, AC_DEFINE(HAVE_LIBZ),
1012                         [
1013                                 AC_MSG_ERROR([*** zlib missing - please install first or check config.log ***])
1014                         ]
1015                 )
1016         ]
1019 AC_ARG_WITH(zlib-version-check,
1020         [  --without-zlib-version-check Disable zlib version check],
1021         [  if test "x$withval" = "xno" ; then
1022                 zlib_check_nonfatal=1
1023            fi
1024         ]
1027 AC_MSG_CHECKING(for possibly buggy zlib)
1028 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1029 #include <stdio.h>
1030 #include <zlib.h>
1031 int main()
1033         int a=0, b=0, c=0, d=0, n, v;
1034         n = sscanf(ZLIB_VERSION, "%d.%d.%d.%d", &a, &b, &c, &d);
1035         if (n != 3 && n != 4)
1036                 exit(1);
1037         v = a*1000000 + b*10000 + c*100 + d;
1038         fprintf(stderr, "found zlib version %s (%d)\n", ZLIB_VERSION, v);
1040         /* 1.1.4 is OK */
1041         if (a == 1 && b == 1 && c >= 4)
1042                 exit(0);
1044         /* 1.2.3 and up are OK */
1045         if (v >= 1020300)
1046                 exit(0);
1048         exit(2);
1050         ]])],
1051         AC_MSG_RESULT(no),
1052         [ AC_MSG_RESULT(yes)
1053           if test -z "$zlib_check_nonfatal" ; then
1054                 AC_MSG_ERROR([*** zlib too old - check config.log ***
1055 Your reported zlib version has known security problems.  It's possible your
1056 vendor has fixed these problems without changing the version number.  If you
1057 are sure this is the case, you can disable the check by running
1058 "./configure --without-zlib-version-check".
1059 If you are in doubt, upgrade zlib to version 1.2.3 or greater.
1060 See http://www.gzip.org/zlib/ for details.])
1061           else
1062                 AC_MSG_WARN([zlib version may have security problems])
1063           fi
1064         ],
1065         [       AC_MSG_WARN([cross compiling: not checking zlib version]) ]
1068 dnl UnixWare 2.x
1069 AC_CHECK_FUNC(strcasecmp,
1070         [], [ AC_CHECK_LIB(resolv, strcasecmp, LIBS="$LIBS -lresolv") ]
1072 AC_CHECK_FUNCS(utimes,
1073         [], [ AC_CHECK_LIB(c89, utimes, [AC_DEFINE(HAVE_UTIMES)
1074                                         LIBS="$LIBS -lc89"]) ]
1077 dnl    Checks for libutil functions
1078 AC_CHECK_HEADERS(libutil.h)
1079 AC_SEARCH_LIBS(login, util bsd, [AC_DEFINE(HAVE_LOGIN, 1,
1080         [Define if your libraries define login()])])
1081 AC_CHECK_FUNCS(fmt_scaled logout updwtmp logwtmp)
1083 AC_FUNC_STRFTIME
1085 # Check for ALTDIRFUNC glob() extension
1086 AC_MSG_CHECKING(for GLOB_ALTDIRFUNC support)
1087 AC_EGREP_CPP(FOUNDIT,
1088         [
1089                 #include <glob.h>
1090                 #ifdef GLOB_ALTDIRFUNC
1091                 FOUNDIT
1092                 #endif
1093         ],
1094         [
1095                 AC_DEFINE(GLOB_HAS_ALTDIRFUNC, 1,
1096                         [Define if your system glob() function has
1097                         the GLOB_ALTDIRFUNC extension])
1098                 AC_MSG_RESULT(yes)
1099         ],
1100         [
1101                 AC_MSG_RESULT(no)
1102         ]
1105 # Check for g.gl_matchc glob() extension
1106 AC_MSG_CHECKING(for gl_matchc field in glob_t)
1107 AC_TRY_COMPILE(
1108         [ #include <glob.h> ],
1109         [glob_t g; g.gl_matchc = 1;],
1110         [
1111                 AC_DEFINE(GLOB_HAS_GL_MATCHC, 1,
1112                         [Define if your system glob() function has
1113                         gl_matchc options in glob_t])
1114                 AC_MSG_RESULT(yes)
1115         ],
1116         [
1117                 AC_MSG_RESULT(no)
1118         ]
1121 AC_CHECK_DECLS(GLOB_NOMATCH, , , [#include <glob.h>])
1123 AC_MSG_CHECKING([whether struct dirent allocates space for d_name])
1124 AC_RUN_IFELSE(
1125         [AC_LANG_SOURCE([[
1126 #include <sys/types.h>
1127 #include <dirent.h>
1128 int main(void){struct dirent d;exit(sizeof(d.d_name)<=sizeof(char));}
1129         ]])],
1130         [AC_MSG_RESULT(yes)],
1131         [
1132                 AC_MSG_RESULT(no)
1133                 AC_DEFINE(BROKEN_ONE_BYTE_DIRENT_D_NAME, 1,
1134                         [Define if your struct dirent expects you to
1135                         allocate extra space for d_name])
1136         ],
1137         [
1138                 AC_MSG_WARN([cross compiling: assuming BROKEN_ONE_BYTE_DIRENT_D_NAME])
1139                 AC_DEFINE(BROKEN_ONE_BYTE_DIRENT_D_NAME)
1140         ]
1143 AC_MSG_CHECKING([for /proc/pid/fd directory])
1144 if test -d "/proc/$$/fd" ; then
1145         AC_DEFINE(HAVE_PROC_PID, 1, [Define if you have /proc/$pid/fd])
1146         AC_MSG_RESULT(yes)
1147 else
1148         AC_MSG_RESULT(no)
1151 # Check whether user wants S/Key support
1152 SKEY_MSG="no"
1153 AC_ARG_WITH(skey,
1154         [  --with-skey[[=PATH]]      Enable S/Key support (optionally in PATH)],
1155         [
1156                 if test "x$withval" != "xno" ; then
1158                         if test "x$withval" != "xyes" ; then
1159                                 CPPFLAGS="$CPPFLAGS -I${withval}/include"
1160                                 LDFLAGS="$LDFLAGS -L${withval}/lib"
1161                         fi
1163                         AC_DEFINE(SKEY, 1, [Define if you want S/Key support])
1164                         LIBS="-lskey $LIBS"
1165                         SKEY_MSG="yes"
1167                         AC_MSG_CHECKING([for s/key support])
1168                         AC_LINK_IFELSE(
1169                                 [AC_LANG_SOURCE([[
1170 #include <stdio.h>
1171 #include <skey.h>
1172 int main() { char *ff = skey_keyinfo(""); ff=""; exit(0); }
1173                                 ]])],
1174                                 [AC_MSG_RESULT(yes)],
1175                                 [
1176                                         AC_MSG_RESULT(no)
1177                                         AC_MSG_ERROR([** Incomplete or missing s/key libraries.])
1178                                 ])
1179                         AC_MSG_CHECKING(if skeychallenge takes 4 arguments)
1180                         AC_TRY_COMPILE(
1181                                 [#include <stdio.h>
1182                                  #include <skey.h>],
1183                                 [(void)skeychallenge(NULL,"name","",0);],
1184                                 [AC_MSG_RESULT(yes)
1185                                  AC_DEFINE(SKEYCHALLENGE_4ARG, 1,
1186                                         [Define if your skeychallenge()
1187                                         function takes 4 arguments (NetBSD)])],
1188                                 [AC_MSG_RESULT(no)]
1189                         )
1190                 fi
1191         ]
1194 # Check whether user wants TCP wrappers support
1195 TCPW_MSG="no"
1196 AC_ARG_WITH(tcp-wrappers,
1197         [  --with-tcp-wrappers[[=PATH]] Enable tcpwrappers support (optionally in PATH)],
1198         [
1199                 if test "x$withval" != "xno" ; then
1200                         saved_LIBS="$LIBS"
1201                         saved_LDFLAGS="$LDFLAGS"
1202                         saved_CPPFLAGS="$CPPFLAGS"
1203                         if test -n "${withval}" && \
1204                             test "x${withval}" != "xyes"; then
1205                                 if test -d "${withval}/lib"; then
1206                                         if test -n "${need_dash_r}"; then
1207                                                 LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
1208                                         else
1209                                                 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
1210                                         fi
1211                                 else
1212                                         if test -n "${need_dash_r}"; then
1213                                                 LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
1214                                         else
1215                                                 LDFLAGS="-L${withval} ${LDFLAGS}"
1216                                         fi
1217                                 fi
1218                                 if test -d "${withval}/include"; then
1219                                         CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
1220                                 else
1221                                         CPPFLAGS="-I${withval} ${CPPFLAGS}"
1222                                 fi
1223                         fi
1224                         LIBS="-lwrap $LIBS"
1225                         AC_MSG_CHECKING(for libwrap)
1226                         AC_TRY_LINK(
1227                                 [
1228 #include <sys/types.h>
1229 #include <sys/socket.h>
1230 #include <netinet/in.h>
1231 #include <tcpd.h>
1232                                         int deny_severity = 0, allow_severity = 0;
1233                                 ],
1234                                 [hosts_access(0);],
1235                                 [
1236                                         AC_MSG_RESULT(yes)
1237                                         AC_DEFINE(LIBWRAP, 1,
1238                                                 [Define if you want
1239                                                 TCP Wrappers support])
1240                                         SSHDLIBS="$SSHDLIBS -lwrap"
1241                                         TCPW_MSG="yes"
1242                                 ],
1243                                 [
1244                                         AC_MSG_ERROR([*** libwrap missing])
1245                                 ]
1246                         )
1247                         LIBS="$saved_LIBS"
1248                 fi
1249         ]
1252 # Check whether user wants libedit support
1253 LIBEDIT_MSG="no"
1254 AC_ARG_WITH(libedit,
1255         [  --with-libedit[[=PATH]]   Enable libedit support for sftp],
1256         [ if test "x$withval" != "xno" ; then
1257                 if test "x$withval" = "xyes" ; then
1258                         AC_PATH_PROG(PKGCONFIG, pkg-config, no)
1259                         if test "x$PKGCONFIG" != "xno"; then
1260                                 AC_MSG_CHECKING(if $PKGCONFIG knows about libedit)
1261                                 if "$PKGCONFIG" libedit; then
1262                                         AC_MSG_RESULT(yes)
1263                                         use_pkgconfig_for_libedit=yes
1264                                 else
1265                                         AC_MSG_RESULT(no)
1266                                 fi
1267                         fi
1268                 else
1269                         CPPFLAGS="$CPPFLAGS -I${withval}/include"
1270                         if test -n "${need_dash_r}"; then
1271                                 LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
1272                         else
1273                                 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
1274                         fi
1275                 fi
1276                 if test "x$use_pkgconfig_for_libedit" == "xyes"; then
1277                         LIBEDIT=`$PKGCONFIG --libs-only-l libedit`
1278                         CPPFLAGS="$CPPFLAGS `$PKGCONFIG --cflags libedit`"
1279                 else
1280                         LIBEDIT="-ledit -lcurses"
1281                 fi
1282                 OTHERLIBS=`echo $LIBEDIT | sed 's/-ledit//'`
1283                 AC_CHECK_LIB(edit, el_init,
1284                         [ AC_DEFINE(USE_LIBEDIT, 1, [Use libedit for sftp])
1285                           LIBEDIT_MSG="yes"
1286                           AC_SUBST(LIBEDIT)
1287                         ],
1288                         [ AC_MSG_ERROR(libedit not found) ],
1289                         [ $OTHERLIBS ]
1290                 )
1291                 AC_MSG_CHECKING(if libedit version is compatible)
1292                 AC_COMPILE_IFELSE(
1293                     [AC_LANG_SOURCE([[
1294 #include <histedit.h>
1295 int main(void)
1297         int i = H_SETSIZE;
1298         el_init("", NULL, NULL, NULL);
1299         exit(0);
1301                     ]])],
1302                     [ AC_MSG_RESULT(yes) ],
1303                     [ AC_MSG_RESULT(no)
1304                       AC_MSG_ERROR(libedit version is not compatible) ]
1305                 )
1306         fi ]
1309 AUDIT_MODULE=none
1310 AC_ARG_WITH(audit,
1311         [  --with-audit=module     Enable EXPERIMENTAL audit support (modules=debug,bsm)],
1312         [
1313           AC_MSG_CHECKING(for supported audit module)
1314           case "$withval" in
1315           bsm)
1316                 AC_MSG_RESULT(bsm)
1317                 AUDIT_MODULE=bsm
1318                 dnl    Checks for headers, libs and functions
1319                 AC_CHECK_HEADERS(bsm/audit.h, [],
1320                     [AC_MSG_ERROR(BSM enabled and bsm/audit.h not found)],
1321                     [
1322 #ifdef HAVE_TIME_H
1323 # include <time.h>
1324 #endif
1325                     ]
1327                 AC_CHECK_LIB(bsm, getaudit, [],
1328                     [AC_MSG_ERROR(BSM enabled and required library not found)])
1329                 AC_CHECK_FUNCS(getaudit, [],
1330                     [AC_MSG_ERROR(BSM enabled and required function not found)])
1331                 # These are optional
1332                 AC_CHECK_FUNCS(getaudit_addr aug_get_machine)
1333                 AC_DEFINE(USE_BSM_AUDIT, 1, [Use BSM audit module])
1334                 ;;
1335           debug)
1336                 AUDIT_MODULE=debug
1337                 AC_MSG_RESULT(debug)
1338                 AC_DEFINE(SSH_AUDIT_EVENTS, 1, Use audit debugging module)
1339                 ;;
1340           no)
1341                 AC_MSG_RESULT(no)
1342                 ;;
1343           *)
1344                 AC_MSG_ERROR([Unknown audit module $withval])
1345                 ;;
1346         esac ]
1349 dnl    Checks for library functions. Please keep in alphabetical order
1350 AC_CHECK_FUNCS( \
1351         arc4random \
1352         arc4random_buf \
1353         arc4random_uniform \
1354         asprintf \
1355         b64_ntop \
1356         __b64_ntop \
1357         b64_pton \
1358         __b64_pton \
1359         bcopy \
1360         bindresvport_sa \
1361         clock \
1362         closefrom \
1363         dirfd \
1364         fchmod \
1365         fchown \
1366         freeaddrinfo \
1367         fstatvfs \
1368         futimes \
1369         getaddrinfo \
1370         getcwd \
1371         getgrouplist \
1372         getnameinfo \
1373         getopt \
1374         getpeereid \
1375         getpeerucred \
1376         _getpty \
1377         getrlimit \
1378         getttyent \
1379         glob \
1380         group_from_gid \
1381         inet_aton \
1382         inet_ntoa \
1383         inet_ntop \
1384         innetgr \
1385         login_getcapbool \
1386         md5_crypt \
1387         memmove \
1388         mkdtemp \
1389         mmap \
1390         ngetaddrinfo \
1391         nsleep \
1392         ogetaddrinfo \
1393         openlog_r \
1394         openpty \
1395         poll \
1396         prctl \
1397         pstat \
1398         readpassphrase \
1399         realpath \
1400         recvmsg \
1401         rresvport_af \
1402         sendmsg \
1403         setdtablesize \
1404         setegid \
1405         setenv \
1406         seteuid \
1407         setgroupent \
1408         setgroups \
1409         setlogin \
1410         setpassent\
1411         setpcred \
1412         setproctitle \
1413         setregid \
1414         setreuid \
1415         setrlimit \
1416         setsid \
1417         setvbuf \
1418         sigaction \
1419         sigvec \
1420         snprintf \
1421         socketpair \
1422         statfs \
1423         statvfs \
1424         strdup \
1425         strerror \
1426         strlcat \
1427         strlcpy \
1428         strmode \
1429         strnvis \
1430         strtonum \
1431         strtoll \
1432         strtoul \
1433         swap32 \
1434         sysconf \
1435         tcgetpgrp \
1436         truncate \
1437         unsetenv \
1438         updwtmpx \
1439         user_from_uid \
1440         vasprintf \
1441         vhangup \
1442         vsnprintf \
1443         waitpid \
1446 # PKCS#11 support requires dlopen() and co
1447 AC_SEARCH_LIBS(dlopen, dl,
1448     AC_DEFINE([ENABLE_PKCS11], [], [Enable for PKCS#11 support])
1451 # IRIX has a const char return value for gai_strerror()
1452 AC_CHECK_FUNCS(gai_strerror,[
1453         AC_DEFINE(HAVE_GAI_STRERROR)
1454         AC_TRY_COMPILE([
1455 #include <sys/types.h>
1456 #include <sys/socket.h>
1457 #include <netdb.h>
1459 const char *gai_strerror(int);],[
1460 char *str;
1462 str = gai_strerror(0);],[
1463                 AC_DEFINE(HAVE_CONST_GAI_STRERROR_PROTO, 1,
1464                 [Define if gai_strerror() returns const char *])])])
1466 AC_SEARCH_LIBS(nanosleep, rt posix4, AC_DEFINE(HAVE_NANOSLEEP, 1,
1467         [Some systems put nanosleep outside of libc]))
1469 dnl Make sure prototypes are defined for these before using them.
1470 AC_CHECK_DECL(getrusage, [AC_CHECK_FUNCS(getrusage)])
1471 AC_CHECK_DECL(strsep,
1472         [AC_CHECK_FUNCS(strsep)],
1473         [],
1474         [
1475 #ifdef HAVE_STRING_H
1476 # include <string.h>
1477 #endif
1478         ])
1480 dnl tcsendbreak might be a macro
1481 AC_CHECK_DECL(tcsendbreak,
1482         [AC_DEFINE(HAVE_TCSENDBREAK)],
1483         [AC_CHECK_FUNCS(tcsendbreak)],
1484         [#include <termios.h>]
1487 AC_CHECK_DECLS(h_errno, , ,[#include <netdb.h>])
1489 AC_CHECK_DECLS(SHUT_RD, , ,
1490         [
1491 #include <sys/types.h>
1492 #include <sys/socket.h>
1493         ])
1495 AC_CHECK_DECLS(O_NONBLOCK, , ,
1496         [
1497 #include <sys/types.h>
1498 #ifdef HAVE_SYS_STAT_H
1499 # include <sys/stat.h>
1500 #endif
1501 #ifdef HAVE_FCNTL_H
1502 # include <fcntl.h>
1503 #endif
1504         ])
1506 AC_CHECK_DECLS(writev, , , [
1507 #include <sys/types.h>
1508 #include <sys/uio.h>
1509 #include <unistd.h>
1510         ])
1512 AC_CHECK_DECLS(MAXSYMLINKS, , , [
1513 #include <sys/param.h>
1514         ])
1516 AC_CHECK_DECLS(offsetof, , , [
1517 #include <stddef.h>
1518         ])
1520 AC_CHECK_FUNCS(setresuid, [
1521         dnl Some platorms have setresuid that isn't implemented, test for this
1522         AC_MSG_CHECKING(if setresuid seems to work)
1523         AC_RUN_IFELSE(
1524                 [AC_LANG_SOURCE([[
1525 #include <stdlib.h>
1526 #include <errno.h>
1527 int main(){errno=0; setresuid(0,0,0); if (errno==ENOSYS) exit(1); else exit(0);}
1528                 ]])],
1529                 [AC_MSG_RESULT(yes)],
1530                 [AC_DEFINE(BROKEN_SETRESUID, 1,
1531                         [Define if your setresuid() is broken])
1532                  AC_MSG_RESULT(not implemented)],
1533                 [AC_MSG_WARN([cross compiling: not checking setresuid])]
1534         )
1537 AC_CHECK_FUNCS(setresgid, [
1538         dnl Some platorms have setresgid that isn't implemented, test for this
1539         AC_MSG_CHECKING(if setresgid seems to work)
1540         AC_RUN_IFELSE(
1541                 [AC_LANG_SOURCE([[
1542 #include <stdlib.h>
1543 #include <errno.h>
1544 int main(){errno=0; setresgid(0,0,0); if (errno==ENOSYS) exit(1); else exit(0);}
1545                 ]])],
1546                 [AC_MSG_RESULT(yes)],
1547                 [AC_DEFINE(BROKEN_SETRESGID, 1,
1548                         [Define if your setresgid() is broken])
1549                  AC_MSG_RESULT(not implemented)],
1550                 [AC_MSG_WARN([cross compiling: not checking setresuid])]
1551         )
1554 dnl    Checks for time functions
1555 AC_CHECK_FUNCS(gettimeofday time)
1556 dnl    Checks for utmp functions
1557 AC_CHECK_FUNCS(endutent getutent getutid getutline pututline setutent)
1558 AC_CHECK_FUNCS(utmpname)
1559 dnl    Checks for utmpx functions
1560 AC_CHECK_FUNCS(endutxent getutxent getutxid getutxline getutxuser pututxline)
1561 AC_CHECK_FUNCS(setutxdb setutxent utmpxname)
1562 dnl    Checks for lastlog functions
1563 AC_CHECK_FUNCS(getlastlogxbyname)
1565 AC_CHECK_FUNC(daemon,
1566         [AC_DEFINE(HAVE_DAEMON, 1, [Define if your libraries define daemon()])],
1567         [AC_CHECK_LIB(bsd, daemon,
1568                 [LIBS="$LIBS -lbsd"; AC_DEFINE(HAVE_DAEMON)])]
1571 AC_CHECK_FUNC(getpagesize,
1572         [AC_DEFINE(HAVE_GETPAGESIZE, 1,
1573                 [Define if your libraries define getpagesize()])],
1574         [AC_CHECK_LIB(ucb, getpagesize,
1575                 [LIBS="$LIBS -lucb"; AC_DEFINE(HAVE_GETPAGESIZE)])]
1578 # Check for broken snprintf
1579 if test "x$ac_cv_func_snprintf" = "xyes" ; then
1580         AC_MSG_CHECKING([whether snprintf correctly terminates long strings])
1581         AC_RUN_IFELSE(
1582                 [AC_LANG_SOURCE([[
1583 #include <stdio.h>
1584 int main(void){char b[5];snprintf(b,5,"123456789");exit(b[4]!='\0');}
1585                 ]])],
1586                 [AC_MSG_RESULT(yes)],
1587                 [
1588                         AC_MSG_RESULT(no)
1589                         AC_DEFINE(BROKEN_SNPRINTF, 1,
1590                                 [Define if your snprintf is busted])
1591                         AC_MSG_WARN([****** Your snprintf() function is broken, complain to your vendor])
1592                 ],
1593                 [ AC_MSG_WARN([cross compiling: Assuming working snprintf()]) ]
1594         )
1597 # If we don't have a working asprintf, then we strongly depend on vsnprintf
1598 # returning the right thing on overflow: the number of characters it tried to
1599 # create (as per SUSv3)
1600 if test "x$ac_cv_func_asprintf" != "xyes" && \
1601    test "x$ac_cv_func_vsnprintf" = "xyes" ; then
1602         AC_MSG_CHECKING([whether vsnprintf returns correct values on overflow])
1603         AC_RUN_IFELSE(
1604                 [AC_LANG_SOURCE([[
1605 #include <sys/types.h>
1606 #include <stdio.h>
1607 #include <stdarg.h>
1609 int x_snprintf(char *str,size_t count,const char *fmt,...)
1611         size_t ret; va_list ap;
1612         va_start(ap, fmt); ret = vsnprintf(str, count, fmt, ap); va_end(ap);
1613         return ret;
1615 int main(void)
1617         char x[1];
1618         exit(x_snprintf(x, 1, "%s %d", "hello", 12345) == 11 ? 0 : 1);
1619 } ]])],
1620                 [AC_MSG_RESULT(yes)],
1621                 [
1622                         AC_MSG_RESULT(no)
1623                         AC_DEFINE(BROKEN_SNPRINTF, 1,
1624                                 [Define if your snprintf is busted])
1625                         AC_MSG_WARN([****** Your vsnprintf() function is broken, complain to your vendor])
1626                 ],
1627                 [ AC_MSG_WARN([cross compiling: Assuming working vsnprintf()]) ]
1628         )
1631 # On systems where [v]snprintf is broken, but is declared in stdio,
1632 # check that the fmt argument is const char * or just char *.
1633 # This is only useful for when BROKEN_SNPRINTF
1634 AC_MSG_CHECKING([whether snprintf can declare const char *fmt])
1635 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
1636            int snprintf(char *a, size_t b, const char *c, ...) { return 0; }
1637            int main(void) { snprintf(0, 0, 0); } 
1638     ]])],
1639    [AC_MSG_RESULT(yes)
1640     AC_DEFINE(SNPRINTF_CONST, [const],
1641               [Define as const if snprintf() can declare const char *fmt])],
1642    [AC_MSG_RESULT(no)
1643     AC_DEFINE(SNPRINTF_CONST, [/* not const */])])
1645 # Check for missing getpeereid (or equiv) support
1646 NO_PEERCHECK=""
1647 if test "x$ac_cv_func_getpeereid" != "xyes" -a "x$ac_cv_func_getpeerucred" != "xyes"; then
1648         AC_MSG_CHECKING([whether system supports SO_PEERCRED getsockopt])
1649         AC_TRY_COMPILE(
1650                 [#include <sys/types.h>
1651                  #include <sys/socket.h>],
1652                 [int i = SO_PEERCRED;],
1653                 [ AC_MSG_RESULT(yes)
1654                   AC_DEFINE(HAVE_SO_PEERCRED, 1, [Have PEERCRED socket option])
1655                 ],
1656                 [AC_MSG_RESULT(no)
1657                 NO_PEERCHECK=1]
1658         )
1661 dnl see whether mkstemp() requires XXXXXX
1662 if test "x$ac_cv_func_mkdtemp" = "xyes" ; then
1663 AC_MSG_CHECKING([for (overly) strict mkstemp])
1664 AC_RUN_IFELSE(
1665         [AC_LANG_SOURCE([[
1666 #include <stdlib.h>
1667 main() { char template[]="conftest.mkstemp-test";
1668 if (mkstemp(template) == -1)
1669         exit(1);
1670 unlink(template); exit(0);
1672         ]])],
1673         [
1674                 AC_MSG_RESULT(no)
1675         ],
1676         [
1677                 AC_MSG_RESULT(yes)
1678                 AC_DEFINE(HAVE_STRICT_MKSTEMP, 1, [Silly mkstemp()])
1679         ],
1680         [
1681                 AC_MSG_RESULT(yes)
1682                 AC_DEFINE(HAVE_STRICT_MKSTEMP)
1683         ]
1687 dnl make sure that openpty does not reacquire controlling terminal
1688 if test ! -z "$check_for_openpty_ctty_bug"; then
1689         AC_MSG_CHECKING(if openpty correctly handles controlling tty)
1690         AC_RUN_IFELSE(
1691                 [AC_LANG_SOURCE([[
1692 #include <stdio.h>
1693 #include <sys/fcntl.h>
1694 #include <sys/types.h>
1695 #include <sys/wait.h>
1698 main()
1700         pid_t pid;
1701         int fd, ptyfd, ttyfd, status;
1703         pid = fork();
1704         if (pid < 0) {          /* failed */
1705                 exit(1);
1706         } else if (pid > 0) {   /* parent */
1707                 waitpid(pid, &status, 0);
1708                 if (WIFEXITED(status))
1709                         exit(WEXITSTATUS(status));
1710                 else
1711                         exit(2);
1712         } else {                /* child */
1713                 close(0); close(1); close(2);
1714                 setsid();
1715                 openpty(&ptyfd, &ttyfd, NULL, NULL, NULL);
1716                 fd = open("/dev/tty", O_RDWR | O_NOCTTY);
1717                 if (fd >= 0)
1718                         exit(3);        /* Acquired ctty: broken */
1719                 else
1720                         exit(0);        /* Did not acquire ctty: OK */
1721         }
1723                 ]])],
1724                 [
1725                         AC_MSG_RESULT(yes)
1726                 ],
1727                 [
1728                         AC_MSG_RESULT(no)
1729                         AC_DEFINE(SSHD_ACQUIRES_CTTY)
1730                 ],
1731                 [
1732                         AC_MSG_RESULT(cross-compiling, assuming yes)
1733                 ]
1734         )
1737 if test "x$ac_cv_func_getaddrinfo" = "xyes" && \
1738     test "x$check_for_hpux_broken_getaddrinfo" = "x1"; then
1739         AC_MSG_CHECKING(if getaddrinfo seems to work)
1740         AC_RUN_IFELSE(
1741                 [AC_LANG_SOURCE([[
1742 #include <stdio.h>
1743 #include <sys/socket.h>
1744 #include <netdb.h>
1745 #include <errno.h>
1746 #include <netinet/in.h>
1748 #define TEST_PORT "2222"
1751 main(void)
1753         int err, sock;
1754         struct addrinfo *gai_ai, *ai, hints;
1755         char ntop[NI_MAXHOST], strport[NI_MAXSERV], *name = NULL;
1757         memset(&hints, 0, sizeof(hints));
1758         hints.ai_family = PF_UNSPEC;
1759         hints.ai_socktype = SOCK_STREAM;
1760         hints.ai_flags = AI_PASSIVE;
1762         err = getaddrinfo(name, TEST_PORT, &hints, &gai_ai);
1763         if (err != 0) {
1764                 fprintf(stderr, "getaddrinfo failed (%s)", gai_strerror(err));
1765                 exit(1);
1766         }
1768         for (ai = gai_ai; ai != NULL; ai = ai->ai_next) {
1769                 if (ai->ai_family != AF_INET6)
1770                         continue;
1772                 err = getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop,
1773                     sizeof(ntop), strport, sizeof(strport),
1774                     NI_NUMERICHOST|NI_NUMERICSERV);
1776                 if (err != 0) {
1777                         if (err == EAI_SYSTEM)
1778                                 perror("getnameinfo EAI_SYSTEM");
1779                         else
1780                                 fprintf(stderr, "getnameinfo failed: %s\n",
1781                                     gai_strerror(err));
1782                         exit(2);
1783                 }
1785                 sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
1786                 if (sock < 0)
1787                         perror("socket");
1788                 if (bind(sock, ai->ai_addr, ai->ai_addrlen) < 0) {
1789                         if (errno == EBADF)
1790                                 exit(3);
1791                 }
1792         }
1793         exit(0);
1795                 ]])],
1796                 [
1797                         AC_MSG_RESULT(yes)
1798                 ],
1799                 [
1800                         AC_MSG_RESULT(no)
1801                         AC_DEFINE(BROKEN_GETADDRINFO)
1802                 ],
1803                 [
1804                         AC_MSG_RESULT(cross-compiling, assuming yes)
1805                 ]
1806         )
1809 if test "x$ac_cv_func_getaddrinfo" = "xyes" && \
1810     test "x$check_for_aix_broken_getaddrinfo" = "x1"; then
1811         AC_MSG_CHECKING(if getaddrinfo seems to work)
1812         AC_RUN_IFELSE(
1813                 [AC_LANG_SOURCE([[
1814 #include <stdio.h>
1815 #include <sys/socket.h>
1816 #include <netdb.h>
1817 #include <errno.h>
1818 #include <netinet/in.h>
1820 #define TEST_PORT "2222"
1823 main(void)
1825         int err, sock;
1826         struct addrinfo *gai_ai, *ai, hints;
1827         char ntop[NI_MAXHOST], strport[NI_MAXSERV], *name = NULL;
1829         memset(&hints, 0, sizeof(hints));
1830         hints.ai_family = PF_UNSPEC;
1831         hints.ai_socktype = SOCK_STREAM;
1832         hints.ai_flags = AI_PASSIVE;
1834         err = getaddrinfo(name, TEST_PORT, &hints, &gai_ai);
1835         if (err != 0) {
1836                 fprintf(stderr, "getaddrinfo failed (%s)", gai_strerror(err));
1837                 exit(1);
1838         }
1840         for (ai = gai_ai; ai != NULL; ai = ai->ai_next) {
1841                 if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6)
1842                         continue;
1844                 err = getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop,
1845                     sizeof(ntop), strport, sizeof(strport),
1846                     NI_NUMERICHOST|NI_NUMERICSERV);
1848                 if (ai->ai_family == AF_INET && err != 0) {
1849                         perror("getnameinfo");
1850                         exit(2);
1851                 }
1852         }
1853         exit(0);
1855                 ]])],
1856                 [
1857                         AC_MSG_RESULT(yes)
1858                         AC_DEFINE(AIX_GETNAMEINFO_HACK, 1,
1859                                 [Define if you have a getaddrinfo that fails
1860                                 for the all-zeros IPv6 address])
1861                 ],
1862                 [
1863                         AC_MSG_RESULT(no)
1864                         AC_DEFINE(BROKEN_GETADDRINFO)
1865                 ],
1866                 [
1867                         AC_MSG_RESULT(cross-compiling, assuming no)
1868                 ]
1869         )
1872 if test "x$check_for_conflicting_getspnam" = "x1"; then
1873         AC_MSG_CHECKING(for conflicting getspnam in shadow.h)
1874         AC_COMPILE_IFELSE(
1875                 [
1876 #include <shadow.h>
1877 int main(void) {exit(0);}
1878                 ],
1879                 [
1880                         AC_MSG_RESULT(no)
1881                 ],
1882                 [
1883                         AC_MSG_RESULT(yes)
1884                         AC_DEFINE(GETSPNAM_CONFLICTING_DEFS, 1,
1885                             [Conflicting defs for getspnam])
1886                 ]
1887         )
1890 AC_FUNC_GETPGRP
1892 # Search for OpenSSL
1893 saved_CPPFLAGS="$CPPFLAGS"
1894 saved_LDFLAGS="$LDFLAGS"
1895 AC_ARG_WITH(ssl-dir,
1896         [  --with-ssl-dir=PATH     Specify path to OpenSSL installation ],
1897         [
1898                 if test "x$withval" != "xno" ; then
1899                         case "$withval" in
1900                                 # Relative paths
1901                                 ./*|../*)       withval="`pwd`/$withval"
1902                         esac
1903                         if test -d "$withval/lib"; then
1904                                 if test -n "${need_dash_r}"; then
1905                                         LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
1906                                 else
1907                                         LDFLAGS="-L${withval}/lib ${LDFLAGS}"
1908                                 fi
1909                         else
1910                                 if test -n "${need_dash_r}"; then
1911                                         LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
1912                                 else
1913                                         LDFLAGS="-L${withval} ${LDFLAGS}"
1914                                 fi
1915                         fi
1916                         if test -d "$withval/include"; then
1917                                 CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
1918                         else
1919                                 CPPFLAGS="-I${withval} ${CPPFLAGS}"
1920                         fi
1921                 fi
1922         ]
1924 LIBS="-lcrypto $LIBS"
1925 AC_TRY_LINK_FUNC(RAND_add, AC_DEFINE(HAVE_OPENSSL, 1,
1926         [Define if your ssl headers are included
1927         with #include <openssl/header.h>]),
1928         [
1929                 dnl Check default openssl install dir
1930                 if test -n "${need_dash_r}"; then
1931                         LDFLAGS="-L/usr/local/ssl/lib -R/usr/local/ssl/lib ${saved_LDFLAGS}"
1932                 else
1933                         LDFLAGS="-L/usr/local/ssl/lib ${saved_LDFLAGS}"
1934                 fi
1935                 CPPFLAGS="-I/usr/local/ssl/include ${saved_CPPFLAGS}"
1936                 AC_CHECK_HEADER([openssl/opensslv.h], ,
1937                     AC_MSG_ERROR([*** OpenSSL headers missing - please install first or check config.log ***]))
1938                 AC_TRY_LINK_FUNC(RAND_add, AC_DEFINE(HAVE_OPENSSL),
1939                         [
1940                                 AC_MSG_ERROR([*** Can't find recent OpenSSL libcrypto (see config.log for details) ***])
1941                         ]
1942                 )
1943         ]
1946 # Determine OpenSSL header version
1947 AC_MSG_CHECKING([OpenSSL header version])
1948 AC_RUN_IFELSE(
1949         [AC_LANG_SOURCE([[
1950 #include <stdio.h>
1951 #include <string.h>
1952 #include <openssl/opensslv.h>
1953 #define DATA "conftest.sslincver"
1954 int main(void) {
1955         FILE *fd;
1956         int rc;
1958         fd = fopen(DATA,"w");
1959         if(fd == NULL)
1960                 exit(1);
1962         if ((rc = fprintf(fd ,"%x (%s)\n", OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_TEXT)) <0)
1963                 exit(1);
1965         exit(0);
1967         ]])],
1968         [
1969                 ssl_header_ver=`cat conftest.sslincver`
1970                 AC_MSG_RESULT($ssl_header_ver)
1971         ],
1972         [
1973                 AC_MSG_RESULT(not found)
1974                 AC_MSG_ERROR(OpenSSL version header not found.)
1975         ],
1976         [
1977                 AC_MSG_WARN([cross compiling: not checking])
1978         ]
1981 # Determine OpenSSL library version
1982 AC_MSG_CHECKING([OpenSSL library version])
1983 AC_RUN_IFELSE(
1984         [AC_LANG_SOURCE([[
1985 #include <stdio.h>
1986 #include <string.h>
1987 #include <openssl/opensslv.h>
1988 #include <openssl/crypto.h>
1989 #define DATA "conftest.ssllibver"
1990 int main(void) {
1991         FILE *fd;
1992         int rc;
1994         fd = fopen(DATA,"w");
1995         if(fd == NULL)
1996                 exit(1);
1998         if ((rc = fprintf(fd ,"%x (%s)\n", SSLeay(), SSLeay_version(SSLEAY_VERSION))) <0)
1999                 exit(1);
2001         exit(0);
2003         ]])],
2004         [
2005                 ssl_library_ver=`cat conftest.ssllibver`
2006                 AC_MSG_RESULT($ssl_library_ver)
2007         ],
2008         [
2009                 AC_MSG_RESULT(not found)
2010                 AC_MSG_ERROR(OpenSSL library not found.)
2011         ],
2012         [
2013                 AC_MSG_WARN([cross compiling: not checking])
2014         ]
2017 AC_ARG_WITH(openssl-header-check,
2018         [  --without-openssl-header-check Disable OpenSSL version consistency check],
2019         [  if test "x$withval" = "xno" ; then
2020                 openssl_check_nonfatal=1
2021            fi
2022         ]
2025 # Sanity check OpenSSL headers
2026 AC_MSG_CHECKING([whether OpenSSL's headers match the library])
2027 AC_RUN_IFELSE(
2028         [AC_LANG_SOURCE([[
2029 #include <string.h>
2030 #include <openssl/opensslv.h>
2031 int main(void) { exit(SSLeay() == OPENSSL_VERSION_NUMBER ? 0 : 1); }
2032         ]])],
2033         [
2034                 AC_MSG_RESULT(yes)
2035         ],
2036         [
2037                 AC_MSG_RESULT(no)
2038                 if test "x$openssl_check_nonfatal" = "x"; then
2039                         AC_MSG_ERROR([Your OpenSSL headers do not match your
2040 library. Check config.log for details.
2041 If you are sure your installation is consistent, you can disable the check
2042 by running "./configure --without-openssl-header-check".
2043 Also see contrib/findssl.sh for help identifying header/library mismatches.
2045                 else
2046                         AC_MSG_WARN([Your OpenSSL headers do not match your
2047 library. Check config.log for details.
2048 Also see contrib/findssl.sh for help identifying header/library mismatches.])
2049                 fi
2050         ],
2051         [
2052                 AC_MSG_WARN([cross compiling: not checking])
2053         ]
2056 AC_MSG_CHECKING([if programs using OpenSSL functions will link])
2057 AC_LINK_IFELSE(
2058         [AC_LANG_SOURCE([[
2059 #include <openssl/evp.h>
2060 int main(void) { SSLeay_add_all_algorithms(); }
2061         ]])],
2062         [
2063                 AC_MSG_RESULT(yes)
2064         ],
2065         [
2066                 AC_MSG_RESULT(no)
2067                 saved_LIBS="$LIBS"
2068                 LIBS="$LIBS -ldl"
2069                 AC_MSG_CHECKING([if programs using OpenSSL need -ldl])
2070                 AC_LINK_IFELSE(
2071                         [AC_LANG_SOURCE([[
2072 #include <openssl/evp.h>
2073 int main(void) { SSLeay_add_all_algorithms(); }
2074                         ]])],
2075                         [
2076                                 AC_MSG_RESULT(yes)
2077                         ],
2078                         [
2079                                 AC_MSG_RESULT(no)
2080                                 LIBS="$saved_LIBS"
2081                         ]
2082                 )
2083         ]
2086 AC_ARG_WITH(ssl-engine,
2087         [  --with-ssl-engine       Enable OpenSSL (hardware) ENGINE support ],
2088         [ if test "x$withval" != "xno" ; then
2089                 AC_MSG_CHECKING(for OpenSSL ENGINE support)
2090                 AC_TRY_COMPILE(
2091                         [ #include <openssl/engine.h>],
2092                         [
2093 ENGINE_load_builtin_engines();ENGINE_register_all_complete();
2094                         ],
2095                         [ AC_MSG_RESULT(yes)
2096                           AC_DEFINE(USE_OPENSSL_ENGINE, 1,
2097                              [Enable OpenSSL engine support])
2098                         ],
2099                         [ AC_MSG_ERROR(OpenSSL ENGINE support not found)]
2100                 )
2101           fi ]
2104 # Check for OpenSSL without EVP_aes_{192,256}_cbc
2105 AC_MSG_CHECKING([whether OpenSSL has crippled AES support])
2106 AC_LINK_IFELSE(
2107         [AC_LANG_SOURCE([[
2108 #include <string.h>
2109 #include <openssl/evp.h>
2110 int main(void) { exit(EVP_aes_192_cbc() == NULL || EVP_aes_256_cbc() == NULL);}
2111         ]])],
2112         [
2113                 AC_MSG_RESULT(no)
2114         ],
2115         [
2116                 AC_MSG_RESULT(yes)
2117                 AC_DEFINE(OPENSSL_LOBOTOMISED_AES, 1,
2118                     [libcrypto is missing AES 192 and 256 bit functions])
2119         ]
2122 AC_MSG_CHECKING([if EVP_DigestUpdate returns an int])
2123 AC_LINK_IFELSE(
2124         [AC_LANG_SOURCE([[
2125 #include <string.h>
2126 #include <openssl/evp.h>
2127 int main(void) { if(EVP_DigestUpdate(NULL, NULL,0)) exit(0); }
2128         ]])],
2129         [
2130                 AC_MSG_RESULT(yes)
2131         ],
2132         [
2133                 AC_MSG_RESULT(no)
2134                 AC_DEFINE(OPENSSL_EVP_DIGESTUPDATE_VOID, 1,
2135                     [Define if EVP_DigestUpdate returns void])
2136         ]
2139 # Some systems want crypt() from libcrypt, *not* the version in OpenSSL,
2140 # because the system crypt() is more featureful.
2141 if test "x$check_for_libcrypt_before" = "x1"; then
2142         AC_CHECK_LIB(crypt, crypt)
2145 # Some Linux systems (Slackware) need crypt() from libcrypt, *not* the
2146 # version in OpenSSL.
2147 if test "x$check_for_libcrypt_later" = "x1"; then
2148         AC_CHECK_LIB(crypt, crypt, LIBS="$LIBS -lcrypt")
2151 # Search for SHA256 support in libc and/or OpenSSL
2152 AC_CHECK_FUNCS(SHA256_Update EVP_sha256)
2154 saved_LIBS="$LIBS"
2155 AC_CHECK_LIB(iaf, ia_openinfo, [
2156         LIBS="$LIBS -liaf"
2157         AC_CHECK_FUNCS(set_id, [SSHDLIBS="$SSHDLIBS -liaf"
2158                                 AC_DEFINE(HAVE_LIBIAF, 1,
2159                         [Define if system has libiaf that supports set_id])
2160                                 ])
2162 LIBS="$saved_LIBS"
2164 ### Configure cryptographic random number support
2166 # Check wheter OpenSSL seeds itself
2167 AC_MSG_CHECKING([whether OpenSSL's PRNG is internally seeded])
2168 AC_RUN_IFELSE(
2169         [AC_LANG_SOURCE([[
2170 #include <string.h>
2171 #include <openssl/rand.h>
2172 int main(void) { exit(RAND_status() == 1 ? 0 : 1); }
2173         ]])],
2174         [
2175                 OPENSSL_SEEDS_ITSELF=yes
2176                 AC_MSG_RESULT(yes)
2177         ],
2178         [
2179                 AC_MSG_RESULT(no)
2180                 # Default to use of the rand helper if OpenSSL doesn't
2181                 # seed itself
2182                 USE_RAND_HELPER=yes
2183         ],
2184         [
2185                 AC_MSG_WARN([cross compiling: assuming yes])
2186                 # This is safe, since all recent OpenSSL versions will
2187                 # complain at runtime if not seeded correctly.
2188                 OPENSSL_SEEDS_ITSELF=yes
2189         ]
2192 # Check for PAM libs
2193 PAM_MSG="no"
2194 AC_ARG_WITH(pam,
2195         [  --with-pam              Enable PAM support ],
2196         [
2197                 if test "x$withval" != "xno" ; then
2198                         if test "x$ac_cv_header_security_pam_appl_h" != "xyes" && \
2199                            test "x$ac_cv_header_pam_pam_appl_h" != "xyes" ; then
2200                                 AC_MSG_ERROR([PAM headers not found])
2201                         fi
2203                         saved_LIBS="$LIBS"
2204                         AC_CHECK_LIB(dl, dlopen, , )
2205                         AC_CHECK_LIB(pam, pam_set_item, , AC_MSG_ERROR([*** libpam missing]))
2206                         AC_CHECK_FUNCS(pam_getenvlist)
2207                         AC_CHECK_FUNCS(pam_putenv)
2208                         LIBS="$saved_LIBS"
2210                         PAM_MSG="yes"
2212                         SSHDLIBS="$SSHDLIBS -lpam"
2213                         AC_DEFINE(USE_PAM, 1,
2214                                 [Define if you want to enable PAM support])
2216                         if test $ac_cv_lib_dl_dlopen = yes; then
2217                                 case "$LIBS" in
2218                                 *-ldl*)
2219                                         # libdl already in LIBS
2220                                         ;;
2221                                 *)
2222                                         SSHDLIBS="$SSHDLIBS -ldl"
2223                                         ;;
2224                                 esac
2225                         fi
2226                 fi
2227         ]
2230 # Check for older PAM
2231 if test "x$PAM_MSG" = "xyes" ; then
2232         # Check PAM strerror arguments (old PAM)
2233         AC_MSG_CHECKING([whether pam_strerror takes only one argument])
2234         AC_TRY_COMPILE(
2235                 [
2236 #include <stdlib.h>
2237 #if defined(HAVE_SECURITY_PAM_APPL_H)
2238 #include <security/pam_appl.h>
2239 #elif defined (HAVE_PAM_PAM_APPL_H)
2240 #include <pam/pam_appl.h>
2241 #endif
2242                 ],
2243                 [(void)pam_strerror((pam_handle_t *)NULL, -1);],
2244                 [AC_MSG_RESULT(no)],
2245                 [
2246                         AC_DEFINE(HAVE_OLD_PAM, 1,
2247                                 [Define if you have an old version of PAM
2248                                 which takes only one argument to pam_strerror])
2249                         AC_MSG_RESULT(yes)
2250                         PAM_MSG="yes (old library)"
2251                 ]
2252         )
2255 # Do we want to force the use of the rand helper?
2256 AC_ARG_WITH(rand-helper,
2257         [  --with-rand-helper      Use subprocess to gather strong randomness ],
2258         [
2259                 if test "x$withval" = "xno" ; then
2260                         # Force use of OpenSSL's internal RNG, even if
2261                         # the previous test showed it to be unseeded.
2262                         if test -z "$OPENSSL_SEEDS_ITSELF" ; then
2263                                 AC_MSG_WARN([*** Forcing use of OpenSSL's non-self-seeding PRNG])
2264                                 OPENSSL_SEEDS_ITSELF=yes
2265                                 USE_RAND_HELPER=""
2266                         fi
2267                 else
2268                         USE_RAND_HELPER=yes
2269                 fi
2270         ],
2273 # Which randomness source do we use?
2274 if test ! -z "$OPENSSL_SEEDS_ITSELF" && test -z "$USE_RAND_HELPER" ; then
2275         # OpenSSL only
2276         AC_DEFINE(OPENSSL_PRNG_ONLY, 1,
2277                 [Define if you want OpenSSL's internally seeded PRNG only])
2278         RAND_MSG="OpenSSL internal ONLY"
2279         INSTALL_SSH_RAND_HELPER=""
2280 elif test ! -z "$USE_RAND_HELPER" ; then
2281         # install rand helper
2282         RAND_MSG="ssh-rand-helper"
2283         INSTALL_SSH_RAND_HELPER="yes"
2285 AC_SUBST(INSTALL_SSH_RAND_HELPER)
2287 ### Configuration of ssh-rand-helper
2289 # PRNGD TCP socket
2290 AC_ARG_WITH(prngd-port,
2291         [  --with-prngd-port=PORT  read entropy from PRNGD/EGD TCP localhost:PORT],
2292         [
2293                 case "$withval" in
2294                 no)
2295                         withval=""
2296                         ;;
2297                 [[0-9]]*)
2298                         ;;
2299                 *)
2300                         AC_MSG_ERROR(You must specify a numeric port number for --with-prngd-port)
2301                         ;;
2302                 esac
2303                 if test ! -z "$withval" ; then
2304                         PRNGD_PORT="$withval"
2305                         AC_DEFINE_UNQUOTED(PRNGD_PORT, $PRNGD_PORT,
2306                                 [Port number of PRNGD/EGD random number socket])
2307                 fi
2308         ]
2311 # PRNGD Unix domain socket
2312 AC_ARG_WITH(prngd-socket,
2313         [  --with-prngd-socket=FILE read entropy from PRNGD/EGD socket FILE (default=/var/run/egd-pool)],
2314         [
2315                 case "$withval" in
2316                 yes)
2317                         withval="/var/run/egd-pool"
2318                         ;;
2319                 no)
2320                         withval=""
2321                         ;;
2322                 /*)
2323                         ;;
2324                 *)
2325                         AC_MSG_ERROR(You must specify an absolute path to the entropy socket)
2326                         ;;
2327                 esac
2329                 if test ! -z "$withval" ; then
2330                         if test ! -z "$PRNGD_PORT" ; then
2331                                 AC_MSG_ERROR(You may not specify both a PRNGD/EGD port and socket)
2332                         fi
2333                         if test ! -r "$withval" ; then
2334                                 AC_MSG_WARN(Entropy socket is not readable)
2335                         fi
2336                         PRNGD_SOCKET="$withval"
2337                         AC_DEFINE_UNQUOTED(PRNGD_SOCKET, "$PRNGD_SOCKET",
2338                                 [Location of PRNGD/EGD random number socket])
2339                 fi
2340         ],
2341         [
2342                 # Check for existing socket only if we don't have a random device already
2343                 if test "$USE_RAND_HELPER" = yes ; then
2344                         AC_MSG_CHECKING(for PRNGD/EGD socket)
2345                         # Insert other locations here
2346                         for sock in /var/run/egd-pool /dev/egd-pool /etc/entropy; do
2347                                 if test -r $sock && $TEST_MINUS_S_SH -c "test -S $sock -o -p $sock" ; then
2348                                         PRNGD_SOCKET="$sock"
2349                                         AC_DEFINE_UNQUOTED(PRNGD_SOCKET, "$PRNGD_SOCKET")
2350                                         break;
2351                                 fi
2352                         done
2353                         if test ! -z "$PRNGD_SOCKET" ; then
2354                                 AC_MSG_RESULT($PRNGD_SOCKET)
2355                         else
2356                                 AC_MSG_RESULT(not found)
2357                         fi
2358                 fi
2359         ]
2362 # Change default command timeout for hashing entropy source
2363 entropy_timeout=200
2364 AC_ARG_WITH(entropy-timeout,
2365         [  --with-entropy-timeout  Specify entropy gathering command timeout (msec)],
2366         [
2367                 if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
2368                     test "x${withval}" != "xyes"; then
2369                         entropy_timeout=$withval
2370                 fi
2371         ]
2373 AC_DEFINE_UNQUOTED(ENTROPY_TIMEOUT_MSEC, $entropy_timeout,
2374         [Builtin PRNG command timeout])
2376 SSH_PRIVSEP_USER=sshd
2377 AC_ARG_WITH(privsep-user,
2378         [  --with-privsep-user=user Specify non-privileged user for privilege separation],
2379         [
2380                 if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
2381                     test "x${withval}" != "xyes"; then
2382                         SSH_PRIVSEP_USER=$withval
2383                 fi
2384         ]
2386 AC_DEFINE_UNQUOTED(SSH_PRIVSEP_USER, "$SSH_PRIVSEP_USER",
2387         [non-privileged user for privilege separation])
2388 AC_SUBST(SSH_PRIVSEP_USER)
2390 # We do this little dance with the search path to insure
2391 # that programs that we select for use by installed programs
2392 # (which may be run by the super-user) come from trusted
2393 # locations before they come from the user's private area.
2394 # This should help avoid accidentally configuring some
2395 # random version of a program in someone's personal bin.
2397 OPATH=$PATH
2398 PATH=/bin:/usr/bin
2399 test -h /bin 2> /dev/null && PATH=/usr/bin
2400 test -d /sbin && PATH=$PATH:/sbin
2401 test -d /usr/sbin && PATH=$PATH:/usr/sbin
2402 PATH=$PATH:/etc:$OPATH
2404 # These programs are used by the command hashing source to gather entropy
2405 OSSH_PATH_ENTROPY_PROG(PROG_LS, ls)
2406 OSSH_PATH_ENTROPY_PROG(PROG_NETSTAT, netstat)
2407 OSSH_PATH_ENTROPY_PROG(PROG_ARP, arp)
2408 OSSH_PATH_ENTROPY_PROG(PROG_IFCONFIG, ifconfig)
2409 OSSH_PATH_ENTROPY_PROG(PROG_JSTAT, jstat)
2410 OSSH_PATH_ENTROPY_PROG(PROG_PS, ps)
2411 OSSH_PATH_ENTROPY_PROG(PROG_SAR, sar)
2412 OSSH_PATH_ENTROPY_PROG(PROG_W, w)
2413 OSSH_PATH_ENTROPY_PROG(PROG_WHO, who)
2414 OSSH_PATH_ENTROPY_PROG(PROG_LAST, last)
2415 OSSH_PATH_ENTROPY_PROG(PROG_LASTLOG, lastlog)
2416 OSSH_PATH_ENTROPY_PROG(PROG_DF, df)
2417 OSSH_PATH_ENTROPY_PROG(PROG_VMSTAT, vmstat)
2418 OSSH_PATH_ENTROPY_PROG(PROG_UPTIME, uptime)
2419 OSSH_PATH_ENTROPY_PROG(PROG_IPCS, ipcs)
2420 OSSH_PATH_ENTROPY_PROG(PROG_TAIL, tail)
2421 # restore PATH
2422 PATH=$OPATH
2424 # Where does ssh-rand-helper get its randomness from?
2425 INSTALL_SSH_PRNG_CMDS=""
2426 if test ! -z "$INSTALL_SSH_RAND_HELPER" ; then
2427         if test ! -z "$PRNGD_PORT" ; then
2428                 RAND_HELPER_MSG="TCP localhost:$PRNGD_PORT"
2429         elif test ! -z "$PRNGD_SOCKET" ; then
2430                 RAND_HELPER_MSG="Unix domain socket \"$PRNGD_SOCKET\""
2431         else
2432                 RAND_HELPER_MSG="Command hashing (timeout $entropy_timeout)"
2433                 RAND_HELPER_CMDHASH=yes
2434                 INSTALL_SSH_PRNG_CMDS="yes"
2435         fi
2437 AC_SUBST(INSTALL_SSH_PRNG_CMDS)
2440 # Cheap hack to ensure NEWS-OS libraries are arranged right.
2441 if test ! -z "$SONY" ; then
2442   LIBS="$LIBS -liberty";
2445 # Check for  long long datatypes
2446 AC_CHECK_TYPES([long long, unsigned long long, long double])
2448 # Check datatype sizes
2449 AC_CHECK_SIZEOF(char, 1)
2450 AC_CHECK_SIZEOF(short int, 2)
2451 AC_CHECK_SIZEOF(int, 4)
2452 AC_CHECK_SIZEOF(long int, 4)
2453 AC_CHECK_SIZEOF(long long int, 8)
2455 # Sanity check long long for some platforms (AIX)
2456 if test "x$ac_cv_sizeof_long_long_int" = "x4" ; then
2457         ac_cv_sizeof_long_long_int=0
2460 # compute LLONG_MIN and LLONG_MAX if we don't know them.
2461 if test -z "$have_llong_max"; then
2462         AC_MSG_CHECKING([for max value of long long])
2463         AC_RUN_IFELSE(
2464                 [AC_LANG_SOURCE([[
2465 #include <stdio.h>
2466 /* Why is this so damn hard? */
2467 #ifdef __GNUC__
2468 # undef __GNUC__
2469 #endif
2470 #define __USE_ISOC99
2471 #include <limits.h>
2472 #define DATA "conftest.llminmax"
2473 #define my_abs(a) ((a) < 0 ? ((a) * -1) : (a))
2476  * printf in libc on some platforms (eg old Tru64) does not understand %lld so
2477  * we do this the hard way.
2478  */
2479 static int
2480 fprint_ll(FILE *f, long long n)
2482         unsigned int i;
2483         int l[sizeof(long long) * 8];
2485         if (n < 0)
2486                 if (fprintf(f, "-") < 0)
2487                         return -1;
2488         for (i = 0; n != 0; i++) {
2489                 l[i] = my_abs(n % 10);
2490                 n /= 10;
2491         }
2492         do {
2493                 if (fprintf(f, "%d", l[--i]) < 0)
2494                         return -1;
2495         } while (i != 0);
2496         if (fprintf(f, " ") < 0)
2497                 return -1;
2498         return 0;
2501 int main(void) {
2502         FILE *f;
2503         long long i, llmin, llmax = 0;
2505         if((f = fopen(DATA,"w")) == NULL)
2506                 exit(1);
2508 #if defined(LLONG_MIN) && defined(LLONG_MAX)
2509         fprintf(stderr, "Using system header for LLONG_MIN and LLONG_MAX\n");
2510         llmin = LLONG_MIN;
2511         llmax = LLONG_MAX;
2512 #else
2513         fprintf(stderr, "Calculating  LLONG_MIN and LLONG_MAX\n");
2514         /* This will work on one's complement and two's complement */
2515         for (i = 1; i > llmax; i <<= 1, i++)
2516                 llmax = i;
2517         llmin = llmax + 1LL;    /* wrap */
2518 #endif
2520         /* Sanity check */
2521         if (llmin + 1 < llmin || llmin - 1 < llmin || llmax + 1 > llmax
2522             || llmax - 1 > llmax || llmin == llmax || llmin == 0
2523             || llmax == 0 || llmax < LONG_MAX || llmin > LONG_MIN) {
2524                 fprintf(f, "unknown unknown\n");
2525                 exit(2);
2526         }
2528         if (fprint_ll(f, llmin) < 0)
2529                 exit(3);
2530         if (fprint_ll(f, llmax) < 0)
2531                 exit(4);
2532         if (fclose(f) < 0)
2533                 exit(5);
2534         exit(0);
2536                 ]])],
2537                 [
2538                         llong_min=`$AWK '{print $1}' conftest.llminmax`
2539                         llong_max=`$AWK '{print $2}' conftest.llminmax`
2541                         AC_MSG_RESULT($llong_max)
2542                         AC_DEFINE_UNQUOTED(LLONG_MAX, [${llong_max}LL],
2543                             [max value of long long calculated by configure])
2544                         AC_MSG_CHECKING([for min value of long long])
2545                         AC_MSG_RESULT($llong_min)
2546                         AC_DEFINE_UNQUOTED(LLONG_MIN, [${llong_min}LL],
2547                             [min value of long long calculated by configure])
2548                 ],
2549                 [
2550                         AC_MSG_RESULT(not found)
2551                 ],
2552                 [
2553                         AC_MSG_WARN([cross compiling: not checking])
2554                 ]
2555         )
2559 # More checks for data types
2560 AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [
2561         AC_TRY_COMPILE(
2562                 [ #include <sys/types.h> ],
2563                 [ u_int a; a = 1;],
2564                 [ ac_cv_have_u_int="yes" ],
2565                 [ ac_cv_have_u_int="no" ]
2566         )
2568 if test "x$ac_cv_have_u_int" = "xyes" ; then
2569         AC_DEFINE(HAVE_U_INT, 1, [define if you have u_int data type])
2570         have_u_int=1
2573 AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [
2574         AC_TRY_COMPILE(
2575                 [ #include <sys/types.h> ],
2576                 [ int8_t a; int16_t b; int32_t c; a = b = c = 1;],
2577                 [ ac_cv_have_intxx_t="yes" ],
2578                 [ ac_cv_have_intxx_t="no" ]
2579         )
2581 if test "x$ac_cv_have_intxx_t" = "xyes" ; then
2582         AC_DEFINE(HAVE_INTXX_T, 1, [define if you have intxx_t data type])
2583         have_intxx_t=1
2586 if (test -z "$have_intxx_t" && \
2587            test "x$ac_cv_header_stdint_h" = "xyes")
2588 then
2589     AC_MSG_CHECKING([for intXX_t types in stdint.h])
2590         AC_TRY_COMPILE(
2591                 [ #include <stdint.h> ],
2592                 [ int8_t a; int16_t b; int32_t c; a = b = c = 1;],
2593                 [
2594                         AC_DEFINE(HAVE_INTXX_T)
2595                         AC_MSG_RESULT(yes)
2596                 ],
2597                 [ AC_MSG_RESULT(no) ]
2598         )
2601 AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [
2602         AC_TRY_COMPILE(
2603                 [
2604 #include <sys/types.h>
2605 #ifdef HAVE_STDINT_H
2606 # include <stdint.h>
2607 #endif
2608 #include <sys/socket.h>
2609 #ifdef HAVE_SYS_BITYPES_H
2610 # include <sys/bitypes.h>
2611 #endif
2612                 ],
2613                 [ int64_t a; a = 1;],
2614                 [ ac_cv_have_int64_t="yes" ],
2615                 [ ac_cv_have_int64_t="no" ]
2616         )
2618 if test "x$ac_cv_have_int64_t" = "xyes" ; then
2619         AC_DEFINE(HAVE_INT64_T, 1, [define if you have int64_t data type])
2622 AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [
2623         AC_TRY_COMPILE(
2624                 [ #include <sys/types.h> ],
2625                 [ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;],
2626                 [ ac_cv_have_u_intxx_t="yes" ],
2627                 [ ac_cv_have_u_intxx_t="no" ]
2628         )
2630 if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
2631         AC_DEFINE(HAVE_U_INTXX_T, 1, [define if you have u_intxx_t data type])
2632         have_u_intxx_t=1
2635 if test -z "$have_u_intxx_t" ; then
2636     AC_MSG_CHECKING([for u_intXX_t types in sys/socket.h])
2637         AC_TRY_COMPILE(
2638                 [ #include <sys/socket.h> ],
2639                 [ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;],
2640                 [
2641                         AC_DEFINE(HAVE_U_INTXX_T)
2642                         AC_MSG_RESULT(yes)
2643                 ],
2644                 [ AC_MSG_RESULT(no) ]
2645         )
2648 AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [
2649         AC_TRY_COMPILE(
2650                 [ #include <sys/types.h> ],
2651                 [ u_int64_t a; a = 1;],
2652                 [ ac_cv_have_u_int64_t="yes" ],
2653                 [ ac_cv_have_u_int64_t="no" ]
2654         )
2656 if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
2657         AC_DEFINE(HAVE_U_INT64_T, 1, [define if you have u_int64_t data type])
2658         have_u_int64_t=1
2661 if test -z "$have_u_int64_t" ; then
2662     AC_MSG_CHECKING([for u_int64_t type in sys/bitypes.h])
2663         AC_TRY_COMPILE(
2664                 [ #include <sys/bitypes.h> ],
2665                 [ u_int64_t a; a = 1],
2666                 [
2667                         AC_DEFINE(HAVE_U_INT64_T)
2668                         AC_MSG_RESULT(yes)
2669                 ],
2670                 [ AC_MSG_RESULT(no) ]
2671         )
2674 if test -z "$have_u_intxx_t" ; then
2675         AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [
2676                 AC_TRY_COMPILE(
2677                         [
2678 #include <sys/types.h>
2679                         ],
2680                         [ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1; ],
2681                         [ ac_cv_have_uintxx_t="yes" ],
2682                         [ ac_cv_have_uintxx_t="no" ]
2683                 )
2684         ])
2685         if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
2686                 AC_DEFINE(HAVE_UINTXX_T, 1,
2687                         [define if you have uintxx_t data type])
2688         fi
2691 if test -z "$have_uintxx_t" ; then
2692     AC_MSG_CHECKING([for uintXX_t types in stdint.h])
2693         AC_TRY_COMPILE(
2694                 [ #include <stdint.h> ],
2695                 [ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;],
2696                 [
2697                         AC_DEFINE(HAVE_UINTXX_T)
2698                         AC_MSG_RESULT(yes)
2699                 ],
2700                 [ AC_MSG_RESULT(no) ]
2701         )
2704 if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
2705            test "x$ac_cv_header_sys_bitypes_h" = "xyes")
2706 then
2707         AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
2708         AC_TRY_COMPILE(
2709                 [
2710 #include <sys/bitypes.h>
2711                 ],
2712                 [
2713                         int8_t a; int16_t b; int32_t c;
2714                         u_int8_t e; u_int16_t f; u_int32_t g;
2715                         a = b = c = e = f = g = 1;
2716                 ],
2717                 [
2718                         AC_DEFINE(HAVE_U_INTXX_T)
2719                         AC_DEFINE(HAVE_INTXX_T)
2720                         AC_MSG_RESULT(yes)
2721                 ],
2722                 [AC_MSG_RESULT(no)]
2723         )
2727 AC_CACHE_CHECK([for u_char], ac_cv_have_u_char, [
2728         AC_TRY_COMPILE(
2729                 [
2730 #include <sys/types.h>
2731                 ],
2732                 [ u_char foo; foo = 125; ],
2733                 [ ac_cv_have_u_char="yes" ],
2734                 [ ac_cv_have_u_char="no" ]
2735         )
2737 if test "x$ac_cv_have_u_char" = "xyes" ; then
2738         AC_DEFINE(HAVE_U_CHAR, 1, [define if you have u_char data type])
2741 TYPE_SOCKLEN_T
2743 AC_CHECK_TYPES(sig_atomic_t,,,[#include <signal.h>])
2744 AC_CHECK_TYPES([fsblkcnt_t, fsfilcnt_t],,,[
2745 #include <sys/types.h>
2746 #ifdef HAVE_SYS_BITYPES_H
2747 #include <sys/bitypes.h>
2748 #endif
2749 #ifdef HAVE_SYS_STATFS_H
2750 #include <sys/statfs.h>
2751 #endif
2752 #ifdef HAVE_SYS_STATVFS_H
2753 #include <sys/statvfs.h>
2754 #endif
2757 AC_CHECK_TYPES([in_addr_t, in_port_t],,,
2758 [#include <sys/types.h>
2759 #include <netinet/in.h>])
2761 AC_CACHE_CHECK([for size_t], ac_cv_have_size_t, [
2762         AC_TRY_COMPILE(
2763                 [
2764 #include <sys/types.h>
2765                 ],
2766                 [ size_t foo; foo = 1235; ],
2767                 [ ac_cv_have_size_t="yes" ],
2768                 [ ac_cv_have_size_t="no" ]
2769         )
2771 if test "x$ac_cv_have_size_t" = "xyes" ; then
2772         AC_DEFINE(HAVE_SIZE_T, 1, [define if you have size_t data type])
2775 AC_CACHE_CHECK([for ssize_t], ac_cv_have_ssize_t, [
2776         AC_TRY_COMPILE(
2777                 [
2778 #include <sys/types.h>
2779                 ],
2780                 [ ssize_t foo; foo = 1235; ],
2781                 [ ac_cv_have_ssize_t="yes" ],
2782                 [ ac_cv_have_ssize_t="no" ]
2783         )
2785 if test "x$ac_cv_have_ssize_t" = "xyes" ; then
2786         AC_DEFINE(HAVE_SSIZE_T, 1, [define if you have ssize_t data type])
2789 AC_CACHE_CHECK([for clock_t], ac_cv_have_clock_t, [
2790         AC_TRY_COMPILE(
2791                 [
2792 #include <time.h>
2793                 ],
2794                 [ clock_t foo; foo = 1235; ],
2795                 [ ac_cv_have_clock_t="yes" ],
2796                 [ ac_cv_have_clock_t="no" ]
2797         )
2799 if test "x$ac_cv_have_clock_t" = "xyes" ; then
2800         AC_DEFINE(HAVE_CLOCK_T, 1, [define if you have clock_t data type])
2803 AC_CACHE_CHECK([for sa_family_t], ac_cv_have_sa_family_t, [
2804         AC_TRY_COMPILE(
2805                 [
2806 #include <sys/types.h>
2807 #include <sys/socket.h>
2808                 ],
2809                 [ sa_family_t foo; foo = 1235; ],
2810                 [ ac_cv_have_sa_family_t="yes" ],
2811                 [ AC_TRY_COMPILE(
2812                   [
2813 #include <sys/types.h>
2814 #include <sys/socket.h>
2815 #include <netinet/in.h>
2816                 ],
2817                 [ sa_family_t foo; foo = 1235; ],
2818                 [ ac_cv_have_sa_family_t="yes" ],
2820                 [ ac_cv_have_sa_family_t="no" ]
2821         )]
2822         )
2824 if test "x$ac_cv_have_sa_family_t" = "xyes" ; then
2825         AC_DEFINE(HAVE_SA_FAMILY_T, 1,
2826                 [define if you have sa_family_t data type])
2829 AC_CACHE_CHECK([for pid_t], ac_cv_have_pid_t, [
2830         AC_TRY_COMPILE(
2831                 [
2832 #include <sys/types.h>
2833                 ],
2834                 [ pid_t foo; foo = 1235; ],
2835                 [ ac_cv_have_pid_t="yes" ],
2836                 [ ac_cv_have_pid_t="no" ]
2837         )
2839 if test "x$ac_cv_have_pid_t" = "xyes" ; then
2840         AC_DEFINE(HAVE_PID_T, 1, [define if you have pid_t data type])
2843 AC_CACHE_CHECK([for mode_t], ac_cv_have_mode_t, [
2844         AC_TRY_COMPILE(
2845                 [
2846 #include <sys/types.h>
2847                 ],
2848                 [ mode_t foo; foo = 1235; ],
2849                 [ ac_cv_have_mode_t="yes" ],
2850                 [ ac_cv_have_mode_t="no" ]
2851         )
2853 if test "x$ac_cv_have_mode_t" = "xyes" ; then
2854         AC_DEFINE(HAVE_MODE_T, 1, [define if you have mode_t data type])
2858 AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_have_struct_sockaddr_storage, [
2859         AC_TRY_COMPILE(
2860                 [
2861 #include <sys/types.h>
2862 #include <sys/socket.h>
2863                 ],
2864                 [ struct sockaddr_storage s; ],
2865                 [ ac_cv_have_struct_sockaddr_storage="yes" ],
2866                 [ ac_cv_have_struct_sockaddr_storage="no" ]
2867         )
2869 if test "x$ac_cv_have_struct_sockaddr_storage" = "xyes" ; then
2870         AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
2871                 [define if you have struct sockaddr_storage data type])
2874 AC_CACHE_CHECK([for struct sockaddr_in6], ac_cv_have_struct_sockaddr_in6, [
2875         AC_TRY_COMPILE(
2876                 [
2877 #include <sys/types.h>
2878 #include <netinet/in.h>
2879                 ],
2880                 [ struct sockaddr_in6 s; s.sin6_family = 0; ],
2881                 [ ac_cv_have_struct_sockaddr_in6="yes" ],
2882                 [ ac_cv_have_struct_sockaddr_in6="no" ]
2883         )
2885 if test "x$ac_cv_have_struct_sockaddr_in6" = "xyes" ; then
2886         AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6, 1,
2887                 [define if you have struct sockaddr_in6 data type])
2890 AC_CACHE_CHECK([for struct in6_addr], ac_cv_have_struct_in6_addr, [
2891         AC_TRY_COMPILE(
2892                 [
2893 #include <sys/types.h>
2894 #include <netinet/in.h>
2895                 ],
2896                 [ struct in6_addr s; s.s6_addr[0] = 0; ],
2897                 [ ac_cv_have_struct_in6_addr="yes" ],
2898                 [ ac_cv_have_struct_in6_addr="no" ]
2899         )
2901 if test "x$ac_cv_have_struct_in6_addr" = "xyes" ; then
2902         AC_DEFINE(HAVE_STRUCT_IN6_ADDR, 1,
2903                 [define if you have struct in6_addr data type])
2905 dnl Now check for sin6_scope_id
2906         AC_CHECK_MEMBERS([struct sockaddr_in6.sin6_scope_id],,,
2907                 [
2908 #ifdef HAVE_SYS_TYPES_H
2909 #include <sys/types.h>
2910 #endif
2911 #include <netinet/in.h>
2912                 ])
2915 AC_CACHE_CHECK([for struct addrinfo], ac_cv_have_struct_addrinfo, [
2916         AC_TRY_COMPILE(
2917                 [
2918 #include <sys/types.h>
2919 #include <sys/socket.h>
2920 #include <netdb.h>
2921                 ],
2922                 [ struct addrinfo s; s.ai_flags = AI_PASSIVE; ],
2923                 [ ac_cv_have_struct_addrinfo="yes" ],
2924                 [ ac_cv_have_struct_addrinfo="no" ]
2925         )
2927 if test "x$ac_cv_have_struct_addrinfo" = "xyes" ; then
2928         AC_DEFINE(HAVE_STRUCT_ADDRINFO, 1,
2929                 [define if you have struct addrinfo data type])
2932 AC_CACHE_CHECK([for struct timeval], ac_cv_have_struct_timeval, [
2933         AC_TRY_COMPILE(
2934                 [ #include <sys/time.h> ],
2935                 [ struct timeval tv; tv.tv_sec = 1;],
2936                 [ ac_cv_have_struct_timeval="yes" ],
2937                 [ ac_cv_have_struct_timeval="no" ]
2938         )
2940 if test "x$ac_cv_have_struct_timeval" = "xyes" ; then
2941         AC_DEFINE(HAVE_STRUCT_TIMEVAL, 1, [define if you have struct timeval])
2942         have_struct_timeval=1
2945 AC_CHECK_TYPES(struct timespec)
2947 # We need int64_t or else certian parts of the compile will fail.
2948 if test "x$ac_cv_have_int64_t" = "xno" && \
2949         test "x$ac_cv_sizeof_long_int" != "x8" && \
2950         test "x$ac_cv_sizeof_long_long_int" = "x0" ; then
2951         echo "OpenSSH requires int64_t support.  Contact your vendor or install"
2952         echo "an alternative compiler (I.E., GCC) before continuing."
2953         echo ""
2954         exit 1;
2955 else
2956 dnl test snprintf (broken on SCO w/gcc)
2957         AC_RUN_IFELSE(
2958                 [AC_LANG_SOURCE([[
2959 #include <stdio.h>
2960 #include <string.h>
2961 #ifdef HAVE_SNPRINTF
2962 main()
2964         char buf[50];
2965         char expected_out[50];
2966         int mazsize = 50 ;
2967 #if (SIZEOF_LONG_INT == 8)
2968         long int num = 0x7fffffffffffffff;
2969 #else
2970         long long num = 0x7fffffffffffffffll;
2971 #endif
2972         strcpy(expected_out, "9223372036854775807");
2973         snprintf(buf, mazsize, "%lld", num);
2974         if(strcmp(buf, expected_out) != 0)
2975                 exit(1);
2976         exit(0);
2978 #else
2979 main() { exit(0); }
2980 #endif
2981                 ]])], [ true ], [ AC_DEFINE(BROKEN_SNPRINTF) ],
2982                 AC_MSG_WARN([cross compiling: Assuming working snprintf()])
2983         )
2986 dnl Checks for structure members
2987 OSSH_CHECK_HEADER_FOR_FIELD(ut_host, utmp.h, HAVE_HOST_IN_UTMP)
2988 OSSH_CHECK_HEADER_FOR_FIELD(ut_host, utmpx.h, HAVE_HOST_IN_UTMPX)
2989 OSSH_CHECK_HEADER_FOR_FIELD(syslen, utmpx.h, HAVE_SYSLEN_IN_UTMPX)
2990 OSSH_CHECK_HEADER_FOR_FIELD(ut_pid, utmp.h, HAVE_PID_IN_UTMP)
2991 OSSH_CHECK_HEADER_FOR_FIELD(ut_type, utmp.h, HAVE_TYPE_IN_UTMP)
2992 OSSH_CHECK_HEADER_FOR_FIELD(ut_type, utmpx.h, HAVE_TYPE_IN_UTMPX)
2993 OSSH_CHECK_HEADER_FOR_FIELD(ut_tv, utmp.h, HAVE_TV_IN_UTMP)
2994 OSSH_CHECK_HEADER_FOR_FIELD(ut_id, utmp.h, HAVE_ID_IN_UTMP)
2995 OSSH_CHECK_HEADER_FOR_FIELD(ut_id, utmpx.h, HAVE_ID_IN_UTMPX)
2996 OSSH_CHECK_HEADER_FOR_FIELD(ut_addr, utmp.h, HAVE_ADDR_IN_UTMP)
2997 OSSH_CHECK_HEADER_FOR_FIELD(ut_addr, utmpx.h, HAVE_ADDR_IN_UTMPX)
2998 OSSH_CHECK_HEADER_FOR_FIELD(ut_addr_v6, utmp.h, HAVE_ADDR_V6_IN_UTMP)
2999 OSSH_CHECK_HEADER_FOR_FIELD(ut_addr_v6, utmpx.h, HAVE_ADDR_V6_IN_UTMPX)
3000 OSSH_CHECK_HEADER_FOR_FIELD(ut_exit, utmp.h, HAVE_EXIT_IN_UTMP)
3001 OSSH_CHECK_HEADER_FOR_FIELD(ut_time, utmp.h, HAVE_TIME_IN_UTMP)
3002 OSSH_CHECK_HEADER_FOR_FIELD(ut_time, utmpx.h, HAVE_TIME_IN_UTMPX)
3003 OSSH_CHECK_HEADER_FOR_FIELD(ut_tv, utmpx.h, HAVE_TV_IN_UTMPX)
3005 AC_CHECK_MEMBERS([struct stat.st_blksize])
3006 AC_CHECK_MEMBER([struct __res_state.retrans], [], [AC_DEFINE(__res_state, state,
3007         [Define if we don't have struct __res_state in resolv.h])],
3009 #include <stdio.h>
3010 #if HAVE_SYS_TYPES_H
3011 # include <sys/types.h>
3012 #endif
3013 #include <netinet/in.h>
3014 #include <arpa/nameser.h>
3015 #include <resolv.h>
3018 AC_CACHE_CHECK([for ss_family field in struct sockaddr_storage],
3019                 ac_cv_have_ss_family_in_struct_ss, [
3020         AC_TRY_COMPILE(
3021                 [
3022 #include <sys/types.h>
3023 #include <sys/socket.h>
3024                 ],
3025                 [ struct sockaddr_storage s; s.ss_family = 1; ],
3026                 [ ac_cv_have_ss_family_in_struct_ss="yes" ],
3027                 [ ac_cv_have_ss_family_in_struct_ss="no" ],
3028         )
3030 if test "x$ac_cv_have_ss_family_in_struct_ss" = "xyes" ; then
3031         AC_DEFINE(HAVE_SS_FAMILY_IN_SS, 1, [Fields in struct sockaddr_storage])
3034 AC_CACHE_CHECK([for __ss_family field in struct sockaddr_storage],
3035                 ac_cv_have___ss_family_in_struct_ss, [
3036         AC_TRY_COMPILE(
3037                 [
3038 #include <sys/types.h>
3039 #include <sys/socket.h>
3040                 ],
3041                 [ struct sockaddr_storage s; s.__ss_family = 1; ],
3042                 [ ac_cv_have___ss_family_in_struct_ss="yes" ],
3043                 [ ac_cv_have___ss_family_in_struct_ss="no" ]
3044         )
3046 if test "x$ac_cv_have___ss_family_in_struct_ss" = "xyes" ; then
3047         AC_DEFINE(HAVE___SS_FAMILY_IN_SS, 1,
3048                 [Fields in struct sockaddr_storage])
3051 AC_CACHE_CHECK([for pw_class field in struct passwd],
3052                 ac_cv_have_pw_class_in_struct_passwd, [
3053         AC_TRY_COMPILE(
3054                 [
3055 #include <pwd.h>
3056                 ],
3057                 [ struct passwd p; p.pw_class = 0; ],
3058                 [ ac_cv_have_pw_class_in_struct_passwd="yes" ],
3059                 [ ac_cv_have_pw_class_in_struct_passwd="no" ]
3060         )
3062 if test "x$ac_cv_have_pw_class_in_struct_passwd" = "xyes" ; then
3063         AC_DEFINE(HAVE_PW_CLASS_IN_PASSWD, 1,
3064                 [Define if your password has a pw_class field])
3067 AC_CACHE_CHECK([for pw_expire field in struct passwd],
3068                 ac_cv_have_pw_expire_in_struct_passwd, [
3069         AC_TRY_COMPILE(
3070                 [
3071 #include <pwd.h>
3072                 ],
3073                 [ struct passwd p; p.pw_expire = 0; ],
3074                 [ ac_cv_have_pw_expire_in_struct_passwd="yes" ],
3075                 [ ac_cv_have_pw_expire_in_struct_passwd="no" ]
3076         )
3078 if test "x$ac_cv_have_pw_expire_in_struct_passwd" = "xyes" ; then
3079         AC_DEFINE(HAVE_PW_EXPIRE_IN_PASSWD, 1,
3080                 [Define if your password has a pw_expire field])
3083 AC_CACHE_CHECK([for pw_change field in struct passwd],
3084                 ac_cv_have_pw_change_in_struct_passwd, [
3085         AC_TRY_COMPILE(
3086                 [
3087 #include <pwd.h>
3088                 ],
3089                 [ struct passwd p; p.pw_change = 0; ],
3090                 [ ac_cv_have_pw_change_in_struct_passwd="yes" ],
3091                 [ ac_cv_have_pw_change_in_struct_passwd="no" ]
3092         )
3094 if test "x$ac_cv_have_pw_change_in_struct_passwd" = "xyes" ; then
3095         AC_DEFINE(HAVE_PW_CHANGE_IN_PASSWD, 1,
3096                 [Define if your password has a pw_change field])
3099 dnl make sure we're using the real structure members and not defines
3100 AC_CACHE_CHECK([for msg_accrights field in struct msghdr],
3101                 ac_cv_have_accrights_in_msghdr, [
3102         AC_COMPILE_IFELSE(
3103                 [
3104 #include <sys/types.h>
3105 #include <sys/socket.h>
3106 #include <sys/uio.h>
3107 int main() {
3108 #ifdef msg_accrights
3109 #error "msg_accrights is a macro"
3110 exit(1);
3111 #endif
3112 struct msghdr m;
3113 m.msg_accrights = 0;
3114 exit(0);
3116                 ],
3117                 [ ac_cv_have_accrights_in_msghdr="yes" ],
3118                 [ ac_cv_have_accrights_in_msghdr="no" ]
3119         )
3121 if test "x$ac_cv_have_accrights_in_msghdr" = "xyes" ; then
3122         AC_DEFINE(HAVE_ACCRIGHTS_IN_MSGHDR, 1,
3123                 [Define if your system uses access rights style
3124                 file descriptor passing])
3127 AC_MSG_CHECKING(if struct statvfs.f_fsid is integral type)
3128 AC_TRY_COMPILE([
3129 #include <sys/types.h>
3130 #include <sys/stat.h>
3131 #ifdef HAVE_SYS_TIME_H
3132 # include <sys/time.h>
3133 #endif
3134 #ifdef HAVE_SYS_MOUNT_H
3135 #include <sys/mount.h>
3136 #endif
3137 #ifdef HAVE_SYS_STATVFS_H
3138 #include <sys/statvfs.h>
3139 #endif
3140 ], [struct statvfs s; s.f_fsid = 0;],
3141 [ AC_MSG_RESULT(yes) ],
3142 [ AC_MSG_RESULT(no)
3144         AC_MSG_CHECKING(if fsid_t has member val)
3145         AC_TRY_COMPILE([
3146 #include <sys/types.h>
3147 #include <sys/statvfs.h>],
3148         [fsid_t t; t.val[0] = 0;],
3149         [ AC_MSG_RESULT(yes)
3150           AC_DEFINE(FSID_HAS_VAL, 1, fsid_t has member val) ],
3151         [ AC_MSG_RESULT(no) ])
3153         AC_MSG_CHECKING(if f_fsid has member __val)
3154         AC_TRY_COMPILE([
3155 #include <sys/types.h>
3156 #include <sys/statvfs.h>],
3157         [fsid_t t; t.__val[0] = 0;],
3158         [ AC_MSG_RESULT(yes)
3159           AC_DEFINE(FSID_HAS___VAL, 1, fsid_t has member __val) ],
3160         [ AC_MSG_RESULT(no) ])
3163 AC_CACHE_CHECK([for msg_control field in struct msghdr],
3164                 ac_cv_have_control_in_msghdr, [
3165         AC_COMPILE_IFELSE(
3166                 [
3167 #include <sys/types.h>
3168 #include <sys/socket.h>
3169 #include <sys/uio.h>
3170 int main() {
3171 #ifdef msg_control
3172 #error "msg_control is a macro"
3173 exit(1);
3174 #endif
3175 struct msghdr m;
3176 m.msg_control = 0;
3177 exit(0);
3179                 ],
3180                 [ ac_cv_have_control_in_msghdr="yes" ],
3181                 [ ac_cv_have_control_in_msghdr="no" ]
3182         )
3184 if test "x$ac_cv_have_control_in_msghdr" = "xyes" ; then
3185         AC_DEFINE(HAVE_CONTROL_IN_MSGHDR, 1,
3186                 [Define if your system uses ancillary data style
3187                 file descriptor passing])
3190 AC_CACHE_CHECK([if libc defines __progname], ac_cv_libc_defines___progname, [
3191         AC_TRY_LINK([],
3192                 [ extern char *__progname; printf("%s", __progname); ],
3193                 [ ac_cv_libc_defines___progname="yes" ],
3194                 [ ac_cv_libc_defines___progname="no" ]
3195         )
3197 if test "x$ac_cv_libc_defines___progname" = "xyes" ; then
3198         AC_DEFINE(HAVE___PROGNAME, 1, [Define if libc defines __progname])
3201 AC_CACHE_CHECK([whether $CC implements __FUNCTION__], ac_cv_cc_implements___FUNCTION__, [
3202         AC_TRY_LINK([
3203 #include <stdio.h>
3205                 [ printf("%s", __FUNCTION__); ],
3206                 [ ac_cv_cc_implements___FUNCTION__="yes" ],
3207                 [ ac_cv_cc_implements___FUNCTION__="no" ]
3208         )
3210 if test "x$ac_cv_cc_implements___FUNCTION__" = "xyes" ; then
3211         AC_DEFINE(HAVE___FUNCTION__, 1,
3212                 [Define if compiler implements __FUNCTION__])
3215 AC_CACHE_CHECK([whether $CC implements __func__], ac_cv_cc_implements___func__, [
3216         AC_TRY_LINK([
3217 #include <stdio.h>
3219                 [ printf("%s", __func__); ],
3220                 [ ac_cv_cc_implements___func__="yes" ],
3221                 [ ac_cv_cc_implements___func__="no" ]
3222         )
3224 if test "x$ac_cv_cc_implements___func__" = "xyes" ; then
3225         AC_DEFINE(HAVE___func__, 1, [Define if compiler implements __func__])
3228 AC_CACHE_CHECK([whether va_copy exists], ac_cv_have_va_copy, [
3229         AC_TRY_LINK(
3230                 [#include <stdarg.h>
3231                  va_list x,y;],
3232                 [va_copy(x,y);],
3233                 [ ac_cv_have_va_copy="yes" ],
3234                 [ ac_cv_have_va_copy="no" ]
3235         )
3237 if test "x$ac_cv_have_va_copy" = "xyes" ; then
3238         AC_DEFINE(HAVE_VA_COPY, 1, [Define if va_copy exists])
3241 AC_CACHE_CHECK([whether __va_copy exists], ac_cv_have___va_copy, [
3242         AC_TRY_LINK(
3243                 [#include <stdarg.h>
3244                  va_list x,y;],
3245                 [__va_copy(x,y);],
3246                 [ ac_cv_have___va_copy="yes" ],
3247                 [ ac_cv_have___va_copy="no" ]
3248         )
3250 if test "x$ac_cv_have___va_copy" = "xyes" ; then
3251         AC_DEFINE(HAVE___VA_COPY, 1, [Define if __va_copy exists])
3254 AC_CACHE_CHECK([whether getopt has optreset support],
3255                 ac_cv_have_getopt_optreset, [
3256         AC_TRY_LINK(
3257                 [
3258 #include <getopt.h>
3259                 ],
3260                 [ extern int optreset; optreset = 0; ],
3261                 [ ac_cv_have_getopt_optreset="yes" ],
3262                 [ ac_cv_have_getopt_optreset="no" ]
3263         )
3265 if test "x$ac_cv_have_getopt_optreset" = "xyes" ; then
3266         AC_DEFINE(HAVE_GETOPT_OPTRESET, 1,
3267                 [Define if your getopt(3) defines and uses optreset])
3270 AC_CACHE_CHECK([if libc defines sys_errlist], ac_cv_libc_defines_sys_errlist, [
3271         AC_TRY_LINK([],
3272                 [ extern const char *const sys_errlist[]; printf("%s", sys_errlist[0]);],
3273                 [ ac_cv_libc_defines_sys_errlist="yes" ],
3274                 [ ac_cv_libc_defines_sys_errlist="no" ]
3275         )
3277 if test "x$ac_cv_libc_defines_sys_errlist" = "xyes" ; then
3278         AC_DEFINE(HAVE_SYS_ERRLIST, 1,
3279                 [Define if your system defines sys_errlist[]])
3283 AC_CACHE_CHECK([if libc defines sys_nerr], ac_cv_libc_defines_sys_nerr, [
3284         AC_TRY_LINK([],
3285                 [ extern int sys_nerr; printf("%i", sys_nerr);],
3286                 [ ac_cv_libc_defines_sys_nerr="yes" ],
3287                 [ ac_cv_libc_defines_sys_nerr="no" ]
3288         )
3290 if test "x$ac_cv_libc_defines_sys_nerr" = "xyes" ; then
3291         AC_DEFINE(HAVE_SYS_NERR, 1, [Define if your system defines sys_nerr])
3294 # Check libraries needed by DNS fingerprint support
3295 AC_SEARCH_LIBS(getrrsetbyname, resolv,
3296         [AC_DEFINE(HAVE_GETRRSETBYNAME, 1,
3297                 [Define if getrrsetbyname() exists])],
3298         [
3299                 # Needed by our getrrsetbyname()
3300                 AC_SEARCH_LIBS(res_query, resolv)
3301                 AC_SEARCH_LIBS(dn_expand, resolv)
3302                 AC_MSG_CHECKING(if res_query will link)
3303                 AC_LINK_IFELSE([
3304 #include "confdefs.h"
3305 #include <sys/types.h>
3306 #include <netinet/in.h>
3307 #include <arpa/nameser.h>
3308 #include <netdb.h>
3309 #include <resolv.h>
3310 int main()
3312         res_query (0, 0, 0, 0, 0);
3313         return 0;
3315                    ],
3316                     AC_MSG_RESULT(yes),
3317                    [AC_MSG_RESULT(no)
3318                     saved_LIBS="$LIBS"
3319                     LIBS="$LIBS -lresolv"
3320                     AC_MSG_CHECKING(for res_query in -lresolv)
3321                     AC_LINK_IFELSE([
3322 #include "confdefs.h"
3323 #include <sys/types.h>
3324 #include <netinet/in.h>
3325 #include <arpa/nameser.h>
3326 #include <netdb.h>
3327 #include <resolv.h>
3328 int main()
3330         res_query (0, 0, 0, 0, 0);
3331         return 0;
3333                         ],
3334                         [AC_MSG_RESULT(yes)],
3335                         [LIBS="$saved_LIBS"
3336                          AC_MSG_RESULT(no)])
3337                     ])
3338                 AC_CHECK_FUNCS(_getshort _getlong)
3339                 AC_CHECK_DECLS([_getshort, _getlong], , ,
3340                     [#include <sys/types.h>
3341                     #include <arpa/nameser.h>])
3342                 AC_CHECK_MEMBER(HEADER.ad,
3343                         [AC_DEFINE(HAVE_HEADER_AD, 1,
3344                             [Define if HEADER.ad exists in arpa/nameser.h])],,
3345                         [#include <arpa/nameser.h>])
3346         ])
3348 AC_MSG_CHECKING(if struct __res_state _res is an extern)
3349 AC_LINK_IFELSE([
3350 #include <stdio.h>
3351 #if HAVE_SYS_TYPES_H
3352 # include <sys/types.h>
3353 #endif
3354 #include <netinet/in.h>
3355 #include <arpa/nameser.h>
3356 #include <resolv.h>
3357 extern struct __res_state _res;
3358 int main() { return 0; }
3359                 ],
3360                 [AC_MSG_RESULT(yes)
3361                  AC_DEFINE(HAVE__RES_EXTERN, 1,
3362                     [Define if you have struct __res_state _res as an extern])
3363                 ],
3364                 [ AC_MSG_RESULT(no) ]
3367 # Check whether user wants SELinux support
3368 SELINUX_MSG="no"
3369 LIBSELINUX=""
3370 AC_ARG_WITH(selinux,
3371         [  --with-selinux          Enable SELinux support],
3372         [ if test "x$withval" != "xno" ; then
3373                 save_LIBS="$LIBS"
3374                 AC_DEFINE(WITH_SELINUX,1,[Define if you want SELinux support.])
3375                 SELINUX_MSG="yes"
3376                 AC_CHECK_HEADER([selinux/selinux.h], ,
3377                         AC_MSG_ERROR(SELinux support requires selinux.h header))
3378                 AC_CHECK_LIB(selinux, setexeccon,
3379                         [ LIBSELINUX="-lselinux"
3380                           LIBS="$LIBS -lselinux"
3381                         ],
3382                         AC_MSG_ERROR(SELinux support requires libselinux library))
3383                 SSHDLIBS="$SSHDLIBS $LIBSELINUX"
3384                 AC_CHECK_FUNCS(getseuserbyname get_default_context_with_level)
3385                 LIBS="$save_LIBS"
3386         fi ]
3389 # Check whether user wants Kerberos 5 support
3390 KRB5_MSG="no"
3391 AC_ARG_WITH(kerberos5,
3392         [  --with-kerberos5=PATH   Enable Kerberos 5 support],
3393         [ if test "x$withval" != "xno" ; then
3394                 if test "x$withval" = "xyes" ; then
3395                         KRB5ROOT="/usr/local"
3396                 else
3397                         KRB5ROOT=${withval}
3398                 fi
3400                 AC_DEFINE(KRB5, 1, [Define if you want Kerberos 5 support])
3401                 KRB5_MSG="yes"
3403                 AC_PATH_PROG([KRB5CONF],[krb5-config],
3404                              [$KRB5ROOT/bin/krb5-config],
3405                              [$KRB5ROOT/bin:$PATH])
3406                 if test -x $KRB5CONF ; then
3408                         AC_MSG_CHECKING(for gssapi support)
3409                         if $KRB5CONF | grep gssapi >/dev/null ; then
3410                                 AC_MSG_RESULT(yes)
3411                                 AC_DEFINE(GSSAPI, 1,
3412                                         [Define this if you want GSSAPI
3413                                         support in the version 2 protocol])
3414                                 k5confopts=gssapi
3415                         else
3416                                 AC_MSG_RESULT(no)
3417                                 k5confopts=""
3418                         fi
3419                         K5CFLAGS="`$KRB5CONF --cflags $k5confopts`"
3420                         K5LIBS="`$KRB5CONF --libs $k5confopts`"
3421                         CPPFLAGS="$CPPFLAGS $K5CFLAGS"
3422                         AC_MSG_CHECKING(whether we are using Heimdal)
3423                         AC_TRY_COMPILE([ #include <krb5.h> ],
3424                                        [ char *tmp = heimdal_version; ],
3425                                        [ AC_MSG_RESULT(yes)
3426                                          AC_DEFINE(HEIMDAL, 1,
3427                                         [Define this if you are using the
3428                                         Heimdal version of Kerberos V5]) ],
3429                                          AC_MSG_RESULT(no)
3430                         )
3431                 else
3432                         CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include"
3433                         LDFLAGS="$LDFLAGS -L${KRB5ROOT}/lib"
3434                         AC_MSG_CHECKING(whether we are using Heimdal)
3435                         AC_TRY_COMPILE([ #include <krb5.h> ],
3436                                        [ char *tmp = heimdal_version; ],
3437                                        [ AC_MSG_RESULT(yes)
3438                                          AC_DEFINE(HEIMDAL)
3439                                          K5LIBS="-lkrb5 -ldes"
3440                                          K5LIBS="$K5LIBS -lcom_err -lasn1"
3441                                          AC_CHECK_LIB(roken, net_write,
3442                                            [K5LIBS="$K5LIBS -lroken"])
3443                                        ],
3444                                        [ AC_MSG_RESULT(no)
3445                                          K5LIBS="-lkrb5 -lk5crypto -lcom_err"
3446                                        ]
3447                         )
3448                         AC_SEARCH_LIBS(dn_expand, resolv)
3450                         AC_CHECK_LIB(gssapi_krb5, gss_init_sec_context,
3451                                 [ AC_DEFINE(GSSAPI)
3452                                   K5LIBS="-lgssapi_krb5 $K5LIBS" ],
3453                                 [ AC_CHECK_LIB(gssapi, gss_init_sec_context,
3454                                         [ AC_DEFINE(GSSAPI)
3455                                           K5LIBS="-lgssapi $K5LIBS" ],
3456                                         AC_MSG_WARN([Cannot find any suitable gss-api library - build may fail]),
3457                                         $K5LIBS)
3458                                 ],
3459                                 $K5LIBS)
3461                         AC_CHECK_HEADER(gssapi.h, ,
3462                                 [ unset ac_cv_header_gssapi_h
3463                                   CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
3464                                   AC_CHECK_HEADERS(gssapi.h, ,
3465                                         AC_MSG_WARN([Cannot find any suitable gss-api header - build may fail])
3466                                   )
3467                                 ]
3468                         )
3470                         oldCPP="$CPPFLAGS"
3471                         CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
3472                         AC_CHECK_HEADER(gssapi_krb5.h, ,
3473                                         [ CPPFLAGS="$oldCPP" ])
3475                 fi
3476                 if test ! -z "$need_dash_r" ; then
3477                         LDFLAGS="$LDFLAGS -R${KRB5ROOT}/lib"
3478                 fi
3479                 if test ! -z "$blibpath" ; then
3480                         blibpath="$blibpath:${KRB5ROOT}/lib"
3481                 fi
3483                 AC_CHECK_HEADERS(gssapi.h gssapi/gssapi.h)
3484                 AC_CHECK_HEADERS(gssapi_krb5.h gssapi/gssapi_krb5.h)
3485                 AC_CHECK_HEADERS(gssapi_generic.h gssapi/gssapi_generic.h)
3487                 LIBS="$LIBS $K5LIBS"
3488                 AC_SEARCH_LIBS(k_hasafs, kafs, AC_DEFINE(USE_AFS, 1,
3489                         [Define this if you want to use libkafs' AFS support]))
3490         fi
3491         ]
3494 # Looking for programs, paths and files
3496 PRIVSEP_PATH=/var/empty
3497 AC_ARG_WITH(privsep-path,
3498         [  --with-privsep-path=xxx Path for privilege separation chroot (default=/var/empty)],
3499         [
3500                 if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
3501                     test "x${withval}" != "xyes"; then
3502                         PRIVSEP_PATH=$withval
3503                 fi
3504         ]
3506 AC_SUBST(PRIVSEP_PATH)
3508 AC_ARG_WITH(xauth,
3509         [  --with-xauth=PATH       Specify path to xauth program ],
3510         [
3511                 if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
3512                     test "x${withval}" != "xyes"; then
3513                         xauth_path=$withval
3514                 fi
3515         ],
3516         [
3517                 TestPath="$PATH"
3518                 TestPath="${TestPath}${PATH_SEPARATOR}/usr/X/bin"
3519                 TestPath="${TestPath}${PATH_SEPARATOR}/usr/bin/X11"
3520                 TestPath="${TestPath}${PATH_SEPARATOR}/usr/X11R6/bin"
3521                 TestPath="${TestPath}${PATH_SEPARATOR}/usr/openwin/bin"
3522                 AC_PATH_PROG(xauth_path, xauth, , $TestPath)
3523                 if (test ! -z "$xauth_path" && test -x "/usr/openwin/bin/xauth") ; then
3524                         xauth_path="/usr/openwin/bin/xauth"
3525                 fi
3526         ]
3529 STRIP_OPT=-s
3530 AC_ARG_ENABLE(strip,
3531         [  --disable-strip         Disable calling strip(1) on install],
3532         [
3533                 if test "x$enableval" = "xno" ; then
3534                         STRIP_OPT=
3535                 fi
3536         ]
3538 AC_SUBST(STRIP_OPT)
3540 if test -z "$xauth_path" ; then
3541         XAUTH_PATH="undefined"
3542         AC_SUBST(XAUTH_PATH)
3543 else
3544         AC_DEFINE_UNQUOTED(XAUTH_PATH, "$xauth_path",
3545                 [Define if xauth is found in your path])
3546         XAUTH_PATH=$xauth_path
3547         AC_SUBST(XAUTH_PATH)
3550 # Check for mail directory (last resort if we cannot get it from headers)
3551 if test ! -z "$MAIL" ; then
3552         maildir=`dirname $MAIL`
3553         AC_DEFINE_UNQUOTED(MAIL_DIRECTORY, "$maildir",
3554                 [Set this to your mail directory if you don't have maillock.h])
3557 if test ! -z "$cross_compiling" && test "x$cross_compiling" = "xyes"; then
3558         AC_MSG_WARN([cross compiling: Disabling /dev/ptmx test])
3559         disable_ptmx_check=yes
3561 if test -z "$no_dev_ptmx" ; then
3562         if test "x$disable_ptmx_check" != "xyes" ; then
3563                 AC_CHECK_FILE("/dev/ptmx",
3564                         [
3565                                 AC_DEFINE_UNQUOTED(HAVE_DEV_PTMX, 1,
3566                                         [Define if you have /dev/ptmx])
3567                                 have_dev_ptmx=1
3568                         ]
3569                 )
3570         fi
3573 if test ! -z "$cross_compiling" && test "x$cross_compiling" != "xyes"; then
3574         AC_CHECK_FILE("/dev/ptc",
3575                 [
3576                         AC_DEFINE_UNQUOTED(HAVE_DEV_PTS_AND_PTC, 1,
3577                                 [Define if you have /dev/ptc])
3578                         have_dev_ptc=1
3579                 ]
3580         )
3581 else
3582         AC_MSG_WARN([cross compiling: Disabling /dev/ptc test])
3585 # Options from here on. Some of these are preset by platform above
3586 AC_ARG_WITH(mantype,
3587         [  --with-mantype=man|cat|doc  Set man page type],
3588         [
3589                 case "$withval" in
3590                 man|cat|doc)
3591                         MANTYPE=$withval
3592                         ;;
3593                 *)
3594                         AC_MSG_ERROR(invalid man type: $withval)
3595                         ;;
3596                 esac
3597         ]
3599 if test -z "$MANTYPE"; then
3600         TestPath="/usr/bin${PATH_SEPARATOR}/usr/ucb"
3601         AC_PATH_PROGS(NROFF, nroff awf, /bin/false, $TestPath)
3602         if ${NROFF} -mdoc ${srcdir}/ssh.1 >/dev/null 2>&1; then
3603                 MANTYPE=doc
3604         elif ${NROFF} -man ${srcdir}/ssh.1 >/dev/null 2>&1; then
3605                 MANTYPE=man
3606         else
3607                 MANTYPE=cat
3608         fi
3610 AC_SUBST(MANTYPE)
3611 if test "$MANTYPE" = "doc"; then
3612         mansubdir=man;
3613 else
3614         mansubdir=$MANTYPE;
3616 AC_SUBST(mansubdir)
3618 # Check whether to enable MD5 passwords
3619 MD5_MSG="no"
3620 AC_ARG_WITH(md5-passwords,
3621         [  --with-md5-passwords    Enable use of MD5 passwords],
3622         [
3623                 if test "x$withval" != "xno" ; then
3624                         AC_DEFINE(HAVE_MD5_PASSWORDS, 1,
3625                                 [Define if you want to allow MD5 passwords])
3626                         MD5_MSG="yes"
3627                 fi
3628         ]
3631 # Whether to disable shadow password support
3632 AC_ARG_WITH(shadow,
3633         [  --without-shadow        Disable shadow password support],
3634         [
3635                 if test "x$withval" = "xno" ; then
3636                         AC_DEFINE(DISABLE_SHADOW)
3637                         disable_shadow=yes
3638                 fi
3639         ]
3642 if test -z "$disable_shadow" ; then
3643         AC_MSG_CHECKING([if the systems has expire shadow information])
3644         AC_TRY_COMPILE(
3645         [
3646 #include <sys/types.h>
3647 #include <shadow.h>
3648         struct spwd sp;
3649         ],[ sp.sp_expire = sp.sp_lstchg = sp.sp_inact = 0; ],
3650         [ sp_expire_available=yes ], []
3651         )
3653         if test "x$sp_expire_available" = "xyes" ; then
3654                 AC_MSG_RESULT(yes)
3655                 AC_DEFINE(HAS_SHADOW_EXPIRE, 1,
3656                     [Define if you want to use shadow password expire field])
3657         else
3658                 AC_MSG_RESULT(no)
3659         fi
3662 # Use ip address instead of hostname in $DISPLAY
3663 if test ! -z "$IPADDR_IN_DISPLAY" ; then
3664         DISPLAY_HACK_MSG="yes"
3665         AC_DEFINE(IPADDR_IN_DISPLAY, 1,
3666                 [Define if you need to use IP address
3667                 instead of hostname in $DISPLAY])
3668 else
3669         DISPLAY_HACK_MSG="no"
3670         AC_ARG_WITH(ipaddr-display,
3671                 [  --with-ipaddr-display   Use ip address instead of hostname in \$DISPLAY],
3672                 [
3673                         if test "x$withval" != "xno" ; then
3674                                 AC_DEFINE(IPADDR_IN_DISPLAY)
3675                                 DISPLAY_HACK_MSG="yes"
3676                         fi
3677                 ]
3678         )
3681 # check for /etc/default/login and use it if present.
3682 AC_ARG_ENABLE(etc-default-login,
3683         [  --disable-etc-default-login Disable using PATH from /etc/default/login [no]],
3684         [ if test "x$enableval" = "xno"; then
3685                 AC_MSG_NOTICE([/etc/default/login handling disabled])
3686                 etc_default_login=no
3687           else
3688                 etc_default_login=yes
3689           fi ],
3690         [ if test ! -z "$cross_compiling" && test "x$cross_compiling" = "xyes";
3691           then
3692                 AC_MSG_WARN([cross compiling: not checking /etc/default/login])
3693                 etc_default_login=no
3694           else
3695                 etc_default_login=yes
3696           fi ]
3699 if test "x$etc_default_login" != "xno"; then
3700         AC_CHECK_FILE("/etc/default/login",
3701             [ external_path_file=/etc/default/login ])
3702         if test "x$external_path_file" = "x/etc/default/login"; then
3703                 AC_DEFINE(HAVE_ETC_DEFAULT_LOGIN, 1,
3704                         [Define if your system has /etc/default/login])
3705         fi
3708 dnl BSD systems use /etc/login.conf so --with-default-path= has no effect
3709 if test $ac_cv_func_login_getcapbool = "yes" && \
3710         test $ac_cv_header_login_cap_h = "yes" ; then
3711         external_path_file=/etc/login.conf
3714 # Whether to mess with the default path
3715 SERVER_PATH_MSG="(default)"
3716 AC_ARG_WITH(default-path,
3717         [  --with-default-path=    Specify default \$PATH environment for server],
3718         [
3719                 if test "x$external_path_file" = "x/etc/login.conf" ; then
3720                         AC_MSG_WARN([
3721 --with-default-path=PATH has no effect on this system.
3722 Edit /etc/login.conf instead.])
3723                 elif test "x$withval" != "xno" ; then
3724                         if test ! -z "$external_path_file" ; then
3725                                 AC_MSG_WARN([
3726 --with-default-path=PATH will only be used if PATH is not defined in
3727 $external_path_file .])
3728                         fi
3729                         user_path="$withval"
3730                         SERVER_PATH_MSG="$withval"
3731                 fi
3732         ],
3733         [ if test "x$external_path_file" = "x/etc/login.conf" ; then
3734                 AC_MSG_WARN([Make sure the path to scp is in /etc/login.conf])
3735         else
3736                 if test ! -z "$external_path_file" ; then
3737                         AC_MSG_WARN([
3738 If PATH is defined in $external_path_file, ensure the path to scp is included,
3739 otherwise scp will not work.])
3740                 fi
3741                 AC_RUN_IFELSE(
3742                         [AC_LANG_SOURCE([[
3743 /* find out what STDPATH is */
3744 #include <stdio.h>
3745 #ifdef HAVE_PATHS_H
3746 # include <paths.h>
3747 #endif
3748 #ifndef _PATH_STDPATH
3749 # ifdef _PATH_USERPATH  /* Irix */
3750 #  define _PATH_STDPATH _PATH_USERPATH
3751 # else
3752 #  define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
3753 # endif
3754 #endif
3755 #include <sys/types.h>
3756 #include <sys/stat.h>
3757 #include <fcntl.h>
3758 #define DATA "conftest.stdpath"
3760 main()
3762         FILE *fd;
3763         int rc;
3765         fd = fopen(DATA,"w");
3766         if(fd == NULL)
3767                 exit(1);
3769         if ((rc = fprintf(fd,"%s", _PATH_STDPATH)) < 0)
3770                 exit(1);
3772         exit(0);
3774                 ]])],
3775                 [ user_path=`cat conftest.stdpath` ],
3776                 [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ],
3777                 [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ]
3778         )
3779 # make sure $bindir is in USER_PATH so scp will work
3780                 t_bindir=`eval echo ${bindir}`
3781                 case $t_bindir in
3782                         NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$prefix~"` ;;
3783                 esac
3784                 case $t_bindir in
3785                         NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$ac_default_prefix~"` ;;
3786                 esac
3787                 echo $user_path | grep ":$t_bindir"  > /dev/null 2>&1
3788                 if test $? -ne 0  ; then
3789                         echo $user_path | grep "^$t_bindir"  > /dev/null 2>&1
3790                         if test $? -ne 0  ; then
3791                                 user_path=$user_path:$t_bindir
3792                                 AC_MSG_RESULT(Adding $t_bindir to USER_PATH so scp will work)
3793                         fi
3794                 fi
3795         fi ]
3797 if test "x$external_path_file" != "x/etc/login.conf" ; then
3798         AC_DEFINE_UNQUOTED(USER_PATH, "$user_path", [Specify default $PATH])
3799         AC_SUBST(user_path)
3802 # Set superuser path separately to user path
3803 AC_ARG_WITH(superuser-path,
3804         [  --with-superuser-path=  Specify different path for super-user],
3805         [
3806                 if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
3807                     test "x${withval}" != "xyes"; then
3808                         AC_DEFINE_UNQUOTED(SUPERUSER_PATH, "$withval",
3809                                 [Define if you want a different $PATH
3810                                 for the superuser])
3811                         superuser_path=$withval
3812                 fi
3813         ]
3817 AC_MSG_CHECKING([if we need to convert IPv4 in IPv6-mapped addresses])
3818 IPV4_IN6_HACK_MSG="no"
3819 AC_ARG_WITH(4in6,
3820         [  --with-4in6             Check for and convert IPv4 in IPv6 mapped addresses],
3821         [
3822                 if test "x$withval" != "xno" ; then
3823                         AC_MSG_RESULT(yes)
3824                         AC_DEFINE(IPV4_IN_IPV6, 1,
3825                                 [Detect IPv4 in IPv6 mapped addresses
3826                                 and treat as IPv4])
3827                         IPV4_IN6_HACK_MSG="yes"
3828                 else
3829                         AC_MSG_RESULT(no)
3830                 fi
3831         ],[
3832                 if test "x$inet6_default_4in6" = "xyes"; then
3833                         AC_MSG_RESULT([yes (default)])
3834                         AC_DEFINE(IPV4_IN_IPV6)
3835                         IPV4_IN6_HACK_MSG="yes"
3836                 else
3837                         AC_MSG_RESULT([no (default)])
3838                 fi
3839         ]
3842 # Whether to enable BSD auth support
3843 BSD_AUTH_MSG=no
3844 AC_ARG_WITH(bsd-auth,
3845         [  --with-bsd-auth         Enable BSD auth support],
3846         [
3847                 if test "x$withval" != "xno" ; then
3848                         AC_DEFINE(BSD_AUTH, 1,
3849                                 [Define if you have BSD auth support])
3850                         BSD_AUTH_MSG=yes
3851                 fi
3852         ]
3855 # Where to place sshd.pid
3856 piddir=/var/run
3857 # make sure the directory exists
3858 if test ! -d $piddir ; then
3859         piddir=`eval echo ${sysconfdir}`
3860         case $piddir in
3861                 NONE/*) piddir=`echo $piddir | sed "s~NONE~$ac_default_prefix~"` ;;
3862         esac
3865 AC_ARG_WITH(pid-dir,
3866         [  --with-pid-dir=PATH     Specify location of ssh.pid file],
3867         [
3868                 if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
3869                     test "x${withval}" != "xyes"; then
3870                         piddir=$withval
3871                         if test ! -d $piddir ; then
3872                         AC_MSG_WARN([** no $piddir directory on this system **])
3873                         fi
3874                 fi
3875         ]
3878 AC_DEFINE_UNQUOTED(_PATH_SSH_PIDDIR, "$piddir", [Specify location of ssh.pid])
3879 AC_SUBST(piddir)
3881 dnl allow user to disable some login recording features
3882 AC_ARG_ENABLE(lastlog,
3883         [  --disable-lastlog       disable use of lastlog even if detected [no]],
3884         [
3885                 if test "x$enableval" = "xno" ; then
3886                         AC_DEFINE(DISABLE_LASTLOG)
3887                 fi
3888         ]
3890 AC_ARG_ENABLE(utmp,
3891         [  --disable-utmp          disable use of utmp even if detected [no]],
3892         [
3893                 if test "x$enableval" = "xno" ; then
3894                         AC_DEFINE(DISABLE_UTMP)
3895                 fi
3896         ]
3898 AC_ARG_ENABLE(utmpx,
3899         [  --disable-utmpx         disable use of utmpx even if detected [no]],
3900         [
3901                 if test "x$enableval" = "xno" ; then
3902                         AC_DEFINE(DISABLE_UTMPX, 1,
3903                                 [Define if you don't want to use utmpx])
3904                 fi
3905         ]
3907 AC_ARG_ENABLE(wtmp,
3908         [  --disable-wtmp          disable use of wtmp even if detected [no]],
3909         [
3910                 if test "x$enableval" = "xno" ; then
3911                         AC_DEFINE(DISABLE_WTMP)
3912                 fi
3913         ]
3915 AC_ARG_ENABLE(wtmpx,
3916         [  --disable-wtmpx         disable use of wtmpx even if detected [no]],
3917         [
3918                 if test "x$enableval" = "xno" ; then
3919                         AC_DEFINE(DISABLE_WTMPX, 1,
3920                                 [Define if you don't want to use wtmpx])
3921                 fi
3922         ]
3924 AC_ARG_ENABLE(libutil,
3925         [  --disable-libutil       disable use of libutil (login() etc.) [no]],
3926         [
3927                 if test "x$enableval" = "xno" ; then
3928                         AC_DEFINE(DISABLE_LOGIN)
3929                 fi
3930         ]
3932 AC_ARG_ENABLE(pututline,
3933         [  --disable-pututline     disable use of pututline() etc. ([uw]tmp) [no]],
3934         [
3935                 if test "x$enableval" = "xno" ; then
3936                         AC_DEFINE(DISABLE_PUTUTLINE, 1,
3937                                 [Define if you don't want to use pututline()
3938                                 etc. to write [uw]tmp])
3939                 fi
3940         ]
3942 AC_ARG_ENABLE(pututxline,
3943         [  --disable-pututxline    disable use of pututxline() etc. ([uw]tmpx) [no]],
3944         [
3945                 if test "x$enableval" = "xno" ; then
3946                         AC_DEFINE(DISABLE_PUTUTXLINE, 1,
3947                                 [Define if you don't want to use pututxline()
3948                                 etc. to write [uw]tmpx])
3949                 fi
3950         ]
3952 AC_ARG_WITH(lastlog,
3953   [  --with-lastlog=FILE|DIR specify lastlog location [common locations]],
3954         [
3955                 if test "x$withval" = "xno" ; then
3956                         AC_DEFINE(DISABLE_LASTLOG)
3957                 elif test -n "$withval"  &&  test "x${withval}" != "xyes"; then
3958                         conf_lastlog_location=$withval
3959                 fi
3960         ]
3963 dnl lastlog, [uw]tmpx? detection
3964 dnl  NOTE: set the paths in the platform section to avoid the
3965 dnl   need for command-line parameters
3966 dnl lastlog and [uw]tmp are subject to a file search if all else fails
3968 dnl lastlog detection
3969 dnl  NOTE: the code itself will detect if lastlog is a directory
3970 AC_MSG_CHECKING([if your system defines LASTLOG_FILE])
3971 AC_TRY_COMPILE([
3972 #include <sys/types.h>
3973 #include <utmp.h>
3974 #ifdef HAVE_LASTLOG_H
3975 #  include <lastlog.h>
3976 #endif
3977 #ifdef HAVE_PATHS_H
3978 #  include <paths.h>
3979 #endif
3980 #ifdef HAVE_LOGIN_H
3981 # include <login.h>
3982 #endif
3983         ],
3984         [ char *lastlog = LASTLOG_FILE; ],
3985         [ AC_MSG_RESULT(yes) ],
3986         [
3987                 AC_MSG_RESULT(no)
3988                 AC_MSG_CHECKING([if your system defines _PATH_LASTLOG])
3989                 AC_TRY_COMPILE([
3990 #include <sys/types.h>
3991 #include <utmp.h>
3992 #ifdef HAVE_LASTLOG_H
3993 #  include <lastlog.h>
3994 #endif
3995 #ifdef HAVE_PATHS_H
3996 #  include <paths.h>
3997 #endif
3998                 ],
3999                 [ char *lastlog = _PATH_LASTLOG; ],
4000                 [ AC_MSG_RESULT(yes) ],
4001                 [
4002                         AC_MSG_RESULT(no)
4003                         system_lastlog_path=no
4004                 ])
4005         ]
4008 if test -z "$conf_lastlog_location"; then
4009         if test x"$system_lastlog_path" = x"no" ; then
4010                 for f in /var/log/lastlog /usr/adm/lastlog /var/adm/lastlog /etc/security/lastlog ; do
4011                                 if (test -d "$f" || test -f "$f") ; then
4012                                         conf_lastlog_location=$f
4013                                 fi
4014                 done
4015                 if test -z "$conf_lastlog_location"; then
4016                         AC_MSG_WARN([** Cannot find lastlog **])
4017                         dnl Don't define DISABLE_LASTLOG - that means we don't try wtmp/wtmpx
4018                 fi
4019         fi
4022 if test -n "$conf_lastlog_location"; then
4023         AC_DEFINE_UNQUOTED(CONF_LASTLOG_FILE, "$conf_lastlog_location",
4024                 [Define if you want to specify the path to your lastlog file])
4027 dnl utmp detection
4028 AC_MSG_CHECKING([if your system defines UTMP_FILE])
4029 AC_TRY_COMPILE([
4030 #include <sys/types.h>
4031 #include <utmp.h>
4032 #ifdef HAVE_PATHS_H
4033 #  include <paths.h>
4034 #endif
4035         ],
4036         [ char *utmp = UTMP_FILE; ],
4037         [ AC_MSG_RESULT(yes) ],
4038         [ AC_MSG_RESULT(no)
4039           system_utmp_path=no ]
4041 if test -z "$conf_utmp_location"; then
4042         if test x"$system_utmp_path" = x"no" ; then
4043                 for f in /etc/utmp /usr/adm/utmp /var/run/utmp; do
4044                         if test -f $f ; then
4045                                 conf_utmp_location=$f
4046                         fi
4047                 done
4048                 if test -z "$conf_utmp_location"; then
4049                         AC_DEFINE(DISABLE_UTMP)
4050                 fi
4051         fi
4053 if test -n "$conf_utmp_location"; then
4054         AC_DEFINE_UNQUOTED(CONF_UTMP_FILE, "$conf_utmp_location",
4055                 [Define if you want to specify the path to your utmp file])
4058 dnl wtmp detection
4059 AC_MSG_CHECKING([if your system defines WTMP_FILE])
4060 AC_TRY_COMPILE([
4061 #include <sys/types.h>
4062 #include <utmp.h>
4063 #ifdef HAVE_PATHS_H
4064 #  include <paths.h>
4065 #endif
4066         ],
4067         [ char *wtmp = WTMP_FILE; ],
4068         [ AC_MSG_RESULT(yes) ],
4069         [ AC_MSG_RESULT(no)
4070           system_wtmp_path=no ]
4072 if test -z "$conf_wtmp_location"; then
4073         if test x"$system_wtmp_path" = x"no" ; then
4074                 for f in /usr/adm/wtmp /var/log/wtmp; do
4075                         if test -f $f ; then
4076                                 conf_wtmp_location=$f
4077                         fi
4078                 done
4079                 if test -z "$conf_wtmp_location"; then
4080                         AC_DEFINE(DISABLE_WTMP)
4081                 fi
4082         fi
4084 if test -n "$conf_wtmp_location"; then
4085         AC_DEFINE_UNQUOTED(CONF_WTMP_FILE, "$conf_wtmp_location",
4086                 [Define if you want to specify the path to your wtmp file])
4090 dnl wtmpx detection
4091 AC_MSG_CHECKING([if your system defines WTMPX_FILE])
4092 AC_TRY_COMPILE([
4093 #include <sys/types.h>
4094 #include <utmp.h>
4095 #ifdef HAVE_UTMPX_H
4096 #include <utmpx.h>
4097 #endif
4098 #ifdef HAVE_PATHS_H
4099 #  include <paths.h>
4100 #endif
4101         ],
4102         [ char *wtmpx = WTMPX_FILE; ],
4103         [ AC_MSG_RESULT(yes) ],
4104         [ AC_MSG_RESULT(no)
4105           system_wtmpx_path=no ]
4107 if test -z "$conf_wtmpx_location"; then
4108         if test x"$system_wtmpx_path" = x"no" ; then
4109                 AC_DEFINE(DISABLE_WTMPX)
4110         fi
4111 else
4112         AC_DEFINE_UNQUOTED(CONF_WTMPX_FILE, "$conf_wtmpx_location",
4113                 [Define if you want to specify the path to your wtmpx file])
4117 if test ! -z "$blibpath" ; then
4118         LDFLAGS="$LDFLAGS $blibflags$blibpath"
4119         AC_MSG_WARN([Please check and edit blibpath in LDFLAGS in Makefile])
4122 dnl Adding -Werror to CFLAGS early prevents configure tests from running.
4123 dnl Add now.
4124 CFLAGS="$CFLAGS $werror_flags"
4126 if test "x$ac_cv_func_getaddrinfo" != "xyes" ; then
4127         TEST_SSH_IPV6=no
4128 else
4129         TEST_SSH_IPV6=yes
4131 AC_CHECK_DECL(BROKEN_GETADDRINFO,  TEST_SSH_IPV6=no)
4132 AC_SUBST(TEST_SSH_IPV6, $TEST_SSH_IPV6)
4134 AC_EXEEXT
4135 AC_CONFIG_FILES([Makefile buildpkg.sh opensshd.init openssh.xml \
4136         openbsd-compat/Makefile openbsd-compat/regress/Makefile \
4137         ssh_prng_cmds survey.sh])
4138 AC_OUTPUT
4140 # Print summary of options
4142 # Someone please show me a better way :)
4143 A=`eval echo ${prefix}` ; A=`eval echo ${A}`
4144 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
4145 C=`eval echo ${sbindir}` ; C=`eval echo ${C}`
4146 D=`eval echo ${sysconfdir}` ; D=`eval echo ${D}`
4147 E=`eval echo ${libexecdir}/ssh-askpass` ; E=`eval echo ${E}`
4148 F=`eval echo ${mandir}/${mansubdir}X` ; F=`eval echo ${F}`
4149 G=`eval echo ${piddir}` ; G=`eval echo ${G}`
4150 H=`eval echo ${PRIVSEP_PATH}` ; H=`eval echo ${H}`
4151 I=`eval echo ${user_path}` ; I=`eval echo ${I}`
4152 J=`eval echo ${superuser_path}` ; J=`eval echo ${J}`
4154 echo ""
4155 echo "OpenSSH has been configured with the following options:"
4156 echo "                     User binaries: $B"
4157 echo "                   System binaries: $C"
4158 echo "               Configuration files: $D"
4159 echo "                   Askpass program: $E"
4160 echo "                      Manual pages: $F"
4161 echo "                          PID file: $G"
4162 echo "  Privilege separation chroot path: $H"
4163 if test "x$external_path_file" = "x/etc/login.conf" ; then
4164 echo "   At runtime, sshd will use the path defined in $external_path_file"
4165 echo "   Make sure the path to scp is present, otherwise scp will not work"
4166 else
4167 echo "            sshd default user PATH: $I"
4168         if test ! -z "$external_path_file"; then
4169 echo "   (If PATH is set in $external_path_file it will be used instead. If"
4170 echo "   used, ensure the path to scp is present, otherwise scp will not work.)"
4171         fi
4173 if test ! -z "$superuser_path" ; then
4174 echo "          sshd superuser user PATH: $J"
4176 echo "                    Manpage format: $MANTYPE"
4177 echo "                       PAM support: $PAM_MSG"
4178 echo "                   OSF SIA support: $SIA_MSG"
4179 echo "                 KerberosV support: $KRB5_MSG"
4180 echo "                   SELinux support: $SELINUX_MSG"
4181 echo "                 Smartcard support: $SCARD_MSG"
4182 echo "                     S/KEY support: $SKEY_MSG"
4183 echo "              TCP Wrappers support: $TCPW_MSG"
4184 echo "              MD5 password support: $MD5_MSG"
4185 echo "                   libedit support: $LIBEDIT_MSG"
4186 echo "  Solaris process contract support: $SPC_MSG"
4187 echo "       IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG"
4188 echo "           Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG"
4189 echo "                  BSD Auth support: $BSD_AUTH_MSG"
4190 echo "              Random number source: $RAND_MSG"
4191 if test ! -z "$USE_RAND_HELPER" ; then
4192 echo "     ssh-rand-helper collects from: $RAND_HELPER_MSG"
4195 echo ""
4197 echo "              Host: ${host}"
4198 echo "          Compiler: ${CC}"
4199 echo "    Compiler flags: ${CFLAGS}"
4200 echo "Preprocessor flags: ${CPPFLAGS}"
4201 echo "      Linker flags: ${LDFLAGS}"
4202 echo "         Libraries: ${LIBS}"
4203 if test ! -z "${SSHDLIBS}"; then
4204 echo "         +for sshd: ${SSHDLIBS}"
4207 echo ""
4209 if test "x$MAKE_PACKAGE_SUPPORTED" = "xyes" ; then
4210         echo "SVR4 style packages are supported with \"make package\""
4211         echo ""
4214 if test "x$PAM_MSG" = "xyes" ; then
4215         echo "PAM is enabled. You may need to install a PAM control file "
4216         echo "for sshd, otherwise password authentication may fail. "
4217         echo "Example PAM control files can be found in the contrib/ "
4218         echo "subdirectory"
4219         echo ""
4222 if test ! -z "$RAND_HELPER_CMDHASH" ; then
4223         echo "WARNING: you are using the builtin random number collection "
4224         echo "service. Please read WARNING.RNG and request that your OS "
4225         echo "vendor includes kernel-based random number collection in "
4226         echo "future versions of your OS."
4227         echo ""
4230 if test ! -z "$NO_PEERCHECK" ; then
4231         echo "WARNING: the operating system that you are using does not"
4232         echo "appear to support getpeereid(), getpeerucred() or the"
4233         echo "SO_PEERCRED getsockopt() option. These facilities are used to"
4234         echo "enforce security checks to prevent unauthorised connections to"
4235         echo "ssh-agent. Their absence increases the risk that a malicious"
4236         echo "user can connect to your agent."
4237         echo ""
4240 if test "$AUDIT_MODULE" = "bsm" ; then
4241         echo "WARNING: BSM audit support is currently considered EXPERIMENTAL."
4242         echo "See the Solaris section in README.platform for details."