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