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