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