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