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