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