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