blob: c4c759d4ea2ff66641e305c5f9462bed627f0176 [file] [log] [blame]
Damien Miller4fefe242004-03-11 14:20:10 +11001#
2# Copyright (c) 1999-2004 Damien Miller
3#
4# Permission to use, copy, modify, and distribute this software for any
5# purpose with or without fee is hereby granted, provided that the above
6# copyright notice and this permission notice appear in all copies.
7#
8# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Damien Millere9cf3572001-02-09 12:55:35 +110015
Tim Rice648f8762011-01-26 12:38:57 -080016AC_INIT([OpenSSH], [Portable], [openssh-unix-dev@mindrot.org])
Damien Miller3d673d12014-08-27 06:32:01 +100017AC_REVISION($Revision: 1.583 $)
Tim Rice13aae5e2001-10-21 17:53:58 -070018AC_CONFIG_SRCDIR([ssh.c])
Tim Rice648f8762011-01-26 12:38:57 -080019AC_LANG([C])
Damien Miller7f6ea021999-10-28 13:25:17 +100020
Tim Rice648f8762011-01-26 12:38:57 -080021AC_CONFIG_HEADER([config.h])
Damien Miller856799b2000-03-15 21:18:10 +110022AC_PROG_CC
Damien Miller76112de1999-12-21 11:18:08 +110023AC_CANONICAL_HOST
Damien Miller4df5c762001-02-28 08:14:22 +110024AC_C_BIGENDIAN
Damien Miller7f6ea021999-10-28 13:25:17 +100025
Damien Millera22ba012000-03-02 23:09:20 +110026# Checks for programs.
Darren Tucker167bd9c2003-09-07 12:34:54 +100027AC_PROG_AWK
Damien Millerab18c411999-11-11 10:40:23 +110028AC_PROG_CPP
Damien Miller7f6ea021999-10-28 13:25:17 +100029AC_PROG_RANLIB
Damien Millerd8087f61999-11-25 12:31:26 +110030AC_PROG_INSTALL
Tim Ricefd80ddc2006-02-02 19:11:56 -080031AC_PROG_EGREP
Darren Tucker6c8a2462017-12-01 17:11:47 +110032AC_PROG_MKDIR_P
Darren Tucker408f4c22015-04-17 09:39:58 +100033AC_CHECK_TOOLS([AR], [ar])
Tim Rice648f8762011-01-26 12:38:57 -080034AC_PATH_PROG([CAT], [cat])
35AC_PATH_PROG([KILL], [kill])
Tim Rice648f8762011-01-26 12:38:57 -080036AC_PATH_PROG([SED], [sed])
Tim Rice648f8762011-01-26 12:38:57 -080037AC_PATH_PROG([ENT], [ent])
38AC_SUBST([ENT])
39AC_PATH_PROG([TEST_MINUS_S_SH], [bash])
40AC_PATH_PROG([TEST_MINUS_S_SH], [ksh])
41AC_PATH_PROG([TEST_MINUS_S_SH], [sh])
42AC_PATH_PROG([SH], [sh])
43AC_PATH_PROG([GROFF], [groff])
44AC_PATH_PROG([NROFF], [nroff])
45AC_PATH_PROG([MANDOC], [mandoc])
46AC_SUBST([TEST_SHELL], [sh])
Damien Miller2e1b0821999-12-25 10:11:29 +110047
Damien Miller30a69e72011-01-04 08:16:27 +110048dnl select manpage formatter
49if test "x$MANDOC" != "x" ; then
50 MANFMT="$MANDOC"
51elif test "x$NROFF" != "x" ; then
52 MANFMT="$NROFF -mandoc"
53elif test "x$GROFF" != "x" ; then
54 MANFMT="$GROFF -mandoc -Tascii"
55else
56 AC_MSG_WARN([no manpage formatted found])
57 MANFMT="false"
58fi
Tim Rice648f8762011-01-26 12:38:57 -080059AC_SUBST([MANFMT])
Damien Miller30a69e72011-01-04 08:16:27 +110060
Tim Rice6f1f7582004-05-30 21:38:51 -070061dnl for buildpkg.sh
Tim Rice648f8762011-01-26 12:38:57 -080062AC_PATH_PROG([PATH_GROUPADD_PROG], [groupadd], [groupadd],
Tim Rice6f1f7582004-05-30 21:38:51 -070063 [/usr/sbin${PATH_SEPARATOR}/etc])
Tim Rice648f8762011-01-26 12:38:57 -080064AC_PATH_PROG([PATH_USERADD_PROG], [useradd], [useradd],
Tim Rice6f1f7582004-05-30 21:38:51 -070065 [/usr/sbin${PATH_SEPARATOR}/etc])
Tim Rice648f8762011-01-26 12:38:57 -080066AC_CHECK_PROG([MAKE_PACKAGE_SUPPORTED], [pkgmk], [yes], [no])
Darren Tuckerfbea7642006-01-30 00:22:39 +110067if test -x /sbin/sh; then
Tim Rice648f8762011-01-26 12:38:57 -080068 AC_SUBST([STARTUP_SCRIPT_SHELL], [/sbin/sh])
Darren Tuckerfbea7642006-01-30 00:22:39 +110069else
Tim Rice648f8762011-01-26 12:38:57 -080070 AC_SUBST([STARTUP_SCRIPT_SHELL], [/bin/sh])
Darren Tuckerfbea7642006-01-30 00:22:39 +110071fi
Tim Rice6f1f7582004-05-30 21:38:51 -070072
Damien Millere8bb4502001-09-25 16:39:35 +100073# System features
74AC_SYS_LARGEFILE
75
Damien Miller3f62aba2000-11-29 11:56:35 +110076if test -z "$AR" ; then
77 AC_MSG_ERROR([*** 'ar' missing, please install or fix your \$PATH ***])
78fi
79
Tim Rice648f8762011-01-26 12:38:57 -080080AC_PATH_PROG([PATH_PASSWD_PROG], [passwd])
Darren Tucker23bc8d02004-02-06 16:24:31 +110081if test ! -z "$PATH_PASSWD_PROG" ; then
Tim Rice648f8762011-01-26 12:38:57 -080082 AC_DEFINE_UNQUOTED([_PATH_PASSWD_PROG], ["$PATH_PASSWD_PROG"],
Tim Rice7df8d392005-09-19 09:33:39 -070083 [Full path of your "passwd" program])
Darren Tucker23bc8d02004-02-06 16:24:31 +110084fi
85
Darren Tuckerf2c06ab2018-06-08 17:43:36 +100086dnl Since autoconf doesn't support it very well, we no longer allow users to
87dnl override LD, however keeping the hook here for now in case there's a use
88dnl use case we overlooked and someone needs to re-enable it. Unless a good
89dnl reason is found we'll be removing this in future.
90LD="$CC"
Tim Rice648f8762011-01-26 12:38:57 -080091AC_SUBST([LD])
Tim Riceeae17cc2005-03-17 16:52:20 -080092
Damien Miller166bd442000-03-16 10:48:25 +110093AC_C_INLINE
Darren Tucker67b37032005-06-03 17:58:31 +100094
Tim Rice648f8762011-01-26 12:38:57 -080095AC_CHECK_DECL([LLONG_MAX], [have_llong_max=1], , [#include <limits.h>])
Damien Miller69ff1df2011-06-23 08:30:03 +100096AC_CHECK_DECL([SYSTR_POLICY_KILL], [have_systr_policy_kill=1], , [
97 #include <sys/types.h>
98 #include <sys/param.h>
99 #include <dev/systrace.h>
100])
101AC_CHECK_DECL([RLIMIT_NPROC],
102 [AC_DEFINE([HAVE_RLIMIT_NPROC], [], [sys/resource.h has RLIMIT_NPROC])], , [
103 #include <sys/types.h>
104 #include <sys/resource.h>
105])
Damien Millere0956e32012-04-04 11:27:54 +1000106AC_CHECK_DECL([PR_SET_NO_NEW_PRIVS], [have_linux_no_new_privs=1], , [
107 #include <sys/types.h>
108 #include <linux/prctl.h>
109])
Damien Miller868ea1e2014-01-17 16:47:04 +1100110
Damien Miller72ef7c12015-01-15 02:21:31 +1100111openssl=yes
Damien Miller72ef7c12015-01-15 02:21:31 +1100112AC_ARG_WITH([openssl],
113 [ --without-openssl Disable use of OpenSSL; use only limited internal crypto **EXPERIMENTAL** ],
Damien Miller76c04802015-01-13 19:38:18 +1100114 [ if test "x$withval" = "xno" ; then
Damien Miller72ef7c12015-01-15 02:21:31 +1100115 openssl=no
Damien Miller76c04802015-01-13 19:38:18 +1100116 fi
117 ]
118)
Damien Miller72ef7c12015-01-15 02:21:31 +1100119AC_MSG_CHECKING([whether OpenSSL will be used for cryptography])
120if test "x$openssl" = "xyes" ; then
121 AC_MSG_RESULT([yes])
122 AC_DEFINE_UNQUOTED([WITH_OPENSSL], [1], [use libcrypto for cryptography])
123else
124 AC_MSG_RESULT([no])
125fi
126
Darren Tuckerb7918af2008-03-09 11:34:23 +1100127use_stack_protector=1
Darren Tuckerfd994372014-01-17 09:53:24 +1100128use_toolchain_hardening=1
Tim Rice648f8762011-01-26 12:38:57 -0800129AC_ARG_WITH([stackprotect],
Damien Millerda3155e2008-03-27 12:30:18 +1100130 [ --without-stackprotect Don't use compiler's stack protection], [
Darren Tuckerb7918af2008-03-09 11:34:23 +1100131 if test "x$withval" = "xno"; then
132 use_stack_protector=0
133 fi ])
Darren Tuckerfd994372014-01-17 09:53:24 +1100134AC_ARG_WITH([hardening],
135 [ --without-hardening Don't use toolchain hardening flags], [
136 if test "x$withval" = "xno"; then
Darren Tuckerfd994372014-01-17 09:53:24 +1100137 use_toolchain_hardening=0
138 fi ])
Darren Tuckerb7918af2008-03-09 11:34:23 +1100139
Darren Tuckerfd994372014-01-17 09:53:24 +1100140# We use -Werror for the tests only so that we catch warnings like "this is
141# on by default" for things like -fPIE.
142AC_MSG_CHECKING([if $CC supports -Werror])
143saved_CFLAGS="$CFLAGS"
144CFLAGS="$CFLAGS -Werror"
145AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int main(void) { return 0; }]])],
146 [ AC_MSG_RESULT([yes])
147 WERROR="-Werror"],
148 [ AC_MSG_RESULT([no])
149 WERROR="" ]
150)
151CFLAGS="$saved_CFLAGS"
Damien Miller134d02a2011-01-12 16:00:37 +1100152
Damien Millera8e06ce2003-11-21 23:48:55 +1100153if test "$GCC" = "yes" || test "$GCC" = "egcs"; then
Darren Tuckerd9048862017-03-31 11:04:43 +1100154 OSSH_CHECK_CFLAG_COMPILE([-pipe])
Darren Tuckerfd994372014-01-17 09:53:24 +1100155 OSSH_CHECK_CFLAG_COMPILE([-Qunused-arguments])
156 OSSH_CHECK_CFLAG_COMPILE([-Wunknown-warning-option])
Damien Millerb1763622011-05-20 11:45:25 +1000157 OSSH_CHECK_CFLAG_COMPILE([-Wall])
158 OSSH_CHECK_CFLAG_COMPILE([-Wpointer-arith])
159 OSSH_CHECK_CFLAG_COMPILE([-Wuninitialized])
160 OSSH_CHECK_CFLAG_COMPILE([-Wsign-compare])
161 OSSH_CHECK_CFLAG_COMPILE([-Wformat-security])
Darren Tuckerabbc7a72013-05-10 13:54:23 +1000162 OSSH_CHECK_CFLAG_COMPILE([-Wsizeof-pointer-memaccess])
Damien Millerb1763622011-05-20 11:45:25 +1000163 OSSH_CHECK_CFLAG_COMPILE([-Wpointer-sign], [-Wno-pointer-sign])
164 OSSH_CHECK_CFLAG_COMPILE([-Wunused-result], [-Wno-unused-result])
165 OSSH_CHECK_CFLAG_COMPILE([-fno-strict-aliasing])
Darren Tuckerfd994372014-01-17 09:53:24 +1100166 if test "x$use_toolchain_hardening" = "x1"; then
Darren Tucker3377df02018-02-11 09:32:37 +1100167 OSSH_CHECK_CFLAG_COMPILE([-mfunction-return=thunk]) # gcc
168 OSSH_CHECK_CFLAG_COMPILE([-mindirect-branch=thunk]) # gcc
169 OSSH_CHECK_CFLAG_COMPILE([-mretpoline]) # clang
Darren Tucker174bed62018-02-13 18:12:47 +1100170 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,retpolineplt])
Damien Miller161af8f2017-09-19 10:18:56 +1000171 OSSH_CHECK_CFLAG_COMPILE([-D_FORTIFY_SOURCE=2])
Darren Tuckerfd994372014-01-17 09:53:24 +1100172 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,relro])
173 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,now])
174 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,noexecstack])
Damien Miller5c2ff5e2014-01-22 21:30:12 +1100175 # NB. -ftrapv expects certain support functions to be present in
176 # the compiler library (libgcc or similar) to detect integer operations
177 # that can overflow. We must check that the result of enabling it
178 # actually links. The test program compiled/linked includes a number
179 # of integer operations that should exercise this.
180 OSSH_CHECK_CFLAG_LINK([-ftrapv])
Darren Tuckerfd994372014-01-17 09:53:24 +1100181 fi
Tim Rice648f8762011-01-26 12:38:57 -0800182 AC_MSG_CHECKING([gcc version])
Darren Tucker3f9545e2005-11-12 15:20:52 +1100183 GCC_VER=`$CC -v 2>&1 | $AWK '/gcc version /{print $3}'`
Tim Rice3db1e3f2005-08-23 17:11:26 -0700184 case $GCC_VER in
Darren Tucker391de5c2007-04-29 14:49:21 +1000185 1.*) no_attrib_nonnull=1 ;;
186 2.8* | 2.9*)
Darren Tucker391de5c2007-04-29 14:49:21 +1000187 no_attrib_nonnull=1
188 ;;
189 2.*) no_attrib_nonnull=1 ;;
Darren Tuckerf0324352005-11-10 21:30:36 +1100190 *) ;;
Tim Rice3db1e3f2005-08-23 17:11:26 -0700191 esac
Tim Rice648f8762011-01-26 12:38:57 -0800192 AC_MSG_RESULT([$GCC_VER])
Damien Millerde3cb0a2005-05-26 20:48:25 +1000193
Tim Rice648f8762011-01-26 12:38:57 -0800194 AC_MSG_CHECKING([if $CC accepts -fno-builtin-memset])
Darren Tucker330c93f2008-06-16 02:27:48 +1000195 saved_CFLAGS="$CFLAGS"
196 CFLAGS="$CFLAGS -fno-builtin-memset"
Tim Rice648f8762011-01-26 12:38:57 -0800197 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <string.h> ]],
198 [[ char b[10]; memset(b, 0, sizeof(b)); ]])],
199 [ AC_MSG_RESULT([yes]) ],
200 [ AC_MSG_RESULT([no])
Darren Tucker330c93f2008-06-16 02:27:48 +1000201 CFLAGS="$saved_CFLAGS" ]
Tim Rice648f8762011-01-26 12:38:57 -0800202 )
Darren Tucker330c93f2008-06-16 02:27:48 +1000203
Darren Tuckerb7918af2008-03-09 11:34:23 +1100204 # -fstack-protector-all doesn't always work for some GCC versions
Darren Tuckerfe1cf972008-03-09 22:50:50 +1100205 # and/or platforms, so we test if we can. If it's not supported
Damien Miller7df2e402008-12-08 09:35:36 +1100206 # on a given platform gcc will emit a warning so we use -Werror.
Darren Tuckerb7918af2008-03-09 11:34:23 +1100207 if test "x$use_stack_protector" = "x1"; then
Darren Tuckerfd994372014-01-17 09:53:24 +1100208 for t in -fstack-protector-strong -fstack-protector-all \
209 -fstack-protector; do
Tim Rice648f8762011-01-26 12:38:57 -0800210 AC_MSG_CHECKING([if $CC supports $t])
Darren Tuckerb7918af2008-03-09 11:34:23 +1100211 saved_CFLAGS="$CFLAGS"
212 saved_LDFLAGS="$LDFLAGS"
Darren Tuckerfe1cf972008-03-09 22:50:50 +1100213 CFLAGS="$CFLAGS $t -Werror"
214 LDFLAGS="$LDFLAGS $t -Werror"
215 AC_LINK_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -0800216 [AC_LANG_PROGRAM([[ #include <stdio.h> ]],
217 [[
218 char x[256];
219 snprintf(x, sizeof(x), "XXX");
220 ]])],
221 [ AC_MSG_RESULT([yes])
Darren Tuckerfe1cf972008-03-09 22:50:50 +1100222 CFLAGS="$saved_CFLAGS $t"
223 LDFLAGS="$saved_LDFLAGS $t"
Tim Rice648f8762011-01-26 12:38:57 -0800224 AC_MSG_CHECKING([if $t works])
Darren Tuckerb7918af2008-03-09 11:34:23 +1100225 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -0800226 [AC_LANG_PROGRAM([[ #include <stdio.h> ]],
227 [[
228 char x[256];
229 snprintf(x, sizeof(x), "XXX");
230 ]])],
231 [ AC_MSG_RESULT([yes])
Darren Tuckerb7918af2008-03-09 11:34:23 +1100232 break ],
Tim Rice648f8762011-01-26 12:38:57 -0800233 [ AC_MSG_RESULT([no]) ],
Darren Tuckerb7918af2008-03-09 11:34:23 +1100234 [ AC_MSG_WARN([cross compiling: cannot test])
235 break ]
Darren Tuckerfe1cf972008-03-09 22:50:50 +1100236 )
Darren Tuckerb7918af2008-03-09 11:34:23 +1100237 ],
Tim Rice648f8762011-01-26 12:38:57 -0800238 [ AC_MSG_RESULT([no]) ]
Darren Tuckerb7918af2008-03-09 11:34:23 +1100239 )
240 CFLAGS="$saved_CFLAGS"
241 LDFLAGS="$saved_LDFLAGS"
242 done
243 fi
Darren Tucker319b3d92007-12-02 21:02:22 +1100244
Darren Tucker67b37032005-06-03 17:58:31 +1000245 if test -z "$have_llong_max"; then
246 # retry LLONG_MAX with -std=gnu99, needed on some Linuxes
247 unset ac_cv_have_decl_LLONG_MAX
248 saved_CFLAGS="$CFLAGS"
249 CFLAGS="$CFLAGS -std=gnu99"
Tim Rice648f8762011-01-26 12:38:57 -0800250 AC_CHECK_DECL([LLONG_MAX],
Darren Tucker67b37032005-06-03 17:58:31 +1000251 [have_llong_max=1],
252 [CFLAGS="$saved_CFLAGS"],
253 [#include <limits.h>]
254 )
255 fi
Damien Miller166bd442000-03-16 10:48:25 +1100256fi
257
Darren Tucker951b53b2013-02-08 11:50:09 +1100258AC_MSG_CHECKING([if compiler allows __attribute__ on return types])
259AC_COMPILE_IFELSE(
260 [AC_LANG_PROGRAM([[
261#include <stdlib.h>
262__attribute__((__unused__)) static void foo(void){return;}]],
263 [[ exit(0); ]])],
264 [ AC_MSG_RESULT([yes]) ],
265 [ AC_MSG_RESULT([no])
266 AC_DEFINE(NO_ATTRIBUTE_ON_RETURN_TYPE, 1,
267 [compiler does not accept __attribute__ on return types]) ]
268)
269
Darren Tucker1323f122018-02-27 08:41:25 +1100270AC_MSG_CHECKING([if compiler allows __attribute__ prototype args])
271AC_COMPILE_IFELSE(
272 [AC_LANG_PROGRAM([[
273#include <stdlib.h>
274typedef void foo(const char *, ...) __attribute__((format(printf, 1, 2)));]],
275 [[ exit(0); ]])],
276 [ AC_MSG_RESULT([yes]) ],
277 [ AC_MSG_RESULT([no])
278 AC_DEFINE(NO_ATTRIBUTE_ON_PROTOTYPE_ARGS, 1,
Damien Miller10479cc2018-04-10 10:19:02 +1000279 [compiler does not accept __attribute__ on prototype args]) ]
Darren Tucker1323f122018-02-27 08:41:25 +1100280)
281
Darren Tucker391de5c2007-04-29 14:49:21 +1000282if test "x$no_attrib_nonnull" != "x1" ; then
Tim Rice648f8762011-01-26 12:38:57 -0800283 AC_DEFINE([HAVE_ATTRIBUTE__NONNULL__], [1], [Have attribute nonnull])
Darren Tucker391de5c2007-04-29 14:49:21 +1000284fi
285
Tim Rice648f8762011-01-26 12:38:57 -0800286AC_ARG_WITH([rpath],
Tim Rice88368a32003-12-08 12:35:59 -0800287 [ --without-rpath Disable auto-added -R linker paths],
288 [
Tim Riceeae17cc2005-03-17 16:52:20 -0800289 if test "x$withval" = "xno" ; then
Tim Rice88368a32003-12-08 12:35:59 -0800290 need_dash_r=""
291 fi
292 if test "x$withval" = "xyes" ; then
293 need_dash_r=1
294 fi
295 ]
296)
297
Tim Rice1cfab232006-10-03 09:34:35 -0700298# Allow user to specify flags
Tim Rice648f8762011-01-26 12:38:57 -0800299AC_ARG_WITH([cflags],
Tim Rice1cfab232006-10-03 09:34:35 -0700300 [ --with-cflags Specify additional flags to pass to compiler],
301 [
302 if test -n "$withval" && test "x$withval" != "xno" && \
303 test "x${withval}" != "xyes"; then
304 CFLAGS="$CFLAGS $withval"
305 fi
306 ]
307)
Damien Millerde35c382017-09-08 12:38:31 +1000308
309AC_ARG_WITH([cflags-after],
310 [ --with-cflags-after Specify additional flags to pass to compiler after configure],
311 [
312 if test -n "$withval" && test "x$withval" != "xno" && \
313 test "x${withval}" != "xyes"; then
314 CFLAGS_AFTER="$withval"
315 fi
316 ]
317)
Tim Rice648f8762011-01-26 12:38:57 -0800318AC_ARG_WITH([cppflags],
Tim Rice1cfab232006-10-03 09:34:35 -0700319 [ --with-cppflags Specify additional flags to pass to preprocessor] ,
320 [
321 if test -n "$withval" && test "x$withval" != "xno" && \
322 test "x${withval}" != "xyes"; then
323 CPPFLAGS="$CPPFLAGS $withval"
324 fi
325 ]
326)
Tim Rice648f8762011-01-26 12:38:57 -0800327AC_ARG_WITH([ldflags],
Tim Rice1cfab232006-10-03 09:34:35 -0700328 [ --with-ldflags Specify additional flags to pass to linker],
329 [
330 if test -n "$withval" && test "x$withval" != "xno" && \
331 test "x${withval}" != "xyes"; then
332 LDFLAGS="$LDFLAGS $withval"
333 fi
334 ]
335)
Damien Millerde35c382017-09-08 12:38:31 +1000336AC_ARG_WITH([ldflags-after],
337 [ --with-ldflags-after Specify additional flags to pass to linker after configure],
338 [
339 if test -n "$withval" && test "x$withval" != "xno" && \
340 test "x${withval}" != "xyes"; then
341 LDFLAGS_AFTER="$withval"
342 fi
343 ]
344)
Tim Rice648f8762011-01-26 12:38:57 -0800345AC_ARG_WITH([libs],
Tim Rice1cfab232006-10-03 09:34:35 -0700346 [ --with-libs Specify additional libraries to link with],
347 [
348 if test -n "$withval" && test "x$withval" != "xno" && \
349 test "x${withval}" != "xyes"; then
350 LIBS="$LIBS $withval"
351 fi
352 ]
353)
Tim Rice648f8762011-01-26 12:38:57 -0800354AC_ARG_WITH([Werror],
Tim Rice1cfab232006-10-03 09:34:35 -0700355 [ --with-Werror Build main code with -Werror],
356 [
357 if test -n "$withval" && test "x$withval" != "xno"; then
358 werror_flags="-Werror"
359 if test "x${withval}" != "xyes"; then
360 werror_flags="$withval"
361 fi
362 fi
363 ]
364)
365
Tim Rice648f8762011-01-26 12:38:57 -0800366AC_CHECK_HEADERS([ \
Damien Miller1ff130d2013-12-07 11:51:51 +1100367 blf.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700368 bstring.h \
369 crypt.h \
370 crypto/sha2.h \
371 dirent.h \
372 endian.h \
Damien Miller91f40d82013-02-22 11:37:00 +1100373 elf.h \
Darren Tucker6310ef22016-07-13 14:42:35 +1000374 err.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700375 features.h \
376 fcntl.h \
377 floatingpoint.h \
378 getopt.h \
379 glob.h \
380 ia.h \
381 iaf.h \
Darren Tuckerb59162d2018-02-23 15:20:42 +1100382 ifaddrs.h \
Darren Tucker6d725682014-01-17 19:17:34 +1100383 inttypes.h \
Darren Tuckerf3f2cc82016-07-11 17:23:38 +1000384 langinfo.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700385 limits.h \
Darren Tuckerae133d42013-06-06 08:30:20 +1000386 locale.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700387 login.h \
388 maillock.h \
389 ndir.h \
390 net/if_tun.h \
391 netdb.h \
392 netgroup.h \
393 pam/pam_appl.h \
394 paths.h \
Darren Tuckerfebf0f52007-06-25 22:15:12 +1000395 poll.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700396 pty.h \
397 readpassphrase.h \
398 rpc/types.h \
399 security/pam_appl.h \
400 sha2.h \
401 shadow.h \
402 stddef.h \
403 stdint.h \
404 string.h \
405 strings.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700406 sys/bitypes.h \
407 sys/bsdtty.h \
408 sys/cdefs.h \
409 sys/dir.h \
Damien Millerf8854742018-02-26 12:18:14 +1100410 sys/file.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700411 sys/mman.h \
Darren Tuckerce066f62018-02-22 20:45:09 +1100412 sys/label.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700413 sys/ndir.h \
Darren Tucker7c92a652007-09-27 07:00:09 +1000414 sys/poll.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700415 sys/prctl.h \
416 sys/pstat.h \
Darren Tucker5ee3fb52016-11-01 08:12:33 +1100417 sys/ptrace.h \
Damien Millerafa6e792018-04-13 13:31:42 +1000418 sys/random.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700419 sys/select.h \
420 sys/stat.h \
421 sys/stream.h \
422 sys/stropts.h \
423 sys/strtio.h \
Darren Tucker5b2e2ba2008-06-08 09:25:28 +1000424 sys/statvfs.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700425 sys/sysmacros.h \
426 sys/time.h \
427 sys/timers.h \
Darren Tucker11057562018-02-25 11:22:57 +1100428 sys/vfs.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700429 time.h \
430 tmpdir.h \
431 ttyent.h \
Tim Riceaa8954f2007-05-09 15:57:43 -0700432 ucred.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700433 unistd.h \
434 usersec.h \
435 util.h \
436 utime.h \
437 utmp.h \
438 utmpx.h \
439 vis.h \
Darren Tuckerf3f2cc82016-07-11 17:23:38 +1000440 wchar.h \
Tim Rice648f8762011-01-26 12:38:57 -0800441])
Tim Rice1cfab232006-10-03 09:34:35 -0700442
Darren Tuckerce066f62018-02-22 20:45:09 +1100443# On some platforms (eg SunOS4) sys/audit.h requires sys/[time|types|label.h]
444# to be included first.
445AC_CHECK_HEADERS([sys/audit.h], [], [], [
446#ifdef HAVE_SYS_TIME_H
447# include <sys/time.h>
448#endif
449#ifdef HAVE_SYS_TYPES_H
450# include <sys/types.h>
451#endif
452#ifdef HAVE_SYS_LABEL_H
453# include <sys/label.h>
454#endif
455])
456
Darren Tuckerdd9d9b32017-08-28 16:48:27 +1000457# sys/capsicum.h requires sys/types.h
458AC_CHECK_HEADERS([sys/capsicum.h], [], [], [
459#ifdef HAVE_SYS_TYPES_H
460# include <sys/types.h>
461#endif
462])
463
Darren Tuckerfa1b8342017-11-03 14:09:45 +1100464# net/route.h requires sys/socket.h and sys/types.h.
465# sys/sysctl.h also requires sys/param.h
466AC_CHECK_HEADERS([net/route.h sys/sysctl.h], [], [], [
467#ifdef HAVE_SYS_TYPES_H
468# include <sys/types.h>
469#endif
470#include <sys/param.h>
Damien Miller32354732017-10-25 11:25:43 +1100471#include <sys/socket.h>
472])
473
Tim Rice1cfab232006-10-03 09:34:35 -0700474# lastlog.h requires sys/time.h to be included first on Solaris
Tim Rice648f8762011-01-26 12:38:57 -0800475AC_CHECK_HEADERS([lastlog.h], [], [], [
Tim Rice1cfab232006-10-03 09:34:35 -0700476#ifdef HAVE_SYS_TIME_H
477# include <sys/time.h>
478#endif
479])
480
481# sys/ptms.h requires sys/stream.h to be included first on Solaris
Tim Rice648f8762011-01-26 12:38:57 -0800482AC_CHECK_HEADERS([sys/ptms.h], [], [], [
Tim Rice1cfab232006-10-03 09:34:35 -0700483#ifdef HAVE_SYS_STREAM_H
484# include <sys/stream.h>
485#endif
486])
487
488# login_cap.h requires sys/types.h on NetBSD
Tim Rice648f8762011-01-26 12:38:57 -0800489AC_CHECK_HEADERS([login_cap.h], [], [], [
Tim Rice1cfab232006-10-03 09:34:35 -0700490#include <sys/types.h>
491])
492
Darren Tuckerc4b22ca2009-07-12 21:56:29 +1000493# older BSDs need sys/param.h before sys/mount.h
Tim Rice648f8762011-01-26 12:38:57 -0800494AC_CHECK_HEADERS([sys/mount.h], [], [], [
Darren Tuckerc4b22ca2009-07-12 21:56:29 +1000495#include <sys/param.h>
496])
497
Darren Tuckeref4901c2013-06-03 01:59:13 +1000498# Android requires sys/socket.h to be included before sys/un.h
499AC_CHECK_HEADERS([sys/un.h], [], [], [
Darren Tucker0b43ffe2013-06-03 09:30:44 +1000500#include <sys/types.h>
Darren Tucker16cac192013-06-04 12:55:24 +1000501#include <sys/socket.h>
Darren Tuckeref4901c2013-06-03 01:59:13 +1000502])
503
Damien Miller1b06dc32006-08-31 03:24:41 +1000504# Messages for features tested for in target-specific section
505SIA_MSG="no"
506SPC_MSG="no"
Darren Tucker97528352010-11-05 12:03:05 +1100507SP_MSG="no"
Damien Miller4626cba2016-01-08 14:24:56 +1100508SPP_MSG="no"
509
510# Support for Solaris/Illumos privileges (this test is used by both
511# the --with-solaris-privs option and --with-sandbox=solaris).
512SOLARIS_PRIVS="no"
Damien Miller1b06dc32006-08-31 03:24:41 +1000513
Damien Millera22ba012000-03-02 23:09:20 +1100514# Check for some target-specific stuff
Damien Miller76112de1999-12-21 11:18:08 +1100515case "$host" in
Damien Miller75b1d102000-01-07 14:01:41 +1100516*-*-aix*)
Darren Tucker9216c372006-09-18 23:17:40 +1000517 # Some versions of VAC won't allow macro redefinitions at
518 # -qlanglevel=ansi, and autoconf 2.60 sometimes insists on using that
519 # particularly with older versions of vac or xlc.
Damien Miller10479cc2018-04-10 10:19:02 +1000520 # It also throws errors about null macro arguments, but these are
Darren Tucker9216c372006-09-18 23:17:40 +1000521 # not fatal.
Tim Rice648f8762011-01-26 12:38:57 -0800522 AC_MSG_CHECKING([if compiler allows macro redefinitions])
Darren Tucker9216c372006-09-18 23:17:40 +1000523 AC_COMPILE_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -0800524 [AC_LANG_PROGRAM([[
Darren Tucker9216c372006-09-18 23:17:40 +1000525#define testmacro foo
Tim Rice648f8762011-01-26 12:38:57 -0800526#define testmacro bar]],
527 [[ exit(0); ]])],
528 [ AC_MSG_RESULT([yes]) ],
529 [ AC_MSG_RESULT([no])
Darren Tucker9216c372006-09-18 23:17:40 +1000530 CC="`echo $CC | sed 's/-qlanglvl\=ansi//g'`"
Darren Tucker9216c372006-09-18 23:17:40 +1000531 CFLAGS="`echo $CFLAGS | sed 's/-qlanglvl\=ansi//g'`"
532 CPPFLAGS="`echo $CPPFLAGS | sed 's/-qlanglvl\=ansi//g'`"
533 ]
534 )
535
Damien Millera8e06ce2003-11-21 23:48:55 +1100536 AC_MSG_CHECKING([how to specify blibpath for linker ($LD)])
Damien Millereab4bae2003-04-29 23:22:40 +1000537 if (test -z "$blibpath"); then
Tim Ricefcb62202004-01-23 18:35:16 -0800538 blibpath="/usr/lib:/lib"
Damien Miller29ea30d2000-03-17 10:54:15 +1100539 fi
Damien Millereab4bae2003-04-29 23:22:40 +1000540 saved_LDFLAGS="$LDFLAGS"
Darren Tuckerbdc12122006-07-06 11:56:25 +1000541 if test "$GCC" = "yes"; then
542 flags="-Wl,-blibpath: -Wl,-rpath, -blibpath:"
543 else
544 flags="-blibpath: -Wl,-blibpath: -Wl,-rpath,"
545 fi
546 for tryflags in $flags ;do
Damien Millereab4bae2003-04-29 23:22:40 +1000547 if (test -z "$blibflags"); then
548 LDFLAGS="$saved_LDFLAGS $tryflags$blibpath"
Tim Rice648f8762011-01-26 12:38:57 -0800549 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
550 [blibflags=$tryflags], [])
Damien Millereab4bae2003-04-29 23:22:40 +1000551 fi
552 done
553 if (test -z "$blibflags"); then
Tim Rice648f8762011-01-26 12:38:57 -0800554 AC_MSG_RESULT([not found])
Damien Millereab4bae2003-04-29 23:22:40 +1000555 AC_MSG_ERROR([*** must be able to specify blibpath on AIX - check config.log])
556 else
Tim Rice648f8762011-01-26 12:38:57 -0800557 AC_MSG_RESULT([$blibflags])
Damien Millereab4bae2003-04-29 23:22:40 +1000558 fi
559 LDFLAGS="$saved_LDFLAGS"
Darren Tucker5c6a91a2003-07-14 16:21:44 +1000560 dnl Check for authenticate. Might be in libs.a on older AIXes
Tim Rice648f8762011-01-26 12:38:57 -0800561 AC_CHECK_FUNC([authenticate], [AC_DEFINE([WITH_AIXAUTHENTICATE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700562 [Define if you want to enable AIX4's authenticate function])],
Tim Rice648f8762011-01-26 12:38:57 -0800563 [AC_CHECK_LIB([s], [authenticate],
564 [ AC_DEFINE([WITH_AIXAUTHENTICATE])
Tim Ricee958ed32002-07-05 07:12:33 -0700565 LIBS="$LIBS -ls"
566 ])
567 ])
Darren Tucker3c774c52005-02-16 22:49:31 +1100568 dnl Check for various auth function declarations in headers.
Darren Tucker04cfbe02005-02-20 23:27:11 +1100569 AC_CHECK_DECLS([authenticate, loginrestrictions, loginsuccess,
Darren Tuckere66519d2005-03-21 22:46:34 +1100570 passwdexpired, setauthdb], , , [#include <usersec.h>])
Darren Tucker5c6a91a2003-07-14 16:21:44 +1000571 dnl Check if loginfailed is declared and takes 4 arguments (AIX >= 5.2)
Tim Rice648f8762011-01-26 12:38:57 -0800572 AC_CHECK_DECLS([loginfailed],
573 [AC_MSG_CHECKING([if loginfailed takes 4 arguments])
574 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <usersec.h> ]],
575 [[ (void)loginfailed("user","host","tty",0); ]])],
576 [AC_MSG_RESULT([yes])
577 AC_DEFINE([AIX_LOGINFAILED_4ARG], [1],
578 [Define if your AIX loginfailed() function
579 takes 4 arguments (AIX >= 5.2)])], [AC_MSG_RESULT([no])
580 ])],
581 [],
582 [#include <usersec.h>]
Darren Tucker5c6a91a2003-07-14 16:21:44 +1000583 )
Tim Rice648f8762011-01-26 12:38:57 -0800584 AC_CHECK_FUNCS([getgrset setauthdb])
585 AC_CHECK_DECL([F_CLOSEM],
586 AC_DEFINE([HAVE_FCNTL_CLOSEM], [1], [Use F_CLOSEM fcntl for closefrom]),
Darren Tucker3083bc22006-08-17 19:35:49 +1000587 [],
588 [ #include <limits.h>
589 #include <fcntl.h> ]
590 )
Darren Tucker691d5232005-02-15 21:45:57 +1100591 check_for_aix_broken_getaddrinfo=1
Tim Rice648f8762011-01-26 12:38:57 -0800592 AC_DEFINE([BROKEN_REALPATH], [1], [Define if you have a broken realpath.])
593 AC_DEFINE([SETEUID_BREAKS_SETUID], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700594 [Define if your platform breaks doing a seteuid before a setuid])
Tim Rice648f8762011-01-26 12:38:57 -0800595 AC_DEFINE([BROKEN_SETREUID], [1], [Define if your setreuid() is broken])
596 AC_DEFINE([BROKEN_SETREGID], [1], [Define if your setregid() is broken])
andre60f3c982000-06-03 16:18:19 +0000597 dnl AIX handles lastlog as part of its login message
Tim Rice648f8762011-01-26 12:38:57 -0800598 AC_DEFINE([DISABLE_LASTLOG], [1], [Define if you don't want to use lastlog])
599 AC_DEFINE([LOGIN_NEEDS_UTMPX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700600 [Some systems need a utmpx entry for /bin/login to work])
Tim Rice648f8762011-01-26 12:38:57 -0800601 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV],
Tim Rice7df8d392005-09-19 09:33:39 -0700602 [Define to a Set Process Title type if your system is
603 supported by bsd-setproctitle.c])
Tim Rice648f8762011-01-26 12:38:57 -0800604 AC_DEFINE([SSHPAM_CHAUTHTOK_NEEDS_RUID], [1],
Darren Tucker91d25a02005-11-26 22:24:09 +1100605 [AIX 5.2 and 5.3 (and presumably newer) require this])
Tim Rice648f8762011-01-26 12:38:57 -0800606 AC_DEFINE([PTY_ZEROREAD], [1], [read(1) can return 0 for a non-closed fd])
Darren Tuckeraa97d132013-03-12 11:31:05 +1100607 AC_DEFINE([PLATFORM_SYS_DIR_UID], 2, [System dirs owned by bin (uid 2)])
Darren Tucker2c71ca12018-03-30 18:23:07 +1100608 AC_DEFINE([BROKEN_STRNDUP], 1, [strndup broken, see APAR IY61211])
609 AC_DEFINE([BROKEN_STRNLEN], 1, [strnlen broken, see APAR IY62551])
Damien Miller75b1d102000-01-07 14:01:41 +1100610 ;;
Darren Tucker898ac932013-06-03 02:03:25 +1000611*-*-android*)
612 AC_DEFINE([DISABLE_UTMP], [1], [Define if you don't want to use utmp])
613 AC_DEFINE([DISABLE_WTMP], [1], [Define if you don't want to use wtmp])
614 ;;
Damien Millerbac2d8a2000-09-05 16:13:06 +1100615*-*-cygwin*)
Damien Millerc8936ac2003-02-11 10:04:03 +1100616 check_for_libcrypt_later=1
Darren Tucker573e3872007-03-02 17:50:03 +1100617 LIBS="$LIBS /usr/lib/textreadmode.o"
Tim Rice648f8762011-01-26 12:38:57 -0800618 AC_DEFINE([HAVE_CYGWIN], [1], [Define if you are on Cygwin])
619 AC_DEFINE([USE_PIPES], [1], [Use PIPES instead of a socketpair()])
Damien Miller4626cba2016-01-08 14:24:56 +1100620 AC_DEFINE([NO_UID_RESTORATION_TEST], [1],
621 [Define to disable UID restoration test])
Tim Rice648f8762011-01-26 12:38:57 -0800622 AC_DEFINE([DISABLE_SHADOW], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700623 [Define if you want to disable shadow passwords])
Tim Rice648f8762011-01-26 12:38:57 -0800624 AC_DEFINE([NO_X11_UNIX_SOCKETS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700625 [Define if X11 doesn't support AF_UNIX sockets on that system])
Tim Rice648f8762011-01-26 12:38:57 -0800626 AC_DEFINE([DISABLE_FD_PASSING], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700627 [Define if your platform needs to skip post auth
628 file descriptor passing])
Tim Rice648f8762011-01-26 12:38:57 -0800629 AC_DEFINE([SSH_IOBUFSZ], [65535], [Windows is sensitive to read buffer size])
Darren Tuckerfdce3732014-01-18 21:12:42 +1100630 AC_DEFINE([FILESYSTEM_NO_BACKSLASH], [1], [File names may not contain backslash characters])
631 # Cygwin defines optargs, optargs as declspec(dllimport) for historical
632 # reasons which cause compile warnings, so we disable those warnings.
633 OSSH_CHECK_CFLAG_COMPILE([-Wno-attributes])
Damien Millerbac2d8a2000-09-05 16:13:06 +1100634 ;;
Ben Lindstrom58055132001-02-15 18:34:29 +0000635*-*-dgux*)
Tim Rice648f8762011-01-26 12:38:57 -0800636 AC_DEFINE([IP_TOS_IS_BROKEN], [1],
Tim Ricea74000e2009-03-18 11:25:02 -0700637 [Define if your system choked on IP TOS setting])
Tim Rice648f8762011-01-26 12:38:57 -0800638 AC_DEFINE([SETEUID_BREAKS_SETUID])
639 AC_DEFINE([BROKEN_SETREUID])
640 AC_DEFINE([BROKEN_SETREGID])
Ben Lindstrom58055132001-02-15 18:34:29 +0000641 ;;
Ben Lindstromfed7bb42001-07-15 18:30:42 +0000642*-*-darwin*)
Damien Miller852472a2014-01-22 16:31:18 +1100643 use_pie=auto
Tim Rice648f8762011-01-26 12:38:57 -0800644 AC_MSG_CHECKING([if we have working getaddrinfo])
645 AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <mach-o/dyld.h>
Damien Millerfc93d4b2002-09-04 23:26:29 +1000646main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
647 exit(0);
648 else
649 exit(1);
Tim Rice648f8762011-01-26 12:38:57 -0800650}
651 ]])],
652 [AC_MSG_RESULT([working])],
653 [AC_MSG_RESULT([buggy])
654 AC_DEFINE([BROKEN_GETADDRINFO], [1],
655 [getaddrinfo is broken (if present)])
656 ],
657 [AC_MSG_RESULT([assume it is working])])
658 AC_DEFINE([SETEUID_BREAKS_SETUID])
659 AC_DEFINE([BROKEN_SETREUID])
660 AC_DEFINE([BROKEN_SETREGID])
661 AC_DEFINE([BROKEN_GLOB], [1], [OS X glob does not do what we expect])
662 AC_DEFINE_UNQUOTED([BIND_8_COMPAT], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700663 [Define if your resolver libs need this for getrrsetbyname])
Tim Rice648f8762011-01-26 12:38:57 -0800664 AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
665 AC_DEFINE([SSH_TUN_COMPAT_AF], [1],
Darren Tucker3eb48342006-06-23 21:05:12 +1000666 [Use tunnel device compatibility to OpenBSD])
Tim Rice648f8762011-01-26 12:38:57 -0800667 AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
Darren Tucker3eb48342006-06-23 21:05:12 +1000668 [Prepend the address family to IP tunnel traffic])
Tim Rice648f8762011-01-26 12:38:57 -0800669 m4_pattern_allow([AU_IPv])
Tim Ricee1d93702016-05-31 11:13:22 -0700670 AC_CHECK_DECL([AU_IPv4], [],
Tim Rice648f8762011-01-26 12:38:57 -0800671 AC_DEFINE([AU_IPv4], [0], [System only supports IPv4 audit records])
Darren Tuckeracada072008-02-25 21:05:04 +1100672 [#include <bsm/audit.h>]
Tim Rice648f8762011-01-26 12:38:57 -0800673 AC_DEFINE([LASTLOG_WRITE_PUTUTXLINE], [1],
Damien Miller20e231f2009-02-12 13:12:21 +1100674 [Define if pututxline updates lastlog too])
Darren Tuckeracada072008-02-25 21:05:04 +1100675 )
Damien Millerc09182f2011-06-03 12:11:38 +1000676 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV],
677 [Define to a Set Process Title type if your system is
678 supported by bsd-setproctitle.c])
Damien Millercd5e52e2011-06-27 07:18:18 +1000679 AC_CHECK_FUNCS([sandbox_init])
680 AC_CHECK_HEADERS([sandbox.h])
Damien Miller39f303b2016-02-23 12:56:59 +1100681 AC_CHECK_LIB([sandbox], [sandbox_apply], [
682 SSHDLIBS="$SSHDLIBS -lsandbox"
683 ])
Ben Lindstromfed7bb42001-07-15 18:30:42 +0000684 ;;
Darren Tucker57b29202006-09-10 20:25:51 +1000685*-*-dragonfly*)
686 SSHDLIBS="$SSHDLIBS -lcrypt"
Darren Tucker882abfd2013-11-09 00:17:41 +1100687 TEST_MALLOC_OPTIONS="AFGJPRX"
Darren Tucker57b29202006-09-10 20:25:51 +1000688 ;;
Tim Ricee1d93702016-05-31 11:13:22 -0700689*-*-haiku*)
Darren Tucker5faa52d2016-08-02 15:22:40 +1000690 LIBS="$LIBS -lbsd "
691 AC_CHECK_LIB([network], [socket])
692 AC_DEFINE([HAVE_U_INT64_T])
693 MANTYPE=man
694 ;;
Darren Tuckerfd333282005-05-28 18:31:42 +1000695*-*-hpux*)
696 # first we define all of the options common to all HP-UX releases
Kevin Steves315f8b72001-06-28 00:24:41 +0000697 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
Damien Miller9a947342000-08-30 10:03:33 +1100698 IPADDR_IN_DISPLAY=yes
Tim Rice648f8762011-01-26 12:38:57 -0800699 AC_DEFINE([USE_PIPES])
Tim Rice648f8762011-01-26 12:38:57 -0800700 AC_DEFINE([LOGIN_NEEDS_UTMPX])
701 AC_DEFINE([LOCKED_PASSWD_STRING], ["*"],
Tim Rice7df8d392005-09-19 09:33:39 -0700702 [String used in /etc/passwd to denote locked account])
Tim Rice648f8762011-01-26 12:38:57 -0800703 AC_DEFINE([SPT_TYPE], [SPT_PSTAT])
Darren Tuckeraa97d132013-03-12 11:31:05 +1100704 AC_DEFINE([PLATFORM_SYS_DIR_UID], 2, [System dirs owned by bin (uid 2)])
Tim Rice90f42b02011-06-02 18:17:49 -0700705 maildir="/var/mail"
Tim Ricef028f1e2002-07-19 12:41:10 -0700706 LIBS="$LIBS -lsec"
Tim Rice648f8762011-01-26 12:38:57 -0800707 AC_CHECK_LIB([xnet], [t_error], ,
708 [AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***])])
Darren Tuckerfd333282005-05-28 18:31:42 +1000709
710 # next, we define all of the options specific to major releases
711 case "$host" in
712 *-*-hpux10*)
713 if test -z "$GCC"; then
714 CFLAGS="$CFLAGS -Ae"
715 fi
716 ;;
717 *-*-hpux11*)
Tim Rice648f8762011-01-26 12:38:57 -0800718 AC_DEFINE([PAM_SUN_CODEBASE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700719 [Define if you are using Solaris-derived PAM which
720 passes pam_messages to the conversation function
721 with an extra level of indirection])
Tim Rice648f8762011-01-26 12:38:57 -0800722 AC_DEFINE([DISABLE_UTMP], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700723 [Define if you don't want to use utmp])
Tim Rice648f8762011-01-26 12:38:57 -0800724 AC_DEFINE([USE_BTMP], [1], [Use btmp to log bad logins])
Darren Tuckerfd333282005-05-28 18:31:42 +1000725 check_for_hpux_broken_getaddrinfo=1
726 check_for_conflicting_getspnam=1
727 ;;
728 esac
729
730 # lastly, we define options specific to minor releases
731 case "$host" in
732 *-*-hpux10.26)
Tim Rice648f8762011-01-26 12:38:57 -0800733 AC_DEFINE([HAVE_SECUREWARE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700734 [Define if you have SecureWare-based
735 protected password database])
Darren Tuckerfd333282005-05-28 18:31:42 +1000736 disable_ptmx_check=yes
737 LIBS="$LIBS -lsecpw"
738 ;;
739 esac
Damien Miller1bead332000-04-30 00:47:29 +1000740 ;;
Damien Millerbeb4ba51999-12-28 15:09:35 +1100741*-*-irix5*)
Damien Miller190d5a82000-09-30 09:43:19 +1100742 PATH="$PATH:/usr/etc"
Tim Rice648f8762011-01-26 12:38:57 -0800743 AC_DEFINE([BROKEN_INET_NTOA], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700744 [Define if you system's inet_ntoa is busted
745 (e.g. Irix gcc issue)])
Tim Rice648f8762011-01-26 12:38:57 -0800746 AC_DEFINE([SETEUID_BREAKS_SETUID])
747 AC_DEFINE([BROKEN_SETREUID])
748 AC_DEFINE([BROKEN_SETREGID])
749 AC_DEFINE([WITH_ABBREV_NO_TTY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700750 [Define if you shouldn't strip 'tty' from your
751 ttyname in [uw]tmp])
Tim Rice648f8762011-01-26 12:38:57 -0800752 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Damien Miller1808f382000-01-06 12:03:12 +1100753 ;;
754*-*-irix6*)
Damien Miller190d5a82000-09-30 09:43:19 +1100755 PATH="$PATH:/usr/etc"
Tim Rice648f8762011-01-26 12:38:57 -0800756 AC_DEFINE([WITH_IRIX_ARRAY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700757 [Define if you have/want arrays
Damien Miller10479cc2018-04-10 10:19:02 +1000758 (cluster-wide session management, not C arrays)])
Tim Rice648f8762011-01-26 12:38:57 -0800759 AC_DEFINE([WITH_IRIX_PROJECT], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700760 [Define if you want IRIX project management])
Tim Rice648f8762011-01-26 12:38:57 -0800761 AC_DEFINE([WITH_IRIX_AUDIT], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700762 [Define if you want IRIX audit trails])
Tim Rice648f8762011-01-26 12:38:57 -0800763 AC_CHECK_FUNC([jlimit_startjob], [AC_DEFINE([WITH_IRIX_JOBS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700764 [Define if you want IRIX kernel jobs])])
Tim Rice648f8762011-01-26 12:38:57 -0800765 AC_DEFINE([BROKEN_INET_NTOA])
766 AC_DEFINE([SETEUID_BREAKS_SETUID])
767 AC_DEFINE([BROKEN_SETREUID])
768 AC_DEFINE([BROKEN_SETREGID])
769 AC_DEFINE([BROKEN_UPDWTMPX], [1], [updwtmpx is broken (if present)])
770 AC_DEFINE([WITH_ABBREV_NO_TTY])
771 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Damien Millerbeb4ba51999-12-28 15:09:35 +1100772 ;;
Damien Miller90551722009-02-16 15:37:03 +1100773*-*-k*bsd*-gnu | *-*-kopensolaris*-gnu)
774 check_for_libcrypt_later=1
Tim Rice648f8762011-01-26 12:38:57 -0800775 AC_DEFINE([PAM_TTY_KLUDGE])
776 AC_DEFINE([LOCKED_PASSWD_PREFIX], ["!"])
777 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV])
778 AC_DEFINE([_PATH_BTMP], ["/var/log/btmp"], [log for bad login attempts])
779 AC_DEFINE([USE_BTMP], [1], [Use btmp to log bad logins])
Damien Miller90551722009-02-16 15:37:03 +1100780 ;;
Damien Millerb29ea912000-01-15 14:12:03 +1100781*-*-linux*)
782 no_dev_ptmx=1
Damien Miller852472a2014-01-22 16:31:18 +1100783 use_pie=auto
Damien Millera64b57a2001-01-17 10:44:13 +1100784 check_for_libcrypt_later=1
Darren Tucker70a3d552003-08-21 17:58:29 +1000785 check_for_openpty_ctty_bug=1
Darren Tuckerc61d5ec2017-02-03 14:10:34 +1100786 dnl Target SUSv3/POSIX.1-2001 plus BSD specifics.
787 dnl _DEFAULT_SOURCE is the new name for _BSD_SOURCE
788 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_DEFAULT_SOURCE"
Tim Rice648f8762011-01-26 12:38:57 -0800789 AC_DEFINE([PAM_TTY_KLUDGE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700790 [Work around problematic Linux PAM modules handling of PAM_TTY])
Tim Rice648f8762011-01-26 12:38:57 -0800791 AC_DEFINE([LOCKED_PASSWD_PREFIX], ["!"],
Tim Rice7df8d392005-09-19 09:33:39 -0700792 [String used in /etc/passwd to denote locked account])
Tim Rice648f8762011-01-26 12:38:57 -0800793 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV])
794 AC_DEFINE([LINK_OPNOTSUPP_ERRNO], [EPERM],
Tim Rice7df8d392005-09-19 09:33:39 -0700795 [Define to whatever link() returns for "not supported"
796 if it doesn't return EOPNOTSUPP.])
Tim Rice648f8762011-01-26 12:38:57 -0800797 AC_DEFINE([_PATH_BTMP], ["/var/log/btmp"], [log for bad login attempts])
798 AC_DEFINE([USE_BTMP])
799 AC_DEFINE([LINUX_OOM_ADJUST], [1], [Adjust Linux out-of-memory killer])
Damien Miller7bcb0892000-03-11 20:45:40 +1100800 inet6_default_4in6=yes
Darren Tucker3c016542003-05-02 20:48:21 +1000801 case `uname -r` in
Darren Tuckerc437cda2003-05-10 17:05:46 +1000802 1.*|2.0.*)
Tim Rice648f8762011-01-26 12:38:57 -0800803 AC_DEFINE([BROKEN_CMSG_TYPE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700804 [Define if cmsg_type is not passed correctly])
Darren Tucker3c016542003-05-02 20:48:21 +1000805 ;;
Darren Tucker3c016542003-05-02 20:48:21 +1000806 esac
Damien Miller89e03ba2005-12-31 16:42:03 +1100807 # tun(4) forwarding compat code
Tim Rice648f8762011-01-26 12:38:57 -0800808 AC_CHECK_HEADERS([linux/if_tun.h])
Damien Millerbd4e4102006-01-01 21:03:30 +1100809 if test "x$ac_cv_header_linux_if_tun_h" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -0800810 AC_DEFINE([SSH_TUN_LINUX], [1],
Damien Miller89e03ba2005-12-31 16:42:03 +1100811 [Open tunnel devices the Linux tun/tap way])
Tim Rice648f8762011-01-26 12:38:57 -0800812 AC_DEFINE([SSH_TUN_COMPAT_AF], [1],
Damien Miller89e03ba2005-12-31 16:42:03 +1100813 [Use tunnel device compatibility to OpenBSD])
Tim Rice648f8762011-01-26 12:38:57 -0800814 AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
Damien Miller89e03ba2005-12-31 16:42:03 +1100815 [Prepend the address family to IP tunnel traffic])
816 fi
Darren Tucker81c9ccd2017-11-03 14:52:51 +1100817 AC_CHECK_HEADER([linux/if.h],
818 AC_DEFINE([SYS_RDOMAIN_LINUX], [1],
Darren Tucker24d2a332018-02-11 21:20:39 +1300819 [Support routing domains using Linux VRF]), [], [
820#ifdef HAVE_SYS_TYPES_H
821# include <sys/types.H>
822#endif
823 ])
Darren Tucker60395f92012-07-03 14:31:18 +1000824 AC_CHECK_HEADERS([linux/seccomp.h linux/filter.h linux/audit.h], [],
825 [], [#include <linux/types.h>])
Vicente Olivert Riera58008672017-06-20 16:42:11 +0100826 # Obtain MIPS ABI
827 case "$host" in
828 mips*)
Darren Tuckerfbd733a2018-03-12 19:17:26 +1100829 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Vicente Olivert Riera58008672017-06-20 16:42:11 +0100830#if _MIPS_SIM != _ABIO32
831#error
832#endif
Darren Tuckerfbd733a2018-03-12 19:17:26 +1100833 ]])],[mips_abi="o32"],[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Vicente Olivert Riera58008672017-06-20 16:42:11 +0100834#if _MIPS_SIM != _ABIN32
835#error
836#endif
Darren Tuckerfbd733a2018-03-12 19:17:26 +1100837 ]])],[mips_abi="n32"],[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Vicente Olivert Riera58008672017-06-20 16:42:11 +0100838#if _MIPS_SIM != _ABI64
839#error
840#endif
Darren Tuckerfbd733a2018-03-12 19:17:26 +1100841 ]])],[mips_abi="n64"],[AC_MSG_ERROR([unknown MIPS ABI])
Vicente Olivert Riera58008672017-06-20 16:42:11 +0100842 ])
843 ])
844 ])
845 ;;
846 esac
Damien Miller91f40d82013-02-22 11:37:00 +1100847 AC_MSG_CHECKING([for seccomp architecture])
848 seccomp_audit_arch=
Damien Millere0956e32012-04-04 11:27:54 +1000849 case "$host" in
850 x86_64-*)
Damien Miller91f40d82013-02-22 11:37:00 +1100851 seccomp_audit_arch=AUDIT_ARCH_X86_64
Damien Millere0956e32012-04-04 11:27:54 +1000852 ;;
853 i*86-*)
Damien Miller91f40d82013-02-22 11:37:00 +1100854 seccomp_audit_arch=AUDIT_ARCH_I386
Damien Millere0956e32012-04-04 11:27:54 +1000855 ;;
Damien Miller99f33d72015-06-17 10:50:51 +1000856 arm*-*)
Damien Miller91f40d82013-02-22 11:37:00 +1100857 seccomp_audit_arch=AUDIT_ARCH_ARM
Damien Miller99f33d72015-06-17 10:50:51 +1000858 ;;
859 aarch64*-*)
860 seccomp_audit_arch=AUDIT_ARCH_AARCH64
Damien Miller5c15e222015-06-18 15:07:56 +1000861 ;;
Damien Millerb9c50612016-07-08 13:59:13 +1000862 s390x-*)
863 seccomp_audit_arch=AUDIT_ARCH_S390X
864 ;;
865 s390-*)
866 seccomp_audit_arch=AUDIT_ARCH_S390
867 ;;
868 powerpc64-*)
869 seccomp_audit_arch=AUDIT_ARCH_PPC64
870 ;;
871 powerpc64le-*)
872 seccomp_audit_arch=AUDIT_ARCH_PPC64LE
873 ;;
874 mips-*)
875 seccomp_audit_arch=AUDIT_ARCH_MIPS
876 ;;
877 mipsel-*)
878 seccomp_audit_arch=AUDIT_ARCH_MIPSEL
879 ;;
880 mips64-*)
Vicente Olivert Riera45011512017-06-20 16:42:28 +0100881 case "$mips_abi" in
882 "n32")
883 seccomp_audit_arch=AUDIT_ARCH_MIPS64N32
884 ;;
885 "n64")
886 seccomp_audit_arch=AUDIT_ARCH_MIPS64
887 ;;
888 esac
Damien Millerb9c50612016-07-08 13:59:13 +1000889 ;;
890 mips64el-*)
Vicente Olivert Riera45011512017-06-20 16:42:28 +0100891 case "$mips_abi" in
892 "n32")
893 seccomp_audit_arch=AUDIT_ARCH_MIPSEL64N32
894 ;;
895 "n64")
896 seccomp_audit_arch=AUDIT_ARCH_MIPSEL64
897 ;;
898 esac
Damien Millerb9c50612016-07-08 13:59:13 +1000899 ;;
Damien Millere0956e32012-04-04 11:27:54 +1000900 esac
Damien Miller91f40d82013-02-22 11:37:00 +1100901 if test "x$seccomp_audit_arch" != "x" ; then
902 AC_MSG_RESULT(["$seccomp_audit_arch"])
Damien Miller99f33d72015-06-17 10:50:51 +1000903 AC_DEFINE_UNQUOTED([SECCOMP_AUDIT_ARCH], [$seccomp_audit_arch],
904 [Specify the system call convention in use])
Damien Miller91f40d82013-02-22 11:37:00 +1100905 else
906 AC_MSG_RESULT([architecture not supported])
907 fi
Damien Millerb29ea912000-01-15 14:12:03 +1100908 ;;
Ben Lindstromb5628642000-10-18 00:02:25 +0000909mips-sony-bsd|mips-sony-newsos4)
Tim Rice648f8762011-01-26 12:38:57 -0800910 AC_DEFINE([NEED_SETPGRP], [1], [Need setpgrp to acquire controlling tty])
Ben Lindstromb5628642000-10-18 00:02:25 +0000911 SONY=1
Ben Lindstromb5628642000-10-18 00:02:25 +0000912 ;;
Damien Milleree1c0b32000-01-21 00:18:15 +1100913*-*-netbsd*)
Damien Millerfc93d4b2002-09-04 23:26:29 +1000914 check_for_libcrypt_before=1
Tim Riceeae17cc2005-03-17 16:52:20 -0800915 if test "x$withval" != "xno" ; then
Tim Rice88368a32003-12-08 12:35:59 -0800916 need_dash_r=1
917 fi
Damien Miller99522ba2016-07-28 08:54:27 +1000918 CPPFLAGS="$CPPFLAGS -D_OPENBSD_SOURCE"
Tim Rice648f8762011-01-26 12:38:57 -0800919 AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
Damien Miller2dcddbf2006-01-01 19:47:05 +1100920 AC_CHECK_HEADER([net/if_tap.h], ,
Tim Rice648f8762011-01-26 12:38:57 -0800921 AC_DEFINE([SSH_TUN_NO_L2], [1], [No layer 2 tunnel support]))
922 AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
Damien Miller2dcddbf2006-01-01 19:47:05 +1100923 [Prepend the address family to IP tunnel traffic])
Darren Tucker882abfd2013-11-09 00:17:41 +1100924 TEST_MALLOC_OPTIONS="AJRX"
Damien Millerf5bbd3b2014-01-30 11:26:46 +1100925 AC_DEFINE([BROKEN_READ_COMPARISON], [1],
926 [NetBSD read function is sometimes redirected, breaking atomicio comparisons against it])
Damien Milleree1c0b32000-01-21 00:18:15 +1100927 ;;
Damien Millerfbd884a2001-02-27 08:39:07 +1100928*-*-freebsd*)
929 check_for_libcrypt_later=1
Tim Rice648f8762011-01-26 12:38:57 -0800930 AC_DEFINE([LOCKED_PASSWD_PREFIX], ["*LOCKED*"], [Account locked with pw(1)])
931 AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
Damien Miller2dcddbf2006-01-01 19:47:05 +1100932 AC_CHECK_HEADER([net/if_tap.h], ,
Tim Rice648f8762011-01-26 12:38:57 -0800933 AC_DEFINE([SSH_TUN_NO_L2], [1], [No layer 2 tunnel support]))
934 AC_DEFINE([BROKEN_GLOB], [1], [FreeBSD glob does not do what we need])
Darren Tucker882abfd2013-11-09 00:17:41 +1100935 TEST_MALLOC_OPTIONS="AJRX"
Damien Miller2035b222014-01-26 09:39:53 +1100936 # Preauth crypto occasionally uses file descriptors for crypto offload
937 # and will crash if they cannot be opened.
Damien Miller5b447c02014-01-26 09:46:53 +1100938 AC_DEFINE([SANDBOX_SKIP_RLIMIT_NOFILE], [1],
Tim Rice03ae0812014-02-21 09:09:34 -0800939 [define if setrlimit RLIMIT_NOFILE breaks things])
Damien Millerfbd884a2001-02-27 08:39:07 +1100940 ;;
Darren Tuckered9eb022003-09-22 11:18:47 +1000941*-*-bsdi*)
Tim Rice648f8762011-01-26 12:38:57 -0800942 AC_DEFINE([SETEUID_BREAKS_SETUID])
943 AC_DEFINE([BROKEN_SETREUID])
944 AC_DEFINE([BROKEN_SETREGID])
Darren Tuckered9eb022003-09-22 11:18:47 +1000945 ;;
Damien Miller0f91b4e2000-06-18 15:43:25 +1000946*-next-*)
Damien Miller0f91b4e2000-06-18 15:43:25 +1000947 conf_lastlog_location="/usr/adm/lastlog"
Damien Millere5192fa2000-08-29 14:30:37 +1100948 conf_utmp_location=/etc/utmp
949 conf_wtmp_location=/usr/adm/wtmp
Tim Rice90f42b02011-06-02 18:17:49 -0700950 maildir=/usr/spool/mail
Tim Rice648f8762011-01-26 12:38:57 -0800951 AC_DEFINE([HAVE_NEXT], [1], [Define if you are on NeXT])
952 AC_DEFINE([BROKEN_REALPATH])
953 AC_DEFINE([USE_PIPES])
954 AC_DEFINE([BROKEN_SAVED_UIDS], [1], [Needed for NeXT])
Damien Miller0f91b4e2000-06-18 15:43:25 +1000955 ;;
Darren Tucker4a422572005-07-14 17:22:11 +1000956*-*-openbsd*)
Damien Miller852472a2014-01-22 16:31:18 +1100957 use_pie=auto
Tim Rice648f8762011-01-26 12:38:57 -0800958 AC_DEFINE([HAVE_ATTRIBUTE__SENTINEL__], [1], [OpenBSD's gcc has sentinel])
959 AC_DEFINE([HAVE_ATTRIBUTE__BOUNDED__], [1], [OpenBSD's gcc has bounded])
960 AC_DEFINE([SSH_TUN_OPENBSD], [1], [Open tunnel devices the OpenBSD way])
961 AC_DEFINE([SYSLOG_R_SAFE_IN_SIGHAND], [1],
Damien Millerbb598142006-08-19 08:38:23 +1000962 [syslog_r function is safe to use in in a signal handler])
Darren Tucker882abfd2013-11-09 00:17:41 +1100963 TEST_MALLOC_OPTIONS="AFGJPRX"
Darren Tucker4a422572005-07-14 17:22:11 +1000964 ;;
Damien Miller75b1d102000-01-07 14:01:41 +1100965*-*-solaris*)
Tim Riceeae17cc2005-03-17 16:52:20 -0800966 if test "x$withval" != "xno" ; then
Tim Ricead4a1882004-02-29 15:53:37 -0800967 need_dash_r=1
968 fi
Tim Rice648f8762011-01-26 12:38:57 -0800969 AC_DEFINE([PAM_SUN_CODEBASE])
970 AC_DEFINE([LOGIN_NEEDS_UTMPX])
Tim Rice648f8762011-01-26 12:38:57 -0800971 AC_DEFINE([PAM_TTY_KLUDGE])
972 AC_DEFINE([SSHPAM_CHAUTHTOK_NEEDS_RUID], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700973 [Define if pam_chauthtok wants real uid set
974 to the unpriv'ed user])
Tim Rice648f8762011-01-26 12:38:57 -0800975 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Darren Tuckerc437cda2003-05-10 17:05:46 +1000976 # Pushing STREAMS modules will cause sshd to acquire a controlling tty.
Tim Rice648f8762011-01-26 12:38:57 -0800977 AC_DEFINE([SSHD_ACQUIRES_CTTY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700978 [Define if sshd somehow reacquires a controlling TTY
979 after setsid()])
Tim Rice648f8762011-01-26 12:38:57 -0800980 AC_DEFINE([PASSWD_NEEDS_USERNAME], [1], [must supply username to passwd
Darren Tucker0249f932006-06-24 12:10:07 +1000981 in case the name is longer than 8 chars])
Tim Rice648f8762011-01-26 12:38:57 -0800982 AC_DEFINE([BROKEN_TCGETATTR_ICANON], [1], [tcgetattr with ICANON may hang])
Darren Tuckere1a790d2003-09-16 11:52:19 +1000983 external_path_file=/etc/default/login
andre2ff7b5d2000-06-03 14:57:40 +0000984 # hardwire lastlog location (can't detect it on some versions)
985 conf_lastlog_location="/var/adm/lastlog"
Tim Rice648f8762011-01-26 12:38:57 -0800986 AC_MSG_CHECKING([for obsolete utmp and wtmp in solaris2.x])
Damien Millera1cb6442000-06-09 11:58:35 +1000987 sol2ver=`echo "$host"| sed -e 's/.*[[0-9]]\.//'`
988 if test "$sol2ver" -ge 8; then
Tim Rice648f8762011-01-26 12:38:57 -0800989 AC_MSG_RESULT([yes])
990 AC_DEFINE([DISABLE_UTMP])
991 AC_DEFINE([DISABLE_WTMP], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700992 [Define if you don't want to use wtmp])
Damien Millera1cb6442000-06-09 11:58:35 +1000993 else
Tim Rice648f8762011-01-26 12:38:57 -0800994 AC_MSG_RESULT([no])
Damien Millera1cb6442000-06-09 11:58:35 +1000995 fi
Darren Tuckera86ec4d2016-06-14 10:48:27 +1000996 AC_CHECK_FUNCS([setpflags])
Darren Tucker907091a2016-02-19 09:05:39 +1100997 AC_CHECK_FUNCS([setppriv])
998 AC_CHECK_FUNCS([priv_basicset])
999 AC_CHECK_HEADERS([priv.h])
Tim Rice648f8762011-01-26 12:38:57 -08001000 AC_ARG_WITH([solaris-contracts],
Damien Miller1b06dc32006-08-31 03:24:41 +10001001 [ --with-solaris-contracts Enable Solaris process contracts (experimental)],
1002 [
Tim Rice648f8762011-01-26 12:38:57 -08001003 AC_CHECK_LIB([contract], [ct_tmpl_activate],
1004 [ AC_DEFINE([USE_SOLARIS_PROCESS_CONTRACTS], [1],
Damien Miller1b06dc32006-08-31 03:24:41 +10001005 [Define if you have Solaris process contracts])
Damien Miller4626cba2016-01-08 14:24:56 +11001006 LIBS="$LIBS -lcontract"
Damien Miller1b06dc32006-08-31 03:24:41 +10001007 SPC_MSG="yes" ], )
1008 ],
1009 )
Tim Rice648f8762011-01-26 12:38:57 -08001010 AC_ARG_WITH([solaris-projects],
Darren Tucker97528352010-11-05 12:03:05 +11001011 [ --with-solaris-projects Enable Solaris projects (experimental)],
1012 [
Tim Rice648f8762011-01-26 12:38:57 -08001013 AC_CHECK_LIB([project], [setproject],
1014 [ AC_DEFINE([USE_SOLARIS_PROJECTS], [1],
Darren Tucker97528352010-11-05 12:03:05 +11001015 [Define if you have Solaris projects])
Damien Miller4626cba2016-01-08 14:24:56 +11001016 LIBS="$LIBS -lproject"
Darren Tucker97528352010-11-05 12:03:05 +11001017 SP_MSG="yes" ], )
1018 ],
1019 )
Damien Miller4626cba2016-01-08 14:24:56 +11001020 AC_ARG_WITH([solaris-privs],
1021 [ --with-solaris-privs Enable Solaris/Illumos privileges (experimental)],
1022 [
1023 AC_MSG_CHECKING([for Solaris/Illumos privilege support])
Darren Tucker907091a2016-02-19 09:05:39 +11001024 if test "x$ac_cv_func_setppriv" = "xyes" -a \
1025 "x$ac_cv_header_priv_h" = "xyes" ; then
1026 SOLARIS_PRIVS=yes
Damien Miller4626cba2016-01-08 14:24:56 +11001027 AC_MSG_RESULT([found])
1028 AC_DEFINE([NO_UID_RESTORATION_TEST], [1],
1029 [Define to disable UID restoration test])
1030 AC_DEFINE([USE_SOLARIS_PRIVS], [1],
1031 [Define if you have Solaris privileges])
1032 SPP_MSG="yes"
1033 else
1034 AC_MSG_RESULT([not found])
1035 AC_MSG_ERROR([*** must have support for Solaris privileges to use --with-solaris-privs])
1036 fi
1037 ],
1038 )
Tim Rice5ab9b632013-06-02 14:05:48 -07001039 TEST_SHELL=$SHELL # let configure find us a capable shell
Damien Miller75b1d102000-01-07 14:01:41 +11001040 ;;
Damien Millerdfc83f42000-05-20 15:02:59 +10001041*-*-sunos4*)
Ben Lindstrom28bfc0d2000-12-18 19:58:57 +00001042 CPPFLAGS="$CPPFLAGS -DSUNOS4"
Tim Rice648f8762011-01-26 12:38:57 -08001043 AC_CHECK_FUNCS([getpwanam])
1044 AC_DEFINE([PAM_SUN_CODEBASE])
Damien Miller36ccb5c2000-08-09 16:34:27 +10001045 conf_utmp_location=/etc/utmp
1046 conf_wtmp_location=/var/adm/wtmp
1047 conf_lastlog_location=/var/adm/lastlog
Tim Rice648f8762011-01-26 12:38:57 -08001048 AC_DEFINE([USE_PIPES])
Darren Tuckerc0a0c3f2018-03-05 20:03:07 +11001049 AC_DEFINE([DISABLE_UTMPX], [1], [no utmpx])
Damien Millerdfc83f42000-05-20 15:02:59 +10001050 ;;
Ben Lindstrom603bdfd2001-02-12 07:29:45 +00001051*-ncr-sysv*)
Tim Rice13aae5e2001-10-21 17:53:58 -07001052 LIBS="$LIBS -lc89"
Tim Rice648f8762011-01-26 12:38:57 -08001053 AC_DEFINE([USE_PIPES])
1054 AC_DEFINE([SSHD_ACQUIRES_CTTY])
1055 AC_DEFINE([SETEUID_BREAKS_SETUID])
1056 AC_DEFINE([BROKEN_SETREUID])
1057 AC_DEFINE([BROKEN_SETREGID])
Ben Lindstrom603bdfd2001-02-12 07:29:45 +00001058 ;;
Damien Miller2ae714f2000-07-11 09:29:50 +10001059*-sni-sysv*)
Tim Riceffdf4aa2001-10-27 10:45:36 -07001060 # /usr/ucblib MUST NOT be searched on ReliantUNIX
Tim Rice648f8762011-01-26 12:38:57 -08001061 AC_CHECK_LIB([dl], [dlsym], ,)
Darren Tucker79d09fa2005-11-24 22:34:54 +11001062 # -lresolv needs to be at the end of LIBS or DNS lookups break
Tim Rice648f8762011-01-26 12:38:57 -08001063 AC_CHECK_LIB([resolv], [res_query], [ LIBS="$LIBS -lresolv" ])
Damien Millerfd9885e2001-01-10 08:16:53 +11001064 IPADDR_IN_DISPLAY=yes
Tim Rice648f8762011-01-26 12:38:57 -08001065 AC_DEFINE([USE_PIPES])
1066 AC_DEFINE([IP_TOS_IS_BROKEN])
1067 AC_DEFINE([SETEUID_BREAKS_SETUID])
1068 AC_DEFINE([BROKEN_SETREUID])
1069 AC_DEFINE([BROKEN_SETREGID])
1070 AC_DEFINE([SSHD_ACQUIRES_CTTY])
Darren Tuckere1a790d2003-09-16 11:52:19 +10001071 external_path_file=/etc/default/login
Tim Riceffdf4aa2001-10-27 10:45:36 -07001072 # /usr/ucblib/libucb.a no longer needed on ReliantUNIX
1073 # Attention: always take care to bind libsocket and libnsl before libc,
1074 # otherwise you will find lots of "SIOCGPGRP errno 22" on syslog
Damien Miller2ae714f2000-07-11 09:29:50 +10001075 ;;
Tim Rice0f83d292004-12-08 18:29:58 -08001076# UnixWare 1.x, UnixWare 2.x, and others based on code from Univel.
Damien Miller78315eb2000-09-29 23:01:36 +11001077*-*-sysv4.2*)
Tim Rice648f8762011-01-26 12:38:57 -08001078 AC_DEFINE([USE_PIPES])
1079 AC_DEFINE([SETEUID_BREAKS_SETUID])
1080 AC_DEFINE([BROKEN_SETREUID])
1081 AC_DEFINE([BROKEN_SETREGID])
1082 AC_DEFINE([PASSWD_NEEDS_USERNAME], [1], [must supply username to passwd])
1083 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Tim Rice5ab9b632013-06-02 14:05:48 -07001084 TEST_SHELL=$SHELL # let configure find us a capable shell
Damien Miller78315eb2000-09-29 23:01:36 +11001085 ;;
Tim Rice0f83d292004-12-08 18:29:58 -08001086# UnixWare 7.x, OpenUNIX 8
Damien Miller78315eb2000-09-29 23:01:36 +11001087*-*-sysv5*)
Tim Rice641ebf12010-01-17 17:05:39 -08001088 CPPFLAGS="$CPPFLAGS -Dvsnprintf=_xvsnprintf -Dsnprintf=_xsnprintf"
Tim Rice648f8762011-01-26 12:38:57 -08001089 AC_DEFINE([UNIXWARE_LONG_PASSWORDS], [1], [Support passwords > 8 chars])
1090 AC_DEFINE([USE_PIPES])
1091 AC_DEFINE([SETEUID_BREAKS_SETUID])
1092 AC_DEFINE([BROKEN_GETADDRINFO])
1093 AC_DEFINE([BROKEN_SETREUID])
1094 AC_DEFINE([BROKEN_SETREGID])
1095 AC_DEFINE([PASSWD_NEEDS_USERNAME])
Tim Rice8433d512017-07-11 18:47:56 -07001096 AC_DEFINE([BROKEN_TCGETATTR_ICANON])
Tim Rice5ab9b632013-06-02 14:05:48 -07001097 TEST_SHELL=$SHELL # let configure find us a capable shell
Tim Rice4afeaf32018-03-25 10:00:21 -07001098 check_for_libcrypt_later=1
Tim Rice4dbacff2005-06-01 20:09:28 -07001099 case "$host" in
1100 *-*-sysv5SCO_SV*) # SCO OpenServer 6.x
Tim Rice90f42b02011-06-02 18:17:49 -07001101 maildir=/var/spool/mail
Tim Rice648f8762011-01-26 12:38:57 -08001102 AC_DEFINE([BROKEN_UPDWTMPX])
1103 AC_CHECK_LIB([prot], [getluid], [ LIBS="$LIBS -lprot"
1104 AC_CHECK_FUNCS([getluid setluid], , , [-lprot])
Tim Rice648f8762011-01-26 12:38:57 -08001105 ], , )
Tim Rice4dbacff2005-06-01 20:09:28 -07001106 ;;
Tim Rice648f8762011-01-26 12:38:57 -08001107 *) AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Tim Rice46259d82005-11-28 18:40:34 -08001108 ;;
Tim Rice4dbacff2005-06-01 20:09:28 -07001109 esac
Damien Miller78315eb2000-09-29 23:01:36 +11001110 ;;
Damien Miller75b1d102000-01-07 14:01:41 +11001111*-*-sysv*)
Damien Miller75b1d102000-01-07 14:01:41 +11001112 ;;
Tim Rice0f83d292004-12-08 18:29:58 -08001113# SCO UNIX and OEM versions of SCO UNIX
Damien Miller78315eb2000-09-29 23:01:36 +11001114*-*-sco3.2v4*)
Tim Ricec390c8d2005-03-07 01:21:37 -08001115 AC_MSG_ERROR("This Platform is no longer supported.")
Damien Miller78315eb2000-09-29 23:01:36 +11001116 ;;
Tim Rice0f83d292004-12-08 18:29:58 -08001117# SCO OpenServer 5.x
Damien Miller78315eb2000-09-29 23:01:36 +11001118*-*-sco3.2v5*)
Tim Rice89fe3f32003-01-19 20:20:24 -08001119 if test -z "$GCC"; then
1120 CFLAGS="$CFLAGS -belf"
1121 fi
Damien Miller5dfe9762001-02-16 12:05:39 +11001122 LIBS="$LIBS -lprot -lx -ltinfo -lm"
Damien Millera66626b2000-06-13 18:57:53 +10001123 no_dev_ptmx=1
Tim Rice648f8762011-01-26 12:38:57 -08001124 AC_DEFINE([USE_PIPES])
1125 AC_DEFINE([HAVE_SECUREWARE])
1126 AC_DEFINE([DISABLE_SHADOW])
1127 AC_DEFINE([DISABLE_FD_PASSING])
1128 AC_DEFINE([SETEUID_BREAKS_SETUID])
1129 AC_DEFINE([BROKEN_GETADDRINFO])
1130 AC_DEFINE([BROKEN_SETREUID])
1131 AC_DEFINE([BROKEN_SETREGID])
1132 AC_DEFINE([WITH_ABBREV_NO_TTY])
1133 AC_DEFINE([BROKEN_UPDWTMPX])
1134 AC_DEFINE([PASSWD_NEEDS_USERNAME])
1135 AC_CHECK_FUNCS([getluid setluid])
Tim Rice07183b82001-04-25 21:40:28 -07001136 MANTYPE=man
Tim Rice5ab9b632013-06-02 14:05:48 -07001137 TEST_SHELL=$SHELL # let configure find us a capable shell
Tim Riceaa86c392013-03-16 20:55:46 -07001138 SKIP_DISABLE_LASTLOG_DEFINE=yes
Damien Millera66626b2000-06-13 18:57:53 +10001139 ;;
Damien Millerb8c656e2000-06-28 15:22:41 +10001140*-dec-osf*)
Tim Rice648f8762011-01-26 12:38:57 -08001141 AC_MSG_CHECKING([for Digital Unix SIA])
Ben Lindstrom72af2ef2001-05-08 20:42:28 +00001142 no_osfsia=""
Tim Rice648f8762011-01-26 12:38:57 -08001143 AC_ARG_WITH([osfsia],
Ben Lindstrom72af2ef2001-05-08 20:42:28 +00001144 [ --with-osfsia Enable Digital Unix SIA],
1145 [
1146 if test "x$withval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08001147 AC_MSG_RESULT([disabled])
Ben Lindstrom72af2ef2001-05-08 20:42:28 +00001148 no_osfsia=1
1149 fi
1150 ],
1151 )
1152 if test -z "$no_osfsia" ; then
Damien Millerb8c656e2000-06-28 15:22:41 +10001153 if test -f /etc/sia/matrix.conf; then
Tim Rice648f8762011-01-26 12:38:57 -08001154 AC_MSG_RESULT([yes])
1155 AC_DEFINE([HAVE_OSF_SIA], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001156 [Define if you have Digital Unix Security
1157 Integration Architecture])
Tim Rice648f8762011-01-26 12:38:57 -08001158 AC_DEFINE([DISABLE_LOGIN], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001159 [Define if you don't want to use your
1160 system's login() call])
Tim Rice648f8762011-01-26 12:38:57 -08001161 AC_DEFINE([DISABLE_FD_PASSING])
Damien Millerb8c656e2000-06-28 15:22:41 +10001162 LIBS="$LIBS -lsecurity -ldb -lm -laud"
Damien Miller1b06dc32006-08-31 03:24:41 +10001163 SIA_MSG="yes"
Damien Millerb8c656e2000-06-28 15:22:41 +10001164 else
Tim Rice648f8762011-01-26 12:38:57 -08001165 AC_MSG_RESULT([no])
1166 AC_DEFINE([LOCKED_PASSWD_SUBSTR], ["Nologin"],
Tim Rice7df8d392005-09-19 09:33:39 -07001167 [String used in /etc/passwd to denote locked account])
Damien Millerb8c656e2000-06-28 15:22:41 +10001168 fi
1169 fi
Tim Rice648f8762011-01-26 12:38:57 -08001170 AC_DEFINE([BROKEN_GETADDRINFO])
1171 AC_DEFINE([SETEUID_BREAKS_SETUID])
1172 AC_DEFINE([BROKEN_SETREUID])
1173 AC_DEFINE([BROKEN_SETREGID])
1174 AC_DEFINE([BROKEN_READV_COMPARISON], [1], [Can't do comparisons on readv])
Damien Millerb8c656e2000-06-28 15:22:41 +10001175 ;;
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00001176
Tim Rice70335a62006-02-04 17:42:58 -08001177*-*-nto-qnx*)
Tim Rice648f8762011-01-26 12:38:57 -08001178 AC_DEFINE([USE_PIPES])
1179 AC_DEFINE([NO_X11_UNIX_SOCKETS])
Tim Rice648f8762011-01-26 12:38:57 -08001180 AC_DEFINE([DISABLE_LASTLOG])
1181 AC_DEFINE([SSHD_ACQUIRES_CTTY])
1182 AC_DEFINE([BROKEN_SHADOW_EXPIRE], [1], [QNX shadow support is broken])
Tim Rice2f993462006-02-11 18:37:48 -08001183 enable_etc_default_login=no # has incompatible /etc/default/login
Darren Tucker8acb3b62007-08-10 14:36:12 +10001184 case "$host" in
1185 *-*-nto-qnx6*)
Tim Rice648f8762011-01-26 12:38:57 -08001186 AC_DEFINE([DISABLE_FD_PASSING])
Darren Tucker8acb3b62007-08-10 14:36:12 +10001187 ;;
1188 esac
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00001189 ;;
Darren Tucker2be1cbb2005-05-27 21:13:40 +10001190
1191*-*-ultrix*)
Tim Rice648f8762011-01-26 12:38:57 -08001192 AC_DEFINE([BROKEN_GETGROUPS], [1], [getgroups(0,NULL) will return -1])
Tim Rice648f8762011-01-26 12:38:57 -08001193 AC_DEFINE([NEED_SETPGRP])
1194 AC_DEFINE([HAVE_SYS_SYSLOG_H], [1], [Force use of sys/syslog.h on Ultrix])
Tim Ricefcc7ff12005-06-02 20:28:29 -07001195 ;;
Darren Tucker93e7e8f2005-08-23 08:06:55 +10001196
1197*-*-lynxos)
Darren Tucker5faa52d2016-08-02 15:22:40 +10001198 CFLAGS="$CFLAGS -D__NO_INCLUDE_WARN__"
1199 AC_DEFINE([BROKEN_SETVBUF], [1],
1200 [LynxOS has broken setvbuf() implementation])
1201 ;;
Damien Miller76112de1999-12-21 11:18:08 +11001202esac
1203
Tim Rice648f8762011-01-26 12:38:57 -08001204AC_MSG_CHECKING([compiler and flags for sanity])
1205AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]], [[ exit(0); ]])],
1206 [ AC_MSG_RESULT([yes]) ],
Darren Tucker6eb93042003-06-29 21:30:41 +10001207 [
Tim Rice648f8762011-01-26 12:38:57 -08001208 AC_MSG_RESULT([no])
Darren Tucker6eb93042003-06-29 21:30:41 +10001209 AC_MSG_ERROR([*** compiler cannot create working executables, check config.log ***])
Darren Tuckera0c2b392004-09-11 23:26:37 +10001210 ],
1211 [ AC_MSG_WARN([cross compiling: not checking compiler sanity]) ]
Darren Tucker6eb93042003-06-29 21:30:41 +10001212)
1213
Darren Tucker0c9653f2005-05-28 15:58:14 +10001214dnl Checks for header files.
Damien Millera22ba012000-03-02 23:09:20 +11001215# Checks for libraries.
Tim Rice648f8762011-01-26 12:38:57 -08001216AC_CHECK_FUNC([setsockopt], , [AC_CHECK_LIB([socket], [setsockopt])])
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00001217
Tim Rice1e1ef642003-09-11 22:19:31 -07001218dnl IRIX and Solaris 2.5.1 have dirname() in libgen
Tim Rice648f8762011-01-26 12:38:57 -08001219AC_CHECK_FUNCS([dirname], [AC_CHECK_HEADERS([libgen.h])] , [
1220 AC_CHECK_LIB([gen], [dirname], [
Tim Rice1e1ef642003-09-11 22:19:31 -07001221 AC_CACHE_CHECK([for broken dirname],
1222 ac_cv_have_broken_dirname, [
1223 save_LIBS="$LIBS"
1224 LIBS="$LIBS -lgen"
Darren Tucker314d89e2005-10-17 23:29:23 +10001225 AC_RUN_IFELSE(
1226 [AC_LANG_SOURCE([[
Tim Rice1e1ef642003-09-11 22:19:31 -07001227#include <libgen.h>
1228#include <string.h>
1229
1230int main(int argc, char **argv) {
1231 char *s, buf[32];
1232
1233 strncpy(buf,"/etc", 32);
1234 s = dirname(buf);
1235 if (!s || strncmp(s, "/", 32) != 0) {
1236 exit(1);
1237 } else {
1238 exit(0);
1239 }
1240}
Darren Tucker314d89e2005-10-17 23:29:23 +10001241 ]])],
Tim Rice1e1ef642003-09-11 22:19:31 -07001242 [ ac_cv_have_broken_dirname="no" ],
Darren Tucker314d89e2005-10-17 23:29:23 +10001243 [ ac_cv_have_broken_dirname="yes" ],
1244 [ ac_cv_have_broken_dirname="no" ],
Tim Rice1e1ef642003-09-11 22:19:31 -07001245 )
1246 LIBS="$save_LIBS"
1247 ])
1248 if test "x$ac_cv_have_broken_dirname" = "xno" ; then
1249 LIBS="$LIBS -lgen"
Tim Rice648f8762011-01-26 12:38:57 -08001250 AC_DEFINE([HAVE_DIRNAME])
1251 AC_CHECK_HEADERS([libgen.h])
Tim Rice1e1ef642003-09-11 22:19:31 -07001252 fi
1253 ])
1254])
1255
Tim Rice648f8762011-01-26 12:38:57 -08001256AC_CHECK_FUNC([getspnam], ,
1257 [AC_CHECK_LIB([gen], [getspnam], [LIBS="$LIBS -lgen"])])
1258AC_SEARCH_LIBS([basename], [gen], [AC_DEFINE([HAVE_BASENAME], [1],
1259 [Define if you have the basename function.])])
Tim Rice1e1ef642003-09-11 22:19:31 -07001260
Tim Rice13aae5e2001-10-21 17:53:58 -07001261dnl zlib is required
Tim Rice648f8762011-01-26 12:38:57 -08001262AC_ARG_WITH([zlib],
Tim Rice13aae5e2001-10-21 17:53:58 -07001263 [ --with-zlib=PATH Use zlib in PATH],
Darren Tucker86a5f8d2005-03-21 09:55:17 +11001264 [ if test "x$withval" = "xno" ; then
1265 AC_MSG_ERROR([*** zlib is required ***])
1266 elif test "x$withval" != "xyes"; then
Tim Rice13aae5e2001-10-21 17:53:58 -07001267 if test -d "$withval/lib"; then
1268 if test -n "${need_dash_r}"; then
Tim Rice02cebcd2001-10-25 10:01:30 -07001269 LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001270 else
Tim Rice02cebcd2001-10-25 10:01:30 -07001271 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001272 fi
1273 else
1274 if test -n "${need_dash_r}"; then
Tim Rice02cebcd2001-10-25 10:01:30 -07001275 LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001276 else
Tim Rice02cebcd2001-10-25 10:01:30 -07001277 LDFLAGS="-L${withval} ${LDFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001278 fi
1279 fi
1280 if test -d "$withval/include"; then
Tim Rice02cebcd2001-10-25 10:01:30 -07001281 CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001282 else
Tim Rice02cebcd2001-10-25 10:01:30 -07001283 CPPFLAGS="-I${withval} ${CPPFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001284 fi
Darren Tucker86a5f8d2005-03-21 09:55:17 +11001285 fi ]
Tim Rice13aae5e2001-10-21 17:53:58 -07001286)
1287
Tim Rice648f8762011-01-26 12:38:57 -08001288AC_CHECK_HEADER([zlib.h], ,[AC_MSG_ERROR([*** zlib.h missing - please install first or check config.log ***])])
1289AC_CHECK_LIB([z], [deflate], ,
Tim Ricefcb62202004-01-23 18:35:16 -08001290 [
1291 saved_CPPFLAGS="$CPPFLAGS"
1292 saved_LDFLAGS="$LDFLAGS"
1293 save_LIBS="$LIBS"
1294 dnl Check default zlib install dir
1295 if test -n "${need_dash_r}"; then
1296 LDFLAGS="-L/usr/local/lib -R/usr/local/lib ${saved_LDFLAGS}"
1297 else
1298 LDFLAGS="-L/usr/local/lib ${saved_LDFLAGS}"
1299 fi
1300 CPPFLAGS="-I/usr/local/include ${saved_CPPFLAGS}"
1301 LIBS="$LIBS -lz"
Tim Rice648f8762011-01-26 12:38:57 -08001302 AC_TRY_LINK_FUNC([deflate], [AC_DEFINE([HAVE_LIBZ])],
Tim Ricefcb62202004-01-23 18:35:16 -08001303 [
1304 AC_MSG_ERROR([*** zlib missing - please install first or check config.log ***])
1305 ]
1306 )
1307 ]
1308)
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001309
Tim Rice648f8762011-01-26 12:38:57 -08001310AC_ARG_WITH([zlib-version-check],
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001311 [ --without-zlib-version-check Disable zlib version check],
1312 [ if test "x$withval" = "xno" ; then
1313 zlib_check_nonfatal=1
1314 fi
1315 ]
1316)
1317
Tim Rice648f8762011-01-26 12:38:57 -08001318AC_MSG_CHECKING([for possibly buggy zlib])
1319AC_RUN_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001320#include <stdio.h>
Darren Tuckerc8a0f272013-03-22 12:49:14 +11001321#include <stdlib.h>
Darren Tucker2dcd2392004-01-23 17:13:33 +11001322#include <zlib.h>
Tim Rice648f8762011-01-26 12:38:57 -08001323 ]],
1324 [[
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001325 int a=0, b=0, c=0, d=0, n, v;
1326 n = sscanf(ZLIB_VERSION, "%d.%d.%d.%d", &a, &b, &c, &d);
1327 if (n != 3 && n != 4)
Darren Tucker2dcd2392004-01-23 17:13:33 +11001328 exit(1);
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001329 v = a*1000000 + b*10000 + c*100 + d;
1330 fprintf(stderr, "found zlib version %s (%d)\n", ZLIB_VERSION, v);
1331
1332 /* 1.1.4 is OK */
1333 if (a == 1 && b == 1 && c >= 4)
Darren Tucker2dcd2392004-01-23 17:13:33 +11001334 exit(0);
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001335
Darren Tucker41097ed2005-07-25 15:24:21 +10001336 /* 1.2.3 and up are OK */
1337 if (v >= 1020300)
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001338 exit(0);
1339
Darren Tucker2dcd2392004-01-23 17:13:33 +11001340 exit(2);
Darren Tucker623d92f2004-09-12 22:36:15 +10001341 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001342 AC_MSG_RESULT([no]),
1343 [ AC_MSG_RESULT([yes])
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001344 if test -z "$zlib_check_nonfatal" ; then
1345 AC_MSG_ERROR([*** zlib too old - check config.log ***
1346Your reported zlib version has known security problems. It's possible your
1347vendor has fixed these problems without changing the version number. If you
1348are sure this is the case, you can disable the check by running
1349"./configure --without-zlib-version-check".
Darren Tuckerac1910f2005-07-26 12:00:42 +10001350If you are in doubt, upgrade zlib to version 1.2.3 or greater.
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001351See http://www.gzip.org/zlib/ for details.])
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001352 else
1353 AC_MSG_WARN([zlib version may have security problems])
1354 fi
Darren Tuckera0c2b392004-09-11 23:26:37 +10001355 ],
1356 [ AC_MSG_WARN([cross compiling: not checking zlib version]) ]
Darren Tucker2dcd2392004-01-23 17:13:33 +11001357)
Damien Miller6f9c3372000-10-25 10:06:04 +11001358
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00001359dnl UnixWare 2.x
Tim Rice648f8762011-01-26 12:38:57 -08001360AC_CHECK_FUNC([strcasecmp],
1361 [], [ AC_CHECK_LIB([resolv], [strcasecmp], [LIBS="$LIBS -lresolv"]) ]
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00001362)
Tim Rice648f8762011-01-26 12:38:57 -08001363AC_CHECK_FUNCS([utimes],
1364 [], [ AC_CHECK_LIB([c89], [utimes], [AC_DEFINE([HAVE_UTIMES])
Tim Ricecbb90662002-07-08 19:17:10 -07001365 LIBS="$LIBS -lc89"]) ]
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00001366)
Damien Millerab18c411999-11-11 10:40:23 +11001367
Tim Ricee589a292001-11-03 11:09:32 -08001368dnl Checks for libutil functions
Damien Millerb87f6b72013-02-23 09:12:23 +11001369AC_CHECK_HEADERS([bsd/libutil.h libutil.h])
Damien Miller398c0ff2012-04-19 21:46:35 +10001370AC_SEARCH_LIBS([fmt_scaled], [util bsd])
Darren Tuckere194ba42013-05-16 20:47:31 +10001371AC_SEARCH_LIBS([scan_scaled], [util bsd])
Damien Miller398c0ff2012-04-19 21:46:35 +10001372AC_SEARCH_LIBS([login], [util bsd])
1373AC_SEARCH_LIBS([logout], [util bsd])
1374AC_SEARCH_LIBS([logwtmp], [util bsd])
1375AC_SEARCH_LIBS([openpty], [util bsd])
1376AC_SEARCH_LIBS([updwtmp], [util bsd])
Darren Tuckere194ba42013-05-16 20:47:31 +10001377AC_CHECK_FUNCS([fmt_scaled scan_scaled login logout openpty updwtmp logwtmp])
Tim Ricee589a292001-11-03 11:09:32 -08001378
Darren Tucker2fee9092016-02-17 09:48:15 +11001379# On some platforms, inet_ntop and gethostbyname may be found in libresolv
1380# or libnsl.
Damien Millerab039492014-01-28 15:07:10 +11001381AC_SEARCH_LIBS([inet_ntop], [resolv nsl])
Darren Tucker2fee9092016-02-17 09:48:15 +11001382AC_SEARCH_LIBS([gethostbyname], [resolv nsl])
Damien Millerab039492014-01-28 15:07:10 +11001383
Darren Tucker74c1c362017-09-27 07:44:41 +10001384# "Particular Function Checks"
1385# see https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Particular-Functions.html
Ben Lindstrom8697e082001-02-24 21:41:10 +00001386AC_FUNC_STRFTIME
Darren Tucker74c1c362017-09-27 07:44:41 +10001387AC_FUNC_MALLOC
1388AC_FUNC_REALLOC
1389# autoconf doesn't have AC_FUNC_CALLOC so fake it if malloc returns NULL;
Darren Tuckere9dede02018-02-25 10:20:31 +11001390AC_MSG_CHECKING([if calloc(0, N) returns non-null])
1391AC_RUN_IFELSE(
1392 [AC_LANG_PROGRAM(
1393 [[ #include <stdlib.h> ]],
1394 [[ void *p = calloc(0, 1); exit(p == NULL); ]]
1395 )],
1396 [ func_calloc_0_nonnull=yes ],
1397 [ func_calloc_0_nonnull=no ],
1398 [ AC_MSG_WARN([cross compiling: assuming same as malloc])
1399 func_calloc_0_nonnull="$ac_cv_func_malloc_0_nonnull"]
1400)
1401AC_MSG_RESULT([$func_calloc_0_nonnull])
1402
Darren Tuckerd97874c2018-04-13 13:43:55 +10001403if test "x$func_calloc_0_nonnull" = "xyes"; then
Darren Tuckere9dede02018-02-25 10:20:31 +11001404 AC_DEFINE(HAVE_CALLOC, 1, [calloc(0, x) returns non-null])
1405else
1406 AC_DEFINE(HAVE_CALLOC, 0, [calloc(0, x) returns NULL])
Darren Tucker74c1c362017-09-27 07:44:41 +10001407 AC_DEFINE(calloc, rpl_calloc,
1408 [Define to rpl_calloc if the replacement function should be used.])
1409fi
Ben Lindstrom8697e082001-02-24 21:41:10 +00001410
Damien Miller3c027682001-03-14 11:39:45 +11001411# Check for ALTDIRFUNC glob() extension
Tim Rice648f8762011-01-26 12:38:57 -08001412AC_MSG_CHECKING([for GLOB_ALTDIRFUNC support])
1413AC_EGREP_CPP([FOUNDIT],
Damien Miller3c027682001-03-14 11:39:45 +11001414 [
1415 #include <glob.h>
1416 #ifdef GLOB_ALTDIRFUNC
1417 FOUNDIT
1418 #endif
Damien Millera8e06ce2003-11-21 23:48:55 +11001419 ],
Damien Miller3c027682001-03-14 11:39:45 +11001420 [
Tim Rice648f8762011-01-26 12:38:57 -08001421 AC_DEFINE([GLOB_HAS_ALTDIRFUNC], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001422 [Define if your system glob() function has
1423 the GLOB_ALTDIRFUNC extension])
Tim Rice648f8762011-01-26 12:38:57 -08001424 AC_MSG_RESULT([yes])
Damien Miller3c027682001-03-14 11:39:45 +11001425 ],
1426 [
Tim Rice648f8762011-01-26 12:38:57 -08001427 AC_MSG_RESULT([no])
Damien Miller3c027682001-03-14 11:39:45 +11001428 ]
1429)
Damien Millerab18c411999-11-11 10:40:23 +11001430
Ben Lindstrom45b14db2001-03-17 01:15:38 +00001431# Check for g.gl_matchc glob() extension
Tim Rice648f8762011-01-26 12:38:57 -08001432AC_MSG_CHECKING([for gl_matchc field in glob_t])
1433AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <glob.h> ]],
1434 [[ glob_t g; g.gl_matchc = 1; ]])],
Damien Millera8e06ce2003-11-21 23:48:55 +11001435 [
Tim Rice648f8762011-01-26 12:38:57 -08001436 AC_DEFINE([GLOB_HAS_GL_MATCHC], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001437 [Define if your system glob() function has
1438 gl_matchc options in glob_t])
Tim Rice648f8762011-01-26 12:38:57 -08001439 AC_MSG_RESULT([yes])
1440 ], [
1441 AC_MSG_RESULT([no])
1442])
Ben Lindstrom45b14db2001-03-17 01:15:38 +00001443
Damien Millera6e121a2010-10-07 21:39:17 +11001444# Check for g.gl_statv glob() extension
Tim Rice648f8762011-01-26 12:38:57 -08001445AC_MSG_CHECKING([for gl_statv and GLOB_KEEPSTAT extensions for glob])
1446AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <glob.h> ]], [[
Damien Millera6e121a2010-10-07 21:39:17 +11001447#ifndef GLOB_KEEPSTAT
1448#error "glob does not support GLOB_KEEPSTAT extension"
1449#endif
1450glob_t g;
1451g.gl_statv = NULL;
Tim Rice648f8762011-01-26 12:38:57 -08001452]])],
Damien Millera6e121a2010-10-07 21:39:17 +11001453 [
Tim Rice648f8762011-01-26 12:38:57 -08001454 AC_DEFINE([GLOB_HAS_GL_STATV], [1],
Damien Millera6e121a2010-10-07 21:39:17 +11001455 [Define if your system glob() function has
1456 gl_statv options in glob_t])
Tim Rice648f8762011-01-26 12:38:57 -08001457 AC_MSG_RESULT([yes])
1458 ], [
1459 AC_MSG_RESULT([no])
Damien Miller72ef7c12015-01-15 02:21:31 +11001460
Tim Rice648f8762011-01-26 12:38:57 -08001461])
Damien Millera6e121a2010-10-07 21:39:17 +11001462
Tim Rice648f8762011-01-26 12:38:57 -08001463AC_CHECK_DECLS([GLOB_NOMATCH], , , [#include <glob.h>])
Darren Tucker096faec2006-09-01 20:29:10 +10001464
Darren Tucker7df91b02016-07-14 12:25:24 +10001465AC_CHECK_DECL([VIS_ALL], ,
1466 AC_DEFINE(BROKEN_STRNVIS, 1, [missing VIS_ALL]), [#include <vis.h>])
1467
Damien Miller18bb4732001-03-28 14:35:30 +10001468AC_MSG_CHECKING([whether struct dirent allocates space for d_name])
Darren Tuckera0c2b392004-09-11 23:26:37 +10001469AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001470 [AC_LANG_PROGRAM([[
Damien Miller18bb4732001-03-28 14:35:30 +10001471#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08001472#include <dirent.h>]],
1473 [[
1474 struct dirent d;
1475 exit(sizeof(d.d_name)<=sizeof(char));
Darren Tucker623d92f2004-09-12 22:36:15 +10001476 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001477 [AC_MSG_RESULT([yes])],
Damien Miller18bb4732001-03-28 14:35:30 +10001478 [
Tim Rice648f8762011-01-26 12:38:57 -08001479 AC_MSG_RESULT([no])
1480 AC_DEFINE([BROKEN_ONE_BYTE_DIRENT_D_NAME], [1],
Darren Tucker79d09fa2005-11-24 22:34:54 +11001481 [Define if your struct dirent expects you to
Tim Rice7df8d392005-09-19 09:33:39 -07001482 allocate extra space for d_name])
Darren Tuckera0c2b392004-09-11 23:26:37 +10001483 ],
Tim Riceeae17cc2005-03-17 16:52:20 -08001484 [
Darren Tuckera0c2b392004-09-11 23:26:37 +10001485 AC_MSG_WARN([cross compiling: assuming BROKEN_ONE_BYTE_DIRENT_D_NAME])
Tim Rice648f8762011-01-26 12:38:57 -08001486 AC_DEFINE([BROKEN_ONE_BYTE_DIRENT_D_NAME])
Damien Miller18bb4732001-03-28 14:35:30 +10001487 ]
1488)
1489
Damien Miller36f49652004-08-15 18:40:59 +10001490AC_MSG_CHECKING([for /proc/pid/fd directory])
1491if test -d "/proc/$$/fd" ; then
Tim Rice648f8762011-01-26 12:38:57 -08001492 AC_DEFINE([HAVE_PROC_PID], [1], [Define if you have /proc/$pid/fd])
1493 AC_MSG_RESULT([yes])
Damien Miller36f49652004-08-15 18:40:59 +10001494else
Tim Rice648f8762011-01-26 12:38:57 -08001495 AC_MSG_RESULT([no])
Damien Miller36f49652004-08-15 18:40:59 +10001496fi
1497
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001498# Check whether user wants to use ldns
1499LDNS_MSG="no"
1500AC_ARG_WITH(ldns,
1501 [ --with-ldns[[=PATH]] Use ldns for DNSSEC support (optionally in PATH)],
Damien Miller523db852017-02-03 16:01:22 +11001502 [
1503 ldns=""
1504 if test "x$withval" = "xyes" ; then
1505 AC_PATH_TOOL([LDNSCONFIG], [ldns-config], [no])
Darren Tuckerf001de82017-12-11 13:42:51 +11001506 if test "x$LDNSCONFIG" = "xno"; then
Damien Miller523db852017-02-03 16:01:22 +11001507 CPPFLAGS="$CPPFLAGS -I${withval}/include"
1508 LDFLAGS="$LDFLAGS -L${withval}/lib"
1509 LIBS="-lldns $LIBS"
1510 ldns=yes
1511 else
1512 LIBS="$LIBS `$LDNSCONFIG --libs`"
1513 CPPFLAGS="$CPPFLAGS `$LDNSCONFIG --cflags`"
Darren Tucker7af27bf2017-03-24 09:44:56 +11001514 ldns=yes
Damien Miller523db852017-02-03 16:01:22 +11001515 fi
1516 elif test "x$withval" != "xno" ; then
1517 CPPFLAGS="$CPPFLAGS -I${withval}/include"
1518 LDFLAGS="$LDFLAGS -L${withval}/lib"
1519 LIBS="-lldns $LIBS"
1520 ldns=yes
1521 fi
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001522
Damien Miller523db852017-02-03 16:01:22 +11001523 # Verify that it works.
1524 if test "x$ldns" = "xyes" ; then
1525 AC_DEFINE(HAVE_LDNS, 1, [Define if you want ldns support])
1526 LDNS_MSG="yes"
1527 AC_MSG_CHECKING([for ldns support])
1528 AC_LINK_IFELSE(
1529 [AC_LANG_SOURCE([[
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001530#include <stdio.h>
1531#include <stdlib.h>
1532#include <stdint.h>
1533#include <ldns/ldns.h>
1534int main() { ldns_status status = ldns_verify_trusted(NULL, NULL, NULL, NULL); status=LDNS_STATUS_OK; exit(0); }
Damien Miller523db852017-02-03 16:01:22 +11001535 ]])
1536 ],
1537 [AC_MSG_RESULT(yes)],
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001538 [
1539 AC_MSG_RESULT(no)
1540 AC_MSG_ERROR([** Incomplete or missing ldns libraries.])
1541 ])
Damien Miller523db852017-02-03 16:01:22 +11001542 fi
1543])
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001544
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001545# Check whether user wants libedit support
1546LIBEDIT_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08001547AC_ARG_WITH([libedit],
Darren Tucker1b6f2292005-02-11 16:11:49 +11001548 [ --with-libedit[[=PATH]] Enable libedit support for sftp],
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001549 [ if test "x$withval" != "xno" ; then
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001550 if test "x$withval" = "xyes" ; then
Darren Tucker59353892012-05-19 15:24:37 +10001551 AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no])
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001552 if test "x$PKGCONFIG" != "xno"; then
Tim Rice648f8762011-01-26 12:38:57 -08001553 AC_MSG_CHECKING([if $PKGCONFIG knows about libedit])
Tim Ricee1d93702016-05-31 11:13:22 -07001554 if "$PKGCONFIG" libedit; then
Tim Rice648f8762011-01-26 12:38:57 -08001555 AC_MSG_RESULT([yes])
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001556 use_pkgconfig_for_libedit=yes
1557 else
Tim Rice648f8762011-01-26 12:38:57 -08001558 AC_MSG_RESULT([no])
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001559 fi
1560 fi
1561 else
Darren Tuckerc373a562005-09-22 20:15:08 +10001562 CPPFLAGS="$CPPFLAGS -I${withval}/include"
1563 if test -n "${need_dash_r}"; then
1564 LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
1565 else
1566 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
1567 fi
Darren Tucker1df61452005-03-21 09:58:07 +11001568 fi
Damien Miller1f789802010-10-11 22:35:22 +11001569 if test "x$use_pkgconfig_for_libedit" = "xyes"; then
Darren Tucker8369c8e2013-12-05 11:00:16 +11001570 LIBEDIT=`$PKGCONFIG --libs libedit`
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001571 CPPFLAGS="$CPPFLAGS `$PKGCONFIG --cflags libedit`"
1572 else
1573 LIBEDIT="-ledit -lcurses"
1574 fi
1575 OTHERLIBS=`echo $LIBEDIT | sed 's/-ledit//'`
Tim Rice648f8762011-01-26 12:38:57 -08001576 AC_CHECK_LIB([edit], [el_init],
1577 [ AC_DEFINE([USE_LIBEDIT], [1], [Use libedit for sftp])
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001578 LIBEDIT_MSG="yes"
Tim Rice648f8762011-01-26 12:38:57 -08001579 AC_SUBST([LIBEDIT])
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001580 ],
Tim Rice648f8762011-01-26 12:38:57 -08001581 [ AC_MSG_ERROR([libedit not found]) ],
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001582 [ $OTHERLIBS ]
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001583 )
Tim Rice648f8762011-01-26 12:38:57 -08001584 AC_MSG_CHECKING([if libedit version is compatible])
Tim Ricec1819c82005-08-15 17:48:40 -07001585 AC_COMPILE_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001586 [AC_LANG_PROGRAM([[ #include <histedit.h> ]],
1587 [[
Darren Tuckerc7572b22005-08-10 20:34:15 +10001588 int i = H_SETSIZE;
1589 el_init("", NULL, NULL, NULL);
1590 exit(0);
Tim Ricec1819c82005-08-15 17:48:40 -07001591 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001592 [ AC_MSG_RESULT([yes]) ],
1593 [ AC_MSG_RESULT([no])
1594 AC_MSG_ERROR([libedit version is not compatible]) ]
Darren Tuckerc7572b22005-08-10 20:34:15 +10001595 )
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001596 fi ]
1597)
1598
Darren Tuckerd9f88912005-02-20 21:01:48 +11001599AUDIT_MODULE=none
Tim Rice648f8762011-01-26 12:38:57 -08001600AC_ARG_WITH([audit],
Darren Tuckerea52a822011-01-17 21:15:27 +11001601 [ --with-audit=module Enable audit support (modules=debug,bsm,linux)],
Darren Tuckerd9f88912005-02-20 21:01:48 +11001602 [
Tim Rice648f8762011-01-26 12:38:57 -08001603 AC_MSG_CHECKING([for supported audit module])
Darren Tuckerd9f88912005-02-20 21:01:48 +11001604 case "$withval" in
1605 bsm)
Tim Rice648f8762011-01-26 12:38:57 -08001606 AC_MSG_RESULT([bsm])
Darren Tuckerd9f88912005-02-20 21:01:48 +11001607 AUDIT_MODULE=bsm
1608 dnl Checks for headers, libs and functions
Tim Rice648f8762011-01-26 12:38:57 -08001609 AC_CHECK_HEADERS([bsm/audit.h], [],
1610 [AC_MSG_ERROR([BSM enabled and bsm/audit.h not found])],
Darren Tucker6d0d6fb2006-09-09 01:05:21 +10001611 [
1612#ifdef HAVE_TIME_H
1613# include <time.h>
1614#endif
1615 ]
1616)
Tim Rice648f8762011-01-26 12:38:57 -08001617 AC_CHECK_LIB([bsm], [getaudit], [],
1618 [AC_MSG_ERROR([BSM enabled and required library not found])])
1619 AC_CHECK_FUNCS([getaudit], [],
1620 [AC_MSG_ERROR([BSM enabled and required function not found])])
Darren Tuckerd9f88912005-02-20 21:01:48 +11001621 # These are optional
Tim Rice648f8762011-01-26 12:38:57 -08001622 AC_CHECK_FUNCS([getaudit_addr aug_get_machine])
1623 AC_DEFINE([USE_BSM_AUDIT], [1], [Use BSM audit module])
Darren Tucker1fcec9d2013-12-19 11:00:12 +11001624 if test "$sol2ver" -ge 11; then
Tim Ricee1d93702016-05-31 11:13:22 -07001625 SSHDLIBS="$SSHDLIBS -lscf"
1626 AC_DEFINE([BROKEN_BSM_API], [1],
1627 [The system has incomplete BSM API])
Darren Tucker93a2d412012-02-24 10:40:41 +11001628 fi
Darren Tuckerd9f88912005-02-20 21:01:48 +11001629 ;;
Darren Tuckerea52a822011-01-17 21:15:27 +11001630 linux)
Tim Rice648f8762011-01-26 12:38:57 -08001631 AC_MSG_RESULT([linux])
Darren Tuckerea52a822011-01-17 21:15:27 +11001632 AUDIT_MODULE=linux
1633 dnl Checks for headers, libs and functions
Tim Rice648f8762011-01-26 12:38:57 -08001634 AC_CHECK_HEADERS([libaudit.h])
Darren Tuckerea52a822011-01-17 21:15:27 +11001635 SSHDLIBS="$SSHDLIBS -laudit"
Tim Rice648f8762011-01-26 12:38:57 -08001636 AC_DEFINE([USE_LINUX_AUDIT], [1], [Use Linux audit module])
Darren Tuckerea52a822011-01-17 21:15:27 +11001637 ;;
Darren Tuckerd9f88912005-02-20 21:01:48 +11001638 debug)
1639 AUDIT_MODULE=debug
Tim Rice648f8762011-01-26 12:38:57 -08001640 AC_MSG_RESULT([debug])
1641 AC_DEFINE([SSH_AUDIT_EVENTS], [1], [Use audit debugging module])
Darren Tuckerd9f88912005-02-20 21:01:48 +11001642 ;;
Tim Rice8bc6b902005-08-09 10:09:53 -07001643 no)
Tim Rice648f8762011-01-26 12:38:57 -08001644 AC_MSG_RESULT([no])
Tim Rice8bc6b902005-08-09 10:09:53 -07001645 ;;
Darren Tuckerd9f88912005-02-20 21:01:48 +11001646 *)
1647 AC_MSG_ERROR([Unknown audit module $withval])
1648 ;;
1649 esac ]
1650)
1651
Darren Tucker096118d2014-01-21 12:48:51 +11001652AC_ARG_WITH([pie],
Damien Miller76c04802015-01-13 19:38:18 +11001653 [ --with-pie Build Position Independent Executables if possible], [
Darren Tucker096118d2014-01-21 12:48:51 +11001654 if test "x$withval" = "xno"; then
Damien Miller852472a2014-01-22 16:31:18 +11001655 use_pie=no
Darren Tucker096118d2014-01-21 12:48:51 +11001656 fi
1657 if test "x$withval" = "xyes"; then
Damien Miller852472a2014-01-22 16:31:18 +11001658 use_pie=yes
Darren Tucker096118d2014-01-21 12:48:51 +11001659 fi
1660 ]
1661)
Damien Miller852472a2014-01-22 16:31:18 +11001662if test "x$use_pie" = "x"; then
1663 use_pie=no
1664fi
1665if test "x$use_toolchain_hardening" != "x1" && test "x$use_pie" = "xauto"; then
1666 # Turn off automatic PIE when toolchain hardening is off.
1667 use_pie=no
1668fi
Damien Millerc161fc92014-01-29 21:01:33 +11001669if test "x$use_pie" = "xauto"; then
Damien Miller852472a2014-01-22 16:31:18 +11001670 # Automatic PIE requires gcc >= 4.x
1671 AC_MSG_CHECKING([for gcc >= 4.x])
1672 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1673#if !defined(__GNUC__) || __GNUC__ < 4
1674#error gcc is too old
1675#endif
1676]])],
1677 [ AC_MSG_RESULT([yes]) ],
1678 [ AC_MSG_RESULT([no])
1679 use_pie=no ]
1680)
1681fi
1682if test "x$use_pie" != "xno"; then
Damien Miller5c2ff5e2014-01-22 21:30:12 +11001683 SAVED_CFLAGS="$CFLAGS"
1684 SAVED_LDFLAGS="$LDFLAGS"
Darren Tucker096118d2014-01-21 12:48:51 +11001685 OSSH_CHECK_CFLAG_COMPILE([-fPIE])
1686 OSSH_CHECK_LDFLAG_LINK([-pie])
Damien Miller5c2ff5e2014-01-22 21:30:12 +11001687 # We use both -fPIE and -pie or neither.
1688 AC_MSG_CHECKING([whether both -fPIE and -pie are supported])
1689 if echo "x $CFLAGS" | grep ' -fPIE' >/dev/null 2>&1 && \
1690 echo "x $LDFLAGS" | grep ' -pie' >/dev/null 2>&1 ; then
1691 AC_MSG_RESULT([yes])
1692 else
1693 AC_MSG_RESULT([no])
1694 CFLAGS="$SAVED_CFLAGS"
1695 LDFLAGS="$SAVED_LDFLAGS"
1696 fi
Darren Tucker096118d2014-01-21 12:48:51 +11001697fi
1698
Damien Millerfe1f1432003-02-24 15:45:42 +11001699dnl Checks for library functions. Please keep in alphabetical order
Tim Rice648f8762011-01-26 12:38:57 -08001700AC_CHECK_FUNCS([ \
Damien Miller1ff130d2013-12-07 11:51:51 +11001701 Blowfish_initstate \
1702 Blowfish_expandstate \
1703 Blowfish_expand0state \
1704 Blowfish_stream2word \
Damien Miller57f39152005-11-24 19:58:19 +11001705 asprintf \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001706 b64_ntop \
1707 __b64_ntop \
1708 b64_pton \
1709 __b64_pton \
1710 bcopy \
Damien Millera9134422013-12-07 11:35:36 +11001711 bcrypt_pbkdf \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001712 bindresvport_sa \
Damien Miller1ff130d2013-12-07 11:51:51 +11001713 blf_enc \
Darren Tuckera9004422018-02-24 20:25:22 +11001714 bzero \
Damien Millerc96d8532014-01-25 13:12:28 +11001715 cap_rights_limit \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001716 clock \
1717 closefrom \
1718 dirfd \
Darren Tuckerefdf5342013-05-30 08:29:08 +10001719 endgrent \
Darren Tucker6310ef22016-07-13 14:42:35 +10001720 err \
1721 errx \
Damien Miller1d2c4562014-02-04 11:18:20 +11001722 explicit_bzero \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001723 fchmod \
1724 fchown \
Darren Tuckercd3ab572018-02-26 14:37:06 +11001725 flock \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001726 freeaddrinfo \
Damien Millerb7956912017-09-19 12:29:23 +10001727 freezero \
Darren Tuckera5cf1e22014-01-17 18:10:58 +11001728 fstatfs \
Darren Tucker598eaa62008-06-09 03:32:29 +10001729 fstatvfs \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001730 futimes \
1731 getaddrinfo \
1732 getcwd \
1733 getgrouplist \
Darren Tucker6301e6c2018-07-02 21:16:58 +10001734 getline \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001735 getnameinfo \
1736 getopt \
Damien Miller151c6e42017-06-01 15:25:13 +10001737 getpagesize \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001738 getpeereid \
Darren Tucker164aa302007-03-21 21:39:57 +11001739 getpeerucred \
Darren Tucker3c4a24c2013-02-15 11:41:35 +11001740 getpgid \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001741 _getpty \
1742 getrlimit \
Damien Millerafa6e792018-04-13 13:31:42 +10001743 getrandom \
Darren Tuckerb39593a2018-02-25 13:25:15 +11001744 getsid \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001745 getttyent \
1746 glob \
Darren Tucker909a3902010-01-15 12:38:30 +11001747 group_from_gid \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001748 inet_aton \
1749 inet_ntoa \
1750 inet_ntop \
1751 innetgr \
Darren Tuckerd38f05d2017-03-20 13:38:27 +11001752 llabs \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001753 login_getcapbool \
1754 md5_crypt \
1755 memmove \
Damien Miller3d673d12014-08-27 06:32:01 +10001756 memset_s \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001757 mkdtemp \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001758 ngetaddrinfo \
1759 nsleep \
1760 ogetaddrinfo \
1761 openlog_r \
Darren Tucker3ddd15e2015-11-30 07:23:53 +11001762 pledge \
Darren Tuckerfebf0f52007-06-25 22:15:12 +10001763 poll \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001764 prctl \
1765 pstat \
Darren Tucker6c8c9a62018-02-24 20:46:37 +11001766 raise \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001767 readpassphrase \
Darren Tucker642652d2014-12-10 01:32:23 +11001768 reallocarray \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001769 recvmsg \
Damien Miller151c6e42017-06-01 15:25:13 +10001770 recallocarray \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001771 rresvport_af \
1772 sendmsg \
1773 setdtablesize \
1774 setegid \
1775 setenv \
1776 seteuid \
Darren Tucker909a3902010-01-15 12:38:30 +11001777 setgroupent \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001778 setgroups \
Darren Tucker34f702a2012-07-04 08:50:09 +10001779 setlinebuf \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001780 setlogin \
Darren Tucker909a3902010-01-15 12:38:30 +11001781 setpassent\
Darren Tucker0c9653f2005-05-28 15:58:14 +10001782 setpcred \
1783 setproctitle \
1784 setregid \
1785 setreuid \
1786 setrlimit \
1787 setsid \
1788 setvbuf \
1789 sigaction \
1790 sigvec \
1791 snprintf \
1792 socketpair \
Darren Tucker5b2e2ba2008-06-08 09:25:28 +10001793 statfs \
1794 statvfs \
Darren Tuckerafec0772016-12-13 10:23:03 +11001795 strcasestr \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001796 strdup \
1797 strerror \
1798 strlcat \
1799 strlcpy \
1800 strmode \
Darren Tucker33561e62018-03-03 14:56:09 +11001801 strndup \
Darren Tuckerb54f50e2011-09-29 23:17:18 +10001802 strnlen \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001803 strnvis \
Darren Tuckeraa74f672010-08-16 13:15:23 +10001804 strptime \
Darren Tucker44fc3342017-09-25 09:48:10 +10001805 strsignal \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001806 strtonum \
Darren Tucker81eb5d52005-06-01 21:39:33 +10001807 strtoll \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001808 strtoul \
Darren Tucker8e6fb782013-02-15 12:13:01 +11001809 strtoull \
Damien Miller34a17692007-06-11 14:15:42 +10001810 swap32 \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001811 sysconf \
1812 tcgetpgrp \
Damien Milleraa180632010-10-07 21:25:27 +11001813 timingsafe_bcmp \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001814 truncate \
1815 unsetenv \
1816 updwtmpx \
Darren Tucker909a3902010-01-15 12:38:30 +11001817 user_from_uid \
Damien Millerf4db77d2013-03-15 10:34:25 +11001818 usleep \
Damien Miller57f39152005-11-24 19:58:19 +11001819 vasprintf \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001820 vsnprintf \
1821 waitpid \
Darren Tucker6310ef22016-07-13 14:42:35 +10001822 warn \
Tim Rice648f8762011-01-26 12:38:57 -08001823])
Tim Rice13aae5e2001-10-21 17:53:58 -07001824
Darren Tuckera9004422018-02-24 20:25:22 +11001825AC_CHECK_DECLS([bzero])
1826
Darren Tuckerc61d5ec2017-02-03 14:10:34 +11001827dnl Wide character support.
Darren Tuckera2333582016-07-14 10:59:09 +10001828AC_CHECK_FUNCS([mblen mbtowc nl_langinfo wcwidth])
Darren Tuckera2333582016-07-14 10:59:09 +10001829
Darren Tucker10e290e2016-12-13 13:51:32 +11001830TEST_SSH_UTF8=${TEST_SSH_UTF8:=yes}
Darren Tucker47b8c992016-12-08 15:48:34 +11001831AC_MSG_CHECKING([for utf8 locale support])
1832AC_RUN_IFELSE(
1833 [AC_LANG_PROGRAM([[
1834#include <locale.h>
Darren Tuckerc3599502016-12-09 12:52:02 +11001835#include <stdlib.h>
Darren Tucker47b8c992016-12-08 15:48:34 +11001836 ]], [[
1837 char *loc = setlocale(LC_CTYPE, "en_US.UTF-8");
1838 if (loc != NULL)
1839 exit(0);
1840 exit(1);
1841 ]])],
1842 AC_MSG_RESULT(yes),
1843 [AC_MSG_RESULT(no)
1844 TEST_SSH_UTF8=no],
1845 AC_MSG_WARN([cross compiling: assuming yes])
1846)
1847
Tim Ricec7a8af02010-11-08 14:26:23 -08001848AC_LINK_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001849 [AC_LANG_PROGRAM(
1850 [[ #include <ctype.h> ]],
1851 [[ return (isblank('a')); ]])],
1852 [AC_DEFINE([HAVE_ISBLANK], [1], [Define if you have isblank(3C).])
Tim Ricec7a8af02010-11-08 14:26:23 -08001853])
1854
Damien Miller5fbe93f2016-07-15 13:54:31 +10001855disable_pkcs11=
1856AC_ARG_ENABLE([pkcs11],
1857 [ --disable-pkcs11 disable PKCS#11 support code [no]],
1858 [
1859 if test "x$enableval" = "xno" ; then
1860 disable_pkcs11=1
1861 fi
1862 ]
1863)
1864
Damien Miller72ef7c12015-01-15 02:21:31 +11001865# PKCS11 depends on OpenSSL.
Damien Miller5fbe93f2016-07-15 13:54:31 +10001866if test "x$openssl" = "xyes" && test "x$disable_pkcs11" = "x"; then
Damien Miller72ef7c12015-01-15 02:21:31 +11001867 # PKCS#11 support requires dlopen() and co
1868 AC_SEARCH_LIBS([dlopen], [dl],
Darren Tucker146c3bd2018-02-26 12:51:29 +11001869 AC_CHECK_DECL([RTLD_NOW],
1870 AC_DEFINE([ENABLE_PKCS11], [], [Enable for PKCS#11 support]),
1871 [], [#include <dlfcn.h>]
1872 )
Damien Miller72ef7c12015-01-15 02:21:31 +11001873 )
1874fi
Damien Millerb3c9f782010-02-12 10:11:34 +11001875
Darren Tuckerd5e082f2003-09-22 12:08:23 +10001876# IRIX has a const char return value for gai_strerror()
Tim Rice648f8762011-01-26 12:38:57 -08001877AC_CHECK_FUNCS([gai_strerror], [
1878 AC_DEFINE([HAVE_GAI_STRERROR])
1879 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckerd5e082f2003-09-22 12:08:23 +10001880#include <sys/types.h>
1881#include <sys/socket.h>
1882#include <netdb.h>
1883
Tim Rice648f8762011-01-26 12:38:57 -08001884const char *gai_strerror(int);
1885 ]], [[
1886 char *str;
1887 str = gai_strerror(0);
1888 ]])], [
1889 AC_DEFINE([HAVE_CONST_GAI_STRERROR_PROTO], [1],
1890 [Define if gai_strerror() returns const char *])], [])])
Darren Tuckerd5e082f2003-09-22 12:08:23 +10001891
Tim Rice648f8762011-01-26 12:38:57 -08001892AC_SEARCH_LIBS([nanosleep], [rt posix4], [AC_DEFINE([HAVE_NANOSLEEP], [1],
1893 [Some systems put nanosleep outside of libc])])
Damien Millercd6853c2003-01-28 11:33:42 +11001894
Darren Tuckera7108912013-06-02 08:18:31 +10001895AC_SEARCH_LIBS([clock_gettime], [rt],
1896 [AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Have clock_gettime])])
1897
Darren Tuckerf1159b52003-07-07 19:44:01 +10001898dnl Make sure prototypes are defined for these before using them.
Tim Rice648f8762011-01-26 12:38:57 -08001899AC_CHECK_DECL([strsep],
1900 [AC_CHECK_FUNCS([strsep])],
Darren Tucker390b6d52005-05-28 16:54:36 +10001901 [],
1902 [
1903#ifdef HAVE_STRING_H
1904# include <string.h>
1905#endif
1906 ])
Ben Lindstrom3e006472002-10-16 00:24:03 +00001907
Darren Tuckerb2427c82003-09-10 15:22:44 +10001908dnl tcsendbreak might be a macro
Tim Rice648f8762011-01-26 12:38:57 -08001909AC_CHECK_DECL([tcsendbreak],
1910 [AC_DEFINE([HAVE_TCSENDBREAK])],
1911 [AC_CHECK_FUNCS([tcsendbreak])],
Darren Tuckerb2427c82003-09-10 15:22:44 +10001912 [#include <termios.h>]
1913)
1914
Tim Rice648f8762011-01-26 12:38:57 -08001915AC_CHECK_DECLS([h_errno], , ,[#include <netdb.h>])
Darren Tucker5bb14002004-04-23 18:53:10 +10001916
Tim Rice648f8762011-01-26 12:38:57 -08001917AC_CHECK_DECLS([SHUT_RD], , ,
Darren Tucker128a0892006-07-12 19:02:56 +10001918 [
1919#include <sys/types.h>
1920#include <sys/socket.h>
1921 ])
Darren Tucker248469b2006-07-12 14:14:31 +10001922
Tim Rice648f8762011-01-26 12:38:57 -08001923AC_CHECK_DECLS([O_NONBLOCK], , ,
Darren Tucker248469b2006-07-12 14:14:31 +10001924 [
1925#include <sys/types.h>
1926#ifdef HAVE_SYS_STAT_H
1927# include <sys/stat.h>
1928#endif
1929#ifdef HAVE_FCNTL_H
1930# include <fcntl.h>
1931#endif
1932 ])
1933
Darren Tucker2eb40412018-02-24 21:06:48 +11001934AC_CHECK_DECLS([readv, writev], , , [
Darren Tuckered0b5922006-09-03 22:44:49 +10001935#include <sys/types.h>
1936#include <sys/uio.h>
1937#include <unistd.h>
1938 ])
1939
Tim Rice648f8762011-01-26 12:38:57 -08001940AC_CHECK_DECLS([MAXSYMLINKS], , , [
Darren Tucker6d862a52007-04-29 14:39:02 +10001941#include <sys/param.h>
1942 ])
1943
Tim Rice648f8762011-01-26 12:38:57 -08001944AC_CHECK_DECLS([offsetof], , , [
Darren Tuckerdca0edf2007-04-29 15:06:44 +10001945#include <stddef.h>
1946 ])
1947
Darren Tuckerc7aad002013-06-02 07:18:47 +10001948# extra bits for select(2)
1949AC_CHECK_DECLS([howmany, NFDBITS], [], [], [[
1950#include <sys/param.h>
1951#include <sys/types.h>
1952#ifdef HAVE_SYS_SYSMACROS_H
1953#include <sys/sysmacros.h>
1954#endif
1955#ifdef HAVE_SYS_SELECT_H
1956#include <sys/select.h>
1957#endif
1958#ifdef HAVE_SYS_TIME_H
1959#include <sys/time.h>
1960#endif
1961#ifdef HAVE_UNISTD_H
1962#include <unistd.h>
1963#endif
1964 ]])
1965AC_CHECK_TYPES([fd_mask], [], [], [[
1966#include <sys/param.h>
1967#include <sys/types.h>
1968#ifdef HAVE_SYS_SELECT_H
1969#include <sys/select.h>
1970#endif
1971#ifdef HAVE_SYS_TIME_H
1972#include <sys/time.h>
1973#endif
1974#ifdef HAVE_UNISTD_H
1975#include <unistd.h>
1976#endif
1977 ]])
1978
Tim Rice648f8762011-01-26 12:38:57 -08001979AC_CHECK_FUNCS([setresuid], [
Darren Tucker2a6b0292003-12-31 14:59:17 +11001980 dnl Some platorms have setresuid that isn't implemented, test for this
Tim Rice648f8762011-01-26 12:38:57 -08001981 AC_MSG_CHECKING([if setresuid seems to work])
Darren Tucker623d92f2004-09-12 22:36:15 +10001982 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001983 [AC_LANG_PROGRAM([[
Darren Tuckere937be32003-12-17 18:53:26 +11001984#include <stdlib.h>
1985#include <errno.h>
Tim Rice648f8762011-01-26 12:38:57 -08001986 ]], [[
1987 errno=0;
1988 setresuid(0,0,0);
1989 if (errno==ENOSYS)
1990 exit(1);
1991 else
1992 exit(0);
Darren Tucker623d92f2004-09-12 22:36:15 +10001993 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001994 [AC_MSG_RESULT([yes])],
1995 [AC_DEFINE([BROKEN_SETRESUID], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001996 [Define if your setresuid() is broken])
Tim Rice648f8762011-01-26 12:38:57 -08001997 AC_MSG_RESULT([not implemented])],
Darren Tuckera0c2b392004-09-11 23:26:37 +10001998 [AC_MSG_WARN([cross compiling: not checking setresuid])]
Darren Tucker2a6b0292003-12-31 14:59:17 +11001999 )
2000])
Darren Tuckere937be32003-12-17 18:53:26 +11002001
Tim Rice648f8762011-01-26 12:38:57 -08002002AC_CHECK_FUNCS([setresgid], [
Darren Tucker2a6b0292003-12-31 14:59:17 +11002003 dnl Some platorms have setresgid that isn't implemented, test for this
Tim Rice648f8762011-01-26 12:38:57 -08002004 AC_MSG_CHECKING([if setresgid seems to work])
Darren Tucker623d92f2004-09-12 22:36:15 +10002005 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002006 [AC_LANG_PROGRAM([[
Darren Tuckere937be32003-12-17 18:53:26 +11002007#include <stdlib.h>
2008#include <errno.h>
Tim Rice648f8762011-01-26 12:38:57 -08002009 ]], [[
2010 errno=0;
2011 setresgid(0,0,0);
2012 if (errno==ENOSYS)
2013 exit(1);
2014 else
2015 exit(0);
Darren Tucker623d92f2004-09-12 22:36:15 +10002016 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08002017 [AC_MSG_RESULT([yes])],
2018 [AC_DEFINE([BROKEN_SETRESGID], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07002019 [Define if your setresgid() is broken])
Tim Rice648f8762011-01-26 12:38:57 -08002020 AC_MSG_RESULT([not implemented])],
Darren Tuckera0c2b392004-09-11 23:26:37 +10002021 [AC_MSG_WARN([cross compiling: not checking setresuid])]
Darren Tucker2a6b0292003-12-31 14:59:17 +11002022 )
2023])
Darren Tuckere937be32003-12-17 18:53:26 +11002024
Darren Tuckerd3e2aee2015-07-17 12:52:34 +10002025AC_CHECK_FUNCS([realpath], [
2026 dnl the sftp v3 spec says SSH_FXP_REALPATH will "canonicalize any given
2027 dnl path name", however some implementations of realpath (and some
2028 dnl versions of the POSIX spec) do not work on non-existent files,
2029 dnl so we use the OpenBSD implementation on those platforms.
2030 AC_MSG_CHECKING([if realpath works with non-existent files])
2031 AC_RUN_IFELSE(
2032 [AC_LANG_PROGRAM([[
2033#include <limits.h>
2034#include <stdlib.h>
2035#include <errno.h>
2036 ]], [[
2037 char buf[PATH_MAX];
2038 if (realpath("/opensshnonexistentfilename1234", buf) == NULL)
2039 if (errno == ENOENT)
2040 exit(1);
2041 exit(0);
2042 ]])],
2043 [AC_MSG_RESULT([yes])],
2044 [AC_DEFINE([BROKEN_REALPATH], [1],
2045 [realpath does not work with nonexistent files])
2046 AC_MSG_RESULT([no])],
2047 [AC_MSG_WARN([cross compiling: assuming working])]
2048 )
2049])
2050
Darren Tucker58fd4c52018-03-05 19:28:08 +11002051AC_MSG_CHECKING([for working fflush(NULL)])
2052AC_RUN_IFELSE(
2053 [AC_LANG_PROGRAM([[#include <stdio.h>]], [[fflush(NULL); exit(0);]])],
2054 AC_MSG_RESULT([yes]),
2055 [AC_MSG_RESULT([no])
2056 AC_DEFINE([FFLUSH_NULL_BUG], [1],
2057 [define if fflush(NULL) does not work])],
2058 AC_MSG_WARN([cross compiling: assuming working])
2059)
2060
Damien Millerad833b32000-08-23 10:46:23 +10002061dnl Checks for time functions
Tim Rice648f8762011-01-26 12:38:57 -08002062AC_CHECK_FUNCS([gettimeofday time])
Damien Millerad833b32000-08-23 10:46:23 +10002063dnl Checks for utmp functions
Tim Rice648f8762011-01-26 12:38:57 -08002064AC_CHECK_FUNCS([endutent getutent getutid getutline pututline setutent])
2065AC_CHECK_FUNCS([utmpname])
Damien Millerad833b32000-08-23 10:46:23 +10002066dnl Checks for utmpx functions
Tim Rice648f8762011-01-26 12:38:57 -08002067AC_CHECK_FUNCS([endutxent getutxent getutxid getutxline getutxuser pututxline])
2068AC_CHECK_FUNCS([setutxdb setutxent utmpxname])
Damien Miller20e231f2009-02-12 13:12:21 +11002069dnl Checks for lastlog functions
Tim Rice648f8762011-01-26 12:38:57 -08002070AC_CHECK_FUNCS([getlastlogxbyname])
Damien Millercedfecc1999-11-15 14:36:53 +11002071
Tim Rice648f8762011-01-26 12:38:57 -08002072AC_CHECK_FUNC([daemon],
2073 [AC_DEFINE([HAVE_DAEMON], [1], [Define if your libraries define daemon()])],
2074 [AC_CHECK_LIB([bsd], [daemon],
2075 [LIBS="$LIBS -lbsd"; AC_DEFINE([HAVE_DAEMON])])]
Damien Miller04f80141999-11-19 15:32:34 +11002076)
2077
Tim Rice648f8762011-01-26 12:38:57 -08002078AC_CHECK_FUNC([getpagesize],
2079 [AC_DEFINE([HAVE_GETPAGESIZE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07002080 [Define if your libraries define getpagesize()])],
Tim Rice648f8762011-01-26 12:38:57 -08002081 [AC_CHECK_LIB([ucb], [getpagesize],
2082 [LIBS="$LIBS -lucb"; AC_DEFINE([HAVE_GETPAGESIZE])])]
Damien Miller9fb07e42000-03-05 16:22:59 +11002083)
2084
Damien Millercb170cb2000-07-01 16:52:55 +10002085# Check for broken snprintf
2086if test "x$ac_cv_func_snprintf" = "xyes" ; then
2087 AC_MSG_CHECKING([whether snprintf correctly terminates long strings])
Darren Tuckera0c2b392004-09-11 23:26:37 +10002088 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002089 [AC_LANG_PROGRAM([[ #include <stdio.h> ]],
2090 [[
2091 char b[5];
2092 snprintf(b,5,"123456789");
Tim Ricee1d93702016-05-31 11:13:22 -07002093 exit(b[4]!='\0');
Darren Tucker623d92f2004-09-12 22:36:15 +10002094 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08002095 [AC_MSG_RESULT([yes])],
Damien Millercb170cb2000-07-01 16:52:55 +10002096 [
Tim Rice648f8762011-01-26 12:38:57 -08002097 AC_MSG_RESULT([no])
2098 AC_DEFINE([BROKEN_SNPRINTF], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07002099 [Define if your snprintf is busted])
Damien Millercb170cb2000-07-01 16:52:55 +10002100 AC_MSG_WARN([****** Your snprintf() function is broken, complain to your vendor])
Darren Tuckera0c2b392004-09-11 23:26:37 +10002101 ],
2102 [ AC_MSG_WARN([cross compiling: Assuming working snprintf()]) ]
Damien Millercb170cb2000-07-01 16:52:55 +10002103 )
2104fi
2105
Damien Millerd244a582014-08-23 17:06:49 +10002106# We depend on vsnprintf returning the right thing on overflow: the
2107# number of characters it tried to create (as per SUSv3)
2108if test "x$ac_cv_func_vsnprintf" = "xyes" ; then
Damien Miller57f39152005-11-24 19:58:19 +11002109 AC_MSG_CHECKING([whether vsnprintf returns correct values on overflow])
2110 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002111 [AC_LANG_PROGRAM([[
Damien Miller57f39152005-11-24 19:58:19 +11002112#include <sys/types.h>
2113#include <stdio.h>
2114#include <stdarg.h>
2115
Damien Millerd244a582014-08-23 17:06:49 +10002116int x_snprintf(char *str, size_t count, const char *fmt, ...)
Damien Miller57f39152005-11-24 19:58:19 +11002117{
Damien Millerd244a582014-08-23 17:06:49 +10002118 size_t ret;
2119 va_list ap;
2120
2121 va_start(ap, fmt);
2122 ret = vsnprintf(str, count, fmt, ap);
2123 va_end(ap);
Damien Miller57f39152005-11-24 19:58:19 +11002124 return ret;
2125}
Tim Rice648f8762011-01-26 12:38:57 -08002126 ]], [[
Damien Millerd244a582014-08-23 17:06:49 +10002127char x[1];
2128if (x_snprintf(x, 1, "%s %d", "hello", 12345) != 11)
2129 return 1;
2130if (x_snprintf(NULL, 0, "%s %d", "hello", 12345) != 11)
2131 return 1;
2132return 0;
Tim Rice648f8762011-01-26 12:38:57 -08002133 ]])],
2134 [AC_MSG_RESULT([yes])],
Damien Miller57f39152005-11-24 19:58:19 +11002135 [
Tim Rice648f8762011-01-26 12:38:57 -08002136 AC_MSG_RESULT([no])
2137 AC_DEFINE([BROKEN_SNPRINTF], [1],
Damien Miller57f39152005-11-24 19:58:19 +11002138 [Define if your snprintf is busted])
2139 AC_MSG_WARN([****** Your vsnprintf() function is broken, complain to your vendor])
2140 ],
2141 [ AC_MSG_WARN([cross compiling: Assuming working vsnprintf()]) ]
2142 )
2143fi
2144
Darren Tuckerd40c66c2005-12-17 22:32:03 +11002145# On systems where [v]snprintf is broken, but is declared in stdio,
2146# check that the fmt argument is const char * or just char *.
2147# This is only useful for when BROKEN_SNPRINTF
2148AC_MSG_CHECKING([whether snprintf can declare const char *fmt])
Tim Rice648f8762011-01-26 12:38:57 -08002149AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2150#include <stdio.h>
2151int snprintf(char *a, size_t b, const char *c, ...) { return 0; }
2152 ]], [[
2153 snprintf(0, 0, 0);
2154 ]])],
2155 [AC_MSG_RESULT([yes])
2156 AC_DEFINE([SNPRINTF_CONST], [const],
Darren Tuckerd40c66c2005-12-17 22:32:03 +11002157 [Define as const if snprintf() can declare const char *fmt])],
Tim Rice648f8762011-01-26 12:38:57 -08002158 [AC_MSG_RESULT([no])
2159 AC_DEFINE([SNPRINTF_CONST], [/* not const */])])
Darren Tuckerd40c66c2005-12-17 22:32:03 +11002160
Damien Millerb4097182004-05-23 14:09:40 +10002161# Check for missing getpeereid (or equiv) support
2162NO_PEERCHECK=""
Darren Tucker164aa302007-03-21 21:39:57 +11002163if test "x$ac_cv_func_getpeereid" != "xyes" -a "x$ac_cv_func_getpeerucred" != "xyes"; then
Damien Millerb4097182004-05-23 14:09:40 +10002164 AC_MSG_CHECKING([whether system supports SO_PEERCRED getsockopt])
Tim Rice648f8762011-01-26 12:38:57 -08002165 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2166#include <sys/types.h>
2167#include <sys/socket.h>]], [[int i = SO_PEERCRED;]])],
2168 [ AC_MSG_RESULT([yes])
2169 AC_DEFINE([HAVE_SO_PEERCRED], [1], [Have PEERCRED socket option])
2170 ], [AC_MSG_RESULT([no])
2171 NO_PEERCHECK=1
2172 ])
Damien Millerb4097182004-05-23 14:09:40 +10002173fi
2174
Damien Millere8328192003-01-07 15:18:32 +11002175dnl see whether mkstemp() requires XXXXXX
2176if test "x$ac_cv_func_mkdtemp" = "xyes" ; then
2177AC_MSG_CHECKING([for (overly) strict mkstemp])
Darren Tucker314d89e2005-10-17 23:29:23 +10002178AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002179 [AC_LANG_PROGRAM([[
Damien Millere8328192003-01-07 15:18:32 +11002180#include <stdlib.h>
Tim Rice648f8762011-01-26 12:38:57 -08002181 ]], [[
2182 char template[]="conftest.mkstemp-test";
2183 if (mkstemp(template) == -1)
2184 exit(1);
2185 unlink(template);
2186 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10002187 ]])],
Damien Millere8328192003-01-07 15:18:32 +11002188 [
Tim Rice648f8762011-01-26 12:38:57 -08002189 AC_MSG_RESULT([no])
Damien Millere8328192003-01-07 15:18:32 +11002190 ],
Damien Millera8e06ce2003-11-21 23:48:55 +11002191 [
Tim Rice648f8762011-01-26 12:38:57 -08002192 AC_MSG_RESULT([yes])
2193 AC_DEFINE([HAVE_STRICT_MKSTEMP], [1], [Silly mkstemp()])
Damien Millere8328192003-01-07 15:18:32 +11002194 ],
2195 [
Tim Rice648f8762011-01-26 12:38:57 -08002196 AC_MSG_RESULT([yes])
2197 AC_DEFINE([HAVE_STRICT_MKSTEMP])
Damien Millera8e06ce2003-11-21 23:48:55 +11002198 ]
Damien Millere8328192003-01-07 15:18:32 +11002199)
2200fi
2201
Darren Tucker70a3d552003-08-21 17:58:29 +10002202dnl make sure that openpty does not reacquire controlling terminal
2203if test ! -z "$check_for_openpty_ctty_bug"; then
Tim Rice648f8762011-01-26 12:38:57 -08002204 AC_MSG_CHECKING([if openpty correctly handles controlling tty])
Darren Tucker314d89e2005-10-17 23:29:23 +10002205 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002206 [AC_LANG_PROGRAM([[
Darren Tucker70a3d552003-08-21 17:58:29 +10002207#include <stdio.h>
2208#include <sys/fcntl.h>
2209#include <sys/types.h>
2210#include <sys/wait.h>
Tim Rice648f8762011-01-26 12:38:57 -08002211 ]], [[
Darren Tucker70a3d552003-08-21 17:58:29 +10002212 pid_t pid;
2213 int fd, ptyfd, ttyfd, status;
2214
2215 pid = fork();
2216 if (pid < 0) { /* failed */
2217 exit(1);
2218 } else if (pid > 0) { /* parent */
2219 waitpid(pid, &status, 0);
Damien Millera8e06ce2003-11-21 23:48:55 +11002220 if (WIFEXITED(status))
Darren Tucker70a3d552003-08-21 17:58:29 +10002221 exit(WEXITSTATUS(status));
2222 else
2223 exit(2);
2224 } else { /* child */
2225 close(0); close(1); close(2);
2226 setsid();
2227 openpty(&ptyfd, &ttyfd, NULL, NULL, NULL);
2228 fd = open("/dev/tty", O_RDWR | O_NOCTTY);
2229 if (fd >= 0)
2230 exit(3); /* Acquired ctty: broken */
2231 else
2232 exit(0); /* Did not acquire ctty: OK */
2233 }
Darren Tucker314d89e2005-10-17 23:29:23 +10002234 ]])],
Darren Tucker70a3d552003-08-21 17:58:29 +10002235 [
Tim Rice648f8762011-01-26 12:38:57 -08002236 AC_MSG_RESULT([yes])
Darren Tucker70a3d552003-08-21 17:58:29 +10002237 ],
2238 [
Tim Rice648f8762011-01-26 12:38:57 -08002239 AC_MSG_RESULT([no])
2240 AC_DEFINE([SSHD_ACQUIRES_CTTY])
Darren Tucker314d89e2005-10-17 23:29:23 +10002241 ],
2242 [
Tim Rice648f8762011-01-26 12:38:57 -08002243 AC_MSG_RESULT([cross-compiling, assuming yes])
Darren Tucker70a3d552003-08-21 17:58:29 +10002244 ]
2245 )
2246fi
2247
Tim Rice8bb561b2005-03-17 16:23:19 -08002248if test "x$ac_cv_func_getaddrinfo" = "xyes" && \
2249 test "x$check_for_hpux_broken_getaddrinfo" = "x1"; then
Tim Rice648f8762011-01-26 12:38:57 -08002250 AC_MSG_CHECKING([if getaddrinfo seems to work])
Darren Tucker314d89e2005-10-17 23:29:23 +10002251 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002252 [AC_LANG_PROGRAM([[
Darren Tucker4398cf52004-04-06 21:39:02 +10002253#include <stdio.h>
2254#include <sys/socket.h>
2255#include <netdb.h>
2256#include <errno.h>
2257#include <netinet/in.h>
2258
2259#define TEST_PORT "2222"
Tim Rice648f8762011-01-26 12:38:57 -08002260 ]], [[
Darren Tucker4398cf52004-04-06 21:39:02 +10002261 int err, sock;
2262 struct addrinfo *gai_ai, *ai, hints;
2263 char ntop[NI_MAXHOST], strport[NI_MAXSERV], *name = NULL;
2264
2265 memset(&hints, 0, sizeof(hints));
2266 hints.ai_family = PF_UNSPEC;
2267 hints.ai_socktype = SOCK_STREAM;
2268 hints.ai_flags = AI_PASSIVE;
2269
2270 err = getaddrinfo(name, TEST_PORT, &hints, &gai_ai);
2271 if (err != 0) {
2272 fprintf(stderr, "getaddrinfo failed (%s)", gai_strerror(err));
2273 exit(1);
2274 }
2275
2276 for (ai = gai_ai; ai != NULL; ai = ai->ai_next) {
2277 if (ai->ai_family != AF_INET6)
2278 continue;
2279
2280 err = getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop,
2281 sizeof(ntop), strport, sizeof(strport),
2282 NI_NUMERICHOST|NI_NUMERICSERV);
2283
2284 if (err != 0) {
2285 if (err == EAI_SYSTEM)
2286 perror("getnameinfo EAI_SYSTEM");
2287 else
2288 fprintf(stderr, "getnameinfo failed: %s\n",
2289 gai_strerror(err));
2290 exit(2);
2291 }
2292
2293 sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
2294 if (sock < 0)
2295 perror("socket");
2296 if (bind(sock, ai->ai_addr, ai->ai_addrlen) < 0) {
2297 if (errno == EBADF)
2298 exit(3);
2299 }
2300 }
2301 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10002302 ]])],
Darren Tucker4398cf52004-04-06 21:39:02 +10002303 [
Tim Rice648f8762011-01-26 12:38:57 -08002304 AC_MSG_RESULT([yes])
Darren Tucker4398cf52004-04-06 21:39:02 +10002305 ],
2306 [
Tim Rice648f8762011-01-26 12:38:57 -08002307 AC_MSG_RESULT([no])
2308 AC_DEFINE([BROKEN_GETADDRINFO])
Darren Tucker314d89e2005-10-17 23:29:23 +10002309 ],
2310 [
Tim Rice648f8762011-01-26 12:38:57 -08002311 AC_MSG_RESULT([cross-compiling, assuming yes])
Darren Tucker4398cf52004-04-06 21:39:02 +10002312 ]
2313 )
2314fi
2315
Tim Rice8bb561b2005-03-17 16:23:19 -08002316if test "x$ac_cv_func_getaddrinfo" = "xyes" && \
2317 test "x$check_for_aix_broken_getaddrinfo" = "x1"; then
Tim Rice648f8762011-01-26 12:38:57 -08002318 AC_MSG_CHECKING([if getaddrinfo seems to work])
Darren Tucker314d89e2005-10-17 23:29:23 +10002319 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002320 [AC_LANG_PROGRAM([[
Darren Tucker691d5232005-02-15 21:45:57 +11002321#include <stdio.h>
2322#include <sys/socket.h>
2323#include <netdb.h>
2324#include <errno.h>
2325#include <netinet/in.h>
2326
2327#define TEST_PORT "2222"
Tim Rice648f8762011-01-26 12:38:57 -08002328 ]], [[
Darren Tucker691d5232005-02-15 21:45:57 +11002329 int err, sock;
2330 struct addrinfo *gai_ai, *ai, hints;
2331 char ntop[NI_MAXHOST], strport[NI_MAXSERV], *name = NULL;
2332
2333 memset(&hints, 0, sizeof(hints));
2334 hints.ai_family = PF_UNSPEC;
2335 hints.ai_socktype = SOCK_STREAM;
2336 hints.ai_flags = AI_PASSIVE;
2337
2338 err = getaddrinfo(name, TEST_PORT, &hints, &gai_ai);
2339 if (err != 0) {
2340 fprintf(stderr, "getaddrinfo failed (%s)", gai_strerror(err));
2341 exit(1);
2342 }
2343
2344 for (ai = gai_ai; ai != NULL; ai = ai->ai_next) {
2345 if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6)
2346 continue;
2347
2348 err = getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop,
2349 sizeof(ntop), strport, sizeof(strport),
2350 NI_NUMERICHOST|NI_NUMERICSERV);
2351
2352 if (ai->ai_family == AF_INET && err != 0) {
2353 perror("getnameinfo");
2354 exit(2);
2355 }
2356 }
2357 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10002358 ]])],
Darren Tucker691d5232005-02-15 21:45:57 +11002359 [
Tim Rice648f8762011-01-26 12:38:57 -08002360 AC_MSG_RESULT([yes])
2361 AC_DEFINE([AIX_GETNAMEINFO_HACK], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07002362 [Define if you have a getaddrinfo that fails
2363 for the all-zeros IPv6 address])
Darren Tucker691d5232005-02-15 21:45:57 +11002364 ],
2365 [
Tim Rice648f8762011-01-26 12:38:57 -08002366 AC_MSG_RESULT([no])
2367 AC_DEFINE([BROKEN_GETADDRINFO])
Darren Tucker314d89e2005-10-17 23:29:23 +10002368 ],
Darren Tucker8b272ab2006-06-27 11:20:28 +10002369 [
Tim Rice648f8762011-01-26 12:38:57 -08002370 AC_MSG_RESULT([cross-compiling, assuming no])
Darren Tucker691d5232005-02-15 21:45:57 +11002371 ]
2372 )
2373fi
2374
Darren Tuckere50e8c92015-02-21 15:10:33 +11002375if test "x$ac_cv_func_getaddrinfo" = "xyes"; then
2376 AC_CHECK_DECLS(AI_NUMERICSERV, , ,
2377 [#include <sys/types.h>
2378 #include <sys/socket.h>
2379 #include <netdb.h>])
2380fi
2381
Darren Tuckera56f1912004-11-02 20:30:54 +11002382if test "x$check_for_conflicting_getspnam" = "x1"; then
Tim Rice648f8762011-01-26 12:38:57 -08002383 AC_MSG_CHECKING([for conflicting getspnam in shadow.h])
2384 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <shadow.h> ]],
2385 [[ exit(0); ]])],
Darren Tuckera56f1912004-11-02 20:30:54 +11002386 [
Tim Rice648f8762011-01-26 12:38:57 -08002387 AC_MSG_RESULT([no])
Darren Tuckera56f1912004-11-02 20:30:54 +11002388 ],
2389 [
Tim Rice648f8762011-01-26 12:38:57 -08002390 AC_MSG_RESULT([yes])
2391 AC_DEFINE([GETSPNAM_CONFLICTING_DEFS], [1],
Darren Tuckera56f1912004-11-02 20:30:54 +11002392 [Conflicting defs for getspnam])
2393 ]
2394 )
2395fi
2396
Darren Tucker20e5e8b2016-08-02 12:16:34 +10002397dnl NetBSD added an strnvis and unfortunately made it incompatible with the
2398dnl existing one in OpenBSD and Linux's libbsd (the former having existed
2399dnl for over ten years). Despite this incompatibility being reported during
2400dnl development (see http://gnats.netbsd.org/44977) they still shipped it.
2401dnl Even more unfortunately FreeBSD and later MacOS picked up this incompatible
2402dnl implementation. Try to detect this mess, and assume the only safe option
2403dnl if we're cross compiling.
2404dnl
2405dnl OpenBSD, 2001: strnvis(char *dst, const char *src, size_t dlen, int flag);
2406dnl NetBSD: 2012, strnvis(char *dst, size_t dlen, const char *src, int flag);
2407if test "x$ac_cv_func_strnvis" = "xyes"; then
2408 AC_MSG_CHECKING([for working strnvis])
2409 AC_RUN_IFELSE(
2410 [AC_LANG_PROGRAM([[
2411#include <signal.h>
2412#include <stdlib.h>
2413#include <string.h>
2414#include <vis.h>
2415static void sighandler(int sig) { _exit(1); }
2416 ]], [[
2417 char dst[16];
2418
2419 signal(SIGSEGV, sighandler);
2420 if (strnvis(dst, "src", 4, 0) && strcmp(dst, "src") == 0)
2421 exit(0);
2422 exit(1)
2423 ]])],
2424 [AC_MSG_RESULT([yes])],
2425 [AC_MSG_RESULT([no])
2426 AC_DEFINE([BROKEN_STRNVIS], [1], [strnvis detected broken])],
2427 [AC_MSG_WARN([cross compiling: assuming broken])
2428 AC_DEFINE([BROKEN_STRNVIS], [1], [strnvis assumed broken])]
2429 )
2430fi
2431
Darren Tuckerc7b5a472018-02-25 23:55:41 +11002432AC_CHECK_FUNCS([getpgrp],[
2433 AC_MSG_CHECKING([if getpgrp accepts zero args])
2434 AC_COMPILE_IFELSE(
2435 [AC_LANG_PROGRAM([[$ac_includes_default]], [[ getpgrp(); ]])],
2436 [ AC_MSG_RESULT([yes])
2437 AC_DEFINE([GETPGRP_VOID], [1], [getpgrp takes zero args])],
2438 [ AC_MSG_RESULT([no])
2439 AC_DEFINE([GETPGRP_VOID], [0], [getpgrp takes one arg])]
2440 )
2441])
Damien Miller606f8802000-09-16 15:39:56 +11002442
Tim Riceaef73712002-05-11 13:17:42 -07002443# Search for OpenSSL
2444saved_CPPFLAGS="$CPPFLAGS"
2445saved_LDFLAGS="$LDFLAGS"
Tim Rice648f8762011-01-26 12:38:57 -08002446AC_ARG_WITH([ssl-dir],
Damien Millera22ba012000-03-02 23:09:20 +11002447 [ --with-ssl-dir=PATH Specify path to OpenSSL installation ],
2448 [
Damien Miller72ef7c12015-01-15 02:21:31 +11002449 if test "x$openssl" = "xno" ; then
2450 AC_MSG_ERROR([cannot use --with-ssl-dir when OpenSSL disabled])
2451 fi
Ben Lindstrom23e13712000-10-29 22:49:19 +00002452 if test "x$withval" != "xno" ; then
Darren Tuckerc7e38d52005-02-09 22:12:30 +11002453 case "$withval" in
2454 # Relative paths
2455 ./*|../*) withval="`pwd`/$withval"
2456 esac
Tim Riceaef73712002-05-11 13:17:42 -07002457 if test -d "$withval/lib"; then
2458 if test -n "${need_dash_r}"; then
2459 LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
2460 else
2461 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
2462 fi
Darren Tucker9f8703b2010-04-23 11:12:06 +10002463 elif test -d "$withval/lib64"; then
2464 if test -n "${need_dash_r}"; then
2465 LDFLAGS="-L${withval}/lib64 -R${withval}/lib64 ${LDFLAGS}"
2466 else
2467 LDFLAGS="-L${withval}/lib64 ${LDFLAGS}"
2468 fi
Tim Riceaef73712002-05-11 13:17:42 -07002469 else
2470 if test -n "${need_dash_r}"; then
2471 LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
2472 else
2473 LDFLAGS="-L${withval} ${LDFLAGS}"
2474 fi
2475 fi
2476 if test -d "$withval/include"; then
2477 CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
2478 else
2479 CPPFLAGS="-I${withval} ${CPPFLAGS}"
2480 fi
Damien Millera22ba012000-03-02 23:09:20 +11002481 fi
2482 ]
2483)
Damien Millerb9c56672014-05-15 14:43:37 +10002484
Tim Rice648f8762011-01-26 12:38:57 -08002485AC_ARG_WITH([openssl-header-check],
Damien Miller9975e482007-03-05 11:51:27 +11002486 [ --without-openssl-header-check Disable OpenSSL version consistency check],
Damien Millerec932372002-01-22 22:16:03 +11002487 [
Damien Miller72ef7c12015-01-15 02:21:31 +11002488 if test "x$withval" = "xno" ; then
2489 openssl_check_nonfatal=1
Damien Miller9975e482007-03-05 11:51:27 +11002490 fi
Damien Millerec932372002-01-22 22:16:03 +11002491 ]
2492)
2493
Damien Miller72ef7c12015-01-15 02:21:31 +11002494openssl_engine=no
Tim Rice648f8762011-01-26 12:38:57 -08002495AC_ARG_WITH([ssl-engine],
Darren Tuckerfabdb6c2006-02-20 20:17:35 +11002496 [ --with-ssl-engine Enable OpenSSL (hardware) ENGINE support ],
Damien Miller72ef7c12015-01-15 02:21:31 +11002497 [
Damien Miller72ef7c12015-01-15 02:21:31 +11002498 if test "x$withval" != "xno" ; then
Darren Tuckerb5fa0cd2015-12-15 15:10:32 +11002499 if test "x$openssl" = "xno" ; then
2500 AC_MSG_ERROR([cannot use --with-ssl-engine when OpenSSL disabled])
2501 fi
Damien Miller72ef7c12015-01-15 02:21:31 +11002502 openssl_engine=yes
2503 fi
2504 ]
2505)
2506
2507if test "x$openssl" = "xyes" ; then
2508 LIBS="-lcrypto $LIBS"
2509 AC_TRY_LINK_FUNC([RAND_add], [AC_DEFINE([HAVE_OPENSSL], [1],
2510 [Define if your ssl headers are included
2511 with #include <openssl/header.h>])],
2512 [
2513 dnl Check default openssl install dir
2514 if test -n "${need_dash_r}"; then
2515 LDFLAGS="-L/usr/local/ssl/lib -R/usr/local/ssl/lib ${saved_LDFLAGS}"
2516 else
2517 LDFLAGS="-L/usr/local/ssl/lib ${saved_LDFLAGS}"
2518 fi
2519 CPPFLAGS="-I/usr/local/ssl/include ${saved_CPPFLAGS}"
2520 AC_CHECK_HEADER([openssl/opensslv.h], ,
2521 [AC_MSG_ERROR([*** OpenSSL headers missing - please install first or check config.log ***])])
2522 AC_TRY_LINK_FUNC([RAND_add], [AC_DEFINE([HAVE_OPENSSL])],
2523 [
2524 AC_MSG_ERROR([*** Can't find recent OpenSSL libcrypto (see config.log for details) ***])
2525 ]
2526 )
2527 ]
2528 )
2529
2530 # Determine OpenSSL header version
2531 AC_MSG_CHECKING([OpenSSL header version])
2532 AC_RUN_IFELSE(
2533 [AC_LANG_PROGRAM([[
Darren Tucker15605962015-11-10 11:14:47 +11002534 #include <stdlib.h>
Damien Miller72ef7c12015-01-15 02:21:31 +11002535 #include <stdio.h>
2536 #include <string.h>
2537 #include <openssl/opensslv.h>
2538 #define DATA "conftest.sslincver"
2539 ]], [[
2540 FILE *fd;
2541 int rc;
2542
2543 fd = fopen(DATA,"w");
2544 if(fd == NULL)
2545 exit(1);
2546
Darren Tuckerb3413532016-04-04 11:09:21 +10002547 if ((rc = fprintf(fd, "%08lx (%s)\n",
2548 (unsigned long)OPENSSL_VERSION_NUMBER,
2549 OPENSSL_VERSION_TEXT)) < 0)
Damien Miller72ef7c12015-01-15 02:21:31 +11002550 exit(1);
2551
2552 exit(0);
2553 ]])],
2554 [
2555 ssl_header_ver=`cat conftest.sslincver`
2556 AC_MSG_RESULT([$ssl_header_ver])
2557 ],
2558 [
2559 AC_MSG_RESULT([not found])
2560 AC_MSG_ERROR([OpenSSL version header not found.])
2561 ],
2562 [
2563 AC_MSG_WARN([cross compiling: not checking])
2564 ]
2565 )
2566
2567 # Determine OpenSSL library version
2568 AC_MSG_CHECKING([OpenSSL library version])
2569 AC_RUN_IFELSE(
2570 [AC_LANG_PROGRAM([[
2571 #include <stdio.h>
2572 #include <string.h>
2573 #include <openssl/opensslv.h>
2574 #include <openssl/crypto.h>
2575 #define DATA "conftest.ssllibver"
2576 ]], [[
2577 FILE *fd;
2578 int rc;
2579
2580 fd = fopen(DATA,"w");
2581 if(fd == NULL)
2582 exit(1);
2583
Darren Tucker815bcac2016-04-04 11:07:59 +10002584 if ((rc = fprintf(fd, "%08lx (%s)\n", (unsigned long)SSLeay(),
2585 SSLeay_version(SSLEAY_VERSION))) < 0)
Damien Miller72ef7c12015-01-15 02:21:31 +11002586 exit(1);
2587
2588 exit(0);
2589 ]])],
2590 [
2591 ssl_library_ver=`cat conftest.ssllibver`
2592 # Check version is supported.
2593 case "$ssl_library_ver" in
Damien Miller2429cf72017-03-14 18:01:52 +11002594 10000*|0*)
2595 AC_MSG_ERROR([OpenSSL >= 1.0.1 required (have "$ssl_library_ver")])
Damien Miller72ef7c12015-01-15 02:21:31 +11002596 ;;
Damien Miller04dc0702017-09-28 14:54:34 -07002597 100*) ;; # 1.0.x
Damien Millerbba69c22017-09-28 16:06:21 -07002598 200*) ;; # LibreSSL
Damien Miller04dc0702017-09-28 14:54:34 -07002599 *)
2600 AC_MSG_ERROR([OpenSSL >= 1.1.0 is not yet supported (have "$ssl_library_ver")])
2601 ;;
Damien Miller72ef7c12015-01-15 02:21:31 +11002602 esac
2603 AC_MSG_RESULT([$ssl_library_ver])
2604 ],
2605 [
2606 AC_MSG_RESULT([not found])
2607 AC_MSG_ERROR([OpenSSL library not found.])
2608 ],
2609 [
2610 AC_MSG_WARN([cross compiling: not checking])
2611 ]
2612 )
2613
2614 # Sanity check OpenSSL headers
2615 AC_MSG_CHECKING([whether OpenSSL's headers match the library])
2616 AC_RUN_IFELSE(
2617 [AC_LANG_PROGRAM([[
2618 #include <string.h>
2619 #include <openssl/opensslv.h>
Darren Tuckerc1d7e542015-12-15 14:27:09 +11002620 #include <openssl/crypto.h>
Damien Miller72ef7c12015-01-15 02:21:31 +11002621 ]], [[
2622 exit(SSLeay() == OPENSSL_VERSION_NUMBER ? 0 : 1);
2623 ]])],
2624 [
2625 AC_MSG_RESULT([yes])
2626 ],
2627 [
2628 AC_MSG_RESULT([no])
2629 if test "x$openssl_check_nonfatal" = "x"; then
2630 AC_MSG_ERROR([Your OpenSSL headers do not match your
2631 library. Check config.log for details.
2632 If you are sure your installation is consistent, you can disable the check
2633 by running "./configure --without-openssl-header-check".
2634 Also see contrib/findssl.sh for help identifying header/library mismatches.
2635 ])
2636 else
2637 AC_MSG_WARN([Your OpenSSL headers do not match your
2638 library. Check config.log for details.
2639 Also see contrib/findssl.sh for help identifying header/library mismatches.])
2640 fi
2641 ],
2642 [
2643 AC_MSG_WARN([cross compiling: not checking])
2644 ]
2645 )
2646
2647 AC_MSG_CHECKING([if programs using OpenSSL functions will link])
2648 AC_LINK_IFELSE(
2649 [AC_LANG_PROGRAM([[ #include <openssl/evp.h> ]],
2650 [[ SSLeay_add_all_algorithms(); ]])],
2651 [
2652 AC_MSG_RESULT([yes])
2653 ],
2654 [
2655 AC_MSG_RESULT([no])
2656 saved_LIBS="$LIBS"
2657 LIBS="$LIBS -ldl"
2658 AC_MSG_CHECKING([if programs using OpenSSL need -ldl])
2659 AC_LINK_IFELSE(
2660 [AC_LANG_PROGRAM([[ #include <openssl/evp.h> ]],
2661 [[ SSLeay_add_all_algorithms(); ]])],
2662 [
2663 AC_MSG_RESULT([yes])
2664 ],
2665 [
2666 AC_MSG_RESULT([no])
2667 LIBS="$saved_LIBS"
2668 ]
2669 )
2670 ]
2671 )
2672
2673 AC_CHECK_FUNCS([ \
2674 BN_is_prime_ex \
2675 DSA_generate_parameters_ex \
2676 EVP_DigestInit_ex \
2677 EVP_DigestFinal_ex \
2678 EVP_MD_CTX_init \
2679 EVP_MD_CTX_cleanup \
2680 EVP_MD_CTX_copy_ex \
2681 HMAC_CTX_init \
2682 RSA_generate_key_ex \
2683 RSA_get_default_method \
2684 ])
2685
2686 if test "x$openssl_engine" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08002687 AC_MSG_CHECKING([for OpenSSL ENGINE support])
2688 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller72ef7c12015-01-15 02:21:31 +11002689 #include <openssl/engine.h>
Tim Rice648f8762011-01-26 12:38:57 -08002690 ]], [[
Damien Miller72ef7c12015-01-15 02:21:31 +11002691 ENGINE_load_builtin_engines();
2692 ENGINE_register_all_complete();
Tim Rice648f8762011-01-26 12:38:57 -08002693 ]])],
2694 [ AC_MSG_RESULT([yes])
2695 AC_DEFINE([USE_OPENSSL_ENGINE], [1],
Darren Tuckerfabdb6c2006-02-20 20:17:35 +11002696 [Enable OpenSSL engine support])
Tim Rice648f8762011-01-26 12:38:57 -08002697 ], [ AC_MSG_ERROR([OpenSSL ENGINE support not found])
2698 ])
Damien Miller72ef7c12015-01-15 02:21:31 +11002699 fi
Darren Tuckerfabdb6c2006-02-20 20:17:35 +11002700
Damien Miller72ef7c12015-01-15 02:21:31 +11002701 # Check for OpenSSL without EVP_aes_{192,256}_cbc
2702 AC_MSG_CHECKING([whether OpenSSL has crippled AES support])
2703 AC_LINK_IFELSE(
Darren Tucker37bcef52013-11-09 18:39:25 +11002704 [AC_LANG_PROGRAM([[
Damien Miller72ef7c12015-01-15 02:21:31 +11002705 #include <string.h>
2706 #include <openssl/evp.h>
2707 ]], [[
2708 exit(EVP_aes_192_cbc() == NULL || EVP_aes_256_cbc() == NULL);
2709 ]])],
2710 [
2711 AC_MSG_RESULT([no])
2712 ],
2713 [
2714 AC_MSG_RESULT([yes])
2715 AC_DEFINE([OPENSSL_LOBOTOMISED_AES], [1],
2716 [libcrypto is missing AES 192 and 256 bit functions])
2717 ]
2718 )
2719
2720 # Check for OpenSSL with EVP_aes_*ctr
2721 AC_MSG_CHECKING([whether OpenSSL has AES CTR via EVP])
2722 AC_LINK_IFELSE(
2723 [AC_LANG_PROGRAM([[
2724 #include <string.h>
2725 #include <openssl/evp.h>
2726 ]], [[
2727 exit(EVP_aes_128_ctr() == NULL ||
2728 EVP_aes_192_cbc() == NULL ||
2729 EVP_aes_256_cbc() == NULL);
2730 ]])],
2731 [
2732 AC_MSG_RESULT([yes])
2733 AC_DEFINE([OPENSSL_HAVE_EVPCTR], [1],
2734 [libcrypto has EVP AES CTR])
2735 ],
2736 [
2737 AC_MSG_RESULT([no])
2738 ]
2739 )
2740
2741 # Check for OpenSSL with EVP_aes_*gcm
2742 AC_MSG_CHECKING([whether OpenSSL has AES GCM via EVP])
2743 AC_LINK_IFELSE(
2744 [AC_LANG_PROGRAM([[
2745 #include <string.h>
2746 #include <openssl/evp.h>
2747 ]], [[
2748 exit(EVP_aes_128_gcm() == NULL ||
2749 EVP_aes_256_gcm() == NULL ||
2750 EVP_CTRL_GCM_SET_IV_FIXED == 0 ||
2751 EVP_CTRL_GCM_IV_GEN == 0 ||
2752 EVP_CTRL_GCM_SET_TAG == 0 ||
2753 EVP_CTRL_GCM_GET_TAG == 0 ||
2754 EVP_CIPHER_CTX_ctrl(NULL, 0, 0, NULL) == 0);
2755 ]])],
2756 [
2757 AC_MSG_RESULT([yes])
2758 AC_DEFINE([OPENSSL_HAVE_EVPGCM], [1],
2759 [libcrypto has EVP AES GCM])
2760 ],
2761 [
2762 AC_MSG_RESULT([no])
2763 unsupported_algorithms="$unsupported_cipers \
Damien Miller679ce882016-07-15 13:44:38 +10002764 aes128-gcm@openssh.com \
2765 aes256-gcm@openssh.com"
Damien Miller72ef7c12015-01-15 02:21:31 +11002766 ]
2767 )
2768
2769 AC_SEARCH_LIBS([EVP_CIPHER_CTX_ctrl], [crypto],
2770 [AC_DEFINE([HAVE_EVP_CIPHER_CTX_CTRL], [1],
2771 [Define if libcrypto has EVP_CIPHER_CTX_ctrl])])
2772
2773 AC_MSG_CHECKING([if EVP_DigestUpdate returns an int])
2774 AC_LINK_IFELSE(
2775 [AC_LANG_PROGRAM([[
2776 #include <string.h>
2777 #include <openssl/evp.h>
2778 ]], [[
2779 if(EVP_DigestUpdate(NULL, NULL,0))
2780 exit(0);
2781 ]])],
2782 [
2783 AC_MSG_RESULT([yes])
2784 ],
2785 [
2786 AC_MSG_RESULT([no])
2787 AC_DEFINE([OPENSSL_EVP_DIGESTUPDATE_VOID], [1],
2788 [Define if EVP_DigestUpdate returns void])
2789 ]
2790 )
2791
2792 # Some systems want crypt() from libcrypt, *not* the version in OpenSSL,
2793 # because the system crypt() is more featureful.
2794 if test "x$check_for_libcrypt_before" = "x1"; then
2795 AC_CHECK_LIB([crypt], [crypt])
2796 fi
2797
2798 # Some Linux systems (Slackware) need crypt() from libcrypt, *not* the
2799 # version in OpenSSL.
2800 if test "x$check_for_libcrypt_later" = "x1"; then
2801 AC_CHECK_LIB([crypt], [crypt], [LIBS="$LIBS -lcrypt"])
2802 fi
Damien Miller00797e82015-03-04 05:02:45 +11002803 AC_CHECK_FUNCS([crypt DES_crypt])
Damien Miller72ef7c12015-01-15 02:21:31 +11002804
2805 # Search for SHA256 support in libc and/or OpenSSL
2806 AC_CHECK_FUNCS([SHA256_Update EVP_sha256], ,
2807 [unsupported_algorithms="$unsupported_algorithms \
Damien Miller679ce882016-07-15 13:44:38 +10002808 hmac-sha2-256 \
2809 hmac-sha2-512 \
Damien Miller72ef7c12015-01-15 02:21:31 +11002810 diffie-hellman-group-exchange-sha256 \
Damien Miller679ce882016-07-15 13:44:38 +10002811 hmac-sha2-256-etm@openssh.com \
2812 hmac-sha2-512-etm@openssh.com"
Damien Miller72ef7c12015-01-15 02:21:31 +11002813 ]
2814 )
2815 # Search for RIPE-MD support in OpenSSL
2816 AC_CHECK_FUNCS([EVP_ripemd160], ,
2817 [unsupported_algorithms="$unsupported_algorithms \
Damien Miller679ce882016-07-15 13:44:38 +10002818 hmac-ripemd160 \
2819 hmac-ripemd160@openssh.com \
Damien Miller72ef7c12015-01-15 02:21:31 +11002820 hmac-ripemd160-etm@openssh.com"
2821 ]
2822 )
2823
2824 # Check complete ECC support in OpenSSL
2825 AC_MSG_CHECKING([whether OpenSSL has NID_X9_62_prime256v1])
2826 AC_LINK_IFELSE(
2827 [AC_LANG_PROGRAM([[
2828 #include <openssl/ec.h>
2829 #include <openssl/ecdh.h>
2830 #include <openssl/ecdsa.h>
2831 #include <openssl/evp.h>
2832 #include <openssl/objects.h>
2833 #include <openssl/opensslv.h>
Damien Miller72ef7c12015-01-15 02:21:31 +11002834 ]], [[
2835 EC_KEY *e = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
2836 const EVP_MD *m = EVP_sha256(); /* We need this too */
Darren Tucker37bcef52013-11-09 18:39:25 +11002837 ]])],
2838 [ AC_MSG_RESULT([yes])
Damien Miller72ef7c12015-01-15 02:21:31 +11002839 enable_nistp256=1 ],
2840 [ AC_MSG_RESULT([no]) ]
2841 )
Darren Tucker37bcef52013-11-09 18:39:25 +11002842
Damien Miller72ef7c12015-01-15 02:21:31 +11002843 AC_MSG_CHECKING([whether OpenSSL has NID_secp384r1])
2844 AC_LINK_IFELSE(
2845 [AC_LANG_PROGRAM([[
2846 #include <openssl/ec.h>
2847 #include <openssl/ecdh.h>
2848 #include <openssl/ecdsa.h>
2849 #include <openssl/evp.h>
2850 #include <openssl/objects.h>
2851 #include <openssl/opensslv.h>
Damien Miller72ef7c12015-01-15 02:21:31 +11002852 ]], [[
2853 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp384r1);
2854 const EVP_MD *m = EVP_sha384(); /* We need this too */
2855 ]])],
2856 [ AC_MSG_RESULT([yes])
2857 enable_nistp384=1 ],
2858 [ AC_MSG_RESULT([no]) ]
2859 )
Darren Tucker37bcef52013-11-09 18:39:25 +11002860
Damien Miller72ef7c12015-01-15 02:21:31 +11002861 AC_MSG_CHECKING([whether OpenSSL has NID_secp521r1])
2862 AC_LINK_IFELSE(
2863 [AC_LANG_PROGRAM([[
2864 #include <openssl/ec.h>
2865 #include <openssl/ecdh.h>
2866 #include <openssl/ecdsa.h>
2867 #include <openssl/evp.h>
2868 #include <openssl/objects.h>
2869 #include <openssl/opensslv.h>
Damien Miller72ef7c12015-01-15 02:21:31 +11002870 ]], [[
2871 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1);
2872 const EVP_MD *m = EVP_sha512(); /* We need this too */
2873 ]])],
2874 [ AC_MSG_RESULT([yes])
2875 AC_MSG_CHECKING([if OpenSSL's NID_secp521r1 is functional])
2876 AC_RUN_IFELSE(
2877 [AC_LANG_PROGRAM([[
2878 #include <openssl/ec.h>
2879 #include <openssl/ecdh.h>
2880 #include <openssl/ecdsa.h>
2881 #include <openssl/evp.h>
2882 #include <openssl/objects.h>
2883 #include <openssl/opensslv.h>
2884 ]],[[
2885 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1);
2886 const EVP_MD *m = EVP_sha512(); /* We need this too */
2887 exit(e == NULL || m == NULL);
2888 ]])],
2889 [ AC_MSG_RESULT([yes])
2890 enable_nistp521=1 ],
2891 [ AC_MSG_RESULT([no]) ],
2892 [ AC_MSG_WARN([cross-compiling: assuming yes])
2893 enable_nistp521=1 ]
2894 )],
2895 AC_MSG_RESULT([no])
2896 )
Darren Tucker37bcef52013-11-09 18:39:25 +11002897
Damien Miller72ef7c12015-01-15 02:21:31 +11002898 COMMENT_OUT_ECC="#no ecc#"
2899 TEST_SSH_ECC=no
2900
2901 if test x$enable_nistp256 = x1 || test x$enable_nistp384 = x1 || \
2902 test x$enable_nistp521 = x1; then
2903 AC_DEFINE(OPENSSL_HAS_ECC, [1], [OpenSSL has ECC])
2904 fi
2905 if test x$enable_nistp256 = x1; then
2906 AC_DEFINE([OPENSSL_HAS_NISTP256], [1],
2907 [libcrypto has NID_X9_62_prime256v1])
2908 TEST_SSH_ECC=yes
2909 COMMENT_OUT_ECC=""
2910 else
Damien Miller679ce882016-07-15 13:44:38 +10002911 unsupported_algorithms="$unsupported_algorithms \
2912 ecdsa-sha2-nistp256 \
2913 ecdh-sha2-nistp256 \
2914 ecdsa-sha2-nistp256-cert-v01@openssh.com"
Damien Miller72ef7c12015-01-15 02:21:31 +11002915 fi
2916 if test x$enable_nistp384 = x1; then
2917 AC_DEFINE([OPENSSL_HAS_NISTP384], [1], [libcrypto has NID_secp384r1])
2918 TEST_SSH_ECC=yes
2919 COMMENT_OUT_ECC=""
2920 else
Damien Miller679ce882016-07-15 13:44:38 +10002921 unsupported_algorithms="$unsupported_algorithms \
2922 ecdsa-sha2-nistp384 \
2923 ecdh-sha2-nistp384 \
2924 ecdsa-sha2-nistp384-cert-v01@openssh.com"
Damien Miller72ef7c12015-01-15 02:21:31 +11002925 fi
2926 if test x$enable_nistp521 = x1; then
2927 AC_DEFINE([OPENSSL_HAS_NISTP521], [1], [libcrypto has NID_secp521r1])
2928 TEST_SSH_ECC=yes
2929 COMMENT_OUT_ECC=""
2930 else
Damien Miller679ce882016-07-15 13:44:38 +10002931 unsupported_algorithms="$unsupported_algorithms \
2932 ecdh-sha2-nistp521 \
2933 ecdsa-sha2-nistp521 \
2934 ecdsa-sha2-nistp521-cert-v01@openssh.com"
Damien Miller72ef7c12015-01-15 02:21:31 +11002935 fi
2936
2937 AC_SUBST([TEST_SSH_ECC])
2938 AC_SUBST([COMMENT_OUT_ECC])
2939else
2940 AC_CHECK_LIB([crypt], [crypt], [LIBS="$LIBS -lcrypt"])
Damien Miller00797e82015-03-04 05:02:45 +11002941 AC_CHECK_FUNCS([crypt])
Damien Miller72ef7c12015-01-15 02:21:31 +11002942fi
Damien Miller6af914a2010-09-10 11:39:26 +10002943
Damien Miller00f9cd22014-07-15 10:41:38 +10002944AC_CHECK_FUNCS([ \
2945 arc4random \
2946 arc4random_buf \
2947 arc4random_stir \
2948 arc4random_uniform \
2949])
2950
Tim Rice99203ec2007-03-26 09:35:28 -07002951saved_LIBS="$LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08002952AC_CHECK_LIB([iaf], [ia_openinfo], [
Tim Rice99203ec2007-03-26 09:35:28 -07002953 LIBS="$LIBS -liaf"
Tim Rice648f8762011-01-26 12:38:57 -08002954 AC_CHECK_FUNCS([set_id], [SSHDLIBS="$SSHDLIBS -liaf"
2955 AC_DEFINE([HAVE_LIBIAF], [1],
Tim Ricee1d93702016-05-31 11:13:22 -07002956 [Define if system has libiaf that supports set_id])
Tim Rice0eeaf122007-09-10 16:24:17 -07002957 ])
Tim Rice99203ec2007-03-26 09:35:28 -07002958])
2959LIBS="$saved_LIBS"
Damien Miller6c21c512002-01-22 21:57:53 +11002960
2961### Configure cryptographic random number support
2962
Damien Miller10479cc2018-04-10 10:19:02 +10002963# Check whether OpenSSL seeds itself
Damien Miller72ef7c12015-01-15 02:21:31 +11002964if test "x$openssl" = "xyes" ; then
2965 AC_MSG_CHECKING([whether OpenSSL's PRNG is internally seeded])
2966 AC_RUN_IFELSE(
2967 [AC_LANG_PROGRAM([[
2968 #include <string.h>
2969 #include <openssl/rand.h>
2970 ]], [[
2971 exit(RAND_status() == 1 ? 0 : 1);
2972 ]])],
2973 [
2974 OPENSSL_SEEDS_ITSELF=yes
2975 AC_MSG_RESULT([yes])
2976 ],
2977 [
2978 AC_MSG_RESULT([no])
2979 ],
2980 [
2981 AC_MSG_WARN([cross compiling: assuming yes])
2982 # This is safe, since we will fatal() at runtime if
2983 # OpenSSL is not seeded correctly.
2984 OPENSSL_SEEDS_ITSELF=yes
2985 ]
2986 )
2987fi
Damien Miller6c21c512002-01-22 21:57:53 +11002988
Damien Millerf22019b2011-05-05 13:48:37 +10002989# PRNGD TCP socket
2990AC_ARG_WITH([prngd-port],
2991 [ --with-prngd-port=PORT read entropy from PRNGD/EGD TCP localhost:PORT],
2992 [
2993 case "$withval" in
2994 no)
2995 withval=""
2996 ;;
2997 [[0-9]]*)
2998 ;;
2999 *)
3000 AC_MSG_ERROR([You must specify a numeric port number for --with-prngd-port])
3001 ;;
3002 esac
3003 if test ! -z "$withval" ; then
3004 PRNGD_PORT="$withval"
3005 AC_DEFINE_UNQUOTED([PRNGD_PORT], [$PRNGD_PORT],
3006 [Port number of PRNGD/EGD random number socket])
3007 fi
3008 ]
3009)
3010
3011# PRNGD Unix domain socket
3012AC_ARG_WITH([prngd-socket],
3013 [ --with-prngd-socket=FILE read entropy from PRNGD/EGD socket FILE (default=/var/run/egd-pool)],
3014 [
3015 case "$withval" in
3016 yes)
3017 withval="/var/run/egd-pool"
3018 ;;
3019 no)
3020 withval=""
3021 ;;
3022 /*)
3023 ;;
3024 *)
3025 AC_MSG_ERROR([You must specify an absolute path to the entropy socket])
3026 ;;
3027 esac
3028
3029 if test ! -z "$withval" ; then
3030 if test ! -z "$PRNGD_PORT" ; then
3031 AC_MSG_ERROR([You may not specify both a PRNGD/EGD port and socket])
3032 fi
3033 if test ! -r "$withval" ; then
3034 AC_MSG_WARN([Entropy socket is not readable])
3035 fi
3036 PRNGD_SOCKET="$withval"
3037 AC_DEFINE_UNQUOTED([PRNGD_SOCKET], ["$PRNGD_SOCKET"],
3038 [Location of PRNGD/EGD random number socket])
3039 fi
3040 ],
3041 [
3042 # Check for existing socket only if we don't have a random device already
3043 if test "x$OPENSSL_SEEDS_ITSELF" != "xyes" ; then
3044 AC_MSG_CHECKING([for PRNGD/EGD socket])
3045 # Insert other locations here
3046 for sock in /var/run/egd-pool /dev/egd-pool /etc/entropy; do
3047 if test -r $sock && $TEST_MINUS_S_SH -c "test -S $sock -o -p $sock" ; then
3048 PRNGD_SOCKET="$sock"
3049 AC_DEFINE_UNQUOTED([PRNGD_SOCKET], ["$PRNGD_SOCKET"])
3050 break;
3051 fi
3052 done
3053 if test ! -z "$PRNGD_SOCKET" ; then
3054 AC_MSG_RESULT([$PRNGD_SOCKET])
3055 else
3056 AC_MSG_RESULT([not found])
3057 fi
3058 fi
3059 ]
3060)
3061
3062# Which randomness source do we use?
3063if test ! -z "$PRNGD_PORT" ; then
3064 RAND_MSG="PRNGd port $PRNGD_PORT"
3065elif test ! -z "$PRNGD_SOCKET" ; then
3066 RAND_MSG="PRNGd socket $PRNGD_SOCKET"
3067elif test ! -z "$OPENSSL_SEEDS_ITSELF" ; then
3068 AC_DEFINE([OPENSSL_PRNG_ONLY], [1],
Damien Miller72ef7c12015-01-15 02:21:31 +11003069 [Define if you want the OpenSSL internally seeded PRNG only])
Damien Millerf22019b2011-05-05 13:48:37 +10003070 RAND_MSG="OpenSSL internal ONLY"
Damien Miller72ef7c12015-01-15 02:21:31 +11003071elif test "x$openssl" = "xno" ; then
3072 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 +10003073else
3074 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])
3075fi
3076
Darren Tucker3e6bde42006-08-20 20:03:50 +10003077# Check for PAM libs
3078PAM_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08003079AC_ARG_WITH([pam],
Darren Tucker3e6bde42006-08-20 20:03:50 +10003080 [ --with-pam Enable PAM support ],
3081 [
3082 if test "x$withval" != "xno" ; then
3083 if test "x$ac_cv_header_security_pam_appl_h" != "xyes" && \
3084 test "x$ac_cv_header_pam_pam_appl_h" != "xyes" ; then
3085 AC_MSG_ERROR([PAM headers not found])
3086 fi
3087
3088 saved_LIBS="$LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08003089 AC_CHECK_LIB([dl], [dlopen], , )
3090 AC_CHECK_LIB([pam], [pam_set_item], , [AC_MSG_ERROR([*** libpam missing])])
3091 AC_CHECK_FUNCS([pam_getenvlist])
3092 AC_CHECK_FUNCS([pam_putenv])
Darren Tucker3e6bde42006-08-20 20:03:50 +10003093 LIBS="$saved_LIBS"
3094
3095 PAM_MSG="yes"
3096
Darren Tucker20e9f972007-03-25 18:26:01 +10003097 SSHDLIBS="$SSHDLIBS -lpam"
Tim Rice648f8762011-01-26 12:38:57 -08003098 AC_DEFINE([USE_PAM], [1],
Darren Tucker3e6bde42006-08-20 20:03:50 +10003099 [Define if you want to enable PAM support])
Darren Tucker639bbe82006-08-20 20:17:53 +10003100
Darren Tucker3e6bde42006-08-20 20:03:50 +10003101 if test $ac_cv_lib_dl_dlopen = yes; then
Darren Tucker639bbe82006-08-20 20:17:53 +10003102 case "$LIBS" in
3103 *-ldl*)
3104 # libdl already in LIBS
3105 ;;
3106 *)
Darren Tucker20e9f972007-03-25 18:26:01 +10003107 SSHDLIBS="$SSHDLIBS -ldl"
Darren Tucker639bbe82006-08-20 20:17:53 +10003108 ;;
3109 esac
Darren Tucker3e6bde42006-08-20 20:03:50 +10003110 fi
Darren Tucker3e6bde42006-08-20 20:03:50 +10003111 fi
3112 ]
3113)
3114
Damien Miller8bd81e12016-08-16 13:30:56 +10003115AC_ARG_WITH([pam-service],
3116 [ --with-pam-service=name Specify PAM service name ],
3117 [
3118 if test "x$withval" != "xno" && \
3119 test "x$withval" != "xyes" ; then
3120 AC_DEFINE_UNQUOTED([SSHD_PAM_SERVICE],
3121 ["$withval"], [sshd PAM service name])
3122 fi
3123 ]
3124)
3125
Darren Tucker3e6bde42006-08-20 20:03:50 +10003126# Check for older PAM
3127if test "x$PAM_MSG" = "xyes" ; then
3128 # Check PAM strerror arguments (old PAM)
3129 AC_MSG_CHECKING([whether pam_strerror takes only one argument])
Tim Rice648f8762011-01-26 12:38:57 -08003130 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker3e6bde42006-08-20 20:03:50 +10003131#include <stdlib.h>
3132#if defined(HAVE_SECURITY_PAM_APPL_H)
3133#include <security/pam_appl.h>
3134#elif defined (HAVE_PAM_PAM_APPL_H)
3135#include <pam/pam_appl.h>
3136#endif
Tim Rice648f8762011-01-26 12:38:57 -08003137 ]], [[
3138(void)pam_strerror((pam_handle_t *)NULL, -1);
3139 ]])], [AC_MSG_RESULT([no])], [
3140 AC_DEFINE([HAVE_OLD_PAM], [1],
Darren Tucker3e6bde42006-08-20 20:03:50 +10003141 [Define if you have an old version of PAM
3142 which takes only one argument to pam_strerror])
Tim Rice648f8762011-01-26 12:38:57 -08003143 AC_MSG_RESULT([yes])
Darren Tucker3e6bde42006-08-20 20:03:50 +10003144 PAM_MSG="yes (old library)"
Damien Miller72ef7c12015-01-15 02:21:31 +11003145
Tim Rice648f8762011-01-26 12:38:57 -08003146 ])
Darren Tucker3e6bde42006-08-20 20:03:50 +10003147fi
Damien Miller6c21c512002-01-22 21:57:53 +11003148
Damien Miller6482d902014-05-27 14:34:42 +10003149case "$host" in
3150*-*-cygwin*)
3151 SSH_PRIVSEP_USER=CYGWIN_SSH_PRIVSEP_USER
3152 ;;
3153*)
3154 SSH_PRIVSEP_USER=sshd
3155 ;;
3156esac
Tim Rice648f8762011-01-26 12:38:57 -08003157AC_ARG_WITH([privsep-user],
Kevin Stevesc81e1292002-05-13 03:51:40 +00003158 [ --with-privsep-user=user Specify non-privileged user for privilege separation],
Kevin Steves7ff91122002-04-07 19:22:54 +00003159 [
Tim Rice35cc69d2005-03-17 16:44:25 -08003160 if test -n "$withval" && test "x$withval" != "xno" && \
3161 test "x${withval}" != "xyes"; then
Damien Millerd3f6ad22002-06-25 10:24:47 +10003162 SSH_PRIVSEP_USER=$withval
Kevin Steves7ff91122002-04-07 19:22:54 +00003163 fi
Tim Riceeae17cc2005-03-17 16:52:20 -08003164 ]
Kevin Steves7ff91122002-04-07 19:22:54 +00003165)
Damien Miller6482d902014-05-27 14:34:42 +10003166if test "x$SSH_PRIVSEP_USER" = "xCYGWIN_SSH_PRIVSEP_USER" ; then
3167 AC_DEFINE_UNQUOTED([SSH_PRIVSEP_USER], [CYGWIN_SSH_PRIVSEP_USER],
3168 [Cygwin function to fetch non-privileged user for privilege separation])
3169else
3170 AC_DEFINE_UNQUOTED([SSH_PRIVSEP_USER], ["$SSH_PRIVSEP_USER"],
3171 [non-privileged user for privilege separation])
3172fi
Tim Rice648f8762011-01-26 12:38:57 -08003173AC_SUBST([SSH_PRIVSEP_USER])
Kevin Steves7ff91122002-04-07 19:22:54 +00003174
Damien Miller91f40d82013-02-22 11:37:00 +11003175if test "x$have_linux_no_new_privs" = "x1" ; then
3176AC_CHECK_DECL([SECCOMP_MODE_FILTER], [have_seccomp_filter=1], , [
3177 #include <sys/types.h>
3178 #include <linux/seccomp.h>
3179])
3180fi
3181if test "x$have_seccomp_filter" = "x1" ; then
3182AC_MSG_CHECKING([kernel for seccomp_filter support])
3183AC_LINK_IFELSE([AC_LANG_PROGRAM([[
3184 #include <errno.h>
3185 #include <elf.h>
3186 #include <linux/audit.h>
3187 #include <linux/seccomp.h>
3188 #include <stdlib.h>
3189 #include <sys/prctl.h>
3190 ]],
3191 [[ int i = $seccomp_audit_arch;
3192 errno = 0;
3193 prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, NULL, 0, 0);
3194 exit(errno == EFAULT ? 0 : 1); ]])],
3195 [ AC_MSG_RESULT([yes]) ], [
3196 AC_MSG_RESULT([no])
3197 # Disable seccomp filter as a target
3198 have_seccomp_filter=0
3199 ]
3200)
3201fi
3202
Damien Miller69ff1df2011-06-23 08:30:03 +10003203# Decide which sandbox style to use
3204sandbox_arg=""
3205AC_ARG_WITH([sandbox],
deraadt@openbsd.org2539dce2015-10-09 01:37:08 +00003206 [ --with-sandbox=style Specify privilege separation sandbox (no, capsicum, darwin, rlimit, seccomp_filter, systrace, pledge)],
Damien Miller69ff1df2011-06-23 08:30:03 +10003207 [
3208 if test "x$withval" = "xyes" ; then
3209 sandbox_arg=""
3210 else
3211 sandbox_arg="$withval"
3212 fi
3213 ]
3214)
Darren Tucker60395f92012-07-03 14:31:18 +10003215
3216# Some platforms (seems to be the ones that have a kernel poll(2)-type
3217# function with which they implement select(2)) use an extra file descriptor
3218# when calling select(2), which means we can't use the rlimit sandbox.
3219AC_MSG_CHECKING([if select works with descriptor rlimit])
3220AC_RUN_IFELSE(
3221 [AC_LANG_PROGRAM([[
3222#include <sys/types.h>
3223#ifdef HAVE_SYS_TIME_H
3224# include <sys/time.h>
3225#endif
3226#include <sys/resource.h>
3227#ifdef HAVE_SYS_SELECT_H
3228# include <sys/select.h>
3229#endif
3230#include <errno.h>
3231#include <fcntl.h>
3232#include <stdlib.h>
3233 ]],[[
3234 struct rlimit rl_zero;
3235 int fd, r;
3236 fd_set fds;
Damien Millere4f43472013-03-08 12:14:22 +11003237 struct timeval tv;
Darren Tucker60395f92012-07-03 14:31:18 +10003238
3239 fd = open("/dev/null", O_RDONLY);
3240 FD_ZERO(&fds);
3241 FD_SET(fd, &fds);
3242 rl_zero.rlim_cur = rl_zero.rlim_max = 0;
3243 setrlimit(RLIMIT_FSIZE, &rl_zero);
3244 setrlimit(RLIMIT_NOFILE, &rl_zero);
Damien Millere4f43472013-03-08 12:14:22 +11003245 tv.tv_sec = 1;
3246 tv.tv_usec = 0;
3247 r = select(fd+1, &fds, NULL, NULL, &tv);
Darren Tucker60395f92012-07-03 14:31:18 +10003248 exit (r == -1 ? 1 : 0);
3249 ]])],
3250 [AC_MSG_RESULT([yes])
3251 select_works_with_rlimit=yes],
3252 [AC_MSG_RESULT([no])
3253 select_works_with_rlimit=no],
Mike Frysingerdcc714c2017-05-24 23:21:19 -04003254 [AC_MSG_WARN([cross compiling: assuming yes])
3255 select_works_with_rlimit=yes]
Darren Tucker60395f92012-07-03 14:31:18 +10003256)
3257
Darren Tuckerff008de2013-03-06 17:48:48 +11003258AC_MSG_CHECKING([if setrlimit(RLIMIT_NOFILE,{0,0}) works])
3259AC_RUN_IFELSE(
3260 [AC_LANG_PROGRAM([[
3261#include <sys/types.h>
3262#ifdef HAVE_SYS_TIME_H
3263# include <sys/time.h>
3264#endif
3265#include <sys/resource.h>
3266#include <errno.h>
3267#include <stdlib.h>
3268 ]],[[
3269 struct rlimit rl_zero;
3270 int fd, r;
3271 fd_set fds;
3272
3273 rl_zero.rlim_cur = rl_zero.rlim_max = 0;
3274 r = setrlimit(RLIMIT_NOFILE, &rl_zero);
3275 exit (r == -1 ? 1 : 0);
3276 ]])],
3277 [AC_MSG_RESULT([yes])
3278 rlimit_nofile_zero_works=yes],
3279 [AC_MSG_RESULT([no])
3280 rlimit_nofile_zero_works=no],
Mike Frysingerdcc714c2017-05-24 23:21:19 -04003281 [AC_MSG_WARN([cross compiling: assuming yes])
3282 rlimit_nofile_zero_works=yes]
Darren Tuckerff008de2013-03-06 17:48:48 +11003283)
3284
Darren Tuckerd545a4b2012-07-03 22:48:31 +10003285AC_MSG_CHECKING([if setrlimit RLIMIT_FSIZE works])
3286AC_RUN_IFELSE(
3287 [AC_LANG_PROGRAM([[
3288#include <sys/types.h>
3289#include <sys/resource.h>
3290#include <stdlib.h>
3291 ]],[[
3292 struct rlimit rl_zero;
3293
3294 rl_zero.rlim_cur = rl_zero.rlim_max = 0;
3295 exit(setrlimit(RLIMIT_FSIZE, &rl_zero) != 0);
3296 ]])],
3297 [AC_MSG_RESULT([yes])],
3298 [AC_MSG_RESULT([no])
3299 AC_DEFINE(SANDBOX_SKIP_RLIMIT_FSIZE, 1,
3300 [setrlimit RLIMIT_FSIZE works])],
3301 [AC_MSG_WARN([cross compiling: assuming yes])]
3302)
3303
deraadt@openbsd.org2539dce2015-10-09 01:37:08 +00003304if test "x$sandbox_arg" = "xpledge" || \
3305 ( test -z "$sandbox_arg" && test "x$ac_cv_func_pledge" = "xyes" ) ; then
3306 test "x$ac_cv_func_pledge" != "xyes" && \
3307 AC_MSG_ERROR([pledge sandbox requires pledge(2) support])
3308 SANDBOX_STYLE="pledge"
Damien Millerfafe1d82015-10-14 09:22:15 -07003309 AC_DEFINE([SANDBOX_PLEDGE], [1], [Sandbox using pledge(2)])
Damien Miller9846a2f2015-10-08 04:30:48 +11003310elif test "x$sandbox_arg" = "xsystrace" || \
Damien Miller69ff1df2011-06-23 08:30:03 +10003311 ( test -z "$sandbox_arg" && test "x$have_systr_policy_kill" = "x1" ) ; then
Damien Miller1a91c0f2011-08-17 11:59:25 +10003312 test "x$have_systr_policy_kill" != "x1" && \
3313 AC_MSG_ERROR([systrace sandbox requires systrace headers and SYSTR_POLICY_KILL support])
Damien Miller69ff1df2011-06-23 08:30:03 +10003314 SANDBOX_STYLE="systrace"
3315 AC_DEFINE([SANDBOX_SYSTRACE], [1], [Sandbox using systrace(4)])
Damien Millercd5e52e2011-06-27 07:18:18 +10003316elif test "x$sandbox_arg" = "xdarwin" || \
3317 ( test -z "$sandbox_arg" && test "x$ac_cv_func_sandbox_init" = "xyes" && \
3318 test "x$ac_cv_header_sandbox_h" = "xyes") ; then
Damien Miller1a91c0f2011-08-17 11:59:25 +10003319 test "x$ac_cv_func_sandbox_init" != "xyes" -o \
3320 "x$ac_cv_header_sandbox_h" != "xyes" && \
3321 AC_MSG_ERROR([Darwin seatbelt sandbox requires sandbox.h and sandbox_init function])
Damien Millercd5e52e2011-06-27 07:18:18 +10003322 SANDBOX_STYLE="darwin"
3323 AC_DEFINE([SANDBOX_DARWIN], [1], [Sandbox using Darwin sandbox_init(3)])
Damien Millere0956e32012-04-04 11:27:54 +10003324elif test "x$sandbox_arg" = "xseccomp_filter" || \
3325 ( test -z "$sandbox_arg" && \
Darren Tuckerd0494fd2012-05-19 14:25:39 +10003326 test "x$have_seccomp_filter" = "x1" && \
Damien Miller91f40d82013-02-22 11:37:00 +11003327 test "x$ac_cv_header_elf_h" = "xyes" && \
Damien Millere0956e32012-04-04 11:27:54 +10003328 test "x$ac_cv_header_linux_audit_h" = "xyes" && \
Damien Miller91f40d82013-02-22 11:37:00 +11003329 test "x$ac_cv_header_linux_filter_h" = "xyes" && \
3330 test "x$seccomp_audit_arch" != "x" && \
Damien Millere0956e32012-04-04 11:27:54 +10003331 test "x$have_linux_no_new_privs" = "x1" && \
3332 test "x$ac_cv_func_prctl" = "xyes" ) ; then
Damien Miller91f40d82013-02-22 11:37:00 +11003333 test "x$seccomp_audit_arch" = "x" && \
Damien Millere0956e32012-04-04 11:27:54 +10003334 AC_MSG_ERROR([seccomp_filter sandbox not supported on $host])
3335 test "x$have_linux_no_new_privs" != "x1" && \
3336 AC_MSG_ERROR([seccomp_filter sandbox requires PR_SET_NO_NEW_PRIVS])
3337 test "x$have_seccomp_filter" != "x1" && \
3338 AC_MSG_ERROR([seccomp_filter sandbox requires seccomp headers])
3339 test "x$ac_cv_func_prctl" != "xyes" && \
3340 AC_MSG_ERROR([seccomp_filter sandbox requires prctl function])
3341 SANDBOX_STYLE="seccomp_filter"
3342 AC_DEFINE([SANDBOX_SECCOMP_FILTER], [1], [Sandbox using seccomp filter])
Damien Millerf62ecef2014-01-25 12:34:38 +11003343elif test "x$sandbox_arg" = "xcapsicum" || \
3344 ( test -z "$sandbox_arg" && \
Darren Tuckerdd9d9b32017-08-28 16:48:27 +10003345 test "x$ac_cv_header_sys_capsicum_h" = "xyes" && \
Damien Miller603b8f42014-01-25 13:16:59 +11003346 test "x$ac_cv_func_cap_rights_limit" = "xyes") ; then
Darren Tuckerdd9d9b32017-08-28 16:48:27 +10003347 test "x$ac_cv_header_sys_capsicum_h" != "xyes" && \
3348 AC_MSG_ERROR([capsicum sandbox requires sys/capsicum.h header])
Damien Miller603b8f42014-01-25 13:16:59 +11003349 test "x$ac_cv_func_cap_rights_limit" != "xyes" && \
Damien Millerc96d8532014-01-25 13:12:28 +11003350 AC_MSG_ERROR([capsicum sandbox requires cap_rights_limit function])
Damien Millerf62ecef2014-01-25 12:34:38 +11003351 SANDBOX_STYLE="capsicum"
3352 AC_DEFINE([SANDBOX_CAPSICUM], [1], [Sandbox using capsicum])
Damien Miller69ff1df2011-06-23 08:30:03 +10003353elif test "x$sandbox_arg" = "xrlimit" || \
Darren Tucker60395f92012-07-03 14:31:18 +10003354 ( test -z "$sandbox_arg" && test "x$ac_cv_func_setrlimit" = "xyes" && \
Darren Tuckerff008de2013-03-06 17:48:48 +11003355 test "x$select_works_with_rlimit" = "xyes" && \
3356 test "x$rlimit_nofile_zero_works" = "xyes" ) ; then
Damien Miller1a91c0f2011-08-17 11:59:25 +10003357 test "x$ac_cv_func_setrlimit" != "xyes" && \
3358 AC_MSG_ERROR([rlimit sandbox requires setrlimit function])
Darren Tucker60395f92012-07-03 14:31:18 +10003359 test "x$select_works_with_rlimit" != "xyes" && \
3360 AC_MSG_ERROR([rlimit sandbox requires select to work with rlimit])
Damien Miller69ff1df2011-06-23 08:30:03 +10003361 SANDBOX_STYLE="rlimit"
3362 AC_DEFINE([SANDBOX_RLIMIT], [1], [Sandbox using setrlimit(2)])
Damien Miller4626cba2016-01-08 14:24:56 +11003363elif test "x$sandbox_arg" = "xsolaris" || \
3364 ( test -z "$sandbox_arg" && test "x$SOLARIS_PRIVS" = "xyes" ) ; then
3365 SANDBOX_STYLE="solaris"
3366 AC_DEFINE([SANDBOX_SOLARIS], [1], [Sandbox using Solaris/Illumos privileges])
Damien Miller69ff1df2011-06-23 08:30:03 +10003367elif test -z "$sandbox_arg" || test "x$sandbox_arg" = "xno" || \
3368 test "x$sandbox_arg" = "xnone" || test "x$sandbox_arg" = "xnull" ; then
3369 SANDBOX_STYLE="none"
3370 AC_DEFINE([SANDBOX_NULL], [1], [no privsep sandboxing])
3371else
Tim Ricea6e60612011-08-17 21:48:22 -07003372 AC_MSG_ERROR([unsupported --with-sandbox])
Damien Miller69ff1df2011-06-23 08:30:03 +10003373fi
3374
Ben Lindstromb5628642000-10-18 00:02:25 +00003375# Cheap hack to ensure NEWS-OS libraries are arranged right.
3376if test ! -z "$SONY" ; then
3377 LIBS="$LIBS -liberty";
3378fi
3379
Damien Miller57f39152005-11-24 19:58:19 +11003380# Check for long long datatypes
3381AC_CHECK_TYPES([long long, unsigned long long, long double])
3382
3383# Check datatype sizes
Tim Rice648f8762011-01-26 12:38:57 -08003384AC_CHECK_SIZEOF([short int], [2])
3385AC_CHECK_SIZEOF([int], [4])
3386AC_CHECK_SIZEOF([long int], [4])
3387AC_CHECK_SIZEOF([long long int], [8])
Damien Millerc6398ef1999-11-20 12:18:40 +11003388
Damien Millerfa2bb692002-04-23 23:22:25 +10003389# Sanity check long long for some platforms (AIX)
3390if test "x$ac_cv_sizeof_long_long_int" = "x4" ; then
3391 ac_cv_sizeof_long_long_int=0
3392fi
3393
Darren Tucker537f1ed2005-10-25 18:38:33 +10003394# compute LLONG_MIN and LLONG_MAX if we don't know them.
3395if test -z "$have_llong_max"; then
3396 AC_MSG_CHECKING([for max value of long long])
3397 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08003398 [AC_LANG_PROGRAM([[
Darren Tucker537f1ed2005-10-25 18:38:33 +10003399#include <stdio.h>
3400/* Why is this so damn hard? */
3401#ifdef __GNUC__
3402# undef __GNUC__
3403#endif
3404#define __USE_ISOC99
3405#include <limits.h>
3406#define DATA "conftest.llminmax"
Darren Tuckerd1450db2006-03-13 19:06:51 +11003407#define my_abs(a) ((a) < 0 ? ((a) * -1) : (a))
3408
3409/*
3410 * printf in libc on some platforms (eg old Tru64) does not understand %lld so
3411 * we do this the hard way.
3412 */
3413static int
3414fprint_ll(FILE *f, long long n)
3415{
3416 unsigned int i;
3417 int l[sizeof(long long) * 8];
3418
3419 if (n < 0)
3420 if (fprintf(f, "-") < 0)
3421 return -1;
3422 for (i = 0; n != 0; i++) {
3423 l[i] = my_abs(n % 10);
3424 n /= 10;
3425 }
3426 do {
3427 if (fprintf(f, "%d", l[--i]) < 0)
3428 return -1;
3429 } while (i != 0);
3430 if (fprintf(f, " ") < 0)
3431 return -1;
3432 return 0;
3433}
Tim Rice648f8762011-01-26 12:38:57 -08003434 ]], [[
Darren Tucker537f1ed2005-10-25 18:38:33 +10003435 FILE *f;
3436 long long i, llmin, llmax = 0;
3437
3438 if((f = fopen(DATA,"w")) == NULL)
3439 exit(1);
3440
3441#if defined(LLONG_MIN) && defined(LLONG_MAX)
3442 fprintf(stderr, "Using system header for LLONG_MIN and LLONG_MAX\n");
3443 llmin = LLONG_MIN;
3444 llmax = LLONG_MAX;
3445#else
3446 fprintf(stderr, "Calculating LLONG_MIN and LLONG_MAX\n");
3447 /* This will work on one's complement and two's complement */
3448 for (i = 1; i > llmax; i <<= 1, i++)
3449 llmax = i;
3450 llmin = llmax + 1LL; /* wrap */
3451#endif
3452
3453 /* Sanity check */
3454 if (llmin + 1 < llmin || llmin - 1 < llmin || llmax + 1 > llmax
Darren Tuckerd1450db2006-03-13 19:06:51 +11003455 || llmax - 1 > llmax || llmin == llmax || llmin == 0
3456 || llmax == 0 || llmax < LONG_MAX || llmin > LONG_MIN) {
Darren Tucker537f1ed2005-10-25 18:38:33 +10003457 fprintf(f, "unknown unknown\n");
3458 exit(2);
3459 }
3460
Darren Tuckerd1450db2006-03-13 19:06:51 +11003461 if (fprint_ll(f, llmin) < 0)
Darren Tucker537f1ed2005-10-25 18:38:33 +10003462 exit(3);
Darren Tuckerd1450db2006-03-13 19:06:51 +11003463 if (fprint_ll(f, llmax) < 0)
3464 exit(4);
3465 if (fclose(f) < 0)
3466 exit(5);
Darren Tucker537f1ed2005-10-25 18:38:33 +10003467 exit(0);
Darren Tucker537f1ed2005-10-25 18:38:33 +10003468 ]])],
3469 [
3470 llong_min=`$AWK '{print $1}' conftest.llminmax`
3471 llong_max=`$AWK '{print $2}' conftest.llminmax`
3472
Tim Rice648f8762011-01-26 12:38:57 -08003473 AC_MSG_RESULT([$llong_max])
3474 AC_DEFINE_UNQUOTED([LLONG_MAX], [${llong_max}LL],
Darren Tucker537f1ed2005-10-25 18:38:33 +10003475 [max value of long long calculated by configure])
3476 AC_MSG_CHECKING([for min value of long long])
Tim Rice648f8762011-01-26 12:38:57 -08003477 AC_MSG_RESULT([$llong_min])
3478 AC_DEFINE_UNQUOTED([LLONG_MIN], [${llong_min}LL],
Darren Tucker537f1ed2005-10-25 18:38:33 +10003479 [min value of long long calculated by configure])
3480 ],
3481 [
Tim Rice648f8762011-01-26 12:38:57 -08003482 AC_MSG_RESULT([not found])
Darren Tucker537f1ed2005-10-25 18:38:33 +10003483 ],
3484 [
3485 AC_MSG_WARN([cross compiling: not checking])
3486 ]
3487 )
3488fi
3489
3490
Damien Millera22ba012000-03-02 23:09:20 +11003491# More checks for data types
Damien Millercaf6dd62000-08-29 11:33:50 +11003492AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [
Tim Rice648f8762011-01-26 12:38:57 -08003493 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3494 [[ u_int a; a = 1;]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003495 [ ac_cv_have_u_int="yes" ], [ ac_cv_have_u_int="no"
Tim Rice648f8762011-01-26 12:38:57 -08003496 ])
Damien Millercaf6dd62000-08-29 11:33:50 +11003497])
3498if test "x$ac_cv_have_u_int" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003499 AC_DEFINE([HAVE_U_INT], [1], [define if you have u_int data type])
Damien Millercaf6dd62000-08-29 11:33:50 +11003500 have_u_int=1
3501fi
3502
Damien Miller61e50f12000-05-08 20:49:37 +10003503AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003504 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3505 [[ int8_t a; int16_t b; int32_t c; a = b = c = 1;]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003506 [ ac_cv_have_intxx_t="yes" ], [ ac_cv_have_intxx_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003507 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003508])
3509if test "x$ac_cv_have_intxx_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003510 AC_DEFINE([HAVE_INTXX_T], [1], [define if you have intxx_t data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003511 have_intxx_t=1
3512fi
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003513
3514if (test -z "$have_intxx_t" && \
Damien Millera8e06ce2003-11-21 23:48:55 +11003515 test "x$ac_cv_header_stdint_h" = "xyes")
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003516then
3517 AC_MSG_CHECKING([for intXX_t types in stdint.h])
Tim Rice648f8762011-01-26 12:38:57 -08003518 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdint.h> ]],
3519 [[ int8_t a; int16_t b; int32_t c; a = b = c = 1;]])],
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003520 [
Tim Rice648f8762011-01-26 12:38:57 -08003521 AC_DEFINE([HAVE_INTXX_T])
3522 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003523 ], [ AC_MSG_RESULT([no])
Tim Rice648f8762011-01-26 12:38:57 -08003524 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003525fi
3526
Damien Miller578783e2000-09-23 14:12:24 +11003527AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003528 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Tim Rice907881e2002-07-18 11:44:50 -07003529#include <sys/types.h>
3530#ifdef HAVE_STDINT_H
3531# include <stdint.h>
3532#endif
3533#include <sys/socket.h>
3534#ifdef HAVE_SYS_BITYPES_H
3535# include <sys/bitypes.h>
3536#endif
Tim Rice648f8762011-01-26 12:38:57 -08003537 ]], [[
3538int64_t a; a = 1;
3539 ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003540 [ ac_cv_have_int64_t="yes" ], [ ac_cv_have_int64_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003541 ])
Damien Miller578783e2000-09-23 14:12:24 +11003542])
3543if test "x$ac_cv_have_int64_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003544 AC_DEFINE([HAVE_INT64_T], [1], [define if you have int64_t data type])
Tim Rice4cec93f2002-02-26 08:40:48 -08003545fi
3546
Damien Miller61e50f12000-05-08 20:49:37 +10003547AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003548 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3549 [[ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003550 [ ac_cv_have_u_intxx_t="yes" ], [ ac_cv_have_u_intxx_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003551 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003552])
3553if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003554 AC_DEFINE([HAVE_U_INTXX_T], [1], [define if you have u_intxx_t data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003555 have_u_intxx_t=1
3556fi
Damien Millerc6398ef1999-11-20 12:18:40 +11003557
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003558if test -z "$have_u_intxx_t" ; then
3559 AC_MSG_CHECKING([for u_intXX_t types in sys/socket.h])
Tim Rice648f8762011-01-26 12:38:57 -08003560 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/socket.h> ]],
3561 [[ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;]])],
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003562 [
Tim Rice648f8762011-01-26 12:38:57 -08003563 AC_DEFINE([HAVE_U_INTXX_T])
3564 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003565 ], [ AC_MSG_RESULT([no])
Tim Rice648f8762011-01-26 12:38:57 -08003566 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003567fi
3568
Damien Miller578783e2000-09-23 14:12:24 +11003569AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003570 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3571 [[ u_int64_t a; a = 1;]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003572 [ ac_cv_have_u_int64_t="yes" ], [ ac_cv_have_u_int64_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003573 ])
Damien Miller578783e2000-09-23 14:12:24 +11003574])
3575if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003576 AC_DEFINE([HAVE_U_INT64_T], [1], [define if you have u_int64_t data type])
Damien Miller578783e2000-09-23 14:12:24 +11003577 have_u_int64_t=1
3578fi
3579
Damien Millerc2868192014-01-30 10:21:19 +11003580if (test -z "$have_u_int64_t" && \
3581 test "x$ac_cv_header_sys_bitypes_h" = "xyes")
3582then
Tim Rice4cec93f2002-02-26 08:40:48 -08003583 AC_MSG_CHECKING([for u_int64_t type in sys/bitypes.h])
Tim Rice648f8762011-01-26 12:38:57 -08003584 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/bitypes.h> ]],
3585 [[ u_int64_t a; a = 1]])],
Tim Rice4cec93f2002-02-26 08:40:48 -08003586 [
Tim Rice648f8762011-01-26 12:38:57 -08003587 AC_DEFINE([HAVE_U_INT64_T])
3588 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003589 ], [ AC_MSG_RESULT([no])
Tim Rice648f8762011-01-26 12:38:57 -08003590 ])
Tim Rice4cec93f2002-02-26 08:40:48 -08003591fi
3592
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003593if test -z "$have_u_intxx_t" ; then
3594 AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003595 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003596#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08003597 ]], [[
3598 uint8_t a;
3599 uint16_t b;
3600 uint32_t c;
3601 a = b = c = 1;
3602 ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003603 [ ac_cv_have_uintxx_t="yes" ], [ ac_cv_have_uintxx_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003604 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003605 ])
3606 if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003607 AC_DEFINE([HAVE_UINTXX_T], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003608 [define if you have uintxx_t data type])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003609 fi
3610fi
3611
Damien Millerc2868192014-01-30 10:21:19 +11003612if (test -z "$have_uintxx_t" && \
3613 test "x$ac_cv_header_stdint_h" = "xyes")
3614then
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003615 AC_MSG_CHECKING([for uintXX_t types in stdint.h])
Tim Rice648f8762011-01-26 12:38:57 -08003616 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdint.h> ]],
3617 [[ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;]])],
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003618 [
Tim Rice648f8762011-01-26 12:38:57 -08003619 AC_DEFINE([HAVE_UINTXX_T])
3620 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003621 ], [ AC_MSG_RESULT([no])
Tim Rice648f8762011-01-26 12:38:57 -08003622 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003623fi
3624
Damien Millerc2868192014-01-30 10:21:19 +11003625if (test -z "$have_uintxx_t" && \
3626 test "x$ac_cv_header_inttypes_h" = "xyes")
3627then
Darren Tucker6d725682014-01-17 19:17:34 +11003628 AC_MSG_CHECKING([for uintXX_t types in inttypes.h])
3629 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <inttypes.h> ]],
3630 [[ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;]])],
3631 [
3632 AC_DEFINE([HAVE_UINTXX_T])
3633 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003634 ], [ AC_MSG_RESULT([no])
Darren Tucker6d725682014-01-17 19:17:34 +11003635 ])
3636fi
3637
Damien Milleredb82922000-06-20 13:25:52 +10003638if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
Damien Millera8e06ce2003-11-21 23:48:55 +11003639 test "x$ac_cv_header_sys_bitypes_h" = "xyes")
Damien Millerb29ea912000-01-15 14:12:03 +11003640then
3641 AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
Tim Rice648f8762011-01-26 12:38:57 -08003642 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller61e50f12000-05-08 20:49:37 +10003643#include <sys/bitypes.h>
Tim Rice648f8762011-01-26 12:38:57 -08003644 ]], [[
Damien Miller70494d12000-04-03 15:57:06 +10003645 int8_t a; int16_t b; int32_t c;
3646 u_int8_t e; u_int16_t f; u_int32_t g;
3647 a = b = c = e = f = g = 1;
Tim Rice648f8762011-01-26 12:38:57 -08003648 ]])],
Damien Millerb29ea912000-01-15 14:12:03 +11003649 [
Tim Rice648f8762011-01-26 12:38:57 -08003650 AC_DEFINE([HAVE_U_INTXX_T])
3651 AC_DEFINE([HAVE_INTXX_T])
3652 AC_MSG_RESULT([yes])
3653 ], [AC_MSG_RESULT([no])
3654 ])
Damien Millerb29ea912000-01-15 14:12:03 +11003655fi
3656
Damien Miller58be7382001-09-15 21:31:54 +10003657
3658AC_CACHE_CHECK([for u_char], ac_cv_have_u_char, [
Tim Rice648f8762011-01-26 12:38:57 -08003659 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3660 [[ u_char foo; foo = 125; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003661 [ ac_cv_have_u_char="yes" ], [ ac_cv_have_u_char="no"
Tim Rice648f8762011-01-26 12:38:57 -08003662 ])
Damien Miller58be7382001-09-15 21:31:54 +10003663])
3664if test "x$ac_cv_have_u_char" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003665 AC_DEFINE([HAVE_U_CHAR], [1], [define if you have u_char data type])
Damien Miller58be7382001-09-15 21:31:54 +10003666fi
3667
Darren Tucker007e3b32013-11-03 18:43:55 +11003668AC_CHECK_TYPES([intmax_t, uintmax_t], , , [
3669#include <sys/types.h>
3670#include <stdint.h>
3671])
3672
Tim Rice13aae5e2001-10-21 17:53:58 -07003673TYPE_SOCKLEN_T
Damien Miller74d0d4a1999-12-29 02:24:35 +11003674
Tim Rice648f8762011-01-26 12:38:57 -08003675AC_CHECK_TYPES([sig_atomic_t], , , [#include <signal.h>])
3676AC_CHECK_TYPES([fsblkcnt_t, fsfilcnt_t], , , [
Darren Tucker598eaa62008-06-09 03:32:29 +10003677#include <sys/types.h>
3678#ifdef HAVE_SYS_BITYPES_H
3679#include <sys/bitypes.h>
3680#endif
3681#ifdef HAVE_SYS_STATFS_H
3682#include <sys/statfs.h>
3683#endif
3684#ifdef HAVE_SYS_STATVFS_H
3685#include <sys/statvfs.h>
3686#endif
3687])
Tim Rice4cec93f2002-02-26 08:40:48 -08003688
Darren Tucker11057562018-02-25 11:22:57 +11003689AC_CHECK_MEMBERS([struct statfs.f_flags], [], [], [[
3690#include <sys/types.h>
3691#ifdef HAVE_SYS_BITYPES_H
3692#include <sys/bitypes.h>
3693#endif
3694#ifdef HAVE_SYS_STATFS_H
3695#include <sys/statfs.h>
3696#endif
3697#ifdef HAVE_SYS_STATVFS_H
3698#include <sys/statvfs.h>
3699#endif
3700#ifdef HAVE_SYS_VFS_H
3701#include <sys/vfs.h>
3702#endif
3703]])
3704
3705
Tim Rice648f8762011-01-26 12:38:57 -08003706AC_CHECK_TYPES([in_addr_t, in_port_t], , ,
Damien Miller848b9932005-02-24 12:12:34 +11003707[#include <sys/types.h>
3708#include <netinet/in.h>])
Darren Tuckerd9f88912005-02-20 21:01:48 +11003709
Damien Miller61e50f12000-05-08 20:49:37 +10003710AC_CACHE_CHECK([for size_t], ac_cv_have_size_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003711 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3712 [[ size_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003713 [ ac_cv_have_size_t="yes" ], [ ac_cv_have_size_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003714 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003715])
3716if test "x$ac_cv_have_size_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003717 AC_DEFINE([HAVE_SIZE_T], [1], [define if you have size_t data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003718fi
Damien Miller95058511999-12-29 10:36:45 +11003719
Damien Miller615f9392000-05-17 22:53:33 +10003720AC_CACHE_CHECK([for ssize_t], ac_cv_have_ssize_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003721 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3722 [[ ssize_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003723 [ ac_cv_have_ssize_t="yes" ], [ ac_cv_have_ssize_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003724 ])
Damien Miller615f9392000-05-17 22:53:33 +10003725])
3726if test "x$ac_cv_have_ssize_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003727 AC_DEFINE([HAVE_SSIZE_T], [1], [define if you have ssize_t data type])
Damien Miller615f9392000-05-17 22:53:33 +10003728fi
3729
Ben Lindstrom0d5af602001-01-09 00:50:29 +00003730AC_CACHE_CHECK([for clock_t], ac_cv_have_clock_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003731 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <time.h> ]],
3732 [[ clock_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003733 [ ac_cv_have_clock_t="yes" ], [ ac_cv_have_clock_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003734 ])
Ben Lindstrom0d5af602001-01-09 00:50:29 +00003735])
3736if test "x$ac_cv_have_clock_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003737 AC_DEFINE([HAVE_CLOCK_T], [1], [define if you have clock_t data type])
Ben Lindstrom0d5af602001-01-09 00:50:29 +00003738fi
3739
Damien Millerb54b40e2000-06-23 08:23:34 +10003740AC_CACHE_CHECK([for sa_family_t], ac_cv_have_sa_family_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003741 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Millerb54b40e2000-06-23 08:23:34 +10003742#include <sys/types.h>
3743#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08003744 ]], [[ sa_family_t foo; foo = 1235; ]])],
3745 [ ac_cv_have_sa_family_t="yes" ],
3746 [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller78315eb2000-09-29 23:01:36 +11003747#include <sys/types.h>
3748#include <sys/socket.h>
3749#include <netinet/in.h>
Tim Rice648f8762011-01-26 12:38:57 -08003750 ]], [[ sa_family_t foo; foo = 1235; ]])],
Damien Miller78315eb2000-09-29 23:01:36 +11003751 [ ac_cv_have_sa_family_t="yes" ],
Damien Millerb54b40e2000-06-23 08:23:34 +10003752 [ ac_cv_have_sa_family_t="no" ]
3753 )
Tim Rice648f8762011-01-26 12:38:57 -08003754 ])
Damien Millerb54b40e2000-06-23 08:23:34 +10003755])
3756if test "x$ac_cv_have_sa_family_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003757 AC_DEFINE([HAVE_SA_FAMILY_T], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003758 [define if you have sa_family_t data type])
Damien Millerb54b40e2000-06-23 08:23:34 +10003759fi
3760
Damien Miller0f91b4e2000-06-18 15:43:25 +10003761AC_CACHE_CHECK([for pid_t], ac_cv_have_pid_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003762 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3763 [[ pid_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003764 [ ac_cv_have_pid_t="yes" ], [ ac_cv_have_pid_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003765 ])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003766])
3767if test "x$ac_cv_have_pid_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003768 AC_DEFINE([HAVE_PID_T], [1], [define if you have pid_t data type])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003769fi
3770
3771AC_CACHE_CHECK([for mode_t], ac_cv_have_mode_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003772 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3773 [[ mode_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003774 [ ac_cv_have_mode_t="yes" ], [ ac_cv_have_mode_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003775 ])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003776])
3777if test "x$ac_cv_have_mode_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003778 AC_DEFINE([HAVE_MODE_T], [1], [define if you have mode_t data type])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003779fi
3780
Damien Miller61e50f12000-05-08 20:49:37 +10003781
3782AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_have_struct_sockaddr_storage, [
Tim Rice648f8762011-01-26 12:38:57 -08003783 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10003784#include <sys/types.h>
3785#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08003786 ]], [[ struct sockaddr_storage s; ]])],
3787 [ ac_cv_have_struct_sockaddr_storage="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003788 [ ac_cv_have_struct_sockaddr_storage="no"
Tim Rice648f8762011-01-26 12:38:57 -08003789 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003790])
3791if test "x$ac_cv_have_struct_sockaddr_storage" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003792 AC_DEFINE([HAVE_STRUCT_SOCKADDR_STORAGE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003793 [define if you have struct sockaddr_storage data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003794fi
Damien Miller34132e52000-01-14 15:45:46 +11003795
Damien Miller61e50f12000-05-08 20:49:37 +10003796AC_CACHE_CHECK([for struct sockaddr_in6], ac_cv_have_struct_sockaddr_in6, [
Tim Rice648f8762011-01-26 12:38:57 -08003797 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller7b22d652000-06-18 14:07:04 +10003798#include <sys/types.h>
Damien Miller61e50f12000-05-08 20:49:37 +10003799#include <netinet/in.h>
Tim Rice648f8762011-01-26 12:38:57 -08003800 ]], [[ struct sockaddr_in6 s; s.sin6_family = 0; ]])],
3801 [ ac_cv_have_struct_sockaddr_in6="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003802 [ ac_cv_have_struct_sockaddr_in6="no"
Tim Rice648f8762011-01-26 12:38:57 -08003803 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003804])
3805if test "x$ac_cv_have_struct_sockaddr_in6" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003806 AC_DEFINE([HAVE_STRUCT_SOCKADDR_IN6], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003807 [define if you have struct sockaddr_in6 data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003808fi
Damien Miller34132e52000-01-14 15:45:46 +11003809
Damien Miller61e50f12000-05-08 20:49:37 +10003810AC_CACHE_CHECK([for struct in6_addr], ac_cv_have_struct_in6_addr, [
Tim Rice648f8762011-01-26 12:38:57 -08003811 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller7b22d652000-06-18 14:07:04 +10003812#include <sys/types.h>
Damien Miller61e50f12000-05-08 20:49:37 +10003813#include <netinet/in.h>
Tim Rice648f8762011-01-26 12:38:57 -08003814 ]], [[ struct in6_addr s; s.s6_addr[0] = 0; ]])],
3815 [ ac_cv_have_struct_in6_addr="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003816 [ ac_cv_have_struct_in6_addr="no"
Tim Rice648f8762011-01-26 12:38:57 -08003817 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003818])
3819if test "x$ac_cv_have_struct_in6_addr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003820 AC_DEFINE([HAVE_STRUCT_IN6_ADDR], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003821 [define if you have struct in6_addr data type])
Tim Rice0f4d2c02008-11-18 21:26:41 -08003822
3823dnl Now check for sin6_scope_id
Tim Rice648f8762011-01-26 12:38:57 -08003824 AC_CHECK_MEMBERS([struct sockaddr_in6.sin6_scope_id], , ,
Tim Rice0f4d2c02008-11-18 21:26:41 -08003825 [
3826#ifdef HAVE_SYS_TYPES_H
3827#include <sys/types.h>
3828#endif
3829#include <netinet/in.h>
3830 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003831fi
Damien Miller34132e52000-01-14 15:45:46 +11003832
Damien Miller61e50f12000-05-08 20:49:37 +10003833AC_CACHE_CHECK([for struct addrinfo], ac_cv_have_struct_addrinfo, [
Tim Rice648f8762011-01-26 12:38:57 -08003834 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10003835#include <sys/types.h>
3836#include <sys/socket.h>
3837#include <netdb.h>
Tim Rice648f8762011-01-26 12:38:57 -08003838 ]], [[ struct addrinfo s; s.ai_flags = AI_PASSIVE; ]])],
3839 [ ac_cv_have_struct_addrinfo="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003840 [ ac_cv_have_struct_addrinfo="no"
Tim Rice648f8762011-01-26 12:38:57 -08003841 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003842])
3843if test "x$ac_cv_have_struct_addrinfo" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003844 AC_DEFINE([HAVE_STRUCT_ADDRINFO], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003845 [define if you have struct addrinfo data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003846fi
3847
Ben Lindstrom42202bc2001-01-15 02:34:37 +00003848AC_CACHE_CHECK([for struct timeval], ac_cv_have_struct_timeval, [
Tim Rice648f8762011-01-26 12:38:57 -08003849 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/time.h> ]],
3850 [[ struct timeval tv; tv.tv_sec = 1;]])],
3851 [ ac_cv_have_struct_timeval="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003852 [ ac_cv_have_struct_timeval="no"
Tim Rice648f8762011-01-26 12:38:57 -08003853 ])
Ben Lindstrom42202bc2001-01-15 02:34:37 +00003854])
3855if test "x$ac_cv_have_struct_timeval" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003856 AC_DEFINE([HAVE_STRUCT_TIMEVAL], [1], [define if you have struct timeval])
Ben Lindstrom42202bc2001-01-15 02:34:37 +00003857 have_struct_timeval=1
3858fi
3859
Tim Rice648f8762011-01-26 12:38:57 -08003860AC_CHECK_TYPES([struct timespec])
Tim Rice4e4dc562003-03-18 10:21:40 -08003861
Damien Miller10479cc2018-04-10 10:19:02 +10003862# We need int64_t or else certain parts of the compile will fail.
Tim Rice8bb561b2005-03-17 16:23:19 -08003863if test "x$ac_cv_have_int64_t" = "xno" && \
3864 test "x$ac_cv_sizeof_long_int" != "x8" && \
3865 test "x$ac_cv_sizeof_long_long_int" = "x0" ; then
Ben Lindstrom5bd6eb72003-03-21 00:34:34 +00003866 echo "OpenSSH requires int64_t support. Contact your vendor or install"
3867 echo "an alternative compiler (I.E., GCC) before continuing."
3868 echo ""
3869 exit 1;
Tim Ricebee3f222001-03-11 17:32:12 -08003870else
3871dnl test snprintf (broken on SCO w/gcc)
Darren Tuckera0c2b392004-09-11 23:26:37 +10003872 AC_RUN_IFELSE(
Darren Tucker623d92f2004-09-12 22:36:15 +10003873 [AC_LANG_SOURCE([[
Tim Ricebee3f222001-03-11 17:32:12 -08003874#include <stdio.h>
3875#include <string.h>
3876#ifdef HAVE_SNPRINTF
3877main()
3878{
3879 char buf[50];
3880 char expected_out[50];
3881 int mazsize = 50 ;
3882#if (SIZEOF_LONG_INT == 8)
3883 long int num = 0x7fffffffffffffff;
3884#else
Kevin Steves6482ec82001-07-15 02:09:28 +00003885 long long num = 0x7fffffffffffffffll;
Tim Ricebee3f222001-03-11 17:32:12 -08003886#endif
3887 strcpy(expected_out, "9223372036854775807");
3888 snprintf(buf, mazsize, "%lld", num);
3889 if(strcmp(buf, expected_out) != 0)
Damien Millera8e06ce2003-11-21 23:48:55 +11003890 exit(1);
Tim Ricebee3f222001-03-11 17:32:12 -08003891 exit(0);
3892}
3893#else
3894main() { exit(0); }
3895#endif
Tim Rice648f8762011-01-26 12:38:57 -08003896 ]])], [ true ], [ AC_DEFINE([BROKEN_SNPRINTF]) ],
Darren Tuckera0c2b392004-09-11 23:26:37 +10003897 AC_MSG_WARN([cross compiling: Assuming working snprintf()])
Tim Ricebee3f222001-03-11 17:32:12 -08003898 )
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00003899fi
3900
Damien Miller78315eb2000-09-29 23:01:36 +11003901dnl Checks for structure members
Tim Rice648f8762011-01-26 12:38:57 -08003902OSSH_CHECK_HEADER_FOR_FIELD([ut_host], [utmp.h], [HAVE_HOST_IN_UTMP])
3903OSSH_CHECK_HEADER_FOR_FIELD([ut_host], [utmpx.h], [HAVE_HOST_IN_UTMPX])
3904OSSH_CHECK_HEADER_FOR_FIELD([syslen], [utmpx.h], [HAVE_SYSLEN_IN_UTMPX])
3905OSSH_CHECK_HEADER_FOR_FIELD([ut_pid], [utmp.h], [HAVE_PID_IN_UTMP])
3906OSSH_CHECK_HEADER_FOR_FIELD([ut_type], [utmp.h], [HAVE_TYPE_IN_UTMP])
3907OSSH_CHECK_HEADER_FOR_FIELD([ut_type], [utmpx.h], [HAVE_TYPE_IN_UTMPX])
3908OSSH_CHECK_HEADER_FOR_FIELD([ut_tv], [utmp.h], [HAVE_TV_IN_UTMP])
3909OSSH_CHECK_HEADER_FOR_FIELD([ut_id], [utmp.h], [HAVE_ID_IN_UTMP])
3910OSSH_CHECK_HEADER_FOR_FIELD([ut_id], [utmpx.h], [HAVE_ID_IN_UTMPX])
3911OSSH_CHECK_HEADER_FOR_FIELD([ut_addr], [utmp.h], [HAVE_ADDR_IN_UTMP])
3912OSSH_CHECK_HEADER_FOR_FIELD([ut_addr], [utmpx.h], [HAVE_ADDR_IN_UTMPX])
3913OSSH_CHECK_HEADER_FOR_FIELD([ut_addr_v6], [utmp.h], [HAVE_ADDR_V6_IN_UTMP])
3914OSSH_CHECK_HEADER_FOR_FIELD([ut_addr_v6], [utmpx.h], [HAVE_ADDR_V6_IN_UTMPX])
3915OSSH_CHECK_HEADER_FOR_FIELD([ut_exit], [utmp.h], [HAVE_EXIT_IN_UTMP])
3916OSSH_CHECK_HEADER_FOR_FIELD([ut_time], [utmp.h], [HAVE_TIME_IN_UTMP])
3917OSSH_CHECK_HEADER_FOR_FIELD([ut_time], [utmpx.h], [HAVE_TIME_IN_UTMPX])
3918OSSH_CHECK_HEADER_FOR_FIELD([ut_tv], [utmpx.h], [HAVE_TV_IN_UTMPX])
Tim Rice13aae5e2001-10-21 17:53:58 -07003919
3920AC_CHECK_MEMBERS([struct stat.st_blksize])
Damien Millerbcd14852017-06-10 23:41:25 +10003921AC_CHECK_MEMBERS([struct stat.st_mtim])
3922AC_CHECK_MEMBERS([struct stat.st_mtime])
Damien Miller6332da22013-04-23 14:25:52 +10003923AC_CHECK_MEMBERS([struct passwd.pw_gecos, struct passwd.pw_class,
3924struct passwd.pw_change, struct passwd.pw_expire],
3925[], [], [[
3926#include <sys/types.h>
3927#include <pwd.h>
3928]])
3929
Tim Rice648f8762011-01-26 12:38:57 -08003930AC_CHECK_MEMBER([struct __res_state.retrans], [], [AC_DEFINE([__res_state], [state],
Darren Tucker58e298d2005-11-25 13:14:58 +11003931 [Define if we don't have struct __res_state in resolv.h])],
Damien Miller6332da22013-04-23 14:25:52 +10003932[[
Darren Tucker58e298d2005-11-25 13:14:58 +11003933#include <stdio.h>
3934#if HAVE_SYS_TYPES_H
3935# include <sys/types.h>
3936#endif
3937#include <netinet/in.h>
3938#include <arpa/nameser.h>
3939#include <resolv.h>
Damien Miller6332da22013-04-23 14:25:52 +10003940]])
andre2ff7b5d2000-06-03 14:57:40 +00003941
Damien Miller61e50f12000-05-08 20:49:37 +10003942AC_CACHE_CHECK([for ss_family field in struct sockaddr_storage],
3943 ac_cv_have_ss_family_in_struct_ss, [
Tim Rice648f8762011-01-26 12:38:57 -08003944 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10003945#include <sys/types.h>
3946#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08003947 ]], [[ struct sockaddr_storage s; s.ss_family = 1; ]])],
3948 [ ac_cv_have_ss_family_in_struct_ss="yes" ],
3949 [ ac_cv_have_ss_family_in_struct_ss="no" ])
Damien Miller61e50f12000-05-08 20:49:37 +10003950])
3951if test "x$ac_cv_have_ss_family_in_struct_ss" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003952 AC_DEFINE([HAVE_SS_FAMILY_IN_SS], [1], [Fields in struct sockaddr_storage])
Damien Miller61e50f12000-05-08 20:49:37 +10003953fi
3954
Damien Miller61e50f12000-05-08 20:49:37 +10003955AC_CACHE_CHECK([for __ss_family field in struct sockaddr_storage],
3956 ac_cv_have___ss_family_in_struct_ss, [
Tim Rice648f8762011-01-26 12:38:57 -08003957 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10003958#include <sys/types.h>
3959#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08003960 ]], [[ struct sockaddr_storage s; s.__ss_family = 1; ]])],
3961 [ ac_cv_have___ss_family_in_struct_ss="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003962 [ ac_cv_have___ss_family_in_struct_ss="no"
Tim Rice648f8762011-01-26 12:38:57 -08003963 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003964])
3965if test "x$ac_cv_have___ss_family_in_struct_ss" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003966 AC_DEFINE([HAVE___SS_FAMILY_IN_SS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003967 [Fields in struct sockaddr_storage])
Damien Miller61e50f12000-05-08 20:49:37 +10003968fi
Damien Millerbf1c9b21999-12-09 10:16:54 +11003969
Tim Rice28bbb0c2002-05-27 17:37:32 -07003970dnl make sure we're using the real structure members and not defines
Kevin Steves939c9db2002-03-22 17:23:25 +00003971AC_CACHE_CHECK([for msg_accrights field in struct msghdr],
3972 ac_cv_have_accrights_in_msghdr, [
Tim Rice648f8762011-01-26 12:38:57 -08003973 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Tim Riceae49fe62002-04-12 10:26:21 -07003974#include <sys/types.h>
Kevin Steves939c9db2002-03-22 17:23:25 +00003975#include <sys/socket.h>
3976#include <sys/uio.h>
Tim Rice648f8762011-01-26 12:38:57 -08003977 ]], [[
Tim Rice28bbb0c2002-05-27 17:37:32 -07003978#ifdef msg_accrights
Darren Tuckera0c2b392004-09-11 23:26:37 +10003979#error "msg_accrights is a macro"
Tim Rice28bbb0c2002-05-27 17:37:32 -07003980exit(1);
3981#endif
3982struct msghdr m;
3983m.msg_accrights = 0;
3984exit(0);
Tim Rice648f8762011-01-26 12:38:57 -08003985 ]])],
Kevin Steves939c9db2002-03-22 17:23:25 +00003986 [ ac_cv_have_accrights_in_msghdr="yes" ],
3987 [ ac_cv_have_accrights_in_msghdr="no" ]
3988 )
3989])
3990if test "x$ac_cv_have_accrights_in_msghdr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003991 AC_DEFINE([HAVE_ACCRIGHTS_IN_MSGHDR], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003992 [Define if your system uses access rights style
3993 file descriptor passing])
Kevin Steves939c9db2002-03-22 17:23:25 +00003994fi
3995
Tim Rice648f8762011-01-26 12:38:57 -08003996AC_MSG_CHECKING([if struct statvfs.f_fsid is integral type])
3997AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckere1a3ddf2012-05-04 11:05:45 +10003998#include <sys/param.h>
Darren Tucker32780622009-06-16 16:11:02 +10003999#include <sys/stat.h>
4000#ifdef HAVE_SYS_TIME_H
4001# include <sys/time.h>
4002#endif
4003#ifdef HAVE_SYS_MOUNT_H
4004#include <sys/mount.h>
4005#endif
4006#ifdef HAVE_SYS_STATVFS_H
4007#include <sys/statvfs.h>
4008#endif
Tim Rice648f8762011-01-26 12:38:57 -08004009 ]], [[ struct statvfs s; s.f_fsid = 0; ]])],
4010 [ AC_MSG_RESULT([yes]) ],
4011 [ AC_MSG_RESULT([no])
Darren Tucker32780622009-06-16 16:11:02 +10004012
Tim Rice648f8762011-01-26 12:38:57 -08004013 AC_MSG_CHECKING([if fsid_t has member val])
4014 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker32780622009-06-16 16:11:02 +10004015#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08004016#include <sys/statvfs.h>
4017 ]], [[ fsid_t t; t.val[0] = 0; ]])],
4018 [ AC_MSG_RESULT([yes])
4019 AC_DEFINE([FSID_HAS_VAL], [1], [fsid_t has member val]) ],
4020 [ AC_MSG_RESULT([no]) ])
Darren Tucker32780622009-06-16 16:11:02 +10004021
Tim Rice648f8762011-01-26 12:38:57 -08004022 AC_MSG_CHECKING([if f_fsid has member __val])
4023 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker32780622009-06-16 16:11:02 +10004024#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08004025#include <sys/statvfs.h>
4026 ]], [[ fsid_t t; t.__val[0] = 0; ]])],
4027 [ AC_MSG_RESULT([yes])
4028 AC_DEFINE([FSID_HAS___VAL], [1], [fsid_t has member __val]) ],
4029 [ AC_MSG_RESULT([no]) ])
Darren Tucker32780622009-06-16 16:11:02 +10004030])
Darren Tucker77001382008-06-09 06:17:53 +10004031
Kevin Stevesa44e0352002-04-07 16:18:03 +00004032AC_CACHE_CHECK([for msg_control field in struct msghdr],
4033 ac_cv_have_control_in_msghdr, [
Tim Rice648f8762011-01-26 12:38:57 -08004034 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Tim Riceae49fe62002-04-12 10:26:21 -07004035#include <sys/types.h>
Kevin Stevesa44e0352002-04-07 16:18:03 +00004036#include <sys/socket.h>
4037#include <sys/uio.h>
Tim Rice648f8762011-01-26 12:38:57 -08004038 ]], [[
Tim Rice28bbb0c2002-05-27 17:37:32 -07004039#ifdef msg_control
Darren Tuckera0c2b392004-09-11 23:26:37 +10004040#error "msg_control is a macro"
Tim Rice28bbb0c2002-05-27 17:37:32 -07004041exit(1);
4042#endif
4043struct msghdr m;
4044m.msg_control = 0;
4045exit(0);
Tim Rice648f8762011-01-26 12:38:57 -08004046 ]])],
Kevin Stevesa44e0352002-04-07 16:18:03 +00004047 [ ac_cv_have_control_in_msghdr="yes" ],
4048 [ ac_cv_have_control_in_msghdr="no" ]
4049 )
4050])
4051if test "x$ac_cv_have_control_in_msghdr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004052 AC_DEFINE([HAVE_CONTROL_IN_MSGHDR], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004053 [Define if your system uses ancillary data style
4054 file descriptor passing])
Kevin Stevesa44e0352002-04-07 16:18:03 +00004055fi
4056
Damien Miller61e50f12000-05-08 20:49:37 +10004057AC_CACHE_CHECK([if libc defines __progname], ac_cv_libc_defines___progname, [
Tim Rice648f8762011-01-26 12:38:57 -08004058 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
4059 [[ extern char *__progname; printf("%s", __progname); ]])],
4060 [ ac_cv_libc_defines___progname="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004061 [ ac_cv_libc_defines___progname="no"
Tim Rice648f8762011-01-26 12:38:57 -08004062 ])
Damien Miller61e50f12000-05-08 20:49:37 +10004063])
4064if test "x$ac_cv_libc_defines___progname" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004065 AC_DEFINE([HAVE___PROGNAME], [1], [Define if libc defines __progname])
Damien Miller61e50f12000-05-08 20:49:37 +10004066fi
4067
Kevin Steves4846f4a2002-03-22 18:19:53 +00004068AC_CACHE_CHECK([whether $CC implements __FUNCTION__], ac_cv_cc_implements___FUNCTION__, [
Tim Rice648f8762011-01-26 12:38:57 -08004069 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]],
4070 [[ printf("%s", __FUNCTION__); ]])],
4071 [ ac_cv_cc_implements___FUNCTION__="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004072 [ ac_cv_cc_implements___FUNCTION__="no"
Tim Rice648f8762011-01-26 12:38:57 -08004073 ])
Kevin Steves4846f4a2002-03-22 18:19:53 +00004074])
4075if test "x$ac_cv_cc_implements___FUNCTION__" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004076 AC_DEFINE([HAVE___FUNCTION__], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004077 [Define if compiler implements __FUNCTION__])
Kevin Steves4846f4a2002-03-22 18:19:53 +00004078fi
4079
4080AC_CACHE_CHECK([whether $CC implements __func__], ac_cv_cc_implements___func__, [
Tim Rice648f8762011-01-26 12:38:57 -08004081 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]],
4082 [[ printf("%s", __func__); ]])],
4083 [ ac_cv_cc_implements___func__="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004084 [ ac_cv_cc_implements___func__="no"
Tim Rice648f8762011-01-26 12:38:57 -08004085 ])
Kevin Steves4846f4a2002-03-22 18:19:53 +00004086])
4087if test "x$ac_cv_cc_implements___func__" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004088 AC_DEFINE([HAVE___func__], [1], [Define if compiler implements __func__])
Kevin Steves4846f4a2002-03-22 18:19:53 +00004089fi
4090
Damien Miller57f39152005-11-24 19:58:19 +11004091AC_CACHE_CHECK([whether va_copy exists], ac_cv_have_va_copy, [
Tim Rice648f8762011-01-26 12:38:57 -08004092 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4093#include <stdarg.h>
4094va_list x,y;
4095 ]], [[ va_copy(x,y); ]])],
4096 [ ac_cv_have_va_copy="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004097 [ ac_cv_have_va_copy="no"
Tim Rice648f8762011-01-26 12:38:57 -08004098 ])
Damien Miller57f39152005-11-24 19:58:19 +11004099])
4100if test "x$ac_cv_have_va_copy" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004101 AC_DEFINE([HAVE_VA_COPY], [1], [Define if va_copy exists])
Damien Miller57f39152005-11-24 19:58:19 +11004102fi
4103
4104AC_CACHE_CHECK([whether __va_copy exists], ac_cv_have___va_copy, [
Tim Rice648f8762011-01-26 12:38:57 -08004105 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4106#include <stdarg.h>
4107va_list x,y;
4108 ]], [[ __va_copy(x,y); ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07004109 [ ac_cv_have___va_copy="yes" ], [ ac_cv_have___va_copy="no"
Tim Rice648f8762011-01-26 12:38:57 -08004110 ])
Damien Miller57f39152005-11-24 19:58:19 +11004111])
4112if test "x$ac_cv_have___va_copy" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004113 AC_DEFINE([HAVE___VA_COPY], [1], [Define if __va_copy exists])
Damien Miller57f39152005-11-24 19:58:19 +11004114fi
4115
Damien Miller4f8e6692001-07-14 13:22:53 +10004116AC_CACHE_CHECK([whether getopt has optreset support],
4117 ac_cv_have_getopt_optreset, [
Tim Rice648f8762011-01-26 12:38:57 -08004118 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <getopt.h> ]],
4119 [[ extern int optreset; optreset = 0; ]])],
4120 [ ac_cv_have_getopt_optreset="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004121 [ ac_cv_have_getopt_optreset="no"
Tim Rice648f8762011-01-26 12:38:57 -08004122 ])
Damien Miller4f8e6692001-07-14 13:22:53 +10004123])
4124if test "x$ac_cv_have_getopt_optreset" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004125 AC_DEFINE([HAVE_GETOPT_OPTRESET], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004126 [Define if your getopt(3) defines and uses optreset])
Damien Miller4f8e6692001-07-14 13:22:53 +10004127fi
Damien Millera22ba012000-03-02 23:09:20 +11004128
Damien Millerecbb26d2000-07-15 14:59:14 +10004129AC_CACHE_CHECK([if libc defines sys_errlist], ac_cv_libc_defines_sys_errlist, [
Tim Rice648f8762011-01-26 12:38:57 -08004130 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
4131[[ extern const char *const sys_errlist[]; printf("%s", sys_errlist[0]);]])],
4132 [ ac_cv_libc_defines_sys_errlist="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004133 [ ac_cv_libc_defines_sys_errlist="no"
Tim Rice648f8762011-01-26 12:38:57 -08004134 ])
Damien Millerecbb26d2000-07-15 14:59:14 +10004135])
4136if test "x$ac_cv_libc_defines_sys_errlist" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004137 AC_DEFINE([HAVE_SYS_ERRLIST], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004138 [Define if your system defines sys_errlist[]])
Damien Millerecbb26d2000-07-15 14:59:14 +10004139fi
4140
4141
Damien Miller11fa2cc2000-08-16 10:35:58 +10004142AC_CACHE_CHECK([if libc defines sys_nerr], ac_cv_libc_defines_sys_nerr, [
Tim Rice648f8762011-01-26 12:38:57 -08004143 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
4144[[ extern int sys_nerr; printf("%i", sys_nerr);]])],
4145 [ ac_cv_libc_defines_sys_nerr="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004146 [ ac_cv_libc_defines_sys_nerr="no"
Tim Rice648f8762011-01-26 12:38:57 -08004147 ])
Damien Miller11fa2cc2000-08-16 10:35:58 +10004148])
4149if test "x$ac_cv_libc_defines_sys_nerr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004150 AC_DEFINE([HAVE_SYS_NERR], [1], [Define if your system defines sys_nerr])
Damien Miller11fa2cc2000-08-16 10:35:58 +10004151fi
4152
Darren Tucker5f88d342003-10-15 16:57:57 +10004153# Check libraries needed by DNS fingerprint support
Tim Rice648f8762011-01-26 12:38:57 -08004154AC_SEARCH_LIBS([getrrsetbyname], [resolv],
4155 [AC_DEFINE([HAVE_GETRRSETBYNAME], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004156 [Define if getrrsetbyname() exists])],
Damien Miller7abe09b2003-05-15 10:53:49 +10004157 [
Darren Tucker5f88d342003-10-15 16:57:57 +10004158 # Needed by our getrrsetbyname()
Tim Rice648f8762011-01-26 12:38:57 -08004159 AC_SEARCH_LIBS([res_query], [resolv])
4160 AC_SEARCH_LIBS([dn_expand], [resolv])
4161 AC_MSG_CHECKING([if res_query will link])
4162 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckere02b49a2009-09-11 14:56:08 +10004163#include <sys/types.h>
4164#include <netinet/in.h>
4165#include <arpa/nameser.h>
4166#include <netdb.h>
4167#include <resolv.h>
Tim Rice648f8762011-01-26 12:38:57 -08004168 ]], [[
Darren Tuckere02b49a2009-09-11 14:56:08 +10004169 res_query (0, 0, 0, 0, 0);
Tim Rice648f8762011-01-26 12:38:57 -08004170 ]])],
4171 AC_MSG_RESULT([yes]),
4172 [AC_MSG_RESULT([no])
Darren Tucker8e968a52004-05-13 11:56:16 +10004173 saved_LIBS="$LIBS"
4174 LIBS="$LIBS -lresolv"
Tim Rice648f8762011-01-26 12:38:57 -08004175 AC_MSG_CHECKING([for res_query in -lresolv])
4176 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckere02b49a2009-09-11 14:56:08 +10004177#include <sys/types.h>
4178#include <netinet/in.h>
4179#include <arpa/nameser.h>
4180#include <netdb.h>
Darren Tucker8e968a52004-05-13 11:56:16 +10004181#include <resolv.h>
Tim Rice648f8762011-01-26 12:38:57 -08004182 ]], [[
Darren Tucker8e968a52004-05-13 11:56:16 +10004183 res_query (0, 0, 0, 0, 0);
Tim Rice648f8762011-01-26 12:38:57 -08004184 ]])],
4185 [AC_MSG_RESULT([yes])],
Darren Tucker8e968a52004-05-13 11:56:16 +10004186 [LIBS="$saved_LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08004187 AC_MSG_RESULT([no])])
Darren Tucker8e968a52004-05-13 11:56:16 +10004188 ])
Tim Rice648f8762011-01-26 12:38:57 -08004189 AC_CHECK_FUNCS([_getshort _getlong])
Darren Tuckerd886e1c2005-06-01 18:57:45 +10004190 AC_CHECK_DECLS([_getshort, _getlong], , ,
Tim Ricefcc7ff12005-06-02 20:28:29 -07004191 [#include <sys/types.h>
4192 #include <arpa/nameser.h>])
Tim Rice648f8762011-01-26 12:38:57 -08004193 AC_CHECK_MEMBER([HEADER.ad],
4194 [AC_DEFINE([HAVE_HEADER_AD], [1],
4195 [Define if HEADER.ad exists in arpa/nameser.h])], ,
Darren Tucker5f88d342003-10-15 16:57:57 +10004196 [#include <arpa/nameser.h>])
4197 ])
Damien Miller7abe09b2003-05-15 10:53:49 +10004198
Tim Rice648f8762011-01-26 12:38:57 -08004199AC_MSG_CHECKING([if struct __res_state _res is an extern])
4200AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckercc40d5e2007-04-29 13:58:06 +10004201#include <stdio.h>
4202#if HAVE_SYS_TYPES_H
4203# include <sys/types.h>
4204#endif
4205#include <netinet/in.h>
4206#include <arpa/nameser.h>
4207#include <resolv.h>
4208extern struct __res_state _res;
Darren Tucker7ad8b282015-09-11 13:11:02 +10004209 ]], [[
4210struct __res_state *volatile p = &_res; /* force resolution of _res */
4211return 0;
4212 ]],)],
Tim Rice648f8762011-01-26 12:38:57 -08004213 [AC_MSG_RESULT([yes])
4214 AC_DEFINE([HAVE__RES_EXTERN], [1],
Darren Tuckercc40d5e2007-04-29 13:58:06 +10004215 [Define if you have struct __res_state _res as an extern])
4216 ],
Tim Rice648f8762011-01-26 12:38:57 -08004217 [ AC_MSG_RESULT([no]) ]
Darren Tuckercc40d5e2007-04-29 13:58:06 +10004218)
4219
Damien Miller73b42d22006-04-22 21:26:08 +10004220# Check whether user wants SELinux support
4221SELINUX_MSG="no"
4222LIBSELINUX=""
Tim Rice648f8762011-01-26 12:38:57 -08004223AC_ARG_WITH([selinux],
Damien Miller5b1c8b32008-03-27 12:33:07 +11004224 [ --with-selinux Enable SELinux support],
Damien Miller73b42d22006-04-22 21:26:08 +10004225 [ if test "x$withval" != "xno" ; then
Darren Tucker20e9f972007-03-25 18:26:01 +10004226 save_LIBS="$LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08004227 AC_DEFINE([WITH_SELINUX], [1],
4228 [Define if you want SELinux support.])
Damien Miller73b42d22006-04-22 21:26:08 +10004229 SELINUX_MSG="yes"
4230 AC_CHECK_HEADER([selinux/selinux.h], ,
Tim Rice648f8762011-01-26 12:38:57 -08004231 AC_MSG_ERROR([SELinux support requires selinux.h header]))
4232 AC_CHECK_LIB([selinux], [setexeccon],
Damien Miller1d2bfc42010-02-10 10:19:29 +11004233 [ LIBSELINUX="-lselinux"
4234 LIBS="$LIBS -lselinux"
4235 ],
Tim Rice648f8762011-01-26 12:38:57 -08004236 AC_MSG_ERROR([SELinux support requires libselinux library]))
Damien Miller71adf122011-01-25 12:16:15 +11004237 SSHLIBS="$SSHLIBS $LIBSELINUX"
Darren Tucker20e9f972007-03-25 18:26:01 +10004238 SSHDLIBS="$SSHDLIBS $LIBSELINUX"
Tim Rice648f8762011-01-26 12:38:57 -08004239 AC_CHECK_FUNCS([getseuserbyname get_default_context_with_level])
Darren Tuckeradc947d2006-10-07 09:07:20 +10004240 LIBS="$save_LIBS"
Damien Miller73b42d22006-04-22 21:26:08 +10004241 fi ]
4242)
Tim Rice648f8762011-01-26 12:38:57 -08004243AC_SUBST([SSHLIBS])
4244AC_SUBST([SSHDLIBS])
Damien Miller73b42d22006-04-22 21:26:08 +10004245
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004246# Check whether user wants Kerberos 5 support
Damien Millera8e06ce2003-11-21 23:48:55 +11004247KRB5_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08004248AC_ARG_WITH([kerberos5],
Damien Millera8e06ce2003-11-21 23:48:55 +11004249 [ --with-kerberos5=PATH Enable Kerberos 5 support],
Darren Tucker1d3ca582004-01-22 12:05:34 +11004250 [ if test "x$withval" != "xno" ; then
4251 if test "x$withval" = "xyes" ; then
4252 KRB5ROOT="/usr/local"
4253 else
4254 KRB5ROOT=${withval}
4255 fi
4256
Tim Rice648f8762011-01-26 12:38:57 -08004257 AC_DEFINE([KRB5], [1], [Define if you want Kerberos 5 support])
Darren Tucker1d3ca582004-01-22 12:05:34 +11004258 KRB5_MSG="yes"
4259
Darren Tucker4089fc12016-12-08 12:57:24 +11004260 AC_PATH_TOOL([KRB5CONF], [krb5-config],
Darren Tuckerdad48e72009-09-01 18:26:00 +10004261 [$KRB5ROOT/bin/krb5-config],
4262 [$KRB5ROOT/bin:$PATH])
4263 if test -x $KRB5CONF ; then
Darren Tucker964de182013-02-22 10:39:59 +11004264 K5CFLAGS="`$KRB5CONF --cflags`"
4265 K5LIBS="`$KRB5CONF --libs`"
4266 CPPFLAGS="$CPPFLAGS $K5CFLAGS"
Darren Tucker1d3ca582004-01-22 12:05:34 +11004267
Tim Rice648f8762011-01-26 12:38:57 -08004268 AC_MSG_CHECKING([for gssapi support])
Darren Tucker1d3ca582004-01-22 12:05:34 +11004269 if $KRB5CONF | grep gssapi >/dev/null ; then
Tim Rice648f8762011-01-26 12:38:57 -08004270 AC_MSG_RESULT([yes])
4271 AC_DEFINE([GSSAPI], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004272 [Define this if you want GSSAPI
4273 support in the version 2 protocol])
Darren Tucker964de182013-02-22 10:39:59 +11004274 GSSCFLAGS="`$KRB5CONF --cflags gssapi`"
4275 GSSLIBS="`$KRB5CONF --libs gssapi`"
4276 CPPFLAGS="$CPPFLAGS $GSSCFLAGS"
Damien Millera8e06ce2003-11-21 23:48:55 +11004277 else
Tim Rice648f8762011-01-26 12:38:57 -08004278 AC_MSG_RESULT([no])
Damien Millera8e06ce2003-11-21 23:48:55 +11004279 fi
Tim Rice648f8762011-01-26 12:38:57 -08004280 AC_MSG_CHECKING([whether we are using Heimdal])
4281 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <krb5.h>
4282 ]], [[ char *tmp = heimdal_version; ]])],
4283 [ AC_MSG_RESULT([yes])
4284 AC_DEFINE([HEIMDAL], [1],
4285 [Define this if you are using the Heimdal
4286 version of Kerberos V5]) ],
4287 [AC_MSG_RESULT([no])
4288 ])
Darren Tucker1d3ca582004-01-22 12:05:34 +11004289 else
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004290 CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include"
Damien Millera8e06ce2003-11-21 23:48:55 +11004291 LDFLAGS="$LDFLAGS -L${KRB5ROOT}/lib"
Tim Rice648f8762011-01-26 12:38:57 -08004292 AC_MSG_CHECKING([whether we are using Heimdal])
4293 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <krb5.h>
4294 ]], [[ char *tmp = heimdal_version; ]])],
4295 [ AC_MSG_RESULT([yes])
4296 AC_DEFINE([HEIMDAL])
Damien Miller41bccf72011-01-02 21:53:07 +11004297 K5LIBS="-lkrb5"
Damien Miller5561e0b2004-04-20 20:28:55 +10004298 K5LIBS="$K5LIBS -lcom_err -lasn1"
Tim Rice648f8762011-01-26 12:38:57 -08004299 AC_CHECK_LIB([roken], [net_write],
Damien Miller5561e0b2004-04-20 20:28:55 +10004300 [K5LIBS="$K5LIBS -lroken"])
Tim Rice648f8762011-01-26 12:38:57 -08004301 AC_CHECK_LIB([des], [des_cbc_encrypt],
Damien Miller41bccf72011-01-02 21:53:07 +11004302 [K5LIBS="$K5LIBS -ldes"])
Tim Rice648f8762011-01-26 12:38:57 -08004303 ], [ AC_MSG_RESULT([no])
Damien Millera8e06ce2003-11-21 23:48:55 +11004304 K5LIBS="-lkrb5 -lk5crypto -lcom_err"
Tim Rice648f8762011-01-26 12:38:57 -08004305 ])
4306 AC_SEARCH_LIBS([dn_expand], [resolv])
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004307
Tim Rice648f8762011-01-26 12:38:57 -08004308 AC_CHECK_LIB([gssapi_krb5], [gss_init_sec_context],
4309 [ AC_DEFINE([GSSAPI])
Darren Tucker964de182013-02-22 10:39:59 +11004310 GSSLIBS="-lgssapi_krb5" ],
Tim Rice648f8762011-01-26 12:38:57 -08004311 [ AC_CHECK_LIB([gssapi], [gss_init_sec_context],
4312 [ AC_DEFINE([GSSAPI])
Darren Tucker964de182013-02-22 10:39:59 +11004313 GSSLIBS="-lgssapi" ],
Darren Tuckera2b5a4c2013-02-22 10:43:15 +11004314 [ AC_CHECK_LIB([gss], [gss_init_sec_context],
4315 [ AC_DEFINE([GSSAPI])
4316 GSSLIBS="-lgss" ],
4317 AC_MSG_WARN([Cannot find any suitable gss-api library - build may fail]))
4318 ])
Darren Tucker964de182013-02-22 10:39:59 +11004319 ])
Tim Riceeae17cc2005-03-17 16:52:20 -08004320
Tim Rice648f8762011-01-26 12:38:57 -08004321 AC_CHECK_HEADER([gssapi.h], ,
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004322 [ unset ac_cv_header_gssapi_h
Damien Millera8e06ce2003-11-21 23:48:55 +11004323 CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
Tim Rice648f8762011-01-26 12:38:57 -08004324 AC_CHECK_HEADERS([gssapi.h], ,
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004325 AC_MSG_WARN([Cannot find any suitable gss-api header - build may fail])
Damien Millera8e06ce2003-11-21 23:48:55 +11004326 )
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004327 ]
4328 )
4329
4330 oldCPP="$CPPFLAGS"
4331 CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
Tim Rice648f8762011-01-26 12:38:57 -08004332 AC_CHECK_HEADER([gssapi_krb5.h], ,
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004333 [ CPPFLAGS="$oldCPP" ])
4334
Damien Millera8e06ce2003-11-21 23:48:55 +11004335 fi
Darren Tucker1d3ca582004-01-22 12:05:34 +11004336 if test ! -z "$need_dash_r" ; then
4337 LDFLAGS="$LDFLAGS -R${KRB5ROOT}/lib"
4338 fi
4339 if test ! -z "$blibpath" ; then
4340 blibpath="$blibpath:${KRB5ROOT}/lib"
4341 fi
Tim Ricefd9e9e32005-09-12 17:36:10 -07004342
Tim Rice648f8762011-01-26 12:38:57 -08004343 AC_CHECK_HEADERS([gssapi.h gssapi/gssapi.h])
4344 AC_CHECK_HEADERS([gssapi_krb5.h gssapi/gssapi_krb5.h])
4345 AC_CHECK_HEADERS([gssapi_generic.h gssapi/gssapi_generic.h])
Tim Ricefd9e9e32005-09-12 17:36:10 -07004346
Tim Rice648f8762011-01-26 12:38:57 -08004347 AC_SEARCH_LIBS([k_hasafs], [kafs], [AC_DEFINE([USE_AFS], [1],
4348 [Define this if you want to use libkafs' AFS support])])
Darren Tucker03978c62013-02-25 11:24:44 +11004349
4350 AC_CHECK_DECLS([GSS_C_NT_HOSTBASED_SERVICE], [], [], [[
4351#ifdef HAVE_GSSAPI_H
4352# include <gssapi.h>
4353#elif defined(HAVE_GSSAPI_GSSAPI_H)
4354# include <gssapi/gssapi.h>
4355#endif
4356
4357#ifdef HAVE_GSSAPI_GENERIC_H
4358# include <gssapi_generic.h>
4359#elif defined(HAVE_GSSAPI_GSSAPI_GENERIC_H)
4360# include <gssapi/gssapi_generic.h>
4361#endif
4362 ]])
Darren Tuckerf3ab2c52013-08-04 21:48:41 +10004363 saved_LIBS="$LIBS"
4364 LIBS="$LIBS $K5LIBS"
4365 AC_CHECK_FUNCS([krb5_cc_new_unique krb5_get_error_message krb5_free_error_message])
4366 LIBS="$saved_LIBS"
4367
Darren Tucker0d27ed12004-02-24 10:37:33 +11004368 fi
Darren Tucker0d27ed12004-02-24 10:37:33 +11004369 ]
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004370)
Darren Tucker964de182013-02-22 10:39:59 +11004371AC_SUBST([GSSLIBS])
4372AC_SUBST([K5LIBS])
Damien Millerc79bc0d2001-03-28 13:03:42 +10004373
Damien Millera22ba012000-03-02 23:09:20 +11004374# Looking for programs, paths and files
Damien Millera22ba012000-03-02 23:09:20 +11004375
Damien Millerf58c6722002-05-13 13:15:42 +10004376PRIVSEP_PATH=/var/empty
Tim Rice648f8762011-01-26 12:38:57 -08004377AC_ARG_WITH([privsep-path],
Tim Ricecbb90662002-07-08 19:17:10 -07004378 [ --with-privsep-path=xxx Path for privilege separation chroot (default=/var/empty)],
Damien Millerf58c6722002-05-13 13:15:42 +10004379 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004380 if test -n "$withval" && test "x$withval" != "xno" && \
4381 test "x${withval}" != "xyes"; then
Damien Millerf58c6722002-05-13 13:15:42 +10004382 PRIVSEP_PATH=$withval
4383 fi
4384 ]
4385)
Tim Rice648f8762011-01-26 12:38:57 -08004386AC_SUBST([PRIVSEP_PATH])
Damien Millerf58c6722002-05-13 13:15:42 +10004387
Tim Rice648f8762011-01-26 12:38:57 -08004388AC_ARG_WITH([xauth],
Damien Millera22ba012000-03-02 23:09:20 +11004389 [ --with-xauth=PATH Specify path to xauth program ],
4390 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004391 if test -n "$withval" && test "x$withval" != "xno" && \
4392 test "x${withval}" != "xyes"; then
Damien Miller7b22d652000-06-18 14:07:04 +10004393 xauth_path=$withval
Damien Millera22ba012000-03-02 23:09:20 +11004394 fi
4395 ],
4396 [
Tim Ricee22be3b2002-07-17 19:20:07 -07004397 TestPath="$PATH"
4398 TestPath="${TestPath}${PATH_SEPARATOR}/usr/X/bin"
4399 TestPath="${TestPath}${PATH_SEPARATOR}/usr/bin/X11"
4400 TestPath="${TestPath}${PATH_SEPARATOR}/usr/X11R6/bin"
4401 TestPath="${TestPath}${PATH_SEPARATOR}/usr/openwin/bin"
Tim Rice648f8762011-01-26 12:38:57 -08004402 AC_PATH_PROG([xauth_path], [xauth], , [$TestPath])
Damien Milleredb82922000-06-20 13:25:52 +10004403 if (test ! -z "$xauth_path" && test -x "/usr/openwin/bin/xauth") ; then
Damien Millera22ba012000-03-02 23:09:20 +11004404 xauth_path="/usr/openwin/bin/xauth"
4405 fi
4406 ]
4407)
4408
Damien Miller7d901272003-01-13 16:55:22 +11004409STRIP_OPT=-s
Tim Rice648f8762011-01-26 12:38:57 -08004410AC_ARG_ENABLE([strip],
Damien Miller7d901272003-01-13 16:55:22 +11004411 [ --disable-strip Disable calling strip(1) on install],
4412 [
4413 if test "x$enableval" = "xno" ; then
4414 STRIP_OPT=
4415 fi
4416 ]
4417)
Tim Rice648f8762011-01-26 12:38:57 -08004418AC_SUBST([STRIP_OPT])
Damien Miller7d901272003-01-13 16:55:22 +11004419
Damien Millera19cf472000-11-29 13:28:50 +11004420if test -z "$xauth_path" ; then
4421 XAUTH_PATH="undefined"
Tim Rice648f8762011-01-26 12:38:57 -08004422 AC_SUBST([XAUTH_PATH])
Damien Millera19cf472000-11-29 13:28:50 +11004423else
Tim Rice648f8762011-01-26 12:38:57 -08004424 AC_DEFINE_UNQUOTED([XAUTH_PATH], ["$xauth_path"],
Tim Rice7df8d392005-09-19 09:33:39 -07004425 [Define if xauth is found in your path])
Damien Millera19cf472000-11-29 13:28:50 +11004426 XAUTH_PATH=$xauth_path
Tim Rice648f8762011-01-26 12:38:57 -08004427 AC_SUBST([XAUTH_PATH])
Damien Millera22ba012000-03-02 23:09:20 +11004428fi
Damien Millera22ba012000-03-02 23:09:20 +11004429
Tim Rice90f42b02011-06-02 18:17:49 -07004430dnl # --with-maildir=/path/to/mail gets top priority.
4431dnl # if maildir is set in the platform case statement above we use that.
4432dnl # Otherwise we run a program to get the dir from system headers.
4433dnl # We first look for _PATH_MAILDIR then MAILDIR then _PATH_MAIL
4434dnl # If we find _PATH_MAILDIR we do nothing because that is what
4435dnl # session.c expects anyway. Otherwise we set to the value found
4436dnl # stripping any trailing slash. If for some strage reason our program
4437dnl # does not find what it needs, we default to /var/spool/mail.
4438# Check for mail directory
4439AC_ARG_WITH([maildir],
4440 [ --with-maildir=/path/to/mail Specify your system mail directory],
4441 [
4442 if test "X$withval" != X && test "x$withval" != xno && \
4443 test "x${withval}" != xyes; then
4444 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$withval"],
4445 [Set this to your mail directory if you do not have _PATH_MAILDIR])
4446 fi
4447 ],[
4448 if test "X$maildir" != "X"; then
4449 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$maildir"])
4450 else
4451 AC_MSG_CHECKING([Discovering system mail directory])
4452 AC_RUN_IFELSE(
4453 [AC_LANG_PROGRAM([[
4454#include <stdio.h>
4455#include <string.h>
4456#ifdef HAVE_PATHS_H
4457#include <paths.h>
4458#endif
4459#ifdef HAVE_MAILLOCK_H
4460#include <maillock.h>
4461#endif
4462#define DATA "conftest.maildir"
4463 ]], [[
4464 FILE *fd;
4465 int rc;
4466
4467 fd = fopen(DATA,"w");
4468 if(fd == NULL)
4469 exit(1);
4470
4471#if defined (_PATH_MAILDIR)
4472 if ((rc = fprintf(fd ,"_PATH_MAILDIR:%s\n", _PATH_MAILDIR)) <0)
4473 exit(1);
4474#elif defined (MAILDIR)
4475 if ((rc = fprintf(fd ,"MAILDIR:%s\n", MAILDIR)) <0)
4476 exit(1);
4477#elif defined (_PATH_MAIL)
4478 if ((rc = fprintf(fd ,"_PATH_MAIL:%s\n", _PATH_MAIL)) <0)
4479 exit(1);
4480#else
4481 exit (2);
4482#endif
4483
4484 exit(0);
4485 ]])],
4486 [
Tim Ricee1d93702016-05-31 11:13:22 -07004487 maildir_what=`awk -F: '{print $1}' conftest.maildir`
Tim Rice90f42b02011-06-02 18:17:49 -07004488 maildir=`awk -F: '{print $2}' conftest.maildir \
4489 | sed 's|/$||'`
4490 AC_MSG_RESULT([Using: $maildir from $maildir_what])
4491 if test "x$maildir_what" != "x_PATH_MAILDIR"; then
4492 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$maildir"])
4493 fi
4494 ],
4495 [
4496 if test "X$ac_status" = "X2";then
4497# our test program didn't find it. Default to /var/spool/mail
4498 AC_MSG_RESULT([Using: default value of /var/spool/mail])
4499 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["/var/spool/mail"])
4500 else
4501 AC_MSG_RESULT([*** not found ***])
4502 fi
4503 ],
4504 [
4505 AC_MSG_WARN([cross compiling: use --with-maildir=/path/to/mail])
4506 ]
4507 )
4508 fi
4509 ]
4510) # maildir
Damien Millera22ba012000-03-02 23:09:20 +11004511
Darren Tucker623d92f2004-09-12 22:36:15 +10004512if test ! -z "$cross_compiling" && test "x$cross_compiling" = "xyes"; then
Darren Tuckera0c2b392004-09-11 23:26:37 +10004513 AC_MSG_WARN([cross compiling: Disabling /dev/ptmx test])
4514 disable_ptmx_check=yes
4515fi
Damien Millera22ba012000-03-02 23:09:20 +11004516if test -z "$no_dev_ptmx" ; then
Kevin Steves0ea1d9d2002-04-25 18:17:04 +00004517 if test "x$disable_ptmx_check" != "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004518 AC_CHECK_FILE(["/dev/ptmx"],
Kevin Steves0ea1d9d2002-04-25 18:17:04 +00004519 [
Tim Rice648f8762011-01-26 12:38:57 -08004520 AC_DEFINE_UNQUOTED([HAVE_DEV_PTMX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004521 [Define if you have /dev/ptmx])
Kevin Steves0ea1d9d2002-04-25 18:17:04 +00004522 have_dev_ptmx=1
4523 ]
4524 )
4525 fi
Damien Millera22ba012000-03-02 23:09:20 +11004526fi
Darren Tuckera0c2b392004-09-11 23:26:37 +10004527
Darren Tucker623d92f2004-09-12 22:36:15 +10004528if test ! -z "$cross_compiling" && test "x$cross_compiling" != "xyes"; then
Tim Rice648f8762011-01-26 12:38:57 -08004529 AC_CHECK_FILE(["/dev/ptc"],
Darren Tuckera0c2b392004-09-11 23:26:37 +10004530 [
Tim Rice648f8762011-01-26 12:38:57 -08004531 AC_DEFINE_UNQUOTED([HAVE_DEV_PTS_AND_PTC], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004532 [Define if you have /dev/ptc])
Darren Tuckera0c2b392004-09-11 23:26:37 +10004533 have_dev_ptc=1
4534 ]
4535 )
4536else
4537 AC_MSG_WARN([cross compiling: Disabling /dev/ptc test])
4538fi
Damien Miller204ad072000-03-02 23:56:12 +11004539
Damien Millera22ba012000-03-02 23:09:20 +11004540# Options from here on. Some of these are preset by platform above
Tim Rice648f8762011-01-26 12:38:57 -08004541AC_ARG_WITH([mantype],
Damien Miller897741e2001-04-16 10:41:46 +10004542 [ --with-mantype=man|cat|doc Set man page type],
Damien Miller670a4b82000-01-22 13:53:11 +11004543 [
Damien Miller897741e2001-04-16 10:41:46 +10004544 case "$withval" in
4545 man|cat|doc)
4546 MANTYPE=$withval
4547 ;;
4548 *)
Tim Rice648f8762011-01-26 12:38:57 -08004549 AC_MSG_ERROR([invalid man type: $withval])
Damien Miller897741e2001-04-16 10:41:46 +10004550 ;;
4551 esac
Damien Miller670a4b82000-01-22 13:53:11 +11004552 ]
4553)
Ben Lindstrombc709922001-04-18 18:04:21 +00004554if test -z "$MANTYPE"; then
Tim Ricee22be3b2002-07-17 19:20:07 -07004555 TestPath="/usr/bin${PATH_SEPARATOR}/usr/ucb"
Tim Rice648f8762011-01-26 12:38:57 -08004556 AC_PATH_PROGS([NROFF], [nroff awf], [/bin/false], [$TestPath])
Ben Lindstrombc709922001-04-18 18:04:21 +00004557 if ${NROFF} -mdoc ${srcdir}/ssh.1 >/dev/null 2>&1; then
4558 MANTYPE=doc
4559 elif ${NROFF} -man ${srcdir}/ssh.1 >/dev/null 2>&1; then
4560 MANTYPE=man
4561 else
4562 MANTYPE=cat
4563 fi
4564fi
Tim Rice648f8762011-01-26 12:38:57 -08004565AC_SUBST([MANTYPE])
Ben Lindstrombc709922001-04-18 18:04:21 +00004566if test "$MANTYPE" = "doc"; then
4567 mansubdir=man;
4568else
4569 mansubdir=$MANTYPE;
4570fi
Tim Rice648f8762011-01-26 12:38:57 -08004571AC_SUBST([mansubdir])
Damien Miller8bdeee21999-12-30 15:50:54 +11004572
Damien Millera22ba012000-03-02 23:09:20 +11004573# Check whether to enable MD5 passwords
Damien Millera8e06ce2003-11-21 23:48:55 +11004574MD5_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08004575AC_ARG_WITH([md5-passwords],
Damien Millerdd1c7ba1999-11-19 15:53:20 +11004576 [ --with-md5-passwords Enable use of MD5 passwords],
Damien Miller8bdeee21999-12-30 15:50:54 +11004577 [
Damien Millerb85dcad2000-03-11 11:37:00 +11004578 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004579 AC_DEFINE([HAVE_MD5_PASSWORDS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004580 [Define if you want to allow MD5 passwords])
Damien Millera8e06ce2003-11-21 23:48:55 +11004581 MD5_MSG="yes"
Damien Miller8bdeee21999-12-30 15:50:54 +11004582 fi
4583 ]
Damien Millerdd1c7ba1999-11-19 15:53:20 +11004584)
4585
Damien Millera22ba012000-03-02 23:09:20 +11004586# Whether to disable shadow password support
Tim Rice648f8762011-01-26 12:38:57 -08004587AC_ARG_WITH([shadow],
Damien Miller76112de1999-12-21 11:18:08 +11004588 [ --without-shadow Disable shadow password support],
4589 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004590 if test "x$withval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004591 AC_DEFINE([DISABLE_SHADOW])
Damien Miller1f335fb2000-06-26 11:31:33 +10004592 disable_shadow=yes
Damien Miller76112de1999-12-21 11:18:08 +11004593 fi
4594 ]
4595)
4596
Damien Miller1f335fb2000-06-26 11:31:33 +10004597if test -z "$disable_shadow" ; then
4598 AC_MSG_CHECKING([if the systems has expire shadow information])
Tim Rice648f8762011-01-26 12:38:57 -08004599 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller1f335fb2000-06-26 11:31:33 +10004600#include <sys/types.h>
4601#include <shadow.h>
Tim Rice648f8762011-01-26 12:38:57 -08004602struct spwd sp;
4603 ]], [[ sp.sp_expire = sp.sp_lstchg = sp.sp_inact = 0; ]])],
4604 [ sp_expire_available=yes ], [
4605 ])
Damien Miller1f335fb2000-06-26 11:31:33 +10004606
4607 if test "x$sp_expire_available" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004608 AC_MSG_RESULT([yes])
4609 AC_DEFINE([HAS_SHADOW_EXPIRE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004610 [Define if you want to use shadow password expire field])
Damien Miller1f335fb2000-06-26 11:31:33 +10004611 else
Tim Rice648f8762011-01-26 12:38:57 -08004612 AC_MSG_RESULT([no])
Damien Miller1f335fb2000-06-26 11:31:33 +10004613 fi
4614fi
4615
Damien Millera22ba012000-03-02 23:09:20 +11004616# Use ip address instead of hostname in $DISPLAY
Damien Miller9a947342000-08-30 10:03:33 +11004617if test ! -z "$IPADDR_IN_DISPLAY" ; then
4618 DISPLAY_HACK_MSG="yes"
Tim Rice648f8762011-01-26 12:38:57 -08004619 AC_DEFINE([IPADDR_IN_DISPLAY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004620 [Define if you need to use IP address
4621 instead of hostname in $DISPLAY])
Damien Miller9a947342000-08-30 10:03:33 +11004622else
Damien Millera8e06ce2003-11-21 23:48:55 +11004623 DISPLAY_HACK_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08004624 AC_ARG_WITH([ipaddr-display],
Tim Rice6397eed2015-06-03 21:41:11 -07004625 [ --with-ipaddr-display Use ip address instead of hostname in $DISPLAY],
Damien Miller9a947342000-08-30 10:03:33 +11004626 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004627 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004628 AC_DEFINE([IPADDR_IN_DISPLAY])
Damien Millera8e06ce2003-11-21 23:48:55 +11004629 DISPLAY_HACK_MSG="yes"
Damien Miller9a947342000-08-30 10:03:33 +11004630 fi
4631 ]
4632 )
4633fi
Damien Miller76112de1999-12-21 11:18:08 +11004634
Darren Tuckere1a790d2003-09-16 11:52:19 +10004635# check for /etc/default/login and use it if present.
Tim Rice648f8762011-01-26 12:38:57 -08004636AC_ARG_ENABLE([etc-default-login],
Darren Tucker1b6f2292005-02-11 16:11:49 +11004637 [ --disable-etc-default-login Disable using PATH from /etc/default/login [no]],
Darren Tucker2f9573d2005-02-10 22:28:54 +11004638 [ if test "x$enableval" = "xno"; then
4639 AC_MSG_NOTICE([/etc/default/login handling disabled])
4640 etc_default_login=no
4641 else
4642 etc_default_login=yes
4643 fi ],
Darren Tucker314d89e2005-10-17 23:29:23 +10004644 [ if test ! -z "$cross_compiling" && test "x$cross_compiling" = "xyes";
4645 then
4646 AC_MSG_WARN([cross compiling: not checking /etc/default/login])
4647 etc_default_login=no
4648 else
4649 etc_default_login=yes
4650 fi ]
Darren Tucker2f9573d2005-02-10 22:28:54 +11004651)
Darren Tuckere1a790d2003-09-16 11:52:19 +10004652
Darren Tucker2f9573d2005-02-10 22:28:54 +11004653if test "x$etc_default_login" != "xno"; then
Tim Rice648f8762011-01-26 12:38:57 -08004654 AC_CHECK_FILE(["/etc/default/login"],
Darren Tucker2f9573d2005-02-10 22:28:54 +11004655 [ external_path_file=/etc/default/login ])
Darren Tucker314d89e2005-10-17 23:29:23 +10004656 if test "x$external_path_file" = "x/etc/default/login"; then
Tim Rice648f8762011-01-26 12:38:57 -08004657 AC_DEFINE([HAVE_ETC_DEFAULT_LOGIN], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004658 [Define if your system has /etc/default/login])
Darren Tuckera0c2b392004-09-11 23:26:37 +10004659 fi
Darren Tucker2f9573d2005-02-10 22:28:54 +11004660fi
Darren Tuckere1a790d2003-09-16 11:52:19 +10004661
Tim Rice43a1c132002-04-17 21:19:14 -07004662dnl BSD systems use /etc/login.conf so --with-default-path= has no effect
Tim Rice8bb561b2005-03-17 16:23:19 -08004663if test $ac_cv_func_login_getcapbool = "yes" && \
4664 test $ac_cv_header_login_cap_h = "yes" ; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10004665 external_path_file=/etc/login.conf
Tim Rice43a1c132002-04-17 21:19:14 -07004666fi
Darren Tuckere1a790d2003-09-16 11:52:19 +10004667
Damien Millera22ba012000-03-02 23:09:20 +11004668# Whether to mess with the default path
Damien Millera8e06ce2003-11-21 23:48:55 +11004669SERVER_PATH_MSG="(default)"
Tim Rice648f8762011-01-26 12:38:57 -08004670AC_ARG_WITH([default-path],
Tim Rice6397eed2015-06-03 21:41:11 -07004671 [ --with-default-path= Specify default $PATH environment for server],
Damien Miller5a3e6831999-12-27 09:48:56 +11004672 [
Darren Tuckere1a790d2003-09-16 11:52:19 +10004673 if test "x$external_path_file" = "x/etc/login.conf" ; then
Tim Rice43a1c132002-04-17 21:19:14 -07004674 AC_MSG_WARN([
4675--with-default-path=PATH has no effect on this system.
4676Edit /etc/login.conf instead.])
Tim Riceeae17cc2005-03-17 16:52:20 -08004677 elif test "x$withval" != "xno" ; then
Tim Riceb925b4b2003-09-15 22:40:49 -07004678 if test ! -z "$external_path_file" ; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10004679 AC_MSG_WARN([
4680--with-default-path=PATH will only be used if PATH is not defined in
4681$external_path_file .])
4682 fi
Tim Rice59ea0a02001-03-10 13:50:45 -08004683 user_path="$withval"
Damien Millera8e06ce2003-11-21 23:48:55 +11004684 SERVER_PATH_MSG="$withval"
Damien Miller5a3e6831999-12-27 09:48:56 +11004685 fi
Tim Rice59ea0a02001-03-10 13:50:45 -08004686 ],
Darren Tuckere1a790d2003-09-16 11:52:19 +10004687 [ if test "x$external_path_file" = "x/etc/login.conf" ; then
4688 AC_MSG_WARN([Make sure the path to scp is in /etc/login.conf])
Tim Rice43a1c132002-04-17 21:19:14 -07004689 else
Tim Riceb925b4b2003-09-15 22:40:49 -07004690 if test ! -z "$external_path_file" ; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10004691 AC_MSG_WARN([
4692If PATH is defined in $external_path_file, ensure the path to scp is included,
4693otherwise scp will not work.])
4694 fi
Darren Tucker314d89e2005-10-17 23:29:23 +10004695 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08004696 [AC_LANG_PROGRAM([[
Tim Rice59ea0a02001-03-10 13:50:45 -08004697/* find out what STDPATH is */
4698#include <stdio.h>
Tim Rice59ea0a02001-03-10 13:50:45 -08004699#ifdef HAVE_PATHS_H
4700# include <paths.h>
4701#endif
4702#ifndef _PATH_STDPATH
Tim Rice1c9e6882002-11-22 13:29:01 -08004703# ifdef _PATH_USERPATH /* Irix */
4704# define _PATH_STDPATH _PATH_USERPATH
4705# else
4706# define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
4707# endif
Tim Rice59ea0a02001-03-10 13:50:45 -08004708#endif
4709#include <sys/types.h>
4710#include <sys/stat.h>
4711#include <fcntl.h>
4712#define DATA "conftest.stdpath"
Tim Rice648f8762011-01-26 12:38:57 -08004713 ]], [[
Tim Rice59ea0a02001-03-10 13:50:45 -08004714 FILE *fd;
4715 int rc;
Tim Riceeae17cc2005-03-17 16:52:20 -08004716
Tim Rice59ea0a02001-03-10 13:50:45 -08004717 fd = fopen(DATA,"w");
4718 if(fd == NULL)
4719 exit(1);
Tim Riceeae17cc2005-03-17 16:52:20 -08004720
Tim Rice59ea0a02001-03-10 13:50:45 -08004721 if ((rc = fprintf(fd,"%s", _PATH_STDPATH)) < 0)
4722 exit(1);
4723
4724 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10004725 ]])],
4726 [ user_path=`cat conftest.stdpath` ],
Tim Rice59ea0a02001-03-10 13:50:45 -08004727 [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ],
4728 [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ]
4729 )
4730# make sure $bindir is in USER_PATH so scp will work
Damien Miller77eab7b2012-07-06 11:49:28 +10004731 t_bindir="${bindir}"
4732 while echo "${t_bindir}" | egrep '\$\{|NONE/' >/dev/null 2>&1; do
4733 t_bindir=`eval echo ${t_bindir}`
4734 case $t_bindir in
4735 NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$prefix~"` ;;
4736 esac
4737 case $t_bindir in
4738 NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$ac_default_prefix~"` ;;
4739 esac
4740 done
Tim Rice59ea0a02001-03-10 13:50:45 -08004741 echo $user_path | grep ":$t_bindir" > /dev/null 2>&1
4742 if test $? -ne 0 ; then
4743 echo $user_path | grep "^$t_bindir" > /dev/null 2>&1
4744 if test $? -ne 0 ; then
4745 user_path=$user_path:$t_bindir
Tim Rice648f8762011-01-26 12:38:57 -08004746 AC_MSG_RESULT([Adding $t_bindir to USER_PATH so scp will work])
Tim Rice59ea0a02001-03-10 13:50:45 -08004747 fi
4748 fi
Tim Rice43a1c132002-04-17 21:19:14 -07004749 fi ]
Damien Miller5a3e6831999-12-27 09:48:56 +11004750)
Darren Tuckere1a790d2003-09-16 11:52:19 +10004751if test "x$external_path_file" != "x/etc/login.conf" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004752 AC_DEFINE_UNQUOTED([USER_PATH], ["$user_path"], [Specify default $PATH])
4753 AC_SUBST([user_path])
Tim Rice43a1c132002-04-17 21:19:14 -07004754fi
Damien Miller5a3e6831999-12-27 09:48:56 +11004755
Damien Millera18bbd32002-05-13 10:48:57 +10004756# Set superuser path separately to user path
Tim Rice648f8762011-01-26 12:38:57 -08004757AC_ARG_WITH([superuser-path],
Damien Millera18bbd32002-05-13 10:48:57 +10004758 [ --with-superuser-path= Specify different path for super-user],
4759 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004760 if test -n "$withval" && test "x$withval" != "xno" && \
4761 test "x${withval}" != "xyes"; then
Tim Rice648f8762011-01-26 12:38:57 -08004762 AC_DEFINE_UNQUOTED([SUPERUSER_PATH], ["$withval"],
Tim Rice7df8d392005-09-19 09:33:39 -07004763 [Define if you want a different $PATH
4764 for the superuser])
Damien Millera18bbd32002-05-13 10:48:57 +10004765 superuser_path=$withval
4766 fi
4767 ]
4768)
4769
4770
Damien Miller61e50f12000-05-08 20:49:37 +10004771AC_MSG_CHECKING([if we need to convert IPv4 in IPv6-mapped addresses])
Damien Millera8e06ce2003-11-21 23:48:55 +11004772IPV4_IN6_HACK_MSG="no"
Damien Miller7bcb0892000-03-11 20:45:40 +11004773AC_ARG_WITH(4in6,
4774 [ --with-4in6 Check for and convert IPv4 in IPv6 mapped addresses],
4775 [
4776 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004777 AC_MSG_RESULT([yes])
4778 AC_DEFINE([IPV4_IN_IPV6], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004779 [Detect IPv4 in IPv6 mapped addresses
4780 and treat as IPv4])
Damien Millera8e06ce2003-11-21 23:48:55 +11004781 IPV4_IN6_HACK_MSG="yes"
Damien Miller7bcb0892000-03-11 20:45:40 +11004782 else
Tim Rice648f8762011-01-26 12:38:57 -08004783 AC_MSG_RESULT([no])
Damien Miller7bcb0892000-03-11 20:45:40 +11004784 fi
Tim Rice648f8762011-01-26 12:38:57 -08004785 ], [
Damien Miller7bcb0892000-03-11 20:45:40 +11004786 if test "x$inet6_default_4in6" = "xyes"; then
4787 AC_MSG_RESULT([yes (default)])
Tim Rice648f8762011-01-26 12:38:57 -08004788 AC_DEFINE([IPV4_IN_IPV6])
Damien Millera8e06ce2003-11-21 23:48:55 +11004789 IPV4_IN6_HACK_MSG="yes"
Damien Miller7bcb0892000-03-11 20:45:40 +11004790 else
4791 AC_MSG_RESULT([no (default)])
4792 fi
4793 ]
4794)
4795
Damien Miller60396b02001-02-18 17:01:00 +11004796# Whether to enable BSD auth support
Damien Miller6c21c512002-01-22 21:57:53 +11004797BSD_AUTH_MSG=no
Tim Rice648f8762011-01-26 12:38:57 -08004798AC_ARG_WITH([bsd-auth],
Damien Miller60396b02001-02-18 17:01:00 +11004799 [ --with-bsd-auth Enable BSD auth support],
4800 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004801 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004802 AC_DEFINE([BSD_AUTH], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004803 [Define if you have BSD auth support])
Damien Miller6c21c512002-01-22 21:57:53 +11004804 BSD_AUTH_MSG=yes
Damien Miller60396b02001-02-18 17:01:00 +11004805 fi
4806 ]
4807)
4808
Damien Millera22ba012000-03-02 23:09:20 +11004809# Where to place sshd.pid
Damien Millerb13c73e2000-01-17 22:02:17 +11004810piddir=/var/run
Damien Miller78315eb2000-09-29 23:01:36 +11004811# make sure the directory exists
Tim Riceeae17cc2005-03-17 16:52:20 -08004812if test ! -d $piddir ; then
Damien Miller78315eb2000-09-29 23:01:36 +11004813 piddir=`eval echo ${sysconfdir}`
4814 case $piddir in
Damien Millera8e06ce2003-11-21 23:48:55 +11004815 NONE/*) piddir=`echo $piddir | sed "s~NONE~$ac_default_prefix~"` ;;
Damien Miller78315eb2000-09-29 23:01:36 +11004816 esac
4817fi
4818
Tim Rice648f8762011-01-26 12:38:57 -08004819AC_ARG_WITH([pid-dir],
Darren Tucker075e2582018-02-13 17:36:43 +11004820 [ --with-pid-dir=PATH Specify location of sshd.pid file],
Tim Rice88f2ab52002-03-17 12:17:34 -08004821 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004822 if test -n "$withval" && test "x$withval" != "xno" && \
4823 test "x${withval}" != "xyes"; then
Tim Rice88f2ab52002-03-17 12:17:34 -08004824 piddir=$withval
Tim Riceeae17cc2005-03-17 16:52:20 -08004825 if test ! -d $piddir ; then
Tim Rice88f2ab52002-03-17 12:17:34 -08004826 AC_MSG_WARN([** no $piddir directory on this system **])
4827 fi
4828 fi
4829 ]
4830)
4831
Tim Ricee1d93702016-05-31 11:13:22 -07004832AC_DEFINE_UNQUOTED([_PATH_SSH_PIDDIR], ["$piddir"],
Tim Rice648f8762011-01-26 12:38:57 -08004833 [Specify location of ssh.pid])
4834AC_SUBST([piddir])
Damien Miller5eed6a22000-01-16 12:05:18 +11004835
andre2ff7b5d2000-06-03 14:57:40 +00004836dnl allow user to disable some login recording features
Tim Rice648f8762011-01-26 12:38:57 -08004837AC_ARG_ENABLE([lastlog],
andre43ca7e22000-06-19 08:23:46 +00004838 [ --disable-lastlog disable use of lastlog even if detected [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_LASTLOG])
Darren Tuckera3020db2003-06-28 12:54:33 +10004842 fi
4843 ]
andre2ff7b5d2000-06-03 14:57:40 +00004844)
Tim Rice648f8762011-01-26 12:38:57 -08004845AC_ARG_ENABLE([utmp],
andre43ca7e22000-06-19 08:23:46 +00004846 [ --disable-utmp disable use of utmp even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004847 [
4848 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004849 AC_DEFINE([DISABLE_UTMP])
Darren Tuckera3020db2003-06-28 12:54:33 +10004850 fi
4851 ]
andre2ff7b5d2000-06-03 14:57:40 +00004852)
Tim Rice648f8762011-01-26 12:38:57 -08004853AC_ARG_ENABLE([utmpx],
andre43ca7e22000-06-19 08:23:46 +00004854 [ --disable-utmpx disable use of utmpx even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004855 [
4856 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004857 AC_DEFINE([DISABLE_UTMPX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004858 [Define if you don't want to use utmpx])
Darren Tuckera3020db2003-06-28 12:54:33 +10004859 fi
4860 ]
andre2ff7b5d2000-06-03 14:57:40 +00004861)
Tim Rice648f8762011-01-26 12:38:57 -08004862AC_ARG_ENABLE([wtmp],
andre43ca7e22000-06-19 08:23:46 +00004863 [ --disable-wtmp disable use of wtmp even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004864 [
4865 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004866 AC_DEFINE([DISABLE_WTMP])
Darren Tuckera3020db2003-06-28 12:54:33 +10004867 fi
4868 ]
andre2ff7b5d2000-06-03 14:57:40 +00004869)
Tim Rice648f8762011-01-26 12:38:57 -08004870AC_ARG_ENABLE([wtmpx],
andre43ca7e22000-06-19 08:23:46 +00004871 [ --disable-wtmpx disable use of wtmpx even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004872 [
4873 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004874 AC_DEFINE([DISABLE_WTMPX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004875 [Define if you don't want to use wtmpx])
Darren Tuckera3020db2003-06-28 12:54:33 +10004876 fi
4877 ]
andre2ff7b5d2000-06-03 14:57:40 +00004878)
Tim Rice648f8762011-01-26 12:38:57 -08004879AC_ARG_ENABLE([libutil],
andre43ca7e22000-06-19 08:23:46 +00004880 [ --disable-libutil disable use of libutil (login() etc.) [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004881 [
4882 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004883 AC_DEFINE([DISABLE_LOGIN])
Darren Tuckera3020db2003-06-28 12:54:33 +10004884 fi
4885 ]
andre2ff7b5d2000-06-03 14:57:40 +00004886)
Tim Rice648f8762011-01-26 12:38:57 -08004887AC_ARG_ENABLE([pututline],
andre43ca7e22000-06-19 08:23:46 +00004888 [ --disable-pututline disable use of pututline() etc. ([uw]tmp) [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004889 [
4890 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004891 AC_DEFINE([DISABLE_PUTUTLINE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004892 [Define if you don't want to use pututline()
4893 etc. to write [uw]tmp])
Darren Tuckera3020db2003-06-28 12:54:33 +10004894 fi
4895 ]
andre2ff7b5d2000-06-03 14:57:40 +00004896)
Tim Rice648f8762011-01-26 12:38:57 -08004897AC_ARG_ENABLE([pututxline],
andre43ca7e22000-06-19 08:23:46 +00004898 [ --disable-pututxline disable use of pututxline() etc. ([uw]tmpx) [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004899 [
4900 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004901 AC_DEFINE([DISABLE_PUTUTXLINE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004902 [Define if you don't want to use pututxline()
4903 etc. to write [uw]tmpx])
Darren Tuckera3020db2003-06-28 12:54:33 +10004904 fi
4905 ]
andre2ff7b5d2000-06-03 14:57:40 +00004906)
Tim Rice648f8762011-01-26 12:38:57 -08004907AC_ARG_WITH([lastlog],
andre43ca7e22000-06-19 08:23:46 +00004908 [ --with-lastlog=FILE|DIR specify lastlog location [common locations]],
Damien Miller709528a2001-01-31 09:57:55 +11004909 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004910 if test "x$withval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004911 AC_DEFINE([DISABLE_LASTLOG])
Tim Rice35cc69d2005-03-17 16:44:25 -08004912 elif test -n "$withval" && test "x${withval}" != "xyes"; then
Damien Miller709528a2001-01-31 09:57:55 +11004913 conf_lastlog_location=$withval
4914 fi
4915 ]
4916)
andre2ff7b5d2000-06-03 14:57:40 +00004917
4918dnl lastlog, [uw]tmpx? detection
4919dnl NOTE: set the paths in the platform section to avoid the
4920dnl need for command-line parameters
4921dnl lastlog and [uw]tmp are subject to a file search if all else fails
4922
4923dnl lastlog detection
4924dnl NOTE: the code itself will detect if lastlog is a directory
4925AC_MSG_CHECKING([if your system defines LASTLOG_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08004926AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00004927#include <sys/types.h>
4928#include <utmp.h>
4929#ifdef HAVE_LASTLOG_H
4930# include <lastlog.h>
4931#endif
Damien Miller2994e082000-06-04 15:51:47 +10004932#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00004933# include <paths.h>
4934#endif
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00004935#ifdef HAVE_LOGIN_H
4936# include <login.h>
4937#endif
Tim Rice648f8762011-01-26 12:38:57 -08004938 ]], [[ char *lastlog = LASTLOG_FILE; ]])],
4939 [ AC_MSG_RESULT([yes]) ],
4940 [
4941 AC_MSG_RESULT([no])
Damien Miller2994e082000-06-04 15:51:47 +10004942 AC_MSG_CHECKING([if your system defines _PATH_LASTLOG])
Tim Rice648f8762011-01-26 12:38:57 -08004943 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller2994e082000-06-04 15:51:47 +10004944#include <sys/types.h>
4945#include <utmp.h>
4946#ifdef HAVE_LASTLOG_H
4947# include <lastlog.h>
4948#endif
4949#ifdef HAVE_PATHS_H
4950# include <paths.h>
4951#endif
Tim Rice648f8762011-01-26 12:38:57 -08004952 ]], [[ char *lastlog = _PATH_LASTLOG; ]])],
4953 [ AC_MSG_RESULT([yes]) ],
Damien Miller2994e082000-06-04 15:51:47 +10004954 [
Tim Rice648f8762011-01-26 12:38:57 -08004955 AC_MSG_RESULT([no])
Damien Miller2994e082000-06-04 15:51:47 +10004956 system_lastlog_path=no
4957 ])
Tim Rice648f8762011-01-26 12:38:57 -08004958])
Damien Miller2994e082000-06-04 15:51:47 +10004959
andre2ff7b5d2000-06-03 14:57:40 +00004960if test -z "$conf_lastlog_location"; then
4961 if test x"$system_lastlog_path" = x"no" ; then
4962 for f in /var/log/lastlog /usr/adm/lastlog /var/adm/lastlog /etc/security/lastlog ; do
Damien Milleredb82922000-06-20 13:25:52 +10004963 if (test -d "$f" || test -f "$f") ; then
andre2ff7b5d2000-06-03 14:57:40 +00004964 conf_lastlog_location=$f
4965 fi
4966 done
4967 if test -z "$conf_lastlog_location"; then
andre45cad512000-06-12 23:27:31 +00004968 AC_MSG_WARN([** Cannot find lastlog **])
4969 dnl Don't define DISABLE_LASTLOG - that means we don't try wtmp/wtmpx
andre2ff7b5d2000-06-03 14:57:40 +00004970 fi
4971 fi
4972fi
4973
4974if test -n "$conf_lastlog_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08004975 AC_DEFINE_UNQUOTED([CONF_LASTLOG_FILE], ["$conf_lastlog_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07004976 [Define if you want to specify the path to your lastlog file])
Tim Riceeae17cc2005-03-17 16:52:20 -08004977fi
andre2ff7b5d2000-06-03 14:57:40 +00004978
4979dnl utmp detection
4980AC_MSG_CHECKING([if your system defines UTMP_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08004981AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00004982#include <sys/types.h>
4983#include <utmp.h>
Damien Miller2994e082000-06-04 15:51:47 +10004984#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00004985# include <paths.h>
4986#endif
Tim Rice648f8762011-01-26 12:38:57 -08004987 ]], [[ char *utmp = UTMP_FILE; ]])],
4988 [ AC_MSG_RESULT([yes]) ],
4989 [ AC_MSG_RESULT([no])
Tim Ricee1d93702016-05-31 11:13:22 -07004990 system_utmp_path=no
Tim Rice648f8762011-01-26 12:38:57 -08004991])
andre2ff7b5d2000-06-03 14:57:40 +00004992if test -z "$conf_utmp_location"; then
4993 if test x"$system_utmp_path" = x"no" ; then
4994 for f in /etc/utmp /usr/adm/utmp /var/run/utmp; do
4995 if test -f $f ; then
4996 conf_utmp_location=$f
4997 fi
4998 done
4999 if test -z "$conf_utmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08005000 AC_DEFINE([DISABLE_UTMP])
andre2ff7b5d2000-06-03 14:57:40 +00005001 fi
5002 fi
5003fi
5004if test -n "$conf_utmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08005005 AC_DEFINE_UNQUOTED([CONF_UTMP_FILE], ["$conf_utmp_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07005006 [Define if you want to specify the path to your utmp file])
Tim Riceeae17cc2005-03-17 16:52:20 -08005007fi
andre2ff7b5d2000-06-03 14:57:40 +00005008
5009dnl wtmp detection
5010AC_MSG_CHECKING([if your system defines WTMP_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08005011AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00005012#include <sys/types.h>
5013#include <utmp.h>
Damien Miller2994e082000-06-04 15:51:47 +10005014#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00005015# include <paths.h>
5016#endif
Tim Rice648f8762011-01-26 12:38:57 -08005017 ]], [[ char *wtmp = WTMP_FILE; ]])],
5018 [ AC_MSG_RESULT([yes]) ],
5019 [ AC_MSG_RESULT([no])
Tim Ricee1d93702016-05-31 11:13:22 -07005020 system_wtmp_path=no
Tim Rice648f8762011-01-26 12:38:57 -08005021])
andre2ff7b5d2000-06-03 14:57:40 +00005022if test -z "$conf_wtmp_location"; then
5023 if test x"$system_wtmp_path" = x"no" ; then
5024 for f in /usr/adm/wtmp /var/log/wtmp; do
5025 if test -f $f ; then
5026 conf_wtmp_location=$f
5027 fi
5028 done
5029 if test -z "$conf_wtmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08005030 AC_DEFINE([DISABLE_WTMP])
andre2ff7b5d2000-06-03 14:57:40 +00005031 fi
5032 fi
5033fi
5034if test -n "$conf_wtmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08005035 AC_DEFINE_UNQUOTED([CONF_WTMP_FILE], ["$conf_wtmp_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07005036 [Define if you want to specify the path to your wtmp file])
Tim Riceeae17cc2005-03-17 16:52:20 -08005037fi
andre2ff7b5d2000-06-03 14:57:40 +00005038
andre2ff7b5d2000-06-03 14:57:40 +00005039dnl wtmpx detection
5040AC_MSG_CHECKING([if your system defines WTMPX_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08005041AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00005042#include <sys/types.h>
5043#include <utmp.h>
5044#ifdef HAVE_UTMPX_H
5045#include <utmpx.h>
5046#endif
Damien Miller2994e082000-06-04 15:51:47 +10005047#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00005048# include <paths.h>
5049#endif
Tim Rice648f8762011-01-26 12:38:57 -08005050 ]], [[ char *wtmpx = WTMPX_FILE; ]])],
5051 [ AC_MSG_RESULT([yes]) ],
5052 [ AC_MSG_RESULT([no])
Tim Ricee1d93702016-05-31 11:13:22 -07005053 system_wtmpx_path=no
Tim Rice648f8762011-01-26 12:38:57 -08005054])
andre2ff7b5d2000-06-03 14:57:40 +00005055if test -z "$conf_wtmpx_location"; then
5056 if test x"$system_wtmpx_path" = x"no" ; then
Tim Rice648f8762011-01-26 12:38:57 -08005057 AC_DEFINE([DISABLE_WTMPX])
andre2ff7b5d2000-06-03 14:57:40 +00005058 fi
5059else
Tim Rice648f8762011-01-26 12:38:57 -08005060 AC_DEFINE_UNQUOTED([CONF_WTMPX_FILE], ["$conf_wtmpx_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07005061 [Define if you want to specify the path to your wtmpx file])
Tim Riceeae17cc2005-03-17 16:52:20 -08005062fi
andre2ff7b5d2000-06-03 14:57:40 +00005063
Damien Miller4018c192000-04-30 09:30:44 +10005064
Damien Miller29ea30d2000-03-17 10:54:15 +11005065if test ! -z "$blibpath" ; then
Damien Millereab4bae2003-04-29 23:22:40 +10005066 LDFLAGS="$LDFLAGS $blibflags$blibpath"
5067 AC_MSG_WARN([Please check and edit blibpath in LDFLAGS in Makefile])
Damien Miller29ea30d2000-03-17 10:54:15 +11005068fi
5069
Damien Millera2438bb2013-03-15 10:23:07 +11005070AC_CHECK_MEMBER([struct lastlog.ll_line], [], [
Tim Riceaa86c392013-03-16 20:55:46 -07005071 if test x$SKIP_DISABLE_LASTLOG_DEFINE != "xyes" ; then
Damien Millera2438bb2013-03-15 10:23:07 +11005072 AC_DEFINE([DISABLE_LASTLOG])
Tim Riceaa86c392013-03-16 20:55:46 -07005073 fi
Damien Millera2438bb2013-03-15 10:23:07 +11005074 ], [
5075#ifdef HAVE_SYS_TYPES_H
5076#include <sys/types.h>
5077#endif
5078#ifdef HAVE_UTMP_H
5079#include <utmp.h>
5080#endif
5081#ifdef HAVE_UTMPX_H
5082#include <utmpx.h>
5083#endif
5084#ifdef HAVE_LASTLOG_H
5085#include <lastlog.h>
5086#endif
5087 ])
5088
5089AC_CHECK_MEMBER([struct utmp.ut_line], [], [
5090 AC_DEFINE([DISABLE_UTMP])
5091 AC_DEFINE([DISABLE_WTMP])
5092 ], [
5093#ifdef HAVE_SYS_TYPES_H
5094#include <sys/types.h>
5095#endif
5096#ifdef HAVE_UTMP_H
5097#include <utmp.h>
5098#endif
5099#ifdef HAVE_UTMPX_H
5100#include <utmpx.h>
5101#endif
5102#ifdef HAVE_LASTLOG_H
5103#include <lastlog.h>
5104#endif
5105 ])
5106
Darren Tucker7da23cb2005-08-03 00:20:15 +10005107dnl Adding -Werror to CFLAGS early prevents configure tests from running.
5108dnl Add now.
5109CFLAGS="$CFLAGS $werror_flags"
5110
Darren Tucker627337d2010-04-10 22:58:01 +10005111if test "x$ac_cv_func_getaddrinfo" != "xyes" ; then
5112 TEST_SSH_IPV6=no
5113else
5114 TEST_SSH_IPV6=yes
5115fi
Tim Rice648f8762011-01-26 12:38:57 -08005116AC_CHECK_DECL([BROKEN_GETADDRINFO], [TEST_SSH_IPV6=no])
5117AC_SUBST([TEST_SSH_IPV6], [$TEST_SSH_IPV6])
Darren Tucker47b8c992016-12-08 15:48:34 +11005118AC_SUBST([TEST_SSH_UTF8], [$TEST_SSH_UTF8])
Darren Tucker882abfd2013-11-09 00:17:41 +11005119AC_SUBST([TEST_MALLOC_OPTIONS], [$TEST_MALLOC_OPTIONS])
Darren Tucker6d8bd572013-06-11 11:26:10 +10005120AC_SUBST([UNSUPPORTED_ALGORITHMS], [$unsupported_algorithms])
Darren Tucker79c0e1d2017-12-11 14:38:33 +11005121AC_SUBST([DEPEND], [$(cat $srcdir/.depend)])
Darren Tucker5d376902008-06-11 04:15:05 +10005122
Damien Millerde35c382017-09-08 12:38:31 +10005123CFLAGS="${CFLAGS} ${CFLAGS_AFTER}"
5124LDFLAGS="${LDFLAGS} ${LDFLAGS_AFTER}"
5125
Damien Millerbac2d8a2000-09-05 16:13:06 +11005126AC_EXEEXT
Damien Miller223897a2006-09-12 21:54:10 +10005127AC_CONFIG_FILES([Makefile buildpkg.sh opensshd.init openssh.xml \
5128 openbsd-compat/Makefile openbsd-compat/regress/Makefile \
Damien Millerf22019b2011-05-05 13:48:37 +10005129 survey.sh])
Tim Rice13aae5e2001-10-21 17:53:58 -07005130AC_OUTPUT
Damien Miller0437b332000-05-02 09:56:41 +10005131
Damien Miller7b22d652000-06-18 14:07:04 +10005132# Print summary of options
5133
Damien Miller7b22d652000-06-18 14:07:04 +10005134# Someone please show me a better way :)
5135A=`eval echo ${prefix}` ; A=`eval echo ${A}`
5136B=`eval echo ${bindir}` ; B=`eval echo ${B}`
5137C=`eval echo ${sbindir}` ; C=`eval echo ${C}`
5138D=`eval echo ${sysconfdir}` ; D=`eval echo ${D}`
Kevin Stevese0f49142000-10-14 17:51:48 +00005139E=`eval echo ${libexecdir}/ssh-askpass` ; E=`eval echo ${E}`
Ben Lindstrombc709922001-04-18 18:04:21 +00005140F=`eval echo ${mandir}/${mansubdir}X` ; F=`eval echo ${F}`
Damien Miller7b22d652000-06-18 14:07:04 +10005141G=`eval echo ${piddir}` ; G=`eval echo ${G}`
Damien Millerf58c6722002-05-13 13:15:42 +10005142H=`eval echo ${PRIVSEP_PATH}` ; H=`eval echo ${H}`
5143I=`eval echo ${user_path}` ; I=`eval echo ${I}`
5144J=`eval echo ${superuser_path}` ; J=`eval echo ${J}`
Damien Miller7b22d652000-06-18 14:07:04 +10005145
5146echo ""
Kevin Steves393d2f72001-04-08 22:50:43 +00005147echo "OpenSSH has been configured with the following options:"
Damien Millerf58c6722002-05-13 13:15:42 +10005148echo " User binaries: $B"
5149echo " System binaries: $C"
5150echo " Configuration files: $D"
5151echo " Askpass program: $E"
5152echo " Manual pages: $F"
5153echo " PID file: $G"
5154echo " Privilege separation chroot path: $H"
Darren Tuckere1a790d2003-09-16 11:52:19 +10005155if test "x$external_path_file" = "x/etc/login.conf" ; then
5156echo " At runtime, sshd will use the path defined in $external_path_file"
5157echo " Make sure the path to scp is present, otherwise scp will not work"
Tim Rice43a1c132002-04-17 21:19:14 -07005158else
Damien Millerf58c6722002-05-13 13:15:42 +10005159echo " sshd default user PATH: $I"
Tim Riceb925b4b2003-09-15 22:40:49 -07005160 if test ! -z "$external_path_file"; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10005161echo " (If PATH is set in $external_path_file it will be used instead. If"
5162echo " used, ensure the path to scp is present, otherwise scp will not work.)"
5163 fi
Tim Rice43a1c132002-04-17 21:19:14 -07005164fi
Damien Millera18bbd32002-05-13 10:48:57 +10005165if test ! -z "$superuser_path" ; then
Damien Millerf58c6722002-05-13 13:15:42 +10005166echo " sshd superuser user PATH: $J"
Damien Millera18bbd32002-05-13 10:48:57 +10005167fi
Damien Millerf58c6722002-05-13 13:15:42 +10005168echo " Manpage format: $MANTYPE"
Damien Miller7abe09b2003-05-15 10:53:49 +10005169echo " PAM support: $PAM_MSG"
Damien Miller1b06dc32006-08-31 03:24:41 +10005170echo " OSF SIA support: $SIA_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10005171echo " KerberosV support: $KRB5_MSG"
Damien Miller73b42d22006-04-22 21:26:08 +10005172echo " SELinux support: $SELINUX_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10005173echo " MD5 password support: $MD5_MSG"
Darren Tucker16bcc1c2004-11-07 20:14:34 +11005174echo " libedit support: $LIBEDIT_MSG"
Damien Miller523db852017-02-03 16:01:22 +11005175echo " libldns support: $LDNS_MSG"
Damien Miller1b06dc32006-08-31 03:24:41 +10005176echo " Solaris process contract support: $SPC_MSG"
Darren Tucker97528352010-11-05 12:03:05 +11005177echo " Solaris project support: $SP_MSG"
Damien Miller4626cba2016-01-08 14:24:56 +11005178echo " Solaris privilege support: $SPP_MSG"
Damien Miller903e1152002-05-13 14:41:31 +10005179echo " IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10005180echo " Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG"
5181echo " BSD Auth support: $BSD_AUTH_MSG"
5182echo " Random number source: $RAND_MSG"
Damien Miller69ff1df2011-06-23 08:30:03 +10005183echo " Privsep sandbox style: $SANDBOX_STYLE"
Damien Miller60396b02001-02-18 17:01:00 +11005184
Damien Miller7b22d652000-06-18 14:07:04 +10005185echo ""
5186
Ben Lindstrom28bfc0d2000-12-18 19:58:57 +00005187echo " Host: ${host}"
5188echo " Compiler: ${CC}"
5189echo " Compiler flags: ${CFLAGS}"
5190echo "Preprocessor flags: ${CPPFLAGS}"
5191echo " Linker flags: ${LDFLAGS}"
Darren Tucker20e9f972007-03-25 18:26:01 +10005192echo " Libraries: ${LIBS}"
5193if test ! -z "${SSHDLIBS}"; then
5194echo " +for sshd: ${SSHDLIBS}"
5195fi
Damien Miller71adf122011-01-25 12:16:15 +11005196if test ! -z "${SSHLIBS}"; then
5197echo " +for ssh: ${SSHLIBS}"
5198fi
Damien Miller7b22d652000-06-18 14:07:04 +10005199
5200echo ""
5201
Tim Rice6f1f7582004-05-30 21:38:51 -07005202if test "x$MAKE_PACKAGE_SUPPORTED" = "xyes" ; then
Darren Tuckercf59d312004-08-29 21:18:09 +10005203 echo "SVR4 style packages are supported with \"make package\""
5204 echo ""
Tim Rice6f1f7582004-05-30 21:38:51 -07005205fi
5206
Damien Miller82cf0ce2000-12-20 13:34:48 +11005207if test "x$PAM_MSG" = "xyes" ; then
Damien Miller6c21c512002-01-22 21:57:53 +11005208 echo "PAM is enabled. You may need to install a PAM control file "
5209 echo "for sshd, otherwise password authentication may fail. "
Damien Millera8e06ce2003-11-21 23:48:55 +11005210 echo "Example PAM control files can be found in the contrib/ "
Damien Miller6c21c512002-01-22 21:57:53 +11005211 echo "subdirectory"
Damien Miller6f9c3372000-10-25 10:06:04 +11005212 echo ""
5213fi
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00005214
Damien Millerb4097182004-05-23 14:09:40 +10005215if test ! -z "$NO_PEERCHECK" ; then
Darren Tucker164aa302007-03-21 21:39:57 +11005216 echo "WARNING: the operating system that you are using does not"
5217 echo "appear to support getpeereid(), getpeerucred() or the"
5218 echo "SO_PEERCRED getsockopt() option. These facilities are used to"
5219 echo "enforce security checks to prevent unauthorised connections to"
5220 echo "ssh-agent. Their absence increases the risk that a malicious"
5221 echo "user can connect to your agent."
Damien Millerb4097182004-05-23 14:09:40 +10005222 echo ""
5223fi
5224
Darren Tuckerd9f88912005-02-20 21:01:48 +11005225if test "$AUDIT_MODULE" = "bsm" ; then
5226 echo "WARNING: BSM audit support is currently considered EXPERIMENTAL."
5227 echo "See the Solaris section in README.platform for details."
5228fi