blob: 455a224eb3c23d317078157eaf76bfbb57162d21 [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
Damien Miller72ef7c12015-01-15 02:21:31 +1100112AC_ARG_WITH([openssl],
113 [ --without-openssl Disable use of OpenSSL; use only limited internal crypto **EXPERIMENTAL** ],
Damien Miller76c04802015-01-13 19:38:18 +1100114 [ if test "x$withval" = "xno" ; then
Damien Miller72ef7c12015-01-15 02:21:31 +1100115 openssl=no
Damien Miller76c04802015-01-13 19:38:18 +1100116 fi
117 ]
118)
Damien Miller72ef7c12015-01-15 02:21:31 +1100119AC_MSG_CHECKING([whether OpenSSL will be used for cryptography])
120if test "x$openssl" = "xyes" ; then
121 AC_MSG_RESULT([yes])
122 AC_DEFINE_UNQUOTED([WITH_OPENSSL], [1], [use libcrypto for cryptography])
123else
124 AC_MSG_RESULT([no])
125fi
126
Darren Tuckerb7918af2008-03-09 11:34:23 +1100127use_stack_protector=1
Darren Tuckerfd994372014-01-17 09:53:24 +1100128use_toolchain_hardening=1
Tim Rice648f8762011-01-26 12:38:57 -0800129AC_ARG_WITH([stackprotect],
Damien Millerda3155e2008-03-27 12:30:18 +1100130 [ --without-stackprotect Don't use compiler's stack protection], [
Darren Tuckerb7918af2008-03-09 11:34:23 +1100131 if test "x$withval" = "xno"; then
132 use_stack_protector=0
133 fi ])
Darren Tuckerfd994372014-01-17 09:53:24 +1100134AC_ARG_WITH([hardening],
135 [ --without-hardening Don't use toolchain hardening flags], [
136 if test "x$withval" = "xno"; then
Darren Tuckerfd994372014-01-17 09:53:24 +1100137 use_toolchain_hardening=0
138 fi ])
Darren Tuckerb7918af2008-03-09 11:34:23 +1100139
Darren Tuckerfd994372014-01-17 09:53:24 +1100140# We use -Werror for the tests only so that we catch warnings like "this is
141# on by default" for things like -fPIE.
142AC_MSG_CHECKING([if $CC supports -Werror])
143saved_CFLAGS="$CFLAGS"
144CFLAGS="$CFLAGS -Werror"
145AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int main(void) { return 0; }]])],
146 [ AC_MSG_RESULT([yes])
147 WERROR="-Werror"],
148 [ AC_MSG_RESULT([no])
149 WERROR="" ]
150)
151CFLAGS="$saved_CFLAGS"
Damien Miller134d02a2011-01-12 16:00:37 +1100152
Damien Millera8e06ce2003-11-21 23:48:55 +1100153if test "$GCC" = "yes" || test "$GCC" = "egcs"; then
Darren Tuckerd9048862017-03-31 11:04:43 +1100154 OSSH_CHECK_CFLAG_COMPILE([-pipe])
Darren Tuckerfd994372014-01-17 09:53:24 +1100155 OSSH_CHECK_CFLAG_COMPILE([-Qunused-arguments])
156 OSSH_CHECK_CFLAG_COMPILE([-Wunknown-warning-option])
Damien Millerb1763622011-05-20 11:45:25 +1000157 OSSH_CHECK_CFLAG_COMPILE([-Wall])
158 OSSH_CHECK_CFLAG_COMPILE([-Wpointer-arith])
159 OSSH_CHECK_CFLAG_COMPILE([-Wuninitialized])
160 OSSH_CHECK_CFLAG_COMPILE([-Wsign-compare])
161 OSSH_CHECK_CFLAG_COMPILE([-Wformat-security])
Darren Tuckerabbc7a72013-05-10 13:54:23 +1000162 OSSH_CHECK_CFLAG_COMPILE([-Wsizeof-pointer-memaccess])
Damien Millerb1763622011-05-20 11:45:25 +1000163 OSSH_CHECK_CFLAG_COMPILE([-Wpointer-sign], [-Wno-pointer-sign])
164 OSSH_CHECK_CFLAG_COMPILE([-Wunused-result], [-Wno-unused-result])
165 OSSH_CHECK_CFLAG_COMPILE([-fno-strict-aliasing])
Darren Tuckerfd994372014-01-17 09:53:24 +1100166 if test "x$use_toolchain_hardening" = "x1"; then
Damien Miller161af8f2017-09-19 10:18:56 +1000167 OSSH_CHECK_CFLAG_COMPILE([-D_FORTIFY_SOURCE=2])
Darren Tuckerfd994372014-01-17 09:53:24 +1100168 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,relro])
169 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,now])
170 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,noexecstack])
Damien Miller5c2ff5e2014-01-22 21:30:12 +1100171 # NB. -ftrapv expects certain support functions to be present in
172 # the compiler library (libgcc or similar) to detect integer operations
173 # that can overflow. We must check that the result of enabling it
174 # actually links. The test program compiled/linked includes a number
175 # of integer operations that should exercise this.
176 OSSH_CHECK_CFLAG_LINK([-ftrapv])
Darren Tuckerfd994372014-01-17 09:53:24 +1100177 fi
Tim Rice648f8762011-01-26 12:38:57 -0800178 AC_MSG_CHECKING([gcc version])
Darren Tucker3f9545e2005-11-12 15:20:52 +1100179 GCC_VER=`$CC -v 2>&1 | $AWK '/gcc version /{print $3}'`
Tim Rice3db1e3f2005-08-23 17:11:26 -0700180 case $GCC_VER in
Darren Tucker391de5c2007-04-29 14:49:21 +1000181 1.*) no_attrib_nonnull=1 ;;
182 2.8* | 2.9*)
Darren Tucker391de5c2007-04-29 14:49:21 +1000183 no_attrib_nonnull=1
184 ;;
185 2.*) no_attrib_nonnull=1 ;;
Darren Tuckerf0324352005-11-10 21:30:36 +1100186 *) ;;
Tim Rice3db1e3f2005-08-23 17:11:26 -0700187 esac
Tim Rice648f8762011-01-26 12:38:57 -0800188 AC_MSG_RESULT([$GCC_VER])
Damien Millerde3cb0a2005-05-26 20:48:25 +1000189
Tim Rice648f8762011-01-26 12:38:57 -0800190 AC_MSG_CHECKING([if $CC accepts -fno-builtin-memset])
Darren Tucker330c93f2008-06-16 02:27:48 +1000191 saved_CFLAGS="$CFLAGS"
192 CFLAGS="$CFLAGS -fno-builtin-memset"
Tim Rice648f8762011-01-26 12:38:57 -0800193 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <string.h> ]],
194 [[ char b[10]; memset(b, 0, sizeof(b)); ]])],
195 [ AC_MSG_RESULT([yes]) ],
196 [ AC_MSG_RESULT([no])
Darren Tucker330c93f2008-06-16 02:27:48 +1000197 CFLAGS="$saved_CFLAGS" ]
Tim Rice648f8762011-01-26 12:38:57 -0800198 )
Darren Tucker330c93f2008-06-16 02:27:48 +1000199
Darren Tuckerb7918af2008-03-09 11:34:23 +1100200 # -fstack-protector-all doesn't always work for some GCC versions
Darren Tuckerfe1cf972008-03-09 22:50:50 +1100201 # and/or platforms, so we test if we can. If it's not supported
Damien Miller7df2e402008-12-08 09:35:36 +1100202 # on a given platform gcc will emit a warning so we use -Werror.
Darren Tuckerb7918af2008-03-09 11:34:23 +1100203 if test "x$use_stack_protector" = "x1"; then
Darren Tuckerfd994372014-01-17 09:53:24 +1100204 for t in -fstack-protector-strong -fstack-protector-all \
205 -fstack-protector; do
Tim Rice648f8762011-01-26 12:38:57 -0800206 AC_MSG_CHECKING([if $CC supports $t])
Darren Tuckerb7918af2008-03-09 11:34:23 +1100207 saved_CFLAGS="$CFLAGS"
208 saved_LDFLAGS="$LDFLAGS"
Darren Tuckerfe1cf972008-03-09 22:50:50 +1100209 CFLAGS="$CFLAGS $t -Werror"
210 LDFLAGS="$LDFLAGS $t -Werror"
211 AC_LINK_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -0800212 [AC_LANG_PROGRAM([[ #include <stdio.h> ]],
213 [[
214 char x[256];
215 snprintf(x, sizeof(x), "XXX");
216 ]])],
217 [ AC_MSG_RESULT([yes])
Darren Tuckerfe1cf972008-03-09 22:50:50 +1100218 CFLAGS="$saved_CFLAGS $t"
219 LDFLAGS="$saved_LDFLAGS $t"
Tim Rice648f8762011-01-26 12:38:57 -0800220 AC_MSG_CHECKING([if $t works])
Darren Tuckerb7918af2008-03-09 11:34:23 +1100221 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -0800222 [AC_LANG_PROGRAM([[ #include <stdio.h> ]],
223 [[
224 char x[256];
225 snprintf(x, sizeof(x), "XXX");
226 ]])],
227 [ AC_MSG_RESULT([yes])
Darren Tuckerb7918af2008-03-09 11:34:23 +1100228 break ],
Tim Rice648f8762011-01-26 12:38:57 -0800229 [ AC_MSG_RESULT([no]) ],
Darren Tuckerb7918af2008-03-09 11:34:23 +1100230 [ AC_MSG_WARN([cross compiling: cannot test])
231 break ]
Darren Tuckerfe1cf972008-03-09 22:50:50 +1100232 )
Darren Tuckerb7918af2008-03-09 11:34:23 +1100233 ],
Tim Rice648f8762011-01-26 12:38:57 -0800234 [ AC_MSG_RESULT([no]) ]
Darren Tuckerb7918af2008-03-09 11:34:23 +1100235 )
236 CFLAGS="$saved_CFLAGS"
237 LDFLAGS="$saved_LDFLAGS"
238 done
239 fi
Darren Tucker319b3d92007-12-02 21:02:22 +1100240
Darren Tucker67b37032005-06-03 17:58:31 +1000241 if test -z "$have_llong_max"; then
242 # retry LLONG_MAX with -std=gnu99, needed on some Linuxes
243 unset ac_cv_have_decl_LLONG_MAX
244 saved_CFLAGS="$CFLAGS"
245 CFLAGS="$CFLAGS -std=gnu99"
Tim Rice648f8762011-01-26 12:38:57 -0800246 AC_CHECK_DECL([LLONG_MAX],
Darren Tucker67b37032005-06-03 17:58:31 +1000247 [have_llong_max=1],
248 [CFLAGS="$saved_CFLAGS"],
249 [#include <limits.h>]
250 )
251 fi
Damien Miller166bd442000-03-16 10:48:25 +1100252fi
253
Darren Tucker951b53b2013-02-08 11:50:09 +1100254AC_MSG_CHECKING([if compiler allows __attribute__ on return types])
255AC_COMPILE_IFELSE(
256 [AC_LANG_PROGRAM([[
257#include <stdlib.h>
258__attribute__((__unused__)) static void foo(void){return;}]],
259 [[ exit(0); ]])],
260 [ AC_MSG_RESULT([yes]) ],
261 [ AC_MSG_RESULT([no])
262 AC_DEFINE(NO_ATTRIBUTE_ON_RETURN_TYPE, 1,
263 [compiler does not accept __attribute__ on return types]) ]
264)
265
Darren Tucker391de5c2007-04-29 14:49:21 +1000266if test "x$no_attrib_nonnull" != "x1" ; then
Tim Rice648f8762011-01-26 12:38:57 -0800267 AC_DEFINE([HAVE_ATTRIBUTE__NONNULL__], [1], [Have attribute nonnull])
Darren Tucker391de5c2007-04-29 14:49:21 +1000268fi
269
Tim Rice648f8762011-01-26 12:38:57 -0800270AC_ARG_WITH([rpath],
Tim Rice88368a32003-12-08 12:35:59 -0800271 [ --without-rpath Disable auto-added -R linker paths],
272 [
Tim Riceeae17cc2005-03-17 16:52:20 -0800273 if test "x$withval" = "xno" ; then
Tim Rice88368a32003-12-08 12:35:59 -0800274 need_dash_r=""
275 fi
276 if test "x$withval" = "xyes" ; then
277 need_dash_r=1
278 fi
279 ]
280)
281
Tim Rice1cfab232006-10-03 09:34:35 -0700282# Allow user to specify flags
Tim Rice648f8762011-01-26 12:38:57 -0800283AC_ARG_WITH([cflags],
Tim Rice1cfab232006-10-03 09:34:35 -0700284 [ --with-cflags Specify additional flags to pass to compiler],
285 [
286 if test -n "$withval" && test "x$withval" != "xno" && \
287 test "x${withval}" != "xyes"; then
288 CFLAGS="$CFLAGS $withval"
289 fi
290 ]
291)
Damien Millerde35c382017-09-08 12:38:31 +1000292
293AC_ARG_WITH([cflags-after],
294 [ --with-cflags-after Specify additional flags to pass to compiler after configure],
295 [
296 if test -n "$withval" && test "x$withval" != "xno" && \
297 test "x${withval}" != "xyes"; then
298 CFLAGS_AFTER="$withval"
299 fi
300 ]
301)
Tim Rice648f8762011-01-26 12:38:57 -0800302AC_ARG_WITH([cppflags],
Tim Rice1cfab232006-10-03 09:34:35 -0700303 [ --with-cppflags Specify additional flags to pass to preprocessor] ,
304 [
305 if test -n "$withval" && test "x$withval" != "xno" && \
306 test "x${withval}" != "xyes"; then
307 CPPFLAGS="$CPPFLAGS $withval"
308 fi
309 ]
310)
Tim Rice648f8762011-01-26 12:38:57 -0800311AC_ARG_WITH([ldflags],
Tim Rice1cfab232006-10-03 09:34:35 -0700312 [ --with-ldflags Specify additional flags to pass to linker],
313 [
314 if test -n "$withval" && test "x$withval" != "xno" && \
315 test "x${withval}" != "xyes"; then
316 LDFLAGS="$LDFLAGS $withval"
317 fi
318 ]
319)
Damien Millerde35c382017-09-08 12:38:31 +1000320AC_ARG_WITH([ldflags-after],
321 [ --with-ldflags-after Specify additional flags to pass to linker after configure],
322 [
323 if test -n "$withval" && test "x$withval" != "xno" && \
324 test "x${withval}" != "xyes"; then
325 LDFLAGS_AFTER="$withval"
326 fi
327 ]
328)
Tim Rice648f8762011-01-26 12:38:57 -0800329AC_ARG_WITH([libs],
Tim Rice1cfab232006-10-03 09:34:35 -0700330 [ --with-libs Specify additional libraries to link with],
331 [
332 if test -n "$withval" && test "x$withval" != "xno" && \
333 test "x${withval}" != "xyes"; then
334 LIBS="$LIBS $withval"
335 fi
336 ]
337)
Tim Rice648f8762011-01-26 12:38:57 -0800338AC_ARG_WITH([Werror],
Tim Rice1cfab232006-10-03 09:34:35 -0700339 [ --with-Werror Build main code with -Werror],
340 [
341 if test -n "$withval" && test "x$withval" != "xno"; then
342 werror_flags="-Werror"
343 if test "x${withval}" != "xyes"; then
344 werror_flags="$withval"
345 fi
346 fi
347 ]
348)
349
Tim Rice648f8762011-01-26 12:38:57 -0800350AC_CHECK_HEADERS([ \
Damien Miller1ff130d2013-12-07 11:51:51 +1100351 blf.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700352 bstring.h \
353 crypt.h \
354 crypto/sha2.h \
355 dirent.h \
356 endian.h \
Damien Miller91f40d82013-02-22 11:37:00 +1100357 elf.h \
Darren Tucker6310ef22016-07-13 14:42:35 +1000358 err.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700359 features.h \
360 fcntl.h \
361 floatingpoint.h \
362 getopt.h \
363 glob.h \
364 ia.h \
365 iaf.h \
Darren Tucker6d725682014-01-17 19:17:34 +1100366 inttypes.h \
Darren Tuckerf3f2cc82016-07-11 17:23:38 +1000367 langinfo.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700368 limits.h \
Darren Tuckerae133d42013-06-06 08:30:20 +1000369 locale.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700370 login.h \
371 maillock.h \
372 ndir.h \
373 net/if_tun.h \
374 netdb.h \
375 netgroup.h \
376 pam/pam_appl.h \
377 paths.h \
Darren Tuckerfebf0f52007-06-25 22:15:12 +1000378 poll.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700379 pty.h \
380 readpassphrase.h \
381 rpc/types.h \
382 security/pam_appl.h \
383 sha2.h \
384 shadow.h \
385 stddef.h \
386 stdint.h \
387 string.h \
388 strings.h \
389 sys/audit.h \
390 sys/bitypes.h \
391 sys/bsdtty.h \
392 sys/cdefs.h \
393 sys/dir.h \
394 sys/mman.h \
395 sys/ndir.h \
Darren Tucker7c92a652007-09-27 07:00:09 +1000396 sys/poll.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700397 sys/prctl.h \
398 sys/pstat.h \
Darren Tucker5ee3fb52016-11-01 08:12:33 +1100399 sys/ptrace.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700400 sys/select.h \
401 sys/stat.h \
402 sys/stream.h \
403 sys/stropts.h \
404 sys/strtio.h \
Darren Tucker5b2e2ba2008-06-08 09:25:28 +1000405 sys/statvfs.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700406 sys/sysmacros.h \
Damien Miller32354732017-10-25 11:25:43 +1100407 sys/sysctl.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700408 sys/time.h \
409 sys/timers.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700410 time.h \
411 tmpdir.h \
412 ttyent.h \
Tim Riceaa8954f2007-05-09 15:57:43 -0700413 ucred.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700414 unistd.h \
415 usersec.h \
416 util.h \
417 utime.h \
418 utmp.h \
419 utmpx.h \
420 vis.h \
Darren Tuckerf3f2cc82016-07-11 17:23:38 +1000421 wchar.h \
Tim Rice648f8762011-01-26 12:38:57 -0800422])
Tim Rice1cfab232006-10-03 09:34:35 -0700423
Darren Tuckerdd9d9b32017-08-28 16:48:27 +1000424# sys/capsicum.h requires sys/types.h
425AC_CHECK_HEADERS([sys/capsicum.h], [], [], [
426#ifdef HAVE_SYS_TYPES_H
427# include <sys/types.h>
428#endif
429])
430
Damien Miller32354732017-10-25 11:25:43 +1100431# net/route.h requires sys/socket.h
432AC_CHECK_HEADERS([net/route.h], [], [], [
433#include <sys/socket.h>
434])
435
Tim Rice1cfab232006-10-03 09:34:35 -0700436# lastlog.h requires sys/time.h to be included first on Solaris
Tim Rice648f8762011-01-26 12:38:57 -0800437AC_CHECK_HEADERS([lastlog.h], [], [], [
Tim Rice1cfab232006-10-03 09:34:35 -0700438#ifdef HAVE_SYS_TIME_H
439# include <sys/time.h>
440#endif
441])
442
443# sys/ptms.h requires sys/stream.h to be included first on Solaris
Tim Rice648f8762011-01-26 12:38:57 -0800444AC_CHECK_HEADERS([sys/ptms.h], [], [], [
Tim Rice1cfab232006-10-03 09:34:35 -0700445#ifdef HAVE_SYS_STREAM_H
446# include <sys/stream.h>
447#endif
448])
449
450# login_cap.h requires sys/types.h on NetBSD
Tim Rice648f8762011-01-26 12:38:57 -0800451AC_CHECK_HEADERS([login_cap.h], [], [], [
Tim Rice1cfab232006-10-03 09:34:35 -0700452#include <sys/types.h>
453])
454
Darren Tuckerc4b22ca2009-07-12 21:56:29 +1000455# older BSDs need sys/param.h before sys/mount.h
Tim Rice648f8762011-01-26 12:38:57 -0800456AC_CHECK_HEADERS([sys/mount.h], [], [], [
Darren Tuckerc4b22ca2009-07-12 21:56:29 +1000457#include <sys/param.h>
458])
459
Darren Tuckeref4901c2013-06-03 01:59:13 +1000460# Android requires sys/socket.h to be included before sys/un.h
461AC_CHECK_HEADERS([sys/un.h], [], [], [
Darren Tucker0b43ffe2013-06-03 09:30:44 +1000462#include <sys/types.h>
Darren Tucker16cac192013-06-04 12:55:24 +1000463#include <sys/socket.h>
Darren Tuckeref4901c2013-06-03 01:59:13 +1000464])
465
Damien Miller1b06dc32006-08-31 03:24:41 +1000466# Messages for features tested for in target-specific section
467SIA_MSG="no"
468SPC_MSG="no"
Darren Tucker97528352010-11-05 12:03:05 +1100469SP_MSG="no"
Damien Miller4626cba2016-01-08 14:24:56 +1100470SPP_MSG="no"
471
472# Support for Solaris/Illumos privileges (this test is used by both
473# the --with-solaris-privs option and --with-sandbox=solaris).
474SOLARIS_PRIVS="no"
Damien Miller1b06dc32006-08-31 03:24:41 +1000475
Damien Millera22ba012000-03-02 23:09:20 +1100476# Check for some target-specific stuff
Damien Miller76112de1999-12-21 11:18:08 +1100477case "$host" in
Damien Miller75b1d102000-01-07 14:01:41 +1100478*-*-aix*)
Darren Tucker9216c372006-09-18 23:17:40 +1000479 # Some versions of VAC won't allow macro redefinitions at
480 # -qlanglevel=ansi, and autoconf 2.60 sometimes insists on using that
481 # particularly with older versions of vac or xlc.
482 # It also throws errors about null macro argments, but these are
483 # not fatal.
Tim Rice648f8762011-01-26 12:38:57 -0800484 AC_MSG_CHECKING([if compiler allows macro redefinitions])
Darren Tucker9216c372006-09-18 23:17:40 +1000485 AC_COMPILE_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -0800486 [AC_LANG_PROGRAM([[
Darren Tucker9216c372006-09-18 23:17:40 +1000487#define testmacro foo
Tim Rice648f8762011-01-26 12:38:57 -0800488#define testmacro bar]],
489 [[ exit(0); ]])],
490 [ AC_MSG_RESULT([yes]) ],
491 [ AC_MSG_RESULT([no])
Darren Tucker9216c372006-09-18 23:17:40 +1000492 CC="`echo $CC | sed 's/-qlanglvl\=ansi//g'`"
493 LD="`echo $LD | sed 's/-qlanglvl\=ansi//g'`"
494 CFLAGS="`echo $CFLAGS | sed 's/-qlanglvl\=ansi//g'`"
495 CPPFLAGS="`echo $CPPFLAGS | sed 's/-qlanglvl\=ansi//g'`"
496 ]
497 )
498
Damien Millera8e06ce2003-11-21 23:48:55 +1100499 AC_MSG_CHECKING([how to specify blibpath for linker ($LD)])
Damien Millereab4bae2003-04-29 23:22:40 +1000500 if (test -z "$blibpath"); then
Tim Ricefcb62202004-01-23 18:35:16 -0800501 blibpath="/usr/lib:/lib"
Damien Miller29ea30d2000-03-17 10:54:15 +1100502 fi
Damien Millereab4bae2003-04-29 23:22:40 +1000503 saved_LDFLAGS="$LDFLAGS"
Darren Tuckerbdc12122006-07-06 11:56:25 +1000504 if test "$GCC" = "yes"; then
505 flags="-Wl,-blibpath: -Wl,-rpath, -blibpath:"
506 else
507 flags="-blibpath: -Wl,-blibpath: -Wl,-rpath,"
508 fi
509 for tryflags in $flags ;do
Damien Millereab4bae2003-04-29 23:22:40 +1000510 if (test -z "$blibflags"); then
511 LDFLAGS="$saved_LDFLAGS $tryflags$blibpath"
Tim Rice648f8762011-01-26 12:38:57 -0800512 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
513 [blibflags=$tryflags], [])
Damien Millereab4bae2003-04-29 23:22:40 +1000514 fi
515 done
516 if (test -z "$blibflags"); then
Tim Rice648f8762011-01-26 12:38:57 -0800517 AC_MSG_RESULT([not found])
Damien Millereab4bae2003-04-29 23:22:40 +1000518 AC_MSG_ERROR([*** must be able to specify blibpath on AIX - check config.log])
519 else
Tim Rice648f8762011-01-26 12:38:57 -0800520 AC_MSG_RESULT([$blibflags])
Damien Millereab4bae2003-04-29 23:22:40 +1000521 fi
522 LDFLAGS="$saved_LDFLAGS"
Darren Tucker5c6a91a2003-07-14 16:21:44 +1000523 dnl Check for authenticate. Might be in libs.a on older AIXes
Tim Rice648f8762011-01-26 12:38:57 -0800524 AC_CHECK_FUNC([authenticate], [AC_DEFINE([WITH_AIXAUTHENTICATE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700525 [Define if you want to enable AIX4's authenticate function])],
Tim Rice648f8762011-01-26 12:38:57 -0800526 [AC_CHECK_LIB([s], [authenticate],
527 [ AC_DEFINE([WITH_AIXAUTHENTICATE])
Tim Ricee958ed32002-07-05 07:12:33 -0700528 LIBS="$LIBS -ls"
529 ])
530 ])
Darren Tucker3c774c52005-02-16 22:49:31 +1100531 dnl Check for various auth function declarations in headers.
Darren Tucker04cfbe02005-02-20 23:27:11 +1100532 AC_CHECK_DECLS([authenticate, loginrestrictions, loginsuccess,
Darren Tuckere66519d2005-03-21 22:46:34 +1100533 passwdexpired, setauthdb], , , [#include <usersec.h>])
Darren Tucker5c6a91a2003-07-14 16:21:44 +1000534 dnl Check if loginfailed is declared and takes 4 arguments (AIX >= 5.2)
Tim Rice648f8762011-01-26 12:38:57 -0800535 AC_CHECK_DECLS([loginfailed],
536 [AC_MSG_CHECKING([if loginfailed takes 4 arguments])
537 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <usersec.h> ]],
538 [[ (void)loginfailed("user","host","tty",0); ]])],
539 [AC_MSG_RESULT([yes])
540 AC_DEFINE([AIX_LOGINFAILED_4ARG], [1],
541 [Define if your AIX loginfailed() function
542 takes 4 arguments (AIX >= 5.2)])], [AC_MSG_RESULT([no])
543 ])],
544 [],
545 [#include <usersec.h>]
Darren Tucker5c6a91a2003-07-14 16:21:44 +1000546 )
Tim Rice648f8762011-01-26 12:38:57 -0800547 AC_CHECK_FUNCS([getgrset setauthdb])
548 AC_CHECK_DECL([F_CLOSEM],
549 AC_DEFINE([HAVE_FCNTL_CLOSEM], [1], [Use F_CLOSEM fcntl for closefrom]),
Darren Tucker3083bc22006-08-17 19:35:49 +1000550 [],
551 [ #include <limits.h>
552 #include <fcntl.h> ]
553 )
Darren Tucker691d5232005-02-15 21:45:57 +1100554 check_for_aix_broken_getaddrinfo=1
Tim Rice648f8762011-01-26 12:38:57 -0800555 AC_DEFINE([BROKEN_REALPATH], [1], [Define if you have a broken realpath.])
556 AC_DEFINE([SETEUID_BREAKS_SETUID], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700557 [Define if your platform breaks doing a seteuid before a setuid])
Tim Rice648f8762011-01-26 12:38:57 -0800558 AC_DEFINE([BROKEN_SETREUID], [1], [Define if your setreuid() is broken])
559 AC_DEFINE([BROKEN_SETREGID], [1], [Define if your setregid() is broken])
andre60f3c982000-06-03 16:18:19 +0000560 dnl AIX handles lastlog as part of its login message
Tim Rice648f8762011-01-26 12:38:57 -0800561 AC_DEFINE([DISABLE_LASTLOG], [1], [Define if you don't want to use lastlog])
562 AC_DEFINE([LOGIN_NEEDS_UTMPX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700563 [Some systems need a utmpx entry for /bin/login to work])
Tim Rice648f8762011-01-26 12:38:57 -0800564 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV],
Tim Rice7df8d392005-09-19 09:33:39 -0700565 [Define to a Set Process Title type if your system is
566 supported by bsd-setproctitle.c])
Tim Rice648f8762011-01-26 12:38:57 -0800567 AC_DEFINE([SSHPAM_CHAUTHTOK_NEEDS_RUID], [1],
Darren Tucker91d25a02005-11-26 22:24:09 +1100568 [AIX 5.2 and 5.3 (and presumably newer) require this])
Tim Rice648f8762011-01-26 12:38:57 -0800569 AC_DEFINE([PTY_ZEROREAD], [1], [read(1) can return 0 for a non-closed fd])
Darren Tuckeraa97d132013-03-12 11:31:05 +1100570 AC_DEFINE([PLATFORM_SYS_DIR_UID], 2, [System dirs owned by bin (uid 2)])
Damien Miller75b1d102000-01-07 14:01:41 +1100571 ;;
Darren Tucker898ac932013-06-03 02:03:25 +1000572*-*-android*)
573 AC_DEFINE([DISABLE_UTMP], [1], [Define if you don't want to use utmp])
574 AC_DEFINE([DISABLE_WTMP], [1], [Define if you don't want to use wtmp])
575 ;;
Damien Millerbac2d8a2000-09-05 16:13:06 +1100576*-*-cygwin*)
Damien Millerc8936ac2003-02-11 10:04:03 +1100577 check_for_libcrypt_later=1
Darren Tucker573e3872007-03-02 17:50:03 +1100578 LIBS="$LIBS /usr/lib/textreadmode.o"
Tim Rice648f8762011-01-26 12:38:57 -0800579 AC_DEFINE([HAVE_CYGWIN], [1], [Define if you are on Cygwin])
580 AC_DEFINE([USE_PIPES], [1], [Use PIPES instead of a socketpair()])
Damien Miller4626cba2016-01-08 14:24:56 +1100581 AC_DEFINE([NO_UID_RESTORATION_TEST], [1],
582 [Define to disable UID restoration test])
Tim Rice648f8762011-01-26 12:38:57 -0800583 AC_DEFINE([DISABLE_SHADOW], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700584 [Define if you want to disable shadow passwords])
Tim Rice648f8762011-01-26 12:38:57 -0800585 AC_DEFINE([NO_X11_UNIX_SOCKETS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700586 [Define if X11 doesn't support AF_UNIX sockets on that system])
Tim Rice648f8762011-01-26 12:38:57 -0800587 AC_DEFINE([DISABLE_FD_PASSING], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700588 [Define if your platform needs to skip post auth
589 file descriptor passing])
Tim Rice648f8762011-01-26 12:38:57 -0800590 AC_DEFINE([SSH_IOBUFSZ], [65535], [Windows is sensitive to read buffer size])
Darren Tuckerfdce3732014-01-18 21:12:42 +1100591 AC_DEFINE([FILESYSTEM_NO_BACKSLASH], [1], [File names may not contain backslash characters])
592 # Cygwin defines optargs, optargs as declspec(dllimport) for historical
593 # reasons which cause compile warnings, so we disable those warnings.
594 OSSH_CHECK_CFLAG_COMPILE([-Wno-attributes])
Damien Millerbac2d8a2000-09-05 16:13:06 +1100595 ;;
Ben Lindstrom58055132001-02-15 18:34:29 +0000596*-*-dgux*)
Tim Rice648f8762011-01-26 12:38:57 -0800597 AC_DEFINE([IP_TOS_IS_BROKEN], [1],
Tim Ricea74000e2009-03-18 11:25:02 -0700598 [Define if your system choked on IP TOS setting])
Tim Rice648f8762011-01-26 12:38:57 -0800599 AC_DEFINE([SETEUID_BREAKS_SETUID])
600 AC_DEFINE([BROKEN_SETREUID])
601 AC_DEFINE([BROKEN_SETREGID])
Ben Lindstrom58055132001-02-15 18:34:29 +0000602 ;;
Ben Lindstromfed7bb42001-07-15 18:30:42 +0000603*-*-darwin*)
Damien Miller852472a2014-01-22 16:31:18 +1100604 use_pie=auto
Tim Rice648f8762011-01-26 12:38:57 -0800605 AC_MSG_CHECKING([if we have working getaddrinfo])
606 AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <mach-o/dyld.h>
Damien Millerfc93d4b2002-09-04 23:26:29 +1000607main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
608 exit(0);
609 else
610 exit(1);
Tim Rice648f8762011-01-26 12:38:57 -0800611}
612 ]])],
613 [AC_MSG_RESULT([working])],
614 [AC_MSG_RESULT([buggy])
615 AC_DEFINE([BROKEN_GETADDRINFO], [1],
616 [getaddrinfo is broken (if present)])
617 ],
618 [AC_MSG_RESULT([assume it is working])])
619 AC_DEFINE([SETEUID_BREAKS_SETUID])
620 AC_DEFINE([BROKEN_SETREUID])
621 AC_DEFINE([BROKEN_SETREGID])
622 AC_DEFINE([BROKEN_GLOB], [1], [OS X glob does not do what we expect])
623 AC_DEFINE_UNQUOTED([BIND_8_COMPAT], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700624 [Define if your resolver libs need this for getrrsetbyname])
Tim Rice648f8762011-01-26 12:38:57 -0800625 AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
626 AC_DEFINE([SSH_TUN_COMPAT_AF], [1],
Darren Tucker3eb48342006-06-23 21:05:12 +1000627 [Use tunnel device compatibility to OpenBSD])
Tim Rice648f8762011-01-26 12:38:57 -0800628 AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
Darren Tucker3eb48342006-06-23 21:05:12 +1000629 [Prepend the address family to IP tunnel traffic])
Tim Rice648f8762011-01-26 12:38:57 -0800630 m4_pattern_allow([AU_IPv])
Tim Ricee1d93702016-05-31 11:13:22 -0700631 AC_CHECK_DECL([AU_IPv4], [],
Tim Rice648f8762011-01-26 12:38:57 -0800632 AC_DEFINE([AU_IPv4], [0], [System only supports IPv4 audit records])
Darren Tuckeracada072008-02-25 21:05:04 +1100633 [#include <bsm/audit.h>]
Tim Rice648f8762011-01-26 12:38:57 -0800634 AC_DEFINE([LASTLOG_WRITE_PUTUTXLINE], [1],
Damien Miller20e231f2009-02-12 13:12:21 +1100635 [Define if pututxline updates lastlog too])
Darren Tuckeracada072008-02-25 21:05:04 +1100636 )
Damien Millerc09182f2011-06-03 12:11:38 +1000637 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV],
638 [Define to a Set Process Title type if your system is
639 supported by bsd-setproctitle.c])
Damien Millercd5e52e2011-06-27 07:18:18 +1000640 AC_CHECK_FUNCS([sandbox_init])
641 AC_CHECK_HEADERS([sandbox.h])
Damien Miller39f303b2016-02-23 12:56:59 +1100642 AC_CHECK_LIB([sandbox], [sandbox_apply], [
643 SSHDLIBS="$SSHDLIBS -lsandbox"
644 ])
Ben Lindstromfed7bb42001-07-15 18:30:42 +0000645 ;;
Darren Tucker57b29202006-09-10 20:25:51 +1000646*-*-dragonfly*)
647 SSHDLIBS="$SSHDLIBS -lcrypt"
Darren Tucker882abfd2013-11-09 00:17:41 +1100648 TEST_MALLOC_OPTIONS="AFGJPRX"
Darren Tucker57b29202006-09-10 20:25:51 +1000649 ;;
Tim Ricee1d93702016-05-31 11:13:22 -0700650*-*-haiku*)
Darren Tucker5faa52d2016-08-02 15:22:40 +1000651 LIBS="$LIBS -lbsd "
652 AC_CHECK_LIB([network], [socket])
653 AC_DEFINE([HAVE_U_INT64_T])
654 MANTYPE=man
655 ;;
Darren Tuckerfd333282005-05-28 18:31:42 +1000656*-*-hpux*)
657 # first we define all of the options common to all HP-UX releases
Kevin Steves315f8b72001-06-28 00:24:41 +0000658 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
Damien Miller9a947342000-08-30 10:03:33 +1100659 IPADDR_IN_DISPLAY=yes
Tim Rice648f8762011-01-26 12:38:57 -0800660 AC_DEFINE([USE_PIPES])
Tim Rice648f8762011-01-26 12:38:57 -0800661 AC_DEFINE([LOGIN_NEEDS_UTMPX])
662 AC_DEFINE([LOCKED_PASSWD_STRING], ["*"],
Tim Rice7df8d392005-09-19 09:33:39 -0700663 [String used in /etc/passwd to denote locked account])
Tim Rice648f8762011-01-26 12:38:57 -0800664 AC_DEFINE([SPT_TYPE], [SPT_PSTAT])
Darren Tuckeraa97d132013-03-12 11:31:05 +1100665 AC_DEFINE([PLATFORM_SYS_DIR_UID], 2, [System dirs owned by bin (uid 2)])
Tim Rice90f42b02011-06-02 18:17:49 -0700666 maildir="/var/mail"
Tim Ricef028f1e2002-07-19 12:41:10 -0700667 LIBS="$LIBS -lsec"
Tim Rice648f8762011-01-26 12:38:57 -0800668 AC_CHECK_LIB([xnet], [t_error], ,
669 [AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***])])
Darren Tuckerfd333282005-05-28 18:31:42 +1000670
671 # next, we define all of the options specific to major releases
672 case "$host" in
673 *-*-hpux10*)
674 if test -z "$GCC"; then
675 CFLAGS="$CFLAGS -Ae"
676 fi
677 ;;
678 *-*-hpux11*)
Tim Rice648f8762011-01-26 12:38:57 -0800679 AC_DEFINE([PAM_SUN_CODEBASE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700680 [Define if you are using Solaris-derived PAM which
681 passes pam_messages to the conversation function
682 with an extra level of indirection])
Tim Rice648f8762011-01-26 12:38:57 -0800683 AC_DEFINE([DISABLE_UTMP], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700684 [Define if you don't want to use utmp])
Tim Rice648f8762011-01-26 12:38:57 -0800685 AC_DEFINE([USE_BTMP], [1], [Use btmp to log bad logins])
Darren Tuckerfd333282005-05-28 18:31:42 +1000686 check_for_hpux_broken_getaddrinfo=1
687 check_for_conflicting_getspnam=1
688 ;;
689 esac
690
691 # lastly, we define options specific to minor releases
692 case "$host" in
693 *-*-hpux10.26)
Tim Rice648f8762011-01-26 12:38:57 -0800694 AC_DEFINE([HAVE_SECUREWARE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700695 [Define if you have SecureWare-based
696 protected password database])
Darren Tuckerfd333282005-05-28 18:31:42 +1000697 disable_ptmx_check=yes
698 LIBS="$LIBS -lsecpw"
699 ;;
700 esac
Damien Miller1bead332000-04-30 00:47:29 +1000701 ;;
Damien Millerbeb4ba51999-12-28 15:09:35 +1100702*-*-irix5*)
Damien Miller190d5a82000-09-30 09:43:19 +1100703 PATH="$PATH:/usr/etc"
Tim Rice648f8762011-01-26 12:38:57 -0800704 AC_DEFINE([BROKEN_INET_NTOA], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700705 [Define if you system's inet_ntoa is busted
706 (e.g. Irix gcc issue)])
Tim Rice648f8762011-01-26 12:38:57 -0800707 AC_DEFINE([SETEUID_BREAKS_SETUID])
708 AC_DEFINE([BROKEN_SETREUID])
709 AC_DEFINE([BROKEN_SETREGID])
710 AC_DEFINE([WITH_ABBREV_NO_TTY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700711 [Define if you shouldn't strip 'tty' from your
712 ttyname in [uw]tmp])
Tim Rice648f8762011-01-26 12:38:57 -0800713 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Damien Miller1808f382000-01-06 12:03:12 +1100714 ;;
715*-*-irix6*)
Damien Miller190d5a82000-09-30 09:43:19 +1100716 PATH="$PATH:/usr/etc"
Tim Rice648f8762011-01-26 12:38:57 -0800717 AC_DEFINE([WITH_IRIX_ARRAY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700718 [Define if you have/want arrays
719 (cluster-wide session managment, not C arrays)])
Tim Rice648f8762011-01-26 12:38:57 -0800720 AC_DEFINE([WITH_IRIX_PROJECT], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700721 [Define if you want IRIX project management])
Tim Rice648f8762011-01-26 12:38:57 -0800722 AC_DEFINE([WITH_IRIX_AUDIT], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700723 [Define if you want IRIX audit trails])
Tim Rice648f8762011-01-26 12:38:57 -0800724 AC_CHECK_FUNC([jlimit_startjob], [AC_DEFINE([WITH_IRIX_JOBS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700725 [Define if you want IRIX kernel jobs])])
Tim Rice648f8762011-01-26 12:38:57 -0800726 AC_DEFINE([BROKEN_INET_NTOA])
727 AC_DEFINE([SETEUID_BREAKS_SETUID])
728 AC_DEFINE([BROKEN_SETREUID])
729 AC_DEFINE([BROKEN_SETREGID])
730 AC_DEFINE([BROKEN_UPDWTMPX], [1], [updwtmpx is broken (if present)])
731 AC_DEFINE([WITH_ABBREV_NO_TTY])
732 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Damien Millerbeb4ba51999-12-28 15:09:35 +1100733 ;;
Damien Miller90551722009-02-16 15:37:03 +1100734*-*-k*bsd*-gnu | *-*-kopensolaris*-gnu)
735 check_for_libcrypt_later=1
Tim Rice648f8762011-01-26 12:38:57 -0800736 AC_DEFINE([PAM_TTY_KLUDGE])
737 AC_DEFINE([LOCKED_PASSWD_PREFIX], ["!"])
738 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV])
739 AC_DEFINE([_PATH_BTMP], ["/var/log/btmp"], [log for bad login attempts])
740 AC_DEFINE([USE_BTMP], [1], [Use btmp to log bad logins])
Damien Miller90551722009-02-16 15:37:03 +1100741 ;;
Damien Millerb29ea912000-01-15 14:12:03 +1100742*-*-linux*)
743 no_dev_ptmx=1
Damien Miller852472a2014-01-22 16:31:18 +1100744 use_pie=auto
Damien Millera64b57a2001-01-17 10:44:13 +1100745 check_for_libcrypt_later=1
Darren Tucker70a3d552003-08-21 17:58:29 +1000746 check_for_openpty_ctty_bug=1
Darren Tuckerc61d5ec2017-02-03 14:10:34 +1100747 dnl Target SUSv3/POSIX.1-2001 plus BSD specifics.
748 dnl _DEFAULT_SOURCE is the new name for _BSD_SOURCE
749 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_DEFAULT_SOURCE"
Tim Rice648f8762011-01-26 12:38:57 -0800750 AC_DEFINE([PAM_TTY_KLUDGE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700751 [Work around problematic Linux PAM modules handling of PAM_TTY])
Tim Rice648f8762011-01-26 12:38:57 -0800752 AC_DEFINE([LOCKED_PASSWD_PREFIX], ["!"],
Tim Rice7df8d392005-09-19 09:33:39 -0700753 [String used in /etc/passwd to denote locked account])
Tim Rice648f8762011-01-26 12:38:57 -0800754 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV])
755 AC_DEFINE([LINK_OPNOTSUPP_ERRNO], [EPERM],
Tim Rice7df8d392005-09-19 09:33:39 -0700756 [Define to whatever link() returns for "not supported"
757 if it doesn't return EOPNOTSUPP.])
Tim Rice648f8762011-01-26 12:38:57 -0800758 AC_DEFINE([_PATH_BTMP], ["/var/log/btmp"], [log for bad login attempts])
759 AC_DEFINE([USE_BTMP])
760 AC_DEFINE([LINUX_OOM_ADJUST], [1], [Adjust Linux out-of-memory killer])
Damien Miller7bcb0892000-03-11 20:45:40 +1100761 inet6_default_4in6=yes
Darren Tucker3c016542003-05-02 20:48:21 +1000762 case `uname -r` in
Darren Tuckerc437cda2003-05-10 17:05:46 +1000763 1.*|2.0.*)
Tim Rice648f8762011-01-26 12:38:57 -0800764 AC_DEFINE([BROKEN_CMSG_TYPE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700765 [Define if cmsg_type is not passed correctly])
Darren Tucker3c016542003-05-02 20:48:21 +1000766 ;;
Darren Tucker3c016542003-05-02 20:48:21 +1000767 esac
Damien Miller89e03ba2005-12-31 16:42:03 +1100768 # tun(4) forwarding compat code
Tim Rice648f8762011-01-26 12:38:57 -0800769 AC_CHECK_HEADERS([linux/if_tun.h])
Damien Millerbd4e4102006-01-01 21:03:30 +1100770 if test "x$ac_cv_header_linux_if_tun_h" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -0800771 AC_DEFINE([SSH_TUN_LINUX], [1],
Damien Miller89e03ba2005-12-31 16:42:03 +1100772 [Open tunnel devices the Linux tun/tap way])
Tim Rice648f8762011-01-26 12:38:57 -0800773 AC_DEFINE([SSH_TUN_COMPAT_AF], [1],
Damien Miller89e03ba2005-12-31 16:42:03 +1100774 [Use tunnel device compatibility to OpenBSD])
Tim Rice648f8762011-01-26 12:38:57 -0800775 AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
Damien Miller89e03ba2005-12-31 16:42:03 +1100776 [Prepend the address family to IP tunnel traffic])
777 fi
Darren Tucker60395f92012-07-03 14:31:18 +1000778 AC_CHECK_HEADERS([linux/seccomp.h linux/filter.h linux/audit.h], [],
779 [], [#include <linux/types.h>])
Damien Miller91f40d82013-02-22 11:37:00 +1100780 AC_MSG_CHECKING([for seccomp architecture])
781 seccomp_audit_arch=
Damien Millere0956e32012-04-04 11:27:54 +1000782 case "$host" in
783 x86_64-*)
Damien Miller91f40d82013-02-22 11:37:00 +1100784 seccomp_audit_arch=AUDIT_ARCH_X86_64
Damien Millere0956e32012-04-04 11:27:54 +1000785 ;;
786 i*86-*)
Damien Miller91f40d82013-02-22 11:37:00 +1100787 seccomp_audit_arch=AUDIT_ARCH_I386
Damien Millere0956e32012-04-04 11:27:54 +1000788 ;;
Damien Miller99f33d72015-06-17 10:50:51 +1000789 arm*-*)
Damien Miller91f40d82013-02-22 11:37:00 +1100790 seccomp_audit_arch=AUDIT_ARCH_ARM
Damien Miller99f33d72015-06-17 10:50:51 +1000791 ;;
792 aarch64*-*)
793 seccomp_audit_arch=AUDIT_ARCH_AARCH64
Damien Miller5c15e222015-06-18 15:07:56 +1000794 ;;
Damien Millerb9c50612016-07-08 13:59:13 +1000795 s390x-*)
796 seccomp_audit_arch=AUDIT_ARCH_S390X
797 ;;
798 s390-*)
799 seccomp_audit_arch=AUDIT_ARCH_S390
800 ;;
801 powerpc64-*)
802 seccomp_audit_arch=AUDIT_ARCH_PPC64
803 ;;
804 powerpc64le-*)
805 seccomp_audit_arch=AUDIT_ARCH_PPC64LE
806 ;;
807 mips-*)
808 seccomp_audit_arch=AUDIT_ARCH_MIPS
809 ;;
810 mipsel-*)
811 seccomp_audit_arch=AUDIT_ARCH_MIPSEL
812 ;;
813 mips64-*)
814 seccomp_audit_arch=AUDIT_ARCH_MIPS64
815 ;;
816 mips64el-*)
817 seccomp_audit_arch=AUDIT_ARCH_MIPSEL64
818 ;;
Damien Millere0956e32012-04-04 11:27:54 +1000819 esac
Damien Miller91f40d82013-02-22 11:37:00 +1100820 if test "x$seccomp_audit_arch" != "x" ; then
821 AC_MSG_RESULT(["$seccomp_audit_arch"])
Damien Miller99f33d72015-06-17 10:50:51 +1000822 AC_DEFINE_UNQUOTED([SECCOMP_AUDIT_ARCH], [$seccomp_audit_arch],
823 [Specify the system call convention in use])
Damien Miller91f40d82013-02-22 11:37:00 +1100824 else
825 AC_MSG_RESULT([architecture not supported])
826 fi
Damien Millerb29ea912000-01-15 14:12:03 +1100827 ;;
Ben Lindstromb5628642000-10-18 00:02:25 +0000828mips-sony-bsd|mips-sony-newsos4)
Tim Rice648f8762011-01-26 12:38:57 -0800829 AC_DEFINE([NEED_SETPGRP], [1], [Need setpgrp to acquire controlling tty])
Ben Lindstromb5628642000-10-18 00:02:25 +0000830 SONY=1
Ben Lindstromb5628642000-10-18 00:02:25 +0000831 ;;
Damien Milleree1c0b32000-01-21 00:18:15 +1100832*-*-netbsd*)
Damien Millerfc93d4b2002-09-04 23:26:29 +1000833 check_for_libcrypt_before=1
Tim Riceeae17cc2005-03-17 16:52:20 -0800834 if test "x$withval" != "xno" ; then
Tim Rice88368a32003-12-08 12:35:59 -0800835 need_dash_r=1
836 fi
Damien Miller99522ba2016-07-28 08:54:27 +1000837 CPPFLAGS="$CPPFLAGS -D_OPENBSD_SOURCE"
Tim Rice648f8762011-01-26 12:38:57 -0800838 AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
Damien Miller2dcddbf2006-01-01 19:47:05 +1100839 AC_CHECK_HEADER([net/if_tap.h], ,
Tim Rice648f8762011-01-26 12:38:57 -0800840 AC_DEFINE([SSH_TUN_NO_L2], [1], [No layer 2 tunnel support]))
841 AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
Damien Miller2dcddbf2006-01-01 19:47:05 +1100842 [Prepend the address family to IP tunnel traffic])
Darren Tucker882abfd2013-11-09 00:17:41 +1100843 TEST_MALLOC_OPTIONS="AJRX"
Damien Millerf5bbd3b2014-01-30 11:26:46 +1100844 AC_DEFINE([BROKEN_READ_COMPARISON], [1],
845 [NetBSD read function is sometimes redirected, breaking atomicio comparisons against it])
Damien Milleree1c0b32000-01-21 00:18:15 +1100846 ;;
Damien Millerfbd884a2001-02-27 08:39:07 +1100847*-*-freebsd*)
848 check_for_libcrypt_later=1
Tim Rice648f8762011-01-26 12:38:57 -0800849 AC_DEFINE([LOCKED_PASSWD_PREFIX], ["*LOCKED*"], [Account locked with pw(1)])
850 AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
Damien Miller2dcddbf2006-01-01 19:47:05 +1100851 AC_CHECK_HEADER([net/if_tap.h], ,
Tim Rice648f8762011-01-26 12:38:57 -0800852 AC_DEFINE([SSH_TUN_NO_L2], [1], [No layer 2 tunnel support]))
853 AC_DEFINE([BROKEN_GLOB], [1], [FreeBSD glob does not do what we need])
Darren Tucker882abfd2013-11-09 00:17:41 +1100854 TEST_MALLOC_OPTIONS="AJRX"
Damien Miller2035b222014-01-26 09:39:53 +1100855 # Preauth crypto occasionally uses file descriptors for crypto offload
856 # and will crash if they cannot be opened.
Damien Miller5b447c02014-01-26 09:46:53 +1100857 AC_DEFINE([SANDBOX_SKIP_RLIMIT_NOFILE], [1],
Tim Rice03ae0812014-02-21 09:09:34 -0800858 [define if setrlimit RLIMIT_NOFILE breaks things])
Damien Millerfbd884a2001-02-27 08:39:07 +1100859 ;;
Darren Tuckered9eb022003-09-22 11:18:47 +1000860*-*-bsdi*)
Tim Rice648f8762011-01-26 12:38:57 -0800861 AC_DEFINE([SETEUID_BREAKS_SETUID])
862 AC_DEFINE([BROKEN_SETREUID])
863 AC_DEFINE([BROKEN_SETREGID])
Darren Tuckered9eb022003-09-22 11:18:47 +1000864 ;;
Damien Miller0f91b4e2000-06-18 15:43:25 +1000865*-next-*)
Damien Miller0f91b4e2000-06-18 15:43:25 +1000866 conf_lastlog_location="/usr/adm/lastlog"
Damien Millere5192fa2000-08-29 14:30:37 +1100867 conf_utmp_location=/etc/utmp
868 conf_wtmp_location=/usr/adm/wtmp
Tim Rice90f42b02011-06-02 18:17:49 -0700869 maildir=/usr/spool/mail
Tim Rice648f8762011-01-26 12:38:57 -0800870 AC_DEFINE([HAVE_NEXT], [1], [Define if you are on NeXT])
871 AC_DEFINE([BROKEN_REALPATH])
872 AC_DEFINE([USE_PIPES])
873 AC_DEFINE([BROKEN_SAVED_UIDS], [1], [Needed for NeXT])
Damien Miller0f91b4e2000-06-18 15:43:25 +1000874 ;;
Darren Tucker4a422572005-07-14 17:22:11 +1000875*-*-openbsd*)
Damien Miller852472a2014-01-22 16:31:18 +1100876 use_pie=auto
Tim Rice648f8762011-01-26 12:38:57 -0800877 AC_DEFINE([HAVE_ATTRIBUTE__SENTINEL__], [1], [OpenBSD's gcc has sentinel])
878 AC_DEFINE([HAVE_ATTRIBUTE__BOUNDED__], [1], [OpenBSD's gcc has bounded])
879 AC_DEFINE([SSH_TUN_OPENBSD], [1], [Open tunnel devices the OpenBSD way])
880 AC_DEFINE([SYSLOG_R_SAFE_IN_SIGHAND], [1],
Damien Millerbb598142006-08-19 08:38:23 +1000881 [syslog_r function is safe to use in in a signal handler])
Darren Tucker882abfd2013-11-09 00:17:41 +1100882 TEST_MALLOC_OPTIONS="AFGJPRX"
Darren Tucker4a422572005-07-14 17:22:11 +1000883 ;;
Damien Miller75b1d102000-01-07 14:01:41 +1100884*-*-solaris*)
Tim Riceeae17cc2005-03-17 16:52:20 -0800885 if test "x$withval" != "xno" ; then
Tim Ricead4a1882004-02-29 15:53:37 -0800886 need_dash_r=1
887 fi
Tim Rice648f8762011-01-26 12:38:57 -0800888 AC_DEFINE([PAM_SUN_CODEBASE])
889 AC_DEFINE([LOGIN_NEEDS_UTMPX])
Tim Rice648f8762011-01-26 12:38:57 -0800890 AC_DEFINE([PAM_TTY_KLUDGE])
891 AC_DEFINE([SSHPAM_CHAUTHTOK_NEEDS_RUID], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700892 [Define if pam_chauthtok wants real uid set
893 to the unpriv'ed user])
Tim Rice648f8762011-01-26 12:38:57 -0800894 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Darren Tuckerc437cda2003-05-10 17:05:46 +1000895 # Pushing STREAMS modules will cause sshd to acquire a controlling tty.
Tim Rice648f8762011-01-26 12:38:57 -0800896 AC_DEFINE([SSHD_ACQUIRES_CTTY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700897 [Define if sshd somehow reacquires a controlling TTY
898 after setsid()])
Tim Rice648f8762011-01-26 12:38:57 -0800899 AC_DEFINE([PASSWD_NEEDS_USERNAME], [1], [must supply username to passwd
Darren Tucker0249f932006-06-24 12:10:07 +1000900 in case the name is longer than 8 chars])
Tim Rice648f8762011-01-26 12:38:57 -0800901 AC_DEFINE([BROKEN_TCGETATTR_ICANON], [1], [tcgetattr with ICANON may hang])
Darren Tuckere1a790d2003-09-16 11:52:19 +1000902 external_path_file=/etc/default/login
andre2ff7b5d2000-06-03 14:57:40 +0000903 # hardwire lastlog location (can't detect it on some versions)
904 conf_lastlog_location="/var/adm/lastlog"
Tim Rice648f8762011-01-26 12:38:57 -0800905 AC_MSG_CHECKING([for obsolete utmp and wtmp in solaris2.x])
Damien Millera1cb6442000-06-09 11:58:35 +1000906 sol2ver=`echo "$host"| sed -e 's/.*[[0-9]]\.//'`
907 if test "$sol2ver" -ge 8; then
Tim Rice648f8762011-01-26 12:38:57 -0800908 AC_MSG_RESULT([yes])
909 AC_DEFINE([DISABLE_UTMP])
910 AC_DEFINE([DISABLE_WTMP], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700911 [Define if you don't want to use wtmp])
Damien Millera1cb6442000-06-09 11:58:35 +1000912 else
Tim Rice648f8762011-01-26 12:38:57 -0800913 AC_MSG_RESULT([no])
Damien Millera1cb6442000-06-09 11:58:35 +1000914 fi
Darren Tuckera86ec4d2016-06-14 10:48:27 +1000915 AC_CHECK_FUNCS([setpflags])
Darren Tucker907091a2016-02-19 09:05:39 +1100916 AC_CHECK_FUNCS([setppriv])
917 AC_CHECK_FUNCS([priv_basicset])
918 AC_CHECK_HEADERS([priv.h])
Tim Rice648f8762011-01-26 12:38:57 -0800919 AC_ARG_WITH([solaris-contracts],
Damien Miller1b06dc32006-08-31 03:24:41 +1000920 [ --with-solaris-contracts Enable Solaris process contracts (experimental)],
921 [
Tim Rice648f8762011-01-26 12:38:57 -0800922 AC_CHECK_LIB([contract], [ct_tmpl_activate],
923 [ AC_DEFINE([USE_SOLARIS_PROCESS_CONTRACTS], [1],
Damien Miller1b06dc32006-08-31 03:24:41 +1000924 [Define if you have Solaris process contracts])
Damien Miller4626cba2016-01-08 14:24:56 +1100925 LIBS="$LIBS -lcontract"
Damien Miller1b06dc32006-08-31 03:24:41 +1000926 SPC_MSG="yes" ], )
927 ],
928 )
Tim Rice648f8762011-01-26 12:38:57 -0800929 AC_ARG_WITH([solaris-projects],
Darren Tucker97528352010-11-05 12:03:05 +1100930 [ --with-solaris-projects Enable Solaris projects (experimental)],
931 [
Tim Rice648f8762011-01-26 12:38:57 -0800932 AC_CHECK_LIB([project], [setproject],
933 [ AC_DEFINE([USE_SOLARIS_PROJECTS], [1],
Darren Tucker97528352010-11-05 12:03:05 +1100934 [Define if you have Solaris projects])
Damien Miller4626cba2016-01-08 14:24:56 +1100935 LIBS="$LIBS -lproject"
Darren Tucker97528352010-11-05 12:03:05 +1100936 SP_MSG="yes" ], )
937 ],
938 )
Damien Miller4626cba2016-01-08 14:24:56 +1100939 AC_ARG_WITH([solaris-privs],
940 [ --with-solaris-privs Enable Solaris/Illumos privileges (experimental)],
941 [
942 AC_MSG_CHECKING([for Solaris/Illumos privilege support])
Darren Tucker907091a2016-02-19 09:05:39 +1100943 if test "x$ac_cv_func_setppriv" = "xyes" -a \
944 "x$ac_cv_header_priv_h" = "xyes" ; then
945 SOLARIS_PRIVS=yes
Damien Miller4626cba2016-01-08 14:24:56 +1100946 AC_MSG_RESULT([found])
947 AC_DEFINE([NO_UID_RESTORATION_TEST], [1],
948 [Define to disable UID restoration test])
949 AC_DEFINE([USE_SOLARIS_PRIVS], [1],
950 [Define if you have Solaris privileges])
951 SPP_MSG="yes"
952 else
953 AC_MSG_RESULT([not found])
954 AC_MSG_ERROR([*** must have support for Solaris privileges to use --with-solaris-privs])
955 fi
956 ],
957 )
Tim Rice5ab9b632013-06-02 14:05:48 -0700958 TEST_SHELL=$SHELL # let configure find us a capable shell
Damien Miller75b1d102000-01-07 14:01:41 +1100959 ;;
Damien Millerdfc83f42000-05-20 15:02:59 +1000960*-*-sunos4*)
Ben Lindstrom28bfc0d2000-12-18 19:58:57 +0000961 CPPFLAGS="$CPPFLAGS -DSUNOS4"
Tim Rice648f8762011-01-26 12:38:57 -0800962 AC_CHECK_FUNCS([getpwanam])
963 AC_DEFINE([PAM_SUN_CODEBASE])
Damien Miller36ccb5c2000-08-09 16:34:27 +1000964 conf_utmp_location=/etc/utmp
965 conf_wtmp_location=/var/adm/wtmp
966 conf_lastlog_location=/var/adm/lastlog
Tim Rice648f8762011-01-26 12:38:57 -0800967 AC_DEFINE([USE_PIPES])
Damien Millerdfc83f42000-05-20 15:02:59 +1000968 ;;
Ben Lindstrom603bdfd2001-02-12 07:29:45 +0000969*-ncr-sysv*)
Tim Rice13aae5e2001-10-21 17:53:58 -0700970 LIBS="$LIBS -lc89"
Tim Rice648f8762011-01-26 12:38:57 -0800971 AC_DEFINE([USE_PIPES])
972 AC_DEFINE([SSHD_ACQUIRES_CTTY])
973 AC_DEFINE([SETEUID_BREAKS_SETUID])
974 AC_DEFINE([BROKEN_SETREUID])
975 AC_DEFINE([BROKEN_SETREGID])
Ben Lindstrom603bdfd2001-02-12 07:29:45 +0000976 ;;
Damien Miller2ae714f2000-07-11 09:29:50 +1000977*-sni-sysv*)
Tim Riceffdf4aa2001-10-27 10:45:36 -0700978 # /usr/ucblib MUST NOT be searched on ReliantUNIX
Tim Rice648f8762011-01-26 12:38:57 -0800979 AC_CHECK_LIB([dl], [dlsym], ,)
Darren Tucker79d09fa2005-11-24 22:34:54 +1100980 # -lresolv needs to be at the end of LIBS or DNS lookups break
Tim Rice648f8762011-01-26 12:38:57 -0800981 AC_CHECK_LIB([resolv], [res_query], [ LIBS="$LIBS -lresolv" ])
Damien Millerfd9885e2001-01-10 08:16:53 +1100982 IPADDR_IN_DISPLAY=yes
Tim Rice648f8762011-01-26 12:38:57 -0800983 AC_DEFINE([USE_PIPES])
984 AC_DEFINE([IP_TOS_IS_BROKEN])
985 AC_DEFINE([SETEUID_BREAKS_SETUID])
986 AC_DEFINE([BROKEN_SETREUID])
987 AC_DEFINE([BROKEN_SETREGID])
988 AC_DEFINE([SSHD_ACQUIRES_CTTY])
Darren Tuckere1a790d2003-09-16 11:52:19 +1000989 external_path_file=/etc/default/login
Tim Riceffdf4aa2001-10-27 10:45:36 -0700990 # /usr/ucblib/libucb.a no longer needed on ReliantUNIX
991 # Attention: always take care to bind libsocket and libnsl before libc,
992 # otherwise you will find lots of "SIOCGPGRP errno 22" on syslog
Damien Miller2ae714f2000-07-11 09:29:50 +1000993 ;;
Tim Rice0f83d292004-12-08 18:29:58 -0800994# UnixWare 1.x, UnixWare 2.x, and others based on code from Univel.
Damien Miller78315eb2000-09-29 23:01:36 +1100995*-*-sysv4.2*)
Tim Rice648f8762011-01-26 12:38:57 -0800996 AC_DEFINE([USE_PIPES])
997 AC_DEFINE([SETEUID_BREAKS_SETUID])
998 AC_DEFINE([BROKEN_SETREUID])
999 AC_DEFINE([BROKEN_SETREGID])
1000 AC_DEFINE([PASSWD_NEEDS_USERNAME], [1], [must supply username to passwd])
1001 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Tim Rice5ab9b632013-06-02 14:05:48 -07001002 TEST_SHELL=$SHELL # let configure find us a capable shell
Damien Miller78315eb2000-09-29 23:01:36 +11001003 ;;
Tim Rice0f83d292004-12-08 18:29:58 -08001004# UnixWare 7.x, OpenUNIX 8
Damien Miller78315eb2000-09-29 23:01:36 +11001005*-*-sysv5*)
Tim Rice641ebf12010-01-17 17:05:39 -08001006 CPPFLAGS="$CPPFLAGS -Dvsnprintf=_xvsnprintf -Dsnprintf=_xsnprintf"
Tim Rice648f8762011-01-26 12:38:57 -08001007 AC_DEFINE([UNIXWARE_LONG_PASSWORDS], [1], [Support passwords > 8 chars])
1008 AC_DEFINE([USE_PIPES])
1009 AC_DEFINE([SETEUID_BREAKS_SETUID])
1010 AC_DEFINE([BROKEN_GETADDRINFO])
1011 AC_DEFINE([BROKEN_SETREUID])
1012 AC_DEFINE([BROKEN_SETREGID])
1013 AC_DEFINE([PASSWD_NEEDS_USERNAME])
Tim Rice8433d512017-07-11 18:47:56 -07001014 AC_DEFINE([BROKEN_TCGETATTR_ICANON])
Tim Rice5ab9b632013-06-02 14:05:48 -07001015 TEST_SHELL=$SHELL # let configure find us a capable shell
Tim Rice4dbacff2005-06-01 20:09:28 -07001016 case "$host" in
1017 *-*-sysv5SCO_SV*) # SCO OpenServer 6.x
Tim Rice90f42b02011-06-02 18:17:49 -07001018 maildir=/var/spool/mail
Tim Rice648f8762011-01-26 12:38:57 -08001019 AC_DEFINE([BROKEN_LIBIAF], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001020 [ia_uinfo routines not supported by OS yet])
Tim Rice648f8762011-01-26 12:38:57 -08001021 AC_DEFINE([BROKEN_UPDWTMPX])
1022 AC_CHECK_LIB([prot], [getluid], [ LIBS="$LIBS -lprot"
1023 AC_CHECK_FUNCS([getluid setluid], , , [-lprot])
1024 AC_DEFINE([HAVE_SECUREWARE])
1025 AC_DEFINE([DISABLE_SHADOW])
1026 ], , )
Tim Rice4dbacff2005-06-01 20:09:28 -07001027 ;;
Tim Rice648f8762011-01-26 12:38:57 -08001028 *) AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Tim Rice26767912009-01-07 20:50:08 -08001029 check_for_libcrypt_later=1
Tim Rice46259d82005-11-28 18:40:34 -08001030 ;;
Tim Rice4dbacff2005-06-01 20:09:28 -07001031 esac
Damien Miller78315eb2000-09-29 23:01:36 +11001032 ;;
Damien Miller75b1d102000-01-07 14:01:41 +11001033*-*-sysv*)
Damien Miller75b1d102000-01-07 14:01:41 +11001034 ;;
Tim Rice0f83d292004-12-08 18:29:58 -08001035# SCO UNIX and OEM versions of SCO UNIX
Damien Miller78315eb2000-09-29 23:01:36 +11001036*-*-sco3.2v4*)
Tim Ricec390c8d2005-03-07 01:21:37 -08001037 AC_MSG_ERROR("This Platform is no longer supported.")
Damien Miller78315eb2000-09-29 23:01:36 +11001038 ;;
Tim Rice0f83d292004-12-08 18:29:58 -08001039# SCO OpenServer 5.x
Damien Miller78315eb2000-09-29 23:01:36 +11001040*-*-sco3.2v5*)
Tim Rice89fe3f32003-01-19 20:20:24 -08001041 if test -z "$GCC"; then
1042 CFLAGS="$CFLAGS -belf"
1043 fi
Damien Miller5dfe9762001-02-16 12:05:39 +11001044 LIBS="$LIBS -lprot -lx -ltinfo -lm"
Damien Millera66626b2000-06-13 18:57:53 +10001045 no_dev_ptmx=1
Tim Rice648f8762011-01-26 12:38:57 -08001046 AC_DEFINE([USE_PIPES])
1047 AC_DEFINE([HAVE_SECUREWARE])
1048 AC_DEFINE([DISABLE_SHADOW])
1049 AC_DEFINE([DISABLE_FD_PASSING])
1050 AC_DEFINE([SETEUID_BREAKS_SETUID])
1051 AC_DEFINE([BROKEN_GETADDRINFO])
1052 AC_DEFINE([BROKEN_SETREUID])
1053 AC_DEFINE([BROKEN_SETREGID])
1054 AC_DEFINE([WITH_ABBREV_NO_TTY])
1055 AC_DEFINE([BROKEN_UPDWTMPX])
1056 AC_DEFINE([PASSWD_NEEDS_USERNAME])
1057 AC_CHECK_FUNCS([getluid setluid])
Tim Rice07183b82001-04-25 21:40:28 -07001058 MANTYPE=man
Tim Rice5ab9b632013-06-02 14:05:48 -07001059 TEST_SHELL=$SHELL # let configure find us a capable shell
Tim Riceaa86c392013-03-16 20:55:46 -07001060 SKIP_DISABLE_LASTLOG_DEFINE=yes
Damien Millera66626b2000-06-13 18:57:53 +10001061 ;;
Ben Lindstrom232ccf72002-07-22 23:34:25 +00001062*-*-unicosmk*)
Tim Rice648f8762011-01-26 12:38:57 -08001063 AC_DEFINE([NO_SSH_LASTLOG], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001064 [Define if you don't want to use lastlog in session.c])
Tim Rice648f8762011-01-26 12:38:57 -08001065 AC_DEFINE([SETEUID_BREAKS_SETUID])
1066 AC_DEFINE([BROKEN_SETREUID])
1067 AC_DEFINE([BROKEN_SETREGID])
1068 AC_DEFINE([USE_PIPES])
1069 AC_DEFINE([DISABLE_FD_PASSING])
Ben Lindstrom232ccf72002-07-22 23:34:25 +00001070 LDFLAGS="$LDFLAGS"
1071 LIBS="$LIBS -lgen -lrsc -lshare -luex -lacm"
1072 MANTYPE=cat
Ben Lindstrom762104e2002-07-23 00:00:05 +00001073 ;;
Darren Tucker9f7ffc52003-09-10 11:39:05 +10001074*-*-unicosmp*)
Tim Rice648f8762011-01-26 12:38:57 -08001075 AC_DEFINE([SETEUID_BREAKS_SETUID])
1076 AC_DEFINE([BROKEN_SETREUID])
1077 AC_DEFINE([BROKEN_SETREGID])
1078 AC_DEFINE([WITH_ABBREV_NO_TTY])
1079 AC_DEFINE([USE_PIPES])
1080 AC_DEFINE([DISABLE_FD_PASSING])
Darren Tucker9f7ffc52003-09-10 11:39:05 +10001081 LDFLAGS="$LDFLAGS"
Darren Tucker2df33432004-01-30 14:34:21 +11001082 LIBS="$LIBS -lgen -lacid -ldb"
Darren Tucker9f7ffc52003-09-10 11:39:05 +10001083 MANTYPE=cat
1084 ;;
Ben Lindstromd9e08242001-07-22 19:32:00 +00001085*-*-unicos*)
Tim Rice648f8762011-01-26 12:38:57 -08001086 AC_DEFINE([SETEUID_BREAKS_SETUID])
1087 AC_DEFINE([BROKEN_SETREUID])
1088 AC_DEFINE([BROKEN_SETREGID])
1089 AC_DEFINE([USE_PIPES])
1090 AC_DEFINE([DISABLE_FD_PASSING])
1091 AC_DEFINE([NO_SSH_LASTLOG])
Ben Lindstrom232ccf72002-07-22 23:34:25 +00001092 LDFLAGS="$LDFLAGS -Wl,-Dmsglevel=334:fatal"
1093 LIBS="$LIBS -lgen -lrsc -lshare -luex -lacm"
1094 MANTYPE=cat
Tim Ricee991e3c2001-08-07 15:29:07 -07001095 ;;
Damien Millerb8c656e2000-06-28 15:22:41 +10001096*-dec-osf*)
Tim Rice648f8762011-01-26 12:38:57 -08001097 AC_MSG_CHECKING([for Digital Unix SIA])
Ben Lindstrom72af2ef2001-05-08 20:42:28 +00001098 no_osfsia=""
Tim Rice648f8762011-01-26 12:38:57 -08001099 AC_ARG_WITH([osfsia],
Ben Lindstrom72af2ef2001-05-08 20:42:28 +00001100 [ --with-osfsia Enable Digital Unix SIA],
1101 [
1102 if test "x$withval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08001103 AC_MSG_RESULT([disabled])
Ben Lindstrom72af2ef2001-05-08 20:42:28 +00001104 no_osfsia=1
1105 fi
1106 ],
1107 )
1108 if test -z "$no_osfsia" ; then
Damien Millerb8c656e2000-06-28 15:22:41 +10001109 if test -f /etc/sia/matrix.conf; then
Tim Rice648f8762011-01-26 12:38:57 -08001110 AC_MSG_RESULT([yes])
1111 AC_DEFINE([HAVE_OSF_SIA], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001112 [Define if you have Digital Unix Security
1113 Integration Architecture])
Tim Rice648f8762011-01-26 12:38:57 -08001114 AC_DEFINE([DISABLE_LOGIN], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001115 [Define if you don't want to use your
1116 system's login() call])
Tim Rice648f8762011-01-26 12:38:57 -08001117 AC_DEFINE([DISABLE_FD_PASSING])
Damien Millerb8c656e2000-06-28 15:22:41 +10001118 LIBS="$LIBS -lsecurity -ldb -lm -laud"
Damien Miller1b06dc32006-08-31 03:24:41 +10001119 SIA_MSG="yes"
Damien Millerb8c656e2000-06-28 15:22:41 +10001120 else
Tim Rice648f8762011-01-26 12:38:57 -08001121 AC_MSG_RESULT([no])
1122 AC_DEFINE([LOCKED_PASSWD_SUBSTR], ["Nologin"],
Tim Rice7df8d392005-09-19 09:33:39 -07001123 [String used in /etc/passwd to denote locked account])
Damien Millerb8c656e2000-06-28 15:22:41 +10001124 fi
1125 fi
Tim Rice648f8762011-01-26 12:38:57 -08001126 AC_DEFINE([BROKEN_GETADDRINFO])
1127 AC_DEFINE([SETEUID_BREAKS_SETUID])
1128 AC_DEFINE([BROKEN_SETREUID])
1129 AC_DEFINE([BROKEN_SETREGID])
1130 AC_DEFINE([BROKEN_READV_COMPARISON], [1], [Can't do comparisons on readv])
Damien Millerb8c656e2000-06-28 15:22:41 +10001131 ;;
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00001132
Tim Rice70335a62006-02-04 17:42:58 -08001133*-*-nto-qnx*)
Tim Rice648f8762011-01-26 12:38:57 -08001134 AC_DEFINE([USE_PIPES])
1135 AC_DEFINE([NO_X11_UNIX_SOCKETS])
Tim Rice648f8762011-01-26 12:38:57 -08001136 AC_DEFINE([DISABLE_LASTLOG])
1137 AC_DEFINE([SSHD_ACQUIRES_CTTY])
1138 AC_DEFINE([BROKEN_SHADOW_EXPIRE], [1], [QNX shadow support is broken])
Tim Rice2f993462006-02-11 18:37:48 -08001139 enable_etc_default_login=no # has incompatible /etc/default/login
Darren Tucker8acb3b62007-08-10 14:36:12 +10001140 case "$host" in
1141 *-*-nto-qnx6*)
Tim Rice648f8762011-01-26 12:38:57 -08001142 AC_DEFINE([DISABLE_FD_PASSING])
Darren Tucker8acb3b62007-08-10 14:36:12 +10001143 ;;
1144 esac
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00001145 ;;
Darren Tucker2be1cbb2005-05-27 21:13:40 +10001146
1147*-*-ultrix*)
Tim Rice648f8762011-01-26 12:38:57 -08001148 AC_DEFINE([BROKEN_GETGROUPS], [1], [getgroups(0,NULL) will return -1])
Tim Rice648f8762011-01-26 12:38:57 -08001149 AC_DEFINE([NEED_SETPGRP])
1150 AC_DEFINE([HAVE_SYS_SYSLOG_H], [1], [Force use of sys/syslog.h on Ultrix])
Tim Ricefcc7ff12005-06-02 20:28:29 -07001151 ;;
Darren Tucker93e7e8f2005-08-23 08:06:55 +10001152
1153*-*-lynxos)
Darren Tucker5faa52d2016-08-02 15:22:40 +10001154 CFLAGS="$CFLAGS -D__NO_INCLUDE_WARN__"
1155 AC_DEFINE([BROKEN_SETVBUF], [1],
1156 [LynxOS has broken setvbuf() implementation])
1157 ;;
Damien Miller76112de1999-12-21 11:18:08 +11001158esac
1159
Tim Rice648f8762011-01-26 12:38:57 -08001160AC_MSG_CHECKING([compiler and flags for sanity])
1161AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]], [[ exit(0); ]])],
1162 [ AC_MSG_RESULT([yes]) ],
Darren Tucker6eb93042003-06-29 21:30:41 +10001163 [
Tim Rice648f8762011-01-26 12:38:57 -08001164 AC_MSG_RESULT([no])
Darren Tucker6eb93042003-06-29 21:30:41 +10001165 AC_MSG_ERROR([*** compiler cannot create working executables, check config.log ***])
Darren Tuckera0c2b392004-09-11 23:26:37 +10001166 ],
1167 [ AC_MSG_WARN([cross compiling: not checking compiler sanity]) ]
Darren Tucker6eb93042003-06-29 21:30:41 +10001168)
1169
Darren Tucker0c9653f2005-05-28 15:58:14 +10001170dnl Checks for header files.
Damien Millera22ba012000-03-02 23:09:20 +11001171# Checks for libraries.
Tim Rice648f8762011-01-26 12:38:57 -08001172AC_CHECK_FUNC([setsockopt], , [AC_CHECK_LIB([socket], [setsockopt])])
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00001173
Tim Rice1e1ef642003-09-11 22:19:31 -07001174dnl IRIX and Solaris 2.5.1 have dirname() in libgen
Tim Rice648f8762011-01-26 12:38:57 -08001175AC_CHECK_FUNCS([dirname], [AC_CHECK_HEADERS([libgen.h])] , [
1176 AC_CHECK_LIB([gen], [dirname], [
Tim Rice1e1ef642003-09-11 22:19:31 -07001177 AC_CACHE_CHECK([for broken dirname],
1178 ac_cv_have_broken_dirname, [
1179 save_LIBS="$LIBS"
1180 LIBS="$LIBS -lgen"
Darren Tucker314d89e2005-10-17 23:29:23 +10001181 AC_RUN_IFELSE(
1182 [AC_LANG_SOURCE([[
Tim Rice1e1ef642003-09-11 22:19:31 -07001183#include <libgen.h>
1184#include <string.h>
1185
1186int main(int argc, char **argv) {
1187 char *s, buf[32];
1188
1189 strncpy(buf,"/etc", 32);
1190 s = dirname(buf);
1191 if (!s || strncmp(s, "/", 32) != 0) {
1192 exit(1);
1193 } else {
1194 exit(0);
1195 }
1196}
Darren Tucker314d89e2005-10-17 23:29:23 +10001197 ]])],
Tim Rice1e1ef642003-09-11 22:19:31 -07001198 [ ac_cv_have_broken_dirname="no" ],
Darren Tucker314d89e2005-10-17 23:29:23 +10001199 [ ac_cv_have_broken_dirname="yes" ],
1200 [ ac_cv_have_broken_dirname="no" ],
Tim Rice1e1ef642003-09-11 22:19:31 -07001201 )
1202 LIBS="$save_LIBS"
1203 ])
1204 if test "x$ac_cv_have_broken_dirname" = "xno" ; then
1205 LIBS="$LIBS -lgen"
Tim Rice648f8762011-01-26 12:38:57 -08001206 AC_DEFINE([HAVE_DIRNAME])
1207 AC_CHECK_HEADERS([libgen.h])
Tim Rice1e1ef642003-09-11 22:19:31 -07001208 fi
1209 ])
1210])
1211
Tim Rice648f8762011-01-26 12:38:57 -08001212AC_CHECK_FUNC([getspnam], ,
1213 [AC_CHECK_LIB([gen], [getspnam], [LIBS="$LIBS -lgen"])])
1214AC_SEARCH_LIBS([basename], [gen], [AC_DEFINE([HAVE_BASENAME], [1],
1215 [Define if you have the basename function.])])
Tim Rice1e1ef642003-09-11 22:19:31 -07001216
Tim Rice13aae5e2001-10-21 17:53:58 -07001217dnl zlib is required
Tim Rice648f8762011-01-26 12:38:57 -08001218AC_ARG_WITH([zlib],
Tim Rice13aae5e2001-10-21 17:53:58 -07001219 [ --with-zlib=PATH Use zlib in PATH],
Darren Tucker86a5f8d2005-03-21 09:55:17 +11001220 [ if test "x$withval" = "xno" ; then
1221 AC_MSG_ERROR([*** zlib is required ***])
1222 elif test "x$withval" != "xyes"; then
Tim Rice13aae5e2001-10-21 17:53:58 -07001223 if test -d "$withval/lib"; then
1224 if test -n "${need_dash_r}"; then
Tim Rice02cebcd2001-10-25 10:01:30 -07001225 LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001226 else
Tim Rice02cebcd2001-10-25 10:01:30 -07001227 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001228 fi
1229 else
1230 if test -n "${need_dash_r}"; then
Tim Rice02cebcd2001-10-25 10:01:30 -07001231 LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001232 else
Tim Rice02cebcd2001-10-25 10:01:30 -07001233 LDFLAGS="-L${withval} ${LDFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001234 fi
1235 fi
1236 if test -d "$withval/include"; then
Tim Rice02cebcd2001-10-25 10:01:30 -07001237 CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001238 else
Tim Rice02cebcd2001-10-25 10:01:30 -07001239 CPPFLAGS="-I${withval} ${CPPFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001240 fi
Darren Tucker86a5f8d2005-03-21 09:55:17 +11001241 fi ]
Tim Rice13aae5e2001-10-21 17:53:58 -07001242)
1243
Tim Rice648f8762011-01-26 12:38:57 -08001244AC_CHECK_HEADER([zlib.h], ,[AC_MSG_ERROR([*** zlib.h missing - please install first or check config.log ***])])
1245AC_CHECK_LIB([z], [deflate], ,
Tim Ricefcb62202004-01-23 18:35:16 -08001246 [
1247 saved_CPPFLAGS="$CPPFLAGS"
1248 saved_LDFLAGS="$LDFLAGS"
1249 save_LIBS="$LIBS"
1250 dnl Check default zlib install dir
1251 if test -n "${need_dash_r}"; then
1252 LDFLAGS="-L/usr/local/lib -R/usr/local/lib ${saved_LDFLAGS}"
1253 else
1254 LDFLAGS="-L/usr/local/lib ${saved_LDFLAGS}"
1255 fi
1256 CPPFLAGS="-I/usr/local/include ${saved_CPPFLAGS}"
1257 LIBS="$LIBS -lz"
Tim Rice648f8762011-01-26 12:38:57 -08001258 AC_TRY_LINK_FUNC([deflate], [AC_DEFINE([HAVE_LIBZ])],
Tim Ricefcb62202004-01-23 18:35:16 -08001259 [
1260 AC_MSG_ERROR([*** zlib missing - please install first or check config.log ***])
1261 ]
1262 )
1263 ]
1264)
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001265
Tim Rice648f8762011-01-26 12:38:57 -08001266AC_ARG_WITH([zlib-version-check],
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001267 [ --without-zlib-version-check Disable zlib version check],
1268 [ if test "x$withval" = "xno" ; then
1269 zlib_check_nonfatal=1
1270 fi
1271 ]
1272)
1273
Tim Rice648f8762011-01-26 12:38:57 -08001274AC_MSG_CHECKING([for possibly buggy zlib])
1275AC_RUN_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001276#include <stdio.h>
Darren Tuckerc8a0f272013-03-22 12:49:14 +11001277#include <stdlib.h>
Darren Tucker2dcd2392004-01-23 17:13:33 +11001278#include <zlib.h>
Tim Rice648f8762011-01-26 12:38:57 -08001279 ]],
1280 [[
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001281 int a=0, b=0, c=0, d=0, n, v;
1282 n = sscanf(ZLIB_VERSION, "%d.%d.%d.%d", &a, &b, &c, &d);
1283 if (n != 3 && n != 4)
Darren Tucker2dcd2392004-01-23 17:13:33 +11001284 exit(1);
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001285 v = a*1000000 + b*10000 + c*100 + d;
1286 fprintf(stderr, "found zlib version %s (%d)\n", ZLIB_VERSION, v);
1287
1288 /* 1.1.4 is OK */
1289 if (a == 1 && b == 1 && c >= 4)
Darren Tucker2dcd2392004-01-23 17:13:33 +11001290 exit(0);
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001291
Darren Tucker41097ed2005-07-25 15:24:21 +10001292 /* 1.2.3 and up are OK */
1293 if (v >= 1020300)
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001294 exit(0);
1295
Darren Tucker2dcd2392004-01-23 17:13:33 +11001296 exit(2);
Darren Tucker623d92f2004-09-12 22:36:15 +10001297 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001298 AC_MSG_RESULT([no]),
1299 [ AC_MSG_RESULT([yes])
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001300 if test -z "$zlib_check_nonfatal" ; then
1301 AC_MSG_ERROR([*** zlib too old - check config.log ***
1302Your reported zlib version has known security problems. It's possible your
1303vendor has fixed these problems without changing the version number. If you
1304are sure this is the case, you can disable the check by running
1305"./configure --without-zlib-version-check".
Darren Tuckerac1910f2005-07-26 12:00:42 +10001306If you are in doubt, upgrade zlib to version 1.2.3 or greater.
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001307See http://www.gzip.org/zlib/ for details.])
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001308 else
1309 AC_MSG_WARN([zlib version may have security problems])
1310 fi
Darren Tuckera0c2b392004-09-11 23:26:37 +10001311 ],
1312 [ AC_MSG_WARN([cross compiling: not checking zlib version]) ]
Darren Tucker2dcd2392004-01-23 17:13:33 +11001313)
Damien Miller6f9c3372000-10-25 10:06:04 +11001314
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00001315dnl UnixWare 2.x
Tim Rice648f8762011-01-26 12:38:57 -08001316AC_CHECK_FUNC([strcasecmp],
1317 [], [ AC_CHECK_LIB([resolv], [strcasecmp], [LIBS="$LIBS -lresolv"]) ]
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00001318)
Tim Rice648f8762011-01-26 12:38:57 -08001319AC_CHECK_FUNCS([utimes],
1320 [], [ AC_CHECK_LIB([c89], [utimes], [AC_DEFINE([HAVE_UTIMES])
Tim Ricecbb90662002-07-08 19:17:10 -07001321 LIBS="$LIBS -lc89"]) ]
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00001322)
Damien Millerab18c411999-11-11 10:40:23 +11001323
Tim Ricee589a292001-11-03 11:09:32 -08001324dnl Checks for libutil functions
Damien Millerb87f6b72013-02-23 09:12:23 +11001325AC_CHECK_HEADERS([bsd/libutil.h libutil.h])
Damien Miller398c0ff2012-04-19 21:46:35 +10001326AC_SEARCH_LIBS([fmt_scaled], [util bsd])
Darren Tuckere194ba42013-05-16 20:47:31 +10001327AC_SEARCH_LIBS([scan_scaled], [util bsd])
Damien Miller398c0ff2012-04-19 21:46:35 +10001328AC_SEARCH_LIBS([login], [util bsd])
1329AC_SEARCH_LIBS([logout], [util bsd])
1330AC_SEARCH_LIBS([logwtmp], [util bsd])
1331AC_SEARCH_LIBS([openpty], [util bsd])
1332AC_SEARCH_LIBS([updwtmp], [util bsd])
Darren Tuckere194ba42013-05-16 20:47:31 +10001333AC_CHECK_FUNCS([fmt_scaled scan_scaled login logout openpty updwtmp logwtmp])
Tim Ricee589a292001-11-03 11:09:32 -08001334
Darren Tucker2fee9092016-02-17 09:48:15 +11001335# On some platforms, inet_ntop and gethostbyname may be found in libresolv
1336# or libnsl.
Damien Millerab039492014-01-28 15:07:10 +11001337AC_SEARCH_LIBS([inet_ntop], [resolv nsl])
Darren Tucker2fee9092016-02-17 09:48:15 +11001338AC_SEARCH_LIBS([gethostbyname], [resolv nsl])
Damien Millerab039492014-01-28 15:07:10 +11001339
Darren Tucker74c1c362017-09-27 07:44:41 +10001340# "Particular Function Checks"
1341# see https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Particular-Functions.html
Ben Lindstrom8697e082001-02-24 21:41:10 +00001342AC_FUNC_STRFTIME
Darren Tucker74c1c362017-09-27 07:44:41 +10001343AC_FUNC_MALLOC
1344AC_FUNC_REALLOC
1345# autoconf doesn't have AC_FUNC_CALLOC so fake it if malloc returns NULL;
1346if test "x$ac_cv_func_malloc_0_nonnull" != "xyes"; then
1347 AC_DEFINE(HAVE_CALLOC, 0, [calloc(x, 0) returns NULL])
1348 AC_DEFINE(calloc, rpl_calloc,
1349 [Define to rpl_calloc if the replacement function should be used.])
1350fi
Ben Lindstrom8697e082001-02-24 21:41:10 +00001351
Damien Miller3c027682001-03-14 11:39:45 +11001352# Check for ALTDIRFUNC glob() extension
Tim Rice648f8762011-01-26 12:38:57 -08001353AC_MSG_CHECKING([for GLOB_ALTDIRFUNC support])
1354AC_EGREP_CPP([FOUNDIT],
Damien Miller3c027682001-03-14 11:39:45 +11001355 [
1356 #include <glob.h>
1357 #ifdef GLOB_ALTDIRFUNC
1358 FOUNDIT
1359 #endif
Damien Millera8e06ce2003-11-21 23:48:55 +11001360 ],
Damien Miller3c027682001-03-14 11:39:45 +11001361 [
Tim Rice648f8762011-01-26 12:38:57 -08001362 AC_DEFINE([GLOB_HAS_ALTDIRFUNC], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001363 [Define if your system glob() function has
1364 the GLOB_ALTDIRFUNC extension])
Tim Rice648f8762011-01-26 12:38:57 -08001365 AC_MSG_RESULT([yes])
Damien Miller3c027682001-03-14 11:39:45 +11001366 ],
1367 [
Tim Rice648f8762011-01-26 12:38:57 -08001368 AC_MSG_RESULT([no])
Damien Miller3c027682001-03-14 11:39:45 +11001369 ]
1370)
Damien Millerab18c411999-11-11 10:40:23 +11001371
Ben Lindstrom45b14db2001-03-17 01:15:38 +00001372# Check for g.gl_matchc glob() extension
Tim Rice648f8762011-01-26 12:38:57 -08001373AC_MSG_CHECKING([for gl_matchc field in glob_t])
1374AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <glob.h> ]],
1375 [[ glob_t g; g.gl_matchc = 1; ]])],
Damien Millera8e06ce2003-11-21 23:48:55 +11001376 [
Tim Rice648f8762011-01-26 12:38:57 -08001377 AC_DEFINE([GLOB_HAS_GL_MATCHC], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001378 [Define if your system glob() function has
1379 gl_matchc options in glob_t])
Tim Rice648f8762011-01-26 12:38:57 -08001380 AC_MSG_RESULT([yes])
1381 ], [
1382 AC_MSG_RESULT([no])
1383])
Ben Lindstrom45b14db2001-03-17 01:15:38 +00001384
Damien Millera6e121a2010-10-07 21:39:17 +11001385# Check for g.gl_statv glob() extension
Tim Rice648f8762011-01-26 12:38:57 -08001386AC_MSG_CHECKING([for gl_statv and GLOB_KEEPSTAT extensions for glob])
1387AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <glob.h> ]], [[
Damien Millera6e121a2010-10-07 21:39:17 +11001388#ifndef GLOB_KEEPSTAT
1389#error "glob does not support GLOB_KEEPSTAT extension"
1390#endif
1391glob_t g;
1392g.gl_statv = NULL;
Tim Rice648f8762011-01-26 12:38:57 -08001393]])],
Damien Millera6e121a2010-10-07 21:39:17 +11001394 [
Tim Rice648f8762011-01-26 12:38:57 -08001395 AC_DEFINE([GLOB_HAS_GL_STATV], [1],
Damien Millera6e121a2010-10-07 21:39:17 +11001396 [Define if your system glob() function has
1397 gl_statv options in glob_t])
Tim Rice648f8762011-01-26 12:38:57 -08001398 AC_MSG_RESULT([yes])
1399 ], [
1400 AC_MSG_RESULT([no])
Damien Miller72ef7c12015-01-15 02:21:31 +11001401
Tim Rice648f8762011-01-26 12:38:57 -08001402])
Damien Millera6e121a2010-10-07 21:39:17 +11001403
Tim Rice648f8762011-01-26 12:38:57 -08001404AC_CHECK_DECLS([GLOB_NOMATCH], , , [#include <glob.h>])
Darren Tucker096faec2006-09-01 20:29:10 +10001405
Darren Tucker7df91b02016-07-14 12:25:24 +10001406AC_CHECK_DECL([VIS_ALL], ,
1407 AC_DEFINE(BROKEN_STRNVIS, 1, [missing VIS_ALL]), [#include <vis.h>])
1408
Damien Miller18bb4732001-03-28 14:35:30 +10001409AC_MSG_CHECKING([whether struct dirent allocates space for d_name])
Darren Tuckera0c2b392004-09-11 23:26:37 +10001410AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001411 [AC_LANG_PROGRAM([[
Damien Miller18bb4732001-03-28 14:35:30 +10001412#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08001413#include <dirent.h>]],
1414 [[
1415 struct dirent d;
1416 exit(sizeof(d.d_name)<=sizeof(char));
Darren Tucker623d92f2004-09-12 22:36:15 +10001417 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001418 [AC_MSG_RESULT([yes])],
Damien Miller18bb4732001-03-28 14:35:30 +10001419 [
Tim Rice648f8762011-01-26 12:38:57 -08001420 AC_MSG_RESULT([no])
1421 AC_DEFINE([BROKEN_ONE_BYTE_DIRENT_D_NAME], [1],
Darren Tucker79d09fa2005-11-24 22:34:54 +11001422 [Define if your struct dirent expects you to
Tim Rice7df8d392005-09-19 09:33:39 -07001423 allocate extra space for d_name])
Darren Tuckera0c2b392004-09-11 23:26:37 +10001424 ],
Tim Riceeae17cc2005-03-17 16:52:20 -08001425 [
Darren Tuckera0c2b392004-09-11 23:26:37 +10001426 AC_MSG_WARN([cross compiling: assuming BROKEN_ONE_BYTE_DIRENT_D_NAME])
Tim Rice648f8762011-01-26 12:38:57 -08001427 AC_DEFINE([BROKEN_ONE_BYTE_DIRENT_D_NAME])
Damien Miller18bb4732001-03-28 14:35:30 +10001428 ]
1429)
1430
Damien Miller36f49652004-08-15 18:40:59 +10001431AC_MSG_CHECKING([for /proc/pid/fd directory])
1432if test -d "/proc/$$/fd" ; then
Tim Rice648f8762011-01-26 12:38:57 -08001433 AC_DEFINE([HAVE_PROC_PID], [1], [Define if you have /proc/$pid/fd])
1434 AC_MSG_RESULT([yes])
Damien Miller36f49652004-08-15 18:40:59 +10001435else
Tim Rice648f8762011-01-26 12:38:57 -08001436 AC_MSG_RESULT([no])
Damien Miller36f49652004-08-15 18:40:59 +10001437fi
1438
Damien Millerc547bf12001-02-16 10:18:12 +11001439# Check whether user wants S/Key support
Damien Millera8e06ce2003-11-21 23:48:55 +11001440SKEY_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08001441AC_ARG_WITH([skey],
Darren Tucker1b6f2292005-02-11 16:11:49 +11001442 [ --with-skey[[=PATH]] Enable S/Key support (optionally in PATH)],
Damien Millerc547bf12001-02-16 10:18:12 +11001443 [
1444 if test "x$withval" != "xno" ; then
1445
1446 if test "x$withval" != "xyes" ; then
1447 CPPFLAGS="$CPPFLAGS -I${withval}/include"
1448 LDFLAGS="$LDFLAGS -L${withval}/lib"
1449 fi
1450
Tim Rice648f8762011-01-26 12:38:57 -08001451 AC_DEFINE([SKEY], [1], [Define if you want S/Key support])
Damien Millerc547bf12001-02-16 10:18:12 +11001452 LIBS="-lskey $LIBS"
Damien Millera8e06ce2003-11-21 23:48:55 +11001453 SKEY_MSG="yes"
Tim Riceeae17cc2005-03-17 16:52:20 -08001454
Tim Rice4cec93f2002-02-26 08:40:48 -08001455 AC_MSG_CHECKING([for s/key support])
Darren Tucker314d89e2005-10-17 23:29:23 +10001456 AC_LINK_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001457 [AC_LANG_PROGRAM([[
Tim Rice4cec93f2002-02-26 08:40:48 -08001458#include <stdio.h>
1459#include <skey.h>
Tim Rice648f8762011-01-26 12:38:57 -08001460 ]], [[
1461 char *ff = skey_keyinfo(""); ff="";
1462 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10001463 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001464 [AC_MSG_RESULT([yes])],
Tim Rice4cec93f2002-02-26 08:40:48 -08001465 [
Tim Rice648f8762011-01-26 12:38:57 -08001466 AC_MSG_RESULT([no])
Damien Millerc547bf12001-02-16 10:18:12 +11001467 AC_MSG_ERROR([** Incomplete or missing s/key libraries.])
1468 ])
Tim Ricee1d93702016-05-31 11:13:22 -07001469 AC_MSG_CHECKING([if skeychallenge takes 4 arguments])
Tim Rice648f8762011-01-26 12:38:57 -08001470 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1471#include <stdio.h>
1472#include <skey.h>
1473 ]], [[
1474 (void)skeychallenge(NULL,"name","",0);
1475 ]])],
1476 [
1477 AC_MSG_RESULT([yes])
1478 AC_DEFINE([SKEYCHALLENGE_4ARG], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001479 [Define if your skeychallenge()
1480 function takes 4 arguments (NetBSD)])],
Tim Rice648f8762011-01-26 12:38:57 -08001481 [
1482 AC_MSG_RESULT([no])
1483 ])
Damien Millerc547bf12001-02-16 10:18:12 +11001484 fi
1485 ]
1486)
1487
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001488# Check whether user wants to use ldns
1489LDNS_MSG="no"
1490AC_ARG_WITH(ldns,
1491 [ --with-ldns[[=PATH]] Use ldns for DNSSEC support (optionally in PATH)],
Damien Miller523db852017-02-03 16:01:22 +11001492 [
1493 ldns=""
1494 if test "x$withval" = "xyes" ; then
1495 AC_PATH_TOOL([LDNSCONFIG], [ldns-config], [no])
1496 if test "x$PKGCONFIG" = "xno"; then
1497 CPPFLAGS="$CPPFLAGS -I${withval}/include"
1498 LDFLAGS="$LDFLAGS -L${withval}/lib"
1499 LIBS="-lldns $LIBS"
1500 ldns=yes
1501 else
1502 LIBS="$LIBS `$LDNSCONFIG --libs`"
1503 CPPFLAGS="$CPPFLAGS `$LDNSCONFIG --cflags`"
Darren Tucker7af27bf2017-03-24 09:44:56 +11001504 ldns=yes
Damien Miller523db852017-02-03 16:01:22 +11001505 fi
1506 elif test "x$withval" != "xno" ; then
1507 CPPFLAGS="$CPPFLAGS -I${withval}/include"
1508 LDFLAGS="$LDFLAGS -L${withval}/lib"
1509 LIBS="-lldns $LIBS"
1510 ldns=yes
1511 fi
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001512
Damien Miller523db852017-02-03 16:01:22 +11001513 # Verify that it works.
1514 if test "x$ldns" = "xyes" ; then
1515 AC_DEFINE(HAVE_LDNS, 1, [Define if you want ldns support])
1516 LDNS_MSG="yes"
1517 AC_MSG_CHECKING([for ldns support])
1518 AC_LINK_IFELSE(
1519 [AC_LANG_SOURCE([[
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001520#include <stdio.h>
1521#include <stdlib.h>
1522#include <stdint.h>
1523#include <ldns/ldns.h>
1524int main() { ldns_status status = ldns_verify_trusted(NULL, NULL, NULL, NULL); status=LDNS_STATUS_OK; exit(0); }
Damien Miller523db852017-02-03 16:01:22 +11001525 ]])
1526 ],
1527 [AC_MSG_RESULT(yes)],
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001528 [
1529 AC_MSG_RESULT(no)
1530 AC_MSG_ERROR([** Incomplete or missing ldns libraries.])
1531 ])
Damien Miller523db852017-02-03 16:01:22 +11001532 fi
1533])
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001534
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001535# Check whether user wants libedit support
1536LIBEDIT_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08001537AC_ARG_WITH([libedit],
Darren Tucker1b6f2292005-02-11 16:11:49 +11001538 [ --with-libedit[[=PATH]] Enable libedit support for sftp],
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001539 [ if test "x$withval" != "xno" ; then
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001540 if test "x$withval" = "xyes" ; then
Darren Tucker59353892012-05-19 15:24:37 +10001541 AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no])
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001542 if test "x$PKGCONFIG" != "xno"; then
Tim Rice648f8762011-01-26 12:38:57 -08001543 AC_MSG_CHECKING([if $PKGCONFIG knows about libedit])
Tim Ricee1d93702016-05-31 11:13:22 -07001544 if "$PKGCONFIG" libedit; then
Tim Rice648f8762011-01-26 12:38:57 -08001545 AC_MSG_RESULT([yes])
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001546 use_pkgconfig_for_libedit=yes
1547 else
Tim Rice648f8762011-01-26 12:38:57 -08001548 AC_MSG_RESULT([no])
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001549 fi
1550 fi
1551 else
Darren Tuckerc373a562005-09-22 20:15:08 +10001552 CPPFLAGS="$CPPFLAGS -I${withval}/include"
1553 if test -n "${need_dash_r}"; then
1554 LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
1555 else
1556 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
1557 fi
Darren Tucker1df61452005-03-21 09:58:07 +11001558 fi
Damien Miller1f789802010-10-11 22:35:22 +11001559 if test "x$use_pkgconfig_for_libedit" = "xyes"; then
Darren Tucker8369c8e2013-12-05 11:00:16 +11001560 LIBEDIT=`$PKGCONFIG --libs libedit`
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001561 CPPFLAGS="$CPPFLAGS `$PKGCONFIG --cflags libedit`"
1562 else
1563 LIBEDIT="-ledit -lcurses"
1564 fi
1565 OTHERLIBS=`echo $LIBEDIT | sed 's/-ledit//'`
Tim Rice648f8762011-01-26 12:38:57 -08001566 AC_CHECK_LIB([edit], [el_init],
1567 [ AC_DEFINE([USE_LIBEDIT], [1], [Use libedit for sftp])
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001568 LIBEDIT_MSG="yes"
Tim Rice648f8762011-01-26 12:38:57 -08001569 AC_SUBST([LIBEDIT])
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001570 ],
Tim Rice648f8762011-01-26 12:38:57 -08001571 [ AC_MSG_ERROR([libedit not found]) ],
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001572 [ $OTHERLIBS ]
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001573 )
Tim Rice648f8762011-01-26 12:38:57 -08001574 AC_MSG_CHECKING([if libedit version is compatible])
Tim Ricec1819c82005-08-15 17:48:40 -07001575 AC_COMPILE_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001576 [AC_LANG_PROGRAM([[ #include <histedit.h> ]],
1577 [[
Darren Tuckerc7572b22005-08-10 20:34:15 +10001578 int i = H_SETSIZE;
1579 el_init("", NULL, NULL, NULL);
1580 exit(0);
Tim Ricec1819c82005-08-15 17:48:40 -07001581 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001582 [ AC_MSG_RESULT([yes]) ],
1583 [ AC_MSG_RESULT([no])
1584 AC_MSG_ERROR([libedit version is not compatible]) ]
Darren Tuckerc7572b22005-08-10 20:34:15 +10001585 )
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001586 fi ]
1587)
1588
Darren Tuckerd9f88912005-02-20 21:01:48 +11001589AUDIT_MODULE=none
Tim Rice648f8762011-01-26 12:38:57 -08001590AC_ARG_WITH([audit],
Darren Tuckerea52a822011-01-17 21:15:27 +11001591 [ --with-audit=module Enable audit support (modules=debug,bsm,linux)],
Darren Tuckerd9f88912005-02-20 21:01:48 +11001592 [
Tim Rice648f8762011-01-26 12:38:57 -08001593 AC_MSG_CHECKING([for supported audit module])
Darren Tuckerd9f88912005-02-20 21:01:48 +11001594 case "$withval" in
1595 bsm)
Tim Rice648f8762011-01-26 12:38:57 -08001596 AC_MSG_RESULT([bsm])
Darren Tuckerd9f88912005-02-20 21:01:48 +11001597 AUDIT_MODULE=bsm
1598 dnl Checks for headers, libs and functions
Tim Rice648f8762011-01-26 12:38:57 -08001599 AC_CHECK_HEADERS([bsm/audit.h], [],
1600 [AC_MSG_ERROR([BSM enabled and bsm/audit.h not found])],
Darren Tucker6d0d6fb2006-09-09 01:05:21 +10001601 [
1602#ifdef HAVE_TIME_H
1603# include <time.h>
1604#endif
1605 ]
1606)
Tim Rice648f8762011-01-26 12:38:57 -08001607 AC_CHECK_LIB([bsm], [getaudit], [],
1608 [AC_MSG_ERROR([BSM enabled and required library not found])])
1609 AC_CHECK_FUNCS([getaudit], [],
1610 [AC_MSG_ERROR([BSM enabled and required function not found])])
Darren Tuckerd9f88912005-02-20 21:01:48 +11001611 # These are optional
Tim Rice648f8762011-01-26 12:38:57 -08001612 AC_CHECK_FUNCS([getaudit_addr aug_get_machine])
1613 AC_DEFINE([USE_BSM_AUDIT], [1], [Use BSM audit module])
Darren Tucker1fcec9d2013-12-19 11:00:12 +11001614 if test "$sol2ver" -ge 11; then
Tim Ricee1d93702016-05-31 11:13:22 -07001615 SSHDLIBS="$SSHDLIBS -lscf"
1616 AC_DEFINE([BROKEN_BSM_API], [1],
1617 [The system has incomplete BSM API])
Darren Tucker93a2d412012-02-24 10:40:41 +11001618 fi
Darren Tuckerd9f88912005-02-20 21:01:48 +11001619 ;;
Darren Tuckerea52a822011-01-17 21:15:27 +11001620 linux)
Tim Rice648f8762011-01-26 12:38:57 -08001621 AC_MSG_RESULT([linux])
Darren Tuckerea52a822011-01-17 21:15:27 +11001622 AUDIT_MODULE=linux
1623 dnl Checks for headers, libs and functions
Tim Rice648f8762011-01-26 12:38:57 -08001624 AC_CHECK_HEADERS([libaudit.h])
Darren Tuckerea52a822011-01-17 21:15:27 +11001625 SSHDLIBS="$SSHDLIBS -laudit"
Tim Rice648f8762011-01-26 12:38:57 -08001626 AC_DEFINE([USE_LINUX_AUDIT], [1], [Use Linux audit module])
Darren Tuckerea52a822011-01-17 21:15:27 +11001627 ;;
Darren Tuckerd9f88912005-02-20 21:01:48 +11001628 debug)
1629 AUDIT_MODULE=debug
Tim Rice648f8762011-01-26 12:38:57 -08001630 AC_MSG_RESULT([debug])
1631 AC_DEFINE([SSH_AUDIT_EVENTS], [1], [Use audit debugging module])
Darren Tuckerd9f88912005-02-20 21:01:48 +11001632 ;;
Tim Rice8bc6b902005-08-09 10:09:53 -07001633 no)
Tim Rice648f8762011-01-26 12:38:57 -08001634 AC_MSG_RESULT([no])
Tim Rice8bc6b902005-08-09 10:09:53 -07001635 ;;
Darren Tuckerd9f88912005-02-20 21:01:48 +11001636 *)
1637 AC_MSG_ERROR([Unknown audit module $withval])
1638 ;;
1639 esac ]
1640)
1641
Darren Tucker096118d2014-01-21 12:48:51 +11001642AC_ARG_WITH([pie],
Damien Miller76c04802015-01-13 19:38:18 +11001643 [ --with-pie Build Position Independent Executables if possible], [
Darren Tucker096118d2014-01-21 12:48:51 +11001644 if test "x$withval" = "xno"; then
Damien Miller852472a2014-01-22 16:31:18 +11001645 use_pie=no
Darren Tucker096118d2014-01-21 12:48:51 +11001646 fi
1647 if test "x$withval" = "xyes"; then
Damien Miller852472a2014-01-22 16:31:18 +11001648 use_pie=yes
Darren Tucker096118d2014-01-21 12:48:51 +11001649 fi
1650 ]
1651)
Damien Miller852472a2014-01-22 16:31:18 +11001652if test "x$use_pie" = "x"; then
1653 use_pie=no
1654fi
1655if test "x$use_toolchain_hardening" != "x1" && test "x$use_pie" = "xauto"; then
1656 # Turn off automatic PIE when toolchain hardening is off.
1657 use_pie=no
1658fi
Damien Millerc161fc92014-01-29 21:01:33 +11001659if test "x$use_pie" = "xauto"; then
Damien Miller852472a2014-01-22 16:31:18 +11001660 # Automatic PIE requires gcc >= 4.x
1661 AC_MSG_CHECKING([for gcc >= 4.x])
1662 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1663#if !defined(__GNUC__) || __GNUC__ < 4
1664#error gcc is too old
1665#endif
1666]])],
1667 [ AC_MSG_RESULT([yes]) ],
1668 [ AC_MSG_RESULT([no])
1669 use_pie=no ]
1670)
1671fi
1672if test "x$use_pie" != "xno"; then
Damien Miller5c2ff5e2014-01-22 21:30:12 +11001673 SAVED_CFLAGS="$CFLAGS"
1674 SAVED_LDFLAGS="$LDFLAGS"
Darren Tucker096118d2014-01-21 12:48:51 +11001675 OSSH_CHECK_CFLAG_COMPILE([-fPIE])
1676 OSSH_CHECK_LDFLAG_LINK([-pie])
Damien Miller5c2ff5e2014-01-22 21:30:12 +11001677 # We use both -fPIE and -pie or neither.
1678 AC_MSG_CHECKING([whether both -fPIE and -pie are supported])
1679 if echo "x $CFLAGS" | grep ' -fPIE' >/dev/null 2>&1 && \
1680 echo "x $LDFLAGS" | grep ' -pie' >/dev/null 2>&1 ; then
1681 AC_MSG_RESULT([yes])
1682 else
1683 AC_MSG_RESULT([no])
1684 CFLAGS="$SAVED_CFLAGS"
1685 LDFLAGS="$SAVED_LDFLAGS"
1686 fi
Darren Tucker096118d2014-01-21 12:48:51 +11001687fi
1688
Damien Millerfe1f1432003-02-24 15:45:42 +11001689dnl Checks for library functions. Please keep in alphabetical order
Tim Rice648f8762011-01-26 12:38:57 -08001690AC_CHECK_FUNCS([ \
Damien Miller1ff130d2013-12-07 11:51:51 +11001691 Blowfish_initstate \
1692 Blowfish_expandstate \
1693 Blowfish_expand0state \
1694 Blowfish_stream2word \
Damien Miller57f39152005-11-24 19:58:19 +11001695 asprintf \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001696 b64_ntop \
1697 __b64_ntop \
1698 b64_pton \
1699 __b64_pton \
1700 bcopy \
Damien Millera9134422013-12-07 11:35:36 +11001701 bcrypt_pbkdf \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001702 bindresvport_sa \
Damien Miller1ff130d2013-12-07 11:51:51 +11001703 blf_enc \
Damien Millerc96d8532014-01-25 13:12:28 +11001704 cap_rights_limit \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001705 clock \
1706 closefrom \
1707 dirfd \
Darren Tuckerefdf5342013-05-30 08:29:08 +10001708 endgrent \
Darren Tucker6310ef22016-07-13 14:42:35 +10001709 err \
1710 errx \
Damien Miller1d2c4562014-02-04 11:18:20 +11001711 explicit_bzero \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001712 fchmod \
1713 fchown \
1714 freeaddrinfo \
Damien Millerb7956912017-09-19 12:29:23 +10001715 freezero \
Darren Tuckera5cf1e22014-01-17 18:10:58 +11001716 fstatfs \
Darren Tucker598eaa62008-06-09 03:32:29 +10001717 fstatvfs \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001718 futimes \
1719 getaddrinfo \
1720 getcwd \
1721 getgrouplist \
1722 getnameinfo \
1723 getopt \
Damien Miller151c6e42017-06-01 15:25:13 +10001724 getpagesize \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001725 getpeereid \
Darren Tucker164aa302007-03-21 21:39:57 +11001726 getpeerucred \
Darren Tucker3c4a24c2013-02-15 11:41:35 +11001727 getpgid \
1728 getpgrp \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001729 _getpty \
1730 getrlimit \
1731 getttyent \
1732 glob \
Darren Tucker909a3902010-01-15 12:38:30 +11001733 group_from_gid \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001734 inet_aton \
1735 inet_ntoa \
1736 inet_ntop \
1737 innetgr \
Darren Tuckerd38f05d2017-03-20 13:38:27 +11001738 llabs \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001739 login_getcapbool \
1740 md5_crypt \
1741 memmove \
Damien Miller3d673d12014-08-27 06:32:01 +10001742 memset_s \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001743 mkdtemp \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001744 ngetaddrinfo \
1745 nsleep \
1746 ogetaddrinfo \
1747 openlog_r \
Darren Tucker3ddd15e2015-11-30 07:23:53 +11001748 pledge \
Darren Tuckerfebf0f52007-06-25 22:15:12 +10001749 poll \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001750 prctl \
1751 pstat \
1752 readpassphrase \
Darren Tucker642652d2014-12-10 01:32:23 +11001753 reallocarray \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001754 recvmsg \
Damien Miller151c6e42017-06-01 15:25:13 +10001755 recallocarray \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001756 rresvport_af \
1757 sendmsg \
1758 setdtablesize \
1759 setegid \
1760 setenv \
1761 seteuid \
Darren Tucker909a3902010-01-15 12:38:30 +11001762 setgroupent \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001763 setgroups \
Darren Tucker34f702a2012-07-04 08:50:09 +10001764 setlinebuf \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001765 setlogin \
Darren Tucker909a3902010-01-15 12:38:30 +11001766 setpassent\
Darren Tucker0c9653f2005-05-28 15:58:14 +10001767 setpcred \
1768 setproctitle \
1769 setregid \
1770 setreuid \
1771 setrlimit \
1772 setsid \
1773 setvbuf \
1774 sigaction \
1775 sigvec \
1776 snprintf \
1777 socketpair \
Darren Tucker5b2e2ba2008-06-08 09:25:28 +10001778 statfs \
1779 statvfs \
Darren Tuckerafec0772016-12-13 10:23:03 +11001780 strcasestr \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001781 strdup \
1782 strerror \
1783 strlcat \
1784 strlcpy \
1785 strmode \
Darren Tuckerb54f50e2011-09-29 23:17:18 +10001786 strnlen \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001787 strnvis \
Darren Tuckeraa74f672010-08-16 13:15:23 +10001788 strptime \
Darren Tucker44fc3342017-09-25 09:48:10 +10001789 strsignal \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001790 strtonum \
Darren Tucker81eb5d52005-06-01 21:39:33 +10001791 strtoll \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001792 strtoul \
Darren Tucker8e6fb782013-02-15 12:13:01 +11001793 strtoull \
Damien Miller34a17692007-06-11 14:15:42 +10001794 swap32 \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001795 sysconf \
1796 tcgetpgrp \
Damien Milleraa180632010-10-07 21:25:27 +11001797 timingsafe_bcmp \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001798 truncate \
1799 unsetenv \
1800 updwtmpx \
Darren Tucker909a3902010-01-15 12:38:30 +11001801 user_from_uid \
Damien Millerf4db77d2013-03-15 10:34:25 +11001802 usleep \
Damien Miller57f39152005-11-24 19:58:19 +11001803 vasprintf \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001804 vsnprintf \
1805 waitpid \
Darren Tucker6310ef22016-07-13 14:42:35 +10001806 warn \
Tim Rice648f8762011-01-26 12:38:57 -08001807])
Tim Rice13aae5e2001-10-21 17:53:58 -07001808
Darren Tuckerc61d5ec2017-02-03 14:10:34 +11001809dnl Wide character support.
Darren Tuckera2333582016-07-14 10:59:09 +10001810AC_CHECK_FUNCS([mblen mbtowc nl_langinfo wcwidth])
Darren Tuckera2333582016-07-14 10:59:09 +10001811
Darren Tucker10e290e2016-12-13 13:51:32 +11001812TEST_SSH_UTF8=${TEST_SSH_UTF8:=yes}
Darren Tucker47b8c992016-12-08 15:48:34 +11001813AC_MSG_CHECKING([for utf8 locale support])
1814AC_RUN_IFELSE(
1815 [AC_LANG_PROGRAM([[
1816#include <locale.h>
Darren Tuckerc3599502016-12-09 12:52:02 +11001817#include <stdlib.h>
Darren Tucker47b8c992016-12-08 15:48:34 +11001818 ]], [[
1819 char *loc = setlocale(LC_CTYPE, "en_US.UTF-8");
1820 if (loc != NULL)
1821 exit(0);
1822 exit(1);
1823 ]])],
1824 AC_MSG_RESULT(yes),
1825 [AC_MSG_RESULT(no)
1826 TEST_SSH_UTF8=no],
1827 AC_MSG_WARN([cross compiling: assuming yes])
1828)
1829
Tim Ricec7a8af02010-11-08 14:26:23 -08001830AC_LINK_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001831 [AC_LANG_PROGRAM(
1832 [[ #include <ctype.h> ]],
1833 [[ return (isblank('a')); ]])],
1834 [AC_DEFINE([HAVE_ISBLANK], [1], [Define if you have isblank(3C).])
Tim Ricec7a8af02010-11-08 14:26:23 -08001835])
1836
Damien Miller5fbe93f2016-07-15 13:54:31 +10001837disable_pkcs11=
1838AC_ARG_ENABLE([pkcs11],
1839 [ --disable-pkcs11 disable PKCS#11 support code [no]],
1840 [
1841 if test "x$enableval" = "xno" ; then
1842 disable_pkcs11=1
1843 fi
1844 ]
1845)
1846
Damien Miller72ef7c12015-01-15 02:21:31 +11001847# PKCS11 depends on OpenSSL.
Damien Miller5fbe93f2016-07-15 13:54:31 +10001848if test "x$openssl" = "xyes" && test "x$disable_pkcs11" = "x"; then
Damien Miller72ef7c12015-01-15 02:21:31 +11001849 # PKCS#11 support requires dlopen() and co
1850 AC_SEARCH_LIBS([dlopen], [dl],
1851 [AC_DEFINE([ENABLE_PKCS11], [], [Enable for PKCS#11 support])]
1852 )
1853fi
Damien Millerb3c9f782010-02-12 10:11:34 +11001854
Darren Tuckerd5e082f2003-09-22 12:08:23 +10001855# IRIX has a const char return value for gai_strerror()
Tim Rice648f8762011-01-26 12:38:57 -08001856AC_CHECK_FUNCS([gai_strerror], [
1857 AC_DEFINE([HAVE_GAI_STRERROR])
1858 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckerd5e082f2003-09-22 12:08:23 +10001859#include <sys/types.h>
1860#include <sys/socket.h>
1861#include <netdb.h>
1862
Tim Rice648f8762011-01-26 12:38:57 -08001863const char *gai_strerror(int);
1864 ]], [[
1865 char *str;
1866 str = gai_strerror(0);
1867 ]])], [
1868 AC_DEFINE([HAVE_CONST_GAI_STRERROR_PROTO], [1],
1869 [Define if gai_strerror() returns const char *])], [])])
Darren Tuckerd5e082f2003-09-22 12:08:23 +10001870
Tim Rice648f8762011-01-26 12:38:57 -08001871AC_SEARCH_LIBS([nanosleep], [rt posix4], [AC_DEFINE([HAVE_NANOSLEEP], [1],
1872 [Some systems put nanosleep outside of libc])])
Damien Millercd6853c2003-01-28 11:33:42 +11001873
Darren Tuckera7108912013-06-02 08:18:31 +10001874AC_SEARCH_LIBS([clock_gettime], [rt],
1875 [AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Have clock_gettime])])
1876
Darren Tuckerf1159b52003-07-07 19:44:01 +10001877dnl Make sure prototypes are defined for these before using them.
Tim Rice648f8762011-01-26 12:38:57 -08001878AC_CHECK_DECL([getrusage], [AC_CHECK_FUNCS([getrusage])])
1879AC_CHECK_DECL([strsep],
1880 [AC_CHECK_FUNCS([strsep])],
Darren Tucker390b6d52005-05-28 16:54:36 +10001881 [],
1882 [
1883#ifdef HAVE_STRING_H
1884# include <string.h>
1885#endif
1886 ])
Ben Lindstrom3e006472002-10-16 00:24:03 +00001887
Darren Tuckerb2427c82003-09-10 15:22:44 +10001888dnl tcsendbreak might be a macro
Tim Rice648f8762011-01-26 12:38:57 -08001889AC_CHECK_DECL([tcsendbreak],
1890 [AC_DEFINE([HAVE_TCSENDBREAK])],
1891 [AC_CHECK_FUNCS([tcsendbreak])],
Darren Tuckerb2427c82003-09-10 15:22:44 +10001892 [#include <termios.h>]
1893)
1894
Tim Rice648f8762011-01-26 12:38:57 -08001895AC_CHECK_DECLS([h_errno], , ,[#include <netdb.h>])
Darren Tucker5bb14002004-04-23 18:53:10 +10001896
Tim Rice648f8762011-01-26 12:38:57 -08001897AC_CHECK_DECLS([SHUT_RD], , ,
Darren Tucker128a0892006-07-12 19:02:56 +10001898 [
1899#include <sys/types.h>
1900#include <sys/socket.h>
1901 ])
Darren Tucker248469b2006-07-12 14:14:31 +10001902
Tim Rice648f8762011-01-26 12:38:57 -08001903AC_CHECK_DECLS([O_NONBLOCK], , ,
Darren Tucker248469b2006-07-12 14:14:31 +10001904 [
1905#include <sys/types.h>
1906#ifdef HAVE_SYS_STAT_H
1907# include <sys/stat.h>
1908#endif
1909#ifdef HAVE_FCNTL_H
1910# include <fcntl.h>
1911#endif
1912 ])
1913
Tim Rice648f8762011-01-26 12:38:57 -08001914AC_CHECK_DECLS([writev], , , [
Darren Tuckered0b5922006-09-03 22:44:49 +10001915#include <sys/types.h>
1916#include <sys/uio.h>
1917#include <unistd.h>
1918 ])
1919
Tim Rice648f8762011-01-26 12:38:57 -08001920AC_CHECK_DECLS([MAXSYMLINKS], , , [
Darren Tucker6d862a52007-04-29 14:39:02 +10001921#include <sys/param.h>
1922 ])
1923
Tim Rice648f8762011-01-26 12:38:57 -08001924AC_CHECK_DECLS([offsetof], , , [
Darren Tuckerdca0edf2007-04-29 15:06:44 +10001925#include <stddef.h>
1926 ])
1927
Darren Tuckerc7aad002013-06-02 07:18:47 +10001928# extra bits for select(2)
1929AC_CHECK_DECLS([howmany, NFDBITS], [], [], [[
1930#include <sys/param.h>
1931#include <sys/types.h>
1932#ifdef HAVE_SYS_SYSMACROS_H
1933#include <sys/sysmacros.h>
1934#endif
1935#ifdef HAVE_SYS_SELECT_H
1936#include <sys/select.h>
1937#endif
1938#ifdef HAVE_SYS_TIME_H
1939#include <sys/time.h>
1940#endif
1941#ifdef HAVE_UNISTD_H
1942#include <unistd.h>
1943#endif
1944 ]])
1945AC_CHECK_TYPES([fd_mask], [], [], [[
1946#include <sys/param.h>
1947#include <sys/types.h>
1948#ifdef HAVE_SYS_SELECT_H
1949#include <sys/select.h>
1950#endif
1951#ifdef HAVE_SYS_TIME_H
1952#include <sys/time.h>
1953#endif
1954#ifdef HAVE_UNISTD_H
1955#include <unistd.h>
1956#endif
1957 ]])
1958
Tim Rice648f8762011-01-26 12:38:57 -08001959AC_CHECK_FUNCS([setresuid], [
Darren Tucker2a6b0292003-12-31 14:59:17 +11001960 dnl Some platorms have setresuid that isn't implemented, test for this
Tim Rice648f8762011-01-26 12:38:57 -08001961 AC_MSG_CHECKING([if setresuid seems to work])
Darren Tucker623d92f2004-09-12 22:36:15 +10001962 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001963 [AC_LANG_PROGRAM([[
Darren Tuckere937be32003-12-17 18:53:26 +11001964#include <stdlib.h>
1965#include <errno.h>
Tim Rice648f8762011-01-26 12:38:57 -08001966 ]], [[
1967 errno=0;
1968 setresuid(0,0,0);
1969 if (errno==ENOSYS)
1970 exit(1);
1971 else
1972 exit(0);
Darren Tucker623d92f2004-09-12 22:36:15 +10001973 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001974 [AC_MSG_RESULT([yes])],
1975 [AC_DEFINE([BROKEN_SETRESUID], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001976 [Define if your setresuid() is broken])
Tim Rice648f8762011-01-26 12:38:57 -08001977 AC_MSG_RESULT([not implemented])],
Darren Tuckera0c2b392004-09-11 23:26:37 +10001978 [AC_MSG_WARN([cross compiling: not checking setresuid])]
Darren Tucker2a6b0292003-12-31 14:59:17 +11001979 )
1980])
Darren Tuckere937be32003-12-17 18:53:26 +11001981
Tim Rice648f8762011-01-26 12:38:57 -08001982AC_CHECK_FUNCS([setresgid], [
Darren Tucker2a6b0292003-12-31 14:59:17 +11001983 dnl Some platorms have setresgid that isn't implemented, test for this
Tim Rice648f8762011-01-26 12:38:57 -08001984 AC_MSG_CHECKING([if setresgid seems to work])
Darren Tucker623d92f2004-09-12 22:36:15 +10001985 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001986 [AC_LANG_PROGRAM([[
Darren Tuckere937be32003-12-17 18:53:26 +11001987#include <stdlib.h>
1988#include <errno.h>
Tim Rice648f8762011-01-26 12:38:57 -08001989 ]], [[
1990 errno=0;
1991 setresgid(0,0,0);
1992 if (errno==ENOSYS)
1993 exit(1);
1994 else
1995 exit(0);
Darren Tucker623d92f2004-09-12 22:36:15 +10001996 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001997 [AC_MSG_RESULT([yes])],
1998 [AC_DEFINE([BROKEN_SETRESGID], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001999 [Define if your setresgid() is broken])
Tim Rice648f8762011-01-26 12:38:57 -08002000 AC_MSG_RESULT([not implemented])],
Darren Tuckera0c2b392004-09-11 23:26:37 +10002001 [AC_MSG_WARN([cross compiling: not checking setresuid])]
Darren Tucker2a6b0292003-12-31 14:59:17 +11002002 )
2003])
Darren Tuckere937be32003-12-17 18:53:26 +11002004
Darren Tuckerd3e2aee2015-07-17 12:52:34 +10002005AC_CHECK_FUNCS([realpath], [
2006 dnl the sftp v3 spec says SSH_FXP_REALPATH will "canonicalize any given
2007 dnl path name", however some implementations of realpath (and some
2008 dnl versions of the POSIX spec) do not work on non-existent files,
2009 dnl so we use the OpenBSD implementation on those platforms.
2010 AC_MSG_CHECKING([if realpath works with non-existent files])
2011 AC_RUN_IFELSE(
2012 [AC_LANG_PROGRAM([[
2013#include <limits.h>
2014#include <stdlib.h>
2015#include <errno.h>
2016 ]], [[
2017 char buf[PATH_MAX];
2018 if (realpath("/opensshnonexistentfilename1234", buf) == NULL)
2019 if (errno == ENOENT)
2020 exit(1);
2021 exit(0);
2022 ]])],
2023 [AC_MSG_RESULT([yes])],
2024 [AC_DEFINE([BROKEN_REALPATH], [1],
2025 [realpath does not work with nonexistent files])
2026 AC_MSG_RESULT([no])],
2027 [AC_MSG_WARN([cross compiling: assuming working])]
2028 )
2029])
2030
Damien Millerad833b32000-08-23 10:46:23 +10002031dnl Checks for time functions
Tim Rice648f8762011-01-26 12:38:57 -08002032AC_CHECK_FUNCS([gettimeofday time])
Damien Millerad833b32000-08-23 10:46:23 +10002033dnl Checks for utmp functions
Tim Rice648f8762011-01-26 12:38:57 -08002034AC_CHECK_FUNCS([endutent getutent getutid getutline pututline setutent])
2035AC_CHECK_FUNCS([utmpname])
Damien Millerad833b32000-08-23 10:46:23 +10002036dnl Checks for utmpx functions
Tim Rice648f8762011-01-26 12:38:57 -08002037AC_CHECK_FUNCS([endutxent getutxent getutxid getutxline getutxuser pututxline])
2038AC_CHECK_FUNCS([setutxdb setutxent utmpxname])
Damien Miller20e231f2009-02-12 13:12:21 +11002039dnl Checks for lastlog functions
Tim Rice648f8762011-01-26 12:38:57 -08002040AC_CHECK_FUNCS([getlastlogxbyname])
Damien Millercedfecc1999-11-15 14:36:53 +11002041
Tim Rice648f8762011-01-26 12:38:57 -08002042AC_CHECK_FUNC([daemon],
2043 [AC_DEFINE([HAVE_DAEMON], [1], [Define if your libraries define daemon()])],
2044 [AC_CHECK_LIB([bsd], [daemon],
2045 [LIBS="$LIBS -lbsd"; AC_DEFINE([HAVE_DAEMON])])]
Damien Miller04f80141999-11-19 15:32:34 +11002046)
2047
Tim Rice648f8762011-01-26 12:38:57 -08002048AC_CHECK_FUNC([getpagesize],
2049 [AC_DEFINE([HAVE_GETPAGESIZE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07002050 [Define if your libraries define getpagesize()])],
Tim Rice648f8762011-01-26 12:38:57 -08002051 [AC_CHECK_LIB([ucb], [getpagesize],
2052 [LIBS="$LIBS -lucb"; AC_DEFINE([HAVE_GETPAGESIZE])])]
Damien Miller9fb07e42000-03-05 16:22:59 +11002053)
2054
Damien Millercb170cb2000-07-01 16:52:55 +10002055# Check for broken snprintf
2056if test "x$ac_cv_func_snprintf" = "xyes" ; then
2057 AC_MSG_CHECKING([whether snprintf correctly terminates long strings])
Darren Tuckera0c2b392004-09-11 23:26:37 +10002058 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002059 [AC_LANG_PROGRAM([[ #include <stdio.h> ]],
2060 [[
2061 char b[5];
2062 snprintf(b,5,"123456789");
Tim Ricee1d93702016-05-31 11:13:22 -07002063 exit(b[4]!='\0');
Darren Tucker623d92f2004-09-12 22:36:15 +10002064 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08002065 [AC_MSG_RESULT([yes])],
Damien Millercb170cb2000-07-01 16:52:55 +10002066 [
Tim Rice648f8762011-01-26 12:38:57 -08002067 AC_MSG_RESULT([no])
2068 AC_DEFINE([BROKEN_SNPRINTF], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07002069 [Define if your snprintf is busted])
Damien Millercb170cb2000-07-01 16:52:55 +10002070 AC_MSG_WARN([****** Your snprintf() function is broken, complain to your vendor])
Darren Tuckera0c2b392004-09-11 23:26:37 +10002071 ],
2072 [ AC_MSG_WARN([cross compiling: Assuming working snprintf()]) ]
Damien Millercb170cb2000-07-01 16:52:55 +10002073 )
2074fi
2075
Damien Millerd244a582014-08-23 17:06:49 +10002076# We depend on vsnprintf returning the right thing on overflow: the
2077# number of characters it tried to create (as per SUSv3)
2078if test "x$ac_cv_func_vsnprintf" = "xyes" ; then
Damien Miller57f39152005-11-24 19:58:19 +11002079 AC_MSG_CHECKING([whether vsnprintf returns correct values on overflow])
2080 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002081 [AC_LANG_PROGRAM([[
Damien Miller57f39152005-11-24 19:58:19 +11002082#include <sys/types.h>
2083#include <stdio.h>
2084#include <stdarg.h>
2085
Damien Millerd244a582014-08-23 17:06:49 +10002086int x_snprintf(char *str, size_t count, const char *fmt, ...)
Damien Miller57f39152005-11-24 19:58:19 +11002087{
Damien Millerd244a582014-08-23 17:06:49 +10002088 size_t ret;
2089 va_list ap;
2090
2091 va_start(ap, fmt);
2092 ret = vsnprintf(str, count, fmt, ap);
2093 va_end(ap);
Damien Miller57f39152005-11-24 19:58:19 +11002094 return ret;
2095}
Tim Rice648f8762011-01-26 12:38:57 -08002096 ]], [[
Damien Millerd244a582014-08-23 17:06:49 +10002097char x[1];
2098if (x_snprintf(x, 1, "%s %d", "hello", 12345) != 11)
2099 return 1;
2100if (x_snprintf(NULL, 0, "%s %d", "hello", 12345) != 11)
2101 return 1;
2102return 0;
Tim Rice648f8762011-01-26 12:38:57 -08002103 ]])],
2104 [AC_MSG_RESULT([yes])],
Damien Miller57f39152005-11-24 19:58:19 +11002105 [
Tim Rice648f8762011-01-26 12:38:57 -08002106 AC_MSG_RESULT([no])
2107 AC_DEFINE([BROKEN_SNPRINTF], [1],
Damien Miller57f39152005-11-24 19:58:19 +11002108 [Define if your snprintf is busted])
2109 AC_MSG_WARN([****** Your vsnprintf() function is broken, complain to your vendor])
2110 ],
2111 [ AC_MSG_WARN([cross compiling: Assuming working vsnprintf()]) ]
2112 )
2113fi
2114
Darren Tuckerd40c66c2005-12-17 22:32:03 +11002115# On systems where [v]snprintf is broken, but is declared in stdio,
2116# check that the fmt argument is const char * or just char *.
2117# This is only useful for when BROKEN_SNPRINTF
2118AC_MSG_CHECKING([whether snprintf can declare const char *fmt])
Tim Rice648f8762011-01-26 12:38:57 -08002119AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2120#include <stdio.h>
2121int snprintf(char *a, size_t b, const char *c, ...) { return 0; }
2122 ]], [[
2123 snprintf(0, 0, 0);
2124 ]])],
2125 [AC_MSG_RESULT([yes])
2126 AC_DEFINE([SNPRINTF_CONST], [const],
Darren Tuckerd40c66c2005-12-17 22:32:03 +11002127 [Define as const if snprintf() can declare const char *fmt])],
Tim Rice648f8762011-01-26 12:38:57 -08002128 [AC_MSG_RESULT([no])
2129 AC_DEFINE([SNPRINTF_CONST], [/* not const */])])
Darren Tuckerd40c66c2005-12-17 22:32:03 +11002130
Damien Millerb4097182004-05-23 14:09:40 +10002131# Check for missing getpeereid (or equiv) support
2132NO_PEERCHECK=""
Darren Tucker164aa302007-03-21 21:39:57 +11002133if test "x$ac_cv_func_getpeereid" != "xyes" -a "x$ac_cv_func_getpeerucred" != "xyes"; then
Damien Millerb4097182004-05-23 14:09:40 +10002134 AC_MSG_CHECKING([whether system supports SO_PEERCRED getsockopt])
Tim Rice648f8762011-01-26 12:38:57 -08002135 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2136#include <sys/types.h>
2137#include <sys/socket.h>]], [[int i = SO_PEERCRED;]])],
2138 [ AC_MSG_RESULT([yes])
2139 AC_DEFINE([HAVE_SO_PEERCRED], [1], [Have PEERCRED socket option])
2140 ], [AC_MSG_RESULT([no])
2141 NO_PEERCHECK=1
2142 ])
Damien Millerb4097182004-05-23 14:09:40 +10002143fi
2144
Damien Millere8328192003-01-07 15:18:32 +11002145dnl see whether mkstemp() requires XXXXXX
2146if test "x$ac_cv_func_mkdtemp" = "xyes" ; then
2147AC_MSG_CHECKING([for (overly) strict mkstemp])
Darren Tucker314d89e2005-10-17 23:29:23 +10002148AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002149 [AC_LANG_PROGRAM([[
Damien Millere8328192003-01-07 15:18:32 +11002150#include <stdlib.h>
Tim Rice648f8762011-01-26 12:38:57 -08002151 ]], [[
2152 char template[]="conftest.mkstemp-test";
2153 if (mkstemp(template) == -1)
2154 exit(1);
2155 unlink(template);
2156 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10002157 ]])],
Damien Millere8328192003-01-07 15:18:32 +11002158 [
Tim Rice648f8762011-01-26 12:38:57 -08002159 AC_MSG_RESULT([no])
Damien Millere8328192003-01-07 15:18:32 +11002160 ],
Damien Millera8e06ce2003-11-21 23:48:55 +11002161 [
Tim Rice648f8762011-01-26 12:38:57 -08002162 AC_MSG_RESULT([yes])
2163 AC_DEFINE([HAVE_STRICT_MKSTEMP], [1], [Silly mkstemp()])
Damien Millere8328192003-01-07 15:18:32 +11002164 ],
2165 [
Tim Rice648f8762011-01-26 12:38:57 -08002166 AC_MSG_RESULT([yes])
2167 AC_DEFINE([HAVE_STRICT_MKSTEMP])
Damien Millera8e06ce2003-11-21 23:48:55 +11002168 ]
Damien Millere8328192003-01-07 15:18:32 +11002169)
2170fi
2171
Darren Tucker70a3d552003-08-21 17:58:29 +10002172dnl make sure that openpty does not reacquire controlling terminal
2173if test ! -z "$check_for_openpty_ctty_bug"; then
Tim Rice648f8762011-01-26 12:38:57 -08002174 AC_MSG_CHECKING([if openpty correctly handles controlling tty])
Darren Tucker314d89e2005-10-17 23:29:23 +10002175 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002176 [AC_LANG_PROGRAM([[
Darren Tucker70a3d552003-08-21 17:58:29 +10002177#include <stdio.h>
2178#include <sys/fcntl.h>
2179#include <sys/types.h>
2180#include <sys/wait.h>
Tim Rice648f8762011-01-26 12:38:57 -08002181 ]], [[
Darren Tucker70a3d552003-08-21 17:58:29 +10002182 pid_t pid;
2183 int fd, ptyfd, ttyfd, status;
2184
2185 pid = fork();
2186 if (pid < 0) { /* failed */
2187 exit(1);
2188 } else if (pid > 0) { /* parent */
2189 waitpid(pid, &status, 0);
Damien Millera8e06ce2003-11-21 23:48:55 +11002190 if (WIFEXITED(status))
Darren Tucker70a3d552003-08-21 17:58:29 +10002191 exit(WEXITSTATUS(status));
2192 else
2193 exit(2);
2194 } else { /* child */
2195 close(0); close(1); close(2);
2196 setsid();
2197 openpty(&ptyfd, &ttyfd, NULL, NULL, NULL);
2198 fd = open("/dev/tty", O_RDWR | O_NOCTTY);
2199 if (fd >= 0)
2200 exit(3); /* Acquired ctty: broken */
2201 else
2202 exit(0); /* Did not acquire ctty: OK */
2203 }
Darren Tucker314d89e2005-10-17 23:29:23 +10002204 ]])],
Darren Tucker70a3d552003-08-21 17:58:29 +10002205 [
Tim Rice648f8762011-01-26 12:38:57 -08002206 AC_MSG_RESULT([yes])
Darren Tucker70a3d552003-08-21 17:58:29 +10002207 ],
2208 [
Tim Rice648f8762011-01-26 12:38:57 -08002209 AC_MSG_RESULT([no])
2210 AC_DEFINE([SSHD_ACQUIRES_CTTY])
Darren Tucker314d89e2005-10-17 23:29:23 +10002211 ],
2212 [
Tim Rice648f8762011-01-26 12:38:57 -08002213 AC_MSG_RESULT([cross-compiling, assuming yes])
Darren Tucker70a3d552003-08-21 17:58:29 +10002214 ]
2215 )
2216fi
2217
Tim Rice8bb561b2005-03-17 16:23:19 -08002218if test "x$ac_cv_func_getaddrinfo" = "xyes" && \
2219 test "x$check_for_hpux_broken_getaddrinfo" = "x1"; then
Tim Rice648f8762011-01-26 12:38:57 -08002220 AC_MSG_CHECKING([if getaddrinfo seems to work])
Darren Tucker314d89e2005-10-17 23:29:23 +10002221 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002222 [AC_LANG_PROGRAM([[
Darren Tucker4398cf52004-04-06 21:39:02 +10002223#include <stdio.h>
2224#include <sys/socket.h>
2225#include <netdb.h>
2226#include <errno.h>
2227#include <netinet/in.h>
2228
2229#define TEST_PORT "2222"
Tim Rice648f8762011-01-26 12:38:57 -08002230 ]], [[
Darren Tucker4398cf52004-04-06 21:39:02 +10002231 int err, sock;
2232 struct addrinfo *gai_ai, *ai, hints;
2233 char ntop[NI_MAXHOST], strport[NI_MAXSERV], *name = NULL;
2234
2235 memset(&hints, 0, sizeof(hints));
2236 hints.ai_family = PF_UNSPEC;
2237 hints.ai_socktype = SOCK_STREAM;
2238 hints.ai_flags = AI_PASSIVE;
2239
2240 err = getaddrinfo(name, TEST_PORT, &hints, &gai_ai);
2241 if (err != 0) {
2242 fprintf(stderr, "getaddrinfo failed (%s)", gai_strerror(err));
2243 exit(1);
2244 }
2245
2246 for (ai = gai_ai; ai != NULL; ai = ai->ai_next) {
2247 if (ai->ai_family != AF_INET6)
2248 continue;
2249
2250 err = getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop,
2251 sizeof(ntop), strport, sizeof(strport),
2252 NI_NUMERICHOST|NI_NUMERICSERV);
2253
2254 if (err != 0) {
2255 if (err == EAI_SYSTEM)
2256 perror("getnameinfo EAI_SYSTEM");
2257 else
2258 fprintf(stderr, "getnameinfo failed: %s\n",
2259 gai_strerror(err));
2260 exit(2);
2261 }
2262
2263 sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
2264 if (sock < 0)
2265 perror("socket");
2266 if (bind(sock, ai->ai_addr, ai->ai_addrlen) < 0) {
2267 if (errno == EBADF)
2268 exit(3);
2269 }
2270 }
2271 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10002272 ]])],
Darren Tucker4398cf52004-04-06 21:39:02 +10002273 [
Tim Rice648f8762011-01-26 12:38:57 -08002274 AC_MSG_RESULT([yes])
Darren Tucker4398cf52004-04-06 21:39:02 +10002275 ],
2276 [
Tim Rice648f8762011-01-26 12:38:57 -08002277 AC_MSG_RESULT([no])
2278 AC_DEFINE([BROKEN_GETADDRINFO])
Darren Tucker314d89e2005-10-17 23:29:23 +10002279 ],
2280 [
Tim Rice648f8762011-01-26 12:38:57 -08002281 AC_MSG_RESULT([cross-compiling, assuming yes])
Darren Tucker4398cf52004-04-06 21:39:02 +10002282 ]
2283 )
2284fi
2285
Tim Rice8bb561b2005-03-17 16:23:19 -08002286if test "x$ac_cv_func_getaddrinfo" = "xyes" && \
2287 test "x$check_for_aix_broken_getaddrinfo" = "x1"; then
Tim Rice648f8762011-01-26 12:38:57 -08002288 AC_MSG_CHECKING([if getaddrinfo seems to work])
Darren Tucker314d89e2005-10-17 23:29:23 +10002289 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002290 [AC_LANG_PROGRAM([[
Darren Tucker691d5232005-02-15 21:45:57 +11002291#include <stdio.h>
2292#include <sys/socket.h>
2293#include <netdb.h>
2294#include <errno.h>
2295#include <netinet/in.h>
2296
2297#define TEST_PORT "2222"
Tim Rice648f8762011-01-26 12:38:57 -08002298 ]], [[
Darren Tucker691d5232005-02-15 21:45:57 +11002299 int err, sock;
2300 struct addrinfo *gai_ai, *ai, hints;
2301 char ntop[NI_MAXHOST], strport[NI_MAXSERV], *name = NULL;
2302
2303 memset(&hints, 0, sizeof(hints));
2304 hints.ai_family = PF_UNSPEC;
2305 hints.ai_socktype = SOCK_STREAM;
2306 hints.ai_flags = AI_PASSIVE;
2307
2308 err = getaddrinfo(name, TEST_PORT, &hints, &gai_ai);
2309 if (err != 0) {
2310 fprintf(stderr, "getaddrinfo failed (%s)", gai_strerror(err));
2311 exit(1);
2312 }
2313
2314 for (ai = gai_ai; ai != NULL; ai = ai->ai_next) {
2315 if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6)
2316 continue;
2317
2318 err = getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop,
2319 sizeof(ntop), strport, sizeof(strport),
2320 NI_NUMERICHOST|NI_NUMERICSERV);
2321
2322 if (ai->ai_family == AF_INET && err != 0) {
2323 perror("getnameinfo");
2324 exit(2);
2325 }
2326 }
2327 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10002328 ]])],
Darren Tucker691d5232005-02-15 21:45:57 +11002329 [
Tim Rice648f8762011-01-26 12:38:57 -08002330 AC_MSG_RESULT([yes])
2331 AC_DEFINE([AIX_GETNAMEINFO_HACK], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07002332 [Define if you have a getaddrinfo that fails
2333 for the all-zeros IPv6 address])
Darren Tucker691d5232005-02-15 21:45:57 +11002334 ],
2335 [
Tim Rice648f8762011-01-26 12:38:57 -08002336 AC_MSG_RESULT([no])
2337 AC_DEFINE([BROKEN_GETADDRINFO])
Darren Tucker314d89e2005-10-17 23:29:23 +10002338 ],
Darren Tucker8b272ab2006-06-27 11:20:28 +10002339 [
Tim Rice648f8762011-01-26 12:38:57 -08002340 AC_MSG_RESULT([cross-compiling, assuming no])
Darren Tucker691d5232005-02-15 21:45:57 +11002341 ]
2342 )
2343fi
2344
Darren Tuckere50e8c92015-02-21 15:10:33 +11002345if test "x$ac_cv_func_getaddrinfo" = "xyes"; then
2346 AC_CHECK_DECLS(AI_NUMERICSERV, , ,
2347 [#include <sys/types.h>
2348 #include <sys/socket.h>
2349 #include <netdb.h>])
2350fi
2351
Darren Tuckera56f1912004-11-02 20:30:54 +11002352if test "x$check_for_conflicting_getspnam" = "x1"; then
Tim Rice648f8762011-01-26 12:38:57 -08002353 AC_MSG_CHECKING([for conflicting getspnam in shadow.h])
2354 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <shadow.h> ]],
2355 [[ exit(0); ]])],
Darren Tuckera56f1912004-11-02 20:30:54 +11002356 [
Tim Rice648f8762011-01-26 12:38:57 -08002357 AC_MSG_RESULT([no])
Darren Tuckera56f1912004-11-02 20:30:54 +11002358 ],
2359 [
Tim Rice648f8762011-01-26 12:38:57 -08002360 AC_MSG_RESULT([yes])
2361 AC_DEFINE([GETSPNAM_CONFLICTING_DEFS], [1],
Darren Tuckera56f1912004-11-02 20:30:54 +11002362 [Conflicting defs for getspnam])
2363 ]
2364 )
2365fi
2366
Darren Tucker20e5e8b2016-08-02 12:16:34 +10002367dnl NetBSD added an strnvis and unfortunately made it incompatible with the
2368dnl existing one in OpenBSD and Linux's libbsd (the former having existed
2369dnl for over ten years). Despite this incompatibility being reported during
2370dnl development (see http://gnats.netbsd.org/44977) they still shipped it.
2371dnl Even more unfortunately FreeBSD and later MacOS picked up this incompatible
2372dnl implementation. Try to detect this mess, and assume the only safe option
2373dnl if we're cross compiling.
2374dnl
2375dnl OpenBSD, 2001: strnvis(char *dst, const char *src, size_t dlen, int flag);
2376dnl NetBSD: 2012, strnvis(char *dst, size_t dlen, const char *src, int flag);
2377if test "x$ac_cv_func_strnvis" = "xyes"; then
2378 AC_MSG_CHECKING([for working strnvis])
2379 AC_RUN_IFELSE(
2380 [AC_LANG_PROGRAM([[
2381#include <signal.h>
2382#include <stdlib.h>
2383#include <string.h>
2384#include <vis.h>
2385static void sighandler(int sig) { _exit(1); }
2386 ]], [[
2387 char dst[16];
2388
2389 signal(SIGSEGV, sighandler);
2390 if (strnvis(dst, "src", 4, 0) && strcmp(dst, "src") == 0)
2391 exit(0);
2392 exit(1)
2393 ]])],
2394 [AC_MSG_RESULT([yes])],
2395 [AC_MSG_RESULT([no])
2396 AC_DEFINE([BROKEN_STRNVIS], [1], [strnvis detected broken])],
2397 [AC_MSG_WARN([cross compiling: assuming broken])
2398 AC_DEFINE([BROKEN_STRNVIS], [1], [strnvis assumed broken])]
2399 )
2400fi
2401
Damien Miller606f8802000-09-16 15:39:56 +11002402AC_FUNC_GETPGRP
2403
Tim Riceaef73712002-05-11 13:17:42 -07002404# Search for OpenSSL
2405saved_CPPFLAGS="$CPPFLAGS"
2406saved_LDFLAGS="$LDFLAGS"
Tim Rice648f8762011-01-26 12:38:57 -08002407AC_ARG_WITH([ssl-dir],
Damien Millera22ba012000-03-02 23:09:20 +11002408 [ --with-ssl-dir=PATH Specify path to OpenSSL installation ],
2409 [
Damien Miller72ef7c12015-01-15 02:21:31 +11002410 if test "x$openssl" = "xno" ; then
2411 AC_MSG_ERROR([cannot use --with-ssl-dir when OpenSSL disabled])
2412 fi
Ben Lindstrom23e13712000-10-29 22:49:19 +00002413 if test "x$withval" != "xno" ; then
Darren Tuckerc7e38d52005-02-09 22:12:30 +11002414 case "$withval" in
2415 # Relative paths
2416 ./*|../*) withval="`pwd`/$withval"
2417 esac
Tim Riceaef73712002-05-11 13:17:42 -07002418 if test -d "$withval/lib"; then
2419 if test -n "${need_dash_r}"; then
2420 LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
2421 else
2422 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
2423 fi
Darren Tucker9f8703b2010-04-23 11:12:06 +10002424 elif test -d "$withval/lib64"; then
2425 if test -n "${need_dash_r}"; then
2426 LDFLAGS="-L${withval}/lib64 -R${withval}/lib64 ${LDFLAGS}"
2427 else
2428 LDFLAGS="-L${withval}/lib64 ${LDFLAGS}"
2429 fi
Tim Riceaef73712002-05-11 13:17:42 -07002430 else
2431 if test -n "${need_dash_r}"; then
2432 LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
2433 else
2434 LDFLAGS="-L${withval} ${LDFLAGS}"
2435 fi
2436 fi
2437 if test -d "$withval/include"; then
2438 CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
2439 else
2440 CPPFLAGS="-I${withval} ${CPPFLAGS}"
2441 fi
Damien Millera22ba012000-03-02 23:09:20 +11002442 fi
2443 ]
2444)
Damien Millerb9c56672014-05-15 14:43:37 +10002445
Tim Rice648f8762011-01-26 12:38:57 -08002446AC_ARG_WITH([openssl-header-check],
Damien Miller9975e482007-03-05 11:51:27 +11002447 [ --without-openssl-header-check Disable OpenSSL version consistency check],
Damien Millerec932372002-01-22 22:16:03 +11002448 [
Damien Miller72ef7c12015-01-15 02:21:31 +11002449 if test "x$withval" = "xno" ; then
2450 openssl_check_nonfatal=1
Damien Miller9975e482007-03-05 11:51:27 +11002451 fi
Damien Millerec932372002-01-22 22:16:03 +11002452 ]
2453)
2454
Damien Miller72ef7c12015-01-15 02:21:31 +11002455openssl_engine=no
Tim Rice648f8762011-01-26 12:38:57 -08002456AC_ARG_WITH([ssl-engine],
Darren Tuckerfabdb6c2006-02-20 20:17:35 +11002457 [ --with-ssl-engine Enable OpenSSL (hardware) ENGINE support ],
Damien Miller72ef7c12015-01-15 02:21:31 +11002458 [
Damien Miller72ef7c12015-01-15 02:21:31 +11002459 if test "x$withval" != "xno" ; then
Darren Tuckerb5fa0cd2015-12-15 15:10:32 +11002460 if test "x$openssl" = "xno" ; then
2461 AC_MSG_ERROR([cannot use --with-ssl-engine when OpenSSL disabled])
2462 fi
Damien Miller72ef7c12015-01-15 02:21:31 +11002463 openssl_engine=yes
2464 fi
2465 ]
2466)
2467
2468if test "x$openssl" = "xyes" ; then
2469 LIBS="-lcrypto $LIBS"
2470 AC_TRY_LINK_FUNC([RAND_add], [AC_DEFINE([HAVE_OPENSSL], [1],
2471 [Define if your ssl headers are included
2472 with #include <openssl/header.h>])],
2473 [
2474 dnl Check default openssl install dir
2475 if test -n "${need_dash_r}"; then
2476 LDFLAGS="-L/usr/local/ssl/lib -R/usr/local/ssl/lib ${saved_LDFLAGS}"
2477 else
2478 LDFLAGS="-L/usr/local/ssl/lib ${saved_LDFLAGS}"
2479 fi
2480 CPPFLAGS="-I/usr/local/ssl/include ${saved_CPPFLAGS}"
2481 AC_CHECK_HEADER([openssl/opensslv.h], ,
2482 [AC_MSG_ERROR([*** OpenSSL headers missing - please install first or check config.log ***])])
2483 AC_TRY_LINK_FUNC([RAND_add], [AC_DEFINE([HAVE_OPENSSL])],
2484 [
2485 AC_MSG_ERROR([*** Can't find recent OpenSSL libcrypto (see config.log for details) ***])
2486 ]
2487 )
2488 ]
2489 )
2490
2491 # Determine OpenSSL header version
2492 AC_MSG_CHECKING([OpenSSL header version])
2493 AC_RUN_IFELSE(
2494 [AC_LANG_PROGRAM([[
Darren Tucker15605962015-11-10 11:14:47 +11002495 #include <stdlib.h>
Damien Miller72ef7c12015-01-15 02:21:31 +11002496 #include <stdio.h>
2497 #include <string.h>
2498 #include <openssl/opensslv.h>
2499 #define DATA "conftest.sslincver"
2500 ]], [[
2501 FILE *fd;
2502 int rc;
2503
2504 fd = fopen(DATA,"w");
2505 if(fd == NULL)
2506 exit(1);
2507
Darren Tuckerb3413532016-04-04 11:09:21 +10002508 if ((rc = fprintf(fd, "%08lx (%s)\n",
2509 (unsigned long)OPENSSL_VERSION_NUMBER,
2510 OPENSSL_VERSION_TEXT)) < 0)
Damien Miller72ef7c12015-01-15 02:21:31 +11002511 exit(1);
2512
2513 exit(0);
2514 ]])],
2515 [
2516 ssl_header_ver=`cat conftest.sslincver`
2517 AC_MSG_RESULT([$ssl_header_ver])
2518 ],
2519 [
2520 AC_MSG_RESULT([not found])
2521 AC_MSG_ERROR([OpenSSL version header not found.])
2522 ],
2523 [
2524 AC_MSG_WARN([cross compiling: not checking])
2525 ]
2526 )
2527
2528 # Determine OpenSSL library version
2529 AC_MSG_CHECKING([OpenSSL library version])
2530 AC_RUN_IFELSE(
2531 [AC_LANG_PROGRAM([[
2532 #include <stdio.h>
2533 #include <string.h>
2534 #include <openssl/opensslv.h>
2535 #include <openssl/crypto.h>
2536 #define DATA "conftest.ssllibver"
2537 ]], [[
2538 FILE *fd;
2539 int rc;
2540
2541 fd = fopen(DATA,"w");
2542 if(fd == NULL)
2543 exit(1);
2544
Darren Tucker815bcac2016-04-04 11:07:59 +10002545 if ((rc = fprintf(fd, "%08lx (%s)\n", (unsigned long)SSLeay(),
2546 SSLeay_version(SSLEAY_VERSION))) < 0)
Damien Miller72ef7c12015-01-15 02:21:31 +11002547 exit(1);
2548
2549 exit(0);
2550 ]])],
2551 [
2552 ssl_library_ver=`cat conftest.ssllibver`
2553 # Check version is supported.
2554 case "$ssl_library_ver" in
Damien Miller2429cf72017-03-14 18:01:52 +11002555 10000*|0*)
2556 AC_MSG_ERROR([OpenSSL >= 1.0.1 required (have "$ssl_library_ver")])
Damien Miller72ef7c12015-01-15 02:21:31 +11002557 ;;
Damien Miller04dc0702017-09-28 14:54:34 -07002558 100*) ;; # 1.0.x
Damien Millerbba69c22017-09-28 16:06:21 -07002559 200*) ;; # LibreSSL
Damien Miller04dc0702017-09-28 14:54:34 -07002560 *)
2561 AC_MSG_ERROR([OpenSSL >= 1.1.0 is not yet supported (have "$ssl_library_ver")])
2562 ;;
Damien Miller72ef7c12015-01-15 02:21:31 +11002563 esac
2564 AC_MSG_RESULT([$ssl_library_ver])
2565 ],
2566 [
2567 AC_MSG_RESULT([not found])
2568 AC_MSG_ERROR([OpenSSL library not found.])
2569 ],
2570 [
2571 AC_MSG_WARN([cross compiling: not checking])
2572 ]
2573 )
2574
2575 # Sanity check OpenSSL headers
2576 AC_MSG_CHECKING([whether OpenSSL's headers match the library])
2577 AC_RUN_IFELSE(
2578 [AC_LANG_PROGRAM([[
2579 #include <string.h>
2580 #include <openssl/opensslv.h>
Darren Tuckerc1d7e542015-12-15 14:27:09 +11002581 #include <openssl/crypto.h>
Damien Miller72ef7c12015-01-15 02:21:31 +11002582 ]], [[
2583 exit(SSLeay() == OPENSSL_VERSION_NUMBER ? 0 : 1);
2584 ]])],
2585 [
2586 AC_MSG_RESULT([yes])
2587 ],
2588 [
2589 AC_MSG_RESULT([no])
2590 if test "x$openssl_check_nonfatal" = "x"; then
2591 AC_MSG_ERROR([Your OpenSSL headers do not match your
2592 library. Check config.log for details.
2593 If you are sure your installation is consistent, you can disable the check
2594 by running "./configure --without-openssl-header-check".
2595 Also see contrib/findssl.sh for help identifying header/library mismatches.
2596 ])
2597 else
2598 AC_MSG_WARN([Your OpenSSL headers do not match your
2599 library. Check config.log for details.
2600 Also see contrib/findssl.sh for help identifying header/library mismatches.])
2601 fi
2602 ],
2603 [
2604 AC_MSG_WARN([cross compiling: not checking])
2605 ]
2606 )
2607
2608 AC_MSG_CHECKING([if programs using OpenSSL functions will link])
2609 AC_LINK_IFELSE(
2610 [AC_LANG_PROGRAM([[ #include <openssl/evp.h> ]],
2611 [[ SSLeay_add_all_algorithms(); ]])],
2612 [
2613 AC_MSG_RESULT([yes])
2614 ],
2615 [
2616 AC_MSG_RESULT([no])
2617 saved_LIBS="$LIBS"
2618 LIBS="$LIBS -ldl"
2619 AC_MSG_CHECKING([if programs using OpenSSL need -ldl])
2620 AC_LINK_IFELSE(
2621 [AC_LANG_PROGRAM([[ #include <openssl/evp.h> ]],
2622 [[ SSLeay_add_all_algorithms(); ]])],
2623 [
2624 AC_MSG_RESULT([yes])
2625 ],
2626 [
2627 AC_MSG_RESULT([no])
2628 LIBS="$saved_LIBS"
2629 ]
2630 )
2631 ]
2632 )
2633
2634 AC_CHECK_FUNCS([ \
2635 BN_is_prime_ex \
2636 DSA_generate_parameters_ex \
2637 EVP_DigestInit_ex \
2638 EVP_DigestFinal_ex \
2639 EVP_MD_CTX_init \
2640 EVP_MD_CTX_cleanup \
2641 EVP_MD_CTX_copy_ex \
2642 HMAC_CTX_init \
2643 RSA_generate_key_ex \
2644 RSA_get_default_method \
2645 ])
2646
2647 if test "x$openssl_engine" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08002648 AC_MSG_CHECKING([for OpenSSL ENGINE support])
2649 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller72ef7c12015-01-15 02:21:31 +11002650 #include <openssl/engine.h>
Tim Rice648f8762011-01-26 12:38:57 -08002651 ]], [[
Damien Miller72ef7c12015-01-15 02:21:31 +11002652 ENGINE_load_builtin_engines();
2653 ENGINE_register_all_complete();
Tim Rice648f8762011-01-26 12:38:57 -08002654 ]])],
2655 [ AC_MSG_RESULT([yes])
2656 AC_DEFINE([USE_OPENSSL_ENGINE], [1],
Darren Tuckerfabdb6c2006-02-20 20:17:35 +11002657 [Enable OpenSSL engine support])
Tim Rice648f8762011-01-26 12:38:57 -08002658 ], [ AC_MSG_ERROR([OpenSSL ENGINE support not found])
2659 ])
Damien Miller72ef7c12015-01-15 02:21:31 +11002660 fi
Darren Tuckerfabdb6c2006-02-20 20:17:35 +11002661
Damien Miller72ef7c12015-01-15 02:21:31 +11002662 # Check for OpenSSL without EVP_aes_{192,256}_cbc
2663 AC_MSG_CHECKING([whether OpenSSL has crippled AES support])
2664 AC_LINK_IFELSE(
Darren Tucker37bcef52013-11-09 18:39:25 +11002665 [AC_LANG_PROGRAM([[
Damien Miller72ef7c12015-01-15 02:21:31 +11002666 #include <string.h>
2667 #include <openssl/evp.h>
2668 ]], [[
2669 exit(EVP_aes_192_cbc() == NULL || EVP_aes_256_cbc() == NULL);
2670 ]])],
2671 [
2672 AC_MSG_RESULT([no])
2673 ],
2674 [
2675 AC_MSG_RESULT([yes])
2676 AC_DEFINE([OPENSSL_LOBOTOMISED_AES], [1],
2677 [libcrypto is missing AES 192 and 256 bit functions])
2678 ]
2679 )
2680
2681 # Check for OpenSSL with EVP_aes_*ctr
2682 AC_MSG_CHECKING([whether OpenSSL has AES CTR via EVP])
2683 AC_LINK_IFELSE(
2684 [AC_LANG_PROGRAM([[
2685 #include <string.h>
2686 #include <openssl/evp.h>
2687 ]], [[
2688 exit(EVP_aes_128_ctr() == NULL ||
2689 EVP_aes_192_cbc() == NULL ||
2690 EVP_aes_256_cbc() == NULL);
2691 ]])],
2692 [
2693 AC_MSG_RESULT([yes])
2694 AC_DEFINE([OPENSSL_HAVE_EVPCTR], [1],
2695 [libcrypto has EVP AES CTR])
2696 ],
2697 [
2698 AC_MSG_RESULT([no])
2699 ]
2700 )
2701
2702 # Check for OpenSSL with EVP_aes_*gcm
2703 AC_MSG_CHECKING([whether OpenSSL has AES GCM via EVP])
2704 AC_LINK_IFELSE(
2705 [AC_LANG_PROGRAM([[
2706 #include <string.h>
2707 #include <openssl/evp.h>
2708 ]], [[
2709 exit(EVP_aes_128_gcm() == NULL ||
2710 EVP_aes_256_gcm() == NULL ||
2711 EVP_CTRL_GCM_SET_IV_FIXED == 0 ||
2712 EVP_CTRL_GCM_IV_GEN == 0 ||
2713 EVP_CTRL_GCM_SET_TAG == 0 ||
2714 EVP_CTRL_GCM_GET_TAG == 0 ||
2715 EVP_CIPHER_CTX_ctrl(NULL, 0, 0, NULL) == 0);
2716 ]])],
2717 [
2718 AC_MSG_RESULT([yes])
2719 AC_DEFINE([OPENSSL_HAVE_EVPGCM], [1],
2720 [libcrypto has EVP AES GCM])
2721 ],
2722 [
2723 AC_MSG_RESULT([no])
2724 unsupported_algorithms="$unsupported_cipers \
Damien Miller679ce882016-07-15 13:44:38 +10002725 aes128-gcm@openssh.com \
2726 aes256-gcm@openssh.com"
Damien Miller72ef7c12015-01-15 02:21:31 +11002727 ]
2728 )
2729
2730 AC_SEARCH_LIBS([EVP_CIPHER_CTX_ctrl], [crypto],
2731 [AC_DEFINE([HAVE_EVP_CIPHER_CTX_CTRL], [1],
2732 [Define if libcrypto has EVP_CIPHER_CTX_ctrl])])
2733
2734 AC_MSG_CHECKING([if EVP_DigestUpdate returns an int])
2735 AC_LINK_IFELSE(
2736 [AC_LANG_PROGRAM([[
2737 #include <string.h>
2738 #include <openssl/evp.h>
2739 ]], [[
2740 if(EVP_DigestUpdate(NULL, NULL,0))
2741 exit(0);
2742 ]])],
2743 [
2744 AC_MSG_RESULT([yes])
2745 ],
2746 [
2747 AC_MSG_RESULT([no])
2748 AC_DEFINE([OPENSSL_EVP_DIGESTUPDATE_VOID], [1],
2749 [Define if EVP_DigestUpdate returns void])
2750 ]
2751 )
2752
2753 # Some systems want crypt() from libcrypt, *not* the version in OpenSSL,
2754 # because the system crypt() is more featureful.
2755 if test "x$check_for_libcrypt_before" = "x1"; then
2756 AC_CHECK_LIB([crypt], [crypt])
2757 fi
2758
2759 # Some Linux systems (Slackware) need crypt() from libcrypt, *not* the
2760 # version in OpenSSL.
2761 if test "x$check_for_libcrypt_later" = "x1"; then
2762 AC_CHECK_LIB([crypt], [crypt], [LIBS="$LIBS -lcrypt"])
2763 fi
Damien Miller00797e82015-03-04 05:02:45 +11002764 AC_CHECK_FUNCS([crypt DES_crypt])
Damien Miller72ef7c12015-01-15 02:21:31 +11002765
2766 # Search for SHA256 support in libc and/or OpenSSL
2767 AC_CHECK_FUNCS([SHA256_Update EVP_sha256], ,
2768 [unsupported_algorithms="$unsupported_algorithms \
Damien Miller679ce882016-07-15 13:44:38 +10002769 hmac-sha2-256 \
2770 hmac-sha2-512 \
Damien Miller72ef7c12015-01-15 02:21:31 +11002771 diffie-hellman-group-exchange-sha256 \
Damien Miller679ce882016-07-15 13:44:38 +10002772 hmac-sha2-256-etm@openssh.com \
2773 hmac-sha2-512-etm@openssh.com"
Damien Miller72ef7c12015-01-15 02:21:31 +11002774 ]
2775 )
2776 # Search for RIPE-MD support in OpenSSL
2777 AC_CHECK_FUNCS([EVP_ripemd160], ,
2778 [unsupported_algorithms="$unsupported_algorithms \
Damien Miller679ce882016-07-15 13:44:38 +10002779 hmac-ripemd160 \
2780 hmac-ripemd160@openssh.com \
Damien Miller72ef7c12015-01-15 02:21:31 +11002781 hmac-ripemd160-etm@openssh.com"
2782 ]
2783 )
2784
2785 # Check complete ECC support in OpenSSL
2786 AC_MSG_CHECKING([whether OpenSSL has NID_X9_62_prime256v1])
2787 AC_LINK_IFELSE(
2788 [AC_LANG_PROGRAM([[
2789 #include <openssl/ec.h>
2790 #include <openssl/ecdh.h>
2791 #include <openssl/ecdsa.h>
2792 #include <openssl/evp.h>
2793 #include <openssl/objects.h>
2794 #include <openssl/opensslv.h>
Damien Miller72ef7c12015-01-15 02:21:31 +11002795 ]], [[
2796 EC_KEY *e = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
2797 const EVP_MD *m = EVP_sha256(); /* We need this too */
Darren Tucker37bcef52013-11-09 18:39:25 +11002798 ]])],
2799 [ AC_MSG_RESULT([yes])
Damien Miller72ef7c12015-01-15 02:21:31 +11002800 enable_nistp256=1 ],
2801 [ AC_MSG_RESULT([no]) ]
2802 )
Darren Tucker37bcef52013-11-09 18:39:25 +11002803
Damien Miller72ef7c12015-01-15 02:21:31 +11002804 AC_MSG_CHECKING([whether OpenSSL has NID_secp384r1])
2805 AC_LINK_IFELSE(
2806 [AC_LANG_PROGRAM([[
2807 #include <openssl/ec.h>
2808 #include <openssl/ecdh.h>
2809 #include <openssl/ecdsa.h>
2810 #include <openssl/evp.h>
2811 #include <openssl/objects.h>
2812 #include <openssl/opensslv.h>
Damien Miller72ef7c12015-01-15 02:21:31 +11002813 ]], [[
2814 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp384r1);
2815 const EVP_MD *m = EVP_sha384(); /* We need this too */
2816 ]])],
2817 [ AC_MSG_RESULT([yes])
2818 enable_nistp384=1 ],
2819 [ AC_MSG_RESULT([no]) ]
2820 )
Darren Tucker37bcef52013-11-09 18:39:25 +11002821
Damien Miller72ef7c12015-01-15 02:21:31 +11002822 AC_MSG_CHECKING([whether OpenSSL has NID_secp521r1])
2823 AC_LINK_IFELSE(
2824 [AC_LANG_PROGRAM([[
2825 #include <openssl/ec.h>
2826 #include <openssl/ecdh.h>
2827 #include <openssl/ecdsa.h>
2828 #include <openssl/evp.h>
2829 #include <openssl/objects.h>
2830 #include <openssl/opensslv.h>
Damien Miller72ef7c12015-01-15 02:21:31 +11002831 ]], [[
2832 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1);
2833 const EVP_MD *m = EVP_sha512(); /* We need this too */
2834 ]])],
2835 [ AC_MSG_RESULT([yes])
2836 AC_MSG_CHECKING([if OpenSSL's NID_secp521r1 is functional])
2837 AC_RUN_IFELSE(
2838 [AC_LANG_PROGRAM([[
2839 #include <openssl/ec.h>
2840 #include <openssl/ecdh.h>
2841 #include <openssl/ecdsa.h>
2842 #include <openssl/evp.h>
2843 #include <openssl/objects.h>
2844 #include <openssl/opensslv.h>
2845 ]],[[
2846 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1);
2847 const EVP_MD *m = EVP_sha512(); /* We need this too */
2848 exit(e == NULL || m == NULL);
2849 ]])],
2850 [ AC_MSG_RESULT([yes])
2851 enable_nistp521=1 ],
2852 [ AC_MSG_RESULT([no]) ],
2853 [ AC_MSG_WARN([cross-compiling: assuming yes])
2854 enable_nistp521=1 ]
2855 )],
2856 AC_MSG_RESULT([no])
2857 )
Darren Tucker37bcef52013-11-09 18:39:25 +11002858
Damien Miller72ef7c12015-01-15 02:21:31 +11002859 COMMENT_OUT_ECC="#no ecc#"
2860 TEST_SSH_ECC=no
2861
2862 if test x$enable_nistp256 = x1 || test x$enable_nistp384 = x1 || \
2863 test x$enable_nistp521 = x1; then
2864 AC_DEFINE(OPENSSL_HAS_ECC, [1], [OpenSSL has ECC])
2865 fi
2866 if test x$enable_nistp256 = x1; then
2867 AC_DEFINE([OPENSSL_HAS_NISTP256], [1],
2868 [libcrypto has NID_X9_62_prime256v1])
2869 TEST_SSH_ECC=yes
2870 COMMENT_OUT_ECC=""
2871 else
Damien Miller679ce882016-07-15 13:44:38 +10002872 unsupported_algorithms="$unsupported_algorithms \
2873 ecdsa-sha2-nistp256 \
2874 ecdh-sha2-nistp256 \
2875 ecdsa-sha2-nistp256-cert-v01@openssh.com"
Damien Miller72ef7c12015-01-15 02:21:31 +11002876 fi
2877 if test x$enable_nistp384 = x1; then
2878 AC_DEFINE([OPENSSL_HAS_NISTP384], [1], [libcrypto has NID_secp384r1])
2879 TEST_SSH_ECC=yes
2880 COMMENT_OUT_ECC=""
2881 else
Damien Miller679ce882016-07-15 13:44:38 +10002882 unsupported_algorithms="$unsupported_algorithms \
2883 ecdsa-sha2-nistp384 \
2884 ecdh-sha2-nistp384 \
2885 ecdsa-sha2-nistp384-cert-v01@openssh.com"
Damien Miller72ef7c12015-01-15 02:21:31 +11002886 fi
2887 if test x$enable_nistp521 = x1; then
2888 AC_DEFINE([OPENSSL_HAS_NISTP521], [1], [libcrypto has NID_secp521r1])
2889 TEST_SSH_ECC=yes
2890 COMMENT_OUT_ECC=""
2891 else
Damien Miller679ce882016-07-15 13:44:38 +10002892 unsupported_algorithms="$unsupported_algorithms \
2893 ecdh-sha2-nistp521 \
2894 ecdsa-sha2-nistp521 \
2895 ecdsa-sha2-nistp521-cert-v01@openssh.com"
Damien Miller72ef7c12015-01-15 02:21:31 +11002896 fi
2897
2898 AC_SUBST([TEST_SSH_ECC])
2899 AC_SUBST([COMMENT_OUT_ECC])
2900else
2901 AC_CHECK_LIB([crypt], [crypt], [LIBS="$LIBS -lcrypt"])
Damien Miller00797e82015-03-04 05:02:45 +11002902 AC_CHECK_FUNCS([crypt])
Damien Miller72ef7c12015-01-15 02:21:31 +11002903fi
Damien Miller6af914a2010-09-10 11:39:26 +10002904
Damien Miller00f9cd22014-07-15 10:41:38 +10002905AC_CHECK_FUNCS([ \
2906 arc4random \
2907 arc4random_buf \
2908 arc4random_stir \
2909 arc4random_uniform \
2910])
2911
Tim Rice99203ec2007-03-26 09:35:28 -07002912saved_LIBS="$LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08002913AC_CHECK_LIB([iaf], [ia_openinfo], [
Tim Rice99203ec2007-03-26 09:35:28 -07002914 LIBS="$LIBS -liaf"
Tim Rice648f8762011-01-26 12:38:57 -08002915 AC_CHECK_FUNCS([set_id], [SSHDLIBS="$SSHDLIBS -liaf"
2916 AC_DEFINE([HAVE_LIBIAF], [1],
Tim Ricee1d93702016-05-31 11:13:22 -07002917 [Define if system has libiaf that supports set_id])
Tim Rice0eeaf122007-09-10 16:24:17 -07002918 ])
Tim Rice99203ec2007-03-26 09:35:28 -07002919])
2920LIBS="$saved_LIBS"
Damien Miller6c21c512002-01-22 21:57:53 +11002921
2922### Configure cryptographic random number support
2923
2924# Check wheter OpenSSL seeds itself
Damien Miller72ef7c12015-01-15 02:21:31 +11002925if test "x$openssl" = "xyes" ; then
2926 AC_MSG_CHECKING([whether OpenSSL's PRNG is internally seeded])
2927 AC_RUN_IFELSE(
2928 [AC_LANG_PROGRAM([[
2929 #include <string.h>
2930 #include <openssl/rand.h>
2931 ]], [[
2932 exit(RAND_status() == 1 ? 0 : 1);
2933 ]])],
2934 [
2935 OPENSSL_SEEDS_ITSELF=yes
2936 AC_MSG_RESULT([yes])
2937 ],
2938 [
2939 AC_MSG_RESULT([no])
2940 ],
2941 [
2942 AC_MSG_WARN([cross compiling: assuming yes])
2943 # This is safe, since we will fatal() at runtime if
2944 # OpenSSL is not seeded correctly.
2945 OPENSSL_SEEDS_ITSELF=yes
2946 ]
2947 )
2948fi
Damien Miller6c21c512002-01-22 21:57:53 +11002949
Damien Millerf22019b2011-05-05 13:48:37 +10002950# PRNGD TCP socket
2951AC_ARG_WITH([prngd-port],
2952 [ --with-prngd-port=PORT read entropy from PRNGD/EGD TCP localhost:PORT],
2953 [
2954 case "$withval" in
2955 no)
2956 withval=""
2957 ;;
2958 [[0-9]]*)
2959 ;;
2960 *)
2961 AC_MSG_ERROR([You must specify a numeric port number for --with-prngd-port])
2962 ;;
2963 esac
2964 if test ! -z "$withval" ; then
2965 PRNGD_PORT="$withval"
2966 AC_DEFINE_UNQUOTED([PRNGD_PORT], [$PRNGD_PORT],
2967 [Port number of PRNGD/EGD random number socket])
2968 fi
2969 ]
2970)
2971
2972# PRNGD Unix domain socket
2973AC_ARG_WITH([prngd-socket],
2974 [ --with-prngd-socket=FILE read entropy from PRNGD/EGD socket FILE (default=/var/run/egd-pool)],
2975 [
2976 case "$withval" in
2977 yes)
2978 withval="/var/run/egd-pool"
2979 ;;
2980 no)
2981 withval=""
2982 ;;
2983 /*)
2984 ;;
2985 *)
2986 AC_MSG_ERROR([You must specify an absolute path to the entropy socket])
2987 ;;
2988 esac
2989
2990 if test ! -z "$withval" ; then
2991 if test ! -z "$PRNGD_PORT" ; then
2992 AC_MSG_ERROR([You may not specify both a PRNGD/EGD port and socket])
2993 fi
2994 if test ! -r "$withval" ; then
2995 AC_MSG_WARN([Entropy socket is not readable])
2996 fi
2997 PRNGD_SOCKET="$withval"
2998 AC_DEFINE_UNQUOTED([PRNGD_SOCKET], ["$PRNGD_SOCKET"],
2999 [Location of PRNGD/EGD random number socket])
3000 fi
3001 ],
3002 [
3003 # Check for existing socket only if we don't have a random device already
3004 if test "x$OPENSSL_SEEDS_ITSELF" != "xyes" ; then
3005 AC_MSG_CHECKING([for PRNGD/EGD socket])
3006 # Insert other locations here
3007 for sock in /var/run/egd-pool /dev/egd-pool /etc/entropy; do
3008 if test -r $sock && $TEST_MINUS_S_SH -c "test -S $sock -o -p $sock" ; then
3009 PRNGD_SOCKET="$sock"
3010 AC_DEFINE_UNQUOTED([PRNGD_SOCKET], ["$PRNGD_SOCKET"])
3011 break;
3012 fi
3013 done
3014 if test ! -z "$PRNGD_SOCKET" ; then
3015 AC_MSG_RESULT([$PRNGD_SOCKET])
3016 else
3017 AC_MSG_RESULT([not found])
3018 fi
3019 fi
3020 ]
3021)
3022
3023# Which randomness source do we use?
3024if test ! -z "$PRNGD_PORT" ; then
3025 RAND_MSG="PRNGd port $PRNGD_PORT"
3026elif test ! -z "$PRNGD_SOCKET" ; then
3027 RAND_MSG="PRNGd socket $PRNGD_SOCKET"
3028elif test ! -z "$OPENSSL_SEEDS_ITSELF" ; then
3029 AC_DEFINE([OPENSSL_PRNG_ONLY], [1],
Damien Miller72ef7c12015-01-15 02:21:31 +11003030 [Define if you want the OpenSSL internally seeded PRNG only])
Damien Millerf22019b2011-05-05 13:48:37 +10003031 RAND_MSG="OpenSSL internal ONLY"
Damien Miller72ef7c12015-01-15 02:21:31 +11003032elif test "x$openssl" = "xno" ; then
3033 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 +10003034else
3035 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])
3036fi
3037
Darren Tucker3e6bde42006-08-20 20:03:50 +10003038# Check for PAM libs
3039PAM_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08003040AC_ARG_WITH([pam],
Darren Tucker3e6bde42006-08-20 20:03:50 +10003041 [ --with-pam Enable PAM support ],
3042 [
3043 if test "x$withval" != "xno" ; then
3044 if test "x$ac_cv_header_security_pam_appl_h" != "xyes" && \
3045 test "x$ac_cv_header_pam_pam_appl_h" != "xyes" ; then
3046 AC_MSG_ERROR([PAM headers not found])
3047 fi
3048
3049 saved_LIBS="$LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08003050 AC_CHECK_LIB([dl], [dlopen], , )
3051 AC_CHECK_LIB([pam], [pam_set_item], , [AC_MSG_ERROR([*** libpam missing])])
3052 AC_CHECK_FUNCS([pam_getenvlist])
3053 AC_CHECK_FUNCS([pam_putenv])
Darren Tucker3e6bde42006-08-20 20:03:50 +10003054 LIBS="$saved_LIBS"
3055
3056 PAM_MSG="yes"
3057
Darren Tucker20e9f972007-03-25 18:26:01 +10003058 SSHDLIBS="$SSHDLIBS -lpam"
Tim Rice648f8762011-01-26 12:38:57 -08003059 AC_DEFINE([USE_PAM], [1],
Darren Tucker3e6bde42006-08-20 20:03:50 +10003060 [Define if you want to enable PAM support])
Darren Tucker639bbe82006-08-20 20:17:53 +10003061
Darren Tucker3e6bde42006-08-20 20:03:50 +10003062 if test $ac_cv_lib_dl_dlopen = yes; then
Darren Tucker639bbe82006-08-20 20:17:53 +10003063 case "$LIBS" in
3064 *-ldl*)
3065 # libdl already in LIBS
3066 ;;
3067 *)
Darren Tucker20e9f972007-03-25 18:26:01 +10003068 SSHDLIBS="$SSHDLIBS -ldl"
Darren Tucker639bbe82006-08-20 20:17:53 +10003069 ;;
3070 esac
Darren Tucker3e6bde42006-08-20 20:03:50 +10003071 fi
Darren Tucker3e6bde42006-08-20 20:03:50 +10003072 fi
3073 ]
3074)
3075
Damien Miller8bd81e12016-08-16 13:30:56 +10003076AC_ARG_WITH([pam-service],
3077 [ --with-pam-service=name Specify PAM service name ],
3078 [
3079 if test "x$withval" != "xno" && \
3080 test "x$withval" != "xyes" ; then
3081 AC_DEFINE_UNQUOTED([SSHD_PAM_SERVICE],
3082 ["$withval"], [sshd PAM service name])
3083 fi
3084 ]
3085)
3086
Darren Tucker3e6bde42006-08-20 20:03:50 +10003087# Check for older PAM
3088if test "x$PAM_MSG" = "xyes" ; then
3089 # Check PAM strerror arguments (old PAM)
3090 AC_MSG_CHECKING([whether pam_strerror takes only one argument])
Tim Rice648f8762011-01-26 12:38:57 -08003091 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker3e6bde42006-08-20 20:03:50 +10003092#include <stdlib.h>
3093#if defined(HAVE_SECURITY_PAM_APPL_H)
3094#include <security/pam_appl.h>
3095#elif defined (HAVE_PAM_PAM_APPL_H)
3096#include <pam/pam_appl.h>
3097#endif
Tim Rice648f8762011-01-26 12:38:57 -08003098 ]], [[
3099(void)pam_strerror((pam_handle_t *)NULL, -1);
3100 ]])], [AC_MSG_RESULT([no])], [
3101 AC_DEFINE([HAVE_OLD_PAM], [1],
Darren Tucker3e6bde42006-08-20 20:03:50 +10003102 [Define if you have an old version of PAM
3103 which takes only one argument to pam_strerror])
Tim Rice648f8762011-01-26 12:38:57 -08003104 AC_MSG_RESULT([yes])
Darren Tucker3e6bde42006-08-20 20:03:50 +10003105 PAM_MSG="yes (old library)"
Damien Miller72ef7c12015-01-15 02:21:31 +11003106
Tim Rice648f8762011-01-26 12:38:57 -08003107 ])
Darren Tucker3e6bde42006-08-20 20:03:50 +10003108fi
Damien Miller6c21c512002-01-22 21:57:53 +11003109
Damien Miller6482d902014-05-27 14:34:42 +10003110case "$host" in
3111*-*-cygwin*)
3112 SSH_PRIVSEP_USER=CYGWIN_SSH_PRIVSEP_USER
3113 ;;
3114*)
3115 SSH_PRIVSEP_USER=sshd
3116 ;;
3117esac
Tim Rice648f8762011-01-26 12:38:57 -08003118AC_ARG_WITH([privsep-user],
Kevin Stevesc81e1292002-05-13 03:51:40 +00003119 [ --with-privsep-user=user Specify non-privileged user for privilege separation],
Kevin Steves7ff91122002-04-07 19:22:54 +00003120 [
Tim Rice35cc69d2005-03-17 16:44:25 -08003121 if test -n "$withval" && test "x$withval" != "xno" && \
3122 test "x${withval}" != "xyes"; then
Damien Millerd3f6ad22002-06-25 10:24:47 +10003123 SSH_PRIVSEP_USER=$withval
Kevin Steves7ff91122002-04-07 19:22:54 +00003124 fi
Tim Riceeae17cc2005-03-17 16:52:20 -08003125 ]
Kevin Steves7ff91122002-04-07 19:22:54 +00003126)
Damien Miller6482d902014-05-27 14:34:42 +10003127if test "x$SSH_PRIVSEP_USER" = "xCYGWIN_SSH_PRIVSEP_USER" ; then
3128 AC_DEFINE_UNQUOTED([SSH_PRIVSEP_USER], [CYGWIN_SSH_PRIVSEP_USER],
3129 [Cygwin function to fetch non-privileged user for privilege separation])
3130else
3131 AC_DEFINE_UNQUOTED([SSH_PRIVSEP_USER], ["$SSH_PRIVSEP_USER"],
3132 [non-privileged user for privilege separation])
3133fi
Tim Rice648f8762011-01-26 12:38:57 -08003134AC_SUBST([SSH_PRIVSEP_USER])
Kevin Steves7ff91122002-04-07 19:22:54 +00003135
Damien Miller91f40d82013-02-22 11:37:00 +11003136if test "x$have_linux_no_new_privs" = "x1" ; then
3137AC_CHECK_DECL([SECCOMP_MODE_FILTER], [have_seccomp_filter=1], , [
3138 #include <sys/types.h>
3139 #include <linux/seccomp.h>
3140])
3141fi
3142if test "x$have_seccomp_filter" = "x1" ; then
3143AC_MSG_CHECKING([kernel for seccomp_filter support])
3144AC_LINK_IFELSE([AC_LANG_PROGRAM([[
3145 #include <errno.h>
3146 #include <elf.h>
3147 #include <linux/audit.h>
3148 #include <linux/seccomp.h>
3149 #include <stdlib.h>
3150 #include <sys/prctl.h>
3151 ]],
3152 [[ int i = $seccomp_audit_arch;
3153 errno = 0;
3154 prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, NULL, 0, 0);
3155 exit(errno == EFAULT ? 0 : 1); ]])],
3156 [ AC_MSG_RESULT([yes]) ], [
3157 AC_MSG_RESULT([no])
3158 # Disable seccomp filter as a target
3159 have_seccomp_filter=0
3160 ]
3161)
3162fi
3163
Damien Miller69ff1df2011-06-23 08:30:03 +10003164# Decide which sandbox style to use
3165sandbox_arg=""
3166AC_ARG_WITH([sandbox],
deraadt@openbsd.org2539dce2015-10-09 01:37:08 +00003167 [ --with-sandbox=style Specify privilege separation sandbox (no, capsicum, darwin, rlimit, seccomp_filter, systrace, pledge)],
Damien Miller69ff1df2011-06-23 08:30:03 +10003168 [
3169 if test "x$withval" = "xyes" ; then
3170 sandbox_arg=""
3171 else
3172 sandbox_arg="$withval"
3173 fi
3174 ]
3175)
Darren Tucker60395f92012-07-03 14:31:18 +10003176
3177# Some platforms (seems to be the ones that have a kernel poll(2)-type
3178# function with which they implement select(2)) use an extra file descriptor
3179# when calling select(2), which means we can't use the rlimit sandbox.
3180AC_MSG_CHECKING([if select works with descriptor rlimit])
3181AC_RUN_IFELSE(
3182 [AC_LANG_PROGRAM([[
3183#include <sys/types.h>
3184#ifdef HAVE_SYS_TIME_H
3185# include <sys/time.h>
3186#endif
3187#include <sys/resource.h>
3188#ifdef HAVE_SYS_SELECT_H
3189# include <sys/select.h>
3190#endif
3191#include <errno.h>
3192#include <fcntl.h>
3193#include <stdlib.h>
3194 ]],[[
3195 struct rlimit rl_zero;
3196 int fd, r;
3197 fd_set fds;
Damien Millere4f43472013-03-08 12:14:22 +11003198 struct timeval tv;
Darren Tucker60395f92012-07-03 14:31:18 +10003199
3200 fd = open("/dev/null", O_RDONLY);
3201 FD_ZERO(&fds);
3202 FD_SET(fd, &fds);
3203 rl_zero.rlim_cur = rl_zero.rlim_max = 0;
3204 setrlimit(RLIMIT_FSIZE, &rl_zero);
3205 setrlimit(RLIMIT_NOFILE, &rl_zero);
Damien Millere4f43472013-03-08 12:14:22 +11003206 tv.tv_sec = 1;
3207 tv.tv_usec = 0;
3208 r = select(fd+1, &fds, NULL, NULL, &tv);
Darren Tucker60395f92012-07-03 14:31:18 +10003209 exit (r == -1 ? 1 : 0);
3210 ]])],
3211 [AC_MSG_RESULT([yes])
3212 select_works_with_rlimit=yes],
3213 [AC_MSG_RESULT([no])
3214 select_works_with_rlimit=no],
Mike Frysingerdcc714c2017-05-24 23:21:19 -04003215 [AC_MSG_WARN([cross compiling: assuming yes])
3216 select_works_with_rlimit=yes]
Darren Tucker60395f92012-07-03 14:31:18 +10003217)
3218
Darren Tuckerff008de2013-03-06 17:48:48 +11003219AC_MSG_CHECKING([if setrlimit(RLIMIT_NOFILE,{0,0}) works])
3220AC_RUN_IFELSE(
3221 [AC_LANG_PROGRAM([[
3222#include <sys/types.h>
3223#ifdef HAVE_SYS_TIME_H
3224# include <sys/time.h>
3225#endif
3226#include <sys/resource.h>
3227#include <errno.h>
3228#include <stdlib.h>
3229 ]],[[
3230 struct rlimit rl_zero;
3231 int fd, r;
3232 fd_set fds;
3233
3234 rl_zero.rlim_cur = rl_zero.rlim_max = 0;
3235 r = setrlimit(RLIMIT_NOFILE, &rl_zero);
3236 exit (r == -1 ? 1 : 0);
3237 ]])],
3238 [AC_MSG_RESULT([yes])
3239 rlimit_nofile_zero_works=yes],
3240 [AC_MSG_RESULT([no])
3241 rlimit_nofile_zero_works=no],
Mike Frysingerdcc714c2017-05-24 23:21:19 -04003242 [AC_MSG_WARN([cross compiling: assuming yes])
3243 rlimit_nofile_zero_works=yes]
Darren Tuckerff008de2013-03-06 17:48:48 +11003244)
3245
Darren Tuckerd545a4b2012-07-03 22:48:31 +10003246AC_MSG_CHECKING([if setrlimit RLIMIT_FSIZE works])
3247AC_RUN_IFELSE(
3248 [AC_LANG_PROGRAM([[
3249#include <sys/types.h>
3250#include <sys/resource.h>
3251#include <stdlib.h>
3252 ]],[[
3253 struct rlimit rl_zero;
3254
3255 rl_zero.rlim_cur = rl_zero.rlim_max = 0;
3256 exit(setrlimit(RLIMIT_FSIZE, &rl_zero) != 0);
3257 ]])],
3258 [AC_MSG_RESULT([yes])],
3259 [AC_MSG_RESULT([no])
3260 AC_DEFINE(SANDBOX_SKIP_RLIMIT_FSIZE, 1,
3261 [setrlimit RLIMIT_FSIZE works])],
3262 [AC_MSG_WARN([cross compiling: assuming yes])]
3263)
3264
deraadt@openbsd.org2539dce2015-10-09 01:37:08 +00003265if test "x$sandbox_arg" = "xpledge" || \
3266 ( test -z "$sandbox_arg" && test "x$ac_cv_func_pledge" = "xyes" ) ; then
3267 test "x$ac_cv_func_pledge" != "xyes" && \
3268 AC_MSG_ERROR([pledge sandbox requires pledge(2) support])
3269 SANDBOX_STYLE="pledge"
Damien Millerfafe1d82015-10-14 09:22:15 -07003270 AC_DEFINE([SANDBOX_PLEDGE], [1], [Sandbox using pledge(2)])
Damien Miller9846a2f2015-10-08 04:30:48 +11003271elif test "x$sandbox_arg" = "xsystrace" || \
Damien Miller69ff1df2011-06-23 08:30:03 +10003272 ( test -z "$sandbox_arg" && test "x$have_systr_policy_kill" = "x1" ) ; then
Damien Miller1a91c0f2011-08-17 11:59:25 +10003273 test "x$have_systr_policy_kill" != "x1" && \
3274 AC_MSG_ERROR([systrace sandbox requires systrace headers and SYSTR_POLICY_KILL support])
Damien Miller69ff1df2011-06-23 08:30:03 +10003275 SANDBOX_STYLE="systrace"
3276 AC_DEFINE([SANDBOX_SYSTRACE], [1], [Sandbox using systrace(4)])
Damien Millercd5e52e2011-06-27 07:18:18 +10003277elif test "x$sandbox_arg" = "xdarwin" || \
3278 ( test -z "$sandbox_arg" && test "x$ac_cv_func_sandbox_init" = "xyes" && \
3279 test "x$ac_cv_header_sandbox_h" = "xyes") ; then
Damien Miller1a91c0f2011-08-17 11:59:25 +10003280 test "x$ac_cv_func_sandbox_init" != "xyes" -o \
3281 "x$ac_cv_header_sandbox_h" != "xyes" && \
3282 AC_MSG_ERROR([Darwin seatbelt sandbox requires sandbox.h and sandbox_init function])
Damien Millercd5e52e2011-06-27 07:18:18 +10003283 SANDBOX_STYLE="darwin"
3284 AC_DEFINE([SANDBOX_DARWIN], [1], [Sandbox using Darwin sandbox_init(3)])
Damien Millere0956e32012-04-04 11:27:54 +10003285elif test "x$sandbox_arg" = "xseccomp_filter" || \
3286 ( test -z "$sandbox_arg" && \
Darren Tuckerd0494fd2012-05-19 14:25:39 +10003287 test "x$have_seccomp_filter" = "x1" && \
Damien Miller91f40d82013-02-22 11:37:00 +11003288 test "x$ac_cv_header_elf_h" = "xyes" && \
Damien Millere0956e32012-04-04 11:27:54 +10003289 test "x$ac_cv_header_linux_audit_h" = "xyes" && \
Damien Miller91f40d82013-02-22 11:37:00 +11003290 test "x$ac_cv_header_linux_filter_h" = "xyes" && \
3291 test "x$seccomp_audit_arch" != "x" && \
Damien Millere0956e32012-04-04 11:27:54 +10003292 test "x$have_linux_no_new_privs" = "x1" && \
3293 test "x$ac_cv_func_prctl" = "xyes" ) ; then
Damien Miller91f40d82013-02-22 11:37:00 +11003294 test "x$seccomp_audit_arch" = "x" && \
Damien Millere0956e32012-04-04 11:27:54 +10003295 AC_MSG_ERROR([seccomp_filter sandbox not supported on $host])
3296 test "x$have_linux_no_new_privs" != "x1" && \
3297 AC_MSG_ERROR([seccomp_filter sandbox requires PR_SET_NO_NEW_PRIVS])
3298 test "x$have_seccomp_filter" != "x1" && \
3299 AC_MSG_ERROR([seccomp_filter sandbox requires seccomp headers])
3300 test "x$ac_cv_func_prctl" != "xyes" && \
3301 AC_MSG_ERROR([seccomp_filter sandbox requires prctl function])
3302 SANDBOX_STYLE="seccomp_filter"
3303 AC_DEFINE([SANDBOX_SECCOMP_FILTER], [1], [Sandbox using seccomp filter])
Damien Millerf62ecef2014-01-25 12:34:38 +11003304elif test "x$sandbox_arg" = "xcapsicum" || \
3305 ( test -z "$sandbox_arg" && \
Darren Tuckerdd9d9b32017-08-28 16:48:27 +10003306 test "x$ac_cv_header_sys_capsicum_h" = "xyes" && \
Damien Miller603b8f42014-01-25 13:16:59 +11003307 test "x$ac_cv_func_cap_rights_limit" = "xyes") ; then
Darren Tuckerdd9d9b32017-08-28 16:48:27 +10003308 test "x$ac_cv_header_sys_capsicum_h" != "xyes" && \
3309 AC_MSG_ERROR([capsicum sandbox requires sys/capsicum.h header])
Damien Miller603b8f42014-01-25 13:16:59 +11003310 test "x$ac_cv_func_cap_rights_limit" != "xyes" && \
Damien Millerc96d8532014-01-25 13:12:28 +11003311 AC_MSG_ERROR([capsicum sandbox requires cap_rights_limit function])
Damien Millerf62ecef2014-01-25 12:34:38 +11003312 SANDBOX_STYLE="capsicum"
3313 AC_DEFINE([SANDBOX_CAPSICUM], [1], [Sandbox using capsicum])
Damien Miller69ff1df2011-06-23 08:30:03 +10003314elif test "x$sandbox_arg" = "xrlimit" || \
Darren Tucker60395f92012-07-03 14:31:18 +10003315 ( test -z "$sandbox_arg" && test "x$ac_cv_func_setrlimit" = "xyes" && \
Darren Tuckerff008de2013-03-06 17:48:48 +11003316 test "x$select_works_with_rlimit" = "xyes" && \
3317 test "x$rlimit_nofile_zero_works" = "xyes" ) ; then
Damien Miller1a91c0f2011-08-17 11:59:25 +10003318 test "x$ac_cv_func_setrlimit" != "xyes" && \
3319 AC_MSG_ERROR([rlimit sandbox requires setrlimit function])
Darren Tucker60395f92012-07-03 14:31:18 +10003320 test "x$select_works_with_rlimit" != "xyes" && \
3321 AC_MSG_ERROR([rlimit sandbox requires select to work with rlimit])
Damien Miller69ff1df2011-06-23 08:30:03 +10003322 SANDBOX_STYLE="rlimit"
3323 AC_DEFINE([SANDBOX_RLIMIT], [1], [Sandbox using setrlimit(2)])
Damien Miller4626cba2016-01-08 14:24:56 +11003324elif test "x$sandbox_arg" = "xsolaris" || \
3325 ( test -z "$sandbox_arg" && test "x$SOLARIS_PRIVS" = "xyes" ) ; then
3326 SANDBOX_STYLE="solaris"
3327 AC_DEFINE([SANDBOX_SOLARIS], [1], [Sandbox using Solaris/Illumos privileges])
Damien Miller69ff1df2011-06-23 08:30:03 +10003328elif test -z "$sandbox_arg" || test "x$sandbox_arg" = "xno" || \
3329 test "x$sandbox_arg" = "xnone" || test "x$sandbox_arg" = "xnull" ; then
3330 SANDBOX_STYLE="none"
3331 AC_DEFINE([SANDBOX_NULL], [1], [no privsep sandboxing])
3332else
Tim Ricea6e60612011-08-17 21:48:22 -07003333 AC_MSG_ERROR([unsupported --with-sandbox])
Damien Miller69ff1df2011-06-23 08:30:03 +10003334fi
3335
Ben Lindstromb5628642000-10-18 00:02:25 +00003336# Cheap hack to ensure NEWS-OS libraries are arranged right.
3337if test ! -z "$SONY" ; then
3338 LIBS="$LIBS -liberty";
3339fi
3340
Damien Miller57f39152005-11-24 19:58:19 +11003341# Check for long long datatypes
3342AC_CHECK_TYPES([long long, unsigned long long, long double])
3343
3344# Check datatype sizes
Tim Rice648f8762011-01-26 12:38:57 -08003345AC_CHECK_SIZEOF([short int], [2])
3346AC_CHECK_SIZEOF([int], [4])
3347AC_CHECK_SIZEOF([long int], [4])
3348AC_CHECK_SIZEOF([long long int], [8])
Damien Millerc6398ef1999-11-20 12:18:40 +11003349
Damien Millerfa2bb692002-04-23 23:22:25 +10003350# Sanity check long long for some platforms (AIX)
3351if test "x$ac_cv_sizeof_long_long_int" = "x4" ; then
3352 ac_cv_sizeof_long_long_int=0
3353fi
3354
Darren Tucker537f1ed2005-10-25 18:38:33 +10003355# compute LLONG_MIN and LLONG_MAX if we don't know them.
3356if test -z "$have_llong_max"; then
3357 AC_MSG_CHECKING([for max value of long long])
3358 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08003359 [AC_LANG_PROGRAM([[
Darren Tucker537f1ed2005-10-25 18:38:33 +10003360#include <stdio.h>
3361/* Why is this so damn hard? */
3362#ifdef __GNUC__
3363# undef __GNUC__
3364#endif
3365#define __USE_ISOC99
3366#include <limits.h>
3367#define DATA "conftest.llminmax"
Darren Tuckerd1450db2006-03-13 19:06:51 +11003368#define my_abs(a) ((a) < 0 ? ((a) * -1) : (a))
3369
3370/*
3371 * printf in libc on some platforms (eg old Tru64) does not understand %lld so
3372 * we do this the hard way.
3373 */
3374static int
3375fprint_ll(FILE *f, long long n)
3376{
3377 unsigned int i;
3378 int l[sizeof(long long) * 8];
3379
3380 if (n < 0)
3381 if (fprintf(f, "-") < 0)
3382 return -1;
3383 for (i = 0; n != 0; i++) {
3384 l[i] = my_abs(n % 10);
3385 n /= 10;
3386 }
3387 do {
3388 if (fprintf(f, "%d", l[--i]) < 0)
3389 return -1;
3390 } while (i != 0);
3391 if (fprintf(f, " ") < 0)
3392 return -1;
3393 return 0;
3394}
Tim Rice648f8762011-01-26 12:38:57 -08003395 ]], [[
Darren Tucker537f1ed2005-10-25 18:38:33 +10003396 FILE *f;
3397 long long i, llmin, llmax = 0;
3398
3399 if((f = fopen(DATA,"w")) == NULL)
3400 exit(1);
3401
3402#if defined(LLONG_MIN) && defined(LLONG_MAX)
3403 fprintf(stderr, "Using system header for LLONG_MIN and LLONG_MAX\n");
3404 llmin = LLONG_MIN;
3405 llmax = LLONG_MAX;
3406#else
3407 fprintf(stderr, "Calculating LLONG_MIN and LLONG_MAX\n");
3408 /* This will work on one's complement and two's complement */
3409 for (i = 1; i > llmax; i <<= 1, i++)
3410 llmax = i;
3411 llmin = llmax + 1LL; /* wrap */
3412#endif
3413
3414 /* Sanity check */
3415 if (llmin + 1 < llmin || llmin - 1 < llmin || llmax + 1 > llmax
Darren Tuckerd1450db2006-03-13 19:06:51 +11003416 || llmax - 1 > llmax || llmin == llmax || llmin == 0
3417 || llmax == 0 || llmax < LONG_MAX || llmin > LONG_MIN) {
Darren Tucker537f1ed2005-10-25 18:38:33 +10003418 fprintf(f, "unknown unknown\n");
3419 exit(2);
3420 }
3421
Darren Tuckerd1450db2006-03-13 19:06:51 +11003422 if (fprint_ll(f, llmin) < 0)
Darren Tucker537f1ed2005-10-25 18:38:33 +10003423 exit(3);
Darren Tuckerd1450db2006-03-13 19:06:51 +11003424 if (fprint_ll(f, llmax) < 0)
3425 exit(4);
3426 if (fclose(f) < 0)
3427 exit(5);
Darren Tucker537f1ed2005-10-25 18:38:33 +10003428 exit(0);
Darren Tucker537f1ed2005-10-25 18:38:33 +10003429 ]])],
3430 [
3431 llong_min=`$AWK '{print $1}' conftest.llminmax`
3432 llong_max=`$AWK '{print $2}' conftest.llminmax`
3433
Tim Rice648f8762011-01-26 12:38:57 -08003434 AC_MSG_RESULT([$llong_max])
3435 AC_DEFINE_UNQUOTED([LLONG_MAX], [${llong_max}LL],
Darren Tucker537f1ed2005-10-25 18:38:33 +10003436 [max value of long long calculated by configure])
3437 AC_MSG_CHECKING([for min value of long long])
Tim Rice648f8762011-01-26 12:38:57 -08003438 AC_MSG_RESULT([$llong_min])
3439 AC_DEFINE_UNQUOTED([LLONG_MIN], [${llong_min}LL],
Darren Tucker537f1ed2005-10-25 18:38:33 +10003440 [min value of long long calculated by configure])
3441 ],
3442 [
Tim Rice648f8762011-01-26 12:38:57 -08003443 AC_MSG_RESULT([not found])
Darren Tucker537f1ed2005-10-25 18:38:33 +10003444 ],
3445 [
3446 AC_MSG_WARN([cross compiling: not checking])
3447 ]
3448 )
3449fi
3450
3451
Damien Millera22ba012000-03-02 23:09:20 +11003452# More checks for data types
Damien Millercaf6dd62000-08-29 11:33:50 +11003453AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [
Tim Rice648f8762011-01-26 12:38:57 -08003454 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3455 [[ u_int a; a = 1;]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003456 [ ac_cv_have_u_int="yes" ], [ ac_cv_have_u_int="no"
Tim Rice648f8762011-01-26 12:38:57 -08003457 ])
Damien Millercaf6dd62000-08-29 11:33:50 +11003458])
3459if test "x$ac_cv_have_u_int" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003460 AC_DEFINE([HAVE_U_INT], [1], [define if you have u_int data type])
Damien Millercaf6dd62000-08-29 11:33:50 +11003461 have_u_int=1
3462fi
3463
Damien Miller61e50f12000-05-08 20:49:37 +10003464AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003465 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3466 [[ int8_t a; int16_t b; int32_t c; a = b = c = 1;]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003467 [ ac_cv_have_intxx_t="yes" ], [ ac_cv_have_intxx_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003468 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003469])
3470if test "x$ac_cv_have_intxx_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003471 AC_DEFINE([HAVE_INTXX_T], [1], [define if you have intxx_t data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003472 have_intxx_t=1
3473fi
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003474
3475if (test -z "$have_intxx_t" && \
Damien Millera8e06ce2003-11-21 23:48:55 +11003476 test "x$ac_cv_header_stdint_h" = "xyes")
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003477then
3478 AC_MSG_CHECKING([for intXX_t types in stdint.h])
Tim Rice648f8762011-01-26 12:38:57 -08003479 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdint.h> ]],
3480 [[ int8_t a; int16_t b; int32_t c; a = b = c = 1;]])],
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003481 [
Tim Rice648f8762011-01-26 12:38:57 -08003482 AC_DEFINE([HAVE_INTXX_T])
3483 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003484 ], [ AC_MSG_RESULT([no])
Tim Rice648f8762011-01-26 12:38:57 -08003485 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003486fi
3487
Damien Miller578783e2000-09-23 14:12:24 +11003488AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003489 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Tim Rice907881e2002-07-18 11:44:50 -07003490#include <sys/types.h>
3491#ifdef HAVE_STDINT_H
3492# include <stdint.h>
3493#endif
3494#include <sys/socket.h>
3495#ifdef HAVE_SYS_BITYPES_H
3496# include <sys/bitypes.h>
3497#endif
Tim Rice648f8762011-01-26 12:38:57 -08003498 ]], [[
3499int64_t a; a = 1;
3500 ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003501 [ ac_cv_have_int64_t="yes" ], [ ac_cv_have_int64_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003502 ])
Damien Miller578783e2000-09-23 14:12:24 +11003503])
3504if test "x$ac_cv_have_int64_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003505 AC_DEFINE([HAVE_INT64_T], [1], [define if you have int64_t data type])
Tim Rice4cec93f2002-02-26 08:40:48 -08003506fi
3507
Damien Miller61e50f12000-05-08 20:49:37 +10003508AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003509 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3510 [[ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003511 [ ac_cv_have_u_intxx_t="yes" ], [ ac_cv_have_u_intxx_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003512 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003513])
3514if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003515 AC_DEFINE([HAVE_U_INTXX_T], [1], [define if you have u_intxx_t data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003516 have_u_intxx_t=1
3517fi
Damien Millerc6398ef1999-11-20 12:18:40 +11003518
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003519if test -z "$have_u_intxx_t" ; then
3520 AC_MSG_CHECKING([for u_intXX_t types in sys/socket.h])
Tim Rice648f8762011-01-26 12:38:57 -08003521 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/socket.h> ]],
3522 [[ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;]])],
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003523 [
Tim Rice648f8762011-01-26 12:38:57 -08003524 AC_DEFINE([HAVE_U_INTXX_T])
3525 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003526 ], [ AC_MSG_RESULT([no])
Tim Rice648f8762011-01-26 12:38:57 -08003527 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003528fi
3529
Damien Miller578783e2000-09-23 14:12:24 +11003530AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003531 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3532 [[ u_int64_t a; a = 1;]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003533 [ ac_cv_have_u_int64_t="yes" ], [ ac_cv_have_u_int64_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003534 ])
Damien Miller578783e2000-09-23 14:12:24 +11003535])
3536if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003537 AC_DEFINE([HAVE_U_INT64_T], [1], [define if you have u_int64_t data type])
Damien Miller578783e2000-09-23 14:12:24 +11003538 have_u_int64_t=1
3539fi
3540
Damien Millerc2868192014-01-30 10:21:19 +11003541if (test -z "$have_u_int64_t" && \
3542 test "x$ac_cv_header_sys_bitypes_h" = "xyes")
3543then
Tim Rice4cec93f2002-02-26 08:40:48 -08003544 AC_MSG_CHECKING([for u_int64_t type in sys/bitypes.h])
Tim Rice648f8762011-01-26 12:38:57 -08003545 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/bitypes.h> ]],
3546 [[ u_int64_t a; a = 1]])],
Tim Rice4cec93f2002-02-26 08:40:48 -08003547 [
Tim Rice648f8762011-01-26 12:38:57 -08003548 AC_DEFINE([HAVE_U_INT64_T])
3549 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003550 ], [ AC_MSG_RESULT([no])
Tim Rice648f8762011-01-26 12:38:57 -08003551 ])
Tim Rice4cec93f2002-02-26 08:40:48 -08003552fi
3553
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003554if test -z "$have_u_intxx_t" ; then
3555 AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003556 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003557#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08003558 ]], [[
3559 uint8_t a;
3560 uint16_t b;
3561 uint32_t c;
3562 a = b = c = 1;
3563 ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003564 [ ac_cv_have_uintxx_t="yes" ], [ ac_cv_have_uintxx_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003565 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003566 ])
3567 if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003568 AC_DEFINE([HAVE_UINTXX_T], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003569 [define if you have uintxx_t data type])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003570 fi
3571fi
3572
Damien Millerc2868192014-01-30 10:21:19 +11003573if (test -z "$have_uintxx_t" && \
3574 test "x$ac_cv_header_stdint_h" = "xyes")
3575then
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003576 AC_MSG_CHECKING([for uintXX_t types in stdint.h])
Tim Rice648f8762011-01-26 12:38:57 -08003577 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdint.h> ]],
3578 [[ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;]])],
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003579 [
Tim Rice648f8762011-01-26 12:38:57 -08003580 AC_DEFINE([HAVE_UINTXX_T])
3581 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003582 ], [ AC_MSG_RESULT([no])
Tim Rice648f8762011-01-26 12:38:57 -08003583 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003584fi
3585
Damien Millerc2868192014-01-30 10:21:19 +11003586if (test -z "$have_uintxx_t" && \
3587 test "x$ac_cv_header_inttypes_h" = "xyes")
3588then
Darren Tucker6d725682014-01-17 19:17:34 +11003589 AC_MSG_CHECKING([for uintXX_t types in inttypes.h])
3590 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <inttypes.h> ]],
3591 [[ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;]])],
3592 [
3593 AC_DEFINE([HAVE_UINTXX_T])
3594 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003595 ], [ AC_MSG_RESULT([no])
Darren Tucker6d725682014-01-17 19:17:34 +11003596 ])
3597fi
3598
Damien Milleredb82922000-06-20 13:25:52 +10003599if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
Damien Millera8e06ce2003-11-21 23:48:55 +11003600 test "x$ac_cv_header_sys_bitypes_h" = "xyes")
Damien Millerb29ea912000-01-15 14:12:03 +11003601then
3602 AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
Tim Rice648f8762011-01-26 12:38:57 -08003603 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller61e50f12000-05-08 20:49:37 +10003604#include <sys/bitypes.h>
Tim Rice648f8762011-01-26 12:38:57 -08003605 ]], [[
Damien Miller70494d12000-04-03 15:57:06 +10003606 int8_t a; int16_t b; int32_t c;
3607 u_int8_t e; u_int16_t f; u_int32_t g;
3608 a = b = c = e = f = g = 1;
Tim Rice648f8762011-01-26 12:38:57 -08003609 ]])],
Damien Millerb29ea912000-01-15 14:12:03 +11003610 [
Tim Rice648f8762011-01-26 12:38:57 -08003611 AC_DEFINE([HAVE_U_INTXX_T])
3612 AC_DEFINE([HAVE_INTXX_T])
3613 AC_MSG_RESULT([yes])
3614 ], [AC_MSG_RESULT([no])
3615 ])
Damien Millerb29ea912000-01-15 14:12:03 +11003616fi
3617
Damien Miller58be7382001-09-15 21:31:54 +10003618
3619AC_CACHE_CHECK([for u_char], ac_cv_have_u_char, [
Tim Rice648f8762011-01-26 12:38:57 -08003620 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3621 [[ u_char foo; foo = 125; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003622 [ ac_cv_have_u_char="yes" ], [ ac_cv_have_u_char="no"
Tim Rice648f8762011-01-26 12:38:57 -08003623 ])
Damien Miller58be7382001-09-15 21:31:54 +10003624])
3625if test "x$ac_cv_have_u_char" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003626 AC_DEFINE([HAVE_U_CHAR], [1], [define if you have u_char data type])
Damien Miller58be7382001-09-15 21:31:54 +10003627fi
3628
Darren Tucker007e3b32013-11-03 18:43:55 +11003629AC_CHECK_TYPES([intmax_t, uintmax_t], , , [
3630#include <sys/types.h>
3631#include <stdint.h>
3632])
3633
Tim Rice13aae5e2001-10-21 17:53:58 -07003634TYPE_SOCKLEN_T
Damien Miller74d0d4a1999-12-29 02:24:35 +11003635
Tim Rice648f8762011-01-26 12:38:57 -08003636AC_CHECK_TYPES([sig_atomic_t], , , [#include <signal.h>])
3637AC_CHECK_TYPES([fsblkcnt_t, fsfilcnt_t], , , [
Darren Tucker598eaa62008-06-09 03:32:29 +10003638#include <sys/types.h>
3639#ifdef HAVE_SYS_BITYPES_H
3640#include <sys/bitypes.h>
3641#endif
3642#ifdef HAVE_SYS_STATFS_H
3643#include <sys/statfs.h>
3644#endif
3645#ifdef HAVE_SYS_STATVFS_H
3646#include <sys/statvfs.h>
3647#endif
3648])
Tim Rice4cec93f2002-02-26 08:40:48 -08003649
Tim Rice648f8762011-01-26 12:38:57 -08003650AC_CHECK_TYPES([in_addr_t, in_port_t], , ,
Damien Miller848b9932005-02-24 12:12:34 +11003651[#include <sys/types.h>
3652#include <netinet/in.h>])
Darren Tuckerd9f88912005-02-20 21:01:48 +11003653
Damien Miller61e50f12000-05-08 20:49:37 +10003654AC_CACHE_CHECK([for size_t], ac_cv_have_size_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003655 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3656 [[ size_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003657 [ ac_cv_have_size_t="yes" ], [ ac_cv_have_size_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003658 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003659])
3660if test "x$ac_cv_have_size_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003661 AC_DEFINE([HAVE_SIZE_T], [1], [define if you have size_t data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003662fi
Damien Miller95058511999-12-29 10:36:45 +11003663
Damien Miller615f9392000-05-17 22:53:33 +10003664AC_CACHE_CHECK([for ssize_t], ac_cv_have_ssize_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003665 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3666 [[ ssize_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003667 [ ac_cv_have_ssize_t="yes" ], [ ac_cv_have_ssize_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003668 ])
Damien Miller615f9392000-05-17 22:53:33 +10003669])
3670if test "x$ac_cv_have_ssize_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003671 AC_DEFINE([HAVE_SSIZE_T], [1], [define if you have ssize_t data type])
Damien Miller615f9392000-05-17 22:53:33 +10003672fi
3673
Ben Lindstrom0d5af602001-01-09 00:50:29 +00003674AC_CACHE_CHECK([for clock_t], ac_cv_have_clock_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003675 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <time.h> ]],
3676 [[ clock_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003677 [ ac_cv_have_clock_t="yes" ], [ ac_cv_have_clock_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003678 ])
Ben Lindstrom0d5af602001-01-09 00:50:29 +00003679])
3680if test "x$ac_cv_have_clock_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003681 AC_DEFINE([HAVE_CLOCK_T], [1], [define if you have clock_t data type])
Ben Lindstrom0d5af602001-01-09 00:50:29 +00003682fi
3683
Damien Millerb54b40e2000-06-23 08:23:34 +10003684AC_CACHE_CHECK([for sa_family_t], ac_cv_have_sa_family_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003685 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Millerb54b40e2000-06-23 08:23:34 +10003686#include <sys/types.h>
3687#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08003688 ]], [[ sa_family_t foo; foo = 1235; ]])],
3689 [ ac_cv_have_sa_family_t="yes" ],
3690 [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller78315eb2000-09-29 23:01:36 +11003691#include <sys/types.h>
3692#include <sys/socket.h>
3693#include <netinet/in.h>
Tim Rice648f8762011-01-26 12:38:57 -08003694 ]], [[ sa_family_t foo; foo = 1235; ]])],
Damien Miller78315eb2000-09-29 23:01:36 +11003695 [ ac_cv_have_sa_family_t="yes" ],
Damien Millerb54b40e2000-06-23 08:23:34 +10003696 [ ac_cv_have_sa_family_t="no" ]
3697 )
Tim Rice648f8762011-01-26 12:38:57 -08003698 ])
Damien Millerb54b40e2000-06-23 08:23:34 +10003699])
3700if test "x$ac_cv_have_sa_family_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003701 AC_DEFINE([HAVE_SA_FAMILY_T], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003702 [define if you have sa_family_t data type])
Damien Millerb54b40e2000-06-23 08:23:34 +10003703fi
3704
Damien Miller0f91b4e2000-06-18 15:43:25 +10003705AC_CACHE_CHECK([for pid_t], ac_cv_have_pid_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003706 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3707 [[ pid_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003708 [ ac_cv_have_pid_t="yes" ], [ ac_cv_have_pid_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003709 ])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003710])
3711if test "x$ac_cv_have_pid_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003712 AC_DEFINE([HAVE_PID_T], [1], [define if you have pid_t data type])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003713fi
3714
3715AC_CACHE_CHECK([for mode_t], ac_cv_have_mode_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003716 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3717 [[ mode_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003718 [ ac_cv_have_mode_t="yes" ], [ ac_cv_have_mode_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003719 ])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003720])
3721if test "x$ac_cv_have_mode_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003722 AC_DEFINE([HAVE_MODE_T], [1], [define if you have mode_t data type])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003723fi
3724
Damien Miller61e50f12000-05-08 20:49:37 +10003725
3726AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_have_struct_sockaddr_storage, [
Tim Rice648f8762011-01-26 12:38:57 -08003727 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10003728#include <sys/types.h>
3729#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08003730 ]], [[ struct sockaddr_storage s; ]])],
3731 [ ac_cv_have_struct_sockaddr_storage="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003732 [ ac_cv_have_struct_sockaddr_storage="no"
Tim Rice648f8762011-01-26 12:38:57 -08003733 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003734])
3735if test "x$ac_cv_have_struct_sockaddr_storage" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003736 AC_DEFINE([HAVE_STRUCT_SOCKADDR_STORAGE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003737 [define if you have struct sockaddr_storage data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003738fi
Damien Miller34132e52000-01-14 15:45:46 +11003739
Damien Miller61e50f12000-05-08 20:49:37 +10003740AC_CACHE_CHECK([for struct sockaddr_in6], ac_cv_have_struct_sockaddr_in6, [
Tim Rice648f8762011-01-26 12:38:57 -08003741 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller7b22d652000-06-18 14:07:04 +10003742#include <sys/types.h>
Damien Miller61e50f12000-05-08 20:49:37 +10003743#include <netinet/in.h>
Tim Rice648f8762011-01-26 12:38:57 -08003744 ]], [[ struct sockaddr_in6 s; s.sin6_family = 0; ]])],
3745 [ ac_cv_have_struct_sockaddr_in6="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003746 [ ac_cv_have_struct_sockaddr_in6="no"
Tim Rice648f8762011-01-26 12:38:57 -08003747 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003748])
3749if test "x$ac_cv_have_struct_sockaddr_in6" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003750 AC_DEFINE([HAVE_STRUCT_SOCKADDR_IN6], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003751 [define if you have struct sockaddr_in6 data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003752fi
Damien Miller34132e52000-01-14 15:45:46 +11003753
Damien Miller61e50f12000-05-08 20:49:37 +10003754AC_CACHE_CHECK([for struct in6_addr], ac_cv_have_struct_in6_addr, [
Tim Rice648f8762011-01-26 12:38:57 -08003755 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller7b22d652000-06-18 14:07:04 +10003756#include <sys/types.h>
Damien Miller61e50f12000-05-08 20:49:37 +10003757#include <netinet/in.h>
Tim Rice648f8762011-01-26 12:38:57 -08003758 ]], [[ struct in6_addr s; s.s6_addr[0] = 0; ]])],
3759 [ ac_cv_have_struct_in6_addr="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003760 [ ac_cv_have_struct_in6_addr="no"
Tim Rice648f8762011-01-26 12:38:57 -08003761 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003762])
3763if test "x$ac_cv_have_struct_in6_addr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003764 AC_DEFINE([HAVE_STRUCT_IN6_ADDR], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003765 [define if you have struct in6_addr data type])
Tim Rice0f4d2c02008-11-18 21:26:41 -08003766
3767dnl Now check for sin6_scope_id
Tim Rice648f8762011-01-26 12:38:57 -08003768 AC_CHECK_MEMBERS([struct sockaddr_in6.sin6_scope_id], , ,
Tim Rice0f4d2c02008-11-18 21:26:41 -08003769 [
3770#ifdef HAVE_SYS_TYPES_H
3771#include <sys/types.h>
3772#endif
3773#include <netinet/in.h>
3774 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003775fi
Damien Miller34132e52000-01-14 15:45:46 +11003776
Damien Miller61e50f12000-05-08 20:49:37 +10003777AC_CACHE_CHECK([for struct addrinfo], ac_cv_have_struct_addrinfo, [
Tim Rice648f8762011-01-26 12:38:57 -08003778 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10003779#include <sys/types.h>
3780#include <sys/socket.h>
3781#include <netdb.h>
Tim Rice648f8762011-01-26 12:38:57 -08003782 ]], [[ struct addrinfo s; s.ai_flags = AI_PASSIVE; ]])],
3783 [ ac_cv_have_struct_addrinfo="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003784 [ ac_cv_have_struct_addrinfo="no"
Tim Rice648f8762011-01-26 12:38:57 -08003785 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003786])
3787if test "x$ac_cv_have_struct_addrinfo" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003788 AC_DEFINE([HAVE_STRUCT_ADDRINFO], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003789 [define if you have struct addrinfo data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003790fi
3791
Ben Lindstrom42202bc2001-01-15 02:34:37 +00003792AC_CACHE_CHECK([for struct timeval], ac_cv_have_struct_timeval, [
Tim Rice648f8762011-01-26 12:38:57 -08003793 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/time.h> ]],
3794 [[ struct timeval tv; tv.tv_sec = 1;]])],
3795 [ ac_cv_have_struct_timeval="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003796 [ ac_cv_have_struct_timeval="no"
Tim Rice648f8762011-01-26 12:38:57 -08003797 ])
Ben Lindstrom42202bc2001-01-15 02:34:37 +00003798])
3799if test "x$ac_cv_have_struct_timeval" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003800 AC_DEFINE([HAVE_STRUCT_TIMEVAL], [1], [define if you have struct timeval])
Ben Lindstrom42202bc2001-01-15 02:34:37 +00003801 have_struct_timeval=1
3802fi
3803
Tim Rice648f8762011-01-26 12:38:57 -08003804AC_CHECK_TYPES([struct timespec])
Tim Rice4e4dc562003-03-18 10:21:40 -08003805
Ben Lindstrom5bd6eb72003-03-21 00:34:34 +00003806# We need int64_t or else certian parts of the compile will fail.
Tim Rice8bb561b2005-03-17 16:23:19 -08003807if test "x$ac_cv_have_int64_t" = "xno" && \
3808 test "x$ac_cv_sizeof_long_int" != "x8" && \
3809 test "x$ac_cv_sizeof_long_long_int" = "x0" ; then
Ben Lindstrom5bd6eb72003-03-21 00:34:34 +00003810 echo "OpenSSH requires int64_t support. Contact your vendor or install"
3811 echo "an alternative compiler (I.E., GCC) before continuing."
3812 echo ""
3813 exit 1;
Tim Ricebee3f222001-03-11 17:32:12 -08003814else
3815dnl test snprintf (broken on SCO w/gcc)
Darren Tuckera0c2b392004-09-11 23:26:37 +10003816 AC_RUN_IFELSE(
Darren Tucker623d92f2004-09-12 22:36:15 +10003817 [AC_LANG_SOURCE([[
Tim Ricebee3f222001-03-11 17:32:12 -08003818#include <stdio.h>
3819#include <string.h>
3820#ifdef HAVE_SNPRINTF
3821main()
3822{
3823 char buf[50];
3824 char expected_out[50];
3825 int mazsize = 50 ;
3826#if (SIZEOF_LONG_INT == 8)
3827 long int num = 0x7fffffffffffffff;
3828#else
Kevin Steves6482ec82001-07-15 02:09:28 +00003829 long long num = 0x7fffffffffffffffll;
Tim Ricebee3f222001-03-11 17:32:12 -08003830#endif
3831 strcpy(expected_out, "9223372036854775807");
3832 snprintf(buf, mazsize, "%lld", num);
3833 if(strcmp(buf, expected_out) != 0)
Damien Millera8e06ce2003-11-21 23:48:55 +11003834 exit(1);
Tim Ricebee3f222001-03-11 17:32:12 -08003835 exit(0);
3836}
3837#else
3838main() { exit(0); }
3839#endif
Tim Rice648f8762011-01-26 12:38:57 -08003840 ]])], [ true ], [ AC_DEFINE([BROKEN_SNPRINTF]) ],
Darren Tuckera0c2b392004-09-11 23:26:37 +10003841 AC_MSG_WARN([cross compiling: Assuming working snprintf()])
Tim Ricebee3f222001-03-11 17:32:12 -08003842 )
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00003843fi
3844
Damien Miller78315eb2000-09-29 23:01:36 +11003845dnl Checks for structure members
Tim Rice648f8762011-01-26 12:38:57 -08003846OSSH_CHECK_HEADER_FOR_FIELD([ut_host], [utmp.h], [HAVE_HOST_IN_UTMP])
3847OSSH_CHECK_HEADER_FOR_FIELD([ut_host], [utmpx.h], [HAVE_HOST_IN_UTMPX])
3848OSSH_CHECK_HEADER_FOR_FIELD([syslen], [utmpx.h], [HAVE_SYSLEN_IN_UTMPX])
3849OSSH_CHECK_HEADER_FOR_FIELD([ut_pid], [utmp.h], [HAVE_PID_IN_UTMP])
3850OSSH_CHECK_HEADER_FOR_FIELD([ut_type], [utmp.h], [HAVE_TYPE_IN_UTMP])
3851OSSH_CHECK_HEADER_FOR_FIELD([ut_type], [utmpx.h], [HAVE_TYPE_IN_UTMPX])
3852OSSH_CHECK_HEADER_FOR_FIELD([ut_tv], [utmp.h], [HAVE_TV_IN_UTMP])
3853OSSH_CHECK_HEADER_FOR_FIELD([ut_id], [utmp.h], [HAVE_ID_IN_UTMP])
3854OSSH_CHECK_HEADER_FOR_FIELD([ut_id], [utmpx.h], [HAVE_ID_IN_UTMPX])
3855OSSH_CHECK_HEADER_FOR_FIELD([ut_addr], [utmp.h], [HAVE_ADDR_IN_UTMP])
3856OSSH_CHECK_HEADER_FOR_FIELD([ut_addr], [utmpx.h], [HAVE_ADDR_IN_UTMPX])
3857OSSH_CHECK_HEADER_FOR_FIELD([ut_addr_v6], [utmp.h], [HAVE_ADDR_V6_IN_UTMP])
3858OSSH_CHECK_HEADER_FOR_FIELD([ut_addr_v6], [utmpx.h], [HAVE_ADDR_V6_IN_UTMPX])
3859OSSH_CHECK_HEADER_FOR_FIELD([ut_exit], [utmp.h], [HAVE_EXIT_IN_UTMP])
3860OSSH_CHECK_HEADER_FOR_FIELD([ut_time], [utmp.h], [HAVE_TIME_IN_UTMP])
3861OSSH_CHECK_HEADER_FOR_FIELD([ut_time], [utmpx.h], [HAVE_TIME_IN_UTMPX])
3862OSSH_CHECK_HEADER_FOR_FIELD([ut_tv], [utmpx.h], [HAVE_TV_IN_UTMPX])
Tim Rice13aae5e2001-10-21 17:53:58 -07003863
3864AC_CHECK_MEMBERS([struct stat.st_blksize])
Damien Millerbcd14852017-06-10 23:41:25 +10003865AC_CHECK_MEMBERS([struct stat.st_mtim])
3866AC_CHECK_MEMBERS([struct stat.st_mtime])
Damien Miller6332da22013-04-23 14:25:52 +10003867AC_CHECK_MEMBERS([struct passwd.pw_gecos, struct passwd.pw_class,
3868struct passwd.pw_change, struct passwd.pw_expire],
3869[], [], [[
3870#include <sys/types.h>
3871#include <pwd.h>
3872]])
3873
Tim Rice648f8762011-01-26 12:38:57 -08003874AC_CHECK_MEMBER([struct __res_state.retrans], [], [AC_DEFINE([__res_state], [state],
Darren Tucker58e298d2005-11-25 13:14:58 +11003875 [Define if we don't have struct __res_state in resolv.h])],
Damien Miller6332da22013-04-23 14:25:52 +10003876[[
Darren Tucker58e298d2005-11-25 13:14:58 +11003877#include <stdio.h>
3878#if HAVE_SYS_TYPES_H
3879# include <sys/types.h>
3880#endif
3881#include <netinet/in.h>
3882#include <arpa/nameser.h>
3883#include <resolv.h>
Damien Miller6332da22013-04-23 14:25:52 +10003884]])
andre2ff7b5d2000-06-03 14:57:40 +00003885
Damien Miller61e50f12000-05-08 20:49:37 +10003886AC_CACHE_CHECK([for ss_family field in struct sockaddr_storage],
3887 ac_cv_have_ss_family_in_struct_ss, [
Tim Rice648f8762011-01-26 12:38:57 -08003888 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10003889#include <sys/types.h>
3890#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08003891 ]], [[ struct sockaddr_storage s; s.ss_family = 1; ]])],
3892 [ ac_cv_have_ss_family_in_struct_ss="yes" ],
3893 [ ac_cv_have_ss_family_in_struct_ss="no" ])
Damien Miller61e50f12000-05-08 20:49:37 +10003894])
3895if test "x$ac_cv_have_ss_family_in_struct_ss" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003896 AC_DEFINE([HAVE_SS_FAMILY_IN_SS], [1], [Fields in struct sockaddr_storage])
Damien Miller61e50f12000-05-08 20:49:37 +10003897fi
3898
Damien Miller61e50f12000-05-08 20:49:37 +10003899AC_CACHE_CHECK([for __ss_family field in struct sockaddr_storage],
3900 ac_cv_have___ss_family_in_struct_ss, [
Tim Rice648f8762011-01-26 12:38:57 -08003901 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10003902#include <sys/types.h>
3903#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08003904 ]], [[ struct sockaddr_storage s; s.__ss_family = 1; ]])],
3905 [ ac_cv_have___ss_family_in_struct_ss="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003906 [ ac_cv_have___ss_family_in_struct_ss="no"
Tim Rice648f8762011-01-26 12:38:57 -08003907 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003908])
3909if test "x$ac_cv_have___ss_family_in_struct_ss" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003910 AC_DEFINE([HAVE___SS_FAMILY_IN_SS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003911 [Fields in struct sockaddr_storage])
Damien Miller61e50f12000-05-08 20:49:37 +10003912fi
Damien Millerbf1c9b21999-12-09 10:16:54 +11003913
Tim Rice28bbb0c2002-05-27 17:37:32 -07003914dnl make sure we're using the real structure members and not defines
Kevin Steves939c9db2002-03-22 17:23:25 +00003915AC_CACHE_CHECK([for msg_accrights field in struct msghdr],
3916 ac_cv_have_accrights_in_msghdr, [
Tim Rice648f8762011-01-26 12:38:57 -08003917 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Tim Riceae49fe62002-04-12 10:26:21 -07003918#include <sys/types.h>
Kevin Steves939c9db2002-03-22 17:23:25 +00003919#include <sys/socket.h>
3920#include <sys/uio.h>
Tim Rice648f8762011-01-26 12:38:57 -08003921 ]], [[
Tim Rice28bbb0c2002-05-27 17:37:32 -07003922#ifdef msg_accrights
Darren Tuckera0c2b392004-09-11 23:26:37 +10003923#error "msg_accrights is a macro"
Tim Rice28bbb0c2002-05-27 17:37:32 -07003924exit(1);
3925#endif
3926struct msghdr m;
3927m.msg_accrights = 0;
3928exit(0);
Tim Rice648f8762011-01-26 12:38:57 -08003929 ]])],
Kevin Steves939c9db2002-03-22 17:23:25 +00003930 [ ac_cv_have_accrights_in_msghdr="yes" ],
3931 [ ac_cv_have_accrights_in_msghdr="no" ]
3932 )
3933])
3934if test "x$ac_cv_have_accrights_in_msghdr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003935 AC_DEFINE([HAVE_ACCRIGHTS_IN_MSGHDR], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003936 [Define if your system uses access rights style
3937 file descriptor passing])
Kevin Steves939c9db2002-03-22 17:23:25 +00003938fi
3939
Tim Rice648f8762011-01-26 12:38:57 -08003940AC_MSG_CHECKING([if struct statvfs.f_fsid is integral type])
3941AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckere1a3ddf2012-05-04 11:05:45 +10003942#include <sys/param.h>
Darren Tucker32780622009-06-16 16:11:02 +10003943#include <sys/stat.h>
3944#ifdef HAVE_SYS_TIME_H
3945# include <sys/time.h>
3946#endif
3947#ifdef HAVE_SYS_MOUNT_H
3948#include <sys/mount.h>
3949#endif
3950#ifdef HAVE_SYS_STATVFS_H
3951#include <sys/statvfs.h>
3952#endif
Tim Rice648f8762011-01-26 12:38:57 -08003953 ]], [[ struct statvfs s; s.f_fsid = 0; ]])],
3954 [ AC_MSG_RESULT([yes]) ],
3955 [ AC_MSG_RESULT([no])
Darren Tucker32780622009-06-16 16:11:02 +10003956
Tim Rice648f8762011-01-26 12:38:57 -08003957 AC_MSG_CHECKING([if fsid_t has member val])
3958 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker32780622009-06-16 16:11:02 +10003959#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08003960#include <sys/statvfs.h>
3961 ]], [[ fsid_t t; t.val[0] = 0; ]])],
3962 [ AC_MSG_RESULT([yes])
3963 AC_DEFINE([FSID_HAS_VAL], [1], [fsid_t has member val]) ],
3964 [ AC_MSG_RESULT([no]) ])
Darren Tucker32780622009-06-16 16:11:02 +10003965
Tim Rice648f8762011-01-26 12:38:57 -08003966 AC_MSG_CHECKING([if f_fsid has member __val])
3967 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker32780622009-06-16 16:11:02 +10003968#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08003969#include <sys/statvfs.h>
3970 ]], [[ fsid_t t; t.__val[0] = 0; ]])],
3971 [ AC_MSG_RESULT([yes])
3972 AC_DEFINE([FSID_HAS___VAL], [1], [fsid_t has member __val]) ],
3973 [ AC_MSG_RESULT([no]) ])
Darren Tucker32780622009-06-16 16:11:02 +10003974])
Darren Tucker77001382008-06-09 06:17:53 +10003975
Kevin Stevesa44e0352002-04-07 16:18:03 +00003976AC_CACHE_CHECK([for msg_control field in struct msghdr],
3977 ac_cv_have_control_in_msghdr, [
Tim Rice648f8762011-01-26 12:38:57 -08003978 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Tim Riceae49fe62002-04-12 10:26:21 -07003979#include <sys/types.h>
Kevin Stevesa44e0352002-04-07 16:18:03 +00003980#include <sys/socket.h>
3981#include <sys/uio.h>
Tim Rice648f8762011-01-26 12:38:57 -08003982 ]], [[
Tim Rice28bbb0c2002-05-27 17:37:32 -07003983#ifdef msg_control
Darren Tuckera0c2b392004-09-11 23:26:37 +10003984#error "msg_control is a macro"
Tim Rice28bbb0c2002-05-27 17:37:32 -07003985exit(1);
3986#endif
3987struct msghdr m;
3988m.msg_control = 0;
3989exit(0);
Tim Rice648f8762011-01-26 12:38:57 -08003990 ]])],
Kevin Stevesa44e0352002-04-07 16:18:03 +00003991 [ ac_cv_have_control_in_msghdr="yes" ],
3992 [ ac_cv_have_control_in_msghdr="no" ]
3993 )
3994])
3995if test "x$ac_cv_have_control_in_msghdr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003996 AC_DEFINE([HAVE_CONTROL_IN_MSGHDR], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003997 [Define if your system uses ancillary data style
3998 file descriptor passing])
Kevin Stevesa44e0352002-04-07 16:18:03 +00003999fi
4000
Damien Miller61e50f12000-05-08 20:49:37 +10004001AC_CACHE_CHECK([if libc defines __progname], ac_cv_libc_defines___progname, [
Tim Rice648f8762011-01-26 12:38:57 -08004002 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
4003 [[ extern char *__progname; printf("%s", __progname); ]])],
4004 [ ac_cv_libc_defines___progname="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004005 [ ac_cv_libc_defines___progname="no"
Tim Rice648f8762011-01-26 12:38:57 -08004006 ])
Damien Miller61e50f12000-05-08 20:49:37 +10004007])
4008if test "x$ac_cv_libc_defines___progname" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004009 AC_DEFINE([HAVE___PROGNAME], [1], [Define if libc defines __progname])
Damien Miller61e50f12000-05-08 20:49:37 +10004010fi
4011
Kevin Steves4846f4a2002-03-22 18:19:53 +00004012AC_CACHE_CHECK([whether $CC implements __FUNCTION__], ac_cv_cc_implements___FUNCTION__, [
Tim Rice648f8762011-01-26 12:38:57 -08004013 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]],
4014 [[ printf("%s", __FUNCTION__); ]])],
4015 [ ac_cv_cc_implements___FUNCTION__="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004016 [ ac_cv_cc_implements___FUNCTION__="no"
Tim Rice648f8762011-01-26 12:38:57 -08004017 ])
Kevin Steves4846f4a2002-03-22 18:19:53 +00004018])
4019if test "x$ac_cv_cc_implements___FUNCTION__" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004020 AC_DEFINE([HAVE___FUNCTION__], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004021 [Define if compiler implements __FUNCTION__])
Kevin Steves4846f4a2002-03-22 18:19:53 +00004022fi
4023
4024AC_CACHE_CHECK([whether $CC implements __func__], ac_cv_cc_implements___func__, [
Tim Rice648f8762011-01-26 12:38:57 -08004025 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]],
4026 [[ printf("%s", __func__); ]])],
4027 [ ac_cv_cc_implements___func__="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004028 [ ac_cv_cc_implements___func__="no"
Tim Rice648f8762011-01-26 12:38:57 -08004029 ])
Kevin Steves4846f4a2002-03-22 18:19:53 +00004030])
4031if test "x$ac_cv_cc_implements___func__" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004032 AC_DEFINE([HAVE___func__], [1], [Define if compiler implements __func__])
Kevin Steves4846f4a2002-03-22 18:19:53 +00004033fi
4034
Damien Miller57f39152005-11-24 19:58:19 +11004035AC_CACHE_CHECK([whether va_copy exists], ac_cv_have_va_copy, [
Tim Rice648f8762011-01-26 12:38:57 -08004036 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4037#include <stdarg.h>
4038va_list x,y;
4039 ]], [[ va_copy(x,y); ]])],
4040 [ ac_cv_have_va_copy="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004041 [ ac_cv_have_va_copy="no"
Tim Rice648f8762011-01-26 12:38:57 -08004042 ])
Damien Miller57f39152005-11-24 19:58:19 +11004043])
4044if test "x$ac_cv_have_va_copy" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004045 AC_DEFINE([HAVE_VA_COPY], [1], [Define if va_copy exists])
Damien Miller57f39152005-11-24 19:58:19 +11004046fi
4047
4048AC_CACHE_CHECK([whether __va_copy exists], ac_cv_have___va_copy, [
Tim Rice648f8762011-01-26 12:38:57 -08004049 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4050#include <stdarg.h>
4051va_list x,y;
4052 ]], [[ __va_copy(x,y); ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07004053 [ ac_cv_have___va_copy="yes" ], [ ac_cv_have___va_copy="no"
Tim Rice648f8762011-01-26 12:38:57 -08004054 ])
Damien Miller57f39152005-11-24 19:58:19 +11004055])
4056if test "x$ac_cv_have___va_copy" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004057 AC_DEFINE([HAVE___VA_COPY], [1], [Define if __va_copy exists])
Damien Miller57f39152005-11-24 19:58:19 +11004058fi
4059
Damien Miller4f8e6692001-07-14 13:22:53 +10004060AC_CACHE_CHECK([whether getopt has optreset support],
4061 ac_cv_have_getopt_optreset, [
Tim Rice648f8762011-01-26 12:38:57 -08004062 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <getopt.h> ]],
4063 [[ extern int optreset; optreset = 0; ]])],
4064 [ ac_cv_have_getopt_optreset="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004065 [ ac_cv_have_getopt_optreset="no"
Tim Rice648f8762011-01-26 12:38:57 -08004066 ])
Damien Miller4f8e6692001-07-14 13:22:53 +10004067])
4068if test "x$ac_cv_have_getopt_optreset" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004069 AC_DEFINE([HAVE_GETOPT_OPTRESET], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004070 [Define if your getopt(3) defines and uses optreset])
Damien Miller4f8e6692001-07-14 13:22:53 +10004071fi
Damien Millera22ba012000-03-02 23:09:20 +11004072
Damien Millerecbb26d2000-07-15 14:59:14 +10004073AC_CACHE_CHECK([if libc defines sys_errlist], ac_cv_libc_defines_sys_errlist, [
Tim Rice648f8762011-01-26 12:38:57 -08004074 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
4075[[ extern const char *const sys_errlist[]; printf("%s", sys_errlist[0]);]])],
4076 [ ac_cv_libc_defines_sys_errlist="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004077 [ ac_cv_libc_defines_sys_errlist="no"
Tim Rice648f8762011-01-26 12:38:57 -08004078 ])
Damien Millerecbb26d2000-07-15 14:59:14 +10004079])
4080if test "x$ac_cv_libc_defines_sys_errlist" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004081 AC_DEFINE([HAVE_SYS_ERRLIST], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004082 [Define if your system defines sys_errlist[]])
Damien Millerecbb26d2000-07-15 14:59:14 +10004083fi
4084
4085
Damien Miller11fa2cc2000-08-16 10:35:58 +10004086AC_CACHE_CHECK([if libc defines sys_nerr], ac_cv_libc_defines_sys_nerr, [
Tim Rice648f8762011-01-26 12:38:57 -08004087 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
4088[[ extern int sys_nerr; printf("%i", sys_nerr);]])],
4089 [ ac_cv_libc_defines_sys_nerr="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004090 [ ac_cv_libc_defines_sys_nerr="no"
Tim Rice648f8762011-01-26 12:38:57 -08004091 ])
Damien Miller11fa2cc2000-08-16 10:35:58 +10004092])
4093if test "x$ac_cv_libc_defines_sys_nerr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004094 AC_DEFINE([HAVE_SYS_NERR], [1], [Define if your system defines sys_nerr])
Damien Miller11fa2cc2000-08-16 10:35:58 +10004095fi
4096
Darren Tucker5f88d342003-10-15 16:57:57 +10004097# Check libraries needed by DNS fingerprint support
Tim Rice648f8762011-01-26 12:38:57 -08004098AC_SEARCH_LIBS([getrrsetbyname], [resolv],
4099 [AC_DEFINE([HAVE_GETRRSETBYNAME], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004100 [Define if getrrsetbyname() exists])],
Damien Miller7abe09b2003-05-15 10:53:49 +10004101 [
Darren Tucker5f88d342003-10-15 16:57:57 +10004102 # Needed by our getrrsetbyname()
Tim Rice648f8762011-01-26 12:38:57 -08004103 AC_SEARCH_LIBS([res_query], [resolv])
4104 AC_SEARCH_LIBS([dn_expand], [resolv])
4105 AC_MSG_CHECKING([if res_query will link])
4106 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckere02b49a2009-09-11 14:56:08 +10004107#include <sys/types.h>
4108#include <netinet/in.h>
4109#include <arpa/nameser.h>
4110#include <netdb.h>
4111#include <resolv.h>
Tim Rice648f8762011-01-26 12:38:57 -08004112 ]], [[
Darren Tuckere02b49a2009-09-11 14:56:08 +10004113 res_query (0, 0, 0, 0, 0);
Tim Rice648f8762011-01-26 12:38:57 -08004114 ]])],
4115 AC_MSG_RESULT([yes]),
4116 [AC_MSG_RESULT([no])
Darren Tucker8e968a52004-05-13 11:56:16 +10004117 saved_LIBS="$LIBS"
4118 LIBS="$LIBS -lresolv"
Tim Rice648f8762011-01-26 12:38:57 -08004119 AC_MSG_CHECKING([for res_query in -lresolv])
4120 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckere02b49a2009-09-11 14:56:08 +10004121#include <sys/types.h>
4122#include <netinet/in.h>
4123#include <arpa/nameser.h>
4124#include <netdb.h>
Darren Tucker8e968a52004-05-13 11:56:16 +10004125#include <resolv.h>
Tim Rice648f8762011-01-26 12:38:57 -08004126 ]], [[
Darren Tucker8e968a52004-05-13 11:56:16 +10004127 res_query (0, 0, 0, 0, 0);
Tim Rice648f8762011-01-26 12:38:57 -08004128 ]])],
4129 [AC_MSG_RESULT([yes])],
Darren Tucker8e968a52004-05-13 11:56:16 +10004130 [LIBS="$saved_LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08004131 AC_MSG_RESULT([no])])
Darren Tucker8e968a52004-05-13 11:56:16 +10004132 ])
Tim Rice648f8762011-01-26 12:38:57 -08004133 AC_CHECK_FUNCS([_getshort _getlong])
Darren Tuckerd886e1c2005-06-01 18:57:45 +10004134 AC_CHECK_DECLS([_getshort, _getlong], , ,
Tim Ricefcc7ff12005-06-02 20:28:29 -07004135 [#include <sys/types.h>
4136 #include <arpa/nameser.h>])
Tim Rice648f8762011-01-26 12:38:57 -08004137 AC_CHECK_MEMBER([HEADER.ad],
4138 [AC_DEFINE([HAVE_HEADER_AD], [1],
4139 [Define if HEADER.ad exists in arpa/nameser.h])], ,
Darren Tucker5f88d342003-10-15 16:57:57 +10004140 [#include <arpa/nameser.h>])
4141 ])
Damien Miller7abe09b2003-05-15 10:53:49 +10004142
Tim Rice648f8762011-01-26 12:38:57 -08004143AC_MSG_CHECKING([if struct __res_state _res is an extern])
4144AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckercc40d5e2007-04-29 13:58:06 +10004145#include <stdio.h>
4146#if HAVE_SYS_TYPES_H
4147# include <sys/types.h>
4148#endif
4149#include <netinet/in.h>
4150#include <arpa/nameser.h>
4151#include <resolv.h>
4152extern struct __res_state _res;
Darren Tucker7ad8b282015-09-11 13:11:02 +10004153 ]], [[
4154struct __res_state *volatile p = &_res; /* force resolution of _res */
4155return 0;
4156 ]],)],
Tim Rice648f8762011-01-26 12:38:57 -08004157 [AC_MSG_RESULT([yes])
4158 AC_DEFINE([HAVE__RES_EXTERN], [1],
Darren Tuckercc40d5e2007-04-29 13:58:06 +10004159 [Define if you have struct __res_state _res as an extern])
4160 ],
Tim Rice648f8762011-01-26 12:38:57 -08004161 [ AC_MSG_RESULT([no]) ]
Darren Tuckercc40d5e2007-04-29 13:58:06 +10004162)
4163
Damien Miller73b42d22006-04-22 21:26:08 +10004164# Check whether user wants SELinux support
4165SELINUX_MSG="no"
4166LIBSELINUX=""
Tim Rice648f8762011-01-26 12:38:57 -08004167AC_ARG_WITH([selinux],
Damien Miller5b1c8b32008-03-27 12:33:07 +11004168 [ --with-selinux Enable SELinux support],
Damien Miller73b42d22006-04-22 21:26:08 +10004169 [ if test "x$withval" != "xno" ; then
Darren Tucker20e9f972007-03-25 18:26:01 +10004170 save_LIBS="$LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08004171 AC_DEFINE([WITH_SELINUX], [1],
4172 [Define if you want SELinux support.])
Damien Miller73b42d22006-04-22 21:26:08 +10004173 SELINUX_MSG="yes"
4174 AC_CHECK_HEADER([selinux/selinux.h], ,
Tim Rice648f8762011-01-26 12:38:57 -08004175 AC_MSG_ERROR([SELinux support requires selinux.h header]))
4176 AC_CHECK_LIB([selinux], [setexeccon],
Damien Miller1d2bfc42010-02-10 10:19:29 +11004177 [ LIBSELINUX="-lselinux"
4178 LIBS="$LIBS -lselinux"
4179 ],
Tim Rice648f8762011-01-26 12:38:57 -08004180 AC_MSG_ERROR([SELinux support requires libselinux library]))
Damien Miller71adf122011-01-25 12:16:15 +11004181 SSHLIBS="$SSHLIBS $LIBSELINUX"
Darren Tucker20e9f972007-03-25 18:26:01 +10004182 SSHDLIBS="$SSHDLIBS $LIBSELINUX"
Tim Rice648f8762011-01-26 12:38:57 -08004183 AC_CHECK_FUNCS([getseuserbyname get_default_context_with_level])
Darren Tuckeradc947d2006-10-07 09:07:20 +10004184 LIBS="$save_LIBS"
Damien Miller73b42d22006-04-22 21:26:08 +10004185 fi ]
4186)
Tim Rice648f8762011-01-26 12:38:57 -08004187AC_SUBST([SSHLIBS])
4188AC_SUBST([SSHDLIBS])
Damien Miller73b42d22006-04-22 21:26:08 +10004189
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004190# Check whether user wants Kerberos 5 support
Damien Millera8e06ce2003-11-21 23:48:55 +11004191KRB5_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08004192AC_ARG_WITH([kerberos5],
Damien Millera8e06ce2003-11-21 23:48:55 +11004193 [ --with-kerberos5=PATH Enable Kerberos 5 support],
Darren Tucker1d3ca582004-01-22 12:05:34 +11004194 [ if test "x$withval" != "xno" ; then
4195 if test "x$withval" = "xyes" ; then
4196 KRB5ROOT="/usr/local"
4197 else
4198 KRB5ROOT=${withval}
4199 fi
4200
Tim Rice648f8762011-01-26 12:38:57 -08004201 AC_DEFINE([KRB5], [1], [Define if you want Kerberos 5 support])
Darren Tucker1d3ca582004-01-22 12:05:34 +11004202 KRB5_MSG="yes"
4203
Darren Tucker4089fc12016-12-08 12:57:24 +11004204 AC_PATH_TOOL([KRB5CONF], [krb5-config],
Darren Tuckerdad48e72009-09-01 18:26:00 +10004205 [$KRB5ROOT/bin/krb5-config],
4206 [$KRB5ROOT/bin:$PATH])
4207 if test -x $KRB5CONF ; then
Darren Tucker964de182013-02-22 10:39:59 +11004208 K5CFLAGS="`$KRB5CONF --cflags`"
4209 K5LIBS="`$KRB5CONF --libs`"
4210 CPPFLAGS="$CPPFLAGS $K5CFLAGS"
Darren Tucker1d3ca582004-01-22 12:05:34 +11004211
Tim Rice648f8762011-01-26 12:38:57 -08004212 AC_MSG_CHECKING([for gssapi support])
Darren Tucker1d3ca582004-01-22 12:05:34 +11004213 if $KRB5CONF | grep gssapi >/dev/null ; then
Tim Rice648f8762011-01-26 12:38:57 -08004214 AC_MSG_RESULT([yes])
4215 AC_DEFINE([GSSAPI], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004216 [Define this if you want GSSAPI
4217 support in the version 2 protocol])
Darren Tucker964de182013-02-22 10:39:59 +11004218 GSSCFLAGS="`$KRB5CONF --cflags gssapi`"
4219 GSSLIBS="`$KRB5CONF --libs gssapi`"
4220 CPPFLAGS="$CPPFLAGS $GSSCFLAGS"
Damien Millera8e06ce2003-11-21 23:48:55 +11004221 else
Tim Rice648f8762011-01-26 12:38:57 -08004222 AC_MSG_RESULT([no])
Damien Millera8e06ce2003-11-21 23:48:55 +11004223 fi
Tim Rice648f8762011-01-26 12:38:57 -08004224 AC_MSG_CHECKING([whether we are using Heimdal])
4225 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <krb5.h>
4226 ]], [[ char *tmp = heimdal_version; ]])],
4227 [ AC_MSG_RESULT([yes])
4228 AC_DEFINE([HEIMDAL], [1],
4229 [Define this if you are using the Heimdal
4230 version of Kerberos V5]) ],
4231 [AC_MSG_RESULT([no])
4232 ])
Darren Tucker1d3ca582004-01-22 12:05:34 +11004233 else
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004234 CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include"
Damien Millera8e06ce2003-11-21 23:48:55 +11004235 LDFLAGS="$LDFLAGS -L${KRB5ROOT}/lib"
Tim Rice648f8762011-01-26 12:38:57 -08004236 AC_MSG_CHECKING([whether we are using Heimdal])
4237 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <krb5.h>
4238 ]], [[ char *tmp = heimdal_version; ]])],
4239 [ AC_MSG_RESULT([yes])
4240 AC_DEFINE([HEIMDAL])
Damien Miller41bccf72011-01-02 21:53:07 +11004241 K5LIBS="-lkrb5"
Damien Miller5561e0b2004-04-20 20:28:55 +10004242 K5LIBS="$K5LIBS -lcom_err -lasn1"
Tim Rice648f8762011-01-26 12:38:57 -08004243 AC_CHECK_LIB([roken], [net_write],
Damien Miller5561e0b2004-04-20 20:28:55 +10004244 [K5LIBS="$K5LIBS -lroken"])
Tim Rice648f8762011-01-26 12:38:57 -08004245 AC_CHECK_LIB([des], [des_cbc_encrypt],
Damien Miller41bccf72011-01-02 21:53:07 +11004246 [K5LIBS="$K5LIBS -ldes"])
Tim Rice648f8762011-01-26 12:38:57 -08004247 ], [ AC_MSG_RESULT([no])
Damien Millera8e06ce2003-11-21 23:48:55 +11004248 K5LIBS="-lkrb5 -lk5crypto -lcom_err"
Tim Rice648f8762011-01-26 12:38:57 -08004249 ])
4250 AC_SEARCH_LIBS([dn_expand], [resolv])
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004251
Tim Rice648f8762011-01-26 12:38:57 -08004252 AC_CHECK_LIB([gssapi_krb5], [gss_init_sec_context],
4253 [ AC_DEFINE([GSSAPI])
Darren Tucker964de182013-02-22 10:39:59 +11004254 GSSLIBS="-lgssapi_krb5" ],
Tim Rice648f8762011-01-26 12:38:57 -08004255 [ AC_CHECK_LIB([gssapi], [gss_init_sec_context],
4256 [ AC_DEFINE([GSSAPI])
Darren Tucker964de182013-02-22 10:39:59 +11004257 GSSLIBS="-lgssapi" ],
Darren Tuckera2b5a4c2013-02-22 10:43:15 +11004258 [ AC_CHECK_LIB([gss], [gss_init_sec_context],
4259 [ AC_DEFINE([GSSAPI])
4260 GSSLIBS="-lgss" ],
4261 AC_MSG_WARN([Cannot find any suitable gss-api library - build may fail]))
4262 ])
Darren Tucker964de182013-02-22 10:39:59 +11004263 ])
Tim Riceeae17cc2005-03-17 16:52:20 -08004264
Tim Rice648f8762011-01-26 12:38:57 -08004265 AC_CHECK_HEADER([gssapi.h], ,
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004266 [ unset ac_cv_header_gssapi_h
Damien Millera8e06ce2003-11-21 23:48:55 +11004267 CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
Tim Rice648f8762011-01-26 12:38:57 -08004268 AC_CHECK_HEADERS([gssapi.h], ,
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004269 AC_MSG_WARN([Cannot find any suitable gss-api header - build may fail])
Damien Millera8e06ce2003-11-21 23:48:55 +11004270 )
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004271 ]
4272 )
4273
4274 oldCPP="$CPPFLAGS"
4275 CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
Tim Rice648f8762011-01-26 12:38:57 -08004276 AC_CHECK_HEADER([gssapi_krb5.h], ,
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004277 [ CPPFLAGS="$oldCPP" ])
4278
Damien Millera8e06ce2003-11-21 23:48:55 +11004279 fi
Darren Tucker1d3ca582004-01-22 12:05:34 +11004280 if test ! -z "$need_dash_r" ; then
4281 LDFLAGS="$LDFLAGS -R${KRB5ROOT}/lib"
4282 fi
4283 if test ! -z "$blibpath" ; then
4284 blibpath="$blibpath:${KRB5ROOT}/lib"
4285 fi
Tim Ricefd9e9e32005-09-12 17:36:10 -07004286
Tim Rice648f8762011-01-26 12:38:57 -08004287 AC_CHECK_HEADERS([gssapi.h gssapi/gssapi.h])
4288 AC_CHECK_HEADERS([gssapi_krb5.h gssapi/gssapi_krb5.h])
4289 AC_CHECK_HEADERS([gssapi_generic.h gssapi/gssapi_generic.h])
Tim Ricefd9e9e32005-09-12 17:36:10 -07004290
Tim Rice648f8762011-01-26 12:38:57 -08004291 AC_SEARCH_LIBS([k_hasafs], [kafs], [AC_DEFINE([USE_AFS], [1],
4292 [Define this if you want to use libkafs' AFS support])])
Darren Tucker03978c62013-02-25 11:24:44 +11004293
4294 AC_CHECK_DECLS([GSS_C_NT_HOSTBASED_SERVICE], [], [], [[
4295#ifdef HAVE_GSSAPI_H
4296# include <gssapi.h>
4297#elif defined(HAVE_GSSAPI_GSSAPI_H)
4298# include <gssapi/gssapi.h>
4299#endif
4300
4301#ifdef HAVE_GSSAPI_GENERIC_H
4302# include <gssapi_generic.h>
4303#elif defined(HAVE_GSSAPI_GSSAPI_GENERIC_H)
4304# include <gssapi/gssapi_generic.h>
4305#endif
4306 ]])
Darren Tuckerf3ab2c52013-08-04 21:48:41 +10004307 saved_LIBS="$LIBS"
4308 LIBS="$LIBS $K5LIBS"
4309 AC_CHECK_FUNCS([krb5_cc_new_unique krb5_get_error_message krb5_free_error_message])
4310 LIBS="$saved_LIBS"
4311
Darren Tucker0d27ed12004-02-24 10:37:33 +11004312 fi
Darren Tucker0d27ed12004-02-24 10:37:33 +11004313 ]
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004314)
Darren Tucker964de182013-02-22 10:39:59 +11004315AC_SUBST([GSSLIBS])
4316AC_SUBST([K5LIBS])
Damien Millerc79bc0d2001-03-28 13:03:42 +10004317
Damien Millera22ba012000-03-02 23:09:20 +11004318# Looking for programs, paths and files
Damien Millera22ba012000-03-02 23:09:20 +11004319
Damien Millerf58c6722002-05-13 13:15:42 +10004320PRIVSEP_PATH=/var/empty
Tim Rice648f8762011-01-26 12:38:57 -08004321AC_ARG_WITH([privsep-path],
Tim Ricecbb90662002-07-08 19:17:10 -07004322 [ --with-privsep-path=xxx Path for privilege separation chroot (default=/var/empty)],
Damien Millerf58c6722002-05-13 13:15:42 +10004323 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004324 if test -n "$withval" && test "x$withval" != "xno" && \
4325 test "x${withval}" != "xyes"; then
Damien Millerf58c6722002-05-13 13:15:42 +10004326 PRIVSEP_PATH=$withval
4327 fi
4328 ]
4329)
Tim Rice648f8762011-01-26 12:38:57 -08004330AC_SUBST([PRIVSEP_PATH])
Damien Millerf58c6722002-05-13 13:15:42 +10004331
Tim Rice648f8762011-01-26 12:38:57 -08004332AC_ARG_WITH([xauth],
Damien Millera22ba012000-03-02 23:09:20 +11004333 [ --with-xauth=PATH Specify path to xauth program ],
4334 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004335 if test -n "$withval" && test "x$withval" != "xno" && \
4336 test "x${withval}" != "xyes"; then
Damien Miller7b22d652000-06-18 14:07:04 +10004337 xauth_path=$withval
Damien Millera22ba012000-03-02 23:09:20 +11004338 fi
4339 ],
4340 [
Tim Ricee22be3b2002-07-17 19:20:07 -07004341 TestPath="$PATH"
4342 TestPath="${TestPath}${PATH_SEPARATOR}/usr/X/bin"
4343 TestPath="${TestPath}${PATH_SEPARATOR}/usr/bin/X11"
4344 TestPath="${TestPath}${PATH_SEPARATOR}/usr/X11R6/bin"
4345 TestPath="${TestPath}${PATH_SEPARATOR}/usr/openwin/bin"
Tim Rice648f8762011-01-26 12:38:57 -08004346 AC_PATH_PROG([xauth_path], [xauth], , [$TestPath])
Damien Milleredb82922000-06-20 13:25:52 +10004347 if (test ! -z "$xauth_path" && test -x "/usr/openwin/bin/xauth") ; then
Damien Millera22ba012000-03-02 23:09:20 +11004348 xauth_path="/usr/openwin/bin/xauth"
4349 fi
4350 ]
4351)
4352
Damien Miller7d901272003-01-13 16:55:22 +11004353STRIP_OPT=-s
Tim Rice648f8762011-01-26 12:38:57 -08004354AC_ARG_ENABLE([strip],
Damien Miller7d901272003-01-13 16:55:22 +11004355 [ --disable-strip Disable calling strip(1) on install],
4356 [
4357 if test "x$enableval" = "xno" ; then
4358 STRIP_OPT=
4359 fi
4360 ]
4361)
Tim Rice648f8762011-01-26 12:38:57 -08004362AC_SUBST([STRIP_OPT])
Damien Miller7d901272003-01-13 16:55:22 +11004363
Damien Millera19cf472000-11-29 13:28:50 +11004364if test -z "$xauth_path" ; then
4365 XAUTH_PATH="undefined"
Tim Rice648f8762011-01-26 12:38:57 -08004366 AC_SUBST([XAUTH_PATH])
Damien Millera19cf472000-11-29 13:28:50 +11004367else
Tim Rice648f8762011-01-26 12:38:57 -08004368 AC_DEFINE_UNQUOTED([XAUTH_PATH], ["$xauth_path"],
Tim Rice7df8d392005-09-19 09:33:39 -07004369 [Define if xauth is found in your path])
Damien Millera19cf472000-11-29 13:28:50 +11004370 XAUTH_PATH=$xauth_path
Tim Rice648f8762011-01-26 12:38:57 -08004371 AC_SUBST([XAUTH_PATH])
Damien Millera22ba012000-03-02 23:09:20 +11004372fi
Damien Millera22ba012000-03-02 23:09:20 +11004373
Tim Rice90f42b02011-06-02 18:17:49 -07004374dnl # --with-maildir=/path/to/mail gets top priority.
4375dnl # if maildir is set in the platform case statement above we use that.
4376dnl # Otherwise we run a program to get the dir from system headers.
4377dnl # We first look for _PATH_MAILDIR then MAILDIR then _PATH_MAIL
4378dnl # If we find _PATH_MAILDIR we do nothing because that is what
4379dnl # session.c expects anyway. Otherwise we set to the value found
4380dnl # stripping any trailing slash. If for some strage reason our program
4381dnl # does not find what it needs, we default to /var/spool/mail.
4382# Check for mail directory
4383AC_ARG_WITH([maildir],
4384 [ --with-maildir=/path/to/mail Specify your system mail directory],
4385 [
4386 if test "X$withval" != X && test "x$withval" != xno && \
4387 test "x${withval}" != xyes; then
4388 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$withval"],
4389 [Set this to your mail directory if you do not have _PATH_MAILDIR])
4390 fi
4391 ],[
4392 if test "X$maildir" != "X"; then
4393 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$maildir"])
4394 else
4395 AC_MSG_CHECKING([Discovering system mail directory])
4396 AC_RUN_IFELSE(
4397 [AC_LANG_PROGRAM([[
4398#include <stdio.h>
4399#include <string.h>
4400#ifdef HAVE_PATHS_H
4401#include <paths.h>
4402#endif
4403#ifdef HAVE_MAILLOCK_H
4404#include <maillock.h>
4405#endif
4406#define DATA "conftest.maildir"
4407 ]], [[
4408 FILE *fd;
4409 int rc;
4410
4411 fd = fopen(DATA,"w");
4412 if(fd == NULL)
4413 exit(1);
4414
4415#if defined (_PATH_MAILDIR)
4416 if ((rc = fprintf(fd ,"_PATH_MAILDIR:%s\n", _PATH_MAILDIR)) <0)
4417 exit(1);
4418#elif defined (MAILDIR)
4419 if ((rc = fprintf(fd ,"MAILDIR:%s\n", MAILDIR)) <0)
4420 exit(1);
4421#elif defined (_PATH_MAIL)
4422 if ((rc = fprintf(fd ,"_PATH_MAIL:%s\n", _PATH_MAIL)) <0)
4423 exit(1);
4424#else
4425 exit (2);
4426#endif
4427
4428 exit(0);
4429 ]])],
4430 [
Tim Ricee1d93702016-05-31 11:13:22 -07004431 maildir_what=`awk -F: '{print $1}' conftest.maildir`
Tim Rice90f42b02011-06-02 18:17:49 -07004432 maildir=`awk -F: '{print $2}' conftest.maildir \
4433 | sed 's|/$||'`
4434 AC_MSG_RESULT([Using: $maildir from $maildir_what])
4435 if test "x$maildir_what" != "x_PATH_MAILDIR"; then
4436 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$maildir"])
4437 fi
4438 ],
4439 [
4440 if test "X$ac_status" = "X2";then
4441# our test program didn't find it. Default to /var/spool/mail
4442 AC_MSG_RESULT([Using: default value of /var/spool/mail])
4443 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["/var/spool/mail"])
4444 else
4445 AC_MSG_RESULT([*** not found ***])
4446 fi
4447 ],
4448 [
4449 AC_MSG_WARN([cross compiling: use --with-maildir=/path/to/mail])
4450 ]
4451 )
4452 fi
4453 ]
4454) # maildir
Damien Millera22ba012000-03-02 23:09:20 +11004455
Darren Tucker623d92f2004-09-12 22:36:15 +10004456if test ! -z "$cross_compiling" && test "x$cross_compiling" = "xyes"; then
Darren Tuckera0c2b392004-09-11 23:26:37 +10004457 AC_MSG_WARN([cross compiling: Disabling /dev/ptmx test])
4458 disable_ptmx_check=yes
4459fi
Damien Millera22ba012000-03-02 23:09:20 +11004460if test -z "$no_dev_ptmx" ; then
Kevin Steves0ea1d9d2002-04-25 18:17:04 +00004461 if test "x$disable_ptmx_check" != "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004462 AC_CHECK_FILE(["/dev/ptmx"],
Kevin Steves0ea1d9d2002-04-25 18:17:04 +00004463 [
Tim Rice648f8762011-01-26 12:38:57 -08004464 AC_DEFINE_UNQUOTED([HAVE_DEV_PTMX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004465 [Define if you have /dev/ptmx])
Kevin Steves0ea1d9d2002-04-25 18:17:04 +00004466 have_dev_ptmx=1
4467 ]
4468 )
4469 fi
Damien Millera22ba012000-03-02 23:09:20 +11004470fi
Darren Tuckera0c2b392004-09-11 23:26:37 +10004471
Darren Tucker623d92f2004-09-12 22:36:15 +10004472if test ! -z "$cross_compiling" && test "x$cross_compiling" != "xyes"; then
Tim Rice648f8762011-01-26 12:38:57 -08004473 AC_CHECK_FILE(["/dev/ptc"],
Darren Tuckera0c2b392004-09-11 23:26:37 +10004474 [
Tim Rice648f8762011-01-26 12:38:57 -08004475 AC_DEFINE_UNQUOTED([HAVE_DEV_PTS_AND_PTC], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004476 [Define if you have /dev/ptc])
Darren Tuckera0c2b392004-09-11 23:26:37 +10004477 have_dev_ptc=1
4478 ]
4479 )
4480else
4481 AC_MSG_WARN([cross compiling: Disabling /dev/ptc test])
4482fi
Damien Miller204ad072000-03-02 23:56:12 +11004483
Damien Millera22ba012000-03-02 23:09:20 +11004484# Options from here on. Some of these are preset by platform above
Tim Rice648f8762011-01-26 12:38:57 -08004485AC_ARG_WITH([mantype],
Damien Miller897741e2001-04-16 10:41:46 +10004486 [ --with-mantype=man|cat|doc Set man page type],
Damien Miller670a4b82000-01-22 13:53:11 +11004487 [
Damien Miller897741e2001-04-16 10:41:46 +10004488 case "$withval" in
4489 man|cat|doc)
4490 MANTYPE=$withval
4491 ;;
4492 *)
Tim Rice648f8762011-01-26 12:38:57 -08004493 AC_MSG_ERROR([invalid man type: $withval])
Damien Miller897741e2001-04-16 10:41:46 +10004494 ;;
4495 esac
Damien Miller670a4b82000-01-22 13:53:11 +11004496 ]
4497)
Ben Lindstrombc709922001-04-18 18:04:21 +00004498if test -z "$MANTYPE"; then
Tim Ricee22be3b2002-07-17 19:20:07 -07004499 TestPath="/usr/bin${PATH_SEPARATOR}/usr/ucb"
Tim Rice648f8762011-01-26 12:38:57 -08004500 AC_PATH_PROGS([NROFF], [nroff awf], [/bin/false], [$TestPath])
Ben Lindstrombc709922001-04-18 18:04:21 +00004501 if ${NROFF} -mdoc ${srcdir}/ssh.1 >/dev/null 2>&1; then
4502 MANTYPE=doc
4503 elif ${NROFF} -man ${srcdir}/ssh.1 >/dev/null 2>&1; then
4504 MANTYPE=man
4505 else
4506 MANTYPE=cat
4507 fi
4508fi
Tim Rice648f8762011-01-26 12:38:57 -08004509AC_SUBST([MANTYPE])
Ben Lindstrombc709922001-04-18 18:04:21 +00004510if test "$MANTYPE" = "doc"; then
4511 mansubdir=man;
4512else
4513 mansubdir=$MANTYPE;
4514fi
Tim Rice648f8762011-01-26 12:38:57 -08004515AC_SUBST([mansubdir])
Damien Miller8bdeee21999-12-30 15:50:54 +11004516
Damien Millera22ba012000-03-02 23:09:20 +11004517# Check whether to enable MD5 passwords
Damien Millera8e06ce2003-11-21 23:48:55 +11004518MD5_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08004519AC_ARG_WITH([md5-passwords],
Damien Millerdd1c7ba1999-11-19 15:53:20 +11004520 [ --with-md5-passwords Enable use of MD5 passwords],
Damien Miller8bdeee21999-12-30 15:50:54 +11004521 [
Damien Millerb85dcad2000-03-11 11:37:00 +11004522 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004523 AC_DEFINE([HAVE_MD5_PASSWORDS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004524 [Define if you want to allow MD5 passwords])
Damien Millera8e06ce2003-11-21 23:48:55 +11004525 MD5_MSG="yes"
Damien Miller8bdeee21999-12-30 15:50:54 +11004526 fi
4527 ]
Damien Millerdd1c7ba1999-11-19 15:53:20 +11004528)
4529
Damien Millera22ba012000-03-02 23:09:20 +11004530# Whether to disable shadow password support
Tim Rice648f8762011-01-26 12:38:57 -08004531AC_ARG_WITH([shadow],
Damien Miller76112de1999-12-21 11:18:08 +11004532 [ --without-shadow Disable shadow password support],
4533 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004534 if test "x$withval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004535 AC_DEFINE([DISABLE_SHADOW])
Damien Miller1f335fb2000-06-26 11:31:33 +10004536 disable_shadow=yes
Damien Miller76112de1999-12-21 11:18:08 +11004537 fi
4538 ]
4539)
4540
Damien Miller1f335fb2000-06-26 11:31:33 +10004541if test -z "$disable_shadow" ; then
4542 AC_MSG_CHECKING([if the systems has expire shadow information])
Tim Rice648f8762011-01-26 12:38:57 -08004543 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller1f335fb2000-06-26 11:31:33 +10004544#include <sys/types.h>
4545#include <shadow.h>
Tim Rice648f8762011-01-26 12:38:57 -08004546struct spwd sp;
4547 ]], [[ sp.sp_expire = sp.sp_lstchg = sp.sp_inact = 0; ]])],
4548 [ sp_expire_available=yes ], [
4549 ])
Damien Miller1f335fb2000-06-26 11:31:33 +10004550
4551 if test "x$sp_expire_available" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004552 AC_MSG_RESULT([yes])
4553 AC_DEFINE([HAS_SHADOW_EXPIRE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004554 [Define if you want to use shadow password expire field])
Damien Miller1f335fb2000-06-26 11:31:33 +10004555 else
Tim Rice648f8762011-01-26 12:38:57 -08004556 AC_MSG_RESULT([no])
Damien Miller1f335fb2000-06-26 11:31:33 +10004557 fi
4558fi
4559
Damien Millera22ba012000-03-02 23:09:20 +11004560# Use ip address instead of hostname in $DISPLAY
Damien Miller9a947342000-08-30 10:03:33 +11004561if test ! -z "$IPADDR_IN_DISPLAY" ; then
4562 DISPLAY_HACK_MSG="yes"
Tim Rice648f8762011-01-26 12:38:57 -08004563 AC_DEFINE([IPADDR_IN_DISPLAY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004564 [Define if you need to use IP address
4565 instead of hostname in $DISPLAY])
Damien Miller9a947342000-08-30 10:03:33 +11004566else
Damien Millera8e06ce2003-11-21 23:48:55 +11004567 DISPLAY_HACK_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08004568 AC_ARG_WITH([ipaddr-display],
Tim Rice6397eed2015-06-03 21:41:11 -07004569 [ --with-ipaddr-display Use ip address instead of hostname in $DISPLAY],
Damien Miller9a947342000-08-30 10:03:33 +11004570 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004571 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004572 AC_DEFINE([IPADDR_IN_DISPLAY])
Damien Millera8e06ce2003-11-21 23:48:55 +11004573 DISPLAY_HACK_MSG="yes"
Damien Miller9a947342000-08-30 10:03:33 +11004574 fi
4575 ]
4576 )
4577fi
Damien Miller76112de1999-12-21 11:18:08 +11004578
Darren Tuckere1a790d2003-09-16 11:52:19 +10004579# check for /etc/default/login and use it if present.
Tim Rice648f8762011-01-26 12:38:57 -08004580AC_ARG_ENABLE([etc-default-login],
Darren Tucker1b6f2292005-02-11 16:11:49 +11004581 [ --disable-etc-default-login Disable using PATH from /etc/default/login [no]],
Darren Tucker2f9573d2005-02-10 22:28:54 +11004582 [ if test "x$enableval" = "xno"; then
4583 AC_MSG_NOTICE([/etc/default/login handling disabled])
4584 etc_default_login=no
4585 else
4586 etc_default_login=yes
4587 fi ],
Darren Tucker314d89e2005-10-17 23:29:23 +10004588 [ if test ! -z "$cross_compiling" && test "x$cross_compiling" = "xyes";
4589 then
4590 AC_MSG_WARN([cross compiling: not checking /etc/default/login])
4591 etc_default_login=no
4592 else
4593 etc_default_login=yes
4594 fi ]
Darren Tucker2f9573d2005-02-10 22:28:54 +11004595)
Darren Tuckere1a790d2003-09-16 11:52:19 +10004596
Darren Tucker2f9573d2005-02-10 22:28:54 +11004597if test "x$etc_default_login" != "xno"; then
Tim Rice648f8762011-01-26 12:38:57 -08004598 AC_CHECK_FILE(["/etc/default/login"],
Darren Tucker2f9573d2005-02-10 22:28:54 +11004599 [ external_path_file=/etc/default/login ])
Darren Tucker314d89e2005-10-17 23:29:23 +10004600 if test "x$external_path_file" = "x/etc/default/login"; then
Tim Rice648f8762011-01-26 12:38:57 -08004601 AC_DEFINE([HAVE_ETC_DEFAULT_LOGIN], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004602 [Define if your system has /etc/default/login])
Darren Tuckera0c2b392004-09-11 23:26:37 +10004603 fi
Darren Tucker2f9573d2005-02-10 22:28:54 +11004604fi
Darren Tuckere1a790d2003-09-16 11:52:19 +10004605
Tim Rice43a1c132002-04-17 21:19:14 -07004606dnl BSD systems use /etc/login.conf so --with-default-path= has no effect
Tim Rice8bb561b2005-03-17 16:23:19 -08004607if test $ac_cv_func_login_getcapbool = "yes" && \
4608 test $ac_cv_header_login_cap_h = "yes" ; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10004609 external_path_file=/etc/login.conf
Tim Rice43a1c132002-04-17 21:19:14 -07004610fi
Darren Tuckere1a790d2003-09-16 11:52:19 +10004611
Damien Millera22ba012000-03-02 23:09:20 +11004612# Whether to mess with the default path
Damien Millera8e06ce2003-11-21 23:48:55 +11004613SERVER_PATH_MSG="(default)"
Tim Rice648f8762011-01-26 12:38:57 -08004614AC_ARG_WITH([default-path],
Tim Rice6397eed2015-06-03 21:41:11 -07004615 [ --with-default-path= Specify default $PATH environment for server],
Damien Miller5a3e6831999-12-27 09:48:56 +11004616 [
Darren Tuckere1a790d2003-09-16 11:52:19 +10004617 if test "x$external_path_file" = "x/etc/login.conf" ; then
Tim Rice43a1c132002-04-17 21:19:14 -07004618 AC_MSG_WARN([
4619--with-default-path=PATH has no effect on this system.
4620Edit /etc/login.conf instead.])
Tim Riceeae17cc2005-03-17 16:52:20 -08004621 elif test "x$withval" != "xno" ; then
Tim Riceb925b4b2003-09-15 22:40:49 -07004622 if test ! -z "$external_path_file" ; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10004623 AC_MSG_WARN([
4624--with-default-path=PATH will only be used if PATH is not defined in
4625$external_path_file .])
4626 fi
Tim Rice59ea0a02001-03-10 13:50:45 -08004627 user_path="$withval"
Damien Millera8e06ce2003-11-21 23:48:55 +11004628 SERVER_PATH_MSG="$withval"
Damien Miller5a3e6831999-12-27 09:48:56 +11004629 fi
Tim Rice59ea0a02001-03-10 13:50:45 -08004630 ],
Darren Tuckere1a790d2003-09-16 11:52:19 +10004631 [ if test "x$external_path_file" = "x/etc/login.conf" ; then
4632 AC_MSG_WARN([Make sure the path to scp is in /etc/login.conf])
Tim Rice43a1c132002-04-17 21:19:14 -07004633 else
Tim Riceb925b4b2003-09-15 22:40:49 -07004634 if test ! -z "$external_path_file" ; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10004635 AC_MSG_WARN([
4636If PATH is defined in $external_path_file, ensure the path to scp is included,
4637otherwise scp will not work.])
4638 fi
Darren Tucker314d89e2005-10-17 23:29:23 +10004639 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08004640 [AC_LANG_PROGRAM([[
Tim Rice59ea0a02001-03-10 13:50:45 -08004641/* find out what STDPATH is */
4642#include <stdio.h>
Tim Rice59ea0a02001-03-10 13:50:45 -08004643#ifdef HAVE_PATHS_H
4644# include <paths.h>
4645#endif
4646#ifndef _PATH_STDPATH
Tim Rice1c9e6882002-11-22 13:29:01 -08004647# ifdef _PATH_USERPATH /* Irix */
4648# define _PATH_STDPATH _PATH_USERPATH
4649# else
4650# define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
4651# endif
Tim Rice59ea0a02001-03-10 13:50:45 -08004652#endif
4653#include <sys/types.h>
4654#include <sys/stat.h>
4655#include <fcntl.h>
4656#define DATA "conftest.stdpath"
Tim Rice648f8762011-01-26 12:38:57 -08004657 ]], [[
Tim Rice59ea0a02001-03-10 13:50:45 -08004658 FILE *fd;
4659 int rc;
Tim Riceeae17cc2005-03-17 16:52:20 -08004660
Tim Rice59ea0a02001-03-10 13:50:45 -08004661 fd = fopen(DATA,"w");
4662 if(fd == NULL)
4663 exit(1);
Tim Riceeae17cc2005-03-17 16:52:20 -08004664
Tim Rice59ea0a02001-03-10 13:50:45 -08004665 if ((rc = fprintf(fd,"%s", _PATH_STDPATH)) < 0)
4666 exit(1);
4667
4668 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10004669 ]])],
4670 [ user_path=`cat conftest.stdpath` ],
Tim Rice59ea0a02001-03-10 13:50:45 -08004671 [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ],
4672 [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ]
4673 )
4674# make sure $bindir is in USER_PATH so scp will work
Damien Miller77eab7b2012-07-06 11:49:28 +10004675 t_bindir="${bindir}"
4676 while echo "${t_bindir}" | egrep '\$\{|NONE/' >/dev/null 2>&1; do
4677 t_bindir=`eval echo ${t_bindir}`
4678 case $t_bindir in
4679 NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$prefix~"` ;;
4680 esac
4681 case $t_bindir in
4682 NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$ac_default_prefix~"` ;;
4683 esac
4684 done
Tim Rice59ea0a02001-03-10 13:50:45 -08004685 echo $user_path | grep ":$t_bindir" > /dev/null 2>&1
4686 if test $? -ne 0 ; then
4687 echo $user_path | grep "^$t_bindir" > /dev/null 2>&1
4688 if test $? -ne 0 ; then
4689 user_path=$user_path:$t_bindir
Tim Rice648f8762011-01-26 12:38:57 -08004690 AC_MSG_RESULT([Adding $t_bindir to USER_PATH so scp will work])
Tim Rice59ea0a02001-03-10 13:50:45 -08004691 fi
4692 fi
Tim Rice43a1c132002-04-17 21:19:14 -07004693 fi ]
Damien Miller5a3e6831999-12-27 09:48:56 +11004694)
Darren Tuckere1a790d2003-09-16 11:52:19 +10004695if test "x$external_path_file" != "x/etc/login.conf" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004696 AC_DEFINE_UNQUOTED([USER_PATH], ["$user_path"], [Specify default $PATH])
4697 AC_SUBST([user_path])
Tim Rice43a1c132002-04-17 21:19:14 -07004698fi
Damien Miller5a3e6831999-12-27 09:48:56 +11004699
Damien Millera18bbd32002-05-13 10:48:57 +10004700# Set superuser path separately to user path
Tim Rice648f8762011-01-26 12:38:57 -08004701AC_ARG_WITH([superuser-path],
Damien Millera18bbd32002-05-13 10:48:57 +10004702 [ --with-superuser-path= Specify different path for super-user],
4703 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004704 if test -n "$withval" && test "x$withval" != "xno" && \
4705 test "x${withval}" != "xyes"; then
Tim Rice648f8762011-01-26 12:38:57 -08004706 AC_DEFINE_UNQUOTED([SUPERUSER_PATH], ["$withval"],
Tim Rice7df8d392005-09-19 09:33:39 -07004707 [Define if you want a different $PATH
4708 for the superuser])
Damien Millera18bbd32002-05-13 10:48:57 +10004709 superuser_path=$withval
4710 fi
4711 ]
4712)
4713
4714
Damien Miller61e50f12000-05-08 20:49:37 +10004715AC_MSG_CHECKING([if we need to convert IPv4 in IPv6-mapped addresses])
Damien Millera8e06ce2003-11-21 23:48:55 +11004716IPV4_IN6_HACK_MSG="no"
Damien Miller7bcb0892000-03-11 20:45:40 +11004717AC_ARG_WITH(4in6,
4718 [ --with-4in6 Check for and convert IPv4 in IPv6 mapped addresses],
4719 [
4720 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004721 AC_MSG_RESULT([yes])
4722 AC_DEFINE([IPV4_IN_IPV6], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004723 [Detect IPv4 in IPv6 mapped addresses
4724 and treat as IPv4])
Damien Millera8e06ce2003-11-21 23:48:55 +11004725 IPV4_IN6_HACK_MSG="yes"
Damien Miller7bcb0892000-03-11 20:45:40 +11004726 else
Tim Rice648f8762011-01-26 12:38:57 -08004727 AC_MSG_RESULT([no])
Damien Miller7bcb0892000-03-11 20:45:40 +11004728 fi
Tim Rice648f8762011-01-26 12:38:57 -08004729 ], [
Damien Miller7bcb0892000-03-11 20:45:40 +11004730 if test "x$inet6_default_4in6" = "xyes"; then
4731 AC_MSG_RESULT([yes (default)])
Tim Rice648f8762011-01-26 12:38:57 -08004732 AC_DEFINE([IPV4_IN_IPV6])
Damien Millera8e06ce2003-11-21 23:48:55 +11004733 IPV4_IN6_HACK_MSG="yes"
Damien Miller7bcb0892000-03-11 20:45:40 +11004734 else
4735 AC_MSG_RESULT([no (default)])
4736 fi
4737 ]
4738)
4739
Damien Miller60396b02001-02-18 17:01:00 +11004740# Whether to enable BSD auth support
Damien Miller6c21c512002-01-22 21:57:53 +11004741BSD_AUTH_MSG=no
Tim Rice648f8762011-01-26 12:38:57 -08004742AC_ARG_WITH([bsd-auth],
Damien Miller60396b02001-02-18 17:01:00 +11004743 [ --with-bsd-auth Enable BSD auth support],
4744 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004745 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004746 AC_DEFINE([BSD_AUTH], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004747 [Define if you have BSD auth support])
Damien Miller6c21c512002-01-22 21:57:53 +11004748 BSD_AUTH_MSG=yes
Damien Miller60396b02001-02-18 17:01:00 +11004749 fi
4750 ]
4751)
4752
Damien Millera22ba012000-03-02 23:09:20 +11004753# Where to place sshd.pid
Damien Millerb13c73e2000-01-17 22:02:17 +11004754piddir=/var/run
Damien Miller78315eb2000-09-29 23:01:36 +11004755# make sure the directory exists
Tim Riceeae17cc2005-03-17 16:52:20 -08004756if test ! -d $piddir ; then
Damien Miller78315eb2000-09-29 23:01:36 +11004757 piddir=`eval echo ${sysconfdir}`
4758 case $piddir in
Damien Millera8e06ce2003-11-21 23:48:55 +11004759 NONE/*) piddir=`echo $piddir | sed "s~NONE~$ac_default_prefix~"` ;;
Damien Miller78315eb2000-09-29 23:01:36 +11004760 esac
4761fi
4762
Tim Rice648f8762011-01-26 12:38:57 -08004763AC_ARG_WITH([pid-dir],
Tim Rice88f2ab52002-03-17 12:17:34 -08004764 [ --with-pid-dir=PATH Specify location of ssh.pid file],
4765 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004766 if test -n "$withval" && test "x$withval" != "xno" && \
4767 test "x${withval}" != "xyes"; then
Tim Rice88f2ab52002-03-17 12:17:34 -08004768 piddir=$withval
Tim Riceeae17cc2005-03-17 16:52:20 -08004769 if test ! -d $piddir ; then
Tim Rice88f2ab52002-03-17 12:17:34 -08004770 AC_MSG_WARN([** no $piddir directory on this system **])
4771 fi
4772 fi
4773 ]
4774)
4775
Tim Ricee1d93702016-05-31 11:13:22 -07004776AC_DEFINE_UNQUOTED([_PATH_SSH_PIDDIR], ["$piddir"],
Tim Rice648f8762011-01-26 12:38:57 -08004777 [Specify location of ssh.pid])
4778AC_SUBST([piddir])
Damien Miller5eed6a22000-01-16 12:05:18 +11004779
andre2ff7b5d2000-06-03 14:57:40 +00004780dnl allow user to disable some login recording features
Tim Rice648f8762011-01-26 12:38:57 -08004781AC_ARG_ENABLE([lastlog],
andre43ca7e22000-06-19 08:23:46 +00004782 [ --disable-lastlog disable use of lastlog even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004783 [
4784 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004785 AC_DEFINE([DISABLE_LASTLOG])
Darren Tuckera3020db2003-06-28 12:54:33 +10004786 fi
4787 ]
andre2ff7b5d2000-06-03 14:57:40 +00004788)
Tim Rice648f8762011-01-26 12:38:57 -08004789AC_ARG_ENABLE([utmp],
andre43ca7e22000-06-19 08:23:46 +00004790 [ --disable-utmp disable use of utmp even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004791 [
4792 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004793 AC_DEFINE([DISABLE_UTMP])
Darren Tuckera3020db2003-06-28 12:54:33 +10004794 fi
4795 ]
andre2ff7b5d2000-06-03 14:57:40 +00004796)
Tim Rice648f8762011-01-26 12:38:57 -08004797AC_ARG_ENABLE([utmpx],
andre43ca7e22000-06-19 08:23:46 +00004798 [ --disable-utmpx disable use of utmpx even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004799 [
4800 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004801 AC_DEFINE([DISABLE_UTMPX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004802 [Define if you don't want to use utmpx])
Darren Tuckera3020db2003-06-28 12:54:33 +10004803 fi
4804 ]
andre2ff7b5d2000-06-03 14:57:40 +00004805)
Tim Rice648f8762011-01-26 12:38:57 -08004806AC_ARG_ENABLE([wtmp],
andre43ca7e22000-06-19 08:23:46 +00004807 [ --disable-wtmp disable use of wtmp even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004808 [
4809 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004810 AC_DEFINE([DISABLE_WTMP])
Darren Tuckera3020db2003-06-28 12:54:33 +10004811 fi
4812 ]
andre2ff7b5d2000-06-03 14:57:40 +00004813)
Tim Rice648f8762011-01-26 12:38:57 -08004814AC_ARG_ENABLE([wtmpx],
andre43ca7e22000-06-19 08:23:46 +00004815 [ --disable-wtmpx disable use of wtmpx even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004816 [
4817 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004818 AC_DEFINE([DISABLE_WTMPX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004819 [Define if you don't want to use wtmpx])
Darren Tuckera3020db2003-06-28 12:54:33 +10004820 fi
4821 ]
andre2ff7b5d2000-06-03 14:57:40 +00004822)
Tim Rice648f8762011-01-26 12:38:57 -08004823AC_ARG_ENABLE([libutil],
andre43ca7e22000-06-19 08:23:46 +00004824 [ --disable-libutil disable use of libutil (login() etc.) [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004825 [
4826 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004827 AC_DEFINE([DISABLE_LOGIN])
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_ENABLE([pututline],
andre43ca7e22000-06-19 08:23:46 +00004832 [ --disable-pututline disable use of pututline() etc. ([uw]tmp) [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004833 [
4834 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004835 AC_DEFINE([DISABLE_PUTUTLINE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004836 [Define if you don't want to use pututline()
4837 etc. to write [uw]tmp])
Darren Tuckera3020db2003-06-28 12:54:33 +10004838 fi
4839 ]
andre2ff7b5d2000-06-03 14:57:40 +00004840)
Tim Rice648f8762011-01-26 12:38:57 -08004841AC_ARG_ENABLE([pututxline],
andre43ca7e22000-06-19 08:23:46 +00004842 [ --disable-pututxline disable use of pututxline() etc. ([uw]tmpx) [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004843 [
4844 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004845 AC_DEFINE([DISABLE_PUTUTXLINE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004846 [Define if you don't want to use pututxline()
4847 etc. to write [uw]tmpx])
Darren Tuckera3020db2003-06-28 12:54:33 +10004848 fi
4849 ]
andre2ff7b5d2000-06-03 14:57:40 +00004850)
Tim Rice648f8762011-01-26 12:38:57 -08004851AC_ARG_WITH([lastlog],
andre43ca7e22000-06-19 08:23:46 +00004852 [ --with-lastlog=FILE|DIR specify lastlog location [common locations]],
Damien Miller709528a2001-01-31 09:57:55 +11004853 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004854 if test "x$withval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004855 AC_DEFINE([DISABLE_LASTLOG])
Tim Rice35cc69d2005-03-17 16:44:25 -08004856 elif test -n "$withval" && test "x${withval}" != "xyes"; then
Damien Miller709528a2001-01-31 09:57:55 +11004857 conf_lastlog_location=$withval
4858 fi
4859 ]
4860)
andre2ff7b5d2000-06-03 14:57:40 +00004861
4862dnl lastlog, [uw]tmpx? detection
4863dnl NOTE: set the paths in the platform section to avoid the
4864dnl need for command-line parameters
4865dnl lastlog and [uw]tmp are subject to a file search if all else fails
4866
4867dnl lastlog detection
4868dnl NOTE: the code itself will detect if lastlog is a directory
4869AC_MSG_CHECKING([if your system defines LASTLOG_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08004870AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00004871#include <sys/types.h>
4872#include <utmp.h>
4873#ifdef HAVE_LASTLOG_H
4874# include <lastlog.h>
4875#endif
Damien Miller2994e082000-06-04 15:51:47 +10004876#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00004877# include <paths.h>
4878#endif
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00004879#ifdef HAVE_LOGIN_H
4880# include <login.h>
4881#endif
Tim Rice648f8762011-01-26 12:38:57 -08004882 ]], [[ char *lastlog = LASTLOG_FILE; ]])],
4883 [ AC_MSG_RESULT([yes]) ],
4884 [
4885 AC_MSG_RESULT([no])
Damien Miller2994e082000-06-04 15:51:47 +10004886 AC_MSG_CHECKING([if your system defines _PATH_LASTLOG])
Tim Rice648f8762011-01-26 12:38:57 -08004887 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller2994e082000-06-04 15:51:47 +10004888#include <sys/types.h>
4889#include <utmp.h>
4890#ifdef HAVE_LASTLOG_H
4891# include <lastlog.h>
4892#endif
4893#ifdef HAVE_PATHS_H
4894# include <paths.h>
4895#endif
Tim Rice648f8762011-01-26 12:38:57 -08004896 ]], [[ char *lastlog = _PATH_LASTLOG; ]])],
4897 [ AC_MSG_RESULT([yes]) ],
Damien Miller2994e082000-06-04 15:51:47 +10004898 [
Tim Rice648f8762011-01-26 12:38:57 -08004899 AC_MSG_RESULT([no])
Damien Miller2994e082000-06-04 15:51:47 +10004900 system_lastlog_path=no
4901 ])
Tim Rice648f8762011-01-26 12:38:57 -08004902])
Damien Miller2994e082000-06-04 15:51:47 +10004903
andre2ff7b5d2000-06-03 14:57:40 +00004904if test -z "$conf_lastlog_location"; then
4905 if test x"$system_lastlog_path" = x"no" ; then
4906 for f in /var/log/lastlog /usr/adm/lastlog /var/adm/lastlog /etc/security/lastlog ; do
Damien Milleredb82922000-06-20 13:25:52 +10004907 if (test -d "$f" || test -f "$f") ; then
andre2ff7b5d2000-06-03 14:57:40 +00004908 conf_lastlog_location=$f
4909 fi
4910 done
4911 if test -z "$conf_lastlog_location"; then
andre45cad512000-06-12 23:27:31 +00004912 AC_MSG_WARN([** Cannot find lastlog **])
4913 dnl Don't define DISABLE_LASTLOG - that means we don't try wtmp/wtmpx
andre2ff7b5d2000-06-03 14:57:40 +00004914 fi
4915 fi
4916fi
4917
4918if test -n "$conf_lastlog_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08004919 AC_DEFINE_UNQUOTED([CONF_LASTLOG_FILE], ["$conf_lastlog_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07004920 [Define if you want to specify the path to your lastlog file])
Tim Riceeae17cc2005-03-17 16:52:20 -08004921fi
andre2ff7b5d2000-06-03 14:57:40 +00004922
4923dnl utmp detection
4924AC_MSG_CHECKING([if your system defines UTMP_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08004925AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00004926#include <sys/types.h>
4927#include <utmp.h>
Damien Miller2994e082000-06-04 15:51:47 +10004928#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00004929# include <paths.h>
4930#endif
Tim Rice648f8762011-01-26 12:38:57 -08004931 ]], [[ char *utmp = UTMP_FILE; ]])],
4932 [ AC_MSG_RESULT([yes]) ],
4933 [ AC_MSG_RESULT([no])
Tim Ricee1d93702016-05-31 11:13:22 -07004934 system_utmp_path=no
Tim Rice648f8762011-01-26 12:38:57 -08004935])
andre2ff7b5d2000-06-03 14:57:40 +00004936if test -z "$conf_utmp_location"; then
4937 if test x"$system_utmp_path" = x"no" ; then
4938 for f in /etc/utmp /usr/adm/utmp /var/run/utmp; do
4939 if test -f $f ; then
4940 conf_utmp_location=$f
4941 fi
4942 done
4943 if test -z "$conf_utmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08004944 AC_DEFINE([DISABLE_UTMP])
andre2ff7b5d2000-06-03 14:57:40 +00004945 fi
4946 fi
4947fi
4948if test -n "$conf_utmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08004949 AC_DEFINE_UNQUOTED([CONF_UTMP_FILE], ["$conf_utmp_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07004950 [Define if you want to specify the path to your utmp file])
Tim Riceeae17cc2005-03-17 16:52:20 -08004951fi
andre2ff7b5d2000-06-03 14:57:40 +00004952
4953dnl wtmp detection
4954AC_MSG_CHECKING([if your system defines WTMP_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08004955AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00004956#include <sys/types.h>
4957#include <utmp.h>
Damien Miller2994e082000-06-04 15:51:47 +10004958#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00004959# include <paths.h>
4960#endif
Tim Rice648f8762011-01-26 12:38:57 -08004961 ]], [[ char *wtmp = WTMP_FILE; ]])],
4962 [ AC_MSG_RESULT([yes]) ],
4963 [ AC_MSG_RESULT([no])
Tim Ricee1d93702016-05-31 11:13:22 -07004964 system_wtmp_path=no
Tim Rice648f8762011-01-26 12:38:57 -08004965])
andre2ff7b5d2000-06-03 14:57:40 +00004966if test -z "$conf_wtmp_location"; then
4967 if test x"$system_wtmp_path" = x"no" ; then
4968 for f in /usr/adm/wtmp /var/log/wtmp; do
4969 if test -f $f ; then
4970 conf_wtmp_location=$f
4971 fi
4972 done
4973 if test -z "$conf_wtmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08004974 AC_DEFINE([DISABLE_WTMP])
andre2ff7b5d2000-06-03 14:57:40 +00004975 fi
4976 fi
4977fi
4978if test -n "$conf_wtmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08004979 AC_DEFINE_UNQUOTED([CONF_WTMP_FILE], ["$conf_wtmp_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07004980 [Define if you want to specify the path to your wtmp file])
Tim Riceeae17cc2005-03-17 16:52:20 -08004981fi
andre2ff7b5d2000-06-03 14:57:40 +00004982
andre2ff7b5d2000-06-03 14:57:40 +00004983dnl wtmpx detection
4984AC_MSG_CHECKING([if your system defines WTMPX_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08004985AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00004986#include <sys/types.h>
4987#include <utmp.h>
4988#ifdef HAVE_UTMPX_H
4989#include <utmpx.h>
4990#endif
Damien Miller2994e082000-06-04 15:51:47 +10004991#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00004992# include <paths.h>
4993#endif
Tim Rice648f8762011-01-26 12:38:57 -08004994 ]], [[ char *wtmpx = WTMPX_FILE; ]])],
4995 [ AC_MSG_RESULT([yes]) ],
4996 [ AC_MSG_RESULT([no])
Tim Ricee1d93702016-05-31 11:13:22 -07004997 system_wtmpx_path=no
Tim Rice648f8762011-01-26 12:38:57 -08004998])
andre2ff7b5d2000-06-03 14:57:40 +00004999if test -z "$conf_wtmpx_location"; then
5000 if test x"$system_wtmpx_path" = x"no" ; then
Tim Rice648f8762011-01-26 12:38:57 -08005001 AC_DEFINE([DISABLE_WTMPX])
andre2ff7b5d2000-06-03 14:57:40 +00005002 fi
5003else
Tim Rice648f8762011-01-26 12:38:57 -08005004 AC_DEFINE_UNQUOTED([CONF_WTMPX_FILE], ["$conf_wtmpx_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07005005 [Define if you want to specify the path to your wtmpx file])
Tim Riceeae17cc2005-03-17 16:52:20 -08005006fi
andre2ff7b5d2000-06-03 14:57:40 +00005007
Damien Miller4018c192000-04-30 09:30:44 +10005008
Damien Miller29ea30d2000-03-17 10:54:15 +11005009if test ! -z "$blibpath" ; then
Damien Millereab4bae2003-04-29 23:22:40 +10005010 LDFLAGS="$LDFLAGS $blibflags$blibpath"
5011 AC_MSG_WARN([Please check and edit blibpath in LDFLAGS in Makefile])
Damien Miller29ea30d2000-03-17 10:54:15 +11005012fi
5013
Damien Millera2438bb2013-03-15 10:23:07 +11005014AC_CHECK_MEMBER([struct lastlog.ll_line], [], [
Tim Riceaa86c392013-03-16 20:55:46 -07005015 if test x$SKIP_DISABLE_LASTLOG_DEFINE != "xyes" ; then
Damien Millera2438bb2013-03-15 10:23:07 +11005016 AC_DEFINE([DISABLE_LASTLOG])
Tim Riceaa86c392013-03-16 20:55:46 -07005017 fi
Damien Millera2438bb2013-03-15 10:23:07 +11005018 ], [
5019#ifdef HAVE_SYS_TYPES_H
5020#include <sys/types.h>
5021#endif
5022#ifdef HAVE_UTMP_H
5023#include <utmp.h>
5024#endif
5025#ifdef HAVE_UTMPX_H
5026#include <utmpx.h>
5027#endif
5028#ifdef HAVE_LASTLOG_H
5029#include <lastlog.h>
5030#endif
5031 ])
5032
5033AC_CHECK_MEMBER([struct utmp.ut_line], [], [
5034 AC_DEFINE([DISABLE_UTMP])
5035 AC_DEFINE([DISABLE_WTMP])
5036 ], [
5037#ifdef HAVE_SYS_TYPES_H
5038#include <sys/types.h>
5039#endif
5040#ifdef HAVE_UTMP_H
5041#include <utmp.h>
5042#endif
5043#ifdef HAVE_UTMPX_H
5044#include <utmpx.h>
5045#endif
5046#ifdef HAVE_LASTLOG_H
5047#include <lastlog.h>
5048#endif
5049 ])
5050
Darren Tucker7da23cb2005-08-03 00:20:15 +10005051dnl Adding -Werror to CFLAGS early prevents configure tests from running.
5052dnl Add now.
5053CFLAGS="$CFLAGS $werror_flags"
5054
Darren Tucker627337d2010-04-10 22:58:01 +10005055if test "x$ac_cv_func_getaddrinfo" != "xyes" ; then
5056 TEST_SSH_IPV6=no
5057else
5058 TEST_SSH_IPV6=yes
5059fi
Tim Rice648f8762011-01-26 12:38:57 -08005060AC_CHECK_DECL([BROKEN_GETADDRINFO], [TEST_SSH_IPV6=no])
5061AC_SUBST([TEST_SSH_IPV6], [$TEST_SSH_IPV6])
Darren Tucker47b8c992016-12-08 15:48:34 +11005062AC_SUBST([TEST_SSH_UTF8], [$TEST_SSH_UTF8])
Darren Tucker882abfd2013-11-09 00:17:41 +11005063AC_SUBST([TEST_MALLOC_OPTIONS], [$TEST_MALLOC_OPTIONS])
Darren Tucker6d8bd572013-06-11 11:26:10 +10005064AC_SUBST([UNSUPPORTED_ALGORITHMS], [$unsupported_algorithms])
Darren Tucker5d376902008-06-11 04:15:05 +10005065
Damien Millerde35c382017-09-08 12:38:31 +10005066CFLAGS="${CFLAGS} ${CFLAGS_AFTER}"
5067LDFLAGS="${LDFLAGS} ${LDFLAGS_AFTER}"
5068
Damien Millerbac2d8a2000-09-05 16:13:06 +11005069AC_EXEEXT
Damien Miller223897a2006-09-12 21:54:10 +10005070AC_CONFIG_FILES([Makefile buildpkg.sh opensshd.init openssh.xml \
5071 openbsd-compat/Makefile openbsd-compat/regress/Makefile \
Damien Millerf22019b2011-05-05 13:48:37 +10005072 survey.sh])
Tim Rice13aae5e2001-10-21 17:53:58 -07005073AC_OUTPUT
Damien Miller0437b332000-05-02 09:56:41 +10005074
Damien Miller7b22d652000-06-18 14:07:04 +10005075# Print summary of options
5076
Damien Miller7b22d652000-06-18 14:07:04 +10005077# Someone please show me a better way :)
5078A=`eval echo ${prefix}` ; A=`eval echo ${A}`
5079B=`eval echo ${bindir}` ; B=`eval echo ${B}`
5080C=`eval echo ${sbindir}` ; C=`eval echo ${C}`
5081D=`eval echo ${sysconfdir}` ; D=`eval echo ${D}`
Kevin Stevese0f49142000-10-14 17:51:48 +00005082E=`eval echo ${libexecdir}/ssh-askpass` ; E=`eval echo ${E}`
Ben Lindstrombc709922001-04-18 18:04:21 +00005083F=`eval echo ${mandir}/${mansubdir}X` ; F=`eval echo ${F}`
Damien Miller7b22d652000-06-18 14:07:04 +10005084G=`eval echo ${piddir}` ; G=`eval echo ${G}`
Damien Millerf58c6722002-05-13 13:15:42 +10005085H=`eval echo ${PRIVSEP_PATH}` ; H=`eval echo ${H}`
5086I=`eval echo ${user_path}` ; I=`eval echo ${I}`
5087J=`eval echo ${superuser_path}` ; J=`eval echo ${J}`
Damien Miller7b22d652000-06-18 14:07:04 +10005088
5089echo ""
Kevin Steves393d2f72001-04-08 22:50:43 +00005090echo "OpenSSH has been configured with the following options:"
Damien Millerf58c6722002-05-13 13:15:42 +10005091echo " User binaries: $B"
5092echo " System binaries: $C"
5093echo " Configuration files: $D"
5094echo " Askpass program: $E"
5095echo " Manual pages: $F"
5096echo " PID file: $G"
5097echo " Privilege separation chroot path: $H"
Darren Tuckere1a790d2003-09-16 11:52:19 +10005098if test "x$external_path_file" = "x/etc/login.conf" ; then
5099echo " At runtime, sshd will use the path defined in $external_path_file"
5100echo " Make sure the path to scp is present, otherwise scp will not work"
Tim Rice43a1c132002-04-17 21:19:14 -07005101else
Damien Millerf58c6722002-05-13 13:15:42 +10005102echo " sshd default user PATH: $I"
Tim Riceb925b4b2003-09-15 22:40:49 -07005103 if test ! -z "$external_path_file"; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10005104echo " (If PATH is set in $external_path_file it will be used instead. If"
5105echo " used, ensure the path to scp is present, otherwise scp will not work.)"
5106 fi
Tim Rice43a1c132002-04-17 21:19:14 -07005107fi
Damien Millera18bbd32002-05-13 10:48:57 +10005108if test ! -z "$superuser_path" ; then
Damien Millerf58c6722002-05-13 13:15:42 +10005109echo " sshd superuser user PATH: $J"
Damien Millera18bbd32002-05-13 10:48:57 +10005110fi
Damien Millerf58c6722002-05-13 13:15:42 +10005111echo " Manpage format: $MANTYPE"
Damien Miller7abe09b2003-05-15 10:53:49 +10005112echo " PAM support: $PAM_MSG"
Damien Miller1b06dc32006-08-31 03:24:41 +10005113echo " OSF SIA support: $SIA_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10005114echo " KerberosV support: $KRB5_MSG"
Damien Miller73b42d22006-04-22 21:26:08 +10005115echo " SELinux support: $SELINUX_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10005116echo " Smartcard support: $SCARD_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10005117echo " S/KEY support: $SKEY_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10005118echo " MD5 password support: $MD5_MSG"
Darren Tucker16bcc1c2004-11-07 20:14:34 +11005119echo " libedit support: $LIBEDIT_MSG"
Damien Miller523db852017-02-03 16:01:22 +11005120echo " libldns support: $LDNS_MSG"
Damien Miller1b06dc32006-08-31 03:24:41 +10005121echo " Solaris process contract support: $SPC_MSG"
Darren Tucker97528352010-11-05 12:03:05 +11005122echo " Solaris project support: $SP_MSG"
Damien Miller4626cba2016-01-08 14:24:56 +11005123echo " Solaris privilege support: $SPP_MSG"
Damien Miller903e1152002-05-13 14:41:31 +10005124echo " IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10005125echo " Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG"
5126echo " BSD Auth support: $BSD_AUTH_MSG"
5127echo " Random number source: $RAND_MSG"
Damien Miller69ff1df2011-06-23 08:30:03 +10005128echo " Privsep sandbox style: $SANDBOX_STYLE"
Damien Miller60396b02001-02-18 17:01:00 +11005129
Damien Miller7b22d652000-06-18 14:07:04 +10005130echo ""
5131
Ben Lindstrom28bfc0d2000-12-18 19:58:57 +00005132echo " Host: ${host}"
5133echo " Compiler: ${CC}"
5134echo " Compiler flags: ${CFLAGS}"
5135echo "Preprocessor flags: ${CPPFLAGS}"
5136echo " Linker flags: ${LDFLAGS}"
Darren Tucker20e9f972007-03-25 18:26:01 +10005137echo " Libraries: ${LIBS}"
5138if test ! -z "${SSHDLIBS}"; then
5139echo " +for sshd: ${SSHDLIBS}"
5140fi
Damien Miller71adf122011-01-25 12:16:15 +11005141if test ! -z "${SSHLIBS}"; then
5142echo " +for ssh: ${SSHLIBS}"
5143fi
Damien Miller7b22d652000-06-18 14:07:04 +10005144
5145echo ""
5146
Tim Rice6f1f7582004-05-30 21:38:51 -07005147if test "x$MAKE_PACKAGE_SUPPORTED" = "xyes" ; then
Darren Tuckercf59d312004-08-29 21:18:09 +10005148 echo "SVR4 style packages are supported with \"make package\""
5149 echo ""
Tim Rice6f1f7582004-05-30 21:38:51 -07005150fi
5151
Damien Miller82cf0ce2000-12-20 13:34:48 +11005152if test "x$PAM_MSG" = "xyes" ; then
Damien Miller6c21c512002-01-22 21:57:53 +11005153 echo "PAM is enabled. You may need to install a PAM control file "
5154 echo "for sshd, otherwise password authentication may fail. "
Damien Millera8e06ce2003-11-21 23:48:55 +11005155 echo "Example PAM control files can be found in the contrib/ "
Damien Miller6c21c512002-01-22 21:57:53 +11005156 echo "subdirectory"
Damien Miller6f9c3372000-10-25 10:06:04 +11005157 echo ""
5158fi
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00005159
Damien Millerb4097182004-05-23 14:09:40 +10005160if test ! -z "$NO_PEERCHECK" ; then
Darren Tucker164aa302007-03-21 21:39:57 +11005161 echo "WARNING: the operating system that you are using does not"
5162 echo "appear to support getpeereid(), getpeerucred() or the"
5163 echo "SO_PEERCRED getsockopt() option. These facilities are used to"
5164 echo "enforce security checks to prevent unauthorised connections to"
5165 echo "ssh-agent. Their absence increases the risk that a malicious"
5166 echo "user can connect to your agent."
Damien Millerb4097182004-05-23 14:09:40 +10005167 echo ""
5168fi
5169
Darren Tuckerd9f88912005-02-20 21:01:48 +11005170if test "$AUDIT_MODULE" = "bsm" ; then
5171 echo "WARNING: BSM audit support is currently considered EXPERIMENTAL."
5172 echo "See the Solaris section in README.platform for details."
5173fi