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