]> andersk Git - openssh.git/blob - configure.ac
fae6fdea9b1cd4c525ad2b2d17103c3a5bb6d453
[openssh.git] / configure.ac
1 # $Id$
2 #
3 # Copyright (c) 1999-2004 Damien Miller
4 #
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
8 #
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
17 AC_INIT(OpenSSH, Portable, openssh-unix-dev@mindrot.org)
18 AC_CONFIG_SRCDIR([ssh.c])
19
20 AC_CONFIG_HEADER(config.h)
21 AC_PROG_CC
22 AC_CANONICAL_HOST
23 AC_C_BIGENDIAN
24
25 # Checks for programs.
26 AC_PROG_AWK
27 AC_PROG_CPP
28 AC_PROG_RANLIB
29 AC_PROG_INSTALL
30 AC_PATH_PROG(AR, ar)
31 AC_PATH_PROG(CAT, cat)
32 AC_PATH_PROG(KILL, kill)
33 AC_PATH_PROGS(PERL, perl5 perl)
34 AC_PATH_PROG(SED, sed)
35 AC_SUBST(PERL)
36 AC_PATH_PROG(ENT, ent)
37 AC_SUBST(ENT)
38 AC_PATH_PROG(TEST_MINUS_S_SH, bash)
39 AC_PATH_PROG(TEST_MINUS_S_SH, ksh)
40 AC_PATH_PROG(TEST_MINUS_S_SH, sh)
41 AC_PATH_PROG(SH, sh)
42 AC_SUBST(TEST_SHELL,sh)
43
44 dnl for buildpkg.sh
45 AC_PATH_PROG(PATH_GROUPADD_PROG, groupadd, groupadd,
46         [/usr/sbin${PATH_SEPARATOR}/etc])
47 AC_PATH_PROG(PATH_USERADD_PROG, useradd, useradd,
48         [/usr/sbin${PATH_SEPARATOR}/etc])
49 AC_CHECK_PROG(MAKE_PACKAGE_SUPPORTED, pkgmk, yes, no)
50
51 # System features
52 AC_SYS_LARGEFILE
53
54 if test -z "$AR" ; then
55         AC_MSG_ERROR([*** 'ar' missing, please install or fix your \$PATH ***])
56 fi
57
58 # Use LOGIN_PROGRAM from environment if possible
59 if test ! -z "$LOGIN_PROGRAM" ; then
60         AC_DEFINE_UNQUOTED(LOGIN_PROGRAM_FALLBACK, "$LOGIN_PROGRAM")
61 else
62         # Search for login
63         AC_PATH_PROG(LOGIN_PROGRAM_FALLBACK, login)
64         if test ! -z "$LOGIN_PROGRAM_FALLBACK" ; then
65                 AC_DEFINE_UNQUOTED(LOGIN_PROGRAM_FALLBACK, "$LOGIN_PROGRAM_FALLBACK")
66         fi
67 fi
68
69 AC_PATH_PROG(PATH_PASSWD_PROG, passwd)
70 if test ! -z "$PATH_PASSWD_PROG" ; then
71         AC_DEFINE_UNQUOTED(_PATH_PASSWD_PROG, "$PATH_PASSWD_PROG")
72 fi
73
74 if test -z "$LD" ; then
75         LD=$CC
76 fi
77 AC_SUBST(LD)
78
79 AC_C_INLINE
80
81 AC_CHECK_DECL(LLONG_MAX, have_llong_max=1, , [#include <limits.h>])
82
83 if test "$GCC" = "yes" || test "$GCC" = "egcs"; then
84         CFLAGS="$CFLAGS -Wall -Wpointer-arith -Wno-uninitialized"
85
86         if test -z "$have_llong_max"; then
87                 # retry LLONG_MAX with -std=gnu99, needed on some Linuxes
88                 unset ac_cv_have_decl_LLONG_MAX
89                 saved_CFLAGS="$CFLAGS"
90                 CFLAGS="$CFLAGS -std=gnu99"
91                 AC_CHECK_DECL(LLONG_MAX,
92                     [have_llong_max=1],
93                     [CFLAGS="$saved_CFLAGS"],
94                     [#include <limits.h>]
95                 )
96         fi
97 fi
98
99 if test -z "$have_llong_max"; then
100         AC_MSG_CHECKING([for max value of long long])
101         AC_RUN_IFELSE(
102                 [AC_LANG_SOURCE([[
103 #include <stdio.h>
104 /* Why is this so damn hard? */
105 #ifdef __GNUC__
106 # undef __GNUC__
107 #endif
108 #define __USE_ISOC99
109 #include <limits.h>
110 #define DATA "conftest.llminmax"
111 int main(void) {
112         FILE *f;
113         long long i, llmin, llmax = 0;
114
115         if((f = fopen(DATA,"w")) == NULL)
116                 exit(1);
117
118 #if defined(LLONG_MIN) && defined(LLONG_MAX)
119         fprintf(stderr, "Using system header for LLONG_MIN and LLONG_MAX\n");
120         llmin = LLONG_MIN;
121         llmax = LLONG_MAX;
122 #else
123         fprintf(stderr, "Calculating  LLONG_MIN and LLONG_MAX\n");
124         /* This will work on one's complement and two's complement */
125         for (i = 1; i > llmax; i <<= 1, i++)
126                 llmax = i;
127         llmin = llmax + 1LL;    /* wrap */
128 #endif
129
130         /* Sanity check */
131         if (llmin + 1 < llmin || llmin - 1 < llmin || llmax + 1 > llmax
132             || llmax - 1 > llmax) {
133                 fprintf(f, "unknown unknown\n");
134                 exit(2);
135         }
136
137         if (fprintf(f ,"%lld %lld", llmin, llmax) < 0)
138                 exit(3);
139
140         exit(0);
141 }
142                 ]])],
143                 [
144                         llong_min=`$AWK '{print $1}' conftest.llminmax`
145                         llong_max=`$AWK '{print $2}' conftest.llminmax`
146                         AC_MSG_RESULT($llong_max)
147                         AC_DEFINE_UNQUOTED(LLONG_MAX, [${llong_max}LL],
148                             [max value of long long calculated by configure])
149                         AC_MSG_CHECKING([for min value of long long])
150                         AC_MSG_RESULT($llong_min)
151                         AC_DEFINE_UNQUOTED(LLONG_MIN, [${llong_min}LL],
152                             [min value of long long calculated by configure])
153                 ],
154                 [
155                         AC_MSG_RESULT(not found)
156                 ],
157                 [
158                         AC_MSG_WARN([cross compiling: not checking])
159                 ]
160         )
161 fi
162
163 AC_ARG_WITH(rpath,
164         [  --without-rpath         Disable auto-added -R linker paths],
165         [
166                 if test "x$withval" = "xno" ; then
167                         need_dash_r=""
168                 fi
169                 if test "x$withval" = "xyes" ; then
170                         need_dash_r=1
171                 fi
172         ]
173 )
174
175 # Check for some target-specific stuff
176 case "$host" in
177 *-*-aix*)
178         AC_MSG_CHECKING([how to specify blibpath for linker ($LD)])
179         if (test -z "$blibpath"); then
180                 blibpath="/usr/lib:/lib"
181         fi
182         saved_LDFLAGS="$LDFLAGS"
183         for tryflags in -blibpath: -Wl,-blibpath: -Wl,-rpath, ;do
184                 if (test -z "$blibflags"); then
185                         LDFLAGS="$saved_LDFLAGS $tryflags$blibpath"
186                         AC_TRY_LINK([], [], [blibflags=$tryflags])
187                 fi
188         done
189         if (test -z "$blibflags"); then
190                 AC_MSG_RESULT(not found)
191                 AC_MSG_ERROR([*** must be able to specify blibpath on AIX - check config.log])
192         else
193                 AC_MSG_RESULT($blibflags)
194         fi
195         LDFLAGS="$saved_LDFLAGS"
196         dnl Check for authenticate.  Might be in libs.a on older AIXes
197         AC_CHECK_FUNC(authenticate, [AC_DEFINE(WITH_AIXAUTHENTICATE)],
198                 [AC_CHECK_LIB(s,authenticate,
199                         [ AC_DEFINE(WITH_AIXAUTHENTICATE)
200                                 LIBS="$LIBS -ls"
201                         ])
202                 ])
203         dnl Check for various auth function declarations in headers.
204         AC_CHECK_DECLS([authenticate, loginrestrictions, loginsuccess,
205             passwdexpired, setauthdb], , , [#include <usersec.h>])
206         dnl Check if loginfailed is declared and takes 4 arguments (AIX >= 5.2)
207         AC_CHECK_DECLS(loginfailed,
208                  [AC_MSG_CHECKING(if loginfailed takes 4 arguments)
209                   AC_TRY_COMPILE(
210                         [#include <usersec.h>],
211                         [(void)loginfailed("user","host","tty",0);],
212                         [AC_MSG_RESULT(yes)
213                          AC_DEFINE(AIX_LOGINFAILED_4ARG)],
214                         [AC_MSG_RESULT(no)]
215                 )],
216                 [],
217                 [#include <usersec.h>]
218         )
219         AC_CHECK_FUNCS(setauthdb)
220         check_for_aix_broken_getaddrinfo=1
221         AC_DEFINE(BROKEN_REALPATH)
222         AC_DEFINE(SETEUID_BREAKS_SETUID)
223         AC_DEFINE(BROKEN_SETREUID)
224         AC_DEFINE(BROKEN_SETREGID)
225         dnl AIX handles lastlog as part of its login message
226         AC_DEFINE(DISABLE_LASTLOG)
227         AC_DEFINE(LOGIN_NEEDS_UTMPX)
228         AC_DEFINE(SPT_TYPE,SPT_REUSEARGV)
229         ;;
230 *-*-cygwin*)
231         check_for_libcrypt_later=1
232         LIBS="$LIBS /usr/lib/textmode.o"
233         AC_DEFINE(HAVE_CYGWIN)
234         AC_DEFINE(USE_PIPES)
235         AC_DEFINE(DISABLE_SHADOW)
236         AC_DEFINE(IP_TOS_IS_BROKEN)
237         AC_DEFINE(NO_X11_UNIX_SOCKETS)
238         AC_DEFINE(NO_IPPORT_RESERVED_CONCEPT)
239         AC_DEFINE(DISABLE_FD_PASSING)
240         ;;
241 *-*-dgux*)
242         AC_DEFINE(IP_TOS_IS_BROKEN)
243         AC_DEFINE(SETEUID_BREAKS_SETUID)
244         AC_DEFINE(BROKEN_SETREUID)
245         AC_DEFINE(BROKEN_SETREGID)
246         ;;
247 *-*-darwin*)
248         AC_MSG_CHECKING(if we have working getaddrinfo)
249         AC_TRY_RUN([#include <mach-o/dyld.h>
250 main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
251                 exit(0);
252         else
253                 exit(1);
254 }], [AC_MSG_RESULT(working)],
255         [AC_MSG_RESULT(buggy)
256         AC_DEFINE(BROKEN_GETADDRINFO)],
257         [AC_MSG_RESULT(assume it is working)])
258         AC_DEFINE(SETEUID_BREAKS_SETUID)
259         AC_DEFINE(BROKEN_SETREUID)
260         AC_DEFINE(BROKEN_SETREGID)
261         AC_DEFINE_UNQUOTED(BIND_8_COMPAT, 1)
262         ;;
263 *-*-hpux*)
264         # first we define all of the options common to all HP-UX releases
265         CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
266         IPADDR_IN_DISPLAY=yes
267         AC_DEFINE(USE_PIPES)
268         AC_DEFINE(LOGIN_NO_ENDOPT)
269         AC_DEFINE(LOGIN_NEEDS_UTMPX)
270         AC_DEFINE(LOCKED_PASSWD_STRING, "*")
271         AC_DEFINE(SPT_TYPE,SPT_PSTAT)
272         LIBS="$LIBS -lsec"
273         AC_CHECK_LIB(xnet, t_error, ,
274             AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***]))
275
276         # next, we define all of the options specific to major releases
277         case "$host" in
278         *-*-hpux10*)
279                 if test -z "$GCC"; then
280                         CFLAGS="$CFLAGS -Ae"
281                 fi
282                 ;;
283         *-*-hpux11*)
284                 AC_DEFINE(PAM_SUN_CODEBASE)
285                 AC_DEFINE(DISABLE_UTMP)
286                 AC_DEFINE(USE_BTMP, 1, [Use btmp to log bad logins])
287                 check_for_hpux_broken_getaddrinfo=1
288                 check_for_conflicting_getspnam=1
289                 ;;
290         esac
291
292         # lastly, we define options specific to minor releases
293         case "$host" in
294         *-*-hpux10.26)
295                 AC_DEFINE(HAVE_SECUREWARE)
296                 disable_ptmx_check=yes
297                 LIBS="$LIBS -lsecpw"
298                 ;;
299         esac
300         ;;
301 *-*-irix5*)
302         PATH="$PATH:/usr/etc"
303         AC_DEFINE(BROKEN_INET_NTOA)
304         AC_DEFINE(SETEUID_BREAKS_SETUID)
305         AC_DEFINE(BROKEN_SETREUID)
306         AC_DEFINE(BROKEN_SETREGID)
307         AC_DEFINE(WITH_ABBREV_NO_TTY)
308         AC_DEFINE(LOCKED_PASSWD_STRING, "*LK*")
309         ;;
310 *-*-irix6*)
311         PATH="$PATH:/usr/etc"
312         AC_DEFINE(WITH_IRIX_ARRAY)
313         AC_DEFINE(WITH_IRIX_PROJECT)
314         AC_DEFINE(WITH_IRIX_AUDIT)
315         AC_CHECK_FUNC(jlimit_startjob, [AC_DEFINE(WITH_IRIX_JOBS)])
316         AC_DEFINE(BROKEN_INET_NTOA)
317         AC_DEFINE(SETEUID_BREAKS_SETUID)
318         AC_DEFINE(BROKEN_SETREUID)
319         AC_DEFINE(BROKEN_SETREGID)
320         AC_DEFINE(BROKEN_UPDWTMPX)
321         AC_DEFINE(WITH_ABBREV_NO_TTY)
322         AC_DEFINE(LOCKED_PASSWD_STRING, "*LK*")
323         ;;
324 *-*-linux*)
325         no_dev_ptmx=1
326         check_for_libcrypt_later=1
327         check_for_openpty_ctty_bug=1
328         AC_DEFINE(DONT_TRY_OTHER_AF)
329         AC_DEFINE(PAM_TTY_KLUDGE)
330         AC_DEFINE(LOCKED_PASSWD_PREFIX, "!")
331         AC_DEFINE(SPT_TYPE,SPT_REUSEARGV)
332         AC_DEFINE(LINK_OPNOTSUPP_ERRNO, EPERM)
333         AC_DEFINE(_PATH_BTMP, "/var/log/btmp", [log for bad login attempts])
334         AC_DEFINE(USE_BTMP, 1, [Use btmp to log bad logins])
335         inet6_default_4in6=yes
336         case `uname -r` in
337         1.*|2.0.*)
338                 AC_DEFINE(BROKEN_CMSG_TYPE)
339                 ;;
340         esac
341         ;;
342 mips-sony-bsd|mips-sony-newsos4)
343         AC_DEFINE(NEED_SETPRGP, [], [Need setpgrp to acquire controlling tty])
344         SONY=1
345         ;;
346 *-*-netbsd*)
347         check_for_libcrypt_before=1
348         if test "x$withval" != "xno" ; then
349                 need_dash_r=1
350         fi
351         ;;
352 *-*-freebsd*)
353         check_for_libcrypt_later=1
354         ;;
355 *-*-bsdi*)
356         AC_DEFINE(SETEUID_BREAKS_SETUID)
357         AC_DEFINE(BROKEN_SETREUID)
358         AC_DEFINE(BROKEN_SETREGID)
359         ;;
360 *-next-*)
361         conf_lastlog_location="/usr/adm/lastlog"
362         conf_utmp_location=/etc/utmp
363         conf_wtmp_location=/usr/adm/wtmp
364         MAIL=/usr/spool/mail
365         AC_DEFINE(HAVE_NEXT)
366         AC_DEFINE(BROKEN_REALPATH)
367         AC_DEFINE(USE_PIPES)
368         AC_DEFINE(BROKEN_SAVED_UIDS)
369         ;;
370 *-*-solaris*)
371         if test "x$withval" != "xno" ; then
372                 need_dash_r=1
373         fi
374         AC_DEFINE(PAM_SUN_CODEBASE)
375         AC_DEFINE(LOGIN_NEEDS_UTMPX)
376         AC_DEFINE(LOGIN_NEEDS_TERM)
377         AC_DEFINE(PAM_TTY_KLUDGE)
378         AC_DEFINE(SSHPAM_CHAUTHTOK_NEEDS_RUID)
379         AC_DEFINE(LOCKED_PASSWD_STRING, "*LK*")
380         # Pushing STREAMS modules will cause sshd to acquire a controlling tty.
381         AC_DEFINE(SSHD_ACQUIRES_CTTY)
382         external_path_file=/etc/default/login
383         # hardwire lastlog location (can't detect it on some versions)
384         conf_lastlog_location="/var/adm/lastlog"
385         AC_MSG_CHECKING(for obsolete utmp and wtmp in solaris2.x)
386         sol2ver=`echo "$host"| sed -e 's/.*[[0-9]]\.//'`
387         if test "$sol2ver" -ge 8; then
388                 AC_MSG_RESULT(yes)
389                 AC_DEFINE(DISABLE_UTMP)
390                 AC_DEFINE(DISABLE_WTMP)
391         else
392                 AC_MSG_RESULT(no)
393         fi
394         ;;
395 *-*-sunos4*)
396         CPPFLAGS="$CPPFLAGS -DSUNOS4"
397         AC_CHECK_FUNCS(getpwanam)
398         AC_DEFINE(PAM_SUN_CODEBASE)
399         conf_utmp_location=/etc/utmp
400         conf_wtmp_location=/var/adm/wtmp
401         conf_lastlog_location=/var/adm/lastlog
402         AC_DEFINE(USE_PIPES)
403         ;;
404 *-ncr-sysv*)
405         LIBS="$LIBS -lc89"
406         AC_DEFINE(USE_PIPES)
407         AC_DEFINE(SSHD_ACQUIRES_CTTY)
408         AC_DEFINE(SETEUID_BREAKS_SETUID)
409         AC_DEFINE(BROKEN_SETREUID)
410         AC_DEFINE(BROKEN_SETREGID)
411         ;;
412 *-sni-sysv*)
413         # /usr/ucblib MUST NOT be searched on ReliantUNIX
414         AC_CHECK_LIB(dl, dlsym, ,)
415         # -lresolv needs to be at then end of LIBS or DNS lookups break
416         AC_CHECK_LIB(res_query, resolv, [ LIBS="$LIBS -lresolv" ])
417         IPADDR_IN_DISPLAY=yes
418         AC_DEFINE(USE_PIPES)
419         AC_DEFINE(IP_TOS_IS_BROKEN)
420         AC_DEFINE(SETEUID_BREAKS_SETUID)
421         AC_DEFINE(BROKEN_SETREUID)
422         AC_DEFINE(BROKEN_SETREGID)
423         AC_DEFINE(SSHD_ACQUIRES_CTTY)
424         external_path_file=/etc/default/login
425         # /usr/ucblib/libucb.a no longer needed on ReliantUNIX
426         # Attention: always take care to bind libsocket and libnsl before libc,
427         # otherwise you will find lots of "SIOCGPGRP errno 22" on syslog
428         ;;
429 # UnixWare 1.x, UnixWare 2.x, and others based on code from Univel.
430 *-*-sysv4.2*)
431         AC_DEFINE(USE_PIPES)
432         AC_DEFINE(SETEUID_BREAKS_SETUID)
433         AC_DEFINE(BROKEN_SETREUID)
434         AC_DEFINE(BROKEN_SETREGID)
435         AC_DEFINE(PASSWD_NEEDS_USERNAME, 1, [must supply username to passwd])
436         ;;
437 # UnixWare 7.x, OpenUNIX 8
438 *-*-sysv5*)
439         AC_DEFINE(USE_PIPES)
440         AC_DEFINE(SETEUID_BREAKS_SETUID)
441         AC_DEFINE(BROKEN_SETREUID)
442         AC_DEFINE(BROKEN_SETREGID)
443         AC_DEFINE(PASSWD_NEEDS_USERNAME, 1, [must supply username to passwd])
444         case "$host" in
445         *-*-sysv5SCO_SV*)       # SCO OpenServer 6.x
446                 TEST_SHELL=/u95/bin/sh
447                 ;;
448         esac
449         ;;
450 *-*-sysv*)
451         ;;
452 # SCO UNIX and OEM versions of SCO UNIX
453 *-*-sco3.2v4*)
454         AC_MSG_ERROR("This Platform is no longer supported.")
455         ;;
456 # SCO OpenServer 5.x
457 *-*-sco3.2v5*)
458         if test -z "$GCC"; then
459                 CFLAGS="$CFLAGS -belf"
460         fi
461         LIBS="$LIBS -lprot -lx -ltinfo -lm"
462         no_dev_ptmx=1
463         AC_DEFINE(USE_PIPES)
464         AC_DEFINE(HAVE_SECUREWARE)
465         AC_DEFINE(DISABLE_SHADOW)
466         AC_DEFINE(DISABLE_FD_PASSING)
467         AC_DEFINE(SETEUID_BREAKS_SETUID)
468         AC_DEFINE(BROKEN_SETREUID)
469         AC_DEFINE(BROKEN_SETREGID)
470         AC_DEFINE(WITH_ABBREV_NO_TTY)
471         AC_DEFINE(BROKEN_UPDWTMPX)
472         AC_DEFINE(PASSWD_NEEDS_USERNAME, 1, [must supply username to passwd])
473         AC_CHECK_FUNCS(getluid setluid)
474         MANTYPE=man
475         TEST_SHELL=ksh
476         ;;
477 *-*-unicosmk*)
478         AC_DEFINE(NO_SSH_LASTLOG)
479         AC_DEFINE(SETEUID_BREAKS_SETUID)
480         AC_DEFINE(BROKEN_SETREUID)
481         AC_DEFINE(BROKEN_SETREGID)
482         AC_DEFINE(USE_PIPES)
483         AC_DEFINE(DISABLE_FD_PASSING)
484         LDFLAGS="$LDFLAGS"
485         LIBS="$LIBS -lgen -lrsc -lshare -luex -lacm"
486         MANTYPE=cat
487         ;;
488 *-*-unicosmp*)
489         AC_DEFINE(SETEUID_BREAKS_SETUID)
490         AC_DEFINE(BROKEN_SETREUID)
491         AC_DEFINE(BROKEN_SETREGID)
492         AC_DEFINE(WITH_ABBREV_NO_TTY)
493         AC_DEFINE(USE_PIPES)
494         AC_DEFINE(DISABLE_FD_PASSING)
495         LDFLAGS="$LDFLAGS"
496         LIBS="$LIBS -lgen -lacid -ldb"
497         MANTYPE=cat
498         ;;
499 *-*-unicos*)
500         AC_DEFINE(SETEUID_BREAKS_SETUID)
501         AC_DEFINE(BROKEN_SETREUID)
502         AC_DEFINE(BROKEN_SETREGID)
503         AC_DEFINE(USE_PIPES)
504         AC_DEFINE(DISABLE_FD_PASSING)
505         AC_DEFINE(NO_SSH_LASTLOG)
506         LDFLAGS="$LDFLAGS -Wl,-Dmsglevel=334:fatal"
507         LIBS="$LIBS -lgen -lrsc -lshare -luex -lacm"
508         MANTYPE=cat
509         ;;
510 *-dec-osf*)
511         AC_MSG_CHECKING(for Digital Unix SIA)
512         no_osfsia=""
513         AC_ARG_WITH(osfsia,
514                 [  --with-osfsia           Enable Digital Unix SIA],
515                 [
516                         if test "x$withval" = "xno" ; then
517                                 AC_MSG_RESULT(disabled)
518                                 no_osfsia=1
519                         fi
520                 ],
521         )
522         if test -z "$no_osfsia" ; then
523                 if test -f /etc/sia/matrix.conf; then
524                         AC_MSG_RESULT(yes)
525                         AC_DEFINE(HAVE_OSF_SIA)
526                         AC_DEFINE(DISABLE_LOGIN)
527                         AC_DEFINE(DISABLE_FD_PASSING)
528                         LIBS="$LIBS -lsecurity -ldb -lm -laud"
529                 else
530                         AC_MSG_RESULT(no)
531                         AC_DEFINE(LOCKED_PASSWD_SUBSTR, "Nologin")
532                 fi
533         fi
534         AC_DEFINE(BROKEN_GETADDRINFO)
535         AC_DEFINE(SETEUID_BREAKS_SETUID)
536         AC_DEFINE(BROKEN_SETREUID)
537         AC_DEFINE(BROKEN_SETREGID)
538         ;;
539
540 *-*-nto-qnx)
541         AC_DEFINE(USE_PIPES)
542         AC_DEFINE(NO_X11_UNIX_SOCKETS)
543         AC_DEFINE(MISSING_NFDBITS)
544         AC_DEFINE(MISSING_HOWMANY)
545         AC_DEFINE(MISSING_FD_MASK)
546         ;;
547
548 *-*-ultrix*)
549         AC_DEFINE(BROKEN_GETGROUPS, [], [getgroups(0,NULL) will return -1])
550         AC_DEFINE(BROKEN_MMAP, [], [Ultrix mmap can't map files])
551         AC_DEFINE(NEED_SETPRGP, [], [Need setpgrp to acquire controlling tty])
552         AC_DEFINE(HAVE_SYS_SYSLOG_H, 1, [Force use of sys/syslog.h on Ultrix])
553         ;;
554 esac
555
556 # Allow user to specify flags
557 AC_ARG_WITH(cflags,
558         [  --with-cflags           Specify additional flags to pass to compiler],
559         [
560                 if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
561                     test "x${withval}" != "xyes"; then
562                         CFLAGS="$CFLAGS $withval"
563                 fi
564         ]
565 )
566 AC_ARG_WITH(cppflags,
567         [  --with-cppflags         Specify additional flags to pass to preprocessor] ,
568         [
569                 if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
570                     test "x${withval}" != "xyes"; then
571                         CPPFLAGS="$CPPFLAGS $withval"
572                 fi
573         ]
574 )
575 AC_ARG_WITH(ldflags,
576         [  --with-ldflags          Specify additional flags to pass to linker],
577         [
578                 if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
579                     test "x${withval}" != "xyes"; then
580                         LDFLAGS="$LDFLAGS $withval"
581                 fi
582         ]
583 )
584 AC_ARG_WITH(libs,
585         [  --with-libs             Specify additional libraries to link with],
586         [
587                 if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
588                     test "x${withval}" != "xyes"; then
589                         LIBS="$LIBS $withval"
590                 fi
591         ]
592 )
593
594 AC_MSG_CHECKING(compiler and flags for sanity)
595 AC_RUN_IFELSE(
596         [AC_LANG_SOURCE([
597 #include <stdio.h>
598 int main(){exit(0);}
599         ])],
600         [       AC_MSG_RESULT(yes) ],
601         [
602                 AC_MSG_RESULT(no)
603                 AC_MSG_ERROR([*** compiler cannot create working executables, check config.log ***])
604         ],
605         [       AC_MSG_WARN([cross compiling: not checking compiler sanity]) ]
606 )
607
608 dnl Checks for header files.
609 AC_CHECK_HEADERS( \
610         bstring.h \
611         crypt.h \
612         dirent.h \
613         endian.h \
614         features.h \
615         floatingpoint.h \
616         getopt.h \
617         glob.h \
618         ia.h \
619         lastlog.h \
620         limits.h \
621         login.h \
622         login_cap.h \
623         maillock.h \
624         ndir.h \
625         netdb.h \
626         netgroup.h \
627         netinet/in_systm.h \
628         pam/pam_appl.h \
629         paths.h \
630         pty.h \
631         readpassphrase.h \
632         rpc/types.h \
633         security/pam_appl.h \
634         shadow.h \
635         stddef.h \
636         stdint.h \
637         string.h \
638         strings.h \
639         sys/audit.h \
640         sys/bitypes.h \
641         sys/bsdtty.h \
642         sys/cdefs.h \
643         sys/dir.h \
644         sys/mman.h \
645         sys/ndir.h \
646         sys/prctl.h \
647         sys/pstat.h \
648         sys/select.h \
649         sys/stat.h \
650         sys/stream.h \
651         sys/stropts.h \
652         sys/strtio.h \
653         sys/sysmacros.h \
654         sys/time.h \
655         sys/timers.h \
656         sys/un.h \
657         time.h \
658         tmpdir.h \
659         ttyent.h \
660         unistd.h \
661         usersec.h \
662         util.h \
663         utime.h \
664         utmp.h \
665         utmpx.h \
666         vis.h \
667 )
668
669 # sys/ptms.h requires sys/stream.h to be included first on Solaris
670 AC_CHECK_HEADERS(sys/ptms.h, [], [], [
671 #ifdef HAVE_SYS_STREAM_H
672 # include <sys/stream.h>
673 #endif
674 ])
675
676 # Checks for libraries.
677 AC_CHECK_FUNC(yp_match, , AC_CHECK_LIB(nsl, yp_match))
678 AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt))
679
680 dnl IRIX and Solaris 2.5.1 have dirname() in libgen
681 AC_CHECK_FUNCS(dirname, [AC_CHECK_HEADERS(libgen.h)] ,[
682         AC_CHECK_LIB(gen, dirname,[
683                 AC_CACHE_CHECK([for broken dirname],
684                         ac_cv_have_broken_dirname, [
685                         save_LIBS="$LIBS"
686                         LIBS="$LIBS -lgen"
687                         AC_TRY_RUN(
688                                 [
689 #include <libgen.h>
690 #include <string.h>
691
692 int main(int argc, char **argv) {
693     char *s, buf[32];
694
695     strncpy(buf,"/etc", 32);
696     s = dirname(buf);
697     if (!s || strncmp(s, "/", 32) != 0) {
698         exit(1);
699     } else {
700         exit(0);
701     }
702 }
703                                 ],
704                                 [ ac_cv_have_broken_dirname="no" ],
705                                 [ ac_cv_have_broken_dirname="yes" ]
706                         )
707                         LIBS="$save_LIBS"
708                 ])
709                 if test "x$ac_cv_have_broken_dirname" = "xno" ; then
710                         LIBS="$LIBS -lgen"
711                         AC_DEFINE(HAVE_DIRNAME)
712                         AC_CHECK_HEADERS(libgen.h)
713                 fi
714         ])
715 ])
716
717 AC_CHECK_FUNC(getspnam, ,
718         AC_CHECK_LIB(gen, getspnam, LIBS="$LIBS -lgen"))
719 AC_SEARCH_LIBS(basename, gen, AC_DEFINE(HAVE_BASENAME))
720
721 dnl zlib is required
722 AC_ARG_WITH(zlib,
723         [  --with-zlib=PATH        Use zlib in PATH],
724         [ if test "x$withval" = "xno" ; then
725                 AC_MSG_ERROR([*** zlib is required ***])
726           elif test "x$withval" != "xyes"; then
727                 if test -d "$withval/lib"; then
728                         if test -n "${need_dash_r}"; then
729                                 LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
730                         else
731                                 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
732                         fi
733                 else
734                         if test -n "${need_dash_r}"; then
735                                 LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
736                         else
737                                 LDFLAGS="-L${withval} ${LDFLAGS}"
738                         fi
739                 fi
740                 if test -d "$withval/include"; then
741                         CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
742                 else
743                         CPPFLAGS="-I${withval} ${CPPFLAGS}"
744                 fi
745         fi ]
746 )
747
748 AC_CHECK_LIB(z, deflate, ,
749         [
750                 saved_CPPFLAGS="$CPPFLAGS"
751                 saved_LDFLAGS="$LDFLAGS"
752                 save_LIBS="$LIBS"
753                 dnl Check default zlib install dir
754                 if test -n "${need_dash_r}"; then
755                         LDFLAGS="-L/usr/local/lib -R/usr/local/lib ${saved_LDFLAGS}"
756                 else
757                         LDFLAGS="-L/usr/local/lib ${saved_LDFLAGS}"
758                 fi
759                 CPPFLAGS="-I/usr/local/include ${saved_CPPFLAGS}"
760                 LIBS="$LIBS -lz"
761                 AC_TRY_LINK_FUNC(deflate, AC_DEFINE(HAVE_LIBZ),
762                         [
763                                 AC_MSG_ERROR([*** zlib missing - please install first or check config.log ***])
764                         ]
765                 )
766         ]
767 )
768 AC_CHECK_HEADER([zlib.h], ,AC_MSG_ERROR([*** zlib.h missing - please install first or check config.log ***]))
769
770 AC_ARG_WITH(zlib-version-check,
771         [  --without-zlib-version-check Disable zlib version check],
772         [  if test "x$withval" = "xno" ; then
773                 zlib_check_nonfatal=1
774            fi
775         ]
776 )
777
778 AC_MSG_CHECKING(for possibly buggy zlib)
779 AC_RUN_IFELSE([AC_LANG_SOURCE([[
780 #include <stdio.h>
781 #include <zlib.h>
782 int main()
783 {
784         int a=0, b=0, c=0, d=0, n, v;
785         n = sscanf(ZLIB_VERSION, "%d.%d.%d.%d", &a, &b, &c, &d);
786         if (n != 3 && n != 4)
787                 exit(1);
788         v = a*1000000 + b*10000 + c*100 + d;
789         fprintf(stderr, "found zlib version %s (%d)\n", ZLIB_VERSION, v);
790
791         /* 1.1.4 is OK */
792         if (a == 1 && b == 1 && c >= 4)
793                 exit(0);
794
795         /* 1.2.1.2 and up are OK */
796         if (v >= 1020102)
797                 exit(0);
798
799         exit(2);
800 }
801         ]])],
802         AC_MSG_RESULT(no),
803         [ AC_MSG_RESULT(yes)
804           if test -z "$zlib_check_nonfatal" ; then
805                 AC_MSG_ERROR([*** zlib too old - check config.log ***
806 Your reported zlib version has known security problems.  It's possible your
807 vendor has fixed these problems without changing the version number.  If you
808 are sure this is the case, you can disable the check by running
809 "./configure --without-zlib-version-check".
810 If you are in doubt, upgrade zlib to version 1.2.1.2 or greater.
811 See http://www.gzip.org/zlib/ for details.])
812           else
813                 AC_MSG_WARN([zlib version may have security problems])
814           fi
815         ],
816         [       AC_MSG_WARN([cross compiling: not checking zlib version]) ]
817 )
818
819 dnl UnixWare 2.x
820 AC_CHECK_FUNC(strcasecmp,
821         [], [ AC_CHECK_LIB(resolv, strcasecmp, LIBS="$LIBS -lresolv") ]
822 )
823 AC_CHECK_FUNC(utimes,
824         [], [ AC_CHECK_LIB(c89, utimes, [AC_DEFINE(HAVE_UTIMES)
825                                         LIBS="$LIBS -lc89"]) ]
826 )
827
828 dnl    Checks for libutil functions
829 AC_CHECK_HEADERS(libutil.h)
830 AC_SEARCH_LIBS(login, util bsd, [AC_DEFINE(HAVE_LOGIN)])
831 AC_CHECK_FUNCS(logout updwtmp logwtmp)
832
833 AC_FUNC_STRFTIME
834
835 # Check for ALTDIRFUNC glob() extension
836 AC_MSG_CHECKING(for GLOB_ALTDIRFUNC support)
837 AC_EGREP_CPP(FOUNDIT,
838         [
839                 #include <glob.h>
840                 #ifdef GLOB_ALTDIRFUNC
841                 FOUNDIT
842                 #endif
843         ],
844         [
845                 AC_DEFINE(GLOB_HAS_ALTDIRFUNC)
846                 AC_MSG_RESULT(yes)
847         ],
848         [
849                 AC_MSG_RESULT(no)
850         ]
851 )
852
853 # Check for g.gl_matchc glob() extension
854 AC_MSG_CHECKING(for gl_matchc field in glob_t)
855 AC_EGREP_CPP(FOUNDIT,
856         [
857                 #include <glob.h>
858                 int main(void){glob_t g; g.gl_matchc = 1;}
859         ],
860         [
861                 AC_DEFINE(GLOB_HAS_GL_MATCHC)
862                 AC_MSG_RESULT(yes)
863         ],
864         [
865                 AC_MSG_RESULT(no)
866         ]
867 )
868
869 AC_MSG_CHECKING([whether struct dirent allocates space for d_name])
870 AC_RUN_IFELSE(
871         [AC_LANG_SOURCE([[
872 #include <sys/types.h>
873 #include <dirent.h>
874 int main(void){struct dirent d;exit(sizeof(d.d_name)<=sizeof(char));}
875         ]])],
876         [AC_MSG_RESULT(yes)],
877         [
878                 AC_MSG_RESULT(no)
879                 AC_DEFINE(BROKEN_ONE_BYTE_DIRENT_D_NAME)
880         ],
881         [
882                 AC_MSG_WARN([cross compiling: assuming BROKEN_ONE_BYTE_DIRENT_D_NAME])
883                 AC_DEFINE(BROKEN_ONE_BYTE_DIRENT_D_NAME)
884         ]
885 )
886
887 AC_MSG_CHECKING([for /proc/pid/fd directory])
888 if test -d "/proc/$$/fd" ; then
889         AC_DEFINE(HAVE_PROC_PID)
890         AC_MSG_RESULT(yes)
891 else
892         AC_MSG_RESULT(no)
893 fi
894
895 # Check whether user wants S/Key support
896 SKEY_MSG="no"
897 AC_ARG_WITH(skey,
898         [  --with-skey[[=PATH]]      Enable S/Key support (optionally in PATH)],
899         [
900                 if test "x$withval" != "xno" ; then
901
902                         if test "x$withval" != "xyes" ; then
903                                 CPPFLAGS="$CPPFLAGS -I${withval}/include"
904                                 LDFLAGS="$LDFLAGS -L${withval}/lib"
905                         fi
906
907                         AC_DEFINE(SKEY)
908                         LIBS="-lskey $LIBS"
909                         SKEY_MSG="yes"
910
911                         AC_MSG_CHECKING([for s/key support])
912                         AC_TRY_RUN(
913                                 [
914 #include <stdio.h>
915 #include <skey.h>
916 int main() { char *ff = skey_keyinfo(""); ff=""; exit(0); }
917                                 ],
918                                 [AC_MSG_RESULT(yes)],
919                                 [
920                                         AC_MSG_RESULT(no)
921                                         AC_MSG_ERROR([** Incomplete or missing s/key libraries.])
922                                 ])
923                         AC_MSG_CHECKING(if skeychallenge takes 4 arguments)
924                         AC_TRY_COMPILE(
925                                 [#include <stdio.h>
926                                  #include <skey.h>],
927                                 [(void)skeychallenge(NULL,"name","",0);],
928                                 [AC_MSG_RESULT(yes)
929                                  AC_DEFINE(SKEYCHALLENGE_4ARG)],
930                                 [AC_MSG_RESULT(no)]
931                         )
932                 fi
933         ]
934 )
935
936 # Check whether user wants TCP wrappers support
937 TCPW_MSG="no"
938 AC_ARG_WITH(tcp-wrappers,
939         [  --with-tcp-wrappers[[=PATH]] Enable tcpwrappers support (optionally in PATH)],
940         [
941                 if test "x$withval" != "xno" ; then
942                         saved_LIBS="$LIBS"
943                         saved_LDFLAGS="$LDFLAGS"
944                         saved_CPPFLAGS="$CPPFLAGS"
945                         if test -n "${withval}" && \
946                             test "x${withval}" != "xyes"; then
947                                 if test -d "${withval}/lib"; then
948                                         if test -n "${need_dash_r}"; then
949                                                 LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
950                                         else
951                                                 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
952                                         fi
953                                 else
954                                         if test -n "${need_dash_r}"; then
955                                                 LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
956                                         else
957                                                 LDFLAGS="-L${withval} ${LDFLAGS}"
958                                         fi
959                                 fi
960                                 if test -d "${withval}/include"; then
961                                         CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
962                                 else
963                                         CPPFLAGS="-I${withval} ${CPPFLAGS}"
964                                 fi
965                         fi
966                         LIBWRAP="-lwrap"
967                         LIBS="$LIBWRAP $LIBS"
968                         AC_MSG_CHECKING(for libwrap)
969                         AC_TRY_LINK(
970                                 [
971 #include <sys/types.h>
972 #include <sys/socket.h>
973 #include <netinet/in.h>
974 #include <tcpd.h>
975                                         int deny_severity = 0, allow_severity = 0;
976                                 ],
977                                 [hosts_access(0);],
978                                 [
979                                         AC_MSG_RESULT(yes)
980                                         AC_DEFINE(LIBWRAP)
981                                         AC_SUBST(LIBWRAP)
982                                         TCPW_MSG="yes"
983                                 ],
984                                 [
985                                         AC_MSG_ERROR([*** libwrap missing])
986                                 ]
987                         )
988                         LIBS="$saved_LIBS"
989                 fi
990         ]
991 )
992
993 # Check whether user wants libedit support
994 LIBEDIT_MSG="no"
995 AC_ARG_WITH(libedit,
996         [  --with-libedit[[=PATH]]   Enable libedit support for sftp],
997         [ if test "x$withval" != "xno" ; then
998                 if test "x$withval" != "xyes"; then
999                         CPPFLAGS="$CPPFLAGS -I$withval/include"
1000                         LDFLAGS="$LDFLAGS -L$withval/lib"
1001                 fi
1002                 AC_CHECK_LIB(edit, el_init,
1003                         [ AC_DEFINE(USE_LIBEDIT, [], [Use libedit for sftp])
1004                           LIBEDIT="-ledit -lcurses"
1005                           LIBEDIT_MSG="yes"
1006                           AC_SUBST(LIBEDIT)
1007                         ],
1008                         [ AC_MSG_ERROR(libedit not found) ],
1009                         [ -lcurses ]
1010                 )
1011         fi ]
1012 )
1013
1014 AUDIT_MODULE=none
1015 AC_ARG_WITH(audit,
1016         [  --with-audit=module     Enable EXPERIMENTAL audit support (modules=debug,bsm)],
1017         [
1018           AC_MSG_CHECKING(for supported audit module)
1019           case "$withval" in
1020           bsm)
1021                 AC_MSG_RESULT(bsm)
1022                 AUDIT_MODULE=bsm
1023                 dnl    Checks for headers, libs and functions
1024                 AC_CHECK_HEADERS(bsm/audit.h, [],
1025                     [AC_MSG_ERROR(BSM enabled and bsm/audit.h not found)])
1026                 AC_CHECK_LIB(bsm, getaudit, [],
1027                     [AC_MSG_ERROR(BSM enabled and required library not found)])
1028                 AC_CHECK_FUNCS(getaudit, [],
1029                     [AC_MSG_ERROR(BSM enabled and required function not found)])
1030                 # These are optional
1031                 AC_CHECK_FUNCS(getaudit_addr)
1032                 AC_DEFINE(USE_BSM_AUDIT, [], [Use BSM audit module])
1033                 ;;
1034           debug)
1035                 AUDIT_MODULE=debug
1036                 AC_MSG_RESULT(debug)
1037                 AC_DEFINE(SSH_AUDIT_EVENTS, [], Use audit debugging module)
1038                 ;;
1039           *)
1040                 AC_MSG_ERROR([Unknown audit module $withval])
1041                 ;;
1042         esac ]
1043 )
1044
1045 dnl    Checks for library functions. Please keep in alphabetical order
1046 AC_CHECK_FUNCS( \
1047         arc4random \
1048         b64_ntop \
1049         __b64_ntop \
1050         b64_pton \
1051         __b64_pton \
1052         bcopy \
1053         bindresvport_sa \
1054         clock \
1055         closefrom \
1056         dirfd \
1057         fchdir \
1058         fchmod \
1059         fchown \
1060         freeaddrinfo \
1061         futimes \
1062         getaddrinfo \
1063         getcwd \
1064         getgrouplist \
1065         getnameinfo \
1066         getopt \
1067         getpeereid \
1068         _getpty \
1069         getrlimit \
1070         getttyent \
1071         glob \
1072         inet_aton \
1073         inet_ntoa \
1074         inet_ntop \
1075         innetgr \
1076         login_getcapbool \
1077         md5_crypt \
1078         memmove \
1079         mkdtemp \
1080         mmap \
1081         ngetaddrinfo \
1082         nsleep \
1083         ogetaddrinfo \
1084         openlog_r \
1085         openpty \
1086         prctl \
1087         pstat \
1088         readpassphrase \
1089         realpath \
1090         recvmsg \
1091         rresvport_af \
1092         sendmsg \
1093         setdtablesize \
1094         setegid \
1095         setenv \
1096         seteuid \
1097         setgroups \
1098         setlogin \
1099         setpcred \
1100         setproctitle \
1101         setregid \
1102         setreuid \
1103         setrlimit \
1104         setsid \
1105         setvbuf \
1106         sigaction \
1107         sigvec \
1108         snprintf \
1109         socketpair \
1110         strdup \
1111         strerror \
1112         strlcat \
1113         strlcpy \
1114         strmode \
1115         strnvis \
1116         strtonum \
1117         strtoll \
1118         strtoul \
1119         sysconf \
1120         tcgetpgrp \
1121         truncate \
1122         unsetenv \
1123         updwtmpx \
1124         utimes \
1125         vhangup \
1126         vsnprintf \
1127         waitpid \
1128 )
1129
1130 # IRIX has a const char return value for gai_strerror()
1131 AC_CHECK_FUNCS(gai_strerror,[
1132         AC_DEFINE(HAVE_GAI_STRERROR)
1133         AC_TRY_COMPILE([
1134 #include <sys/types.h>
1135 #include <sys/socket.h>
1136 #include <netdb.h>
1137
1138 const char *gai_strerror(int);],[
1139 char *str;
1140
1141 str = gai_strerror(0);],[
1142                 AC_DEFINE(HAVE_CONST_GAI_STRERROR_PROTO, 1,
1143                 [Define if gai_strerror() returns const char *])])])
1144
1145 AC_SEARCH_LIBS(nanosleep, rt posix4, AC_DEFINE(HAVE_NANOSLEEP))
1146
1147 dnl Make sure prototypes are defined for these before using them.
1148 AC_CHECK_DECL(getrusage, [AC_CHECK_FUNCS(getrusage)])
1149 AC_CHECK_DECL(strsep,
1150         [AC_CHECK_FUNCS(strsep)],
1151         [],
1152         [
1153 #ifdef HAVE_STRING_H
1154 # include <string.h>
1155 #endif
1156         ])
1157
1158 dnl tcsendbreak might be a macro
1159 AC_CHECK_DECL(tcsendbreak,
1160         [AC_DEFINE(HAVE_TCSENDBREAK)],
1161         [AC_CHECK_FUNCS(tcsendbreak)],
1162         [#include <termios.h>]
1163 )
1164
1165 AC_CHECK_DECLS(h_errno, , ,[#include <netdb.h>])
1166
1167 AC_CHECK_FUNCS(setresuid, [
1168         dnl Some platorms have setresuid that isn't implemented, test for this
1169         AC_MSG_CHECKING(if setresuid seems to work)
1170         AC_RUN_IFELSE(
1171                 [AC_LANG_SOURCE([[
1172 #include <stdlib.h>
1173 #include <errno.h>
1174 int main(){errno=0; setresuid(0,0,0); if (errno==ENOSYS) exit(1); else exit(0);}
1175                 ]])],
1176                 [AC_MSG_RESULT(yes)],
1177                 [AC_DEFINE(BROKEN_SETRESUID)
1178                  AC_MSG_RESULT(not implemented)],
1179                 [AC_MSG_WARN([cross compiling: not checking setresuid])]
1180         )
1181 ])
1182
1183 AC_CHECK_FUNCS(setresgid, [
1184         dnl Some platorms have setresgid that isn't implemented, test for this
1185         AC_MSG_CHECKING(if setresgid seems to work)
1186         AC_RUN_IFELSE(
1187                 [AC_LANG_SOURCE([[
1188 #include <stdlib.h>
1189 #include <errno.h>
1190 int main(){errno=0; setresgid(0,0,0); if (errno==ENOSYS) exit(1); else exit(0);}
1191                 ]])],
1192                 [AC_MSG_RESULT(yes)],
1193                 [AC_DEFINE(BROKEN_SETRESGID)
1194                  AC_MSG_RESULT(not implemented)],
1195                 [AC_MSG_WARN([cross compiling: not checking setresuid])]
1196         )
1197 ])
1198
1199 dnl    Checks for time functions
1200 AC_CHECK_FUNCS(gettimeofday time)
1201 dnl    Checks for utmp functions
1202 AC_CHECK_FUNCS(endutent getutent getutid getutline pututline setutent)
1203 AC_CHECK_FUNCS(utmpname)
1204 dnl    Checks for utmpx functions
1205 AC_CHECK_FUNCS(endutxent getutxent getutxid getutxline pututxline )
1206 AC_CHECK_FUNCS(setutxent utmpxname)
1207
1208 AC_CHECK_FUNC(daemon,
1209         [AC_DEFINE(HAVE_DAEMON)],
1210         [AC_CHECK_LIB(bsd, daemon, [LIBS="$LIBS -lbsd"; AC_DEFINE(HAVE_DAEMON)])]
1211 )
1212
1213 AC_CHECK_FUNC(getpagesize,
1214         [AC_DEFINE(HAVE_GETPAGESIZE)],
1215         [AC_CHECK_LIB(ucb, getpagesize, [LIBS="$LIBS -lucb"; AC_DEFINE(HAVE_GETPAGESIZE)])]
1216 )
1217
1218 # Check for broken snprintf
1219 if test "x$ac_cv_func_snprintf" = "xyes" ; then
1220         AC_MSG_CHECKING([whether snprintf correctly terminates long strings])
1221         AC_RUN_IFELSE(
1222                 [AC_LANG_SOURCE([[
1223 #include <stdio.h>
1224 int main(void){char b[5];snprintf(b,5,"123456789");exit(b[4]!='\0');}
1225                 ]])],
1226                 [AC_MSG_RESULT(yes)],
1227                 [
1228                         AC_MSG_RESULT(no)
1229                         AC_DEFINE(BROKEN_SNPRINTF)
1230                         AC_MSG_WARN([****** Your snprintf() function is broken, complain to your vendor])
1231                 ],
1232                 [ AC_MSG_WARN([cross compiling: Assuming working snprintf()]) ]
1233         )
1234 fi
1235
1236 # Check for missing getpeereid (or equiv) support
1237 NO_PEERCHECK=""
1238 if test "x$ac_cv_func_getpeereid" != "xyes" ; then
1239         AC_MSG_CHECKING([whether system supports SO_PEERCRED getsockopt])
1240         AC_TRY_COMPILE(
1241                 [#include <sys/types.h>
1242                  #include <sys/socket.h>],
1243                 [int i = SO_PEERCRED;],
1244                 [ AC_MSG_RESULT(yes)
1245                   AC_DEFINE(HAVE_SO_PEERCRED, [], [Have PEERCRED socket option])
1246                 ],
1247                 [AC_MSG_RESULT(no)
1248                 NO_PEERCHECK=1]
1249         )
1250 fi
1251
1252 dnl see whether mkstemp() requires XXXXXX
1253 if test "x$ac_cv_func_mkdtemp" = "xyes" ; then
1254 AC_MSG_CHECKING([for (overly) strict mkstemp])
1255 AC_TRY_RUN(
1256         [
1257 #include <stdlib.h>
1258 main() { char template[]="conftest.mkstemp-test";
1259 if (mkstemp(template) == -1)
1260         exit(1);
1261 unlink(template); exit(0);
1262 }
1263         ],
1264         [
1265                 AC_MSG_RESULT(no)
1266         ],
1267         [
1268                 AC_MSG_RESULT(yes)
1269                 AC_DEFINE(HAVE_STRICT_MKSTEMP)
1270         ],
1271         [
1272                 AC_MSG_RESULT(yes)
1273                 AC_DEFINE(HAVE_STRICT_MKSTEMP)
1274         ]
1275 )
1276 fi
1277
1278 dnl make sure that openpty does not reacquire controlling terminal
1279 if test ! -z "$check_for_openpty_ctty_bug"; then
1280         AC_MSG_CHECKING(if openpty correctly handles controlling tty)
1281         AC_TRY_RUN(
1282                 [
1283 #include <stdio.h>
1284 #include <sys/fcntl.h>
1285 #include <sys/types.h>
1286 #include <sys/wait.h>
1287
1288 int
1289 main()
1290 {
1291         pid_t pid;
1292         int fd, ptyfd, ttyfd, status;
1293
1294         pid = fork();
1295         if (pid < 0) {          /* failed */
1296                 exit(1);
1297         } else if (pid > 0) {   /* parent */
1298                 waitpid(pid, &status, 0);
1299                 if (WIFEXITED(status))
1300                         exit(WEXITSTATUS(status));
1301                 else
1302                         exit(2);
1303         } else {                /* child */
1304                 close(0); close(1); close(2);
1305                 setsid();
1306                 openpty(&ptyfd, &ttyfd, NULL, NULL, NULL);
1307                 fd = open("/dev/tty", O_RDWR | O_NOCTTY);
1308                 if (fd >= 0)
1309                         exit(3);        /* Acquired ctty: broken */
1310                 else
1311                         exit(0);        /* Did not acquire ctty: OK */
1312         }
1313 }
1314                 ],
1315                 [
1316                         AC_MSG_RESULT(yes)
1317                 ],
1318                 [
1319                         AC_MSG_RESULT(no)
1320                         AC_DEFINE(SSHD_ACQUIRES_CTTY)
1321                 ]
1322         )
1323 fi
1324
1325 if test "x$ac_cv_func_getaddrinfo" = "xyes" && \
1326     test "x$check_for_hpux_broken_getaddrinfo" = "x1"; then
1327         AC_MSG_CHECKING(if getaddrinfo seems to work)
1328         AC_TRY_RUN(
1329                 [
1330 #include <stdio.h>
1331 #include <sys/socket.h>
1332 #include <netdb.h>
1333 #include <errno.h>
1334 #include <netinet/in.h>
1335
1336 #define TEST_PORT "2222"
1337
1338 int
1339 main(void)
1340 {
1341         int err, sock;
1342         struct addrinfo *gai_ai, *ai, hints;
1343         char ntop[NI_MAXHOST], strport[NI_MAXSERV], *name = NULL;
1344
1345         memset(&hints, 0, sizeof(hints));
1346         hints.ai_family = PF_UNSPEC;
1347         hints.ai_socktype = SOCK_STREAM;
1348         hints.ai_flags = AI_PASSIVE;
1349
1350         err = getaddrinfo(name, TEST_PORT, &hints, &gai_ai);
1351         if (err != 0) {
1352                 fprintf(stderr, "getaddrinfo failed (%s)", gai_strerror(err));
1353                 exit(1);
1354         }
1355
1356         for (ai = gai_ai; ai != NULL; ai = ai->ai_next) {
1357                 if (ai->ai_family != AF_INET6)
1358                         continue;
1359
1360                 err = getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop,
1361                     sizeof(ntop), strport, sizeof(strport),
1362                     NI_NUMERICHOST|NI_NUMERICSERV);
1363
1364                 if (err != 0) {
1365                         if (err == EAI_SYSTEM)
1366                                 perror("getnameinfo EAI_SYSTEM");
1367                         else
1368                                 fprintf(stderr, "getnameinfo failed: %s\n",
1369                                     gai_strerror(err));
1370                         exit(2);
1371                 }
1372
1373                 sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
1374                 if (sock < 0)
1375                         perror("socket");
1376                 if (bind(sock, ai->ai_addr, ai->ai_addrlen) < 0) {
1377                         if (errno == EBADF)
1378                                 exit(3);
1379                 }
1380         }
1381         exit(0);
1382 }
1383                 ],
1384                 [
1385                         AC_MSG_RESULT(yes)
1386                 ],
1387                 [
1388                         AC_MSG_RESULT(no)
1389                         AC_DEFINE(BROKEN_GETADDRINFO)
1390                 ]
1391         )
1392 fi
1393
1394 if test "x$ac_cv_func_getaddrinfo" = "xyes" && \
1395     test "x$check_for_aix_broken_getaddrinfo" = "x1"; then
1396         AC_MSG_CHECKING(if getaddrinfo seems to work)
1397         AC_TRY_RUN(
1398                 [
1399 #include <stdio.h>
1400 #include <sys/socket.h>
1401 #include <netdb.h>
1402 #include <errno.h>
1403 #include <netinet/in.h>
1404
1405 #define TEST_PORT "2222"
1406
1407 int
1408 main(void)
1409 {
1410         int err, sock;
1411         struct addrinfo *gai_ai, *ai, hints;
1412         char ntop[NI_MAXHOST], strport[NI_MAXSERV], *name = NULL;
1413
1414         memset(&hints, 0, sizeof(hints));
1415         hints.ai_family = PF_UNSPEC;
1416         hints.ai_socktype = SOCK_STREAM;
1417         hints.ai_flags = AI_PASSIVE;
1418
1419         err = getaddrinfo(name, TEST_PORT, &hints, &gai_ai);
1420         if (err != 0) {
1421                 fprintf(stderr, "getaddrinfo failed (%s)", gai_strerror(err));
1422                 exit(1);
1423         }
1424
1425         for (ai = gai_ai; ai != NULL; ai = ai->ai_next) {
1426                 if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6)
1427                         continue;
1428
1429                 err = getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop,
1430                     sizeof(ntop), strport, sizeof(strport),
1431                     NI_NUMERICHOST|NI_NUMERICSERV);
1432
1433                 if (ai->ai_family == AF_INET && err != 0) {
1434                         perror("getnameinfo");
1435                         exit(2);
1436                 }
1437         }
1438         exit(0);
1439 }
1440                 ],
1441                 [
1442                         AC_MSG_RESULT(yes)
1443                         AC_DEFINE(AIX_GETNAMEINFO_HACK, [],
1444 [Define if you have a getaddrinfo that fails for the all-zeros IPv6 address])
1445                 ],
1446                 [
1447                         AC_MSG_RESULT(no)
1448                         AC_DEFINE(BROKEN_GETADDRINFO)
1449                 ]
1450         )
1451 fi
1452
1453 if test "x$check_for_conflicting_getspnam" = "x1"; then
1454         AC_MSG_CHECKING(for conflicting getspnam in shadow.h)
1455         AC_COMPILE_IFELSE(
1456                 [
1457 #include <shadow.h>
1458 int main(void) {exit(0);}
1459                 ],
1460                 [
1461                         AC_MSG_RESULT(no)
1462                 ],
1463                 [
1464                         AC_MSG_RESULT(yes)
1465                         AC_DEFINE(GETSPNAM_CONFLICTING_DEFS, 1,
1466                             [Conflicting defs for getspnam])
1467                 ]
1468         )
1469 fi
1470
1471 AC_FUNC_GETPGRP
1472
1473 # Check for PAM libs
1474 PAM_MSG="no"
1475 AC_ARG_WITH(pam,
1476         [  --with-pam              Enable PAM support ],
1477         [
1478                 if test "x$withval" != "xno" ; then
1479                         if test "x$ac_cv_header_security_pam_appl_h" != "xyes" && \
1480                            test "x$ac_cv_header_pam_pam_appl_h" != "xyes" ; then
1481                                 AC_MSG_ERROR([PAM headers not found])
1482                         fi
1483
1484                         AC_CHECK_LIB(dl, dlopen, , )
1485                         AC_CHECK_LIB(pam, pam_set_item, , AC_MSG_ERROR([*** libpam missing]))
1486                         AC_CHECK_FUNCS(pam_getenvlist)
1487                         AC_CHECK_FUNCS(pam_putenv)
1488
1489                         PAM_MSG="yes"
1490
1491                         AC_DEFINE(USE_PAM)
1492                         if test $ac_cv_lib_dl_dlopen = yes; then
1493                                 LIBPAM="-lpam -ldl"
1494                         else
1495                                 LIBPAM="-lpam"
1496                         fi
1497                         AC_SUBST(LIBPAM)
1498                 fi
1499         ]
1500 )
1501
1502 # Check for older PAM
1503 if test "x$PAM_MSG" = "xyes" ; then
1504         # Check PAM strerror arguments (old PAM)
1505         AC_MSG_CHECKING([whether pam_strerror takes only one argument])
1506         AC_TRY_COMPILE(
1507                 [
1508 #include <stdlib.h>
1509 #if defined(HAVE_SECURITY_PAM_APPL_H)
1510 #include <security/pam_appl.h>
1511 #elif defined (HAVE_PAM_PAM_APPL_H)
1512 #include <pam/pam_appl.h>
1513 #endif
1514                 ],
1515                 [(void)pam_strerror((pam_handle_t *)NULL, -1);],
1516                 [AC_MSG_RESULT(no)],
1517                 [
1518                         AC_DEFINE(HAVE_OLD_PAM)
1519                         AC_MSG_RESULT(yes)
1520                         PAM_MSG="yes (old library)"
1521                 ]
1522         )
1523 fi
1524
1525 # Search for OpenSSL
1526 saved_CPPFLAGS="$CPPFLAGS"
1527 saved_LDFLAGS="$LDFLAGS"
1528 AC_ARG_WITH(ssl-dir,
1529         [  --with-ssl-dir=PATH     Specify path to OpenSSL installation ],
1530         [
1531                 if test "x$withval" != "xno" ; then
1532                         case "$withval" in
1533                                 # Relative paths
1534                                 ./*|../*)       withval="`pwd`/$withval"
1535                         esac
1536                         if test -d "$withval/lib"; then
1537                                 if test -n "${need_dash_r}"; then
1538                                         LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
1539                                 else
1540                                         LDFLAGS="-L${withval}/lib ${LDFLAGS}"
1541                                 fi
1542                         else
1543                                 if test -n "${need_dash_r}"; then
1544                                         LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
1545                                 else
1546                                         LDFLAGS="-L${withval} ${LDFLAGS}"
1547                                 fi
1548                         fi
1549                         if test -d "$withval/include"; then
1550                                 CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
1551                         else
1552                                 CPPFLAGS="-I${withval} ${CPPFLAGS}"
1553                         fi
1554                 fi
1555         ]
1556 )
1557 LIBS="-lcrypto $LIBS"
1558 AC_TRY_LINK_FUNC(RAND_add, AC_DEFINE(HAVE_OPENSSL),
1559         [
1560                 dnl Check default openssl install dir
1561                 if test -n "${need_dash_r}"; then
1562                         LDFLAGS="-L/usr/local/ssl/lib -R/usr/local/ssl/lib ${saved_LDFLAGS}"
1563                 else
1564                         LDFLAGS="-L/usr/local/ssl/lib ${saved_LDFLAGS}"
1565                 fi
1566                 CPPFLAGS="-I/usr/local/ssl/include ${saved_CPPFLAGS}"
1567                 AC_TRY_LINK_FUNC(RAND_add, AC_DEFINE(HAVE_OPENSSL),
1568                         [
1569                                 AC_MSG_ERROR([*** Can't find recent OpenSSL libcrypto (see config.log for details) ***])
1570                         ]
1571                 )
1572         ]
1573 )
1574
1575 # Determine OpenSSL header version
1576 AC_MSG_CHECKING([OpenSSL header version])
1577 AC_RUN_IFELSE(
1578         [AC_LANG_SOURCE([[
1579 #include <stdio.h>
1580 #include <string.h>
1581 #include <openssl/opensslv.h>
1582 #define DATA "conftest.sslincver"
1583 int main(void) {
1584         FILE *fd;
1585         int rc;
1586
1587         fd = fopen(DATA,"w");
1588         if(fd == NULL)
1589                 exit(1);
1590
1591         if ((rc = fprintf(fd ,"%x (%s)\n", OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_TEXT)) <0)
1592                 exit(1);
1593
1594         exit(0);
1595 }
1596         ]])],
1597         [
1598                 ssl_header_ver=`cat conftest.sslincver`
1599                 AC_MSG_RESULT($ssl_header_ver)
1600         ],
1601         [
1602                 AC_MSG_RESULT(not found)
1603                 AC_MSG_ERROR(OpenSSL version header not found.)
1604         ],
1605         [
1606                 AC_MSG_WARN([cross compiling: not checking])
1607         ]
1608 )
1609
1610 # Determine OpenSSL library version
1611 AC_MSG_CHECKING([OpenSSL library version])
1612 AC_RUN_IFELSE(
1613         [AC_LANG_SOURCE([[
1614 #include <stdio.h>
1615 #include <string.h>
1616 #include <openssl/opensslv.h>
1617 #include <openssl/crypto.h>
1618 #define DATA "conftest.ssllibver"
1619 int main(void) {
1620         FILE *fd;
1621         int rc;
1622
1623         fd = fopen(DATA,"w");
1624         if(fd == NULL)
1625                 exit(1);
1626
1627         if ((rc = fprintf(fd ,"%x (%s)\n", SSLeay(), SSLeay_version(SSLEAY_VERSION))) <0)
1628                 exit(1);
1629
1630         exit(0);
1631 }
1632         ]])],
1633         [
1634                 ssl_library_ver=`cat conftest.ssllibver`
1635                 AC_MSG_RESULT($ssl_library_ver)
1636         ],
1637         [
1638                 AC_MSG_RESULT(not found)
1639                 AC_MSG_ERROR(OpenSSL library not found.)
1640         ],
1641         [
1642                 AC_MSG_WARN([cross compiling: not checking])
1643         ]
1644 )
1645
1646 # Sanity check OpenSSL headers
1647 AC_MSG_CHECKING([whether OpenSSL's headers match the library])
1648 AC_RUN_IFELSE(
1649         [AC_LANG_SOURCE([[
1650 #include <string.h>
1651 #include <openssl/opensslv.h>
1652 int main(void) { exit(SSLeay() == OPENSSL_VERSION_NUMBER ? 0 : 1); }
1653         ]])],
1654         [
1655                 AC_MSG_RESULT(yes)
1656         ],
1657         [
1658                 AC_MSG_RESULT(no)
1659                 AC_MSG_ERROR([Your OpenSSL headers do not match your library.
1660 Check config.log for details.
1661 Also see contrib/findssl.sh for help identifying header/library mismatches.])
1662         ],
1663         [
1664                 AC_MSG_WARN([cross compiling: not checking])
1665         ]
1666 )
1667
1668 # Some systems want crypt() from libcrypt, *not* the version in OpenSSL,
1669 # because the system crypt() is more featureful.
1670 if test "x$check_for_libcrypt_before" = "x1"; then
1671         AC_CHECK_LIB(crypt, crypt)
1672 fi
1673
1674 # Some Linux systems (Slackware) need crypt() from libcrypt, *not* the
1675 # version in OpenSSL.
1676 if test "x$check_for_libcrypt_later" = "x1"; then
1677         AC_CHECK_LIB(crypt, crypt, LIBS="$LIBS -lcrypt")
1678 fi
1679
1680
1681 ### Configure cryptographic random number support
1682
1683 # Check wheter OpenSSL seeds itself
1684 AC_MSG_CHECKING([whether OpenSSL's PRNG is internally seeded])
1685 AC_RUN_IFELSE(
1686         [AC_LANG_SOURCE([[
1687 #include <string.h>
1688 #include <openssl/rand.h>
1689 int main(void) { exit(RAND_status() == 1 ? 0 : 1); }
1690         ]])],
1691         [
1692                 OPENSSL_SEEDS_ITSELF=yes
1693                 AC_MSG_RESULT(yes)
1694         ],
1695         [
1696                 AC_MSG_RESULT(no)
1697                 # Default to use of the rand helper if OpenSSL doesn't
1698                 # seed itself
1699                 USE_RAND_HELPER=yes
1700         ],
1701         [
1702                 AC_MSG_WARN([cross compiling: assuming yes])
1703                 # This is safe, since all recent OpenSSL versions will
1704                 # complain at runtime if not seeded correctly.
1705                 OPENSSL_SEEDS_ITSELF=yes
1706         ]
1707 )
1708
1709
1710 # Do we want to force the use of the rand helper?
1711 AC_ARG_WITH(rand-helper,
1712         [  --with-rand-helper      Use subprocess to gather strong randomness ],
1713         [
1714                 if test "x$withval" = "xno" ; then
1715                         # Force use of OpenSSL's internal RNG, even if
1716                         # the previous test showed it to be unseeded.
1717                         if test -z "$OPENSSL_SEEDS_ITSELF" ; then
1718                                 AC_MSG_WARN([*** Forcing use of OpenSSL's non-self-seeding PRNG])
1719                                 OPENSSL_SEEDS_ITSELF=yes
1720                                 USE_RAND_HELPER=""
1721                         fi
1722                 else
1723                         USE_RAND_HELPER=yes
1724                 fi
1725         ],
1726 )
1727
1728 # Which randomness source do we use?
1729 if test ! -z "$OPENSSL_SEEDS_ITSELF" && test -z "$USE_RAND_HELPER" ; then
1730         # OpenSSL only
1731         AC_DEFINE(OPENSSL_PRNG_ONLY)
1732         RAND_MSG="OpenSSL internal ONLY"
1733         INSTALL_SSH_RAND_HELPER=""
1734 elif test ! -z "$USE_RAND_HELPER" ; then
1735         # install rand helper
1736         RAND_MSG="ssh-rand-helper"
1737         INSTALL_SSH_RAND_HELPER="yes"
1738 fi
1739 AC_SUBST(INSTALL_SSH_RAND_HELPER)
1740
1741 ### Configuration of ssh-rand-helper
1742
1743 # PRNGD TCP socket
1744 AC_ARG_WITH(prngd-port,
1745         [  --with-prngd-port=PORT  read entropy from PRNGD/EGD TCP localhost:PORT],
1746         [
1747                 case "$withval" in
1748                 no)
1749                         withval=""
1750                         ;;
1751                 [[0-9]]*)
1752                         ;;
1753                 *)
1754                         AC_MSG_ERROR(You must specify a numeric port number for --with-prngd-port)
1755                         ;;
1756                 esac
1757                 if test ! -z "$withval" ; then
1758                         PRNGD_PORT="$withval"
1759                         AC_DEFINE_UNQUOTED(PRNGD_PORT, $PRNGD_PORT)
1760                 fi
1761         ]
1762 )
1763
1764 # PRNGD Unix domain socket
1765 AC_ARG_WITH(prngd-socket,
1766         [  --with-prngd-socket=FILE read entropy from PRNGD/EGD socket FILE (default=/var/run/egd-pool)],
1767         [
1768                 case "$withval" in
1769                 yes)
1770                         withval="/var/run/egd-pool"
1771                         ;;
1772                 no)
1773                         withval=""
1774                         ;;
1775                 /*)
1776                         ;;
1777                 *)
1778                         AC_MSG_ERROR(You must specify an absolute path to the entropy socket)
1779                         ;;
1780                 esac
1781
1782                 if test ! -z "$withval" ; then
1783                         if test ! -z "$PRNGD_PORT" ; then
1784                                 AC_MSG_ERROR(You may not specify both a PRNGD/EGD port and socket)
1785                         fi
1786                         if test ! -r "$withval" ; then
1787                                 AC_MSG_WARN(Entropy socket is not readable)
1788                         fi
1789                         PRNGD_SOCKET="$withval"
1790                         AC_DEFINE_UNQUOTED(PRNGD_SOCKET, "$PRNGD_SOCKET")
1791                 fi
1792         ],
1793         [
1794                 # Check for existing socket only if we don't have a random device already
1795                 if test "$USE_RAND_HELPER" = yes ; then
1796                         AC_MSG_CHECKING(for PRNGD/EGD socket)
1797                         # Insert other locations here
1798                         for sock in /var/run/egd-pool /dev/egd-pool /etc/entropy; do
1799                                 if test -r $sock && $TEST_MINUS_S_SH -c "test -S $sock -o -p $sock" ; then
1800                                         PRNGD_SOCKET="$sock"
1801                                         AC_DEFINE_UNQUOTED(PRNGD_SOCKET, "$PRNGD_SOCKET")
1802                                         break;
1803                                 fi
1804                         done
1805                         if test ! -z "$PRNGD_SOCKET" ; then
1806                                 AC_MSG_RESULT($PRNGD_SOCKET)
1807                         else
1808                                 AC_MSG_RESULT(not found)
1809                         fi
1810                 fi
1811         ]
1812 )
1813
1814 # Change default command timeout for hashing entropy source
1815 entropy_timeout=200
1816 AC_ARG_WITH(entropy-timeout,
1817         [  --with-entropy-timeout  Specify entropy gathering command timeout (msec)],
1818         [
1819                 if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
1820                     test "x${withval}" != "xyes"; then
1821                         entropy_timeout=$withval
1822                 fi
1823         ]
1824 )
1825 AC_DEFINE_UNQUOTED(ENTROPY_TIMEOUT_MSEC, $entropy_timeout)
1826
1827 SSH_PRIVSEP_USER=sshd
1828 AC_ARG_WITH(privsep-user,
1829         [  --with-privsep-user=user Specify non-privileged user for privilege separation],
1830         [
1831                 if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
1832                     test "x${withval}" != "xyes"; then
1833                         SSH_PRIVSEP_USER=$withval
1834                 fi
1835         ]
1836 )
1837 AC_DEFINE_UNQUOTED(SSH_PRIVSEP_USER, "$SSH_PRIVSEP_USER")
1838 AC_SUBST(SSH_PRIVSEP_USER)
1839
1840 # We do this little dance with the search path to insure
1841 # that programs that we select for use by installed programs
1842 # (which may be run by the super-user) come from trusted
1843 # locations before they come from the user's private area.
1844 # This should help avoid accidentally configuring some
1845 # random version of a program in someone's personal bin.
1846
1847 OPATH=$PATH
1848 PATH=/bin:/usr/bin
1849 test -h /bin 2> /dev/null && PATH=/usr/bin
1850 test -d /sbin && PATH=$PATH:/sbin
1851 test -d /usr/sbin && PATH=$PATH:/usr/sbin
1852 PATH=$PATH:/etc:$OPATH
1853
1854 # These programs are used by the command hashing source to gather entropy
1855 OSSH_PATH_ENTROPY_PROG(PROG_LS, ls)
1856 OSSH_PATH_ENTROPY_PROG(PROG_NETSTAT, netstat)
1857 OSSH_PATH_ENTROPY_PROG(PROG_ARP, arp)
1858 OSSH_PATH_ENTROPY_PROG(PROG_IFCONFIG, ifconfig)
1859 OSSH_PATH_ENTROPY_PROG(PROG_JSTAT, jstat)
1860 OSSH_PATH_ENTROPY_PROG(PROG_PS, ps)
1861 OSSH_PATH_ENTROPY_PROG(PROG_SAR, sar)
1862 OSSH_PATH_ENTROPY_PROG(PROG_W, w)
1863 OSSH_PATH_ENTROPY_PROG(PROG_WHO, who)
1864 OSSH_PATH_ENTROPY_PROG(PROG_LAST, last)
1865 OSSH_PATH_ENTROPY_PROG(PROG_LASTLOG, lastlog)
1866 OSSH_PATH_ENTROPY_PROG(PROG_DF, df)
1867 OSSH_PATH_ENTROPY_PROG(PROG_VMSTAT, vmstat)
1868 OSSH_PATH_ENTROPY_PROG(PROG_UPTIME, uptime)
1869 OSSH_PATH_ENTROPY_PROG(PROG_IPCS, ipcs)
1870 OSSH_PATH_ENTROPY_PROG(PROG_TAIL, tail)
1871 # restore PATH
1872 PATH=$OPATH
1873
1874 # Where does ssh-rand-helper get its randomness from?
1875 INSTALL_SSH_PRNG_CMDS=""
1876 if test ! -z "$INSTALL_SSH_RAND_HELPER" ; then
1877         if test ! -z "$PRNGD_PORT" ; then
1878                 RAND_HELPER_MSG="TCP localhost:$PRNGD_PORT"
1879         elif test ! -z "$PRNGD_SOCKET" ; then
1880                 RAND_HELPER_MSG="Unix domain socket \"$PRNGD_SOCKET\""
1881         else
1882                 RAND_HELPER_MSG="Command hashing (timeout $entropy_timeout)"
1883                 RAND_HELPER_CMDHASH=yes
1884                 INSTALL_SSH_PRNG_CMDS="yes"
1885         fi
1886 fi
1887 AC_SUBST(INSTALL_SSH_PRNG_CMDS)
1888
1889
1890 # Cheap hack to ensure NEWS-OS libraries are arranged right.
1891 if test ! -z "$SONY" ; then
1892   LIBS="$LIBS -liberty";
1893 fi
1894
1895 # Checks for data types
1896 AC_CHECK_SIZEOF(char, 1)
1897 AC_CHECK_SIZEOF(short int, 2)
1898 AC_CHECK_SIZEOF(int, 4)
1899 AC_CHECK_SIZEOF(long int, 4)
1900 AC_CHECK_SIZEOF(long long int, 8)
1901
1902 # Sanity check long long for some platforms (AIX)
1903 if test "x$ac_cv_sizeof_long_long_int" = "x4" ; then
1904         ac_cv_sizeof_long_long_int=0
1905 fi
1906
1907 # More checks for data types
1908 AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [
1909         AC_TRY_COMPILE(
1910                 [ #include <sys/types.h> ],
1911                 [ u_int a; a = 1;],
1912                 [ ac_cv_have_u_int="yes" ],
1913                 [ ac_cv_have_u_int="no" ]
1914         )
1915 ])
1916 if test "x$ac_cv_have_u_int" = "xyes" ; then
1917         AC_DEFINE(HAVE_U_INT)
1918         have_u_int=1
1919 fi
1920
1921 AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [
1922         AC_TRY_COMPILE(
1923                 [ #include <sys/types.h> ],
1924                 [ int8_t a; int16_t b; int32_t c; a = b = c = 1;],
1925                 [ ac_cv_have_intxx_t="yes" ],
1926                 [ ac_cv_have_intxx_t="no" ]
1927         )
1928 ])
1929 if test "x$ac_cv_have_intxx_t" = "xyes" ; then
1930         AC_DEFINE(HAVE_INTXX_T)
1931         have_intxx_t=1
1932 fi
1933
1934 if (test -z "$have_intxx_t" && \
1935            test "x$ac_cv_header_stdint_h" = "xyes")
1936 then
1937     AC_MSG_CHECKING([for intXX_t types in stdint.h])
1938         AC_TRY_COMPILE(
1939                 [ #include <stdint.h> ],
1940                 [ int8_t a; int16_t b; int32_t c; a = b = c = 1;],
1941                 [
1942                         AC_DEFINE(HAVE_INTXX_T)
1943                         AC_MSG_RESULT(yes)
1944                 ],
1945                 [ AC_MSG_RESULT(no) ]
1946         )
1947 fi
1948
1949 AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [
1950         AC_TRY_COMPILE(
1951                 [
1952 #include <sys/types.h>
1953 #ifdef HAVE_STDINT_H
1954 # include <stdint.h>
1955 #endif
1956 #include <sys/socket.h>
1957 #ifdef HAVE_SYS_BITYPES_H
1958 # include <sys/bitypes.h>
1959 #endif
1960                 ],
1961                 [ int64_t a; a = 1;],
1962                 [ ac_cv_have_int64_t="yes" ],
1963                 [ ac_cv_have_int64_t="no" ]
1964         )
1965 ])
1966 if test "x$ac_cv_have_int64_t" = "xyes" ; then
1967         AC_DEFINE(HAVE_INT64_T)
1968 fi
1969
1970 AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [
1971         AC_TRY_COMPILE(
1972                 [ #include <sys/types.h> ],
1973                 [ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;],
1974                 [ ac_cv_have_u_intxx_t="yes" ],
1975                 [ ac_cv_have_u_intxx_t="no" ]
1976         )
1977 ])
1978 if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
1979         AC_DEFINE(HAVE_U_INTXX_T)
1980         have_u_intxx_t=1
1981 fi
1982
1983 if test -z "$have_u_intxx_t" ; then
1984     AC_MSG_CHECKING([for u_intXX_t types in sys/socket.h])
1985         AC_TRY_COMPILE(
1986                 [ #include <sys/socket.h> ],
1987                 [ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;],
1988                 [
1989                         AC_DEFINE(HAVE_U_INTXX_T)
1990                         AC_MSG_RESULT(yes)
1991                 ],
1992                 [ AC_MSG_RESULT(no) ]
1993         )
1994 fi
1995
1996 AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [
1997         AC_TRY_COMPILE(
1998                 [ #include <sys/types.h> ],
1999                 [ u_int64_t a; a = 1;],
2000                 [ ac_cv_have_u_int64_t="yes" ],
2001                 [ ac_cv_have_u_int64_t="no" ]
2002         )
2003 ])
2004 if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
2005         AC_DEFINE(HAVE_U_INT64_T)
2006         have_u_int64_t=1
2007 fi
2008
2009 if test -z "$have_u_int64_t" ; then
2010     AC_MSG_CHECKING([for u_int64_t type in sys/bitypes.h])
2011         AC_TRY_COMPILE(
2012                 [ #include <sys/bitypes.h> ],
2013                 [ u_int64_t a; a = 1],
2014                 [
2015                         AC_DEFINE(HAVE_U_INT64_T)
2016                         AC_MSG_RESULT(yes)
2017                 ],
2018                 [ AC_MSG_RESULT(no) ]
2019         )
2020 fi
2021
2022 if test -z "$have_u_intxx_t" ; then
2023         AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [
2024                 AC_TRY_COMPILE(
2025                         [
2026 #include <sys/types.h>
2027                         ],
2028                         [ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1; ],
2029                         [ ac_cv_have_uintxx_t="yes" ],
2030                         [ ac_cv_have_uintxx_t="no" ]
2031                 )
2032         ])
2033         if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
2034                 AC_DEFINE(HAVE_UINTXX_T)
2035         fi
2036 fi
2037
2038 if test -z "$have_uintxx_t" ; then
2039     AC_MSG_CHECKING([for uintXX_t types in stdint.h])
2040         AC_TRY_COMPILE(
2041                 [ #include <stdint.h> ],
2042                 [ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;],
2043                 [
2044                         AC_DEFINE(HAVE_UINTXX_T)
2045                         AC_MSG_RESULT(yes)
2046                 ],
2047                 [ AC_MSG_RESULT(no) ]
2048         )
2049 fi
2050
2051 if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
2052            test "x$ac_cv_header_sys_bitypes_h" = "xyes")
2053 then
2054         AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
2055         AC_TRY_COMPILE(
2056                 [
2057 #include <sys/bitypes.h>
2058                 ],
2059                 [
2060                         int8_t a; int16_t b; int32_t c;
2061                         u_int8_t e; u_int16_t f; u_int32_t g;
2062                         a = b = c = e = f = g = 1;
2063                 ],
2064                 [
2065                         AC_DEFINE(HAVE_U_INTXX_T)
2066                         AC_DEFINE(HAVE_INTXX_T)
2067                         AC_MSG_RESULT(yes)
2068                 ],
2069                 [AC_MSG_RESULT(no)]
2070         )
2071 fi
2072
2073
2074 AC_CACHE_CHECK([for u_char], ac_cv_have_u_char, [
2075         AC_TRY_COMPILE(
2076                 [
2077 #include <sys/types.h>
2078                 ],
2079                 [ u_char foo; foo = 125; ],
2080                 [ ac_cv_have_u_char="yes" ],
2081                 [ ac_cv_have_u_char="no" ]
2082         )
2083 ])
2084 if test "x$ac_cv_have_u_char" = "xyes" ; then
2085         AC_DEFINE(HAVE_U_CHAR)
2086 fi
2087
2088 TYPE_SOCKLEN_T
2089
2090 AC_CHECK_TYPES(sig_atomic_t,,,[#include <signal.h>])
2091
2092 AC_CHECK_TYPES(in_addr_t,,,
2093 [#include <sys/types.h>
2094 #include <netinet/in.h>])
2095
2096 AC_CACHE_CHECK([for size_t], ac_cv_have_size_t, [
2097         AC_TRY_COMPILE(
2098                 [
2099 #include <sys/types.h>
2100                 ],
2101                 [ size_t foo; foo = 1235; ],
2102                 [ ac_cv_have_size_t="yes" ],
2103                 [ ac_cv_have_size_t="no" ]
2104         )
2105 ])
2106 if test "x$ac_cv_have_size_t" = "xyes" ; then
2107         AC_DEFINE(HAVE_SIZE_T)
2108 fi
2109
2110 AC_CACHE_CHECK([for ssize_t], ac_cv_have_ssize_t, [
2111         AC_TRY_COMPILE(
2112                 [
2113 #include <sys/types.h>
2114                 ],
2115                 [ ssize_t foo; foo = 1235; ],
2116                 [ ac_cv_have_ssize_t="yes" ],
2117                 [ ac_cv_have_ssize_t="no" ]
2118         )
2119 ])
2120 if test "x$ac_cv_have_ssize_t" = "xyes" ; then
2121         AC_DEFINE(HAVE_SSIZE_T)
2122 fi
2123
2124 AC_CACHE_CHECK([for clock_t], ac_cv_have_clock_t, [
2125         AC_TRY_COMPILE(
2126                 [
2127 #include <time.h>
2128                 ],
2129                 [ clock_t foo; foo = 1235; ],
2130                 [ ac_cv_have_clock_t="yes" ],
2131                 [ ac_cv_have_clock_t="no" ]
2132         )
2133 ])
2134 if test "x$ac_cv_have_clock_t" = "xyes" ; then
2135         AC_DEFINE(HAVE_CLOCK_T)
2136 fi
2137
2138 AC_CACHE_CHECK([for sa_family_t], ac_cv_have_sa_family_t, [
2139         AC_TRY_COMPILE(
2140                 [
2141 #include <sys/types.h>
2142 #include <sys/socket.h>
2143                 ],
2144                 [ sa_family_t foo; foo = 1235; ],
2145                 [ ac_cv_have_sa_family_t="yes" ],
2146                 [ AC_TRY_COMPILE(
2147                   [
2148 #include <sys/types.h>
2149 #include <sys/socket.h>
2150 #include <netinet/in.h>
2151                 ],
2152                 [ sa_family_t foo; foo = 1235; ],
2153                 [ ac_cv_have_sa_family_t="yes" ],
2154
2155                 [ ac_cv_have_sa_family_t="no" ]
2156         )]
2157         )
2158 ])
2159 if test "x$ac_cv_have_sa_family_t" = "xyes" ; then
2160         AC_DEFINE(HAVE_SA_FAMILY_T)
2161 fi
2162
2163 AC_CACHE_CHECK([for pid_t], ac_cv_have_pid_t, [
2164         AC_TRY_COMPILE(
2165                 [
2166 #include <sys/types.h>
2167                 ],
2168                 [ pid_t foo; foo = 1235; ],
2169                 [ ac_cv_have_pid_t="yes" ],
2170                 [ ac_cv_have_pid_t="no" ]
2171         )
2172 ])
2173 if test "x$ac_cv_have_pid_t" = "xyes" ; then
2174         AC_DEFINE(HAVE_PID_T)
2175 fi
2176
2177 AC_CACHE_CHECK([for mode_t], ac_cv_have_mode_t, [
2178         AC_TRY_COMPILE(
2179                 [
2180 #include <sys/types.h>
2181                 ],
2182                 [ mode_t foo; foo = 1235; ],
2183                 [ ac_cv_have_mode_t="yes" ],
2184                 [ ac_cv_have_mode_t="no" ]
2185         )
2186 ])
2187 if test "x$ac_cv_have_mode_t" = "xyes" ; then
2188         AC_DEFINE(HAVE_MODE_T)
2189 fi
2190
2191
2192 AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_have_struct_sockaddr_storage, [
2193         AC_TRY_COMPILE(
2194                 [
2195 #include <sys/types.h>
2196 #include <sys/socket.h>
2197                 ],
2198                 [ struct sockaddr_storage s; ],
2199                 [ ac_cv_have_struct_sockaddr_storage="yes" ],
2200                 [ ac_cv_have_struct_sockaddr_storage="no" ]
2201         )
2202 ])
2203 if test "x$ac_cv_have_struct_sockaddr_storage" = "xyes" ; then
2204         AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE)
2205 fi
2206
2207 AC_CACHE_CHECK([for struct sockaddr_in6], ac_cv_have_struct_sockaddr_in6, [
2208         AC_TRY_COMPILE(
2209                 [
2210 #include <sys/types.h>
2211 #include <netinet/in.h>
2212                 ],
2213                 [ struct sockaddr_in6 s; s.sin6_family = 0; ],
2214                 [ ac_cv_have_struct_sockaddr_in6="yes" ],
2215                 [ ac_cv_have_struct_sockaddr_in6="no" ]
2216         )
2217 ])
2218 if test "x$ac_cv_have_struct_sockaddr_in6" = "xyes" ; then
2219         AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6)
2220 fi
2221
2222 AC_CACHE_CHECK([for struct in6_addr], ac_cv_have_struct_in6_addr, [
2223         AC_TRY_COMPILE(
2224                 [
2225 #include <sys/types.h>
2226 #include <netinet/in.h>
2227                 ],
2228                 [ struct in6_addr s; s.s6_addr[0] = 0; ],
2229                 [ ac_cv_have_struct_in6_addr="yes" ],
2230                 [ ac_cv_have_struct_in6_addr="no" ]
2231         )
2232 ])
2233 if test "x$ac_cv_have_struct_in6_addr" = "xyes" ; then
2234         AC_DEFINE(HAVE_STRUCT_IN6_ADDR)
2235 fi
2236
2237 AC_CACHE_CHECK([for struct addrinfo], ac_cv_have_struct_addrinfo, [
2238         AC_TRY_COMPILE(
2239                 [
2240 #include <sys/types.h>
2241 #include <sys/socket.h>
2242 #include <netdb.h>
2243                 ],
2244                 [ struct addrinfo s; s.ai_flags = AI_PASSIVE; ],
2245                 [ ac_cv_have_struct_addrinfo="yes" ],
2246                 [ ac_cv_have_struct_addrinfo="no" ]
2247         )
2248 ])
2249 if test "x$ac_cv_have_struct_addrinfo" = "xyes" ; then
2250         AC_DEFINE(HAVE_STRUCT_ADDRINFO)
2251 fi
2252
2253 AC_CACHE_CHECK([for struct timeval], ac_cv_have_struct_timeval, [
2254         AC_TRY_COMPILE(
2255                 [ #include <sys/time.h> ],
2256                 [ struct timeval tv; tv.tv_sec = 1;],
2257                 [ ac_cv_have_struct_timeval="yes" ],
2258                 [ ac_cv_have_struct_timeval="no" ]
2259         )
2260 ])
2261 if test "x$ac_cv_have_struct_timeval" = "xyes" ; then
2262         AC_DEFINE(HAVE_STRUCT_TIMEVAL)
2263         have_struct_timeval=1
2264 fi
2265
2266 AC_CHECK_TYPES(struct timespec)
2267
2268 # We need int64_t or else certian parts of the compile will fail.
2269 if test "x$ac_cv_have_int64_t" = "xno" && \
2270         test "x$ac_cv_sizeof_long_int" != "x8" && \
2271         test "x$ac_cv_sizeof_long_long_int" = "x0" ; then
2272         echo "OpenSSH requires int64_t support.  Contact your vendor or install"
2273         echo "an alternative compiler (I.E., GCC) before continuing."
2274         echo ""
2275         exit 1;
2276 else
2277 dnl test snprintf (broken on SCO w/gcc)
2278         AC_RUN_IFELSE(
2279                 [AC_LANG_SOURCE([[
2280 #include <stdio.h>
2281 #include <string.h>
2282 #ifdef HAVE_SNPRINTF
2283 main()
2284 {
2285         char buf[50];
2286         char expected_out[50];
2287         int mazsize = 50 ;
2288 #if (SIZEOF_LONG_INT == 8)
2289         long int num = 0x7fffffffffffffff;
2290 #else
2291         long long num = 0x7fffffffffffffffll;
2292 #endif
2293         strcpy(expected_out, "9223372036854775807");
2294         snprintf(buf, mazsize, "%lld", num);
2295         if(strcmp(buf, expected_out) != 0)
2296                 exit(1);
2297         exit(0);
2298 }
2299 #else
2300 main() { exit(0); }
2301 #endif
2302                 ]])], [ true ], [ AC_DEFINE(BROKEN_SNPRINTF) ],
2303                 AC_MSG_WARN([cross compiling: Assuming working snprintf()])
2304         )
2305 fi
2306
2307 dnl Checks for structure members
2308 OSSH_CHECK_HEADER_FOR_FIELD(ut_host, utmp.h, HAVE_HOST_IN_UTMP)
2309 OSSH_CHECK_HEADER_FOR_FIELD(ut_host, utmpx.h, HAVE_HOST_IN_UTMPX)
2310 OSSH_CHECK_HEADER_FOR_FIELD(syslen, utmpx.h, HAVE_SYSLEN_IN_UTMPX)
2311 OSSH_CHECK_HEADER_FOR_FIELD(ut_pid, utmp.h, HAVE_PID_IN_UTMP)
2312 OSSH_CHECK_HEADER_FOR_FIELD(ut_type, utmp.h, HAVE_TYPE_IN_UTMP)
2313 OSSH_CHECK_HEADER_FOR_FIELD(ut_type, utmpx.h, HAVE_TYPE_IN_UTMPX)
2314 OSSH_CHECK_HEADER_FOR_FIELD(ut_tv, utmp.h, HAVE_TV_IN_UTMP)
2315 OSSH_CHECK_HEADER_FOR_FIELD(ut_id, utmp.h, HAVE_ID_IN_UTMP)
2316 OSSH_CHECK_HEADER_FOR_FIELD(ut_id, utmpx.h, HAVE_ID_IN_UTMPX)
2317 OSSH_CHECK_HEADER_FOR_FIELD(ut_addr, utmp.h, HAVE_ADDR_IN_UTMP)
2318 OSSH_CHECK_HEADER_FOR_FIELD(ut_addr, utmpx.h, HAVE_ADDR_IN_UTMPX)
2319 OSSH_CHECK_HEADER_FOR_FIELD(ut_addr_v6, utmp.h, HAVE_ADDR_V6_IN_UTMP)
2320 OSSH_CHECK_HEADER_FOR_FIELD(ut_addr_v6, utmpx.h, HAVE_ADDR_V6_IN_UTMPX)
2321 OSSH_CHECK_HEADER_FOR_FIELD(ut_exit, utmp.h, HAVE_EXIT_IN_UTMP)
2322 OSSH_CHECK_HEADER_FOR_FIELD(ut_time, utmp.h, HAVE_TIME_IN_UTMP)
2323 OSSH_CHECK_HEADER_FOR_FIELD(ut_time, utmpx.h, HAVE_TIME_IN_UTMPX)
2324 OSSH_CHECK_HEADER_FOR_FIELD(ut_tv, utmpx.h, HAVE_TV_IN_UTMPX)
2325
2326 AC_CHECK_MEMBERS([struct stat.st_blksize])
2327
2328 AC_CACHE_CHECK([for ss_family field in struct sockaddr_storage],
2329                 ac_cv_have_ss_family_in_struct_ss, [
2330         AC_TRY_COMPILE(
2331                 [
2332 #include <sys/types.h>
2333 #include <sys/socket.h>
2334                 ],
2335                 [ struct sockaddr_storage s; s.ss_family = 1; ],
2336                 [ ac_cv_have_ss_family_in_struct_ss="yes" ],
2337                 [ ac_cv_have_ss_family_in_struct_ss="no" ],
2338         )
2339 ])
2340 if test "x$ac_cv_have_ss_family_in_struct_ss" = "xyes" ; then
2341         AC_DEFINE(HAVE_SS_FAMILY_IN_SS)
2342 fi
2343
2344 AC_CACHE_CHECK([for __ss_family field in struct sockaddr_storage],
2345                 ac_cv_have___ss_family_in_struct_ss, [
2346         AC_TRY_COMPILE(
2347                 [
2348 #include <sys/types.h>
2349 #include <sys/socket.h>
2350                 ],
2351                 [ struct sockaddr_storage s; s.__ss_family = 1; ],
2352                 [ ac_cv_have___ss_family_in_struct_ss="yes" ],
2353                 [ ac_cv_have___ss_family_in_struct_ss="no" ]
2354         )
2355 ])
2356 if test "x$ac_cv_have___ss_family_in_struct_ss" = "xyes" ; then
2357         AC_DEFINE(HAVE___SS_FAMILY_IN_SS)
2358 fi
2359
2360 AC_CACHE_CHECK([for pw_class field in struct passwd],
2361                 ac_cv_have_pw_class_in_struct_passwd, [
2362         AC_TRY_COMPILE(
2363                 [
2364 #include <pwd.h>
2365                 ],
2366                 [ struct passwd p; p.pw_class = 0; ],
2367                 [ ac_cv_have_pw_class_in_struct_passwd="yes" ],
2368                 [ ac_cv_have_pw_class_in_struct_passwd="no" ]
2369         )
2370 ])
2371 if test "x$ac_cv_have_pw_class_in_struct_passwd" = "xyes" ; then
2372         AC_DEFINE(HAVE_PW_CLASS_IN_PASSWD)
2373 fi
2374
2375 AC_CACHE_CHECK([for pw_expire field in struct passwd],
2376                 ac_cv_have_pw_expire_in_struct_passwd, [
2377         AC_TRY_COMPILE(
2378                 [
2379 #include <pwd.h>
2380                 ],
2381                 [ struct passwd p; p.pw_expire = 0; ],
2382                 [ ac_cv_have_pw_expire_in_struct_passwd="yes" ],
2383                 [ ac_cv_have_pw_expire_in_struct_passwd="no" ]
2384         )
2385 ])
2386 if test "x$ac_cv_have_pw_expire_in_struct_passwd" = "xyes" ; then
2387         AC_DEFINE(HAVE_PW_EXPIRE_IN_PASSWD)
2388 fi
2389
2390 AC_CACHE_CHECK([for pw_change field in struct passwd],
2391                 ac_cv_have_pw_change_in_struct_passwd, [
2392         AC_TRY_COMPILE(
2393                 [
2394 #include <pwd.h>
2395                 ],
2396                 [ struct passwd p; p.pw_change = 0; ],
2397                 [ ac_cv_have_pw_change_in_struct_passwd="yes" ],
2398                 [ ac_cv_have_pw_change_in_struct_passwd="no" ]
2399         )
2400 ])
2401 if test "x$ac_cv_have_pw_change_in_struct_passwd" = "xyes" ; then
2402         AC_DEFINE(HAVE_PW_CHANGE_IN_PASSWD)
2403 fi
2404
2405 dnl make sure we're using the real structure members and not defines
2406 AC_CACHE_CHECK([for msg_accrights field in struct msghdr],
2407                 ac_cv_have_accrights_in_msghdr, [
2408         AC_COMPILE_IFELSE(
2409                 [
2410 #include <sys/types.h>
2411 #include <sys/socket.h>
2412 #include <sys/uio.h>
2413 int main() {
2414 #ifdef msg_accrights
2415 #error "msg_accrights is a macro"
2416 exit(1);
2417 #endif
2418 struct msghdr m;
2419 m.msg_accrights = 0;
2420 exit(0);
2421 }
2422                 ],
2423                 [ ac_cv_have_accrights_in_msghdr="yes" ],
2424                 [ ac_cv_have_accrights_in_msghdr="no" ]
2425         )
2426 ])
2427 if test "x$ac_cv_have_accrights_in_msghdr" = "xyes" ; then
2428         AC_DEFINE(HAVE_ACCRIGHTS_IN_MSGHDR)
2429 fi
2430
2431 AC_CACHE_CHECK([for msg_control field in struct msghdr],
2432                 ac_cv_have_control_in_msghdr, [
2433         AC_COMPILE_IFELSE(
2434                 [
2435 #include <sys/types.h>
2436 #include <sys/socket.h>
2437 #include <sys/uio.h>
2438 int main() {
2439 #ifdef msg_control
2440 #error "msg_control is a macro"
2441 exit(1);
2442 #endif
2443 struct msghdr m;
2444 m.msg_control = 0;
2445 exit(0);
2446 }
2447                 ],
2448                 [ ac_cv_have_control_in_msghdr="yes" ],
2449                 [ ac_cv_have_control_in_msghdr="no" ]
2450         )
2451 ])
2452 if test "x$ac_cv_have_control_in_msghdr" = "xyes" ; then
2453         AC_DEFINE(HAVE_CONTROL_IN_MSGHDR)
2454 fi
2455
2456 AC_CACHE_CHECK([if libc defines __progname], ac_cv_libc_defines___progname, [
2457         AC_TRY_LINK([],
2458                 [ extern char *__progname; printf("%s", __progname); ],
2459                 [ ac_cv_libc_defines___progname="yes" ],
2460                 [ ac_cv_libc_defines___progname="no" ]
2461         )
2462 ])
2463 if test "x$ac_cv_libc_defines___progname" = "xyes" ; then
2464         AC_DEFINE(HAVE___PROGNAME)
2465 fi
2466
2467 AC_CACHE_CHECK([whether $CC implements __FUNCTION__], ac_cv_cc_implements___FUNCTION__, [
2468         AC_TRY_LINK([
2469 #include <stdio.h>
2470 ],
2471                 [ printf("%s", __FUNCTION__); ],
2472                 [ ac_cv_cc_implements___FUNCTION__="yes" ],
2473                 [ ac_cv_cc_implements___FUNCTION__="no" ]
2474         )
2475 ])
2476 if test "x$ac_cv_cc_implements___FUNCTION__" = "xyes" ; then
2477         AC_DEFINE(HAVE___FUNCTION__)
2478 fi
2479
2480 AC_CACHE_CHECK([whether $CC implements __func__], ac_cv_cc_implements___func__, [
2481         AC_TRY_LINK([
2482 #include <stdio.h>
2483 ],
2484                 [ printf("%s", __func__); ],
2485                 [ ac_cv_cc_implements___func__="yes" ],
2486                 [ ac_cv_cc_implements___func__="no" ]
2487         )
2488 ])
2489 if test "x$ac_cv_cc_implements___func__" = "xyes" ; then
2490         AC_DEFINE(HAVE___func__)
2491 fi
2492
2493 AC_CACHE_CHECK([whether getopt has optreset support],
2494                 ac_cv_have_getopt_optreset, [
2495         AC_TRY_LINK(
2496                 [
2497 #include <getopt.h>
2498                 ],
2499                 [ extern int optreset; optreset = 0; ],
2500                 [ ac_cv_have_getopt_optreset="yes" ],
2501                 [ ac_cv_have_getopt_optreset="no" ]
2502         )
2503 ])
2504 if test "x$ac_cv_have_getopt_optreset" = "xyes" ; then
2505         AC_DEFINE(HAVE_GETOPT_OPTRESET)
2506 fi
2507
2508 AC_CACHE_CHECK([if libc defines sys_errlist], ac_cv_libc_defines_sys_errlist, [
2509         AC_TRY_LINK([],
2510                 [ extern const char *const sys_errlist[]; printf("%s", sys_errlist[0]);],
2511                 [ ac_cv_libc_defines_sys_errlist="yes" ],
2512                 [ ac_cv_libc_defines_sys_errlist="no" ]
2513         )
2514 ])
2515 if test "x$ac_cv_libc_defines_sys_errlist" = "xyes" ; then
2516         AC_DEFINE(HAVE_SYS_ERRLIST)
2517 fi
2518
2519
2520 AC_CACHE_CHECK([if libc defines sys_nerr], ac_cv_libc_defines_sys_nerr, [
2521         AC_TRY_LINK([],
2522                 [ extern int sys_nerr; printf("%i", sys_nerr);],
2523                 [ ac_cv_libc_defines_sys_nerr="yes" ],
2524                 [ ac_cv_libc_defines_sys_nerr="no" ]
2525         )
2526 ])
2527 if test "x$ac_cv_libc_defines_sys_nerr" = "xyes" ; then
2528         AC_DEFINE(HAVE_SYS_NERR)
2529 fi
2530
2531 SCARD_MSG="no"
2532 # Check whether user wants sectok support
2533 AC_ARG_WITH(sectok,
2534         [  --with-sectok           Enable smartcard support using libsectok],
2535         [
2536                 if test "x$withval" != "xno" ; then
2537                         if test "x$withval" != "xyes" ; then
2538                                 CPPFLAGS="$CPPFLAGS -I${withval}"
2539                                 LDFLAGS="$LDFLAGS -L${withval}"
2540                                 if test ! -z "$need_dash_r" ; then
2541                                         LDFLAGS="$LDFLAGS -R${withval}"
2542                                 fi
2543                                 if test ! -z "$blibpath" ; then
2544                                         blibpath="$blibpath:${withval}"
2545                                 fi
2546                         fi
2547                         AC_CHECK_HEADERS(sectok.h)
2548                         if test "$ac_cv_header_sectok_h" != yes; then
2549                                 AC_MSG_ERROR(Can't find sectok.h)
2550                         fi
2551                         AC_CHECK_LIB(sectok, sectok_open)
2552                         if test "$ac_cv_lib_sectok_sectok_open" != yes; then
2553                                 AC_MSG_ERROR(Can't find libsectok)
2554                         fi
2555                         AC_DEFINE(SMARTCARD)
2556                         AC_DEFINE(USE_SECTOK)
2557                         SCARD_MSG="yes, using sectok"
2558                 fi
2559         ]
2560 )
2561
2562 # Check whether user wants OpenSC support
2563 OPENSC_CONFIG="no"
2564 AC_ARG_WITH(opensc,
2565         [--with-opensc[[=PFX]]       Enable smartcard support using OpenSC (optionally in PATH)],
2566         [
2567             if test "x$withval" != "xno" ; then
2568                 if test "x$withval" != "xyes" ; then
2569                         OPENSC_CONFIG=$withval/bin/opensc-config
2570                 else
2571                         AC_PATH_PROG(OPENSC_CONFIG, opensc-config, no)
2572                 fi
2573                 if test "$OPENSC_CONFIG" != "no"; then
2574                         LIBOPENSC_CFLAGS=`$OPENSC_CONFIG --cflags`
2575                         LIBOPENSC_LIBS=`$OPENSC_CONFIG --libs`
2576                         CPPFLAGS="$CPPFLAGS $LIBOPENSC_CFLAGS"
2577                         LDFLAGS="$LDFLAGS $LIBOPENSC_LIBS"
2578                         AC_DEFINE(SMARTCARD)
2579                         AC_DEFINE(USE_OPENSC)
2580                         SCARD_MSG="yes, using OpenSC"
2581                 fi
2582             fi
2583         ]
2584 )
2585
2586 # Check libraries needed by DNS fingerprint support
2587 AC_SEARCH_LIBS(getrrsetbyname, resolv,
2588         [AC_DEFINE(HAVE_GETRRSETBYNAME)],
2589         [
2590                 # Needed by our getrrsetbyname()
2591                 AC_SEARCH_LIBS(res_query, resolv)
2592                 AC_SEARCH_LIBS(dn_expand, resolv)
2593                 AC_MSG_CHECKING(if res_query will link)
2594                 AC_TRY_LINK_FUNC(res_query, AC_MSG_RESULT(yes),
2595                    [AC_MSG_RESULT(no)
2596                     saved_LIBS="$LIBS"
2597                     LIBS="$LIBS -lresolv"
2598                     AC_MSG_CHECKING(for res_query in -lresolv)
2599                     AC_LINK_IFELSE([
2600 #include <resolv.h>
2601 int main()
2602 {
2603         res_query (0, 0, 0, 0, 0);
2604         return 0;
2605 }
2606                         ],
2607                         [LIBS="$LIBS -lresolv"
2608                          AC_MSG_RESULT(yes)],
2609                         [LIBS="$saved_LIBS"
2610                          AC_MSG_RESULT(no)])
2611                     ])
2612                 AC_CHECK_FUNCS(_getshort _getlong)
2613                 AC_CHECK_DECLS([_getshort, _getlong], , ,
2614                     [#include <sys/types.h>
2615                     #include <arpa/nameser.h>])
2616                 AC_CHECK_MEMBER(HEADER.ad,
2617                         [AC_DEFINE(HAVE_HEADER_AD)],,
2618                         [#include <arpa/nameser.h>])
2619         ])
2620
2621 # Check whether user wants Kerberos 5 support
2622 KRB5_MSG="no"
2623 AC_ARG_WITH(kerberos5,
2624         [  --with-kerberos5=PATH   Enable Kerberos 5 support],
2625         [ if test "x$withval" != "xno" ; then
2626                 if test "x$withval" = "xyes" ; then
2627                         KRB5ROOT="/usr/local"
2628                 else
2629                         KRB5ROOT=${withval}
2630                 fi
2631
2632                 AC_DEFINE(KRB5)
2633                 KRB5_MSG="yes"
2634
2635                 AC_MSG_CHECKING(for krb5-config)
2636                 if test -x  $KRB5ROOT/bin/krb5-config ; then
2637                         KRB5CONF=$KRB5ROOT/bin/krb5-config
2638                         AC_MSG_RESULT($KRB5CONF)
2639
2640                         AC_MSG_CHECKING(for gssapi support)
2641                         if $KRB5CONF | grep gssapi >/dev/null ; then
2642                                 AC_MSG_RESULT(yes)
2643                                 AC_DEFINE(GSSAPI)
2644                                 k5confopts=gssapi
2645                         else
2646                                 AC_MSG_RESULT(no)
2647                                 k5confopts=""
2648                         fi
2649                         K5CFLAGS="`$KRB5CONF --cflags $k5confopts`"
2650                         K5LIBS="`$KRB5CONF --libs $k5confopts`"
2651                         CPPFLAGS="$CPPFLAGS $K5CFLAGS"
2652                         AC_MSG_CHECKING(whether we are using Heimdal)
2653                         AC_TRY_COMPILE([ #include <krb5.h> ],
2654                                        [ char *tmp = heimdal_version; ],
2655                                        [ AC_MSG_RESULT(yes)
2656                                          AC_DEFINE(HEIMDAL) ],
2657                                          AC_MSG_RESULT(no)
2658                         )
2659                 else
2660                         AC_MSG_RESULT(no)
2661                         CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include"
2662                         LDFLAGS="$LDFLAGS -L${KRB5ROOT}/lib"
2663                         AC_MSG_CHECKING(whether we are using Heimdal)
2664                         AC_TRY_COMPILE([ #include <krb5.h> ],
2665                                        [ char *tmp = heimdal_version; ],
2666                                        [ AC_MSG_RESULT(yes)
2667                                          AC_DEFINE(HEIMDAL)
2668                                          K5LIBS="-lkrb5 -ldes"
2669                                          K5LIBS="$K5LIBS -lcom_err -lasn1"
2670                                          AC_CHECK_LIB(roken, net_write,
2671                                            [K5LIBS="$K5LIBS -lroken"])
2672                                        ],
2673                                        [ AC_MSG_RESULT(no)
2674                                          K5LIBS="-lkrb5 -lk5crypto -lcom_err"
2675                                        ]
2676                         )
2677                         AC_SEARCH_LIBS(dn_expand, resolv)
2678
2679                         AC_CHECK_LIB(gssapi,gss_init_sec_context,
2680                                 [ AC_DEFINE(GSSAPI)
2681                                   K5LIBS="-lgssapi $K5LIBS" ],
2682                                 [ AC_CHECK_LIB(gssapi_krb5,gss_init_sec_context,
2683                                         [ AC_DEFINE(GSSAPI)
2684                                           K5LIBS="-lgssapi_krb5 $K5LIBS" ],
2685                                         AC_MSG_WARN([Cannot find any suitable gss-api library - build may fail]),
2686                                         $K5LIBS)
2687                                 ],
2688                                 $K5LIBS)
2689
2690                         AC_CHECK_HEADER(gssapi.h, ,
2691                                 [ unset ac_cv_header_gssapi_h
2692                                   CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
2693                                   AC_CHECK_HEADERS(gssapi.h, ,
2694                                         AC_MSG_WARN([Cannot find any suitable gss-api header - build may fail])
2695                                   )
2696                                 ]
2697                         )
2698
2699                         oldCPP="$CPPFLAGS"
2700                         CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
2701                         AC_CHECK_HEADER(gssapi_krb5.h, ,
2702                                         [ CPPFLAGS="$oldCPP" ])
2703
2704                 fi
2705                 if test ! -z "$need_dash_r" ; then
2706                         LDFLAGS="$LDFLAGS -R${KRB5ROOT}/lib"
2707                 fi
2708                 if test ! -z "$blibpath" ; then
2709                         blibpath="$blibpath:${KRB5ROOT}/lib"
2710                 fi
2711         fi
2712
2713         AC_CHECK_HEADERS(gssapi.h gssapi/gssapi.h)
2714         AC_CHECK_HEADERS(gssapi_krb5.h gssapi/gssapi_krb5.h)
2715         AC_CHECK_HEADERS(gssapi_generic.h gssapi/gssapi_generic.h)
2716
2717         LIBS="$LIBS $K5LIBS"
2718         AC_SEARCH_LIBS(k_hasafs, kafs, AC_DEFINE(USE_AFS))
2719         AC_SEARCH_LIBS(krb5_init_ets, $K5LIBS, AC_DEFINE(KRB5_INIT_ETS))
2720         ]
2721 )
2722
2723 # Looking for programs, paths and files
2724
2725 PRIVSEP_PATH=/var/empty
2726 AC_ARG_WITH(privsep-path,
2727         [  --with-privsep-path=xxx Path for privilege separation chroot (default=/var/empty)],
2728         [
2729                 if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
2730                     test "x${withval}" != "xyes"; then
2731                         PRIVSEP_PATH=$withval
2732                 fi
2733         ]
2734 )
2735 AC_SUBST(PRIVSEP_PATH)
2736
2737 AC_ARG_WITH(xauth,
2738         [  --with-xauth=PATH       Specify path to xauth program ],
2739         [
2740                 if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
2741                     test "x${withval}" != "xyes"; then
2742                         xauth_path=$withval
2743                 fi
2744         ],
2745         [
2746                 TestPath="$PATH"
2747                 TestPath="${TestPath}${PATH_SEPARATOR}/usr/X/bin"
2748                 TestPath="${TestPath}${PATH_SEPARATOR}/usr/bin/X11"
2749                 TestPath="${TestPath}${PATH_SEPARATOR}/usr/X11R6/bin"
2750                 TestPath="${TestPath}${PATH_SEPARATOR}/usr/openwin/bin"
2751                 AC_PATH_PROG(xauth_path, xauth, , $TestPath)
2752                 if (test ! -z "$xauth_path" && test -x "/usr/openwin/bin/xauth") ; then
2753                         xauth_path="/usr/openwin/bin/xauth"
2754                 fi
2755         ]
2756 )
2757
2758 STRIP_OPT=-s
2759 AC_ARG_ENABLE(strip,
2760         [  --disable-strip         Disable calling strip(1) on install],
2761         [
2762                 if test "x$enableval" = "xno" ; then
2763                         STRIP_OPT=
2764                 fi
2765         ]
2766 )
2767 AC_SUBST(STRIP_OPT)
2768
2769 if test -z "$xauth_path" ; then
2770         XAUTH_PATH="undefined"
2771         AC_SUBST(XAUTH_PATH)
2772 else
2773         AC_DEFINE_UNQUOTED(XAUTH_PATH, "$xauth_path")
2774         XAUTH_PATH=$xauth_path
2775         AC_SUBST(XAUTH_PATH)
2776 fi
2777
2778 # Check for mail directory (last resort if we cannot get it from headers)
2779 if test ! -z "$MAIL" ; then
2780         maildir=`dirname $MAIL`
2781         AC_DEFINE_UNQUOTED(MAIL_DIRECTORY, "$maildir")
2782 fi
2783
2784 if test ! -z "$cross_compiling" && test "x$cross_compiling" = "xyes"; then
2785         AC_MSG_WARN([cross compiling: Disabling /dev/ptmx test])
2786         disable_ptmx_check=yes
2787 fi
2788 if test -z "$no_dev_ptmx" ; then
2789         if test "x$disable_ptmx_check" != "xyes" ; then
2790                 AC_CHECK_FILE("/dev/ptmx",
2791                         [
2792                                 AC_DEFINE_UNQUOTED(HAVE_DEV_PTMX)
2793                                 have_dev_ptmx=1
2794                         ]
2795                 )
2796         fi
2797 fi
2798
2799 if test ! -z "$cross_compiling" && test "x$cross_compiling" != "xyes"; then
2800         AC_CHECK_FILE("/dev/ptc",
2801                 [
2802                         AC_DEFINE_UNQUOTED(HAVE_DEV_PTS_AND_PTC)
2803                         have_dev_ptc=1
2804                 ]
2805         )
2806 else
2807         AC_MSG_WARN([cross compiling: Disabling /dev/ptc test])
2808 fi
2809
2810 # Options from here on. Some of these are preset by platform above
2811 AC_ARG_WITH(mantype,
2812         [  --with-mantype=man|cat|doc  Set man page type],
2813         [
2814                 case "$withval" in
2815                 man|cat|doc)
2816                         MANTYPE=$withval
2817                         ;;
2818                 *)
2819                         AC_MSG_ERROR(invalid man type: $withval)
2820                         ;;
2821                 esac
2822         ]
2823 )
2824 if test -z "$MANTYPE"; then
2825         TestPath="/usr/bin${PATH_SEPARATOR}/usr/ucb"
2826         AC_PATH_PROGS(NROFF, nroff awf, /bin/false, $TestPath)
2827         if ${NROFF} -mdoc ${srcdir}/ssh.1 >/dev/null 2>&1; then
2828                 MANTYPE=doc
2829         elif ${NROFF} -man ${srcdir}/ssh.1 >/dev/null 2>&1; then
2830                 MANTYPE=man
2831         else
2832                 MANTYPE=cat
2833         fi
2834 fi
2835 AC_SUBST(MANTYPE)
2836 if test "$MANTYPE" = "doc"; then
2837         mansubdir=man;
2838 else
2839         mansubdir=$MANTYPE;
2840 fi
2841 AC_SUBST(mansubdir)
2842
2843 # Check whether to enable MD5 passwords
2844 MD5_MSG="no"
2845 AC_ARG_WITH(md5-passwords,
2846         [  --with-md5-passwords    Enable use of MD5 passwords],
2847         [
2848                 if test "x$withval" != "xno" ; then
2849                         AC_DEFINE(HAVE_MD5_PASSWORDS)
2850                         MD5_MSG="yes"
2851                 fi
2852         ]
2853 )
2854
2855 # Whether to disable shadow password support
2856 AC_ARG_WITH(shadow,
2857         [  --without-shadow        Disable shadow password support],
2858         [
2859                 if test "x$withval" = "xno" ; then
2860                         AC_DEFINE(DISABLE_SHADOW)
2861                         disable_shadow=yes
2862                 fi
2863         ]
2864 )
2865
2866 if test -z "$disable_shadow" ; then
2867         AC_MSG_CHECKING([if the systems has expire shadow information])
2868         AC_TRY_COMPILE(
2869         [
2870 #include <sys/types.h>
2871 #include <shadow.h>
2872         struct spwd sp;
2873         ],[ sp.sp_expire = sp.sp_lstchg = sp.sp_inact = 0; ],
2874         [ sp_expire_available=yes ], []
2875         )
2876
2877         if test "x$sp_expire_available" = "xyes" ; then
2878                 AC_MSG_RESULT(yes)
2879                 AC_DEFINE(HAS_SHADOW_EXPIRE)
2880         else
2881                 AC_MSG_RESULT(no)
2882         fi
2883 fi
2884
2885 # Use ip address instead of hostname in $DISPLAY
2886 if test ! -z "$IPADDR_IN_DISPLAY" ; then
2887         DISPLAY_HACK_MSG="yes"
2888         AC_DEFINE(IPADDR_IN_DISPLAY)
2889 else
2890         DISPLAY_HACK_MSG="no"
2891         AC_ARG_WITH(ipaddr-display,
2892                 [  --with-ipaddr-display   Use ip address instead of hostname in \$DISPLAY],
2893                 [
2894                         if test "x$withval" != "xno" ; then
2895                                 AC_DEFINE(IPADDR_IN_DISPLAY)
2896                                 DISPLAY_HACK_MSG="yes"
2897                         fi
2898                 ]
2899         )
2900 fi
2901
2902 # check for /etc/default/login and use it if present.
2903 AC_ARG_ENABLE(etc-default-login,
2904         [  --disable-etc-default-login Disable using PATH from /etc/default/login [no]],
2905         [ if test "x$enableval" = "xno"; then
2906                 AC_MSG_NOTICE([/etc/default/login handling disabled])
2907                 etc_default_login=no
2908           else
2909                 etc_default_login=yes
2910           fi ],
2911         [ etc_default_login=yes ]
2912 )
2913
2914 if test "x$etc_default_login" != "xno"; then
2915         AC_CHECK_FILE("/etc/default/login",
2916             [ external_path_file=/etc/default/login ])
2917         if test ! -z "$cross_compiling" && test "x$cross_compiling" = "xyes";
2918         then
2919                 AC_MSG_WARN([cross compiling: Disabling /etc/default/login test])
2920         elif test "x$external_path_file" = "x/etc/default/login"; then
2921                 AC_DEFINE(HAVE_ETC_DEFAULT_LOGIN)
2922         fi
2923 fi
2924
2925 dnl BSD systems use /etc/login.conf so --with-default-path= has no effect
2926 if test $ac_cv_func_login_getcapbool = "yes" && \
2927         test $ac_cv_header_login_cap_h = "yes" ; then
2928         external_path_file=/etc/login.conf
2929 fi
2930
2931 # Whether to mess with the default path
2932 SERVER_PATH_MSG="(default)"
2933 AC_ARG_WITH(default-path,
2934         [  --with-default-path=    Specify default \$PATH environment for server],
2935         [
2936                 if test "x$external_path_file" = "x/etc/login.conf" ; then
2937                         AC_MSG_WARN([
2938 --with-default-path=PATH has no effect on this system.
2939 Edit /etc/login.conf instead.])
2940                 elif test "x$withval" != "xno" ; then
2941                         if test ! -z "$external_path_file" ; then
2942                                 AC_MSG_WARN([
2943 --with-default-path=PATH will only be used if PATH is not defined in
2944 $external_path_file .])
2945                         fi
2946                         user_path="$withval"
2947                         SERVER_PATH_MSG="$withval"
2948                 fi
2949         ],
2950         [ if test "x$external_path_file" = "x/etc/login.conf" ; then
2951                 AC_MSG_WARN([Make sure the path to scp is in /etc/login.conf])
2952         else
2953                 if test ! -z "$external_path_file" ; then
2954                         AC_MSG_WARN([
2955 If PATH is defined in $external_path_file, ensure the path to scp is included,
2956 otherwise scp will not work.])
2957                 fi
2958                 AC_TRY_RUN(
2959                         [
2960 /* find out what STDPATH is */
2961 #include <stdio.h>
2962 #ifdef HAVE_PATHS_H
2963 # include <paths.h>
2964 #endif
2965 #ifndef _PATH_STDPATH
2966 # ifdef _PATH_USERPATH  /* Irix */
2967 #  define _PATH_STDPATH _PATH_USERPATH
2968 # else
2969 #  define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
2970 # endif
2971 #endif
2972 #include <sys/types.h>
2973 #include <sys/stat.h>
2974 #include <fcntl.h>
2975 #define DATA "conftest.stdpath"
2976
2977 main()
2978 {
2979         FILE *fd;
2980         int rc;
2981
2982         fd = fopen(DATA,"w");
2983         if(fd == NULL)
2984                 exit(1);
2985
2986         if ((rc = fprintf(fd,"%s", _PATH_STDPATH)) < 0)
2987                 exit(1);
2988
2989         exit(0);
2990 }
2991                 ], [ user_path=`cat conftest.stdpath` ],
2992                 [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ],
2993                 [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ]
2994         )
2995 # make sure $bindir is in USER_PATH so scp will work
2996                 t_bindir=`eval echo ${bindir}`
2997                 case $t_bindir in
2998                         NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$prefix~"` ;;
2999                 esac
3000                 case $t_bindir in
3001                         NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$ac_default_prefix~"` ;;
3002                 esac
3003                 echo $user_path | grep ":$t_bindir"  > /dev/null 2>&1
3004                 if test $? -ne 0  ; then
3005                         echo $user_path | grep "^$t_bindir"  > /dev/null 2>&1
3006                         if test $? -ne 0  ; then
3007                                 user_path=$user_path:$t_bindir
3008                                 AC_MSG_RESULT(Adding $t_bindir to USER_PATH so scp will work)
3009                         fi
3010                 fi
3011         fi ]
3012 )
3013 if test "x$external_path_file" != "x/etc/login.conf" ; then
3014         AC_DEFINE_UNQUOTED(USER_PATH, "$user_path")
3015         AC_SUBST(user_path)
3016 fi
3017
3018 # Set superuser path separately to user path
3019 AC_ARG_WITH(superuser-path,
3020         [  --with-superuser-path=  Specify different path for super-user],
3021         [
3022                 if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
3023                     test "x${withval}" != "xyes"; then
3024                         AC_DEFINE_UNQUOTED(SUPERUSER_PATH, "$withval")
3025                         superuser_path=$withval
3026                 fi
3027         ]
3028 )
3029
3030
3031 AC_MSG_CHECKING([if we need to convert IPv4 in IPv6-mapped addresses])
3032 IPV4_IN6_HACK_MSG="no"
3033 AC_ARG_WITH(4in6,
3034         [  --with-4in6             Check for and convert IPv4 in IPv6 mapped addresses],
3035         [
3036                 if test "x$withval" != "xno" ; then
3037                         AC_MSG_RESULT(yes)
3038                         AC_DEFINE(IPV4_IN_IPV6)
3039                         IPV4_IN6_HACK_MSG="yes"
3040                 else
3041                         AC_MSG_RESULT(no)
3042                 fi
3043         ],[
3044                 if test "x$inet6_default_4in6" = "xyes"; then
3045                         AC_MSG_RESULT([yes (default)])
3046                         AC_DEFINE(IPV4_IN_IPV6)
3047                         IPV4_IN6_HACK_MSG="yes"
3048                 else
3049                         AC_MSG_RESULT([no (default)])
3050                 fi
3051         ]
3052 )
3053
3054 # Whether to enable BSD auth support
3055 BSD_AUTH_MSG=no
3056 AC_ARG_WITH(bsd-auth,
3057         [  --with-bsd-auth         Enable BSD auth support],
3058         [
3059                 if test "x$withval" != "xno" ; then
3060                         AC_DEFINE(BSD_AUTH)
3061                         BSD_AUTH_MSG=yes
3062                 fi
3063         ]
3064 )
3065
3066 # Where to place sshd.pid
3067 piddir=/var/run
3068 # make sure the directory exists
3069 if test ! -d $piddir ; then
3070         piddir=`eval echo ${sysconfdir}`
3071         case $piddir in
3072                 NONE/*) piddir=`echo $piddir | sed "s~NONE~$ac_default_prefix~"` ;;
3073         esac
3074 fi
3075
3076 AC_ARG_WITH(pid-dir,
3077         [  --with-pid-dir=PATH     Specify location of ssh.pid file],
3078         [
3079                 if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
3080                     test "x${withval}" != "xyes"; then
3081                         piddir=$withval
3082                         if test ! -d $piddir ; then
3083                         AC_MSG_WARN([** no $piddir directory on this system **])
3084                         fi
3085                 fi
3086         ]
3087 )
3088
3089 AC_DEFINE_UNQUOTED(_PATH_SSH_PIDDIR, "$piddir")
3090 AC_SUBST(piddir)
3091
3092 dnl allow user to disable some login recording features
3093 AC_ARG_ENABLE(lastlog,
3094         [  --disable-lastlog       disable use of lastlog even if detected [no]],
3095         [
3096                 if test "x$enableval" = "xno" ; then
3097                         AC_DEFINE(DISABLE_LASTLOG)
3098                 fi
3099         ]
3100 )
3101 AC_ARG_ENABLE(utmp,
3102         [  --disable-utmp          disable use of utmp even if detected [no]],
3103         [
3104                 if test "x$enableval" = "xno" ; then
3105                         AC_DEFINE(DISABLE_UTMP)
3106                 fi
3107         ]
3108 )
3109 AC_ARG_ENABLE(utmpx,
3110         [  --disable-utmpx         disable use of utmpx even if detected [no]],
3111         [
3112                 if test "x$enableval" = "xno" ; then
3113                         AC_DEFINE(DISABLE_UTMPX)
3114                 fi
3115         ]
3116 )
3117 AC_ARG_ENABLE(wtmp,
3118         [  --disable-wtmp          disable use of wtmp even if detected [no]],
3119         [
3120                 if test "x$enableval" = "xno" ; then
3121                         AC_DEFINE(DISABLE_WTMP)
3122                 fi
3123         ]
3124 )
3125 AC_ARG_ENABLE(wtmpx,
3126         [  --disable-wtmpx         disable use of wtmpx even if detected [no]],
3127         [
3128                 if test "x$enableval" = "xno" ; then
3129                         AC_DEFINE(DISABLE_WTMPX)
3130                 fi
3131         ]
3132 )
3133 AC_ARG_ENABLE(libutil,
3134         [  --disable-libutil       disable use of libutil (login() etc.) [no]],
3135         [
3136                 if test "x$enableval" = "xno" ; then
3137                         AC_DEFINE(DISABLE_LOGIN)
3138                 fi
3139         ]
3140 )
3141 AC_ARG_ENABLE(pututline,
3142         [  --disable-pututline     disable use of pututline() etc. ([uw]tmp) [no]],
3143         [
3144                 if test "x$enableval" = "xno" ; then
3145                         AC_DEFINE(DISABLE_PUTUTLINE)
3146                 fi
3147         ]
3148 )
3149 AC_ARG_ENABLE(pututxline,
3150         [  --disable-pututxline    disable use of pututxline() etc. ([uw]tmpx) [no]],
3151         [
3152                 if test "x$enableval" = "xno" ; then
3153                         AC_DEFINE(DISABLE_PUTUTXLINE)
3154                 fi
3155         ]
3156 )
3157 AC_ARG_WITH(lastlog,
3158   [  --with-lastlog=FILE|DIR specify lastlog location [common locations]],
3159         [
3160                 if test "x$withval" = "xno" ; then
3161                         AC_DEFINE(DISABLE_LASTLOG)
3162                 elif test -n "$withval"  &&  test "x${withval}" != "xyes"; then
3163                         conf_lastlog_location=$withval
3164                 fi
3165         ]
3166 )
3167
3168 dnl lastlog, [uw]tmpx? detection
3169 dnl  NOTE: set the paths in the platform section to avoid the
3170 dnl   need for command-line parameters
3171 dnl lastlog and [uw]tmp are subject to a file search if all else fails
3172
3173 dnl lastlog detection
3174 dnl  NOTE: the code itself will detect if lastlog is a directory
3175 AC_MSG_CHECKING([if your system defines LASTLOG_FILE])
3176 AC_TRY_COMPILE([
3177 #include <sys/types.h>
3178 #include <utmp.h>
3179 #ifdef HAVE_LASTLOG_H
3180 #  include <lastlog.h>
3181 #endif
3182 #ifdef HAVE_PATHS_H
3183 #  include <paths.h>
3184 #endif
3185 #ifdef HAVE_LOGIN_H
3186 # include <login.h>
3187 #endif
3188         ],
3189         [ char *lastlog = LASTLOG_FILE; ],
3190         [ AC_MSG_RESULT(yes) ],
3191         [
3192                 AC_MSG_RESULT(no)
3193                 AC_MSG_CHECKING([if your system defines _PATH_LASTLOG])
3194                 AC_TRY_COMPILE([
3195 #include <sys/types.h>
3196 #include <utmp.h>
3197 #ifdef HAVE_LASTLOG_H
3198 #  include <lastlog.h>
3199 #endif
3200 #ifdef HAVE_PATHS_H
3201 #  include <paths.h>
3202 #endif
3203                 ],
3204                 [ char *lastlog = _PATH_LASTLOG; ],
3205                 [ AC_MSG_RESULT(yes) ],
3206                 [
3207                         AC_MSG_RESULT(no)
3208                         system_lastlog_path=no
3209                 ])
3210         ]
3211 )
3212
3213 if test -z "$conf_lastlog_location"; then
3214         if test x"$system_lastlog_path" = x"no" ; then
3215                 for f in /var/log/lastlog /usr/adm/lastlog /var/adm/lastlog /etc/security/lastlog ; do
3216                                 if (test -d "$f" || test -f "$f") ; then
3217                                         conf_lastlog_location=$f
3218                                 fi
3219                 done
3220                 if test -z "$conf_lastlog_location"; then
3221                         AC_MSG_WARN([** Cannot find lastlog **])
3222                         dnl Don't define DISABLE_LASTLOG - that means we don't try wtmp/wtmpx
3223                 fi
3224         fi
3225 fi
3226
3227 if test -n "$conf_lastlog_location"; then
3228         AC_DEFINE_UNQUOTED(CONF_LASTLOG_FILE, "$conf_lastlog_location")
3229 fi
3230
3231 dnl utmp detection
3232 AC_MSG_CHECKING([if your system defines UTMP_FILE])
3233 AC_TRY_COMPILE([
3234 #include <sys/types.h>
3235 #include <utmp.h>
3236 #ifdef HAVE_PATHS_H
3237 #  include <paths.h>
3238 #endif
3239         ],
3240         [ char *utmp = UTMP_FILE; ],
3241         [ AC_MSG_RESULT(yes) ],
3242         [ AC_MSG_RESULT(no)
3243           system_utmp_path=no ]
3244 )
3245 if test -z "$conf_utmp_location"; then
3246         if test x"$system_utmp_path" = x"no" ; then
3247                 for f in /etc/utmp /usr/adm/utmp /var/run/utmp; do
3248                         if test -f $f ; then
3249                                 conf_utmp_location=$f
3250                         fi
3251                 done
3252                 if test -z "$conf_utmp_location"; then
3253                         AC_DEFINE(DISABLE_UTMP)
3254                 fi
3255         fi
3256 fi
3257 if test -n "$conf_utmp_location"; then
3258         AC_DEFINE_UNQUOTED(CONF_UTMP_FILE, "$conf_utmp_location")
3259 fi
3260
3261 dnl wtmp detection
3262 AC_MSG_CHECKING([if your system defines WTMP_FILE])
3263 AC_TRY_COMPILE([
3264 #include <sys/types.h>
3265 #include <utmp.h>
3266 #ifdef HAVE_PATHS_H
3267 #  include <paths.h>
3268 #endif
3269         ],
3270         [ char *wtmp = WTMP_FILE; ],
3271         [ AC_MSG_RESULT(yes) ],
3272         [ AC_MSG_RESULT(no)
3273           system_wtmp_path=no ]
3274 )
3275 if test -z "$conf_wtmp_location"; then
3276         if test x"$system_wtmp_path" = x"no" ; then
3277                 for f in /usr/adm/wtmp /var/log/wtmp; do
3278                         if test -f $f ; then
3279                                 conf_wtmp_location=$f
3280                         fi
3281                 done
3282                 if test -z "$conf_wtmp_location"; then
3283                         AC_DEFINE(DISABLE_WTMP)
3284                 fi
3285         fi
3286 fi
3287 if test -n "$conf_wtmp_location"; then
3288         AC_DEFINE_UNQUOTED(CONF_WTMP_FILE, "$conf_wtmp_location")
3289 fi
3290
3291
3292 dnl utmpx detection - I don't know any system so perverse as to require
3293 dnl  utmpx, but not define UTMPX_FILE (ditto wtmpx.) No doubt it's out
3294 dnl  there, though.
3295 AC_MSG_CHECKING([if your system defines UTMPX_FILE])
3296 AC_TRY_COMPILE([
3297 #include <sys/types.h>
3298 #include <utmp.h>
3299 #ifdef HAVE_UTMPX_H
3300 #include <utmpx.h>
3301 #endif
3302 #ifdef HAVE_PATHS_H
3303 #  include <paths.h>
3304 #endif
3305         ],
3306         [ char *utmpx = UTMPX_FILE; ],
3307         [ AC_MSG_RESULT(yes) ],
3308         [ AC_MSG_RESULT(no)
3309           system_utmpx_path=no ]
3310 )
3311 if test -z "$conf_utmpx_location"; then
3312         if test x"$system_utmpx_path" = x"no" ; then
3313                 AC_DEFINE(DISABLE_UTMPX)
3314         fi
3315 else
3316         AC_DEFINE_UNQUOTED(CONF_UTMPX_FILE, "$conf_utmpx_location")
3317 fi
3318
3319 dnl wtmpx detection
3320 AC_MSG_CHECKING([if your system defines WTMPX_FILE])
3321 AC_TRY_COMPILE([
3322 #include <sys/types.h>
3323 #include <utmp.h>
3324 #ifdef HAVE_UTMPX_H
3325 #include <utmpx.h>
3326 #endif
3327 #ifdef HAVE_PATHS_H
3328 #  include <paths.h>
3329 #endif
3330         ],
3331         [ char *wtmpx = WTMPX_FILE; ],
3332         [ AC_MSG_RESULT(yes) ],
3333         [ AC_MSG_RESULT(no)
3334           system_wtmpx_path=no ]
3335 )
3336 if test -z "$conf_wtmpx_location"; then
3337         if test x"$system_wtmpx_path" = x"no" ; then
3338                 AC_DEFINE(DISABLE_WTMPX)
3339         fi
3340 else
3341         AC_DEFINE_UNQUOTED(CONF_WTMPX_FILE, "$conf_wtmpx_location")
3342 fi
3343
3344
3345 if test ! -z "$blibpath" ; then
3346         LDFLAGS="$LDFLAGS $blibflags$blibpath"
3347         AC_MSG_WARN([Please check and edit blibpath in LDFLAGS in Makefile])
3348 fi
3349
3350 dnl remove pam and dl because they are in $LIBPAM
3351 if test "$PAM_MSG" = yes ; then
3352         LIBS=`echo $LIBS | sed 's/-lpam //'`
3353 fi
3354 if test "$ac_cv_lib_pam_pam_set_item" = yes ; then
3355         LIBS=`echo $LIBS | sed 's/-ldl //'`
3356 fi
3357
3358 AC_EXEEXT
3359 AC_CONFIG_FILES([Makefile buildpkg.sh opensshd.init openbsd-compat/Makefile \
3360         scard/Makefile ssh_prng_cmds survey.sh])
3361 AC_OUTPUT
3362
3363 # Print summary of options
3364
3365 # Someone please show me a better way :)
3366 A=`eval echo ${prefix}` ; A=`eval echo ${A}`
3367 B=`eval echo ${bindir}` ; B=`eval echo ${B}`
3368 C=`eval echo ${sbindir}` ; C=`eval echo ${C}`
3369 D=`eval echo ${sysconfdir}` ; D=`eval echo ${D}`
3370 E=`eval echo ${libexecdir}/ssh-askpass` ; E=`eval echo ${E}`
3371 F=`eval echo ${mandir}/${mansubdir}X` ; F=`eval echo ${F}`
3372 G=`eval echo ${piddir}` ; G=`eval echo ${G}`
3373 H=`eval echo ${PRIVSEP_PATH}` ; H=`eval echo ${H}`
3374 I=`eval echo ${user_path}` ; I=`eval echo ${I}`
3375 J=`eval echo ${superuser_path}` ; J=`eval echo ${J}`
3376
3377 echo ""
3378 echo "OpenSSH has been configured with the following options:"
3379 echo "                     User binaries: $B"
3380 echo "                   System binaries: $C"
3381 echo "               Configuration files: $D"
3382 echo "                   Askpass program: $E"
3383 echo "                      Manual pages: $F"
3384 echo "                          PID file: $G"
3385 echo "  Privilege separation chroot path: $H"
3386 if test "x$external_path_file" = "x/etc/login.conf" ; then
3387 echo "   At runtime, sshd will use the path defined in $external_path_file"
3388 echo "   Make sure the path to scp is present, otherwise scp will not work"
3389 else
3390 echo "            sshd default user PATH: $I"
3391         if test ! -z "$external_path_file"; then
3392 echo "   (If PATH is set in $external_path_file it will be used instead. If"
3393 echo "   used, ensure the path to scp is present, otherwise scp will not work.)"
3394         fi
3395 fi
3396 if test ! -z "$superuser_path" ; then
3397 echo "          sshd superuser user PATH: $J"
3398 fi
3399 echo "                    Manpage format: $MANTYPE"
3400 echo "                       PAM support: $PAM_MSG"
3401 echo "                 KerberosV support: $KRB5_MSG"
3402 echo "                 Smartcard support: $SCARD_MSG"
3403 echo "                     S/KEY support: $SKEY_MSG"
3404 echo "              TCP Wrappers support: $TCPW_MSG"
3405 echo "              MD5 password support: $MD5_MSG"
3406 echo "                   libedit support: $LIBEDIT_MSG"
3407 echo "       IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG"
3408 echo "           Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG"
3409 echo "                  BSD Auth support: $BSD_AUTH_MSG"
3410 echo "              Random number source: $RAND_MSG"
3411 if test ! -z "$USE_RAND_HELPER" ; then
3412 echo "     ssh-rand-helper collects from: $RAND_HELPER_MSG"
3413 fi
3414
3415 echo ""
3416
3417 echo "              Host: ${host}"
3418 echo "          Compiler: ${CC}"
3419 echo "    Compiler flags: ${CFLAGS}"
3420 echo "Preprocessor flags: ${CPPFLAGS}"
3421 echo "      Linker flags: ${LDFLAGS}"
3422 echo "         Libraries: ${LIBWRAP} ${LIBPAM} ${LIBS}"
3423
3424 echo ""
3425
3426 if test "x$MAKE_PACKAGE_SUPPORTED" = "xyes" ; then
3427         echo "SVR4 style packages are supported with \"make package\""
3428         echo ""
3429 fi
3430
3431 if test "x$PAM_MSG" = "xyes" ; then
3432         echo "PAM is enabled. You may need to install a PAM control file "
3433         echo "for sshd, otherwise password authentication may fail. "
3434         echo "Example PAM control files can be found in the contrib/ "
3435         echo "subdirectory"
3436         echo ""
3437 fi
3438
3439 if test ! -z "$RAND_HELPER_CMDHASH" ; then
3440         echo "WARNING: you are using the builtin random number collection "
3441         echo "service. Please read WARNING.RNG and request that your OS "
3442         echo "vendor includes kernel-based random number collection in "
3443         echo "future versions of your OS."
3444         echo ""
3445 fi
3446
3447 if test ! -z "$NO_PEERCHECK" ; then
3448         echo "WARNING: the operating system that you are using does not "
3449         echo "appear to support either the getpeereid() API nor the "
3450         echo "SO_PEERCRED getsockopt() option. These facilities are used to "
3451         echo "enforce security checks to prevent unauthorised connections to "
3452         echo "ssh-agent. Their absence increases the risk that a malicious "
3453         echo "user can connect to your agent. "
3454         echo ""
3455 fi
3456
3457 if test "$AUDIT_MODULE" = "bsm" ; then
3458         echo "WARNING: BSM audit support is currently considered EXPERIMENTAL."
3459         echo "See the Solaris section in README.platform for details."
3460 fi
This page took 0.483305 seconds and 3 git commands to generate.