]> andersk Git - openssh.git/blob - configure.ac
- (dtucker) [README.platform auth.c configure.ac loginrec.c
[openssh.git] / configure.ac
1 # $Id$
2 #
3 # Copyright (c) 1999-2004 Damien Miller
4 #
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
8 #
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
17 AC_INIT(OpenSSH, Portable)
18 AC_CONFIG_SRCDIR([ssh.c])
19
20 AC_CONFIG_HEADER(config.h)
21 AC_PROG_CC
22 AC_CANONICAL_HOST
23 AC_C_BIGENDIAN
24
25 # Checks for programs.
26 AC_PROG_AWK
27 AC_PROG_CPP
28 AC_PROG_RANLIB
29 AC_PROG_INSTALL
30 AC_PATH_PROG(AR, ar)
31 AC_PATH_PROG(CAT, cat)
32 AC_PATH_PROG(KILL, kill)
33 AC_PATH_PROGS(PERL, perl5 perl)
34 AC_PATH_PROG(SED, sed)
35 AC_SUBST(PERL)
36 AC_PATH_PROG(ENT, ent)
37 AC_SUBST(ENT)
38 AC_PATH_PROG(TEST_MINUS_S_SH, bash)
39 AC_PATH_PROG(TEST_MINUS_S_SH, ksh)
40 AC_PATH_PROG(TEST_MINUS_S_SH, sh)
41 AC_PATH_PROG(SH, sh)
42 AC_SUBST(TEST_SHELL,sh)
43
44 dnl for buildpkg.sh
45 AC_PATH_PROG(PATH_GROUPADD_PROG, groupadd, groupadd,
46         [/usr/sbin${PATH_SEPARATOR}/etc])
47 AC_PATH_PROG(PATH_USERADD_PROG, useradd, useradd,
48         [/usr/sbin${PATH_SEPARATOR}/etc])
49 AC_CHECK_PROG(MAKE_PACKAGE_SUPPORTED, pkgmk, yes, no)
50
51 # System features
52 AC_SYS_LARGEFILE
53
54 if test -z "$AR" ; then
55         AC_MSG_ERROR([*** 'ar' missing, please install or fix your \$PATH ***])
56 fi
57
58 # Use LOGIN_PROGRAM from environment if possible
59 if test ! -z "$LOGIN_PROGRAM" ; then
60         AC_DEFINE_UNQUOTED(LOGIN_PROGRAM_FALLBACK, "$LOGIN_PROGRAM")
61 else
62         # Search for login
63         AC_PATH_PROG(LOGIN_PROGRAM_FALLBACK, login)
64         if test ! -z "$LOGIN_PROGRAM_FALLBACK" ; then
65                 AC_DEFINE_UNQUOTED(LOGIN_PROGRAM_FALLBACK, "$LOGIN_PROGRAM_FALLBACK")
66         fi
67 fi
68
69 AC_PATH_PROG(PATH_PASSWD_PROG, passwd)
70 if test ! -z "$PATH_PASSWD_PROG" ; then
71         AC_DEFINE_UNQUOTED(_PATH_PASSWD_PROG, "$PATH_PASSWD_PROG")
72 fi
73
74 if test -z "$LD" ; then
75         LD=$CC
76 fi
77 AC_SUBST(LD)
78         
79 AC_C_INLINE
80 if test "$GCC" = "yes" || test "$GCC" = "egcs"; then
81         CFLAGS="$CFLAGS -Wall -Wpointer-arith -Wno-uninitialized"
82 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         check_for_aix_broken_getaddrinfo=1
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 (optionally in PATH)],
770         [
771                 if test "x$withval" != "xno" ; then
772
773                         if test "x$withval" != "xyes" ; then
774                                 CPPFLAGS="$CPPFLAGS -I${withval}/include"
775                                 LDFLAGS="$LDFLAGS -L${withval}/lib"
776                         fi
777
778                         AC_DEFINE(SKEY)
779                         LIBS="-lskey $LIBS"
780                         SKEY_MSG="yes"
781         
782                         AC_MSG_CHECKING([for s/key support])
783                         AC_TRY_RUN(
784                                 [
785 #include <stdio.h>
786 #include <skey.h>
787 int main() { char *ff = skey_keyinfo(""); ff=""; exit(0); }
788                                 ],
789                                 [AC_MSG_RESULT(yes)],
790                                 [
791                                         AC_MSG_RESULT(no)
792                                         AC_MSG_ERROR([** Incomplete or missing s/key libraries.])
793                                 ])
794                         AC_MSG_CHECKING(if skeychallenge takes 4 arguments)
795                         AC_TRY_COMPILE(
796                                 [#include <stdio.h>
797                                  #include <skey.h>],
798                                 [(void)skeychallenge(NULL,"name","",0);],
799                                 [AC_MSG_RESULT(yes)
800                                  AC_DEFINE(SKEYCHALLENGE_4ARG)],
801                                 [AC_MSG_RESULT(no)]
802                         )
803                 fi
804         ]
805 )
806
807 # Check whether user wants TCP wrappers support
808 TCPW_MSG="no"
809 AC_ARG_WITH(tcp-wrappers,
810         [  --with-tcp-wrappers[[=PATH]] Enable tcpwrappers support (optionally in PATH)],
811         [
812                 if test "x$withval" != "xno" ; then
813                         saved_LIBS="$LIBS"
814                         saved_LDFLAGS="$LDFLAGS"
815                         saved_CPPFLAGS="$CPPFLAGS"
816                         if test -n "${withval}" -a "${withval}" != "yes"; then
817                                 if test -d "${withval}/lib"; then
818                                         if test -n "${need_dash_r}"; then
819                                                 LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
820                                         else
821                                                 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
822                                         fi
823                                 else
824                                         if test -n "${need_dash_r}"; then
825                                                 LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
826                                         else
827                                                 LDFLAGS="-L${withval} ${LDFLAGS}"
828                                         fi
829                                 fi
830                                 if test -d "${withval}/include"; then
831                                         CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
832                                 else
833                                         CPPFLAGS="-I${withval} ${CPPFLAGS}"
834                                 fi
835                         fi
836                         LIBWRAP="-lwrap"
837                         LIBS="$LIBWRAP $LIBS"
838                         AC_MSG_CHECKING(for libwrap)
839                         AC_TRY_LINK(
840                                 [
841 #include <sys/types.h>
842 #include <sys/socket.h>
843 #include <netinet/in.h>
844 #include <tcpd.h>
845                                         int deny_severity = 0, allow_severity = 0;
846                                 ],
847                                 [hosts_access(0);],
848                                 [
849                                         AC_MSG_RESULT(yes)
850                                         AC_DEFINE(LIBWRAP)
851                                         AC_SUBST(LIBWRAP)
852                                         TCPW_MSG="yes"
853                                 ],
854                                 [
855                                         AC_MSG_ERROR([*** libwrap missing])
856                                 ]
857                         )
858                         LIBS="$saved_LIBS"
859                 fi
860         ]
861 )
862
863 # Check whether user wants libedit support
864 LIBEDIT_MSG="no"
865 AC_ARG_WITH(libedit,
866         [  --with-libedit[[=PATH]]   Enable libedit support for sftp],
867         [ if test "x$withval" != "xno" ; then
868                 AC_CHECK_LIB(edit, el_init,
869                         [ AC_DEFINE(USE_LIBEDIT, [], [Use libedit for sftp])
870                           LIBEDIT="-ledit -lcurses"
871                           LIBEDIT_MSG="yes"
872                           AC_SUBST(LIBEDIT)
873                         ],
874                         [], [-lcurses]
875                 )
876         fi ]
877 )
878
879 dnl    Checks for library functions. Please keep in alphabetical order
880 AC_CHECK_FUNCS(\
881         arc4random __b64_ntop b64_ntop __b64_pton b64_pton bcopy \
882         bindresvport_sa clock closefrom dirfd fchdir fchmod fchown \
883         freeaddrinfo futimes getaddrinfo getcwd getgrouplist getnameinfo \
884         getopt getpeereid _getpty getrlimit getttyent glob inet_aton \
885         inet_ntoa inet_ntop innetgr login_getcapbool md5_crypt memmove \
886         mkdtemp mmap ngetaddrinfo nsleep ogetaddrinfo openlog_r openpty \
887         pstat prctl readpassphrase realpath recvmsg rresvport_af sendmsg \
888         setdtablesize setegid setenv seteuid setgroups setlogin setpcred \
889         setproctitle setregid setreuid setrlimit \
890         setsid setvbuf sigaction sigvec snprintf socketpair strerror \
891         strlcat strlcpy strmode strnvis strtoul sysconf tcgetpgrp \
892         truncate unsetenv updwtmpx utimes vhangup vsnprintf waitpid \
893 )
894
895 # IRIX has a const char return value for gai_strerror()
896 AC_CHECK_FUNCS(gai_strerror,[
897         AC_DEFINE(HAVE_GAI_STRERROR)
898         AC_TRY_COMPILE([
899 #include <sys/types.h>
900 #include <sys/socket.h>
901 #include <netdb.h>
902
903 const char *gai_strerror(int);],[
904 char *str;
905
906 str = gai_strerror(0);],[
907                 AC_DEFINE(HAVE_CONST_GAI_STRERROR_PROTO, 1,
908                 [Define if gai_strerror() returns const char *])])])
909
910 AC_SEARCH_LIBS(nanosleep, rt posix4, AC_DEFINE(HAVE_NANOSLEEP))
911
912 dnl Make sure prototypes are defined for these before using them.
913 AC_CHECK_DECL(strsep, [AC_CHECK_FUNCS(strsep)])
914 AC_CHECK_DECL(getrusage, [AC_CHECK_FUNCS(getrusage)])
915
916 dnl tcsendbreak might be a macro
917 AC_CHECK_DECL(tcsendbreak,
918         [AC_DEFINE(HAVE_TCSENDBREAK)],
919         [AC_CHECK_FUNCS(tcsendbreak)],
920         [#include <termios.h>]
921 )
922
923 AC_CHECK_DECLS(h_errno, , ,[#include <netdb.h>])
924
925 AC_CHECK_FUNCS(setresuid, [
926         dnl Some platorms have setresuid that isn't implemented, test for this
927         AC_MSG_CHECKING(if setresuid seems to work)
928         AC_RUN_IFELSE(
929                 [AC_LANG_SOURCE([[
930 #include <stdlib.h>
931 #include <errno.h>
932 int main(){errno=0; setresuid(0,0,0); if (errno==ENOSYS) exit(1); else exit(0);}
933                 ]])],
934                 [AC_MSG_RESULT(yes)],
935                 [AC_DEFINE(BROKEN_SETRESUID)
936                  AC_MSG_RESULT(not implemented)],
937                 [AC_MSG_WARN([cross compiling: not checking setresuid])]
938         )
939 ])
940
941 AC_CHECK_FUNCS(setresgid, [
942         dnl Some platorms have setresgid that isn't implemented, test for this
943         AC_MSG_CHECKING(if setresgid seems to work)
944         AC_RUN_IFELSE(
945                 [AC_LANG_SOURCE([[
946 #include <stdlib.h>
947 #include <errno.h>
948 int main(){errno=0; setresgid(0,0,0); if (errno==ENOSYS) exit(1); else exit(0);}
949                 ]])],
950                 [AC_MSG_RESULT(yes)],
951                 [AC_DEFINE(BROKEN_SETRESGID)
952                  AC_MSG_RESULT(not implemented)],
953                 [AC_MSG_WARN([cross compiling: not checking setresuid])]
954         )
955 ])
956
957 dnl    Checks for time functions
958 AC_CHECK_FUNCS(gettimeofday time)
959 dnl    Checks for utmp functions
960 AC_CHECK_FUNCS(endutent getutent getutid getutline pututline setutent)
961 AC_CHECK_FUNCS(utmpname)
962 dnl    Checks for utmpx functions
963 AC_CHECK_FUNCS(endutxent getutxent getutxid getutxline pututxline )
964 AC_CHECK_FUNCS(setutxent utmpxname)
965
966 AC_CHECK_FUNC(daemon,
967         [AC_DEFINE(HAVE_DAEMON)],
968         [AC_CHECK_LIB(bsd, daemon, [LIBS="$LIBS -lbsd"; AC_DEFINE(HAVE_DAEMON)])]
969 )
970
971 AC_CHECK_FUNC(getpagesize,
972         [AC_DEFINE(HAVE_GETPAGESIZE)],
973         [AC_CHECK_LIB(ucb, getpagesize, [LIBS="$LIBS -lucb"; AC_DEFINE(HAVE_GETPAGESIZE)])]
974 )
975
976 # Check for broken snprintf
977 if test "x$ac_cv_func_snprintf" = "xyes" ; then
978         AC_MSG_CHECKING([whether snprintf correctly terminates long strings])
979         AC_RUN_IFELSE(
980                 [AC_LANG_SOURCE([[
981 #include <stdio.h>
982 int main(void){char b[5];snprintf(b,5,"123456789");exit(b[4]!='\0');}
983                 ]])],
984                 [AC_MSG_RESULT(yes)],
985                 [
986                         AC_MSG_RESULT(no)
987                         AC_DEFINE(BROKEN_SNPRINTF)
988                         AC_MSG_WARN([****** Your snprintf() function is broken, complain to your vendor])
989                 ],
990                 [ AC_MSG_WARN([cross compiling: Assuming working snprintf()]) ]
991         )
992 fi
993
994 # Check for missing getpeereid (or equiv) support
995 NO_PEERCHECK=""
996 if test "x$ac_cv_func_getpeereid" != "xyes" ; then
997         AC_MSG_CHECKING([whether system supports SO_PEERCRED getsockopt])
998         AC_TRY_COMPILE(
999                 [#include <sys/types.h>
1000                  #include <sys/socket.h>],
1001                 [int i = SO_PEERCRED;],
1002                 [AC_MSG_RESULT(yes)],
1003                 [AC_MSG_RESULT(no)
1004                 NO_PEERCHECK=1]
1005         )
1006 fi
1007
1008 dnl see whether mkstemp() requires XXXXXX
1009 if test "x$ac_cv_func_mkdtemp" = "xyes" ; then
1010 AC_MSG_CHECKING([for (overly) strict mkstemp])
1011 AC_TRY_RUN(
1012         [
1013 #include <stdlib.h>
1014 main() { char template[]="conftest.mkstemp-test";
1015 if (mkstemp(template) == -1)
1016         exit(1);
1017 unlink(template); exit(0);
1018 }
1019         ],
1020         [
1021                 AC_MSG_RESULT(no)
1022         ],
1023         [
1024                 AC_MSG_RESULT(yes)
1025                 AC_DEFINE(HAVE_STRICT_MKSTEMP)
1026         ],
1027         [
1028                 AC_MSG_RESULT(yes)
1029                 AC_DEFINE(HAVE_STRICT_MKSTEMP)
1030         ]
1031 )
1032 fi
1033
1034 dnl make sure that openpty does not reacquire controlling terminal
1035 if test ! -z "$check_for_openpty_ctty_bug"; then
1036         AC_MSG_CHECKING(if openpty correctly handles controlling tty)
1037         AC_TRY_RUN(
1038                 [
1039 #include <stdio.h>
1040 #include <sys/fcntl.h>
1041 #include <sys/types.h>
1042 #include <sys/wait.h>
1043
1044 int
1045 main()
1046 {
1047         pid_t pid;
1048         int fd, ptyfd, ttyfd, status;
1049
1050         pid = fork();
1051         if (pid < 0) {          /* failed */
1052                 exit(1);
1053         } else if (pid > 0) {   /* parent */
1054                 waitpid(pid, &status, 0);
1055                 if (WIFEXITED(status))
1056                         exit(WEXITSTATUS(status));
1057                 else
1058                         exit(2);
1059         } else {                /* child */
1060                 close(0); close(1); close(2);
1061                 setsid();
1062                 openpty(&ptyfd, &ttyfd, NULL, NULL, NULL);
1063                 fd = open("/dev/tty", O_RDWR | O_NOCTTY);
1064                 if (fd >= 0)
1065                         exit(3);        /* Acquired ctty: broken */
1066                 else
1067                         exit(0);        /* Did not acquire ctty: OK */
1068         }
1069 }
1070                 ],
1071                 [
1072                         AC_MSG_RESULT(yes)
1073                 ],
1074                 [
1075                         AC_MSG_RESULT(no)
1076                         AC_DEFINE(SSHD_ACQUIRES_CTTY)
1077                 ]
1078         )
1079 fi
1080
1081 if test "x$ac_cv_func_getaddrinfo" = "xyes" -a "x$check_for_hpux_broken_getaddrinfo" = "x1"; then
1082         AC_MSG_CHECKING(if getaddrinfo seems to work)
1083         AC_TRY_RUN(
1084                 [
1085 #include <stdio.h>
1086 #include <sys/socket.h>
1087 #include <netdb.h>
1088 #include <errno.h>
1089 #include <netinet/in.h>
1090
1091 #define TEST_PORT "2222"
1092
1093 int
1094 main(void)
1095 {
1096         int err, sock;
1097         struct addrinfo *gai_ai, *ai, hints;
1098         char ntop[NI_MAXHOST], strport[NI_MAXSERV], *name = NULL;
1099
1100         memset(&hints, 0, sizeof(hints));
1101         hints.ai_family = PF_UNSPEC;
1102         hints.ai_socktype = SOCK_STREAM;
1103         hints.ai_flags = AI_PASSIVE;
1104
1105         err = getaddrinfo(name, TEST_PORT, &hints, &gai_ai);
1106         if (err != 0) {
1107                 fprintf(stderr, "getaddrinfo failed (%s)", gai_strerror(err));
1108                 exit(1);
1109         }
1110
1111         for (ai = gai_ai; ai != NULL; ai = ai->ai_next) {
1112                 if (ai->ai_family != AF_INET6)
1113                         continue;
1114
1115                 err = getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop,
1116                     sizeof(ntop), strport, sizeof(strport),
1117                     NI_NUMERICHOST|NI_NUMERICSERV);
1118
1119                 if (err != 0) {
1120                         if (err == EAI_SYSTEM)
1121                                 perror("getnameinfo EAI_SYSTEM");
1122                         else
1123                                 fprintf(stderr, "getnameinfo failed: %s\n",
1124                                     gai_strerror(err));
1125                         exit(2);
1126                 }
1127
1128                 sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
1129                 if (sock < 0)
1130                         perror("socket");
1131                 if (bind(sock, ai->ai_addr, ai->ai_addrlen) < 0) {
1132                         if (errno == EBADF)
1133                                 exit(3);
1134                 }
1135         }
1136         exit(0);
1137 }
1138                 ],
1139                 [
1140                         AC_MSG_RESULT(yes)
1141                 ],
1142                 [
1143                         AC_MSG_RESULT(no)
1144                         AC_DEFINE(BROKEN_GETADDRINFO)
1145                 ]
1146         )
1147 fi
1148
1149 if test "x$ac_cv_func_getaddrinfo" = "xyes" -a "x$check_for_aix_broken_getaddrinfo" = "x1"; then
1150         AC_MSG_CHECKING(if getaddrinfo seems to work)
1151         AC_TRY_RUN(
1152                 [
1153 #include <stdio.h>
1154 #include <sys/socket.h>
1155 #include <netdb.h>
1156 #include <errno.h>
1157 #include <netinet/in.h>
1158
1159 #define TEST_PORT "2222"
1160
1161 int
1162 main(void)
1163 {
1164         int err, sock;
1165         struct addrinfo *gai_ai, *ai, hints;
1166         char ntop[NI_MAXHOST], strport[NI_MAXSERV], *name = NULL;
1167
1168         memset(&hints, 0, sizeof(hints));
1169         hints.ai_family = PF_UNSPEC;
1170         hints.ai_socktype = SOCK_STREAM;
1171         hints.ai_flags = AI_PASSIVE;
1172
1173         err = getaddrinfo(name, TEST_PORT, &hints, &gai_ai);
1174         if (err != 0) {
1175                 fprintf(stderr, "getaddrinfo failed (%s)", gai_strerror(err));
1176                 exit(1);
1177         }
1178
1179         for (ai = gai_ai; ai != NULL; ai = ai->ai_next) {
1180                 if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6)
1181                         continue;
1182
1183                 err = getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop,
1184                     sizeof(ntop), strport, sizeof(strport),
1185                     NI_NUMERICHOST|NI_NUMERICSERV);
1186
1187                 if (ai->ai_family == AF_INET && err != 0) {
1188                         perror("getnameinfo");
1189                         exit(2);
1190                 }
1191         }
1192         exit(0);
1193 }
1194                 ],
1195                 [
1196                         AC_MSG_RESULT(yes)
1197                         AC_DEFINE(AIX_GETNAMEINFO_HACK, [],
1198 [Define if you have a getaddrinfo that fails for the all-zeros IPv6 address])
1199                 ],
1200                 [
1201                         AC_MSG_RESULT(no)
1202                         AC_DEFINE(BROKEN_GETADDRINFO)
1203                 ]
1204         )
1205 fi
1206
1207 if test "x$check_for_conflicting_getspnam" = "x1"; then
1208         AC_MSG_CHECKING(for conflicting getspnam in shadow.h)
1209         AC_COMPILE_IFELSE(
1210                 [
1211 #include <shadow.h>
1212 int main(void) {exit(0);}
1213                 ],
1214                 [
1215                         AC_MSG_RESULT(no)
1216                 ],
1217                 [
1218                         AC_MSG_RESULT(yes)
1219                         AC_DEFINE(GETSPNAM_CONFLICTING_DEFS, 1,
1220                             [Conflicting defs for getspnam])
1221                 ]
1222         )
1223 fi
1224
1225 AC_FUNC_GETPGRP
1226
1227 # Check for PAM libs
1228 PAM_MSG="no"
1229 AC_ARG_WITH(pam,
1230         [  --with-pam              Enable PAM support ],
1231         [
1232                 if test "x$withval" != "xno" ; then
1233                         if test "x$ac_cv_header_security_pam_appl_h" != "xyes" && \
1234                            test "x$ac_cv_header_pam_pam_appl_h" != "xyes" ; then
1235                                 AC_MSG_ERROR([PAM headers not found])
1236                         fi
1237
1238                         AC_CHECK_LIB(dl, dlopen, , )
1239                         AC_CHECK_LIB(pam, pam_set_item, , AC_MSG_ERROR([*** libpam missing]))
1240                         AC_CHECK_FUNCS(pam_getenvlist)
1241                         AC_CHECK_FUNCS(pam_putenv)
1242
1243                         PAM_MSG="yes"
1244
1245                         AC_DEFINE(USE_PAM)
1246                         if test $ac_cv_lib_dl_dlopen = yes; then
1247                                 LIBPAM="-lpam -ldl"
1248                         else
1249                                 LIBPAM="-lpam"
1250                         fi
1251                         AC_SUBST(LIBPAM)
1252                 fi
1253         ]
1254 )
1255
1256 # Check for older PAM
1257 if test "x$PAM_MSG" = "xyes" ; then
1258         # Check PAM strerror arguments (old PAM)
1259         AC_MSG_CHECKING([whether pam_strerror takes only one argument])
1260         AC_TRY_COMPILE(
1261                 [
1262 #include <stdlib.h>
1263 #if defined(HAVE_SECURITY_PAM_APPL_H)
1264 #include <security/pam_appl.h>
1265 #elif defined (HAVE_PAM_PAM_APPL_H)
1266 #include <pam/pam_appl.h>
1267 #endif
1268                 ],
1269                 [(void)pam_strerror((pam_handle_t *)NULL, -1);],
1270                 [AC_MSG_RESULT(no)],
1271                 [
1272                         AC_DEFINE(HAVE_OLD_PAM)
1273                         AC_MSG_RESULT(yes)
1274                         PAM_MSG="yes (old library)"
1275                 ]
1276         )
1277 fi
1278
1279 # Search for OpenSSL
1280 saved_CPPFLAGS="$CPPFLAGS"
1281 saved_LDFLAGS="$LDFLAGS"
1282 AC_ARG_WITH(ssl-dir,
1283         [  --with-ssl-dir=PATH     Specify path to OpenSSL installation ],
1284         [
1285                 if test "x$withval" != "xno" ; then
1286                         case "$withval" in
1287                                 # Relative paths
1288                                 ./*|../*)       withval="`pwd`/$withval"
1289                         esac
1290                         if test -d "$withval/lib"; then
1291                                 if test -n "${need_dash_r}"; then
1292                                         LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
1293                                 else
1294                                         LDFLAGS="-L${withval}/lib ${LDFLAGS}"
1295                                 fi
1296                         else
1297                                 if test -n "${need_dash_r}"; then
1298                                         LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
1299                                 else
1300                                         LDFLAGS="-L${withval} ${LDFLAGS}"
1301                                 fi
1302                         fi
1303                         if test -d "$withval/include"; then
1304                                 CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
1305                         else
1306                                 CPPFLAGS="-I${withval} ${CPPFLAGS}"
1307                         fi
1308                 fi
1309         ]
1310 )
1311 LIBS="-lcrypto $LIBS"
1312 AC_TRY_LINK_FUNC(RAND_add, AC_DEFINE(HAVE_OPENSSL),
1313         [
1314                 dnl Check default openssl install dir
1315                 if test -n "${need_dash_r}"; then
1316                         LDFLAGS="-L/usr/local/ssl/lib -R/usr/local/ssl/lib ${saved_LDFLAGS}"
1317                 else
1318                         LDFLAGS="-L/usr/local/ssl/lib ${saved_LDFLAGS}"
1319                 fi
1320                 CPPFLAGS="-I/usr/local/ssl/include ${saved_CPPFLAGS}"
1321                 AC_TRY_LINK_FUNC(RAND_add, AC_DEFINE(HAVE_OPENSSL),
1322                         [
1323                                 AC_MSG_ERROR([*** Can't find recent OpenSSL libcrypto (see config.log for details) ***])
1324                         ]
1325                 )
1326         ]
1327 )
1328
1329 # Determine OpenSSL header version
1330 AC_MSG_CHECKING([OpenSSL header version])
1331 AC_RUN_IFELSE(
1332         [AC_LANG_SOURCE([[
1333 #include <stdio.h>
1334 #include <string.h>
1335 #include <openssl/opensslv.h>
1336 #define DATA "conftest.sslincver"
1337 int main(void) {
1338         FILE *fd;
1339         int rc;
1340
1341         fd = fopen(DATA,"w");
1342         if(fd == NULL)
1343                 exit(1);
1344
1345         if ((rc = fprintf(fd ,"%x (%s)\n", OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_TEXT)) <0)
1346                 exit(1);
1347
1348         exit(0);
1349 }
1350         ]])],
1351         [
1352                 ssl_header_ver=`cat conftest.sslincver`
1353                 AC_MSG_RESULT($ssl_header_ver)
1354         ],
1355         [
1356                 AC_MSG_RESULT(not found)
1357                 AC_MSG_ERROR(OpenSSL version header not found.)
1358         ],
1359         [
1360                 AC_MSG_WARN([cross compiling: not checking])
1361         ]
1362 )
1363
1364 # Determine OpenSSL library version
1365 AC_MSG_CHECKING([OpenSSL library version])
1366 AC_RUN_IFELSE(
1367         [AC_LANG_SOURCE([[
1368 #include <stdio.h>
1369 #include <string.h>
1370 #include <openssl/opensslv.h>
1371 #include <openssl/crypto.h>
1372 #define DATA "conftest.ssllibver"
1373 int main(void) {
1374         FILE *fd;
1375         int rc;
1376
1377         fd = fopen(DATA,"w");
1378         if(fd == NULL)
1379                 exit(1);
1380
1381         if ((rc = fprintf(fd ,"%x (%s)\n", SSLeay(), SSLeay_version(SSLEAY_VERSION))) <0)
1382                 exit(1);
1383
1384         exit(0);
1385 }
1386         ]])],
1387         [
1388                 ssl_library_ver=`cat conftest.ssllibver`
1389                 AC_MSG_RESULT($ssl_library_ver)
1390         ],
1391         [
1392                 AC_MSG_RESULT(not found)
1393                 AC_MSG_ERROR(OpenSSL library not found.)
1394         ],
1395         [
1396                 AC_MSG_WARN([cross compiling: not checking])
1397         ]
1398 )
1399
1400 # Sanity check OpenSSL headers
1401 AC_MSG_CHECKING([whether OpenSSL's headers match the library])
1402 AC_RUN_IFELSE(
1403         [AC_LANG_SOURCE([[
1404 #include <string.h>
1405 #include <openssl/opensslv.h>
1406 int main(void) { exit(SSLeay() == OPENSSL_VERSION_NUMBER ? 0 : 1); }
1407         ]])],
1408         [
1409                 AC_MSG_RESULT(yes)
1410         ],
1411         [
1412                 AC_MSG_RESULT(no)
1413                 AC_MSG_ERROR([Your OpenSSL headers do not match your library.
1414 Check config.log for details.
1415 Also see contrib/findssl.sh for help identifying header/library mismatches.])
1416         ],
1417         [
1418                 AC_MSG_WARN([cross compiling: not checking])
1419         ]
1420 )
1421
1422 # Some systems want crypt() from libcrypt, *not* the version in OpenSSL,
1423 # because the system crypt() is more featureful.
1424 if test "x$check_for_libcrypt_before" = "x1"; then
1425         AC_CHECK_LIB(crypt, crypt)
1426 fi
1427
1428 # Some Linux systems (Slackware) need crypt() from libcrypt, *not* the
1429 # version in OpenSSL.
1430 if test "x$check_for_libcrypt_later" = "x1"; then
1431         AC_CHECK_LIB(crypt, crypt, LIBS="$LIBS -lcrypt")
1432 fi
1433
1434
1435 ### Configure cryptographic random number support
1436
1437 # Check wheter OpenSSL seeds itself
1438 AC_MSG_CHECKING([whether OpenSSL's PRNG is internally seeded])
1439 AC_RUN_IFELSE(
1440         [AC_LANG_SOURCE([[
1441 #include <string.h>
1442 #include <openssl/rand.h>
1443 int main(void) { exit(RAND_status() == 1 ? 0 : 1); }
1444         ]])],
1445         [
1446                 OPENSSL_SEEDS_ITSELF=yes
1447                 AC_MSG_RESULT(yes)
1448         ],
1449         [
1450                 AC_MSG_RESULT(no)
1451                 # Default to use of the rand helper if OpenSSL doesn't
1452                 # seed itself
1453                 USE_RAND_HELPER=yes
1454         ],
1455         [
1456                 AC_MSG_WARN([cross compiling: assuming yes])
1457                 # This is safe, since all recent OpenSSL versions will
1458                 # complain at runtime if not seeded correctly. 
1459                 OPENSSL_SEEDS_ITSELF=yes
1460         ]
1461 )
1462
1463
1464 # Do we want to force the use of the rand helper?
1465 AC_ARG_WITH(rand-helper,
1466         [  --with-rand-helper      Use subprocess to gather strong randomness ],
1467         [
1468                 if test "x$withval" = "xno" ; then
1469                         # Force use of OpenSSL's internal RNG, even if
1470                         # the previous test showed it to be unseeded.
1471                         if test -z "$OPENSSL_SEEDS_ITSELF" ; then
1472                                 AC_MSG_WARN([*** Forcing use of OpenSSL's non-self-seeding PRNG])
1473                                 OPENSSL_SEEDS_ITSELF=yes
1474                                 USE_RAND_HELPER=""
1475                         fi
1476                 else
1477                         USE_RAND_HELPER=yes
1478                 fi
1479         ],
1480 )       
1481
1482 # Which randomness source do we use?
1483 if test ! -z "$OPENSSL_SEEDS_ITSELF" -a -z "$USE_RAND_HELPER" ; then
1484         # OpenSSL only
1485         AC_DEFINE(OPENSSL_PRNG_ONLY)
1486         RAND_MSG="OpenSSL internal ONLY"
1487         INSTALL_SSH_RAND_HELPER=""
1488 elif test ! -z "$USE_RAND_HELPER" ; then
1489         # install rand helper
1490         RAND_MSG="ssh-rand-helper"
1491         INSTALL_SSH_RAND_HELPER="yes"
1492 fi
1493 AC_SUBST(INSTALL_SSH_RAND_HELPER)
1494
1495 ### Configuration of ssh-rand-helper
1496
1497 # PRNGD TCP socket
1498 AC_ARG_WITH(prngd-port,
1499         [  --with-prngd-port=PORT  read entropy from PRNGD/EGD TCP localhost:PORT],
1500         [
1501                 case "$withval" in
1502                 no)
1503                         withval=""
1504                         ;;
1505                 [[0-9]]*)
1506                         ;;
1507                 *)
1508                         AC_MSG_ERROR(You must specify a numeric port number for --with-prngd-port)
1509                         ;;
1510                 esac
1511                 if test ! -z "$withval" ; then
1512                         PRNGD_PORT="$withval"
1513                         AC_DEFINE_UNQUOTED(PRNGD_PORT, $PRNGD_PORT)
1514                 fi
1515         ]
1516 )
1517
1518 # PRNGD Unix domain socket
1519 AC_ARG_WITH(prngd-socket,
1520         [  --with-prngd-socket=FILE read entropy from PRNGD/EGD socket FILE (default=/var/run/egd-pool)],
1521         [
1522                 case "$withval" in
1523                 yes)
1524                         withval="/var/run/egd-pool"
1525                         ;;
1526                 no)
1527                         withval=""
1528                         ;;
1529                 /*)
1530                         ;;
1531                 *)
1532                         AC_MSG_ERROR(You must specify an absolute path to the entropy socket)
1533                         ;;
1534                 esac
1535
1536                 if test ! -z "$withval" ; then
1537                         if test ! -z "$PRNGD_PORT" ; then
1538                                 AC_MSG_ERROR(You may not specify both a PRNGD/EGD port and socket)
1539                         fi
1540                         if test ! -r "$withval" ; then
1541                                 AC_MSG_WARN(Entropy socket is not readable)
1542                         fi
1543                         PRNGD_SOCKET="$withval"
1544                         AC_DEFINE_UNQUOTED(PRNGD_SOCKET, "$PRNGD_SOCKET")
1545                 fi
1546         ],
1547         [
1548                 # Check for existing socket only if we don't have a random device already
1549                 if test "$USE_RAND_HELPER" = yes ; then
1550                         AC_MSG_CHECKING(for PRNGD/EGD socket)
1551                         # Insert other locations here
1552                         for sock in /var/run/egd-pool /dev/egd-pool /etc/entropy; do
1553                                 if test -r $sock && $TEST_MINUS_S_SH -c "test -S $sock -o -p $sock" ; then
1554                                         PRNGD_SOCKET="$sock"
1555                                         AC_DEFINE_UNQUOTED(PRNGD_SOCKET, "$PRNGD_SOCKET")
1556                                         break;
1557                                 fi
1558                         done
1559                         if test ! -z "$PRNGD_SOCKET" ; then
1560                                 AC_MSG_RESULT($PRNGD_SOCKET)
1561                         else
1562                                 AC_MSG_RESULT(not found)
1563                         fi
1564                 fi
1565         ]
1566 )
1567
1568 # Change default command timeout for hashing entropy source
1569 entropy_timeout=200
1570 AC_ARG_WITH(entropy-timeout,
1571         [  --with-entropy-timeout  Specify entropy gathering command timeout (msec)],
1572         [
1573                 if test "x$withval" != "xno" ; then
1574                         entropy_timeout=$withval
1575                 fi
1576         ]       
1577 )
1578 AC_DEFINE_UNQUOTED(ENTROPY_TIMEOUT_MSEC, $entropy_timeout)
1579
1580 SSH_PRIVSEP_USER=sshd
1581 AC_ARG_WITH(privsep-user,
1582         [  --with-privsep-user=user Specify non-privileged user for privilege separation],
1583         [
1584                 if test -n "$withval"; then
1585                         SSH_PRIVSEP_USER=$withval
1586                 fi
1587         ]       
1588 )
1589 AC_DEFINE_UNQUOTED(SSH_PRIVSEP_USER, "$SSH_PRIVSEP_USER")
1590 AC_SUBST(SSH_PRIVSEP_USER)
1591
1592 # We do this little dance with the search path to insure
1593 # that programs that we select for use by installed programs
1594 # (which may be run by the super-user) come from trusted
1595 # locations before they come from the user's private area.
1596 # This should help avoid accidentally configuring some
1597 # random version of a program in someone's personal bin.
1598
1599 OPATH=$PATH
1600 PATH=/bin:/usr/bin
1601 test -h /bin 2> /dev/null && PATH=/usr/bin
1602 test -d /sbin && PATH=$PATH:/sbin
1603 test -d /usr/sbin && PATH=$PATH:/usr/sbin
1604 PATH=$PATH:/etc:$OPATH
1605
1606 # These programs are used by the command hashing source to gather entropy
1607 OSSH_PATH_ENTROPY_PROG(PROG_LS, ls)
1608 OSSH_PATH_ENTROPY_PROG(PROG_NETSTAT, netstat)
1609 OSSH_PATH_ENTROPY_PROG(PROG_ARP, arp)
1610 OSSH_PATH_ENTROPY_PROG(PROG_IFCONFIG, ifconfig)
1611 OSSH_PATH_ENTROPY_PROG(PROG_JSTAT, jstat)
1612 OSSH_PATH_ENTROPY_PROG(PROG_PS, ps)
1613 OSSH_PATH_ENTROPY_PROG(PROG_SAR, sar)
1614 OSSH_PATH_ENTROPY_PROG(PROG_W, w)
1615 OSSH_PATH_ENTROPY_PROG(PROG_WHO, who)
1616 OSSH_PATH_ENTROPY_PROG(PROG_LAST, last)
1617 OSSH_PATH_ENTROPY_PROG(PROG_LASTLOG, lastlog)
1618 OSSH_PATH_ENTROPY_PROG(PROG_DF, df)
1619 OSSH_PATH_ENTROPY_PROG(PROG_VMSTAT, vmstat)
1620 OSSH_PATH_ENTROPY_PROG(PROG_UPTIME, uptime)
1621 OSSH_PATH_ENTROPY_PROG(PROG_IPCS, ipcs)
1622 OSSH_PATH_ENTROPY_PROG(PROG_TAIL, tail)
1623 # restore PATH
1624 PATH=$OPATH
1625
1626 # Where does ssh-rand-helper get its randomness from?
1627 INSTALL_SSH_PRNG_CMDS=""
1628 if test ! -z "$INSTALL_SSH_RAND_HELPER" ; then
1629         if test ! -z "$PRNGD_PORT" ; then
1630                 RAND_HELPER_MSG="TCP localhost:$PRNGD_PORT"
1631         elif test ! -z "$PRNGD_SOCKET" ; then
1632                 RAND_HELPER_MSG="Unix domain socket \"$PRNGD_SOCKET\""
1633         else
1634                 RAND_HELPER_MSG="Command hashing (timeout $entropy_timeout)"
1635                 RAND_HELPER_CMDHASH=yes
1636                 INSTALL_SSH_PRNG_CMDS="yes"
1637         fi
1638 fi
1639 AC_SUBST(INSTALL_SSH_PRNG_CMDS)
1640
1641
1642 # Cheap hack to ensure NEWS-OS libraries are arranged right.
1643 if test ! -z "$SONY" ; then
1644   LIBS="$LIBS -liberty";
1645 fi
1646
1647 # Checks for data types
1648 AC_CHECK_SIZEOF(char, 1)
1649 AC_CHECK_SIZEOF(short int, 2)
1650 AC_CHECK_SIZEOF(int, 4)
1651 AC_CHECK_SIZEOF(long int, 4)
1652 AC_CHECK_SIZEOF(long long int, 8)
1653
1654 # Sanity check long long for some platforms (AIX)
1655 if test "x$ac_cv_sizeof_long_long_int" = "x4" ; then
1656         ac_cv_sizeof_long_long_int=0
1657 fi
1658
1659 # More checks for data types
1660 AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [
1661         AC_TRY_COMPILE(
1662                 [ #include <sys/types.h> ],
1663                 [ u_int a; a = 1;],
1664                 [ ac_cv_have_u_int="yes" ],
1665                 [ ac_cv_have_u_int="no" ]
1666         )
1667 ])
1668 if test "x$ac_cv_have_u_int" = "xyes" ; then
1669         AC_DEFINE(HAVE_U_INT)
1670         have_u_int=1
1671 fi
1672
1673 AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [
1674         AC_TRY_COMPILE(
1675                 [ #include <sys/types.h> ],
1676                 [ int8_t a; int16_t b; int32_t c; a = b = c = 1;],
1677                 [ ac_cv_have_intxx_t="yes" ],
1678                 [ ac_cv_have_intxx_t="no" ]
1679         )
1680 ])
1681 if test "x$ac_cv_have_intxx_t" = "xyes" ; then
1682         AC_DEFINE(HAVE_INTXX_T)
1683         have_intxx_t=1
1684 fi
1685
1686 if (test -z "$have_intxx_t" && \
1687            test "x$ac_cv_header_stdint_h" = "xyes")
1688 then
1689     AC_MSG_CHECKING([for intXX_t types in stdint.h])
1690         AC_TRY_COMPILE(
1691                 [ #include <stdint.h> ],
1692                 [ int8_t a; int16_t b; int32_t c; a = b = c = 1;],
1693                 [
1694                         AC_DEFINE(HAVE_INTXX_T)
1695                         AC_MSG_RESULT(yes)
1696                 ],
1697                 [ AC_MSG_RESULT(no) ]
1698         )
1699 fi
1700
1701 AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [
1702         AC_TRY_COMPILE(
1703                 [
1704 #include <sys/types.h>
1705 #ifdef HAVE_STDINT_H
1706 # include <stdint.h>
1707 #endif
1708 #include <sys/socket.h>
1709 #ifdef HAVE_SYS_BITYPES_H
1710 # include <sys/bitypes.h>
1711 #endif
1712                 ],
1713                 [ int64_t a; a = 1;],
1714                 [ ac_cv_have_int64_t="yes" ],
1715                 [ ac_cv_have_int64_t="no" ]
1716         )
1717 ])
1718 if test "x$ac_cv_have_int64_t" = "xyes" ; then
1719         AC_DEFINE(HAVE_INT64_T)
1720 fi
1721
1722 AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [
1723         AC_TRY_COMPILE(
1724                 [ #include <sys/types.h> ],
1725                 [ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;],
1726                 [ ac_cv_have_u_intxx_t="yes" ],
1727                 [ ac_cv_have_u_intxx_t="no" ]
1728         )
1729 ])
1730 if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
1731         AC_DEFINE(HAVE_U_INTXX_T)
1732         have_u_intxx_t=1
1733 fi
1734
1735 if test -z "$have_u_intxx_t" ; then
1736     AC_MSG_CHECKING([for u_intXX_t types in sys/socket.h])
1737         AC_TRY_COMPILE(
1738                 [ #include <sys/socket.h> ],
1739                 [ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;],
1740                 [
1741                         AC_DEFINE(HAVE_U_INTXX_T)
1742                         AC_MSG_RESULT(yes)
1743                 ],
1744                 [ AC_MSG_RESULT(no) ]
1745         )
1746 fi
1747
1748 AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [
1749         AC_TRY_COMPILE(
1750                 [ #include <sys/types.h> ],
1751                 [ u_int64_t a; a = 1;],
1752                 [ ac_cv_have_u_int64_t="yes" ],
1753                 [ ac_cv_have_u_int64_t="no" ]
1754         )
1755 ])
1756 if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
1757         AC_DEFINE(HAVE_U_INT64_T)
1758         have_u_int64_t=1
1759 fi
1760
1761 if test -z "$have_u_int64_t" ; then
1762     AC_MSG_CHECKING([for u_int64_t type in sys/bitypes.h])
1763         AC_TRY_COMPILE(
1764                 [ #include <sys/bitypes.h> ],
1765                 [ u_int64_t a; a = 1],
1766                 [
1767                         AC_DEFINE(HAVE_U_INT64_T)
1768                         AC_MSG_RESULT(yes)
1769                 ],
1770                 [ AC_MSG_RESULT(no) ]
1771         )
1772 fi
1773
1774 if test -z "$have_u_intxx_t" ; then
1775         AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [
1776                 AC_TRY_COMPILE(
1777                         [
1778 #include <sys/types.h>
1779                         ],
1780                         [ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1; ],
1781                         [ ac_cv_have_uintxx_t="yes" ],
1782                         [ ac_cv_have_uintxx_t="no" ]
1783                 )
1784         ])
1785         if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
1786                 AC_DEFINE(HAVE_UINTXX_T)
1787         fi
1788 fi
1789
1790 if test -z "$have_uintxx_t" ; then
1791     AC_MSG_CHECKING([for uintXX_t types in stdint.h])
1792         AC_TRY_COMPILE(
1793                 [ #include <stdint.h> ],
1794                 [ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;],
1795                 [
1796                         AC_DEFINE(HAVE_UINTXX_T)
1797                         AC_MSG_RESULT(yes)
1798                 ],
1799                 [ AC_MSG_RESULT(no) ]
1800         )
1801 fi
1802
1803 if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
1804            test "x$ac_cv_header_sys_bitypes_h" = "xyes")
1805 then
1806         AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
1807         AC_TRY_COMPILE(
1808                 [
1809 #include <sys/bitypes.h>
1810                 ],
1811                 [
1812                         int8_t a; int16_t b; int32_t c;
1813                         u_int8_t e; u_int16_t f; u_int32_t g;
1814                         a = b = c = e = f = g = 1;
1815                 ],
1816                 [
1817                         AC_DEFINE(HAVE_U_INTXX_T)
1818                         AC_DEFINE(HAVE_INTXX_T)
1819                         AC_MSG_RESULT(yes)
1820                 ],
1821                 [AC_MSG_RESULT(no)]
1822         )
1823 fi
1824
1825
1826 AC_CACHE_CHECK([for u_char], ac_cv_have_u_char, [
1827         AC_TRY_COMPILE(
1828                 [
1829 #include <sys/types.h>
1830                 ],
1831                 [ u_char foo; foo = 125; ],
1832                 [ ac_cv_have_u_char="yes" ],
1833                 [ ac_cv_have_u_char="no" ]
1834         )
1835 ])
1836 if test "x$ac_cv_have_u_char" = "xyes" ; then
1837         AC_DEFINE(HAVE_U_CHAR)
1838 fi
1839
1840 TYPE_SOCKLEN_T
1841
1842 AC_CHECK_TYPES(sig_atomic_t,,,[#include <signal.h>])
1843
1844 AC_CACHE_CHECK([for size_t], ac_cv_have_size_t, [
1845         AC_TRY_COMPILE(
1846                 [
1847 #include <sys/types.h>
1848                 ],
1849                 [ size_t foo; foo = 1235; ],
1850                 [ ac_cv_have_size_t="yes" ],
1851                 [ ac_cv_have_size_t="no" ]
1852         )
1853 ])
1854 if test "x$ac_cv_have_size_t" = "xyes" ; then
1855         AC_DEFINE(HAVE_SIZE_T)
1856 fi
1857
1858 AC_CACHE_CHECK([for ssize_t], ac_cv_have_ssize_t, [
1859         AC_TRY_COMPILE(
1860                 [
1861 #include <sys/types.h>
1862                 ],
1863                 [ ssize_t foo; foo = 1235; ],
1864                 [ ac_cv_have_ssize_t="yes" ],
1865                 [ ac_cv_have_ssize_t="no" ]
1866         )
1867 ])
1868 if test "x$ac_cv_have_ssize_t" = "xyes" ; then
1869         AC_DEFINE(HAVE_SSIZE_T)
1870 fi
1871
1872 AC_CACHE_CHECK([for clock_t], ac_cv_have_clock_t, [
1873         AC_TRY_COMPILE(
1874                 [
1875 #include <time.h>
1876                 ],
1877                 [ clock_t foo; foo = 1235; ],
1878                 [ ac_cv_have_clock_t="yes" ],
1879                 [ ac_cv_have_clock_t="no" ]
1880         )
1881 ])
1882 if test "x$ac_cv_have_clock_t" = "xyes" ; then
1883         AC_DEFINE(HAVE_CLOCK_T)
1884 fi
1885
1886 AC_CACHE_CHECK([for sa_family_t], ac_cv_have_sa_family_t, [
1887         AC_TRY_COMPILE(
1888                 [
1889 #include <sys/types.h>
1890 #include <sys/socket.h>
1891                 ],
1892                 [ sa_family_t foo; foo = 1235; ],
1893                 [ ac_cv_have_sa_family_t="yes" ],
1894                 [ AC_TRY_COMPILE(
1895                   [
1896 #include <sys/types.h>
1897 #include <sys/socket.h>
1898 #include <netinet/in.h>
1899                 ],
1900                 [ sa_family_t foo; foo = 1235; ],
1901                 [ ac_cv_have_sa_family_t="yes" ],
1902
1903                 [ ac_cv_have_sa_family_t="no" ]
1904         )]
1905         )
1906 ])
1907 if test "x$ac_cv_have_sa_family_t" = "xyes" ; then
1908         AC_DEFINE(HAVE_SA_FAMILY_T)
1909 fi
1910
1911 AC_CACHE_CHECK([for pid_t], ac_cv_have_pid_t, [
1912         AC_TRY_COMPILE(
1913                 [
1914 #include <sys/types.h>
1915                 ],
1916                 [ pid_t foo; foo = 1235; ],
1917                 [ ac_cv_have_pid_t="yes" ],
1918                 [ ac_cv_have_pid_t="no" ]
1919         )
1920 ])
1921 if test "x$ac_cv_have_pid_t" = "xyes" ; then
1922         AC_DEFINE(HAVE_PID_T)
1923 fi
1924
1925 AC_CACHE_CHECK([for mode_t], ac_cv_have_mode_t, [
1926         AC_TRY_COMPILE(
1927                 [
1928 #include <sys/types.h>
1929                 ],
1930                 [ mode_t foo; foo = 1235; ],
1931                 [ ac_cv_have_mode_t="yes" ],
1932                 [ ac_cv_have_mode_t="no" ]
1933         )
1934 ])
1935 if test "x$ac_cv_have_mode_t" = "xyes" ; then
1936         AC_DEFINE(HAVE_MODE_T)
1937 fi
1938
1939
1940 AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_have_struct_sockaddr_storage, [
1941         AC_TRY_COMPILE(
1942                 [
1943 #include <sys/types.h>
1944 #include <sys/socket.h>
1945                 ],
1946                 [ struct sockaddr_storage s; ],
1947                 [ ac_cv_have_struct_sockaddr_storage="yes" ],
1948                 [ ac_cv_have_struct_sockaddr_storage="no" ]
1949         )
1950 ])
1951 if test "x$ac_cv_have_struct_sockaddr_storage" = "xyes" ; then
1952         AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE)
1953 fi
1954
1955 AC_CACHE_CHECK([for struct sockaddr_in6], ac_cv_have_struct_sockaddr_in6, [
1956         AC_TRY_COMPILE(
1957                 [
1958 #include <sys/types.h>
1959 #include <netinet/in.h>
1960                 ],
1961                 [ struct sockaddr_in6 s; s.sin6_family = 0; ],
1962                 [ ac_cv_have_struct_sockaddr_in6="yes" ],
1963                 [ ac_cv_have_struct_sockaddr_in6="no" ]
1964         )
1965 ])
1966 if test "x$ac_cv_have_struct_sockaddr_in6" = "xyes" ; then
1967         AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6)
1968 fi
1969
1970 AC_CACHE_CHECK([for struct in6_addr], ac_cv_have_struct_in6_addr, [
1971         AC_TRY_COMPILE(
1972                 [
1973 #include <sys/types.h>
1974 #include <netinet/in.h>
1975                 ],
1976                 [ struct in6_addr s; s.s6_addr[0] = 0; ],
1977                 [ ac_cv_have_struct_in6_addr="yes" ],
1978                 [ ac_cv_have_struct_in6_addr="no" ]
1979         )
1980 ])
1981 if test "x$ac_cv_have_struct_in6_addr" = "xyes" ; then
1982         AC_DEFINE(HAVE_STRUCT_IN6_ADDR)
1983 fi
1984
1985 AC_CACHE_CHECK([for struct addrinfo], ac_cv_have_struct_addrinfo, [
1986         AC_TRY_COMPILE(
1987                 [
1988 #include <sys/types.h>
1989 #include <sys/socket.h>
1990 #include <netdb.h>
1991                 ],
1992                 [ struct addrinfo s; s.ai_flags = AI_PASSIVE; ],
1993                 [ ac_cv_have_struct_addrinfo="yes" ],
1994                 [ ac_cv_have_struct_addrinfo="no" ]
1995         )
1996 ])
1997 if test "x$ac_cv_have_struct_addrinfo" = "xyes" ; then
1998         AC_DEFINE(HAVE_STRUCT_ADDRINFO)
1999 fi
2000
2001 AC_CACHE_CHECK([for struct timeval], ac_cv_have_struct_timeval, [
2002         AC_TRY_COMPILE(
2003                 [ #include <sys/time.h> ],
2004                 [ struct timeval tv; tv.tv_sec = 1;],
2005                 [ ac_cv_have_struct_timeval="yes" ],
2006                 [ ac_cv_have_struct_timeval="no" ]
2007         )
2008 ])
2009 if test "x$ac_cv_have_struct_timeval" = "xyes" ; then
2010         AC_DEFINE(HAVE_STRUCT_TIMEVAL)
2011         have_struct_timeval=1
2012 fi
2013
2014 AC_CHECK_TYPES(struct timespec)
2015
2016 # We need int64_t or else certian parts of the compile will fail.
2017 if test "x$ac_cv_have_int64_t" = "xno" -a \
2018         "x$ac_cv_sizeof_long_int" != "x8" -a \
2019         "x$ac_cv_sizeof_long_long_int" = "x0" ; then
2020         echo "OpenSSH requires int64_t support.  Contact your vendor or install"
2021         echo "an alternative compiler (I.E., GCC) before continuing."
2022         echo ""
2023         exit 1;
2024 else
2025 dnl test snprintf (broken on SCO w/gcc)
2026         AC_RUN_IFELSE(
2027                 [AC_LANG_SOURCE([[
2028 #include <stdio.h>
2029 #include <string.h>
2030 #ifdef HAVE_SNPRINTF
2031 main()
2032 {
2033         char buf[50];
2034         char expected_out[50];
2035         int mazsize = 50 ;
2036 #if (SIZEOF_LONG_INT == 8)
2037         long int num = 0x7fffffffffffffff;
2038 #else
2039         long long num = 0x7fffffffffffffffll;
2040 #endif
2041         strcpy(expected_out, "9223372036854775807");
2042         snprintf(buf, mazsize, "%lld", num);
2043         if(strcmp(buf, expected_out) != 0)
2044                 exit(1);
2045         exit(0);
2046 }
2047 #else
2048 main() { exit(0); }
2049 #endif
2050                 ]])], [ true ], [ AC_DEFINE(BROKEN_SNPRINTF) ],
2051                 AC_MSG_WARN([cross compiling: Assuming working snprintf()])
2052         )
2053 fi
2054
2055 dnl Checks for structure members
2056 OSSH_CHECK_HEADER_FOR_FIELD(ut_host, utmp.h, HAVE_HOST_IN_UTMP)
2057 OSSH_CHECK_HEADER_FOR_FIELD(ut_host, utmpx.h, HAVE_HOST_IN_UTMPX)
2058 OSSH_CHECK_HEADER_FOR_FIELD(syslen, utmpx.h, HAVE_SYSLEN_IN_UTMPX)
2059 OSSH_CHECK_HEADER_FOR_FIELD(ut_pid, utmp.h, HAVE_PID_IN_UTMP)
2060 OSSH_CHECK_HEADER_FOR_FIELD(ut_type, utmp.h, HAVE_TYPE_IN_UTMP)
2061 OSSH_CHECK_HEADER_FOR_FIELD(ut_type, utmpx.h, HAVE_TYPE_IN_UTMPX)
2062 OSSH_CHECK_HEADER_FOR_FIELD(ut_tv, utmp.h, HAVE_TV_IN_UTMP)
2063 OSSH_CHECK_HEADER_FOR_FIELD(ut_id, utmp.h, HAVE_ID_IN_UTMP)
2064 OSSH_CHECK_HEADER_FOR_FIELD(ut_id, utmpx.h, HAVE_ID_IN_UTMPX)
2065 OSSH_CHECK_HEADER_FOR_FIELD(ut_addr, utmp.h, HAVE_ADDR_IN_UTMP)
2066 OSSH_CHECK_HEADER_FOR_FIELD(ut_addr, utmpx.h, HAVE_ADDR_IN_UTMPX)
2067 OSSH_CHECK_HEADER_FOR_FIELD(ut_addr_v6, utmp.h, HAVE_ADDR_V6_IN_UTMP)
2068 OSSH_CHECK_HEADER_FOR_FIELD(ut_addr_v6, utmpx.h, HAVE_ADDR_V6_IN_UTMPX)
2069 OSSH_CHECK_HEADER_FOR_FIELD(ut_exit, utmp.h, HAVE_EXIT_IN_UTMP)
2070 OSSH_CHECK_HEADER_FOR_FIELD(ut_time, utmp.h, HAVE_TIME_IN_UTMP)
2071 OSSH_CHECK_HEADER_FOR_FIELD(ut_time, utmpx.h, HAVE_TIME_IN_UTMPX)
2072 OSSH_CHECK_HEADER_FOR_FIELD(ut_tv, utmpx.h, HAVE_TV_IN_UTMPX)
2073
2074 AC_CHECK_MEMBERS([struct stat.st_blksize])
2075
2076 AC_CACHE_CHECK([for ss_family field in struct sockaddr_storage],
2077                 ac_cv_have_ss_family_in_struct_ss, [
2078         AC_TRY_COMPILE(
2079                 [
2080 #include <sys/types.h>
2081 #include <sys/socket.h>
2082                 ],
2083                 [ struct sockaddr_storage s; s.ss_family = 1; ],
2084                 [ ac_cv_have_ss_family_in_struct_ss="yes" ],
2085                 [ ac_cv_have_ss_family_in_struct_ss="no" ],
2086         )
2087 ])
2088 if test "x$ac_cv_have_ss_family_in_struct_ss" = "xyes" ; then
2089         AC_DEFINE(HAVE_SS_FAMILY_IN_SS)
2090 fi
2091
2092 AC_CACHE_CHECK([for __ss_family field in struct sockaddr_storage],
2093                 ac_cv_have___ss_family_in_struct_ss, [
2094         AC_TRY_COMPILE(
2095                 [
2096 #include <sys/types.h>
2097 #include <sys/socket.h>
2098                 ],
2099                 [ struct sockaddr_storage s; s.__ss_family = 1; ],
2100                 [ ac_cv_have___ss_family_in_struct_ss="yes" ],
2101                 [ ac_cv_have___ss_family_in_struct_ss="no" ]
2102         )
2103 ])
2104 if test "x$ac_cv_have___ss_family_in_struct_ss" = "xyes" ; then
2105         AC_DEFINE(HAVE___SS_FAMILY_IN_SS)
2106 fi
2107
2108 AC_CACHE_CHECK([for pw_class field in struct passwd],
2109                 ac_cv_have_pw_class_in_struct_passwd, [
2110         AC_TRY_COMPILE(
2111                 [
2112 #include <pwd.h>
2113                 ],
2114                 [ struct passwd p; p.pw_class = 0; ],
2115                 [ ac_cv_have_pw_class_in_struct_passwd="yes" ],
2116                 [ ac_cv_have_pw_class_in_struct_passwd="no" ]
2117         )
2118 ])
2119 if test "x$ac_cv_have_pw_class_in_struct_passwd" = "xyes" ; then
2120         AC_DEFINE(HAVE_PW_CLASS_IN_PASSWD)
2121 fi
2122
2123 AC_CACHE_CHECK([for pw_expire field in struct passwd],
2124                 ac_cv_have_pw_expire_in_struct_passwd, [
2125         AC_TRY_COMPILE(
2126                 [
2127 #include <pwd.h>
2128                 ],
2129                 [ struct passwd p; p.pw_expire = 0; ],
2130                 [ ac_cv_have_pw_expire_in_struct_passwd="yes" ],
2131                 [ ac_cv_have_pw_expire_in_struct_passwd="no" ]
2132         )
2133 ])
2134 if test "x$ac_cv_have_pw_expire_in_struct_passwd" = "xyes" ; then
2135         AC_DEFINE(HAVE_PW_EXPIRE_IN_PASSWD)
2136 fi
2137
2138 AC_CACHE_CHECK([for pw_change field in struct passwd],
2139                 ac_cv_have_pw_change_in_struct_passwd, [
2140         AC_TRY_COMPILE(
2141                 [
2142 #include <pwd.h>
2143                 ],
2144                 [ struct passwd p; p.pw_change = 0; ],
2145                 [ ac_cv_have_pw_change_in_struct_passwd="yes" ],
2146                 [ ac_cv_have_pw_change_in_struct_passwd="no" ]
2147         )
2148 ])
2149 if test "x$ac_cv_have_pw_change_in_struct_passwd" = "xyes" ; then
2150         AC_DEFINE(HAVE_PW_CHANGE_IN_PASSWD)
2151 fi
2152
2153 dnl make sure we're using the real structure members and not defines
2154 AC_CACHE_CHECK([for msg_accrights field in struct msghdr],
2155                 ac_cv_have_accrights_in_msghdr, [
2156         AC_COMPILE_IFELSE(
2157                 [
2158 #include <sys/types.h>
2159 #include <sys/socket.h>
2160 #include <sys/uio.h>
2161 int main() {
2162 #ifdef msg_accrights
2163 #error "msg_accrights is a macro"
2164 exit(1);
2165 #endif
2166 struct msghdr m;
2167 m.msg_accrights = 0;
2168 exit(0);
2169 }
2170                 ],
2171                 [ ac_cv_have_accrights_in_msghdr="yes" ],
2172                 [ ac_cv_have_accrights_in_msghdr="no" ]
2173         )
2174 ])
2175 if test "x$ac_cv_have_accrights_in_msghdr" = "xyes" ; then
2176         AC_DEFINE(HAVE_ACCRIGHTS_IN_MSGHDR)
2177 fi
2178
2179 AC_CACHE_CHECK([for msg_control field in struct msghdr],
2180                 ac_cv_have_control_in_msghdr, [
2181         AC_COMPILE_IFELSE(
2182                 [
2183 #include <sys/types.h>
2184 #include <sys/socket.h>
2185 #include <sys/uio.h>
2186 int main() {
2187 #ifdef msg_control
2188 #error "msg_control is a macro"
2189 exit(1);
2190 #endif
2191 struct msghdr m;
2192 m.msg_control = 0;
2193 exit(0);
2194 }
2195                 ],
2196                 [ ac_cv_have_control_in_msghdr="yes" ],
2197                 [ ac_cv_have_control_in_msghdr="no" ]
2198         )
2199 ])
2200 if test "x$ac_cv_have_control_in_msghdr" = "xyes" ; then
2201         AC_DEFINE(HAVE_CONTROL_IN_MSGHDR)
2202 fi
2203
2204 AC_CACHE_CHECK([if libc defines __progname], ac_cv_libc_defines___progname, [
2205         AC_TRY_LINK([],
2206                 [ extern char *__progname; printf("%s", __progname); ],
2207                 [ ac_cv_libc_defines___progname="yes" ],
2208                 [ ac_cv_libc_defines___progname="no" ]
2209         )
2210 ])
2211 if test "x$ac_cv_libc_defines___progname" = "xyes" ; then
2212         AC_DEFINE(HAVE___PROGNAME)
2213 fi
2214
2215 AC_CACHE_CHECK([whether $CC implements __FUNCTION__], ac_cv_cc_implements___FUNCTION__, [
2216         AC_TRY_LINK([
2217 #include <stdio.h>
2218 ],
2219                 [ printf("%s", __FUNCTION__); ],
2220                 [ ac_cv_cc_implements___FUNCTION__="yes" ],
2221                 [ ac_cv_cc_implements___FUNCTION__="no" ]
2222         )
2223 ])
2224 if test "x$ac_cv_cc_implements___FUNCTION__" = "xyes" ; then
2225         AC_DEFINE(HAVE___FUNCTION__)
2226 fi
2227
2228 AC_CACHE_CHECK([whether $CC implements __func__], ac_cv_cc_implements___func__, [
2229         AC_TRY_LINK([
2230 #include <stdio.h>
2231 ],
2232                 [ printf("%s", __func__); ],
2233                 [ ac_cv_cc_implements___func__="yes" ],
2234                 [ ac_cv_cc_implements___func__="no" ]
2235         )
2236 ])
2237 if test "x$ac_cv_cc_implements___func__" = "xyes" ; then
2238         AC_DEFINE(HAVE___func__)
2239 fi
2240
2241 AC_CACHE_CHECK([whether getopt has optreset support],
2242                 ac_cv_have_getopt_optreset, [
2243         AC_TRY_LINK(
2244                 [
2245 #include <getopt.h>
2246                 ],
2247                 [ extern int optreset; optreset = 0; ],
2248                 [ ac_cv_have_getopt_optreset="yes" ],
2249                 [ ac_cv_have_getopt_optreset="no" ]
2250         )
2251 ])
2252 if test "x$ac_cv_have_getopt_optreset" = "xyes" ; then
2253         AC_DEFINE(HAVE_GETOPT_OPTRESET)
2254 fi
2255
2256 AC_CACHE_CHECK([if libc defines sys_errlist], ac_cv_libc_defines_sys_errlist, [
2257         AC_TRY_LINK([],
2258                 [ extern const char *const sys_errlist[]; printf("%s", sys_errlist[0]);],
2259                 [ ac_cv_libc_defines_sys_errlist="yes" ],
2260                 [ ac_cv_libc_defines_sys_errlist="no" ]
2261         )
2262 ])
2263 if test "x$ac_cv_libc_defines_sys_errlist" = "xyes" ; then
2264         AC_DEFINE(HAVE_SYS_ERRLIST)
2265 fi
2266
2267
2268 AC_CACHE_CHECK([if libc defines sys_nerr], ac_cv_libc_defines_sys_nerr, [
2269         AC_TRY_LINK([],
2270                 [ extern int sys_nerr; printf("%i", sys_nerr);],
2271                 [ ac_cv_libc_defines_sys_nerr="yes" ],
2272                 [ ac_cv_libc_defines_sys_nerr="no" ]
2273         )
2274 ])
2275 if test "x$ac_cv_libc_defines_sys_nerr" = "xyes" ; then
2276         AC_DEFINE(HAVE_SYS_NERR)
2277 fi
2278
2279 SCARD_MSG="no"
2280 # Check whether user wants sectok support
2281 AC_ARG_WITH(sectok,
2282         [  --with-sectok           Enable smartcard support using libsectok],
2283         [
2284                 if test "x$withval" != "xno" ; then
2285                         if test "x$withval" != "xyes" ; then
2286                                 CPPFLAGS="$CPPFLAGS -I${withval}"
2287                                 LDFLAGS="$LDFLAGS -L${withval}"
2288                                 if test ! -z "$need_dash_r" ; then
2289                                         LDFLAGS="$LDFLAGS -R${withval}"
2290                                 fi
2291                                 if test ! -z "$blibpath" ; then
2292                                         blibpath="$blibpath:${withval}"
2293                                 fi
2294                         fi
2295                         AC_CHECK_HEADERS(sectok.h)
2296                         if test "$ac_cv_header_sectok_h" != yes; then
2297                                 AC_MSG_ERROR(Can't find sectok.h)
2298                         fi
2299                         AC_CHECK_LIB(sectok, sectok_open)
2300                         if test "$ac_cv_lib_sectok_sectok_open" != yes; then
2301                                 AC_MSG_ERROR(Can't find libsectok)
2302                         fi
2303                         AC_DEFINE(SMARTCARD)
2304                         AC_DEFINE(USE_SECTOK)
2305                         SCARD_MSG="yes, using sectok"
2306                 fi
2307         ]
2308 )
2309
2310 # Check whether user wants OpenSC support
2311 AC_ARG_WITH(opensc,
2312         AC_HELP_STRING([--with-opensc=PFX],
2313                        [Enable smartcard support using OpenSC]),
2314         opensc_config_prefix="$withval", opensc_config_prefix="")
2315 if test x$opensc_config_prefix != x ; then
2316   OPENSC_CONFIG=$opensc_config_prefix/bin/opensc-config
2317   AC_PATH_PROG(OPENSC_CONFIG, opensc-config, no)
2318   if test "$OPENSC_CONFIG" != "no"; then
2319     LIBOPENSC_CFLAGS=`$OPENSC_CONFIG --cflags`
2320     LIBOPENSC_LIBS=`$OPENSC_CONFIG --libs`
2321     CPPFLAGS="$CPPFLAGS $LIBOPENSC_CFLAGS"
2322     LDFLAGS="$LDFLAGS $LIBOPENSC_LIBS"
2323     AC_DEFINE(SMARTCARD)
2324     AC_DEFINE(USE_OPENSC)
2325     SCARD_MSG="yes, using OpenSC"
2326   fi
2327 fi
2328
2329 # Check libraries needed by DNS fingerprint support
2330 AC_SEARCH_LIBS(getrrsetbyname, resolv,
2331         [AC_DEFINE(HAVE_GETRRSETBYNAME)],
2332         [
2333                 # Needed by our getrrsetbyname()
2334                 AC_SEARCH_LIBS(res_query, resolv)
2335                 AC_SEARCH_LIBS(dn_expand, resolv)
2336                 AC_MSG_CHECKING(if res_query will link)
2337                 AC_TRY_LINK_FUNC(res_query, AC_MSG_RESULT(yes),
2338                    [AC_MSG_RESULT(no)
2339                     saved_LIBS="$LIBS"
2340                     LIBS="$LIBS -lresolv"
2341                     AC_MSG_CHECKING(for res_query in -lresolv)
2342                     AC_LINK_IFELSE([
2343 #include <resolv.h>
2344 int main()
2345 {
2346         res_query (0, 0, 0, 0, 0);
2347         return 0;
2348 }
2349                         ],
2350                         [LIBS="$LIBS -lresolv"
2351                          AC_MSG_RESULT(yes)],
2352                         [LIBS="$saved_LIBS"
2353                          AC_MSG_RESULT(no)])
2354                     ])
2355                 AC_CHECK_FUNCS(_getshort _getlong)
2356                 AC_CHECK_MEMBER(HEADER.ad,
2357                         [AC_DEFINE(HAVE_HEADER_AD)],,
2358                         [#include <arpa/nameser.h>])
2359         ])
2360
2361 # Check whether user wants Kerberos 5 support
2362 KRB5_MSG="no"
2363 AC_ARG_WITH(kerberos5,
2364         [  --with-kerberos5=PATH   Enable Kerberos 5 support],
2365         [ if test "x$withval" != "xno" ; then
2366                 if test "x$withval" = "xyes" ; then
2367                         KRB5ROOT="/usr/local"
2368                 else
2369                         KRB5ROOT=${withval}
2370                 fi
2371
2372                 AC_DEFINE(KRB5)
2373                 KRB5_MSG="yes"
2374
2375                 AC_MSG_CHECKING(for krb5-config)
2376                 if test -x  $KRB5ROOT/bin/krb5-config ; then
2377                         KRB5CONF=$KRB5ROOT/bin/krb5-config
2378                         AC_MSG_RESULT($KRB5CONF)
2379
2380                         AC_MSG_CHECKING(for gssapi support)
2381                         if $KRB5CONF | grep gssapi >/dev/null ; then
2382                                 AC_MSG_RESULT(yes)
2383                                 AC_DEFINE(GSSAPI)
2384                                 k5confopts=gssapi
2385                         else
2386                                 AC_MSG_RESULT(no)
2387                                 k5confopts=""
2388                         fi
2389                         K5CFLAGS="`$KRB5CONF --cflags $k5confopts`"
2390                         K5LIBS="`$KRB5CONF --libs $k5confopts`"
2391                         CPPFLAGS="$CPPFLAGS $K5CFLAGS"
2392                         AC_MSG_CHECKING(whether we are using Heimdal)
2393                         AC_TRY_COMPILE([ #include <krb5.h> ],
2394                                        [ char *tmp = heimdal_version; ],
2395                                        [ AC_MSG_RESULT(yes)
2396                                          AC_DEFINE(HEIMDAL) ],
2397                                          AC_MSG_RESULT(no)
2398                         )
2399                 else
2400                         AC_MSG_RESULT(no)
2401                         CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include"
2402                         LDFLAGS="$LDFLAGS -L${KRB5ROOT}/lib"
2403                         AC_MSG_CHECKING(whether we are using Heimdal)
2404                         AC_TRY_COMPILE([ #include <krb5.h> ],
2405                                        [ char *tmp = heimdal_version; ],
2406                                        [ AC_MSG_RESULT(yes)
2407                                          AC_DEFINE(HEIMDAL)
2408                                          K5LIBS="-lkrb5 -ldes"
2409                                          K5LIBS="$K5LIBS -lcom_err -lasn1"
2410                                          AC_CHECK_LIB(roken, net_write, 
2411                                            [K5LIBS="$K5LIBS -lroken"])
2412                                        ],
2413                                        [ AC_MSG_RESULT(no)
2414                                          K5LIBS="-lkrb5 -lk5crypto -lcom_err"
2415                                        ]
2416                         )
2417                         AC_SEARCH_LIBS(dn_expand, resolv)
2418
2419                         AC_CHECK_LIB(gssapi,gss_init_sec_context,
2420                                 [ AC_DEFINE(GSSAPI)
2421                                   K5LIBS="-lgssapi $K5LIBS" ],
2422                                 [ AC_CHECK_LIB(gssapi_krb5,gss_init_sec_context,
2423                                         [ AC_DEFINE(GSSAPI)
2424                                           K5LIBS="-lgssapi_krb5 $K5LIBS" ],
2425                                         AC_MSG_WARN([Cannot find any suitable gss-api library - build may fail]),
2426                                         $K5LIBS)
2427                                 ],
2428                                 $K5LIBS)
2429                         
2430                         AC_CHECK_HEADER(gssapi.h, ,
2431                                 [ unset ac_cv_header_gssapi_h
2432                                   CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
2433                                   AC_CHECK_HEADERS(gssapi.h, ,
2434                                         AC_MSG_WARN([Cannot find any suitable gss-api header - build may fail])
2435                                   )
2436                                 ]
2437                         )
2438
2439                         oldCPP="$CPPFLAGS"
2440                         CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
2441                         AC_CHECK_HEADER(gssapi_krb5.h, ,
2442                                         [ CPPFLAGS="$oldCPP" ])
2443
2444                 fi
2445                 if test ! -z "$need_dash_r" ; then
2446                         LDFLAGS="$LDFLAGS -R${KRB5ROOT}/lib"
2447                 fi
2448                 if test ! -z "$blibpath" ; then
2449                         blibpath="$blibpath:${KRB5ROOT}/lib"
2450                 fi
2451         fi
2452
2453         AC_CHECK_HEADERS(gssapi.h gssapi/gssapi.h)
2454         AC_CHECK_HEADERS(gssapi_krb5.h gssapi/gssapi_krb5.h)
2455         AC_CHECK_HEADERS(gssapi_generic.h gssapi/gssapi_generic.h)
2456
2457         LIBS="$LIBS $K5LIBS"
2458         AC_SEARCH_LIBS(k_hasafs, kafs, AC_DEFINE(USE_AFS))
2459         AC_SEARCH_LIBS(krb5_init_ets, $K5LIBS, AC_DEFINE(KRB5_INIT_ETS))
2460         ]
2461 )
2462
2463 # Looking for programs, paths and files
2464
2465 PRIVSEP_PATH=/var/empty
2466 AC_ARG_WITH(privsep-path,
2467         [  --with-privsep-path=xxx Path for privilege separation chroot (default=/var/empty)],
2468         [
2469                 if test "x$withval" != "$no" ; then
2470                         PRIVSEP_PATH=$withval
2471                 fi
2472         ]
2473 )
2474 AC_SUBST(PRIVSEP_PATH)
2475
2476 AC_ARG_WITH(xauth,
2477         [  --with-xauth=PATH       Specify path to xauth program ],
2478         [
2479                 if test "x$withval" != "xno" ; then
2480                         xauth_path=$withval
2481                 fi
2482         ],
2483         [
2484                 TestPath="$PATH"
2485                 TestPath="${TestPath}${PATH_SEPARATOR}/usr/X/bin"
2486                 TestPath="${TestPath}${PATH_SEPARATOR}/usr/bin/X11"
2487                 TestPath="${TestPath}${PATH_SEPARATOR}/usr/X11R6/bin"
2488                 TestPath="${TestPath}${PATH_SEPARATOR}/usr/openwin/bin"
2489                 AC_PATH_PROG(xauth_path, xauth, , $TestPath)
2490                 if (test ! -z "$xauth_path" && test -x "/usr/openwin/bin/xauth") ; then
2491                         xauth_path="/usr/openwin/bin/xauth"
2492                 fi
2493         ]
2494 )
2495
2496 STRIP_OPT=-s
2497 AC_ARG_ENABLE(strip,
2498         [  --disable-strip         Disable calling strip(1) on install],
2499         [
2500                 if test "x$enableval" = "xno" ; then
2501                         STRIP_OPT=
2502                 fi
2503         ]
2504 )
2505 AC_SUBST(STRIP_OPT)
2506
2507 if test -z "$xauth_path" ; then
2508         XAUTH_PATH="undefined"
2509         AC_SUBST(XAUTH_PATH)
2510 else
2511         AC_DEFINE_UNQUOTED(XAUTH_PATH, "$xauth_path")
2512         XAUTH_PATH=$xauth_path
2513         AC_SUBST(XAUTH_PATH)
2514 fi
2515
2516 # Check for mail directory (last resort if we cannot get it from headers)
2517 if test ! -z "$MAIL" ; then
2518         maildir=`dirname $MAIL`
2519         AC_DEFINE_UNQUOTED(MAIL_DIRECTORY, "$maildir")
2520 fi
2521
2522 if test ! -z "$cross_compiling" && test "x$cross_compiling" = "xyes"; then
2523         AC_MSG_WARN([cross compiling: Disabling /dev/ptmx test])
2524         disable_ptmx_check=yes
2525 fi
2526 if test -z "$no_dev_ptmx" ; then
2527         if test "x$disable_ptmx_check" != "xyes" ; then
2528                 AC_CHECK_FILE("/dev/ptmx",
2529                         [
2530                                 AC_DEFINE_UNQUOTED(HAVE_DEV_PTMX)
2531                                 have_dev_ptmx=1
2532                         ]
2533                 )
2534         fi
2535 fi
2536
2537 if test ! -z "$cross_compiling" && test "x$cross_compiling" != "xyes"; then
2538         AC_CHECK_FILE("/dev/ptc",
2539                 [
2540                         AC_DEFINE_UNQUOTED(HAVE_DEV_PTS_AND_PTC)
2541                         have_dev_ptc=1
2542                 ]
2543         )
2544 else
2545         AC_MSG_WARN([cross compiling: Disabling /dev/ptc test])
2546 fi
2547
2548 # Options from here on. Some of these are preset by platform above
2549 AC_ARG_WITH(mantype,
2550         [  --with-mantype=man|cat|doc  Set man page type],
2551         [
2552                 case "$withval" in
2553                 man|cat|doc)
2554                         MANTYPE=$withval
2555                         ;;
2556                 *)
2557                         AC_MSG_ERROR(invalid man type: $withval)
2558                         ;;
2559                 esac
2560         ]
2561 )
2562 if test -z "$MANTYPE"; then
2563         TestPath="/usr/bin${PATH_SEPARATOR}/usr/ucb"
2564         AC_PATH_PROGS(NROFF, nroff awf, /bin/false, $TestPath)
2565         if ${NROFF} -mdoc ${srcdir}/ssh.1 >/dev/null 2>&1; then
2566                 MANTYPE=doc
2567         elif ${NROFF} -man ${srcdir}/ssh.1 >/dev/null 2>&1; then
2568                 MANTYPE=man
2569         else
2570                 MANTYPE=cat
2571         fi
2572 fi
2573 AC_SUBST(MANTYPE)
2574 if test "$MANTYPE" = "doc"; then
2575         mansubdir=man;
2576 else
2577         mansubdir=$MANTYPE;
2578 fi
2579 AC_SUBST(mansubdir)
2580
2581 # Check whether to enable MD5 passwords
2582 MD5_MSG="no"
2583 AC_ARG_WITH(md5-passwords,
2584         [  --with-md5-passwords    Enable use of MD5 passwords],
2585         [
2586                 if test "x$withval" != "xno" ; then
2587                         AC_DEFINE(HAVE_MD5_PASSWORDS)
2588                         MD5_MSG="yes"
2589                 fi
2590         ]
2591 )
2592
2593 # Whether to disable shadow password support
2594 AC_ARG_WITH(shadow,
2595         [  --without-shadow        Disable shadow password support],
2596         [
2597                 if test "x$withval" = "xno" ; then      
2598                         AC_DEFINE(DISABLE_SHADOW)
2599                         disable_shadow=yes
2600                 fi
2601         ]
2602 )
2603
2604 if test -z "$disable_shadow" ; then
2605         AC_MSG_CHECKING([if the systems has expire shadow information])
2606         AC_TRY_COMPILE(
2607         [
2608 #include <sys/types.h>
2609 #include <shadow.h>
2610         struct spwd sp;
2611         ],[ sp.sp_expire = sp.sp_lstchg = sp.sp_inact = 0; ],
2612         [ sp_expire_available=yes ], []
2613         )
2614
2615         if test "x$sp_expire_available" = "xyes" ; then
2616                 AC_MSG_RESULT(yes)
2617                 AC_DEFINE(HAS_SHADOW_EXPIRE)
2618         else
2619                 AC_MSG_RESULT(no)
2620         fi
2621 fi
2622
2623 # Use ip address instead of hostname in $DISPLAY
2624 if test ! -z "$IPADDR_IN_DISPLAY" ; then
2625         DISPLAY_HACK_MSG="yes"
2626         AC_DEFINE(IPADDR_IN_DISPLAY)
2627 else
2628         DISPLAY_HACK_MSG="no"
2629         AC_ARG_WITH(ipaddr-display,
2630                 [  --with-ipaddr-display   Use ip address instead of hostname in \$DISPLAY],
2631                 [
2632                         if test "x$withval" != "xno" ; then     
2633                                 AC_DEFINE(IPADDR_IN_DISPLAY)
2634                                 DISPLAY_HACK_MSG="yes"
2635                         fi
2636                 ]
2637         )
2638 fi
2639
2640 # check for /etc/default/login and use it if present.
2641 AC_ARG_ENABLE(etc-default-login,
2642         [  --disable-etc-default-login Disable using PATH from /etc/default/login [no]],
2643         [ if test "x$enableval" = "xno"; then
2644                 AC_MSG_NOTICE([/etc/default/login handling disabled])
2645                 etc_default_login=no
2646           else
2647                 etc_default_login=yes
2648           fi ],
2649         [ etc_default_login=yes ]
2650 )
2651
2652 if test "x$etc_default_login" != "xno"; then
2653         AC_CHECK_FILE("/etc/default/login",
2654             [ external_path_file=/etc/default/login ])
2655         if test ! -z "$cross_compiling" && test "x$cross_compiling" = "xyes";
2656         then
2657                 AC_MSG_WARN([cross compiling: Disabling /etc/default/login test])
2658         elif test "x$external_path_file" = "x/etc/default/login"; then
2659                 AC_DEFINE(HAVE_ETC_DEFAULT_LOGIN)
2660         fi
2661 fi
2662
2663 dnl BSD systems use /etc/login.conf so --with-default-path= has no effect
2664 if test $ac_cv_func_login_getcapbool = "yes" -a \
2665         $ac_cv_header_login_cap_h = "yes" ; then
2666         external_path_file=/etc/login.conf
2667 fi
2668
2669 # Whether to mess with the default path
2670 SERVER_PATH_MSG="(default)"
2671 AC_ARG_WITH(default-path,
2672         [  --with-default-path=    Specify default \$PATH environment for server],
2673         [
2674                 if test "x$external_path_file" = "x/etc/login.conf" ; then
2675                         AC_MSG_WARN([
2676 --with-default-path=PATH has no effect on this system.
2677 Edit /etc/login.conf instead.])
2678                 elif test "x$withval" != "xno" ; then   
2679                         if test ! -z "$external_path_file" ; then
2680                                 AC_MSG_WARN([
2681 --with-default-path=PATH will only be used if PATH is not defined in
2682 $external_path_file .])
2683                         fi
2684                         user_path="$withval"
2685                         SERVER_PATH_MSG="$withval"
2686                 fi
2687         ],
2688         [ if test "x$external_path_file" = "x/etc/login.conf" ; then
2689                 AC_MSG_WARN([Make sure the path to scp is in /etc/login.conf])
2690         else
2691                 if test ! -z "$external_path_file" ; then
2692                         AC_MSG_WARN([
2693 If PATH is defined in $external_path_file, ensure the path to scp is included,
2694 otherwise scp will not work.])
2695                 fi
2696                 AC_TRY_RUN(
2697                         [
2698 /* find out what STDPATH is */
2699 #include <stdio.h>
2700 #ifdef HAVE_PATHS_H
2701 # include <paths.h>
2702 #endif
2703 #ifndef _PATH_STDPATH
2704 # ifdef _PATH_USERPATH  /* Irix */
2705 #  define _PATH_STDPATH _PATH_USERPATH
2706 # else
2707 #  define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
2708 # endif
2709 #endif
2710 #include <sys/types.h>
2711 #include <sys/stat.h>
2712 #include <fcntl.h>
2713 #define DATA "conftest.stdpath"
2714
2715 main()
2716 {
2717         FILE *fd;
2718         int rc;
2719         
2720         fd = fopen(DATA,"w");
2721         if(fd == NULL)
2722                 exit(1);
2723         
2724         if ((rc = fprintf(fd,"%s", _PATH_STDPATH)) < 0)
2725                 exit(1);
2726
2727         exit(0);
2728 }
2729                 ], [ user_path=`cat conftest.stdpath` ],
2730                 [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ],
2731                 [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ]
2732         )
2733 # make sure $bindir is in USER_PATH so scp will work
2734                 t_bindir=`eval echo ${bindir}`
2735                 case $t_bindir in
2736                         NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$prefix~"` ;;
2737                 esac
2738                 case $t_bindir in
2739                         NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$ac_default_prefix~"` ;;
2740                 esac
2741                 echo $user_path | grep ":$t_bindir"  > /dev/null 2>&1
2742                 if test $? -ne 0  ; then
2743                         echo $user_path | grep "^$t_bindir"  > /dev/null 2>&1
2744                         if test $? -ne 0  ; then
2745                                 user_path=$user_path:$t_bindir
2746                                 AC_MSG_RESULT(Adding $t_bindir to USER_PATH so scp will work)
2747                         fi
2748                 fi
2749         fi ]
2750 )
2751 if test "x$external_path_file" != "x/etc/login.conf" ; then
2752         AC_DEFINE_UNQUOTED(USER_PATH, "$user_path")
2753         AC_SUBST(user_path)
2754 fi
2755
2756 # Set superuser path separately to user path
2757 AC_ARG_WITH(superuser-path,
2758         [  --with-superuser-path=  Specify different path for super-user],
2759         [
2760                 if test "x$withval" != "xno" ; then
2761                         AC_DEFINE_UNQUOTED(SUPERUSER_PATH, "$withval")
2762                         superuser_path=$withval
2763                 fi
2764         ]
2765 )
2766
2767
2768 AC_MSG_CHECKING([if we need to convert IPv4 in IPv6-mapped addresses])
2769 IPV4_IN6_HACK_MSG="no"
2770 AC_ARG_WITH(4in6,
2771         [  --with-4in6             Check for and convert IPv4 in IPv6 mapped addresses],
2772         [
2773                 if test "x$withval" != "xno" ; then
2774                         AC_MSG_RESULT(yes)
2775                         AC_DEFINE(IPV4_IN_IPV6)
2776                         IPV4_IN6_HACK_MSG="yes"
2777                 else
2778                         AC_MSG_RESULT(no)
2779                 fi
2780         ],[
2781                 if test "x$inet6_default_4in6" = "xyes"; then
2782                         AC_MSG_RESULT([yes (default)])
2783                         AC_DEFINE(IPV4_IN_IPV6)
2784                         IPV4_IN6_HACK_MSG="yes"
2785                 else
2786                         AC_MSG_RESULT([no (default)])
2787                 fi
2788         ]
2789 )
2790
2791 # Whether to enable BSD auth support
2792 BSD_AUTH_MSG=no
2793 AC_ARG_WITH(bsd-auth,
2794         [  --with-bsd-auth         Enable BSD auth support],
2795         [
2796                 if test "x$withval" != "xno" ; then     
2797                         AC_DEFINE(BSD_AUTH)
2798                         BSD_AUTH_MSG=yes
2799                 fi
2800         ]
2801 )
2802
2803 # Where to place sshd.pid
2804 piddir=/var/run
2805 # make sure the directory exists
2806 if test ! -d $piddir ; then     
2807         piddir=`eval echo ${sysconfdir}`
2808         case $piddir in
2809                 NONE/*) piddir=`echo $piddir | sed "s~NONE~$ac_default_prefix~"` ;;
2810         esac
2811 fi
2812
2813 AC_ARG_WITH(pid-dir,
2814         [  --with-pid-dir=PATH     Specify location of ssh.pid file],
2815         [
2816                 if test "x$withval" != "xno" ; then     
2817                         piddir=$withval
2818                         if test ! -d $piddir ; then     
2819                         AC_MSG_WARN([** no $piddir directory on this system **])
2820                         fi
2821                 fi
2822         ]
2823 )
2824
2825 AC_DEFINE_UNQUOTED(_PATH_SSH_PIDDIR, "$piddir")
2826 AC_SUBST(piddir)
2827
2828 dnl allow user to disable some login recording features
2829 AC_ARG_ENABLE(lastlog,
2830         [  --disable-lastlog       disable use of lastlog even if detected [no]],
2831         [
2832                 if test "x$enableval" = "xno" ; then
2833                         AC_DEFINE(DISABLE_LASTLOG)
2834                 fi
2835         ]
2836 )
2837 AC_ARG_ENABLE(utmp,
2838         [  --disable-utmp          disable use of utmp even if detected [no]],
2839         [
2840                 if test "x$enableval" = "xno" ; then
2841                         AC_DEFINE(DISABLE_UTMP)
2842                 fi
2843         ]
2844 )
2845 AC_ARG_ENABLE(utmpx,
2846         [  --disable-utmpx         disable use of utmpx even if detected [no]],
2847         [
2848                 if test "x$enableval" = "xno" ; then
2849                         AC_DEFINE(DISABLE_UTMPX)
2850                 fi
2851         ]
2852 )
2853 AC_ARG_ENABLE(wtmp,
2854         [  --disable-wtmp          disable use of wtmp even if detected [no]],
2855         [
2856                 if test "x$enableval" = "xno" ; then
2857                         AC_DEFINE(DISABLE_WTMP)
2858                 fi
2859         ]
2860 )
2861 AC_ARG_ENABLE(wtmpx,
2862         [  --disable-wtmpx         disable use of wtmpx even if detected [no]],
2863         [
2864                 if test "x$enableval" = "xno" ; then
2865                         AC_DEFINE(DISABLE_WTMPX)
2866                 fi
2867         ]
2868 )
2869 AC_ARG_ENABLE(libutil,
2870         [  --disable-libutil       disable use of libutil (login() etc.) [no]],
2871         [
2872                 if test "x$enableval" = "xno" ; then
2873                         AC_DEFINE(DISABLE_LOGIN)
2874                 fi
2875         ]
2876 )
2877 AC_ARG_ENABLE(pututline,
2878         [  --disable-pututline     disable use of pututline() etc. ([uw]tmp) [no]],
2879         [
2880                 if test "x$enableval" = "xno" ; then
2881                         AC_DEFINE(DISABLE_PUTUTLINE)
2882                 fi
2883         ]
2884 )
2885 AC_ARG_ENABLE(pututxline,
2886         [  --disable-pututxline    disable use of pututxline() etc. ([uw]tmpx) [no]],
2887         [
2888                 if test "x$enableval" = "xno" ; then
2889                         AC_DEFINE(DISABLE_PUTUTXLINE)
2890                 fi
2891         ]
2892 )
2893 AC_ARG_WITH(lastlog,
2894   [  --with-lastlog=FILE|DIR specify lastlog location [common locations]],
2895         [
2896                 if test "x$withval" = "xno" ; then      
2897                         AC_DEFINE(DISABLE_LASTLOG)
2898                 else
2899                         conf_lastlog_location=$withval
2900                 fi
2901         ]
2902 )
2903
2904 dnl lastlog, [uw]tmpx? detection
2905 dnl  NOTE: set the paths in the platform section to avoid the
2906 dnl   need for command-line parameters
2907 dnl lastlog and [uw]tmp are subject to a file search if all else fails
2908
2909 dnl lastlog detection
2910 dnl  NOTE: the code itself will detect if lastlog is a directory
2911 AC_MSG_CHECKING([if your system defines LASTLOG_FILE])
2912 AC_TRY_COMPILE([
2913 #include <sys/types.h>
2914 #include <utmp.h>
2915 #ifdef HAVE_LASTLOG_H
2916 #  include <lastlog.h>
2917 #endif
2918 #ifdef HAVE_PATHS_H
2919 #  include <paths.h>
2920 #endif
2921 #ifdef HAVE_LOGIN_H
2922 # include <login.h>
2923 #endif
2924         ],
2925         [ char *lastlog = LASTLOG_FILE; ],
2926         [ AC_MSG_RESULT(yes) ],
2927         [
2928                 AC_MSG_RESULT(no)
2929                 AC_MSG_CHECKING([if your system defines _PATH_LASTLOG])
2930                 AC_TRY_COMPILE([
2931 #include <sys/types.h>
2932 #include <utmp.h>
2933 #ifdef HAVE_LASTLOG_H
2934 #  include <lastlog.h>
2935 #endif
2936 #ifdef HAVE_PATHS_H
2937 #  include <paths.h>
2938 #endif
2939                 ],
2940                 [ char *lastlog = _PATH_LASTLOG; ],
2941                 [ AC_MSG_RESULT(yes) ],
2942                 [
2943                         AC_MSG_RESULT(no)
2944                         system_lastlog_path=no
2945                 ])
2946         ]
2947 )
2948
2949 if test -z "$conf_lastlog_location"; then
2950         if test x"$system_lastlog_path" = x"no" ; then
2951                 for f in /var/log/lastlog /usr/adm/lastlog /var/adm/lastlog /etc/security/lastlog ; do
2952                                 if (test -d "$f" || test -f "$f") ; then
2953                                         conf_lastlog_location=$f
2954                                 fi
2955                 done
2956                 if test -z "$conf_lastlog_location"; then
2957                         AC_MSG_WARN([** Cannot find lastlog **])
2958                         dnl Don't define DISABLE_LASTLOG - that means we don't try wtmp/wtmpx
2959                 fi
2960         fi
2961 fi
2962
2963 if test -n "$conf_lastlog_location"; then
2964         AC_DEFINE_UNQUOTED(CONF_LASTLOG_FILE, "$conf_lastlog_location")
2965 fi      
2966
2967 dnl utmp detection
2968 AC_MSG_CHECKING([if your system defines UTMP_FILE])
2969 AC_TRY_COMPILE([
2970 #include <sys/types.h>
2971 #include <utmp.h>
2972 #ifdef HAVE_PATHS_H
2973 #  include <paths.h>
2974 #endif
2975         ],
2976         [ char *utmp = UTMP_FILE; ],
2977         [ AC_MSG_RESULT(yes) ],
2978         [ AC_MSG_RESULT(no)
2979           system_utmp_path=no ]
2980 )
2981 if test -z "$conf_utmp_location"; then
2982         if test x"$system_utmp_path" = x"no" ; then
2983                 for f in /etc/utmp /usr/adm/utmp /var/run/utmp; do
2984                         if test -f $f ; then
2985                                 conf_utmp_location=$f
2986                         fi
2987                 done
2988                 if test -z "$conf_utmp_location"; then
2989                         AC_DEFINE(DISABLE_UTMP)
2990                 fi
2991         fi
2992 fi
2993 if test -n "$conf_utmp_location"; then
2994         AC_DEFINE_UNQUOTED(CONF_UTMP_FILE, "$conf_utmp_location")
2995 fi      
2996
2997 dnl wtmp detection
2998 AC_MSG_CHECKING([if your system defines WTMP_FILE])
2999 AC_TRY_COMPILE([
3000 #include <sys/types.h>
3001 #include <utmp.h>
3002 #ifdef HAVE_PATHS_H
3003 #  include <paths.h>
3004 #endif
3005         ],
3006         [ char *wtmp = WTMP_FILE; ],
3007         [ AC_MSG_RESULT(yes) ],
3008         [ AC_MSG_RESULT(no)
3009           system_wtmp_path=no ]
3010 )
3011 if test -z "$conf_wtmp_location"; then
3012         if test x"$system_wtmp_path" = x"no" ; then
3013                 for f in /usr/adm/wtmp /var/log/wtmp; do
3014                         if test -f $f ; then
3015                                 conf_wtmp_location=$f
3016                         fi
3017                 done
3018                 if test -z "$conf_wtmp_location"; then
3019                         AC_DEFINE(DISABLE_WTMP)
3020                 fi
3021         fi
3022 fi
3023 if test -n "$conf_wtmp_location"; then
3024         AC_DEFINE_UNQUOTED(CONF_WTMP_FILE, "$conf_wtmp_location")
3025 fi      
3026
3027
3028 dnl utmpx detection - I don't know any system so perverse as to require
3029 dnl  utmpx, but not define UTMPX_FILE (ditto wtmpx.) No doubt it's out
3030 dnl  there, though.
3031 AC_MSG_CHECKING([if your system defines UTMPX_FILE])
3032 AC_TRY_COMPILE([
3033 #include <sys/types.h>
3034 #include <utmp.h>
3035 #ifdef HAVE_UTMPX_H
3036 #include <utmpx.h>
3037 #endif
3038 #ifdef HAVE_PATHS_H
3039 #  include <paths.h>
3040 #endif
3041         ],
3042         [ char *utmpx = UTMPX_FILE; ],
3043         [ AC_MSG_RESULT(yes) ],
3044         [ AC_MSG_RESULT(no)
3045           system_utmpx_path=no ]
3046 )
3047 if test -z "$conf_utmpx_location"; then
3048         if test x"$system_utmpx_path" = x"no" ; then
3049                 AC_DEFINE(DISABLE_UTMPX)
3050         fi
3051 else
3052         AC_DEFINE_UNQUOTED(CONF_UTMPX_FILE, "$conf_utmpx_location")
3053 fi      
3054
3055 dnl wtmpx detection
3056 AC_MSG_CHECKING([if your system defines WTMPX_FILE])
3057 AC_TRY_COMPILE([
3058 #include <sys/types.h>
3059 #include <utmp.h>
3060 #ifdef HAVE_UTMPX_H
3061 #include <utmpx.h>
3062 #endif
3063 #ifdef HAVE_PATHS_H
3064 #  include <paths.h>
3065 #endif
3066         ],
3067         [ char *wtmpx = WTMPX_FILE; ],
3068         [ AC_MSG_RESULT(yes) ],
3069         [ AC_MSG_RESULT(no)
3070           system_wtmpx_path=no ]
3071 )
3072 if test -z "$conf_wtmpx_location"; then
3073         if test x"$system_wtmpx_path" = x"no" ; then
3074                 AC_DEFINE(DISABLE_WTMPX)
3075         fi
3076 else
3077         AC_DEFINE_UNQUOTED(CONF_WTMPX_FILE, "$conf_wtmpx_location")
3078 fi      
3079
3080
3081 if test ! -z "$blibpath" ; then
3082         LDFLAGS="$LDFLAGS $blibflags$blibpath"
3083         AC_MSG_WARN([Please check and edit blibpath in LDFLAGS in Makefile])
3084 fi
3085
3086 dnl remove pam and dl because they are in $LIBPAM
3087 if test "$PAM_MSG" = yes ; then
3088         LIBS=`echo $LIBS | sed 's/-lpam //'`
3089 fi
3090 if test "$ac_cv_lib_pam_pam_set_item" = yes ; then
3091         LIBS=`echo $LIBS | sed 's/-ldl //'`
3092 fi
3093
3094 AC_EXEEXT
3095 AC_CONFIG_FILES([Makefile buildpkg.sh opensshd.init openbsd-compat/Makefile \
3096         scard/Makefile ssh_prng_cmds survey.sh])
3097 AC_OUTPUT
3098
3099 # Print summary of options
3100
3101 # Someone please show me a better way :)
3102 A=`eval echo ${prefix}` ; A=`eval echo ${A}`
3103 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
3104 C=`eval echo ${sbindir}` ; C=`eval echo ${C}`
3105 D=`eval echo ${sysconfdir}` ; D=`eval echo ${D}`
3106 E=`eval echo ${libexecdir}/ssh-askpass` ; E=`eval echo ${E}`
3107 F=`eval echo ${mandir}/${mansubdir}X` ; F=`eval echo ${F}`
3108 G=`eval echo ${piddir}` ; G=`eval echo ${G}`
3109 H=`eval echo ${PRIVSEP_PATH}` ; H=`eval echo ${H}`
3110 I=`eval echo ${user_path}` ; I=`eval echo ${I}`
3111 J=`eval echo ${superuser_path}` ; J=`eval echo ${J}`
3112
3113 echo ""
3114 echo "OpenSSH has been configured with the following options:"
3115 echo "                     User binaries: $B"
3116 echo "                   System binaries: $C"
3117 echo "               Configuration files: $D"
3118 echo "                   Askpass program: $E"
3119 echo "                      Manual pages: $F"
3120 echo "                          PID file: $G"
3121 echo "  Privilege separation chroot path: $H"
3122 if test "x$external_path_file" = "x/etc/login.conf" ; then
3123 echo "   At runtime, sshd will use the path defined in $external_path_file"
3124 echo "   Make sure the path to scp is present, otherwise scp will not work"
3125 else
3126 echo "            sshd default user PATH: $I"
3127         if test ! -z "$external_path_file"; then
3128 echo "   (If PATH is set in $external_path_file it will be used instead. If"
3129 echo "   used, ensure the path to scp is present, otherwise scp will not work.)"
3130         fi
3131 fi
3132 if test ! -z "$superuser_path" ; then
3133 echo "          sshd superuser user PATH: $J"
3134 fi
3135 echo "                    Manpage format: $MANTYPE"
3136 echo "                       PAM support: $PAM_MSG"
3137 echo "                 KerberosV support: $KRB5_MSG"
3138 echo "                 Smartcard support: $SCARD_MSG"
3139 echo "                     S/KEY support: $SKEY_MSG"
3140 echo "              TCP Wrappers support: $TCPW_MSG"
3141 echo "              MD5 password support: $MD5_MSG"
3142 echo "                   libedit support: $LIBEDIT_MSG"
3143 echo "       IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG"
3144 echo "           Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG"
3145 echo "                  BSD Auth support: $BSD_AUTH_MSG"
3146 echo "              Random number source: $RAND_MSG"
3147 if test ! -z "$USE_RAND_HELPER" ; then
3148 echo "     ssh-rand-helper collects from: $RAND_HELPER_MSG"
3149 fi
3150
3151 echo ""
3152
3153 echo "              Host: ${host}"
3154 echo "          Compiler: ${CC}"
3155 echo "    Compiler flags: ${CFLAGS}"
3156 echo "Preprocessor flags: ${CPPFLAGS}"
3157 echo "      Linker flags: ${LDFLAGS}"
3158 echo "         Libraries: ${LIBWRAP} ${LIBPAM} ${LIBS}"
3159
3160 echo ""
3161
3162 if test "x$MAKE_PACKAGE_SUPPORTED" = "xyes" ; then
3163         echo "SVR4 style packages are supported with \"make package\""
3164         echo ""
3165 fi
3166
3167 if test "x$PAM_MSG" = "xyes" ; then
3168         echo "PAM is enabled. You may need to install a PAM control file "
3169         echo "for sshd, otherwise password authentication may fail. "
3170         echo "Example PAM control files can be found in the contrib/ "
3171         echo "subdirectory"
3172         echo ""
3173 fi
3174
3175 if test ! -z "$RAND_HELPER_CMDHASH" ; then
3176         echo "WARNING: you are using the builtin random number collection "
3177         echo "service. Please read WARNING.RNG and request that your OS "
3178         echo "vendor includes kernel-based random number collection in "
3179         echo "future versions of your OS."
3180         echo ""
3181 fi
3182
3183 if test ! -z "$NO_PEERCHECK" ; then
3184         echo "WARNING: the operating system that you are using does not "
3185         echo "appear to support either the getpeereid() API nor the "
3186         echo "SO_PEERCRED getsockopt() option. These facilities are used to "
3187         echo "enforce security checks to prevent unauthorised connections to "
3188         echo "ssh-agent. Their absence increases the risk that a malicious "
3189         echo "user can connect to your agent. "
3190         echo ""
3191 fi
3192
This page took 0.345549 seconds and 5 git commands to generate.