blob: c14f484b04c7113cdd5883bd1282151c9a073a1f [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 Tucker6c8a2462017-12-01 17:11:47 +110033AC_PROG_MKDIR_P
Darren Tucker408f4c22015-04-17 09:39:58 +100034AC_CHECK_TOOLS([AR], [ar])
Tim Rice648f8762011-01-26 12:38:57 -080035AC_PATH_PROG([CAT], [cat])
36AC_PATH_PROG([KILL], [kill])
Tim Rice648f8762011-01-26 12:38:57 -080037AC_PATH_PROG([SED], [sed])
Tim Rice648f8762011-01-26 12:38:57 -080038AC_PATH_PROG([ENT], [ent])
39AC_SUBST([ENT])
40AC_PATH_PROG([TEST_MINUS_S_SH], [bash])
41AC_PATH_PROG([TEST_MINUS_S_SH], [ksh])
42AC_PATH_PROG([TEST_MINUS_S_SH], [sh])
43AC_PATH_PROG([SH], [sh])
44AC_PATH_PROG([GROFF], [groff])
45AC_PATH_PROG([NROFF], [nroff])
46AC_PATH_PROG([MANDOC], [mandoc])
47AC_SUBST([TEST_SHELL], [sh])
Damien Miller2e1b0821999-12-25 10:11:29 +110048
Damien Miller30a69e72011-01-04 08:16:27 +110049dnl select manpage formatter
50if test "x$MANDOC" != "x" ; then
51 MANFMT="$MANDOC"
52elif test "x$NROFF" != "x" ; then
53 MANFMT="$NROFF -mandoc"
54elif test "x$GROFF" != "x" ; then
55 MANFMT="$GROFF -mandoc -Tascii"
56else
57 AC_MSG_WARN([no manpage formatted found])
58 MANFMT="false"
59fi
Tim Rice648f8762011-01-26 12:38:57 -080060AC_SUBST([MANFMT])
Damien Miller30a69e72011-01-04 08:16:27 +110061
Tim Rice6f1f7582004-05-30 21:38:51 -070062dnl for buildpkg.sh
Tim Rice648f8762011-01-26 12:38:57 -080063AC_PATH_PROG([PATH_GROUPADD_PROG], [groupadd], [groupadd],
Tim Rice6f1f7582004-05-30 21:38:51 -070064 [/usr/sbin${PATH_SEPARATOR}/etc])
Tim Rice648f8762011-01-26 12:38:57 -080065AC_PATH_PROG([PATH_USERADD_PROG], [useradd], [useradd],
Tim Rice6f1f7582004-05-30 21:38:51 -070066 [/usr/sbin${PATH_SEPARATOR}/etc])
Tim Rice648f8762011-01-26 12:38:57 -080067AC_CHECK_PROG([MAKE_PACKAGE_SUPPORTED], [pkgmk], [yes], [no])
Darren Tuckerfbea7642006-01-30 00:22:39 +110068if test -x /sbin/sh; then
Tim Rice648f8762011-01-26 12:38:57 -080069 AC_SUBST([STARTUP_SCRIPT_SHELL], [/sbin/sh])
Darren Tuckerfbea7642006-01-30 00:22:39 +110070else
Tim Rice648f8762011-01-26 12:38:57 -080071 AC_SUBST([STARTUP_SCRIPT_SHELL], [/bin/sh])
Darren Tuckerfbea7642006-01-30 00:22:39 +110072fi
Tim Rice6f1f7582004-05-30 21:38:51 -070073
Damien Millere8bb4502001-09-25 16:39:35 +100074# System features
75AC_SYS_LARGEFILE
76
Damien Miller3f62aba2000-11-29 11:56:35 +110077if test -z "$AR" ; then
78 AC_MSG_ERROR([*** 'ar' missing, please install or fix your \$PATH ***])
79fi
80
Tim Rice648f8762011-01-26 12:38:57 -080081AC_PATH_PROG([PATH_PASSWD_PROG], [passwd])
Darren Tucker23bc8d02004-02-06 16:24:31 +110082if test ! -z "$PATH_PASSWD_PROG" ; then
Tim Rice648f8762011-01-26 12:38:57 -080083 AC_DEFINE_UNQUOTED([_PATH_PASSWD_PROG], ["$PATH_PASSWD_PROG"],
Tim Rice7df8d392005-09-19 09:33:39 -070084 [Full path of your "passwd" program])
Darren Tucker23bc8d02004-02-06 16:24:31 +110085fi
86
Damien Miller166bd442000-03-16 10:48:25 +110087if test -z "$LD" ; then
88 LD=$CC
89fi
Tim Rice648f8762011-01-26 12:38:57 -080090AC_SUBST([LD])
Tim Riceeae17cc2005-03-17 16:52:20 -080091
Damien Miller166bd442000-03-16 10:48:25 +110092AC_C_INLINE
Darren Tucker67b37032005-06-03 17:58:31 +100093
Tim Rice648f8762011-01-26 12:38:57 -080094AC_CHECK_DECL([LLONG_MAX], [have_llong_max=1], , [#include <limits.h>])
Damien Miller69ff1df2011-06-23 08:30:03 +100095AC_CHECK_DECL([SYSTR_POLICY_KILL], [have_systr_policy_kill=1], , [
96 #include <sys/types.h>
97 #include <sys/param.h>
98 #include <dev/systrace.h>
99])
100AC_CHECK_DECL([RLIMIT_NPROC],
101 [AC_DEFINE([HAVE_RLIMIT_NPROC], [], [sys/resource.h has RLIMIT_NPROC])], , [
102 #include <sys/types.h>
103 #include <sys/resource.h>
104])
Damien Millere0956e32012-04-04 11:27:54 +1000105AC_CHECK_DECL([PR_SET_NO_NEW_PRIVS], [have_linux_no_new_privs=1], , [
106 #include <sys/types.h>
107 #include <linux/prctl.h>
108])
Damien Miller868ea1e2014-01-17 16:47:04 +1100109
Damien Miller72ef7c12015-01-15 02:21:31 +1100110openssl=yes
Damien Miller72ef7c12015-01-15 02:21:31 +1100111AC_ARG_WITH([openssl],
112 [ --without-openssl Disable use of OpenSSL; use only limited internal crypto **EXPERIMENTAL** ],
Damien Miller76c04802015-01-13 19:38:18 +1100113 [ if test "x$withval" = "xno" ; then
Damien Miller72ef7c12015-01-15 02:21:31 +1100114 openssl=no
Damien Miller76c04802015-01-13 19:38:18 +1100115 fi
116 ]
117)
Damien Miller72ef7c12015-01-15 02:21:31 +1100118AC_MSG_CHECKING([whether OpenSSL will be used for cryptography])
119if test "x$openssl" = "xyes" ; then
120 AC_MSG_RESULT([yes])
121 AC_DEFINE_UNQUOTED([WITH_OPENSSL], [1], [use libcrypto for cryptography])
122else
123 AC_MSG_RESULT([no])
124fi
125
Darren Tuckerb7918af2008-03-09 11:34:23 +1100126use_stack_protector=1
Darren Tuckerfd994372014-01-17 09:53:24 +1100127use_toolchain_hardening=1
Tim Rice648f8762011-01-26 12:38:57 -0800128AC_ARG_WITH([stackprotect],
Damien Millerda3155e2008-03-27 12:30:18 +1100129 [ --without-stackprotect Don't use compiler's stack protection], [
Darren Tuckerb7918af2008-03-09 11:34:23 +1100130 if test "x$withval" = "xno"; then
131 use_stack_protector=0
132 fi ])
Darren Tuckerfd994372014-01-17 09:53:24 +1100133AC_ARG_WITH([hardening],
134 [ --without-hardening Don't use toolchain hardening flags], [
135 if test "x$withval" = "xno"; then
Darren Tuckerfd994372014-01-17 09:53:24 +1100136 use_toolchain_hardening=0
137 fi ])
Darren Tuckerb7918af2008-03-09 11:34:23 +1100138
Darren Tuckerfd994372014-01-17 09:53:24 +1100139# We use -Werror for the tests only so that we catch warnings like "this is
140# on by default" for things like -fPIE.
141AC_MSG_CHECKING([if $CC supports -Werror])
142saved_CFLAGS="$CFLAGS"
143CFLAGS="$CFLAGS -Werror"
144AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int main(void) { return 0; }]])],
145 [ AC_MSG_RESULT([yes])
146 WERROR="-Werror"],
147 [ AC_MSG_RESULT([no])
148 WERROR="" ]
149)
150CFLAGS="$saved_CFLAGS"
Damien Miller134d02a2011-01-12 16:00:37 +1100151
Damien Millera8e06ce2003-11-21 23:48:55 +1100152if test "$GCC" = "yes" || test "$GCC" = "egcs"; then
Darren Tuckerd9048862017-03-31 11:04:43 +1100153 OSSH_CHECK_CFLAG_COMPILE([-pipe])
Darren Tuckerfd994372014-01-17 09:53:24 +1100154 OSSH_CHECK_CFLAG_COMPILE([-Qunused-arguments])
155 OSSH_CHECK_CFLAG_COMPILE([-Wunknown-warning-option])
Damien Millerb1763622011-05-20 11:45:25 +1000156 OSSH_CHECK_CFLAG_COMPILE([-Wall])
157 OSSH_CHECK_CFLAG_COMPILE([-Wpointer-arith])
158 OSSH_CHECK_CFLAG_COMPILE([-Wuninitialized])
159 OSSH_CHECK_CFLAG_COMPILE([-Wsign-compare])
160 OSSH_CHECK_CFLAG_COMPILE([-Wformat-security])
Darren Tuckerabbc7a72013-05-10 13:54:23 +1000161 OSSH_CHECK_CFLAG_COMPILE([-Wsizeof-pointer-memaccess])
Damien Millerb1763622011-05-20 11:45:25 +1000162 OSSH_CHECK_CFLAG_COMPILE([-Wpointer-sign], [-Wno-pointer-sign])
163 OSSH_CHECK_CFLAG_COMPILE([-Wunused-result], [-Wno-unused-result])
164 OSSH_CHECK_CFLAG_COMPILE([-fno-strict-aliasing])
Darren Tuckerfd994372014-01-17 09:53:24 +1100165 if test "x$use_toolchain_hardening" = "x1"; then
Damien Miller161af8f2017-09-19 10:18:56 +1000166 OSSH_CHECK_CFLAG_COMPILE([-D_FORTIFY_SOURCE=2])
Darren Tuckerfd994372014-01-17 09:53:24 +1100167 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,relro])
168 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,now])
169 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,noexecstack])
Damien Miller5c2ff5e2014-01-22 21:30:12 +1100170 # NB. -ftrapv expects certain support functions to be present in
171 # the compiler library (libgcc or similar) to detect integer operations
172 # that can overflow. We must check that the result of enabling it
173 # actually links. The test program compiled/linked includes a number
174 # of integer operations that should exercise this.
175 OSSH_CHECK_CFLAG_LINK([-ftrapv])
Darren Tuckerfd994372014-01-17 09:53:24 +1100176 fi
Tim Rice648f8762011-01-26 12:38:57 -0800177 AC_MSG_CHECKING([gcc version])
Darren Tucker3f9545e2005-11-12 15:20:52 +1100178 GCC_VER=`$CC -v 2>&1 | $AWK '/gcc version /{print $3}'`
Tim Rice3db1e3f2005-08-23 17:11:26 -0700179 case $GCC_VER in
Darren Tucker391de5c2007-04-29 14:49:21 +1000180 1.*) no_attrib_nonnull=1 ;;
181 2.8* | 2.9*)
Darren Tucker391de5c2007-04-29 14:49:21 +1000182 no_attrib_nonnull=1
183 ;;
184 2.*) no_attrib_nonnull=1 ;;
Darren Tuckerf0324352005-11-10 21:30:36 +1100185 *) ;;
Tim Rice3db1e3f2005-08-23 17:11:26 -0700186 esac
Tim Rice648f8762011-01-26 12:38:57 -0800187 AC_MSG_RESULT([$GCC_VER])
Damien Millerde3cb0a2005-05-26 20:48:25 +1000188
Tim Rice648f8762011-01-26 12:38:57 -0800189 AC_MSG_CHECKING([if $CC accepts -fno-builtin-memset])
Darren Tucker330c93f2008-06-16 02:27:48 +1000190 saved_CFLAGS="$CFLAGS"
191 CFLAGS="$CFLAGS -fno-builtin-memset"
Tim Rice648f8762011-01-26 12:38:57 -0800192 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <string.h> ]],
193 [[ char b[10]; memset(b, 0, sizeof(b)); ]])],
194 [ AC_MSG_RESULT([yes]) ],
195 [ AC_MSG_RESULT([no])
Darren Tucker330c93f2008-06-16 02:27:48 +1000196 CFLAGS="$saved_CFLAGS" ]
Tim Rice648f8762011-01-26 12:38:57 -0800197 )
Darren Tucker330c93f2008-06-16 02:27:48 +1000198
Darren Tuckerb7918af2008-03-09 11:34:23 +1100199 # -fstack-protector-all doesn't always work for some GCC versions
Darren Tuckerfe1cf972008-03-09 22:50:50 +1100200 # and/or platforms, so we test if we can. If it's not supported
Damien Miller7df2e402008-12-08 09:35:36 +1100201 # on a given platform gcc will emit a warning so we use -Werror.
Darren Tuckerb7918af2008-03-09 11:34:23 +1100202 if test "x$use_stack_protector" = "x1"; then
Darren Tuckerfd994372014-01-17 09:53:24 +1100203 for t in -fstack-protector-strong -fstack-protector-all \
204 -fstack-protector; do
Tim Rice648f8762011-01-26 12:38:57 -0800205 AC_MSG_CHECKING([if $CC supports $t])
Darren Tuckerb7918af2008-03-09 11:34:23 +1100206 saved_CFLAGS="$CFLAGS"
207 saved_LDFLAGS="$LDFLAGS"
Darren Tuckerfe1cf972008-03-09 22:50:50 +1100208 CFLAGS="$CFLAGS $t -Werror"
209 LDFLAGS="$LDFLAGS $t -Werror"
210 AC_LINK_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -0800211 [AC_LANG_PROGRAM([[ #include <stdio.h> ]],
212 [[
213 char x[256];
214 snprintf(x, sizeof(x), "XXX");
215 ]])],
216 [ AC_MSG_RESULT([yes])
Darren Tuckerfe1cf972008-03-09 22:50:50 +1100217 CFLAGS="$saved_CFLAGS $t"
218 LDFLAGS="$saved_LDFLAGS $t"
Tim Rice648f8762011-01-26 12:38:57 -0800219 AC_MSG_CHECKING([if $t works])
Darren Tuckerb7918af2008-03-09 11:34:23 +1100220 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -0800221 [AC_LANG_PROGRAM([[ #include <stdio.h> ]],
222 [[
223 char x[256];
224 snprintf(x, sizeof(x), "XXX");
225 ]])],
226 [ AC_MSG_RESULT([yes])
Darren Tuckerb7918af2008-03-09 11:34:23 +1100227 break ],
Tim Rice648f8762011-01-26 12:38:57 -0800228 [ AC_MSG_RESULT([no]) ],
Darren Tuckerb7918af2008-03-09 11:34:23 +1100229 [ AC_MSG_WARN([cross compiling: cannot test])
230 break ]
Darren Tuckerfe1cf972008-03-09 22:50:50 +1100231 )
Darren Tuckerb7918af2008-03-09 11:34:23 +1100232 ],
Tim Rice648f8762011-01-26 12:38:57 -0800233 [ AC_MSG_RESULT([no]) ]
Darren Tuckerb7918af2008-03-09 11:34:23 +1100234 )
235 CFLAGS="$saved_CFLAGS"
236 LDFLAGS="$saved_LDFLAGS"
237 done
238 fi
Darren Tucker319b3d92007-12-02 21:02:22 +1100239
Darren Tucker67b37032005-06-03 17:58:31 +1000240 if test -z "$have_llong_max"; then
241 # retry LLONG_MAX with -std=gnu99, needed on some Linuxes
242 unset ac_cv_have_decl_LLONG_MAX
243 saved_CFLAGS="$CFLAGS"
244 CFLAGS="$CFLAGS -std=gnu99"
Tim Rice648f8762011-01-26 12:38:57 -0800245 AC_CHECK_DECL([LLONG_MAX],
Darren Tucker67b37032005-06-03 17:58:31 +1000246 [have_llong_max=1],
247 [CFLAGS="$saved_CFLAGS"],
248 [#include <limits.h>]
249 )
250 fi
Damien Miller166bd442000-03-16 10:48:25 +1100251fi
252
Darren Tucker951b53b2013-02-08 11:50:09 +1100253AC_MSG_CHECKING([if compiler allows __attribute__ on return types])
254AC_COMPILE_IFELSE(
255 [AC_LANG_PROGRAM([[
256#include <stdlib.h>
257__attribute__((__unused__)) static void foo(void){return;}]],
258 [[ exit(0); ]])],
259 [ AC_MSG_RESULT([yes]) ],
260 [ AC_MSG_RESULT([no])
261 AC_DEFINE(NO_ATTRIBUTE_ON_RETURN_TYPE, 1,
262 [compiler does not accept __attribute__ on return types]) ]
263)
264
Darren Tucker391de5c2007-04-29 14:49:21 +1000265if test "x$no_attrib_nonnull" != "x1" ; then
Tim Rice648f8762011-01-26 12:38:57 -0800266 AC_DEFINE([HAVE_ATTRIBUTE__NONNULL__], [1], [Have attribute nonnull])
Darren Tucker391de5c2007-04-29 14:49:21 +1000267fi
268
Tim Rice648f8762011-01-26 12:38:57 -0800269AC_ARG_WITH([rpath],
Tim Rice88368a32003-12-08 12:35:59 -0800270 [ --without-rpath Disable auto-added -R linker paths],
271 [
Tim Riceeae17cc2005-03-17 16:52:20 -0800272 if test "x$withval" = "xno" ; then
Tim Rice88368a32003-12-08 12:35:59 -0800273 need_dash_r=""
274 fi
275 if test "x$withval" = "xyes" ; then
276 need_dash_r=1
277 fi
278 ]
279)
280
Tim Rice1cfab232006-10-03 09:34:35 -0700281# Allow user to specify flags
Tim Rice648f8762011-01-26 12:38:57 -0800282AC_ARG_WITH([cflags],
Tim Rice1cfab232006-10-03 09:34:35 -0700283 [ --with-cflags Specify additional flags to pass to compiler],
284 [
285 if test -n "$withval" && test "x$withval" != "xno" && \
286 test "x${withval}" != "xyes"; then
287 CFLAGS="$CFLAGS $withval"
288 fi
289 ]
290)
Damien Millerde35c382017-09-08 12:38:31 +1000291
292AC_ARG_WITH([cflags-after],
293 [ --with-cflags-after Specify additional flags to pass to compiler after configure],
294 [
295 if test -n "$withval" && test "x$withval" != "xno" && \
296 test "x${withval}" != "xyes"; then
297 CFLAGS_AFTER="$withval"
298 fi
299 ]
300)
Tim Rice648f8762011-01-26 12:38:57 -0800301AC_ARG_WITH([cppflags],
Tim Rice1cfab232006-10-03 09:34:35 -0700302 [ --with-cppflags Specify additional flags to pass to preprocessor] ,
303 [
304 if test -n "$withval" && test "x$withval" != "xno" && \
305 test "x${withval}" != "xyes"; then
306 CPPFLAGS="$CPPFLAGS $withval"
307 fi
308 ]
309)
Tim Rice648f8762011-01-26 12:38:57 -0800310AC_ARG_WITH([ldflags],
Tim Rice1cfab232006-10-03 09:34:35 -0700311 [ --with-ldflags Specify additional flags to pass to linker],
312 [
313 if test -n "$withval" && test "x$withval" != "xno" && \
314 test "x${withval}" != "xyes"; then
315 LDFLAGS="$LDFLAGS $withval"
316 fi
317 ]
318)
Damien Millerde35c382017-09-08 12:38:31 +1000319AC_ARG_WITH([ldflags-after],
320 [ --with-ldflags-after Specify additional flags to pass to linker after configure],
321 [
322 if test -n "$withval" && test "x$withval" != "xno" && \
323 test "x${withval}" != "xyes"; then
324 LDFLAGS_AFTER="$withval"
325 fi
326 ]
327)
Tim Rice648f8762011-01-26 12:38:57 -0800328AC_ARG_WITH([libs],
Tim Rice1cfab232006-10-03 09:34:35 -0700329 [ --with-libs Specify additional libraries to link with],
330 [
331 if test -n "$withval" && test "x$withval" != "xno" && \
332 test "x${withval}" != "xyes"; then
333 LIBS="$LIBS $withval"
334 fi
335 ]
336)
Tim Rice648f8762011-01-26 12:38:57 -0800337AC_ARG_WITH([Werror],
Tim Rice1cfab232006-10-03 09:34:35 -0700338 [ --with-Werror Build main code with -Werror],
339 [
340 if test -n "$withval" && test "x$withval" != "xno"; then
341 werror_flags="-Werror"
342 if test "x${withval}" != "xyes"; then
343 werror_flags="$withval"
344 fi
345 fi
346 ]
347)
348
Tim Rice648f8762011-01-26 12:38:57 -0800349AC_CHECK_HEADERS([ \
Damien Miller1ff130d2013-12-07 11:51:51 +1100350 blf.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700351 bstring.h \
352 crypt.h \
353 crypto/sha2.h \
354 dirent.h \
355 endian.h \
Damien Miller91f40d82013-02-22 11:37:00 +1100356 elf.h \
Darren Tucker6310ef22016-07-13 14:42:35 +1000357 err.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700358 features.h \
359 fcntl.h \
360 floatingpoint.h \
361 getopt.h \
362 glob.h \
363 ia.h \
364 iaf.h \
Darren Tucker6d725682014-01-17 19:17:34 +1100365 inttypes.h \
Darren Tuckerf3f2cc82016-07-11 17:23:38 +1000366 langinfo.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700367 limits.h \
Darren Tuckerae133d42013-06-06 08:30:20 +1000368 locale.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700369 login.h \
370 maillock.h \
371 ndir.h \
372 net/if_tun.h \
373 netdb.h \
374 netgroup.h \
375 pam/pam_appl.h \
376 paths.h \
Darren Tuckerfebf0f52007-06-25 22:15:12 +1000377 poll.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700378 pty.h \
379 readpassphrase.h \
380 rpc/types.h \
381 security/pam_appl.h \
382 sha2.h \
383 shadow.h \
384 stddef.h \
385 stdint.h \
386 string.h \
387 strings.h \
388 sys/audit.h \
389 sys/bitypes.h \
390 sys/bsdtty.h \
391 sys/cdefs.h \
392 sys/dir.h \
393 sys/mman.h \
394 sys/ndir.h \
Darren Tucker7c92a652007-09-27 07:00:09 +1000395 sys/poll.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700396 sys/prctl.h \
397 sys/pstat.h \
Darren Tucker5ee3fb52016-11-01 08:12:33 +1100398 sys/ptrace.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700399 sys/select.h \
400 sys/stat.h \
401 sys/stream.h \
402 sys/stropts.h \
403 sys/strtio.h \
Darren Tucker5b2e2ba2008-06-08 09:25:28 +1000404 sys/statvfs.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700405 sys/sysmacros.h \
406 sys/time.h \
407 sys/timers.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700408 time.h \
409 tmpdir.h \
410 ttyent.h \
Tim Riceaa8954f2007-05-09 15:57:43 -0700411 ucred.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700412 unistd.h \
413 usersec.h \
414 util.h \
415 utime.h \
416 utmp.h \
417 utmpx.h \
418 vis.h \
Darren Tuckerf3f2cc82016-07-11 17:23:38 +1000419 wchar.h \
Tim Rice648f8762011-01-26 12:38:57 -0800420])
Tim Rice1cfab232006-10-03 09:34:35 -0700421
Darren Tuckerdd9d9b32017-08-28 16:48:27 +1000422# sys/capsicum.h requires sys/types.h
423AC_CHECK_HEADERS([sys/capsicum.h], [], [], [
424#ifdef HAVE_SYS_TYPES_H
425# include <sys/types.h>
426#endif
427])
428
Darren Tuckerfa1b8342017-11-03 14:09:45 +1100429# net/route.h requires sys/socket.h and sys/types.h.
430# sys/sysctl.h also requires sys/param.h
431AC_CHECK_HEADERS([net/route.h sys/sysctl.h], [], [], [
432#ifdef HAVE_SYS_TYPES_H
433# include <sys/types.h>
434#endif
435#include <sys/param.h>
Damien Miller32354732017-10-25 11:25:43 +1100436#include <sys/socket.h>
437])
438
Tim Rice1cfab232006-10-03 09:34:35 -0700439# lastlog.h requires sys/time.h to be included first on Solaris
Tim Rice648f8762011-01-26 12:38:57 -0800440AC_CHECK_HEADERS([lastlog.h], [], [], [
Tim Rice1cfab232006-10-03 09:34:35 -0700441#ifdef HAVE_SYS_TIME_H
442# include <sys/time.h>
443#endif
444])
445
446# sys/ptms.h requires sys/stream.h to be included first on Solaris
Tim Rice648f8762011-01-26 12:38:57 -0800447AC_CHECK_HEADERS([sys/ptms.h], [], [], [
Tim Rice1cfab232006-10-03 09:34:35 -0700448#ifdef HAVE_SYS_STREAM_H
449# include <sys/stream.h>
450#endif
451])
452
453# login_cap.h requires sys/types.h on NetBSD
Tim Rice648f8762011-01-26 12:38:57 -0800454AC_CHECK_HEADERS([login_cap.h], [], [], [
Tim Rice1cfab232006-10-03 09:34:35 -0700455#include <sys/types.h>
456])
457
Darren Tuckerc4b22ca2009-07-12 21:56:29 +1000458# older BSDs need sys/param.h before sys/mount.h
Tim Rice648f8762011-01-26 12:38:57 -0800459AC_CHECK_HEADERS([sys/mount.h], [], [], [
Darren Tuckerc4b22ca2009-07-12 21:56:29 +1000460#include <sys/param.h>
461])
462
Darren Tuckeref4901c2013-06-03 01:59:13 +1000463# Android requires sys/socket.h to be included before sys/un.h
464AC_CHECK_HEADERS([sys/un.h], [], [], [
Darren Tucker0b43ffe2013-06-03 09:30:44 +1000465#include <sys/types.h>
Darren Tucker16cac192013-06-04 12:55:24 +1000466#include <sys/socket.h>
Darren Tuckeref4901c2013-06-03 01:59:13 +1000467])
468
Damien Miller1b06dc32006-08-31 03:24:41 +1000469# Messages for features tested for in target-specific section
470SIA_MSG="no"
471SPC_MSG="no"
Darren Tucker97528352010-11-05 12:03:05 +1100472SP_MSG="no"
Damien Miller4626cba2016-01-08 14:24:56 +1100473SPP_MSG="no"
474
475# Support for Solaris/Illumos privileges (this test is used by both
476# the --with-solaris-privs option and --with-sandbox=solaris).
477SOLARIS_PRIVS="no"
Damien Miller1b06dc32006-08-31 03:24:41 +1000478
Damien Millera22ba012000-03-02 23:09:20 +1100479# Check for some target-specific stuff
Damien Miller76112de1999-12-21 11:18:08 +1100480case "$host" in
Damien Miller75b1d102000-01-07 14:01:41 +1100481*-*-aix*)
Darren Tucker9216c372006-09-18 23:17:40 +1000482 # Some versions of VAC won't allow macro redefinitions at
483 # -qlanglevel=ansi, and autoconf 2.60 sometimes insists on using that
484 # particularly with older versions of vac or xlc.
485 # It also throws errors about null macro argments, but these are
486 # not fatal.
Tim Rice648f8762011-01-26 12:38:57 -0800487 AC_MSG_CHECKING([if compiler allows macro redefinitions])
Darren Tucker9216c372006-09-18 23:17:40 +1000488 AC_COMPILE_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -0800489 [AC_LANG_PROGRAM([[
Darren Tucker9216c372006-09-18 23:17:40 +1000490#define testmacro foo
Tim Rice648f8762011-01-26 12:38:57 -0800491#define testmacro bar]],
492 [[ exit(0); ]])],
493 [ AC_MSG_RESULT([yes]) ],
494 [ AC_MSG_RESULT([no])
Darren Tucker9216c372006-09-18 23:17:40 +1000495 CC="`echo $CC | sed 's/-qlanglvl\=ansi//g'`"
496 LD="`echo $LD | sed 's/-qlanglvl\=ansi//g'`"
497 CFLAGS="`echo $CFLAGS | sed 's/-qlanglvl\=ansi//g'`"
498 CPPFLAGS="`echo $CPPFLAGS | sed 's/-qlanglvl\=ansi//g'`"
499 ]
500 )
501
Damien Millera8e06ce2003-11-21 23:48:55 +1100502 AC_MSG_CHECKING([how to specify blibpath for linker ($LD)])
Damien Millereab4bae2003-04-29 23:22:40 +1000503 if (test -z "$blibpath"); then
Tim Ricefcb62202004-01-23 18:35:16 -0800504 blibpath="/usr/lib:/lib"
Damien Miller29ea30d2000-03-17 10:54:15 +1100505 fi
Damien Millereab4bae2003-04-29 23:22:40 +1000506 saved_LDFLAGS="$LDFLAGS"
Darren Tuckerbdc12122006-07-06 11:56:25 +1000507 if test "$GCC" = "yes"; then
508 flags="-Wl,-blibpath: -Wl,-rpath, -blibpath:"
509 else
510 flags="-blibpath: -Wl,-blibpath: -Wl,-rpath,"
511 fi
512 for tryflags in $flags ;do
Damien Millereab4bae2003-04-29 23:22:40 +1000513 if (test -z "$blibflags"); then
514 LDFLAGS="$saved_LDFLAGS $tryflags$blibpath"
Tim Rice648f8762011-01-26 12:38:57 -0800515 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
516 [blibflags=$tryflags], [])
Damien Millereab4bae2003-04-29 23:22:40 +1000517 fi
518 done
519 if (test -z "$blibflags"); then
Tim Rice648f8762011-01-26 12:38:57 -0800520 AC_MSG_RESULT([not found])
Damien Millereab4bae2003-04-29 23:22:40 +1000521 AC_MSG_ERROR([*** must be able to specify blibpath on AIX - check config.log])
522 else
Tim Rice648f8762011-01-26 12:38:57 -0800523 AC_MSG_RESULT([$blibflags])
Damien Millereab4bae2003-04-29 23:22:40 +1000524 fi
525 LDFLAGS="$saved_LDFLAGS"
Darren Tucker5c6a91a2003-07-14 16:21:44 +1000526 dnl Check for authenticate. Might be in libs.a on older AIXes
Tim Rice648f8762011-01-26 12:38:57 -0800527 AC_CHECK_FUNC([authenticate], [AC_DEFINE([WITH_AIXAUTHENTICATE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700528 [Define if you want to enable AIX4's authenticate function])],
Tim Rice648f8762011-01-26 12:38:57 -0800529 [AC_CHECK_LIB([s], [authenticate],
530 [ AC_DEFINE([WITH_AIXAUTHENTICATE])
Tim Ricee958ed32002-07-05 07:12:33 -0700531 LIBS="$LIBS -ls"
532 ])
533 ])
Darren Tucker3c774c52005-02-16 22:49:31 +1100534 dnl Check for various auth function declarations in headers.
Darren Tucker04cfbe02005-02-20 23:27:11 +1100535 AC_CHECK_DECLS([authenticate, loginrestrictions, loginsuccess,
Darren Tuckere66519d2005-03-21 22:46:34 +1100536 passwdexpired, setauthdb], , , [#include <usersec.h>])
Darren Tucker5c6a91a2003-07-14 16:21:44 +1000537 dnl Check if loginfailed is declared and takes 4 arguments (AIX >= 5.2)
Tim Rice648f8762011-01-26 12:38:57 -0800538 AC_CHECK_DECLS([loginfailed],
539 [AC_MSG_CHECKING([if loginfailed takes 4 arguments])
540 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <usersec.h> ]],
541 [[ (void)loginfailed("user","host","tty",0); ]])],
542 [AC_MSG_RESULT([yes])
543 AC_DEFINE([AIX_LOGINFAILED_4ARG], [1],
544 [Define if your AIX loginfailed() function
545 takes 4 arguments (AIX >= 5.2)])], [AC_MSG_RESULT([no])
546 ])],
547 [],
548 [#include <usersec.h>]
Darren Tucker5c6a91a2003-07-14 16:21:44 +1000549 )
Tim Rice648f8762011-01-26 12:38:57 -0800550 AC_CHECK_FUNCS([getgrset setauthdb])
551 AC_CHECK_DECL([F_CLOSEM],
552 AC_DEFINE([HAVE_FCNTL_CLOSEM], [1], [Use F_CLOSEM fcntl for closefrom]),
Darren Tucker3083bc22006-08-17 19:35:49 +1000553 [],
554 [ #include <limits.h>
555 #include <fcntl.h> ]
556 )
Darren Tucker691d5232005-02-15 21:45:57 +1100557 check_for_aix_broken_getaddrinfo=1
Tim Rice648f8762011-01-26 12:38:57 -0800558 AC_DEFINE([BROKEN_REALPATH], [1], [Define if you have a broken realpath.])
559 AC_DEFINE([SETEUID_BREAKS_SETUID], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700560 [Define if your platform breaks doing a seteuid before a setuid])
Tim Rice648f8762011-01-26 12:38:57 -0800561 AC_DEFINE([BROKEN_SETREUID], [1], [Define if your setreuid() is broken])
562 AC_DEFINE([BROKEN_SETREGID], [1], [Define if your setregid() is broken])
andre60f3c982000-06-03 16:18:19 +0000563 dnl AIX handles lastlog as part of its login message
Tim Rice648f8762011-01-26 12:38:57 -0800564 AC_DEFINE([DISABLE_LASTLOG], [1], [Define if you don't want to use lastlog])
565 AC_DEFINE([LOGIN_NEEDS_UTMPX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700566 [Some systems need a utmpx entry for /bin/login to work])
Tim Rice648f8762011-01-26 12:38:57 -0800567 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV],
Tim Rice7df8d392005-09-19 09:33:39 -0700568 [Define to a Set Process Title type if your system is
569 supported by bsd-setproctitle.c])
Tim Rice648f8762011-01-26 12:38:57 -0800570 AC_DEFINE([SSHPAM_CHAUTHTOK_NEEDS_RUID], [1],
Darren Tucker91d25a02005-11-26 22:24:09 +1100571 [AIX 5.2 and 5.3 (and presumably newer) require this])
Tim Rice648f8762011-01-26 12:38:57 -0800572 AC_DEFINE([PTY_ZEROREAD], [1], [read(1) can return 0 for a non-closed fd])
Darren Tuckeraa97d132013-03-12 11:31:05 +1100573 AC_DEFINE([PLATFORM_SYS_DIR_UID], 2, [System dirs owned by bin (uid 2)])
Damien Miller75b1d102000-01-07 14:01:41 +1100574 ;;
Darren Tucker898ac932013-06-03 02:03:25 +1000575*-*-android*)
576 AC_DEFINE([DISABLE_UTMP], [1], [Define if you don't want to use utmp])
577 AC_DEFINE([DISABLE_WTMP], [1], [Define if you don't want to use wtmp])
578 ;;
Damien Millerbac2d8a2000-09-05 16:13:06 +1100579*-*-cygwin*)
Damien Millerc8936ac2003-02-11 10:04:03 +1100580 check_for_libcrypt_later=1
Darren Tucker573e3872007-03-02 17:50:03 +1100581 LIBS="$LIBS /usr/lib/textreadmode.o"
Tim Rice648f8762011-01-26 12:38:57 -0800582 AC_DEFINE([HAVE_CYGWIN], [1], [Define if you are on Cygwin])
583 AC_DEFINE([USE_PIPES], [1], [Use PIPES instead of a socketpair()])
Damien Miller4626cba2016-01-08 14:24:56 +1100584 AC_DEFINE([NO_UID_RESTORATION_TEST], [1],
585 [Define to disable UID restoration test])
Tim Rice648f8762011-01-26 12:38:57 -0800586 AC_DEFINE([DISABLE_SHADOW], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700587 [Define if you want to disable shadow passwords])
Tim Rice648f8762011-01-26 12:38:57 -0800588 AC_DEFINE([NO_X11_UNIX_SOCKETS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700589 [Define if X11 doesn't support AF_UNIX sockets on that system])
Tim Rice648f8762011-01-26 12:38:57 -0800590 AC_DEFINE([DISABLE_FD_PASSING], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700591 [Define if your platform needs to skip post auth
592 file descriptor passing])
Tim Rice648f8762011-01-26 12:38:57 -0800593 AC_DEFINE([SSH_IOBUFSZ], [65535], [Windows is sensitive to read buffer size])
Darren Tuckerfdce3732014-01-18 21:12:42 +1100594 AC_DEFINE([FILESYSTEM_NO_BACKSLASH], [1], [File names may not contain backslash characters])
595 # Cygwin defines optargs, optargs as declspec(dllimport) for historical
596 # reasons which cause compile warnings, so we disable those warnings.
597 OSSH_CHECK_CFLAG_COMPILE([-Wno-attributes])
Damien Millerbac2d8a2000-09-05 16:13:06 +1100598 ;;
Ben Lindstrom58055132001-02-15 18:34:29 +0000599*-*-dgux*)
Tim Rice648f8762011-01-26 12:38:57 -0800600 AC_DEFINE([IP_TOS_IS_BROKEN], [1],
Tim Ricea74000e2009-03-18 11:25:02 -0700601 [Define if your system choked on IP TOS setting])
Tim Rice648f8762011-01-26 12:38:57 -0800602 AC_DEFINE([SETEUID_BREAKS_SETUID])
603 AC_DEFINE([BROKEN_SETREUID])
604 AC_DEFINE([BROKEN_SETREGID])
Ben Lindstrom58055132001-02-15 18:34:29 +0000605 ;;
Ben Lindstromfed7bb42001-07-15 18:30:42 +0000606*-*-darwin*)
Damien Miller852472a2014-01-22 16:31:18 +1100607 use_pie=auto
Tim Rice648f8762011-01-26 12:38:57 -0800608 AC_MSG_CHECKING([if we have working getaddrinfo])
609 AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <mach-o/dyld.h>
Damien Millerfc93d4b2002-09-04 23:26:29 +1000610main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
611 exit(0);
612 else
613 exit(1);
Tim Rice648f8762011-01-26 12:38:57 -0800614}
615 ]])],
616 [AC_MSG_RESULT([working])],
617 [AC_MSG_RESULT([buggy])
618 AC_DEFINE([BROKEN_GETADDRINFO], [1],
619 [getaddrinfo is broken (if present)])
620 ],
621 [AC_MSG_RESULT([assume it is working])])
622 AC_DEFINE([SETEUID_BREAKS_SETUID])
623 AC_DEFINE([BROKEN_SETREUID])
624 AC_DEFINE([BROKEN_SETREGID])
625 AC_DEFINE([BROKEN_GLOB], [1], [OS X glob does not do what we expect])
626 AC_DEFINE_UNQUOTED([BIND_8_COMPAT], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700627 [Define if your resolver libs need this for getrrsetbyname])
Tim Rice648f8762011-01-26 12:38:57 -0800628 AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
629 AC_DEFINE([SSH_TUN_COMPAT_AF], [1],
Darren Tucker3eb48342006-06-23 21:05:12 +1000630 [Use tunnel device compatibility to OpenBSD])
Tim Rice648f8762011-01-26 12:38:57 -0800631 AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
Darren Tucker3eb48342006-06-23 21:05:12 +1000632 [Prepend the address family to IP tunnel traffic])
Tim Rice648f8762011-01-26 12:38:57 -0800633 m4_pattern_allow([AU_IPv])
Tim Ricee1d93702016-05-31 11:13:22 -0700634 AC_CHECK_DECL([AU_IPv4], [],
Tim Rice648f8762011-01-26 12:38:57 -0800635 AC_DEFINE([AU_IPv4], [0], [System only supports IPv4 audit records])
Darren Tuckeracada072008-02-25 21:05:04 +1100636 [#include <bsm/audit.h>]
Tim Rice648f8762011-01-26 12:38:57 -0800637 AC_DEFINE([LASTLOG_WRITE_PUTUTXLINE], [1],
Damien Miller20e231f2009-02-12 13:12:21 +1100638 [Define if pututxline updates lastlog too])
Darren Tuckeracada072008-02-25 21:05:04 +1100639 )
Damien Millerc09182f2011-06-03 12:11:38 +1000640 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV],
641 [Define to a Set Process Title type if your system is
642 supported by bsd-setproctitle.c])
Damien Millercd5e52e2011-06-27 07:18:18 +1000643 AC_CHECK_FUNCS([sandbox_init])
644 AC_CHECK_HEADERS([sandbox.h])
Damien Miller39f303b2016-02-23 12:56:59 +1100645 AC_CHECK_LIB([sandbox], [sandbox_apply], [
646 SSHDLIBS="$SSHDLIBS -lsandbox"
647 ])
Ben Lindstromfed7bb42001-07-15 18:30:42 +0000648 ;;
Darren Tucker57b29202006-09-10 20:25:51 +1000649*-*-dragonfly*)
650 SSHDLIBS="$SSHDLIBS -lcrypt"
Darren Tucker882abfd2013-11-09 00:17:41 +1100651 TEST_MALLOC_OPTIONS="AFGJPRX"
Darren Tucker57b29202006-09-10 20:25:51 +1000652 ;;
Tim Ricee1d93702016-05-31 11:13:22 -0700653*-*-haiku*)
Darren Tucker5faa52d2016-08-02 15:22:40 +1000654 LIBS="$LIBS -lbsd "
655 AC_CHECK_LIB([network], [socket])
656 AC_DEFINE([HAVE_U_INT64_T])
657 MANTYPE=man
658 ;;
Darren Tuckerfd333282005-05-28 18:31:42 +1000659*-*-hpux*)
660 # first we define all of the options common to all HP-UX releases
Kevin Steves315f8b72001-06-28 00:24:41 +0000661 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
Damien Miller9a947342000-08-30 10:03:33 +1100662 IPADDR_IN_DISPLAY=yes
Tim Rice648f8762011-01-26 12:38:57 -0800663 AC_DEFINE([USE_PIPES])
Tim Rice648f8762011-01-26 12:38:57 -0800664 AC_DEFINE([LOGIN_NEEDS_UTMPX])
665 AC_DEFINE([LOCKED_PASSWD_STRING], ["*"],
Tim Rice7df8d392005-09-19 09:33:39 -0700666 [String used in /etc/passwd to denote locked account])
Tim Rice648f8762011-01-26 12:38:57 -0800667 AC_DEFINE([SPT_TYPE], [SPT_PSTAT])
Darren Tuckeraa97d132013-03-12 11:31:05 +1100668 AC_DEFINE([PLATFORM_SYS_DIR_UID], 2, [System dirs owned by bin (uid 2)])
Tim Rice90f42b02011-06-02 18:17:49 -0700669 maildir="/var/mail"
Tim Ricef028f1e2002-07-19 12:41:10 -0700670 LIBS="$LIBS -lsec"
Tim Rice648f8762011-01-26 12:38:57 -0800671 AC_CHECK_LIB([xnet], [t_error], ,
672 [AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***])])
Darren Tuckerfd333282005-05-28 18:31:42 +1000673
674 # next, we define all of the options specific to major releases
675 case "$host" in
676 *-*-hpux10*)
677 if test -z "$GCC"; then
678 CFLAGS="$CFLAGS -Ae"
679 fi
680 ;;
681 *-*-hpux11*)
Tim Rice648f8762011-01-26 12:38:57 -0800682 AC_DEFINE([PAM_SUN_CODEBASE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700683 [Define if you are using Solaris-derived PAM which
684 passes pam_messages to the conversation function
685 with an extra level of indirection])
Tim Rice648f8762011-01-26 12:38:57 -0800686 AC_DEFINE([DISABLE_UTMP], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700687 [Define if you don't want to use utmp])
Tim Rice648f8762011-01-26 12:38:57 -0800688 AC_DEFINE([USE_BTMP], [1], [Use btmp to log bad logins])
Darren Tuckerfd333282005-05-28 18:31:42 +1000689 check_for_hpux_broken_getaddrinfo=1
690 check_for_conflicting_getspnam=1
691 ;;
692 esac
693
694 # lastly, we define options specific to minor releases
695 case "$host" in
696 *-*-hpux10.26)
Tim Rice648f8762011-01-26 12:38:57 -0800697 AC_DEFINE([HAVE_SECUREWARE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700698 [Define if you have SecureWare-based
699 protected password database])
Darren Tuckerfd333282005-05-28 18:31:42 +1000700 disable_ptmx_check=yes
701 LIBS="$LIBS -lsecpw"
702 ;;
703 esac
Damien Miller1bead332000-04-30 00:47:29 +1000704 ;;
Damien Millerbeb4ba51999-12-28 15:09:35 +1100705*-*-irix5*)
Damien Miller190d5a82000-09-30 09:43:19 +1100706 PATH="$PATH:/usr/etc"
Tim Rice648f8762011-01-26 12:38:57 -0800707 AC_DEFINE([BROKEN_INET_NTOA], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700708 [Define if you system's inet_ntoa is busted
709 (e.g. Irix gcc issue)])
Tim Rice648f8762011-01-26 12:38:57 -0800710 AC_DEFINE([SETEUID_BREAKS_SETUID])
711 AC_DEFINE([BROKEN_SETREUID])
712 AC_DEFINE([BROKEN_SETREGID])
713 AC_DEFINE([WITH_ABBREV_NO_TTY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700714 [Define if you shouldn't strip 'tty' from your
715 ttyname in [uw]tmp])
Tim Rice648f8762011-01-26 12:38:57 -0800716 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Damien Miller1808f382000-01-06 12:03:12 +1100717 ;;
718*-*-irix6*)
Damien Miller190d5a82000-09-30 09:43:19 +1100719 PATH="$PATH:/usr/etc"
Tim Rice648f8762011-01-26 12:38:57 -0800720 AC_DEFINE([WITH_IRIX_ARRAY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700721 [Define if you have/want arrays
722 (cluster-wide session managment, not C arrays)])
Tim Rice648f8762011-01-26 12:38:57 -0800723 AC_DEFINE([WITH_IRIX_PROJECT], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700724 [Define if you want IRIX project management])
Tim Rice648f8762011-01-26 12:38:57 -0800725 AC_DEFINE([WITH_IRIX_AUDIT], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700726 [Define if you want IRIX audit trails])
Tim Rice648f8762011-01-26 12:38:57 -0800727 AC_CHECK_FUNC([jlimit_startjob], [AC_DEFINE([WITH_IRIX_JOBS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700728 [Define if you want IRIX kernel jobs])])
Tim Rice648f8762011-01-26 12:38:57 -0800729 AC_DEFINE([BROKEN_INET_NTOA])
730 AC_DEFINE([SETEUID_BREAKS_SETUID])
731 AC_DEFINE([BROKEN_SETREUID])
732 AC_DEFINE([BROKEN_SETREGID])
733 AC_DEFINE([BROKEN_UPDWTMPX], [1], [updwtmpx is broken (if present)])
734 AC_DEFINE([WITH_ABBREV_NO_TTY])
735 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Damien Millerbeb4ba51999-12-28 15:09:35 +1100736 ;;
Damien Miller90551722009-02-16 15:37:03 +1100737*-*-k*bsd*-gnu | *-*-kopensolaris*-gnu)
738 check_for_libcrypt_later=1
Tim Rice648f8762011-01-26 12:38:57 -0800739 AC_DEFINE([PAM_TTY_KLUDGE])
740 AC_DEFINE([LOCKED_PASSWD_PREFIX], ["!"])
741 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV])
742 AC_DEFINE([_PATH_BTMP], ["/var/log/btmp"], [log for bad login attempts])
743 AC_DEFINE([USE_BTMP], [1], [Use btmp to log bad logins])
Damien Miller90551722009-02-16 15:37:03 +1100744 ;;
Damien Millerb29ea912000-01-15 14:12:03 +1100745*-*-linux*)
746 no_dev_ptmx=1
Damien Miller852472a2014-01-22 16:31:18 +1100747 use_pie=auto
Damien Millera64b57a2001-01-17 10:44:13 +1100748 check_for_libcrypt_later=1
Darren Tucker70a3d552003-08-21 17:58:29 +1000749 check_for_openpty_ctty_bug=1
Darren Tuckerc61d5ec2017-02-03 14:10:34 +1100750 dnl Target SUSv3/POSIX.1-2001 plus BSD specifics.
751 dnl _DEFAULT_SOURCE is the new name for _BSD_SOURCE
752 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_DEFAULT_SOURCE"
Tim Rice648f8762011-01-26 12:38:57 -0800753 AC_DEFINE([PAM_TTY_KLUDGE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700754 [Work around problematic Linux PAM modules handling of PAM_TTY])
Tim Rice648f8762011-01-26 12:38:57 -0800755 AC_DEFINE([LOCKED_PASSWD_PREFIX], ["!"],
Tim Rice7df8d392005-09-19 09:33:39 -0700756 [String used in /etc/passwd to denote locked account])
Tim Rice648f8762011-01-26 12:38:57 -0800757 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV])
758 AC_DEFINE([LINK_OPNOTSUPP_ERRNO], [EPERM],
Tim Rice7df8d392005-09-19 09:33:39 -0700759 [Define to whatever link() returns for "not supported"
760 if it doesn't return EOPNOTSUPP.])
Tim Rice648f8762011-01-26 12:38:57 -0800761 AC_DEFINE([_PATH_BTMP], ["/var/log/btmp"], [log for bad login attempts])
762 AC_DEFINE([USE_BTMP])
763 AC_DEFINE([LINUX_OOM_ADJUST], [1], [Adjust Linux out-of-memory killer])
Damien Miller7bcb0892000-03-11 20:45:40 +1100764 inet6_default_4in6=yes
Darren Tucker3c016542003-05-02 20:48:21 +1000765 case `uname -r` in
Darren Tuckerc437cda2003-05-10 17:05:46 +1000766 1.*|2.0.*)
Tim Rice648f8762011-01-26 12:38:57 -0800767 AC_DEFINE([BROKEN_CMSG_TYPE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700768 [Define if cmsg_type is not passed correctly])
Darren Tucker3c016542003-05-02 20:48:21 +1000769 ;;
Darren Tucker3c016542003-05-02 20:48:21 +1000770 esac
Damien Miller89e03ba2005-12-31 16:42:03 +1100771 # tun(4) forwarding compat code
Tim Rice648f8762011-01-26 12:38:57 -0800772 AC_CHECK_HEADERS([linux/if_tun.h])
Damien Millerbd4e4102006-01-01 21:03:30 +1100773 if test "x$ac_cv_header_linux_if_tun_h" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -0800774 AC_DEFINE([SSH_TUN_LINUX], [1],
Damien Miller89e03ba2005-12-31 16:42:03 +1100775 [Open tunnel devices the Linux tun/tap way])
Tim Rice648f8762011-01-26 12:38:57 -0800776 AC_DEFINE([SSH_TUN_COMPAT_AF], [1],
Damien Miller89e03ba2005-12-31 16:42:03 +1100777 [Use tunnel device compatibility to OpenBSD])
Tim Rice648f8762011-01-26 12:38:57 -0800778 AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
Damien Miller89e03ba2005-12-31 16:42:03 +1100779 [Prepend the address family to IP tunnel traffic])
780 fi
Darren Tucker81c9ccd2017-11-03 14:52:51 +1100781 AC_CHECK_HEADER([linux/if.h],
782 AC_DEFINE([SYS_RDOMAIN_LINUX], [1],
783 [Support routing domains using Linux VRF]))
Darren Tucker60395f92012-07-03 14:31:18 +1000784 AC_CHECK_HEADERS([linux/seccomp.h linux/filter.h linux/audit.h], [],
785 [], [#include <linux/types.h>])
Damien Miller91f40d82013-02-22 11:37:00 +1100786 AC_MSG_CHECKING([for seccomp architecture])
787 seccomp_audit_arch=
Damien Millere0956e32012-04-04 11:27:54 +1000788 case "$host" in
789 x86_64-*)
Damien Miller91f40d82013-02-22 11:37:00 +1100790 seccomp_audit_arch=AUDIT_ARCH_X86_64
Damien Millere0956e32012-04-04 11:27:54 +1000791 ;;
792 i*86-*)
Damien Miller91f40d82013-02-22 11:37:00 +1100793 seccomp_audit_arch=AUDIT_ARCH_I386
Damien Millere0956e32012-04-04 11:27:54 +1000794 ;;
Damien Miller99f33d72015-06-17 10:50:51 +1000795 arm*-*)
Damien Miller91f40d82013-02-22 11:37:00 +1100796 seccomp_audit_arch=AUDIT_ARCH_ARM
Damien Miller99f33d72015-06-17 10:50:51 +1000797 ;;
798 aarch64*-*)
799 seccomp_audit_arch=AUDIT_ARCH_AARCH64
Damien Miller5c15e222015-06-18 15:07:56 +1000800 ;;
Damien Millerb9c50612016-07-08 13:59:13 +1000801 s390x-*)
802 seccomp_audit_arch=AUDIT_ARCH_S390X
803 ;;
804 s390-*)
805 seccomp_audit_arch=AUDIT_ARCH_S390
806 ;;
807 powerpc64-*)
808 seccomp_audit_arch=AUDIT_ARCH_PPC64
809 ;;
810 powerpc64le-*)
811 seccomp_audit_arch=AUDIT_ARCH_PPC64LE
812 ;;
813 mips-*)
814 seccomp_audit_arch=AUDIT_ARCH_MIPS
815 ;;
816 mipsel-*)
817 seccomp_audit_arch=AUDIT_ARCH_MIPSEL
818 ;;
819 mips64-*)
820 seccomp_audit_arch=AUDIT_ARCH_MIPS64
821 ;;
822 mips64el-*)
823 seccomp_audit_arch=AUDIT_ARCH_MIPSEL64
824 ;;
Damien Millere0956e32012-04-04 11:27:54 +1000825 esac
Damien Miller91f40d82013-02-22 11:37:00 +1100826 if test "x$seccomp_audit_arch" != "x" ; then
827 AC_MSG_RESULT(["$seccomp_audit_arch"])
Damien Miller99f33d72015-06-17 10:50:51 +1000828 AC_DEFINE_UNQUOTED([SECCOMP_AUDIT_ARCH], [$seccomp_audit_arch],
829 [Specify the system call convention in use])
Damien Miller91f40d82013-02-22 11:37:00 +1100830 else
831 AC_MSG_RESULT([architecture not supported])
832 fi
Damien Millerb29ea912000-01-15 14:12:03 +1100833 ;;
Ben Lindstromb5628642000-10-18 00:02:25 +0000834mips-sony-bsd|mips-sony-newsos4)
Tim Rice648f8762011-01-26 12:38:57 -0800835 AC_DEFINE([NEED_SETPGRP], [1], [Need setpgrp to acquire controlling tty])
Ben Lindstromb5628642000-10-18 00:02:25 +0000836 SONY=1
Ben Lindstromb5628642000-10-18 00:02:25 +0000837 ;;
Damien Milleree1c0b32000-01-21 00:18:15 +1100838*-*-netbsd*)
Damien Millerfc93d4b2002-09-04 23:26:29 +1000839 check_for_libcrypt_before=1
Tim Riceeae17cc2005-03-17 16:52:20 -0800840 if test "x$withval" != "xno" ; then
Tim Rice88368a32003-12-08 12:35:59 -0800841 need_dash_r=1
842 fi
Damien Miller99522ba2016-07-28 08:54:27 +1000843 CPPFLAGS="$CPPFLAGS -D_OPENBSD_SOURCE"
Tim Rice648f8762011-01-26 12:38:57 -0800844 AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
Damien Miller2dcddbf2006-01-01 19:47:05 +1100845 AC_CHECK_HEADER([net/if_tap.h], ,
Tim Rice648f8762011-01-26 12:38:57 -0800846 AC_DEFINE([SSH_TUN_NO_L2], [1], [No layer 2 tunnel support]))
847 AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
Damien Miller2dcddbf2006-01-01 19:47:05 +1100848 [Prepend the address family to IP tunnel traffic])
Darren Tucker882abfd2013-11-09 00:17:41 +1100849 TEST_MALLOC_OPTIONS="AJRX"
Damien Millerf5bbd3b2014-01-30 11:26:46 +1100850 AC_DEFINE([BROKEN_READ_COMPARISON], [1],
851 [NetBSD read function is sometimes redirected, breaking atomicio comparisons against it])
Damien Milleree1c0b32000-01-21 00:18:15 +1100852 ;;
Damien Millerfbd884a2001-02-27 08:39:07 +1100853*-*-freebsd*)
854 check_for_libcrypt_later=1
Tim Rice648f8762011-01-26 12:38:57 -0800855 AC_DEFINE([LOCKED_PASSWD_PREFIX], ["*LOCKED*"], [Account locked with pw(1)])
856 AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
Damien Miller2dcddbf2006-01-01 19:47:05 +1100857 AC_CHECK_HEADER([net/if_tap.h], ,
Tim Rice648f8762011-01-26 12:38:57 -0800858 AC_DEFINE([SSH_TUN_NO_L2], [1], [No layer 2 tunnel support]))
859 AC_DEFINE([BROKEN_GLOB], [1], [FreeBSD glob does not do what we need])
Darren Tucker882abfd2013-11-09 00:17:41 +1100860 TEST_MALLOC_OPTIONS="AJRX"
Damien Miller2035b222014-01-26 09:39:53 +1100861 # Preauth crypto occasionally uses file descriptors for crypto offload
862 # and will crash if they cannot be opened.
Damien Miller5b447c02014-01-26 09:46:53 +1100863 AC_DEFINE([SANDBOX_SKIP_RLIMIT_NOFILE], [1],
Tim Rice03ae0812014-02-21 09:09:34 -0800864 [define if setrlimit RLIMIT_NOFILE breaks things])
Damien Millerfbd884a2001-02-27 08:39:07 +1100865 ;;
Darren Tuckered9eb022003-09-22 11:18:47 +1000866*-*-bsdi*)
Tim Rice648f8762011-01-26 12:38:57 -0800867 AC_DEFINE([SETEUID_BREAKS_SETUID])
868 AC_DEFINE([BROKEN_SETREUID])
869 AC_DEFINE([BROKEN_SETREGID])
Darren Tuckered9eb022003-09-22 11:18:47 +1000870 ;;
Damien Miller0f91b4e2000-06-18 15:43:25 +1000871*-next-*)
Damien Miller0f91b4e2000-06-18 15:43:25 +1000872 conf_lastlog_location="/usr/adm/lastlog"
Damien Millere5192fa2000-08-29 14:30:37 +1100873 conf_utmp_location=/etc/utmp
874 conf_wtmp_location=/usr/adm/wtmp
Tim Rice90f42b02011-06-02 18:17:49 -0700875 maildir=/usr/spool/mail
Tim Rice648f8762011-01-26 12:38:57 -0800876 AC_DEFINE([HAVE_NEXT], [1], [Define if you are on NeXT])
877 AC_DEFINE([BROKEN_REALPATH])
878 AC_DEFINE([USE_PIPES])
879 AC_DEFINE([BROKEN_SAVED_UIDS], [1], [Needed for NeXT])
Damien Miller0f91b4e2000-06-18 15:43:25 +1000880 ;;
Darren Tucker4a422572005-07-14 17:22:11 +1000881*-*-openbsd*)
Damien Miller852472a2014-01-22 16:31:18 +1100882 use_pie=auto
Tim Rice648f8762011-01-26 12:38:57 -0800883 AC_DEFINE([HAVE_ATTRIBUTE__SENTINEL__], [1], [OpenBSD's gcc has sentinel])
884 AC_DEFINE([HAVE_ATTRIBUTE__BOUNDED__], [1], [OpenBSD's gcc has bounded])
885 AC_DEFINE([SSH_TUN_OPENBSD], [1], [Open tunnel devices the OpenBSD way])
886 AC_DEFINE([SYSLOG_R_SAFE_IN_SIGHAND], [1],
Damien Millerbb598142006-08-19 08:38:23 +1000887 [syslog_r function is safe to use in in a signal handler])
Darren Tucker882abfd2013-11-09 00:17:41 +1100888 TEST_MALLOC_OPTIONS="AFGJPRX"
Darren Tucker4a422572005-07-14 17:22:11 +1000889 ;;
Damien Miller75b1d102000-01-07 14:01:41 +1100890*-*-solaris*)
Tim Riceeae17cc2005-03-17 16:52:20 -0800891 if test "x$withval" != "xno" ; then
Tim Ricead4a1882004-02-29 15:53:37 -0800892 need_dash_r=1
893 fi
Tim Rice648f8762011-01-26 12:38:57 -0800894 AC_DEFINE([PAM_SUN_CODEBASE])
895 AC_DEFINE([LOGIN_NEEDS_UTMPX])
Tim Rice648f8762011-01-26 12:38:57 -0800896 AC_DEFINE([PAM_TTY_KLUDGE])
897 AC_DEFINE([SSHPAM_CHAUTHTOK_NEEDS_RUID], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700898 [Define if pam_chauthtok wants real uid set
899 to the unpriv'ed user])
Tim Rice648f8762011-01-26 12:38:57 -0800900 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Darren Tuckerc437cda2003-05-10 17:05:46 +1000901 # Pushing STREAMS modules will cause sshd to acquire a controlling tty.
Tim Rice648f8762011-01-26 12:38:57 -0800902 AC_DEFINE([SSHD_ACQUIRES_CTTY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700903 [Define if sshd somehow reacquires a controlling TTY
904 after setsid()])
Tim Rice648f8762011-01-26 12:38:57 -0800905 AC_DEFINE([PASSWD_NEEDS_USERNAME], [1], [must supply username to passwd
Darren Tucker0249f932006-06-24 12:10:07 +1000906 in case the name is longer than 8 chars])
Tim Rice648f8762011-01-26 12:38:57 -0800907 AC_DEFINE([BROKEN_TCGETATTR_ICANON], [1], [tcgetattr with ICANON may hang])
Darren Tuckere1a790d2003-09-16 11:52:19 +1000908 external_path_file=/etc/default/login
andre2ff7b5d2000-06-03 14:57:40 +0000909 # hardwire lastlog location (can't detect it on some versions)
910 conf_lastlog_location="/var/adm/lastlog"
Tim Rice648f8762011-01-26 12:38:57 -0800911 AC_MSG_CHECKING([for obsolete utmp and wtmp in solaris2.x])
Damien Millera1cb6442000-06-09 11:58:35 +1000912 sol2ver=`echo "$host"| sed -e 's/.*[[0-9]]\.//'`
913 if test "$sol2ver" -ge 8; then
Tim Rice648f8762011-01-26 12:38:57 -0800914 AC_MSG_RESULT([yes])
915 AC_DEFINE([DISABLE_UTMP])
916 AC_DEFINE([DISABLE_WTMP], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700917 [Define if you don't want to use wtmp])
Damien Millera1cb6442000-06-09 11:58:35 +1000918 else
Tim Rice648f8762011-01-26 12:38:57 -0800919 AC_MSG_RESULT([no])
Damien Millera1cb6442000-06-09 11:58:35 +1000920 fi
Darren Tuckera86ec4d2016-06-14 10:48:27 +1000921 AC_CHECK_FUNCS([setpflags])
Darren Tucker907091a2016-02-19 09:05:39 +1100922 AC_CHECK_FUNCS([setppriv])
923 AC_CHECK_FUNCS([priv_basicset])
924 AC_CHECK_HEADERS([priv.h])
Tim Rice648f8762011-01-26 12:38:57 -0800925 AC_ARG_WITH([solaris-contracts],
Damien Miller1b06dc32006-08-31 03:24:41 +1000926 [ --with-solaris-contracts Enable Solaris process contracts (experimental)],
927 [
Tim Rice648f8762011-01-26 12:38:57 -0800928 AC_CHECK_LIB([contract], [ct_tmpl_activate],
929 [ AC_DEFINE([USE_SOLARIS_PROCESS_CONTRACTS], [1],
Damien Miller1b06dc32006-08-31 03:24:41 +1000930 [Define if you have Solaris process contracts])
Damien Miller4626cba2016-01-08 14:24:56 +1100931 LIBS="$LIBS -lcontract"
Damien Miller1b06dc32006-08-31 03:24:41 +1000932 SPC_MSG="yes" ], )
933 ],
934 )
Tim Rice648f8762011-01-26 12:38:57 -0800935 AC_ARG_WITH([solaris-projects],
Darren Tucker97528352010-11-05 12:03:05 +1100936 [ --with-solaris-projects Enable Solaris projects (experimental)],
937 [
Tim Rice648f8762011-01-26 12:38:57 -0800938 AC_CHECK_LIB([project], [setproject],
939 [ AC_DEFINE([USE_SOLARIS_PROJECTS], [1],
Darren Tucker97528352010-11-05 12:03:05 +1100940 [Define if you have Solaris projects])
Damien Miller4626cba2016-01-08 14:24:56 +1100941 LIBS="$LIBS -lproject"
Darren Tucker97528352010-11-05 12:03:05 +1100942 SP_MSG="yes" ], )
943 ],
944 )
Damien Miller4626cba2016-01-08 14:24:56 +1100945 AC_ARG_WITH([solaris-privs],
946 [ --with-solaris-privs Enable Solaris/Illumos privileges (experimental)],
947 [
948 AC_MSG_CHECKING([for Solaris/Illumos privilege support])
Darren Tucker907091a2016-02-19 09:05:39 +1100949 if test "x$ac_cv_func_setppriv" = "xyes" -a \
950 "x$ac_cv_header_priv_h" = "xyes" ; then
951 SOLARIS_PRIVS=yes
Damien Miller4626cba2016-01-08 14:24:56 +1100952 AC_MSG_RESULT([found])
953 AC_DEFINE([NO_UID_RESTORATION_TEST], [1],
954 [Define to disable UID restoration test])
955 AC_DEFINE([USE_SOLARIS_PRIVS], [1],
956 [Define if you have Solaris privileges])
957 SPP_MSG="yes"
958 else
959 AC_MSG_RESULT([not found])
960 AC_MSG_ERROR([*** must have support for Solaris privileges to use --with-solaris-privs])
961 fi
962 ],
963 )
Tim Rice5ab9b632013-06-02 14:05:48 -0700964 TEST_SHELL=$SHELL # let configure find us a capable shell
Damien Miller75b1d102000-01-07 14:01:41 +1100965 ;;
Damien Millerdfc83f42000-05-20 15:02:59 +1000966*-*-sunos4*)
Ben Lindstrom28bfc0d2000-12-18 19:58:57 +0000967 CPPFLAGS="$CPPFLAGS -DSUNOS4"
Tim Rice648f8762011-01-26 12:38:57 -0800968 AC_CHECK_FUNCS([getpwanam])
969 AC_DEFINE([PAM_SUN_CODEBASE])
Damien Miller36ccb5c2000-08-09 16:34:27 +1000970 conf_utmp_location=/etc/utmp
971 conf_wtmp_location=/var/adm/wtmp
972 conf_lastlog_location=/var/adm/lastlog
Tim Rice648f8762011-01-26 12:38:57 -0800973 AC_DEFINE([USE_PIPES])
Damien Millerdfc83f42000-05-20 15:02:59 +1000974 ;;
Ben Lindstrom603bdfd2001-02-12 07:29:45 +0000975*-ncr-sysv*)
Tim Rice13aae5e2001-10-21 17:53:58 -0700976 LIBS="$LIBS -lc89"
Tim Rice648f8762011-01-26 12:38:57 -0800977 AC_DEFINE([USE_PIPES])
978 AC_DEFINE([SSHD_ACQUIRES_CTTY])
979 AC_DEFINE([SETEUID_BREAKS_SETUID])
980 AC_DEFINE([BROKEN_SETREUID])
981 AC_DEFINE([BROKEN_SETREGID])
Ben Lindstrom603bdfd2001-02-12 07:29:45 +0000982 ;;
Damien Miller2ae714f2000-07-11 09:29:50 +1000983*-sni-sysv*)
Tim Riceffdf4aa2001-10-27 10:45:36 -0700984 # /usr/ucblib MUST NOT be searched on ReliantUNIX
Tim Rice648f8762011-01-26 12:38:57 -0800985 AC_CHECK_LIB([dl], [dlsym], ,)
Darren Tucker79d09fa2005-11-24 22:34:54 +1100986 # -lresolv needs to be at the end of LIBS or DNS lookups break
Tim Rice648f8762011-01-26 12:38:57 -0800987 AC_CHECK_LIB([resolv], [res_query], [ LIBS="$LIBS -lresolv" ])
Damien Millerfd9885e2001-01-10 08:16:53 +1100988 IPADDR_IN_DISPLAY=yes
Tim Rice648f8762011-01-26 12:38:57 -0800989 AC_DEFINE([USE_PIPES])
990 AC_DEFINE([IP_TOS_IS_BROKEN])
991 AC_DEFINE([SETEUID_BREAKS_SETUID])
992 AC_DEFINE([BROKEN_SETREUID])
993 AC_DEFINE([BROKEN_SETREGID])
994 AC_DEFINE([SSHD_ACQUIRES_CTTY])
Darren Tuckere1a790d2003-09-16 11:52:19 +1000995 external_path_file=/etc/default/login
Tim Riceffdf4aa2001-10-27 10:45:36 -0700996 # /usr/ucblib/libucb.a no longer needed on ReliantUNIX
997 # Attention: always take care to bind libsocket and libnsl before libc,
998 # otherwise you will find lots of "SIOCGPGRP errno 22" on syslog
Damien Miller2ae714f2000-07-11 09:29:50 +1000999 ;;
Tim Rice0f83d292004-12-08 18:29:58 -08001000# UnixWare 1.x, UnixWare 2.x, and others based on code from Univel.
Damien Miller78315eb2000-09-29 23:01:36 +11001001*-*-sysv4.2*)
Tim Rice648f8762011-01-26 12:38:57 -08001002 AC_DEFINE([USE_PIPES])
1003 AC_DEFINE([SETEUID_BREAKS_SETUID])
1004 AC_DEFINE([BROKEN_SETREUID])
1005 AC_DEFINE([BROKEN_SETREGID])
1006 AC_DEFINE([PASSWD_NEEDS_USERNAME], [1], [must supply username to passwd])
1007 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Tim Rice5ab9b632013-06-02 14:05:48 -07001008 TEST_SHELL=$SHELL # let configure find us a capable shell
Damien Miller78315eb2000-09-29 23:01:36 +11001009 ;;
Tim Rice0f83d292004-12-08 18:29:58 -08001010# UnixWare 7.x, OpenUNIX 8
Damien Miller78315eb2000-09-29 23:01:36 +11001011*-*-sysv5*)
Tim Rice641ebf12010-01-17 17:05:39 -08001012 CPPFLAGS="$CPPFLAGS -Dvsnprintf=_xvsnprintf -Dsnprintf=_xsnprintf"
Tim Rice648f8762011-01-26 12:38:57 -08001013 AC_DEFINE([UNIXWARE_LONG_PASSWORDS], [1], [Support passwords > 8 chars])
1014 AC_DEFINE([USE_PIPES])
1015 AC_DEFINE([SETEUID_BREAKS_SETUID])
1016 AC_DEFINE([BROKEN_GETADDRINFO])
1017 AC_DEFINE([BROKEN_SETREUID])
1018 AC_DEFINE([BROKEN_SETREGID])
1019 AC_DEFINE([PASSWD_NEEDS_USERNAME])
Tim Rice8433d512017-07-11 18:47:56 -07001020 AC_DEFINE([BROKEN_TCGETATTR_ICANON])
Tim Rice5ab9b632013-06-02 14:05:48 -07001021 TEST_SHELL=$SHELL # let configure find us a capable shell
Tim Rice4dbacff2005-06-01 20:09:28 -07001022 case "$host" in
1023 *-*-sysv5SCO_SV*) # SCO OpenServer 6.x
Tim Rice90f42b02011-06-02 18:17:49 -07001024 maildir=/var/spool/mail
Tim Rice648f8762011-01-26 12:38:57 -08001025 AC_DEFINE([BROKEN_LIBIAF], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001026 [ia_uinfo routines not supported by OS yet])
Tim Rice648f8762011-01-26 12:38:57 -08001027 AC_DEFINE([BROKEN_UPDWTMPX])
1028 AC_CHECK_LIB([prot], [getluid], [ LIBS="$LIBS -lprot"
1029 AC_CHECK_FUNCS([getluid setluid], , , [-lprot])
1030 AC_DEFINE([HAVE_SECUREWARE])
1031 AC_DEFINE([DISABLE_SHADOW])
1032 ], , )
Tim Rice4dbacff2005-06-01 20:09:28 -07001033 ;;
Tim Rice648f8762011-01-26 12:38:57 -08001034 *) AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Tim Rice26767912009-01-07 20:50:08 -08001035 check_for_libcrypt_later=1
Tim Rice46259d82005-11-28 18:40:34 -08001036 ;;
Tim Rice4dbacff2005-06-01 20:09:28 -07001037 esac
Damien Miller78315eb2000-09-29 23:01:36 +11001038 ;;
Damien Miller75b1d102000-01-07 14:01:41 +11001039*-*-sysv*)
Damien Miller75b1d102000-01-07 14:01:41 +11001040 ;;
Tim Rice0f83d292004-12-08 18:29:58 -08001041# SCO UNIX and OEM versions of SCO UNIX
Damien Miller78315eb2000-09-29 23:01:36 +11001042*-*-sco3.2v4*)
Tim Ricec390c8d2005-03-07 01:21:37 -08001043 AC_MSG_ERROR("This Platform is no longer supported.")
Damien Miller78315eb2000-09-29 23:01:36 +11001044 ;;
Tim Rice0f83d292004-12-08 18:29:58 -08001045# SCO OpenServer 5.x
Damien Miller78315eb2000-09-29 23:01:36 +11001046*-*-sco3.2v5*)
Tim Rice89fe3f32003-01-19 20:20:24 -08001047 if test -z "$GCC"; then
1048 CFLAGS="$CFLAGS -belf"
1049 fi
Damien Miller5dfe9762001-02-16 12:05:39 +11001050 LIBS="$LIBS -lprot -lx -ltinfo -lm"
Damien Millera66626b2000-06-13 18:57:53 +10001051 no_dev_ptmx=1
Tim Rice648f8762011-01-26 12:38:57 -08001052 AC_DEFINE([USE_PIPES])
1053 AC_DEFINE([HAVE_SECUREWARE])
1054 AC_DEFINE([DISABLE_SHADOW])
1055 AC_DEFINE([DISABLE_FD_PASSING])
1056 AC_DEFINE([SETEUID_BREAKS_SETUID])
1057 AC_DEFINE([BROKEN_GETADDRINFO])
1058 AC_DEFINE([BROKEN_SETREUID])
1059 AC_DEFINE([BROKEN_SETREGID])
1060 AC_DEFINE([WITH_ABBREV_NO_TTY])
1061 AC_DEFINE([BROKEN_UPDWTMPX])
1062 AC_DEFINE([PASSWD_NEEDS_USERNAME])
1063 AC_CHECK_FUNCS([getluid setluid])
Tim Rice07183b82001-04-25 21:40:28 -07001064 MANTYPE=man
Tim Rice5ab9b632013-06-02 14:05:48 -07001065 TEST_SHELL=$SHELL # let configure find us a capable shell
Tim Riceaa86c392013-03-16 20:55:46 -07001066 SKIP_DISABLE_LASTLOG_DEFINE=yes
Damien Millera66626b2000-06-13 18:57:53 +10001067 ;;
Ben Lindstrom232ccf72002-07-22 23:34:25 +00001068*-*-unicosmk*)
Tim Rice648f8762011-01-26 12:38:57 -08001069 AC_DEFINE([NO_SSH_LASTLOG], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001070 [Define if you don't want to use lastlog in session.c])
Tim Rice648f8762011-01-26 12:38:57 -08001071 AC_DEFINE([SETEUID_BREAKS_SETUID])
1072 AC_DEFINE([BROKEN_SETREUID])
1073 AC_DEFINE([BROKEN_SETREGID])
1074 AC_DEFINE([USE_PIPES])
1075 AC_DEFINE([DISABLE_FD_PASSING])
Ben Lindstrom232ccf72002-07-22 23:34:25 +00001076 LDFLAGS="$LDFLAGS"
1077 LIBS="$LIBS -lgen -lrsc -lshare -luex -lacm"
1078 MANTYPE=cat
Ben Lindstrom762104e2002-07-23 00:00:05 +00001079 ;;
Darren Tucker9f7ffc52003-09-10 11:39:05 +10001080*-*-unicosmp*)
Tim Rice648f8762011-01-26 12:38:57 -08001081 AC_DEFINE([SETEUID_BREAKS_SETUID])
1082 AC_DEFINE([BROKEN_SETREUID])
1083 AC_DEFINE([BROKEN_SETREGID])
1084 AC_DEFINE([WITH_ABBREV_NO_TTY])
1085 AC_DEFINE([USE_PIPES])
1086 AC_DEFINE([DISABLE_FD_PASSING])
Darren Tucker9f7ffc52003-09-10 11:39:05 +10001087 LDFLAGS="$LDFLAGS"
Darren Tucker2df33432004-01-30 14:34:21 +11001088 LIBS="$LIBS -lgen -lacid -ldb"
Darren Tucker9f7ffc52003-09-10 11:39:05 +10001089 MANTYPE=cat
1090 ;;
Ben Lindstromd9e08242001-07-22 19:32:00 +00001091*-*-unicos*)
Tim Rice648f8762011-01-26 12:38:57 -08001092 AC_DEFINE([SETEUID_BREAKS_SETUID])
1093 AC_DEFINE([BROKEN_SETREUID])
1094 AC_DEFINE([BROKEN_SETREGID])
1095 AC_DEFINE([USE_PIPES])
1096 AC_DEFINE([DISABLE_FD_PASSING])
1097 AC_DEFINE([NO_SSH_LASTLOG])
Ben Lindstrom232ccf72002-07-22 23:34:25 +00001098 LDFLAGS="$LDFLAGS -Wl,-Dmsglevel=334:fatal"
1099 LIBS="$LIBS -lgen -lrsc -lshare -luex -lacm"
1100 MANTYPE=cat
Tim Ricee991e3c2001-08-07 15:29:07 -07001101 ;;
Damien Millerb8c656e2000-06-28 15:22:41 +10001102*-dec-osf*)
Tim Rice648f8762011-01-26 12:38:57 -08001103 AC_MSG_CHECKING([for Digital Unix SIA])
Ben Lindstrom72af2ef2001-05-08 20:42:28 +00001104 no_osfsia=""
Tim Rice648f8762011-01-26 12:38:57 -08001105 AC_ARG_WITH([osfsia],
Ben Lindstrom72af2ef2001-05-08 20:42:28 +00001106 [ --with-osfsia Enable Digital Unix SIA],
1107 [
1108 if test "x$withval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08001109 AC_MSG_RESULT([disabled])
Ben Lindstrom72af2ef2001-05-08 20:42:28 +00001110 no_osfsia=1
1111 fi
1112 ],
1113 )
1114 if test -z "$no_osfsia" ; then
Damien Millerb8c656e2000-06-28 15:22:41 +10001115 if test -f /etc/sia/matrix.conf; then
Tim Rice648f8762011-01-26 12:38:57 -08001116 AC_MSG_RESULT([yes])
1117 AC_DEFINE([HAVE_OSF_SIA], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001118 [Define if you have Digital Unix Security
1119 Integration Architecture])
Tim Rice648f8762011-01-26 12:38:57 -08001120 AC_DEFINE([DISABLE_LOGIN], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001121 [Define if you don't want to use your
1122 system's login() call])
Tim Rice648f8762011-01-26 12:38:57 -08001123 AC_DEFINE([DISABLE_FD_PASSING])
Damien Millerb8c656e2000-06-28 15:22:41 +10001124 LIBS="$LIBS -lsecurity -ldb -lm -laud"
Damien Miller1b06dc32006-08-31 03:24:41 +10001125 SIA_MSG="yes"
Damien Millerb8c656e2000-06-28 15:22:41 +10001126 else
Tim Rice648f8762011-01-26 12:38:57 -08001127 AC_MSG_RESULT([no])
1128 AC_DEFINE([LOCKED_PASSWD_SUBSTR], ["Nologin"],
Tim Rice7df8d392005-09-19 09:33:39 -07001129 [String used in /etc/passwd to denote locked account])
Damien Millerb8c656e2000-06-28 15:22:41 +10001130 fi
1131 fi
Tim Rice648f8762011-01-26 12:38:57 -08001132 AC_DEFINE([BROKEN_GETADDRINFO])
1133 AC_DEFINE([SETEUID_BREAKS_SETUID])
1134 AC_DEFINE([BROKEN_SETREUID])
1135 AC_DEFINE([BROKEN_SETREGID])
1136 AC_DEFINE([BROKEN_READV_COMPARISON], [1], [Can't do comparisons on readv])
Damien Millerb8c656e2000-06-28 15:22:41 +10001137 ;;
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00001138
Tim Rice70335a62006-02-04 17:42:58 -08001139*-*-nto-qnx*)
Tim Rice648f8762011-01-26 12:38:57 -08001140 AC_DEFINE([USE_PIPES])
1141 AC_DEFINE([NO_X11_UNIX_SOCKETS])
Tim Rice648f8762011-01-26 12:38:57 -08001142 AC_DEFINE([DISABLE_LASTLOG])
1143 AC_DEFINE([SSHD_ACQUIRES_CTTY])
1144 AC_DEFINE([BROKEN_SHADOW_EXPIRE], [1], [QNX shadow support is broken])
Tim Rice2f993462006-02-11 18:37:48 -08001145 enable_etc_default_login=no # has incompatible /etc/default/login
Darren Tucker8acb3b62007-08-10 14:36:12 +10001146 case "$host" in
1147 *-*-nto-qnx6*)
Tim Rice648f8762011-01-26 12:38:57 -08001148 AC_DEFINE([DISABLE_FD_PASSING])
Darren Tucker8acb3b62007-08-10 14:36:12 +10001149 ;;
1150 esac
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00001151 ;;
Darren Tucker2be1cbb2005-05-27 21:13:40 +10001152
1153*-*-ultrix*)
Tim Rice648f8762011-01-26 12:38:57 -08001154 AC_DEFINE([BROKEN_GETGROUPS], [1], [getgroups(0,NULL) will return -1])
Tim Rice648f8762011-01-26 12:38:57 -08001155 AC_DEFINE([NEED_SETPGRP])
1156 AC_DEFINE([HAVE_SYS_SYSLOG_H], [1], [Force use of sys/syslog.h on Ultrix])
Tim Ricefcc7ff12005-06-02 20:28:29 -07001157 ;;
Darren Tucker93e7e8f2005-08-23 08:06:55 +10001158
1159*-*-lynxos)
Darren Tucker5faa52d2016-08-02 15:22:40 +10001160 CFLAGS="$CFLAGS -D__NO_INCLUDE_WARN__"
1161 AC_DEFINE([BROKEN_SETVBUF], [1],
1162 [LynxOS has broken setvbuf() implementation])
1163 ;;
Damien Miller76112de1999-12-21 11:18:08 +11001164esac
1165
Tim Rice648f8762011-01-26 12:38:57 -08001166AC_MSG_CHECKING([compiler and flags for sanity])
1167AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]], [[ exit(0); ]])],
1168 [ AC_MSG_RESULT([yes]) ],
Darren Tucker6eb93042003-06-29 21:30:41 +10001169 [
Tim Rice648f8762011-01-26 12:38:57 -08001170 AC_MSG_RESULT([no])
Darren Tucker6eb93042003-06-29 21:30:41 +10001171 AC_MSG_ERROR([*** compiler cannot create working executables, check config.log ***])
Darren Tuckera0c2b392004-09-11 23:26:37 +10001172 ],
1173 [ AC_MSG_WARN([cross compiling: not checking compiler sanity]) ]
Darren Tucker6eb93042003-06-29 21:30:41 +10001174)
1175
Darren Tucker0c9653f2005-05-28 15:58:14 +10001176dnl Checks for header files.
Damien Millera22ba012000-03-02 23:09:20 +11001177# Checks for libraries.
Tim Rice648f8762011-01-26 12:38:57 -08001178AC_CHECK_FUNC([setsockopt], , [AC_CHECK_LIB([socket], [setsockopt])])
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00001179
Tim Rice1e1ef642003-09-11 22:19:31 -07001180dnl IRIX and Solaris 2.5.1 have dirname() in libgen
Tim Rice648f8762011-01-26 12:38:57 -08001181AC_CHECK_FUNCS([dirname], [AC_CHECK_HEADERS([libgen.h])] , [
1182 AC_CHECK_LIB([gen], [dirname], [
Tim Rice1e1ef642003-09-11 22:19:31 -07001183 AC_CACHE_CHECK([for broken dirname],
1184 ac_cv_have_broken_dirname, [
1185 save_LIBS="$LIBS"
1186 LIBS="$LIBS -lgen"
Darren Tucker314d89e2005-10-17 23:29:23 +10001187 AC_RUN_IFELSE(
1188 [AC_LANG_SOURCE([[
Tim Rice1e1ef642003-09-11 22:19:31 -07001189#include <libgen.h>
1190#include <string.h>
1191
1192int main(int argc, char **argv) {
1193 char *s, buf[32];
1194
1195 strncpy(buf,"/etc", 32);
1196 s = dirname(buf);
1197 if (!s || strncmp(s, "/", 32) != 0) {
1198 exit(1);
1199 } else {
1200 exit(0);
1201 }
1202}
Darren Tucker314d89e2005-10-17 23:29:23 +10001203 ]])],
Tim Rice1e1ef642003-09-11 22:19:31 -07001204 [ ac_cv_have_broken_dirname="no" ],
Darren Tucker314d89e2005-10-17 23:29:23 +10001205 [ ac_cv_have_broken_dirname="yes" ],
1206 [ ac_cv_have_broken_dirname="no" ],
Tim Rice1e1ef642003-09-11 22:19:31 -07001207 )
1208 LIBS="$save_LIBS"
1209 ])
1210 if test "x$ac_cv_have_broken_dirname" = "xno" ; then
1211 LIBS="$LIBS -lgen"
Tim Rice648f8762011-01-26 12:38:57 -08001212 AC_DEFINE([HAVE_DIRNAME])
1213 AC_CHECK_HEADERS([libgen.h])
Tim Rice1e1ef642003-09-11 22:19:31 -07001214 fi
1215 ])
1216])
1217
Tim Rice648f8762011-01-26 12:38:57 -08001218AC_CHECK_FUNC([getspnam], ,
1219 [AC_CHECK_LIB([gen], [getspnam], [LIBS="$LIBS -lgen"])])
1220AC_SEARCH_LIBS([basename], [gen], [AC_DEFINE([HAVE_BASENAME], [1],
1221 [Define if you have the basename function.])])
Tim Rice1e1ef642003-09-11 22:19:31 -07001222
Tim Rice13aae5e2001-10-21 17:53:58 -07001223dnl zlib is required
Tim Rice648f8762011-01-26 12:38:57 -08001224AC_ARG_WITH([zlib],
Tim Rice13aae5e2001-10-21 17:53:58 -07001225 [ --with-zlib=PATH Use zlib in PATH],
Darren Tucker86a5f8d2005-03-21 09:55:17 +11001226 [ if test "x$withval" = "xno" ; then
1227 AC_MSG_ERROR([*** zlib is required ***])
1228 elif test "x$withval" != "xyes"; then
Tim Rice13aae5e2001-10-21 17:53:58 -07001229 if test -d "$withval/lib"; then
1230 if test -n "${need_dash_r}"; then
Tim Rice02cebcd2001-10-25 10:01:30 -07001231 LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001232 else
Tim Rice02cebcd2001-10-25 10:01:30 -07001233 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001234 fi
1235 else
1236 if test -n "${need_dash_r}"; then
Tim Rice02cebcd2001-10-25 10:01:30 -07001237 LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001238 else
Tim Rice02cebcd2001-10-25 10:01:30 -07001239 LDFLAGS="-L${withval} ${LDFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001240 fi
1241 fi
1242 if test -d "$withval/include"; then
Tim Rice02cebcd2001-10-25 10:01:30 -07001243 CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001244 else
Tim Rice02cebcd2001-10-25 10:01:30 -07001245 CPPFLAGS="-I${withval} ${CPPFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001246 fi
Darren Tucker86a5f8d2005-03-21 09:55:17 +11001247 fi ]
Tim Rice13aae5e2001-10-21 17:53:58 -07001248)
1249
Tim Rice648f8762011-01-26 12:38:57 -08001250AC_CHECK_HEADER([zlib.h], ,[AC_MSG_ERROR([*** zlib.h missing - please install first or check config.log ***])])
1251AC_CHECK_LIB([z], [deflate], ,
Tim Ricefcb62202004-01-23 18:35:16 -08001252 [
1253 saved_CPPFLAGS="$CPPFLAGS"
1254 saved_LDFLAGS="$LDFLAGS"
1255 save_LIBS="$LIBS"
1256 dnl Check default zlib install dir
1257 if test -n "${need_dash_r}"; then
1258 LDFLAGS="-L/usr/local/lib -R/usr/local/lib ${saved_LDFLAGS}"
1259 else
1260 LDFLAGS="-L/usr/local/lib ${saved_LDFLAGS}"
1261 fi
1262 CPPFLAGS="-I/usr/local/include ${saved_CPPFLAGS}"
1263 LIBS="$LIBS -lz"
Tim Rice648f8762011-01-26 12:38:57 -08001264 AC_TRY_LINK_FUNC([deflate], [AC_DEFINE([HAVE_LIBZ])],
Tim Ricefcb62202004-01-23 18:35:16 -08001265 [
1266 AC_MSG_ERROR([*** zlib missing - please install first or check config.log ***])
1267 ]
1268 )
1269 ]
1270)
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001271
Tim Rice648f8762011-01-26 12:38:57 -08001272AC_ARG_WITH([zlib-version-check],
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001273 [ --without-zlib-version-check Disable zlib version check],
1274 [ if test "x$withval" = "xno" ; then
1275 zlib_check_nonfatal=1
1276 fi
1277 ]
1278)
1279
Tim Rice648f8762011-01-26 12:38:57 -08001280AC_MSG_CHECKING([for possibly buggy zlib])
1281AC_RUN_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001282#include <stdio.h>
Darren Tuckerc8a0f272013-03-22 12:49:14 +11001283#include <stdlib.h>
Darren Tucker2dcd2392004-01-23 17:13:33 +11001284#include <zlib.h>
Tim Rice648f8762011-01-26 12:38:57 -08001285 ]],
1286 [[
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001287 int a=0, b=0, c=0, d=0, n, v;
1288 n = sscanf(ZLIB_VERSION, "%d.%d.%d.%d", &a, &b, &c, &d);
1289 if (n != 3 && n != 4)
Darren Tucker2dcd2392004-01-23 17:13:33 +11001290 exit(1);
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001291 v = a*1000000 + b*10000 + c*100 + d;
1292 fprintf(stderr, "found zlib version %s (%d)\n", ZLIB_VERSION, v);
1293
1294 /* 1.1.4 is OK */
1295 if (a == 1 && b == 1 && c >= 4)
Darren Tucker2dcd2392004-01-23 17:13:33 +11001296 exit(0);
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001297
Darren Tucker41097ed2005-07-25 15:24:21 +10001298 /* 1.2.3 and up are OK */
1299 if (v >= 1020300)
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001300 exit(0);
1301
Darren Tucker2dcd2392004-01-23 17:13:33 +11001302 exit(2);
Darren Tucker623d92f2004-09-12 22:36:15 +10001303 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001304 AC_MSG_RESULT([no]),
1305 [ AC_MSG_RESULT([yes])
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001306 if test -z "$zlib_check_nonfatal" ; then
1307 AC_MSG_ERROR([*** zlib too old - check config.log ***
1308Your reported zlib version has known security problems. It's possible your
1309vendor has fixed these problems without changing the version number. If you
1310are sure this is the case, you can disable the check by running
1311"./configure --without-zlib-version-check".
Darren Tuckerac1910f2005-07-26 12:00:42 +10001312If you are in doubt, upgrade zlib to version 1.2.3 or greater.
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001313See http://www.gzip.org/zlib/ for details.])
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001314 else
1315 AC_MSG_WARN([zlib version may have security problems])
1316 fi
Darren Tuckera0c2b392004-09-11 23:26:37 +10001317 ],
1318 [ AC_MSG_WARN([cross compiling: not checking zlib version]) ]
Darren Tucker2dcd2392004-01-23 17:13:33 +11001319)
Damien Miller6f9c3372000-10-25 10:06:04 +11001320
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00001321dnl UnixWare 2.x
Tim Rice648f8762011-01-26 12:38:57 -08001322AC_CHECK_FUNC([strcasecmp],
1323 [], [ AC_CHECK_LIB([resolv], [strcasecmp], [LIBS="$LIBS -lresolv"]) ]
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00001324)
Tim Rice648f8762011-01-26 12:38:57 -08001325AC_CHECK_FUNCS([utimes],
1326 [], [ AC_CHECK_LIB([c89], [utimes], [AC_DEFINE([HAVE_UTIMES])
Tim Ricecbb90662002-07-08 19:17:10 -07001327 LIBS="$LIBS -lc89"]) ]
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00001328)
Damien Millerab18c411999-11-11 10:40:23 +11001329
Tim Ricee589a292001-11-03 11:09:32 -08001330dnl Checks for libutil functions
Damien Millerb87f6b72013-02-23 09:12:23 +11001331AC_CHECK_HEADERS([bsd/libutil.h libutil.h])
Damien Miller398c0ff2012-04-19 21:46:35 +10001332AC_SEARCH_LIBS([fmt_scaled], [util bsd])
Darren Tuckere194ba42013-05-16 20:47:31 +10001333AC_SEARCH_LIBS([scan_scaled], [util bsd])
Damien Miller398c0ff2012-04-19 21:46:35 +10001334AC_SEARCH_LIBS([login], [util bsd])
1335AC_SEARCH_LIBS([logout], [util bsd])
1336AC_SEARCH_LIBS([logwtmp], [util bsd])
1337AC_SEARCH_LIBS([openpty], [util bsd])
1338AC_SEARCH_LIBS([updwtmp], [util bsd])
Darren Tuckere194ba42013-05-16 20:47:31 +10001339AC_CHECK_FUNCS([fmt_scaled scan_scaled login logout openpty updwtmp logwtmp])
Tim Ricee589a292001-11-03 11:09:32 -08001340
Darren Tucker2fee9092016-02-17 09:48:15 +11001341# On some platforms, inet_ntop and gethostbyname may be found in libresolv
1342# or libnsl.
Damien Millerab039492014-01-28 15:07:10 +11001343AC_SEARCH_LIBS([inet_ntop], [resolv nsl])
Darren Tucker2fee9092016-02-17 09:48:15 +11001344AC_SEARCH_LIBS([gethostbyname], [resolv nsl])
Damien Millerab039492014-01-28 15:07:10 +11001345
Darren Tucker74c1c362017-09-27 07:44:41 +10001346# "Particular Function Checks"
1347# see https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Particular-Functions.html
Ben Lindstrom8697e082001-02-24 21:41:10 +00001348AC_FUNC_STRFTIME
Darren Tucker74c1c362017-09-27 07:44:41 +10001349AC_FUNC_MALLOC
1350AC_FUNC_REALLOC
1351# autoconf doesn't have AC_FUNC_CALLOC so fake it if malloc returns NULL;
1352if test "x$ac_cv_func_malloc_0_nonnull" != "xyes"; then
1353 AC_DEFINE(HAVE_CALLOC, 0, [calloc(x, 0) returns NULL])
1354 AC_DEFINE(calloc, rpl_calloc,
1355 [Define to rpl_calloc if the replacement function should be used.])
1356fi
Ben Lindstrom8697e082001-02-24 21:41:10 +00001357
Damien Miller3c027682001-03-14 11:39:45 +11001358# Check for ALTDIRFUNC glob() extension
Tim Rice648f8762011-01-26 12:38:57 -08001359AC_MSG_CHECKING([for GLOB_ALTDIRFUNC support])
1360AC_EGREP_CPP([FOUNDIT],
Damien Miller3c027682001-03-14 11:39:45 +11001361 [
1362 #include <glob.h>
1363 #ifdef GLOB_ALTDIRFUNC
1364 FOUNDIT
1365 #endif
Damien Millera8e06ce2003-11-21 23:48:55 +11001366 ],
Damien Miller3c027682001-03-14 11:39:45 +11001367 [
Tim Rice648f8762011-01-26 12:38:57 -08001368 AC_DEFINE([GLOB_HAS_ALTDIRFUNC], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001369 [Define if your system glob() function has
1370 the GLOB_ALTDIRFUNC extension])
Tim Rice648f8762011-01-26 12:38:57 -08001371 AC_MSG_RESULT([yes])
Damien Miller3c027682001-03-14 11:39:45 +11001372 ],
1373 [
Tim Rice648f8762011-01-26 12:38:57 -08001374 AC_MSG_RESULT([no])
Damien Miller3c027682001-03-14 11:39:45 +11001375 ]
1376)
Damien Millerab18c411999-11-11 10:40:23 +11001377
Ben Lindstrom45b14db2001-03-17 01:15:38 +00001378# Check for g.gl_matchc glob() extension
Tim Rice648f8762011-01-26 12:38:57 -08001379AC_MSG_CHECKING([for gl_matchc field in glob_t])
1380AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <glob.h> ]],
1381 [[ glob_t g; g.gl_matchc = 1; ]])],
Damien Millera8e06ce2003-11-21 23:48:55 +11001382 [
Tim Rice648f8762011-01-26 12:38:57 -08001383 AC_DEFINE([GLOB_HAS_GL_MATCHC], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001384 [Define if your system glob() function has
1385 gl_matchc options in glob_t])
Tim Rice648f8762011-01-26 12:38:57 -08001386 AC_MSG_RESULT([yes])
1387 ], [
1388 AC_MSG_RESULT([no])
1389])
Ben Lindstrom45b14db2001-03-17 01:15:38 +00001390
Damien Millera6e121a2010-10-07 21:39:17 +11001391# Check for g.gl_statv glob() extension
Tim Rice648f8762011-01-26 12:38:57 -08001392AC_MSG_CHECKING([for gl_statv and GLOB_KEEPSTAT extensions for glob])
1393AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <glob.h> ]], [[
Damien Millera6e121a2010-10-07 21:39:17 +11001394#ifndef GLOB_KEEPSTAT
1395#error "glob does not support GLOB_KEEPSTAT extension"
1396#endif
1397glob_t g;
1398g.gl_statv = NULL;
Tim Rice648f8762011-01-26 12:38:57 -08001399]])],
Damien Millera6e121a2010-10-07 21:39:17 +11001400 [
Tim Rice648f8762011-01-26 12:38:57 -08001401 AC_DEFINE([GLOB_HAS_GL_STATV], [1],
Damien Millera6e121a2010-10-07 21:39:17 +11001402 [Define if your system glob() function has
1403 gl_statv options in glob_t])
Tim Rice648f8762011-01-26 12:38:57 -08001404 AC_MSG_RESULT([yes])
1405 ], [
1406 AC_MSG_RESULT([no])
Damien Miller72ef7c12015-01-15 02:21:31 +11001407
Tim Rice648f8762011-01-26 12:38:57 -08001408])
Damien Millera6e121a2010-10-07 21:39:17 +11001409
Tim Rice648f8762011-01-26 12:38:57 -08001410AC_CHECK_DECLS([GLOB_NOMATCH], , , [#include <glob.h>])
Darren Tucker096faec2006-09-01 20:29:10 +10001411
Darren Tucker7df91b02016-07-14 12:25:24 +10001412AC_CHECK_DECL([VIS_ALL], ,
1413 AC_DEFINE(BROKEN_STRNVIS, 1, [missing VIS_ALL]), [#include <vis.h>])
1414
Damien Miller18bb4732001-03-28 14:35:30 +10001415AC_MSG_CHECKING([whether struct dirent allocates space for d_name])
Darren Tuckera0c2b392004-09-11 23:26:37 +10001416AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001417 [AC_LANG_PROGRAM([[
Damien Miller18bb4732001-03-28 14:35:30 +10001418#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08001419#include <dirent.h>]],
1420 [[
1421 struct dirent d;
1422 exit(sizeof(d.d_name)<=sizeof(char));
Darren Tucker623d92f2004-09-12 22:36:15 +10001423 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001424 [AC_MSG_RESULT([yes])],
Damien Miller18bb4732001-03-28 14:35:30 +10001425 [
Tim Rice648f8762011-01-26 12:38:57 -08001426 AC_MSG_RESULT([no])
1427 AC_DEFINE([BROKEN_ONE_BYTE_DIRENT_D_NAME], [1],
Darren Tucker79d09fa2005-11-24 22:34:54 +11001428 [Define if your struct dirent expects you to
Tim Rice7df8d392005-09-19 09:33:39 -07001429 allocate extra space for d_name])
Darren Tuckera0c2b392004-09-11 23:26:37 +10001430 ],
Tim Riceeae17cc2005-03-17 16:52:20 -08001431 [
Darren Tuckera0c2b392004-09-11 23:26:37 +10001432 AC_MSG_WARN([cross compiling: assuming BROKEN_ONE_BYTE_DIRENT_D_NAME])
Tim Rice648f8762011-01-26 12:38:57 -08001433 AC_DEFINE([BROKEN_ONE_BYTE_DIRENT_D_NAME])
Damien Miller18bb4732001-03-28 14:35:30 +10001434 ]
1435)
1436
Damien Miller36f49652004-08-15 18:40:59 +10001437AC_MSG_CHECKING([for /proc/pid/fd directory])
1438if test -d "/proc/$$/fd" ; then
Tim Rice648f8762011-01-26 12:38:57 -08001439 AC_DEFINE([HAVE_PROC_PID], [1], [Define if you have /proc/$pid/fd])
1440 AC_MSG_RESULT([yes])
Damien Miller36f49652004-08-15 18:40:59 +10001441else
Tim Rice648f8762011-01-26 12:38:57 -08001442 AC_MSG_RESULT([no])
Damien Miller36f49652004-08-15 18:40:59 +10001443fi
1444
Damien Millerc547bf12001-02-16 10:18:12 +11001445# Check whether user wants S/Key support
Damien Millera8e06ce2003-11-21 23:48:55 +11001446SKEY_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08001447AC_ARG_WITH([skey],
Darren Tucker1b6f2292005-02-11 16:11:49 +11001448 [ --with-skey[[=PATH]] Enable S/Key support (optionally in PATH)],
Damien Millerc547bf12001-02-16 10:18:12 +11001449 [
1450 if test "x$withval" != "xno" ; then
1451
1452 if test "x$withval" != "xyes" ; then
1453 CPPFLAGS="$CPPFLAGS -I${withval}/include"
1454 LDFLAGS="$LDFLAGS -L${withval}/lib"
1455 fi
1456
Tim Rice648f8762011-01-26 12:38:57 -08001457 AC_DEFINE([SKEY], [1], [Define if you want S/Key support])
Damien Millerc547bf12001-02-16 10:18:12 +11001458 LIBS="-lskey $LIBS"
Damien Millera8e06ce2003-11-21 23:48:55 +11001459 SKEY_MSG="yes"
Tim Riceeae17cc2005-03-17 16:52:20 -08001460
Tim Rice4cec93f2002-02-26 08:40:48 -08001461 AC_MSG_CHECKING([for s/key support])
Darren Tucker314d89e2005-10-17 23:29:23 +10001462 AC_LINK_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001463 [AC_LANG_PROGRAM([[
Tim Rice4cec93f2002-02-26 08:40:48 -08001464#include <stdio.h>
1465#include <skey.h>
Tim Rice648f8762011-01-26 12:38:57 -08001466 ]], [[
1467 char *ff = skey_keyinfo(""); ff="";
1468 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10001469 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001470 [AC_MSG_RESULT([yes])],
Tim Rice4cec93f2002-02-26 08:40:48 -08001471 [
Tim Rice648f8762011-01-26 12:38:57 -08001472 AC_MSG_RESULT([no])
Damien Millerc547bf12001-02-16 10:18:12 +11001473 AC_MSG_ERROR([** Incomplete or missing s/key libraries.])
1474 ])
Tim Ricee1d93702016-05-31 11:13:22 -07001475 AC_MSG_CHECKING([if skeychallenge takes 4 arguments])
Tim Rice648f8762011-01-26 12:38:57 -08001476 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1477#include <stdio.h>
1478#include <skey.h>
1479 ]], [[
1480 (void)skeychallenge(NULL,"name","",0);
1481 ]])],
1482 [
1483 AC_MSG_RESULT([yes])
1484 AC_DEFINE([SKEYCHALLENGE_4ARG], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001485 [Define if your skeychallenge()
1486 function takes 4 arguments (NetBSD)])],
Tim Rice648f8762011-01-26 12:38:57 -08001487 [
1488 AC_MSG_RESULT([no])
1489 ])
Damien Millerc547bf12001-02-16 10:18:12 +11001490 fi
1491 ]
1492)
1493
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001494# Check whether user wants to use ldns
1495LDNS_MSG="no"
1496AC_ARG_WITH(ldns,
1497 [ --with-ldns[[=PATH]] Use ldns for DNSSEC support (optionally in PATH)],
Damien Miller523db852017-02-03 16:01:22 +11001498 [
1499 ldns=""
1500 if test "x$withval" = "xyes" ; then
1501 AC_PATH_TOOL([LDNSCONFIG], [ldns-config], [no])
Darren Tuckerf001de82017-12-11 13:42:51 +11001502 if test "x$LDNSCONFIG" = "xno"; then
Damien Miller523db852017-02-03 16:01:22 +11001503 CPPFLAGS="$CPPFLAGS -I${withval}/include"
1504 LDFLAGS="$LDFLAGS -L${withval}/lib"
1505 LIBS="-lldns $LIBS"
1506 ldns=yes
1507 else
1508 LIBS="$LIBS `$LDNSCONFIG --libs`"
1509 CPPFLAGS="$CPPFLAGS `$LDNSCONFIG --cflags`"
Darren Tucker7af27bf2017-03-24 09:44:56 +11001510 ldns=yes
Damien Miller523db852017-02-03 16:01:22 +11001511 fi
1512 elif test "x$withval" != "xno" ; then
1513 CPPFLAGS="$CPPFLAGS -I${withval}/include"
1514 LDFLAGS="$LDFLAGS -L${withval}/lib"
1515 LIBS="-lldns $LIBS"
1516 ldns=yes
1517 fi
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001518
Damien Miller523db852017-02-03 16:01:22 +11001519 # Verify that it works.
1520 if test "x$ldns" = "xyes" ; then
1521 AC_DEFINE(HAVE_LDNS, 1, [Define if you want ldns support])
1522 LDNS_MSG="yes"
1523 AC_MSG_CHECKING([for ldns support])
1524 AC_LINK_IFELSE(
1525 [AC_LANG_SOURCE([[
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001526#include <stdio.h>
1527#include <stdlib.h>
1528#include <stdint.h>
1529#include <ldns/ldns.h>
1530int main() { ldns_status status = ldns_verify_trusted(NULL, NULL, NULL, NULL); status=LDNS_STATUS_OK; exit(0); }
Damien Miller523db852017-02-03 16:01:22 +11001531 ]])
1532 ],
1533 [AC_MSG_RESULT(yes)],
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001534 [
1535 AC_MSG_RESULT(no)
1536 AC_MSG_ERROR([** Incomplete or missing ldns libraries.])
1537 ])
Damien Miller523db852017-02-03 16:01:22 +11001538 fi
1539])
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001540
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001541# Check whether user wants libedit support
1542LIBEDIT_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08001543AC_ARG_WITH([libedit],
Darren Tucker1b6f2292005-02-11 16:11:49 +11001544 [ --with-libedit[[=PATH]] Enable libedit support for sftp],
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001545 [ if test "x$withval" != "xno" ; then
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001546 if test "x$withval" = "xyes" ; then
Darren Tucker59353892012-05-19 15:24:37 +10001547 AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no])
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001548 if test "x$PKGCONFIG" != "xno"; then
Tim Rice648f8762011-01-26 12:38:57 -08001549 AC_MSG_CHECKING([if $PKGCONFIG knows about libedit])
Tim Ricee1d93702016-05-31 11:13:22 -07001550 if "$PKGCONFIG" libedit; then
Tim Rice648f8762011-01-26 12:38:57 -08001551 AC_MSG_RESULT([yes])
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001552 use_pkgconfig_for_libedit=yes
1553 else
Tim Rice648f8762011-01-26 12:38:57 -08001554 AC_MSG_RESULT([no])
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001555 fi
1556 fi
1557 else
Darren Tuckerc373a562005-09-22 20:15:08 +10001558 CPPFLAGS="$CPPFLAGS -I${withval}/include"
1559 if test -n "${need_dash_r}"; then
1560 LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
1561 else
1562 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
1563 fi
Darren Tucker1df61452005-03-21 09:58:07 +11001564 fi
Damien Miller1f789802010-10-11 22:35:22 +11001565 if test "x$use_pkgconfig_for_libedit" = "xyes"; then
Darren Tucker8369c8e2013-12-05 11:00:16 +11001566 LIBEDIT=`$PKGCONFIG --libs libedit`
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001567 CPPFLAGS="$CPPFLAGS `$PKGCONFIG --cflags libedit`"
1568 else
1569 LIBEDIT="-ledit -lcurses"
1570 fi
1571 OTHERLIBS=`echo $LIBEDIT | sed 's/-ledit//'`
Tim Rice648f8762011-01-26 12:38:57 -08001572 AC_CHECK_LIB([edit], [el_init],
1573 [ AC_DEFINE([USE_LIBEDIT], [1], [Use libedit for sftp])
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001574 LIBEDIT_MSG="yes"
Tim Rice648f8762011-01-26 12:38:57 -08001575 AC_SUBST([LIBEDIT])
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001576 ],
Tim Rice648f8762011-01-26 12:38:57 -08001577 [ AC_MSG_ERROR([libedit not found]) ],
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001578 [ $OTHERLIBS ]
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001579 )
Tim Rice648f8762011-01-26 12:38:57 -08001580 AC_MSG_CHECKING([if libedit version is compatible])
Tim Ricec1819c82005-08-15 17:48:40 -07001581 AC_COMPILE_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001582 [AC_LANG_PROGRAM([[ #include <histedit.h> ]],
1583 [[
Darren Tuckerc7572b22005-08-10 20:34:15 +10001584 int i = H_SETSIZE;
1585 el_init("", NULL, NULL, NULL);
1586 exit(0);
Tim Ricec1819c82005-08-15 17:48:40 -07001587 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001588 [ AC_MSG_RESULT([yes]) ],
1589 [ AC_MSG_RESULT([no])
1590 AC_MSG_ERROR([libedit version is not compatible]) ]
Darren Tuckerc7572b22005-08-10 20:34:15 +10001591 )
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001592 fi ]
1593)
1594
Darren Tuckerd9f88912005-02-20 21:01:48 +11001595AUDIT_MODULE=none
Tim Rice648f8762011-01-26 12:38:57 -08001596AC_ARG_WITH([audit],
Darren Tuckerea52a822011-01-17 21:15:27 +11001597 [ --with-audit=module Enable audit support (modules=debug,bsm,linux)],
Darren Tuckerd9f88912005-02-20 21:01:48 +11001598 [
Tim Rice648f8762011-01-26 12:38:57 -08001599 AC_MSG_CHECKING([for supported audit module])
Darren Tuckerd9f88912005-02-20 21:01:48 +11001600 case "$withval" in
1601 bsm)
Tim Rice648f8762011-01-26 12:38:57 -08001602 AC_MSG_RESULT([bsm])
Darren Tuckerd9f88912005-02-20 21:01:48 +11001603 AUDIT_MODULE=bsm
1604 dnl Checks for headers, libs and functions
Tim Rice648f8762011-01-26 12:38:57 -08001605 AC_CHECK_HEADERS([bsm/audit.h], [],
1606 [AC_MSG_ERROR([BSM enabled and bsm/audit.h not found])],
Darren Tucker6d0d6fb2006-09-09 01:05:21 +10001607 [
1608#ifdef HAVE_TIME_H
1609# include <time.h>
1610#endif
1611 ]
1612)
Tim Rice648f8762011-01-26 12:38:57 -08001613 AC_CHECK_LIB([bsm], [getaudit], [],
1614 [AC_MSG_ERROR([BSM enabled and required library not found])])
1615 AC_CHECK_FUNCS([getaudit], [],
1616 [AC_MSG_ERROR([BSM enabled and required function not found])])
Darren Tuckerd9f88912005-02-20 21:01:48 +11001617 # These are optional
Tim Rice648f8762011-01-26 12:38:57 -08001618 AC_CHECK_FUNCS([getaudit_addr aug_get_machine])
1619 AC_DEFINE([USE_BSM_AUDIT], [1], [Use BSM audit module])
Darren Tucker1fcec9d2013-12-19 11:00:12 +11001620 if test "$sol2ver" -ge 11; then
Tim Ricee1d93702016-05-31 11:13:22 -07001621 SSHDLIBS="$SSHDLIBS -lscf"
1622 AC_DEFINE([BROKEN_BSM_API], [1],
1623 [The system has incomplete BSM API])
Darren Tucker93a2d412012-02-24 10:40:41 +11001624 fi
Darren Tuckerd9f88912005-02-20 21:01:48 +11001625 ;;
Darren Tuckerea52a822011-01-17 21:15:27 +11001626 linux)
Tim Rice648f8762011-01-26 12:38:57 -08001627 AC_MSG_RESULT([linux])
Darren Tuckerea52a822011-01-17 21:15:27 +11001628 AUDIT_MODULE=linux
1629 dnl Checks for headers, libs and functions
Tim Rice648f8762011-01-26 12:38:57 -08001630 AC_CHECK_HEADERS([libaudit.h])
Darren Tuckerea52a822011-01-17 21:15:27 +11001631 SSHDLIBS="$SSHDLIBS -laudit"
Tim Rice648f8762011-01-26 12:38:57 -08001632 AC_DEFINE([USE_LINUX_AUDIT], [1], [Use Linux audit module])
Darren Tuckerea52a822011-01-17 21:15:27 +11001633 ;;
Darren Tuckerd9f88912005-02-20 21:01:48 +11001634 debug)
1635 AUDIT_MODULE=debug
Tim Rice648f8762011-01-26 12:38:57 -08001636 AC_MSG_RESULT([debug])
1637 AC_DEFINE([SSH_AUDIT_EVENTS], [1], [Use audit debugging module])
Darren Tuckerd9f88912005-02-20 21:01:48 +11001638 ;;
Tim Rice8bc6b902005-08-09 10:09:53 -07001639 no)
Tim Rice648f8762011-01-26 12:38:57 -08001640 AC_MSG_RESULT([no])
Tim Rice8bc6b902005-08-09 10:09:53 -07001641 ;;
Darren Tuckerd9f88912005-02-20 21:01:48 +11001642 *)
1643 AC_MSG_ERROR([Unknown audit module $withval])
1644 ;;
1645 esac ]
1646)
1647
Darren Tucker096118d2014-01-21 12:48:51 +11001648AC_ARG_WITH([pie],
Damien Miller76c04802015-01-13 19:38:18 +11001649 [ --with-pie Build Position Independent Executables if possible], [
Darren Tucker096118d2014-01-21 12:48:51 +11001650 if test "x$withval" = "xno"; then
Damien Miller852472a2014-01-22 16:31:18 +11001651 use_pie=no
Darren Tucker096118d2014-01-21 12:48:51 +11001652 fi
1653 if test "x$withval" = "xyes"; then
Damien Miller852472a2014-01-22 16:31:18 +11001654 use_pie=yes
Darren Tucker096118d2014-01-21 12:48:51 +11001655 fi
1656 ]
1657)
Damien Miller852472a2014-01-22 16:31:18 +11001658if test "x$use_pie" = "x"; then
1659 use_pie=no
1660fi
1661if test "x$use_toolchain_hardening" != "x1" && test "x$use_pie" = "xauto"; then
1662 # Turn off automatic PIE when toolchain hardening is off.
1663 use_pie=no
1664fi
Damien Millerc161fc92014-01-29 21:01:33 +11001665if test "x$use_pie" = "xauto"; then
Damien Miller852472a2014-01-22 16:31:18 +11001666 # Automatic PIE requires gcc >= 4.x
1667 AC_MSG_CHECKING([for gcc >= 4.x])
1668 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1669#if !defined(__GNUC__) || __GNUC__ < 4
1670#error gcc is too old
1671#endif
1672]])],
1673 [ AC_MSG_RESULT([yes]) ],
1674 [ AC_MSG_RESULT([no])
1675 use_pie=no ]
1676)
1677fi
1678if test "x$use_pie" != "xno"; then
Damien Miller5c2ff5e2014-01-22 21:30:12 +11001679 SAVED_CFLAGS="$CFLAGS"
1680 SAVED_LDFLAGS="$LDFLAGS"
Darren Tucker096118d2014-01-21 12:48:51 +11001681 OSSH_CHECK_CFLAG_COMPILE([-fPIE])
1682 OSSH_CHECK_LDFLAG_LINK([-pie])
Damien Miller5c2ff5e2014-01-22 21:30:12 +11001683 # We use both -fPIE and -pie or neither.
1684 AC_MSG_CHECKING([whether both -fPIE and -pie are supported])
1685 if echo "x $CFLAGS" | grep ' -fPIE' >/dev/null 2>&1 && \
1686 echo "x $LDFLAGS" | grep ' -pie' >/dev/null 2>&1 ; then
1687 AC_MSG_RESULT([yes])
1688 else
1689 AC_MSG_RESULT([no])
1690 CFLAGS="$SAVED_CFLAGS"
1691 LDFLAGS="$SAVED_LDFLAGS"
1692 fi
Darren Tucker096118d2014-01-21 12:48:51 +11001693fi
1694
Damien Millerfe1f1432003-02-24 15:45:42 +11001695dnl Checks for library functions. Please keep in alphabetical order
Tim Rice648f8762011-01-26 12:38:57 -08001696AC_CHECK_FUNCS([ \
Damien Miller1ff130d2013-12-07 11:51:51 +11001697 Blowfish_initstate \
1698 Blowfish_expandstate \
1699 Blowfish_expand0state \
1700 Blowfish_stream2word \
Damien Miller57f39152005-11-24 19:58:19 +11001701 asprintf \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001702 b64_ntop \
1703 __b64_ntop \
1704 b64_pton \
1705 __b64_pton \
1706 bcopy \
Damien Millera9134422013-12-07 11:35:36 +11001707 bcrypt_pbkdf \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001708 bindresvport_sa \
Damien Miller1ff130d2013-12-07 11:51:51 +11001709 blf_enc \
Damien Millerc96d8532014-01-25 13:12:28 +11001710 cap_rights_limit \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001711 clock \
1712 closefrom \
1713 dirfd \
Darren Tuckerefdf5342013-05-30 08:29:08 +10001714 endgrent \
Darren Tucker6310ef22016-07-13 14:42:35 +10001715 err \
1716 errx \
Damien Miller1d2c4562014-02-04 11:18:20 +11001717 explicit_bzero \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001718 fchmod \
1719 fchown \
1720 freeaddrinfo \
Damien Millerb7956912017-09-19 12:29:23 +10001721 freezero \
Darren Tuckera5cf1e22014-01-17 18:10:58 +11001722 fstatfs \
Darren Tucker598eaa62008-06-09 03:32:29 +10001723 fstatvfs \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001724 futimes \
1725 getaddrinfo \
1726 getcwd \
1727 getgrouplist \
1728 getnameinfo \
1729 getopt \
Damien Miller151c6e42017-06-01 15:25:13 +10001730 getpagesize \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001731 getpeereid \
Darren Tucker164aa302007-03-21 21:39:57 +11001732 getpeerucred \
Darren Tucker3c4a24c2013-02-15 11:41:35 +11001733 getpgid \
1734 getpgrp \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001735 _getpty \
1736 getrlimit \
1737 getttyent \
1738 glob \
Darren Tucker909a3902010-01-15 12:38:30 +11001739 group_from_gid \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001740 inet_aton \
1741 inet_ntoa \
1742 inet_ntop \
1743 innetgr \
Darren Tuckerd38f05d2017-03-20 13:38:27 +11001744 llabs \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001745 login_getcapbool \
1746 md5_crypt \
1747 memmove \
Damien Miller3d673d12014-08-27 06:32:01 +10001748 memset_s \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001749 mkdtemp \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001750 ngetaddrinfo \
1751 nsleep \
1752 ogetaddrinfo \
1753 openlog_r \
Darren Tucker3ddd15e2015-11-30 07:23:53 +11001754 pledge \
Darren Tuckerfebf0f52007-06-25 22:15:12 +10001755 poll \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001756 prctl \
1757 pstat \
1758 readpassphrase \
Darren Tucker642652d2014-12-10 01:32:23 +11001759 reallocarray \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001760 recvmsg \
Damien Miller151c6e42017-06-01 15:25:13 +10001761 recallocarray \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001762 rresvport_af \
1763 sendmsg \
1764 setdtablesize \
1765 setegid \
1766 setenv \
1767 seteuid \
Darren Tucker909a3902010-01-15 12:38:30 +11001768 setgroupent \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001769 setgroups \
Darren Tucker34f702a2012-07-04 08:50:09 +10001770 setlinebuf \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001771 setlogin \
Darren Tucker909a3902010-01-15 12:38:30 +11001772 setpassent\
Darren Tucker0c9653f2005-05-28 15:58:14 +10001773 setpcred \
1774 setproctitle \
1775 setregid \
1776 setreuid \
1777 setrlimit \
1778 setsid \
1779 setvbuf \
1780 sigaction \
1781 sigvec \
1782 snprintf \
1783 socketpair \
Darren Tucker5b2e2ba2008-06-08 09:25:28 +10001784 statfs \
1785 statvfs \
Darren Tuckerafec0772016-12-13 10:23:03 +11001786 strcasestr \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001787 strdup \
1788 strerror \
1789 strlcat \
1790 strlcpy \
1791 strmode \
Darren Tuckerb54f50e2011-09-29 23:17:18 +10001792 strnlen \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001793 strnvis \
Darren Tuckeraa74f672010-08-16 13:15:23 +10001794 strptime \
Darren Tucker44fc3342017-09-25 09:48:10 +10001795 strsignal \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001796 strtonum \
Darren Tucker81eb5d52005-06-01 21:39:33 +10001797 strtoll \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001798 strtoul \
Darren Tucker8e6fb782013-02-15 12:13:01 +11001799 strtoull \
Damien Miller34a17692007-06-11 14:15:42 +10001800 swap32 \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001801 sysconf \
1802 tcgetpgrp \
Damien Milleraa180632010-10-07 21:25:27 +11001803 timingsafe_bcmp \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001804 truncate \
1805 unsetenv \
1806 updwtmpx \
Darren Tucker909a3902010-01-15 12:38:30 +11001807 user_from_uid \
Damien Millerf4db77d2013-03-15 10:34:25 +11001808 usleep \
Damien Miller57f39152005-11-24 19:58:19 +11001809 vasprintf \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001810 vsnprintf \
1811 waitpid \
Darren Tucker6310ef22016-07-13 14:42:35 +10001812 warn \
Tim Rice648f8762011-01-26 12:38:57 -08001813])
Tim Rice13aae5e2001-10-21 17:53:58 -07001814
Darren Tuckerc61d5ec2017-02-03 14:10:34 +11001815dnl Wide character support.
Darren Tuckera2333582016-07-14 10:59:09 +10001816AC_CHECK_FUNCS([mblen mbtowc nl_langinfo wcwidth])
Darren Tuckera2333582016-07-14 10:59:09 +10001817
Darren Tucker10e290e2016-12-13 13:51:32 +11001818TEST_SSH_UTF8=${TEST_SSH_UTF8:=yes}
Darren Tucker47b8c992016-12-08 15:48:34 +11001819AC_MSG_CHECKING([for utf8 locale support])
1820AC_RUN_IFELSE(
1821 [AC_LANG_PROGRAM([[
1822#include <locale.h>
Darren Tuckerc3599502016-12-09 12:52:02 +11001823#include <stdlib.h>
Darren Tucker47b8c992016-12-08 15:48:34 +11001824 ]], [[
1825 char *loc = setlocale(LC_CTYPE, "en_US.UTF-8");
1826 if (loc != NULL)
1827 exit(0);
1828 exit(1);
1829 ]])],
1830 AC_MSG_RESULT(yes),
1831 [AC_MSG_RESULT(no)
1832 TEST_SSH_UTF8=no],
1833 AC_MSG_WARN([cross compiling: assuming yes])
1834)
1835
Tim Ricec7a8af02010-11-08 14:26:23 -08001836AC_LINK_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001837 [AC_LANG_PROGRAM(
1838 [[ #include <ctype.h> ]],
1839 [[ return (isblank('a')); ]])],
1840 [AC_DEFINE([HAVE_ISBLANK], [1], [Define if you have isblank(3C).])
Tim Ricec7a8af02010-11-08 14:26:23 -08001841])
1842
Damien Miller5fbe93f2016-07-15 13:54:31 +10001843disable_pkcs11=
1844AC_ARG_ENABLE([pkcs11],
1845 [ --disable-pkcs11 disable PKCS#11 support code [no]],
1846 [
1847 if test "x$enableval" = "xno" ; then
1848 disable_pkcs11=1
1849 fi
1850 ]
1851)
1852
Damien Miller72ef7c12015-01-15 02:21:31 +11001853# PKCS11 depends on OpenSSL.
Damien Miller5fbe93f2016-07-15 13:54:31 +10001854if test "x$openssl" = "xyes" && test "x$disable_pkcs11" = "x"; then
Damien Miller72ef7c12015-01-15 02:21:31 +11001855 # PKCS#11 support requires dlopen() and co
1856 AC_SEARCH_LIBS([dlopen], [dl],
1857 [AC_DEFINE([ENABLE_PKCS11], [], [Enable for PKCS#11 support])]
1858 )
1859fi
Damien Millerb3c9f782010-02-12 10:11:34 +11001860
Darren Tuckerd5e082f2003-09-22 12:08:23 +10001861# IRIX has a const char return value for gai_strerror()
Tim Rice648f8762011-01-26 12:38:57 -08001862AC_CHECK_FUNCS([gai_strerror], [
1863 AC_DEFINE([HAVE_GAI_STRERROR])
1864 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckerd5e082f2003-09-22 12:08:23 +10001865#include <sys/types.h>
1866#include <sys/socket.h>
1867#include <netdb.h>
1868
Tim Rice648f8762011-01-26 12:38:57 -08001869const char *gai_strerror(int);
1870 ]], [[
1871 char *str;
1872 str = gai_strerror(0);
1873 ]])], [
1874 AC_DEFINE([HAVE_CONST_GAI_STRERROR_PROTO], [1],
1875 [Define if gai_strerror() returns const char *])], [])])
Darren Tuckerd5e082f2003-09-22 12:08:23 +10001876
Tim Rice648f8762011-01-26 12:38:57 -08001877AC_SEARCH_LIBS([nanosleep], [rt posix4], [AC_DEFINE([HAVE_NANOSLEEP], [1],
1878 [Some systems put nanosleep outside of libc])])
Damien Millercd6853c2003-01-28 11:33:42 +11001879
Darren Tuckera7108912013-06-02 08:18:31 +10001880AC_SEARCH_LIBS([clock_gettime], [rt],
1881 [AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Have clock_gettime])])
1882
Darren Tuckerf1159b52003-07-07 19:44:01 +10001883dnl Make sure prototypes are defined for these before using them.
Tim Rice648f8762011-01-26 12:38:57 -08001884AC_CHECK_DECL([getrusage], [AC_CHECK_FUNCS([getrusage])])
1885AC_CHECK_DECL([strsep],
1886 [AC_CHECK_FUNCS([strsep])],
Darren Tucker390b6d52005-05-28 16:54:36 +10001887 [],
1888 [
1889#ifdef HAVE_STRING_H
1890# include <string.h>
1891#endif
1892 ])
Ben Lindstrom3e006472002-10-16 00:24:03 +00001893
Darren Tuckerb2427c82003-09-10 15:22:44 +10001894dnl tcsendbreak might be a macro
Tim Rice648f8762011-01-26 12:38:57 -08001895AC_CHECK_DECL([tcsendbreak],
1896 [AC_DEFINE([HAVE_TCSENDBREAK])],
1897 [AC_CHECK_FUNCS([tcsendbreak])],
Darren Tuckerb2427c82003-09-10 15:22:44 +10001898 [#include <termios.h>]
1899)
1900
Tim Rice648f8762011-01-26 12:38:57 -08001901AC_CHECK_DECLS([h_errno], , ,[#include <netdb.h>])
Darren Tucker5bb14002004-04-23 18:53:10 +10001902
Tim Rice648f8762011-01-26 12:38:57 -08001903AC_CHECK_DECLS([SHUT_RD], , ,
Darren Tucker128a0892006-07-12 19:02:56 +10001904 [
1905#include <sys/types.h>
1906#include <sys/socket.h>
1907 ])
Darren Tucker248469b2006-07-12 14:14:31 +10001908
Tim Rice648f8762011-01-26 12:38:57 -08001909AC_CHECK_DECLS([O_NONBLOCK], , ,
Darren Tucker248469b2006-07-12 14:14:31 +10001910 [
1911#include <sys/types.h>
1912#ifdef HAVE_SYS_STAT_H
1913# include <sys/stat.h>
1914#endif
1915#ifdef HAVE_FCNTL_H
1916# include <fcntl.h>
1917#endif
1918 ])
1919
Tim Rice648f8762011-01-26 12:38:57 -08001920AC_CHECK_DECLS([writev], , , [
Darren Tuckered0b5922006-09-03 22:44:49 +10001921#include <sys/types.h>
1922#include <sys/uio.h>
1923#include <unistd.h>
1924 ])
1925
Tim Rice648f8762011-01-26 12:38:57 -08001926AC_CHECK_DECLS([MAXSYMLINKS], , , [
Darren Tucker6d862a52007-04-29 14:39:02 +10001927#include <sys/param.h>
1928 ])
1929
Tim Rice648f8762011-01-26 12:38:57 -08001930AC_CHECK_DECLS([offsetof], , , [
Darren Tuckerdca0edf2007-04-29 15:06:44 +10001931#include <stddef.h>
1932 ])
1933
Darren Tuckerc7aad002013-06-02 07:18:47 +10001934# extra bits for select(2)
1935AC_CHECK_DECLS([howmany, NFDBITS], [], [], [[
1936#include <sys/param.h>
1937#include <sys/types.h>
1938#ifdef HAVE_SYS_SYSMACROS_H
1939#include <sys/sysmacros.h>
1940#endif
1941#ifdef HAVE_SYS_SELECT_H
1942#include <sys/select.h>
1943#endif
1944#ifdef HAVE_SYS_TIME_H
1945#include <sys/time.h>
1946#endif
1947#ifdef HAVE_UNISTD_H
1948#include <unistd.h>
1949#endif
1950 ]])
1951AC_CHECK_TYPES([fd_mask], [], [], [[
1952#include <sys/param.h>
1953#include <sys/types.h>
1954#ifdef HAVE_SYS_SELECT_H
1955#include <sys/select.h>
1956#endif
1957#ifdef HAVE_SYS_TIME_H
1958#include <sys/time.h>
1959#endif
1960#ifdef HAVE_UNISTD_H
1961#include <unistd.h>
1962#endif
1963 ]])
1964
Tim Rice648f8762011-01-26 12:38:57 -08001965AC_CHECK_FUNCS([setresuid], [
Darren Tucker2a6b0292003-12-31 14:59:17 +11001966 dnl Some platorms have setresuid that isn't implemented, test for this
Tim Rice648f8762011-01-26 12:38:57 -08001967 AC_MSG_CHECKING([if setresuid seems to work])
Darren Tucker623d92f2004-09-12 22:36:15 +10001968 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001969 [AC_LANG_PROGRAM([[
Darren Tuckere937be32003-12-17 18:53:26 +11001970#include <stdlib.h>
1971#include <errno.h>
Tim Rice648f8762011-01-26 12:38:57 -08001972 ]], [[
1973 errno=0;
1974 setresuid(0,0,0);
1975 if (errno==ENOSYS)
1976 exit(1);
1977 else
1978 exit(0);
Darren Tucker623d92f2004-09-12 22:36:15 +10001979 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001980 [AC_MSG_RESULT([yes])],
1981 [AC_DEFINE([BROKEN_SETRESUID], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001982 [Define if your setresuid() is broken])
Tim Rice648f8762011-01-26 12:38:57 -08001983 AC_MSG_RESULT([not implemented])],
Darren Tuckera0c2b392004-09-11 23:26:37 +10001984 [AC_MSG_WARN([cross compiling: not checking setresuid])]
Darren Tucker2a6b0292003-12-31 14:59:17 +11001985 )
1986])
Darren Tuckere937be32003-12-17 18:53:26 +11001987
Tim Rice648f8762011-01-26 12:38:57 -08001988AC_CHECK_FUNCS([setresgid], [
Darren Tucker2a6b0292003-12-31 14:59:17 +11001989 dnl Some platorms have setresgid that isn't implemented, test for this
Tim Rice648f8762011-01-26 12:38:57 -08001990 AC_MSG_CHECKING([if setresgid seems to work])
Darren Tucker623d92f2004-09-12 22:36:15 +10001991 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001992 [AC_LANG_PROGRAM([[
Darren Tuckere937be32003-12-17 18:53:26 +11001993#include <stdlib.h>
1994#include <errno.h>
Tim Rice648f8762011-01-26 12:38:57 -08001995 ]], [[
1996 errno=0;
1997 setresgid(0,0,0);
1998 if (errno==ENOSYS)
1999 exit(1);
2000 else
2001 exit(0);
Darren Tucker623d92f2004-09-12 22:36:15 +10002002 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08002003 [AC_MSG_RESULT([yes])],
2004 [AC_DEFINE([BROKEN_SETRESGID], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07002005 [Define if your setresgid() is broken])
Tim Rice648f8762011-01-26 12:38:57 -08002006 AC_MSG_RESULT([not implemented])],
Darren Tuckera0c2b392004-09-11 23:26:37 +10002007 [AC_MSG_WARN([cross compiling: not checking setresuid])]
Darren Tucker2a6b0292003-12-31 14:59:17 +11002008 )
2009])
Darren Tuckere937be32003-12-17 18:53:26 +11002010
Darren Tuckerd3e2aee2015-07-17 12:52:34 +10002011AC_CHECK_FUNCS([realpath], [
2012 dnl the sftp v3 spec says SSH_FXP_REALPATH will "canonicalize any given
2013 dnl path name", however some implementations of realpath (and some
2014 dnl versions of the POSIX spec) do not work on non-existent files,
2015 dnl so we use the OpenBSD implementation on those platforms.
2016 AC_MSG_CHECKING([if realpath works with non-existent files])
2017 AC_RUN_IFELSE(
2018 [AC_LANG_PROGRAM([[
2019#include <limits.h>
2020#include <stdlib.h>
2021#include <errno.h>
2022 ]], [[
2023 char buf[PATH_MAX];
2024 if (realpath("/opensshnonexistentfilename1234", buf) == NULL)
2025 if (errno == ENOENT)
2026 exit(1);
2027 exit(0);
2028 ]])],
2029 [AC_MSG_RESULT([yes])],
2030 [AC_DEFINE([BROKEN_REALPATH], [1],
2031 [realpath does not work with nonexistent files])
2032 AC_MSG_RESULT([no])],
2033 [AC_MSG_WARN([cross compiling: assuming working])]
2034 )
2035])
2036
Damien Millerad833b32000-08-23 10:46:23 +10002037dnl Checks for time functions
Tim Rice648f8762011-01-26 12:38:57 -08002038AC_CHECK_FUNCS([gettimeofday time])
Damien Millerad833b32000-08-23 10:46:23 +10002039dnl Checks for utmp functions
Tim Rice648f8762011-01-26 12:38:57 -08002040AC_CHECK_FUNCS([endutent getutent getutid getutline pututline setutent])
2041AC_CHECK_FUNCS([utmpname])
Damien Millerad833b32000-08-23 10:46:23 +10002042dnl Checks for utmpx functions
Tim Rice648f8762011-01-26 12:38:57 -08002043AC_CHECK_FUNCS([endutxent getutxent getutxid getutxline getutxuser pututxline])
2044AC_CHECK_FUNCS([setutxdb setutxent utmpxname])
Damien Miller20e231f2009-02-12 13:12:21 +11002045dnl Checks for lastlog functions
Tim Rice648f8762011-01-26 12:38:57 -08002046AC_CHECK_FUNCS([getlastlogxbyname])
Damien Millercedfecc1999-11-15 14:36:53 +11002047
Tim Rice648f8762011-01-26 12:38:57 -08002048AC_CHECK_FUNC([daemon],
2049 [AC_DEFINE([HAVE_DAEMON], [1], [Define if your libraries define daemon()])],
2050 [AC_CHECK_LIB([bsd], [daemon],
2051 [LIBS="$LIBS -lbsd"; AC_DEFINE([HAVE_DAEMON])])]
Damien Miller04f80141999-11-19 15:32:34 +11002052)
2053
Tim Rice648f8762011-01-26 12:38:57 -08002054AC_CHECK_FUNC([getpagesize],
2055 [AC_DEFINE([HAVE_GETPAGESIZE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07002056 [Define if your libraries define getpagesize()])],
Tim Rice648f8762011-01-26 12:38:57 -08002057 [AC_CHECK_LIB([ucb], [getpagesize],
2058 [LIBS="$LIBS -lucb"; AC_DEFINE([HAVE_GETPAGESIZE])])]
Damien Miller9fb07e42000-03-05 16:22:59 +11002059)
2060
Damien Millercb170cb2000-07-01 16:52:55 +10002061# Check for broken snprintf
2062if test "x$ac_cv_func_snprintf" = "xyes" ; then
2063 AC_MSG_CHECKING([whether snprintf correctly terminates long strings])
Darren Tuckera0c2b392004-09-11 23:26:37 +10002064 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002065 [AC_LANG_PROGRAM([[ #include <stdio.h> ]],
2066 [[
2067 char b[5];
2068 snprintf(b,5,"123456789");
Tim Ricee1d93702016-05-31 11:13:22 -07002069 exit(b[4]!='\0');
Darren Tucker623d92f2004-09-12 22:36:15 +10002070 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08002071 [AC_MSG_RESULT([yes])],
Damien Millercb170cb2000-07-01 16:52:55 +10002072 [
Tim Rice648f8762011-01-26 12:38:57 -08002073 AC_MSG_RESULT([no])
2074 AC_DEFINE([BROKEN_SNPRINTF], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07002075 [Define if your snprintf is busted])
Damien Millercb170cb2000-07-01 16:52:55 +10002076 AC_MSG_WARN([****** Your snprintf() function is broken, complain to your vendor])
Darren Tuckera0c2b392004-09-11 23:26:37 +10002077 ],
2078 [ AC_MSG_WARN([cross compiling: Assuming working snprintf()]) ]
Damien Millercb170cb2000-07-01 16:52:55 +10002079 )
2080fi
2081
Damien Millerd244a582014-08-23 17:06:49 +10002082# We depend on vsnprintf returning the right thing on overflow: the
2083# number of characters it tried to create (as per SUSv3)
2084if test "x$ac_cv_func_vsnprintf" = "xyes" ; then
Damien Miller57f39152005-11-24 19:58:19 +11002085 AC_MSG_CHECKING([whether vsnprintf returns correct values on overflow])
2086 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002087 [AC_LANG_PROGRAM([[
Damien Miller57f39152005-11-24 19:58:19 +11002088#include <sys/types.h>
2089#include <stdio.h>
2090#include <stdarg.h>
2091
Damien Millerd244a582014-08-23 17:06:49 +10002092int x_snprintf(char *str, size_t count, const char *fmt, ...)
Damien Miller57f39152005-11-24 19:58:19 +11002093{
Damien Millerd244a582014-08-23 17:06:49 +10002094 size_t ret;
2095 va_list ap;
2096
2097 va_start(ap, fmt);
2098 ret = vsnprintf(str, count, fmt, ap);
2099 va_end(ap);
Damien Miller57f39152005-11-24 19:58:19 +11002100 return ret;
2101}
Tim Rice648f8762011-01-26 12:38:57 -08002102 ]], [[
Damien Millerd244a582014-08-23 17:06:49 +10002103char x[1];
2104if (x_snprintf(x, 1, "%s %d", "hello", 12345) != 11)
2105 return 1;
2106if (x_snprintf(NULL, 0, "%s %d", "hello", 12345) != 11)
2107 return 1;
2108return 0;
Tim Rice648f8762011-01-26 12:38:57 -08002109 ]])],
2110 [AC_MSG_RESULT([yes])],
Damien Miller57f39152005-11-24 19:58:19 +11002111 [
Tim Rice648f8762011-01-26 12:38:57 -08002112 AC_MSG_RESULT([no])
2113 AC_DEFINE([BROKEN_SNPRINTF], [1],
Damien Miller57f39152005-11-24 19:58:19 +11002114 [Define if your snprintf is busted])
2115 AC_MSG_WARN([****** Your vsnprintf() function is broken, complain to your vendor])
2116 ],
2117 [ AC_MSG_WARN([cross compiling: Assuming working vsnprintf()]) ]
2118 )
2119fi
2120
Darren Tuckerd40c66c2005-12-17 22:32:03 +11002121# On systems where [v]snprintf is broken, but is declared in stdio,
2122# check that the fmt argument is const char * or just char *.
2123# This is only useful for when BROKEN_SNPRINTF
2124AC_MSG_CHECKING([whether snprintf can declare const char *fmt])
Tim Rice648f8762011-01-26 12:38:57 -08002125AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2126#include <stdio.h>
2127int snprintf(char *a, size_t b, const char *c, ...) { return 0; }
2128 ]], [[
2129 snprintf(0, 0, 0);
2130 ]])],
2131 [AC_MSG_RESULT([yes])
2132 AC_DEFINE([SNPRINTF_CONST], [const],
Darren Tuckerd40c66c2005-12-17 22:32:03 +11002133 [Define as const if snprintf() can declare const char *fmt])],
Tim Rice648f8762011-01-26 12:38:57 -08002134 [AC_MSG_RESULT([no])
2135 AC_DEFINE([SNPRINTF_CONST], [/* not const */])])
Darren Tuckerd40c66c2005-12-17 22:32:03 +11002136
Damien Millerb4097182004-05-23 14:09:40 +10002137# Check for missing getpeereid (or equiv) support
2138NO_PEERCHECK=""
Darren Tucker164aa302007-03-21 21:39:57 +11002139if test "x$ac_cv_func_getpeereid" != "xyes" -a "x$ac_cv_func_getpeerucred" != "xyes"; then
Damien Millerb4097182004-05-23 14:09:40 +10002140 AC_MSG_CHECKING([whether system supports SO_PEERCRED getsockopt])
Tim Rice648f8762011-01-26 12:38:57 -08002141 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2142#include <sys/types.h>
2143#include <sys/socket.h>]], [[int i = SO_PEERCRED;]])],
2144 [ AC_MSG_RESULT([yes])
2145 AC_DEFINE([HAVE_SO_PEERCRED], [1], [Have PEERCRED socket option])
2146 ], [AC_MSG_RESULT([no])
2147 NO_PEERCHECK=1
2148 ])
Damien Millerb4097182004-05-23 14:09:40 +10002149fi
2150
Damien Millere8328192003-01-07 15:18:32 +11002151dnl see whether mkstemp() requires XXXXXX
2152if test "x$ac_cv_func_mkdtemp" = "xyes" ; then
2153AC_MSG_CHECKING([for (overly) strict mkstemp])
Darren Tucker314d89e2005-10-17 23:29:23 +10002154AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002155 [AC_LANG_PROGRAM([[
Damien Millere8328192003-01-07 15:18:32 +11002156#include <stdlib.h>
Tim Rice648f8762011-01-26 12:38:57 -08002157 ]], [[
2158 char template[]="conftest.mkstemp-test";
2159 if (mkstemp(template) == -1)
2160 exit(1);
2161 unlink(template);
2162 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10002163 ]])],
Damien Millere8328192003-01-07 15:18:32 +11002164 [
Tim Rice648f8762011-01-26 12:38:57 -08002165 AC_MSG_RESULT([no])
Damien Millere8328192003-01-07 15:18:32 +11002166 ],
Damien Millera8e06ce2003-11-21 23:48:55 +11002167 [
Tim Rice648f8762011-01-26 12:38:57 -08002168 AC_MSG_RESULT([yes])
2169 AC_DEFINE([HAVE_STRICT_MKSTEMP], [1], [Silly mkstemp()])
Damien Millere8328192003-01-07 15:18:32 +11002170 ],
2171 [
Tim Rice648f8762011-01-26 12:38:57 -08002172 AC_MSG_RESULT([yes])
2173 AC_DEFINE([HAVE_STRICT_MKSTEMP])
Damien Millera8e06ce2003-11-21 23:48:55 +11002174 ]
Damien Millere8328192003-01-07 15:18:32 +11002175)
2176fi
2177
Darren Tucker70a3d552003-08-21 17:58:29 +10002178dnl make sure that openpty does not reacquire controlling terminal
2179if test ! -z "$check_for_openpty_ctty_bug"; then
Tim Rice648f8762011-01-26 12:38:57 -08002180 AC_MSG_CHECKING([if openpty correctly handles controlling tty])
Darren Tucker314d89e2005-10-17 23:29:23 +10002181 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002182 [AC_LANG_PROGRAM([[
Darren Tucker70a3d552003-08-21 17:58:29 +10002183#include <stdio.h>
2184#include <sys/fcntl.h>
2185#include <sys/types.h>
2186#include <sys/wait.h>
Tim Rice648f8762011-01-26 12:38:57 -08002187 ]], [[
Darren Tucker70a3d552003-08-21 17:58:29 +10002188 pid_t pid;
2189 int fd, ptyfd, ttyfd, status;
2190
2191 pid = fork();
2192 if (pid < 0) { /* failed */
2193 exit(1);
2194 } else if (pid > 0) { /* parent */
2195 waitpid(pid, &status, 0);
Damien Millera8e06ce2003-11-21 23:48:55 +11002196 if (WIFEXITED(status))
Darren Tucker70a3d552003-08-21 17:58:29 +10002197 exit(WEXITSTATUS(status));
2198 else
2199 exit(2);
2200 } else { /* child */
2201 close(0); close(1); close(2);
2202 setsid();
2203 openpty(&ptyfd, &ttyfd, NULL, NULL, NULL);
2204 fd = open("/dev/tty", O_RDWR | O_NOCTTY);
2205 if (fd >= 0)
2206 exit(3); /* Acquired ctty: broken */
2207 else
2208 exit(0); /* Did not acquire ctty: OK */
2209 }
Darren Tucker314d89e2005-10-17 23:29:23 +10002210 ]])],
Darren Tucker70a3d552003-08-21 17:58:29 +10002211 [
Tim Rice648f8762011-01-26 12:38:57 -08002212 AC_MSG_RESULT([yes])
Darren Tucker70a3d552003-08-21 17:58:29 +10002213 ],
2214 [
Tim Rice648f8762011-01-26 12:38:57 -08002215 AC_MSG_RESULT([no])
2216 AC_DEFINE([SSHD_ACQUIRES_CTTY])
Darren Tucker314d89e2005-10-17 23:29:23 +10002217 ],
2218 [
Tim Rice648f8762011-01-26 12:38:57 -08002219 AC_MSG_RESULT([cross-compiling, assuming yes])
Darren Tucker70a3d552003-08-21 17:58:29 +10002220 ]
2221 )
2222fi
2223
Tim Rice8bb561b2005-03-17 16:23:19 -08002224if test "x$ac_cv_func_getaddrinfo" = "xyes" && \
2225 test "x$check_for_hpux_broken_getaddrinfo" = "x1"; then
Tim Rice648f8762011-01-26 12:38:57 -08002226 AC_MSG_CHECKING([if getaddrinfo seems to work])
Darren Tucker314d89e2005-10-17 23:29:23 +10002227 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002228 [AC_LANG_PROGRAM([[
Darren Tucker4398cf52004-04-06 21:39:02 +10002229#include <stdio.h>
2230#include <sys/socket.h>
2231#include <netdb.h>
2232#include <errno.h>
2233#include <netinet/in.h>
2234
2235#define TEST_PORT "2222"
Tim Rice648f8762011-01-26 12:38:57 -08002236 ]], [[
Darren Tucker4398cf52004-04-06 21:39:02 +10002237 int err, sock;
2238 struct addrinfo *gai_ai, *ai, hints;
2239 char ntop[NI_MAXHOST], strport[NI_MAXSERV], *name = NULL;
2240
2241 memset(&hints, 0, sizeof(hints));
2242 hints.ai_family = PF_UNSPEC;
2243 hints.ai_socktype = SOCK_STREAM;
2244 hints.ai_flags = AI_PASSIVE;
2245
2246 err = getaddrinfo(name, TEST_PORT, &hints, &gai_ai);
2247 if (err != 0) {
2248 fprintf(stderr, "getaddrinfo failed (%s)", gai_strerror(err));
2249 exit(1);
2250 }
2251
2252 for (ai = gai_ai; ai != NULL; ai = ai->ai_next) {
2253 if (ai->ai_family != AF_INET6)
2254 continue;
2255
2256 err = getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop,
2257 sizeof(ntop), strport, sizeof(strport),
2258 NI_NUMERICHOST|NI_NUMERICSERV);
2259
2260 if (err != 0) {
2261 if (err == EAI_SYSTEM)
2262 perror("getnameinfo EAI_SYSTEM");
2263 else
2264 fprintf(stderr, "getnameinfo failed: %s\n",
2265 gai_strerror(err));
2266 exit(2);
2267 }
2268
2269 sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
2270 if (sock < 0)
2271 perror("socket");
2272 if (bind(sock, ai->ai_addr, ai->ai_addrlen) < 0) {
2273 if (errno == EBADF)
2274 exit(3);
2275 }
2276 }
2277 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10002278 ]])],
Darren Tucker4398cf52004-04-06 21:39:02 +10002279 [
Tim Rice648f8762011-01-26 12:38:57 -08002280 AC_MSG_RESULT([yes])
Darren Tucker4398cf52004-04-06 21:39:02 +10002281 ],
2282 [
Tim Rice648f8762011-01-26 12:38:57 -08002283 AC_MSG_RESULT([no])
2284 AC_DEFINE([BROKEN_GETADDRINFO])
Darren Tucker314d89e2005-10-17 23:29:23 +10002285 ],
2286 [
Tim Rice648f8762011-01-26 12:38:57 -08002287 AC_MSG_RESULT([cross-compiling, assuming yes])
Darren Tucker4398cf52004-04-06 21:39:02 +10002288 ]
2289 )
2290fi
2291
Tim Rice8bb561b2005-03-17 16:23:19 -08002292if test "x$ac_cv_func_getaddrinfo" = "xyes" && \
2293 test "x$check_for_aix_broken_getaddrinfo" = "x1"; then
Tim Rice648f8762011-01-26 12:38:57 -08002294 AC_MSG_CHECKING([if getaddrinfo seems to work])
Darren Tucker314d89e2005-10-17 23:29:23 +10002295 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002296 [AC_LANG_PROGRAM([[
Darren Tucker691d5232005-02-15 21:45:57 +11002297#include <stdio.h>
2298#include <sys/socket.h>
2299#include <netdb.h>
2300#include <errno.h>
2301#include <netinet/in.h>
2302
2303#define TEST_PORT "2222"
Tim Rice648f8762011-01-26 12:38:57 -08002304 ]], [[
Darren Tucker691d5232005-02-15 21:45:57 +11002305 int err, sock;
2306 struct addrinfo *gai_ai, *ai, hints;
2307 char ntop[NI_MAXHOST], strport[NI_MAXSERV], *name = NULL;
2308
2309 memset(&hints, 0, sizeof(hints));
2310 hints.ai_family = PF_UNSPEC;
2311 hints.ai_socktype = SOCK_STREAM;
2312 hints.ai_flags = AI_PASSIVE;
2313
2314 err = getaddrinfo(name, TEST_PORT, &hints, &gai_ai);
2315 if (err != 0) {
2316 fprintf(stderr, "getaddrinfo failed (%s)", gai_strerror(err));
2317 exit(1);
2318 }
2319
2320 for (ai = gai_ai; ai != NULL; ai = ai->ai_next) {
2321 if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6)
2322 continue;
2323
2324 err = getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop,
2325 sizeof(ntop), strport, sizeof(strport),
2326 NI_NUMERICHOST|NI_NUMERICSERV);
2327
2328 if (ai->ai_family == AF_INET && err != 0) {
2329 perror("getnameinfo");
2330 exit(2);
2331 }
2332 }
2333 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10002334 ]])],
Darren Tucker691d5232005-02-15 21:45:57 +11002335 [
Tim Rice648f8762011-01-26 12:38:57 -08002336 AC_MSG_RESULT([yes])
2337 AC_DEFINE([AIX_GETNAMEINFO_HACK], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07002338 [Define if you have a getaddrinfo that fails
2339 for the all-zeros IPv6 address])
Darren Tucker691d5232005-02-15 21:45:57 +11002340 ],
2341 [
Tim Rice648f8762011-01-26 12:38:57 -08002342 AC_MSG_RESULT([no])
2343 AC_DEFINE([BROKEN_GETADDRINFO])
Darren Tucker314d89e2005-10-17 23:29:23 +10002344 ],
Darren Tucker8b272ab2006-06-27 11:20:28 +10002345 [
Tim Rice648f8762011-01-26 12:38:57 -08002346 AC_MSG_RESULT([cross-compiling, assuming no])
Darren Tucker691d5232005-02-15 21:45:57 +11002347 ]
2348 )
2349fi
2350
Darren Tuckere50e8c92015-02-21 15:10:33 +11002351if test "x$ac_cv_func_getaddrinfo" = "xyes"; then
2352 AC_CHECK_DECLS(AI_NUMERICSERV, , ,
2353 [#include <sys/types.h>
2354 #include <sys/socket.h>
2355 #include <netdb.h>])
2356fi
2357
Darren Tuckera56f1912004-11-02 20:30:54 +11002358if test "x$check_for_conflicting_getspnam" = "x1"; then
Tim Rice648f8762011-01-26 12:38:57 -08002359 AC_MSG_CHECKING([for conflicting getspnam in shadow.h])
2360 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <shadow.h> ]],
2361 [[ exit(0); ]])],
Darren Tuckera56f1912004-11-02 20:30:54 +11002362 [
Tim Rice648f8762011-01-26 12:38:57 -08002363 AC_MSG_RESULT([no])
Darren Tuckera56f1912004-11-02 20:30:54 +11002364 ],
2365 [
Tim Rice648f8762011-01-26 12:38:57 -08002366 AC_MSG_RESULT([yes])
2367 AC_DEFINE([GETSPNAM_CONFLICTING_DEFS], [1],
Darren Tuckera56f1912004-11-02 20:30:54 +11002368 [Conflicting defs for getspnam])
2369 ]
2370 )
2371fi
2372
Darren Tucker20e5e8b2016-08-02 12:16:34 +10002373dnl NetBSD added an strnvis and unfortunately made it incompatible with the
2374dnl existing one in OpenBSD and Linux's libbsd (the former having existed
2375dnl for over ten years). Despite this incompatibility being reported during
2376dnl development (see http://gnats.netbsd.org/44977) they still shipped it.
2377dnl Even more unfortunately FreeBSD and later MacOS picked up this incompatible
2378dnl implementation. Try to detect this mess, and assume the only safe option
2379dnl if we're cross compiling.
2380dnl
2381dnl OpenBSD, 2001: strnvis(char *dst, const char *src, size_t dlen, int flag);
2382dnl NetBSD: 2012, strnvis(char *dst, size_t dlen, const char *src, int flag);
2383if test "x$ac_cv_func_strnvis" = "xyes"; then
2384 AC_MSG_CHECKING([for working strnvis])
2385 AC_RUN_IFELSE(
2386 [AC_LANG_PROGRAM([[
2387#include <signal.h>
2388#include <stdlib.h>
2389#include <string.h>
2390#include <vis.h>
2391static void sighandler(int sig) { _exit(1); }
2392 ]], [[
2393 char dst[16];
2394
2395 signal(SIGSEGV, sighandler);
2396 if (strnvis(dst, "src", 4, 0) && strcmp(dst, "src") == 0)
2397 exit(0);
2398 exit(1)
2399 ]])],
2400 [AC_MSG_RESULT([yes])],
2401 [AC_MSG_RESULT([no])
2402 AC_DEFINE([BROKEN_STRNVIS], [1], [strnvis detected broken])],
2403 [AC_MSG_WARN([cross compiling: assuming broken])
2404 AC_DEFINE([BROKEN_STRNVIS], [1], [strnvis assumed broken])]
2405 )
2406fi
2407
Damien Miller606f8802000-09-16 15:39:56 +11002408AC_FUNC_GETPGRP
2409
Tim Riceaef73712002-05-11 13:17:42 -07002410# Search for OpenSSL
2411saved_CPPFLAGS="$CPPFLAGS"
2412saved_LDFLAGS="$LDFLAGS"
Tim Rice648f8762011-01-26 12:38:57 -08002413AC_ARG_WITH([ssl-dir],
Damien Millera22ba012000-03-02 23:09:20 +11002414 [ --with-ssl-dir=PATH Specify path to OpenSSL installation ],
2415 [
Damien Miller72ef7c12015-01-15 02:21:31 +11002416 if test "x$openssl" = "xno" ; then
2417 AC_MSG_ERROR([cannot use --with-ssl-dir when OpenSSL disabled])
2418 fi
Ben Lindstrom23e13712000-10-29 22:49:19 +00002419 if test "x$withval" != "xno" ; then
Darren Tuckerc7e38d52005-02-09 22:12:30 +11002420 case "$withval" in
2421 # Relative paths
2422 ./*|../*) withval="`pwd`/$withval"
2423 esac
Tim Riceaef73712002-05-11 13:17:42 -07002424 if test -d "$withval/lib"; then
2425 if test -n "${need_dash_r}"; then
2426 LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
2427 else
2428 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
2429 fi
Darren Tucker9f8703b2010-04-23 11:12:06 +10002430 elif test -d "$withval/lib64"; then
2431 if test -n "${need_dash_r}"; then
2432 LDFLAGS="-L${withval}/lib64 -R${withval}/lib64 ${LDFLAGS}"
2433 else
2434 LDFLAGS="-L${withval}/lib64 ${LDFLAGS}"
2435 fi
Tim Riceaef73712002-05-11 13:17:42 -07002436 else
2437 if test -n "${need_dash_r}"; then
2438 LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
2439 else
2440 LDFLAGS="-L${withval} ${LDFLAGS}"
2441 fi
2442 fi
2443 if test -d "$withval/include"; then
2444 CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
2445 else
2446 CPPFLAGS="-I${withval} ${CPPFLAGS}"
2447 fi
Damien Millera22ba012000-03-02 23:09:20 +11002448 fi
2449 ]
2450)
Damien Millerb9c56672014-05-15 14:43:37 +10002451
Tim Rice648f8762011-01-26 12:38:57 -08002452AC_ARG_WITH([openssl-header-check],
Damien Miller9975e482007-03-05 11:51:27 +11002453 [ --without-openssl-header-check Disable OpenSSL version consistency check],
Damien Millerec932372002-01-22 22:16:03 +11002454 [
Damien Miller72ef7c12015-01-15 02:21:31 +11002455 if test "x$withval" = "xno" ; then
2456 openssl_check_nonfatal=1
Damien Miller9975e482007-03-05 11:51:27 +11002457 fi
Damien Millerec932372002-01-22 22:16:03 +11002458 ]
2459)
2460
Damien Miller72ef7c12015-01-15 02:21:31 +11002461openssl_engine=no
Tim Rice648f8762011-01-26 12:38:57 -08002462AC_ARG_WITH([ssl-engine],
Darren Tuckerfabdb6c2006-02-20 20:17:35 +11002463 [ --with-ssl-engine Enable OpenSSL (hardware) ENGINE support ],
Damien Miller72ef7c12015-01-15 02:21:31 +11002464 [
Damien Miller72ef7c12015-01-15 02:21:31 +11002465 if test "x$withval" != "xno" ; then
Darren Tuckerb5fa0cd2015-12-15 15:10:32 +11002466 if test "x$openssl" = "xno" ; then
2467 AC_MSG_ERROR([cannot use --with-ssl-engine when OpenSSL disabled])
2468 fi
Damien Miller72ef7c12015-01-15 02:21:31 +11002469 openssl_engine=yes
2470 fi
2471 ]
2472)
2473
2474if test "x$openssl" = "xyes" ; then
2475 LIBS="-lcrypto $LIBS"
2476 AC_TRY_LINK_FUNC([RAND_add], [AC_DEFINE([HAVE_OPENSSL], [1],
2477 [Define if your ssl headers are included
2478 with #include <openssl/header.h>])],
2479 [
2480 dnl Check default openssl install dir
2481 if test -n "${need_dash_r}"; then
2482 LDFLAGS="-L/usr/local/ssl/lib -R/usr/local/ssl/lib ${saved_LDFLAGS}"
2483 else
2484 LDFLAGS="-L/usr/local/ssl/lib ${saved_LDFLAGS}"
2485 fi
2486 CPPFLAGS="-I/usr/local/ssl/include ${saved_CPPFLAGS}"
2487 AC_CHECK_HEADER([openssl/opensslv.h], ,
2488 [AC_MSG_ERROR([*** OpenSSL headers missing - please install first or check config.log ***])])
2489 AC_TRY_LINK_FUNC([RAND_add], [AC_DEFINE([HAVE_OPENSSL])],
2490 [
2491 AC_MSG_ERROR([*** Can't find recent OpenSSL libcrypto (see config.log for details) ***])
2492 ]
2493 )
2494 ]
2495 )
2496
2497 # Determine OpenSSL header version
2498 AC_MSG_CHECKING([OpenSSL header version])
2499 AC_RUN_IFELSE(
2500 [AC_LANG_PROGRAM([[
Darren Tucker15605962015-11-10 11:14:47 +11002501 #include <stdlib.h>
Damien Miller72ef7c12015-01-15 02:21:31 +11002502 #include <stdio.h>
2503 #include <string.h>
2504 #include <openssl/opensslv.h>
2505 #define DATA "conftest.sslincver"
2506 ]], [[
2507 FILE *fd;
2508 int rc;
2509
2510 fd = fopen(DATA,"w");
2511 if(fd == NULL)
2512 exit(1);
2513
Darren Tuckerb3413532016-04-04 11:09:21 +10002514 if ((rc = fprintf(fd, "%08lx (%s)\n",
2515 (unsigned long)OPENSSL_VERSION_NUMBER,
2516 OPENSSL_VERSION_TEXT)) < 0)
Damien Miller72ef7c12015-01-15 02:21:31 +11002517 exit(1);
2518
2519 exit(0);
2520 ]])],
2521 [
2522 ssl_header_ver=`cat conftest.sslincver`
2523 AC_MSG_RESULT([$ssl_header_ver])
2524 ],
2525 [
2526 AC_MSG_RESULT([not found])
2527 AC_MSG_ERROR([OpenSSL version header not found.])
2528 ],
2529 [
2530 AC_MSG_WARN([cross compiling: not checking])
2531 ]
2532 )
2533
2534 # Determine OpenSSL library version
2535 AC_MSG_CHECKING([OpenSSL library version])
2536 AC_RUN_IFELSE(
2537 [AC_LANG_PROGRAM([[
2538 #include <stdio.h>
2539 #include <string.h>
2540 #include <openssl/opensslv.h>
2541 #include <openssl/crypto.h>
2542 #define DATA "conftest.ssllibver"
2543 ]], [[
2544 FILE *fd;
2545 int rc;
2546
2547 fd = fopen(DATA,"w");
2548 if(fd == NULL)
2549 exit(1);
2550
Darren Tucker815bcac2016-04-04 11:07:59 +10002551 if ((rc = fprintf(fd, "%08lx (%s)\n", (unsigned long)SSLeay(),
2552 SSLeay_version(SSLEAY_VERSION))) < 0)
Damien Miller72ef7c12015-01-15 02:21:31 +11002553 exit(1);
2554
2555 exit(0);
2556 ]])],
2557 [
2558 ssl_library_ver=`cat conftest.ssllibver`
2559 # Check version is supported.
2560 case "$ssl_library_ver" in
Damien Miller2429cf72017-03-14 18:01:52 +11002561 10000*|0*)
2562 AC_MSG_ERROR([OpenSSL >= 1.0.1 required (have "$ssl_library_ver")])
Damien Miller72ef7c12015-01-15 02:21:31 +11002563 ;;
Damien Miller04dc0702017-09-28 14:54:34 -07002564 100*) ;; # 1.0.x
Damien Millerbba69c22017-09-28 16:06:21 -07002565 200*) ;; # LibreSSL
Damien Miller04dc0702017-09-28 14:54:34 -07002566 *)
2567 AC_MSG_ERROR([OpenSSL >= 1.1.0 is not yet supported (have "$ssl_library_ver")])
2568 ;;
Damien Miller72ef7c12015-01-15 02:21:31 +11002569 esac
2570 AC_MSG_RESULT([$ssl_library_ver])
2571 ],
2572 [
2573 AC_MSG_RESULT([not found])
2574 AC_MSG_ERROR([OpenSSL library not found.])
2575 ],
2576 [
2577 AC_MSG_WARN([cross compiling: not checking])
2578 ]
2579 )
2580
2581 # Sanity check OpenSSL headers
2582 AC_MSG_CHECKING([whether OpenSSL's headers match the library])
2583 AC_RUN_IFELSE(
2584 [AC_LANG_PROGRAM([[
2585 #include <string.h>
2586 #include <openssl/opensslv.h>
Darren Tuckerc1d7e542015-12-15 14:27:09 +11002587 #include <openssl/crypto.h>
Damien Miller72ef7c12015-01-15 02:21:31 +11002588 ]], [[
2589 exit(SSLeay() == OPENSSL_VERSION_NUMBER ? 0 : 1);
2590 ]])],
2591 [
2592 AC_MSG_RESULT([yes])
2593 ],
2594 [
2595 AC_MSG_RESULT([no])
2596 if test "x$openssl_check_nonfatal" = "x"; then
2597 AC_MSG_ERROR([Your OpenSSL headers do not match your
2598 library. Check config.log for details.
2599 If you are sure your installation is consistent, you can disable the check
2600 by running "./configure --without-openssl-header-check".
2601 Also see contrib/findssl.sh for help identifying header/library mismatches.
2602 ])
2603 else
2604 AC_MSG_WARN([Your OpenSSL headers do not match your
2605 library. Check config.log for details.
2606 Also see contrib/findssl.sh for help identifying header/library mismatches.])
2607 fi
2608 ],
2609 [
2610 AC_MSG_WARN([cross compiling: not checking])
2611 ]
2612 )
2613
2614 AC_MSG_CHECKING([if programs using OpenSSL functions will link])
2615 AC_LINK_IFELSE(
2616 [AC_LANG_PROGRAM([[ #include <openssl/evp.h> ]],
2617 [[ SSLeay_add_all_algorithms(); ]])],
2618 [
2619 AC_MSG_RESULT([yes])
2620 ],
2621 [
2622 AC_MSG_RESULT([no])
2623 saved_LIBS="$LIBS"
2624 LIBS="$LIBS -ldl"
2625 AC_MSG_CHECKING([if programs using OpenSSL need -ldl])
2626 AC_LINK_IFELSE(
2627 [AC_LANG_PROGRAM([[ #include <openssl/evp.h> ]],
2628 [[ SSLeay_add_all_algorithms(); ]])],
2629 [
2630 AC_MSG_RESULT([yes])
2631 ],
2632 [
2633 AC_MSG_RESULT([no])
2634 LIBS="$saved_LIBS"
2635 ]
2636 )
2637 ]
2638 )
2639
2640 AC_CHECK_FUNCS([ \
2641 BN_is_prime_ex \
2642 DSA_generate_parameters_ex \
2643 EVP_DigestInit_ex \
2644 EVP_DigestFinal_ex \
2645 EVP_MD_CTX_init \
2646 EVP_MD_CTX_cleanup \
2647 EVP_MD_CTX_copy_ex \
2648 HMAC_CTX_init \
2649 RSA_generate_key_ex \
2650 RSA_get_default_method \
2651 ])
2652
2653 if test "x$openssl_engine" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08002654 AC_MSG_CHECKING([for OpenSSL ENGINE support])
2655 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller72ef7c12015-01-15 02:21:31 +11002656 #include <openssl/engine.h>
Tim Rice648f8762011-01-26 12:38:57 -08002657 ]], [[
Damien Miller72ef7c12015-01-15 02:21:31 +11002658 ENGINE_load_builtin_engines();
2659 ENGINE_register_all_complete();
Tim Rice648f8762011-01-26 12:38:57 -08002660 ]])],
2661 [ AC_MSG_RESULT([yes])
2662 AC_DEFINE([USE_OPENSSL_ENGINE], [1],
Darren Tuckerfabdb6c2006-02-20 20:17:35 +11002663 [Enable OpenSSL engine support])
Tim Rice648f8762011-01-26 12:38:57 -08002664 ], [ AC_MSG_ERROR([OpenSSL ENGINE support not found])
2665 ])
Damien Miller72ef7c12015-01-15 02:21:31 +11002666 fi
Darren Tuckerfabdb6c2006-02-20 20:17:35 +11002667
Damien Miller72ef7c12015-01-15 02:21:31 +11002668 # Check for OpenSSL without EVP_aes_{192,256}_cbc
2669 AC_MSG_CHECKING([whether OpenSSL has crippled AES support])
2670 AC_LINK_IFELSE(
Darren Tucker37bcef52013-11-09 18:39:25 +11002671 [AC_LANG_PROGRAM([[
Damien Miller72ef7c12015-01-15 02:21:31 +11002672 #include <string.h>
2673 #include <openssl/evp.h>
2674 ]], [[
2675 exit(EVP_aes_192_cbc() == NULL || EVP_aes_256_cbc() == NULL);
2676 ]])],
2677 [
2678 AC_MSG_RESULT([no])
2679 ],
2680 [
2681 AC_MSG_RESULT([yes])
2682 AC_DEFINE([OPENSSL_LOBOTOMISED_AES], [1],
2683 [libcrypto is missing AES 192 and 256 bit functions])
2684 ]
2685 )
2686
2687 # Check for OpenSSL with EVP_aes_*ctr
2688 AC_MSG_CHECKING([whether OpenSSL has AES CTR via EVP])
2689 AC_LINK_IFELSE(
2690 [AC_LANG_PROGRAM([[
2691 #include <string.h>
2692 #include <openssl/evp.h>
2693 ]], [[
2694 exit(EVP_aes_128_ctr() == NULL ||
2695 EVP_aes_192_cbc() == NULL ||
2696 EVP_aes_256_cbc() == NULL);
2697 ]])],
2698 [
2699 AC_MSG_RESULT([yes])
2700 AC_DEFINE([OPENSSL_HAVE_EVPCTR], [1],
2701 [libcrypto has EVP AES CTR])
2702 ],
2703 [
2704 AC_MSG_RESULT([no])
2705 ]
2706 )
2707
2708 # Check for OpenSSL with EVP_aes_*gcm
2709 AC_MSG_CHECKING([whether OpenSSL has AES GCM via EVP])
2710 AC_LINK_IFELSE(
2711 [AC_LANG_PROGRAM([[
2712 #include <string.h>
2713 #include <openssl/evp.h>
2714 ]], [[
2715 exit(EVP_aes_128_gcm() == NULL ||
2716 EVP_aes_256_gcm() == NULL ||
2717 EVP_CTRL_GCM_SET_IV_FIXED == 0 ||
2718 EVP_CTRL_GCM_IV_GEN == 0 ||
2719 EVP_CTRL_GCM_SET_TAG == 0 ||
2720 EVP_CTRL_GCM_GET_TAG == 0 ||
2721 EVP_CIPHER_CTX_ctrl(NULL, 0, 0, NULL) == 0);
2722 ]])],
2723 [
2724 AC_MSG_RESULT([yes])
2725 AC_DEFINE([OPENSSL_HAVE_EVPGCM], [1],
2726 [libcrypto has EVP AES GCM])
2727 ],
2728 [
2729 AC_MSG_RESULT([no])
2730 unsupported_algorithms="$unsupported_cipers \
Damien Miller679ce882016-07-15 13:44:38 +10002731 aes128-gcm@openssh.com \
2732 aes256-gcm@openssh.com"
Damien Miller72ef7c12015-01-15 02:21:31 +11002733 ]
2734 )
2735
2736 AC_SEARCH_LIBS([EVP_CIPHER_CTX_ctrl], [crypto],
2737 [AC_DEFINE([HAVE_EVP_CIPHER_CTX_CTRL], [1],
2738 [Define if libcrypto has EVP_CIPHER_CTX_ctrl])])
2739
2740 AC_MSG_CHECKING([if EVP_DigestUpdate returns an int])
2741 AC_LINK_IFELSE(
2742 [AC_LANG_PROGRAM([[
2743 #include <string.h>
2744 #include <openssl/evp.h>
2745 ]], [[
2746 if(EVP_DigestUpdate(NULL, NULL,0))
2747 exit(0);
2748 ]])],
2749 [
2750 AC_MSG_RESULT([yes])
2751 ],
2752 [
2753 AC_MSG_RESULT([no])
2754 AC_DEFINE([OPENSSL_EVP_DIGESTUPDATE_VOID], [1],
2755 [Define if EVP_DigestUpdate returns void])
2756 ]
2757 )
2758
2759 # Some systems want crypt() from libcrypt, *not* the version in OpenSSL,
2760 # because the system crypt() is more featureful.
2761 if test "x$check_for_libcrypt_before" = "x1"; then
2762 AC_CHECK_LIB([crypt], [crypt])
2763 fi
2764
2765 # Some Linux systems (Slackware) need crypt() from libcrypt, *not* the
2766 # version in OpenSSL.
2767 if test "x$check_for_libcrypt_later" = "x1"; then
2768 AC_CHECK_LIB([crypt], [crypt], [LIBS="$LIBS -lcrypt"])
2769 fi
Damien Miller00797e82015-03-04 05:02:45 +11002770 AC_CHECK_FUNCS([crypt DES_crypt])
Damien Miller72ef7c12015-01-15 02:21:31 +11002771
2772 # Search for SHA256 support in libc and/or OpenSSL
2773 AC_CHECK_FUNCS([SHA256_Update EVP_sha256], ,
2774 [unsupported_algorithms="$unsupported_algorithms \
Damien Miller679ce882016-07-15 13:44:38 +10002775 hmac-sha2-256 \
2776 hmac-sha2-512 \
Damien Miller72ef7c12015-01-15 02:21:31 +11002777 diffie-hellman-group-exchange-sha256 \
Damien Miller679ce882016-07-15 13:44:38 +10002778 hmac-sha2-256-etm@openssh.com \
2779 hmac-sha2-512-etm@openssh.com"
Damien Miller72ef7c12015-01-15 02:21:31 +11002780 ]
2781 )
2782 # Search for RIPE-MD support in OpenSSL
2783 AC_CHECK_FUNCS([EVP_ripemd160], ,
2784 [unsupported_algorithms="$unsupported_algorithms \
Damien Miller679ce882016-07-15 13:44:38 +10002785 hmac-ripemd160 \
2786 hmac-ripemd160@openssh.com \
Damien Miller72ef7c12015-01-15 02:21:31 +11002787 hmac-ripemd160-etm@openssh.com"
2788 ]
2789 )
2790
2791 # Check complete ECC support in OpenSSL
2792 AC_MSG_CHECKING([whether OpenSSL has NID_X9_62_prime256v1])
2793 AC_LINK_IFELSE(
2794 [AC_LANG_PROGRAM([[
2795 #include <openssl/ec.h>
2796 #include <openssl/ecdh.h>
2797 #include <openssl/ecdsa.h>
2798 #include <openssl/evp.h>
2799 #include <openssl/objects.h>
2800 #include <openssl/opensslv.h>
Damien Miller72ef7c12015-01-15 02:21:31 +11002801 ]], [[
2802 EC_KEY *e = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
2803 const EVP_MD *m = EVP_sha256(); /* We need this too */
Darren Tucker37bcef52013-11-09 18:39:25 +11002804 ]])],
2805 [ AC_MSG_RESULT([yes])
Damien Miller72ef7c12015-01-15 02:21:31 +11002806 enable_nistp256=1 ],
2807 [ AC_MSG_RESULT([no]) ]
2808 )
Darren Tucker37bcef52013-11-09 18:39:25 +11002809
Damien Miller72ef7c12015-01-15 02:21:31 +11002810 AC_MSG_CHECKING([whether OpenSSL has NID_secp384r1])
2811 AC_LINK_IFELSE(
2812 [AC_LANG_PROGRAM([[
2813 #include <openssl/ec.h>
2814 #include <openssl/ecdh.h>
2815 #include <openssl/ecdsa.h>
2816 #include <openssl/evp.h>
2817 #include <openssl/objects.h>
2818 #include <openssl/opensslv.h>
Damien Miller72ef7c12015-01-15 02:21:31 +11002819 ]], [[
2820 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp384r1);
2821 const EVP_MD *m = EVP_sha384(); /* We need this too */
2822 ]])],
2823 [ AC_MSG_RESULT([yes])
2824 enable_nistp384=1 ],
2825 [ AC_MSG_RESULT([no]) ]
2826 )
Darren Tucker37bcef52013-11-09 18:39:25 +11002827
Damien Miller72ef7c12015-01-15 02:21:31 +11002828 AC_MSG_CHECKING([whether OpenSSL has NID_secp521r1])
2829 AC_LINK_IFELSE(
2830 [AC_LANG_PROGRAM([[
2831 #include <openssl/ec.h>
2832 #include <openssl/ecdh.h>
2833 #include <openssl/ecdsa.h>
2834 #include <openssl/evp.h>
2835 #include <openssl/objects.h>
2836 #include <openssl/opensslv.h>
Damien Miller72ef7c12015-01-15 02:21:31 +11002837 ]], [[
2838 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1);
2839 const EVP_MD *m = EVP_sha512(); /* We need this too */
2840 ]])],
2841 [ AC_MSG_RESULT([yes])
2842 AC_MSG_CHECKING([if OpenSSL's NID_secp521r1 is functional])
2843 AC_RUN_IFELSE(
2844 [AC_LANG_PROGRAM([[
2845 #include <openssl/ec.h>
2846 #include <openssl/ecdh.h>
2847 #include <openssl/ecdsa.h>
2848 #include <openssl/evp.h>
2849 #include <openssl/objects.h>
2850 #include <openssl/opensslv.h>
2851 ]],[[
2852 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1);
2853 const EVP_MD *m = EVP_sha512(); /* We need this too */
2854 exit(e == NULL || m == NULL);
2855 ]])],
2856 [ AC_MSG_RESULT([yes])
2857 enable_nistp521=1 ],
2858 [ AC_MSG_RESULT([no]) ],
2859 [ AC_MSG_WARN([cross-compiling: assuming yes])
2860 enable_nistp521=1 ]
2861 )],
2862 AC_MSG_RESULT([no])
2863 )
Darren Tucker37bcef52013-11-09 18:39:25 +11002864
Damien Miller72ef7c12015-01-15 02:21:31 +11002865 COMMENT_OUT_ECC="#no ecc#"
2866 TEST_SSH_ECC=no
2867
2868 if test x$enable_nistp256 = x1 || test x$enable_nistp384 = x1 || \
2869 test x$enable_nistp521 = x1; then
2870 AC_DEFINE(OPENSSL_HAS_ECC, [1], [OpenSSL has ECC])
2871 fi
2872 if test x$enable_nistp256 = x1; then
2873 AC_DEFINE([OPENSSL_HAS_NISTP256], [1],
2874 [libcrypto has NID_X9_62_prime256v1])
2875 TEST_SSH_ECC=yes
2876 COMMENT_OUT_ECC=""
2877 else
Damien Miller679ce882016-07-15 13:44:38 +10002878 unsupported_algorithms="$unsupported_algorithms \
2879 ecdsa-sha2-nistp256 \
2880 ecdh-sha2-nistp256 \
2881 ecdsa-sha2-nistp256-cert-v01@openssh.com"
Damien Miller72ef7c12015-01-15 02:21:31 +11002882 fi
2883 if test x$enable_nistp384 = x1; then
2884 AC_DEFINE([OPENSSL_HAS_NISTP384], [1], [libcrypto has NID_secp384r1])
2885 TEST_SSH_ECC=yes
2886 COMMENT_OUT_ECC=""
2887 else
Damien Miller679ce882016-07-15 13:44:38 +10002888 unsupported_algorithms="$unsupported_algorithms \
2889 ecdsa-sha2-nistp384 \
2890 ecdh-sha2-nistp384 \
2891 ecdsa-sha2-nistp384-cert-v01@openssh.com"
Damien Miller72ef7c12015-01-15 02:21:31 +11002892 fi
2893 if test x$enable_nistp521 = x1; then
2894 AC_DEFINE([OPENSSL_HAS_NISTP521], [1], [libcrypto has NID_secp521r1])
2895 TEST_SSH_ECC=yes
2896 COMMENT_OUT_ECC=""
2897 else
Damien Miller679ce882016-07-15 13:44:38 +10002898 unsupported_algorithms="$unsupported_algorithms \
2899 ecdh-sha2-nistp521 \
2900 ecdsa-sha2-nistp521 \
2901 ecdsa-sha2-nistp521-cert-v01@openssh.com"
Damien Miller72ef7c12015-01-15 02:21:31 +11002902 fi
2903
2904 AC_SUBST([TEST_SSH_ECC])
2905 AC_SUBST([COMMENT_OUT_ECC])
2906else
2907 AC_CHECK_LIB([crypt], [crypt], [LIBS="$LIBS -lcrypt"])
Damien Miller00797e82015-03-04 05:02:45 +11002908 AC_CHECK_FUNCS([crypt])
Damien Miller72ef7c12015-01-15 02:21:31 +11002909fi
Damien Miller6af914a2010-09-10 11:39:26 +10002910
Damien Miller00f9cd22014-07-15 10:41:38 +10002911AC_CHECK_FUNCS([ \
2912 arc4random \
2913 arc4random_buf \
2914 arc4random_stir \
2915 arc4random_uniform \
2916])
2917
Tim Rice99203ec2007-03-26 09:35:28 -07002918saved_LIBS="$LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08002919AC_CHECK_LIB([iaf], [ia_openinfo], [
Tim Rice99203ec2007-03-26 09:35:28 -07002920 LIBS="$LIBS -liaf"
Tim Rice648f8762011-01-26 12:38:57 -08002921 AC_CHECK_FUNCS([set_id], [SSHDLIBS="$SSHDLIBS -liaf"
2922 AC_DEFINE([HAVE_LIBIAF], [1],
Tim Ricee1d93702016-05-31 11:13:22 -07002923 [Define if system has libiaf that supports set_id])
Tim Rice0eeaf122007-09-10 16:24:17 -07002924 ])
Tim Rice99203ec2007-03-26 09:35:28 -07002925])
2926LIBS="$saved_LIBS"
Damien Miller6c21c512002-01-22 21:57:53 +11002927
2928### Configure cryptographic random number support
2929
2930# Check wheter OpenSSL seeds itself
Damien Miller72ef7c12015-01-15 02:21:31 +11002931if test "x$openssl" = "xyes" ; then
2932 AC_MSG_CHECKING([whether OpenSSL's PRNG is internally seeded])
2933 AC_RUN_IFELSE(
2934 [AC_LANG_PROGRAM([[
2935 #include <string.h>
2936 #include <openssl/rand.h>
2937 ]], [[
2938 exit(RAND_status() == 1 ? 0 : 1);
2939 ]])],
2940 [
2941 OPENSSL_SEEDS_ITSELF=yes
2942 AC_MSG_RESULT([yes])
2943 ],
2944 [
2945 AC_MSG_RESULT([no])
2946 ],
2947 [
2948 AC_MSG_WARN([cross compiling: assuming yes])
2949 # This is safe, since we will fatal() at runtime if
2950 # OpenSSL is not seeded correctly.
2951 OPENSSL_SEEDS_ITSELF=yes
2952 ]
2953 )
2954fi
Damien Miller6c21c512002-01-22 21:57:53 +11002955
Damien Millerf22019b2011-05-05 13:48:37 +10002956# PRNGD TCP socket
2957AC_ARG_WITH([prngd-port],
2958 [ --with-prngd-port=PORT read entropy from PRNGD/EGD TCP localhost:PORT],
2959 [
2960 case "$withval" in
2961 no)
2962 withval=""
2963 ;;
2964 [[0-9]]*)
2965 ;;
2966 *)
2967 AC_MSG_ERROR([You must specify a numeric port number for --with-prngd-port])
2968 ;;
2969 esac
2970 if test ! -z "$withval" ; then
2971 PRNGD_PORT="$withval"
2972 AC_DEFINE_UNQUOTED([PRNGD_PORT], [$PRNGD_PORT],
2973 [Port number of PRNGD/EGD random number socket])
2974 fi
2975 ]
2976)
2977
2978# PRNGD Unix domain socket
2979AC_ARG_WITH([prngd-socket],
2980 [ --with-prngd-socket=FILE read entropy from PRNGD/EGD socket FILE (default=/var/run/egd-pool)],
2981 [
2982 case "$withval" in
2983 yes)
2984 withval="/var/run/egd-pool"
2985 ;;
2986 no)
2987 withval=""
2988 ;;
2989 /*)
2990 ;;
2991 *)
2992 AC_MSG_ERROR([You must specify an absolute path to the entropy socket])
2993 ;;
2994 esac
2995
2996 if test ! -z "$withval" ; then
2997 if test ! -z "$PRNGD_PORT" ; then
2998 AC_MSG_ERROR([You may not specify both a PRNGD/EGD port and socket])
2999 fi
3000 if test ! -r "$withval" ; then
3001 AC_MSG_WARN([Entropy socket is not readable])
3002 fi
3003 PRNGD_SOCKET="$withval"
3004 AC_DEFINE_UNQUOTED([PRNGD_SOCKET], ["$PRNGD_SOCKET"],
3005 [Location of PRNGD/EGD random number socket])
3006 fi
3007 ],
3008 [
3009 # Check for existing socket only if we don't have a random device already
3010 if test "x$OPENSSL_SEEDS_ITSELF" != "xyes" ; then
3011 AC_MSG_CHECKING([for PRNGD/EGD socket])
3012 # Insert other locations here
3013 for sock in /var/run/egd-pool /dev/egd-pool /etc/entropy; do
3014 if test -r $sock && $TEST_MINUS_S_SH -c "test -S $sock -o -p $sock" ; then
3015 PRNGD_SOCKET="$sock"
3016 AC_DEFINE_UNQUOTED([PRNGD_SOCKET], ["$PRNGD_SOCKET"])
3017 break;
3018 fi
3019 done
3020 if test ! -z "$PRNGD_SOCKET" ; then
3021 AC_MSG_RESULT([$PRNGD_SOCKET])
3022 else
3023 AC_MSG_RESULT([not found])
3024 fi
3025 fi
3026 ]
3027)
3028
3029# Which randomness source do we use?
3030if test ! -z "$PRNGD_PORT" ; then
3031 RAND_MSG="PRNGd port $PRNGD_PORT"
3032elif test ! -z "$PRNGD_SOCKET" ; then
3033 RAND_MSG="PRNGd socket $PRNGD_SOCKET"
3034elif test ! -z "$OPENSSL_SEEDS_ITSELF" ; then
3035 AC_DEFINE([OPENSSL_PRNG_ONLY], [1],
Damien Miller72ef7c12015-01-15 02:21:31 +11003036 [Define if you want the OpenSSL internally seeded PRNG only])
Damien Millerf22019b2011-05-05 13:48:37 +10003037 RAND_MSG="OpenSSL internal ONLY"
Damien Miller72ef7c12015-01-15 02:21:31 +11003038elif test "x$openssl" = "xno" ; then
3039 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 +10003040else
3041 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])
3042fi
3043
Darren Tucker3e6bde42006-08-20 20:03:50 +10003044# Check for PAM libs
3045PAM_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08003046AC_ARG_WITH([pam],
Darren Tucker3e6bde42006-08-20 20:03:50 +10003047 [ --with-pam Enable PAM support ],
3048 [
3049 if test "x$withval" != "xno" ; then
3050 if test "x$ac_cv_header_security_pam_appl_h" != "xyes" && \
3051 test "x$ac_cv_header_pam_pam_appl_h" != "xyes" ; then
3052 AC_MSG_ERROR([PAM headers not found])
3053 fi
3054
3055 saved_LIBS="$LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08003056 AC_CHECK_LIB([dl], [dlopen], , )
3057 AC_CHECK_LIB([pam], [pam_set_item], , [AC_MSG_ERROR([*** libpam missing])])
3058 AC_CHECK_FUNCS([pam_getenvlist])
3059 AC_CHECK_FUNCS([pam_putenv])
Darren Tucker3e6bde42006-08-20 20:03:50 +10003060 LIBS="$saved_LIBS"
3061
3062 PAM_MSG="yes"
3063
Darren Tucker20e9f972007-03-25 18:26:01 +10003064 SSHDLIBS="$SSHDLIBS -lpam"
Tim Rice648f8762011-01-26 12:38:57 -08003065 AC_DEFINE([USE_PAM], [1],
Darren Tucker3e6bde42006-08-20 20:03:50 +10003066 [Define if you want to enable PAM support])
Darren Tucker639bbe82006-08-20 20:17:53 +10003067
Darren Tucker3e6bde42006-08-20 20:03:50 +10003068 if test $ac_cv_lib_dl_dlopen = yes; then
Darren Tucker639bbe82006-08-20 20:17:53 +10003069 case "$LIBS" in
3070 *-ldl*)
3071 # libdl already in LIBS
3072 ;;
3073 *)
Darren Tucker20e9f972007-03-25 18:26:01 +10003074 SSHDLIBS="$SSHDLIBS -ldl"
Darren Tucker639bbe82006-08-20 20:17:53 +10003075 ;;
3076 esac
Darren Tucker3e6bde42006-08-20 20:03:50 +10003077 fi
Darren Tucker3e6bde42006-08-20 20:03:50 +10003078 fi
3079 ]
3080)
3081
Damien Miller8bd81e12016-08-16 13:30:56 +10003082AC_ARG_WITH([pam-service],
3083 [ --with-pam-service=name Specify PAM service name ],
3084 [
3085 if test "x$withval" != "xno" && \
3086 test "x$withval" != "xyes" ; then
3087 AC_DEFINE_UNQUOTED([SSHD_PAM_SERVICE],
3088 ["$withval"], [sshd PAM service name])
3089 fi
3090 ]
3091)
3092
Darren Tucker3e6bde42006-08-20 20:03:50 +10003093# Check for older PAM
3094if test "x$PAM_MSG" = "xyes" ; then
3095 # Check PAM strerror arguments (old PAM)
3096 AC_MSG_CHECKING([whether pam_strerror takes only one argument])
Tim Rice648f8762011-01-26 12:38:57 -08003097 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker3e6bde42006-08-20 20:03:50 +10003098#include <stdlib.h>
3099#if defined(HAVE_SECURITY_PAM_APPL_H)
3100#include <security/pam_appl.h>
3101#elif defined (HAVE_PAM_PAM_APPL_H)
3102#include <pam/pam_appl.h>
3103#endif
Tim Rice648f8762011-01-26 12:38:57 -08003104 ]], [[
3105(void)pam_strerror((pam_handle_t *)NULL, -1);
3106 ]])], [AC_MSG_RESULT([no])], [
3107 AC_DEFINE([HAVE_OLD_PAM], [1],
Darren Tucker3e6bde42006-08-20 20:03:50 +10003108 [Define if you have an old version of PAM
3109 which takes only one argument to pam_strerror])
Tim Rice648f8762011-01-26 12:38:57 -08003110 AC_MSG_RESULT([yes])
Darren Tucker3e6bde42006-08-20 20:03:50 +10003111 PAM_MSG="yes (old library)"
Damien Miller72ef7c12015-01-15 02:21:31 +11003112
Tim Rice648f8762011-01-26 12:38:57 -08003113 ])
Darren Tucker3e6bde42006-08-20 20:03:50 +10003114fi
Damien Miller6c21c512002-01-22 21:57:53 +11003115
Damien Miller6482d902014-05-27 14:34:42 +10003116case "$host" in
3117*-*-cygwin*)
3118 SSH_PRIVSEP_USER=CYGWIN_SSH_PRIVSEP_USER
3119 ;;
3120*)
3121 SSH_PRIVSEP_USER=sshd
3122 ;;
3123esac
Tim Rice648f8762011-01-26 12:38:57 -08003124AC_ARG_WITH([privsep-user],
Kevin Stevesc81e1292002-05-13 03:51:40 +00003125 [ --with-privsep-user=user Specify non-privileged user for privilege separation],
Kevin Steves7ff91122002-04-07 19:22:54 +00003126 [
Tim Rice35cc69d2005-03-17 16:44:25 -08003127 if test -n "$withval" && test "x$withval" != "xno" && \
3128 test "x${withval}" != "xyes"; then
Damien Millerd3f6ad22002-06-25 10:24:47 +10003129 SSH_PRIVSEP_USER=$withval
Kevin Steves7ff91122002-04-07 19:22:54 +00003130 fi
Tim Riceeae17cc2005-03-17 16:52:20 -08003131 ]
Kevin Steves7ff91122002-04-07 19:22:54 +00003132)
Damien Miller6482d902014-05-27 14:34:42 +10003133if test "x$SSH_PRIVSEP_USER" = "xCYGWIN_SSH_PRIVSEP_USER" ; then
3134 AC_DEFINE_UNQUOTED([SSH_PRIVSEP_USER], [CYGWIN_SSH_PRIVSEP_USER],
3135 [Cygwin function to fetch non-privileged user for privilege separation])
3136else
3137 AC_DEFINE_UNQUOTED([SSH_PRIVSEP_USER], ["$SSH_PRIVSEP_USER"],
3138 [non-privileged user for privilege separation])
3139fi
Tim Rice648f8762011-01-26 12:38:57 -08003140AC_SUBST([SSH_PRIVSEP_USER])
Kevin Steves7ff91122002-04-07 19:22:54 +00003141
Damien Miller91f40d82013-02-22 11:37:00 +11003142if test "x$have_linux_no_new_privs" = "x1" ; then
3143AC_CHECK_DECL([SECCOMP_MODE_FILTER], [have_seccomp_filter=1], , [
3144 #include <sys/types.h>
3145 #include <linux/seccomp.h>
3146])
3147fi
3148if test "x$have_seccomp_filter" = "x1" ; then
3149AC_MSG_CHECKING([kernel for seccomp_filter support])
3150AC_LINK_IFELSE([AC_LANG_PROGRAM([[
3151 #include <errno.h>
3152 #include <elf.h>
3153 #include <linux/audit.h>
3154 #include <linux/seccomp.h>
3155 #include <stdlib.h>
3156 #include <sys/prctl.h>
3157 ]],
3158 [[ int i = $seccomp_audit_arch;
3159 errno = 0;
3160 prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, NULL, 0, 0);
3161 exit(errno == EFAULT ? 0 : 1); ]])],
3162 [ AC_MSG_RESULT([yes]) ], [
3163 AC_MSG_RESULT([no])
3164 # Disable seccomp filter as a target
3165 have_seccomp_filter=0
3166 ]
3167)
3168fi
3169
Damien Miller69ff1df2011-06-23 08:30:03 +10003170# Decide which sandbox style to use
3171sandbox_arg=""
3172AC_ARG_WITH([sandbox],
deraadt@openbsd.org2539dce2015-10-09 01:37:08 +00003173 [ --with-sandbox=style Specify privilege separation sandbox (no, capsicum, darwin, rlimit, seccomp_filter, systrace, pledge)],
Damien Miller69ff1df2011-06-23 08:30:03 +10003174 [
3175 if test "x$withval" = "xyes" ; then
3176 sandbox_arg=""
3177 else
3178 sandbox_arg="$withval"
3179 fi
3180 ]
3181)
Darren Tucker60395f92012-07-03 14:31:18 +10003182
3183# Some platforms (seems to be the ones that have a kernel poll(2)-type
3184# function with which they implement select(2)) use an extra file descriptor
3185# when calling select(2), which means we can't use the rlimit sandbox.
3186AC_MSG_CHECKING([if select works with descriptor rlimit])
3187AC_RUN_IFELSE(
3188 [AC_LANG_PROGRAM([[
3189#include <sys/types.h>
3190#ifdef HAVE_SYS_TIME_H
3191# include <sys/time.h>
3192#endif
3193#include <sys/resource.h>
3194#ifdef HAVE_SYS_SELECT_H
3195# include <sys/select.h>
3196#endif
3197#include <errno.h>
3198#include <fcntl.h>
3199#include <stdlib.h>
3200 ]],[[
3201 struct rlimit rl_zero;
3202 int fd, r;
3203 fd_set fds;
Damien Millere4f43472013-03-08 12:14:22 +11003204 struct timeval tv;
Darren Tucker60395f92012-07-03 14:31:18 +10003205
3206 fd = open("/dev/null", O_RDONLY);
3207 FD_ZERO(&fds);
3208 FD_SET(fd, &fds);
3209 rl_zero.rlim_cur = rl_zero.rlim_max = 0;
3210 setrlimit(RLIMIT_FSIZE, &rl_zero);
3211 setrlimit(RLIMIT_NOFILE, &rl_zero);
Damien Millere4f43472013-03-08 12:14:22 +11003212 tv.tv_sec = 1;
3213 tv.tv_usec = 0;
3214 r = select(fd+1, &fds, NULL, NULL, &tv);
Darren Tucker60395f92012-07-03 14:31:18 +10003215 exit (r == -1 ? 1 : 0);
3216 ]])],
3217 [AC_MSG_RESULT([yes])
3218 select_works_with_rlimit=yes],
3219 [AC_MSG_RESULT([no])
3220 select_works_with_rlimit=no],
Mike Frysingerdcc714c2017-05-24 23:21:19 -04003221 [AC_MSG_WARN([cross compiling: assuming yes])
3222 select_works_with_rlimit=yes]
Darren Tucker60395f92012-07-03 14:31:18 +10003223)
3224
Darren Tuckerff008de2013-03-06 17:48:48 +11003225AC_MSG_CHECKING([if setrlimit(RLIMIT_NOFILE,{0,0}) works])
3226AC_RUN_IFELSE(
3227 [AC_LANG_PROGRAM([[
3228#include <sys/types.h>
3229#ifdef HAVE_SYS_TIME_H
3230# include <sys/time.h>
3231#endif
3232#include <sys/resource.h>
3233#include <errno.h>
3234#include <stdlib.h>
3235 ]],[[
3236 struct rlimit rl_zero;
3237 int fd, r;
3238 fd_set fds;
3239
3240 rl_zero.rlim_cur = rl_zero.rlim_max = 0;
3241 r = setrlimit(RLIMIT_NOFILE, &rl_zero);
3242 exit (r == -1 ? 1 : 0);
3243 ]])],
3244 [AC_MSG_RESULT([yes])
3245 rlimit_nofile_zero_works=yes],
3246 [AC_MSG_RESULT([no])
3247 rlimit_nofile_zero_works=no],
Mike Frysingerdcc714c2017-05-24 23:21:19 -04003248 [AC_MSG_WARN([cross compiling: assuming yes])
3249 rlimit_nofile_zero_works=yes]
Darren Tuckerff008de2013-03-06 17:48:48 +11003250)
3251
Darren Tuckerd545a4b2012-07-03 22:48:31 +10003252AC_MSG_CHECKING([if setrlimit RLIMIT_FSIZE works])
3253AC_RUN_IFELSE(
3254 [AC_LANG_PROGRAM([[
3255#include <sys/types.h>
3256#include <sys/resource.h>
3257#include <stdlib.h>
3258 ]],[[
3259 struct rlimit rl_zero;
3260
3261 rl_zero.rlim_cur = rl_zero.rlim_max = 0;
3262 exit(setrlimit(RLIMIT_FSIZE, &rl_zero) != 0);
3263 ]])],
3264 [AC_MSG_RESULT([yes])],
3265 [AC_MSG_RESULT([no])
3266 AC_DEFINE(SANDBOX_SKIP_RLIMIT_FSIZE, 1,
3267 [setrlimit RLIMIT_FSIZE works])],
3268 [AC_MSG_WARN([cross compiling: assuming yes])]
3269)
3270
deraadt@openbsd.org2539dce2015-10-09 01:37:08 +00003271if test "x$sandbox_arg" = "xpledge" || \
3272 ( test -z "$sandbox_arg" && test "x$ac_cv_func_pledge" = "xyes" ) ; then
3273 test "x$ac_cv_func_pledge" != "xyes" && \
3274 AC_MSG_ERROR([pledge sandbox requires pledge(2) support])
3275 SANDBOX_STYLE="pledge"
Damien Millerfafe1d82015-10-14 09:22:15 -07003276 AC_DEFINE([SANDBOX_PLEDGE], [1], [Sandbox using pledge(2)])
Damien Miller9846a2f2015-10-08 04:30:48 +11003277elif test "x$sandbox_arg" = "xsystrace" || \
Damien Miller69ff1df2011-06-23 08:30:03 +10003278 ( test -z "$sandbox_arg" && test "x$have_systr_policy_kill" = "x1" ) ; then
Damien Miller1a91c0f2011-08-17 11:59:25 +10003279 test "x$have_systr_policy_kill" != "x1" && \
3280 AC_MSG_ERROR([systrace sandbox requires systrace headers and SYSTR_POLICY_KILL support])
Damien Miller69ff1df2011-06-23 08:30:03 +10003281 SANDBOX_STYLE="systrace"
3282 AC_DEFINE([SANDBOX_SYSTRACE], [1], [Sandbox using systrace(4)])
Damien Millercd5e52e2011-06-27 07:18:18 +10003283elif test "x$sandbox_arg" = "xdarwin" || \
3284 ( test -z "$sandbox_arg" && test "x$ac_cv_func_sandbox_init" = "xyes" && \
3285 test "x$ac_cv_header_sandbox_h" = "xyes") ; then
Damien Miller1a91c0f2011-08-17 11:59:25 +10003286 test "x$ac_cv_func_sandbox_init" != "xyes" -o \
3287 "x$ac_cv_header_sandbox_h" != "xyes" && \
3288 AC_MSG_ERROR([Darwin seatbelt sandbox requires sandbox.h and sandbox_init function])
Damien Millercd5e52e2011-06-27 07:18:18 +10003289 SANDBOX_STYLE="darwin"
3290 AC_DEFINE([SANDBOX_DARWIN], [1], [Sandbox using Darwin sandbox_init(3)])
Damien Millere0956e32012-04-04 11:27:54 +10003291elif test "x$sandbox_arg" = "xseccomp_filter" || \
3292 ( test -z "$sandbox_arg" && \
Darren Tuckerd0494fd2012-05-19 14:25:39 +10003293 test "x$have_seccomp_filter" = "x1" && \
Damien Miller91f40d82013-02-22 11:37:00 +11003294 test "x$ac_cv_header_elf_h" = "xyes" && \
Damien Millere0956e32012-04-04 11:27:54 +10003295 test "x$ac_cv_header_linux_audit_h" = "xyes" && \
Damien Miller91f40d82013-02-22 11:37:00 +11003296 test "x$ac_cv_header_linux_filter_h" = "xyes" && \
3297 test "x$seccomp_audit_arch" != "x" && \
Damien Millere0956e32012-04-04 11:27:54 +10003298 test "x$have_linux_no_new_privs" = "x1" && \
3299 test "x$ac_cv_func_prctl" = "xyes" ) ; then
Damien Miller91f40d82013-02-22 11:37:00 +11003300 test "x$seccomp_audit_arch" = "x" && \
Damien Millere0956e32012-04-04 11:27:54 +10003301 AC_MSG_ERROR([seccomp_filter sandbox not supported on $host])
3302 test "x$have_linux_no_new_privs" != "x1" && \
3303 AC_MSG_ERROR([seccomp_filter sandbox requires PR_SET_NO_NEW_PRIVS])
3304 test "x$have_seccomp_filter" != "x1" && \
3305 AC_MSG_ERROR([seccomp_filter sandbox requires seccomp headers])
3306 test "x$ac_cv_func_prctl" != "xyes" && \
3307 AC_MSG_ERROR([seccomp_filter sandbox requires prctl function])
3308 SANDBOX_STYLE="seccomp_filter"
3309 AC_DEFINE([SANDBOX_SECCOMP_FILTER], [1], [Sandbox using seccomp filter])
Damien Millerf62ecef2014-01-25 12:34:38 +11003310elif test "x$sandbox_arg" = "xcapsicum" || \
3311 ( test -z "$sandbox_arg" && \
Darren Tuckerdd9d9b32017-08-28 16:48:27 +10003312 test "x$ac_cv_header_sys_capsicum_h" = "xyes" && \
Damien Miller603b8f42014-01-25 13:16:59 +11003313 test "x$ac_cv_func_cap_rights_limit" = "xyes") ; then
Darren Tuckerdd9d9b32017-08-28 16:48:27 +10003314 test "x$ac_cv_header_sys_capsicum_h" != "xyes" && \
3315 AC_MSG_ERROR([capsicum sandbox requires sys/capsicum.h header])
Damien Miller603b8f42014-01-25 13:16:59 +11003316 test "x$ac_cv_func_cap_rights_limit" != "xyes" && \
Damien Millerc96d8532014-01-25 13:12:28 +11003317 AC_MSG_ERROR([capsicum sandbox requires cap_rights_limit function])
Damien Millerf62ecef2014-01-25 12:34:38 +11003318 SANDBOX_STYLE="capsicum"
3319 AC_DEFINE([SANDBOX_CAPSICUM], [1], [Sandbox using capsicum])
Damien Miller69ff1df2011-06-23 08:30:03 +10003320elif test "x$sandbox_arg" = "xrlimit" || \
Darren Tucker60395f92012-07-03 14:31:18 +10003321 ( test -z "$sandbox_arg" && test "x$ac_cv_func_setrlimit" = "xyes" && \
Darren Tuckerff008de2013-03-06 17:48:48 +11003322 test "x$select_works_with_rlimit" = "xyes" && \
3323 test "x$rlimit_nofile_zero_works" = "xyes" ) ; then
Damien Miller1a91c0f2011-08-17 11:59:25 +10003324 test "x$ac_cv_func_setrlimit" != "xyes" && \
3325 AC_MSG_ERROR([rlimit sandbox requires setrlimit function])
Darren Tucker60395f92012-07-03 14:31:18 +10003326 test "x$select_works_with_rlimit" != "xyes" && \
3327 AC_MSG_ERROR([rlimit sandbox requires select to work with rlimit])
Damien Miller69ff1df2011-06-23 08:30:03 +10003328 SANDBOX_STYLE="rlimit"
3329 AC_DEFINE([SANDBOX_RLIMIT], [1], [Sandbox using setrlimit(2)])
Damien Miller4626cba2016-01-08 14:24:56 +11003330elif test "x$sandbox_arg" = "xsolaris" || \
3331 ( test -z "$sandbox_arg" && test "x$SOLARIS_PRIVS" = "xyes" ) ; then
3332 SANDBOX_STYLE="solaris"
3333 AC_DEFINE([SANDBOX_SOLARIS], [1], [Sandbox using Solaris/Illumos privileges])
Damien Miller69ff1df2011-06-23 08:30:03 +10003334elif test -z "$sandbox_arg" || test "x$sandbox_arg" = "xno" || \
3335 test "x$sandbox_arg" = "xnone" || test "x$sandbox_arg" = "xnull" ; then
3336 SANDBOX_STYLE="none"
3337 AC_DEFINE([SANDBOX_NULL], [1], [no privsep sandboxing])
3338else
Tim Ricea6e60612011-08-17 21:48:22 -07003339 AC_MSG_ERROR([unsupported --with-sandbox])
Damien Miller69ff1df2011-06-23 08:30:03 +10003340fi
3341
Ben Lindstromb5628642000-10-18 00:02:25 +00003342# Cheap hack to ensure NEWS-OS libraries are arranged right.
3343if test ! -z "$SONY" ; then
3344 LIBS="$LIBS -liberty";
3345fi
3346
Damien Miller57f39152005-11-24 19:58:19 +11003347# Check for long long datatypes
3348AC_CHECK_TYPES([long long, unsigned long long, long double])
3349
3350# Check datatype sizes
Tim Rice648f8762011-01-26 12:38:57 -08003351AC_CHECK_SIZEOF([short int], [2])
3352AC_CHECK_SIZEOF([int], [4])
3353AC_CHECK_SIZEOF([long int], [4])
3354AC_CHECK_SIZEOF([long long int], [8])
Damien Millerc6398ef1999-11-20 12:18:40 +11003355
Damien Millerfa2bb692002-04-23 23:22:25 +10003356# Sanity check long long for some platforms (AIX)
3357if test "x$ac_cv_sizeof_long_long_int" = "x4" ; then
3358 ac_cv_sizeof_long_long_int=0
3359fi
3360
Darren Tucker537f1ed2005-10-25 18:38:33 +10003361# compute LLONG_MIN and LLONG_MAX if we don't know them.
3362if test -z "$have_llong_max"; then
3363 AC_MSG_CHECKING([for max value of long long])
3364 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08003365 [AC_LANG_PROGRAM([[
Darren Tucker537f1ed2005-10-25 18:38:33 +10003366#include <stdio.h>
3367/* Why is this so damn hard? */
3368#ifdef __GNUC__
3369# undef __GNUC__
3370#endif
3371#define __USE_ISOC99
3372#include <limits.h>
3373#define DATA "conftest.llminmax"
Darren Tuckerd1450db2006-03-13 19:06:51 +11003374#define my_abs(a) ((a) < 0 ? ((a) * -1) : (a))
3375
3376/*
3377 * printf in libc on some platforms (eg old Tru64) does not understand %lld so
3378 * we do this the hard way.
3379 */
3380static int
3381fprint_ll(FILE *f, long long n)
3382{
3383 unsigned int i;
3384 int l[sizeof(long long) * 8];
3385
3386 if (n < 0)
3387 if (fprintf(f, "-") < 0)
3388 return -1;
3389 for (i = 0; n != 0; i++) {
3390 l[i] = my_abs(n % 10);
3391 n /= 10;
3392 }
3393 do {
3394 if (fprintf(f, "%d", l[--i]) < 0)
3395 return -1;
3396 } while (i != 0);
3397 if (fprintf(f, " ") < 0)
3398 return -1;
3399 return 0;
3400}
Tim Rice648f8762011-01-26 12:38:57 -08003401 ]], [[
Darren Tucker537f1ed2005-10-25 18:38:33 +10003402 FILE *f;
3403 long long i, llmin, llmax = 0;
3404
3405 if((f = fopen(DATA,"w")) == NULL)
3406 exit(1);
3407
3408#if defined(LLONG_MIN) && defined(LLONG_MAX)
3409 fprintf(stderr, "Using system header for LLONG_MIN and LLONG_MAX\n");
3410 llmin = LLONG_MIN;
3411 llmax = LLONG_MAX;
3412#else
3413 fprintf(stderr, "Calculating LLONG_MIN and LLONG_MAX\n");
3414 /* This will work on one's complement and two's complement */
3415 for (i = 1; i > llmax; i <<= 1, i++)
3416 llmax = i;
3417 llmin = llmax + 1LL; /* wrap */
3418#endif
3419
3420 /* Sanity check */
3421 if (llmin + 1 < llmin || llmin - 1 < llmin || llmax + 1 > llmax
Darren Tuckerd1450db2006-03-13 19:06:51 +11003422 || llmax - 1 > llmax || llmin == llmax || llmin == 0
3423 || llmax == 0 || llmax < LONG_MAX || llmin > LONG_MIN) {
Darren Tucker537f1ed2005-10-25 18:38:33 +10003424 fprintf(f, "unknown unknown\n");
3425 exit(2);
3426 }
3427
Darren Tuckerd1450db2006-03-13 19:06:51 +11003428 if (fprint_ll(f, llmin) < 0)
Darren Tucker537f1ed2005-10-25 18:38:33 +10003429 exit(3);
Darren Tuckerd1450db2006-03-13 19:06:51 +11003430 if (fprint_ll(f, llmax) < 0)
3431 exit(4);
3432 if (fclose(f) < 0)
3433 exit(5);
Darren Tucker537f1ed2005-10-25 18:38:33 +10003434 exit(0);
Darren Tucker537f1ed2005-10-25 18:38:33 +10003435 ]])],
3436 [
3437 llong_min=`$AWK '{print $1}' conftest.llminmax`
3438 llong_max=`$AWK '{print $2}' conftest.llminmax`
3439
Tim Rice648f8762011-01-26 12:38:57 -08003440 AC_MSG_RESULT([$llong_max])
3441 AC_DEFINE_UNQUOTED([LLONG_MAX], [${llong_max}LL],
Darren Tucker537f1ed2005-10-25 18:38:33 +10003442 [max value of long long calculated by configure])
3443 AC_MSG_CHECKING([for min value of long long])
Tim Rice648f8762011-01-26 12:38:57 -08003444 AC_MSG_RESULT([$llong_min])
3445 AC_DEFINE_UNQUOTED([LLONG_MIN], [${llong_min}LL],
Darren Tucker537f1ed2005-10-25 18:38:33 +10003446 [min value of long long calculated by configure])
3447 ],
3448 [
Tim Rice648f8762011-01-26 12:38:57 -08003449 AC_MSG_RESULT([not found])
Darren Tucker537f1ed2005-10-25 18:38:33 +10003450 ],
3451 [
3452 AC_MSG_WARN([cross compiling: not checking])
3453 ]
3454 )
3455fi
3456
3457
Damien Millera22ba012000-03-02 23:09:20 +11003458# More checks for data types
Damien Millercaf6dd62000-08-29 11:33:50 +11003459AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [
Tim Rice648f8762011-01-26 12:38:57 -08003460 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3461 [[ u_int a; a = 1;]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003462 [ ac_cv_have_u_int="yes" ], [ ac_cv_have_u_int="no"
Tim Rice648f8762011-01-26 12:38:57 -08003463 ])
Damien Millercaf6dd62000-08-29 11:33:50 +11003464])
3465if test "x$ac_cv_have_u_int" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003466 AC_DEFINE([HAVE_U_INT], [1], [define if you have u_int data type])
Damien Millercaf6dd62000-08-29 11:33:50 +11003467 have_u_int=1
3468fi
3469
Damien Miller61e50f12000-05-08 20:49:37 +10003470AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003471 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3472 [[ int8_t a; int16_t b; int32_t c; a = b = c = 1;]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003473 [ ac_cv_have_intxx_t="yes" ], [ ac_cv_have_intxx_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003474 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003475])
3476if test "x$ac_cv_have_intxx_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003477 AC_DEFINE([HAVE_INTXX_T], [1], [define if you have intxx_t data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003478 have_intxx_t=1
3479fi
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003480
3481if (test -z "$have_intxx_t" && \
Damien Millera8e06ce2003-11-21 23:48:55 +11003482 test "x$ac_cv_header_stdint_h" = "xyes")
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003483then
3484 AC_MSG_CHECKING([for intXX_t types in stdint.h])
Tim Rice648f8762011-01-26 12:38:57 -08003485 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdint.h> ]],
3486 [[ int8_t a; int16_t b; int32_t c; a = b = c = 1;]])],
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003487 [
Tim Rice648f8762011-01-26 12:38:57 -08003488 AC_DEFINE([HAVE_INTXX_T])
3489 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003490 ], [ AC_MSG_RESULT([no])
Tim Rice648f8762011-01-26 12:38:57 -08003491 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003492fi
3493
Damien Miller578783e2000-09-23 14:12:24 +11003494AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003495 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Tim Rice907881e2002-07-18 11:44:50 -07003496#include <sys/types.h>
3497#ifdef HAVE_STDINT_H
3498# include <stdint.h>
3499#endif
3500#include <sys/socket.h>
3501#ifdef HAVE_SYS_BITYPES_H
3502# include <sys/bitypes.h>
3503#endif
Tim Rice648f8762011-01-26 12:38:57 -08003504 ]], [[
3505int64_t a; a = 1;
3506 ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003507 [ ac_cv_have_int64_t="yes" ], [ ac_cv_have_int64_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003508 ])
Damien Miller578783e2000-09-23 14:12:24 +11003509])
3510if test "x$ac_cv_have_int64_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003511 AC_DEFINE([HAVE_INT64_T], [1], [define if you have int64_t data type])
Tim Rice4cec93f2002-02-26 08:40:48 -08003512fi
3513
Damien Miller61e50f12000-05-08 20:49:37 +10003514AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003515 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3516 [[ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003517 [ ac_cv_have_u_intxx_t="yes" ], [ ac_cv_have_u_intxx_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003518 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003519])
3520if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003521 AC_DEFINE([HAVE_U_INTXX_T], [1], [define if you have u_intxx_t data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003522 have_u_intxx_t=1
3523fi
Damien Millerc6398ef1999-11-20 12:18:40 +11003524
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003525if test -z "$have_u_intxx_t" ; then
3526 AC_MSG_CHECKING([for u_intXX_t types in sys/socket.h])
Tim Rice648f8762011-01-26 12:38:57 -08003527 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/socket.h> ]],
3528 [[ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;]])],
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003529 [
Tim Rice648f8762011-01-26 12:38:57 -08003530 AC_DEFINE([HAVE_U_INTXX_T])
3531 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003532 ], [ AC_MSG_RESULT([no])
Tim Rice648f8762011-01-26 12:38:57 -08003533 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003534fi
3535
Damien Miller578783e2000-09-23 14:12:24 +11003536AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003537 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3538 [[ u_int64_t a; a = 1;]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003539 [ ac_cv_have_u_int64_t="yes" ], [ ac_cv_have_u_int64_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003540 ])
Damien Miller578783e2000-09-23 14:12:24 +11003541])
3542if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003543 AC_DEFINE([HAVE_U_INT64_T], [1], [define if you have u_int64_t data type])
Damien Miller578783e2000-09-23 14:12:24 +11003544 have_u_int64_t=1
3545fi
3546
Damien Millerc2868192014-01-30 10:21:19 +11003547if (test -z "$have_u_int64_t" && \
3548 test "x$ac_cv_header_sys_bitypes_h" = "xyes")
3549then
Tim Rice4cec93f2002-02-26 08:40:48 -08003550 AC_MSG_CHECKING([for u_int64_t type in sys/bitypes.h])
Tim Rice648f8762011-01-26 12:38:57 -08003551 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/bitypes.h> ]],
3552 [[ u_int64_t a; a = 1]])],
Tim Rice4cec93f2002-02-26 08:40:48 -08003553 [
Tim Rice648f8762011-01-26 12:38:57 -08003554 AC_DEFINE([HAVE_U_INT64_T])
3555 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003556 ], [ AC_MSG_RESULT([no])
Tim Rice648f8762011-01-26 12:38:57 -08003557 ])
Tim Rice4cec93f2002-02-26 08:40:48 -08003558fi
3559
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003560if test -z "$have_u_intxx_t" ; then
3561 AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003562 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003563#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08003564 ]], [[
3565 uint8_t a;
3566 uint16_t b;
3567 uint32_t c;
3568 a = b = c = 1;
3569 ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003570 [ ac_cv_have_uintxx_t="yes" ], [ ac_cv_have_uintxx_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003571 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003572 ])
3573 if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003574 AC_DEFINE([HAVE_UINTXX_T], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003575 [define if you have uintxx_t data type])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003576 fi
3577fi
3578
Damien Millerc2868192014-01-30 10:21:19 +11003579if (test -z "$have_uintxx_t" && \
3580 test "x$ac_cv_header_stdint_h" = "xyes")
3581then
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003582 AC_MSG_CHECKING([for uintXX_t types in stdint.h])
Tim Rice648f8762011-01-26 12:38:57 -08003583 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdint.h> ]],
3584 [[ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;]])],
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003585 [
Tim Rice648f8762011-01-26 12:38:57 -08003586 AC_DEFINE([HAVE_UINTXX_T])
3587 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003588 ], [ AC_MSG_RESULT([no])
Tim Rice648f8762011-01-26 12:38:57 -08003589 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003590fi
3591
Damien Millerc2868192014-01-30 10:21:19 +11003592if (test -z "$have_uintxx_t" && \
3593 test "x$ac_cv_header_inttypes_h" = "xyes")
3594then
Darren Tucker6d725682014-01-17 19:17:34 +11003595 AC_MSG_CHECKING([for uintXX_t types in inttypes.h])
3596 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <inttypes.h> ]],
3597 [[ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;]])],
3598 [
3599 AC_DEFINE([HAVE_UINTXX_T])
3600 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003601 ], [ AC_MSG_RESULT([no])
Darren Tucker6d725682014-01-17 19:17:34 +11003602 ])
3603fi
3604
Damien Milleredb82922000-06-20 13:25:52 +10003605if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
Damien Millera8e06ce2003-11-21 23:48:55 +11003606 test "x$ac_cv_header_sys_bitypes_h" = "xyes")
Damien Millerb29ea912000-01-15 14:12:03 +11003607then
3608 AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
Tim Rice648f8762011-01-26 12:38:57 -08003609 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller61e50f12000-05-08 20:49:37 +10003610#include <sys/bitypes.h>
Tim Rice648f8762011-01-26 12:38:57 -08003611 ]], [[
Damien Miller70494d12000-04-03 15:57:06 +10003612 int8_t a; int16_t b; int32_t c;
3613 u_int8_t e; u_int16_t f; u_int32_t g;
3614 a = b = c = e = f = g = 1;
Tim Rice648f8762011-01-26 12:38:57 -08003615 ]])],
Damien Millerb29ea912000-01-15 14:12:03 +11003616 [
Tim Rice648f8762011-01-26 12:38:57 -08003617 AC_DEFINE([HAVE_U_INTXX_T])
3618 AC_DEFINE([HAVE_INTXX_T])
3619 AC_MSG_RESULT([yes])
3620 ], [AC_MSG_RESULT([no])
3621 ])
Damien Millerb29ea912000-01-15 14:12:03 +11003622fi
3623
Damien Miller58be7382001-09-15 21:31:54 +10003624
3625AC_CACHE_CHECK([for u_char], ac_cv_have_u_char, [
Tim Rice648f8762011-01-26 12:38:57 -08003626 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3627 [[ u_char foo; foo = 125; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003628 [ ac_cv_have_u_char="yes" ], [ ac_cv_have_u_char="no"
Tim Rice648f8762011-01-26 12:38:57 -08003629 ])
Damien Miller58be7382001-09-15 21:31:54 +10003630])
3631if test "x$ac_cv_have_u_char" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003632 AC_DEFINE([HAVE_U_CHAR], [1], [define if you have u_char data type])
Damien Miller58be7382001-09-15 21:31:54 +10003633fi
3634
Darren Tucker007e3b32013-11-03 18:43:55 +11003635AC_CHECK_TYPES([intmax_t, uintmax_t], , , [
3636#include <sys/types.h>
3637#include <stdint.h>
3638])
3639
Tim Rice13aae5e2001-10-21 17:53:58 -07003640TYPE_SOCKLEN_T
Damien Miller74d0d4a1999-12-29 02:24:35 +11003641
Tim Rice648f8762011-01-26 12:38:57 -08003642AC_CHECK_TYPES([sig_atomic_t], , , [#include <signal.h>])
3643AC_CHECK_TYPES([fsblkcnt_t, fsfilcnt_t], , , [
Darren Tucker598eaa62008-06-09 03:32:29 +10003644#include <sys/types.h>
3645#ifdef HAVE_SYS_BITYPES_H
3646#include <sys/bitypes.h>
3647#endif
3648#ifdef HAVE_SYS_STATFS_H
3649#include <sys/statfs.h>
3650#endif
3651#ifdef HAVE_SYS_STATVFS_H
3652#include <sys/statvfs.h>
3653#endif
3654])
Tim Rice4cec93f2002-02-26 08:40:48 -08003655
Tim Rice648f8762011-01-26 12:38:57 -08003656AC_CHECK_TYPES([in_addr_t, in_port_t], , ,
Damien Miller848b9932005-02-24 12:12:34 +11003657[#include <sys/types.h>
3658#include <netinet/in.h>])
Darren Tuckerd9f88912005-02-20 21:01:48 +11003659
Damien Miller61e50f12000-05-08 20:49:37 +10003660AC_CACHE_CHECK([for size_t], ac_cv_have_size_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003661 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3662 [[ size_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003663 [ ac_cv_have_size_t="yes" ], [ ac_cv_have_size_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003664 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003665])
3666if test "x$ac_cv_have_size_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003667 AC_DEFINE([HAVE_SIZE_T], [1], [define if you have size_t data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003668fi
Damien Miller95058511999-12-29 10:36:45 +11003669
Damien Miller615f9392000-05-17 22:53:33 +10003670AC_CACHE_CHECK([for ssize_t], ac_cv_have_ssize_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003671 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3672 [[ ssize_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003673 [ ac_cv_have_ssize_t="yes" ], [ ac_cv_have_ssize_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003674 ])
Damien Miller615f9392000-05-17 22:53:33 +10003675])
3676if test "x$ac_cv_have_ssize_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003677 AC_DEFINE([HAVE_SSIZE_T], [1], [define if you have ssize_t data type])
Damien Miller615f9392000-05-17 22:53:33 +10003678fi
3679
Ben Lindstrom0d5af602001-01-09 00:50:29 +00003680AC_CACHE_CHECK([for clock_t], ac_cv_have_clock_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003681 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <time.h> ]],
3682 [[ clock_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003683 [ ac_cv_have_clock_t="yes" ], [ ac_cv_have_clock_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003684 ])
Ben Lindstrom0d5af602001-01-09 00:50:29 +00003685])
3686if test "x$ac_cv_have_clock_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003687 AC_DEFINE([HAVE_CLOCK_T], [1], [define if you have clock_t data type])
Ben Lindstrom0d5af602001-01-09 00:50:29 +00003688fi
3689
Damien Millerb54b40e2000-06-23 08:23:34 +10003690AC_CACHE_CHECK([for sa_family_t], ac_cv_have_sa_family_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003691 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Millerb54b40e2000-06-23 08:23:34 +10003692#include <sys/types.h>
3693#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08003694 ]], [[ sa_family_t foo; foo = 1235; ]])],
3695 [ ac_cv_have_sa_family_t="yes" ],
3696 [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller78315eb2000-09-29 23:01:36 +11003697#include <sys/types.h>
3698#include <sys/socket.h>
3699#include <netinet/in.h>
Tim Rice648f8762011-01-26 12:38:57 -08003700 ]], [[ sa_family_t foo; foo = 1235; ]])],
Damien Miller78315eb2000-09-29 23:01:36 +11003701 [ ac_cv_have_sa_family_t="yes" ],
Damien Millerb54b40e2000-06-23 08:23:34 +10003702 [ ac_cv_have_sa_family_t="no" ]
3703 )
Tim Rice648f8762011-01-26 12:38:57 -08003704 ])
Damien Millerb54b40e2000-06-23 08:23:34 +10003705])
3706if test "x$ac_cv_have_sa_family_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003707 AC_DEFINE([HAVE_SA_FAMILY_T], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003708 [define if you have sa_family_t data type])
Damien Millerb54b40e2000-06-23 08:23:34 +10003709fi
3710
Damien Miller0f91b4e2000-06-18 15:43:25 +10003711AC_CACHE_CHECK([for pid_t], ac_cv_have_pid_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003712 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3713 [[ pid_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003714 [ ac_cv_have_pid_t="yes" ], [ ac_cv_have_pid_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003715 ])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003716])
3717if test "x$ac_cv_have_pid_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003718 AC_DEFINE([HAVE_PID_T], [1], [define if you have pid_t data type])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003719fi
3720
3721AC_CACHE_CHECK([for mode_t], ac_cv_have_mode_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003722 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3723 [[ mode_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003724 [ ac_cv_have_mode_t="yes" ], [ ac_cv_have_mode_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003725 ])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003726])
3727if test "x$ac_cv_have_mode_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003728 AC_DEFINE([HAVE_MODE_T], [1], [define if you have mode_t data type])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003729fi
3730
Damien Miller61e50f12000-05-08 20:49:37 +10003731
3732AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_have_struct_sockaddr_storage, [
Tim Rice648f8762011-01-26 12:38:57 -08003733 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10003734#include <sys/types.h>
3735#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08003736 ]], [[ struct sockaddr_storage s; ]])],
3737 [ ac_cv_have_struct_sockaddr_storage="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003738 [ ac_cv_have_struct_sockaddr_storage="no"
Tim Rice648f8762011-01-26 12:38:57 -08003739 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003740])
3741if test "x$ac_cv_have_struct_sockaddr_storage" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003742 AC_DEFINE([HAVE_STRUCT_SOCKADDR_STORAGE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003743 [define if you have struct sockaddr_storage data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003744fi
Damien Miller34132e52000-01-14 15:45:46 +11003745
Damien Miller61e50f12000-05-08 20:49:37 +10003746AC_CACHE_CHECK([for struct sockaddr_in6], ac_cv_have_struct_sockaddr_in6, [
Tim Rice648f8762011-01-26 12:38:57 -08003747 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller7b22d652000-06-18 14:07:04 +10003748#include <sys/types.h>
Damien Miller61e50f12000-05-08 20:49:37 +10003749#include <netinet/in.h>
Tim Rice648f8762011-01-26 12:38:57 -08003750 ]], [[ struct sockaddr_in6 s; s.sin6_family = 0; ]])],
3751 [ ac_cv_have_struct_sockaddr_in6="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003752 [ ac_cv_have_struct_sockaddr_in6="no"
Tim Rice648f8762011-01-26 12:38:57 -08003753 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003754])
3755if test "x$ac_cv_have_struct_sockaddr_in6" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003756 AC_DEFINE([HAVE_STRUCT_SOCKADDR_IN6], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003757 [define if you have struct sockaddr_in6 data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003758fi
Damien Miller34132e52000-01-14 15:45:46 +11003759
Damien Miller61e50f12000-05-08 20:49:37 +10003760AC_CACHE_CHECK([for struct in6_addr], ac_cv_have_struct_in6_addr, [
Tim Rice648f8762011-01-26 12:38:57 -08003761 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller7b22d652000-06-18 14:07:04 +10003762#include <sys/types.h>
Damien Miller61e50f12000-05-08 20:49:37 +10003763#include <netinet/in.h>
Tim Rice648f8762011-01-26 12:38:57 -08003764 ]], [[ struct in6_addr s; s.s6_addr[0] = 0; ]])],
3765 [ ac_cv_have_struct_in6_addr="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003766 [ ac_cv_have_struct_in6_addr="no"
Tim Rice648f8762011-01-26 12:38:57 -08003767 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003768])
3769if test "x$ac_cv_have_struct_in6_addr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003770 AC_DEFINE([HAVE_STRUCT_IN6_ADDR], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003771 [define if you have struct in6_addr data type])
Tim Rice0f4d2c02008-11-18 21:26:41 -08003772
3773dnl Now check for sin6_scope_id
Tim Rice648f8762011-01-26 12:38:57 -08003774 AC_CHECK_MEMBERS([struct sockaddr_in6.sin6_scope_id], , ,
Tim Rice0f4d2c02008-11-18 21:26:41 -08003775 [
3776#ifdef HAVE_SYS_TYPES_H
3777#include <sys/types.h>
3778#endif
3779#include <netinet/in.h>
3780 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003781fi
Damien Miller34132e52000-01-14 15:45:46 +11003782
Damien Miller61e50f12000-05-08 20:49:37 +10003783AC_CACHE_CHECK([for struct addrinfo], ac_cv_have_struct_addrinfo, [
Tim Rice648f8762011-01-26 12:38:57 -08003784 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10003785#include <sys/types.h>
3786#include <sys/socket.h>
3787#include <netdb.h>
Tim Rice648f8762011-01-26 12:38:57 -08003788 ]], [[ struct addrinfo s; s.ai_flags = AI_PASSIVE; ]])],
3789 [ ac_cv_have_struct_addrinfo="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003790 [ ac_cv_have_struct_addrinfo="no"
Tim Rice648f8762011-01-26 12:38:57 -08003791 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003792])
3793if test "x$ac_cv_have_struct_addrinfo" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003794 AC_DEFINE([HAVE_STRUCT_ADDRINFO], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003795 [define if you have struct addrinfo data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003796fi
3797
Ben Lindstrom42202bc2001-01-15 02:34:37 +00003798AC_CACHE_CHECK([for struct timeval], ac_cv_have_struct_timeval, [
Tim Rice648f8762011-01-26 12:38:57 -08003799 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/time.h> ]],
3800 [[ struct timeval tv; tv.tv_sec = 1;]])],
3801 [ ac_cv_have_struct_timeval="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003802 [ ac_cv_have_struct_timeval="no"
Tim Rice648f8762011-01-26 12:38:57 -08003803 ])
Ben Lindstrom42202bc2001-01-15 02:34:37 +00003804])
3805if test "x$ac_cv_have_struct_timeval" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003806 AC_DEFINE([HAVE_STRUCT_TIMEVAL], [1], [define if you have struct timeval])
Ben Lindstrom42202bc2001-01-15 02:34:37 +00003807 have_struct_timeval=1
3808fi
3809
Tim Rice648f8762011-01-26 12:38:57 -08003810AC_CHECK_TYPES([struct timespec])
Tim Rice4e4dc562003-03-18 10:21:40 -08003811
Ben Lindstrom5bd6eb72003-03-21 00:34:34 +00003812# We need int64_t or else certian parts of the compile will fail.
Tim Rice8bb561b2005-03-17 16:23:19 -08003813if test "x$ac_cv_have_int64_t" = "xno" && \
3814 test "x$ac_cv_sizeof_long_int" != "x8" && \
3815 test "x$ac_cv_sizeof_long_long_int" = "x0" ; then
Ben Lindstrom5bd6eb72003-03-21 00:34:34 +00003816 echo "OpenSSH requires int64_t support. Contact your vendor or install"
3817 echo "an alternative compiler (I.E., GCC) before continuing."
3818 echo ""
3819 exit 1;
Tim Ricebee3f222001-03-11 17:32:12 -08003820else
3821dnl test snprintf (broken on SCO w/gcc)
Darren Tuckera0c2b392004-09-11 23:26:37 +10003822 AC_RUN_IFELSE(
Darren Tucker623d92f2004-09-12 22:36:15 +10003823 [AC_LANG_SOURCE([[
Tim Ricebee3f222001-03-11 17:32:12 -08003824#include <stdio.h>
3825#include <string.h>
3826#ifdef HAVE_SNPRINTF
3827main()
3828{
3829 char buf[50];
3830 char expected_out[50];
3831 int mazsize = 50 ;
3832#if (SIZEOF_LONG_INT == 8)
3833 long int num = 0x7fffffffffffffff;
3834#else
Kevin Steves6482ec82001-07-15 02:09:28 +00003835 long long num = 0x7fffffffffffffffll;
Tim Ricebee3f222001-03-11 17:32:12 -08003836#endif
3837 strcpy(expected_out, "9223372036854775807");
3838 snprintf(buf, mazsize, "%lld", num);
3839 if(strcmp(buf, expected_out) != 0)
Damien Millera8e06ce2003-11-21 23:48:55 +11003840 exit(1);
Tim Ricebee3f222001-03-11 17:32:12 -08003841 exit(0);
3842}
3843#else
3844main() { exit(0); }
3845#endif
Tim Rice648f8762011-01-26 12:38:57 -08003846 ]])], [ true ], [ AC_DEFINE([BROKEN_SNPRINTF]) ],
Darren Tuckera0c2b392004-09-11 23:26:37 +10003847 AC_MSG_WARN([cross compiling: Assuming working snprintf()])
Tim Ricebee3f222001-03-11 17:32:12 -08003848 )
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00003849fi
3850
Damien Miller78315eb2000-09-29 23:01:36 +11003851dnl Checks for structure members
Tim Rice648f8762011-01-26 12:38:57 -08003852OSSH_CHECK_HEADER_FOR_FIELD([ut_host], [utmp.h], [HAVE_HOST_IN_UTMP])
3853OSSH_CHECK_HEADER_FOR_FIELD([ut_host], [utmpx.h], [HAVE_HOST_IN_UTMPX])
3854OSSH_CHECK_HEADER_FOR_FIELD([syslen], [utmpx.h], [HAVE_SYSLEN_IN_UTMPX])
3855OSSH_CHECK_HEADER_FOR_FIELD([ut_pid], [utmp.h], [HAVE_PID_IN_UTMP])
3856OSSH_CHECK_HEADER_FOR_FIELD([ut_type], [utmp.h], [HAVE_TYPE_IN_UTMP])
3857OSSH_CHECK_HEADER_FOR_FIELD([ut_type], [utmpx.h], [HAVE_TYPE_IN_UTMPX])
3858OSSH_CHECK_HEADER_FOR_FIELD([ut_tv], [utmp.h], [HAVE_TV_IN_UTMP])
3859OSSH_CHECK_HEADER_FOR_FIELD([ut_id], [utmp.h], [HAVE_ID_IN_UTMP])
3860OSSH_CHECK_HEADER_FOR_FIELD([ut_id], [utmpx.h], [HAVE_ID_IN_UTMPX])
3861OSSH_CHECK_HEADER_FOR_FIELD([ut_addr], [utmp.h], [HAVE_ADDR_IN_UTMP])
3862OSSH_CHECK_HEADER_FOR_FIELD([ut_addr], [utmpx.h], [HAVE_ADDR_IN_UTMPX])
3863OSSH_CHECK_HEADER_FOR_FIELD([ut_addr_v6], [utmp.h], [HAVE_ADDR_V6_IN_UTMP])
3864OSSH_CHECK_HEADER_FOR_FIELD([ut_addr_v6], [utmpx.h], [HAVE_ADDR_V6_IN_UTMPX])
3865OSSH_CHECK_HEADER_FOR_FIELD([ut_exit], [utmp.h], [HAVE_EXIT_IN_UTMP])
3866OSSH_CHECK_HEADER_FOR_FIELD([ut_time], [utmp.h], [HAVE_TIME_IN_UTMP])
3867OSSH_CHECK_HEADER_FOR_FIELD([ut_time], [utmpx.h], [HAVE_TIME_IN_UTMPX])
3868OSSH_CHECK_HEADER_FOR_FIELD([ut_tv], [utmpx.h], [HAVE_TV_IN_UTMPX])
Tim Rice13aae5e2001-10-21 17:53:58 -07003869
3870AC_CHECK_MEMBERS([struct stat.st_blksize])
Damien Millerbcd14852017-06-10 23:41:25 +10003871AC_CHECK_MEMBERS([struct stat.st_mtim])
3872AC_CHECK_MEMBERS([struct stat.st_mtime])
Damien Miller6332da22013-04-23 14:25:52 +10003873AC_CHECK_MEMBERS([struct passwd.pw_gecos, struct passwd.pw_class,
3874struct passwd.pw_change, struct passwd.pw_expire],
3875[], [], [[
3876#include <sys/types.h>
3877#include <pwd.h>
3878]])
3879
Tim Rice648f8762011-01-26 12:38:57 -08003880AC_CHECK_MEMBER([struct __res_state.retrans], [], [AC_DEFINE([__res_state], [state],
Darren Tucker58e298d2005-11-25 13:14:58 +11003881 [Define if we don't have struct __res_state in resolv.h])],
Damien Miller6332da22013-04-23 14:25:52 +10003882[[
Darren Tucker58e298d2005-11-25 13:14:58 +11003883#include <stdio.h>
3884#if HAVE_SYS_TYPES_H
3885# include <sys/types.h>
3886#endif
3887#include <netinet/in.h>
3888#include <arpa/nameser.h>
3889#include <resolv.h>
Damien Miller6332da22013-04-23 14:25:52 +10003890]])
andre2ff7b5d2000-06-03 14:57:40 +00003891
Damien Miller61e50f12000-05-08 20:49:37 +10003892AC_CACHE_CHECK([for ss_family field in struct sockaddr_storage],
3893 ac_cv_have_ss_family_in_struct_ss, [
Tim Rice648f8762011-01-26 12:38:57 -08003894 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10003895#include <sys/types.h>
3896#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08003897 ]], [[ struct sockaddr_storage s; s.ss_family = 1; ]])],
3898 [ ac_cv_have_ss_family_in_struct_ss="yes" ],
3899 [ ac_cv_have_ss_family_in_struct_ss="no" ])
Damien Miller61e50f12000-05-08 20:49:37 +10003900])
3901if test "x$ac_cv_have_ss_family_in_struct_ss" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003902 AC_DEFINE([HAVE_SS_FAMILY_IN_SS], [1], [Fields in struct sockaddr_storage])
Damien Miller61e50f12000-05-08 20:49:37 +10003903fi
3904
Damien Miller61e50f12000-05-08 20:49:37 +10003905AC_CACHE_CHECK([for __ss_family field in struct sockaddr_storage],
3906 ac_cv_have___ss_family_in_struct_ss, [
Tim Rice648f8762011-01-26 12:38:57 -08003907 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10003908#include <sys/types.h>
3909#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08003910 ]], [[ struct sockaddr_storage s; s.__ss_family = 1; ]])],
3911 [ ac_cv_have___ss_family_in_struct_ss="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003912 [ ac_cv_have___ss_family_in_struct_ss="no"
Tim Rice648f8762011-01-26 12:38:57 -08003913 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003914])
3915if test "x$ac_cv_have___ss_family_in_struct_ss" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003916 AC_DEFINE([HAVE___SS_FAMILY_IN_SS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003917 [Fields in struct sockaddr_storage])
Damien Miller61e50f12000-05-08 20:49:37 +10003918fi
Damien Millerbf1c9b21999-12-09 10:16:54 +11003919
Tim Rice28bbb0c2002-05-27 17:37:32 -07003920dnl make sure we're using the real structure members and not defines
Kevin Steves939c9db2002-03-22 17:23:25 +00003921AC_CACHE_CHECK([for msg_accrights field in struct msghdr],
3922 ac_cv_have_accrights_in_msghdr, [
Tim Rice648f8762011-01-26 12:38:57 -08003923 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Tim Riceae49fe62002-04-12 10:26:21 -07003924#include <sys/types.h>
Kevin Steves939c9db2002-03-22 17:23:25 +00003925#include <sys/socket.h>
3926#include <sys/uio.h>
Tim Rice648f8762011-01-26 12:38:57 -08003927 ]], [[
Tim Rice28bbb0c2002-05-27 17:37:32 -07003928#ifdef msg_accrights
Darren Tuckera0c2b392004-09-11 23:26:37 +10003929#error "msg_accrights is a macro"
Tim Rice28bbb0c2002-05-27 17:37:32 -07003930exit(1);
3931#endif
3932struct msghdr m;
3933m.msg_accrights = 0;
3934exit(0);
Tim Rice648f8762011-01-26 12:38:57 -08003935 ]])],
Kevin Steves939c9db2002-03-22 17:23:25 +00003936 [ ac_cv_have_accrights_in_msghdr="yes" ],
3937 [ ac_cv_have_accrights_in_msghdr="no" ]
3938 )
3939])
3940if test "x$ac_cv_have_accrights_in_msghdr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003941 AC_DEFINE([HAVE_ACCRIGHTS_IN_MSGHDR], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003942 [Define if your system uses access rights style
3943 file descriptor passing])
Kevin Steves939c9db2002-03-22 17:23:25 +00003944fi
3945
Tim Rice648f8762011-01-26 12:38:57 -08003946AC_MSG_CHECKING([if struct statvfs.f_fsid is integral type])
3947AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckere1a3ddf2012-05-04 11:05:45 +10003948#include <sys/param.h>
Darren Tucker32780622009-06-16 16:11:02 +10003949#include <sys/stat.h>
3950#ifdef HAVE_SYS_TIME_H
3951# include <sys/time.h>
3952#endif
3953#ifdef HAVE_SYS_MOUNT_H
3954#include <sys/mount.h>
3955#endif
3956#ifdef HAVE_SYS_STATVFS_H
3957#include <sys/statvfs.h>
3958#endif
Tim Rice648f8762011-01-26 12:38:57 -08003959 ]], [[ struct statvfs s; s.f_fsid = 0; ]])],
3960 [ AC_MSG_RESULT([yes]) ],
3961 [ AC_MSG_RESULT([no])
Darren Tucker32780622009-06-16 16:11:02 +10003962
Tim Rice648f8762011-01-26 12:38:57 -08003963 AC_MSG_CHECKING([if fsid_t has member val])
3964 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker32780622009-06-16 16:11:02 +10003965#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08003966#include <sys/statvfs.h>
3967 ]], [[ fsid_t t; t.val[0] = 0; ]])],
3968 [ AC_MSG_RESULT([yes])
3969 AC_DEFINE([FSID_HAS_VAL], [1], [fsid_t has member val]) ],
3970 [ AC_MSG_RESULT([no]) ])
Darren Tucker32780622009-06-16 16:11:02 +10003971
Tim Rice648f8762011-01-26 12:38:57 -08003972 AC_MSG_CHECKING([if f_fsid has member __val])
3973 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker32780622009-06-16 16:11:02 +10003974#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08003975#include <sys/statvfs.h>
3976 ]], [[ fsid_t t; t.__val[0] = 0; ]])],
3977 [ AC_MSG_RESULT([yes])
3978 AC_DEFINE([FSID_HAS___VAL], [1], [fsid_t has member __val]) ],
3979 [ AC_MSG_RESULT([no]) ])
Darren Tucker32780622009-06-16 16:11:02 +10003980])
Darren Tucker77001382008-06-09 06:17:53 +10003981
Kevin Stevesa44e0352002-04-07 16:18:03 +00003982AC_CACHE_CHECK([for msg_control field in struct msghdr],
3983 ac_cv_have_control_in_msghdr, [
Tim Rice648f8762011-01-26 12:38:57 -08003984 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Tim Riceae49fe62002-04-12 10:26:21 -07003985#include <sys/types.h>
Kevin Stevesa44e0352002-04-07 16:18:03 +00003986#include <sys/socket.h>
3987#include <sys/uio.h>
Tim Rice648f8762011-01-26 12:38:57 -08003988 ]], [[
Tim Rice28bbb0c2002-05-27 17:37:32 -07003989#ifdef msg_control
Darren Tuckera0c2b392004-09-11 23:26:37 +10003990#error "msg_control is a macro"
Tim Rice28bbb0c2002-05-27 17:37:32 -07003991exit(1);
3992#endif
3993struct msghdr m;
3994m.msg_control = 0;
3995exit(0);
Tim Rice648f8762011-01-26 12:38:57 -08003996 ]])],
Kevin Stevesa44e0352002-04-07 16:18:03 +00003997 [ ac_cv_have_control_in_msghdr="yes" ],
3998 [ ac_cv_have_control_in_msghdr="no" ]
3999 )
4000])
4001if test "x$ac_cv_have_control_in_msghdr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004002 AC_DEFINE([HAVE_CONTROL_IN_MSGHDR], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004003 [Define if your system uses ancillary data style
4004 file descriptor passing])
Kevin Stevesa44e0352002-04-07 16:18:03 +00004005fi
4006
Damien Miller61e50f12000-05-08 20:49:37 +10004007AC_CACHE_CHECK([if libc defines __progname], ac_cv_libc_defines___progname, [
Tim Rice648f8762011-01-26 12:38:57 -08004008 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
4009 [[ extern char *__progname; printf("%s", __progname); ]])],
4010 [ ac_cv_libc_defines___progname="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004011 [ ac_cv_libc_defines___progname="no"
Tim Rice648f8762011-01-26 12:38:57 -08004012 ])
Damien Miller61e50f12000-05-08 20:49:37 +10004013])
4014if test "x$ac_cv_libc_defines___progname" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004015 AC_DEFINE([HAVE___PROGNAME], [1], [Define if libc defines __progname])
Damien Miller61e50f12000-05-08 20:49:37 +10004016fi
4017
Kevin Steves4846f4a2002-03-22 18:19:53 +00004018AC_CACHE_CHECK([whether $CC implements __FUNCTION__], ac_cv_cc_implements___FUNCTION__, [
Tim Rice648f8762011-01-26 12:38:57 -08004019 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]],
4020 [[ printf("%s", __FUNCTION__); ]])],
4021 [ ac_cv_cc_implements___FUNCTION__="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004022 [ ac_cv_cc_implements___FUNCTION__="no"
Tim Rice648f8762011-01-26 12:38:57 -08004023 ])
Kevin Steves4846f4a2002-03-22 18:19:53 +00004024])
4025if test "x$ac_cv_cc_implements___FUNCTION__" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004026 AC_DEFINE([HAVE___FUNCTION__], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004027 [Define if compiler implements __FUNCTION__])
Kevin Steves4846f4a2002-03-22 18:19:53 +00004028fi
4029
4030AC_CACHE_CHECK([whether $CC implements __func__], ac_cv_cc_implements___func__, [
Tim Rice648f8762011-01-26 12:38:57 -08004031 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]],
4032 [[ printf("%s", __func__); ]])],
4033 [ ac_cv_cc_implements___func__="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004034 [ ac_cv_cc_implements___func__="no"
Tim Rice648f8762011-01-26 12:38:57 -08004035 ])
Kevin Steves4846f4a2002-03-22 18:19:53 +00004036])
4037if test "x$ac_cv_cc_implements___func__" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004038 AC_DEFINE([HAVE___func__], [1], [Define if compiler implements __func__])
Kevin Steves4846f4a2002-03-22 18:19:53 +00004039fi
4040
Damien Miller57f39152005-11-24 19:58:19 +11004041AC_CACHE_CHECK([whether va_copy exists], ac_cv_have_va_copy, [
Tim Rice648f8762011-01-26 12:38:57 -08004042 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4043#include <stdarg.h>
4044va_list x,y;
4045 ]], [[ va_copy(x,y); ]])],
4046 [ ac_cv_have_va_copy="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004047 [ ac_cv_have_va_copy="no"
Tim Rice648f8762011-01-26 12:38:57 -08004048 ])
Damien Miller57f39152005-11-24 19:58:19 +11004049])
4050if test "x$ac_cv_have_va_copy" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004051 AC_DEFINE([HAVE_VA_COPY], [1], [Define if va_copy exists])
Damien Miller57f39152005-11-24 19:58:19 +11004052fi
4053
4054AC_CACHE_CHECK([whether __va_copy exists], ac_cv_have___va_copy, [
Tim Rice648f8762011-01-26 12:38:57 -08004055 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4056#include <stdarg.h>
4057va_list x,y;
4058 ]], [[ __va_copy(x,y); ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07004059 [ ac_cv_have___va_copy="yes" ], [ ac_cv_have___va_copy="no"
Tim Rice648f8762011-01-26 12:38:57 -08004060 ])
Damien Miller57f39152005-11-24 19:58:19 +11004061])
4062if test "x$ac_cv_have___va_copy" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004063 AC_DEFINE([HAVE___VA_COPY], [1], [Define if __va_copy exists])
Damien Miller57f39152005-11-24 19:58:19 +11004064fi
4065
Damien Miller4f8e6692001-07-14 13:22:53 +10004066AC_CACHE_CHECK([whether getopt has optreset support],
4067 ac_cv_have_getopt_optreset, [
Tim Rice648f8762011-01-26 12:38:57 -08004068 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <getopt.h> ]],
4069 [[ extern int optreset; optreset = 0; ]])],
4070 [ ac_cv_have_getopt_optreset="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004071 [ ac_cv_have_getopt_optreset="no"
Tim Rice648f8762011-01-26 12:38:57 -08004072 ])
Damien Miller4f8e6692001-07-14 13:22:53 +10004073])
4074if test "x$ac_cv_have_getopt_optreset" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004075 AC_DEFINE([HAVE_GETOPT_OPTRESET], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004076 [Define if your getopt(3) defines and uses optreset])
Damien Miller4f8e6692001-07-14 13:22:53 +10004077fi
Damien Millera22ba012000-03-02 23:09:20 +11004078
Damien Millerecbb26d2000-07-15 14:59:14 +10004079AC_CACHE_CHECK([if libc defines sys_errlist], ac_cv_libc_defines_sys_errlist, [
Tim Rice648f8762011-01-26 12:38:57 -08004080 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
4081[[ extern const char *const sys_errlist[]; printf("%s", sys_errlist[0]);]])],
4082 [ ac_cv_libc_defines_sys_errlist="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004083 [ ac_cv_libc_defines_sys_errlist="no"
Tim Rice648f8762011-01-26 12:38:57 -08004084 ])
Damien Millerecbb26d2000-07-15 14:59:14 +10004085])
4086if test "x$ac_cv_libc_defines_sys_errlist" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004087 AC_DEFINE([HAVE_SYS_ERRLIST], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004088 [Define if your system defines sys_errlist[]])
Damien Millerecbb26d2000-07-15 14:59:14 +10004089fi
4090
4091
Damien Miller11fa2cc2000-08-16 10:35:58 +10004092AC_CACHE_CHECK([if libc defines sys_nerr], ac_cv_libc_defines_sys_nerr, [
Tim Rice648f8762011-01-26 12:38:57 -08004093 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
4094[[ extern int sys_nerr; printf("%i", sys_nerr);]])],
4095 [ ac_cv_libc_defines_sys_nerr="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004096 [ ac_cv_libc_defines_sys_nerr="no"
Tim Rice648f8762011-01-26 12:38:57 -08004097 ])
Damien Miller11fa2cc2000-08-16 10:35:58 +10004098])
4099if test "x$ac_cv_libc_defines_sys_nerr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004100 AC_DEFINE([HAVE_SYS_NERR], [1], [Define if your system defines sys_nerr])
Damien Miller11fa2cc2000-08-16 10:35:58 +10004101fi
4102
Darren Tucker5f88d342003-10-15 16:57:57 +10004103# Check libraries needed by DNS fingerprint support
Tim Rice648f8762011-01-26 12:38:57 -08004104AC_SEARCH_LIBS([getrrsetbyname], [resolv],
4105 [AC_DEFINE([HAVE_GETRRSETBYNAME], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004106 [Define if getrrsetbyname() exists])],
Damien Miller7abe09b2003-05-15 10:53:49 +10004107 [
Darren Tucker5f88d342003-10-15 16:57:57 +10004108 # Needed by our getrrsetbyname()
Tim Rice648f8762011-01-26 12:38:57 -08004109 AC_SEARCH_LIBS([res_query], [resolv])
4110 AC_SEARCH_LIBS([dn_expand], [resolv])
4111 AC_MSG_CHECKING([if res_query will link])
4112 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckere02b49a2009-09-11 14:56:08 +10004113#include <sys/types.h>
4114#include <netinet/in.h>
4115#include <arpa/nameser.h>
4116#include <netdb.h>
4117#include <resolv.h>
Tim Rice648f8762011-01-26 12:38:57 -08004118 ]], [[
Darren Tuckere02b49a2009-09-11 14:56:08 +10004119 res_query (0, 0, 0, 0, 0);
Tim Rice648f8762011-01-26 12:38:57 -08004120 ]])],
4121 AC_MSG_RESULT([yes]),
4122 [AC_MSG_RESULT([no])
Darren Tucker8e968a52004-05-13 11:56:16 +10004123 saved_LIBS="$LIBS"
4124 LIBS="$LIBS -lresolv"
Tim Rice648f8762011-01-26 12:38:57 -08004125 AC_MSG_CHECKING([for res_query in -lresolv])
4126 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckere02b49a2009-09-11 14:56:08 +10004127#include <sys/types.h>
4128#include <netinet/in.h>
4129#include <arpa/nameser.h>
4130#include <netdb.h>
Darren Tucker8e968a52004-05-13 11:56:16 +10004131#include <resolv.h>
Tim Rice648f8762011-01-26 12:38:57 -08004132 ]], [[
Darren Tucker8e968a52004-05-13 11:56:16 +10004133 res_query (0, 0, 0, 0, 0);
Tim Rice648f8762011-01-26 12:38:57 -08004134 ]])],
4135 [AC_MSG_RESULT([yes])],
Darren Tucker8e968a52004-05-13 11:56:16 +10004136 [LIBS="$saved_LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08004137 AC_MSG_RESULT([no])])
Darren Tucker8e968a52004-05-13 11:56:16 +10004138 ])
Tim Rice648f8762011-01-26 12:38:57 -08004139 AC_CHECK_FUNCS([_getshort _getlong])
Darren Tuckerd886e1c2005-06-01 18:57:45 +10004140 AC_CHECK_DECLS([_getshort, _getlong], , ,
Tim Ricefcc7ff12005-06-02 20:28:29 -07004141 [#include <sys/types.h>
4142 #include <arpa/nameser.h>])
Tim Rice648f8762011-01-26 12:38:57 -08004143 AC_CHECK_MEMBER([HEADER.ad],
4144 [AC_DEFINE([HAVE_HEADER_AD], [1],
4145 [Define if HEADER.ad exists in arpa/nameser.h])], ,
Darren Tucker5f88d342003-10-15 16:57:57 +10004146 [#include <arpa/nameser.h>])
4147 ])
Damien Miller7abe09b2003-05-15 10:53:49 +10004148
Tim Rice648f8762011-01-26 12:38:57 -08004149AC_MSG_CHECKING([if struct __res_state _res is an extern])
4150AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckercc40d5e2007-04-29 13:58:06 +10004151#include <stdio.h>
4152#if HAVE_SYS_TYPES_H
4153# include <sys/types.h>
4154#endif
4155#include <netinet/in.h>
4156#include <arpa/nameser.h>
4157#include <resolv.h>
4158extern struct __res_state _res;
Darren Tucker7ad8b282015-09-11 13:11:02 +10004159 ]], [[
4160struct __res_state *volatile p = &_res; /* force resolution of _res */
4161return 0;
4162 ]],)],
Tim Rice648f8762011-01-26 12:38:57 -08004163 [AC_MSG_RESULT([yes])
4164 AC_DEFINE([HAVE__RES_EXTERN], [1],
Darren Tuckercc40d5e2007-04-29 13:58:06 +10004165 [Define if you have struct __res_state _res as an extern])
4166 ],
Tim Rice648f8762011-01-26 12:38:57 -08004167 [ AC_MSG_RESULT([no]) ]
Darren Tuckercc40d5e2007-04-29 13:58:06 +10004168)
4169
Damien Miller73b42d22006-04-22 21:26:08 +10004170# Check whether user wants SELinux support
4171SELINUX_MSG="no"
4172LIBSELINUX=""
Tim Rice648f8762011-01-26 12:38:57 -08004173AC_ARG_WITH([selinux],
Damien Miller5b1c8b32008-03-27 12:33:07 +11004174 [ --with-selinux Enable SELinux support],
Damien Miller73b42d22006-04-22 21:26:08 +10004175 [ if test "x$withval" != "xno" ; then
Darren Tucker20e9f972007-03-25 18:26:01 +10004176 save_LIBS="$LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08004177 AC_DEFINE([WITH_SELINUX], [1],
4178 [Define if you want SELinux support.])
Damien Miller73b42d22006-04-22 21:26:08 +10004179 SELINUX_MSG="yes"
4180 AC_CHECK_HEADER([selinux/selinux.h], ,
Tim Rice648f8762011-01-26 12:38:57 -08004181 AC_MSG_ERROR([SELinux support requires selinux.h header]))
4182 AC_CHECK_LIB([selinux], [setexeccon],
Damien Miller1d2bfc42010-02-10 10:19:29 +11004183 [ LIBSELINUX="-lselinux"
4184 LIBS="$LIBS -lselinux"
4185 ],
Tim Rice648f8762011-01-26 12:38:57 -08004186 AC_MSG_ERROR([SELinux support requires libselinux library]))
Damien Miller71adf122011-01-25 12:16:15 +11004187 SSHLIBS="$SSHLIBS $LIBSELINUX"
Darren Tucker20e9f972007-03-25 18:26:01 +10004188 SSHDLIBS="$SSHDLIBS $LIBSELINUX"
Tim Rice648f8762011-01-26 12:38:57 -08004189 AC_CHECK_FUNCS([getseuserbyname get_default_context_with_level])
Darren Tuckeradc947d2006-10-07 09:07:20 +10004190 LIBS="$save_LIBS"
Damien Miller73b42d22006-04-22 21:26:08 +10004191 fi ]
4192)
Tim Rice648f8762011-01-26 12:38:57 -08004193AC_SUBST([SSHLIBS])
4194AC_SUBST([SSHDLIBS])
Damien Miller73b42d22006-04-22 21:26:08 +10004195
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004196# Check whether user wants Kerberos 5 support
Damien Millera8e06ce2003-11-21 23:48:55 +11004197KRB5_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08004198AC_ARG_WITH([kerberos5],
Damien Millera8e06ce2003-11-21 23:48:55 +11004199 [ --with-kerberos5=PATH Enable Kerberos 5 support],
Darren Tucker1d3ca582004-01-22 12:05:34 +11004200 [ if test "x$withval" != "xno" ; then
4201 if test "x$withval" = "xyes" ; then
4202 KRB5ROOT="/usr/local"
4203 else
4204 KRB5ROOT=${withval}
4205 fi
4206
Tim Rice648f8762011-01-26 12:38:57 -08004207 AC_DEFINE([KRB5], [1], [Define if you want Kerberos 5 support])
Darren Tucker1d3ca582004-01-22 12:05:34 +11004208 KRB5_MSG="yes"
4209
Darren Tucker4089fc12016-12-08 12:57:24 +11004210 AC_PATH_TOOL([KRB5CONF], [krb5-config],
Darren Tuckerdad48e72009-09-01 18:26:00 +10004211 [$KRB5ROOT/bin/krb5-config],
4212 [$KRB5ROOT/bin:$PATH])
4213 if test -x $KRB5CONF ; then
Darren Tucker964de182013-02-22 10:39:59 +11004214 K5CFLAGS="`$KRB5CONF --cflags`"
4215 K5LIBS="`$KRB5CONF --libs`"
4216 CPPFLAGS="$CPPFLAGS $K5CFLAGS"
Darren Tucker1d3ca582004-01-22 12:05:34 +11004217
Tim Rice648f8762011-01-26 12:38:57 -08004218 AC_MSG_CHECKING([for gssapi support])
Darren Tucker1d3ca582004-01-22 12:05:34 +11004219 if $KRB5CONF | grep gssapi >/dev/null ; then
Tim Rice648f8762011-01-26 12:38:57 -08004220 AC_MSG_RESULT([yes])
4221 AC_DEFINE([GSSAPI], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004222 [Define this if you want GSSAPI
4223 support in the version 2 protocol])
Darren Tucker964de182013-02-22 10:39:59 +11004224 GSSCFLAGS="`$KRB5CONF --cflags gssapi`"
4225 GSSLIBS="`$KRB5CONF --libs gssapi`"
4226 CPPFLAGS="$CPPFLAGS $GSSCFLAGS"
Damien Millera8e06ce2003-11-21 23:48:55 +11004227 else
Tim Rice648f8762011-01-26 12:38:57 -08004228 AC_MSG_RESULT([no])
Damien Millera8e06ce2003-11-21 23:48:55 +11004229 fi
Tim Rice648f8762011-01-26 12:38:57 -08004230 AC_MSG_CHECKING([whether we are using Heimdal])
4231 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <krb5.h>
4232 ]], [[ char *tmp = heimdal_version; ]])],
4233 [ AC_MSG_RESULT([yes])
4234 AC_DEFINE([HEIMDAL], [1],
4235 [Define this if you are using the Heimdal
4236 version of Kerberos V5]) ],
4237 [AC_MSG_RESULT([no])
4238 ])
Darren Tucker1d3ca582004-01-22 12:05:34 +11004239 else
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004240 CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include"
Damien Millera8e06ce2003-11-21 23:48:55 +11004241 LDFLAGS="$LDFLAGS -L${KRB5ROOT}/lib"
Tim Rice648f8762011-01-26 12:38:57 -08004242 AC_MSG_CHECKING([whether we are using Heimdal])
4243 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <krb5.h>
4244 ]], [[ char *tmp = heimdal_version; ]])],
4245 [ AC_MSG_RESULT([yes])
4246 AC_DEFINE([HEIMDAL])
Damien Miller41bccf72011-01-02 21:53:07 +11004247 K5LIBS="-lkrb5"
Damien Miller5561e0b2004-04-20 20:28:55 +10004248 K5LIBS="$K5LIBS -lcom_err -lasn1"
Tim Rice648f8762011-01-26 12:38:57 -08004249 AC_CHECK_LIB([roken], [net_write],
Damien Miller5561e0b2004-04-20 20:28:55 +10004250 [K5LIBS="$K5LIBS -lroken"])
Tim Rice648f8762011-01-26 12:38:57 -08004251 AC_CHECK_LIB([des], [des_cbc_encrypt],
Damien Miller41bccf72011-01-02 21:53:07 +11004252 [K5LIBS="$K5LIBS -ldes"])
Tim Rice648f8762011-01-26 12:38:57 -08004253 ], [ AC_MSG_RESULT([no])
Damien Millera8e06ce2003-11-21 23:48:55 +11004254 K5LIBS="-lkrb5 -lk5crypto -lcom_err"
Tim Rice648f8762011-01-26 12:38:57 -08004255 ])
4256 AC_SEARCH_LIBS([dn_expand], [resolv])
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004257
Tim Rice648f8762011-01-26 12:38:57 -08004258 AC_CHECK_LIB([gssapi_krb5], [gss_init_sec_context],
4259 [ AC_DEFINE([GSSAPI])
Darren Tucker964de182013-02-22 10:39:59 +11004260 GSSLIBS="-lgssapi_krb5" ],
Tim Rice648f8762011-01-26 12:38:57 -08004261 [ AC_CHECK_LIB([gssapi], [gss_init_sec_context],
4262 [ AC_DEFINE([GSSAPI])
Darren Tucker964de182013-02-22 10:39:59 +11004263 GSSLIBS="-lgssapi" ],
Darren Tuckera2b5a4c2013-02-22 10:43:15 +11004264 [ AC_CHECK_LIB([gss], [gss_init_sec_context],
4265 [ AC_DEFINE([GSSAPI])
4266 GSSLIBS="-lgss" ],
4267 AC_MSG_WARN([Cannot find any suitable gss-api library - build may fail]))
4268 ])
Darren Tucker964de182013-02-22 10:39:59 +11004269 ])
Tim Riceeae17cc2005-03-17 16:52:20 -08004270
Tim Rice648f8762011-01-26 12:38:57 -08004271 AC_CHECK_HEADER([gssapi.h], ,
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004272 [ unset ac_cv_header_gssapi_h
Damien Millera8e06ce2003-11-21 23:48:55 +11004273 CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
Tim Rice648f8762011-01-26 12:38:57 -08004274 AC_CHECK_HEADERS([gssapi.h], ,
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004275 AC_MSG_WARN([Cannot find any suitable gss-api header - build may fail])
Damien Millera8e06ce2003-11-21 23:48:55 +11004276 )
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004277 ]
4278 )
4279
4280 oldCPP="$CPPFLAGS"
4281 CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
Tim Rice648f8762011-01-26 12:38:57 -08004282 AC_CHECK_HEADER([gssapi_krb5.h], ,
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004283 [ CPPFLAGS="$oldCPP" ])
4284
Damien Millera8e06ce2003-11-21 23:48:55 +11004285 fi
Darren Tucker1d3ca582004-01-22 12:05:34 +11004286 if test ! -z "$need_dash_r" ; then
4287 LDFLAGS="$LDFLAGS -R${KRB5ROOT}/lib"
4288 fi
4289 if test ! -z "$blibpath" ; then
4290 blibpath="$blibpath:${KRB5ROOT}/lib"
4291 fi
Tim Ricefd9e9e32005-09-12 17:36:10 -07004292
Tim Rice648f8762011-01-26 12:38:57 -08004293 AC_CHECK_HEADERS([gssapi.h gssapi/gssapi.h])
4294 AC_CHECK_HEADERS([gssapi_krb5.h gssapi/gssapi_krb5.h])
4295 AC_CHECK_HEADERS([gssapi_generic.h gssapi/gssapi_generic.h])
Tim Ricefd9e9e32005-09-12 17:36:10 -07004296
Tim Rice648f8762011-01-26 12:38:57 -08004297 AC_SEARCH_LIBS([k_hasafs], [kafs], [AC_DEFINE([USE_AFS], [1],
4298 [Define this if you want to use libkafs' AFS support])])
Darren Tucker03978c62013-02-25 11:24:44 +11004299
4300 AC_CHECK_DECLS([GSS_C_NT_HOSTBASED_SERVICE], [], [], [[
4301#ifdef HAVE_GSSAPI_H
4302# include <gssapi.h>
4303#elif defined(HAVE_GSSAPI_GSSAPI_H)
4304# include <gssapi/gssapi.h>
4305#endif
4306
4307#ifdef HAVE_GSSAPI_GENERIC_H
4308# include <gssapi_generic.h>
4309#elif defined(HAVE_GSSAPI_GSSAPI_GENERIC_H)
4310# include <gssapi/gssapi_generic.h>
4311#endif
4312 ]])
Darren Tuckerf3ab2c52013-08-04 21:48:41 +10004313 saved_LIBS="$LIBS"
4314 LIBS="$LIBS $K5LIBS"
4315 AC_CHECK_FUNCS([krb5_cc_new_unique krb5_get_error_message krb5_free_error_message])
4316 LIBS="$saved_LIBS"
4317
Darren Tucker0d27ed12004-02-24 10:37:33 +11004318 fi
Darren Tucker0d27ed12004-02-24 10:37:33 +11004319 ]
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004320)
Darren Tucker964de182013-02-22 10:39:59 +11004321AC_SUBST([GSSLIBS])
4322AC_SUBST([K5LIBS])
Damien Millerc79bc0d2001-03-28 13:03:42 +10004323
Damien Millera22ba012000-03-02 23:09:20 +11004324# Looking for programs, paths and files
Damien Millera22ba012000-03-02 23:09:20 +11004325
Damien Millerf58c6722002-05-13 13:15:42 +10004326PRIVSEP_PATH=/var/empty
Tim Rice648f8762011-01-26 12:38:57 -08004327AC_ARG_WITH([privsep-path],
Tim Ricecbb90662002-07-08 19:17:10 -07004328 [ --with-privsep-path=xxx Path for privilege separation chroot (default=/var/empty)],
Damien Millerf58c6722002-05-13 13:15:42 +10004329 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004330 if test -n "$withval" && test "x$withval" != "xno" && \
4331 test "x${withval}" != "xyes"; then
Damien Millerf58c6722002-05-13 13:15:42 +10004332 PRIVSEP_PATH=$withval
4333 fi
4334 ]
4335)
Tim Rice648f8762011-01-26 12:38:57 -08004336AC_SUBST([PRIVSEP_PATH])
Damien Millerf58c6722002-05-13 13:15:42 +10004337
Tim Rice648f8762011-01-26 12:38:57 -08004338AC_ARG_WITH([xauth],
Damien Millera22ba012000-03-02 23:09:20 +11004339 [ --with-xauth=PATH Specify path to xauth program ],
4340 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004341 if test -n "$withval" && test "x$withval" != "xno" && \
4342 test "x${withval}" != "xyes"; then
Damien Miller7b22d652000-06-18 14:07:04 +10004343 xauth_path=$withval
Damien Millera22ba012000-03-02 23:09:20 +11004344 fi
4345 ],
4346 [
Tim Ricee22be3b2002-07-17 19:20:07 -07004347 TestPath="$PATH"
4348 TestPath="${TestPath}${PATH_SEPARATOR}/usr/X/bin"
4349 TestPath="${TestPath}${PATH_SEPARATOR}/usr/bin/X11"
4350 TestPath="${TestPath}${PATH_SEPARATOR}/usr/X11R6/bin"
4351 TestPath="${TestPath}${PATH_SEPARATOR}/usr/openwin/bin"
Tim Rice648f8762011-01-26 12:38:57 -08004352 AC_PATH_PROG([xauth_path], [xauth], , [$TestPath])
Damien Milleredb82922000-06-20 13:25:52 +10004353 if (test ! -z "$xauth_path" && test -x "/usr/openwin/bin/xauth") ; then
Damien Millera22ba012000-03-02 23:09:20 +11004354 xauth_path="/usr/openwin/bin/xauth"
4355 fi
4356 ]
4357)
4358
Damien Miller7d901272003-01-13 16:55:22 +11004359STRIP_OPT=-s
Tim Rice648f8762011-01-26 12:38:57 -08004360AC_ARG_ENABLE([strip],
Damien Miller7d901272003-01-13 16:55:22 +11004361 [ --disable-strip Disable calling strip(1) on install],
4362 [
4363 if test "x$enableval" = "xno" ; then
4364 STRIP_OPT=
4365 fi
4366 ]
4367)
Tim Rice648f8762011-01-26 12:38:57 -08004368AC_SUBST([STRIP_OPT])
Damien Miller7d901272003-01-13 16:55:22 +11004369
Damien Millera19cf472000-11-29 13:28:50 +11004370if test -z "$xauth_path" ; then
4371 XAUTH_PATH="undefined"
Tim Rice648f8762011-01-26 12:38:57 -08004372 AC_SUBST([XAUTH_PATH])
Damien Millera19cf472000-11-29 13:28:50 +11004373else
Tim Rice648f8762011-01-26 12:38:57 -08004374 AC_DEFINE_UNQUOTED([XAUTH_PATH], ["$xauth_path"],
Tim Rice7df8d392005-09-19 09:33:39 -07004375 [Define if xauth is found in your path])
Damien Millera19cf472000-11-29 13:28:50 +11004376 XAUTH_PATH=$xauth_path
Tim Rice648f8762011-01-26 12:38:57 -08004377 AC_SUBST([XAUTH_PATH])
Damien Millera22ba012000-03-02 23:09:20 +11004378fi
Damien Millera22ba012000-03-02 23:09:20 +11004379
Tim Rice90f42b02011-06-02 18:17:49 -07004380dnl # --with-maildir=/path/to/mail gets top priority.
4381dnl # if maildir is set in the platform case statement above we use that.
4382dnl # Otherwise we run a program to get the dir from system headers.
4383dnl # We first look for _PATH_MAILDIR then MAILDIR then _PATH_MAIL
4384dnl # If we find _PATH_MAILDIR we do nothing because that is what
4385dnl # session.c expects anyway. Otherwise we set to the value found
4386dnl # stripping any trailing slash. If for some strage reason our program
4387dnl # does not find what it needs, we default to /var/spool/mail.
4388# Check for mail directory
4389AC_ARG_WITH([maildir],
4390 [ --with-maildir=/path/to/mail Specify your system mail directory],
4391 [
4392 if test "X$withval" != X && test "x$withval" != xno && \
4393 test "x${withval}" != xyes; then
4394 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$withval"],
4395 [Set this to your mail directory if you do not have _PATH_MAILDIR])
4396 fi
4397 ],[
4398 if test "X$maildir" != "X"; then
4399 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$maildir"])
4400 else
4401 AC_MSG_CHECKING([Discovering system mail directory])
4402 AC_RUN_IFELSE(
4403 [AC_LANG_PROGRAM([[
4404#include <stdio.h>
4405#include <string.h>
4406#ifdef HAVE_PATHS_H
4407#include <paths.h>
4408#endif
4409#ifdef HAVE_MAILLOCK_H
4410#include <maillock.h>
4411#endif
4412#define DATA "conftest.maildir"
4413 ]], [[
4414 FILE *fd;
4415 int rc;
4416
4417 fd = fopen(DATA,"w");
4418 if(fd == NULL)
4419 exit(1);
4420
4421#if defined (_PATH_MAILDIR)
4422 if ((rc = fprintf(fd ,"_PATH_MAILDIR:%s\n", _PATH_MAILDIR)) <0)
4423 exit(1);
4424#elif defined (MAILDIR)
4425 if ((rc = fprintf(fd ,"MAILDIR:%s\n", MAILDIR)) <0)
4426 exit(1);
4427#elif defined (_PATH_MAIL)
4428 if ((rc = fprintf(fd ,"_PATH_MAIL:%s\n", _PATH_MAIL)) <0)
4429 exit(1);
4430#else
4431 exit (2);
4432#endif
4433
4434 exit(0);
4435 ]])],
4436 [
Tim Ricee1d93702016-05-31 11:13:22 -07004437 maildir_what=`awk -F: '{print $1}' conftest.maildir`
Tim Rice90f42b02011-06-02 18:17:49 -07004438 maildir=`awk -F: '{print $2}' conftest.maildir \
4439 | sed 's|/$||'`
4440 AC_MSG_RESULT([Using: $maildir from $maildir_what])
4441 if test "x$maildir_what" != "x_PATH_MAILDIR"; then
4442 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$maildir"])
4443 fi
4444 ],
4445 [
4446 if test "X$ac_status" = "X2";then
4447# our test program didn't find it. Default to /var/spool/mail
4448 AC_MSG_RESULT([Using: default value of /var/spool/mail])
4449 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["/var/spool/mail"])
4450 else
4451 AC_MSG_RESULT([*** not found ***])
4452 fi
4453 ],
4454 [
4455 AC_MSG_WARN([cross compiling: use --with-maildir=/path/to/mail])
4456 ]
4457 )
4458 fi
4459 ]
4460) # maildir
Damien Millera22ba012000-03-02 23:09:20 +11004461
Darren Tucker623d92f2004-09-12 22:36:15 +10004462if test ! -z "$cross_compiling" && test "x$cross_compiling" = "xyes"; then
Darren Tuckera0c2b392004-09-11 23:26:37 +10004463 AC_MSG_WARN([cross compiling: Disabling /dev/ptmx test])
4464 disable_ptmx_check=yes
4465fi
Damien Millera22ba012000-03-02 23:09:20 +11004466if test -z "$no_dev_ptmx" ; then
Kevin Steves0ea1d9d2002-04-25 18:17:04 +00004467 if test "x$disable_ptmx_check" != "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004468 AC_CHECK_FILE(["/dev/ptmx"],
Kevin Steves0ea1d9d2002-04-25 18:17:04 +00004469 [
Tim Rice648f8762011-01-26 12:38:57 -08004470 AC_DEFINE_UNQUOTED([HAVE_DEV_PTMX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004471 [Define if you have /dev/ptmx])
Kevin Steves0ea1d9d2002-04-25 18:17:04 +00004472 have_dev_ptmx=1
4473 ]
4474 )
4475 fi
Damien Millera22ba012000-03-02 23:09:20 +11004476fi
Darren Tuckera0c2b392004-09-11 23:26:37 +10004477
Darren Tucker623d92f2004-09-12 22:36:15 +10004478if test ! -z "$cross_compiling" && test "x$cross_compiling" != "xyes"; then
Tim Rice648f8762011-01-26 12:38:57 -08004479 AC_CHECK_FILE(["/dev/ptc"],
Darren Tuckera0c2b392004-09-11 23:26:37 +10004480 [
Tim Rice648f8762011-01-26 12:38:57 -08004481 AC_DEFINE_UNQUOTED([HAVE_DEV_PTS_AND_PTC], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004482 [Define if you have /dev/ptc])
Darren Tuckera0c2b392004-09-11 23:26:37 +10004483 have_dev_ptc=1
4484 ]
4485 )
4486else
4487 AC_MSG_WARN([cross compiling: Disabling /dev/ptc test])
4488fi
Damien Miller204ad072000-03-02 23:56:12 +11004489
Damien Millera22ba012000-03-02 23:09:20 +11004490# Options from here on. Some of these are preset by platform above
Tim Rice648f8762011-01-26 12:38:57 -08004491AC_ARG_WITH([mantype],
Damien Miller897741e2001-04-16 10:41:46 +10004492 [ --with-mantype=man|cat|doc Set man page type],
Damien Miller670a4b82000-01-22 13:53:11 +11004493 [
Damien Miller897741e2001-04-16 10:41:46 +10004494 case "$withval" in
4495 man|cat|doc)
4496 MANTYPE=$withval
4497 ;;
4498 *)
Tim Rice648f8762011-01-26 12:38:57 -08004499 AC_MSG_ERROR([invalid man type: $withval])
Damien Miller897741e2001-04-16 10:41:46 +10004500 ;;
4501 esac
Damien Miller670a4b82000-01-22 13:53:11 +11004502 ]
4503)
Ben Lindstrombc709922001-04-18 18:04:21 +00004504if test -z "$MANTYPE"; then
Tim Ricee22be3b2002-07-17 19:20:07 -07004505 TestPath="/usr/bin${PATH_SEPARATOR}/usr/ucb"
Tim Rice648f8762011-01-26 12:38:57 -08004506 AC_PATH_PROGS([NROFF], [nroff awf], [/bin/false], [$TestPath])
Ben Lindstrombc709922001-04-18 18:04:21 +00004507 if ${NROFF} -mdoc ${srcdir}/ssh.1 >/dev/null 2>&1; then
4508 MANTYPE=doc
4509 elif ${NROFF} -man ${srcdir}/ssh.1 >/dev/null 2>&1; then
4510 MANTYPE=man
4511 else
4512 MANTYPE=cat
4513 fi
4514fi
Tim Rice648f8762011-01-26 12:38:57 -08004515AC_SUBST([MANTYPE])
Ben Lindstrombc709922001-04-18 18:04:21 +00004516if test "$MANTYPE" = "doc"; then
4517 mansubdir=man;
4518else
4519 mansubdir=$MANTYPE;
4520fi
Tim Rice648f8762011-01-26 12:38:57 -08004521AC_SUBST([mansubdir])
Damien Miller8bdeee21999-12-30 15:50:54 +11004522
Damien Millera22ba012000-03-02 23:09:20 +11004523# Check whether to enable MD5 passwords
Damien Millera8e06ce2003-11-21 23:48:55 +11004524MD5_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08004525AC_ARG_WITH([md5-passwords],
Damien Millerdd1c7ba1999-11-19 15:53:20 +11004526 [ --with-md5-passwords Enable use of MD5 passwords],
Damien Miller8bdeee21999-12-30 15:50:54 +11004527 [
Damien Millerb85dcad2000-03-11 11:37:00 +11004528 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004529 AC_DEFINE([HAVE_MD5_PASSWORDS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004530 [Define if you want to allow MD5 passwords])
Damien Millera8e06ce2003-11-21 23:48:55 +11004531 MD5_MSG="yes"
Damien Miller8bdeee21999-12-30 15:50:54 +11004532 fi
4533 ]
Damien Millerdd1c7ba1999-11-19 15:53:20 +11004534)
4535
Damien Millera22ba012000-03-02 23:09:20 +11004536# Whether to disable shadow password support
Tim Rice648f8762011-01-26 12:38:57 -08004537AC_ARG_WITH([shadow],
Damien Miller76112de1999-12-21 11:18:08 +11004538 [ --without-shadow Disable shadow password support],
4539 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004540 if test "x$withval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004541 AC_DEFINE([DISABLE_SHADOW])
Damien Miller1f335fb2000-06-26 11:31:33 +10004542 disable_shadow=yes
Damien Miller76112de1999-12-21 11:18:08 +11004543 fi
4544 ]
4545)
4546
Damien Miller1f335fb2000-06-26 11:31:33 +10004547if test -z "$disable_shadow" ; then
4548 AC_MSG_CHECKING([if the systems has expire shadow information])
Tim Rice648f8762011-01-26 12:38:57 -08004549 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller1f335fb2000-06-26 11:31:33 +10004550#include <sys/types.h>
4551#include <shadow.h>
Tim Rice648f8762011-01-26 12:38:57 -08004552struct spwd sp;
4553 ]], [[ sp.sp_expire = sp.sp_lstchg = sp.sp_inact = 0; ]])],
4554 [ sp_expire_available=yes ], [
4555 ])
Damien Miller1f335fb2000-06-26 11:31:33 +10004556
4557 if test "x$sp_expire_available" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004558 AC_MSG_RESULT([yes])
4559 AC_DEFINE([HAS_SHADOW_EXPIRE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004560 [Define if you want to use shadow password expire field])
Damien Miller1f335fb2000-06-26 11:31:33 +10004561 else
Tim Rice648f8762011-01-26 12:38:57 -08004562 AC_MSG_RESULT([no])
Damien Miller1f335fb2000-06-26 11:31:33 +10004563 fi
4564fi
4565
Damien Millera22ba012000-03-02 23:09:20 +11004566# Use ip address instead of hostname in $DISPLAY
Damien Miller9a947342000-08-30 10:03:33 +11004567if test ! -z "$IPADDR_IN_DISPLAY" ; then
4568 DISPLAY_HACK_MSG="yes"
Tim Rice648f8762011-01-26 12:38:57 -08004569 AC_DEFINE([IPADDR_IN_DISPLAY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004570 [Define if you need to use IP address
4571 instead of hostname in $DISPLAY])
Damien Miller9a947342000-08-30 10:03:33 +11004572else
Damien Millera8e06ce2003-11-21 23:48:55 +11004573 DISPLAY_HACK_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08004574 AC_ARG_WITH([ipaddr-display],
Tim Rice6397eed2015-06-03 21:41:11 -07004575 [ --with-ipaddr-display Use ip address instead of hostname in $DISPLAY],
Damien Miller9a947342000-08-30 10:03:33 +11004576 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004577 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004578 AC_DEFINE([IPADDR_IN_DISPLAY])
Damien Millera8e06ce2003-11-21 23:48:55 +11004579 DISPLAY_HACK_MSG="yes"
Damien Miller9a947342000-08-30 10:03:33 +11004580 fi
4581 ]
4582 )
4583fi
Damien Miller76112de1999-12-21 11:18:08 +11004584
Darren Tuckere1a790d2003-09-16 11:52:19 +10004585# check for /etc/default/login and use it if present.
Tim Rice648f8762011-01-26 12:38:57 -08004586AC_ARG_ENABLE([etc-default-login],
Darren Tucker1b6f2292005-02-11 16:11:49 +11004587 [ --disable-etc-default-login Disable using PATH from /etc/default/login [no]],
Darren Tucker2f9573d2005-02-10 22:28:54 +11004588 [ if test "x$enableval" = "xno"; then
4589 AC_MSG_NOTICE([/etc/default/login handling disabled])
4590 etc_default_login=no
4591 else
4592 etc_default_login=yes
4593 fi ],
Darren Tucker314d89e2005-10-17 23:29:23 +10004594 [ if test ! -z "$cross_compiling" && test "x$cross_compiling" = "xyes";
4595 then
4596 AC_MSG_WARN([cross compiling: not checking /etc/default/login])
4597 etc_default_login=no
4598 else
4599 etc_default_login=yes
4600 fi ]
Darren Tucker2f9573d2005-02-10 22:28:54 +11004601)
Darren Tuckere1a790d2003-09-16 11:52:19 +10004602
Darren Tucker2f9573d2005-02-10 22:28:54 +11004603if test "x$etc_default_login" != "xno"; then
Tim Rice648f8762011-01-26 12:38:57 -08004604 AC_CHECK_FILE(["/etc/default/login"],
Darren Tucker2f9573d2005-02-10 22:28:54 +11004605 [ external_path_file=/etc/default/login ])
Darren Tucker314d89e2005-10-17 23:29:23 +10004606 if test "x$external_path_file" = "x/etc/default/login"; then
Tim Rice648f8762011-01-26 12:38:57 -08004607 AC_DEFINE([HAVE_ETC_DEFAULT_LOGIN], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004608 [Define if your system has /etc/default/login])
Darren Tuckera0c2b392004-09-11 23:26:37 +10004609 fi
Darren Tucker2f9573d2005-02-10 22:28:54 +11004610fi
Darren Tuckere1a790d2003-09-16 11:52:19 +10004611
Tim Rice43a1c132002-04-17 21:19:14 -07004612dnl BSD systems use /etc/login.conf so --with-default-path= has no effect
Tim Rice8bb561b2005-03-17 16:23:19 -08004613if test $ac_cv_func_login_getcapbool = "yes" && \
4614 test $ac_cv_header_login_cap_h = "yes" ; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10004615 external_path_file=/etc/login.conf
Tim Rice43a1c132002-04-17 21:19:14 -07004616fi
Darren Tuckere1a790d2003-09-16 11:52:19 +10004617
Damien Millera22ba012000-03-02 23:09:20 +11004618# Whether to mess with the default path
Damien Millera8e06ce2003-11-21 23:48:55 +11004619SERVER_PATH_MSG="(default)"
Tim Rice648f8762011-01-26 12:38:57 -08004620AC_ARG_WITH([default-path],
Tim Rice6397eed2015-06-03 21:41:11 -07004621 [ --with-default-path= Specify default $PATH environment for server],
Damien Miller5a3e6831999-12-27 09:48:56 +11004622 [
Darren Tuckere1a790d2003-09-16 11:52:19 +10004623 if test "x$external_path_file" = "x/etc/login.conf" ; then
Tim Rice43a1c132002-04-17 21:19:14 -07004624 AC_MSG_WARN([
4625--with-default-path=PATH has no effect on this system.
4626Edit /etc/login.conf instead.])
Tim Riceeae17cc2005-03-17 16:52:20 -08004627 elif test "x$withval" != "xno" ; then
Tim Riceb925b4b2003-09-15 22:40:49 -07004628 if test ! -z "$external_path_file" ; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10004629 AC_MSG_WARN([
4630--with-default-path=PATH will only be used if PATH is not defined in
4631$external_path_file .])
4632 fi
Tim Rice59ea0a02001-03-10 13:50:45 -08004633 user_path="$withval"
Damien Millera8e06ce2003-11-21 23:48:55 +11004634 SERVER_PATH_MSG="$withval"
Damien Miller5a3e6831999-12-27 09:48:56 +11004635 fi
Tim Rice59ea0a02001-03-10 13:50:45 -08004636 ],
Darren Tuckere1a790d2003-09-16 11:52:19 +10004637 [ if test "x$external_path_file" = "x/etc/login.conf" ; then
4638 AC_MSG_WARN([Make sure the path to scp is in /etc/login.conf])
Tim Rice43a1c132002-04-17 21:19:14 -07004639 else
Tim Riceb925b4b2003-09-15 22:40:49 -07004640 if test ! -z "$external_path_file" ; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10004641 AC_MSG_WARN([
4642If PATH is defined in $external_path_file, ensure the path to scp is included,
4643otherwise scp will not work.])
4644 fi
Darren Tucker314d89e2005-10-17 23:29:23 +10004645 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08004646 [AC_LANG_PROGRAM([[
Tim Rice59ea0a02001-03-10 13:50:45 -08004647/* find out what STDPATH is */
4648#include <stdio.h>
Tim Rice59ea0a02001-03-10 13:50:45 -08004649#ifdef HAVE_PATHS_H
4650# include <paths.h>
4651#endif
4652#ifndef _PATH_STDPATH
Tim Rice1c9e6882002-11-22 13:29:01 -08004653# ifdef _PATH_USERPATH /* Irix */
4654# define _PATH_STDPATH _PATH_USERPATH
4655# else
4656# define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
4657# endif
Tim Rice59ea0a02001-03-10 13:50:45 -08004658#endif
4659#include <sys/types.h>
4660#include <sys/stat.h>
4661#include <fcntl.h>
4662#define DATA "conftest.stdpath"
Tim Rice648f8762011-01-26 12:38:57 -08004663 ]], [[
Tim Rice59ea0a02001-03-10 13:50:45 -08004664 FILE *fd;
4665 int rc;
Tim Riceeae17cc2005-03-17 16:52:20 -08004666
Tim Rice59ea0a02001-03-10 13:50:45 -08004667 fd = fopen(DATA,"w");
4668 if(fd == NULL)
4669 exit(1);
Tim Riceeae17cc2005-03-17 16:52:20 -08004670
Tim Rice59ea0a02001-03-10 13:50:45 -08004671 if ((rc = fprintf(fd,"%s", _PATH_STDPATH)) < 0)
4672 exit(1);
4673
4674 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10004675 ]])],
4676 [ user_path=`cat conftest.stdpath` ],
Tim Rice59ea0a02001-03-10 13:50:45 -08004677 [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ],
4678 [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ]
4679 )
4680# make sure $bindir is in USER_PATH so scp will work
Damien Miller77eab7b2012-07-06 11:49:28 +10004681 t_bindir="${bindir}"
4682 while echo "${t_bindir}" | egrep '\$\{|NONE/' >/dev/null 2>&1; do
4683 t_bindir=`eval echo ${t_bindir}`
4684 case $t_bindir in
4685 NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$prefix~"` ;;
4686 esac
4687 case $t_bindir in
4688 NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$ac_default_prefix~"` ;;
4689 esac
4690 done
Tim Rice59ea0a02001-03-10 13:50:45 -08004691 echo $user_path | grep ":$t_bindir" > /dev/null 2>&1
4692 if test $? -ne 0 ; then
4693 echo $user_path | grep "^$t_bindir" > /dev/null 2>&1
4694 if test $? -ne 0 ; then
4695 user_path=$user_path:$t_bindir
Tim Rice648f8762011-01-26 12:38:57 -08004696 AC_MSG_RESULT([Adding $t_bindir to USER_PATH so scp will work])
Tim Rice59ea0a02001-03-10 13:50:45 -08004697 fi
4698 fi
Tim Rice43a1c132002-04-17 21:19:14 -07004699 fi ]
Damien Miller5a3e6831999-12-27 09:48:56 +11004700)
Darren Tuckere1a790d2003-09-16 11:52:19 +10004701if test "x$external_path_file" != "x/etc/login.conf" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004702 AC_DEFINE_UNQUOTED([USER_PATH], ["$user_path"], [Specify default $PATH])
4703 AC_SUBST([user_path])
Tim Rice43a1c132002-04-17 21:19:14 -07004704fi
Damien Miller5a3e6831999-12-27 09:48:56 +11004705
Damien Millera18bbd32002-05-13 10:48:57 +10004706# Set superuser path separately to user path
Tim Rice648f8762011-01-26 12:38:57 -08004707AC_ARG_WITH([superuser-path],
Damien Millera18bbd32002-05-13 10:48:57 +10004708 [ --with-superuser-path= Specify different path for super-user],
4709 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004710 if test -n "$withval" && test "x$withval" != "xno" && \
4711 test "x${withval}" != "xyes"; then
Tim Rice648f8762011-01-26 12:38:57 -08004712 AC_DEFINE_UNQUOTED([SUPERUSER_PATH], ["$withval"],
Tim Rice7df8d392005-09-19 09:33:39 -07004713 [Define if you want a different $PATH
4714 for the superuser])
Damien Millera18bbd32002-05-13 10:48:57 +10004715 superuser_path=$withval
4716 fi
4717 ]
4718)
4719
4720
Damien Miller61e50f12000-05-08 20:49:37 +10004721AC_MSG_CHECKING([if we need to convert IPv4 in IPv6-mapped addresses])
Damien Millera8e06ce2003-11-21 23:48:55 +11004722IPV4_IN6_HACK_MSG="no"
Damien Miller7bcb0892000-03-11 20:45:40 +11004723AC_ARG_WITH(4in6,
4724 [ --with-4in6 Check for and convert IPv4 in IPv6 mapped addresses],
4725 [
4726 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004727 AC_MSG_RESULT([yes])
4728 AC_DEFINE([IPV4_IN_IPV6], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004729 [Detect IPv4 in IPv6 mapped addresses
4730 and treat as IPv4])
Damien Millera8e06ce2003-11-21 23:48:55 +11004731 IPV4_IN6_HACK_MSG="yes"
Damien Miller7bcb0892000-03-11 20:45:40 +11004732 else
Tim Rice648f8762011-01-26 12:38:57 -08004733 AC_MSG_RESULT([no])
Damien Miller7bcb0892000-03-11 20:45:40 +11004734 fi
Tim Rice648f8762011-01-26 12:38:57 -08004735 ], [
Damien Miller7bcb0892000-03-11 20:45:40 +11004736 if test "x$inet6_default_4in6" = "xyes"; then
4737 AC_MSG_RESULT([yes (default)])
Tim Rice648f8762011-01-26 12:38:57 -08004738 AC_DEFINE([IPV4_IN_IPV6])
Damien Millera8e06ce2003-11-21 23:48:55 +11004739 IPV4_IN6_HACK_MSG="yes"
Damien Miller7bcb0892000-03-11 20:45:40 +11004740 else
4741 AC_MSG_RESULT([no (default)])
4742 fi
4743 ]
4744)
4745
Damien Miller60396b02001-02-18 17:01:00 +11004746# Whether to enable BSD auth support
Damien Miller6c21c512002-01-22 21:57:53 +11004747BSD_AUTH_MSG=no
Tim Rice648f8762011-01-26 12:38:57 -08004748AC_ARG_WITH([bsd-auth],
Damien Miller60396b02001-02-18 17:01:00 +11004749 [ --with-bsd-auth Enable BSD auth support],
4750 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004751 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004752 AC_DEFINE([BSD_AUTH], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004753 [Define if you have BSD auth support])
Damien Miller6c21c512002-01-22 21:57:53 +11004754 BSD_AUTH_MSG=yes
Damien Miller60396b02001-02-18 17:01:00 +11004755 fi
4756 ]
4757)
4758
Damien Millera22ba012000-03-02 23:09:20 +11004759# Where to place sshd.pid
Damien Millerb13c73e2000-01-17 22:02:17 +11004760piddir=/var/run
Damien Miller78315eb2000-09-29 23:01:36 +11004761# make sure the directory exists
Tim Riceeae17cc2005-03-17 16:52:20 -08004762if test ! -d $piddir ; then
Damien Miller78315eb2000-09-29 23:01:36 +11004763 piddir=`eval echo ${sysconfdir}`
4764 case $piddir in
Damien Millera8e06ce2003-11-21 23:48:55 +11004765 NONE/*) piddir=`echo $piddir | sed "s~NONE~$ac_default_prefix~"` ;;
Damien Miller78315eb2000-09-29 23:01:36 +11004766 esac
4767fi
4768
Tim Rice648f8762011-01-26 12:38:57 -08004769AC_ARG_WITH([pid-dir],
Tim Rice88f2ab52002-03-17 12:17:34 -08004770 [ --with-pid-dir=PATH Specify location of ssh.pid file],
4771 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004772 if test -n "$withval" && test "x$withval" != "xno" && \
4773 test "x${withval}" != "xyes"; then
Tim Rice88f2ab52002-03-17 12:17:34 -08004774 piddir=$withval
Tim Riceeae17cc2005-03-17 16:52:20 -08004775 if test ! -d $piddir ; then
Tim Rice88f2ab52002-03-17 12:17:34 -08004776 AC_MSG_WARN([** no $piddir directory on this system **])
4777 fi
4778 fi
4779 ]
4780)
4781
Tim Ricee1d93702016-05-31 11:13:22 -07004782AC_DEFINE_UNQUOTED([_PATH_SSH_PIDDIR], ["$piddir"],
Tim Rice648f8762011-01-26 12:38:57 -08004783 [Specify location of ssh.pid])
4784AC_SUBST([piddir])
Damien Miller5eed6a22000-01-16 12:05:18 +11004785
andre2ff7b5d2000-06-03 14:57:40 +00004786dnl allow user to disable some login recording features
Tim Rice648f8762011-01-26 12:38:57 -08004787AC_ARG_ENABLE([lastlog],
andre43ca7e22000-06-19 08:23:46 +00004788 [ --disable-lastlog disable use of lastlog even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004789 [
4790 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004791 AC_DEFINE([DISABLE_LASTLOG])
Darren Tuckera3020db2003-06-28 12:54:33 +10004792 fi
4793 ]
andre2ff7b5d2000-06-03 14:57:40 +00004794)
Tim Rice648f8762011-01-26 12:38:57 -08004795AC_ARG_ENABLE([utmp],
andre43ca7e22000-06-19 08:23:46 +00004796 [ --disable-utmp disable use of utmp even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004797 [
4798 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004799 AC_DEFINE([DISABLE_UTMP])
Darren Tuckera3020db2003-06-28 12:54:33 +10004800 fi
4801 ]
andre2ff7b5d2000-06-03 14:57:40 +00004802)
Tim Rice648f8762011-01-26 12:38:57 -08004803AC_ARG_ENABLE([utmpx],
andre43ca7e22000-06-19 08:23:46 +00004804 [ --disable-utmpx disable use of utmpx even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004805 [
4806 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004807 AC_DEFINE([DISABLE_UTMPX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004808 [Define if you don't want to use utmpx])
Darren Tuckera3020db2003-06-28 12:54:33 +10004809 fi
4810 ]
andre2ff7b5d2000-06-03 14:57:40 +00004811)
Tim Rice648f8762011-01-26 12:38:57 -08004812AC_ARG_ENABLE([wtmp],
andre43ca7e22000-06-19 08:23:46 +00004813 [ --disable-wtmp disable use of wtmp even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004814 [
4815 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004816 AC_DEFINE([DISABLE_WTMP])
Darren Tuckera3020db2003-06-28 12:54:33 +10004817 fi
4818 ]
andre2ff7b5d2000-06-03 14:57:40 +00004819)
Tim Rice648f8762011-01-26 12:38:57 -08004820AC_ARG_ENABLE([wtmpx],
andre43ca7e22000-06-19 08:23:46 +00004821 [ --disable-wtmpx disable use of wtmpx even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004822 [
4823 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004824 AC_DEFINE([DISABLE_WTMPX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004825 [Define if you don't want to use wtmpx])
Darren Tuckera3020db2003-06-28 12:54:33 +10004826 fi
4827 ]
andre2ff7b5d2000-06-03 14:57:40 +00004828)
Tim Rice648f8762011-01-26 12:38:57 -08004829AC_ARG_ENABLE([libutil],
andre43ca7e22000-06-19 08:23:46 +00004830 [ --disable-libutil disable use of libutil (login() etc.) [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004831 [
4832 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004833 AC_DEFINE([DISABLE_LOGIN])
Darren Tuckera3020db2003-06-28 12:54:33 +10004834 fi
4835 ]
andre2ff7b5d2000-06-03 14:57:40 +00004836)
Tim Rice648f8762011-01-26 12:38:57 -08004837AC_ARG_ENABLE([pututline],
andre43ca7e22000-06-19 08:23:46 +00004838 [ --disable-pututline disable use of pututline() etc. ([uw]tmp) [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004839 [
4840 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004841 AC_DEFINE([DISABLE_PUTUTLINE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004842 [Define if you don't want to use pututline()
4843 etc. to write [uw]tmp])
Darren Tuckera3020db2003-06-28 12:54:33 +10004844 fi
4845 ]
andre2ff7b5d2000-06-03 14:57:40 +00004846)
Tim Rice648f8762011-01-26 12:38:57 -08004847AC_ARG_ENABLE([pututxline],
andre43ca7e22000-06-19 08:23:46 +00004848 [ --disable-pututxline disable use of pututxline() etc. ([uw]tmpx) [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004849 [
4850 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004851 AC_DEFINE([DISABLE_PUTUTXLINE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004852 [Define if you don't want to use pututxline()
4853 etc. to write [uw]tmpx])
Darren Tuckera3020db2003-06-28 12:54:33 +10004854 fi
4855 ]
andre2ff7b5d2000-06-03 14:57:40 +00004856)
Tim Rice648f8762011-01-26 12:38:57 -08004857AC_ARG_WITH([lastlog],
andre43ca7e22000-06-19 08:23:46 +00004858 [ --with-lastlog=FILE|DIR specify lastlog location [common locations]],
Damien Miller709528a2001-01-31 09:57:55 +11004859 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004860 if test "x$withval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004861 AC_DEFINE([DISABLE_LASTLOG])
Tim Rice35cc69d2005-03-17 16:44:25 -08004862 elif test -n "$withval" && test "x${withval}" != "xyes"; then
Damien Miller709528a2001-01-31 09:57:55 +11004863 conf_lastlog_location=$withval
4864 fi
4865 ]
4866)
andre2ff7b5d2000-06-03 14:57:40 +00004867
4868dnl lastlog, [uw]tmpx? detection
4869dnl NOTE: set the paths in the platform section to avoid the
4870dnl need for command-line parameters
4871dnl lastlog and [uw]tmp are subject to a file search if all else fails
4872
4873dnl lastlog detection
4874dnl NOTE: the code itself will detect if lastlog is a directory
4875AC_MSG_CHECKING([if your system defines LASTLOG_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08004876AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00004877#include <sys/types.h>
4878#include <utmp.h>
4879#ifdef HAVE_LASTLOG_H
4880# include <lastlog.h>
4881#endif
Damien Miller2994e082000-06-04 15:51:47 +10004882#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00004883# include <paths.h>
4884#endif
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00004885#ifdef HAVE_LOGIN_H
4886# include <login.h>
4887#endif
Tim Rice648f8762011-01-26 12:38:57 -08004888 ]], [[ char *lastlog = LASTLOG_FILE; ]])],
4889 [ AC_MSG_RESULT([yes]) ],
4890 [
4891 AC_MSG_RESULT([no])
Damien Miller2994e082000-06-04 15:51:47 +10004892 AC_MSG_CHECKING([if your system defines _PATH_LASTLOG])
Tim Rice648f8762011-01-26 12:38:57 -08004893 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller2994e082000-06-04 15:51:47 +10004894#include <sys/types.h>
4895#include <utmp.h>
4896#ifdef HAVE_LASTLOG_H
4897# include <lastlog.h>
4898#endif
4899#ifdef HAVE_PATHS_H
4900# include <paths.h>
4901#endif
Tim Rice648f8762011-01-26 12:38:57 -08004902 ]], [[ char *lastlog = _PATH_LASTLOG; ]])],
4903 [ AC_MSG_RESULT([yes]) ],
Damien Miller2994e082000-06-04 15:51:47 +10004904 [
Tim Rice648f8762011-01-26 12:38:57 -08004905 AC_MSG_RESULT([no])
Damien Miller2994e082000-06-04 15:51:47 +10004906 system_lastlog_path=no
4907 ])
Tim Rice648f8762011-01-26 12:38:57 -08004908])
Damien Miller2994e082000-06-04 15:51:47 +10004909
andre2ff7b5d2000-06-03 14:57:40 +00004910if test -z "$conf_lastlog_location"; then
4911 if test x"$system_lastlog_path" = x"no" ; then
4912 for f in /var/log/lastlog /usr/adm/lastlog /var/adm/lastlog /etc/security/lastlog ; do
Damien Milleredb82922000-06-20 13:25:52 +10004913 if (test -d "$f" || test -f "$f") ; then
andre2ff7b5d2000-06-03 14:57:40 +00004914 conf_lastlog_location=$f
4915 fi
4916 done
4917 if test -z "$conf_lastlog_location"; then
andre45cad512000-06-12 23:27:31 +00004918 AC_MSG_WARN([** Cannot find lastlog **])
4919 dnl Don't define DISABLE_LASTLOG - that means we don't try wtmp/wtmpx
andre2ff7b5d2000-06-03 14:57:40 +00004920 fi
4921 fi
4922fi
4923
4924if test -n "$conf_lastlog_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08004925 AC_DEFINE_UNQUOTED([CONF_LASTLOG_FILE], ["$conf_lastlog_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07004926 [Define if you want to specify the path to your lastlog file])
Tim Riceeae17cc2005-03-17 16:52:20 -08004927fi
andre2ff7b5d2000-06-03 14:57:40 +00004928
4929dnl utmp detection
4930AC_MSG_CHECKING([if your system defines UTMP_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08004931AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00004932#include <sys/types.h>
4933#include <utmp.h>
Damien Miller2994e082000-06-04 15:51:47 +10004934#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00004935# include <paths.h>
4936#endif
Tim Rice648f8762011-01-26 12:38:57 -08004937 ]], [[ char *utmp = UTMP_FILE; ]])],
4938 [ AC_MSG_RESULT([yes]) ],
4939 [ AC_MSG_RESULT([no])
Tim Ricee1d93702016-05-31 11:13:22 -07004940 system_utmp_path=no
Tim Rice648f8762011-01-26 12:38:57 -08004941])
andre2ff7b5d2000-06-03 14:57:40 +00004942if test -z "$conf_utmp_location"; then
4943 if test x"$system_utmp_path" = x"no" ; then
4944 for f in /etc/utmp /usr/adm/utmp /var/run/utmp; do
4945 if test -f $f ; then
4946 conf_utmp_location=$f
4947 fi
4948 done
4949 if test -z "$conf_utmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08004950 AC_DEFINE([DISABLE_UTMP])
andre2ff7b5d2000-06-03 14:57:40 +00004951 fi
4952 fi
4953fi
4954if test -n "$conf_utmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08004955 AC_DEFINE_UNQUOTED([CONF_UTMP_FILE], ["$conf_utmp_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07004956 [Define if you want to specify the path to your utmp file])
Tim Riceeae17cc2005-03-17 16:52:20 -08004957fi
andre2ff7b5d2000-06-03 14:57:40 +00004958
4959dnl wtmp detection
4960AC_MSG_CHECKING([if your system defines WTMP_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08004961AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00004962#include <sys/types.h>
4963#include <utmp.h>
Damien Miller2994e082000-06-04 15:51:47 +10004964#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00004965# include <paths.h>
4966#endif
Tim Rice648f8762011-01-26 12:38:57 -08004967 ]], [[ char *wtmp = WTMP_FILE; ]])],
4968 [ AC_MSG_RESULT([yes]) ],
4969 [ AC_MSG_RESULT([no])
Tim Ricee1d93702016-05-31 11:13:22 -07004970 system_wtmp_path=no
Tim Rice648f8762011-01-26 12:38:57 -08004971])
andre2ff7b5d2000-06-03 14:57:40 +00004972if test -z "$conf_wtmp_location"; then
4973 if test x"$system_wtmp_path" = x"no" ; then
4974 for f in /usr/adm/wtmp /var/log/wtmp; do
4975 if test -f $f ; then
4976 conf_wtmp_location=$f
4977 fi
4978 done
4979 if test -z "$conf_wtmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08004980 AC_DEFINE([DISABLE_WTMP])
andre2ff7b5d2000-06-03 14:57:40 +00004981 fi
4982 fi
4983fi
4984if test -n "$conf_wtmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08004985 AC_DEFINE_UNQUOTED([CONF_WTMP_FILE], ["$conf_wtmp_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07004986 [Define if you want to specify the path to your wtmp file])
Tim Riceeae17cc2005-03-17 16:52:20 -08004987fi
andre2ff7b5d2000-06-03 14:57:40 +00004988
andre2ff7b5d2000-06-03 14:57:40 +00004989dnl wtmpx detection
4990AC_MSG_CHECKING([if your system defines WTMPX_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08004991AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00004992#include <sys/types.h>
4993#include <utmp.h>
4994#ifdef HAVE_UTMPX_H
4995#include <utmpx.h>
4996#endif
Damien Miller2994e082000-06-04 15:51:47 +10004997#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00004998# include <paths.h>
4999#endif
Tim Rice648f8762011-01-26 12:38:57 -08005000 ]], [[ char *wtmpx = WTMPX_FILE; ]])],
5001 [ AC_MSG_RESULT([yes]) ],
5002 [ AC_MSG_RESULT([no])
Tim Ricee1d93702016-05-31 11:13:22 -07005003 system_wtmpx_path=no
Tim Rice648f8762011-01-26 12:38:57 -08005004])
andre2ff7b5d2000-06-03 14:57:40 +00005005if test -z "$conf_wtmpx_location"; then
5006 if test x"$system_wtmpx_path" = x"no" ; then
Tim Rice648f8762011-01-26 12:38:57 -08005007 AC_DEFINE([DISABLE_WTMPX])
andre2ff7b5d2000-06-03 14:57:40 +00005008 fi
5009else
Tim Rice648f8762011-01-26 12:38:57 -08005010 AC_DEFINE_UNQUOTED([CONF_WTMPX_FILE], ["$conf_wtmpx_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07005011 [Define if you want to specify the path to your wtmpx file])
Tim Riceeae17cc2005-03-17 16:52:20 -08005012fi
andre2ff7b5d2000-06-03 14:57:40 +00005013
Damien Miller4018c192000-04-30 09:30:44 +10005014
Damien Miller29ea30d2000-03-17 10:54:15 +11005015if test ! -z "$blibpath" ; then
Damien Millereab4bae2003-04-29 23:22:40 +10005016 LDFLAGS="$LDFLAGS $blibflags$blibpath"
5017 AC_MSG_WARN([Please check and edit blibpath in LDFLAGS in Makefile])
Damien Miller29ea30d2000-03-17 10:54:15 +11005018fi
5019
Damien Millera2438bb2013-03-15 10:23:07 +11005020AC_CHECK_MEMBER([struct lastlog.ll_line], [], [
Tim Riceaa86c392013-03-16 20:55:46 -07005021 if test x$SKIP_DISABLE_LASTLOG_DEFINE != "xyes" ; then
Damien Millera2438bb2013-03-15 10:23:07 +11005022 AC_DEFINE([DISABLE_LASTLOG])
Tim Riceaa86c392013-03-16 20:55:46 -07005023 fi
Damien Millera2438bb2013-03-15 10:23:07 +11005024 ], [
5025#ifdef HAVE_SYS_TYPES_H
5026#include <sys/types.h>
5027#endif
5028#ifdef HAVE_UTMP_H
5029#include <utmp.h>
5030#endif
5031#ifdef HAVE_UTMPX_H
5032#include <utmpx.h>
5033#endif
5034#ifdef HAVE_LASTLOG_H
5035#include <lastlog.h>
5036#endif
5037 ])
5038
5039AC_CHECK_MEMBER([struct utmp.ut_line], [], [
5040 AC_DEFINE([DISABLE_UTMP])
5041 AC_DEFINE([DISABLE_WTMP])
5042 ], [
5043#ifdef HAVE_SYS_TYPES_H
5044#include <sys/types.h>
5045#endif
5046#ifdef HAVE_UTMP_H
5047#include <utmp.h>
5048#endif
5049#ifdef HAVE_UTMPX_H
5050#include <utmpx.h>
5051#endif
5052#ifdef HAVE_LASTLOG_H
5053#include <lastlog.h>
5054#endif
5055 ])
5056
Darren Tucker7da23cb2005-08-03 00:20:15 +10005057dnl Adding -Werror to CFLAGS early prevents configure tests from running.
5058dnl Add now.
5059CFLAGS="$CFLAGS $werror_flags"
5060
Darren Tucker627337d2010-04-10 22:58:01 +10005061if test "x$ac_cv_func_getaddrinfo" != "xyes" ; then
5062 TEST_SSH_IPV6=no
5063else
5064 TEST_SSH_IPV6=yes
5065fi
Tim Rice648f8762011-01-26 12:38:57 -08005066AC_CHECK_DECL([BROKEN_GETADDRINFO], [TEST_SSH_IPV6=no])
5067AC_SUBST([TEST_SSH_IPV6], [$TEST_SSH_IPV6])
Darren Tucker47b8c992016-12-08 15:48:34 +11005068AC_SUBST([TEST_SSH_UTF8], [$TEST_SSH_UTF8])
Darren Tucker882abfd2013-11-09 00:17:41 +11005069AC_SUBST([TEST_MALLOC_OPTIONS], [$TEST_MALLOC_OPTIONS])
Darren Tucker6d8bd572013-06-11 11:26:10 +10005070AC_SUBST([UNSUPPORTED_ALGORITHMS], [$unsupported_algorithms])
Darren Tucker79c0e1d2017-12-11 14:38:33 +11005071AC_SUBST([DEPEND], [$(cat $srcdir/.depend)])
Darren Tucker5d376902008-06-11 04:15:05 +10005072
Damien Millerde35c382017-09-08 12:38:31 +10005073CFLAGS="${CFLAGS} ${CFLAGS_AFTER}"
5074LDFLAGS="${LDFLAGS} ${LDFLAGS_AFTER}"
5075
Damien Millerbac2d8a2000-09-05 16:13:06 +11005076AC_EXEEXT
Damien Miller223897a2006-09-12 21:54:10 +10005077AC_CONFIG_FILES([Makefile buildpkg.sh opensshd.init openssh.xml \
5078 openbsd-compat/Makefile openbsd-compat/regress/Makefile \
Damien Millerf22019b2011-05-05 13:48:37 +10005079 survey.sh])
Tim Rice13aae5e2001-10-21 17:53:58 -07005080AC_OUTPUT
Damien Miller0437b332000-05-02 09:56:41 +10005081
Damien Miller7b22d652000-06-18 14:07:04 +10005082# Print summary of options
5083
Damien Miller7b22d652000-06-18 14:07:04 +10005084# Someone please show me a better way :)
5085A=`eval echo ${prefix}` ; A=`eval echo ${A}`
5086B=`eval echo ${bindir}` ; B=`eval echo ${B}`
5087C=`eval echo ${sbindir}` ; C=`eval echo ${C}`
5088D=`eval echo ${sysconfdir}` ; D=`eval echo ${D}`
Kevin Stevese0f49142000-10-14 17:51:48 +00005089E=`eval echo ${libexecdir}/ssh-askpass` ; E=`eval echo ${E}`
Ben Lindstrombc709922001-04-18 18:04:21 +00005090F=`eval echo ${mandir}/${mansubdir}X` ; F=`eval echo ${F}`
Damien Miller7b22d652000-06-18 14:07:04 +10005091G=`eval echo ${piddir}` ; G=`eval echo ${G}`
Damien Millerf58c6722002-05-13 13:15:42 +10005092H=`eval echo ${PRIVSEP_PATH}` ; H=`eval echo ${H}`
5093I=`eval echo ${user_path}` ; I=`eval echo ${I}`
5094J=`eval echo ${superuser_path}` ; J=`eval echo ${J}`
Damien Miller7b22d652000-06-18 14:07:04 +10005095
5096echo ""
Kevin Steves393d2f72001-04-08 22:50:43 +00005097echo "OpenSSH has been configured with the following options:"
Damien Millerf58c6722002-05-13 13:15:42 +10005098echo " User binaries: $B"
5099echo " System binaries: $C"
5100echo " Configuration files: $D"
5101echo " Askpass program: $E"
5102echo " Manual pages: $F"
5103echo " PID file: $G"
5104echo " Privilege separation chroot path: $H"
Darren Tuckere1a790d2003-09-16 11:52:19 +10005105if test "x$external_path_file" = "x/etc/login.conf" ; then
5106echo " At runtime, sshd will use the path defined in $external_path_file"
5107echo " Make sure the path to scp is present, otherwise scp will not work"
Tim Rice43a1c132002-04-17 21:19:14 -07005108else
Damien Millerf58c6722002-05-13 13:15:42 +10005109echo " sshd default user PATH: $I"
Tim Riceb925b4b2003-09-15 22:40:49 -07005110 if test ! -z "$external_path_file"; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10005111echo " (If PATH is set in $external_path_file it will be used instead. If"
5112echo " used, ensure the path to scp is present, otherwise scp will not work.)"
5113 fi
Tim Rice43a1c132002-04-17 21:19:14 -07005114fi
Damien Millera18bbd32002-05-13 10:48:57 +10005115if test ! -z "$superuser_path" ; then
Damien Millerf58c6722002-05-13 13:15:42 +10005116echo " sshd superuser user PATH: $J"
Damien Millera18bbd32002-05-13 10:48:57 +10005117fi
Damien Millerf58c6722002-05-13 13:15:42 +10005118echo " Manpage format: $MANTYPE"
Damien Miller7abe09b2003-05-15 10:53:49 +10005119echo " PAM support: $PAM_MSG"
Damien Miller1b06dc32006-08-31 03:24:41 +10005120echo " OSF SIA support: $SIA_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10005121echo " KerberosV support: $KRB5_MSG"
Damien Miller73b42d22006-04-22 21:26:08 +10005122echo " SELinux support: $SELINUX_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10005123echo " Smartcard support: $SCARD_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10005124echo " S/KEY support: $SKEY_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10005125echo " MD5 password support: $MD5_MSG"
Darren Tucker16bcc1c2004-11-07 20:14:34 +11005126echo " libedit support: $LIBEDIT_MSG"
Damien Miller523db852017-02-03 16:01:22 +11005127echo " libldns support: $LDNS_MSG"
Damien Miller1b06dc32006-08-31 03:24:41 +10005128echo " Solaris process contract support: $SPC_MSG"
Darren Tucker97528352010-11-05 12:03:05 +11005129echo " Solaris project support: $SP_MSG"
Damien Miller4626cba2016-01-08 14:24:56 +11005130echo " Solaris privilege support: $SPP_MSG"
Damien Miller903e1152002-05-13 14:41:31 +10005131echo " IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10005132echo " Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG"
5133echo " BSD Auth support: $BSD_AUTH_MSG"
5134echo " Random number source: $RAND_MSG"
Damien Miller69ff1df2011-06-23 08:30:03 +10005135echo " Privsep sandbox style: $SANDBOX_STYLE"
Damien Miller60396b02001-02-18 17:01:00 +11005136
Damien Miller7b22d652000-06-18 14:07:04 +10005137echo ""
5138
Ben Lindstrom28bfc0d2000-12-18 19:58:57 +00005139echo " Host: ${host}"
5140echo " Compiler: ${CC}"
5141echo " Compiler flags: ${CFLAGS}"
5142echo "Preprocessor flags: ${CPPFLAGS}"
5143echo " Linker flags: ${LDFLAGS}"
Darren Tucker20e9f972007-03-25 18:26:01 +10005144echo " Libraries: ${LIBS}"
5145if test ! -z "${SSHDLIBS}"; then
5146echo " +for sshd: ${SSHDLIBS}"
5147fi
Damien Miller71adf122011-01-25 12:16:15 +11005148if test ! -z "${SSHLIBS}"; then
5149echo " +for ssh: ${SSHLIBS}"
5150fi
Damien Miller7b22d652000-06-18 14:07:04 +10005151
5152echo ""
5153
Tim Rice6f1f7582004-05-30 21:38:51 -07005154if test "x$MAKE_PACKAGE_SUPPORTED" = "xyes" ; then
Darren Tuckercf59d312004-08-29 21:18:09 +10005155 echo "SVR4 style packages are supported with \"make package\""
5156 echo ""
Tim Rice6f1f7582004-05-30 21:38:51 -07005157fi
5158
Damien Miller82cf0ce2000-12-20 13:34:48 +11005159if test "x$PAM_MSG" = "xyes" ; then
Damien Miller6c21c512002-01-22 21:57:53 +11005160 echo "PAM is enabled. You may need to install a PAM control file "
5161 echo "for sshd, otherwise password authentication may fail. "
Damien Millera8e06ce2003-11-21 23:48:55 +11005162 echo "Example PAM control files can be found in the contrib/ "
Damien Miller6c21c512002-01-22 21:57:53 +11005163 echo "subdirectory"
Damien Miller6f9c3372000-10-25 10:06:04 +11005164 echo ""
5165fi
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00005166
Damien Millerb4097182004-05-23 14:09:40 +10005167if test ! -z "$NO_PEERCHECK" ; then
Darren Tucker164aa302007-03-21 21:39:57 +11005168 echo "WARNING: the operating system that you are using does not"
5169 echo "appear to support getpeereid(), getpeerucred() or the"
5170 echo "SO_PEERCRED getsockopt() option. These facilities are used to"
5171 echo "enforce security checks to prevent unauthorised connections to"
5172 echo "ssh-agent. Their absence increases the risk that a malicious"
5173 echo "user can connect to your agent."
Damien Millerb4097182004-05-23 14:09:40 +10005174 echo ""
5175fi
5176
Darren Tuckerd9f88912005-02-20 21:01:48 +11005177if test "$AUDIT_MODULE" = "bsm" ; then
5178 echo "WARNING: BSM audit support is currently considered EXPERIMENTAL."
5179 echo "See the Solaris section in README.platform for details."
5180fi