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