blob: 972addfebafd1bc2bb7989184620abc6475cdd3d [file] [log] [blame]
Damien Miller3d673d12014-08-27 06:32:01 +10001# $Id: configure.ac,v 1.583 2014/08/26 20:32:01 djm Exp $
Damien Miller4fefe242004-03-11 14:20:10 +11002#
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.
Damien Millere9cf3572001-02-09 12:55:35 +110016
Tim Rice648f8762011-01-26 12:38:57 -080017AC_INIT([OpenSSH], [Portable], [openssh-unix-dev@mindrot.org])
Damien Miller3d673d12014-08-27 06:32:01 +100018AC_REVISION($Revision: 1.583 $)
Tim Rice13aae5e2001-10-21 17:53:58 -070019AC_CONFIG_SRCDIR([ssh.c])
Tim Rice648f8762011-01-26 12:38:57 -080020AC_LANG([C])
Damien Miller7f6ea021999-10-28 13:25:17 +100021
Tim Rice648f8762011-01-26 12:38:57 -080022AC_CONFIG_HEADER([config.h])
Damien Miller856799b2000-03-15 21:18:10 +110023AC_PROG_CC
Damien Miller76112de1999-12-21 11:18:08 +110024AC_CANONICAL_HOST
Damien Miller4df5c762001-02-28 08:14:22 +110025AC_C_BIGENDIAN
Damien Miller7f6ea021999-10-28 13:25:17 +100026
Damien Millera22ba012000-03-02 23:09:20 +110027# Checks for programs.
Darren Tucker167bd9c2003-09-07 12:34:54 +100028AC_PROG_AWK
Damien Millerab18c411999-11-11 10:40:23 +110029AC_PROG_CPP
Damien Miller7f6ea021999-10-28 13:25:17 +100030AC_PROG_RANLIB
Damien Millerd8087f61999-11-25 12:31:26 +110031AC_PROG_INSTALL
Tim Ricefd80ddc2006-02-02 19:11:56 -080032AC_PROG_EGREP
Darren Tucker408f4c22015-04-17 09:39:58 +100033AC_CHECK_TOOLS([AR], [ar])
Tim Rice648f8762011-01-26 12:38:57 -080034AC_PATH_PROG([CAT], [cat])
35AC_PATH_PROG([KILL], [kill])
36AC_PATH_PROGS([PERL], [perl5 perl])
37AC_PATH_PROG([SED], [sed])
38AC_SUBST([PERL])
39AC_PATH_PROG([ENT], [ent])
40AC_SUBST([ENT])
41AC_PATH_PROG([TEST_MINUS_S_SH], [bash])
42AC_PATH_PROG([TEST_MINUS_S_SH], [ksh])
43AC_PATH_PROG([TEST_MINUS_S_SH], [sh])
44AC_PATH_PROG([SH], [sh])
45AC_PATH_PROG([GROFF], [groff])
46AC_PATH_PROG([NROFF], [nroff])
47AC_PATH_PROG([MANDOC], [mandoc])
48AC_SUBST([TEST_SHELL], [sh])
Damien Miller2e1b0821999-12-25 10:11:29 +110049
Damien Miller30a69e72011-01-04 08:16:27 +110050dnl select manpage formatter
51if test "x$MANDOC" != "x" ; then
52 MANFMT="$MANDOC"
53elif test "x$NROFF" != "x" ; then
54 MANFMT="$NROFF -mandoc"
55elif test "x$GROFF" != "x" ; then
56 MANFMT="$GROFF -mandoc -Tascii"
57else
58 AC_MSG_WARN([no manpage formatted found])
59 MANFMT="false"
60fi
Tim Rice648f8762011-01-26 12:38:57 -080061AC_SUBST([MANFMT])
Damien Miller30a69e72011-01-04 08:16:27 +110062
Tim Rice6f1f7582004-05-30 21:38:51 -070063dnl for buildpkg.sh
Tim Rice648f8762011-01-26 12:38:57 -080064AC_PATH_PROG([PATH_GROUPADD_PROG], [groupadd], [groupadd],
Tim Rice6f1f7582004-05-30 21:38:51 -070065 [/usr/sbin${PATH_SEPARATOR}/etc])
Tim Rice648f8762011-01-26 12:38:57 -080066AC_PATH_PROG([PATH_USERADD_PROG], [useradd], [useradd],
Tim Rice6f1f7582004-05-30 21:38:51 -070067 [/usr/sbin${PATH_SEPARATOR}/etc])
Tim Rice648f8762011-01-26 12:38:57 -080068AC_CHECK_PROG([MAKE_PACKAGE_SUPPORTED], [pkgmk], [yes], [no])
Darren Tuckerfbea7642006-01-30 00:22:39 +110069if test -x /sbin/sh; then
Tim Rice648f8762011-01-26 12:38:57 -080070 AC_SUBST([STARTUP_SCRIPT_SHELL], [/sbin/sh])
Darren Tuckerfbea7642006-01-30 00:22:39 +110071else
Tim Rice648f8762011-01-26 12:38:57 -080072 AC_SUBST([STARTUP_SCRIPT_SHELL], [/bin/sh])
Darren Tuckerfbea7642006-01-30 00:22:39 +110073fi
Tim Rice6f1f7582004-05-30 21:38:51 -070074
Damien Millere8bb4502001-09-25 16:39:35 +100075# System features
76AC_SYS_LARGEFILE
77
Damien Miller3f62aba2000-11-29 11:56:35 +110078if test -z "$AR" ; then
79 AC_MSG_ERROR([*** 'ar' missing, please install or fix your \$PATH ***])
80fi
81
Tim Rice648f8762011-01-26 12:38:57 -080082AC_PATH_PROG([PATH_PASSWD_PROG], [passwd])
Darren Tucker23bc8d02004-02-06 16:24:31 +110083if test ! -z "$PATH_PASSWD_PROG" ; then
Tim Rice648f8762011-01-26 12:38:57 -080084 AC_DEFINE_UNQUOTED([_PATH_PASSWD_PROG], ["$PATH_PASSWD_PROG"],
Tim Rice7df8d392005-09-19 09:33:39 -070085 [Full path of your "passwd" program])
Darren Tucker23bc8d02004-02-06 16:24:31 +110086fi
87
Damien Miller166bd442000-03-16 10:48:25 +110088if test -z "$LD" ; then
89 LD=$CC
90fi
Tim Rice648f8762011-01-26 12:38:57 -080091AC_SUBST([LD])
Tim Riceeae17cc2005-03-17 16:52:20 -080092
Damien Miller166bd442000-03-16 10:48:25 +110093AC_C_INLINE
Darren Tucker67b37032005-06-03 17:58:31 +100094
Tim Rice648f8762011-01-26 12:38:57 -080095AC_CHECK_DECL([LLONG_MAX], [have_llong_max=1], , [#include <limits.h>])
Damien Miller69ff1df2011-06-23 08:30:03 +100096AC_CHECK_DECL([SYSTR_POLICY_KILL], [have_systr_policy_kill=1], , [
97 #include <sys/types.h>
98 #include <sys/param.h>
99 #include <dev/systrace.h>
100])
101AC_CHECK_DECL([RLIMIT_NPROC],
102 [AC_DEFINE([HAVE_RLIMIT_NPROC], [], [sys/resource.h has RLIMIT_NPROC])], , [
103 #include <sys/types.h>
104 #include <sys/resource.h>
105])
Damien Millere0956e32012-04-04 11:27:54 +1000106AC_CHECK_DECL([PR_SET_NO_NEW_PRIVS], [have_linux_no_new_privs=1], , [
107 #include <sys/types.h>
108 #include <linux/prctl.h>
109])
Damien Miller868ea1e2014-01-17 16:47:04 +1100110
Damien Miller72ef7c12015-01-15 02:21:31 +1100111openssl=yes
djm@openbsd.org564d63e2015-07-01 23:10:47 +0000112ssh1=no
Tim Ricecf3e0be2016-08-01 14:31:52 -0700113COMMENT_OUT_RSA1="#no ssh1#"
Damien Miller72ef7c12015-01-15 02:21:31 +1100114AC_ARG_WITH([openssl],
115 [ --without-openssl Disable use of OpenSSL; use only limited internal crypto **EXPERIMENTAL** ],
Damien Miller76c04802015-01-13 19:38:18 +1100116 [ if test "x$withval" = "xno" ; then
Damien Miller72ef7c12015-01-15 02:21:31 +1100117 openssl=no
Damien Miller76c04802015-01-13 19:38:18 +1100118 ssh1=no
119 fi
120 ]
121)
Damien Miller72ef7c12015-01-15 02:21:31 +1100122AC_MSG_CHECKING([whether OpenSSL will be used for cryptography])
123if test "x$openssl" = "xyes" ; then
124 AC_MSG_RESULT([yes])
125 AC_DEFINE_UNQUOTED([WITH_OPENSSL], [1], [use libcrypto for cryptography])
126else
127 AC_MSG_RESULT([no])
128fi
129
130AC_ARG_WITH([ssh1],
Darren Tucker366bada2015-09-11 13:29:22 +1000131 [ --with-ssh1 Enable support for SSH protocol 1],
Damien Miller72ef7c12015-01-15 02:21:31 +1100132 [
djm@openbsd.org2aa9da12015-03-24 01:29:19 +0000133 if test "x$withval" = "xyes" ; then
134 if test "x$openssl" = "xno" ; then
135 AC_MSG_ERROR([Cannot enable SSH protocol 1 with OpenSSL disabled])
136 fi
137 ssh1=yes
Tim Ricecf3e0be2016-08-01 14:31:52 -0700138 COMMENT_OUT_RSA1=""
Damien Miller0c2a81d2015-05-29 17:08:28 +1000139 elif test "x$withval" = "xno" ; then
140 ssh1=no
141 else
142 AC_MSG_ERROR([unknown --with-ssh1 argument])
Damien Miller72ef7c12015-01-15 02:21:31 +1100143 fi
144 ]
145)
Damien Miller76c04802015-01-13 19:38:18 +1100146AC_MSG_CHECKING([whether SSH protocol 1 support is enabled])
147if test "x$ssh1" = "xyes" ; then
148 AC_MSG_RESULT([yes])
149 AC_DEFINE_UNQUOTED([WITH_SSH1], [1], [include SSH protocol version 1 support])
Tim Ricecf3e0be2016-08-01 14:31:52 -0700150 AC_SUBST([COMMENT_OUT_RSA1])
Damien Miller76c04802015-01-13 19:38:18 +1100151else
152 AC_MSG_RESULT([no])
153fi
154
Darren Tuckerb7918af2008-03-09 11:34:23 +1100155use_stack_protector=1
Darren Tuckerfd994372014-01-17 09:53:24 +1100156use_toolchain_hardening=1
Tim Rice648f8762011-01-26 12:38:57 -0800157AC_ARG_WITH([stackprotect],
Damien Millerda3155e2008-03-27 12:30:18 +1100158 [ --without-stackprotect Don't use compiler's stack protection], [
Darren Tuckerb7918af2008-03-09 11:34:23 +1100159 if test "x$withval" = "xno"; then
160 use_stack_protector=0
161 fi ])
Darren Tuckerfd994372014-01-17 09:53:24 +1100162AC_ARG_WITH([hardening],
163 [ --without-hardening Don't use toolchain hardening flags], [
164 if test "x$withval" = "xno"; then
Darren Tuckerfd994372014-01-17 09:53:24 +1100165 use_toolchain_hardening=0
166 fi ])
Darren Tuckerb7918af2008-03-09 11:34:23 +1100167
Darren Tuckerfd994372014-01-17 09:53:24 +1100168# We use -Werror for the tests only so that we catch warnings like "this is
169# on by default" for things like -fPIE.
170AC_MSG_CHECKING([if $CC supports -Werror])
171saved_CFLAGS="$CFLAGS"
172CFLAGS="$CFLAGS -Werror"
173AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int main(void) { return 0; }]])],
174 [ AC_MSG_RESULT([yes])
175 WERROR="-Werror"],
176 [ AC_MSG_RESULT([no])
177 WERROR="" ]
178)
179CFLAGS="$saved_CFLAGS"
Damien Miller134d02a2011-01-12 16:00:37 +1100180
Damien Millera8e06ce2003-11-21 23:48:55 +1100181if test "$GCC" = "yes" || test "$GCC" = "egcs"; then
Darren Tuckerfd994372014-01-17 09:53:24 +1100182 OSSH_CHECK_CFLAG_COMPILE([-Qunused-arguments])
183 OSSH_CHECK_CFLAG_COMPILE([-Wunknown-warning-option])
Damien Millerb1763622011-05-20 11:45:25 +1000184 OSSH_CHECK_CFLAG_COMPILE([-Wall])
185 OSSH_CHECK_CFLAG_COMPILE([-Wpointer-arith])
186 OSSH_CHECK_CFLAG_COMPILE([-Wuninitialized])
187 OSSH_CHECK_CFLAG_COMPILE([-Wsign-compare])
188 OSSH_CHECK_CFLAG_COMPILE([-Wformat-security])
Darren Tuckerabbc7a72013-05-10 13:54:23 +1000189 OSSH_CHECK_CFLAG_COMPILE([-Wsizeof-pointer-memaccess])
Damien Millerb1763622011-05-20 11:45:25 +1000190 OSSH_CHECK_CFLAG_COMPILE([-Wpointer-sign], [-Wno-pointer-sign])
191 OSSH_CHECK_CFLAG_COMPILE([-Wunused-result], [-Wno-unused-result])
192 OSSH_CHECK_CFLAG_COMPILE([-fno-strict-aliasing])
Darren Tucker4a725ef2011-11-21 16:38:48 +1100193 OSSH_CHECK_CFLAG_COMPILE([-D_FORTIFY_SOURCE=2])
Darren Tuckerfd994372014-01-17 09:53:24 +1100194 if test "x$use_toolchain_hardening" = "x1"; then
Darren Tuckerfd994372014-01-17 09:53:24 +1100195 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,relro])
196 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,now])
197 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,noexecstack])
Damien Miller5c2ff5e2014-01-22 21:30:12 +1100198 # NB. -ftrapv expects certain support functions to be present in
199 # the compiler library (libgcc or similar) to detect integer operations
200 # that can overflow. We must check that the result of enabling it
201 # actually links. The test program compiled/linked includes a number
202 # of integer operations that should exercise this.
203 OSSH_CHECK_CFLAG_LINK([-ftrapv])
Darren Tuckerfd994372014-01-17 09:53:24 +1100204 fi
Tim Rice648f8762011-01-26 12:38:57 -0800205 AC_MSG_CHECKING([gcc version])
Darren Tucker3f9545e2005-11-12 15:20:52 +1100206 GCC_VER=`$CC -v 2>&1 | $AWK '/gcc version /{print $3}'`
Tim Rice3db1e3f2005-08-23 17:11:26 -0700207 case $GCC_VER in
Darren Tucker391de5c2007-04-29 14:49:21 +1000208 1.*) no_attrib_nonnull=1 ;;
209 2.8* | 2.9*)
Darren Tucker391de5c2007-04-29 14:49:21 +1000210 no_attrib_nonnull=1
211 ;;
212 2.*) no_attrib_nonnull=1 ;;
Darren Tuckerf0324352005-11-10 21:30:36 +1100213 *) ;;
Tim Rice3db1e3f2005-08-23 17:11:26 -0700214 esac
Tim Rice648f8762011-01-26 12:38:57 -0800215 AC_MSG_RESULT([$GCC_VER])
Damien Millerde3cb0a2005-05-26 20:48:25 +1000216
Tim Rice648f8762011-01-26 12:38:57 -0800217 AC_MSG_CHECKING([if $CC accepts -fno-builtin-memset])
Darren Tucker330c93f2008-06-16 02:27:48 +1000218 saved_CFLAGS="$CFLAGS"
219 CFLAGS="$CFLAGS -fno-builtin-memset"
Tim Rice648f8762011-01-26 12:38:57 -0800220 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <string.h> ]],
221 [[ char b[10]; memset(b, 0, sizeof(b)); ]])],
222 [ AC_MSG_RESULT([yes]) ],
223 [ AC_MSG_RESULT([no])
Darren Tucker330c93f2008-06-16 02:27:48 +1000224 CFLAGS="$saved_CFLAGS" ]
Tim Rice648f8762011-01-26 12:38:57 -0800225 )
Darren Tucker330c93f2008-06-16 02:27:48 +1000226
Darren Tuckerb7918af2008-03-09 11:34:23 +1100227 # -fstack-protector-all doesn't always work for some GCC versions
Darren Tuckerfe1cf972008-03-09 22:50:50 +1100228 # and/or platforms, so we test if we can. If it's not supported
Damien Miller7df2e402008-12-08 09:35:36 +1100229 # on a given platform gcc will emit a warning so we use -Werror.
Darren Tuckerb7918af2008-03-09 11:34:23 +1100230 if test "x$use_stack_protector" = "x1"; then
Darren Tuckerfd994372014-01-17 09:53:24 +1100231 for t in -fstack-protector-strong -fstack-protector-all \
232 -fstack-protector; do
Tim Rice648f8762011-01-26 12:38:57 -0800233 AC_MSG_CHECKING([if $CC supports $t])
Darren Tuckerb7918af2008-03-09 11:34:23 +1100234 saved_CFLAGS="$CFLAGS"
235 saved_LDFLAGS="$LDFLAGS"
Darren Tuckerfe1cf972008-03-09 22:50:50 +1100236 CFLAGS="$CFLAGS $t -Werror"
237 LDFLAGS="$LDFLAGS $t -Werror"
238 AC_LINK_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -0800239 [AC_LANG_PROGRAM([[ #include <stdio.h> ]],
240 [[
241 char x[256];
242 snprintf(x, sizeof(x), "XXX");
243 ]])],
244 [ AC_MSG_RESULT([yes])
Darren Tuckerfe1cf972008-03-09 22:50:50 +1100245 CFLAGS="$saved_CFLAGS $t"
246 LDFLAGS="$saved_LDFLAGS $t"
Tim Rice648f8762011-01-26 12:38:57 -0800247 AC_MSG_CHECKING([if $t works])
Darren Tuckerb7918af2008-03-09 11:34:23 +1100248 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -0800249 [AC_LANG_PROGRAM([[ #include <stdio.h> ]],
250 [[
251 char x[256];
252 snprintf(x, sizeof(x), "XXX");
253 ]])],
254 [ AC_MSG_RESULT([yes])
Darren Tuckerb7918af2008-03-09 11:34:23 +1100255 break ],
Tim Rice648f8762011-01-26 12:38:57 -0800256 [ AC_MSG_RESULT([no]) ],
Darren Tuckerb7918af2008-03-09 11:34:23 +1100257 [ AC_MSG_WARN([cross compiling: cannot test])
258 break ]
Darren Tuckerfe1cf972008-03-09 22:50:50 +1100259 )
Darren Tuckerb7918af2008-03-09 11:34:23 +1100260 ],
Tim Rice648f8762011-01-26 12:38:57 -0800261 [ AC_MSG_RESULT([no]) ]
Darren Tuckerb7918af2008-03-09 11:34:23 +1100262 )
263 CFLAGS="$saved_CFLAGS"
264 LDFLAGS="$saved_LDFLAGS"
265 done
266 fi
Darren Tucker319b3d92007-12-02 21:02:22 +1100267
Darren Tucker67b37032005-06-03 17:58:31 +1000268 if test -z "$have_llong_max"; then
269 # retry LLONG_MAX with -std=gnu99, needed on some Linuxes
270 unset ac_cv_have_decl_LLONG_MAX
271 saved_CFLAGS="$CFLAGS"
272 CFLAGS="$CFLAGS -std=gnu99"
Tim Rice648f8762011-01-26 12:38:57 -0800273 AC_CHECK_DECL([LLONG_MAX],
Darren Tucker67b37032005-06-03 17:58:31 +1000274 [have_llong_max=1],
275 [CFLAGS="$saved_CFLAGS"],
276 [#include <limits.h>]
277 )
278 fi
Damien Miller166bd442000-03-16 10:48:25 +1100279fi
280
Darren Tucker951b53b2013-02-08 11:50:09 +1100281AC_MSG_CHECKING([if compiler allows __attribute__ on return types])
282AC_COMPILE_IFELSE(
283 [AC_LANG_PROGRAM([[
284#include <stdlib.h>
285__attribute__((__unused__)) static void foo(void){return;}]],
286 [[ exit(0); ]])],
287 [ AC_MSG_RESULT([yes]) ],
288 [ AC_MSG_RESULT([no])
289 AC_DEFINE(NO_ATTRIBUTE_ON_RETURN_TYPE, 1,
290 [compiler does not accept __attribute__ on return types]) ]
291)
292
Darren Tucker391de5c2007-04-29 14:49:21 +1000293if test "x$no_attrib_nonnull" != "x1" ; then
Tim Rice648f8762011-01-26 12:38:57 -0800294 AC_DEFINE([HAVE_ATTRIBUTE__NONNULL__], [1], [Have attribute nonnull])
Darren Tucker391de5c2007-04-29 14:49:21 +1000295fi
296
Tim Rice648f8762011-01-26 12:38:57 -0800297AC_ARG_WITH([rpath],
Tim Rice88368a32003-12-08 12:35:59 -0800298 [ --without-rpath Disable auto-added -R linker paths],
299 [
Tim Riceeae17cc2005-03-17 16:52:20 -0800300 if test "x$withval" = "xno" ; then
Tim Rice88368a32003-12-08 12:35:59 -0800301 need_dash_r=""
302 fi
303 if test "x$withval" = "xyes" ; then
304 need_dash_r=1
305 fi
306 ]
307)
308
Tim Rice1cfab232006-10-03 09:34:35 -0700309# Allow user to specify flags
Tim Rice648f8762011-01-26 12:38:57 -0800310AC_ARG_WITH([cflags],
Tim Rice1cfab232006-10-03 09:34:35 -0700311 [ --with-cflags Specify additional flags to pass to compiler],
312 [
313 if test -n "$withval" && test "x$withval" != "xno" && \
314 test "x${withval}" != "xyes"; then
315 CFLAGS="$CFLAGS $withval"
316 fi
317 ]
318)
Tim Rice648f8762011-01-26 12:38:57 -0800319AC_ARG_WITH([cppflags],
Tim Rice1cfab232006-10-03 09:34:35 -0700320 [ --with-cppflags Specify additional flags to pass to preprocessor] ,
321 [
322 if test -n "$withval" && test "x$withval" != "xno" && \
323 test "x${withval}" != "xyes"; then
324 CPPFLAGS="$CPPFLAGS $withval"
325 fi
326 ]
327)
Tim Rice648f8762011-01-26 12:38:57 -0800328AC_ARG_WITH([ldflags],
Tim Rice1cfab232006-10-03 09:34:35 -0700329 [ --with-ldflags Specify additional flags to pass to linker],
330 [
331 if test -n "$withval" && test "x$withval" != "xno" && \
332 test "x${withval}" != "xyes"; then
333 LDFLAGS="$LDFLAGS $withval"
334 fi
335 ]
336)
Tim Rice648f8762011-01-26 12:38:57 -0800337AC_ARG_WITH([libs],
Tim Rice1cfab232006-10-03 09:34:35 -0700338 [ --with-libs Specify additional libraries to link with],
339 [
340 if test -n "$withval" && test "x$withval" != "xno" && \
341 test "x${withval}" != "xyes"; then
342 LIBS="$LIBS $withval"
343 fi
344 ]
345)
Tim Rice648f8762011-01-26 12:38:57 -0800346AC_ARG_WITH([Werror],
Tim Rice1cfab232006-10-03 09:34:35 -0700347 [ --with-Werror Build main code with -Werror],
348 [
349 if test -n "$withval" && test "x$withval" != "xno"; then
350 werror_flags="-Werror"
351 if test "x${withval}" != "xyes"; then
352 werror_flags="$withval"
353 fi
354 fi
355 ]
356)
357
Tim Rice648f8762011-01-26 12:38:57 -0800358AC_CHECK_HEADERS([ \
Damien Miller1ff130d2013-12-07 11:51:51 +1100359 blf.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700360 bstring.h \
361 crypt.h \
362 crypto/sha2.h \
363 dirent.h \
364 endian.h \
Damien Miller91f40d82013-02-22 11:37:00 +1100365 elf.h \
Darren Tucker6310ef22016-07-13 14:42:35 +1000366 err.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700367 features.h \
368 fcntl.h \
369 floatingpoint.h \
370 getopt.h \
371 glob.h \
372 ia.h \
373 iaf.h \
Darren Tucker6d725682014-01-17 19:17:34 +1100374 inttypes.h \
Darren Tuckerf3f2cc82016-07-11 17:23:38 +1000375 langinfo.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700376 limits.h \
Darren Tuckerae133d42013-06-06 08:30:20 +1000377 locale.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700378 login.h \
379 maillock.h \
380 ndir.h \
381 net/if_tun.h \
382 netdb.h \
383 netgroup.h \
384 pam/pam_appl.h \
385 paths.h \
Darren Tuckerfebf0f52007-06-25 22:15:12 +1000386 poll.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700387 pty.h \
388 readpassphrase.h \
389 rpc/types.h \
390 security/pam_appl.h \
391 sha2.h \
392 shadow.h \
393 stddef.h \
394 stdint.h \
395 string.h \
396 strings.h \
397 sys/audit.h \
398 sys/bitypes.h \
399 sys/bsdtty.h \
Damien Millerc96d8532014-01-25 13:12:28 +1100400 sys/capability.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700401 sys/cdefs.h \
402 sys/dir.h \
403 sys/mman.h \
404 sys/ndir.h \
Darren Tucker7c92a652007-09-27 07:00:09 +1000405 sys/poll.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700406 sys/prctl.h \
407 sys/pstat.h \
Darren Tucker5ee3fb52016-11-01 08:12:33 +1100408 sys/ptrace.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700409 sys/select.h \
410 sys/stat.h \
411 sys/stream.h \
412 sys/stropts.h \
413 sys/strtio.h \
Darren Tucker5b2e2ba2008-06-08 09:25:28 +1000414 sys/statvfs.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700415 sys/sysmacros.h \
416 sys/time.h \
417 sys/timers.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700418 time.h \
419 tmpdir.h \
420 ttyent.h \
Tim Riceaa8954f2007-05-09 15:57:43 -0700421 ucred.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700422 unistd.h \
423 usersec.h \
424 util.h \
425 utime.h \
426 utmp.h \
427 utmpx.h \
428 vis.h \
Darren Tuckerf3f2cc82016-07-11 17:23:38 +1000429 wchar.h \
Tim Rice648f8762011-01-26 12:38:57 -0800430])
Tim Rice1cfab232006-10-03 09:34:35 -0700431
432# lastlog.h requires sys/time.h to be included first on Solaris
Tim Rice648f8762011-01-26 12:38:57 -0800433AC_CHECK_HEADERS([lastlog.h], [], [], [
Tim Rice1cfab232006-10-03 09:34:35 -0700434#ifdef HAVE_SYS_TIME_H
435# include <sys/time.h>
436#endif
437])
438
439# sys/ptms.h requires sys/stream.h to be included first on Solaris
Tim Rice648f8762011-01-26 12:38:57 -0800440AC_CHECK_HEADERS([sys/ptms.h], [], [], [
Tim Rice1cfab232006-10-03 09:34:35 -0700441#ifdef HAVE_SYS_STREAM_H
442# include <sys/stream.h>
443#endif
444])
445
446# login_cap.h requires sys/types.h on NetBSD
Tim Rice648f8762011-01-26 12:38:57 -0800447AC_CHECK_HEADERS([login_cap.h], [], [], [
Tim Rice1cfab232006-10-03 09:34:35 -0700448#include <sys/types.h>
449])
450
Darren Tuckerc4b22ca2009-07-12 21:56:29 +1000451# older BSDs need sys/param.h before sys/mount.h
Tim Rice648f8762011-01-26 12:38:57 -0800452AC_CHECK_HEADERS([sys/mount.h], [], [], [
Darren Tuckerc4b22ca2009-07-12 21:56:29 +1000453#include <sys/param.h>
454])
455
Darren Tuckeref4901c2013-06-03 01:59:13 +1000456# Android requires sys/socket.h to be included before sys/un.h
457AC_CHECK_HEADERS([sys/un.h], [], [], [
Darren Tucker0b43ffe2013-06-03 09:30:44 +1000458#include <sys/types.h>
Darren Tucker16cac192013-06-04 12:55:24 +1000459#include <sys/socket.h>
Darren Tuckeref4901c2013-06-03 01:59:13 +1000460])
461
Damien Miller1b06dc32006-08-31 03:24:41 +1000462# Messages for features tested for in target-specific section
463SIA_MSG="no"
464SPC_MSG="no"
Darren Tucker97528352010-11-05 12:03:05 +1100465SP_MSG="no"
Damien Miller4626cba2016-01-08 14:24:56 +1100466SPP_MSG="no"
467
468# Support for Solaris/Illumos privileges (this test is used by both
469# the --with-solaris-privs option and --with-sandbox=solaris).
470SOLARIS_PRIVS="no"
Damien Miller1b06dc32006-08-31 03:24:41 +1000471
Damien Millera22ba012000-03-02 23:09:20 +1100472# Check for some target-specific stuff
Damien Miller76112de1999-12-21 11:18:08 +1100473case "$host" in
Damien Miller75b1d102000-01-07 14:01:41 +1100474*-*-aix*)
Darren Tucker9216c372006-09-18 23:17:40 +1000475 # Some versions of VAC won't allow macro redefinitions at
476 # -qlanglevel=ansi, and autoconf 2.60 sometimes insists on using that
477 # particularly with older versions of vac or xlc.
478 # It also throws errors about null macro argments, but these are
479 # not fatal.
Tim Rice648f8762011-01-26 12:38:57 -0800480 AC_MSG_CHECKING([if compiler allows macro redefinitions])
Darren Tucker9216c372006-09-18 23:17:40 +1000481 AC_COMPILE_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -0800482 [AC_LANG_PROGRAM([[
Darren Tucker9216c372006-09-18 23:17:40 +1000483#define testmacro foo
Tim Rice648f8762011-01-26 12:38:57 -0800484#define testmacro bar]],
485 [[ exit(0); ]])],
486 [ AC_MSG_RESULT([yes]) ],
487 [ AC_MSG_RESULT([no])
Darren Tucker9216c372006-09-18 23:17:40 +1000488 CC="`echo $CC | sed 's/-qlanglvl\=ansi//g'`"
489 LD="`echo $LD | sed 's/-qlanglvl\=ansi//g'`"
490 CFLAGS="`echo $CFLAGS | sed 's/-qlanglvl\=ansi//g'`"
491 CPPFLAGS="`echo $CPPFLAGS | sed 's/-qlanglvl\=ansi//g'`"
492 ]
493 )
494
Damien Millera8e06ce2003-11-21 23:48:55 +1100495 AC_MSG_CHECKING([how to specify blibpath for linker ($LD)])
Damien Millereab4bae2003-04-29 23:22:40 +1000496 if (test -z "$blibpath"); then
Tim Ricefcb62202004-01-23 18:35:16 -0800497 blibpath="/usr/lib:/lib"
Damien Miller29ea30d2000-03-17 10:54:15 +1100498 fi
Damien Millereab4bae2003-04-29 23:22:40 +1000499 saved_LDFLAGS="$LDFLAGS"
Darren Tuckerbdc12122006-07-06 11:56:25 +1000500 if test "$GCC" = "yes"; then
501 flags="-Wl,-blibpath: -Wl,-rpath, -blibpath:"
502 else
503 flags="-blibpath: -Wl,-blibpath: -Wl,-rpath,"
504 fi
505 for tryflags in $flags ;do
Damien Millereab4bae2003-04-29 23:22:40 +1000506 if (test -z "$blibflags"); then
507 LDFLAGS="$saved_LDFLAGS $tryflags$blibpath"
Tim Rice648f8762011-01-26 12:38:57 -0800508 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
509 [blibflags=$tryflags], [])
Damien Millereab4bae2003-04-29 23:22:40 +1000510 fi
511 done
512 if (test -z "$blibflags"); then
Tim Rice648f8762011-01-26 12:38:57 -0800513 AC_MSG_RESULT([not found])
Damien Millereab4bae2003-04-29 23:22:40 +1000514 AC_MSG_ERROR([*** must be able to specify blibpath on AIX - check config.log])
515 else
Tim Rice648f8762011-01-26 12:38:57 -0800516 AC_MSG_RESULT([$blibflags])
Damien Millereab4bae2003-04-29 23:22:40 +1000517 fi
518 LDFLAGS="$saved_LDFLAGS"
Darren Tucker5c6a91a2003-07-14 16:21:44 +1000519 dnl Check for authenticate. Might be in libs.a on older AIXes
Tim Rice648f8762011-01-26 12:38:57 -0800520 AC_CHECK_FUNC([authenticate], [AC_DEFINE([WITH_AIXAUTHENTICATE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700521 [Define if you want to enable AIX4's authenticate function])],
Tim Rice648f8762011-01-26 12:38:57 -0800522 [AC_CHECK_LIB([s], [authenticate],
523 [ AC_DEFINE([WITH_AIXAUTHENTICATE])
Tim Ricee958ed32002-07-05 07:12:33 -0700524 LIBS="$LIBS -ls"
525 ])
526 ])
Darren Tucker3c774c52005-02-16 22:49:31 +1100527 dnl Check for various auth function declarations in headers.
Darren Tucker04cfbe02005-02-20 23:27:11 +1100528 AC_CHECK_DECLS([authenticate, loginrestrictions, loginsuccess,
Darren Tuckere66519d2005-03-21 22:46:34 +1100529 passwdexpired, setauthdb], , , [#include <usersec.h>])
Darren Tucker5c6a91a2003-07-14 16:21:44 +1000530 dnl Check if loginfailed is declared and takes 4 arguments (AIX >= 5.2)
Tim Rice648f8762011-01-26 12:38:57 -0800531 AC_CHECK_DECLS([loginfailed],
532 [AC_MSG_CHECKING([if loginfailed takes 4 arguments])
533 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <usersec.h> ]],
534 [[ (void)loginfailed("user","host","tty",0); ]])],
535 [AC_MSG_RESULT([yes])
536 AC_DEFINE([AIX_LOGINFAILED_4ARG], [1],
537 [Define if your AIX loginfailed() function
538 takes 4 arguments (AIX >= 5.2)])], [AC_MSG_RESULT([no])
539 ])],
540 [],
541 [#include <usersec.h>]
Darren Tucker5c6a91a2003-07-14 16:21:44 +1000542 )
Tim Rice648f8762011-01-26 12:38:57 -0800543 AC_CHECK_FUNCS([getgrset setauthdb])
544 AC_CHECK_DECL([F_CLOSEM],
545 AC_DEFINE([HAVE_FCNTL_CLOSEM], [1], [Use F_CLOSEM fcntl for closefrom]),
Darren Tucker3083bc22006-08-17 19:35:49 +1000546 [],
547 [ #include <limits.h>
548 #include <fcntl.h> ]
549 )
Darren Tucker691d5232005-02-15 21:45:57 +1100550 check_for_aix_broken_getaddrinfo=1
Tim Rice648f8762011-01-26 12:38:57 -0800551 AC_DEFINE([BROKEN_REALPATH], [1], [Define if you have a broken realpath.])
552 AC_DEFINE([SETEUID_BREAKS_SETUID], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700553 [Define if your platform breaks doing a seteuid before a setuid])
Tim Rice648f8762011-01-26 12:38:57 -0800554 AC_DEFINE([BROKEN_SETREUID], [1], [Define if your setreuid() is broken])
555 AC_DEFINE([BROKEN_SETREGID], [1], [Define if your setregid() is broken])
andre60f3c982000-06-03 16:18:19 +0000556 dnl AIX handles lastlog as part of its login message
Tim Rice648f8762011-01-26 12:38:57 -0800557 AC_DEFINE([DISABLE_LASTLOG], [1], [Define if you don't want to use lastlog])
558 AC_DEFINE([LOGIN_NEEDS_UTMPX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700559 [Some systems need a utmpx entry for /bin/login to work])
Tim Rice648f8762011-01-26 12:38:57 -0800560 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV],
Tim Rice7df8d392005-09-19 09:33:39 -0700561 [Define to a Set Process Title type if your system is
562 supported by bsd-setproctitle.c])
Tim Rice648f8762011-01-26 12:38:57 -0800563 AC_DEFINE([SSHPAM_CHAUTHTOK_NEEDS_RUID], [1],
Darren Tucker91d25a02005-11-26 22:24:09 +1100564 [AIX 5.2 and 5.3 (and presumably newer) require this])
Tim Rice648f8762011-01-26 12:38:57 -0800565 AC_DEFINE([PTY_ZEROREAD], [1], [read(1) can return 0 for a non-closed fd])
Darren Tuckeraa97d132013-03-12 11:31:05 +1100566 AC_DEFINE([PLATFORM_SYS_DIR_UID], 2, [System dirs owned by bin (uid 2)])
Damien Miller75b1d102000-01-07 14:01:41 +1100567 ;;
Darren Tucker898ac932013-06-03 02:03:25 +1000568*-*-android*)
569 AC_DEFINE([DISABLE_UTMP], [1], [Define if you don't want to use utmp])
570 AC_DEFINE([DISABLE_WTMP], [1], [Define if you don't want to use wtmp])
571 ;;
Damien Millerbac2d8a2000-09-05 16:13:06 +1100572*-*-cygwin*)
Damien Millerc8936ac2003-02-11 10:04:03 +1100573 check_for_libcrypt_later=1
Darren Tucker573e3872007-03-02 17:50:03 +1100574 LIBS="$LIBS /usr/lib/textreadmode.o"
Tim Rice648f8762011-01-26 12:38:57 -0800575 AC_DEFINE([HAVE_CYGWIN], [1], [Define if you are on Cygwin])
576 AC_DEFINE([USE_PIPES], [1], [Use PIPES instead of a socketpair()])
Damien Miller4626cba2016-01-08 14:24:56 +1100577 AC_DEFINE([NO_UID_RESTORATION_TEST], [1],
578 [Define to disable UID restoration test])
Tim Rice648f8762011-01-26 12:38:57 -0800579 AC_DEFINE([DISABLE_SHADOW], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700580 [Define if you want to disable shadow passwords])
Tim Rice648f8762011-01-26 12:38:57 -0800581 AC_DEFINE([NO_X11_UNIX_SOCKETS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700582 [Define if X11 doesn't support AF_UNIX sockets on that system])
Tim Rice648f8762011-01-26 12:38:57 -0800583 AC_DEFINE([DISABLE_FD_PASSING], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700584 [Define if your platform needs to skip post auth
585 file descriptor passing])
Tim Rice648f8762011-01-26 12:38:57 -0800586 AC_DEFINE([SSH_IOBUFSZ], [65535], [Windows is sensitive to read buffer size])
Darren Tuckerfdce3732014-01-18 21:12:42 +1100587 AC_DEFINE([FILESYSTEM_NO_BACKSLASH], [1], [File names may not contain backslash characters])
588 # Cygwin defines optargs, optargs as declspec(dllimport) for historical
589 # reasons which cause compile warnings, so we disable those warnings.
590 OSSH_CHECK_CFLAG_COMPILE([-Wno-attributes])
Damien Millerbac2d8a2000-09-05 16:13:06 +1100591 ;;
Ben Lindstrom58055132001-02-15 18:34:29 +0000592*-*-dgux*)
Tim Rice648f8762011-01-26 12:38:57 -0800593 AC_DEFINE([IP_TOS_IS_BROKEN], [1],
Tim Ricea74000e2009-03-18 11:25:02 -0700594 [Define if your system choked on IP TOS setting])
Tim Rice648f8762011-01-26 12:38:57 -0800595 AC_DEFINE([SETEUID_BREAKS_SETUID])
596 AC_DEFINE([BROKEN_SETREUID])
597 AC_DEFINE([BROKEN_SETREGID])
Ben Lindstrom58055132001-02-15 18:34:29 +0000598 ;;
Ben Lindstromfed7bb42001-07-15 18:30:42 +0000599*-*-darwin*)
Damien Miller852472a2014-01-22 16:31:18 +1100600 use_pie=auto
Tim Rice648f8762011-01-26 12:38:57 -0800601 AC_MSG_CHECKING([if we have working getaddrinfo])
602 AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <mach-o/dyld.h>
Damien Millerfc93d4b2002-09-04 23:26:29 +1000603main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
604 exit(0);
605 else
606 exit(1);
Tim Rice648f8762011-01-26 12:38:57 -0800607}
608 ]])],
609 [AC_MSG_RESULT([working])],
610 [AC_MSG_RESULT([buggy])
611 AC_DEFINE([BROKEN_GETADDRINFO], [1],
612 [getaddrinfo is broken (if present)])
613 ],
614 [AC_MSG_RESULT([assume it is working])])
615 AC_DEFINE([SETEUID_BREAKS_SETUID])
616 AC_DEFINE([BROKEN_SETREUID])
617 AC_DEFINE([BROKEN_SETREGID])
618 AC_DEFINE([BROKEN_GLOB], [1], [OS X glob does not do what we expect])
619 AC_DEFINE_UNQUOTED([BIND_8_COMPAT], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700620 [Define if your resolver libs need this for getrrsetbyname])
Tim Rice648f8762011-01-26 12:38:57 -0800621 AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
622 AC_DEFINE([SSH_TUN_COMPAT_AF], [1],
Darren Tucker3eb48342006-06-23 21:05:12 +1000623 [Use tunnel device compatibility to OpenBSD])
Tim Rice648f8762011-01-26 12:38:57 -0800624 AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
Darren Tucker3eb48342006-06-23 21:05:12 +1000625 [Prepend the address family to IP tunnel traffic])
Tim Rice648f8762011-01-26 12:38:57 -0800626 m4_pattern_allow([AU_IPv])
Tim Ricee1d93702016-05-31 11:13:22 -0700627 AC_CHECK_DECL([AU_IPv4], [],
Tim Rice648f8762011-01-26 12:38:57 -0800628 AC_DEFINE([AU_IPv4], [0], [System only supports IPv4 audit records])
Darren Tuckeracada072008-02-25 21:05:04 +1100629 [#include <bsm/audit.h>]
Tim Rice648f8762011-01-26 12:38:57 -0800630 AC_DEFINE([LASTLOG_WRITE_PUTUTXLINE], [1],
Damien Miller20e231f2009-02-12 13:12:21 +1100631 [Define if pututxline updates lastlog too])
Darren Tuckeracada072008-02-25 21:05:04 +1100632 )
Damien Millerc09182f2011-06-03 12:11:38 +1000633 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV],
634 [Define to a Set Process Title type if your system is
635 supported by bsd-setproctitle.c])
Damien Millercd5e52e2011-06-27 07:18:18 +1000636 AC_CHECK_FUNCS([sandbox_init])
637 AC_CHECK_HEADERS([sandbox.h])
Damien Miller39f303b2016-02-23 12:56:59 +1100638 AC_CHECK_LIB([sandbox], [sandbox_apply], [
639 SSHDLIBS="$SSHDLIBS -lsandbox"
640 ])
Ben Lindstromfed7bb42001-07-15 18:30:42 +0000641 ;;
Darren Tucker57b29202006-09-10 20:25:51 +1000642*-*-dragonfly*)
643 SSHDLIBS="$SSHDLIBS -lcrypt"
Darren Tucker882abfd2013-11-09 00:17:41 +1100644 TEST_MALLOC_OPTIONS="AFGJPRX"
Darren Tucker57b29202006-09-10 20:25:51 +1000645 ;;
Tim Ricee1d93702016-05-31 11:13:22 -0700646*-*-haiku*)
Darren Tucker5faa52d2016-08-02 15:22:40 +1000647 LIBS="$LIBS -lbsd "
648 AC_CHECK_LIB([network], [socket])
649 AC_DEFINE([HAVE_U_INT64_T])
650 MANTYPE=man
651 ;;
Darren Tuckerfd333282005-05-28 18:31:42 +1000652*-*-hpux*)
653 # first we define all of the options common to all HP-UX releases
Kevin Steves315f8b72001-06-28 00:24:41 +0000654 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
Damien Miller9a947342000-08-30 10:03:33 +1100655 IPADDR_IN_DISPLAY=yes
Tim Rice648f8762011-01-26 12:38:57 -0800656 AC_DEFINE([USE_PIPES])
Tim Rice648f8762011-01-26 12:38:57 -0800657 AC_DEFINE([LOGIN_NEEDS_UTMPX])
658 AC_DEFINE([LOCKED_PASSWD_STRING], ["*"],
Tim Rice7df8d392005-09-19 09:33:39 -0700659 [String used in /etc/passwd to denote locked account])
Tim Rice648f8762011-01-26 12:38:57 -0800660 AC_DEFINE([SPT_TYPE], [SPT_PSTAT])
Darren Tuckeraa97d132013-03-12 11:31:05 +1100661 AC_DEFINE([PLATFORM_SYS_DIR_UID], 2, [System dirs owned by bin (uid 2)])
Tim Rice90f42b02011-06-02 18:17:49 -0700662 maildir="/var/mail"
Tim Ricef028f1e2002-07-19 12:41:10 -0700663 LIBS="$LIBS -lsec"
Tim Rice648f8762011-01-26 12:38:57 -0800664 AC_CHECK_LIB([xnet], [t_error], ,
665 [AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***])])
Darren Tuckerfd333282005-05-28 18:31:42 +1000666
667 # next, we define all of the options specific to major releases
668 case "$host" in
669 *-*-hpux10*)
670 if test -z "$GCC"; then
671 CFLAGS="$CFLAGS -Ae"
672 fi
673 ;;
674 *-*-hpux11*)
Tim Rice648f8762011-01-26 12:38:57 -0800675 AC_DEFINE([PAM_SUN_CODEBASE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700676 [Define if you are using Solaris-derived PAM which
677 passes pam_messages to the conversation function
678 with an extra level of indirection])
Tim Rice648f8762011-01-26 12:38:57 -0800679 AC_DEFINE([DISABLE_UTMP], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700680 [Define if you don't want to use utmp])
Tim Rice648f8762011-01-26 12:38:57 -0800681 AC_DEFINE([USE_BTMP], [1], [Use btmp to log bad logins])
Darren Tuckerfd333282005-05-28 18:31:42 +1000682 check_for_hpux_broken_getaddrinfo=1
683 check_for_conflicting_getspnam=1
684 ;;
685 esac
686
687 # lastly, we define options specific to minor releases
688 case "$host" in
689 *-*-hpux10.26)
Tim Rice648f8762011-01-26 12:38:57 -0800690 AC_DEFINE([HAVE_SECUREWARE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700691 [Define if you have SecureWare-based
692 protected password database])
Darren Tuckerfd333282005-05-28 18:31:42 +1000693 disable_ptmx_check=yes
694 LIBS="$LIBS -lsecpw"
695 ;;
696 esac
Damien Miller1bead332000-04-30 00:47:29 +1000697 ;;
Damien Millerbeb4ba51999-12-28 15:09:35 +1100698*-*-irix5*)
Damien Miller190d5a82000-09-30 09:43:19 +1100699 PATH="$PATH:/usr/etc"
Tim Rice648f8762011-01-26 12:38:57 -0800700 AC_DEFINE([BROKEN_INET_NTOA], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700701 [Define if you system's inet_ntoa is busted
702 (e.g. Irix gcc issue)])
Tim Rice648f8762011-01-26 12:38:57 -0800703 AC_DEFINE([SETEUID_BREAKS_SETUID])
704 AC_DEFINE([BROKEN_SETREUID])
705 AC_DEFINE([BROKEN_SETREGID])
706 AC_DEFINE([WITH_ABBREV_NO_TTY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700707 [Define if you shouldn't strip 'tty' from your
708 ttyname in [uw]tmp])
Tim Rice648f8762011-01-26 12:38:57 -0800709 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Damien Miller1808f382000-01-06 12:03:12 +1100710 ;;
711*-*-irix6*)
Damien Miller190d5a82000-09-30 09:43:19 +1100712 PATH="$PATH:/usr/etc"
Tim Rice648f8762011-01-26 12:38:57 -0800713 AC_DEFINE([WITH_IRIX_ARRAY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700714 [Define if you have/want arrays
715 (cluster-wide session managment, not C arrays)])
Tim Rice648f8762011-01-26 12:38:57 -0800716 AC_DEFINE([WITH_IRIX_PROJECT], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700717 [Define if you want IRIX project management])
Tim Rice648f8762011-01-26 12:38:57 -0800718 AC_DEFINE([WITH_IRIX_AUDIT], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700719 [Define if you want IRIX audit trails])
Tim Rice648f8762011-01-26 12:38:57 -0800720 AC_CHECK_FUNC([jlimit_startjob], [AC_DEFINE([WITH_IRIX_JOBS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700721 [Define if you want IRIX kernel jobs])])
Tim Rice648f8762011-01-26 12:38:57 -0800722 AC_DEFINE([BROKEN_INET_NTOA])
723 AC_DEFINE([SETEUID_BREAKS_SETUID])
724 AC_DEFINE([BROKEN_SETREUID])
725 AC_DEFINE([BROKEN_SETREGID])
726 AC_DEFINE([BROKEN_UPDWTMPX], [1], [updwtmpx is broken (if present)])
727 AC_DEFINE([WITH_ABBREV_NO_TTY])
728 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Damien Millerbeb4ba51999-12-28 15:09:35 +1100729 ;;
Damien Miller90551722009-02-16 15:37:03 +1100730*-*-k*bsd*-gnu | *-*-kopensolaris*-gnu)
731 check_for_libcrypt_later=1
Tim Rice648f8762011-01-26 12:38:57 -0800732 AC_DEFINE([PAM_TTY_KLUDGE])
733 AC_DEFINE([LOCKED_PASSWD_PREFIX], ["!"])
734 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV])
735 AC_DEFINE([_PATH_BTMP], ["/var/log/btmp"], [log for bad login attempts])
736 AC_DEFINE([USE_BTMP], [1], [Use btmp to log bad logins])
Damien Miller90551722009-02-16 15:37:03 +1100737 ;;
Damien Millerb29ea912000-01-15 14:12:03 +1100738*-*-linux*)
739 no_dev_ptmx=1
Damien Miller852472a2014-01-22 16:31:18 +1100740 use_pie=auto
Damien Millera64b57a2001-01-17 10:44:13 +1100741 check_for_libcrypt_later=1
Darren Tucker70a3d552003-08-21 17:58:29 +1000742 check_for_openpty_ctty_bug=1
Darren Tuckerc61d5ec2017-02-03 14:10:34 +1100743 dnl Target SUSv3/POSIX.1-2001 plus BSD specifics.
744 dnl _DEFAULT_SOURCE is the new name for _BSD_SOURCE
745 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_DEFAULT_SOURCE"
Tim Rice648f8762011-01-26 12:38:57 -0800746 AC_DEFINE([PAM_TTY_KLUDGE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700747 [Work around problematic Linux PAM modules handling of PAM_TTY])
Tim Rice648f8762011-01-26 12:38:57 -0800748 AC_DEFINE([LOCKED_PASSWD_PREFIX], ["!"],
Tim Rice7df8d392005-09-19 09:33:39 -0700749 [String used in /etc/passwd to denote locked account])
Tim Rice648f8762011-01-26 12:38:57 -0800750 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV])
751 AC_DEFINE([LINK_OPNOTSUPP_ERRNO], [EPERM],
Tim Rice7df8d392005-09-19 09:33:39 -0700752 [Define to whatever link() returns for "not supported"
753 if it doesn't return EOPNOTSUPP.])
Tim Rice648f8762011-01-26 12:38:57 -0800754 AC_DEFINE([_PATH_BTMP], ["/var/log/btmp"], [log for bad login attempts])
755 AC_DEFINE([USE_BTMP])
756 AC_DEFINE([LINUX_OOM_ADJUST], [1], [Adjust Linux out-of-memory killer])
Damien Miller7bcb0892000-03-11 20:45:40 +1100757 inet6_default_4in6=yes
Darren Tucker3c016542003-05-02 20:48:21 +1000758 case `uname -r` in
Darren Tuckerc437cda2003-05-10 17:05:46 +1000759 1.*|2.0.*)
Tim Rice648f8762011-01-26 12:38:57 -0800760 AC_DEFINE([BROKEN_CMSG_TYPE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700761 [Define if cmsg_type is not passed correctly])
Darren Tucker3c016542003-05-02 20:48:21 +1000762 ;;
Darren Tucker3c016542003-05-02 20:48:21 +1000763 esac
Damien Miller89e03ba2005-12-31 16:42:03 +1100764 # tun(4) forwarding compat code
Tim Rice648f8762011-01-26 12:38:57 -0800765 AC_CHECK_HEADERS([linux/if_tun.h])
Damien Millerbd4e4102006-01-01 21:03:30 +1100766 if test "x$ac_cv_header_linux_if_tun_h" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -0800767 AC_DEFINE([SSH_TUN_LINUX], [1],
Damien Miller89e03ba2005-12-31 16:42:03 +1100768 [Open tunnel devices the Linux tun/tap way])
Tim Rice648f8762011-01-26 12:38:57 -0800769 AC_DEFINE([SSH_TUN_COMPAT_AF], [1],
Damien Miller89e03ba2005-12-31 16:42:03 +1100770 [Use tunnel device compatibility to OpenBSD])
Tim Rice648f8762011-01-26 12:38:57 -0800771 AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
Damien Miller89e03ba2005-12-31 16:42:03 +1100772 [Prepend the address family to IP tunnel traffic])
773 fi
Darren Tucker60395f92012-07-03 14:31:18 +1000774 AC_CHECK_HEADERS([linux/seccomp.h linux/filter.h linux/audit.h], [],
775 [], [#include <linux/types.h>])
Damien Miller91f40d82013-02-22 11:37:00 +1100776 AC_MSG_CHECKING([for seccomp architecture])
777 seccomp_audit_arch=
Damien Millere0956e32012-04-04 11:27:54 +1000778 case "$host" in
779 x86_64-*)
Damien Miller91f40d82013-02-22 11:37:00 +1100780 seccomp_audit_arch=AUDIT_ARCH_X86_64
Damien Millere0956e32012-04-04 11:27:54 +1000781 ;;
782 i*86-*)
Damien Miller91f40d82013-02-22 11:37:00 +1100783 seccomp_audit_arch=AUDIT_ARCH_I386
Damien Millere0956e32012-04-04 11:27:54 +1000784 ;;
Damien Miller99f33d72015-06-17 10:50:51 +1000785 arm*-*)
Damien Miller91f40d82013-02-22 11:37:00 +1100786 seccomp_audit_arch=AUDIT_ARCH_ARM
Damien Miller99f33d72015-06-17 10:50:51 +1000787 ;;
788 aarch64*-*)
789 seccomp_audit_arch=AUDIT_ARCH_AARCH64
Damien Miller5c15e222015-06-18 15:07:56 +1000790 ;;
Damien Millerb9c50612016-07-08 13:59:13 +1000791 s390x-*)
792 seccomp_audit_arch=AUDIT_ARCH_S390X
793 ;;
794 s390-*)
795 seccomp_audit_arch=AUDIT_ARCH_S390
796 ;;
797 powerpc64-*)
798 seccomp_audit_arch=AUDIT_ARCH_PPC64
799 ;;
800 powerpc64le-*)
801 seccomp_audit_arch=AUDIT_ARCH_PPC64LE
802 ;;
803 mips-*)
804 seccomp_audit_arch=AUDIT_ARCH_MIPS
805 ;;
806 mipsel-*)
807 seccomp_audit_arch=AUDIT_ARCH_MIPSEL
808 ;;
809 mips64-*)
810 seccomp_audit_arch=AUDIT_ARCH_MIPS64
811 ;;
812 mips64el-*)
813 seccomp_audit_arch=AUDIT_ARCH_MIPSEL64
814 ;;
Damien Millere0956e32012-04-04 11:27:54 +1000815 esac
Damien Miller91f40d82013-02-22 11:37:00 +1100816 if test "x$seccomp_audit_arch" != "x" ; then
817 AC_MSG_RESULT(["$seccomp_audit_arch"])
Damien Miller99f33d72015-06-17 10:50:51 +1000818 AC_DEFINE_UNQUOTED([SECCOMP_AUDIT_ARCH], [$seccomp_audit_arch],
819 [Specify the system call convention in use])
Damien Miller91f40d82013-02-22 11:37:00 +1100820 else
821 AC_MSG_RESULT([architecture not supported])
822 fi
Damien Millerb29ea912000-01-15 14:12:03 +1100823 ;;
Ben Lindstromb5628642000-10-18 00:02:25 +0000824mips-sony-bsd|mips-sony-newsos4)
Tim Rice648f8762011-01-26 12:38:57 -0800825 AC_DEFINE([NEED_SETPGRP], [1], [Need setpgrp to acquire controlling tty])
Ben Lindstromb5628642000-10-18 00:02:25 +0000826 SONY=1
Ben Lindstromb5628642000-10-18 00:02:25 +0000827 ;;
Damien Milleree1c0b32000-01-21 00:18:15 +1100828*-*-netbsd*)
Damien Millerfc93d4b2002-09-04 23:26:29 +1000829 check_for_libcrypt_before=1
Tim Riceeae17cc2005-03-17 16:52:20 -0800830 if test "x$withval" != "xno" ; then
Tim Rice88368a32003-12-08 12:35:59 -0800831 need_dash_r=1
832 fi
Damien Miller99522ba2016-07-28 08:54:27 +1000833 CPPFLAGS="$CPPFLAGS -D_OPENBSD_SOURCE"
Tim Rice648f8762011-01-26 12:38:57 -0800834 AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
Damien Miller2dcddbf2006-01-01 19:47:05 +1100835 AC_CHECK_HEADER([net/if_tap.h], ,
Tim Rice648f8762011-01-26 12:38:57 -0800836 AC_DEFINE([SSH_TUN_NO_L2], [1], [No layer 2 tunnel support]))
837 AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
Damien Miller2dcddbf2006-01-01 19:47:05 +1100838 [Prepend the address family to IP tunnel traffic])
Darren Tucker882abfd2013-11-09 00:17:41 +1100839 TEST_MALLOC_OPTIONS="AJRX"
Damien Millerf5bbd3b2014-01-30 11:26:46 +1100840 AC_DEFINE([BROKEN_READ_COMPARISON], [1],
841 [NetBSD read function is sometimes redirected, breaking atomicio comparisons against it])
Damien Milleree1c0b32000-01-21 00:18:15 +1100842 ;;
Damien Millerfbd884a2001-02-27 08:39:07 +1100843*-*-freebsd*)
844 check_for_libcrypt_later=1
Tim Rice648f8762011-01-26 12:38:57 -0800845 AC_DEFINE([LOCKED_PASSWD_PREFIX], ["*LOCKED*"], [Account locked with pw(1)])
846 AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
Damien Miller2dcddbf2006-01-01 19:47:05 +1100847 AC_CHECK_HEADER([net/if_tap.h], ,
Tim Rice648f8762011-01-26 12:38:57 -0800848 AC_DEFINE([SSH_TUN_NO_L2], [1], [No layer 2 tunnel support]))
849 AC_DEFINE([BROKEN_GLOB], [1], [FreeBSD glob does not do what we need])
Darren Tucker882abfd2013-11-09 00:17:41 +1100850 TEST_MALLOC_OPTIONS="AJRX"
Damien Miller2035b222014-01-26 09:39:53 +1100851 # Preauth crypto occasionally uses file descriptors for crypto offload
852 # and will crash if they cannot be opened.
Damien Miller5b447c02014-01-26 09:46:53 +1100853 AC_DEFINE([SANDBOX_SKIP_RLIMIT_NOFILE], [1],
Tim Rice03ae0812014-02-21 09:09:34 -0800854 [define if setrlimit RLIMIT_NOFILE breaks things])
Damien Millerfbd884a2001-02-27 08:39:07 +1100855 ;;
Darren Tuckered9eb022003-09-22 11:18:47 +1000856*-*-bsdi*)
Tim Rice648f8762011-01-26 12:38:57 -0800857 AC_DEFINE([SETEUID_BREAKS_SETUID])
858 AC_DEFINE([BROKEN_SETREUID])
859 AC_DEFINE([BROKEN_SETREGID])
Darren Tuckered9eb022003-09-22 11:18:47 +1000860 ;;
Damien Miller0f91b4e2000-06-18 15:43:25 +1000861*-next-*)
Damien Miller0f91b4e2000-06-18 15:43:25 +1000862 conf_lastlog_location="/usr/adm/lastlog"
Damien Millere5192fa2000-08-29 14:30:37 +1100863 conf_utmp_location=/etc/utmp
864 conf_wtmp_location=/usr/adm/wtmp
Tim Rice90f42b02011-06-02 18:17:49 -0700865 maildir=/usr/spool/mail
Tim Rice648f8762011-01-26 12:38:57 -0800866 AC_DEFINE([HAVE_NEXT], [1], [Define if you are on NeXT])
867 AC_DEFINE([BROKEN_REALPATH])
868 AC_DEFINE([USE_PIPES])
869 AC_DEFINE([BROKEN_SAVED_UIDS], [1], [Needed for NeXT])
Damien Miller0f91b4e2000-06-18 15:43:25 +1000870 ;;
Darren Tucker4a422572005-07-14 17:22:11 +1000871*-*-openbsd*)
Damien Miller852472a2014-01-22 16:31:18 +1100872 use_pie=auto
Tim Rice648f8762011-01-26 12:38:57 -0800873 AC_DEFINE([HAVE_ATTRIBUTE__SENTINEL__], [1], [OpenBSD's gcc has sentinel])
874 AC_DEFINE([HAVE_ATTRIBUTE__BOUNDED__], [1], [OpenBSD's gcc has bounded])
875 AC_DEFINE([SSH_TUN_OPENBSD], [1], [Open tunnel devices the OpenBSD way])
876 AC_DEFINE([SYSLOG_R_SAFE_IN_SIGHAND], [1],
Damien Millerbb598142006-08-19 08:38:23 +1000877 [syslog_r function is safe to use in in a signal handler])
Darren Tucker882abfd2013-11-09 00:17:41 +1100878 TEST_MALLOC_OPTIONS="AFGJPRX"
Darren Tucker4a422572005-07-14 17:22:11 +1000879 ;;
Damien Miller75b1d102000-01-07 14:01:41 +1100880*-*-solaris*)
Tim Riceeae17cc2005-03-17 16:52:20 -0800881 if test "x$withval" != "xno" ; then
Tim Ricead4a1882004-02-29 15:53:37 -0800882 need_dash_r=1
883 fi
Tim Rice648f8762011-01-26 12:38:57 -0800884 AC_DEFINE([PAM_SUN_CODEBASE])
885 AC_DEFINE([LOGIN_NEEDS_UTMPX])
Tim Rice648f8762011-01-26 12:38:57 -0800886 AC_DEFINE([PAM_TTY_KLUDGE])
887 AC_DEFINE([SSHPAM_CHAUTHTOK_NEEDS_RUID], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700888 [Define if pam_chauthtok wants real uid set
889 to the unpriv'ed user])
Tim Rice648f8762011-01-26 12:38:57 -0800890 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Darren Tuckerc437cda2003-05-10 17:05:46 +1000891 # Pushing STREAMS modules will cause sshd to acquire a controlling tty.
Tim Rice648f8762011-01-26 12:38:57 -0800892 AC_DEFINE([SSHD_ACQUIRES_CTTY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700893 [Define if sshd somehow reacquires a controlling TTY
894 after setsid()])
Tim Rice648f8762011-01-26 12:38:57 -0800895 AC_DEFINE([PASSWD_NEEDS_USERNAME], [1], [must supply username to passwd
Darren Tucker0249f932006-06-24 12:10:07 +1000896 in case the name is longer than 8 chars])
Tim Rice648f8762011-01-26 12:38:57 -0800897 AC_DEFINE([BROKEN_TCGETATTR_ICANON], [1], [tcgetattr with ICANON may hang])
Darren Tuckere1a790d2003-09-16 11:52:19 +1000898 external_path_file=/etc/default/login
andre2ff7b5d2000-06-03 14:57:40 +0000899 # hardwire lastlog location (can't detect it on some versions)
900 conf_lastlog_location="/var/adm/lastlog"
Tim Rice648f8762011-01-26 12:38:57 -0800901 AC_MSG_CHECKING([for obsolete utmp and wtmp in solaris2.x])
Damien Millera1cb6442000-06-09 11:58:35 +1000902 sol2ver=`echo "$host"| sed -e 's/.*[[0-9]]\.//'`
903 if test "$sol2ver" -ge 8; then
Tim Rice648f8762011-01-26 12:38:57 -0800904 AC_MSG_RESULT([yes])
905 AC_DEFINE([DISABLE_UTMP])
906 AC_DEFINE([DISABLE_WTMP], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700907 [Define if you don't want to use wtmp])
Damien Millera1cb6442000-06-09 11:58:35 +1000908 else
Tim Rice648f8762011-01-26 12:38:57 -0800909 AC_MSG_RESULT([no])
Damien Millera1cb6442000-06-09 11:58:35 +1000910 fi
Darren Tuckera86ec4d2016-06-14 10:48:27 +1000911 AC_CHECK_FUNCS([setpflags])
Darren Tucker907091a2016-02-19 09:05:39 +1100912 AC_CHECK_FUNCS([setppriv])
913 AC_CHECK_FUNCS([priv_basicset])
914 AC_CHECK_HEADERS([priv.h])
Tim Rice648f8762011-01-26 12:38:57 -0800915 AC_ARG_WITH([solaris-contracts],
Damien Miller1b06dc32006-08-31 03:24:41 +1000916 [ --with-solaris-contracts Enable Solaris process contracts (experimental)],
917 [
Tim Rice648f8762011-01-26 12:38:57 -0800918 AC_CHECK_LIB([contract], [ct_tmpl_activate],
919 [ AC_DEFINE([USE_SOLARIS_PROCESS_CONTRACTS], [1],
Damien Miller1b06dc32006-08-31 03:24:41 +1000920 [Define if you have Solaris process contracts])
Damien Miller4626cba2016-01-08 14:24:56 +1100921 LIBS="$LIBS -lcontract"
Damien Miller1b06dc32006-08-31 03:24:41 +1000922 SPC_MSG="yes" ], )
923 ],
924 )
Tim Rice648f8762011-01-26 12:38:57 -0800925 AC_ARG_WITH([solaris-projects],
Darren Tucker97528352010-11-05 12:03:05 +1100926 [ --with-solaris-projects Enable Solaris projects (experimental)],
927 [
Tim Rice648f8762011-01-26 12:38:57 -0800928 AC_CHECK_LIB([project], [setproject],
929 [ AC_DEFINE([USE_SOLARIS_PROJECTS], [1],
Darren Tucker97528352010-11-05 12:03:05 +1100930 [Define if you have Solaris projects])
Damien Miller4626cba2016-01-08 14:24:56 +1100931 LIBS="$LIBS -lproject"
Darren Tucker97528352010-11-05 12:03:05 +1100932 SP_MSG="yes" ], )
933 ],
934 )
Damien Miller4626cba2016-01-08 14:24:56 +1100935 AC_ARG_WITH([solaris-privs],
936 [ --with-solaris-privs Enable Solaris/Illumos privileges (experimental)],
937 [
938 AC_MSG_CHECKING([for Solaris/Illumos privilege support])
Darren Tucker907091a2016-02-19 09:05:39 +1100939 if test "x$ac_cv_func_setppriv" = "xyes" -a \
940 "x$ac_cv_header_priv_h" = "xyes" ; then
941 SOLARIS_PRIVS=yes
Damien Miller4626cba2016-01-08 14:24:56 +1100942 AC_MSG_RESULT([found])
943 AC_DEFINE([NO_UID_RESTORATION_TEST], [1],
944 [Define to disable UID restoration test])
945 AC_DEFINE([USE_SOLARIS_PRIVS], [1],
946 [Define if you have Solaris privileges])
947 SPP_MSG="yes"
948 else
949 AC_MSG_RESULT([not found])
950 AC_MSG_ERROR([*** must have support for Solaris privileges to use --with-solaris-privs])
951 fi
952 ],
953 )
Tim Rice5ab9b632013-06-02 14:05:48 -0700954 TEST_SHELL=$SHELL # let configure find us a capable shell
Damien Miller75b1d102000-01-07 14:01:41 +1100955 ;;
Damien Millerdfc83f42000-05-20 15:02:59 +1000956*-*-sunos4*)
Ben Lindstrom28bfc0d2000-12-18 19:58:57 +0000957 CPPFLAGS="$CPPFLAGS -DSUNOS4"
Tim Rice648f8762011-01-26 12:38:57 -0800958 AC_CHECK_FUNCS([getpwanam])
959 AC_DEFINE([PAM_SUN_CODEBASE])
Damien Miller36ccb5c2000-08-09 16:34:27 +1000960 conf_utmp_location=/etc/utmp
961 conf_wtmp_location=/var/adm/wtmp
962 conf_lastlog_location=/var/adm/lastlog
Tim Rice648f8762011-01-26 12:38:57 -0800963 AC_DEFINE([USE_PIPES])
Damien Millerdfc83f42000-05-20 15:02:59 +1000964 ;;
Ben Lindstrom603bdfd2001-02-12 07:29:45 +0000965*-ncr-sysv*)
Tim Rice13aae5e2001-10-21 17:53:58 -0700966 LIBS="$LIBS -lc89"
Tim Rice648f8762011-01-26 12:38:57 -0800967 AC_DEFINE([USE_PIPES])
968 AC_DEFINE([SSHD_ACQUIRES_CTTY])
969 AC_DEFINE([SETEUID_BREAKS_SETUID])
970 AC_DEFINE([BROKEN_SETREUID])
971 AC_DEFINE([BROKEN_SETREGID])
Ben Lindstrom603bdfd2001-02-12 07:29:45 +0000972 ;;
Damien Miller2ae714f2000-07-11 09:29:50 +1000973*-sni-sysv*)
Tim Riceffdf4aa2001-10-27 10:45:36 -0700974 # /usr/ucblib MUST NOT be searched on ReliantUNIX
Tim Rice648f8762011-01-26 12:38:57 -0800975 AC_CHECK_LIB([dl], [dlsym], ,)
Darren Tucker79d09fa2005-11-24 22:34:54 +1100976 # -lresolv needs to be at the end of LIBS or DNS lookups break
Tim Rice648f8762011-01-26 12:38:57 -0800977 AC_CHECK_LIB([resolv], [res_query], [ LIBS="$LIBS -lresolv" ])
Damien Millerfd9885e2001-01-10 08:16:53 +1100978 IPADDR_IN_DISPLAY=yes
Tim Rice648f8762011-01-26 12:38:57 -0800979 AC_DEFINE([USE_PIPES])
980 AC_DEFINE([IP_TOS_IS_BROKEN])
981 AC_DEFINE([SETEUID_BREAKS_SETUID])
982 AC_DEFINE([BROKEN_SETREUID])
983 AC_DEFINE([BROKEN_SETREGID])
984 AC_DEFINE([SSHD_ACQUIRES_CTTY])
Darren Tuckere1a790d2003-09-16 11:52:19 +1000985 external_path_file=/etc/default/login
Tim Riceffdf4aa2001-10-27 10:45:36 -0700986 # /usr/ucblib/libucb.a no longer needed on ReliantUNIX
987 # Attention: always take care to bind libsocket and libnsl before libc,
988 # otherwise you will find lots of "SIOCGPGRP errno 22" on syslog
Damien Miller2ae714f2000-07-11 09:29:50 +1000989 ;;
Tim Rice0f83d292004-12-08 18:29:58 -0800990# UnixWare 1.x, UnixWare 2.x, and others based on code from Univel.
Damien Miller78315eb2000-09-29 23:01:36 +1100991*-*-sysv4.2*)
Tim Rice648f8762011-01-26 12:38:57 -0800992 AC_DEFINE([USE_PIPES])
993 AC_DEFINE([SETEUID_BREAKS_SETUID])
994 AC_DEFINE([BROKEN_SETREUID])
995 AC_DEFINE([BROKEN_SETREGID])
996 AC_DEFINE([PASSWD_NEEDS_USERNAME], [1], [must supply username to passwd])
997 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Tim Rice5ab9b632013-06-02 14:05:48 -0700998 TEST_SHELL=$SHELL # let configure find us a capable shell
Damien Miller78315eb2000-09-29 23:01:36 +1100999 ;;
Tim Rice0f83d292004-12-08 18:29:58 -08001000# UnixWare 7.x, OpenUNIX 8
Damien Miller78315eb2000-09-29 23:01:36 +11001001*-*-sysv5*)
Tim Rice641ebf12010-01-17 17:05:39 -08001002 CPPFLAGS="$CPPFLAGS -Dvsnprintf=_xvsnprintf -Dsnprintf=_xsnprintf"
Tim Rice648f8762011-01-26 12:38:57 -08001003 AC_DEFINE([UNIXWARE_LONG_PASSWORDS], [1], [Support passwords > 8 chars])
1004 AC_DEFINE([USE_PIPES])
1005 AC_DEFINE([SETEUID_BREAKS_SETUID])
1006 AC_DEFINE([BROKEN_GETADDRINFO])
1007 AC_DEFINE([BROKEN_SETREUID])
1008 AC_DEFINE([BROKEN_SETREGID])
1009 AC_DEFINE([PASSWD_NEEDS_USERNAME])
Tim Rice5ab9b632013-06-02 14:05:48 -07001010 TEST_SHELL=$SHELL # let configure find us a capable shell
Tim Rice4dbacff2005-06-01 20:09:28 -07001011 case "$host" in
1012 *-*-sysv5SCO_SV*) # SCO OpenServer 6.x
Tim Rice90f42b02011-06-02 18:17:49 -07001013 maildir=/var/spool/mail
Tim Rice648f8762011-01-26 12:38:57 -08001014 AC_DEFINE([BROKEN_LIBIAF], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001015 [ia_uinfo routines not supported by OS yet])
Tim Rice648f8762011-01-26 12:38:57 -08001016 AC_DEFINE([BROKEN_UPDWTMPX])
1017 AC_CHECK_LIB([prot], [getluid], [ LIBS="$LIBS -lprot"
1018 AC_CHECK_FUNCS([getluid setluid], , , [-lprot])
1019 AC_DEFINE([HAVE_SECUREWARE])
1020 AC_DEFINE([DISABLE_SHADOW])
1021 ], , )
Tim Rice4dbacff2005-06-01 20:09:28 -07001022 ;;
Tim Rice648f8762011-01-26 12:38:57 -08001023 *) AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Tim Rice26767912009-01-07 20:50:08 -08001024 check_for_libcrypt_later=1
Tim Rice46259d82005-11-28 18:40:34 -08001025 ;;
Tim Rice4dbacff2005-06-01 20:09:28 -07001026 esac
Damien Miller78315eb2000-09-29 23:01:36 +11001027 ;;
Damien Miller75b1d102000-01-07 14:01:41 +11001028*-*-sysv*)
Damien Miller75b1d102000-01-07 14:01:41 +11001029 ;;
Tim Rice0f83d292004-12-08 18:29:58 -08001030# SCO UNIX and OEM versions of SCO UNIX
Damien Miller78315eb2000-09-29 23:01:36 +11001031*-*-sco3.2v4*)
Tim Ricec390c8d2005-03-07 01:21:37 -08001032 AC_MSG_ERROR("This Platform is no longer supported.")
Damien Miller78315eb2000-09-29 23:01:36 +11001033 ;;
Tim Rice0f83d292004-12-08 18:29:58 -08001034# SCO OpenServer 5.x
Damien Miller78315eb2000-09-29 23:01:36 +11001035*-*-sco3.2v5*)
Tim Rice89fe3f32003-01-19 20:20:24 -08001036 if test -z "$GCC"; then
1037 CFLAGS="$CFLAGS -belf"
1038 fi
Damien Miller5dfe9762001-02-16 12:05:39 +11001039 LIBS="$LIBS -lprot -lx -ltinfo -lm"
Damien Millera66626b2000-06-13 18:57:53 +10001040 no_dev_ptmx=1
Tim Rice648f8762011-01-26 12:38:57 -08001041 AC_DEFINE([USE_PIPES])
1042 AC_DEFINE([HAVE_SECUREWARE])
1043 AC_DEFINE([DISABLE_SHADOW])
1044 AC_DEFINE([DISABLE_FD_PASSING])
1045 AC_DEFINE([SETEUID_BREAKS_SETUID])
1046 AC_DEFINE([BROKEN_GETADDRINFO])
1047 AC_DEFINE([BROKEN_SETREUID])
1048 AC_DEFINE([BROKEN_SETREGID])
1049 AC_DEFINE([WITH_ABBREV_NO_TTY])
1050 AC_DEFINE([BROKEN_UPDWTMPX])
1051 AC_DEFINE([PASSWD_NEEDS_USERNAME])
1052 AC_CHECK_FUNCS([getluid setluid])
Tim Rice07183b82001-04-25 21:40:28 -07001053 MANTYPE=man
Tim Rice5ab9b632013-06-02 14:05:48 -07001054 TEST_SHELL=$SHELL # let configure find us a capable shell
Tim Riceaa86c392013-03-16 20:55:46 -07001055 SKIP_DISABLE_LASTLOG_DEFINE=yes
Damien Millera66626b2000-06-13 18:57:53 +10001056 ;;
Ben Lindstrom232ccf72002-07-22 23:34:25 +00001057*-*-unicosmk*)
Tim Rice648f8762011-01-26 12:38:57 -08001058 AC_DEFINE([NO_SSH_LASTLOG], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001059 [Define if you don't want to use lastlog in session.c])
Tim Rice648f8762011-01-26 12:38:57 -08001060 AC_DEFINE([SETEUID_BREAKS_SETUID])
1061 AC_DEFINE([BROKEN_SETREUID])
1062 AC_DEFINE([BROKEN_SETREGID])
1063 AC_DEFINE([USE_PIPES])
1064 AC_DEFINE([DISABLE_FD_PASSING])
Ben Lindstrom232ccf72002-07-22 23:34:25 +00001065 LDFLAGS="$LDFLAGS"
1066 LIBS="$LIBS -lgen -lrsc -lshare -luex -lacm"
1067 MANTYPE=cat
Ben Lindstrom762104e2002-07-23 00:00:05 +00001068 ;;
Darren Tucker9f7ffc52003-09-10 11:39:05 +10001069*-*-unicosmp*)
Tim Rice648f8762011-01-26 12:38:57 -08001070 AC_DEFINE([SETEUID_BREAKS_SETUID])
1071 AC_DEFINE([BROKEN_SETREUID])
1072 AC_DEFINE([BROKEN_SETREGID])
1073 AC_DEFINE([WITH_ABBREV_NO_TTY])
1074 AC_DEFINE([USE_PIPES])
1075 AC_DEFINE([DISABLE_FD_PASSING])
Darren Tucker9f7ffc52003-09-10 11:39:05 +10001076 LDFLAGS="$LDFLAGS"
Darren Tucker2df33432004-01-30 14:34:21 +11001077 LIBS="$LIBS -lgen -lacid -ldb"
Darren Tucker9f7ffc52003-09-10 11:39:05 +10001078 MANTYPE=cat
1079 ;;
Ben Lindstromd9e08242001-07-22 19:32:00 +00001080*-*-unicos*)
Tim Rice648f8762011-01-26 12:38:57 -08001081 AC_DEFINE([SETEUID_BREAKS_SETUID])
1082 AC_DEFINE([BROKEN_SETREUID])
1083 AC_DEFINE([BROKEN_SETREGID])
1084 AC_DEFINE([USE_PIPES])
1085 AC_DEFINE([DISABLE_FD_PASSING])
1086 AC_DEFINE([NO_SSH_LASTLOG])
Ben Lindstrom232ccf72002-07-22 23:34:25 +00001087 LDFLAGS="$LDFLAGS -Wl,-Dmsglevel=334:fatal"
1088 LIBS="$LIBS -lgen -lrsc -lshare -luex -lacm"
1089 MANTYPE=cat
Tim Ricee991e3c2001-08-07 15:29:07 -07001090 ;;
Damien Millerb8c656e2000-06-28 15:22:41 +10001091*-dec-osf*)
Tim Rice648f8762011-01-26 12:38:57 -08001092 AC_MSG_CHECKING([for Digital Unix SIA])
Ben Lindstrom72af2ef2001-05-08 20:42:28 +00001093 no_osfsia=""
Tim Rice648f8762011-01-26 12:38:57 -08001094 AC_ARG_WITH([osfsia],
Ben Lindstrom72af2ef2001-05-08 20:42:28 +00001095 [ --with-osfsia Enable Digital Unix SIA],
1096 [
1097 if test "x$withval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08001098 AC_MSG_RESULT([disabled])
Ben Lindstrom72af2ef2001-05-08 20:42:28 +00001099 no_osfsia=1
1100 fi
1101 ],
1102 )
1103 if test -z "$no_osfsia" ; then
Damien Millerb8c656e2000-06-28 15:22:41 +10001104 if test -f /etc/sia/matrix.conf; then
Tim Rice648f8762011-01-26 12:38:57 -08001105 AC_MSG_RESULT([yes])
1106 AC_DEFINE([HAVE_OSF_SIA], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001107 [Define if you have Digital Unix Security
1108 Integration Architecture])
Tim Rice648f8762011-01-26 12:38:57 -08001109 AC_DEFINE([DISABLE_LOGIN], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001110 [Define if you don't want to use your
1111 system's login() call])
Tim Rice648f8762011-01-26 12:38:57 -08001112 AC_DEFINE([DISABLE_FD_PASSING])
Damien Millerb8c656e2000-06-28 15:22:41 +10001113 LIBS="$LIBS -lsecurity -ldb -lm -laud"
Damien Miller1b06dc32006-08-31 03:24:41 +10001114 SIA_MSG="yes"
Damien Millerb8c656e2000-06-28 15:22:41 +10001115 else
Tim Rice648f8762011-01-26 12:38:57 -08001116 AC_MSG_RESULT([no])
1117 AC_DEFINE([LOCKED_PASSWD_SUBSTR], ["Nologin"],
Tim Rice7df8d392005-09-19 09:33:39 -07001118 [String used in /etc/passwd to denote locked account])
Damien Millerb8c656e2000-06-28 15:22:41 +10001119 fi
1120 fi
Tim Rice648f8762011-01-26 12:38:57 -08001121 AC_DEFINE([BROKEN_GETADDRINFO])
1122 AC_DEFINE([SETEUID_BREAKS_SETUID])
1123 AC_DEFINE([BROKEN_SETREUID])
1124 AC_DEFINE([BROKEN_SETREGID])
1125 AC_DEFINE([BROKEN_READV_COMPARISON], [1], [Can't do comparisons on readv])
Damien Millerb8c656e2000-06-28 15:22:41 +10001126 ;;
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00001127
Tim Rice70335a62006-02-04 17:42:58 -08001128*-*-nto-qnx*)
Tim Rice648f8762011-01-26 12:38:57 -08001129 AC_DEFINE([USE_PIPES])
1130 AC_DEFINE([NO_X11_UNIX_SOCKETS])
Tim Rice648f8762011-01-26 12:38:57 -08001131 AC_DEFINE([DISABLE_LASTLOG])
1132 AC_DEFINE([SSHD_ACQUIRES_CTTY])
1133 AC_DEFINE([BROKEN_SHADOW_EXPIRE], [1], [QNX shadow support is broken])
Tim Rice2f993462006-02-11 18:37:48 -08001134 enable_etc_default_login=no # has incompatible /etc/default/login
Darren Tucker8acb3b62007-08-10 14:36:12 +10001135 case "$host" in
1136 *-*-nto-qnx6*)
Tim Rice648f8762011-01-26 12:38:57 -08001137 AC_DEFINE([DISABLE_FD_PASSING])
Darren Tucker8acb3b62007-08-10 14:36:12 +10001138 ;;
1139 esac
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00001140 ;;
Darren Tucker2be1cbb2005-05-27 21:13:40 +10001141
1142*-*-ultrix*)
Tim Rice648f8762011-01-26 12:38:57 -08001143 AC_DEFINE([BROKEN_GETGROUPS], [1], [getgroups(0,NULL) will return -1])
Tim Rice648f8762011-01-26 12:38:57 -08001144 AC_DEFINE([NEED_SETPGRP])
1145 AC_DEFINE([HAVE_SYS_SYSLOG_H], [1], [Force use of sys/syslog.h on Ultrix])
Tim Ricefcc7ff12005-06-02 20:28:29 -07001146 ;;
Darren Tucker93e7e8f2005-08-23 08:06:55 +10001147
1148*-*-lynxos)
Darren Tucker5faa52d2016-08-02 15:22:40 +10001149 CFLAGS="$CFLAGS -D__NO_INCLUDE_WARN__"
1150 AC_DEFINE([BROKEN_SETVBUF], [1],
1151 [LynxOS has broken setvbuf() implementation])
1152 ;;
Damien Miller76112de1999-12-21 11:18:08 +11001153esac
1154
Tim Rice648f8762011-01-26 12:38:57 -08001155AC_MSG_CHECKING([compiler and flags for sanity])
1156AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]], [[ exit(0); ]])],
1157 [ AC_MSG_RESULT([yes]) ],
Darren Tucker6eb93042003-06-29 21:30:41 +10001158 [
Tim Rice648f8762011-01-26 12:38:57 -08001159 AC_MSG_RESULT([no])
Darren Tucker6eb93042003-06-29 21:30:41 +10001160 AC_MSG_ERROR([*** compiler cannot create working executables, check config.log ***])
Darren Tuckera0c2b392004-09-11 23:26:37 +10001161 ],
1162 [ AC_MSG_WARN([cross compiling: not checking compiler sanity]) ]
Darren Tucker6eb93042003-06-29 21:30:41 +10001163)
1164
Darren Tucker0c9653f2005-05-28 15:58:14 +10001165dnl Checks for header files.
Damien Millera22ba012000-03-02 23:09:20 +11001166# Checks for libraries.
Tim Rice648f8762011-01-26 12:38:57 -08001167AC_CHECK_FUNC([setsockopt], , [AC_CHECK_LIB([socket], [setsockopt])])
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00001168
Tim Rice1e1ef642003-09-11 22:19:31 -07001169dnl IRIX and Solaris 2.5.1 have dirname() in libgen
Tim Rice648f8762011-01-26 12:38:57 -08001170AC_CHECK_FUNCS([dirname], [AC_CHECK_HEADERS([libgen.h])] , [
1171 AC_CHECK_LIB([gen], [dirname], [
Tim Rice1e1ef642003-09-11 22:19:31 -07001172 AC_CACHE_CHECK([for broken dirname],
1173 ac_cv_have_broken_dirname, [
1174 save_LIBS="$LIBS"
1175 LIBS="$LIBS -lgen"
Darren Tucker314d89e2005-10-17 23:29:23 +10001176 AC_RUN_IFELSE(
1177 [AC_LANG_SOURCE([[
Tim Rice1e1ef642003-09-11 22:19:31 -07001178#include <libgen.h>
1179#include <string.h>
1180
1181int main(int argc, char **argv) {
1182 char *s, buf[32];
1183
1184 strncpy(buf,"/etc", 32);
1185 s = dirname(buf);
1186 if (!s || strncmp(s, "/", 32) != 0) {
1187 exit(1);
1188 } else {
1189 exit(0);
1190 }
1191}
Darren Tucker314d89e2005-10-17 23:29:23 +10001192 ]])],
Tim Rice1e1ef642003-09-11 22:19:31 -07001193 [ ac_cv_have_broken_dirname="no" ],
Darren Tucker314d89e2005-10-17 23:29:23 +10001194 [ ac_cv_have_broken_dirname="yes" ],
1195 [ ac_cv_have_broken_dirname="no" ],
Tim Rice1e1ef642003-09-11 22:19:31 -07001196 )
1197 LIBS="$save_LIBS"
1198 ])
1199 if test "x$ac_cv_have_broken_dirname" = "xno" ; then
1200 LIBS="$LIBS -lgen"
Tim Rice648f8762011-01-26 12:38:57 -08001201 AC_DEFINE([HAVE_DIRNAME])
1202 AC_CHECK_HEADERS([libgen.h])
Tim Rice1e1ef642003-09-11 22:19:31 -07001203 fi
1204 ])
1205])
1206
Tim Rice648f8762011-01-26 12:38:57 -08001207AC_CHECK_FUNC([getspnam], ,
1208 [AC_CHECK_LIB([gen], [getspnam], [LIBS="$LIBS -lgen"])])
1209AC_SEARCH_LIBS([basename], [gen], [AC_DEFINE([HAVE_BASENAME], [1],
1210 [Define if you have the basename function.])])
Tim Rice1e1ef642003-09-11 22:19:31 -07001211
Tim Rice13aae5e2001-10-21 17:53:58 -07001212dnl zlib is required
Tim Rice648f8762011-01-26 12:38:57 -08001213AC_ARG_WITH([zlib],
Tim Rice13aae5e2001-10-21 17:53:58 -07001214 [ --with-zlib=PATH Use zlib in PATH],
Darren Tucker86a5f8d2005-03-21 09:55:17 +11001215 [ if test "x$withval" = "xno" ; then
1216 AC_MSG_ERROR([*** zlib is required ***])
1217 elif test "x$withval" != "xyes"; then
Tim Rice13aae5e2001-10-21 17:53:58 -07001218 if test -d "$withval/lib"; then
1219 if test -n "${need_dash_r}"; then
Tim Rice02cebcd2001-10-25 10:01:30 -07001220 LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001221 else
Tim Rice02cebcd2001-10-25 10:01:30 -07001222 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001223 fi
1224 else
1225 if test -n "${need_dash_r}"; then
Tim Rice02cebcd2001-10-25 10:01:30 -07001226 LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001227 else
Tim Rice02cebcd2001-10-25 10:01:30 -07001228 LDFLAGS="-L${withval} ${LDFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001229 fi
1230 fi
1231 if test -d "$withval/include"; then
Tim Rice02cebcd2001-10-25 10:01:30 -07001232 CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001233 else
Tim Rice02cebcd2001-10-25 10:01:30 -07001234 CPPFLAGS="-I${withval} ${CPPFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001235 fi
Darren Tucker86a5f8d2005-03-21 09:55:17 +11001236 fi ]
Tim Rice13aae5e2001-10-21 17:53:58 -07001237)
1238
Tim Rice648f8762011-01-26 12:38:57 -08001239AC_CHECK_HEADER([zlib.h], ,[AC_MSG_ERROR([*** zlib.h missing - please install first or check config.log ***])])
1240AC_CHECK_LIB([z], [deflate], ,
Tim Ricefcb62202004-01-23 18:35:16 -08001241 [
1242 saved_CPPFLAGS="$CPPFLAGS"
1243 saved_LDFLAGS="$LDFLAGS"
1244 save_LIBS="$LIBS"
1245 dnl Check default zlib install dir
1246 if test -n "${need_dash_r}"; then
1247 LDFLAGS="-L/usr/local/lib -R/usr/local/lib ${saved_LDFLAGS}"
1248 else
1249 LDFLAGS="-L/usr/local/lib ${saved_LDFLAGS}"
1250 fi
1251 CPPFLAGS="-I/usr/local/include ${saved_CPPFLAGS}"
1252 LIBS="$LIBS -lz"
Tim Rice648f8762011-01-26 12:38:57 -08001253 AC_TRY_LINK_FUNC([deflate], [AC_DEFINE([HAVE_LIBZ])],
Tim Ricefcb62202004-01-23 18:35:16 -08001254 [
1255 AC_MSG_ERROR([*** zlib missing - please install first or check config.log ***])
1256 ]
1257 )
1258 ]
1259)
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001260
Tim Rice648f8762011-01-26 12:38:57 -08001261AC_ARG_WITH([zlib-version-check],
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001262 [ --without-zlib-version-check Disable zlib version check],
1263 [ if test "x$withval" = "xno" ; then
1264 zlib_check_nonfatal=1
1265 fi
1266 ]
1267)
1268
Tim Rice648f8762011-01-26 12:38:57 -08001269AC_MSG_CHECKING([for possibly buggy zlib])
1270AC_RUN_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001271#include <stdio.h>
Darren Tuckerc8a0f272013-03-22 12:49:14 +11001272#include <stdlib.h>
Darren Tucker2dcd2392004-01-23 17:13:33 +11001273#include <zlib.h>
Tim Rice648f8762011-01-26 12:38:57 -08001274 ]],
1275 [[
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001276 int a=0, b=0, c=0, d=0, n, v;
1277 n = sscanf(ZLIB_VERSION, "%d.%d.%d.%d", &a, &b, &c, &d);
1278 if (n != 3 && n != 4)
Darren Tucker2dcd2392004-01-23 17:13:33 +11001279 exit(1);
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001280 v = a*1000000 + b*10000 + c*100 + d;
1281 fprintf(stderr, "found zlib version %s (%d)\n", ZLIB_VERSION, v);
1282
1283 /* 1.1.4 is OK */
1284 if (a == 1 && b == 1 && c >= 4)
Darren Tucker2dcd2392004-01-23 17:13:33 +11001285 exit(0);
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001286
Darren Tucker41097ed2005-07-25 15:24:21 +10001287 /* 1.2.3 and up are OK */
1288 if (v >= 1020300)
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001289 exit(0);
1290
Darren Tucker2dcd2392004-01-23 17:13:33 +11001291 exit(2);
Darren Tucker623d92f2004-09-12 22:36:15 +10001292 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001293 AC_MSG_RESULT([no]),
1294 [ AC_MSG_RESULT([yes])
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001295 if test -z "$zlib_check_nonfatal" ; then
1296 AC_MSG_ERROR([*** zlib too old - check config.log ***
1297Your reported zlib version has known security problems. It's possible your
1298vendor has fixed these problems without changing the version number. If you
1299are sure this is the case, you can disable the check by running
1300"./configure --without-zlib-version-check".
Darren Tuckerac1910f2005-07-26 12:00:42 +10001301If you are in doubt, upgrade zlib to version 1.2.3 or greater.
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001302See http://www.gzip.org/zlib/ for details.])
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001303 else
1304 AC_MSG_WARN([zlib version may have security problems])
1305 fi
Darren Tuckera0c2b392004-09-11 23:26:37 +10001306 ],
1307 [ AC_MSG_WARN([cross compiling: not checking zlib version]) ]
Darren Tucker2dcd2392004-01-23 17:13:33 +11001308)
Damien Miller6f9c3372000-10-25 10:06:04 +11001309
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00001310dnl UnixWare 2.x
Tim Rice648f8762011-01-26 12:38:57 -08001311AC_CHECK_FUNC([strcasecmp],
1312 [], [ AC_CHECK_LIB([resolv], [strcasecmp], [LIBS="$LIBS -lresolv"]) ]
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00001313)
Tim Rice648f8762011-01-26 12:38:57 -08001314AC_CHECK_FUNCS([utimes],
1315 [], [ AC_CHECK_LIB([c89], [utimes], [AC_DEFINE([HAVE_UTIMES])
Tim Ricecbb90662002-07-08 19:17:10 -07001316 LIBS="$LIBS -lc89"]) ]
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00001317)
Damien Millerab18c411999-11-11 10:40:23 +11001318
Tim Ricee589a292001-11-03 11:09:32 -08001319dnl Checks for libutil functions
Damien Millerb87f6b72013-02-23 09:12:23 +11001320AC_CHECK_HEADERS([bsd/libutil.h libutil.h])
Damien Miller398c0ff2012-04-19 21:46:35 +10001321AC_SEARCH_LIBS([fmt_scaled], [util bsd])
Darren Tuckere194ba42013-05-16 20:47:31 +10001322AC_SEARCH_LIBS([scan_scaled], [util bsd])
Damien Miller398c0ff2012-04-19 21:46:35 +10001323AC_SEARCH_LIBS([login], [util bsd])
1324AC_SEARCH_LIBS([logout], [util bsd])
1325AC_SEARCH_LIBS([logwtmp], [util bsd])
1326AC_SEARCH_LIBS([openpty], [util bsd])
1327AC_SEARCH_LIBS([updwtmp], [util bsd])
Darren Tuckere194ba42013-05-16 20:47:31 +10001328AC_CHECK_FUNCS([fmt_scaled scan_scaled login logout openpty updwtmp logwtmp])
Tim Ricee589a292001-11-03 11:09:32 -08001329
Darren Tucker2fee9092016-02-17 09:48:15 +11001330# On some platforms, inet_ntop and gethostbyname may be found in libresolv
1331# or libnsl.
Damien Millerab039492014-01-28 15:07:10 +11001332AC_SEARCH_LIBS([inet_ntop], [resolv nsl])
Darren Tucker2fee9092016-02-17 09:48:15 +11001333AC_SEARCH_LIBS([gethostbyname], [resolv nsl])
Damien Millerab039492014-01-28 15:07:10 +11001334
Ben Lindstrom8697e082001-02-24 21:41:10 +00001335AC_FUNC_STRFTIME
1336
Damien Miller3c027682001-03-14 11:39:45 +11001337# Check for ALTDIRFUNC glob() extension
Tim Rice648f8762011-01-26 12:38:57 -08001338AC_MSG_CHECKING([for GLOB_ALTDIRFUNC support])
1339AC_EGREP_CPP([FOUNDIT],
Damien Miller3c027682001-03-14 11:39:45 +11001340 [
1341 #include <glob.h>
1342 #ifdef GLOB_ALTDIRFUNC
1343 FOUNDIT
1344 #endif
Damien Millera8e06ce2003-11-21 23:48:55 +11001345 ],
Damien Miller3c027682001-03-14 11:39:45 +11001346 [
Tim Rice648f8762011-01-26 12:38:57 -08001347 AC_DEFINE([GLOB_HAS_ALTDIRFUNC], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001348 [Define if your system glob() function has
1349 the GLOB_ALTDIRFUNC extension])
Tim Rice648f8762011-01-26 12:38:57 -08001350 AC_MSG_RESULT([yes])
Damien Miller3c027682001-03-14 11:39:45 +11001351 ],
1352 [
Tim Rice648f8762011-01-26 12:38:57 -08001353 AC_MSG_RESULT([no])
Damien Miller3c027682001-03-14 11:39:45 +11001354 ]
1355)
Damien Millerab18c411999-11-11 10:40:23 +11001356
Ben Lindstrom45b14db2001-03-17 01:15:38 +00001357# Check for g.gl_matchc glob() extension
Tim Rice648f8762011-01-26 12:38:57 -08001358AC_MSG_CHECKING([for gl_matchc field in glob_t])
1359AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <glob.h> ]],
1360 [[ glob_t g; g.gl_matchc = 1; ]])],
Damien Millera8e06ce2003-11-21 23:48:55 +11001361 [
Tim Rice648f8762011-01-26 12:38:57 -08001362 AC_DEFINE([GLOB_HAS_GL_MATCHC], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001363 [Define if your system glob() function has
1364 gl_matchc options in glob_t])
Tim Rice648f8762011-01-26 12:38:57 -08001365 AC_MSG_RESULT([yes])
1366 ], [
1367 AC_MSG_RESULT([no])
1368])
Ben Lindstrom45b14db2001-03-17 01:15:38 +00001369
Damien Millera6e121a2010-10-07 21:39:17 +11001370# Check for g.gl_statv glob() extension
Tim Rice648f8762011-01-26 12:38:57 -08001371AC_MSG_CHECKING([for gl_statv and GLOB_KEEPSTAT extensions for glob])
1372AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <glob.h> ]], [[
Damien Millera6e121a2010-10-07 21:39:17 +11001373#ifndef GLOB_KEEPSTAT
1374#error "glob does not support GLOB_KEEPSTAT extension"
1375#endif
1376glob_t g;
1377g.gl_statv = NULL;
Tim Rice648f8762011-01-26 12:38:57 -08001378]])],
Damien Millera6e121a2010-10-07 21:39:17 +11001379 [
Tim Rice648f8762011-01-26 12:38:57 -08001380 AC_DEFINE([GLOB_HAS_GL_STATV], [1],
Damien Millera6e121a2010-10-07 21:39:17 +11001381 [Define if your system glob() function has
1382 gl_statv options in glob_t])
Tim Rice648f8762011-01-26 12:38:57 -08001383 AC_MSG_RESULT([yes])
1384 ], [
1385 AC_MSG_RESULT([no])
Damien Miller72ef7c12015-01-15 02:21:31 +11001386
Tim Rice648f8762011-01-26 12:38:57 -08001387])
Damien Millera6e121a2010-10-07 21:39:17 +11001388
Tim Rice648f8762011-01-26 12:38:57 -08001389AC_CHECK_DECLS([GLOB_NOMATCH], , , [#include <glob.h>])
Darren Tucker096faec2006-09-01 20:29:10 +10001390
Darren Tucker7df91b02016-07-14 12:25:24 +10001391AC_CHECK_DECL([VIS_ALL], ,
1392 AC_DEFINE(BROKEN_STRNVIS, 1, [missing VIS_ALL]), [#include <vis.h>])
1393
Damien Miller18bb4732001-03-28 14:35:30 +10001394AC_MSG_CHECKING([whether struct dirent allocates space for d_name])
Darren Tuckera0c2b392004-09-11 23:26:37 +10001395AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001396 [AC_LANG_PROGRAM([[
Damien Miller18bb4732001-03-28 14:35:30 +10001397#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08001398#include <dirent.h>]],
1399 [[
1400 struct dirent d;
1401 exit(sizeof(d.d_name)<=sizeof(char));
Darren Tucker623d92f2004-09-12 22:36:15 +10001402 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001403 [AC_MSG_RESULT([yes])],
Damien Miller18bb4732001-03-28 14:35:30 +10001404 [
Tim Rice648f8762011-01-26 12:38:57 -08001405 AC_MSG_RESULT([no])
1406 AC_DEFINE([BROKEN_ONE_BYTE_DIRENT_D_NAME], [1],
Darren Tucker79d09fa2005-11-24 22:34:54 +11001407 [Define if your struct dirent expects you to
Tim Rice7df8d392005-09-19 09:33:39 -07001408 allocate extra space for d_name])
Darren Tuckera0c2b392004-09-11 23:26:37 +10001409 ],
Tim Riceeae17cc2005-03-17 16:52:20 -08001410 [
Darren Tuckera0c2b392004-09-11 23:26:37 +10001411 AC_MSG_WARN([cross compiling: assuming BROKEN_ONE_BYTE_DIRENT_D_NAME])
Tim Rice648f8762011-01-26 12:38:57 -08001412 AC_DEFINE([BROKEN_ONE_BYTE_DIRENT_D_NAME])
Damien Miller18bb4732001-03-28 14:35:30 +10001413 ]
1414)
1415
Damien Miller36f49652004-08-15 18:40:59 +10001416AC_MSG_CHECKING([for /proc/pid/fd directory])
1417if test -d "/proc/$$/fd" ; then
Tim Rice648f8762011-01-26 12:38:57 -08001418 AC_DEFINE([HAVE_PROC_PID], [1], [Define if you have /proc/$pid/fd])
1419 AC_MSG_RESULT([yes])
Damien Miller36f49652004-08-15 18:40:59 +10001420else
Tim Rice648f8762011-01-26 12:38:57 -08001421 AC_MSG_RESULT([no])
Damien Miller36f49652004-08-15 18:40:59 +10001422fi
1423
Damien Millerc547bf12001-02-16 10:18:12 +11001424# Check whether user wants S/Key support
Damien Millera8e06ce2003-11-21 23:48:55 +11001425SKEY_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08001426AC_ARG_WITH([skey],
Darren Tucker1b6f2292005-02-11 16:11:49 +11001427 [ --with-skey[[=PATH]] Enable S/Key support (optionally in PATH)],
Damien Millerc547bf12001-02-16 10:18:12 +11001428 [
1429 if test "x$withval" != "xno" ; then
1430
1431 if test "x$withval" != "xyes" ; then
1432 CPPFLAGS="$CPPFLAGS -I${withval}/include"
1433 LDFLAGS="$LDFLAGS -L${withval}/lib"
1434 fi
1435
Tim Rice648f8762011-01-26 12:38:57 -08001436 AC_DEFINE([SKEY], [1], [Define if you want S/Key support])
Damien Millerc547bf12001-02-16 10:18:12 +11001437 LIBS="-lskey $LIBS"
Damien Millera8e06ce2003-11-21 23:48:55 +11001438 SKEY_MSG="yes"
Tim Riceeae17cc2005-03-17 16:52:20 -08001439
Tim Rice4cec93f2002-02-26 08:40:48 -08001440 AC_MSG_CHECKING([for s/key support])
Darren Tucker314d89e2005-10-17 23:29:23 +10001441 AC_LINK_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001442 [AC_LANG_PROGRAM([[
Tim Rice4cec93f2002-02-26 08:40:48 -08001443#include <stdio.h>
1444#include <skey.h>
Tim Rice648f8762011-01-26 12:38:57 -08001445 ]], [[
1446 char *ff = skey_keyinfo(""); ff="";
1447 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10001448 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001449 [AC_MSG_RESULT([yes])],
Tim Rice4cec93f2002-02-26 08:40:48 -08001450 [
Tim Rice648f8762011-01-26 12:38:57 -08001451 AC_MSG_RESULT([no])
Damien Millerc547bf12001-02-16 10:18:12 +11001452 AC_MSG_ERROR([** Incomplete or missing s/key libraries.])
1453 ])
Tim Ricee1d93702016-05-31 11:13:22 -07001454 AC_MSG_CHECKING([if skeychallenge takes 4 arguments])
Tim Rice648f8762011-01-26 12:38:57 -08001455 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1456#include <stdio.h>
1457#include <skey.h>
1458 ]], [[
1459 (void)skeychallenge(NULL,"name","",0);
1460 ]])],
1461 [
1462 AC_MSG_RESULT([yes])
1463 AC_DEFINE([SKEYCHALLENGE_4ARG], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001464 [Define if your skeychallenge()
1465 function takes 4 arguments (NetBSD)])],
Tim Rice648f8762011-01-26 12:38:57 -08001466 [
1467 AC_MSG_RESULT([no])
1468 ])
Damien Millerc547bf12001-02-16 10:18:12 +11001469 fi
1470 ]
1471)
1472
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001473# Check whether user wants to use ldns
1474LDNS_MSG="no"
1475AC_ARG_WITH(ldns,
1476 [ --with-ldns[[=PATH]] Use ldns for DNSSEC support (optionally in PATH)],
Damien Miller523db852017-02-03 16:01:22 +11001477 [
1478 ldns=""
1479 if test "x$withval" = "xyes" ; then
1480 AC_PATH_TOOL([LDNSCONFIG], [ldns-config], [no])
1481 if test "x$PKGCONFIG" = "xno"; then
1482 CPPFLAGS="$CPPFLAGS -I${withval}/include"
1483 LDFLAGS="$LDFLAGS -L${withval}/lib"
1484 LIBS="-lldns $LIBS"
1485 ldns=yes
1486 else
1487 LIBS="$LIBS `$LDNSCONFIG --libs`"
1488 CPPFLAGS="$CPPFLAGS `$LDNSCONFIG --cflags`"
1489 fi
1490 elif test "x$withval" != "xno" ; then
1491 CPPFLAGS="$CPPFLAGS -I${withval}/include"
1492 LDFLAGS="$LDFLAGS -L${withval}/lib"
1493 LIBS="-lldns $LIBS"
1494 ldns=yes
1495 fi
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001496
Damien Miller523db852017-02-03 16:01:22 +11001497 # Verify that it works.
1498 if test "x$ldns" = "xyes" ; then
1499 AC_DEFINE(HAVE_LDNS, 1, [Define if you want ldns support])
1500 LDNS_MSG="yes"
1501 AC_MSG_CHECKING([for ldns support])
1502 AC_LINK_IFELSE(
1503 [AC_LANG_SOURCE([[
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001504#include <stdio.h>
1505#include <stdlib.h>
1506#include <stdint.h>
1507#include <ldns/ldns.h>
1508int main() { ldns_status status = ldns_verify_trusted(NULL, NULL, NULL, NULL); status=LDNS_STATUS_OK; exit(0); }
Damien Miller523db852017-02-03 16:01:22 +11001509 ]])
1510 ],
1511 [AC_MSG_RESULT(yes)],
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001512 [
1513 AC_MSG_RESULT(no)
1514 AC_MSG_ERROR([** Incomplete or missing ldns libraries.])
1515 ])
Damien Miller523db852017-02-03 16:01:22 +11001516 fi
1517])
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001518
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001519# Check whether user wants libedit support
1520LIBEDIT_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08001521AC_ARG_WITH([libedit],
Darren Tucker1b6f2292005-02-11 16:11:49 +11001522 [ --with-libedit[[=PATH]] Enable libedit support for sftp],
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001523 [ if test "x$withval" != "xno" ; then
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001524 if test "x$withval" = "xyes" ; then
Darren Tucker59353892012-05-19 15:24:37 +10001525 AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no])
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001526 if test "x$PKGCONFIG" != "xno"; then
Tim Rice648f8762011-01-26 12:38:57 -08001527 AC_MSG_CHECKING([if $PKGCONFIG knows about libedit])
Tim Ricee1d93702016-05-31 11:13:22 -07001528 if "$PKGCONFIG" libedit; then
Tim Rice648f8762011-01-26 12:38:57 -08001529 AC_MSG_RESULT([yes])
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001530 use_pkgconfig_for_libedit=yes
1531 else
Tim Rice648f8762011-01-26 12:38:57 -08001532 AC_MSG_RESULT([no])
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001533 fi
1534 fi
1535 else
Darren Tuckerc373a562005-09-22 20:15:08 +10001536 CPPFLAGS="$CPPFLAGS -I${withval}/include"
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
Darren Tucker1df61452005-03-21 09:58:07 +11001542 fi
Damien Miller1f789802010-10-11 22:35:22 +11001543 if test "x$use_pkgconfig_for_libedit" = "xyes"; then
Darren Tucker8369c8e2013-12-05 11:00:16 +11001544 LIBEDIT=`$PKGCONFIG --libs libedit`
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001545 CPPFLAGS="$CPPFLAGS `$PKGCONFIG --cflags libedit`"
1546 else
1547 LIBEDIT="-ledit -lcurses"
1548 fi
1549 OTHERLIBS=`echo $LIBEDIT | sed 's/-ledit//'`
Tim Rice648f8762011-01-26 12:38:57 -08001550 AC_CHECK_LIB([edit], [el_init],
1551 [ AC_DEFINE([USE_LIBEDIT], [1], [Use libedit for sftp])
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001552 LIBEDIT_MSG="yes"
Tim Rice648f8762011-01-26 12:38:57 -08001553 AC_SUBST([LIBEDIT])
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001554 ],
Tim Rice648f8762011-01-26 12:38:57 -08001555 [ AC_MSG_ERROR([libedit not found]) ],
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001556 [ $OTHERLIBS ]
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001557 )
Tim Rice648f8762011-01-26 12:38:57 -08001558 AC_MSG_CHECKING([if libedit version is compatible])
Tim Ricec1819c82005-08-15 17:48:40 -07001559 AC_COMPILE_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001560 [AC_LANG_PROGRAM([[ #include <histedit.h> ]],
1561 [[
Darren Tuckerc7572b22005-08-10 20:34:15 +10001562 int i = H_SETSIZE;
1563 el_init("", NULL, NULL, NULL);
1564 exit(0);
Tim Ricec1819c82005-08-15 17:48:40 -07001565 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001566 [ AC_MSG_RESULT([yes]) ],
1567 [ AC_MSG_RESULT([no])
1568 AC_MSG_ERROR([libedit version is not compatible]) ]
Darren Tuckerc7572b22005-08-10 20:34:15 +10001569 )
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001570 fi ]
1571)
1572
Darren Tuckerd9f88912005-02-20 21:01:48 +11001573AUDIT_MODULE=none
Tim Rice648f8762011-01-26 12:38:57 -08001574AC_ARG_WITH([audit],
Darren Tuckerea52a822011-01-17 21:15:27 +11001575 [ --with-audit=module Enable audit support (modules=debug,bsm,linux)],
Darren Tuckerd9f88912005-02-20 21:01:48 +11001576 [
Tim Rice648f8762011-01-26 12:38:57 -08001577 AC_MSG_CHECKING([for supported audit module])
Darren Tuckerd9f88912005-02-20 21:01:48 +11001578 case "$withval" in
1579 bsm)
Tim Rice648f8762011-01-26 12:38:57 -08001580 AC_MSG_RESULT([bsm])
Darren Tuckerd9f88912005-02-20 21:01:48 +11001581 AUDIT_MODULE=bsm
1582 dnl Checks for headers, libs and functions
Tim Rice648f8762011-01-26 12:38:57 -08001583 AC_CHECK_HEADERS([bsm/audit.h], [],
1584 [AC_MSG_ERROR([BSM enabled and bsm/audit.h not found])],
Darren Tucker6d0d6fb2006-09-09 01:05:21 +10001585 [
1586#ifdef HAVE_TIME_H
1587# include <time.h>
1588#endif
1589 ]
1590)
Tim Rice648f8762011-01-26 12:38:57 -08001591 AC_CHECK_LIB([bsm], [getaudit], [],
1592 [AC_MSG_ERROR([BSM enabled and required library not found])])
1593 AC_CHECK_FUNCS([getaudit], [],
1594 [AC_MSG_ERROR([BSM enabled and required function not found])])
Darren Tuckerd9f88912005-02-20 21:01:48 +11001595 # These are optional
Tim Rice648f8762011-01-26 12:38:57 -08001596 AC_CHECK_FUNCS([getaudit_addr aug_get_machine])
1597 AC_DEFINE([USE_BSM_AUDIT], [1], [Use BSM audit module])
Darren Tucker1fcec9d2013-12-19 11:00:12 +11001598 if test "$sol2ver" -ge 11; then
Tim Ricee1d93702016-05-31 11:13:22 -07001599 SSHDLIBS="$SSHDLIBS -lscf"
1600 AC_DEFINE([BROKEN_BSM_API], [1],
1601 [The system has incomplete BSM API])
Darren Tucker93a2d412012-02-24 10:40:41 +11001602 fi
Darren Tuckerd9f88912005-02-20 21:01:48 +11001603 ;;
Darren Tuckerea52a822011-01-17 21:15:27 +11001604 linux)
Tim Rice648f8762011-01-26 12:38:57 -08001605 AC_MSG_RESULT([linux])
Darren Tuckerea52a822011-01-17 21:15:27 +11001606 AUDIT_MODULE=linux
1607 dnl Checks for headers, libs and functions
Tim Rice648f8762011-01-26 12:38:57 -08001608 AC_CHECK_HEADERS([libaudit.h])
Darren Tuckerea52a822011-01-17 21:15:27 +11001609 SSHDLIBS="$SSHDLIBS -laudit"
Tim Rice648f8762011-01-26 12:38:57 -08001610 AC_DEFINE([USE_LINUX_AUDIT], [1], [Use Linux audit module])
Darren Tuckerea52a822011-01-17 21:15:27 +11001611 ;;
Darren Tuckerd9f88912005-02-20 21:01:48 +11001612 debug)
1613 AUDIT_MODULE=debug
Tim Rice648f8762011-01-26 12:38:57 -08001614 AC_MSG_RESULT([debug])
1615 AC_DEFINE([SSH_AUDIT_EVENTS], [1], [Use audit debugging module])
Darren Tuckerd9f88912005-02-20 21:01:48 +11001616 ;;
Tim Rice8bc6b902005-08-09 10:09:53 -07001617 no)
Tim Rice648f8762011-01-26 12:38:57 -08001618 AC_MSG_RESULT([no])
Tim Rice8bc6b902005-08-09 10:09:53 -07001619 ;;
Darren Tuckerd9f88912005-02-20 21:01:48 +11001620 *)
1621 AC_MSG_ERROR([Unknown audit module $withval])
1622 ;;
1623 esac ]
1624)
1625
Darren Tucker096118d2014-01-21 12:48:51 +11001626AC_ARG_WITH([pie],
Damien Miller76c04802015-01-13 19:38:18 +11001627 [ --with-pie Build Position Independent Executables if possible], [
Darren Tucker096118d2014-01-21 12:48:51 +11001628 if test "x$withval" = "xno"; then
Damien Miller852472a2014-01-22 16:31:18 +11001629 use_pie=no
Darren Tucker096118d2014-01-21 12:48:51 +11001630 fi
1631 if test "x$withval" = "xyes"; then
Damien Miller852472a2014-01-22 16:31:18 +11001632 use_pie=yes
Darren Tucker096118d2014-01-21 12:48:51 +11001633 fi
1634 ]
1635)
Damien Miller852472a2014-01-22 16:31:18 +11001636if test "x$use_pie" = "x"; then
1637 use_pie=no
1638fi
1639if test "x$use_toolchain_hardening" != "x1" && test "x$use_pie" = "xauto"; then
1640 # Turn off automatic PIE when toolchain hardening is off.
1641 use_pie=no
1642fi
Damien Millerc161fc92014-01-29 21:01:33 +11001643if test "x$use_pie" = "xauto"; then
Damien Miller852472a2014-01-22 16:31:18 +11001644 # Automatic PIE requires gcc >= 4.x
1645 AC_MSG_CHECKING([for gcc >= 4.x])
1646 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1647#if !defined(__GNUC__) || __GNUC__ < 4
1648#error gcc is too old
1649#endif
1650]])],
1651 [ AC_MSG_RESULT([yes]) ],
1652 [ AC_MSG_RESULT([no])
1653 use_pie=no ]
1654)
1655fi
1656if test "x$use_pie" != "xno"; then
Damien Miller5c2ff5e2014-01-22 21:30:12 +11001657 SAVED_CFLAGS="$CFLAGS"
1658 SAVED_LDFLAGS="$LDFLAGS"
Darren Tucker096118d2014-01-21 12:48:51 +11001659 OSSH_CHECK_CFLAG_COMPILE([-fPIE])
1660 OSSH_CHECK_LDFLAG_LINK([-pie])
Damien Miller5c2ff5e2014-01-22 21:30:12 +11001661 # We use both -fPIE and -pie or neither.
1662 AC_MSG_CHECKING([whether both -fPIE and -pie are supported])
1663 if echo "x $CFLAGS" | grep ' -fPIE' >/dev/null 2>&1 && \
1664 echo "x $LDFLAGS" | grep ' -pie' >/dev/null 2>&1 ; then
1665 AC_MSG_RESULT([yes])
1666 else
1667 AC_MSG_RESULT([no])
1668 CFLAGS="$SAVED_CFLAGS"
1669 LDFLAGS="$SAVED_LDFLAGS"
1670 fi
Darren Tucker096118d2014-01-21 12:48:51 +11001671fi
1672
Damien Millerfe1f1432003-02-24 15:45:42 +11001673dnl Checks for library functions. Please keep in alphabetical order
Tim Rice648f8762011-01-26 12:38:57 -08001674AC_CHECK_FUNCS([ \
Damien Miller1ff130d2013-12-07 11:51:51 +11001675 Blowfish_initstate \
1676 Blowfish_expandstate \
1677 Blowfish_expand0state \
1678 Blowfish_stream2word \
Damien Miller57f39152005-11-24 19:58:19 +11001679 asprintf \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001680 b64_ntop \
1681 __b64_ntop \
1682 b64_pton \
1683 __b64_pton \
1684 bcopy \
Damien Millera9134422013-12-07 11:35:36 +11001685 bcrypt_pbkdf \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001686 bindresvport_sa \
Damien Miller1ff130d2013-12-07 11:51:51 +11001687 blf_enc \
Damien Millerc96d8532014-01-25 13:12:28 +11001688 cap_rights_limit \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001689 clock \
1690 closefrom \
1691 dirfd \
Darren Tuckerefdf5342013-05-30 08:29:08 +10001692 endgrent \
Darren Tucker6310ef22016-07-13 14:42:35 +10001693 err \
1694 errx \
Damien Miller1d2c4562014-02-04 11:18:20 +11001695 explicit_bzero \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001696 fchmod \
1697 fchown \
1698 freeaddrinfo \
Darren Tuckera5cf1e22014-01-17 18:10:58 +11001699 fstatfs \
Darren Tucker598eaa62008-06-09 03:32:29 +10001700 fstatvfs \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001701 futimes \
1702 getaddrinfo \
1703 getcwd \
1704 getgrouplist \
1705 getnameinfo \
1706 getopt \
1707 getpeereid \
Darren Tucker164aa302007-03-21 21:39:57 +11001708 getpeerucred \
Darren Tucker3c4a24c2013-02-15 11:41:35 +11001709 getpgid \
1710 getpgrp \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001711 _getpty \
1712 getrlimit \
1713 getttyent \
1714 glob \
Darren Tucker909a3902010-01-15 12:38:30 +11001715 group_from_gid \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001716 inet_aton \
1717 inet_ntoa \
1718 inet_ntop \
1719 innetgr \
1720 login_getcapbool \
1721 md5_crypt \
1722 memmove \
Damien Miller3d673d12014-08-27 06:32:01 +10001723 memset_s \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001724 mkdtemp \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001725 ngetaddrinfo \
1726 nsleep \
1727 ogetaddrinfo \
1728 openlog_r \
Darren Tucker3ddd15e2015-11-30 07:23:53 +11001729 pledge \
Darren Tuckerfebf0f52007-06-25 22:15:12 +10001730 poll \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001731 prctl \
1732 pstat \
1733 readpassphrase \
Darren Tucker642652d2014-12-10 01:32:23 +11001734 reallocarray \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001735 recvmsg \
1736 rresvport_af \
1737 sendmsg \
1738 setdtablesize \
1739 setegid \
1740 setenv \
1741 seteuid \
Darren Tucker909a3902010-01-15 12:38:30 +11001742 setgroupent \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001743 setgroups \
Darren Tucker34f702a2012-07-04 08:50:09 +10001744 setlinebuf \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001745 setlogin \
Darren Tucker909a3902010-01-15 12:38:30 +11001746 setpassent\
Darren Tucker0c9653f2005-05-28 15:58:14 +10001747 setpcred \
1748 setproctitle \
1749 setregid \
1750 setreuid \
1751 setrlimit \
1752 setsid \
1753 setvbuf \
1754 sigaction \
1755 sigvec \
1756 snprintf \
1757 socketpair \
Darren Tucker5b2e2ba2008-06-08 09:25:28 +10001758 statfs \
1759 statvfs \
Darren Tuckerafec0772016-12-13 10:23:03 +11001760 strcasestr \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001761 strdup \
1762 strerror \
1763 strlcat \
1764 strlcpy \
1765 strmode \
Darren Tuckerb54f50e2011-09-29 23:17:18 +10001766 strnlen \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001767 strnvis \
Darren Tuckeraa74f672010-08-16 13:15:23 +10001768 strptime \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001769 strtonum \
Darren Tucker81eb5d52005-06-01 21:39:33 +10001770 strtoll \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001771 strtoul \
Darren Tucker8e6fb782013-02-15 12:13:01 +11001772 strtoull \
Damien Miller34a17692007-06-11 14:15:42 +10001773 swap32 \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001774 sysconf \
1775 tcgetpgrp \
Damien Milleraa180632010-10-07 21:25:27 +11001776 timingsafe_bcmp \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001777 truncate \
1778 unsetenv \
1779 updwtmpx \
Darren Tucker909a3902010-01-15 12:38:30 +11001780 user_from_uid \
Damien Millerf4db77d2013-03-15 10:34:25 +11001781 usleep \
Damien Miller57f39152005-11-24 19:58:19 +11001782 vasprintf \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001783 vsnprintf \
1784 waitpid \
Darren Tucker6310ef22016-07-13 14:42:35 +10001785 warn \
Tim Rice648f8762011-01-26 12:38:57 -08001786])
Tim Rice13aae5e2001-10-21 17:53:58 -07001787
Darren Tuckerc61d5ec2017-02-03 14:10:34 +11001788dnl Wide character support.
Darren Tuckera2333582016-07-14 10:59:09 +10001789AC_CHECK_FUNCS([mblen mbtowc nl_langinfo wcwidth])
Darren Tuckera2333582016-07-14 10:59:09 +10001790
Darren Tucker10e290e2016-12-13 13:51:32 +11001791TEST_SSH_UTF8=${TEST_SSH_UTF8:=yes}
Darren Tucker47b8c992016-12-08 15:48:34 +11001792AC_MSG_CHECKING([for utf8 locale support])
1793AC_RUN_IFELSE(
1794 [AC_LANG_PROGRAM([[
1795#include <locale.h>
Darren Tuckerc3599502016-12-09 12:52:02 +11001796#include <stdlib.h>
Darren Tucker47b8c992016-12-08 15:48:34 +11001797 ]], [[
1798 char *loc = setlocale(LC_CTYPE, "en_US.UTF-8");
1799 if (loc != NULL)
1800 exit(0);
1801 exit(1);
1802 ]])],
1803 AC_MSG_RESULT(yes),
1804 [AC_MSG_RESULT(no)
1805 TEST_SSH_UTF8=no],
1806 AC_MSG_WARN([cross compiling: assuming yes])
1807)
1808
Tim Ricec7a8af02010-11-08 14:26:23 -08001809AC_LINK_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001810 [AC_LANG_PROGRAM(
1811 [[ #include <ctype.h> ]],
1812 [[ return (isblank('a')); ]])],
1813 [AC_DEFINE([HAVE_ISBLANK], [1], [Define if you have isblank(3C).])
Tim Ricec7a8af02010-11-08 14:26:23 -08001814])
1815
Damien Miller5fbe93f2016-07-15 13:54:31 +10001816disable_pkcs11=
1817AC_ARG_ENABLE([pkcs11],
1818 [ --disable-pkcs11 disable PKCS#11 support code [no]],
1819 [
1820 if test "x$enableval" = "xno" ; then
1821 disable_pkcs11=1
1822 fi
1823 ]
1824)
1825
Damien Miller72ef7c12015-01-15 02:21:31 +11001826# PKCS11 depends on OpenSSL.
Damien Miller5fbe93f2016-07-15 13:54:31 +10001827if test "x$openssl" = "xyes" && test "x$disable_pkcs11" = "x"; then
Damien Miller72ef7c12015-01-15 02:21:31 +11001828 # PKCS#11 support requires dlopen() and co
1829 AC_SEARCH_LIBS([dlopen], [dl],
1830 [AC_DEFINE([ENABLE_PKCS11], [], [Enable for PKCS#11 support])]
1831 )
1832fi
Damien Millerb3c9f782010-02-12 10:11:34 +11001833
Darren Tuckerd5e082f2003-09-22 12:08:23 +10001834# IRIX has a const char return value for gai_strerror()
Tim Rice648f8762011-01-26 12:38:57 -08001835AC_CHECK_FUNCS([gai_strerror], [
1836 AC_DEFINE([HAVE_GAI_STRERROR])
1837 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckerd5e082f2003-09-22 12:08:23 +10001838#include <sys/types.h>
1839#include <sys/socket.h>
1840#include <netdb.h>
1841
Tim Rice648f8762011-01-26 12:38:57 -08001842const char *gai_strerror(int);
1843 ]], [[
1844 char *str;
1845 str = gai_strerror(0);
1846 ]])], [
1847 AC_DEFINE([HAVE_CONST_GAI_STRERROR_PROTO], [1],
1848 [Define if gai_strerror() returns const char *])], [])])
Darren Tuckerd5e082f2003-09-22 12:08:23 +10001849
Tim Rice648f8762011-01-26 12:38:57 -08001850AC_SEARCH_LIBS([nanosleep], [rt posix4], [AC_DEFINE([HAVE_NANOSLEEP], [1],
1851 [Some systems put nanosleep outside of libc])])
Damien Millercd6853c2003-01-28 11:33:42 +11001852
Darren Tuckera7108912013-06-02 08:18:31 +10001853AC_SEARCH_LIBS([clock_gettime], [rt],
1854 [AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Have clock_gettime])])
1855
Darren Tuckerf1159b52003-07-07 19:44:01 +10001856dnl Make sure prototypes are defined for these before using them.
Tim Rice648f8762011-01-26 12:38:57 -08001857AC_CHECK_DECL([getrusage], [AC_CHECK_FUNCS([getrusage])])
1858AC_CHECK_DECL([strsep],
1859 [AC_CHECK_FUNCS([strsep])],
Darren Tucker390b6d52005-05-28 16:54:36 +10001860 [],
1861 [
1862#ifdef HAVE_STRING_H
1863# include <string.h>
1864#endif
1865 ])
Ben Lindstrom3e006472002-10-16 00:24:03 +00001866
Darren Tuckerb2427c82003-09-10 15:22:44 +10001867dnl tcsendbreak might be a macro
Tim Rice648f8762011-01-26 12:38:57 -08001868AC_CHECK_DECL([tcsendbreak],
1869 [AC_DEFINE([HAVE_TCSENDBREAK])],
1870 [AC_CHECK_FUNCS([tcsendbreak])],
Darren Tuckerb2427c82003-09-10 15:22:44 +10001871 [#include <termios.h>]
1872)
1873
Tim Rice648f8762011-01-26 12:38:57 -08001874AC_CHECK_DECLS([h_errno], , ,[#include <netdb.h>])
Darren Tucker5bb14002004-04-23 18:53:10 +10001875
Tim Rice648f8762011-01-26 12:38:57 -08001876AC_CHECK_DECLS([SHUT_RD], , ,
Darren Tucker128a0892006-07-12 19:02:56 +10001877 [
1878#include <sys/types.h>
1879#include <sys/socket.h>
1880 ])
Darren Tucker248469b2006-07-12 14:14:31 +10001881
Tim Rice648f8762011-01-26 12:38:57 -08001882AC_CHECK_DECLS([O_NONBLOCK], , ,
Darren Tucker248469b2006-07-12 14:14:31 +10001883 [
1884#include <sys/types.h>
1885#ifdef HAVE_SYS_STAT_H
1886# include <sys/stat.h>
1887#endif
1888#ifdef HAVE_FCNTL_H
1889# include <fcntl.h>
1890#endif
1891 ])
1892
Tim Rice648f8762011-01-26 12:38:57 -08001893AC_CHECK_DECLS([writev], , , [
Darren Tuckered0b5922006-09-03 22:44:49 +10001894#include <sys/types.h>
1895#include <sys/uio.h>
1896#include <unistd.h>
1897 ])
1898
Tim Rice648f8762011-01-26 12:38:57 -08001899AC_CHECK_DECLS([MAXSYMLINKS], , , [
Darren Tucker6d862a52007-04-29 14:39:02 +10001900#include <sys/param.h>
1901 ])
1902
Tim Rice648f8762011-01-26 12:38:57 -08001903AC_CHECK_DECLS([offsetof], , , [
Darren Tuckerdca0edf2007-04-29 15:06:44 +10001904#include <stddef.h>
1905 ])
1906
Darren Tuckerc7aad002013-06-02 07:18:47 +10001907# extra bits for select(2)
1908AC_CHECK_DECLS([howmany, NFDBITS], [], [], [[
1909#include <sys/param.h>
1910#include <sys/types.h>
1911#ifdef HAVE_SYS_SYSMACROS_H
1912#include <sys/sysmacros.h>
1913#endif
1914#ifdef HAVE_SYS_SELECT_H
1915#include <sys/select.h>
1916#endif
1917#ifdef HAVE_SYS_TIME_H
1918#include <sys/time.h>
1919#endif
1920#ifdef HAVE_UNISTD_H
1921#include <unistd.h>
1922#endif
1923 ]])
1924AC_CHECK_TYPES([fd_mask], [], [], [[
1925#include <sys/param.h>
1926#include <sys/types.h>
1927#ifdef HAVE_SYS_SELECT_H
1928#include <sys/select.h>
1929#endif
1930#ifdef HAVE_SYS_TIME_H
1931#include <sys/time.h>
1932#endif
1933#ifdef HAVE_UNISTD_H
1934#include <unistd.h>
1935#endif
1936 ]])
1937
Tim Rice648f8762011-01-26 12:38:57 -08001938AC_CHECK_FUNCS([setresuid], [
Darren Tucker2a6b0292003-12-31 14:59:17 +11001939 dnl Some platorms have setresuid that isn't implemented, test for this
Tim Rice648f8762011-01-26 12:38:57 -08001940 AC_MSG_CHECKING([if setresuid seems to work])
Darren Tucker623d92f2004-09-12 22:36:15 +10001941 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001942 [AC_LANG_PROGRAM([[
Darren Tuckere937be32003-12-17 18:53:26 +11001943#include <stdlib.h>
1944#include <errno.h>
Tim Rice648f8762011-01-26 12:38:57 -08001945 ]], [[
1946 errno=0;
1947 setresuid(0,0,0);
1948 if (errno==ENOSYS)
1949 exit(1);
1950 else
1951 exit(0);
Darren Tucker623d92f2004-09-12 22:36:15 +10001952 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001953 [AC_MSG_RESULT([yes])],
1954 [AC_DEFINE([BROKEN_SETRESUID], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001955 [Define if your setresuid() is broken])
Tim Rice648f8762011-01-26 12:38:57 -08001956 AC_MSG_RESULT([not implemented])],
Darren Tuckera0c2b392004-09-11 23:26:37 +10001957 [AC_MSG_WARN([cross compiling: not checking setresuid])]
Darren Tucker2a6b0292003-12-31 14:59:17 +11001958 )
1959])
Darren Tuckere937be32003-12-17 18:53:26 +11001960
Tim Rice648f8762011-01-26 12:38:57 -08001961AC_CHECK_FUNCS([setresgid], [
Darren Tucker2a6b0292003-12-31 14:59:17 +11001962 dnl Some platorms have setresgid that isn't implemented, test for this
Tim Rice648f8762011-01-26 12:38:57 -08001963 AC_MSG_CHECKING([if setresgid seems to work])
Darren Tucker623d92f2004-09-12 22:36:15 +10001964 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001965 [AC_LANG_PROGRAM([[
Darren Tuckere937be32003-12-17 18:53:26 +11001966#include <stdlib.h>
1967#include <errno.h>
Tim Rice648f8762011-01-26 12:38:57 -08001968 ]], [[
1969 errno=0;
1970 setresgid(0,0,0);
1971 if (errno==ENOSYS)
1972 exit(1);
1973 else
1974 exit(0);
Darren Tucker623d92f2004-09-12 22:36:15 +10001975 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001976 [AC_MSG_RESULT([yes])],
1977 [AC_DEFINE([BROKEN_SETRESGID], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001978 [Define if your setresgid() is broken])
Tim Rice648f8762011-01-26 12:38:57 -08001979 AC_MSG_RESULT([not implemented])],
Darren Tuckera0c2b392004-09-11 23:26:37 +10001980 [AC_MSG_WARN([cross compiling: not checking setresuid])]
Darren Tucker2a6b0292003-12-31 14:59:17 +11001981 )
1982])
Darren Tuckere937be32003-12-17 18:53:26 +11001983
Darren Tuckerd3e2aee2015-07-17 12:52:34 +10001984AC_CHECK_FUNCS([realpath], [
1985 dnl the sftp v3 spec says SSH_FXP_REALPATH will "canonicalize any given
1986 dnl path name", however some implementations of realpath (and some
1987 dnl versions of the POSIX spec) do not work on non-existent files,
1988 dnl so we use the OpenBSD implementation on those platforms.
1989 AC_MSG_CHECKING([if realpath works with non-existent files])
1990 AC_RUN_IFELSE(
1991 [AC_LANG_PROGRAM([[
1992#include <limits.h>
1993#include <stdlib.h>
1994#include <errno.h>
1995 ]], [[
1996 char buf[PATH_MAX];
1997 if (realpath("/opensshnonexistentfilename1234", buf) == NULL)
1998 if (errno == ENOENT)
1999 exit(1);
2000 exit(0);
2001 ]])],
2002 [AC_MSG_RESULT([yes])],
2003 [AC_DEFINE([BROKEN_REALPATH], [1],
2004 [realpath does not work with nonexistent files])
2005 AC_MSG_RESULT([no])],
2006 [AC_MSG_WARN([cross compiling: assuming working])]
2007 )
2008])
2009
Damien Millerad833b32000-08-23 10:46:23 +10002010dnl Checks for time functions
Tim Rice648f8762011-01-26 12:38:57 -08002011AC_CHECK_FUNCS([gettimeofday time])
Damien Millerad833b32000-08-23 10:46:23 +10002012dnl Checks for utmp functions
Tim Rice648f8762011-01-26 12:38:57 -08002013AC_CHECK_FUNCS([endutent getutent getutid getutline pututline setutent])
2014AC_CHECK_FUNCS([utmpname])
Damien Millerad833b32000-08-23 10:46:23 +10002015dnl Checks for utmpx functions
Tim Rice648f8762011-01-26 12:38:57 -08002016AC_CHECK_FUNCS([endutxent getutxent getutxid getutxline getutxuser pututxline])
2017AC_CHECK_FUNCS([setutxdb setutxent utmpxname])
Damien Miller20e231f2009-02-12 13:12:21 +11002018dnl Checks for lastlog functions
Tim Rice648f8762011-01-26 12:38:57 -08002019AC_CHECK_FUNCS([getlastlogxbyname])
Damien Millercedfecc1999-11-15 14:36:53 +11002020
Tim Rice648f8762011-01-26 12:38:57 -08002021AC_CHECK_FUNC([daemon],
2022 [AC_DEFINE([HAVE_DAEMON], [1], [Define if your libraries define daemon()])],
2023 [AC_CHECK_LIB([bsd], [daemon],
2024 [LIBS="$LIBS -lbsd"; AC_DEFINE([HAVE_DAEMON])])]
Damien Miller04f80141999-11-19 15:32:34 +11002025)
2026
Tim Rice648f8762011-01-26 12:38:57 -08002027AC_CHECK_FUNC([getpagesize],
2028 [AC_DEFINE([HAVE_GETPAGESIZE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07002029 [Define if your libraries define getpagesize()])],
Tim Rice648f8762011-01-26 12:38:57 -08002030 [AC_CHECK_LIB([ucb], [getpagesize],
2031 [LIBS="$LIBS -lucb"; AC_DEFINE([HAVE_GETPAGESIZE])])]
Damien Miller9fb07e42000-03-05 16:22:59 +11002032)
2033
Damien Millercb170cb2000-07-01 16:52:55 +10002034# Check for broken snprintf
2035if test "x$ac_cv_func_snprintf" = "xyes" ; then
2036 AC_MSG_CHECKING([whether snprintf correctly terminates long strings])
Darren Tuckera0c2b392004-09-11 23:26:37 +10002037 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002038 [AC_LANG_PROGRAM([[ #include <stdio.h> ]],
2039 [[
2040 char b[5];
2041 snprintf(b,5,"123456789");
Tim Ricee1d93702016-05-31 11:13:22 -07002042 exit(b[4]!='\0');
Darren Tucker623d92f2004-09-12 22:36:15 +10002043 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08002044 [AC_MSG_RESULT([yes])],
Damien Millercb170cb2000-07-01 16:52:55 +10002045 [
Tim Rice648f8762011-01-26 12:38:57 -08002046 AC_MSG_RESULT([no])
2047 AC_DEFINE([BROKEN_SNPRINTF], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07002048 [Define if your snprintf is busted])
Damien Millercb170cb2000-07-01 16:52:55 +10002049 AC_MSG_WARN([****** Your snprintf() function is broken, complain to your vendor])
Darren Tuckera0c2b392004-09-11 23:26:37 +10002050 ],
2051 [ AC_MSG_WARN([cross compiling: Assuming working snprintf()]) ]
Damien Millercb170cb2000-07-01 16:52:55 +10002052 )
2053fi
2054
Damien Millerd244a582014-08-23 17:06:49 +10002055# We depend on vsnprintf returning the right thing on overflow: the
2056# number of characters it tried to create (as per SUSv3)
2057if test "x$ac_cv_func_vsnprintf" = "xyes" ; then
Damien Miller57f39152005-11-24 19:58:19 +11002058 AC_MSG_CHECKING([whether vsnprintf returns correct values on overflow])
2059 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002060 [AC_LANG_PROGRAM([[
Damien Miller57f39152005-11-24 19:58:19 +11002061#include <sys/types.h>
2062#include <stdio.h>
2063#include <stdarg.h>
2064
Damien Millerd244a582014-08-23 17:06:49 +10002065int x_snprintf(char *str, size_t count, const char *fmt, ...)
Damien Miller57f39152005-11-24 19:58:19 +11002066{
Damien Millerd244a582014-08-23 17:06:49 +10002067 size_t ret;
2068 va_list ap;
2069
2070 va_start(ap, fmt);
2071 ret = vsnprintf(str, count, fmt, ap);
2072 va_end(ap);
Damien Miller57f39152005-11-24 19:58:19 +11002073 return ret;
2074}
Tim Rice648f8762011-01-26 12:38:57 -08002075 ]], [[
Damien Millerd244a582014-08-23 17:06:49 +10002076char x[1];
2077if (x_snprintf(x, 1, "%s %d", "hello", 12345) != 11)
2078 return 1;
2079if (x_snprintf(NULL, 0, "%s %d", "hello", 12345) != 11)
2080 return 1;
2081return 0;
Tim Rice648f8762011-01-26 12:38:57 -08002082 ]])],
2083 [AC_MSG_RESULT([yes])],
Damien Miller57f39152005-11-24 19:58:19 +11002084 [
Tim Rice648f8762011-01-26 12:38:57 -08002085 AC_MSG_RESULT([no])
2086 AC_DEFINE([BROKEN_SNPRINTF], [1],
Damien Miller57f39152005-11-24 19:58:19 +11002087 [Define if your snprintf is busted])
2088 AC_MSG_WARN([****** Your vsnprintf() function is broken, complain to your vendor])
2089 ],
2090 [ AC_MSG_WARN([cross compiling: Assuming working vsnprintf()]) ]
2091 )
2092fi
2093
Darren Tuckerd40c66c2005-12-17 22:32:03 +11002094# On systems where [v]snprintf is broken, but is declared in stdio,
2095# check that the fmt argument is const char * or just char *.
2096# This is only useful for when BROKEN_SNPRINTF
2097AC_MSG_CHECKING([whether snprintf can declare const char *fmt])
Tim Rice648f8762011-01-26 12:38:57 -08002098AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2099#include <stdio.h>
2100int snprintf(char *a, size_t b, const char *c, ...) { return 0; }
2101 ]], [[
2102 snprintf(0, 0, 0);
2103 ]])],
2104 [AC_MSG_RESULT([yes])
2105 AC_DEFINE([SNPRINTF_CONST], [const],
Darren Tuckerd40c66c2005-12-17 22:32:03 +11002106 [Define as const if snprintf() can declare const char *fmt])],
Tim Rice648f8762011-01-26 12:38:57 -08002107 [AC_MSG_RESULT([no])
2108 AC_DEFINE([SNPRINTF_CONST], [/* not const */])])
Darren Tuckerd40c66c2005-12-17 22:32:03 +11002109
Damien Millerb4097182004-05-23 14:09:40 +10002110# Check for missing getpeereid (or equiv) support
2111NO_PEERCHECK=""
Darren Tucker164aa302007-03-21 21:39:57 +11002112if test "x$ac_cv_func_getpeereid" != "xyes" -a "x$ac_cv_func_getpeerucred" != "xyes"; then
Damien Millerb4097182004-05-23 14:09:40 +10002113 AC_MSG_CHECKING([whether system supports SO_PEERCRED getsockopt])
Tim Rice648f8762011-01-26 12:38:57 -08002114 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2115#include <sys/types.h>
2116#include <sys/socket.h>]], [[int i = SO_PEERCRED;]])],
2117 [ AC_MSG_RESULT([yes])
2118 AC_DEFINE([HAVE_SO_PEERCRED], [1], [Have PEERCRED socket option])
2119 ], [AC_MSG_RESULT([no])
2120 NO_PEERCHECK=1
2121 ])
Damien Millerb4097182004-05-23 14:09:40 +10002122fi
2123
Damien Millere8328192003-01-07 15:18:32 +11002124dnl see whether mkstemp() requires XXXXXX
2125if test "x$ac_cv_func_mkdtemp" = "xyes" ; then
2126AC_MSG_CHECKING([for (overly) strict mkstemp])
Darren Tucker314d89e2005-10-17 23:29:23 +10002127AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002128 [AC_LANG_PROGRAM([[
Damien Millere8328192003-01-07 15:18:32 +11002129#include <stdlib.h>
Tim Rice648f8762011-01-26 12:38:57 -08002130 ]], [[
2131 char template[]="conftest.mkstemp-test";
2132 if (mkstemp(template) == -1)
2133 exit(1);
2134 unlink(template);
2135 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10002136 ]])],
Damien Millere8328192003-01-07 15:18:32 +11002137 [
Tim Rice648f8762011-01-26 12:38:57 -08002138 AC_MSG_RESULT([no])
Damien Millere8328192003-01-07 15:18:32 +11002139 ],
Damien Millera8e06ce2003-11-21 23:48:55 +11002140 [
Tim Rice648f8762011-01-26 12:38:57 -08002141 AC_MSG_RESULT([yes])
2142 AC_DEFINE([HAVE_STRICT_MKSTEMP], [1], [Silly mkstemp()])
Damien Millere8328192003-01-07 15:18:32 +11002143 ],
2144 [
Tim Rice648f8762011-01-26 12:38:57 -08002145 AC_MSG_RESULT([yes])
2146 AC_DEFINE([HAVE_STRICT_MKSTEMP])
Damien Millera8e06ce2003-11-21 23:48:55 +11002147 ]
Damien Millere8328192003-01-07 15:18:32 +11002148)
2149fi
2150
Darren Tucker70a3d552003-08-21 17:58:29 +10002151dnl make sure that openpty does not reacquire controlling terminal
2152if test ! -z "$check_for_openpty_ctty_bug"; then
Tim Rice648f8762011-01-26 12:38:57 -08002153 AC_MSG_CHECKING([if openpty correctly handles controlling tty])
Darren Tucker314d89e2005-10-17 23:29:23 +10002154 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002155 [AC_LANG_PROGRAM([[
Darren Tucker70a3d552003-08-21 17:58:29 +10002156#include <stdio.h>
2157#include <sys/fcntl.h>
2158#include <sys/types.h>
2159#include <sys/wait.h>
Tim Rice648f8762011-01-26 12:38:57 -08002160 ]], [[
Darren Tucker70a3d552003-08-21 17:58:29 +10002161 pid_t pid;
2162 int fd, ptyfd, ttyfd, status;
2163
2164 pid = fork();
2165 if (pid < 0) { /* failed */
2166 exit(1);
2167 } else if (pid > 0) { /* parent */
2168 waitpid(pid, &status, 0);
Damien Millera8e06ce2003-11-21 23:48:55 +11002169 if (WIFEXITED(status))
Darren Tucker70a3d552003-08-21 17:58:29 +10002170 exit(WEXITSTATUS(status));
2171 else
2172 exit(2);
2173 } else { /* child */
2174 close(0); close(1); close(2);
2175 setsid();
2176 openpty(&ptyfd, &ttyfd, NULL, NULL, NULL);
2177 fd = open("/dev/tty", O_RDWR | O_NOCTTY);
2178 if (fd >= 0)
2179 exit(3); /* Acquired ctty: broken */
2180 else
2181 exit(0); /* Did not acquire ctty: OK */
2182 }
Darren Tucker314d89e2005-10-17 23:29:23 +10002183 ]])],
Darren Tucker70a3d552003-08-21 17:58:29 +10002184 [
Tim Rice648f8762011-01-26 12:38:57 -08002185 AC_MSG_RESULT([yes])
Darren Tucker70a3d552003-08-21 17:58:29 +10002186 ],
2187 [
Tim Rice648f8762011-01-26 12:38:57 -08002188 AC_MSG_RESULT([no])
2189 AC_DEFINE([SSHD_ACQUIRES_CTTY])
Darren Tucker314d89e2005-10-17 23:29:23 +10002190 ],
2191 [
Tim Rice648f8762011-01-26 12:38:57 -08002192 AC_MSG_RESULT([cross-compiling, assuming yes])
Darren Tucker70a3d552003-08-21 17:58:29 +10002193 ]
2194 )
2195fi
2196
Tim Rice8bb561b2005-03-17 16:23:19 -08002197if test "x$ac_cv_func_getaddrinfo" = "xyes" && \
2198 test "x$check_for_hpux_broken_getaddrinfo" = "x1"; then
Tim Rice648f8762011-01-26 12:38:57 -08002199 AC_MSG_CHECKING([if getaddrinfo seems to work])
Darren Tucker314d89e2005-10-17 23:29:23 +10002200 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002201 [AC_LANG_PROGRAM([[
Darren Tucker4398cf52004-04-06 21:39:02 +10002202#include <stdio.h>
2203#include <sys/socket.h>
2204#include <netdb.h>
2205#include <errno.h>
2206#include <netinet/in.h>
2207
2208#define TEST_PORT "2222"
Tim Rice648f8762011-01-26 12:38:57 -08002209 ]], [[
Darren Tucker4398cf52004-04-06 21:39:02 +10002210 int err, sock;
2211 struct addrinfo *gai_ai, *ai, hints;
2212 char ntop[NI_MAXHOST], strport[NI_MAXSERV], *name = NULL;
2213
2214 memset(&hints, 0, sizeof(hints));
2215 hints.ai_family = PF_UNSPEC;
2216 hints.ai_socktype = SOCK_STREAM;
2217 hints.ai_flags = AI_PASSIVE;
2218
2219 err = getaddrinfo(name, TEST_PORT, &hints, &gai_ai);
2220 if (err != 0) {
2221 fprintf(stderr, "getaddrinfo failed (%s)", gai_strerror(err));
2222 exit(1);
2223 }
2224
2225 for (ai = gai_ai; ai != NULL; ai = ai->ai_next) {
2226 if (ai->ai_family != AF_INET6)
2227 continue;
2228
2229 err = getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop,
2230 sizeof(ntop), strport, sizeof(strport),
2231 NI_NUMERICHOST|NI_NUMERICSERV);
2232
2233 if (err != 0) {
2234 if (err == EAI_SYSTEM)
2235 perror("getnameinfo EAI_SYSTEM");
2236 else
2237 fprintf(stderr, "getnameinfo failed: %s\n",
2238 gai_strerror(err));
2239 exit(2);
2240 }
2241
2242 sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
2243 if (sock < 0)
2244 perror("socket");
2245 if (bind(sock, ai->ai_addr, ai->ai_addrlen) < 0) {
2246 if (errno == EBADF)
2247 exit(3);
2248 }
2249 }
2250 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10002251 ]])],
Darren Tucker4398cf52004-04-06 21:39:02 +10002252 [
Tim Rice648f8762011-01-26 12:38:57 -08002253 AC_MSG_RESULT([yes])
Darren Tucker4398cf52004-04-06 21:39:02 +10002254 ],
2255 [
Tim Rice648f8762011-01-26 12:38:57 -08002256 AC_MSG_RESULT([no])
2257 AC_DEFINE([BROKEN_GETADDRINFO])
Darren Tucker314d89e2005-10-17 23:29:23 +10002258 ],
2259 [
Tim Rice648f8762011-01-26 12:38:57 -08002260 AC_MSG_RESULT([cross-compiling, assuming yes])
Darren Tucker4398cf52004-04-06 21:39:02 +10002261 ]
2262 )
2263fi
2264
Tim Rice8bb561b2005-03-17 16:23:19 -08002265if test "x$ac_cv_func_getaddrinfo" = "xyes" && \
2266 test "x$check_for_aix_broken_getaddrinfo" = "x1"; then
Tim Rice648f8762011-01-26 12:38:57 -08002267 AC_MSG_CHECKING([if getaddrinfo seems to work])
Darren Tucker314d89e2005-10-17 23:29:23 +10002268 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002269 [AC_LANG_PROGRAM([[
Darren Tucker691d5232005-02-15 21:45:57 +11002270#include <stdio.h>
2271#include <sys/socket.h>
2272#include <netdb.h>
2273#include <errno.h>
2274#include <netinet/in.h>
2275
2276#define TEST_PORT "2222"
Tim Rice648f8762011-01-26 12:38:57 -08002277 ]], [[
Darren Tucker691d5232005-02-15 21:45:57 +11002278 int err, sock;
2279 struct addrinfo *gai_ai, *ai, hints;
2280 char ntop[NI_MAXHOST], strport[NI_MAXSERV], *name = NULL;
2281
2282 memset(&hints, 0, sizeof(hints));
2283 hints.ai_family = PF_UNSPEC;
2284 hints.ai_socktype = SOCK_STREAM;
2285 hints.ai_flags = AI_PASSIVE;
2286
2287 err = getaddrinfo(name, TEST_PORT, &hints, &gai_ai);
2288 if (err != 0) {
2289 fprintf(stderr, "getaddrinfo failed (%s)", gai_strerror(err));
2290 exit(1);
2291 }
2292
2293 for (ai = gai_ai; ai != NULL; ai = ai->ai_next) {
2294 if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6)
2295 continue;
2296
2297 err = getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop,
2298 sizeof(ntop), strport, sizeof(strport),
2299 NI_NUMERICHOST|NI_NUMERICSERV);
2300
2301 if (ai->ai_family == AF_INET && err != 0) {
2302 perror("getnameinfo");
2303 exit(2);
2304 }
2305 }
2306 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10002307 ]])],
Darren Tucker691d5232005-02-15 21:45:57 +11002308 [
Tim Rice648f8762011-01-26 12:38:57 -08002309 AC_MSG_RESULT([yes])
2310 AC_DEFINE([AIX_GETNAMEINFO_HACK], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07002311 [Define if you have a getaddrinfo that fails
2312 for the all-zeros IPv6 address])
Darren Tucker691d5232005-02-15 21:45:57 +11002313 ],
2314 [
Tim Rice648f8762011-01-26 12:38:57 -08002315 AC_MSG_RESULT([no])
2316 AC_DEFINE([BROKEN_GETADDRINFO])
Darren Tucker314d89e2005-10-17 23:29:23 +10002317 ],
Darren Tucker8b272ab2006-06-27 11:20:28 +10002318 [
Tim Rice648f8762011-01-26 12:38:57 -08002319 AC_MSG_RESULT([cross-compiling, assuming no])
Darren Tucker691d5232005-02-15 21:45:57 +11002320 ]
2321 )
2322fi
2323
Darren Tuckere50e8c92015-02-21 15:10:33 +11002324if test "x$ac_cv_func_getaddrinfo" = "xyes"; then
2325 AC_CHECK_DECLS(AI_NUMERICSERV, , ,
2326 [#include <sys/types.h>
2327 #include <sys/socket.h>
2328 #include <netdb.h>])
2329fi
2330
Darren Tuckera56f1912004-11-02 20:30:54 +11002331if test "x$check_for_conflicting_getspnam" = "x1"; then
Tim Rice648f8762011-01-26 12:38:57 -08002332 AC_MSG_CHECKING([for conflicting getspnam in shadow.h])
2333 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <shadow.h> ]],
2334 [[ exit(0); ]])],
Darren Tuckera56f1912004-11-02 20:30:54 +11002335 [
Tim Rice648f8762011-01-26 12:38:57 -08002336 AC_MSG_RESULT([no])
Darren Tuckera56f1912004-11-02 20:30:54 +11002337 ],
2338 [
Tim Rice648f8762011-01-26 12:38:57 -08002339 AC_MSG_RESULT([yes])
2340 AC_DEFINE([GETSPNAM_CONFLICTING_DEFS], [1],
Darren Tuckera56f1912004-11-02 20:30:54 +11002341 [Conflicting defs for getspnam])
2342 ]
2343 )
2344fi
2345
Darren Tucker20e5e8b2016-08-02 12:16:34 +10002346dnl NetBSD added an strnvis and unfortunately made it incompatible with the
2347dnl existing one in OpenBSD and Linux's libbsd (the former having existed
2348dnl for over ten years). Despite this incompatibility being reported during
2349dnl development (see http://gnats.netbsd.org/44977) they still shipped it.
2350dnl Even more unfortunately FreeBSD and later MacOS picked up this incompatible
2351dnl implementation. Try to detect this mess, and assume the only safe option
2352dnl if we're cross compiling.
2353dnl
2354dnl OpenBSD, 2001: strnvis(char *dst, const char *src, size_t dlen, int flag);
2355dnl NetBSD: 2012, strnvis(char *dst, size_t dlen, const char *src, int flag);
2356if test "x$ac_cv_func_strnvis" = "xyes"; then
2357 AC_MSG_CHECKING([for working strnvis])
2358 AC_RUN_IFELSE(
2359 [AC_LANG_PROGRAM([[
2360#include <signal.h>
2361#include <stdlib.h>
2362#include <string.h>
2363#include <vis.h>
2364static void sighandler(int sig) { _exit(1); }
2365 ]], [[
2366 char dst[16];
2367
2368 signal(SIGSEGV, sighandler);
2369 if (strnvis(dst, "src", 4, 0) && strcmp(dst, "src") == 0)
2370 exit(0);
2371 exit(1)
2372 ]])],
2373 [AC_MSG_RESULT([yes])],
2374 [AC_MSG_RESULT([no])
2375 AC_DEFINE([BROKEN_STRNVIS], [1], [strnvis detected broken])],
2376 [AC_MSG_WARN([cross compiling: assuming broken])
2377 AC_DEFINE([BROKEN_STRNVIS], [1], [strnvis assumed broken])]
2378 )
2379fi
2380
Damien Miller606f8802000-09-16 15:39:56 +11002381AC_FUNC_GETPGRP
2382
Tim Riceaef73712002-05-11 13:17:42 -07002383# Search for OpenSSL
2384saved_CPPFLAGS="$CPPFLAGS"
2385saved_LDFLAGS="$LDFLAGS"
Tim Rice648f8762011-01-26 12:38:57 -08002386AC_ARG_WITH([ssl-dir],
Damien Millera22ba012000-03-02 23:09:20 +11002387 [ --with-ssl-dir=PATH Specify path to OpenSSL installation ],
2388 [
Damien Miller72ef7c12015-01-15 02:21:31 +11002389 if test "x$openssl" = "xno" ; then
2390 AC_MSG_ERROR([cannot use --with-ssl-dir when OpenSSL disabled])
2391 fi
Ben Lindstrom23e13712000-10-29 22:49:19 +00002392 if test "x$withval" != "xno" ; then
Darren Tuckerc7e38d52005-02-09 22:12:30 +11002393 case "$withval" in
2394 # Relative paths
2395 ./*|../*) withval="`pwd`/$withval"
2396 esac
Tim Riceaef73712002-05-11 13:17:42 -07002397 if test -d "$withval/lib"; then
2398 if test -n "${need_dash_r}"; then
2399 LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
2400 else
2401 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
2402 fi
Darren Tucker9f8703b2010-04-23 11:12:06 +10002403 elif test -d "$withval/lib64"; then
2404 if test -n "${need_dash_r}"; then
2405 LDFLAGS="-L${withval}/lib64 -R${withval}/lib64 ${LDFLAGS}"
2406 else
2407 LDFLAGS="-L${withval}/lib64 ${LDFLAGS}"
2408 fi
Tim Riceaef73712002-05-11 13:17:42 -07002409 else
2410 if test -n "${need_dash_r}"; then
2411 LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
2412 else
2413 LDFLAGS="-L${withval} ${LDFLAGS}"
2414 fi
2415 fi
2416 if test -d "$withval/include"; then
2417 CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
2418 else
2419 CPPFLAGS="-I${withval} ${CPPFLAGS}"
2420 fi
Damien Millera22ba012000-03-02 23:09:20 +11002421 fi
2422 ]
2423)
Damien Millerb9c56672014-05-15 14:43:37 +10002424
Tim Rice648f8762011-01-26 12:38:57 -08002425AC_ARG_WITH([openssl-header-check],
Damien Miller9975e482007-03-05 11:51:27 +11002426 [ --without-openssl-header-check Disable OpenSSL version consistency check],
Damien Millerec932372002-01-22 22:16:03 +11002427 [
Damien Miller72ef7c12015-01-15 02:21:31 +11002428 if test "x$withval" = "xno" ; then
2429 openssl_check_nonfatal=1
Damien Miller9975e482007-03-05 11:51:27 +11002430 fi
Damien Millerec932372002-01-22 22:16:03 +11002431 ]
2432)
2433
Damien Miller72ef7c12015-01-15 02:21:31 +11002434openssl_engine=no
Tim Rice648f8762011-01-26 12:38:57 -08002435AC_ARG_WITH([ssl-engine],
Darren Tuckerfabdb6c2006-02-20 20:17:35 +11002436 [ --with-ssl-engine Enable OpenSSL (hardware) ENGINE support ],
Damien Miller72ef7c12015-01-15 02:21:31 +11002437 [
Damien Miller72ef7c12015-01-15 02:21:31 +11002438 if test "x$withval" != "xno" ; then
Darren Tuckerb5fa0cd2015-12-15 15:10:32 +11002439 if test "x$openssl" = "xno" ; then
2440 AC_MSG_ERROR([cannot use --with-ssl-engine when OpenSSL disabled])
2441 fi
Damien Miller72ef7c12015-01-15 02:21:31 +11002442 openssl_engine=yes
2443 fi
2444 ]
2445)
2446
2447if test "x$openssl" = "xyes" ; then
2448 LIBS="-lcrypto $LIBS"
2449 AC_TRY_LINK_FUNC([RAND_add], [AC_DEFINE([HAVE_OPENSSL], [1],
2450 [Define if your ssl headers are included
2451 with #include <openssl/header.h>])],
2452 [
2453 dnl Check default openssl install dir
2454 if test -n "${need_dash_r}"; then
2455 LDFLAGS="-L/usr/local/ssl/lib -R/usr/local/ssl/lib ${saved_LDFLAGS}"
2456 else
2457 LDFLAGS="-L/usr/local/ssl/lib ${saved_LDFLAGS}"
2458 fi
2459 CPPFLAGS="-I/usr/local/ssl/include ${saved_CPPFLAGS}"
2460 AC_CHECK_HEADER([openssl/opensslv.h], ,
2461 [AC_MSG_ERROR([*** OpenSSL headers missing - please install first or check config.log ***])])
2462 AC_TRY_LINK_FUNC([RAND_add], [AC_DEFINE([HAVE_OPENSSL])],
2463 [
2464 AC_MSG_ERROR([*** Can't find recent OpenSSL libcrypto (see config.log for details) ***])
2465 ]
2466 )
2467 ]
2468 )
2469
2470 # Determine OpenSSL header version
2471 AC_MSG_CHECKING([OpenSSL header version])
2472 AC_RUN_IFELSE(
2473 [AC_LANG_PROGRAM([[
Darren Tucker15605962015-11-10 11:14:47 +11002474 #include <stdlib.h>
Damien Miller72ef7c12015-01-15 02:21:31 +11002475 #include <stdio.h>
2476 #include <string.h>
2477 #include <openssl/opensslv.h>
2478 #define DATA "conftest.sslincver"
2479 ]], [[
2480 FILE *fd;
2481 int rc;
2482
2483 fd = fopen(DATA,"w");
2484 if(fd == NULL)
2485 exit(1);
2486
Darren Tuckerb3413532016-04-04 11:09:21 +10002487 if ((rc = fprintf(fd, "%08lx (%s)\n",
2488 (unsigned long)OPENSSL_VERSION_NUMBER,
2489 OPENSSL_VERSION_TEXT)) < 0)
Damien Miller72ef7c12015-01-15 02:21:31 +11002490 exit(1);
2491
2492 exit(0);
2493 ]])],
2494 [
2495 ssl_header_ver=`cat conftest.sslincver`
2496 AC_MSG_RESULT([$ssl_header_ver])
2497 ],
2498 [
2499 AC_MSG_RESULT([not found])
2500 AC_MSG_ERROR([OpenSSL version header not found.])
2501 ],
2502 [
2503 AC_MSG_WARN([cross compiling: not checking])
2504 ]
2505 )
2506
2507 # Determine OpenSSL library version
2508 AC_MSG_CHECKING([OpenSSL library version])
2509 AC_RUN_IFELSE(
2510 [AC_LANG_PROGRAM([[
2511 #include <stdio.h>
2512 #include <string.h>
2513 #include <openssl/opensslv.h>
2514 #include <openssl/crypto.h>
2515 #define DATA "conftest.ssllibver"
2516 ]], [[
2517 FILE *fd;
2518 int rc;
2519
2520 fd = fopen(DATA,"w");
2521 if(fd == NULL)
2522 exit(1);
2523
Darren Tucker815bcac2016-04-04 11:07:59 +10002524 if ((rc = fprintf(fd, "%08lx (%s)\n", (unsigned long)SSLeay(),
2525 SSLeay_version(SSLEAY_VERSION))) < 0)
Damien Miller72ef7c12015-01-15 02:21:31 +11002526 exit(1);
2527
2528 exit(0);
2529 ]])],
2530 [
2531 ssl_library_ver=`cat conftest.ssllibver`
2532 # Check version is supported.
2533 case "$ssl_library_ver" in
2534 0090[[0-7]]*|009080[[0-5]]*)
2535 AC_MSG_ERROR([OpenSSL >= 0.9.8f required (have "$ssl_library_ver")])
2536 ;;
2537 *) ;;
2538 esac
2539 AC_MSG_RESULT([$ssl_library_ver])
2540 ],
2541 [
2542 AC_MSG_RESULT([not found])
2543 AC_MSG_ERROR([OpenSSL library not found.])
2544 ],
2545 [
2546 AC_MSG_WARN([cross compiling: not checking])
2547 ]
2548 )
2549
2550 # Sanity check OpenSSL headers
2551 AC_MSG_CHECKING([whether OpenSSL's headers match the library])
2552 AC_RUN_IFELSE(
2553 [AC_LANG_PROGRAM([[
2554 #include <string.h>
2555 #include <openssl/opensslv.h>
Darren Tuckerc1d7e542015-12-15 14:27:09 +11002556 #include <openssl/crypto.h>
Damien Miller72ef7c12015-01-15 02:21:31 +11002557 ]], [[
2558 exit(SSLeay() == OPENSSL_VERSION_NUMBER ? 0 : 1);
2559 ]])],
2560 [
2561 AC_MSG_RESULT([yes])
2562 ],
2563 [
2564 AC_MSG_RESULT([no])
2565 if test "x$openssl_check_nonfatal" = "x"; then
2566 AC_MSG_ERROR([Your OpenSSL headers do not match your
2567 library. Check config.log for details.
2568 If you are sure your installation is consistent, you can disable the check
2569 by running "./configure --without-openssl-header-check".
2570 Also see contrib/findssl.sh for help identifying header/library mismatches.
2571 ])
2572 else
2573 AC_MSG_WARN([Your OpenSSL headers do not match your
2574 library. Check config.log for details.
2575 Also see contrib/findssl.sh for help identifying header/library mismatches.])
2576 fi
2577 ],
2578 [
2579 AC_MSG_WARN([cross compiling: not checking])
2580 ]
2581 )
2582
2583 AC_MSG_CHECKING([if programs using OpenSSL functions will link])
2584 AC_LINK_IFELSE(
2585 [AC_LANG_PROGRAM([[ #include <openssl/evp.h> ]],
2586 [[ SSLeay_add_all_algorithms(); ]])],
2587 [
2588 AC_MSG_RESULT([yes])
2589 ],
2590 [
2591 AC_MSG_RESULT([no])
2592 saved_LIBS="$LIBS"
2593 LIBS="$LIBS -ldl"
2594 AC_MSG_CHECKING([if programs using OpenSSL need -ldl])
2595 AC_LINK_IFELSE(
2596 [AC_LANG_PROGRAM([[ #include <openssl/evp.h> ]],
2597 [[ SSLeay_add_all_algorithms(); ]])],
2598 [
2599 AC_MSG_RESULT([yes])
2600 ],
2601 [
2602 AC_MSG_RESULT([no])
2603 LIBS="$saved_LIBS"
2604 ]
2605 )
2606 ]
2607 )
2608
2609 AC_CHECK_FUNCS([ \
2610 BN_is_prime_ex \
2611 DSA_generate_parameters_ex \
2612 EVP_DigestInit_ex \
2613 EVP_DigestFinal_ex \
2614 EVP_MD_CTX_init \
2615 EVP_MD_CTX_cleanup \
2616 EVP_MD_CTX_copy_ex \
2617 HMAC_CTX_init \
2618 RSA_generate_key_ex \
2619 RSA_get_default_method \
2620 ])
2621
2622 if test "x$openssl_engine" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08002623 AC_MSG_CHECKING([for OpenSSL ENGINE support])
2624 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller72ef7c12015-01-15 02:21:31 +11002625 #include <openssl/engine.h>
Tim Rice648f8762011-01-26 12:38:57 -08002626 ]], [[
Damien Miller72ef7c12015-01-15 02:21:31 +11002627 ENGINE_load_builtin_engines();
2628 ENGINE_register_all_complete();
Tim Rice648f8762011-01-26 12:38:57 -08002629 ]])],
2630 [ AC_MSG_RESULT([yes])
2631 AC_DEFINE([USE_OPENSSL_ENGINE], [1],
Darren Tuckerfabdb6c2006-02-20 20:17:35 +11002632 [Enable OpenSSL engine support])
Tim Rice648f8762011-01-26 12:38:57 -08002633 ], [ AC_MSG_ERROR([OpenSSL ENGINE support not found])
2634 ])
Damien Miller72ef7c12015-01-15 02:21:31 +11002635 fi
Darren Tuckerfabdb6c2006-02-20 20:17:35 +11002636
Damien Miller72ef7c12015-01-15 02:21:31 +11002637 # Check for OpenSSL without EVP_aes_{192,256}_cbc
2638 AC_MSG_CHECKING([whether OpenSSL has crippled AES support])
2639 AC_LINK_IFELSE(
Darren Tucker37bcef52013-11-09 18:39:25 +11002640 [AC_LANG_PROGRAM([[
Damien Miller72ef7c12015-01-15 02:21:31 +11002641 #include <string.h>
2642 #include <openssl/evp.h>
2643 ]], [[
2644 exit(EVP_aes_192_cbc() == NULL || EVP_aes_256_cbc() == NULL);
2645 ]])],
2646 [
2647 AC_MSG_RESULT([no])
2648 ],
2649 [
2650 AC_MSG_RESULT([yes])
2651 AC_DEFINE([OPENSSL_LOBOTOMISED_AES], [1],
2652 [libcrypto is missing AES 192 and 256 bit functions])
2653 ]
2654 )
2655
2656 # Check for OpenSSL with EVP_aes_*ctr
2657 AC_MSG_CHECKING([whether OpenSSL has AES CTR via EVP])
2658 AC_LINK_IFELSE(
2659 [AC_LANG_PROGRAM([[
2660 #include <string.h>
2661 #include <openssl/evp.h>
2662 ]], [[
2663 exit(EVP_aes_128_ctr() == NULL ||
2664 EVP_aes_192_cbc() == NULL ||
2665 EVP_aes_256_cbc() == NULL);
2666 ]])],
2667 [
2668 AC_MSG_RESULT([yes])
2669 AC_DEFINE([OPENSSL_HAVE_EVPCTR], [1],
2670 [libcrypto has EVP AES CTR])
2671 ],
2672 [
2673 AC_MSG_RESULT([no])
2674 ]
2675 )
2676
2677 # Check for OpenSSL with EVP_aes_*gcm
2678 AC_MSG_CHECKING([whether OpenSSL has AES GCM via EVP])
2679 AC_LINK_IFELSE(
2680 [AC_LANG_PROGRAM([[
2681 #include <string.h>
2682 #include <openssl/evp.h>
2683 ]], [[
2684 exit(EVP_aes_128_gcm() == NULL ||
2685 EVP_aes_256_gcm() == NULL ||
2686 EVP_CTRL_GCM_SET_IV_FIXED == 0 ||
2687 EVP_CTRL_GCM_IV_GEN == 0 ||
2688 EVP_CTRL_GCM_SET_TAG == 0 ||
2689 EVP_CTRL_GCM_GET_TAG == 0 ||
2690 EVP_CIPHER_CTX_ctrl(NULL, 0, 0, NULL) == 0);
2691 ]])],
2692 [
2693 AC_MSG_RESULT([yes])
2694 AC_DEFINE([OPENSSL_HAVE_EVPGCM], [1],
2695 [libcrypto has EVP AES GCM])
2696 ],
2697 [
2698 AC_MSG_RESULT([no])
2699 unsupported_algorithms="$unsupported_cipers \
Damien Miller679ce882016-07-15 13:44:38 +10002700 aes128-gcm@openssh.com \
2701 aes256-gcm@openssh.com"
Damien Miller72ef7c12015-01-15 02:21:31 +11002702 ]
2703 )
2704
2705 AC_SEARCH_LIBS([EVP_CIPHER_CTX_ctrl], [crypto],
2706 [AC_DEFINE([HAVE_EVP_CIPHER_CTX_CTRL], [1],
2707 [Define if libcrypto has EVP_CIPHER_CTX_ctrl])])
2708
2709 AC_MSG_CHECKING([if EVP_DigestUpdate returns an int])
2710 AC_LINK_IFELSE(
2711 [AC_LANG_PROGRAM([[
2712 #include <string.h>
2713 #include <openssl/evp.h>
2714 ]], [[
2715 if(EVP_DigestUpdate(NULL, NULL,0))
2716 exit(0);
2717 ]])],
2718 [
2719 AC_MSG_RESULT([yes])
2720 ],
2721 [
2722 AC_MSG_RESULT([no])
2723 AC_DEFINE([OPENSSL_EVP_DIGESTUPDATE_VOID], [1],
2724 [Define if EVP_DigestUpdate returns void])
2725 ]
2726 )
2727
2728 # Some systems want crypt() from libcrypt, *not* the version in OpenSSL,
2729 # because the system crypt() is more featureful.
2730 if test "x$check_for_libcrypt_before" = "x1"; then
2731 AC_CHECK_LIB([crypt], [crypt])
2732 fi
2733
2734 # Some Linux systems (Slackware) need crypt() from libcrypt, *not* the
2735 # version in OpenSSL.
2736 if test "x$check_for_libcrypt_later" = "x1"; then
2737 AC_CHECK_LIB([crypt], [crypt], [LIBS="$LIBS -lcrypt"])
2738 fi
Damien Miller00797e82015-03-04 05:02:45 +11002739 AC_CHECK_FUNCS([crypt DES_crypt])
Damien Miller72ef7c12015-01-15 02:21:31 +11002740
2741 # Search for SHA256 support in libc and/or OpenSSL
2742 AC_CHECK_FUNCS([SHA256_Update EVP_sha256], ,
2743 [unsupported_algorithms="$unsupported_algorithms \
Damien Miller679ce882016-07-15 13:44:38 +10002744 hmac-sha2-256 \
2745 hmac-sha2-512 \
Damien Miller72ef7c12015-01-15 02:21:31 +11002746 diffie-hellman-group-exchange-sha256 \
Damien Miller679ce882016-07-15 13:44:38 +10002747 hmac-sha2-256-etm@openssh.com \
2748 hmac-sha2-512-etm@openssh.com"
Damien Miller72ef7c12015-01-15 02:21:31 +11002749 ]
2750 )
2751 # Search for RIPE-MD support in OpenSSL
2752 AC_CHECK_FUNCS([EVP_ripemd160], ,
2753 [unsupported_algorithms="$unsupported_algorithms \
Damien Miller679ce882016-07-15 13:44:38 +10002754 hmac-ripemd160 \
2755 hmac-ripemd160@openssh.com \
Damien Miller72ef7c12015-01-15 02:21:31 +11002756 hmac-ripemd160-etm@openssh.com"
2757 ]
2758 )
2759
2760 # Check complete ECC support in OpenSSL
2761 AC_MSG_CHECKING([whether OpenSSL has NID_X9_62_prime256v1])
2762 AC_LINK_IFELSE(
2763 [AC_LANG_PROGRAM([[
2764 #include <openssl/ec.h>
2765 #include <openssl/ecdh.h>
2766 #include <openssl/ecdsa.h>
2767 #include <openssl/evp.h>
2768 #include <openssl/objects.h>
2769 #include <openssl/opensslv.h>
2770 #if OPENSSL_VERSION_NUMBER < 0x0090807f /* 0.9.8g */
2771 # error "OpenSSL < 0.9.8g has unreliable ECC code"
2772 #endif
2773 ]], [[
2774 EC_KEY *e = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
2775 const EVP_MD *m = EVP_sha256(); /* We need this too */
Darren Tucker37bcef52013-11-09 18:39:25 +11002776 ]])],
2777 [ AC_MSG_RESULT([yes])
Damien Miller72ef7c12015-01-15 02:21:31 +11002778 enable_nistp256=1 ],
2779 [ AC_MSG_RESULT([no]) ]
2780 )
Darren Tucker37bcef52013-11-09 18:39:25 +11002781
Damien Miller72ef7c12015-01-15 02:21:31 +11002782 AC_MSG_CHECKING([whether OpenSSL has NID_secp384r1])
2783 AC_LINK_IFELSE(
2784 [AC_LANG_PROGRAM([[
2785 #include <openssl/ec.h>
2786 #include <openssl/ecdh.h>
2787 #include <openssl/ecdsa.h>
2788 #include <openssl/evp.h>
2789 #include <openssl/objects.h>
2790 #include <openssl/opensslv.h>
2791 #if OPENSSL_VERSION_NUMBER < 0x0090807f /* 0.9.8g */
2792 # error "OpenSSL < 0.9.8g has unreliable ECC code"
2793 #endif
2794 ]], [[
2795 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp384r1);
2796 const EVP_MD *m = EVP_sha384(); /* We need this too */
2797 ]])],
2798 [ AC_MSG_RESULT([yes])
2799 enable_nistp384=1 ],
2800 [ AC_MSG_RESULT([no]) ]
2801 )
Darren Tucker37bcef52013-11-09 18:39:25 +11002802
Damien Miller72ef7c12015-01-15 02:21:31 +11002803 AC_MSG_CHECKING([whether OpenSSL has NID_secp521r1])
2804 AC_LINK_IFELSE(
2805 [AC_LANG_PROGRAM([[
2806 #include <openssl/ec.h>
2807 #include <openssl/ecdh.h>
2808 #include <openssl/ecdsa.h>
2809 #include <openssl/evp.h>
2810 #include <openssl/objects.h>
2811 #include <openssl/opensslv.h>
2812 #if OPENSSL_VERSION_NUMBER < 0x0090807f /* 0.9.8g */
2813 # error "OpenSSL < 0.9.8g has unreliable ECC code"
2814 #endif
2815 ]], [[
2816 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1);
2817 const EVP_MD *m = EVP_sha512(); /* We need this too */
2818 ]])],
2819 [ AC_MSG_RESULT([yes])
2820 AC_MSG_CHECKING([if OpenSSL's NID_secp521r1 is functional])
2821 AC_RUN_IFELSE(
2822 [AC_LANG_PROGRAM([[
2823 #include <openssl/ec.h>
2824 #include <openssl/ecdh.h>
2825 #include <openssl/ecdsa.h>
2826 #include <openssl/evp.h>
2827 #include <openssl/objects.h>
2828 #include <openssl/opensslv.h>
2829 ]],[[
2830 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1);
2831 const EVP_MD *m = EVP_sha512(); /* We need this too */
2832 exit(e == NULL || m == NULL);
2833 ]])],
2834 [ AC_MSG_RESULT([yes])
2835 enable_nistp521=1 ],
2836 [ AC_MSG_RESULT([no]) ],
2837 [ AC_MSG_WARN([cross-compiling: assuming yes])
2838 enable_nistp521=1 ]
2839 )],
2840 AC_MSG_RESULT([no])
2841 )
Darren Tucker37bcef52013-11-09 18:39:25 +11002842
Damien Miller72ef7c12015-01-15 02:21:31 +11002843 COMMENT_OUT_ECC="#no ecc#"
2844 TEST_SSH_ECC=no
2845
2846 if test x$enable_nistp256 = x1 || test x$enable_nistp384 = x1 || \
2847 test x$enable_nistp521 = x1; then
2848 AC_DEFINE(OPENSSL_HAS_ECC, [1], [OpenSSL has ECC])
2849 fi
2850 if test x$enable_nistp256 = x1; then
2851 AC_DEFINE([OPENSSL_HAS_NISTP256], [1],
2852 [libcrypto has NID_X9_62_prime256v1])
2853 TEST_SSH_ECC=yes
2854 COMMENT_OUT_ECC=""
2855 else
Damien Miller679ce882016-07-15 13:44:38 +10002856 unsupported_algorithms="$unsupported_algorithms \
2857 ecdsa-sha2-nistp256 \
2858 ecdh-sha2-nistp256 \
2859 ecdsa-sha2-nistp256-cert-v01@openssh.com"
Damien Miller72ef7c12015-01-15 02:21:31 +11002860 fi
2861 if test x$enable_nistp384 = x1; then
2862 AC_DEFINE([OPENSSL_HAS_NISTP384], [1], [libcrypto has NID_secp384r1])
2863 TEST_SSH_ECC=yes
2864 COMMENT_OUT_ECC=""
2865 else
Damien Miller679ce882016-07-15 13:44:38 +10002866 unsupported_algorithms="$unsupported_algorithms \
2867 ecdsa-sha2-nistp384 \
2868 ecdh-sha2-nistp384 \
2869 ecdsa-sha2-nistp384-cert-v01@openssh.com"
Damien Miller72ef7c12015-01-15 02:21:31 +11002870 fi
2871 if test x$enable_nistp521 = x1; then
2872 AC_DEFINE([OPENSSL_HAS_NISTP521], [1], [libcrypto has NID_secp521r1])
2873 TEST_SSH_ECC=yes
2874 COMMENT_OUT_ECC=""
2875 else
Damien Miller679ce882016-07-15 13:44:38 +10002876 unsupported_algorithms="$unsupported_algorithms \
2877 ecdh-sha2-nistp521 \
2878 ecdsa-sha2-nistp521 \
2879 ecdsa-sha2-nistp521-cert-v01@openssh.com"
Damien Miller72ef7c12015-01-15 02:21:31 +11002880 fi
2881
2882 AC_SUBST([TEST_SSH_ECC])
2883 AC_SUBST([COMMENT_OUT_ECC])
2884else
2885 AC_CHECK_LIB([crypt], [crypt], [LIBS="$LIBS -lcrypt"])
Damien Miller00797e82015-03-04 05:02:45 +11002886 AC_CHECK_FUNCS([crypt])
Damien Miller72ef7c12015-01-15 02:21:31 +11002887fi
Damien Miller6af914a2010-09-10 11:39:26 +10002888
Damien Miller00f9cd22014-07-15 10:41:38 +10002889AC_CHECK_FUNCS([ \
2890 arc4random \
2891 arc4random_buf \
2892 arc4random_stir \
2893 arc4random_uniform \
2894])
2895
Tim Rice99203ec2007-03-26 09:35:28 -07002896saved_LIBS="$LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08002897AC_CHECK_LIB([iaf], [ia_openinfo], [
Tim Rice99203ec2007-03-26 09:35:28 -07002898 LIBS="$LIBS -liaf"
Tim Rice648f8762011-01-26 12:38:57 -08002899 AC_CHECK_FUNCS([set_id], [SSHDLIBS="$SSHDLIBS -liaf"
2900 AC_DEFINE([HAVE_LIBIAF], [1],
Tim Ricee1d93702016-05-31 11:13:22 -07002901 [Define if system has libiaf that supports set_id])
Tim Rice0eeaf122007-09-10 16:24:17 -07002902 ])
Tim Rice99203ec2007-03-26 09:35:28 -07002903])
2904LIBS="$saved_LIBS"
Damien Miller6c21c512002-01-22 21:57:53 +11002905
2906### Configure cryptographic random number support
2907
2908# Check wheter OpenSSL seeds itself
Damien Miller72ef7c12015-01-15 02:21:31 +11002909if test "x$openssl" = "xyes" ; then
2910 AC_MSG_CHECKING([whether OpenSSL's PRNG is internally seeded])
2911 AC_RUN_IFELSE(
2912 [AC_LANG_PROGRAM([[
2913 #include <string.h>
2914 #include <openssl/rand.h>
2915 ]], [[
2916 exit(RAND_status() == 1 ? 0 : 1);
2917 ]])],
2918 [
2919 OPENSSL_SEEDS_ITSELF=yes
2920 AC_MSG_RESULT([yes])
2921 ],
2922 [
2923 AC_MSG_RESULT([no])
2924 ],
2925 [
2926 AC_MSG_WARN([cross compiling: assuming yes])
2927 # This is safe, since we will fatal() at runtime if
2928 # OpenSSL is not seeded correctly.
2929 OPENSSL_SEEDS_ITSELF=yes
2930 ]
2931 )
2932fi
Damien Miller6c21c512002-01-22 21:57:53 +11002933
Damien Millerf22019b2011-05-05 13:48:37 +10002934# PRNGD TCP socket
2935AC_ARG_WITH([prngd-port],
2936 [ --with-prngd-port=PORT read entropy from PRNGD/EGD TCP localhost:PORT],
2937 [
2938 case "$withval" in
2939 no)
2940 withval=""
2941 ;;
2942 [[0-9]]*)
2943 ;;
2944 *)
2945 AC_MSG_ERROR([You must specify a numeric port number for --with-prngd-port])
2946 ;;
2947 esac
2948 if test ! -z "$withval" ; then
2949 PRNGD_PORT="$withval"
2950 AC_DEFINE_UNQUOTED([PRNGD_PORT], [$PRNGD_PORT],
2951 [Port number of PRNGD/EGD random number socket])
2952 fi
2953 ]
2954)
2955
2956# PRNGD Unix domain socket
2957AC_ARG_WITH([prngd-socket],
2958 [ --with-prngd-socket=FILE read entropy from PRNGD/EGD socket FILE (default=/var/run/egd-pool)],
2959 [
2960 case "$withval" in
2961 yes)
2962 withval="/var/run/egd-pool"
2963 ;;
2964 no)
2965 withval=""
2966 ;;
2967 /*)
2968 ;;
2969 *)
2970 AC_MSG_ERROR([You must specify an absolute path to the entropy socket])
2971 ;;
2972 esac
2973
2974 if test ! -z "$withval" ; then
2975 if test ! -z "$PRNGD_PORT" ; then
2976 AC_MSG_ERROR([You may not specify both a PRNGD/EGD port and socket])
2977 fi
2978 if test ! -r "$withval" ; then
2979 AC_MSG_WARN([Entropy socket is not readable])
2980 fi
2981 PRNGD_SOCKET="$withval"
2982 AC_DEFINE_UNQUOTED([PRNGD_SOCKET], ["$PRNGD_SOCKET"],
2983 [Location of PRNGD/EGD random number socket])
2984 fi
2985 ],
2986 [
2987 # Check for existing socket only if we don't have a random device already
2988 if test "x$OPENSSL_SEEDS_ITSELF" != "xyes" ; then
2989 AC_MSG_CHECKING([for PRNGD/EGD socket])
2990 # Insert other locations here
2991 for sock in /var/run/egd-pool /dev/egd-pool /etc/entropy; do
2992 if test -r $sock && $TEST_MINUS_S_SH -c "test -S $sock -o -p $sock" ; then
2993 PRNGD_SOCKET="$sock"
2994 AC_DEFINE_UNQUOTED([PRNGD_SOCKET], ["$PRNGD_SOCKET"])
2995 break;
2996 fi
2997 done
2998 if test ! -z "$PRNGD_SOCKET" ; then
2999 AC_MSG_RESULT([$PRNGD_SOCKET])
3000 else
3001 AC_MSG_RESULT([not found])
3002 fi
3003 fi
3004 ]
3005)
3006
3007# Which randomness source do we use?
3008if test ! -z "$PRNGD_PORT" ; then
3009 RAND_MSG="PRNGd port $PRNGD_PORT"
3010elif test ! -z "$PRNGD_SOCKET" ; then
3011 RAND_MSG="PRNGd socket $PRNGD_SOCKET"
3012elif test ! -z "$OPENSSL_SEEDS_ITSELF" ; then
3013 AC_DEFINE([OPENSSL_PRNG_ONLY], [1],
Damien Miller72ef7c12015-01-15 02:21:31 +11003014 [Define if you want the OpenSSL internally seeded PRNG only])
Damien Millerf22019b2011-05-05 13:48:37 +10003015 RAND_MSG="OpenSSL internal ONLY"
Damien Miller72ef7c12015-01-15 02:21:31 +11003016elif test "x$openssl" = "xno" ; then
3017 AC_MSG_WARN([OpenSSH will use /dev/urandom as a source of random numbers. It will fail if this device is not supported or accessible])
Damien Millerf22019b2011-05-05 13:48:37 +10003018else
3019 AC_MSG_ERROR([OpenSSH has no source of random numbers. Please configure OpenSSL with an entropy source or re-run configure using one of the --with-prngd-port or --with-prngd-socket options])
3020fi
3021
Darren Tucker3e6bde42006-08-20 20:03:50 +10003022# Check for PAM libs
3023PAM_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08003024AC_ARG_WITH([pam],
Darren Tucker3e6bde42006-08-20 20:03:50 +10003025 [ --with-pam Enable PAM support ],
3026 [
3027 if test "x$withval" != "xno" ; then
3028 if test "x$ac_cv_header_security_pam_appl_h" != "xyes" && \
3029 test "x$ac_cv_header_pam_pam_appl_h" != "xyes" ; then
3030 AC_MSG_ERROR([PAM headers not found])
3031 fi
3032
3033 saved_LIBS="$LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08003034 AC_CHECK_LIB([dl], [dlopen], , )
3035 AC_CHECK_LIB([pam], [pam_set_item], , [AC_MSG_ERROR([*** libpam missing])])
3036 AC_CHECK_FUNCS([pam_getenvlist])
3037 AC_CHECK_FUNCS([pam_putenv])
Darren Tucker3e6bde42006-08-20 20:03:50 +10003038 LIBS="$saved_LIBS"
3039
3040 PAM_MSG="yes"
3041
Darren Tucker20e9f972007-03-25 18:26:01 +10003042 SSHDLIBS="$SSHDLIBS -lpam"
Tim Rice648f8762011-01-26 12:38:57 -08003043 AC_DEFINE([USE_PAM], [1],
Darren Tucker3e6bde42006-08-20 20:03:50 +10003044 [Define if you want to enable PAM support])
Darren Tucker639bbe82006-08-20 20:17:53 +10003045
Darren Tucker3e6bde42006-08-20 20:03:50 +10003046 if test $ac_cv_lib_dl_dlopen = yes; then
Darren Tucker639bbe82006-08-20 20:17:53 +10003047 case "$LIBS" in
3048 *-ldl*)
3049 # libdl already in LIBS
3050 ;;
3051 *)
Darren Tucker20e9f972007-03-25 18:26:01 +10003052 SSHDLIBS="$SSHDLIBS -ldl"
Darren Tucker639bbe82006-08-20 20:17:53 +10003053 ;;
3054 esac
Darren Tucker3e6bde42006-08-20 20:03:50 +10003055 fi
Darren Tucker3e6bde42006-08-20 20:03:50 +10003056 fi
3057 ]
3058)
3059
Damien Miller8bd81e12016-08-16 13:30:56 +10003060AC_ARG_WITH([pam-service],
3061 [ --with-pam-service=name Specify PAM service name ],
3062 [
3063 if test "x$withval" != "xno" && \
3064 test "x$withval" != "xyes" ; then
3065 AC_DEFINE_UNQUOTED([SSHD_PAM_SERVICE],
3066 ["$withval"], [sshd PAM service name])
3067 fi
3068 ]
3069)
3070
Darren Tucker3e6bde42006-08-20 20:03:50 +10003071# Check for older PAM
3072if test "x$PAM_MSG" = "xyes" ; then
3073 # Check PAM strerror arguments (old PAM)
3074 AC_MSG_CHECKING([whether pam_strerror takes only one argument])
Tim Rice648f8762011-01-26 12:38:57 -08003075 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker3e6bde42006-08-20 20:03:50 +10003076#include <stdlib.h>
3077#if defined(HAVE_SECURITY_PAM_APPL_H)
3078#include <security/pam_appl.h>
3079#elif defined (HAVE_PAM_PAM_APPL_H)
3080#include <pam/pam_appl.h>
3081#endif
Tim Rice648f8762011-01-26 12:38:57 -08003082 ]], [[
3083(void)pam_strerror((pam_handle_t *)NULL, -1);
3084 ]])], [AC_MSG_RESULT([no])], [
3085 AC_DEFINE([HAVE_OLD_PAM], [1],
Darren Tucker3e6bde42006-08-20 20:03:50 +10003086 [Define if you have an old version of PAM
3087 which takes only one argument to pam_strerror])
Tim Rice648f8762011-01-26 12:38:57 -08003088 AC_MSG_RESULT([yes])
Darren Tucker3e6bde42006-08-20 20:03:50 +10003089 PAM_MSG="yes (old library)"
Damien Miller72ef7c12015-01-15 02:21:31 +11003090
Tim Rice648f8762011-01-26 12:38:57 -08003091 ])
Darren Tucker3e6bde42006-08-20 20:03:50 +10003092fi
Damien Miller6c21c512002-01-22 21:57:53 +11003093
Damien Miller6482d902014-05-27 14:34:42 +10003094case "$host" in
3095*-*-cygwin*)
3096 SSH_PRIVSEP_USER=CYGWIN_SSH_PRIVSEP_USER
3097 ;;
3098*)
3099 SSH_PRIVSEP_USER=sshd
3100 ;;
3101esac
Tim Rice648f8762011-01-26 12:38:57 -08003102AC_ARG_WITH([privsep-user],
Kevin Stevesc81e1292002-05-13 03:51:40 +00003103 [ --with-privsep-user=user Specify non-privileged user for privilege separation],
Kevin Steves7ff91122002-04-07 19:22:54 +00003104 [
Tim Rice35cc69d2005-03-17 16:44:25 -08003105 if test -n "$withval" && test "x$withval" != "xno" && \
3106 test "x${withval}" != "xyes"; then
Damien Millerd3f6ad22002-06-25 10:24:47 +10003107 SSH_PRIVSEP_USER=$withval
Kevin Steves7ff91122002-04-07 19:22:54 +00003108 fi
Tim Riceeae17cc2005-03-17 16:52:20 -08003109 ]
Kevin Steves7ff91122002-04-07 19:22:54 +00003110)
Damien Miller6482d902014-05-27 14:34:42 +10003111if test "x$SSH_PRIVSEP_USER" = "xCYGWIN_SSH_PRIVSEP_USER" ; then
3112 AC_DEFINE_UNQUOTED([SSH_PRIVSEP_USER], [CYGWIN_SSH_PRIVSEP_USER],
3113 [Cygwin function to fetch non-privileged user for privilege separation])
3114else
3115 AC_DEFINE_UNQUOTED([SSH_PRIVSEP_USER], ["$SSH_PRIVSEP_USER"],
3116 [non-privileged user for privilege separation])
3117fi
Tim Rice648f8762011-01-26 12:38:57 -08003118AC_SUBST([SSH_PRIVSEP_USER])
Kevin Steves7ff91122002-04-07 19:22:54 +00003119
Damien Miller91f40d82013-02-22 11:37:00 +11003120if test "x$have_linux_no_new_privs" = "x1" ; then
3121AC_CHECK_DECL([SECCOMP_MODE_FILTER], [have_seccomp_filter=1], , [
3122 #include <sys/types.h>
3123 #include <linux/seccomp.h>
3124])
3125fi
3126if test "x$have_seccomp_filter" = "x1" ; then
3127AC_MSG_CHECKING([kernel for seccomp_filter support])
3128AC_LINK_IFELSE([AC_LANG_PROGRAM([[
3129 #include <errno.h>
3130 #include <elf.h>
3131 #include <linux/audit.h>
3132 #include <linux/seccomp.h>
3133 #include <stdlib.h>
3134 #include <sys/prctl.h>
3135 ]],
3136 [[ int i = $seccomp_audit_arch;
3137 errno = 0;
3138 prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, NULL, 0, 0);
3139 exit(errno == EFAULT ? 0 : 1); ]])],
3140 [ AC_MSG_RESULT([yes]) ], [
3141 AC_MSG_RESULT([no])
3142 # Disable seccomp filter as a target
3143 have_seccomp_filter=0
3144 ]
3145)
3146fi
3147
Damien Miller69ff1df2011-06-23 08:30:03 +10003148# Decide which sandbox style to use
3149sandbox_arg=""
3150AC_ARG_WITH([sandbox],
deraadt@openbsd.org2539dce2015-10-09 01:37:08 +00003151 [ --with-sandbox=style Specify privilege separation sandbox (no, capsicum, darwin, rlimit, seccomp_filter, systrace, pledge)],
Damien Miller69ff1df2011-06-23 08:30:03 +10003152 [
3153 if test "x$withval" = "xyes" ; then
3154 sandbox_arg=""
3155 else
3156 sandbox_arg="$withval"
3157 fi
3158 ]
3159)
Darren Tucker60395f92012-07-03 14:31:18 +10003160
3161# Some platforms (seems to be the ones that have a kernel poll(2)-type
3162# function with which they implement select(2)) use an extra file descriptor
3163# when calling select(2), which means we can't use the rlimit sandbox.
3164AC_MSG_CHECKING([if select works with descriptor rlimit])
3165AC_RUN_IFELSE(
3166 [AC_LANG_PROGRAM([[
3167#include <sys/types.h>
3168#ifdef HAVE_SYS_TIME_H
3169# include <sys/time.h>
3170#endif
3171#include <sys/resource.h>
3172#ifdef HAVE_SYS_SELECT_H
3173# include <sys/select.h>
3174#endif
3175#include <errno.h>
3176#include <fcntl.h>
3177#include <stdlib.h>
3178 ]],[[
3179 struct rlimit rl_zero;
3180 int fd, r;
3181 fd_set fds;
Damien Millere4f43472013-03-08 12:14:22 +11003182 struct timeval tv;
Darren Tucker60395f92012-07-03 14:31:18 +10003183
3184 fd = open("/dev/null", O_RDONLY);
3185 FD_ZERO(&fds);
3186 FD_SET(fd, &fds);
3187 rl_zero.rlim_cur = rl_zero.rlim_max = 0;
3188 setrlimit(RLIMIT_FSIZE, &rl_zero);
3189 setrlimit(RLIMIT_NOFILE, &rl_zero);
Damien Millere4f43472013-03-08 12:14:22 +11003190 tv.tv_sec = 1;
3191 tv.tv_usec = 0;
3192 r = select(fd+1, &fds, NULL, NULL, &tv);
Darren Tucker60395f92012-07-03 14:31:18 +10003193 exit (r == -1 ? 1 : 0);
3194 ]])],
3195 [AC_MSG_RESULT([yes])
3196 select_works_with_rlimit=yes],
3197 [AC_MSG_RESULT([no])
3198 select_works_with_rlimit=no],
3199 [AC_MSG_WARN([cross compiling: assuming yes])]
3200)
3201
Darren Tuckerff008de2013-03-06 17:48:48 +11003202AC_MSG_CHECKING([if setrlimit(RLIMIT_NOFILE,{0,0}) works])
3203AC_RUN_IFELSE(
3204 [AC_LANG_PROGRAM([[
3205#include <sys/types.h>
3206#ifdef HAVE_SYS_TIME_H
3207# include <sys/time.h>
3208#endif
3209#include <sys/resource.h>
3210#include <errno.h>
3211#include <stdlib.h>
3212 ]],[[
3213 struct rlimit rl_zero;
3214 int fd, r;
3215 fd_set fds;
3216
3217 rl_zero.rlim_cur = rl_zero.rlim_max = 0;
3218 r = setrlimit(RLIMIT_NOFILE, &rl_zero);
3219 exit (r == -1 ? 1 : 0);
3220 ]])],
3221 [AC_MSG_RESULT([yes])
3222 rlimit_nofile_zero_works=yes],
3223 [AC_MSG_RESULT([no])
3224 rlimit_nofile_zero_works=no],
3225 [AC_MSG_WARN([cross compiling: assuming yes])]
3226)
3227
Darren Tuckerd545a4b2012-07-03 22:48:31 +10003228AC_MSG_CHECKING([if setrlimit RLIMIT_FSIZE works])
3229AC_RUN_IFELSE(
3230 [AC_LANG_PROGRAM([[
3231#include <sys/types.h>
3232#include <sys/resource.h>
3233#include <stdlib.h>
3234 ]],[[
3235 struct rlimit rl_zero;
3236
3237 rl_zero.rlim_cur = rl_zero.rlim_max = 0;
3238 exit(setrlimit(RLIMIT_FSIZE, &rl_zero) != 0);
3239 ]])],
3240 [AC_MSG_RESULT([yes])],
3241 [AC_MSG_RESULT([no])
3242 AC_DEFINE(SANDBOX_SKIP_RLIMIT_FSIZE, 1,
3243 [setrlimit RLIMIT_FSIZE works])],
3244 [AC_MSG_WARN([cross compiling: assuming yes])]
3245)
3246
deraadt@openbsd.org2539dce2015-10-09 01:37:08 +00003247if test "x$sandbox_arg" = "xpledge" || \
3248 ( test -z "$sandbox_arg" && test "x$ac_cv_func_pledge" = "xyes" ) ; then
3249 test "x$ac_cv_func_pledge" != "xyes" && \
3250 AC_MSG_ERROR([pledge sandbox requires pledge(2) support])
3251 SANDBOX_STYLE="pledge"
Damien Millerfafe1d82015-10-14 09:22:15 -07003252 AC_DEFINE([SANDBOX_PLEDGE], [1], [Sandbox using pledge(2)])
Damien Miller9846a2f2015-10-08 04:30:48 +11003253elif test "x$sandbox_arg" = "xsystrace" || \
Damien Miller69ff1df2011-06-23 08:30:03 +10003254 ( test -z "$sandbox_arg" && test "x$have_systr_policy_kill" = "x1" ) ; then
Damien Miller1a91c0f2011-08-17 11:59:25 +10003255 test "x$have_systr_policy_kill" != "x1" && \
3256 AC_MSG_ERROR([systrace sandbox requires systrace headers and SYSTR_POLICY_KILL support])
Damien Miller69ff1df2011-06-23 08:30:03 +10003257 SANDBOX_STYLE="systrace"
3258 AC_DEFINE([SANDBOX_SYSTRACE], [1], [Sandbox using systrace(4)])
Damien Millercd5e52e2011-06-27 07:18:18 +10003259elif test "x$sandbox_arg" = "xdarwin" || \
3260 ( test -z "$sandbox_arg" && test "x$ac_cv_func_sandbox_init" = "xyes" && \
3261 test "x$ac_cv_header_sandbox_h" = "xyes") ; then
Damien Miller1a91c0f2011-08-17 11:59:25 +10003262 test "x$ac_cv_func_sandbox_init" != "xyes" -o \
3263 "x$ac_cv_header_sandbox_h" != "xyes" && \
3264 AC_MSG_ERROR([Darwin seatbelt sandbox requires sandbox.h and sandbox_init function])
Damien Millercd5e52e2011-06-27 07:18:18 +10003265 SANDBOX_STYLE="darwin"
3266 AC_DEFINE([SANDBOX_DARWIN], [1], [Sandbox using Darwin sandbox_init(3)])
Damien Millere0956e32012-04-04 11:27:54 +10003267elif test "x$sandbox_arg" = "xseccomp_filter" || \
3268 ( test -z "$sandbox_arg" && \
Darren Tuckerd0494fd2012-05-19 14:25:39 +10003269 test "x$have_seccomp_filter" = "x1" && \
Damien Miller91f40d82013-02-22 11:37:00 +11003270 test "x$ac_cv_header_elf_h" = "xyes" && \
Damien Millere0956e32012-04-04 11:27:54 +10003271 test "x$ac_cv_header_linux_audit_h" = "xyes" && \
Damien Miller91f40d82013-02-22 11:37:00 +11003272 test "x$ac_cv_header_linux_filter_h" = "xyes" && \
3273 test "x$seccomp_audit_arch" != "x" && \
Damien Millere0956e32012-04-04 11:27:54 +10003274 test "x$have_linux_no_new_privs" = "x1" && \
3275 test "x$ac_cv_func_prctl" = "xyes" ) ; then
Damien Miller91f40d82013-02-22 11:37:00 +11003276 test "x$seccomp_audit_arch" = "x" && \
Damien Millere0956e32012-04-04 11:27:54 +10003277 AC_MSG_ERROR([seccomp_filter sandbox not supported on $host])
3278 test "x$have_linux_no_new_privs" != "x1" && \
3279 AC_MSG_ERROR([seccomp_filter sandbox requires PR_SET_NO_NEW_PRIVS])
3280 test "x$have_seccomp_filter" != "x1" && \
3281 AC_MSG_ERROR([seccomp_filter sandbox requires seccomp headers])
3282 test "x$ac_cv_func_prctl" != "xyes" && \
3283 AC_MSG_ERROR([seccomp_filter sandbox requires prctl function])
3284 SANDBOX_STYLE="seccomp_filter"
3285 AC_DEFINE([SANDBOX_SECCOMP_FILTER], [1], [Sandbox using seccomp filter])
Damien Millerf62ecef2014-01-25 12:34:38 +11003286elif test "x$sandbox_arg" = "xcapsicum" || \
3287 ( test -z "$sandbox_arg" && \
Damien Miller603b8f42014-01-25 13:16:59 +11003288 test "x$ac_cv_header_sys_capability_h" = "xyes" && \
3289 test "x$ac_cv_func_cap_rights_limit" = "xyes") ; then
3290 test "x$ac_cv_header_sys_capability_h" != "xyes" && \
Damien Millerc96d8532014-01-25 13:12:28 +11003291 AC_MSG_ERROR([capsicum sandbox requires sys/capability.h header])
Damien Miller603b8f42014-01-25 13:16:59 +11003292 test "x$ac_cv_func_cap_rights_limit" != "xyes" && \
Damien Millerc96d8532014-01-25 13:12:28 +11003293 AC_MSG_ERROR([capsicum sandbox requires cap_rights_limit function])
Damien Millerf62ecef2014-01-25 12:34:38 +11003294 SANDBOX_STYLE="capsicum"
3295 AC_DEFINE([SANDBOX_CAPSICUM], [1], [Sandbox using capsicum])
Damien Miller69ff1df2011-06-23 08:30:03 +10003296elif test "x$sandbox_arg" = "xrlimit" || \
Darren Tucker60395f92012-07-03 14:31:18 +10003297 ( test -z "$sandbox_arg" && test "x$ac_cv_func_setrlimit" = "xyes" && \
Darren Tuckerff008de2013-03-06 17:48:48 +11003298 test "x$select_works_with_rlimit" = "xyes" && \
3299 test "x$rlimit_nofile_zero_works" = "xyes" ) ; then
Damien Miller1a91c0f2011-08-17 11:59:25 +10003300 test "x$ac_cv_func_setrlimit" != "xyes" && \
3301 AC_MSG_ERROR([rlimit sandbox requires setrlimit function])
Darren Tucker60395f92012-07-03 14:31:18 +10003302 test "x$select_works_with_rlimit" != "xyes" && \
3303 AC_MSG_ERROR([rlimit sandbox requires select to work with rlimit])
Damien Miller69ff1df2011-06-23 08:30:03 +10003304 SANDBOX_STYLE="rlimit"
3305 AC_DEFINE([SANDBOX_RLIMIT], [1], [Sandbox using setrlimit(2)])
Damien Miller4626cba2016-01-08 14:24:56 +11003306elif test "x$sandbox_arg" = "xsolaris" || \
3307 ( test -z "$sandbox_arg" && test "x$SOLARIS_PRIVS" = "xyes" ) ; then
3308 SANDBOX_STYLE="solaris"
3309 AC_DEFINE([SANDBOX_SOLARIS], [1], [Sandbox using Solaris/Illumos privileges])
Damien Miller69ff1df2011-06-23 08:30:03 +10003310elif test -z "$sandbox_arg" || test "x$sandbox_arg" = "xno" || \
3311 test "x$sandbox_arg" = "xnone" || test "x$sandbox_arg" = "xnull" ; then
3312 SANDBOX_STYLE="none"
3313 AC_DEFINE([SANDBOX_NULL], [1], [no privsep sandboxing])
3314else
Tim Ricea6e60612011-08-17 21:48:22 -07003315 AC_MSG_ERROR([unsupported --with-sandbox])
Damien Miller69ff1df2011-06-23 08:30:03 +10003316fi
3317
Ben Lindstromb5628642000-10-18 00:02:25 +00003318# Cheap hack to ensure NEWS-OS libraries are arranged right.
3319if test ! -z "$SONY" ; then
3320 LIBS="$LIBS -liberty";
3321fi
3322
Damien Miller57f39152005-11-24 19:58:19 +11003323# Check for long long datatypes
3324AC_CHECK_TYPES([long long, unsigned long long, long double])
3325
3326# Check datatype sizes
Tim Rice648f8762011-01-26 12:38:57 -08003327AC_CHECK_SIZEOF([short int], [2])
3328AC_CHECK_SIZEOF([int], [4])
3329AC_CHECK_SIZEOF([long int], [4])
3330AC_CHECK_SIZEOF([long long int], [8])
Damien Millerc6398ef1999-11-20 12:18:40 +11003331
Damien Millerfa2bb692002-04-23 23:22:25 +10003332# Sanity check long long for some platforms (AIX)
3333if test "x$ac_cv_sizeof_long_long_int" = "x4" ; then
3334 ac_cv_sizeof_long_long_int=0
3335fi
3336
Darren Tucker537f1ed2005-10-25 18:38:33 +10003337# compute LLONG_MIN and LLONG_MAX if we don't know them.
3338if test -z "$have_llong_max"; then
3339 AC_MSG_CHECKING([for max value of long long])
3340 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08003341 [AC_LANG_PROGRAM([[
Darren Tucker537f1ed2005-10-25 18:38:33 +10003342#include <stdio.h>
3343/* Why is this so damn hard? */
3344#ifdef __GNUC__
3345# undef __GNUC__
3346#endif
3347#define __USE_ISOC99
3348#include <limits.h>
3349#define DATA "conftest.llminmax"
Darren Tuckerd1450db2006-03-13 19:06:51 +11003350#define my_abs(a) ((a) < 0 ? ((a) * -1) : (a))
3351
3352/*
3353 * printf in libc on some platforms (eg old Tru64) does not understand %lld so
3354 * we do this the hard way.
3355 */
3356static int
3357fprint_ll(FILE *f, long long n)
3358{
3359 unsigned int i;
3360 int l[sizeof(long long) * 8];
3361
3362 if (n < 0)
3363 if (fprintf(f, "-") < 0)
3364 return -1;
3365 for (i = 0; n != 0; i++) {
3366 l[i] = my_abs(n % 10);
3367 n /= 10;
3368 }
3369 do {
3370 if (fprintf(f, "%d", l[--i]) < 0)
3371 return -1;
3372 } while (i != 0);
3373 if (fprintf(f, " ") < 0)
3374 return -1;
3375 return 0;
3376}
Tim Rice648f8762011-01-26 12:38:57 -08003377 ]], [[
Darren Tucker537f1ed2005-10-25 18:38:33 +10003378 FILE *f;
3379 long long i, llmin, llmax = 0;
3380
3381 if((f = fopen(DATA,"w")) == NULL)
3382 exit(1);
3383
3384#if defined(LLONG_MIN) && defined(LLONG_MAX)
3385 fprintf(stderr, "Using system header for LLONG_MIN and LLONG_MAX\n");
3386 llmin = LLONG_MIN;
3387 llmax = LLONG_MAX;
3388#else
3389 fprintf(stderr, "Calculating LLONG_MIN and LLONG_MAX\n");
3390 /* This will work on one's complement and two's complement */
3391 for (i = 1; i > llmax; i <<= 1, i++)
3392 llmax = i;
3393 llmin = llmax + 1LL; /* wrap */
3394#endif
3395
3396 /* Sanity check */
3397 if (llmin + 1 < llmin || llmin - 1 < llmin || llmax + 1 > llmax
Darren Tuckerd1450db2006-03-13 19:06:51 +11003398 || llmax - 1 > llmax || llmin == llmax || llmin == 0
3399 || llmax == 0 || llmax < LONG_MAX || llmin > LONG_MIN) {
Darren Tucker537f1ed2005-10-25 18:38:33 +10003400 fprintf(f, "unknown unknown\n");
3401 exit(2);
3402 }
3403
Darren Tuckerd1450db2006-03-13 19:06:51 +11003404 if (fprint_ll(f, llmin) < 0)
Darren Tucker537f1ed2005-10-25 18:38:33 +10003405 exit(3);
Darren Tuckerd1450db2006-03-13 19:06:51 +11003406 if (fprint_ll(f, llmax) < 0)
3407 exit(4);
3408 if (fclose(f) < 0)
3409 exit(5);
Darren Tucker537f1ed2005-10-25 18:38:33 +10003410 exit(0);
Darren Tucker537f1ed2005-10-25 18:38:33 +10003411 ]])],
3412 [
3413 llong_min=`$AWK '{print $1}' conftest.llminmax`
3414 llong_max=`$AWK '{print $2}' conftest.llminmax`
3415
Tim Rice648f8762011-01-26 12:38:57 -08003416 AC_MSG_RESULT([$llong_max])
3417 AC_DEFINE_UNQUOTED([LLONG_MAX], [${llong_max}LL],
Darren Tucker537f1ed2005-10-25 18:38:33 +10003418 [max value of long long calculated by configure])
3419 AC_MSG_CHECKING([for min value of long long])
Tim Rice648f8762011-01-26 12:38:57 -08003420 AC_MSG_RESULT([$llong_min])
3421 AC_DEFINE_UNQUOTED([LLONG_MIN], [${llong_min}LL],
Darren Tucker537f1ed2005-10-25 18:38:33 +10003422 [min value of long long calculated by configure])
3423 ],
3424 [
Tim Rice648f8762011-01-26 12:38:57 -08003425 AC_MSG_RESULT([not found])
Darren Tucker537f1ed2005-10-25 18:38:33 +10003426 ],
3427 [
3428 AC_MSG_WARN([cross compiling: not checking])
3429 ]
3430 )
3431fi
3432
3433
Damien Millera22ba012000-03-02 23:09:20 +11003434# More checks for data types
Damien Millercaf6dd62000-08-29 11:33:50 +11003435AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [
Tim Rice648f8762011-01-26 12:38:57 -08003436 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3437 [[ u_int a; a = 1;]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003438 [ ac_cv_have_u_int="yes" ], [ ac_cv_have_u_int="no"
Tim Rice648f8762011-01-26 12:38:57 -08003439 ])
Damien Millercaf6dd62000-08-29 11:33:50 +11003440])
3441if test "x$ac_cv_have_u_int" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003442 AC_DEFINE([HAVE_U_INT], [1], [define if you have u_int data type])
Damien Millercaf6dd62000-08-29 11:33:50 +11003443 have_u_int=1
3444fi
3445
Damien Miller61e50f12000-05-08 20:49:37 +10003446AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003447 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3448 [[ int8_t a; int16_t b; int32_t c; a = b = c = 1;]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003449 [ ac_cv_have_intxx_t="yes" ], [ ac_cv_have_intxx_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003450 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003451])
3452if test "x$ac_cv_have_intxx_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003453 AC_DEFINE([HAVE_INTXX_T], [1], [define if you have intxx_t data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003454 have_intxx_t=1
3455fi
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003456
3457if (test -z "$have_intxx_t" && \
Damien Millera8e06ce2003-11-21 23:48:55 +11003458 test "x$ac_cv_header_stdint_h" = "xyes")
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003459then
3460 AC_MSG_CHECKING([for intXX_t types in stdint.h])
Tim Rice648f8762011-01-26 12:38:57 -08003461 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdint.h> ]],
3462 [[ int8_t a; int16_t b; int32_t c; a = b = c = 1;]])],
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003463 [
Tim Rice648f8762011-01-26 12:38:57 -08003464 AC_DEFINE([HAVE_INTXX_T])
3465 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003466 ], [ AC_MSG_RESULT([no])
Tim Rice648f8762011-01-26 12:38:57 -08003467 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003468fi
3469
Damien Miller578783e2000-09-23 14:12:24 +11003470AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003471 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Tim Rice907881e2002-07-18 11:44:50 -07003472#include <sys/types.h>
3473#ifdef HAVE_STDINT_H
3474# include <stdint.h>
3475#endif
3476#include <sys/socket.h>
3477#ifdef HAVE_SYS_BITYPES_H
3478# include <sys/bitypes.h>
3479#endif
Tim Rice648f8762011-01-26 12:38:57 -08003480 ]], [[
3481int64_t a; a = 1;
3482 ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003483 [ ac_cv_have_int64_t="yes" ], [ ac_cv_have_int64_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003484 ])
Damien Miller578783e2000-09-23 14:12:24 +11003485])
3486if test "x$ac_cv_have_int64_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003487 AC_DEFINE([HAVE_INT64_T], [1], [define if you have int64_t data type])
Tim Rice4cec93f2002-02-26 08:40:48 -08003488fi
3489
Damien Miller61e50f12000-05-08 20:49:37 +10003490AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003491 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3492 [[ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003493 [ ac_cv_have_u_intxx_t="yes" ], [ ac_cv_have_u_intxx_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003494 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003495])
3496if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003497 AC_DEFINE([HAVE_U_INTXX_T], [1], [define if you have u_intxx_t data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003498 have_u_intxx_t=1
3499fi
Damien Millerc6398ef1999-11-20 12:18:40 +11003500
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003501if test -z "$have_u_intxx_t" ; then
3502 AC_MSG_CHECKING([for u_intXX_t types in sys/socket.h])
Tim Rice648f8762011-01-26 12:38:57 -08003503 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/socket.h> ]],
3504 [[ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;]])],
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003505 [
Tim Rice648f8762011-01-26 12:38:57 -08003506 AC_DEFINE([HAVE_U_INTXX_T])
3507 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003508 ], [ AC_MSG_RESULT([no])
Tim Rice648f8762011-01-26 12:38:57 -08003509 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003510fi
3511
Damien Miller578783e2000-09-23 14:12:24 +11003512AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003513 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3514 [[ u_int64_t a; a = 1;]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003515 [ ac_cv_have_u_int64_t="yes" ], [ ac_cv_have_u_int64_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003516 ])
Damien Miller578783e2000-09-23 14:12:24 +11003517])
3518if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003519 AC_DEFINE([HAVE_U_INT64_T], [1], [define if you have u_int64_t data type])
Damien Miller578783e2000-09-23 14:12:24 +11003520 have_u_int64_t=1
3521fi
3522
Damien Millerc2868192014-01-30 10:21:19 +11003523if (test -z "$have_u_int64_t" && \
3524 test "x$ac_cv_header_sys_bitypes_h" = "xyes")
3525then
Tim Rice4cec93f2002-02-26 08:40:48 -08003526 AC_MSG_CHECKING([for u_int64_t type in sys/bitypes.h])
Tim Rice648f8762011-01-26 12:38:57 -08003527 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/bitypes.h> ]],
3528 [[ u_int64_t a; a = 1]])],
Tim Rice4cec93f2002-02-26 08:40:48 -08003529 [
Tim Rice648f8762011-01-26 12:38:57 -08003530 AC_DEFINE([HAVE_U_INT64_T])
3531 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003532 ], [ AC_MSG_RESULT([no])
Tim Rice648f8762011-01-26 12:38:57 -08003533 ])
Tim Rice4cec93f2002-02-26 08:40:48 -08003534fi
3535
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003536if test -z "$have_u_intxx_t" ; then
3537 AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003538 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003539#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08003540 ]], [[
3541 uint8_t a;
3542 uint16_t b;
3543 uint32_t c;
3544 a = b = c = 1;
3545 ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003546 [ ac_cv_have_uintxx_t="yes" ], [ ac_cv_have_uintxx_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003547 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003548 ])
3549 if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003550 AC_DEFINE([HAVE_UINTXX_T], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003551 [define if you have uintxx_t data type])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003552 fi
3553fi
3554
Damien Millerc2868192014-01-30 10:21:19 +11003555if (test -z "$have_uintxx_t" && \
3556 test "x$ac_cv_header_stdint_h" = "xyes")
3557then
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003558 AC_MSG_CHECKING([for uintXX_t types in stdint.h])
Tim Rice648f8762011-01-26 12:38:57 -08003559 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdint.h> ]],
3560 [[ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;]])],
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003561 [
Tim Rice648f8762011-01-26 12:38:57 -08003562 AC_DEFINE([HAVE_UINTXX_T])
3563 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003564 ], [ AC_MSG_RESULT([no])
Tim Rice648f8762011-01-26 12:38:57 -08003565 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003566fi
3567
Damien Millerc2868192014-01-30 10:21:19 +11003568if (test -z "$have_uintxx_t" && \
3569 test "x$ac_cv_header_inttypes_h" = "xyes")
3570then
Darren Tucker6d725682014-01-17 19:17:34 +11003571 AC_MSG_CHECKING([for uintXX_t types in inttypes.h])
3572 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <inttypes.h> ]],
3573 [[ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;]])],
3574 [
3575 AC_DEFINE([HAVE_UINTXX_T])
3576 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003577 ], [ AC_MSG_RESULT([no])
Darren Tucker6d725682014-01-17 19:17:34 +11003578 ])
3579fi
3580
Damien Milleredb82922000-06-20 13:25:52 +10003581if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
Damien Millera8e06ce2003-11-21 23:48:55 +11003582 test "x$ac_cv_header_sys_bitypes_h" = "xyes")
Damien Millerb29ea912000-01-15 14:12:03 +11003583then
3584 AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
Tim Rice648f8762011-01-26 12:38:57 -08003585 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller61e50f12000-05-08 20:49:37 +10003586#include <sys/bitypes.h>
Tim Rice648f8762011-01-26 12:38:57 -08003587 ]], [[
Damien Miller70494d12000-04-03 15:57:06 +10003588 int8_t a; int16_t b; int32_t c;
3589 u_int8_t e; u_int16_t f; u_int32_t g;
3590 a = b = c = e = f = g = 1;
Tim Rice648f8762011-01-26 12:38:57 -08003591 ]])],
Damien Millerb29ea912000-01-15 14:12:03 +11003592 [
Tim Rice648f8762011-01-26 12:38:57 -08003593 AC_DEFINE([HAVE_U_INTXX_T])
3594 AC_DEFINE([HAVE_INTXX_T])
3595 AC_MSG_RESULT([yes])
3596 ], [AC_MSG_RESULT([no])
3597 ])
Damien Millerb29ea912000-01-15 14:12:03 +11003598fi
3599
Damien Miller58be7382001-09-15 21:31:54 +10003600
3601AC_CACHE_CHECK([for u_char], ac_cv_have_u_char, [
Tim Rice648f8762011-01-26 12:38:57 -08003602 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3603 [[ u_char foo; foo = 125; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003604 [ ac_cv_have_u_char="yes" ], [ ac_cv_have_u_char="no"
Tim Rice648f8762011-01-26 12:38:57 -08003605 ])
Damien Miller58be7382001-09-15 21:31:54 +10003606])
3607if test "x$ac_cv_have_u_char" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003608 AC_DEFINE([HAVE_U_CHAR], [1], [define if you have u_char data type])
Damien Miller58be7382001-09-15 21:31:54 +10003609fi
3610
Darren Tucker007e3b32013-11-03 18:43:55 +11003611AC_CHECK_TYPES([intmax_t, uintmax_t], , , [
3612#include <sys/types.h>
3613#include <stdint.h>
3614])
3615
Tim Rice13aae5e2001-10-21 17:53:58 -07003616TYPE_SOCKLEN_T
Damien Miller74d0d4a1999-12-29 02:24:35 +11003617
Tim Rice648f8762011-01-26 12:38:57 -08003618AC_CHECK_TYPES([sig_atomic_t], , , [#include <signal.h>])
3619AC_CHECK_TYPES([fsblkcnt_t, fsfilcnt_t], , , [
Darren Tucker598eaa62008-06-09 03:32:29 +10003620#include <sys/types.h>
3621#ifdef HAVE_SYS_BITYPES_H
3622#include <sys/bitypes.h>
3623#endif
3624#ifdef HAVE_SYS_STATFS_H
3625#include <sys/statfs.h>
3626#endif
3627#ifdef HAVE_SYS_STATVFS_H
3628#include <sys/statvfs.h>
3629#endif
3630])
Tim Rice4cec93f2002-02-26 08:40:48 -08003631
Tim Rice648f8762011-01-26 12:38:57 -08003632AC_CHECK_TYPES([in_addr_t, in_port_t], , ,
Damien Miller848b9932005-02-24 12:12:34 +11003633[#include <sys/types.h>
3634#include <netinet/in.h>])
Darren Tuckerd9f88912005-02-20 21:01:48 +11003635
Damien Miller61e50f12000-05-08 20:49:37 +10003636AC_CACHE_CHECK([for size_t], ac_cv_have_size_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003637 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3638 [[ size_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003639 [ ac_cv_have_size_t="yes" ], [ ac_cv_have_size_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003640 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003641])
3642if test "x$ac_cv_have_size_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003643 AC_DEFINE([HAVE_SIZE_T], [1], [define if you have size_t data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003644fi
Damien Miller95058511999-12-29 10:36:45 +11003645
Damien Miller615f9392000-05-17 22:53:33 +10003646AC_CACHE_CHECK([for ssize_t], ac_cv_have_ssize_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003647 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3648 [[ ssize_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003649 [ ac_cv_have_ssize_t="yes" ], [ ac_cv_have_ssize_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003650 ])
Damien Miller615f9392000-05-17 22:53:33 +10003651])
3652if test "x$ac_cv_have_ssize_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003653 AC_DEFINE([HAVE_SSIZE_T], [1], [define if you have ssize_t data type])
Damien Miller615f9392000-05-17 22:53:33 +10003654fi
3655
Ben Lindstrom0d5af602001-01-09 00:50:29 +00003656AC_CACHE_CHECK([for clock_t], ac_cv_have_clock_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003657 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <time.h> ]],
3658 [[ clock_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003659 [ ac_cv_have_clock_t="yes" ], [ ac_cv_have_clock_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003660 ])
Ben Lindstrom0d5af602001-01-09 00:50:29 +00003661])
3662if test "x$ac_cv_have_clock_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003663 AC_DEFINE([HAVE_CLOCK_T], [1], [define if you have clock_t data type])
Ben Lindstrom0d5af602001-01-09 00:50:29 +00003664fi
3665
Damien Millerb54b40e2000-06-23 08:23:34 +10003666AC_CACHE_CHECK([for sa_family_t], ac_cv_have_sa_family_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003667 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Millerb54b40e2000-06-23 08:23:34 +10003668#include <sys/types.h>
3669#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08003670 ]], [[ sa_family_t foo; foo = 1235; ]])],
3671 [ ac_cv_have_sa_family_t="yes" ],
3672 [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller78315eb2000-09-29 23:01:36 +11003673#include <sys/types.h>
3674#include <sys/socket.h>
3675#include <netinet/in.h>
Tim Rice648f8762011-01-26 12:38:57 -08003676 ]], [[ sa_family_t foo; foo = 1235; ]])],
Damien Miller78315eb2000-09-29 23:01:36 +11003677 [ ac_cv_have_sa_family_t="yes" ],
Damien Millerb54b40e2000-06-23 08:23:34 +10003678 [ ac_cv_have_sa_family_t="no" ]
3679 )
Tim Rice648f8762011-01-26 12:38:57 -08003680 ])
Damien Millerb54b40e2000-06-23 08:23:34 +10003681])
3682if test "x$ac_cv_have_sa_family_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003683 AC_DEFINE([HAVE_SA_FAMILY_T], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003684 [define if you have sa_family_t data type])
Damien Millerb54b40e2000-06-23 08:23:34 +10003685fi
3686
Damien Miller0f91b4e2000-06-18 15:43:25 +10003687AC_CACHE_CHECK([for pid_t], ac_cv_have_pid_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003688 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3689 [[ pid_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003690 [ ac_cv_have_pid_t="yes" ], [ ac_cv_have_pid_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003691 ])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003692])
3693if test "x$ac_cv_have_pid_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003694 AC_DEFINE([HAVE_PID_T], [1], [define if you have pid_t data type])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003695fi
3696
3697AC_CACHE_CHECK([for mode_t], ac_cv_have_mode_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003698 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3699 [[ mode_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003700 [ ac_cv_have_mode_t="yes" ], [ ac_cv_have_mode_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003701 ])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003702])
3703if test "x$ac_cv_have_mode_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003704 AC_DEFINE([HAVE_MODE_T], [1], [define if you have mode_t data type])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003705fi
3706
Damien Miller61e50f12000-05-08 20:49:37 +10003707
3708AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_have_struct_sockaddr_storage, [
Tim Rice648f8762011-01-26 12:38:57 -08003709 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10003710#include <sys/types.h>
3711#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08003712 ]], [[ struct sockaddr_storage s; ]])],
3713 [ ac_cv_have_struct_sockaddr_storage="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003714 [ ac_cv_have_struct_sockaddr_storage="no"
Tim Rice648f8762011-01-26 12:38:57 -08003715 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003716])
3717if test "x$ac_cv_have_struct_sockaddr_storage" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003718 AC_DEFINE([HAVE_STRUCT_SOCKADDR_STORAGE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003719 [define if you have struct sockaddr_storage data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003720fi
Damien Miller34132e52000-01-14 15:45:46 +11003721
Damien Miller61e50f12000-05-08 20:49:37 +10003722AC_CACHE_CHECK([for struct sockaddr_in6], ac_cv_have_struct_sockaddr_in6, [
Tim Rice648f8762011-01-26 12:38:57 -08003723 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller7b22d652000-06-18 14:07:04 +10003724#include <sys/types.h>
Damien Miller61e50f12000-05-08 20:49:37 +10003725#include <netinet/in.h>
Tim Rice648f8762011-01-26 12:38:57 -08003726 ]], [[ struct sockaddr_in6 s; s.sin6_family = 0; ]])],
3727 [ ac_cv_have_struct_sockaddr_in6="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003728 [ ac_cv_have_struct_sockaddr_in6="no"
Tim Rice648f8762011-01-26 12:38:57 -08003729 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003730])
3731if test "x$ac_cv_have_struct_sockaddr_in6" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003732 AC_DEFINE([HAVE_STRUCT_SOCKADDR_IN6], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003733 [define if you have struct sockaddr_in6 data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003734fi
Damien Miller34132e52000-01-14 15:45:46 +11003735
Damien Miller61e50f12000-05-08 20:49:37 +10003736AC_CACHE_CHECK([for struct in6_addr], ac_cv_have_struct_in6_addr, [
Tim Rice648f8762011-01-26 12:38:57 -08003737 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller7b22d652000-06-18 14:07:04 +10003738#include <sys/types.h>
Damien Miller61e50f12000-05-08 20:49:37 +10003739#include <netinet/in.h>
Tim Rice648f8762011-01-26 12:38:57 -08003740 ]], [[ struct in6_addr s; s.s6_addr[0] = 0; ]])],
3741 [ ac_cv_have_struct_in6_addr="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003742 [ ac_cv_have_struct_in6_addr="no"
Tim Rice648f8762011-01-26 12:38:57 -08003743 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003744])
3745if test "x$ac_cv_have_struct_in6_addr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003746 AC_DEFINE([HAVE_STRUCT_IN6_ADDR], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003747 [define if you have struct in6_addr data type])
Tim Rice0f4d2c02008-11-18 21:26:41 -08003748
3749dnl Now check for sin6_scope_id
Tim Rice648f8762011-01-26 12:38:57 -08003750 AC_CHECK_MEMBERS([struct sockaddr_in6.sin6_scope_id], , ,
Tim Rice0f4d2c02008-11-18 21:26:41 -08003751 [
3752#ifdef HAVE_SYS_TYPES_H
3753#include <sys/types.h>
3754#endif
3755#include <netinet/in.h>
3756 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003757fi
Damien Miller34132e52000-01-14 15:45:46 +11003758
Damien Miller61e50f12000-05-08 20:49:37 +10003759AC_CACHE_CHECK([for struct addrinfo], ac_cv_have_struct_addrinfo, [
Tim Rice648f8762011-01-26 12:38:57 -08003760 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10003761#include <sys/types.h>
3762#include <sys/socket.h>
3763#include <netdb.h>
Tim Rice648f8762011-01-26 12:38:57 -08003764 ]], [[ struct addrinfo s; s.ai_flags = AI_PASSIVE; ]])],
3765 [ ac_cv_have_struct_addrinfo="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003766 [ ac_cv_have_struct_addrinfo="no"
Tim Rice648f8762011-01-26 12:38:57 -08003767 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003768])
3769if test "x$ac_cv_have_struct_addrinfo" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003770 AC_DEFINE([HAVE_STRUCT_ADDRINFO], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003771 [define if you have struct addrinfo data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003772fi
3773
Ben Lindstrom42202bc2001-01-15 02:34:37 +00003774AC_CACHE_CHECK([for struct timeval], ac_cv_have_struct_timeval, [
Tim Rice648f8762011-01-26 12:38:57 -08003775 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/time.h> ]],
3776 [[ struct timeval tv; tv.tv_sec = 1;]])],
3777 [ ac_cv_have_struct_timeval="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003778 [ ac_cv_have_struct_timeval="no"
Tim Rice648f8762011-01-26 12:38:57 -08003779 ])
Ben Lindstrom42202bc2001-01-15 02:34:37 +00003780])
3781if test "x$ac_cv_have_struct_timeval" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003782 AC_DEFINE([HAVE_STRUCT_TIMEVAL], [1], [define if you have struct timeval])
Ben Lindstrom42202bc2001-01-15 02:34:37 +00003783 have_struct_timeval=1
3784fi
3785
Tim Rice648f8762011-01-26 12:38:57 -08003786AC_CHECK_TYPES([struct timespec])
Tim Rice4e4dc562003-03-18 10:21:40 -08003787
Ben Lindstrom5bd6eb72003-03-21 00:34:34 +00003788# We need int64_t or else certian parts of the compile will fail.
Tim Rice8bb561b2005-03-17 16:23:19 -08003789if test "x$ac_cv_have_int64_t" = "xno" && \
3790 test "x$ac_cv_sizeof_long_int" != "x8" && \
3791 test "x$ac_cv_sizeof_long_long_int" = "x0" ; then
Ben Lindstrom5bd6eb72003-03-21 00:34:34 +00003792 echo "OpenSSH requires int64_t support. Contact your vendor or install"
3793 echo "an alternative compiler (I.E., GCC) before continuing."
3794 echo ""
3795 exit 1;
Tim Ricebee3f222001-03-11 17:32:12 -08003796else
3797dnl test snprintf (broken on SCO w/gcc)
Darren Tuckera0c2b392004-09-11 23:26:37 +10003798 AC_RUN_IFELSE(
Darren Tucker623d92f2004-09-12 22:36:15 +10003799 [AC_LANG_SOURCE([[
Tim Ricebee3f222001-03-11 17:32:12 -08003800#include <stdio.h>
3801#include <string.h>
3802#ifdef HAVE_SNPRINTF
3803main()
3804{
3805 char buf[50];
3806 char expected_out[50];
3807 int mazsize = 50 ;
3808#if (SIZEOF_LONG_INT == 8)
3809 long int num = 0x7fffffffffffffff;
3810#else
Kevin Steves6482ec82001-07-15 02:09:28 +00003811 long long num = 0x7fffffffffffffffll;
Tim Ricebee3f222001-03-11 17:32:12 -08003812#endif
3813 strcpy(expected_out, "9223372036854775807");
3814 snprintf(buf, mazsize, "%lld", num);
3815 if(strcmp(buf, expected_out) != 0)
Damien Millera8e06ce2003-11-21 23:48:55 +11003816 exit(1);
Tim Ricebee3f222001-03-11 17:32:12 -08003817 exit(0);
3818}
3819#else
3820main() { exit(0); }
3821#endif
Tim Rice648f8762011-01-26 12:38:57 -08003822 ]])], [ true ], [ AC_DEFINE([BROKEN_SNPRINTF]) ],
Darren Tuckera0c2b392004-09-11 23:26:37 +10003823 AC_MSG_WARN([cross compiling: Assuming working snprintf()])
Tim Ricebee3f222001-03-11 17:32:12 -08003824 )
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00003825fi
3826
Damien Miller78315eb2000-09-29 23:01:36 +11003827dnl Checks for structure members
Tim Rice648f8762011-01-26 12:38:57 -08003828OSSH_CHECK_HEADER_FOR_FIELD([ut_host], [utmp.h], [HAVE_HOST_IN_UTMP])
3829OSSH_CHECK_HEADER_FOR_FIELD([ut_host], [utmpx.h], [HAVE_HOST_IN_UTMPX])
3830OSSH_CHECK_HEADER_FOR_FIELD([syslen], [utmpx.h], [HAVE_SYSLEN_IN_UTMPX])
3831OSSH_CHECK_HEADER_FOR_FIELD([ut_pid], [utmp.h], [HAVE_PID_IN_UTMP])
3832OSSH_CHECK_HEADER_FOR_FIELD([ut_type], [utmp.h], [HAVE_TYPE_IN_UTMP])
3833OSSH_CHECK_HEADER_FOR_FIELD([ut_type], [utmpx.h], [HAVE_TYPE_IN_UTMPX])
3834OSSH_CHECK_HEADER_FOR_FIELD([ut_tv], [utmp.h], [HAVE_TV_IN_UTMP])
3835OSSH_CHECK_HEADER_FOR_FIELD([ut_id], [utmp.h], [HAVE_ID_IN_UTMP])
3836OSSH_CHECK_HEADER_FOR_FIELD([ut_id], [utmpx.h], [HAVE_ID_IN_UTMPX])
3837OSSH_CHECK_HEADER_FOR_FIELD([ut_addr], [utmp.h], [HAVE_ADDR_IN_UTMP])
3838OSSH_CHECK_HEADER_FOR_FIELD([ut_addr], [utmpx.h], [HAVE_ADDR_IN_UTMPX])
3839OSSH_CHECK_HEADER_FOR_FIELD([ut_addr_v6], [utmp.h], [HAVE_ADDR_V6_IN_UTMP])
3840OSSH_CHECK_HEADER_FOR_FIELD([ut_addr_v6], [utmpx.h], [HAVE_ADDR_V6_IN_UTMPX])
3841OSSH_CHECK_HEADER_FOR_FIELD([ut_exit], [utmp.h], [HAVE_EXIT_IN_UTMP])
3842OSSH_CHECK_HEADER_FOR_FIELD([ut_time], [utmp.h], [HAVE_TIME_IN_UTMP])
3843OSSH_CHECK_HEADER_FOR_FIELD([ut_time], [utmpx.h], [HAVE_TIME_IN_UTMPX])
3844OSSH_CHECK_HEADER_FOR_FIELD([ut_tv], [utmpx.h], [HAVE_TV_IN_UTMPX])
Tim Rice13aae5e2001-10-21 17:53:58 -07003845
3846AC_CHECK_MEMBERS([struct stat.st_blksize])
Damien Miller6332da22013-04-23 14:25:52 +10003847AC_CHECK_MEMBERS([struct passwd.pw_gecos, struct passwd.pw_class,
3848struct passwd.pw_change, struct passwd.pw_expire],
3849[], [], [[
3850#include <sys/types.h>
3851#include <pwd.h>
3852]])
3853
Tim Rice648f8762011-01-26 12:38:57 -08003854AC_CHECK_MEMBER([struct __res_state.retrans], [], [AC_DEFINE([__res_state], [state],
Darren Tucker58e298d2005-11-25 13:14:58 +11003855 [Define if we don't have struct __res_state in resolv.h])],
Damien Miller6332da22013-04-23 14:25:52 +10003856[[
Darren Tucker58e298d2005-11-25 13:14:58 +11003857#include <stdio.h>
3858#if HAVE_SYS_TYPES_H
3859# include <sys/types.h>
3860#endif
3861#include <netinet/in.h>
3862#include <arpa/nameser.h>
3863#include <resolv.h>
Damien Miller6332da22013-04-23 14:25:52 +10003864]])
andre2ff7b5d2000-06-03 14:57:40 +00003865
Damien Miller61e50f12000-05-08 20:49:37 +10003866AC_CACHE_CHECK([for ss_family field in struct sockaddr_storage],
3867 ac_cv_have_ss_family_in_struct_ss, [
Tim Rice648f8762011-01-26 12:38:57 -08003868 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10003869#include <sys/types.h>
3870#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08003871 ]], [[ struct sockaddr_storage s; s.ss_family = 1; ]])],
3872 [ ac_cv_have_ss_family_in_struct_ss="yes" ],
3873 [ ac_cv_have_ss_family_in_struct_ss="no" ])
Damien Miller61e50f12000-05-08 20:49:37 +10003874])
3875if test "x$ac_cv_have_ss_family_in_struct_ss" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003876 AC_DEFINE([HAVE_SS_FAMILY_IN_SS], [1], [Fields in struct sockaddr_storage])
Damien Miller61e50f12000-05-08 20:49:37 +10003877fi
3878
Damien Miller61e50f12000-05-08 20:49:37 +10003879AC_CACHE_CHECK([for __ss_family field in struct sockaddr_storage],
3880 ac_cv_have___ss_family_in_struct_ss, [
Tim Rice648f8762011-01-26 12:38:57 -08003881 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10003882#include <sys/types.h>
3883#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08003884 ]], [[ struct sockaddr_storage s; s.__ss_family = 1; ]])],
3885 [ ac_cv_have___ss_family_in_struct_ss="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003886 [ ac_cv_have___ss_family_in_struct_ss="no"
Tim Rice648f8762011-01-26 12:38:57 -08003887 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003888])
3889if test "x$ac_cv_have___ss_family_in_struct_ss" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003890 AC_DEFINE([HAVE___SS_FAMILY_IN_SS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003891 [Fields in struct sockaddr_storage])
Damien Miller61e50f12000-05-08 20:49:37 +10003892fi
Damien Millerbf1c9b21999-12-09 10:16:54 +11003893
Tim Rice28bbb0c2002-05-27 17:37:32 -07003894dnl make sure we're using the real structure members and not defines
Kevin Steves939c9db2002-03-22 17:23:25 +00003895AC_CACHE_CHECK([for msg_accrights field in struct msghdr],
3896 ac_cv_have_accrights_in_msghdr, [
Tim Rice648f8762011-01-26 12:38:57 -08003897 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Tim Riceae49fe62002-04-12 10:26:21 -07003898#include <sys/types.h>
Kevin Steves939c9db2002-03-22 17:23:25 +00003899#include <sys/socket.h>
3900#include <sys/uio.h>
Tim Rice648f8762011-01-26 12:38:57 -08003901 ]], [[
Tim Rice28bbb0c2002-05-27 17:37:32 -07003902#ifdef msg_accrights
Darren Tuckera0c2b392004-09-11 23:26:37 +10003903#error "msg_accrights is a macro"
Tim Rice28bbb0c2002-05-27 17:37:32 -07003904exit(1);
3905#endif
3906struct msghdr m;
3907m.msg_accrights = 0;
3908exit(0);
Tim Rice648f8762011-01-26 12:38:57 -08003909 ]])],
Kevin Steves939c9db2002-03-22 17:23:25 +00003910 [ ac_cv_have_accrights_in_msghdr="yes" ],
3911 [ ac_cv_have_accrights_in_msghdr="no" ]
3912 )
3913])
3914if test "x$ac_cv_have_accrights_in_msghdr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003915 AC_DEFINE([HAVE_ACCRIGHTS_IN_MSGHDR], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003916 [Define if your system uses access rights style
3917 file descriptor passing])
Kevin Steves939c9db2002-03-22 17:23:25 +00003918fi
3919
Tim Rice648f8762011-01-26 12:38:57 -08003920AC_MSG_CHECKING([if struct statvfs.f_fsid is integral type])
3921AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckere1a3ddf2012-05-04 11:05:45 +10003922#include <sys/param.h>
Darren Tucker32780622009-06-16 16:11:02 +10003923#include <sys/stat.h>
3924#ifdef HAVE_SYS_TIME_H
3925# include <sys/time.h>
3926#endif
3927#ifdef HAVE_SYS_MOUNT_H
3928#include <sys/mount.h>
3929#endif
3930#ifdef HAVE_SYS_STATVFS_H
3931#include <sys/statvfs.h>
3932#endif
Tim Rice648f8762011-01-26 12:38:57 -08003933 ]], [[ struct statvfs s; s.f_fsid = 0; ]])],
3934 [ AC_MSG_RESULT([yes]) ],
3935 [ AC_MSG_RESULT([no])
Darren Tucker32780622009-06-16 16:11:02 +10003936
Tim Rice648f8762011-01-26 12:38:57 -08003937 AC_MSG_CHECKING([if fsid_t has member val])
3938 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker32780622009-06-16 16:11:02 +10003939#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08003940#include <sys/statvfs.h>
3941 ]], [[ fsid_t t; t.val[0] = 0; ]])],
3942 [ AC_MSG_RESULT([yes])
3943 AC_DEFINE([FSID_HAS_VAL], [1], [fsid_t has member val]) ],
3944 [ AC_MSG_RESULT([no]) ])
Darren Tucker32780622009-06-16 16:11:02 +10003945
Tim Rice648f8762011-01-26 12:38:57 -08003946 AC_MSG_CHECKING([if f_fsid has member __val])
3947 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker32780622009-06-16 16:11:02 +10003948#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08003949#include <sys/statvfs.h>
3950 ]], [[ fsid_t t; t.__val[0] = 0; ]])],
3951 [ AC_MSG_RESULT([yes])
3952 AC_DEFINE([FSID_HAS___VAL], [1], [fsid_t has member __val]) ],
3953 [ AC_MSG_RESULT([no]) ])
Darren Tucker32780622009-06-16 16:11:02 +10003954])
Darren Tucker77001382008-06-09 06:17:53 +10003955
Kevin Stevesa44e0352002-04-07 16:18:03 +00003956AC_CACHE_CHECK([for msg_control field in struct msghdr],
3957 ac_cv_have_control_in_msghdr, [
Tim Rice648f8762011-01-26 12:38:57 -08003958 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Tim Riceae49fe62002-04-12 10:26:21 -07003959#include <sys/types.h>
Kevin Stevesa44e0352002-04-07 16:18:03 +00003960#include <sys/socket.h>
3961#include <sys/uio.h>
Tim Rice648f8762011-01-26 12:38:57 -08003962 ]], [[
Tim Rice28bbb0c2002-05-27 17:37:32 -07003963#ifdef msg_control
Darren Tuckera0c2b392004-09-11 23:26:37 +10003964#error "msg_control is a macro"
Tim Rice28bbb0c2002-05-27 17:37:32 -07003965exit(1);
3966#endif
3967struct msghdr m;
3968m.msg_control = 0;
3969exit(0);
Tim Rice648f8762011-01-26 12:38:57 -08003970 ]])],
Kevin Stevesa44e0352002-04-07 16:18:03 +00003971 [ ac_cv_have_control_in_msghdr="yes" ],
3972 [ ac_cv_have_control_in_msghdr="no" ]
3973 )
3974])
3975if test "x$ac_cv_have_control_in_msghdr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003976 AC_DEFINE([HAVE_CONTROL_IN_MSGHDR], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003977 [Define if your system uses ancillary data style
3978 file descriptor passing])
Kevin Stevesa44e0352002-04-07 16:18:03 +00003979fi
3980
Damien Miller61e50f12000-05-08 20:49:37 +10003981AC_CACHE_CHECK([if libc defines __progname], ac_cv_libc_defines___progname, [
Tim Rice648f8762011-01-26 12:38:57 -08003982 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
3983 [[ extern char *__progname; printf("%s", __progname); ]])],
3984 [ ac_cv_libc_defines___progname="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003985 [ ac_cv_libc_defines___progname="no"
Tim Rice648f8762011-01-26 12:38:57 -08003986 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003987])
3988if test "x$ac_cv_libc_defines___progname" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003989 AC_DEFINE([HAVE___PROGNAME], [1], [Define if libc defines __progname])
Damien Miller61e50f12000-05-08 20:49:37 +10003990fi
3991
Kevin Steves4846f4a2002-03-22 18:19:53 +00003992AC_CACHE_CHECK([whether $CC implements __FUNCTION__], ac_cv_cc_implements___FUNCTION__, [
Tim Rice648f8762011-01-26 12:38:57 -08003993 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]],
3994 [[ printf("%s", __FUNCTION__); ]])],
3995 [ ac_cv_cc_implements___FUNCTION__="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003996 [ ac_cv_cc_implements___FUNCTION__="no"
Tim Rice648f8762011-01-26 12:38:57 -08003997 ])
Kevin Steves4846f4a2002-03-22 18:19:53 +00003998])
3999if test "x$ac_cv_cc_implements___FUNCTION__" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004000 AC_DEFINE([HAVE___FUNCTION__], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004001 [Define if compiler implements __FUNCTION__])
Kevin Steves4846f4a2002-03-22 18:19:53 +00004002fi
4003
4004AC_CACHE_CHECK([whether $CC implements __func__], ac_cv_cc_implements___func__, [
Tim Rice648f8762011-01-26 12:38:57 -08004005 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]],
4006 [[ printf("%s", __func__); ]])],
4007 [ ac_cv_cc_implements___func__="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004008 [ ac_cv_cc_implements___func__="no"
Tim Rice648f8762011-01-26 12:38:57 -08004009 ])
Kevin Steves4846f4a2002-03-22 18:19:53 +00004010])
4011if test "x$ac_cv_cc_implements___func__" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004012 AC_DEFINE([HAVE___func__], [1], [Define if compiler implements __func__])
Kevin Steves4846f4a2002-03-22 18:19:53 +00004013fi
4014
Damien Miller57f39152005-11-24 19:58:19 +11004015AC_CACHE_CHECK([whether va_copy exists], ac_cv_have_va_copy, [
Tim Rice648f8762011-01-26 12:38:57 -08004016 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4017#include <stdarg.h>
4018va_list x,y;
4019 ]], [[ va_copy(x,y); ]])],
4020 [ ac_cv_have_va_copy="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004021 [ ac_cv_have_va_copy="no"
Tim Rice648f8762011-01-26 12:38:57 -08004022 ])
Damien Miller57f39152005-11-24 19:58:19 +11004023])
4024if test "x$ac_cv_have_va_copy" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004025 AC_DEFINE([HAVE_VA_COPY], [1], [Define if va_copy exists])
Damien Miller57f39152005-11-24 19:58:19 +11004026fi
4027
4028AC_CACHE_CHECK([whether __va_copy exists], ac_cv_have___va_copy, [
Tim Rice648f8762011-01-26 12:38:57 -08004029 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4030#include <stdarg.h>
4031va_list x,y;
4032 ]], [[ __va_copy(x,y); ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07004033 [ ac_cv_have___va_copy="yes" ], [ ac_cv_have___va_copy="no"
Tim Rice648f8762011-01-26 12:38:57 -08004034 ])
Damien Miller57f39152005-11-24 19:58:19 +11004035])
4036if test "x$ac_cv_have___va_copy" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004037 AC_DEFINE([HAVE___VA_COPY], [1], [Define if __va_copy exists])
Damien Miller57f39152005-11-24 19:58:19 +11004038fi
4039
Damien Miller4f8e6692001-07-14 13:22:53 +10004040AC_CACHE_CHECK([whether getopt has optreset support],
4041 ac_cv_have_getopt_optreset, [
Tim Rice648f8762011-01-26 12:38:57 -08004042 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <getopt.h> ]],
4043 [[ extern int optreset; optreset = 0; ]])],
4044 [ ac_cv_have_getopt_optreset="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004045 [ ac_cv_have_getopt_optreset="no"
Tim Rice648f8762011-01-26 12:38:57 -08004046 ])
Damien Miller4f8e6692001-07-14 13:22:53 +10004047])
4048if test "x$ac_cv_have_getopt_optreset" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004049 AC_DEFINE([HAVE_GETOPT_OPTRESET], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004050 [Define if your getopt(3) defines and uses optreset])
Damien Miller4f8e6692001-07-14 13:22:53 +10004051fi
Damien Millera22ba012000-03-02 23:09:20 +11004052
Damien Millerecbb26d2000-07-15 14:59:14 +10004053AC_CACHE_CHECK([if libc defines sys_errlist], ac_cv_libc_defines_sys_errlist, [
Tim Rice648f8762011-01-26 12:38:57 -08004054 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
4055[[ extern const char *const sys_errlist[]; printf("%s", sys_errlist[0]);]])],
4056 [ ac_cv_libc_defines_sys_errlist="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004057 [ ac_cv_libc_defines_sys_errlist="no"
Tim Rice648f8762011-01-26 12:38:57 -08004058 ])
Damien Millerecbb26d2000-07-15 14:59:14 +10004059])
4060if test "x$ac_cv_libc_defines_sys_errlist" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004061 AC_DEFINE([HAVE_SYS_ERRLIST], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004062 [Define if your system defines sys_errlist[]])
Damien Millerecbb26d2000-07-15 14:59:14 +10004063fi
4064
4065
Damien Miller11fa2cc2000-08-16 10:35:58 +10004066AC_CACHE_CHECK([if libc defines sys_nerr], ac_cv_libc_defines_sys_nerr, [
Tim Rice648f8762011-01-26 12:38:57 -08004067 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
4068[[ extern int sys_nerr; printf("%i", sys_nerr);]])],
4069 [ ac_cv_libc_defines_sys_nerr="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004070 [ ac_cv_libc_defines_sys_nerr="no"
Tim Rice648f8762011-01-26 12:38:57 -08004071 ])
Damien Miller11fa2cc2000-08-16 10:35:58 +10004072])
4073if test "x$ac_cv_libc_defines_sys_nerr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004074 AC_DEFINE([HAVE_SYS_NERR], [1], [Define if your system defines sys_nerr])
Damien Miller11fa2cc2000-08-16 10:35:58 +10004075fi
4076
Darren Tucker5f88d342003-10-15 16:57:57 +10004077# Check libraries needed by DNS fingerprint support
Tim Rice648f8762011-01-26 12:38:57 -08004078AC_SEARCH_LIBS([getrrsetbyname], [resolv],
4079 [AC_DEFINE([HAVE_GETRRSETBYNAME], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004080 [Define if getrrsetbyname() exists])],
Damien Miller7abe09b2003-05-15 10:53:49 +10004081 [
Darren Tucker5f88d342003-10-15 16:57:57 +10004082 # Needed by our getrrsetbyname()
Tim Rice648f8762011-01-26 12:38:57 -08004083 AC_SEARCH_LIBS([res_query], [resolv])
4084 AC_SEARCH_LIBS([dn_expand], [resolv])
4085 AC_MSG_CHECKING([if res_query will link])
4086 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckere02b49a2009-09-11 14:56:08 +10004087#include <sys/types.h>
4088#include <netinet/in.h>
4089#include <arpa/nameser.h>
4090#include <netdb.h>
4091#include <resolv.h>
Tim Rice648f8762011-01-26 12:38:57 -08004092 ]], [[
Darren Tuckere02b49a2009-09-11 14:56:08 +10004093 res_query (0, 0, 0, 0, 0);
Tim Rice648f8762011-01-26 12:38:57 -08004094 ]])],
4095 AC_MSG_RESULT([yes]),
4096 [AC_MSG_RESULT([no])
Darren Tucker8e968a52004-05-13 11:56:16 +10004097 saved_LIBS="$LIBS"
4098 LIBS="$LIBS -lresolv"
Tim Rice648f8762011-01-26 12:38:57 -08004099 AC_MSG_CHECKING([for res_query in -lresolv])
4100 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckere02b49a2009-09-11 14:56:08 +10004101#include <sys/types.h>
4102#include <netinet/in.h>
4103#include <arpa/nameser.h>
4104#include <netdb.h>
Darren Tucker8e968a52004-05-13 11:56:16 +10004105#include <resolv.h>
Tim Rice648f8762011-01-26 12:38:57 -08004106 ]], [[
Darren Tucker8e968a52004-05-13 11:56:16 +10004107 res_query (0, 0, 0, 0, 0);
Tim Rice648f8762011-01-26 12:38:57 -08004108 ]])],
4109 [AC_MSG_RESULT([yes])],
Darren Tucker8e968a52004-05-13 11:56:16 +10004110 [LIBS="$saved_LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08004111 AC_MSG_RESULT([no])])
Darren Tucker8e968a52004-05-13 11:56:16 +10004112 ])
Tim Rice648f8762011-01-26 12:38:57 -08004113 AC_CHECK_FUNCS([_getshort _getlong])
Darren Tuckerd886e1c2005-06-01 18:57:45 +10004114 AC_CHECK_DECLS([_getshort, _getlong], , ,
Tim Ricefcc7ff12005-06-02 20:28:29 -07004115 [#include <sys/types.h>
4116 #include <arpa/nameser.h>])
Tim Rice648f8762011-01-26 12:38:57 -08004117 AC_CHECK_MEMBER([HEADER.ad],
4118 [AC_DEFINE([HAVE_HEADER_AD], [1],
4119 [Define if HEADER.ad exists in arpa/nameser.h])], ,
Darren Tucker5f88d342003-10-15 16:57:57 +10004120 [#include <arpa/nameser.h>])
4121 ])
Damien Miller7abe09b2003-05-15 10:53:49 +10004122
Tim Rice648f8762011-01-26 12:38:57 -08004123AC_MSG_CHECKING([if struct __res_state _res is an extern])
4124AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckercc40d5e2007-04-29 13:58:06 +10004125#include <stdio.h>
4126#if HAVE_SYS_TYPES_H
4127# include <sys/types.h>
4128#endif
4129#include <netinet/in.h>
4130#include <arpa/nameser.h>
4131#include <resolv.h>
4132extern struct __res_state _res;
Darren Tucker7ad8b282015-09-11 13:11:02 +10004133 ]], [[
4134struct __res_state *volatile p = &_res; /* force resolution of _res */
4135return 0;
4136 ]],)],
Tim Rice648f8762011-01-26 12:38:57 -08004137 [AC_MSG_RESULT([yes])
4138 AC_DEFINE([HAVE__RES_EXTERN], [1],
Darren Tuckercc40d5e2007-04-29 13:58:06 +10004139 [Define if you have struct __res_state _res as an extern])
4140 ],
Tim Rice648f8762011-01-26 12:38:57 -08004141 [ AC_MSG_RESULT([no]) ]
Darren Tuckercc40d5e2007-04-29 13:58:06 +10004142)
4143
Damien Miller73b42d22006-04-22 21:26:08 +10004144# Check whether user wants SELinux support
4145SELINUX_MSG="no"
4146LIBSELINUX=""
Tim Rice648f8762011-01-26 12:38:57 -08004147AC_ARG_WITH([selinux],
Damien Miller5b1c8b32008-03-27 12:33:07 +11004148 [ --with-selinux Enable SELinux support],
Damien Miller73b42d22006-04-22 21:26:08 +10004149 [ if test "x$withval" != "xno" ; then
Darren Tucker20e9f972007-03-25 18:26:01 +10004150 save_LIBS="$LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08004151 AC_DEFINE([WITH_SELINUX], [1],
4152 [Define if you want SELinux support.])
Damien Miller73b42d22006-04-22 21:26:08 +10004153 SELINUX_MSG="yes"
4154 AC_CHECK_HEADER([selinux/selinux.h], ,
Tim Rice648f8762011-01-26 12:38:57 -08004155 AC_MSG_ERROR([SELinux support requires selinux.h header]))
4156 AC_CHECK_LIB([selinux], [setexeccon],
Damien Miller1d2bfc42010-02-10 10:19:29 +11004157 [ LIBSELINUX="-lselinux"
4158 LIBS="$LIBS -lselinux"
4159 ],
Tim Rice648f8762011-01-26 12:38:57 -08004160 AC_MSG_ERROR([SELinux support requires libselinux library]))
Damien Miller71adf122011-01-25 12:16:15 +11004161 SSHLIBS="$SSHLIBS $LIBSELINUX"
Darren Tucker20e9f972007-03-25 18:26:01 +10004162 SSHDLIBS="$SSHDLIBS $LIBSELINUX"
Tim Rice648f8762011-01-26 12:38:57 -08004163 AC_CHECK_FUNCS([getseuserbyname get_default_context_with_level])
Darren Tuckeradc947d2006-10-07 09:07:20 +10004164 LIBS="$save_LIBS"
Damien Miller73b42d22006-04-22 21:26:08 +10004165 fi ]
4166)
Tim Rice648f8762011-01-26 12:38:57 -08004167AC_SUBST([SSHLIBS])
4168AC_SUBST([SSHDLIBS])
Damien Miller73b42d22006-04-22 21:26:08 +10004169
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004170# Check whether user wants Kerberos 5 support
Damien Millera8e06ce2003-11-21 23:48:55 +11004171KRB5_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08004172AC_ARG_WITH([kerberos5],
Damien Millera8e06ce2003-11-21 23:48:55 +11004173 [ --with-kerberos5=PATH Enable Kerberos 5 support],
Darren Tucker1d3ca582004-01-22 12:05:34 +11004174 [ if test "x$withval" != "xno" ; then
4175 if test "x$withval" = "xyes" ; then
4176 KRB5ROOT="/usr/local"
4177 else
4178 KRB5ROOT=${withval}
4179 fi
4180
Tim Rice648f8762011-01-26 12:38:57 -08004181 AC_DEFINE([KRB5], [1], [Define if you want Kerberos 5 support])
Darren Tucker1d3ca582004-01-22 12:05:34 +11004182 KRB5_MSG="yes"
4183
Darren Tucker4089fc12016-12-08 12:57:24 +11004184 AC_PATH_TOOL([KRB5CONF], [krb5-config],
Darren Tuckerdad48e72009-09-01 18:26:00 +10004185 [$KRB5ROOT/bin/krb5-config],
4186 [$KRB5ROOT/bin:$PATH])
4187 if test -x $KRB5CONF ; then
Darren Tucker964de182013-02-22 10:39:59 +11004188 K5CFLAGS="`$KRB5CONF --cflags`"
4189 K5LIBS="`$KRB5CONF --libs`"
4190 CPPFLAGS="$CPPFLAGS $K5CFLAGS"
Darren Tucker1d3ca582004-01-22 12:05:34 +11004191
Tim Rice648f8762011-01-26 12:38:57 -08004192 AC_MSG_CHECKING([for gssapi support])
Darren Tucker1d3ca582004-01-22 12:05:34 +11004193 if $KRB5CONF | grep gssapi >/dev/null ; then
Tim Rice648f8762011-01-26 12:38:57 -08004194 AC_MSG_RESULT([yes])
4195 AC_DEFINE([GSSAPI], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004196 [Define this if you want GSSAPI
4197 support in the version 2 protocol])
Darren Tucker964de182013-02-22 10:39:59 +11004198 GSSCFLAGS="`$KRB5CONF --cflags gssapi`"
4199 GSSLIBS="`$KRB5CONF --libs gssapi`"
4200 CPPFLAGS="$CPPFLAGS $GSSCFLAGS"
Damien Millera8e06ce2003-11-21 23:48:55 +11004201 else
Tim Rice648f8762011-01-26 12:38:57 -08004202 AC_MSG_RESULT([no])
Damien Millera8e06ce2003-11-21 23:48:55 +11004203 fi
Tim Rice648f8762011-01-26 12:38:57 -08004204 AC_MSG_CHECKING([whether we are using Heimdal])
4205 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <krb5.h>
4206 ]], [[ char *tmp = heimdal_version; ]])],
4207 [ AC_MSG_RESULT([yes])
4208 AC_DEFINE([HEIMDAL], [1],
4209 [Define this if you are using the Heimdal
4210 version of Kerberos V5]) ],
4211 [AC_MSG_RESULT([no])
4212 ])
Darren Tucker1d3ca582004-01-22 12:05:34 +11004213 else
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004214 CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include"
Damien Millera8e06ce2003-11-21 23:48:55 +11004215 LDFLAGS="$LDFLAGS -L${KRB5ROOT}/lib"
Tim Rice648f8762011-01-26 12:38:57 -08004216 AC_MSG_CHECKING([whether we are using Heimdal])
4217 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <krb5.h>
4218 ]], [[ char *tmp = heimdal_version; ]])],
4219 [ AC_MSG_RESULT([yes])
4220 AC_DEFINE([HEIMDAL])
Damien Miller41bccf72011-01-02 21:53:07 +11004221 K5LIBS="-lkrb5"
Damien Miller5561e0b2004-04-20 20:28:55 +10004222 K5LIBS="$K5LIBS -lcom_err -lasn1"
Tim Rice648f8762011-01-26 12:38:57 -08004223 AC_CHECK_LIB([roken], [net_write],
Damien Miller5561e0b2004-04-20 20:28:55 +10004224 [K5LIBS="$K5LIBS -lroken"])
Tim Rice648f8762011-01-26 12:38:57 -08004225 AC_CHECK_LIB([des], [des_cbc_encrypt],
Damien Miller41bccf72011-01-02 21:53:07 +11004226 [K5LIBS="$K5LIBS -ldes"])
Tim Rice648f8762011-01-26 12:38:57 -08004227 ], [ AC_MSG_RESULT([no])
Damien Millera8e06ce2003-11-21 23:48:55 +11004228 K5LIBS="-lkrb5 -lk5crypto -lcom_err"
Tim Rice648f8762011-01-26 12:38:57 -08004229 ])
4230 AC_SEARCH_LIBS([dn_expand], [resolv])
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004231
Tim Rice648f8762011-01-26 12:38:57 -08004232 AC_CHECK_LIB([gssapi_krb5], [gss_init_sec_context],
4233 [ AC_DEFINE([GSSAPI])
Darren Tucker964de182013-02-22 10:39:59 +11004234 GSSLIBS="-lgssapi_krb5" ],
Tim Rice648f8762011-01-26 12:38:57 -08004235 [ AC_CHECK_LIB([gssapi], [gss_init_sec_context],
4236 [ AC_DEFINE([GSSAPI])
Darren Tucker964de182013-02-22 10:39:59 +11004237 GSSLIBS="-lgssapi" ],
Darren Tuckera2b5a4c2013-02-22 10:43:15 +11004238 [ AC_CHECK_LIB([gss], [gss_init_sec_context],
4239 [ AC_DEFINE([GSSAPI])
4240 GSSLIBS="-lgss" ],
4241 AC_MSG_WARN([Cannot find any suitable gss-api library - build may fail]))
4242 ])
Darren Tucker964de182013-02-22 10:39:59 +11004243 ])
Tim Riceeae17cc2005-03-17 16:52:20 -08004244
Tim Rice648f8762011-01-26 12:38:57 -08004245 AC_CHECK_HEADER([gssapi.h], ,
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004246 [ unset ac_cv_header_gssapi_h
Damien Millera8e06ce2003-11-21 23:48:55 +11004247 CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
Tim Rice648f8762011-01-26 12:38:57 -08004248 AC_CHECK_HEADERS([gssapi.h], ,
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004249 AC_MSG_WARN([Cannot find any suitable gss-api header - build may fail])
Damien Millera8e06ce2003-11-21 23:48:55 +11004250 )
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004251 ]
4252 )
4253
4254 oldCPP="$CPPFLAGS"
4255 CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
Tim Rice648f8762011-01-26 12:38:57 -08004256 AC_CHECK_HEADER([gssapi_krb5.h], ,
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004257 [ CPPFLAGS="$oldCPP" ])
4258
Damien Millera8e06ce2003-11-21 23:48:55 +11004259 fi
Darren Tucker1d3ca582004-01-22 12:05:34 +11004260 if test ! -z "$need_dash_r" ; then
4261 LDFLAGS="$LDFLAGS -R${KRB5ROOT}/lib"
4262 fi
4263 if test ! -z "$blibpath" ; then
4264 blibpath="$blibpath:${KRB5ROOT}/lib"
4265 fi
Tim Ricefd9e9e32005-09-12 17:36:10 -07004266
Tim Rice648f8762011-01-26 12:38:57 -08004267 AC_CHECK_HEADERS([gssapi.h gssapi/gssapi.h])
4268 AC_CHECK_HEADERS([gssapi_krb5.h gssapi/gssapi_krb5.h])
4269 AC_CHECK_HEADERS([gssapi_generic.h gssapi/gssapi_generic.h])
Tim Ricefd9e9e32005-09-12 17:36:10 -07004270
Tim Rice648f8762011-01-26 12:38:57 -08004271 AC_SEARCH_LIBS([k_hasafs], [kafs], [AC_DEFINE([USE_AFS], [1],
4272 [Define this if you want to use libkafs' AFS support])])
Darren Tucker03978c62013-02-25 11:24:44 +11004273
4274 AC_CHECK_DECLS([GSS_C_NT_HOSTBASED_SERVICE], [], [], [[
4275#ifdef HAVE_GSSAPI_H
4276# include <gssapi.h>
4277#elif defined(HAVE_GSSAPI_GSSAPI_H)
4278# include <gssapi/gssapi.h>
4279#endif
4280
4281#ifdef HAVE_GSSAPI_GENERIC_H
4282# include <gssapi_generic.h>
4283#elif defined(HAVE_GSSAPI_GSSAPI_GENERIC_H)
4284# include <gssapi/gssapi_generic.h>
4285#endif
4286 ]])
Darren Tuckerf3ab2c52013-08-04 21:48:41 +10004287 saved_LIBS="$LIBS"
4288 LIBS="$LIBS $K5LIBS"
4289 AC_CHECK_FUNCS([krb5_cc_new_unique krb5_get_error_message krb5_free_error_message])
4290 LIBS="$saved_LIBS"
4291
Darren Tucker0d27ed12004-02-24 10:37:33 +11004292 fi
Darren Tucker0d27ed12004-02-24 10:37:33 +11004293 ]
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004294)
Darren Tucker964de182013-02-22 10:39:59 +11004295AC_SUBST([GSSLIBS])
4296AC_SUBST([K5LIBS])
Damien Millerc79bc0d2001-03-28 13:03:42 +10004297
Damien Millera22ba012000-03-02 23:09:20 +11004298# Looking for programs, paths and files
Damien Millera22ba012000-03-02 23:09:20 +11004299
Damien Millerf58c6722002-05-13 13:15:42 +10004300PRIVSEP_PATH=/var/empty
Tim Rice648f8762011-01-26 12:38:57 -08004301AC_ARG_WITH([privsep-path],
Tim Ricecbb90662002-07-08 19:17:10 -07004302 [ --with-privsep-path=xxx Path for privilege separation chroot (default=/var/empty)],
Damien Millerf58c6722002-05-13 13:15:42 +10004303 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004304 if test -n "$withval" && test "x$withval" != "xno" && \
4305 test "x${withval}" != "xyes"; then
Damien Millerf58c6722002-05-13 13:15:42 +10004306 PRIVSEP_PATH=$withval
4307 fi
4308 ]
4309)
Tim Rice648f8762011-01-26 12:38:57 -08004310AC_SUBST([PRIVSEP_PATH])
Damien Millerf58c6722002-05-13 13:15:42 +10004311
Tim Rice648f8762011-01-26 12:38:57 -08004312AC_ARG_WITH([xauth],
Damien Millera22ba012000-03-02 23:09:20 +11004313 [ --with-xauth=PATH Specify path to xauth program ],
4314 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004315 if test -n "$withval" && test "x$withval" != "xno" && \
4316 test "x${withval}" != "xyes"; then
Damien Miller7b22d652000-06-18 14:07:04 +10004317 xauth_path=$withval
Damien Millera22ba012000-03-02 23:09:20 +11004318 fi
4319 ],
4320 [
Tim Ricee22be3b2002-07-17 19:20:07 -07004321 TestPath="$PATH"
4322 TestPath="${TestPath}${PATH_SEPARATOR}/usr/X/bin"
4323 TestPath="${TestPath}${PATH_SEPARATOR}/usr/bin/X11"
4324 TestPath="${TestPath}${PATH_SEPARATOR}/usr/X11R6/bin"
4325 TestPath="${TestPath}${PATH_SEPARATOR}/usr/openwin/bin"
Tim Rice648f8762011-01-26 12:38:57 -08004326 AC_PATH_PROG([xauth_path], [xauth], , [$TestPath])
Damien Milleredb82922000-06-20 13:25:52 +10004327 if (test ! -z "$xauth_path" && test -x "/usr/openwin/bin/xauth") ; then
Damien Millera22ba012000-03-02 23:09:20 +11004328 xauth_path="/usr/openwin/bin/xauth"
4329 fi
4330 ]
4331)
4332
Damien Miller7d901272003-01-13 16:55:22 +11004333STRIP_OPT=-s
Tim Rice648f8762011-01-26 12:38:57 -08004334AC_ARG_ENABLE([strip],
Damien Miller7d901272003-01-13 16:55:22 +11004335 [ --disable-strip Disable calling strip(1) on install],
4336 [
4337 if test "x$enableval" = "xno" ; then
4338 STRIP_OPT=
4339 fi
4340 ]
4341)
Tim Rice648f8762011-01-26 12:38:57 -08004342AC_SUBST([STRIP_OPT])
Damien Miller7d901272003-01-13 16:55:22 +11004343
Damien Millera19cf472000-11-29 13:28:50 +11004344if test -z "$xauth_path" ; then
4345 XAUTH_PATH="undefined"
Tim Rice648f8762011-01-26 12:38:57 -08004346 AC_SUBST([XAUTH_PATH])
Damien Millera19cf472000-11-29 13:28:50 +11004347else
Tim Rice648f8762011-01-26 12:38:57 -08004348 AC_DEFINE_UNQUOTED([XAUTH_PATH], ["$xauth_path"],
Tim Rice7df8d392005-09-19 09:33:39 -07004349 [Define if xauth is found in your path])
Damien Millera19cf472000-11-29 13:28:50 +11004350 XAUTH_PATH=$xauth_path
Tim Rice648f8762011-01-26 12:38:57 -08004351 AC_SUBST([XAUTH_PATH])
Damien Millera22ba012000-03-02 23:09:20 +11004352fi
Damien Millera22ba012000-03-02 23:09:20 +11004353
Tim Rice90f42b02011-06-02 18:17:49 -07004354dnl # --with-maildir=/path/to/mail gets top priority.
4355dnl # if maildir is set in the platform case statement above we use that.
4356dnl # Otherwise we run a program to get the dir from system headers.
4357dnl # We first look for _PATH_MAILDIR then MAILDIR then _PATH_MAIL
4358dnl # If we find _PATH_MAILDIR we do nothing because that is what
4359dnl # session.c expects anyway. Otherwise we set to the value found
4360dnl # stripping any trailing slash. If for some strage reason our program
4361dnl # does not find what it needs, we default to /var/spool/mail.
4362# Check for mail directory
4363AC_ARG_WITH([maildir],
4364 [ --with-maildir=/path/to/mail Specify your system mail directory],
4365 [
4366 if test "X$withval" != X && test "x$withval" != xno && \
4367 test "x${withval}" != xyes; then
4368 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$withval"],
4369 [Set this to your mail directory if you do not have _PATH_MAILDIR])
4370 fi
4371 ],[
4372 if test "X$maildir" != "X"; then
4373 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$maildir"])
4374 else
4375 AC_MSG_CHECKING([Discovering system mail directory])
4376 AC_RUN_IFELSE(
4377 [AC_LANG_PROGRAM([[
4378#include <stdio.h>
4379#include <string.h>
4380#ifdef HAVE_PATHS_H
4381#include <paths.h>
4382#endif
4383#ifdef HAVE_MAILLOCK_H
4384#include <maillock.h>
4385#endif
4386#define DATA "conftest.maildir"
4387 ]], [[
4388 FILE *fd;
4389 int rc;
4390
4391 fd = fopen(DATA,"w");
4392 if(fd == NULL)
4393 exit(1);
4394
4395#if defined (_PATH_MAILDIR)
4396 if ((rc = fprintf(fd ,"_PATH_MAILDIR:%s\n", _PATH_MAILDIR)) <0)
4397 exit(1);
4398#elif defined (MAILDIR)
4399 if ((rc = fprintf(fd ,"MAILDIR:%s\n", MAILDIR)) <0)
4400 exit(1);
4401#elif defined (_PATH_MAIL)
4402 if ((rc = fprintf(fd ,"_PATH_MAIL:%s\n", _PATH_MAIL)) <0)
4403 exit(1);
4404#else
4405 exit (2);
4406#endif
4407
4408 exit(0);
4409 ]])],
4410 [
Tim Ricee1d93702016-05-31 11:13:22 -07004411 maildir_what=`awk -F: '{print $1}' conftest.maildir`
Tim Rice90f42b02011-06-02 18:17:49 -07004412 maildir=`awk -F: '{print $2}' conftest.maildir \
4413 | sed 's|/$||'`
4414 AC_MSG_RESULT([Using: $maildir from $maildir_what])
4415 if test "x$maildir_what" != "x_PATH_MAILDIR"; then
4416 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$maildir"])
4417 fi
4418 ],
4419 [
4420 if test "X$ac_status" = "X2";then
4421# our test program didn't find it. Default to /var/spool/mail
4422 AC_MSG_RESULT([Using: default value of /var/spool/mail])
4423 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["/var/spool/mail"])
4424 else
4425 AC_MSG_RESULT([*** not found ***])
4426 fi
4427 ],
4428 [
4429 AC_MSG_WARN([cross compiling: use --with-maildir=/path/to/mail])
4430 ]
4431 )
4432 fi
4433 ]
4434) # maildir
Damien Millera22ba012000-03-02 23:09:20 +11004435
Darren Tucker623d92f2004-09-12 22:36:15 +10004436if test ! -z "$cross_compiling" && test "x$cross_compiling" = "xyes"; then
Darren Tuckera0c2b392004-09-11 23:26:37 +10004437 AC_MSG_WARN([cross compiling: Disabling /dev/ptmx test])
4438 disable_ptmx_check=yes
4439fi
Damien Millera22ba012000-03-02 23:09:20 +11004440if test -z "$no_dev_ptmx" ; then
Kevin Steves0ea1d9d2002-04-25 18:17:04 +00004441 if test "x$disable_ptmx_check" != "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004442 AC_CHECK_FILE(["/dev/ptmx"],
Kevin Steves0ea1d9d2002-04-25 18:17:04 +00004443 [
Tim Rice648f8762011-01-26 12:38:57 -08004444 AC_DEFINE_UNQUOTED([HAVE_DEV_PTMX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004445 [Define if you have /dev/ptmx])
Kevin Steves0ea1d9d2002-04-25 18:17:04 +00004446 have_dev_ptmx=1
4447 ]
4448 )
4449 fi
Damien Millera22ba012000-03-02 23:09:20 +11004450fi
Darren Tuckera0c2b392004-09-11 23:26:37 +10004451
Darren Tucker623d92f2004-09-12 22:36:15 +10004452if test ! -z "$cross_compiling" && test "x$cross_compiling" != "xyes"; then
Tim Rice648f8762011-01-26 12:38:57 -08004453 AC_CHECK_FILE(["/dev/ptc"],
Darren Tuckera0c2b392004-09-11 23:26:37 +10004454 [
Tim Rice648f8762011-01-26 12:38:57 -08004455 AC_DEFINE_UNQUOTED([HAVE_DEV_PTS_AND_PTC], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004456 [Define if you have /dev/ptc])
Darren Tuckera0c2b392004-09-11 23:26:37 +10004457 have_dev_ptc=1
4458 ]
4459 )
4460else
4461 AC_MSG_WARN([cross compiling: Disabling /dev/ptc test])
4462fi
Damien Miller204ad072000-03-02 23:56:12 +11004463
Damien Millera22ba012000-03-02 23:09:20 +11004464# Options from here on. Some of these are preset by platform above
Tim Rice648f8762011-01-26 12:38:57 -08004465AC_ARG_WITH([mantype],
Damien Miller897741e2001-04-16 10:41:46 +10004466 [ --with-mantype=man|cat|doc Set man page type],
Damien Miller670a4b82000-01-22 13:53:11 +11004467 [
Damien Miller897741e2001-04-16 10:41:46 +10004468 case "$withval" in
4469 man|cat|doc)
4470 MANTYPE=$withval
4471 ;;
4472 *)
Tim Rice648f8762011-01-26 12:38:57 -08004473 AC_MSG_ERROR([invalid man type: $withval])
Damien Miller897741e2001-04-16 10:41:46 +10004474 ;;
4475 esac
Damien Miller670a4b82000-01-22 13:53:11 +11004476 ]
4477)
Ben Lindstrombc709922001-04-18 18:04:21 +00004478if test -z "$MANTYPE"; then
Tim Ricee22be3b2002-07-17 19:20:07 -07004479 TestPath="/usr/bin${PATH_SEPARATOR}/usr/ucb"
Tim Rice648f8762011-01-26 12:38:57 -08004480 AC_PATH_PROGS([NROFF], [nroff awf], [/bin/false], [$TestPath])
Ben Lindstrombc709922001-04-18 18:04:21 +00004481 if ${NROFF} -mdoc ${srcdir}/ssh.1 >/dev/null 2>&1; then
4482 MANTYPE=doc
4483 elif ${NROFF} -man ${srcdir}/ssh.1 >/dev/null 2>&1; then
4484 MANTYPE=man
4485 else
4486 MANTYPE=cat
4487 fi
4488fi
Tim Rice648f8762011-01-26 12:38:57 -08004489AC_SUBST([MANTYPE])
Ben Lindstrombc709922001-04-18 18:04:21 +00004490if test "$MANTYPE" = "doc"; then
4491 mansubdir=man;
4492else
4493 mansubdir=$MANTYPE;
4494fi
Tim Rice648f8762011-01-26 12:38:57 -08004495AC_SUBST([mansubdir])
Damien Miller8bdeee21999-12-30 15:50:54 +11004496
Damien Millera22ba012000-03-02 23:09:20 +11004497# Check whether to enable MD5 passwords
Damien Millera8e06ce2003-11-21 23:48:55 +11004498MD5_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08004499AC_ARG_WITH([md5-passwords],
Damien Millerdd1c7ba1999-11-19 15:53:20 +11004500 [ --with-md5-passwords Enable use of MD5 passwords],
Damien Miller8bdeee21999-12-30 15:50:54 +11004501 [
Damien Millerb85dcad2000-03-11 11:37:00 +11004502 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004503 AC_DEFINE([HAVE_MD5_PASSWORDS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004504 [Define if you want to allow MD5 passwords])
Damien Millera8e06ce2003-11-21 23:48:55 +11004505 MD5_MSG="yes"
Damien Miller8bdeee21999-12-30 15:50:54 +11004506 fi
4507 ]
Damien Millerdd1c7ba1999-11-19 15:53:20 +11004508)
4509
Damien Millera22ba012000-03-02 23:09:20 +11004510# Whether to disable shadow password support
Tim Rice648f8762011-01-26 12:38:57 -08004511AC_ARG_WITH([shadow],
Damien Miller76112de1999-12-21 11:18:08 +11004512 [ --without-shadow Disable shadow password support],
4513 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004514 if test "x$withval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004515 AC_DEFINE([DISABLE_SHADOW])
Damien Miller1f335fb2000-06-26 11:31:33 +10004516 disable_shadow=yes
Damien Miller76112de1999-12-21 11:18:08 +11004517 fi
4518 ]
4519)
4520
Damien Miller1f335fb2000-06-26 11:31:33 +10004521if test -z "$disable_shadow" ; then
4522 AC_MSG_CHECKING([if the systems has expire shadow information])
Tim Rice648f8762011-01-26 12:38:57 -08004523 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller1f335fb2000-06-26 11:31:33 +10004524#include <sys/types.h>
4525#include <shadow.h>
Tim Rice648f8762011-01-26 12:38:57 -08004526struct spwd sp;
4527 ]], [[ sp.sp_expire = sp.sp_lstchg = sp.sp_inact = 0; ]])],
4528 [ sp_expire_available=yes ], [
4529 ])
Damien Miller1f335fb2000-06-26 11:31:33 +10004530
4531 if test "x$sp_expire_available" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004532 AC_MSG_RESULT([yes])
4533 AC_DEFINE([HAS_SHADOW_EXPIRE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004534 [Define if you want to use shadow password expire field])
Damien Miller1f335fb2000-06-26 11:31:33 +10004535 else
Tim Rice648f8762011-01-26 12:38:57 -08004536 AC_MSG_RESULT([no])
Damien Miller1f335fb2000-06-26 11:31:33 +10004537 fi
4538fi
4539
Damien Millera22ba012000-03-02 23:09:20 +11004540# Use ip address instead of hostname in $DISPLAY
Damien Miller9a947342000-08-30 10:03:33 +11004541if test ! -z "$IPADDR_IN_DISPLAY" ; then
4542 DISPLAY_HACK_MSG="yes"
Tim Rice648f8762011-01-26 12:38:57 -08004543 AC_DEFINE([IPADDR_IN_DISPLAY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004544 [Define if you need to use IP address
4545 instead of hostname in $DISPLAY])
Damien Miller9a947342000-08-30 10:03:33 +11004546else
Damien Millera8e06ce2003-11-21 23:48:55 +11004547 DISPLAY_HACK_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08004548 AC_ARG_WITH([ipaddr-display],
Tim Rice6397eed2015-06-03 21:41:11 -07004549 [ --with-ipaddr-display Use ip address instead of hostname in $DISPLAY],
Damien Miller9a947342000-08-30 10:03:33 +11004550 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004551 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004552 AC_DEFINE([IPADDR_IN_DISPLAY])
Damien Millera8e06ce2003-11-21 23:48:55 +11004553 DISPLAY_HACK_MSG="yes"
Damien Miller9a947342000-08-30 10:03:33 +11004554 fi
4555 ]
4556 )
4557fi
Damien Miller76112de1999-12-21 11:18:08 +11004558
Darren Tuckere1a790d2003-09-16 11:52:19 +10004559# check for /etc/default/login and use it if present.
Tim Rice648f8762011-01-26 12:38:57 -08004560AC_ARG_ENABLE([etc-default-login],
Darren Tucker1b6f2292005-02-11 16:11:49 +11004561 [ --disable-etc-default-login Disable using PATH from /etc/default/login [no]],
Darren Tucker2f9573d2005-02-10 22:28:54 +11004562 [ if test "x$enableval" = "xno"; then
4563 AC_MSG_NOTICE([/etc/default/login handling disabled])
4564 etc_default_login=no
4565 else
4566 etc_default_login=yes
4567 fi ],
Darren Tucker314d89e2005-10-17 23:29:23 +10004568 [ if test ! -z "$cross_compiling" && test "x$cross_compiling" = "xyes";
4569 then
4570 AC_MSG_WARN([cross compiling: not checking /etc/default/login])
4571 etc_default_login=no
4572 else
4573 etc_default_login=yes
4574 fi ]
Darren Tucker2f9573d2005-02-10 22:28:54 +11004575)
Darren Tuckere1a790d2003-09-16 11:52:19 +10004576
Darren Tucker2f9573d2005-02-10 22:28:54 +11004577if test "x$etc_default_login" != "xno"; then
Tim Rice648f8762011-01-26 12:38:57 -08004578 AC_CHECK_FILE(["/etc/default/login"],
Darren Tucker2f9573d2005-02-10 22:28:54 +11004579 [ external_path_file=/etc/default/login ])
Darren Tucker314d89e2005-10-17 23:29:23 +10004580 if test "x$external_path_file" = "x/etc/default/login"; then
Tim Rice648f8762011-01-26 12:38:57 -08004581 AC_DEFINE([HAVE_ETC_DEFAULT_LOGIN], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004582 [Define if your system has /etc/default/login])
Darren Tuckera0c2b392004-09-11 23:26:37 +10004583 fi
Darren Tucker2f9573d2005-02-10 22:28:54 +11004584fi
Darren Tuckere1a790d2003-09-16 11:52:19 +10004585
Tim Rice43a1c132002-04-17 21:19:14 -07004586dnl BSD systems use /etc/login.conf so --with-default-path= has no effect
Tim Rice8bb561b2005-03-17 16:23:19 -08004587if test $ac_cv_func_login_getcapbool = "yes" && \
4588 test $ac_cv_header_login_cap_h = "yes" ; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10004589 external_path_file=/etc/login.conf
Tim Rice43a1c132002-04-17 21:19:14 -07004590fi
Darren Tuckere1a790d2003-09-16 11:52:19 +10004591
Damien Millera22ba012000-03-02 23:09:20 +11004592# Whether to mess with the default path
Damien Millera8e06ce2003-11-21 23:48:55 +11004593SERVER_PATH_MSG="(default)"
Tim Rice648f8762011-01-26 12:38:57 -08004594AC_ARG_WITH([default-path],
Tim Rice6397eed2015-06-03 21:41:11 -07004595 [ --with-default-path= Specify default $PATH environment for server],
Damien Miller5a3e6831999-12-27 09:48:56 +11004596 [
Darren Tuckere1a790d2003-09-16 11:52:19 +10004597 if test "x$external_path_file" = "x/etc/login.conf" ; then
Tim Rice43a1c132002-04-17 21:19:14 -07004598 AC_MSG_WARN([
4599--with-default-path=PATH has no effect on this system.
4600Edit /etc/login.conf instead.])
Tim Riceeae17cc2005-03-17 16:52:20 -08004601 elif test "x$withval" != "xno" ; then
Tim Riceb925b4b2003-09-15 22:40:49 -07004602 if test ! -z "$external_path_file" ; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10004603 AC_MSG_WARN([
4604--with-default-path=PATH will only be used if PATH is not defined in
4605$external_path_file .])
4606 fi
Tim Rice59ea0a02001-03-10 13:50:45 -08004607 user_path="$withval"
Damien Millera8e06ce2003-11-21 23:48:55 +11004608 SERVER_PATH_MSG="$withval"
Damien Miller5a3e6831999-12-27 09:48:56 +11004609 fi
Tim Rice59ea0a02001-03-10 13:50:45 -08004610 ],
Darren Tuckere1a790d2003-09-16 11:52:19 +10004611 [ if test "x$external_path_file" = "x/etc/login.conf" ; then
4612 AC_MSG_WARN([Make sure the path to scp is in /etc/login.conf])
Tim Rice43a1c132002-04-17 21:19:14 -07004613 else
Tim Riceb925b4b2003-09-15 22:40:49 -07004614 if test ! -z "$external_path_file" ; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10004615 AC_MSG_WARN([
4616If PATH is defined in $external_path_file, ensure the path to scp is included,
4617otherwise scp will not work.])
4618 fi
Darren Tucker314d89e2005-10-17 23:29:23 +10004619 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08004620 [AC_LANG_PROGRAM([[
Tim Rice59ea0a02001-03-10 13:50:45 -08004621/* find out what STDPATH is */
4622#include <stdio.h>
Tim Rice59ea0a02001-03-10 13:50:45 -08004623#ifdef HAVE_PATHS_H
4624# include <paths.h>
4625#endif
4626#ifndef _PATH_STDPATH
Tim Rice1c9e6882002-11-22 13:29:01 -08004627# ifdef _PATH_USERPATH /* Irix */
4628# define _PATH_STDPATH _PATH_USERPATH
4629# else
4630# define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
4631# endif
Tim Rice59ea0a02001-03-10 13:50:45 -08004632#endif
4633#include <sys/types.h>
4634#include <sys/stat.h>
4635#include <fcntl.h>
4636#define DATA "conftest.stdpath"
Tim Rice648f8762011-01-26 12:38:57 -08004637 ]], [[
Tim Rice59ea0a02001-03-10 13:50:45 -08004638 FILE *fd;
4639 int rc;
Tim Riceeae17cc2005-03-17 16:52:20 -08004640
Tim Rice59ea0a02001-03-10 13:50:45 -08004641 fd = fopen(DATA,"w");
4642 if(fd == NULL)
4643 exit(1);
Tim Riceeae17cc2005-03-17 16:52:20 -08004644
Tim Rice59ea0a02001-03-10 13:50:45 -08004645 if ((rc = fprintf(fd,"%s", _PATH_STDPATH)) < 0)
4646 exit(1);
4647
4648 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10004649 ]])],
4650 [ user_path=`cat conftest.stdpath` ],
Tim Rice59ea0a02001-03-10 13:50:45 -08004651 [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ],
4652 [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ]
4653 )
4654# make sure $bindir is in USER_PATH so scp will work
Damien Miller77eab7b2012-07-06 11:49:28 +10004655 t_bindir="${bindir}"
4656 while echo "${t_bindir}" | egrep '\$\{|NONE/' >/dev/null 2>&1; do
4657 t_bindir=`eval echo ${t_bindir}`
4658 case $t_bindir in
4659 NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$prefix~"` ;;
4660 esac
4661 case $t_bindir in
4662 NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$ac_default_prefix~"` ;;
4663 esac
4664 done
Tim Rice59ea0a02001-03-10 13:50:45 -08004665 echo $user_path | grep ":$t_bindir" > /dev/null 2>&1
4666 if test $? -ne 0 ; then
4667 echo $user_path | grep "^$t_bindir" > /dev/null 2>&1
4668 if test $? -ne 0 ; then
4669 user_path=$user_path:$t_bindir
Tim Rice648f8762011-01-26 12:38:57 -08004670 AC_MSG_RESULT([Adding $t_bindir to USER_PATH so scp will work])
Tim Rice59ea0a02001-03-10 13:50:45 -08004671 fi
4672 fi
Tim Rice43a1c132002-04-17 21:19:14 -07004673 fi ]
Damien Miller5a3e6831999-12-27 09:48:56 +11004674)
Darren Tuckere1a790d2003-09-16 11:52:19 +10004675if test "x$external_path_file" != "x/etc/login.conf" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004676 AC_DEFINE_UNQUOTED([USER_PATH], ["$user_path"], [Specify default $PATH])
4677 AC_SUBST([user_path])
Tim Rice43a1c132002-04-17 21:19:14 -07004678fi
Damien Miller5a3e6831999-12-27 09:48:56 +11004679
Damien Millera18bbd32002-05-13 10:48:57 +10004680# Set superuser path separately to user path
Tim Rice648f8762011-01-26 12:38:57 -08004681AC_ARG_WITH([superuser-path],
Damien Millera18bbd32002-05-13 10:48:57 +10004682 [ --with-superuser-path= Specify different path for super-user],
4683 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004684 if test -n "$withval" && test "x$withval" != "xno" && \
4685 test "x${withval}" != "xyes"; then
Tim Rice648f8762011-01-26 12:38:57 -08004686 AC_DEFINE_UNQUOTED([SUPERUSER_PATH], ["$withval"],
Tim Rice7df8d392005-09-19 09:33:39 -07004687 [Define if you want a different $PATH
4688 for the superuser])
Damien Millera18bbd32002-05-13 10:48:57 +10004689 superuser_path=$withval
4690 fi
4691 ]
4692)
4693
4694
Damien Miller61e50f12000-05-08 20:49:37 +10004695AC_MSG_CHECKING([if we need to convert IPv4 in IPv6-mapped addresses])
Damien Millera8e06ce2003-11-21 23:48:55 +11004696IPV4_IN6_HACK_MSG="no"
Damien Miller7bcb0892000-03-11 20:45:40 +11004697AC_ARG_WITH(4in6,
4698 [ --with-4in6 Check for and convert IPv4 in IPv6 mapped addresses],
4699 [
4700 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004701 AC_MSG_RESULT([yes])
4702 AC_DEFINE([IPV4_IN_IPV6], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004703 [Detect IPv4 in IPv6 mapped addresses
4704 and treat as IPv4])
Damien Millera8e06ce2003-11-21 23:48:55 +11004705 IPV4_IN6_HACK_MSG="yes"
Damien Miller7bcb0892000-03-11 20:45:40 +11004706 else
Tim Rice648f8762011-01-26 12:38:57 -08004707 AC_MSG_RESULT([no])
Damien Miller7bcb0892000-03-11 20:45:40 +11004708 fi
Tim Rice648f8762011-01-26 12:38:57 -08004709 ], [
Damien Miller7bcb0892000-03-11 20:45:40 +11004710 if test "x$inet6_default_4in6" = "xyes"; then
4711 AC_MSG_RESULT([yes (default)])
Tim Rice648f8762011-01-26 12:38:57 -08004712 AC_DEFINE([IPV4_IN_IPV6])
Damien Millera8e06ce2003-11-21 23:48:55 +11004713 IPV4_IN6_HACK_MSG="yes"
Damien Miller7bcb0892000-03-11 20:45:40 +11004714 else
4715 AC_MSG_RESULT([no (default)])
4716 fi
4717 ]
4718)
4719
Damien Miller60396b02001-02-18 17:01:00 +11004720# Whether to enable BSD auth support
Damien Miller6c21c512002-01-22 21:57:53 +11004721BSD_AUTH_MSG=no
Tim Rice648f8762011-01-26 12:38:57 -08004722AC_ARG_WITH([bsd-auth],
Damien Miller60396b02001-02-18 17:01:00 +11004723 [ --with-bsd-auth Enable BSD auth support],
4724 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004725 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004726 AC_DEFINE([BSD_AUTH], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004727 [Define if you have BSD auth support])
Damien Miller6c21c512002-01-22 21:57:53 +11004728 BSD_AUTH_MSG=yes
Damien Miller60396b02001-02-18 17:01:00 +11004729 fi
4730 ]
4731)
4732
Damien Millera22ba012000-03-02 23:09:20 +11004733# Where to place sshd.pid
Damien Millerb13c73e2000-01-17 22:02:17 +11004734piddir=/var/run
Damien Miller78315eb2000-09-29 23:01:36 +11004735# make sure the directory exists
Tim Riceeae17cc2005-03-17 16:52:20 -08004736if test ! -d $piddir ; then
Damien Miller78315eb2000-09-29 23:01:36 +11004737 piddir=`eval echo ${sysconfdir}`
4738 case $piddir in
Damien Millera8e06ce2003-11-21 23:48:55 +11004739 NONE/*) piddir=`echo $piddir | sed "s~NONE~$ac_default_prefix~"` ;;
Damien Miller78315eb2000-09-29 23:01:36 +11004740 esac
4741fi
4742
Tim Rice648f8762011-01-26 12:38:57 -08004743AC_ARG_WITH([pid-dir],
Tim Rice88f2ab52002-03-17 12:17:34 -08004744 [ --with-pid-dir=PATH Specify location of ssh.pid file],
4745 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004746 if test -n "$withval" && test "x$withval" != "xno" && \
4747 test "x${withval}" != "xyes"; then
Tim Rice88f2ab52002-03-17 12:17:34 -08004748 piddir=$withval
Tim Riceeae17cc2005-03-17 16:52:20 -08004749 if test ! -d $piddir ; then
Tim Rice88f2ab52002-03-17 12:17:34 -08004750 AC_MSG_WARN([** no $piddir directory on this system **])
4751 fi
4752 fi
4753 ]
4754)
4755
Tim Ricee1d93702016-05-31 11:13:22 -07004756AC_DEFINE_UNQUOTED([_PATH_SSH_PIDDIR], ["$piddir"],
Tim Rice648f8762011-01-26 12:38:57 -08004757 [Specify location of ssh.pid])
4758AC_SUBST([piddir])
Damien Miller5eed6a22000-01-16 12:05:18 +11004759
andre2ff7b5d2000-06-03 14:57:40 +00004760dnl allow user to disable some login recording features
Tim Rice648f8762011-01-26 12:38:57 -08004761AC_ARG_ENABLE([lastlog],
andre43ca7e22000-06-19 08:23:46 +00004762 [ --disable-lastlog disable use of lastlog even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004763 [
4764 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004765 AC_DEFINE([DISABLE_LASTLOG])
Darren Tuckera3020db2003-06-28 12:54:33 +10004766 fi
4767 ]
andre2ff7b5d2000-06-03 14:57:40 +00004768)
Tim Rice648f8762011-01-26 12:38:57 -08004769AC_ARG_ENABLE([utmp],
andre43ca7e22000-06-19 08:23:46 +00004770 [ --disable-utmp disable use of utmp even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004771 [
4772 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004773 AC_DEFINE([DISABLE_UTMP])
Darren Tuckera3020db2003-06-28 12:54:33 +10004774 fi
4775 ]
andre2ff7b5d2000-06-03 14:57:40 +00004776)
Tim Rice648f8762011-01-26 12:38:57 -08004777AC_ARG_ENABLE([utmpx],
andre43ca7e22000-06-19 08:23:46 +00004778 [ --disable-utmpx disable use of utmpx even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004779 [
4780 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004781 AC_DEFINE([DISABLE_UTMPX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004782 [Define if you don't want to use utmpx])
Darren Tuckera3020db2003-06-28 12:54:33 +10004783 fi
4784 ]
andre2ff7b5d2000-06-03 14:57:40 +00004785)
Tim Rice648f8762011-01-26 12:38:57 -08004786AC_ARG_ENABLE([wtmp],
andre43ca7e22000-06-19 08:23:46 +00004787 [ --disable-wtmp disable use of wtmp even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004788 [
4789 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004790 AC_DEFINE([DISABLE_WTMP])
Darren Tuckera3020db2003-06-28 12:54:33 +10004791 fi
4792 ]
andre2ff7b5d2000-06-03 14:57:40 +00004793)
Tim Rice648f8762011-01-26 12:38:57 -08004794AC_ARG_ENABLE([wtmpx],
andre43ca7e22000-06-19 08:23:46 +00004795 [ --disable-wtmpx disable use of wtmpx even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004796 [
4797 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004798 AC_DEFINE([DISABLE_WTMPX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004799 [Define if you don't want to use wtmpx])
Darren Tuckera3020db2003-06-28 12:54:33 +10004800 fi
4801 ]
andre2ff7b5d2000-06-03 14:57:40 +00004802)
Tim Rice648f8762011-01-26 12:38:57 -08004803AC_ARG_ENABLE([libutil],
andre43ca7e22000-06-19 08:23:46 +00004804 [ --disable-libutil disable use of libutil (login() etc.) [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004805 [
4806 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004807 AC_DEFINE([DISABLE_LOGIN])
Darren Tuckera3020db2003-06-28 12:54:33 +10004808 fi
4809 ]
andre2ff7b5d2000-06-03 14:57:40 +00004810)
Tim Rice648f8762011-01-26 12:38:57 -08004811AC_ARG_ENABLE([pututline],
andre43ca7e22000-06-19 08:23:46 +00004812 [ --disable-pututline disable use of pututline() etc. ([uw]tmp) [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004813 [
4814 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004815 AC_DEFINE([DISABLE_PUTUTLINE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004816 [Define if you don't want to use pututline()
4817 etc. to write [uw]tmp])
Darren Tuckera3020db2003-06-28 12:54:33 +10004818 fi
4819 ]
andre2ff7b5d2000-06-03 14:57:40 +00004820)
Tim Rice648f8762011-01-26 12:38:57 -08004821AC_ARG_ENABLE([pututxline],
andre43ca7e22000-06-19 08:23:46 +00004822 [ --disable-pututxline disable use of pututxline() etc. ([uw]tmpx) [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004823 [
4824 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004825 AC_DEFINE([DISABLE_PUTUTXLINE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004826 [Define if you don't want to use pututxline()
4827 etc. to write [uw]tmpx])
Darren Tuckera3020db2003-06-28 12:54:33 +10004828 fi
4829 ]
andre2ff7b5d2000-06-03 14:57:40 +00004830)
Tim Rice648f8762011-01-26 12:38:57 -08004831AC_ARG_WITH([lastlog],
andre43ca7e22000-06-19 08:23:46 +00004832 [ --with-lastlog=FILE|DIR specify lastlog location [common locations]],
Damien Miller709528a2001-01-31 09:57:55 +11004833 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004834 if test "x$withval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004835 AC_DEFINE([DISABLE_LASTLOG])
Tim Rice35cc69d2005-03-17 16:44:25 -08004836 elif test -n "$withval" && test "x${withval}" != "xyes"; then
Damien Miller709528a2001-01-31 09:57:55 +11004837 conf_lastlog_location=$withval
4838 fi
4839 ]
4840)
andre2ff7b5d2000-06-03 14:57:40 +00004841
4842dnl lastlog, [uw]tmpx? detection
4843dnl NOTE: set the paths in the platform section to avoid the
4844dnl need for command-line parameters
4845dnl lastlog and [uw]tmp are subject to a file search if all else fails
4846
4847dnl lastlog detection
4848dnl NOTE: the code itself will detect if lastlog is a directory
4849AC_MSG_CHECKING([if your system defines LASTLOG_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08004850AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00004851#include <sys/types.h>
4852#include <utmp.h>
4853#ifdef HAVE_LASTLOG_H
4854# include <lastlog.h>
4855#endif
Damien Miller2994e082000-06-04 15:51:47 +10004856#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00004857# include <paths.h>
4858#endif
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00004859#ifdef HAVE_LOGIN_H
4860# include <login.h>
4861#endif
Tim Rice648f8762011-01-26 12:38:57 -08004862 ]], [[ char *lastlog = LASTLOG_FILE; ]])],
4863 [ AC_MSG_RESULT([yes]) ],
4864 [
4865 AC_MSG_RESULT([no])
Damien Miller2994e082000-06-04 15:51:47 +10004866 AC_MSG_CHECKING([if your system defines _PATH_LASTLOG])
Tim Rice648f8762011-01-26 12:38:57 -08004867 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller2994e082000-06-04 15:51:47 +10004868#include <sys/types.h>
4869#include <utmp.h>
4870#ifdef HAVE_LASTLOG_H
4871# include <lastlog.h>
4872#endif
4873#ifdef HAVE_PATHS_H
4874# include <paths.h>
4875#endif
Tim Rice648f8762011-01-26 12:38:57 -08004876 ]], [[ char *lastlog = _PATH_LASTLOG; ]])],
4877 [ AC_MSG_RESULT([yes]) ],
Damien Miller2994e082000-06-04 15:51:47 +10004878 [
Tim Rice648f8762011-01-26 12:38:57 -08004879 AC_MSG_RESULT([no])
Damien Miller2994e082000-06-04 15:51:47 +10004880 system_lastlog_path=no
4881 ])
Tim Rice648f8762011-01-26 12:38:57 -08004882])
Damien Miller2994e082000-06-04 15:51:47 +10004883
andre2ff7b5d2000-06-03 14:57:40 +00004884if test -z "$conf_lastlog_location"; then
4885 if test x"$system_lastlog_path" = x"no" ; then
4886 for f in /var/log/lastlog /usr/adm/lastlog /var/adm/lastlog /etc/security/lastlog ; do
Damien Milleredb82922000-06-20 13:25:52 +10004887 if (test -d "$f" || test -f "$f") ; then
andre2ff7b5d2000-06-03 14:57:40 +00004888 conf_lastlog_location=$f
4889 fi
4890 done
4891 if test -z "$conf_lastlog_location"; then
andre45cad512000-06-12 23:27:31 +00004892 AC_MSG_WARN([** Cannot find lastlog **])
4893 dnl Don't define DISABLE_LASTLOG - that means we don't try wtmp/wtmpx
andre2ff7b5d2000-06-03 14:57:40 +00004894 fi
4895 fi
4896fi
4897
4898if test -n "$conf_lastlog_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08004899 AC_DEFINE_UNQUOTED([CONF_LASTLOG_FILE], ["$conf_lastlog_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07004900 [Define if you want to specify the path to your lastlog file])
Tim Riceeae17cc2005-03-17 16:52:20 -08004901fi
andre2ff7b5d2000-06-03 14:57:40 +00004902
4903dnl utmp detection
4904AC_MSG_CHECKING([if your system defines UTMP_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08004905AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00004906#include <sys/types.h>
4907#include <utmp.h>
Damien Miller2994e082000-06-04 15:51:47 +10004908#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00004909# include <paths.h>
4910#endif
Tim Rice648f8762011-01-26 12:38:57 -08004911 ]], [[ char *utmp = UTMP_FILE; ]])],
4912 [ AC_MSG_RESULT([yes]) ],
4913 [ AC_MSG_RESULT([no])
Tim Ricee1d93702016-05-31 11:13:22 -07004914 system_utmp_path=no
Tim Rice648f8762011-01-26 12:38:57 -08004915])
andre2ff7b5d2000-06-03 14:57:40 +00004916if test -z "$conf_utmp_location"; then
4917 if test x"$system_utmp_path" = x"no" ; then
4918 for f in /etc/utmp /usr/adm/utmp /var/run/utmp; do
4919 if test -f $f ; then
4920 conf_utmp_location=$f
4921 fi
4922 done
4923 if test -z "$conf_utmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08004924 AC_DEFINE([DISABLE_UTMP])
andre2ff7b5d2000-06-03 14:57:40 +00004925 fi
4926 fi
4927fi
4928if test -n "$conf_utmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08004929 AC_DEFINE_UNQUOTED([CONF_UTMP_FILE], ["$conf_utmp_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07004930 [Define if you want to specify the path to your utmp file])
Tim Riceeae17cc2005-03-17 16:52:20 -08004931fi
andre2ff7b5d2000-06-03 14:57:40 +00004932
4933dnl wtmp detection
4934AC_MSG_CHECKING([if your system defines WTMP_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08004935AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00004936#include <sys/types.h>
4937#include <utmp.h>
Damien Miller2994e082000-06-04 15:51:47 +10004938#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00004939# include <paths.h>
4940#endif
Tim Rice648f8762011-01-26 12:38:57 -08004941 ]], [[ char *wtmp = WTMP_FILE; ]])],
4942 [ AC_MSG_RESULT([yes]) ],
4943 [ AC_MSG_RESULT([no])
Tim Ricee1d93702016-05-31 11:13:22 -07004944 system_wtmp_path=no
Tim Rice648f8762011-01-26 12:38:57 -08004945])
andre2ff7b5d2000-06-03 14:57:40 +00004946if test -z "$conf_wtmp_location"; then
4947 if test x"$system_wtmp_path" = x"no" ; then
4948 for f in /usr/adm/wtmp /var/log/wtmp; do
4949 if test -f $f ; then
4950 conf_wtmp_location=$f
4951 fi
4952 done
4953 if test -z "$conf_wtmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08004954 AC_DEFINE([DISABLE_WTMP])
andre2ff7b5d2000-06-03 14:57:40 +00004955 fi
4956 fi
4957fi
4958if test -n "$conf_wtmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08004959 AC_DEFINE_UNQUOTED([CONF_WTMP_FILE], ["$conf_wtmp_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07004960 [Define if you want to specify the path to your wtmp file])
Tim Riceeae17cc2005-03-17 16:52:20 -08004961fi
andre2ff7b5d2000-06-03 14:57:40 +00004962
andre2ff7b5d2000-06-03 14:57:40 +00004963dnl wtmpx detection
4964AC_MSG_CHECKING([if your system defines WTMPX_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08004965AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00004966#include <sys/types.h>
4967#include <utmp.h>
4968#ifdef HAVE_UTMPX_H
4969#include <utmpx.h>
4970#endif
Damien Miller2994e082000-06-04 15:51:47 +10004971#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00004972# include <paths.h>
4973#endif
Tim Rice648f8762011-01-26 12:38:57 -08004974 ]], [[ char *wtmpx = WTMPX_FILE; ]])],
4975 [ AC_MSG_RESULT([yes]) ],
4976 [ AC_MSG_RESULT([no])
Tim Ricee1d93702016-05-31 11:13:22 -07004977 system_wtmpx_path=no
Tim Rice648f8762011-01-26 12:38:57 -08004978])
andre2ff7b5d2000-06-03 14:57:40 +00004979if test -z "$conf_wtmpx_location"; then
4980 if test x"$system_wtmpx_path" = x"no" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004981 AC_DEFINE([DISABLE_WTMPX])
andre2ff7b5d2000-06-03 14:57:40 +00004982 fi
4983else
Tim Rice648f8762011-01-26 12:38:57 -08004984 AC_DEFINE_UNQUOTED([CONF_WTMPX_FILE], ["$conf_wtmpx_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07004985 [Define if you want to specify the path to your wtmpx file])
Tim Riceeae17cc2005-03-17 16:52:20 -08004986fi
andre2ff7b5d2000-06-03 14:57:40 +00004987
Damien Miller4018c192000-04-30 09:30:44 +10004988
Damien Miller29ea30d2000-03-17 10:54:15 +11004989if test ! -z "$blibpath" ; then
Damien Millereab4bae2003-04-29 23:22:40 +10004990 LDFLAGS="$LDFLAGS $blibflags$blibpath"
4991 AC_MSG_WARN([Please check and edit blibpath in LDFLAGS in Makefile])
Damien Miller29ea30d2000-03-17 10:54:15 +11004992fi
4993
Damien Millera2438bb2013-03-15 10:23:07 +11004994AC_CHECK_MEMBER([struct lastlog.ll_line], [], [
Tim Riceaa86c392013-03-16 20:55:46 -07004995 if test x$SKIP_DISABLE_LASTLOG_DEFINE != "xyes" ; then
Damien Millera2438bb2013-03-15 10:23:07 +11004996 AC_DEFINE([DISABLE_LASTLOG])
Tim Riceaa86c392013-03-16 20:55:46 -07004997 fi
Damien Millera2438bb2013-03-15 10:23:07 +11004998 ], [
4999#ifdef HAVE_SYS_TYPES_H
5000#include <sys/types.h>
5001#endif
5002#ifdef HAVE_UTMP_H
5003#include <utmp.h>
5004#endif
5005#ifdef HAVE_UTMPX_H
5006#include <utmpx.h>
5007#endif
5008#ifdef HAVE_LASTLOG_H
5009#include <lastlog.h>
5010#endif
5011 ])
5012
5013AC_CHECK_MEMBER([struct utmp.ut_line], [], [
5014 AC_DEFINE([DISABLE_UTMP])
5015 AC_DEFINE([DISABLE_WTMP])
5016 ], [
5017#ifdef HAVE_SYS_TYPES_H
5018#include <sys/types.h>
5019#endif
5020#ifdef HAVE_UTMP_H
5021#include <utmp.h>
5022#endif
5023#ifdef HAVE_UTMPX_H
5024#include <utmpx.h>
5025#endif
5026#ifdef HAVE_LASTLOG_H
5027#include <lastlog.h>
5028#endif
5029 ])
5030
Darren Tucker7da23cb2005-08-03 00:20:15 +10005031dnl Adding -Werror to CFLAGS early prevents configure tests from running.
5032dnl Add now.
5033CFLAGS="$CFLAGS $werror_flags"
5034
Darren Tucker627337d2010-04-10 22:58:01 +10005035if test "x$ac_cv_func_getaddrinfo" != "xyes" ; then
5036 TEST_SSH_IPV6=no
5037else
5038 TEST_SSH_IPV6=yes
5039fi
Tim Rice648f8762011-01-26 12:38:57 -08005040AC_CHECK_DECL([BROKEN_GETADDRINFO], [TEST_SSH_IPV6=no])
5041AC_SUBST([TEST_SSH_IPV6], [$TEST_SSH_IPV6])
Darren Tucker47b8c992016-12-08 15:48:34 +11005042AC_SUBST([TEST_SSH_UTF8], [$TEST_SSH_UTF8])
Darren Tucker882abfd2013-11-09 00:17:41 +11005043AC_SUBST([TEST_MALLOC_OPTIONS], [$TEST_MALLOC_OPTIONS])
Darren Tucker6d8bd572013-06-11 11:26:10 +10005044AC_SUBST([UNSUPPORTED_ALGORITHMS], [$unsupported_algorithms])
Darren Tucker5d376902008-06-11 04:15:05 +10005045
Damien Millerbac2d8a2000-09-05 16:13:06 +11005046AC_EXEEXT
Damien Miller223897a2006-09-12 21:54:10 +10005047AC_CONFIG_FILES([Makefile buildpkg.sh opensshd.init openssh.xml \
5048 openbsd-compat/Makefile openbsd-compat/regress/Makefile \
Damien Millerf22019b2011-05-05 13:48:37 +10005049 survey.sh])
Tim Rice13aae5e2001-10-21 17:53:58 -07005050AC_OUTPUT
Damien Miller0437b332000-05-02 09:56:41 +10005051
Damien Miller7b22d652000-06-18 14:07:04 +10005052# Print summary of options
5053
Damien Miller7b22d652000-06-18 14:07:04 +10005054# Someone please show me a better way :)
5055A=`eval echo ${prefix}` ; A=`eval echo ${A}`
5056B=`eval echo ${bindir}` ; B=`eval echo ${B}`
5057C=`eval echo ${sbindir}` ; C=`eval echo ${C}`
5058D=`eval echo ${sysconfdir}` ; D=`eval echo ${D}`
Kevin Stevese0f49142000-10-14 17:51:48 +00005059E=`eval echo ${libexecdir}/ssh-askpass` ; E=`eval echo ${E}`
Ben Lindstrombc709922001-04-18 18:04:21 +00005060F=`eval echo ${mandir}/${mansubdir}X` ; F=`eval echo ${F}`
Damien Miller7b22d652000-06-18 14:07:04 +10005061G=`eval echo ${piddir}` ; G=`eval echo ${G}`
Damien Millerf58c6722002-05-13 13:15:42 +10005062H=`eval echo ${PRIVSEP_PATH}` ; H=`eval echo ${H}`
5063I=`eval echo ${user_path}` ; I=`eval echo ${I}`
5064J=`eval echo ${superuser_path}` ; J=`eval echo ${J}`
Damien Miller7b22d652000-06-18 14:07:04 +10005065
5066echo ""
Kevin Steves393d2f72001-04-08 22:50:43 +00005067echo "OpenSSH has been configured with the following options:"
Damien Millerf58c6722002-05-13 13:15:42 +10005068echo " User binaries: $B"
5069echo " System binaries: $C"
5070echo " Configuration files: $D"
5071echo " Askpass program: $E"
5072echo " Manual pages: $F"
5073echo " PID file: $G"
5074echo " Privilege separation chroot path: $H"
Darren Tuckere1a790d2003-09-16 11:52:19 +10005075if test "x$external_path_file" = "x/etc/login.conf" ; then
5076echo " At runtime, sshd will use the path defined in $external_path_file"
5077echo " Make sure the path to scp is present, otherwise scp will not work"
Tim Rice43a1c132002-04-17 21:19:14 -07005078else
Damien Millerf58c6722002-05-13 13:15:42 +10005079echo " sshd default user PATH: $I"
Tim Riceb925b4b2003-09-15 22:40:49 -07005080 if test ! -z "$external_path_file"; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10005081echo " (If PATH is set in $external_path_file it will be used instead. If"
5082echo " used, ensure the path to scp is present, otherwise scp will not work.)"
5083 fi
Tim Rice43a1c132002-04-17 21:19:14 -07005084fi
Damien Millera18bbd32002-05-13 10:48:57 +10005085if test ! -z "$superuser_path" ; then
Damien Millerf58c6722002-05-13 13:15:42 +10005086echo " sshd superuser user PATH: $J"
Damien Millera18bbd32002-05-13 10:48:57 +10005087fi
Damien Millerf58c6722002-05-13 13:15:42 +10005088echo " Manpage format: $MANTYPE"
Damien Miller7abe09b2003-05-15 10:53:49 +10005089echo " PAM support: $PAM_MSG"
Damien Miller1b06dc32006-08-31 03:24:41 +10005090echo " OSF SIA support: $SIA_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10005091echo " KerberosV support: $KRB5_MSG"
Damien Miller73b42d22006-04-22 21:26:08 +10005092echo " SELinux support: $SELINUX_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10005093echo " Smartcard support: $SCARD_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10005094echo " S/KEY support: $SKEY_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10005095echo " MD5 password support: $MD5_MSG"
Darren Tucker16bcc1c2004-11-07 20:14:34 +11005096echo " libedit support: $LIBEDIT_MSG"
Damien Miller523db852017-02-03 16:01:22 +11005097echo " libldns support: $LDNS_MSG"
Damien Miller1b06dc32006-08-31 03:24:41 +10005098echo " Solaris process contract support: $SPC_MSG"
Darren Tucker97528352010-11-05 12:03:05 +11005099echo " Solaris project support: $SP_MSG"
Damien Miller4626cba2016-01-08 14:24:56 +11005100echo " Solaris privilege support: $SPP_MSG"
Damien Miller903e1152002-05-13 14:41:31 +10005101echo " IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10005102echo " Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG"
5103echo " BSD Auth support: $BSD_AUTH_MSG"
5104echo " Random number source: $RAND_MSG"
Damien Miller69ff1df2011-06-23 08:30:03 +10005105echo " Privsep sandbox style: $SANDBOX_STYLE"
Damien Miller60396b02001-02-18 17:01:00 +11005106
Damien Miller7b22d652000-06-18 14:07:04 +10005107echo ""
5108
Ben Lindstrom28bfc0d2000-12-18 19:58:57 +00005109echo " Host: ${host}"
5110echo " Compiler: ${CC}"
5111echo " Compiler flags: ${CFLAGS}"
5112echo "Preprocessor flags: ${CPPFLAGS}"
5113echo " Linker flags: ${LDFLAGS}"
Darren Tucker20e9f972007-03-25 18:26:01 +10005114echo " Libraries: ${LIBS}"
5115if test ! -z "${SSHDLIBS}"; then
5116echo " +for sshd: ${SSHDLIBS}"
5117fi
Damien Miller71adf122011-01-25 12:16:15 +11005118if test ! -z "${SSHLIBS}"; then
5119echo " +for ssh: ${SSHLIBS}"
5120fi
Damien Miller7b22d652000-06-18 14:07:04 +10005121
5122echo ""
5123
Tim Rice6f1f7582004-05-30 21:38:51 -07005124if test "x$MAKE_PACKAGE_SUPPORTED" = "xyes" ; then
Darren Tuckercf59d312004-08-29 21:18:09 +10005125 echo "SVR4 style packages are supported with \"make package\""
5126 echo ""
Tim Rice6f1f7582004-05-30 21:38:51 -07005127fi
5128
Damien Miller82cf0ce2000-12-20 13:34:48 +11005129if test "x$PAM_MSG" = "xyes" ; then
Damien Miller6c21c512002-01-22 21:57:53 +11005130 echo "PAM is enabled. You may need to install a PAM control file "
5131 echo "for sshd, otherwise password authentication may fail. "
Damien Millera8e06ce2003-11-21 23:48:55 +11005132 echo "Example PAM control files can be found in the contrib/ "
Damien Miller6c21c512002-01-22 21:57:53 +11005133 echo "subdirectory"
Damien Miller6f9c3372000-10-25 10:06:04 +11005134 echo ""
5135fi
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00005136
Damien Millerb4097182004-05-23 14:09:40 +10005137if test ! -z "$NO_PEERCHECK" ; then
Darren Tucker164aa302007-03-21 21:39:57 +11005138 echo "WARNING: the operating system that you are using does not"
5139 echo "appear to support getpeereid(), getpeerucred() or the"
5140 echo "SO_PEERCRED getsockopt() option. These facilities are used to"
5141 echo "enforce security checks to prevent unauthorised connections to"
5142 echo "ssh-agent. Their absence increases the risk that a malicious"
5143 echo "user can connect to your agent."
Damien Millerb4097182004-05-23 14:09:40 +10005144 echo ""
5145fi
5146
Darren Tuckerd9f88912005-02-20 21:01:48 +11005147if test "$AUDIT_MODULE" = "bsm" ; then
5148 echo "WARNING: BSM audit support is currently considered EXPERIMENTAL."
5149 echo "See the Solaris section in README.platform for details."
5150fi