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