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