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