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