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