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