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