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