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