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