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