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