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