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