blob: 34cd94a7f7b3f4973c209c092d8e4607cf4201df [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])
Darren Tuckerc90a7922019-01-21 09:22:36 +110022AC_PROG_CC([cc gcc])
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])
Darren Tucker285546b2019-05-10 15:04:42 +100044AC_PATH_PROG([NROFF], [nroff awf])
Tim Rice648f8762011-01-26 12:38:57 -080045AC_PATH_PROG([MANDOC], [mandoc])
46AC_SUBST([TEST_SHELL], [sh])
Damien Miller2e1b0821999-12-25 10:11:29 +110047
Darren Tucker285546b2019-05-10 15:04:42 +100048dnl select manpage formatter to be used to build "cat" format pages.
Damien Miller30a69e72011-01-04 08:16:27 +110049if 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
Darren Tucker6fd4aa22019-05-15 16:19:14 +100056 AC_MSG_WARN([no manpage formatter found])
Damien Miller30a69e72011-01-04 08:16:27 +110057 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([-Wunknown-warning-option])
Damien Millere0e7e3d2019-08-30 14:26:19 +1000156 OSSH_CHECK_CFLAG_COMPILE([-Wno-error=format-truncation])
157 OSSH_CHECK_CFLAG_COMPILE([-Qunused-arguments])
Damien Millerb1763622011-05-20 11:45:25 +1000158 OSSH_CHECK_CFLAG_COMPILE([-Wall])
Damien Millere0e7e3d2019-08-30 14:26:19 +1000159 OSSH_CHECK_CFLAG_COMPILE([-Wextra])
Damien Millerb1763622011-05-20 11:45:25 +1000160 OSSH_CHECK_CFLAG_COMPILE([-Wpointer-arith])
161 OSSH_CHECK_CFLAG_COMPILE([-Wuninitialized])
162 OSSH_CHECK_CFLAG_COMPILE([-Wsign-compare])
163 OSSH_CHECK_CFLAG_COMPILE([-Wformat-security])
Darren Tuckerabbc7a72013-05-10 13:54:23 +1000164 OSSH_CHECK_CFLAG_COMPILE([-Wsizeof-pointer-memaccess])
Damien Millerb1763622011-05-20 11:45:25 +1000165 OSSH_CHECK_CFLAG_COMPILE([-Wpointer-sign], [-Wno-pointer-sign])
166 OSSH_CHECK_CFLAG_COMPILE([-Wunused-result], [-Wno-unused-result])
Darren Tucker6cf1c402019-11-18 14:14:18 +1100167 OSSH_CHECK_CFLAG_COMPILE([-Wimplicit-fallthrough])
Damien Millerb1763622011-05-20 11:45:25 +1000168 OSSH_CHECK_CFLAG_COMPILE([-fno-strict-aliasing])
Darren Tuckerfd994372014-01-17 09:53:24 +1100169 if test "x$use_toolchain_hardening" = "x1"; then
Darren Tucker3377df02018-02-11 09:32:37 +1100170 OSSH_CHECK_CFLAG_COMPILE([-mretpoline]) # clang
Darren Tucker174bed62018-02-13 18:12:47 +1100171 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,retpolineplt])
Damien Miller161af8f2017-09-19 10:18:56 +1000172 OSSH_CHECK_CFLAG_COMPILE([-D_FORTIFY_SOURCE=2])
Darren Tuckerfd994372014-01-17 09:53:24 +1100173 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,relro])
174 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,now])
175 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,noexecstack])
Damien Miller5c2ff5e2014-01-22 21:30:12 +1100176 # NB. -ftrapv expects certain support functions to be present in
177 # the compiler library (libgcc or similar) to detect integer operations
178 # that can overflow. We must check that the result of enabling it
179 # actually links. The test program compiled/linked includes a number
180 # of integer operations that should exercise this.
181 OSSH_CHECK_CFLAG_LINK([-ftrapv])
Darren Tuckerfd994372014-01-17 09:53:24 +1100182 fi
Tim Rice648f8762011-01-26 12:38:57 -0800183 AC_MSG_CHECKING([gcc version])
Darren Tucker3f9545e2005-11-12 15:20:52 +1100184 GCC_VER=`$CC -v 2>&1 | $AWK '/gcc version /{print $3}'`
Tim Rice3db1e3f2005-08-23 17:11:26 -0700185 case $GCC_VER in
Darren Tucker391de5c2007-04-29 14:49:21 +1000186 1.*) no_attrib_nonnull=1 ;;
187 2.8* | 2.9*)
Darren Tucker391de5c2007-04-29 14:49:21 +1000188 no_attrib_nonnull=1
189 ;;
190 2.*) no_attrib_nonnull=1 ;;
Darren Tuckerf0324352005-11-10 21:30:36 +1100191 *) ;;
Tim Rice3db1e3f2005-08-23 17:11:26 -0700192 esac
Tim Rice648f8762011-01-26 12:38:57 -0800193 AC_MSG_RESULT([$GCC_VER])
Damien Millerde3cb0a2005-05-26 20:48:25 +1000194
Tim Rice648f8762011-01-26 12:38:57 -0800195 AC_MSG_CHECKING([if $CC accepts -fno-builtin-memset])
Darren Tucker330c93f2008-06-16 02:27:48 +1000196 saved_CFLAGS="$CFLAGS"
197 CFLAGS="$CFLAGS -fno-builtin-memset"
Tim Rice648f8762011-01-26 12:38:57 -0800198 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <string.h> ]],
199 [[ char b[10]; memset(b, 0, sizeof(b)); ]])],
200 [ AC_MSG_RESULT([yes]) ],
201 [ AC_MSG_RESULT([no])
Darren Tucker330c93f2008-06-16 02:27:48 +1000202 CFLAGS="$saved_CFLAGS" ]
Tim Rice648f8762011-01-26 12:38:57 -0800203 )
Darren Tucker330c93f2008-06-16 02:27:48 +1000204
Darren Tuckerb7918af2008-03-09 11:34:23 +1100205 # -fstack-protector-all doesn't always work for some GCC versions
Darren Tuckerfe1cf972008-03-09 22:50:50 +1100206 # and/or platforms, so we test if we can. If it's not supported
Damien Miller7df2e402008-12-08 09:35:36 +1100207 # on a given platform gcc will emit a warning so we use -Werror.
Darren Tuckerb7918af2008-03-09 11:34:23 +1100208 if test "x$use_stack_protector" = "x1"; then
Darren Tuckerfd994372014-01-17 09:53:24 +1100209 for t in -fstack-protector-strong -fstack-protector-all \
210 -fstack-protector; do
Tim Rice648f8762011-01-26 12:38:57 -0800211 AC_MSG_CHECKING([if $CC supports $t])
Darren Tuckerb7918af2008-03-09 11:34:23 +1100212 saved_CFLAGS="$CFLAGS"
213 saved_LDFLAGS="$LDFLAGS"
Darren Tuckerfe1cf972008-03-09 22:50:50 +1100214 CFLAGS="$CFLAGS $t -Werror"
215 LDFLAGS="$LDFLAGS $t -Werror"
216 AC_LINK_IFELSE(
Darren Tucker9239a182019-10-24 14:39:49 +1100217 [AC_LANG_PROGRAM([[
218 #include <stdio.h>
219 int func (int t) {char b[100]; snprintf(b,sizeof b,"%d",t); return t;}
220 ]],
Tim Rice648f8762011-01-26 12:38:57 -0800221 [[
222 char x[256];
Darren Tucker9239a182019-10-24 14:39:49 +1100223 snprintf(x, sizeof(x), "XXX%d", func(1));
Tim Rice648f8762011-01-26 12:38:57 -0800224 ]])],
225 [ AC_MSG_RESULT([yes])
Darren Tuckerfe1cf972008-03-09 22:50:50 +1100226 CFLAGS="$saved_CFLAGS $t"
227 LDFLAGS="$saved_LDFLAGS $t"
Tim Rice648f8762011-01-26 12:38:57 -0800228 AC_MSG_CHECKING([if $t works])
Darren Tuckerb7918af2008-03-09 11:34:23 +1100229 AC_RUN_IFELSE(
Darren Tucker9239a182019-10-24 14:39:49 +1100230 [AC_LANG_PROGRAM([[
231 #include <stdio.h>
232 int func (int t) {char b[100]; snprintf(b,sizeof b,"%d",t); return t;}
233 ]],
Tim Rice648f8762011-01-26 12:38:57 -0800234 [[
235 char x[256];
Darren Tucker9239a182019-10-24 14:39:49 +1100236 snprintf(x, sizeof(x), "XXX%d", func(1));
Tim Rice648f8762011-01-26 12:38:57 -0800237 ]])],
238 [ AC_MSG_RESULT([yes])
Darren Tuckerb7918af2008-03-09 11:34:23 +1100239 break ],
Tim Rice648f8762011-01-26 12:38:57 -0800240 [ AC_MSG_RESULT([no]) ],
Darren Tuckerb7918af2008-03-09 11:34:23 +1100241 [ AC_MSG_WARN([cross compiling: cannot test])
242 break ]
Darren Tuckerfe1cf972008-03-09 22:50:50 +1100243 )
Darren Tuckerb7918af2008-03-09 11:34:23 +1100244 ],
Tim Rice648f8762011-01-26 12:38:57 -0800245 [ AC_MSG_RESULT([no]) ]
Darren Tuckerb7918af2008-03-09 11:34:23 +1100246 )
247 CFLAGS="$saved_CFLAGS"
248 LDFLAGS="$saved_LDFLAGS"
249 done
250 fi
Darren Tucker319b3d92007-12-02 21:02:22 +1100251
Darren Tucker67b37032005-06-03 17:58:31 +1000252 if test -z "$have_llong_max"; then
253 # retry LLONG_MAX with -std=gnu99, needed on some Linuxes
254 unset ac_cv_have_decl_LLONG_MAX
255 saved_CFLAGS="$CFLAGS"
256 CFLAGS="$CFLAGS -std=gnu99"
Tim Rice648f8762011-01-26 12:38:57 -0800257 AC_CHECK_DECL([LLONG_MAX],
Darren Tucker67b37032005-06-03 17:58:31 +1000258 [have_llong_max=1],
259 [CFLAGS="$saved_CFLAGS"],
260 [#include <limits.h>]
261 )
262 fi
Damien Miller166bd442000-03-16 10:48:25 +1100263fi
264
Darren Tucker951b53b2013-02-08 11:50:09 +1100265AC_MSG_CHECKING([if compiler allows __attribute__ on return types])
266AC_COMPILE_IFELSE(
267 [AC_LANG_PROGRAM([[
268#include <stdlib.h>
269__attribute__((__unused__)) static void foo(void){return;}]],
270 [[ exit(0); ]])],
271 [ AC_MSG_RESULT([yes]) ],
272 [ AC_MSG_RESULT([no])
273 AC_DEFINE(NO_ATTRIBUTE_ON_RETURN_TYPE, 1,
274 [compiler does not accept __attribute__ on return types]) ]
275)
276
Darren Tucker1323f122018-02-27 08:41:25 +1100277AC_MSG_CHECKING([if compiler allows __attribute__ prototype args])
278AC_COMPILE_IFELSE(
279 [AC_LANG_PROGRAM([[
280#include <stdlib.h>
281typedef void foo(const char *, ...) __attribute__((format(printf, 1, 2)));]],
282 [[ exit(0); ]])],
283 [ AC_MSG_RESULT([yes]) ],
284 [ AC_MSG_RESULT([no])
285 AC_DEFINE(NO_ATTRIBUTE_ON_PROTOTYPE_ARGS, 1,
Damien Miller10479cc2018-04-10 10:19:02 +1000286 [compiler does not accept __attribute__ on prototype args]) ]
Darren Tucker1323f122018-02-27 08:41:25 +1100287)
288
Darren Tucker391de5c2007-04-29 14:49:21 +1000289if test "x$no_attrib_nonnull" != "x1" ; then
Tim Rice648f8762011-01-26 12:38:57 -0800290 AC_DEFINE([HAVE_ATTRIBUTE__NONNULL__], [1], [Have attribute nonnull])
Darren Tucker391de5c2007-04-29 14:49:21 +1000291fi
292
Tim Rice648f8762011-01-26 12:38:57 -0800293AC_ARG_WITH([rpath],
Tim Rice88368a32003-12-08 12:35:59 -0800294 [ --without-rpath Disable auto-added -R linker paths],
295 [
Tim Riceeae17cc2005-03-17 16:52:20 -0800296 if test "x$withval" = "xno" ; then
Darren Tucker2f0bad22019-01-21 21:28:27 +1100297 rpath_opt=""
298 elif test "x$withval" = "xyes" ; then
299 rpath_opt="-R"
300 else
301 rpath_opt="$withval"
Tim Rice88368a32003-12-08 12:35:59 -0800302 fi
303 ]
304)
305
Tim Rice1cfab232006-10-03 09:34:35 -0700306# Allow user to specify flags
Tim Rice648f8762011-01-26 12:38:57 -0800307AC_ARG_WITH([cflags],
Tim Rice1cfab232006-10-03 09:34:35 -0700308 [ --with-cflags Specify additional flags to pass to compiler],
309 [
310 if test -n "$withval" && test "x$withval" != "xno" && \
311 test "x${withval}" != "xyes"; then
312 CFLAGS="$CFLAGS $withval"
313 fi
314 ]
315)
Damien Millerde35c382017-09-08 12:38:31 +1000316
317AC_ARG_WITH([cflags-after],
318 [ --with-cflags-after Specify additional flags to pass to compiler after configure],
319 [
320 if test -n "$withval" && test "x$withval" != "xno" && \
321 test "x${withval}" != "xyes"; then
322 CFLAGS_AFTER="$withval"
323 fi
324 ]
325)
Tim Rice648f8762011-01-26 12:38:57 -0800326AC_ARG_WITH([cppflags],
Tim Rice1cfab232006-10-03 09:34:35 -0700327 [ --with-cppflags Specify additional flags to pass to preprocessor] ,
328 [
329 if test -n "$withval" && test "x$withval" != "xno" && \
330 test "x${withval}" != "xyes"; then
331 CPPFLAGS="$CPPFLAGS $withval"
332 fi
333 ]
334)
Tim Rice648f8762011-01-26 12:38:57 -0800335AC_ARG_WITH([ldflags],
Tim Rice1cfab232006-10-03 09:34:35 -0700336 [ --with-ldflags Specify additional flags to pass to linker],
337 [
338 if test -n "$withval" && test "x$withval" != "xno" && \
339 test "x${withval}" != "xyes"; then
340 LDFLAGS="$LDFLAGS $withval"
341 fi
342 ]
343)
Damien Millerde35c382017-09-08 12:38:31 +1000344AC_ARG_WITH([ldflags-after],
345 [ --with-ldflags-after Specify additional flags to pass to linker after configure],
346 [
347 if test -n "$withval" && test "x$withval" != "xno" && \
348 test "x${withval}" != "xyes"; then
349 LDFLAGS_AFTER="$withval"
350 fi
351 ]
352)
Tim Rice648f8762011-01-26 12:38:57 -0800353AC_ARG_WITH([libs],
Tim Rice1cfab232006-10-03 09:34:35 -0700354 [ --with-libs Specify additional libraries to link with],
355 [
356 if test -n "$withval" && test "x$withval" != "xno" && \
357 test "x${withval}" != "xyes"; then
358 LIBS="$LIBS $withval"
359 fi
360 ]
361)
Tim Rice648f8762011-01-26 12:38:57 -0800362AC_ARG_WITH([Werror],
Tim Rice1cfab232006-10-03 09:34:35 -0700363 [ --with-Werror Build main code with -Werror],
364 [
365 if test -n "$withval" && test "x$withval" != "xno"; then
366 werror_flags="-Werror"
367 if test "x${withval}" != "xyes"; then
368 werror_flags="$withval"
369 fi
370 fi
371 ]
372)
373
Tim Rice648f8762011-01-26 12:38:57 -0800374AC_CHECK_HEADERS([ \
Damien Miller1ff130d2013-12-07 11:51:51 +1100375 blf.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700376 bstring.h \
377 crypt.h \
378 crypto/sha2.h \
379 dirent.h \
380 endian.h \
Damien Miller91f40d82013-02-22 11:37:00 +1100381 elf.h \
Darren Tucker6310ef22016-07-13 14:42:35 +1000382 err.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700383 features.h \
384 fcntl.h \
385 floatingpoint.h \
Darren Tucker0e3c5bc2019-11-01 18:24:29 +1100386 fnmatch.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700387 getopt.h \
388 glob.h \
389 ia.h \
390 iaf.h \
Darren Tuckerb59162d2018-02-23 15:20:42 +1100391 ifaddrs.h \
Darren Tucker6d725682014-01-17 19:17:34 +1100392 inttypes.h \
Darren Tuckerf3f2cc82016-07-11 17:23:38 +1000393 langinfo.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700394 limits.h \
Darren Tuckerae133d42013-06-06 08:30:20 +1000395 locale.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700396 login.h \
397 maillock.h \
398 ndir.h \
399 net/if_tun.h \
400 netdb.h \
401 netgroup.h \
402 pam/pam_appl.h \
403 paths.h \
Darren Tuckerfebf0f52007-06-25 22:15:12 +1000404 poll.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700405 pty.h \
406 readpassphrase.h \
407 rpc/types.h \
408 security/pam_appl.h \
409 sha2.h \
410 shadow.h \
411 stddef.h \
412 stdint.h \
413 string.h \
414 strings.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700415 sys/bitypes.h \
416 sys/bsdtty.h \
417 sys/cdefs.h \
418 sys/dir.h \
Damien Millerf8854742018-02-26 12:18:14 +1100419 sys/file.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700420 sys/mman.h \
Darren Tuckerce066f62018-02-22 20:45:09 +1100421 sys/label.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700422 sys/ndir.h \
Darren Tucker7c92a652007-09-27 07:00:09 +1000423 sys/poll.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700424 sys/prctl.h \
425 sys/pstat.h \
Darren Tucker5ee3fb52016-11-01 08:12:33 +1100426 sys/ptrace.h \
Damien Millerafa6e792018-04-13 13:31:42 +1000427 sys/random.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700428 sys/select.h \
429 sys/stat.h \
430 sys/stream.h \
431 sys/stropts.h \
432 sys/strtio.h \
Darren Tucker5b2e2ba2008-06-08 09:25:28 +1000433 sys/statvfs.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700434 sys/sysmacros.h \
435 sys/time.h \
436 sys/timers.h \
Darren Tucker11057562018-02-25 11:22:57 +1100437 sys/vfs.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700438 time.h \
439 tmpdir.h \
440 ttyent.h \
Tim Riceaa8954f2007-05-09 15:57:43 -0700441 ucred.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700442 unistd.h \
443 usersec.h \
444 util.h \
445 utime.h \
446 utmp.h \
447 utmpx.h \
448 vis.h \
Darren Tuckerf3f2cc82016-07-11 17:23:38 +1000449 wchar.h \
Tim Rice648f8762011-01-26 12:38:57 -0800450])
Tim Rice1cfab232006-10-03 09:34:35 -0700451
Darren Tuckerce066f62018-02-22 20:45:09 +1100452# On some platforms (eg SunOS4) sys/audit.h requires sys/[time|types|label.h]
453# to be included first.
454AC_CHECK_HEADERS([sys/audit.h], [], [], [
455#ifdef HAVE_SYS_TIME_H
456# include <sys/time.h>
457#endif
458#ifdef HAVE_SYS_TYPES_H
459# include <sys/types.h>
460#endif
461#ifdef HAVE_SYS_LABEL_H
462# include <sys/label.h>
463#endif
464])
465
Darren Tuckerdd9d9b32017-08-28 16:48:27 +1000466# sys/capsicum.h requires sys/types.h
467AC_CHECK_HEADERS([sys/capsicum.h], [], [], [
468#ifdef HAVE_SYS_TYPES_H
469# include <sys/types.h>
470#endif
471])
472
Darren Tuckerfa1b8342017-11-03 14:09:45 +1100473# net/route.h requires sys/socket.h and sys/types.h.
474# sys/sysctl.h also requires sys/param.h
475AC_CHECK_HEADERS([net/route.h sys/sysctl.h], [], [], [
476#ifdef HAVE_SYS_TYPES_H
477# include <sys/types.h>
478#endif
479#include <sys/param.h>
Damien Miller32354732017-10-25 11:25:43 +1100480#include <sys/socket.h>
481])
482
Tim Rice1cfab232006-10-03 09:34:35 -0700483# lastlog.h requires sys/time.h to be included first on Solaris
Tim Rice648f8762011-01-26 12:38:57 -0800484AC_CHECK_HEADERS([lastlog.h], [], [], [
Tim Rice1cfab232006-10-03 09:34:35 -0700485#ifdef HAVE_SYS_TIME_H
486# include <sys/time.h>
487#endif
488])
489
490# sys/ptms.h requires sys/stream.h to be included first on Solaris
Tim Rice648f8762011-01-26 12:38:57 -0800491AC_CHECK_HEADERS([sys/ptms.h], [], [], [
Tim Rice1cfab232006-10-03 09:34:35 -0700492#ifdef HAVE_SYS_STREAM_H
493# include <sys/stream.h>
494#endif
495])
496
497# login_cap.h requires sys/types.h on NetBSD
Tim Rice648f8762011-01-26 12:38:57 -0800498AC_CHECK_HEADERS([login_cap.h], [], [], [
Tim Rice1cfab232006-10-03 09:34:35 -0700499#include <sys/types.h>
500])
501
Darren Tuckerc4b22ca2009-07-12 21:56:29 +1000502# older BSDs need sys/param.h before sys/mount.h
Tim Rice648f8762011-01-26 12:38:57 -0800503AC_CHECK_HEADERS([sys/mount.h], [], [], [
Darren Tuckerc4b22ca2009-07-12 21:56:29 +1000504#include <sys/param.h>
505])
506
Darren Tuckeref4901c2013-06-03 01:59:13 +1000507# Android requires sys/socket.h to be included before sys/un.h
508AC_CHECK_HEADERS([sys/un.h], [], [], [
Darren Tucker0b43ffe2013-06-03 09:30:44 +1000509#include <sys/types.h>
Darren Tucker16cac192013-06-04 12:55:24 +1000510#include <sys/socket.h>
Darren Tuckeref4901c2013-06-03 01:59:13 +1000511])
512
Damien Miller1b06dc32006-08-31 03:24:41 +1000513# Messages for features tested for in target-specific section
514SIA_MSG="no"
515SPC_MSG="no"
Darren Tucker97528352010-11-05 12:03:05 +1100516SP_MSG="no"
Damien Miller4626cba2016-01-08 14:24:56 +1100517SPP_MSG="no"
518
519# Support for Solaris/Illumos privileges (this test is used by both
520# the --with-solaris-privs option and --with-sandbox=solaris).
521SOLARIS_PRIVS="no"
Damien Miller1b06dc32006-08-31 03:24:41 +1000522
Damien Millera22ba012000-03-02 23:09:20 +1100523# Check for some target-specific stuff
Damien Miller76112de1999-12-21 11:18:08 +1100524case "$host" in
Damien Miller75b1d102000-01-07 14:01:41 +1100525*-*-aix*)
Darren Tucker9216c372006-09-18 23:17:40 +1000526 # Some versions of VAC won't allow macro redefinitions at
527 # -qlanglevel=ansi, and autoconf 2.60 sometimes insists on using that
528 # particularly with older versions of vac or xlc.
Damien Miller10479cc2018-04-10 10:19:02 +1000529 # It also throws errors about null macro arguments, but these are
Darren Tucker9216c372006-09-18 23:17:40 +1000530 # not fatal.
Tim Rice648f8762011-01-26 12:38:57 -0800531 AC_MSG_CHECKING([if compiler allows macro redefinitions])
Darren Tucker9216c372006-09-18 23:17:40 +1000532 AC_COMPILE_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -0800533 [AC_LANG_PROGRAM([[
Darren Tucker9216c372006-09-18 23:17:40 +1000534#define testmacro foo
Tim Rice648f8762011-01-26 12:38:57 -0800535#define testmacro bar]],
536 [[ exit(0); ]])],
537 [ AC_MSG_RESULT([yes]) ],
538 [ AC_MSG_RESULT([no])
Darren Tucker9216c372006-09-18 23:17:40 +1000539 CC="`echo $CC | sed 's/-qlanglvl\=ansi//g'`"
Darren Tucker9216c372006-09-18 23:17:40 +1000540 CFLAGS="`echo $CFLAGS | sed 's/-qlanglvl\=ansi//g'`"
541 CPPFLAGS="`echo $CPPFLAGS | sed 's/-qlanglvl\=ansi//g'`"
542 ]
543 )
544
Damien Millera8e06ce2003-11-21 23:48:55 +1100545 AC_MSG_CHECKING([how to specify blibpath for linker ($LD)])
Damien Millereab4bae2003-04-29 23:22:40 +1000546 if (test -z "$blibpath"); then
Tim Ricefcb62202004-01-23 18:35:16 -0800547 blibpath="/usr/lib:/lib"
Damien Miller29ea30d2000-03-17 10:54:15 +1100548 fi
Damien Millereab4bae2003-04-29 23:22:40 +1000549 saved_LDFLAGS="$LDFLAGS"
Darren Tuckerbdc12122006-07-06 11:56:25 +1000550 if test "$GCC" = "yes"; then
551 flags="-Wl,-blibpath: -Wl,-rpath, -blibpath:"
552 else
553 flags="-blibpath: -Wl,-blibpath: -Wl,-rpath,"
554 fi
555 for tryflags in $flags ;do
Damien Millereab4bae2003-04-29 23:22:40 +1000556 if (test -z "$blibflags"); then
557 LDFLAGS="$saved_LDFLAGS $tryflags$blibpath"
Tim Rice648f8762011-01-26 12:38:57 -0800558 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
559 [blibflags=$tryflags], [])
Damien Millereab4bae2003-04-29 23:22:40 +1000560 fi
561 done
562 if (test -z "$blibflags"); then
Tim Rice648f8762011-01-26 12:38:57 -0800563 AC_MSG_RESULT([not found])
Damien Millereab4bae2003-04-29 23:22:40 +1000564 AC_MSG_ERROR([*** must be able to specify blibpath on AIX - check config.log])
565 else
Tim Rice648f8762011-01-26 12:38:57 -0800566 AC_MSG_RESULT([$blibflags])
Damien Millereab4bae2003-04-29 23:22:40 +1000567 fi
568 LDFLAGS="$saved_LDFLAGS"
Darren Tucker5c6a91a2003-07-14 16:21:44 +1000569 dnl Check for authenticate. Might be in libs.a on older AIXes
Tim Rice648f8762011-01-26 12:38:57 -0800570 AC_CHECK_FUNC([authenticate], [AC_DEFINE([WITH_AIXAUTHENTICATE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700571 [Define if you want to enable AIX4's authenticate function])],
Tim Rice648f8762011-01-26 12:38:57 -0800572 [AC_CHECK_LIB([s], [authenticate],
573 [ AC_DEFINE([WITH_AIXAUTHENTICATE])
Tim Ricee958ed32002-07-05 07:12:33 -0700574 LIBS="$LIBS -ls"
575 ])
576 ])
Darren Tucker3c774c52005-02-16 22:49:31 +1100577 dnl Check for various auth function declarations in headers.
Darren Tucker04cfbe02005-02-20 23:27:11 +1100578 AC_CHECK_DECLS([authenticate, loginrestrictions, loginsuccess,
Darren Tuckere66519d2005-03-21 22:46:34 +1100579 passwdexpired, setauthdb], , , [#include <usersec.h>])
Darren Tucker5c6a91a2003-07-14 16:21:44 +1000580 dnl Check if loginfailed is declared and takes 4 arguments (AIX >= 5.2)
Tim Rice648f8762011-01-26 12:38:57 -0800581 AC_CHECK_DECLS([loginfailed],
582 [AC_MSG_CHECKING([if loginfailed takes 4 arguments])
583 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <usersec.h> ]],
584 [[ (void)loginfailed("user","host","tty",0); ]])],
585 [AC_MSG_RESULT([yes])
586 AC_DEFINE([AIX_LOGINFAILED_4ARG], [1],
587 [Define if your AIX loginfailed() function
588 takes 4 arguments (AIX >= 5.2)])], [AC_MSG_RESULT([no])
589 ])],
590 [],
591 [#include <usersec.h>]
Darren Tucker5c6a91a2003-07-14 16:21:44 +1000592 )
Tim Rice648f8762011-01-26 12:38:57 -0800593 AC_CHECK_FUNCS([getgrset setauthdb])
594 AC_CHECK_DECL([F_CLOSEM],
595 AC_DEFINE([HAVE_FCNTL_CLOSEM], [1], [Use F_CLOSEM fcntl for closefrom]),
Darren Tucker3083bc22006-08-17 19:35:49 +1000596 [],
597 [ #include <limits.h>
598 #include <fcntl.h> ]
599 )
Darren Tucker691d5232005-02-15 21:45:57 +1100600 check_for_aix_broken_getaddrinfo=1
Tim Rice648f8762011-01-26 12:38:57 -0800601 AC_DEFINE([SETEUID_BREAKS_SETUID], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700602 [Define if your platform breaks doing a seteuid before a setuid])
Tim Rice648f8762011-01-26 12:38:57 -0800603 AC_DEFINE([BROKEN_SETREUID], [1], [Define if your setreuid() is broken])
604 AC_DEFINE([BROKEN_SETREGID], [1], [Define if your setregid() is broken])
andre60f3c982000-06-03 16:18:19 +0000605 dnl AIX handles lastlog as part of its login message
Tim Rice648f8762011-01-26 12:38:57 -0800606 AC_DEFINE([DISABLE_LASTLOG], [1], [Define if you don't want to use lastlog])
607 AC_DEFINE([LOGIN_NEEDS_UTMPX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700608 [Some systems need a utmpx entry for /bin/login to work])
Tim Rice648f8762011-01-26 12:38:57 -0800609 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV],
Tim Rice7df8d392005-09-19 09:33:39 -0700610 [Define to a Set Process Title type if your system is
611 supported by bsd-setproctitle.c])
Tim Rice648f8762011-01-26 12:38:57 -0800612 AC_DEFINE([SSHPAM_CHAUTHTOK_NEEDS_RUID], [1],
Darren Tucker91d25a02005-11-26 22:24:09 +1100613 [AIX 5.2 and 5.3 (and presumably newer) require this])
Tim Rice648f8762011-01-26 12:38:57 -0800614 AC_DEFINE([PTY_ZEROREAD], [1], [read(1) can return 0 for a non-closed fd])
Darren Tuckeraa97d132013-03-12 11:31:05 +1100615 AC_DEFINE([PLATFORM_SYS_DIR_UID], 2, [System dirs owned by bin (uid 2)])
Darren Tucker2c71ca12018-03-30 18:23:07 +1100616 AC_DEFINE([BROKEN_STRNDUP], 1, [strndup broken, see APAR IY61211])
617 AC_DEFINE([BROKEN_STRNLEN], 1, [strnlen broken, see APAR IY62551])
Damien Miller75b1d102000-01-07 14:01:41 +1100618 ;;
Darren Tucker898ac932013-06-03 02:03:25 +1000619*-*-android*)
620 AC_DEFINE([DISABLE_UTMP], [1], [Define if you don't want to use utmp])
621 AC_DEFINE([DISABLE_WTMP], [1], [Define if you don't want to use wtmp])
622 ;;
Damien Millerbac2d8a2000-09-05 16:13:06 +1100623*-*-cygwin*)
Damien Millerc8936ac2003-02-11 10:04:03 +1100624 check_for_libcrypt_later=1
Darren Tucker573e3872007-03-02 17:50:03 +1100625 LIBS="$LIBS /usr/lib/textreadmode.o"
Tim Rice648f8762011-01-26 12:38:57 -0800626 AC_DEFINE([HAVE_CYGWIN], [1], [Define if you are on Cygwin])
627 AC_DEFINE([USE_PIPES], [1], [Use PIPES instead of a socketpair()])
Damien Miller4626cba2016-01-08 14:24:56 +1100628 AC_DEFINE([NO_UID_RESTORATION_TEST], [1],
629 [Define to disable UID restoration test])
Tim Rice648f8762011-01-26 12:38:57 -0800630 AC_DEFINE([DISABLE_SHADOW], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700631 [Define if you want to disable shadow passwords])
Tim Rice648f8762011-01-26 12:38:57 -0800632 AC_DEFINE([NO_X11_UNIX_SOCKETS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700633 [Define if X11 doesn't support AF_UNIX sockets on that system])
Tim Rice648f8762011-01-26 12:38:57 -0800634 AC_DEFINE([DISABLE_FD_PASSING], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700635 [Define if your platform needs to skip post auth
636 file descriptor passing])
Tim Rice648f8762011-01-26 12:38:57 -0800637 AC_DEFINE([SSH_IOBUFSZ], [65535], [Windows is sensitive to read buffer size])
Darren Tuckerfdce3732014-01-18 21:12:42 +1100638 AC_DEFINE([FILESYSTEM_NO_BACKSLASH], [1], [File names may not contain backslash characters])
639 # Cygwin defines optargs, optargs as declspec(dllimport) for historical
640 # reasons which cause compile warnings, so we disable those warnings.
641 OSSH_CHECK_CFLAG_COMPILE([-Wno-attributes])
Damien Millerbac2d8a2000-09-05 16:13:06 +1100642 ;;
Ben Lindstrom58055132001-02-15 18:34:29 +0000643*-*-dgux*)
Tim Rice648f8762011-01-26 12:38:57 -0800644 AC_DEFINE([IP_TOS_IS_BROKEN], [1],
Tim Ricea74000e2009-03-18 11:25:02 -0700645 [Define if your system choked on IP TOS setting])
Tim Rice648f8762011-01-26 12:38:57 -0800646 AC_DEFINE([SETEUID_BREAKS_SETUID])
647 AC_DEFINE([BROKEN_SETREUID])
648 AC_DEFINE([BROKEN_SETREGID])
Ben Lindstrom58055132001-02-15 18:34:29 +0000649 ;;
Ben Lindstromfed7bb42001-07-15 18:30:42 +0000650*-*-darwin*)
Damien Miller852472a2014-01-22 16:31:18 +1100651 use_pie=auto
Tim Rice648f8762011-01-26 12:38:57 -0800652 AC_MSG_CHECKING([if we have working getaddrinfo])
653 AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <mach-o/dyld.h>
Damien Millerfc93d4b2002-09-04 23:26:29 +1000654main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
655 exit(0);
656 else
657 exit(1);
Tim Rice648f8762011-01-26 12:38:57 -0800658}
659 ]])],
660 [AC_MSG_RESULT([working])],
661 [AC_MSG_RESULT([buggy])
662 AC_DEFINE([BROKEN_GETADDRINFO], [1],
663 [getaddrinfo is broken (if present)])
664 ],
665 [AC_MSG_RESULT([assume it is working])])
666 AC_DEFINE([SETEUID_BREAKS_SETUID])
667 AC_DEFINE([BROKEN_SETREUID])
668 AC_DEFINE([BROKEN_SETREGID])
669 AC_DEFINE([BROKEN_GLOB], [1], [OS X glob does not do what we expect])
670 AC_DEFINE_UNQUOTED([BIND_8_COMPAT], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700671 [Define if your resolver libs need this for getrrsetbyname])
Tim Rice648f8762011-01-26 12:38:57 -0800672 AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
673 AC_DEFINE([SSH_TUN_COMPAT_AF], [1],
Darren Tucker3eb48342006-06-23 21:05:12 +1000674 [Use tunnel device compatibility to OpenBSD])
Tim Rice648f8762011-01-26 12:38:57 -0800675 AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
Darren Tucker3eb48342006-06-23 21:05:12 +1000676 [Prepend the address family to IP tunnel traffic])
Tim Rice648f8762011-01-26 12:38:57 -0800677 m4_pattern_allow([AU_IPv])
Tim Ricee1d93702016-05-31 11:13:22 -0700678 AC_CHECK_DECL([AU_IPv4], [],
Tim Rice648f8762011-01-26 12:38:57 -0800679 AC_DEFINE([AU_IPv4], [0], [System only supports IPv4 audit records])
Darren Tuckeracada072008-02-25 21:05:04 +1100680 [#include <bsm/audit.h>]
Tim Rice648f8762011-01-26 12:38:57 -0800681 AC_DEFINE([LASTLOG_WRITE_PUTUTXLINE], [1],
Damien Miller20e231f2009-02-12 13:12:21 +1100682 [Define if pututxline updates lastlog too])
Darren Tuckeracada072008-02-25 21:05:04 +1100683 )
Damien Millerc09182f2011-06-03 12:11:38 +1000684 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV],
685 [Define to a Set Process Title type if your system is
686 supported by bsd-setproctitle.c])
Damien Millercd5e52e2011-06-27 07:18:18 +1000687 AC_CHECK_FUNCS([sandbox_init])
688 AC_CHECK_HEADERS([sandbox.h])
Damien Miller39f303b2016-02-23 12:56:59 +1100689 AC_CHECK_LIB([sandbox], [sandbox_apply], [
690 SSHDLIBS="$SSHDLIBS -lsandbox"
691 ])
Damien Miller28744182019-08-30 13:21:38 +1000692 # proc_pidinfo()-based closefrom() replacement.
693 AC_CHECK_HEADERS([libproc.h])
694 AC_CHECK_FUNCS([proc_pidinfo])
Ben Lindstromfed7bb42001-07-15 18:30:42 +0000695 ;;
Darren Tucker57b29202006-09-10 20:25:51 +1000696*-*-dragonfly*)
697 SSHDLIBS="$SSHDLIBS -lcrypt"
Darren Tucker882abfd2013-11-09 00:17:41 +1100698 TEST_MALLOC_OPTIONS="AFGJPRX"
Darren Tucker57b29202006-09-10 20:25:51 +1000699 ;;
Tim Ricee1d93702016-05-31 11:13:22 -0700700*-*-haiku*)
Darren Tucker5faa52d2016-08-02 15:22:40 +1000701 LIBS="$LIBS -lbsd "
Darren Tuckerbb4f0032019-11-01 15:06:16 +1100702 CFLAGS="$CFLAGS -D_BSD_SOURCE"
Darren Tucker5faa52d2016-08-02 15:22:40 +1000703 AC_CHECK_LIB([network], [socket])
704 AC_DEFINE([HAVE_U_INT64_T])
Darren Tuckerbb4f0032019-11-01 15:06:16 +1100705 AC_DEFINE([DISABLE_UTMPX], [1], [no utmpx])
Darren Tucker5faa52d2016-08-02 15:22:40 +1000706 MANTYPE=man
707 ;;
Darren Tuckerfd333282005-05-28 18:31:42 +1000708*-*-hpux*)
709 # first we define all of the options common to all HP-UX releases
Kevin Steves315f8b72001-06-28 00:24:41 +0000710 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
Damien Miller9a947342000-08-30 10:03:33 +1100711 IPADDR_IN_DISPLAY=yes
Tim Rice648f8762011-01-26 12:38:57 -0800712 AC_DEFINE([USE_PIPES])
Tim Rice648f8762011-01-26 12:38:57 -0800713 AC_DEFINE([LOGIN_NEEDS_UTMPX])
714 AC_DEFINE([LOCKED_PASSWD_STRING], ["*"],
Tim Rice7df8d392005-09-19 09:33:39 -0700715 [String used in /etc/passwd to denote locked account])
Tim Rice648f8762011-01-26 12:38:57 -0800716 AC_DEFINE([SPT_TYPE], [SPT_PSTAT])
Darren Tuckeraa97d132013-03-12 11:31:05 +1100717 AC_DEFINE([PLATFORM_SYS_DIR_UID], 2, [System dirs owned by bin (uid 2)])
Tim Rice90f42b02011-06-02 18:17:49 -0700718 maildir="/var/mail"
Tim Ricef028f1e2002-07-19 12:41:10 -0700719 LIBS="$LIBS -lsec"
Tim Rice648f8762011-01-26 12:38:57 -0800720 AC_CHECK_LIB([xnet], [t_error], ,
721 [AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***])])
Darren Tuckerfd333282005-05-28 18:31:42 +1000722
723 # next, we define all of the options specific to major releases
724 case "$host" in
725 *-*-hpux10*)
726 if test -z "$GCC"; then
727 CFLAGS="$CFLAGS -Ae"
728 fi
729 ;;
730 *-*-hpux11*)
Tim Rice648f8762011-01-26 12:38:57 -0800731 AC_DEFINE([PAM_SUN_CODEBASE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700732 [Define if you are using Solaris-derived PAM which
733 passes pam_messages to the conversation function
734 with an extra level of indirection])
Tim Rice648f8762011-01-26 12:38:57 -0800735 AC_DEFINE([DISABLE_UTMP], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700736 [Define if you don't want to use utmp])
Tim Rice648f8762011-01-26 12:38:57 -0800737 AC_DEFINE([USE_BTMP], [1], [Use btmp to log bad logins])
Darren Tuckerfd333282005-05-28 18:31:42 +1000738 check_for_hpux_broken_getaddrinfo=1
739 check_for_conflicting_getspnam=1
740 ;;
741 esac
742
743 # lastly, we define options specific to minor releases
744 case "$host" in
745 *-*-hpux10.26)
Tim Rice648f8762011-01-26 12:38:57 -0800746 AC_DEFINE([HAVE_SECUREWARE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700747 [Define if you have SecureWare-based
748 protected password database])
Darren Tuckerfd333282005-05-28 18:31:42 +1000749 disable_ptmx_check=yes
750 LIBS="$LIBS -lsecpw"
751 ;;
752 esac
Damien Miller1bead332000-04-30 00:47:29 +1000753 ;;
Damien Millerbeb4ba51999-12-28 15:09:35 +1100754*-*-irix5*)
Damien Miller190d5a82000-09-30 09:43:19 +1100755 PATH="$PATH:/usr/etc"
Tim Rice648f8762011-01-26 12:38:57 -0800756 AC_DEFINE([BROKEN_INET_NTOA], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700757 [Define if you system's inet_ntoa is busted
758 (e.g. Irix gcc issue)])
Tim Rice648f8762011-01-26 12:38:57 -0800759 AC_DEFINE([SETEUID_BREAKS_SETUID])
760 AC_DEFINE([BROKEN_SETREUID])
761 AC_DEFINE([BROKEN_SETREGID])
762 AC_DEFINE([WITH_ABBREV_NO_TTY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700763 [Define if you shouldn't strip 'tty' from your
764 ttyname in [uw]tmp])
Tim Rice648f8762011-01-26 12:38:57 -0800765 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Damien Miller1808f382000-01-06 12:03:12 +1100766 ;;
767*-*-irix6*)
Damien Miller190d5a82000-09-30 09:43:19 +1100768 PATH="$PATH:/usr/etc"
Tim Rice648f8762011-01-26 12:38:57 -0800769 AC_DEFINE([WITH_IRIX_ARRAY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700770 [Define if you have/want arrays
Damien Miller10479cc2018-04-10 10:19:02 +1000771 (cluster-wide session management, not C arrays)])
Tim Rice648f8762011-01-26 12:38:57 -0800772 AC_DEFINE([WITH_IRIX_PROJECT], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700773 [Define if you want IRIX project management])
Tim Rice648f8762011-01-26 12:38:57 -0800774 AC_DEFINE([WITH_IRIX_AUDIT], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700775 [Define if you want IRIX audit trails])
Tim Rice648f8762011-01-26 12:38:57 -0800776 AC_CHECK_FUNC([jlimit_startjob], [AC_DEFINE([WITH_IRIX_JOBS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700777 [Define if you want IRIX kernel jobs])])
Tim Rice648f8762011-01-26 12:38:57 -0800778 AC_DEFINE([BROKEN_INET_NTOA])
779 AC_DEFINE([SETEUID_BREAKS_SETUID])
780 AC_DEFINE([BROKEN_SETREUID])
781 AC_DEFINE([BROKEN_SETREGID])
782 AC_DEFINE([BROKEN_UPDWTMPX], [1], [updwtmpx is broken (if present)])
783 AC_DEFINE([WITH_ABBREV_NO_TTY])
784 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Damien Millerbeb4ba51999-12-28 15:09:35 +1100785 ;;
Damien Miller90551722009-02-16 15:37:03 +1100786*-*-k*bsd*-gnu | *-*-kopensolaris*-gnu)
787 check_for_libcrypt_later=1
Tim Rice648f8762011-01-26 12:38:57 -0800788 AC_DEFINE([PAM_TTY_KLUDGE])
789 AC_DEFINE([LOCKED_PASSWD_PREFIX], ["!"])
790 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV])
791 AC_DEFINE([_PATH_BTMP], ["/var/log/btmp"], [log for bad login attempts])
792 AC_DEFINE([USE_BTMP], [1], [Use btmp to log bad logins])
Damien Miller90551722009-02-16 15:37:03 +1100793 ;;
Damien Millerb29ea912000-01-15 14:12:03 +1100794*-*-linux*)
795 no_dev_ptmx=1
Damien Miller852472a2014-01-22 16:31:18 +1100796 use_pie=auto
Damien Millera64b57a2001-01-17 10:44:13 +1100797 check_for_libcrypt_later=1
Darren Tucker70a3d552003-08-21 17:58:29 +1000798 check_for_openpty_ctty_bug=1
Darren Tuckerc61d5ec2017-02-03 14:10:34 +1100799 dnl Target SUSv3/POSIX.1-2001 plus BSD specifics.
800 dnl _DEFAULT_SOURCE is the new name for _BSD_SOURCE
801 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_DEFAULT_SOURCE"
Tim Rice648f8762011-01-26 12:38:57 -0800802 AC_DEFINE([PAM_TTY_KLUDGE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700803 [Work around problematic Linux PAM modules handling of PAM_TTY])
Tim Rice648f8762011-01-26 12:38:57 -0800804 AC_DEFINE([LOCKED_PASSWD_PREFIX], ["!"],
Tim Rice7df8d392005-09-19 09:33:39 -0700805 [String used in /etc/passwd to denote locked account])
Tim Rice648f8762011-01-26 12:38:57 -0800806 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV])
807 AC_DEFINE([LINK_OPNOTSUPP_ERRNO], [EPERM],
Tim Rice7df8d392005-09-19 09:33:39 -0700808 [Define to whatever link() returns for "not supported"
809 if it doesn't return EOPNOTSUPP.])
Tim Rice648f8762011-01-26 12:38:57 -0800810 AC_DEFINE([_PATH_BTMP], ["/var/log/btmp"], [log for bad login attempts])
811 AC_DEFINE([USE_BTMP])
812 AC_DEFINE([LINUX_OOM_ADJUST], [1], [Adjust Linux out-of-memory killer])
Damien Miller7bcb0892000-03-11 20:45:40 +1100813 inet6_default_4in6=yes
Darren Tucker3c016542003-05-02 20:48:21 +1000814 case `uname -r` in
Darren Tuckerc437cda2003-05-10 17:05:46 +1000815 1.*|2.0.*)
Tim Rice648f8762011-01-26 12:38:57 -0800816 AC_DEFINE([BROKEN_CMSG_TYPE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700817 [Define if cmsg_type is not passed correctly])
Darren Tucker3c016542003-05-02 20:48:21 +1000818 ;;
Darren Tucker3c016542003-05-02 20:48:21 +1000819 esac
Damien Miller89e03ba2005-12-31 16:42:03 +1100820 # tun(4) forwarding compat code
Tim Rice648f8762011-01-26 12:38:57 -0800821 AC_CHECK_HEADERS([linux/if_tun.h])
Damien Millerbd4e4102006-01-01 21:03:30 +1100822 if test "x$ac_cv_header_linux_if_tun_h" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -0800823 AC_DEFINE([SSH_TUN_LINUX], [1],
Damien Miller89e03ba2005-12-31 16:42:03 +1100824 [Open tunnel devices the Linux tun/tap way])
Tim Rice648f8762011-01-26 12:38:57 -0800825 AC_DEFINE([SSH_TUN_COMPAT_AF], [1],
Damien Miller89e03ba2005-12-31 16:42:03 +1100826 [Use tunnel device compatibility to OpenBSD])
Tim Rice648f8762011-01-26 12:38:57 -0800827 AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
Damien Miller89e03ba2005-12-31 16:42:03 +1100828 [Prepend the address family to IP tunnel traffic])
829 fi
Darren Tucker81c9ccd2017-11-03 14:52:51 +1100830 AC_CHECK_HEADER([linux/if.h],
831 AC_DEFINE([SYS_RDOMAIN_LINUX], [1],
Darren Tucker24d2a332018-02-11 21:20:39 +1300832 [Support routing domains using Linux VRF]), [], [
833#ifdef HAVE_SYS_TYPES_H
Damien Miller87294982019-07-10 09:43:19 +1000834# include <sys/types.h>
Darren Tucker24d2a332018-02-11 21:20:39 +1300835#endif
836 ])
Darren Tucker60395f92012-07-03 14:31:18 +1000837 AC_CHECK_HEADERS([linux/seccomp.h linux/filter.h linux/audit.h], [],
838 [], [#include <linux/types.h>])
Vicente Olivert Riera58008672017-06-20 16:42:11 +0100839 # Obtain MIPS ABI
840 case "$host" in
841 mips*)
Darren Tuckerfbd733a2018-03-12 19:17:26 +1100842 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Vicente Olivert Riera58008672017-06-20 16:42:11 +0100843#if _MIPS_SIM != _ABIO32
844#error
845#endif
Darren Tuckerfbd733a2018-03-12 19:17:26 +1100846 ]])],[mips_abi="o32"],[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Vicente Olivert Riera58008672017-06-20 16:42:11 +0100847#if _MIPS_SIM != _ABIN32
848#error
849#endif
Darren Tuckerfbd733a2018-03-12 19:17:26 +1100850 ]])],[mips_abi="n32"],[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Vicente Olivert Riera58008672017-06-20 16:42:11 +0100851#if _MIPS_SIM != _ABI64
852#error
853#endif
Darren Tuckerfbd733a2018-03-12 19:17:26 +1100854 ]])],[mips_abi="n64"],[AC_MSG_ERROR([unknown MIPS ABI])
Vicente Olivert Riera58008672017-06-20 16:42:11 +0100855 ])
856 ])
857 ])
858 ;;
859 esac
Damien Miller91f40d82013-02-22 11:37:00 +1100860 AC_MSG_CHECKING([for seccomp architecture])
861 seccomp_audit_arch=
Damien Millere0956e32012-04-04 11:27:54 +1000862 case "$host" in
863 x86_64-*)
Damien Miller91f40d82013-02-22 11:37:00 +1100864 seccomp_audit_arch=AUDIT_ARCH_X86_64
Damien Millere0956e32012-04-04 11:27:54 +1000865 ;;
866 i*86-*)
Damien Miller91f40d82013-02-22 11:37:00 +1100867 seccomp_audit_arch=AUDIT_ARCH_I386
Damien Millere0956e32012-04-04 11:27:54 +1000868 ;;
Damien Miller99f33d72015-06-17 10:50:51 +1000869 arm*-*)
Damien Miller91f40d82013-02-22 11:37:00 +1100870 seccomp_audit_arch=AUDIT_ARCH_ARM
Damien Miller99f33d72015-06-17 10:50:51 +1000871 ;;
872 aarch64*-*)
873 seccomp_audit_arch=AUDIT_ARCH_AARCH64
Damien Miller5c15e222015-06-18 15:07:56 +1000874 ;;
Damien Millerb9c50612016-07-08 13:59:13 +1000875 s390x-*)
876 seccomp_audit_arch=AUDIT_ARCH_S390X
877 ;;
878 s390-*)
879 seccomp_audit_arch=AUDIT_ARCH_S390
880 ;;
881 powerpc64-*)
882 seccomp_audit_arch=AUDIT_ARCH_PPC64
883 ;;
884 powerpc64le-*)
885 seccomp_audit_arch=AUDIT_ARCH_PPC64LE
886 ;;
887 mips-*)
888 seccomp_audit_arch=AUDIT_ARCH_MIPS
889 ;;
890 mipsel-*)
891 seccomp_audit_arch=AUDIT_ARCH_MIPSEL
892 ;;
893 mips64-*)
Vicente Olivert Riera45011512017-06-20 16:42:28 +0100894 case "$mips_abi" in
895 "n32")
896 seccomp_audit_arch=AUDIT_ARCH_MIPS64N32
897 ;;
898 "n64")
899 seccomp_audit_arch=AUDIT_ARCH_MIPS64
900 ;;
901 esac
Damien Millerb9c50612016-07-08 13:59:13 +1000902 ;;
903 mips64el-*)
Vicente Olivert Riera45011512017-06-20 16:42:28 +0100904 case "$mips_abi" in
905 "n32")
906 seccomp_audit_arch=AUDIT_ARCH_MIPSEL64N32
907 ;;
908 "n64")
909 seccomp_audit_arch=AUDIT_ARCH_MIPSEL64
910 ;;
911 esac
Damien Millerb9c50612016-07-08 13:59:13 +1000912 ;;
Damien Millere0956e32012-04-04 11:27:54 +1000913 esac
Damien Miller91f40d82013-02-22 11:37:00 +1100914 if test "x$seccomp_audit_arch" != "x" ; then
915 AC_MSG_RESULT(["$seccomp_audit_arch"])
Damien Miller99f33d72015-06-17 10:50:51 +1000916 AC_DEFINE_UNQUOTED([SECCOMP_AUDIT_ARCH], [$seccomp_audit_arch],
917 [Specify the system call convention in use])
Damien Miller91f40d82013-02-22 11:37:00 +1100918 else
919 AC_MSG_RESULT([architecture not supported])
920 fi
Damien Millerb29ea912000-01-15 14:12:03 +1100921 ;;
Ben Lindstromb5628642000-10-18 00:02:25 +0000922mips-sony-bsd|mips-sony-newsos4)
Tim Rice648f8762011-01-26 12:38:57 -0800923 AC_DEFINE([NEED_SETPGRP], [1], [Need setpgrp to acquire controlling tty])
Ben Lindstromb5628642000-10-18 00:02:25 +0000924 SONY=1
Ben Lindstromb5628642000-10-18 00:02:25 +0000925 ;;
Damien Milleree1c0b32000-01-21 00:18:15 +1100926*-*-netbsd*)
Damien Millerfc93d4b2002-09-04 23:26:29 +1000927 check_for_libcrypt_before=1
Tim Riceeae17cc2005-03-17 16:52:20 -0800928 if test "x$withval" != "xno" ; then
Darren Tucker2f0bad22019-01-21 21:28:27 +1100929 rpath_opt="-R"
Tim Rice88368a32003-12-08 12:35:59 -0800930 fi
Damien Miller99522ba2016-07-28 08:54:27 +1000931 CPPFLAGS="$CPPFLAGS -D_OPENBSD_SOURCE"
Tim Rice648f8762011-01-26 12:38:57 -0800932 AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
Damien Miller2dcddbf2006-01-01 19:47:05 +1100933 AC_CHECK_HEADER([net/if_tap.h], ,
Tim Rice648f8762011-01-26 12:38:57 -0800934 AC_DEFINE([SSH_TUN_NO_L2], [1], [No layer 2 tunnel support]))
935 AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
Damien Miller2dcddbf2006-01-01 19:47:05 +1100936 [Prepend the address family to IP tunnel traffic])
Darren Tucker882abfd2013-11-09 00:17:41 +1100937 TEST_MALLOC_OPTIONS="AJRX"
Damien Millerf5bbd3b2014-01-30 11:26:46 +1100938 AC_DEFINE([BROKEN_READ_COMPARISON], [1],
939 [NetBSD read function is sometimes redirected, breaking atomicio comparisons against it])
Damien Milleree1c0b32000-01-21 00:18:15 +1100940 ;;
Damien Millerfbd884a2001-02-27 08:39:07 +1100941*-*-freebsd*)
942 check_for_libcrypt_later=1
Tim Rice648f8762011-01-26 12:38:57 -0800943 AC_DEFINE([LOCKED_PASSWD_PREFIX], ["*LOCKED*"], [Account locked with pw(1)])
944 AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
Damien Miller2dcddbf2006-01-01 19:47:05 +1100945 AC_CHECK_HEADER([net/if_tap.h], ,
Tim Rice648f8762011-01-26 12:38:57 -0800946 AC_DEFINE([SSH_TUN_NO_L2], [1], [No layer 2 tunnel support]))
947 AC_DEFINE([BROKEN_GLOB], [1], [FreeBSD glob does not do what we need])
Darren Tucker882abfd2013-11-09 00:17:41 +1100948 TEST_MALLOC_OPTIONS="AJRX"
Damien Miller2035b222014-01-26 09:39:53 +1100949 # Preauth crypto occasionally uses file descriptors for crypto offload
950 # and will crash if they cannot be opened.
Damien Miller5b447c02014-01-26 09:46:53 +1100951 AC_DEFINE([SANDBOX_SKIP_RLIMIT_NOFILE], [1],
Tim Rice03ae0812014-02-21 09:09:34 -0800952 [define if setrlimit RLIMIT_NOFILE breaks things])
Damien Millerfbd884a2001-02-27 08:39:07 +1100953 ;;
Darren Tuckered9eb022003-09-22 11:18:47 +1000954*-*-bsdi*)
Tim Rice648f8762011-01-26 12:38:57 -0800955 AC_DEFINE([SETEUID_BREAKS_SETUID])
956 AC_DEFINE([BROKEN_SETREUID])
957 AC_DEFINE([BROKEN_SETREGID])
Darren Tuckered9eb022003-09-22 11:18:47 +1000958 ;;
Damien Miller0f91b4e2000-06-18 15:43:25 +1000959*-next-*)
Damien Miller0f91b4e2000-06-18 15:43:25 +1000960 conf_lastlog_location="/usr/adm/lastlog"
Damien Millere5192fa2000-08-29 14:30:37 +1100961 conf_utmp_location=/etc/utmp
962 conf_wtmp_location=/usr/adm/wtmp
Tim Rice90f42b02011-06-02 18:17:49 -0700963 maildir=/usr/spool/mail
Tim Rice648f8762011-01-26 12:38:57 -0800964 AC_DEFINE([HAVE_NEXT], [1], [Define if you are on NeXT])
Tim Rice648f8762011-01-26 12:38:57 -0800965 AC_DEFINE([USE_PIPES])
966 AC_DEFINE([BROKEN_SAVED_UIDS], [1], [Needed for NeXT])
Damien Miller0f91b4e2000-06-18 15:43:25 +1000967 ;;
Darren Tucker4a422572005-07-14 17:22:11 +1000968*-*-openbsd*)
Damien Miller852472a2014-01-22 16:31:18 +1100969 use_pie=auto
Tim Rice648f8762011-01-26 12:38:57 -0800970 AC_DEFINE([HAVE_ATTRIBUTE__SENTINEL__], [1], [OpenBSD's gcc has sentinel])
971 AC_DEFINE([HAVE_ATTRIBUTE__BOUNDED__], [1], [OpenBSD's gcc has bounded])
972 AC_DEFINE([SSH_TUN_OPENBSD], [1], [Open tunnel devices the OpenBSD way])
973 AC_DEFINE([SYSLOG_R_SAFE_IN_SIGHAND], [1],
Damien Millerbb598142006-08-19 08:38:23 +1000974 [syslog_r function is safe to use in in a signal handler])
Darren Tucker882abfd2013-11-09 00:17:41 +1100975 TEST_MALLOC_OPTIONS="AFGJPRX"
Darren Tucker4a422572005-07-14 17:22:11 +1000976 ;;
Damien Miller75b1d102000-01-07 14:01:41 +1100977*-*-solaris*)
Tim Riceeae17cc2005-03-17 16:52:20 -0800978 if test "x$withval" != "xno" ; then
Darren Tucker2f0bad22019-01-21 21:28:27 +1100979 rpath_opt="-R"
Tim Ricead4a1882004-02-29 15:53:37 -0800980 fi
Tim Rice648f8762011-01-26 12:38:57 -0800981 AC_DEFINE([PAM_SUN_CODEBASE])
982 AC_DEFINE([LOGIN_NEEDS_UTMPX])
Tim Rice648f8762011-01-26 12:38:57 -0800983 AC_DEFINE([PAM_TTY_KLUDGE])
984 AC_DEFINE([SSHPAM_CHAUTHTOK_NEEDS_RUID], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700985 [Define if pam_chauthtok wants real uid set
986 to the unpriv'ed user])
Tim Rice648f8762011-01-26 12:38:57 -0800987 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Darren Tuckerc437cda2003-05-10 17:05:46 +1000988 # Pushing STREAMS modules will cause sshd to acquire a controlling tty.
Tim Rice648f8762011-01-26 12:38:57 -0800989 AC_DEFINE([SSHD_ACQUIRES_CTTY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700990 [Define if sshd somehow reacquires a controlling TTY
991 after setsid()])
Tim Rice648f8762011-01-26 12:38:57 -0800992 AC_DEFINE([PASSWD_NEEDS_USERNAME], [1], [must supply username to passwd
Darren Tucker0249f932006-06-24 12:10:07 +1000993 in case the name is longer than 8 chars])
Tim Rice648f8762011-01-26 12:38:57 -0800994 AC_DEFINE([BROKEN_TCGETATTR_ICANON], [1], [tcgetattr with ICANON may hang])
Darren Tuckere1a790d2003-09-16 11:52:19 +1000995 external_path_file=/etc/default/login
andre2ff7b5d2000-06-03 14:57:40 +0000996 # hardwire lastlog location (can't detect it on some versions)
997 conf_lastlog_location="/var/adm/lastlog"
Tim Rice648f8762011-01-26 12:38:57 -0800998 AC_MSG_CHECKING([for obsolete utmp and wtmp in solaris2.x])
Damien Millera1cb6442000-06-09 11:58:35 +1000999 sol2ver=`echo "$host"| sed -e 's/.*[[0-9]]\.//'`
1000 if test "$sol2ver" -ge 8; then
Tim Rice648f8762011-01-26 12:38:57 -08001001 AC_MSG_RESULT([yes])
1002 AC_DEFINE([DISABLE_UTMP])
1003 AC_DEFINE([DISABLE_WTMP], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001004 [Define if you don't want to use wtmp])
Damien Millera1cb6442000-06-09 11:58:35 +10001005 else
Tim Rice648f8762011-01-26 12:38:57 -08001006 AC_MSG_RESULT([no])
Damien Millera1cb6442000-06-09 11:58:35 +10001007 fi
Darren Tuckera86ec4d2016-06-14 10:48:27 +10001008 AC_CHECK_FUNCS([setpflags])
Darren Tucker907091a2016-02-19 09:05:39 +11001009 AC_CHECK_FUNCS([setppriv])
1010 AC_CHECK_FUNCS([priv_basicset])
1011 AC_CHECK_HEADERS([priv.h])
Tim Rice648f8762011-01-26 12:38:57 -08001012 AC_ARG_WITH([solaris-contracts],
Damien Miller1b06dc32006-08-31 03:24:41 +10001013 [ --with-solaris-contracts Enable Solaris process contracts (experimental)],
1014 [
Tim Rice648f8762011-01-26 12:38:57 -08001015 AC_CHECK_LIB([contract], [ct_tmpl_activate],
1016 [ AC_DEFINE([USE_SOLARIS_PROCESS_CONTRACTS], [1],
Damien Miller1b06dc32006-08-31 03:24:41 +10001017 [Define if you have Solaris process contracts])
Damien Miller4626cba2016-01-08 14:24:56 +11001018 LIBS="$LIBS -lcontract"
Damien Miller1b06dc32006-08-31 03:24:41 +10001019 SPC_MSG="yes" ], )
1020 ],
1021 )
Tim Rice648f8762011-01-26 12:38:57 -08001022 AC_ARG_WITH([solaris-projects],
Darren Tucker97528352010-11-05 12:03:05 +11001023 [ --with-solaris-projects Enable Solaris projects (experimental)],
1024 [
Tim Rice648f8762011-01-26 12:38:57 -08001025 AC_CHECK_LIB([project], [setproject],
1026 [ AC_DEFINE([USE_SOLARIS_PROJECTS], [1],
Darren Tucker97528352010-11-05 12:03:05 +11001027 [Define if you have Solaris projects])
Damien Miller4626cba2016-01-08 14:24:56 +11001028 LIBS="$LIBS -lproject"
Darren Tucker97528352010-11-05 12:03:05 +11001029 SP_MSG="yes" ], )
1030 ],
1031 )
Damien Miller4626cba2016-01-08 14:24:56 +11001032 AC_ARG_WITH([solaris-privs],
1033 [ --with-solaris-privs Enable Solaris/Illumos privileges (experimental)],
1034 [
1035 AC_MSG_CHECKING([for Solaris/Illumos privilege support])
Darren Tucker907091a2016-02-19 09:05:39 +11001036 if test "x$ac_cv_func_setppriv" = "xyes" -a \
1037 "x$ac_cv_header_priv_h" = "xyes" ; then
1038 SOLARIS_PRIVS=yes
Damien Miller4626cba2016-01-08 14:24:56 +11001039 AC_MSG_RESULT([found])
1040 AC_DEFINE([NO_UID_RESTORATION_TEST], [1],
1041 [Define to disable UID restoration test])
1042 AC_DEFINE([USE_SOLARIS_PRIVS], [1],
1043 [Define if you have Solaris privileges])
1044 SPP_MSG="yes"
1045 else
1046 AC_MSG_RESULT([not found])
1047 AC_MSG_ERROR([*** must have support for Solaris privileges to use --with-solaris-privs])
1048 fi
1049 ],
1050 )
Tim Rice5ab9b632013-06-02 14:05:48 -07001051 TEST_SHELL=$SHELL # let configure find us a capable shell
Damien Miller75b1d102000-01-07 14:01:41 +11001052 ;;
Damien Millerdfc83f42000-05-20 15:02:59 +10001053*-*-sunos4*)
Ben Lindstrom28bfc0d2000-12-18 19:58:57 +00001054 CPPFLAGS="$CPPFLAGS -DSUNOS4"
Tim Rice648f8762011-01-26 12:38:57 -08001055 AC_CHECK_FUNCS([getpwanam])
1056 AC_DEFINE([PAM_SUN_CODEBASE])
Damien Miller36ccb5c2000-08-09 16:34:27 +10001057 conf_utmp_location=/etc/utmp
1058 conf_wtmp_location=/var/adm/wtmp
1059 conf_lastlog_location=/var/adm/lastlog
Tim Rice648f8762011-01-26 12:38:57 -08001060 AC_DEFINE([USE_PIPES])
Darren Tuckerc0a0c3f2018-03-05 20:03:07 +11001061 AC_DEFINE([DISABLE_UTMPX], [1], [no utmpx])
Damien Millerdfc83f42000-05-20 15:02:59 +10001062 ;;
Ben Lindstrom603bdfd2001-02-12 07:29:45 +00001063*-ncr-sysv*)
Tim Rice13aae5e2001-10-21 17:53:58 -07001064 LIBS="$LIBS -lc89"
Tim Rice648f8762011-01-26 12:38:57 -08001065 AC_DEFINE([USE_PIPES])
1066 AC_DEFINE([SSHD_ACQUIRES_CTTY])
1067 AC_DEFINE([SETEUID_BREAKS_SETUID])
1068 AC_DEFINE([BROKEN_SETREUID])
1069 AC_DEFINE([BROKEN_SETREGID])
Ben Lindstrom603bdfd2001-02-12 07:29:45 +00001070 ;;
Damien Miller2ae714f2000-07-11 09:29:50 +10001071*-sni-sysv*)
Tim Riceffdf4aa2001-10-27 10:45:36 -07001072 # /usr/ucblib MUST NOT be searched on ReliantUNIX
Tim Rice648f8762011-01-26 12:38:57 -08001073 AC_CHECK_LIB([dl], [dlsym], ,)
Darren Tucker79d09fa2005-11-24 22:34:54 +11001074 # -lresolv needs to be at the end of LIBS or DNS lookups break
Tim Rice648f8762011-01-26 12:38:57 -08001075 AC_CHECK_LIB([resolv], [res_query], [ LIBS="$LIBS -lresolv" ])
Damien Millerfd9885e2001-01-10 08:16:53 +11001076 IPADDR_IN_DISPLAY=yes
Tim Rice648f8762011-01-26 12:38:57 -08001077 AC_DEFINE([USE_PIPES])
1078 AC_DEFINE([IP_TOS_IS_BROKEN])
1079 AC_DEFINE([SETEUID_BREAKS_SETUID])
1080 AC_DEFINE([BROKEN_SETREUID])
1081 AC_DEFINE([BROKEN_SETREGID])
1082 AC_DEFINE([SSHD_ACQUIRES_CTTY])
Darren Tuckere1a790d2003-09-16 11:52:19 +10001083 external_path_file=/etc/default/login
Tim Riceffdf4aa2001-10-27 10:45:36 -07001084 # /usr/ucblib/libucb.a no longer needed on ReliantUNIX
1085 # Attention: always take care to bind libsocket and libnsl before libc,
1086 # otherwise you will find lots of "SIOCGPGRP errno 22" on syslog
Damien Miller2ae714f2000-07-11 09:29:50 +10001087 ;;
Tim Rice0f83d292004-12-08 18:29:58 -08001088# UnixWare 1.x, UnixWare 2.x, and others based on code from Univel.
Damien Miller78315eb2000-09-29 23:01:36 +11001089*-*-sysv4.2*)
Tim Rice648f8762011-01-26 12:38:57 -08001090 AC_DEFINE([USE_PIPES])
1091 AC_DEFINE([SETEUID_BREAKS_SETUID])
1092 AC_DEFINE([BROKEN_SETREUID])
1093 AC_DEFINE([BROKEN_SETREGID])
1094 AC_DEFINE([PASSWD_NEEDS_USERNAME], [1], [must supply username to passwd])
1095 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Tim Rice5ab9b632013-06-02 14:05:48 -07001096 TEST_SHELL=$SHELL # let configure find us a capable shell
Damien Miller78315eb2000-09-29 23:01:36 +11001097 ;;
Tim Rice0f83d292004-12-08 18:29:58 -08001098# UnixWare 7.x, OpenUNIX 8
Damien Miller78315eb2000-09-29 23:01:36 +11001099*-*-sysv5*)
Tim Rice641ebf12010-01-17 17:05:39 -08001100 CPPFLAGS="$CPPFLAGS -Dvsnprintf=_xvsnprintf -Dsnprintf=_xsnprintf"
Tim Rice648f8762011-01-26 12:38:57 -08001101 AC_DEFINE([UNIXWARE_LONG_PASSWORDS], [1], [Support passwords > 8 chars])
1102 AC_DEFINE([USE_PIPES])
1103 AC_DEFINE([SETEUID_BREAKS_SETUID])
1104 AC_DEFINE([BROKEN_GETADDRINFO])
1105 AC_DEFINE([BROKEN_SETREUID])
1106 AC_DEFINE([BROKEN_SETREGID])
1107 AC_DEFINE([PASSWD_NEEDS_USERNAME])
Tim Rice8433d512017-07-11 18:47:56 -07001108 AC_DEFINE([BROKEN_TCGETATTR_ICANON])
Tim Rice5ab9b632013-06-02 14:05:48 -07001109 TEST_SHELL=$SHELL # let configure find us a capable shell
Tim Rice4afeaf32018-03-25 10:00:21 -07001110 check_for_libcrypt_later=1
Tim Rice4dbacff2005-06-01 20:09:28 -07001111 case "$host" in
1112 *-*-sysv5SCO_SV*) # SCO OpenServer 6.x
Tim Rice90f42b02011-06-02 18:17:49 -07001113 maildir=/var/spool/mail
Tim Rice648f8762011-01-26 12:38:57 -08001114 AC_DEFINE([BROKEN_UPDWTMPX])
1115 AC_CHECK_LIB([prot], [getluid], [ LIBS="$LIBS -lprot"
1116 AC_CHECK_FUNCS([getluid setluid], , , [-lprot])
Tim Rice648f8762011-01-26 12:38:57 -08001117 ], , )
Tim Rice4dbacff2005-06-01 20:09:28 -07001118 ;;
Tim Rice648f8762011-01-26 12:38:57 -08001119 *) AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Tim Rice46259d82005-11-28 18:40:34 -08001120 ;;
Tim Rice4dbacff2005-06-01 20:09:28 -07001121 esac
Damien Miller78315eb2000-09-29 23:01:36 +11001122 ;;
Damien Miller75b1d102000-01-07 14:01:41 +11001123*-*-sysv*)
Damien Miller75b1d102000-01-07 14:01:41 +11001124 ;;
Tim Rice0f83d292004-12-08 18:29:58 -08001125# SCO UNIX and OEM versions of SCO UNIX
Damien Miller78315eb2000-09-29 23:01:36 +11001126*-*-sco3.2v4*)
Tim Ricec390c8d2005-03-07 01:21:37 -08001127 AC_MSG_ERROR("This Platform is no longer supported.")
Damien Miller78315eb2000-09-29 23:01:36 +11001128 ;;
Tim Rice0f83d292004-12-08 18:29:58 -08001129# SCO OpenServer 5.x
Damien Miller78315eb2000-09-29 23:01:36 +11001130*-*-sco3.2v5*)
Tim Rice89fe3f32003-01-19 20:20:24 -08001131 if test -z "$GCC"; then
1132 CFLAGS="$CFLAGS -belf"
1133 fi
Damien Miller5dfe9762001-02-16 12:05:39 +11001134 LIBS="$LIBS -lprot -lx -ltinfo -lm"
Damien Millera66626b2000-06-13 18:57:53 +10001135 no_dev_ptmx=1
Tim Rice648f8762011-01-26 12:38:57 -08001136 AC_DEFINE([USE_PIPES])
1137 AC_DEFINE([HAVE_SECUREWARE])
1138 AC_DEFINE([DISABLE_SHADOW])
1139 AC_DEFINE([DISABLE_FD_PASSING])
1140 AC_DEFINE([SETEUID_BREAKS_SETUID])
1141 AC_DEFINE([BROKEN_GETADDRINFO])
1142 AC_DEFINE([BROKEN_SETREUID])
1143 AC_DEFINE([BROKEN_SETREGID])
1144 AC_DEFINE([WITH_ABBREV_NO_TTY])
1145 AC_DEFINE([BROKEN_UPDWTMPX])
1146 AC_DEFINE([PASSWD_NEEDS_USERNAME])
1147 AC_CHECK_FUNCS([getluid setluid])
Tim Rice07183b82001-04-25 21:40:28 -07001148 MANTYPE=man
Tim Rice5ab9b632013-06-02 14:05:48 -07001149 TEST_SHELL=$SHELL # let configure find us a capable shell
Tim Riceaa86c392013-03-16 20:55:46 -07001150 SKIP_DISABLE_LASTLOG_DEFINE=yes
Damien Millera66626b2000-06-13 18:57:53 +10001151 ;;
Damien Millerb8c656e2000-06-28 15:22:41 +10001152*-dec-osf*)
Tim Rice648f8762011-01-26 12:38:57 -08001153 AC_MSG_CHECKING([for Digital Unix SIA])
Ben Lindstrom72af2ef2001-05-08 20:42:28 +00001154 no_osfsia=""
Tim Rice648f8762011-01-26 12:38:57 -08001155 AC_ARG_WITH([osfsia],
Ben Lindstrom72af2ef2001-05-08 20:42:28 +00001156 [ --with-osfsia Enable Digital Unix SIA],
1157 [
1158 if test "x$withval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08001159 AC_MSG_RESULT([disabled])
Ben Lindstrom72af2ef2001-05-08 20:42:28 +00001160 no_osfsia=1
1161 fi
1162 ],
1163 )
1164 if test -z "$no_osfsia" ; then
Damien Millerb8c656e2000-06-28 15:22:41 +10001165 if test -f /etc/sia/matrix.conf; then
Tim Rice648f8762011-01-26 12:38:57 -08001166 AC_MSG_RESULT([yes])
1167 AC_DEFINE([HAVE_OSF_SIA], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001168 [Define if you have Digital Unix Security
1169 Integration Architecture])
Tim Rice648f8762011-01-26 12:38:57 -08001170 AC_DEFINE([DISABLE_LOGIN], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001171 [Define if you don't want to use your
1172 system's login() call])
Tim Rice648f8762011-01-26 12:38:57 -08001173 AC_DEFINE([DISABLE_FD_PASSING])
Damien Millerb8c656e2000-06-28 15:22:41 +10001174 LIBS="$LIBS -lsecurity -ldb -lm -laud"
Damien Miller1b06dc32006-08-31 03:24:41 +10001175 SIA_MSG="yes"
Damien Millerb8c656e2000-06-28 15:22:41 +10001176 else
Tim Rice648f8762011-01-26 12:38:57 -08001177 AC_MSG_RESULT([no])
1178 AC_DEFINE([LOCKED_PASSWD_SUBSTR], ["Nologin"],
Tim Rice7df8d392005-09-19 09:33:39 -07001179 [String used in /etc/passwd to denote locked account])
Damien Millerb8c656e2000-06-28 15:22:41 +10001180 fi
1181 fi
Tim Rice648f8762011-01-26 12:38:57 -08001182 AC_DEFINE([BROKEN_GETADDRINFO])
1183 AC_DEFINE([SETEUID_BREAKS_SETUID])
1184 AC_DEFINE([BROKEN_SETREUID])
1185 AC_DEFINE([BROKEN_SETREGID])
1186 AC_DEFINE([BROKEN_READV_COMPARISON], [1], [Can't do comparisons on readv])
Damien Millerb8c656e2000-06-28 15:22:41 +10001187 ;;
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00001188
Tim Rice70335a62006-02-04 17:42:58 -08001189*-*-nto-qnx*)
Tim Rice648f8762011-01-26 12:38:57 -08001190 AC_DEFINE([USE_PIPES])
1191 AC_DEFINE([NO_X11_UNIX_SOCKETS])
Tim Rice648f8762011-01-26 12:38:57 -08001192 AC_DEFINE([DISABLE_LASTLOG])
1193 AC_DEFINE([SSHD_ACQUIRES_CTTY])
1194 AC_DEFINE([BROKEN_SHADOW_EXPIRE], [1], [QNX shadow support is broken])
Tim Rice2f993462006-02-11 18:37:48 -08001195 enable_etc_default_login=no # has incompatible /etc/default/login
Darren Tucker8acb3b62007-08-10 14:36:12 +10001196 case "$host" in
1197 *-*-nto-qnx6*)
Tim Rice648f8762011-01-26 12:38:57 -08001198 AC_DEFINE([DISABLE_FD_PASSING])
Darren Tucker8acb3b62007-08-10 14:36:12 +10001199 ;;
1200 esac
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00001201 ;;
Darren Tucker2be1cbb2005-05-27 21:13:40 +10001202
1203*-*-ultrix*)
Tim Rice648f8762011-01-26 12:38:57 -08001204 AC_DEFINE([BROKEN_GETGROUPS], [1], [getgroups(0,NULL) will return -1])
Darren Tucker9cac1512019-11-01 18:26:07 +11001205 AC_DEFINE([NEED_SETPGRP], [1], [Need setpgrp to for controlling tty])
Tim Rice648f8762011-01-26 12:38:57 -08001206 AC_DEFINE([HAVE_SYS_SYSLOG_H], [1], [Force use of sys/syslog.h on Ultrix])
Darren Tucker9cac1512019-11-01 18:26:07 +11001207 AC_DEFINE([DISABLE_UTMPX], [1], [Disable utmpx])
1208 # DISABLE_FD_PASSING so that we call setpgrp as root, otherwise we
1209 # don't get a controlling tty.
1210 AC_DEFINE([DISABLE_FD_PASSING], [1], [Need to call setpgrp as root])
Darren Tucker39b87102019-11-15 18:56:54 +11001211 # On Ultrix some headers are not protected against multiple includes,
1212 # so we create wrappers and put it where the compiler will find it.
1213 AC_MSG_WARN([creating compat wrappers for headers])
Darren Tucker9cac1512019-11-01 18:26:07 +11001214 mkdir -p netinet
Darren Tucker39b87102019-11-15 18:56:54 +11001215 for header in netinet/ip.h netdb.h resolv.h; do
1216 name=`echo $header | tr 'a-z/.' 'A-Z__'`
1217 cat >$header <<EOD
1218#ifndef _SSH_COMPAT_${name}
1219#define _SSH_COMPAT_${name}
1220#include "/usr/include/${header}"
Darren Tucker9cac1512019-11-01 18:26:07 +11001221#endif
1222EOD
Darren Tucker39b87102019-11-15 18:56:54 +11001223 done
Tim Ricefcc7ff12005-06-02 20:28:29 -07001224 ;;
Darren Tucker93e7e8f2005-08-23 08:06:55 +10001225
1226*-*-lynxos)
Darren Tucker5faa52d2016-08-02 15:22:40 +10001227 CFLAGS="$CFLAGS -D__NO_INCLUDE_WARN__"
1228 AC_DEFINE([BROKEN_SETVBUF], [1],
1229 [LynxOS has broken setvbuf() implementation])
1230 ;;
Damien Miller76112de1999-12-21 11:18:08 +11001231esac
1232
Tim Rice648f8762011-01-26 12:38:57 -08001233AC_MSG_CHECKING([compiler and flags for sanity])
1234AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]], [[ exit(0); ]])],
1235 [ AC_MSG_RESULT([yes]) ],
Darren Tucker6eb93042003-06-29 21:30:41 +10001236 [
Tim Rice648f8762011-01-26 12:38:57 -08001237 AC_MSG_RESULT([no])
Darren Tucker6eb93042003-06-29 21:30:41 +10001238 AC_MSG_ERROR([*** compiler cannot create working executables, check config.log ***])
Darren Tuckera0c2b392004-09-11 23:26:37 +10001239 ],
1240 [ AC_MSG_WARN([cross compiling: not checking compiler sanity]) ]
Darren Tucker6eb93042003-06-29 21:30:41 +10001241)
1242
Darren Tucker0c9653f2005-05-28 15:58:14 +10001243dnl Checks for header files.
Damien Millera22ba012000-03-02 23:09:20 +11001244# Checks for libraries.
Tim Rice648f8762011-01-26 12:38:57 -08001245AC_CHECK_FUNC([setsockopt], , [AC_CHECK_LIB([socket], [setsockopt])])
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00001246
Tim Rice1e1ef642003-09-11 22:19:31 -07001247dnl IRIX and Solaris 2.5.1 have dirname() in libgen
Tim Rice648f8762011-01-26 12:38:57 -08001248AC_CHECK_FUNCS([dirname], [AC_CHECK_HEADERS([libgen.h])] , [
1249 AC_CHECK_LIB([gen], [dirname], [
Tim Rice1e1ef642003-09-11 22:19:31 -07001250 AC_CACHE_CHECK([for broken dirname],
1251 ac_cv_have_broken_dirname, [
1252 save_LIBS="$LIBS"
1253 LIBS="$LIBS -lgen"
Darren Tucker314d89e2005-10-17 23:29:23 +10001254 AC_RUN_IFELSE(
1255 [AC_LANG_SOURCE([[
Tim Rice1e1ef642003-09-11 22:19:31 -07001256#include <libgen.h>
1257#include <string.h>
1258
1259int main(int argc, char **argv) {
1260 char *s, buf[32];
1261
1262 strncpy(buf,"/etc", 32);
1263 s = dirname(buf);
1264 if (!s || strncmp(s, "/", 32) != 0) {
1265 exit(1);
1266 } else {
1267 exit(0);
1268 }
1269}
Darren Tucker314d89e2005-10-17 23:29:23 +10001270 ]])],
Tim Rice1e1ef642003-09-11 22:19:31 -07001271 [ ac_cv_have_broken_dirname="no" ],
Darren Tucker314d89e2005-10-17 23:29:23 +10001272 [ ac_cv_have_broken_dirname="yes" ],
1273 [ ac_cv_have_broken_dirname="no" ],
Tim Rice1e1ef642003-09-11 22:19:31 -07001274 )
1275 LIBS="$save_LIBS"
1276 ])
1277 if test "x$ac_cv_have_broken_dirname" = "xno" ; then
1278 LIBS="$LIBS -lgen"
Tim Rice648f8762011-01-26 12:38:57 -08001279 AC_DEFINE([HAVE_DIRNAME])
1280 AC_CHECK_HEADERS([libgen.h])
Tim Rice1e1ef642003-09-11 22:19:31 -07001281 fi
1282 ])
1283])
1284
Tim Rice648f8762011-01-26 12:38:57 -08001285AC_CHECK_FUNC([getspnam], ,
1286 [AC_CHECK_LIB([gen], [getspnam], [LIBS="$LIBS -lgen"])])
1287AC_SEARCH_LIBS([basename], [gen], [AC_DEFINE([HAVE_BASENAME], [1],
1288 [Define if you have the basename function.])])
Tim Rice1e1ef642003-09-11 22:19:31 -07001289
Darren Tucker633a2af2020-01-23 22:16:51 +11001290dnl zlib defaults to enabled
1291zlib=yes
Tim Rice648f8762011-01-26 12:38:57 -08001292AC_ARG_WITH([zlib],
Tim Rice13aae5e2001-10-21 17:53:58 -07001293 [ --with-zlib=PATH Use zlib in PATH],
Darren Tucker86a5f8d2005-03-21 09:55:17 +11001294 [ if test "x$withval" = "xno" ; then
Darren Tucker633a2af2020-01-23 22:16:51 +11001295 zlib=no
Darren Tucker86a5f8d2005-03-21 09:55:17 +11001296 elif test "x$withval" != "xyes"; then
Tim Rice13aae5e2001-10-21 17:53:58 -07001297 if test -d "$withval/lib"; then
Darren Tucker2f0bad22019-01-21 21:28:27 +11001298 if test -n "${rpath_opt}"; then
1299 LDFLAGS="-L${withval}/lib ${rpath_opt}${withval}/lib ${LDFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001300 else
Tim Rice02cebcd2001-10-25 10:01:30 -07001301 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001302 fi
1303 else
Darren Tucker2f0bad22019-01-21 21:28:27 +11001304 if test -n "${rpath_opt}"; then
1305 LDFLAGS="-L${withval} ${rpath_opt}${withval} ${LDFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001306 else
Tim Rice02cebcd2001-10-25 10:01:30 -07001307 LDFLAGS="-L${withval} ${LDFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001308 fi
1309 fi
1310 if test -d "$withval/include"; then
Tim Rice02cebcd2001-10-25 10:01:30 -07001311 CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001312 else
Tim Rice02cebcd2001-10-25 10:01:30 -07001313 CPPFLAGS="-I${withval} ${CPPFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001314 fi
Darren Tucker86a5f8d2005-03-21 09:55:17 +11001315 fi ]
Tim Rice13aae5e2001-10-21 17:53:58 -07001316)
1317
Darren Tucker633a2af2020-01-23 22:16:51 +11001318AC_MSG_CHECKING([for zlib])
1319if test "x${zlib}" = "xno"; then
1320 AC_MSG_RESULT([no])
1321else
1322 AC_MSG_RESULT([yes])
1323 AC_DEFINE([WITH_ZLIB], [1], [Enable zlib])
1324 AC_CHECK_HEADER([zlib.h], ,[AC_MSG_ERROR([*** zlib.h missing - please install first or check config.log ***])])
1325 AC_CHECK_LIB([z], [deflate], ,
Tim Ricefcb62202004-01-23 18:35:16 -08001326 [
1327 saved_CPPFLAGS="$CPPFLAGS"
1328 saved_LDFLAGS="$LDFLAGS"
1329 save_LIBS="$LIBS"
1330 dnl Check default zlib install dir
Darren Tucker2f0bad22019-01-21 21:28:27 +11001331 if test -n "${rpath_opt}"; then
1332 LDFLAGS="-L/usr/local/lib ${rpath_opt}/usr/local/lib ${saved_LDFLAGS}"
Tim Ricefcb62202004-01-23 18:35:16 -08001333 else
1334 LDFLAGS="-L/usr/local/lib ${saved_LDFLAGS}"
1335 fi
1336 CPPFLAGS="-I/usr/local/include ${saved_CPPFLAGS}"
1337 LIBS="$LIBS -lz"
Tim Rice648f8762011-01-26 12:38:57 -08001338 AC_TRY_LINK_FUNC([deflate], [AC_DEFINE([HAVE_LIBZ])],
Tim Ricefcb62202004-01-23 18:35:16 -08001339 [
1340 AC_MSG_ERROR([*** zlib missing - please install first or check config.log ***])
1341 ]
1342 )
1343 ]
Darren Tucker633a2af2020-01-23 22:16:51 +11001344 )
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001345
Darren Tucker633a2af2020-01-23 22:16:51 +11001346 AC_ARG_WITH([zlib-version-check],
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001347 [ --without-zlib-version-check Disable zlib version check],
1348 [ if test "x$withval" = "xno" ; then
1349 zlib_check_nonfatal=1
1350 fi
1351 ]
Darren Tucker633a2af2020-01-23 22:16:51 +11001352 )
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001353
Darren Tucker633a2af2020-01-23 22:16:51 +11001354 AC_MSG_CHECKING([for possibly buggy zlib])
1355 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001356#include <stdio.h>
Darren Tuckerc8a0f272013-03-22 12:49:14 +11001357#include <stdlib.h>
Darren Tucker2dcd2392004-01-23 17:13:33 +11001358#include <zlib.h>
Tim Rice648f8762011-01-26 12:38:57 -08001359 ]],
1360 [[
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001361 int a=0, b=0, c=0, d=0, n, v;
1362 n = sscanf(ZLIB_VERSION, "%d.%d.%d.%d", &a, &b, &c, &d);
1363 if (n != 3 && n != 4)
Darren Tucker2dcd2392004-01-23 17:13:33 +11001364 exit(1);
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001365 v = a*1000000 + b*10000 + c*100 + d;
1366 fprintf(stderr, "found zlib version %s (%d)\n", ZLIB_VERSION, v);
1367
1368 /* 1.1.4 is OK */
1369 if (a == 1 && b == 1 && c >= 4)
Darren Tucker2dcd2392004-01-23 17:13:33 +11001370 exit(0);
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001371
Darren Tucker41097ed2005-07-25 15:24:21 +10001372 /* 1.2.3 and up are OK */
1373 if (v >= 1020300)
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001374 exit(0);
1375
Darren Tucker2dcd2392004-01-23 17:13:33 +11001376 exit(2);
Darren Tucker623d92f2004-09-12 22:36:15 +10001377 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001378 AC_MSG_RESULT([no]),
1379 [ AC_MSG_RESULT([yes])
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001380 if test -z "$zlib_check_nonfatal" ; then
1381 AC_MSG_ERROR([*** zlib too old - check config.log ***
1382Your reported zlib version has known security problems. It's possible your
1383vendor has fixed these problems without changing the version number. If you
1384are sure this is the case, you can disable the check by running
1385"./configure --without-zlib-version-check".
Darren Tuckerac1910f2005-07-26 12:00:42 +10001386If you are in doubt, upgrade zlib to version 1.2.3 or greater.
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001387See http://www.gzip.org/zlib/ for details.])
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001388 else
1389 AC_MSG_WARN([zlib version may have security problems])
1390 fi
Darren Tuckera0c2b392004-09-11 23:26:37 +10001391 ],
1392 [ AC_MSG_WARN([cross compiling: not checking zlib version]) ]
Darren Tucker633a2af2020-01-23 22:16:51 +11001393 )
1394fi
Damien Miller6f9c3372000-10-25 10:06:04 +11001395
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00001396dnl UnixWare 2.x
Tim Rice648f8762011-01-26 12:38:57 -08001397AC_CHECK_FUNC([strcasecmp],
1398 [], [ AC_CHECK_LIB([resolv], [strcasecmp], [LIBS="$LIBS -lresolv"]) ]
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00001399)
Tim Rice648f8762011-01-26 12:38:57 -08001400AC_CHECK_FUNCS([utimes],
1401 [], [ AC_CHECK_LIB([c89], [utimes], [AC_DEFINE([HAVE_UTIMES])
Tim Ricecbb90662002-07-08 19:17:10 -07001402 LIBS="$LIBS -lc89"]) ]
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00001403)
Damien Millerab18c411999-11-11 10:40:23 +11001404
Tim Ricee589a292001-11-03 11:09:32 -08001405dnl Checks for libutil functions
Damien Millerb87f6b72013-02-23 09:12:23 +11001406AC_CHECK_HEADERS([bsd/libutil.h libutil.h])
Damien Miller398c0ff2012-04-19 21:46:35 +10001407AC_SEARCH_LIBS([fmt_scaled], [util bsd])
Darren Tuckere194ba42013-05-16 20:47:31 +10001408AC_SEARCH_LIBS([scan_scaled], [util bsd])
Damien Miller398c0ff2012-04-19 21:46:35 +10001409AC_SEARCH_LIBS([login], [util bsd])
1410AC_SEARCH_LIBS([logout], [util bsd])
1411AC_SEARCH_LIBS([logwtmp], [util bsd])
1412AC_SEARCH_LIBS([openpty], [util bsd])
1413AC_SEARCH_LIBS([updwtmp], [util bsd])
Darren Tuckere194ba42013-05-16 20:47:31 +10001414AC_CHECK_FUNCS([fmt_scaled scan_scaled login logout openpty updwtmp logwtmp])
Tim Ricee589a292001-11-03 11:09:32 -08001415
Darren Tucker2fee9092016-02-17 09:48:15 +11001416# On some platforms, inet_ntop and gethostbyname may be found in libresolv
1417# or libnsl.
Damien Millerab039492014-01-28 15:07:10 +11001418AC_SEARCH_LIBS([inet_ntop], [resolv nsl])
Darren Tucker2fee9092016-02-17 09:48:15 +11001419AC_SEARCH_LIBS([gethostbyname], [resolv nsl])
Damien Millerab039492014-01-28 15:07:10 +11001420
Darren Tucker74c1c362017-09-27 07:44:41 +10001421# "Particular Function Checks"
1422# see https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Particular-Functions.html
Ben Lindstrom8697e082001-02-24 21:41:10 +00001423AC_FUNC_STRFTIME
Darren Tucker74c1c362017-09-27 07:44:41 +10001424AC_FUNC_MALLOC
1425AC_FUNC_REALLOC
1426# autoconf doesn't have AC_FUNC_CALLOC so fake it if malloc returns NULL;
Darren Tuckere9dede02018-02-25 10:20:31 +11001427AC_MSG_CHECKING([if calloc(0, N) returns non-null])
1428AC_RUN_IFELSE(
1429 [AC_LANG_PROGRAM(
1430 [[ #include <stdlib.h> ]],
1431 [[ void *p = calloc(0, 1); exit(p == NULL); ]]
1432 )],
1433 [ func_calloc_0_nonnull=yes ],
1434 [ func_calloc_0_nonnull=no ],
1435 [ AC_MSG_WARN([cross compiling: assuming same as malloc])
1436 func_calloc_0_nonnull="$ac_cv_func_malloc_0_nonnull"]
1437)
1438AC_MSG_RESULT([$func_calloc_0_nonnull])
1439
Darren Tuckerd97874c2018-04-13 13:43:55 +10001440if test "x$func_calloc_0_nonnull" = "xyes"; then
Darren Tuckere9dede02018-02-25 10:20:31 +11001441 AC_DEFINE(HAVE_CALLOC, 1, [calloc(0, x) returns non-null])
1442else
1443 AC_DEFINE(HAVE_CALLOC, 0, [calloc(0, x) returns NULL])
Darren Tucker74c1c362017-09-27 07:44:41 +10001444 AC_DEFINE(calloc, rpl_calloc,
1445 [Define to rpl_calloc if the replacement function should be used.])
1446fi
Ben Lindstrom8697e082001-02-24 21:41:10 +00001447
Damien Miller3c027682001-03-14 11:39:45 +11001448# Check for ALTDIRFUNC glob() extension
Tim Rice648f8762011-01-26 12:38:57 -08001449AC_MSG_CHECKING([for GLOB_ALTDIRFUNC support])
1450AC_EGREP_CPP([FOUNDIT],
Damien Miller3c027682001-03-14 11:39:45 +11001451 [
1452 #include <glob.h>
1453 #ifdef GLOB_ALTDIRFUNC
1454 FOUNDIT
1455 #endif
Damien Millera8e06ce2003-11-21 23:48:55 +11001456 ],
Damien Miller3c027682001-03-14 11:39:45 +11001457 [
Tim Rice648f8762011-01-26 12:38:57 -08001458 AC_DEFINE([GLOB_HAS_ALTDIRFUNC], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001459 [Define if your system glob() function has
1460 the GLOB_ALTDIRFUNC extension])
Tim Rice648f8762011-01-26 12:38:57 -08001461 AC_MSG_RESULT([yes])
Damien Miller3c027682001-03-14 11:39:45 +11001462 ],
1463 [
Tim Rice648f8762011-01-26 12:38:57 -08001464 AC_MSG_RESULT([no])
Damien Miller3c027682001-03-14 11:39:45 +11001465 ]
1466)
Damien Millerab18c411999-11-11 10:40:23 +11001467
Ben Lindstrom45b14db2001-03-17 01:15:38 +00001468# Check for g.gl_matchc glob() extension
Tim Rice648f8762011-01-26 12:38:57 -08001469AC_MSG_CHECKING([for gl_matchc field in glob_t])
1470AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <glob.h> ]],
1471 [[ glob_t g; g.gl_matchc = 1; ]])],
Damien Millera8e06ce2003-11-21 23:48:55 +11001472 [
Tim Rice648f8762011-01-26 12:38:57 -08001473 AC_DEFINE([GLOB_HAS_GL_MATCHC], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001474 [Define if your system glob() function has
1475 gl_matchc options in glob_t])
Tim Rice648f8762011-01-26 12:38:57 -08001476 AC_MSG_RESULT([yes])
1477 ], [
1478 AC_MSG_RESULT([no])
1479])
Ben Lindstrom45b14db2001-03-17 01:15:38 +00001480
Damien Millera6e121a2010-10-07 21:39:17 +11001481# Check for g.gl_statv glob() extension
Tim Rice648f8762011-01-26 12:38:57 -08001482AC_MSG_CHECKING([for gl_statv and GLOB_KEEPSTAT extensions for glob])
1483AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <glob.h> ]], [[
Damien Millera6e121a2010-10-07 21:39:17 +11001484#ifndef GLOB_KEEPSTAT
1485#error "glob does not support GLOB_KEEPSTAT extension"
1486#endif
1487glob_t g;
1488g.gl_statv = NULL;
Tim Rice648f8762011-01-26 12:38:57 -08001489]])],
Damien Millera6e121a2010-10-07 21:39:17 +11001490 [
Tim Rice648f8762011-01-26 12:38:57 -08001491 AC_DEFINE([GLOB_HAS_GL_STATV], [1],
Damien Millera6e121a2010-10-07 21:39:17 +11001492 [Define if your system glob() function has
1493 gl_statv options in glob_t])
Tim Rice648f8762011-01-26 12:38:57 -08001494 AC_MSG_RESULT([yes])
1495 ], [
1496 AC_MSG_RESULT([no])
Damien Miller72ef7c12015-01-15 02:21:31 +11001497
Tim Rice648f8762011-01-26 12:38:57 -08001498])
Damien Millera6e121a2010-10-07 21:39:17 +11001499
Tim Rice648f8762011-01-26 12:38:57 -08001500AC_CHECK_DECLS([GLOB_NOMATCH], , , [#include <glob.h>])
Darren Tucker096faec2006-09-01 20:29:10 +10001501
Darren Tucker7df91b02016-07-14 12:25:24 +10001502AC_CHECK_DECL([VIS_ALL], ,
1503 AC_DEFINE(BROKEN_STRNVIS, 1, [missing VIS_ALL]), [#include <vis.h>])
1504
Damien Miller18bb4732001-03-28 14:35:30 +10001505AC_MSG_CHECKING([whether struct dirent allocates space for d_name])
Darren Tuckera0c2b392004-09-11 23:26:37 +10001506AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001507 [AC_LANG_PROGRAM([[
Damien Miller18bb4732001-03-28 14:35:30 +10001508#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08001509#include <dirent.h>]],
1510 [[
1511 struct dirent d;
1512 exit(sizeof(d.d_name)<=sizeof(char));
Darren Tucker623d92f2004-09-12 22:36:15 +10001513 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001514 [AC_MSG_RESULT([yes])],
Damien Miller18bb4732001-03-28 14:35:30 +10001515 [
Tim Rice648f8762011-01-26 12:38:57 -08001516 AC_MSG_RESULT([no])
1517 AC_DEFINE([BROKEN_ONE_BYTE_DIRENT_D_NAME], [1],
Darren Tucker79d09fa2005-11-24 22:34:54 +11001518 [Define if your struct dirent expects you to
Tim Rice7df8d392005-09-19 09:33:39 -07001519 allocate extra space for d_name])
Darren Tuckera0c2b392004-09-11 23:26:37 +10001520 ],
Tim Riceeae17cc2005-03-17 16:52:20 -08001521 [
Darren Tuckera0c2b392004-09-11 23:26:37 +10001522 AC_MSG_WARN([cross compiling: assuming BROKEN_ONE_BYTE_DIRENT_D_NAME])
Tim Rice648f8762011-01-26 12:38:57 -08001523 AC_DEFINE([BROKEN_ONE_BYTE_DIRENT_D_NAME])
Damien Miller18bb4732001-03-28 14:35:30 +10001524 ]
1525)
1526
Damien Miller36f49652004-08-15 18:40:59 +10001527AC_MSG_CHECKING([for /proc/pid/fd directory])
1528if test -d "/proc/$$/fd" ; then
Tim Rice648f8762011-01-26 12:38:57 -08001529 AC_DEFINE([HAVE_PROC_PID], [1], [Define if you have /proc/$pid/fd])
1530 AC_MSG_RESULT([yes])
Damien Miller36f49652004-08-15 18:40:59 +10001531else
Tim Rice648f8762011-01-26 12:38:57 -08001532 AC_MSG_RESULT([no])
Damien Miller36f49652004-08-15 18:40:59 +10001533fi
1534
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001535# Check whether user wants to use ldns
1536LDNS_MSG="no"
1537AC_ARG_WITH(ldns,
1538 [ --with-ldns[[=PATH]] Use ldns for DNSSEC support (optionally in PATH)],
Damien Miller523db852017-02-03 16:01:22 +11001539 [
1540 ldns=""
1541 if test "x$withval" = "xyes" ; then
1542 AC_PATH_TOOL([LDNSCONFIG], [ldns-config], [no])
Darren Tuckerf001de82017-12-11 13:42:51 +11001543 if test "x$LDNSCONFIG" = "xno"; then
Damien Miller523db852017-02-03 16:01:22 +11001544 LIBS="-lldns $LIBS"
1545 ldns=yes
1546 else
1547 LIBS="$LIBS `$LDNSCONFIG --libs`"
1548 CPPFLAGS="$CPPFLAGS `$LDNSCONFIG --cflags`"
Darren Tucker7af27bf2017-03-24 09:44:56 +11001549 ldns=yes
Damien Miller523db852017-02-03 16:01:22 +11001550 fi
1551 elif test "x$withval" != "xno" ; then
1552 CPPFLAGS="$CPPFLAGS -I${withval}/include"
1553 LDFLAGS="$LDFLAGS -L${withval}/lib"
1554 LIBS="-lldns $LIBS"
1555 ldns=yes
1556 fi
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001557
Damien Miller523db852017-02-03 16:01:22 +11001558 # Verify that it works.
1559 if test "x$ldns" = "xyes" ; then
1560 AC_DEFINE(HAVE_LDNS, 1, [Define if you want ldns support])
1561 LDNS_MSG="yes"
1562 AC_MSG_CHECKING([for ldns support])
1563 AC_LINK_IFELSE(
1564 [AC_LANG_SOURCE([[
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001565#include <stdio.h>
1566#include <stdlib.h>
1567#include <stdint.h>
1568#include <ldns/ldns.h>
1569int main() { ldns_status status = ldns_verify_trusted(NULL, NULL, NULL, NULL); status=LDNS_STATUS_OK; exit(0); }
Damien Miller523db852017-02-03 16:01:22 +11001570 ]])
1571 ],
1572 [AC_MSG_RESULT(yes)],
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001573 [
1574 AC_MSG_RESULT(no)
1575 AC_MSG_ERROR([** Incomplete or missing ldns libraries.])
1576 ])
Damien Miller523db852017-02-03 16:01:22 +11001577 fi
1578])
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001579
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001580# Check whether user wants libedit support
1581LIBEDIT_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08001582AC_ARG_WITH([libedit],
Darren Tucker1b6f2292005-02-11 16:11:49 +11001583 [ --with-libedit[[=PATH]] Enable libedit support for sftp],
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001584 [ if test "x$withval" != "xno" ; then
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001585 if test "x$withval" = "xyes" ; then
Darren Tucker59353892012-05-19 15:24:37 +10001586 AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no])
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001587 if test "x$PKGCONFIG" != "xno"; then
Tim Rice648f8762011-01-26 12:38:57 -08001588 AC_MSG_CHECKING([if $PKGCONFIG knows about libedit])
Tim Ricee1d93702016-05-31 11:13:22 -07001589 if "$PKGCONFIG" libedit; then
Tim Rice648f8762011-01-26 12:38:57 -08001590 AC_MSG_RESULT([yes])
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001591 use_pkgconfig_for_libedit=yes
1592 else
Tim Rice648f8762011-01-26 12:38:57 -08001593 AC_MSG_RESULT([no])
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001594 fi
1595 fi
1596 else
Darren Tuckerc373a562005-09-22 20:15:08 +10001597 CPPFLAGS="$CPPFLAGS -I${withval}/include"
Darren Tucker2f0bad22019-01-21 21:28:27 +11001598 if test -n "${rpath_opt}"; then
1599 LDFLAGS="-L${withval}/lib ${rpath_opt}${withval}/lib ${LDFLAGS}"
Darren Tuckerc373a562005-09-22 20:15:08 +10001600 else
1601 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
1602 fi
Darren Tucker1df61452005-03-21 09:58:07 +11001603 fi
Damien Miller1f789802010-10-11 22:35:22 +11001604 if test "x$use_pkgconfig_for_libedit" = "xyes"; then
Darren Tucker8369c8e2013-12-05 11:00:16 +11001605 LIBEDIT=`$PKGCONFIG --libs libedit`
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001606 CPPFLAGS="$CPPFLAGS `$PKGCONFIG --cflags libedit`"
1607 else
1608 LIBEDIT="-ledit -lcurses"
1609 fi
1610 OTHERLIBS=`echo $LIBEDIT | sed 's/-ledit//'`
Tim Rice648f8762011-01-26 12:38:57 -08001611 AC_CHECK_LIB([edit], [el_init],
1612 [ AC_DEFINE([USE_LIBEDIT], [1], [Use libedit for sftp])
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001613 LIBEDIT_MSG="yes"
Tim Rice648f8762011-01-26 12:38:57 -08001614 AC_SUBST([LIBEDIT])
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001615 ],
Tim Rice648f8762011-01-26 12:38:57 -08001616 [ AC_MSG_ERROR([libedit not found]) ],
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001617 [ $OTHERLIBS ]
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001618 )
Tim Rice648f8762011-01-26 12:38:57 -08001619 AC_MSG_CHECKING([if libedit version is compatible])
Tim Ricec1819c82005-08-15 17:48:40 -07001620 AC_COMPILE_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001621 [AC_LANG_PROGRAM([[ #include <histedit.h> ]],
1622 [[
Darren Tuckerc7572b22005-08-10 20:34:15 +10001623 int i = H_SETSIZE;
1624 el_init("", NULL, NULL, NULL);
1625 exit(0);
Tim Ricec1819c82005-08-15 17:48:40 -07001626 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001627 [ AC_MSG_RESULT([yes]) ],
1628 [ AC_MSG_RESULT([no])
1629 AC_MSG_ERROR([libedit version is not compatible]) ]
Darren Tuckerc7572b22005-08-10 20:34:15 +10001630 )
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001631 fi ]
1632)
1633
Darren Tuckerd9f88912005-02-20 21:01:48 +11001634AUDIT_MODULE=none
Tim Rice648f8762011-01-26 12:38:57 -08001635AC_ARG_WITH([audit],
Darren Tuckerea52a822011-01-17 21:15:27 +11001636 [ --with-audit=module Enable audit support (modules=debug,bsm,linux)],
Darren Tuckerd9f88912005-02-20 21:01:48 +11001637 [
Tim Rice648f8762011-01-26 12:38:57 -08001638 AC_MSG_CHECKING([for supported audit module])
Darren Tuckerd9f88912005-02-20 21:01:48 +11001639 case "$withval" in
1640 bsm)
Tim Rice648f8762011-01-26 12:38:57 -08001641 AC_MSG_RESULT([bsm])
Darren Tuckerd9f88912005-02-20 21:01:48 +11001642 AUDIT_MODULE=bsm
1643 dnl Checks for headers, libs and functions
Tim Rice648f8762011-01-26 12:38:57 -08001644 AC_CHECK_HEADERS([bsm/audit.h], [],
1645 [AC_MSG_ERROR([BSM enabled and bsm/audit.h not found])],
Darren Tucker6d0d6fb2006-09-09 01:05:21 +10001646 [
1647#ifdef HAVE_TIME_H
1648# include <time.h>
1649#endif
1650 ]
1651)
Tim Rice648f8762011-01-26 12:38:57 -08001652 AC_CHECK_LIB([bsm], [getaudit], [],
1653 [AC_MSG_ERROR([BSM enabled and required library not found])])
1654 AC_CHECK_FUNCS([getaudit], [],
1655 [AC_MSG_ERROR([BSM enabled and required function not found])])
Darren Tuckerd9f88912005-02-20 21:01:48 +11001656 # These are optional
Tim Rice648f8762011-01-26 12:38:57 -08001657 AC_CHECK_FUNCS([getaudit_addr aug_get_machine])
1658 AC_DEFINE([USE_BSM_AUDIT], [1], [Use BSM audit module])
Darren Tucker1fcec9d2013-12-19 11:00:12 +11001659 if test "$sol2ver" -ge 11; then
Tim Ricee1d93702016-05-31 11:13:22 -07001660 SSHDLIBS="$SSHDLIBS -lscf"
1661 AC_DEFINE([BROKEN_BSM_API], [1],
1662 [The system has incomplete BSM API])
Darren Tucker93a2d412012-02-24 10:40:41 +11001663 fi
Darren Tuckerd9f88912005-02-20 21:01:48 +11001664 ;;
Darren Tuckerea52a822011-01-17 21:15:27 +11001665 linux)
Tim Rice648f8762011-01-26 12:38:57 -08001666 AC_MSG_RESULT([linux])
Darren Tuckerea52a822011-01-17 21:15:27 +11001667 AUDIT_MODULE=linux
1668 dnl Checks for headers, libs and functions
Tim Rice648f8762011-01-26 12:38:57 -08001669 AC_CHECK_HEADERS([libaudit.h])
Darren Tuckerea52a822011-01-17 21:15:27 +11001670 SSHDLIBS="$SSHDLIBS -laudit"
Tim Rice648f8762011-01-26 12:38:57 -08001671 AC_DEFINE([USE_LINUX_AUDIT], [1], [Use Linux audit module])
Darren Tuckerea52a822011-01-17 21:15:27 +11001672 ;;
Darren Tuckerd9f88912005-02-20 21:01:48 +11001673 debug)
1674 AUDIT_MODULE=debug
Tim Rice648f8762011-01-26 12:38:57 -08001675 AC_MSG_RESULT([debug])
1676 AC_DEFINE([SSH_AUDIT_EVENTS], [1], [Use audit debugging module])
Darren Tuckerd9f88912005-02-20 21:01:48 +11001677 ;;
Tim Rice8bc6b902005-08-09 10:09:53 -07001678 no)
Tim Rice648f8762011-01-26 12:38:57 -08001679 AC_MSG_RESULT([no])
Tim Rice8bc6b902005-08-09 10:09:53 -07001680 ;;
Darren Tuckerd9f88912005-02-20 21:01:48 +11001681 *)
1682 AC_MSG_ERROR([Unknown audit module $withval])
1683 ;;
1684 esac ]
1685)
1686
Darren Tucker096118d2014-01-21 12:48:51 +11001687AC_ARG_WITH([pie],
Damien Miller76c04802015-01-13 19:38:18 +11001688 [ --with-pie Build Position Independent Executables if possible], [
Darren Tucker096118d2014-01-21 12:48:51 +11001689 if test "x$withval" = "xno"; then
Damien Miller852472a2014-01-22 16:31:18 +11001690 use_pie=no
Darren Tucker096118d2014-01-21 12:48:51 +11001691 fi
1692 if test "x$withval" = "xyes"; then
Damien Miller852472a2014-01-22 16:31:18 +11001693 use_pie=yes
Darren Tucker096118d2014-01-21 12:48:51 +11001694 fi
1695 ]
1696)
Damien Miller852472a2014-01-22 16:31:18 +11001697if test "x$use_pie" = "x"; then
1698 use_pie=no
1699fi
1700if test "x$use_toolchain_hardening" != "x1" && test "x$use_pie" = "xauto"; then
1701 # Turn off automatic PIE when toolchain hardening is off.
1702 use_pie=no
1703fi
Damien Millerc161fc92014-01-29 21:01:33 +11001704if test "x$use_pie" = "xauto"; then
Damien Miller852472a2014-01-22 16:31:18 +11001705 # Automatic PIE requires gcc >= 4.x
1706 AC_MSG_CHECKING([for gcc >= 4.x])
1707 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1708#if !defined(__GNUC__) || __GNUC__ < 4
1709#error gcc is too old
1710#endif
1711]])],
1712 [ AC_MSG_RESULT([yes]) ],
1713 [ AC_MSG_RESULT([no])
1714 use_pie=no ]
1715)
1716fi
1717if test "x$use_pie" != "xno"; then
Damien Miller5c2ff5e2014-01-22 21:30:12 +11001718 SAVED_CFLAGS="$CFLAGS"
1719 SAVED_LDFLAGS="$LDFLAGS"
Darren Tucker096118d2014-01-21 12:48:51 +11001720 OSSH_CHECK_CFLAG_COMPILE([-fPIE])
1721 OSSH_CHECK_LDFLAG_LINK([-pie])
Damien Miller5c2ff5e2014-01-22 21:30:12 +11001722 # We use both -fPIE and -pie or neither.
1723 AC_MSG_CHECKING([whether both -fPIE and -pie are supported])
1724 if echo "x $CFLAGS" | grep ' -fPIE' >/dev/null 2>&1 && \
1725 echo "x $LDFLAGS" | grep ' -pie' >/dev/null 2>&1 ; then
1726 AC_MSG_RESULT([yes])
1727 else
1728 AC_MSG_RESULT([no])
1729 CFLAGS="$SAVED_CFLAGS"
1730 LDFLAGS="$SAVED_LDFLAGS"
1731 fi
Darren Tucker096118d2014-01-21 12:48:51 +11001732fi
1733
Damien Millerb2180552019-11-29 12:32:23 +11001734AC_MSG_CHECKING([whether -fPIC is accepted])
1735SAVED_CFLAGS="$CFLAGS"
1736CFLAGS="$CFLAGS -fPIC"
1737AC_COMPILE_IFELSE(
1738 [AC_LANG_PROGRAM( [[ #include <stdlib.h> ]], [[ exit(0); ]] )],
1739 [AC_MSG_RESULT([yes])
1740 PICFLAG="-fPIC"; ],
1741 [AC_MSG_RESULT([no])
1742 PICFLAG=""; ])
1743CFLAGS="$SAVED_CFLAGS"
1744AC_SUBST([PICFLAG])
1745
Damien Millerfe1f1432003-02-24 15:45:42 +11001746dnl Checks for library functions. Please keep in alphabetical order
Tim Rice648f8762011-01-26 12:38:57 -08001747AC_CHECK_FUNCS([ \
Damien Miller1ff130d2013-12-07 11:51:51 +11001748 Blowfish_initstate \
1749 Blowfish_expandstate \
1750 Blowfish_expand0state \
1751 Blowfish_stream2word \
Darren Tucker11cba2a2019-07-23 21:51:22 +10001752 SHA256Update \
1753 SHA384Update \
1754 SHA512Update \
Damien Miller57f39152005-11-24 19:58:19 +11001755 asprintf \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001756 b64_ntop \
1757 __b64_ntop \
1758 b64_pton \
1759 __b64_pton \
1760 bcopy \
Damien Millera9134422013-12-07 11:35:36 +11001761 bcrypt_pbkdf \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001762 bindresvport_sa \
Damien Miller1ff130d2013-12-07 11:51:51 +11001763 blf_enc \
Darren Tuckera9004422018-02-24 20:25:22 +11001764 bzero \
Damien Millerc96d8532014-01-25 13:12:28 +11001765 cap_rights_limit \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001766 clock \
1767 closefrom \
1768 dirfd \
Darren Tuckerefdf5342013-05-30 08:29:08 +10001769 endgrent \
Darren Tucker6310ef22016-07-13 14:42:35 +10001770 err \
1771 errx \
Damien Miller1d2c4562014-02-04 11:18:20 +11001772 explicit_bzero \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001773 fchmod \
Darren Tuckera6258e52019-01-18 11:09:01 +11001774 fchmodat \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001775 fchown \
Darren Tuckera6258e52019-01-18 11:09:01 +11001776 fchownat \
Darren Tuckercd3ab572018-02-26 14:37:06 +11001777 flock \
Darren Tucker0e3c5bc2019-11-01 18:24:29 +11001778 fnmatch \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001779 freeaddrinfo \
Damien Millerb7956912017-09-19 12:29:23 +10001780 freezero \
Darren Tuckera5cf1e22014-01-17 18:10:58 +11001781 fstatfs \
Darren Tucker598eaa62008-06-09 03:32:29 +10001782 fstatvfs \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001783 futimes \
1784 getaddrinfo \
1785 getcwd \
1786 getgrouplist \
Darren Tucker6301e6c2018-07-02 21:16:58 +10001787 getline \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001788 getnameinfo \
1789 getopt \
Damien Miller151c6e42017-06-01 15:25:13 +10001790 getpagesize \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001791 getpeereid \
Darren Tucker164aa302007-03-21 21:39:57 +11001792 getpeerucred \
Darren Tucker3c4a24c2013-02-15 11:41:35 +11001793 getpgid \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001794 _getpty \
1795 getrlimit \
Damien Millerafa6e792018-04-13 13:31:42 +10001796 getrandom \
Darren Tuckerb39593a2018-02-25 13:25:15 +11001797 getsid \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001798 getttyent \
1799 glob \
Darren Tucker909a3902010-01-15 12:38:30 +11001800 group_from_gid \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001801 inet_aton \
1802 inet_ntoa \
1803 inet_ntop \
1804 innetgr \
Darren Tuckerd38f05d2017-03-20 13:38:27 +11001805 llabs \
Darren Tucker1bcd1162019-10-29 19:45:03 +11001806 localtime_r \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001807 login_getcapbool \
1808 md5_crypt \
Darren Tucker45478892019-07-16 09:20:23 +10001809 memmem \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001810 memmove \
Damien Miller3d673d12014-08-27 06:32:01 +10001811 memset_s \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001812 mkdtemp \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001813 ngetaddrinfo \
1814 nsleep \
1815 ogetaddrinfo \
1816 openlog_r \
Darren Tucker3ddd15e2015-11-30 07:23:53 +11001817 pledge \
Darren Tuckerfebf0f52007-06-25 22:15:12 +10001818 poll \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001819 prctl \
1820 pstat \
Darren Tucker6c8c9a62018-02-24 20:46:37 +11001821 raise \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001822 readpassphrase \
Darren Tucker642652d2014-12-10 01:32:23 +11001823 reallocarray \
Darren Tucker79d46de2019-11-01 15:22:32 +11001824 realpath \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001825 recvmsg \
Damien Miller151c6e42017-06-01 15:25:13 +10001826 recallocarray \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001827 rresvport_af \
1828 sendmsg \
1829 setdtablesize \
1830 setegid \
1831 setenv \
1832 seteuid \
Darren Tucker909a3902010-01-15 12:38:30 +11001833 setgroupent \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001834 setgroups \
Darren Tucker34f702a2012-07-04 08:50:09 +10001835 setlinebuf \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001836 setlogin \
Darren Tucker909a3902010-01-15 12:38:30 +11001837 setpassent\
Darren Tucker0c9653f2005-05-28 15:58:14 +10001838 setpcred \
1839 setproctitle \
1840 setregid \
1841 setreuid \
1842 setrlimit \
1843 setsid \
1844 setvbuf \
1845 sigaction \
1846 sigvec \
1847 snprintf \
1848 socketpair \
Darren Tucker5b2e2ba2008-06-08 09:25:28 +10001849 statfs \
1850 statvfs \
Darren Tuckerafec0772016-12-13 10:23:03 +11001851 strcasestr \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001852 strdup \
1853 strerror \
1854 strlcat \
1855 strlcpy \
1856 strmode \
Darren Tucker33561e62018-03-03 14:56:09 +11001857 strndup \
Darren Tuckerb54f50e2011-09-29 23:17:18 +10001858 strnlen \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001859 strnvis \
Darren Tuckeraa74f672010-08-16 13:15:23 +10001860 strptime \
Darren Tucker44fc3342017-09-25 09:48:10 +10001861 strsignal \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001862 strtonum \
Darren Tucker81eb5d52005-06-01 21:39:33 +10001863 strtoll \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001864 strtoul \
Darren Tucker8e6fb782013-02-15 12:13:01 +11001865 strtoull \
Damien Miller34a17692007-06-11 14:15:42 +10001866 swap32 \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001867 sysconf \
1868 tcgetpgrp \
Damien Milleraa180632010-10-07 21:25:27 +11001869 timingsafe_bcmp \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001870 truncate \
1871 unsetenv \
1872 updwtmpx \
Darren Tucker091093d2019-01-18 12:11:42 +13001873 utimensat \
Darren Tucker909a3902010-01-15 12:38:30 +11001874 user_from_uid \
Damien Millerf4db77d2013-03-15 10:34:25 +11001875 usleep \
Damien Miller57f39152005-11-24 19:58:19 +11001876 vasprintf \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001877 vsnprintf \
1878 waitpid \
Darren Tucker6310ef22016-07-13 14:42:35 +10001879 warn \
Tim Rice648f8762011-01-26 12:38:57 -08001880])
Tim Rice13aae5e2001-10-21 17:53:58 -07001881
Darren Tuckerafffd312019-12-11 13:22:06 +11001882AC_CHECK_DECLS([bzero, memmem])
Darren Tuckera9004422018-02-24 20:25:22 +11001883
Darren Tuckerc61d5ec2017-02-03 14:10:34 +11001884dnl Wide character support.
Darren Tuckera2333582016-07-14 10:59:09 +10001885AC_CHECK_FUNCS([mblen mbtowc nl_langinfo wcwidth])
Darren Tuckera2333582016-07-14 10:59:09 +10001886
Darren Tucker10e290e2016-12-13 13:51:32 +11001887TEST_SSH_UTF8=${TEST_SSH_UTF8:=yes}
Darren Tucker47b8c992016-12-08 15:48:34 +11001888AC_MSG_CHECKING([for utf8 locale support])
1889AC_RUN_IFELSE(
1890 [AC_LANG_PROGRAM([[
1891#include <locale.h>
Darren Tuckerc3599502016-12-09 12:52:02 +11001892#include <stdlib.h>
Darren Tucker47b8c992016-12-08 15:48:34 +11001893 ]], [[
1894 char *loc = setlocale(LC_CTYPE, "en_US.UTF-8");
1895 if (loc != NULL)
1896 exit(0);
1897 exit(1);
1898 ]])],
1899 AC_MSG_RESULT(yes),
1900 [AC_MSG_RESULT(no)
1901 TEST_SSH_UTF8=no],
1902 AC_MSG_WARN([cross compiling: assuming yes])
1903)
1904
Tim Ricec7a8af02010-11-08 14:26:23 -08001905AC_LINK_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001906 [AC_LANG_PROGRAM(
1907 [[ #include <ctype.h> ]],
1908 [[ return (isblank('a')); ]])],
1909 [AC_DEFINE([HAVE_ISBLANK], [1], [Define if you have isblank(3C).])
Tim Ricec7a8af02010-11-08 14:26:23 -08001910])
1911
Damien Miller5fbe93f2016-07-15 13:54:31 +10001912disable_pkcs11=
1913AC_ARG_ENABLE([pkcs11],
1914 [ --disable-pkcs11 disable PKCS#11 support code [no]],
1915 [
1916 if test "x$enableval" = "xno" ; then
1917 disable_pkcs11=1
1918 fi
1919 ]
1920)
1921
Damien Miller764d51e2019-11-01 13:34:49 +11001922disable_sk=
1923AC_ARG_ENABLE([security-key],
1924 [ --disable-security-key disable U2F/FIDO support code [no]],
1925 [
1926 if test "x$enableval" = "xno" ; then
1927 disable_sk=1
1928 fi
1929 ]
1930)
Damien Miller5c0bc272019-11-15 16:08:00 +11001931enable_sk_internal=
1932AC_ARG_WITH([security-key-builtin],
1933 [ --with-security-key-builtin include builtin U2F/FIDO support],
1934 [
1935 if test "x$withval" != "xno" ; then
1936 enable_sk_internal=yes
1937 fi
1938 ]
1939)
1940test "x$disable_sk" != "x" && enable_sk_internal=""
Damien Miller764d51e2019-11-01 13:34:49 +11001941
Damien Miller764d51e2019-11-01 13:34:49 +11001942AC_SEARCH_LIBS([dlopen], [dl])
1943AC_CHECK_FUNCS([dlopen])
1944AC_CHECK_DECL([RTLD_NOW], [], [], [#include <dlfcn.h>])
1945
Darren Tuckerd5e082f2003-09-22 12:08:23 +10001946# IRIX has a const char return value for gai_strerror()
Tim Rice648f8762011-01-26 12:38:57 -08001947AC_CHECK_FUNCS([gai_strerror], [
1948 AC_DEFINE([HAVE_GAI_STRERROR])
1949 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckerd5e082f2003-09-22 12:08:23 +10001950#include <sys/types.h>
1951#include <sys/socket.h>
1952#include <netdb.h>
1953
Tim Rice648f8762011-01-26 12:38:57 -08001954const char *gai_strerror(int);
1955 ]], [[
1956 char *str;
1957 str = gai_strerror(0);
1958 ]])], [
1959 AC_DEFINE([HAVE_CONST_GAI_STRERROR_PROTO], [1],
1960 [Define if gai_strerror() returns const char *])], [])])
Darren Tuckerd5e082f2003-09-22 12:08:23 +10001961
Tim Rice648f8762011-01-26 12:38:57 -08001962AC_SEARCH_LIBS([nanosleep], [rt posix4], [AC_DEFINE([HAVE_NANOSLEEP], [1],
1963 [Some systems put nanosleep outside of libc])])
Damien Millercd6853c2003-01-28 11:33:42 +11001964
Darren Tuckera7108912013-06-02 08:18:31 +10001965AC_SEARCH_LIBS([clock_gettime], [rt],
1966 [AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Have clock_gettime])])
1967
Darren Tuckerf1159b52003-07-07 19:44:01 +10001968dnl Make sure prototypes are defined for these before using them.
Tim Rice648f8762011-01-26 12:38:57 -08001969AC_CHECK_DECL([strsep],
1970 [AC_CHECK_FUNCS([strsep])],
Darren Tucker390b6d52005-05-28 16:54:36 +10001971 [],
1972 [
1973#ifdef HAVE_STRING_H
1974# include <string.h>
1975#endif
1976 ])
Ben Lindstrom3e006472002-10-16 00:24:03 +00001977
Darren Tuckerb2427c82003-09-10 15:22:44 +10001978dnl tcsendbreak might be a macro
Tim Rice648f8762011-01-26 12:38:57 -08001979AC_CHECK_DECL([tcsendbreak],
1980 [AC_DEFINE([HAVE_TCSENDBREAK])],
1981 [AC_CHECK_FUNCS([tcsendbreak])],
Darren Tuckerb2427c82003-09-10 15:22:44 +10001982 [#include <termios.h>]
1983)
1984
Tim Rice648f8762011-01-26 12:38:57 -08001985AC_CHECK_DECLS([h_errno], , ,[#include <netdb.h>])
Darren Tucker5bb14002004-04-23 18:53:10 +10001986
Tim Rice648f8762011-01-26 12:38:57 -08001987AC_CHECK_DECLS([SHUT_RD], , ,
Darren Tucker128a0892006-07-12 19:02:56 +10001988 [
1989#include <sys/types.h>
1990#include <sys/socket.h>
1991 ])
Darren Tucker248469b2006-07-12 14:14:31 +10001992
Tim Rice648f8762011-01-26 12:38:57 -08001993AC_CHECK_DECLS([O_NONBLOCK], , ,
Darren Tucker248469b2006-07-12 14:14:31 +10001994 [
1995#include <sys/types.h>
1996#ifdef HAVE_SYS_STAT_H
1997# include <sys/stat.h>
1998#endif
1999#ifdef HAVE_FCNTL_H
2000# include <fcntl.h>
2001#endif
2002 ])
2003
Darren Tucker2eb40412018-02-24 21:06:48 +11002004AC_CHECK_DECLS([readv, writev], , , [
Darren Tuckered0b5922006-09-03 22:44:49 +10002005#include <sys/types.h>
2006#include <sys/uio.h>
2007#include <unistd.h>
2008 ])
2009
Tim Rice648f8762011-01-26 12:38:57 -08002010AC_CHECK_DECLS([MAXSYMLINKS], , , [
Darren Tucker6d862a52007-04-29 14:39:02 +10002011#include <sys/param.h>
2012 ])
2013
Tim Rice648f8762011-01-26 12:38:57 -08002014AC_CHECK_DECLS([offsetof], , , [
Darren Tuckerdca0edf2007-04-29 15:06:44 +10002015#include <stddef.h>
2016 ])
2017
Darren Tuckerc7aad002013-06-02 07:18:47 +10002018# extra bits for select(2)
2019AC_CHECK_DECLS([howmany, NFDBITS], [], [], [[
2020#include <sys/param.h>
2021#include <sys/types.h>
2022#ifdef HAVE_SYS_SYSMACROS_H
2023#include <sys/sysmacros.h>
2024#endif
2025#ifdef HAVE_SYS_SELECT_H
2026#include <sys/select.h>
2027#endif
2028#ifdef HAVE_SYS_TIME_H
2029#include <sys/time.h>
2030#endif
2031#ifdef HAVE_UNISTD_H
2032#include <unistd.h>
2033#endif
2034 ]])
2035AC_CHECK_TYPES([fd_mask], [], [], [[
2036#include <sys/param.h>
2037#include <sys/types.h>
2038#ifdef HAVE_SYS_SELECT_H
2039#include <sys/select.h>
2040#endif
2041#ifdef HAVE_SYS_TIME_H
2042#include <sys/time.h>
2043#endif
2044#ifdef HAVE_UNISTD_H
2045#include <unistd.h>
2046#endif
2047 ]])
2048
Tim Rice648f8762011-01-26 12:38:57 -08002049AC_CHECK_FUNCS([setresuid], [
Darren Tucker2a6b0292003-12-31 14:59:17 +11002050 dnl Some platorms have setresuid that isn't implemented, test for this
Tim Rice648f8762011-01-26 12:38:57 -08002051 AC_MSG_CHECKING([if setresuid seems to work])
Darren Tucker623d92f2004-09-12 22:36:15 +10002052 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002053 [AC_LANG_PROGRAM([[
Darren Tuckere937be32003-12-17 18:53:26 +11002054#include <stdlib.h>
2055#include <errno.h>
Tim Rice648f8762011-01-26 12:38:57 -08002056 ]], [[
2057 errno=0;
2058 setresuid(0,0,0);
2059 if (errno==ENOSYS)
2060 exit(1);
2061 else
2062 exit(0);
Darren Tucker623d92f2004-09-12 22:36:15 +10002063 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08002064 [AC_MSG_RESULT([yes])],
2065 [AC_DEFINE([BROKEN_SETRESUID], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07002066 [Define if your setresuid() is broken])
Tim Rice648f8762011-01-26 12:38:57 -08002067 AC_MSG_RESULT([not implemented])],
Darren Tuckera0c2b392004-09-11 23:26:37 +10002068 [AC_MSG_WARN([cross compiling: not checking setresuid])]
Darren Tucker2a6b0292003-12-31 14:59:17 +11002069 )
2070])
Darren Tuckere937be32003-12-17 18:53:26 +11002071
Tim Rice648f8762011-01-26 12:38:57 -08002072AC_CHECK_FUNCS([setresgid], [
Darren Tucker2a6b0292003-12-31 14:59:17 +11002073 dnl Some platorms have setresgid that isn't implemented, test for this
Tim Rice648f8762011-01-26 12:38:57 -08002074 AC_MSG_CHECKING([if setresgid seems to work])
Darren Tucker623d92f2004-09-12 22:36:15 +10002075 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002076 [AC_LANG_PROGRAM([[
Darren Tuckere937be32003-12-17 18:53:26 +11002077#include <stdlib.h>
2078#include <errno.h>
Tim Rice648f8762011-01-26 12:38:57 -08002079 ]], [[
2080 errno=0;
2081 setresgid(0,0,0);
2082 if (errno==ENOSYS)
2083 exit(1);
2084 else
2085 exit(0);
Darren Tucker623d92f2004-09-12 22:36:15 +10002086 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08002087 [AC_MSG_RESULT([yes])],
2088 [AC_DEFINE([BROKEN_SETRESGID], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07002089 [Define if your setresgid() is broken])
Tim Rice648f8762011-01-26 12:38:57 -08002090 AC_MSG_RESULT([not implemented])],
Darren Tuckera0c2b392004-09-11 23:26:37 +10002091 [AC_MSG_WARN([cross compiling: not checking setresuid])]
Darren Tucker2a6b0292003-12-31 14:59:17 +11002092 )
2093])
Darren Tuckere937be32003-12-17 18:53:26 +11002094
Darren Tucker58fd4c52018-03-05 19:28:08 +11002095AC_MSG_CHECKING([for working fflush(NULL)])
2096AC_RUN_IFELSE(
2097 [AC_LANG_PROGRAM([[#include <stdio.h>]], [[fflush(NULL); exit(0);]])],
2098 AC_MSG_RESULT([yes]),
2099 [AC_MSG_RESULT([no])
2100 AC_DEFINE([FFLUSH_NULL_BUG], [1],
2101 [define if fflush(NULL) does not work])],
2102 AC_MSG_WARN([cross compiling: assuming working])
2103)
2104
Damien Millerad833b32000-08-23 10:46:23 +10002105dnl Checks for time functions
Tim Rice648f8762011-01-26 12:38:57 -08002106AC_CHECK_FUNCS([gettimeofday time])
Damien Millerad833b32000-08-23 10:46:23 +10002107dnl Checks for utmp functions
Tim Rice648f8762011-01-26 12:38:57 -08002108AC_CHECK_FUNCS([endutent getutent getutid getutline pututline setutent])
2109AC_CHECK_FUNCS([utmpname])
Damien Millerad833b32000-08-23 10:46:23 +10002110dnl Checks for utmpx functions
Tim Rice648f8762011-01-26 12:38:57 -08002111AC_CHECK_FUNCS([endutxent getutxent getutxid getutxline getutxuser pututxline])
2112AC_CHECK_FUNCS([setutxdb setutxent utmpxname])
Damien Miller20e231f2009-02-12 13:12:21 +11002113dnl Checks for lastlog functions
Tim Rice648f8762011-01-26 12:38:57 -08002114AC_CHECK_FUNCS([getlastlogxbyname])
Damien Millercedfecc1999-11-15 14:36:53 +11002115
Tim Rice648f8762011-01-26 12:38:57 -08002116AC_CHECK_FUNC([daemon],
2117 [AC_DEFINE([HAVE_DAEMON], [1], [Define if your libraries define daemon()])],
2118 [AC_CHECK_LIB([bsd], [daemon],
2119 [LIBS="$LIBS -lbsd"; AC_DEFINE([HAVE_DAEMON])])]
Damien Miller04f80141999-11-19 15:32:34 +11002120)
2121
Tim Rice648f8762011-01-26 12:38:57 -08002122AC_CHECK_FUNC([getpagesize],
2123 [AC_DEFINE([HAVE_GETPAGESIZE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07002124 [Define if your libraries define getpagesize()])],
Tim Rice648f8762011-01-26 12:38:57 -08002125 [AC_CHECK_LIB([ucb], [getpagesize],
2126 [LIBS="$LIBS -lucb"; AC_DEFINE([HAVE_GETPAGESIZE])])]
Damien Miller9fb07e42000-03-05 16:22:59 +11002127)
2128
Damien Millercb170cb2000-07-01 16:52:55 +10002129# Check for broken snprintf
2130if test "x$ac_cv_func_snprintf" = "xyes" ; then
2131 AC_MSG_CHECKING([whether snprintf correctly terminates long strings])
Darren Tuckera0c2b392004-09-11 23:26:37 +10002132 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002133 [AC_LANG_PROGRAM([[ #include <stdio.h> ]],
2134 [[
2135 char b[5];
2136 snprintf(b,5,"123456789");
Tim Ricee1d93702016-05-31 11:13:22 -07002137 exit(b[4]!='\0');
Darren Tucker623d92f2004-09-12 22:36:15 +10002138 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08002139 [AC_MSG_RESULT([yes])],
Damien Millercb170cb2000-07-01 16:52:55 +10002140 [
Tim Rice648f8762011-01-26 12:38:57 -08002141 AC_MSG_RESULT([no])
2142 AC_DEFINE([BROKEN_SNPRINTF], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07002143 [Define if your snprintf is busted])
Damien Millercb170cb2000-07-01 16:52:55 +10002144 AC_MSG_WARN([****** Your snprintf() function is broken, complain to your vendor])
Darren Tuckera0c2b392004-09-11 23:26:37 +10002145 ],
2146 [ AC_MSG_WARN([cross compiling: Assuming working snprintf()]) ]
Damien Millercb170cb2000-07-01 16:52:55 +10002147 )
2148fi
2149
Darren Tuckere5261272018-10-12 16:43:35 +11002150if test "x$ac_cv_func_snprintf" = "xyes" ; then
2151 AC_MSG_CHECKING([whether snprintf understands %zu])
2152 AC_RUN_IFELSE(
2153 [AC_LANG_PROGRAM([[
2154#include <sys/types.h>
2155#include <stdio.h>
2156 ]],
2157 [[
2158 size_t a = 1, b = 2;
2159 char z[128];
2160 snprintf(z, sizeof z, "%zu%zu", a, b);
2161 exit(strcmp(z, "12"));
2162 ]])],
2163 [AC_MSG_RESULT([yes])],
2164 [
2165 AC_MSG_RESULT([no])
2166 AC_DEFINE([BROKEN_SNPRINTF], [1],
2167 [snprintf does not understand %zu])
2168 ],
2169 [ AC_MSG_WARN([cross compiling: Assuming working snprintf()]) ]
2170 )
2171fi
2172
Damien Millerd244a582014-08-23 17:06:49 +10002173# We depend on vsnprintf returning the right thing on overflow: the
2174# number of characters it tried to create (as per SUSv3)
2175if test "x$ac_cv_func_vsnprintf" = "xyes" ; then
Damien Miller57f39152005-11-24 19:58:19 +11002176 AC_MSG_CHECKING([whether vsnprintf returns correct values on overflow])
2177 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002178 [AC_LANG_PROGRAM([[
Damien Miller57f39152005-11-24 19:58:19 +11002179#include <sys/types.h>
2180#include <stdio.h>
2181#include <stdarg.h>
2182
Damien Millerd244a582014-08-23 17:06:49 +10002183int x_snprintf(char *str, size_t count, const char *fmt, ...)
Damien Miller57f39152005-11-24 19:58:19 +11002184{
Damien Millerd244a582014-08-23 17:06:49 +10002185 size_t ret;
2186 va_list ap;
2187
2188 va_start(ap, fmt);
2189 ret = vsnprintf(str, count, fmt, ap);
2190 va_end(ap);
Damien Miller57f39152005-11-24 19:58:19 +11002191 return ret;
2192}
Tim Rice648f8762011-01-26 12:38:57 -08002193 ]], [[
Damien Millerd244a582014-08-23 17:06:49 +10002194char x[1];
2195if (x_snprintf(x, 1, "%s %d", "hello", 12345) != 11)
2196 return 1;
2197if (x_snprintf(NULL, 0, "%s %d", "hello", 12345) != 11)
2198 return 1;
2199return 0;
Tim Rice648f8762011-01-26 12:38:57 -08002200 ]])],
2201 [AC_MSG_RESULT([yes])],
Damien Miller57f39152005-11-24 19:58:19 +11002202 [
Tim Rice648f8762011-01-26 12:38:57 -08002203 AC_MSG_RESULT([no])
2204 AC_DEFINE([BROKEN_SNPRINTF], [1],
Damien Miller57f39152005-11-24 19:58:19 +11002205 [Define if your snprintf is busted])
2206 AC_MSG_WARN([****** Your vsnprintf() function is broken, complain to your vendor])
2207 ],
2208 [ AC_MSG_WARN([cross compiling: Assuming working vsnprintf()]) ]
2209 )
2210fi
2211
Darren Tuckerd40c66c2005-12-17 22:32:03 +11002212# On systems where [v]snprintf is broken, but is declared in stdio,
2213# check that the fmt argument is const char * or just char *.
2214# This is only useful for when BROKEN_SNPRINTF
2215AC_MSG_CHECKING([whether snprintf can declare const char *fmt])
Tim Rice648f8762011-01-26 12:38:57 -08002216AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2217#include <stdio.h>
2218int snprintf(char *a, size_t b, const char *c, ...) { return 0; }
2219 ]], [[
2220 snprintf(0, 0, 0);
2221 ]])],
2222 [AC_MSG_RESULT([yes])
2223 AC_DEFINE([SNPRINTF_CONST], [const],
Darren Tuckerd40c66c2005-12-17 22:32:03 +11002224 [Define as const if snprintf() can declare const char *fmt])],
Tim Rice648f8762011-01-26 12:38:57 -08002225 [AC_MSG_RESULT([no])
2226 AC_DEFINE([SNPRINTF_CONST], [/* not const */])])
Darren Tuckerd40c66c2005-12-17 22:32:03 +11002227
Damien Millerb4097182004-05-23 14:09:40 +10002228# Check for missing getpeereid (or equiv) support
2229NO_PEERCHECK=""
Darren Tucker164aa302007-03-21 21:39:57 +11002230if test "x$ac_cv_func_getpeereid" != "xyes" -a "x$ac_cv_func_getpeerucred" != "xyes"; then
Damien Millerb4097182004-05-23 14:09:40 +10002231 AC_MSG_CHECKING([whether system supports SO_PEERCRED getsockopt])
Tim Rice648f8762011-01-26 12:38:57 -08002232 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2233#include <sys/types.h>
2234#include <sys/socket.h>]], [[int i = SO_PEERCRED;]])],
2235 [ AC_MSG_RESULT([yes])
2236 AC_DEFINE([HAVE_SO_PEERCRED], [1], [Have PEERCRED socket option])
2237 ], [AC_MSG_RESULT([no])
2238 NO_PEERCHECK=1
2239 ])
Damien Millerb4097182004-05-23 14:09:40 +10002240fi
2241
Damien Millere8328192003-01-07 15:18:32 +11002242dnl see whether mkstemp() requires XXXXXX
2243if test "x$ac_cv_func_mkdtemp" = "xyes" ; then
2244AC_MSG_CHECKING([for (overly) strict mkstemp])
Darren Tucker314d89e2005-10-17 23:29:23 +10002245AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002246 [AC_LANG_PROGRAM([[
Damien Millere8328192003-01-07 15:18:32 +11002247#include <stdlib.h>
Tim Rice648f8762011-01-26 12:38:57 -08002248 ]], [[
2249 char template[]="conftest.mkstemp-test";
2250 if (mkstemp(template) == -1)
2251 exit(1);
2252 unlink(template);
2253 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10002254 ]])],
Damien Millere8328192003-01-07 15:18:32 +11002255 [
Tim Rice648f8762011-01-26 12:38:57 -08002256 AC_MSG_RESULT([no])
Damien Millere8328192003-01-07 15:18:32 +11002257 ],
Damien Millera8e06ce2003-11-21 23:48:55 +11002258 [
Tim Rice648f8762011-01-26 12:38:57 -08002259 AC_MSG_RESULT([yes])
2260 AC_DEFINE([HAVE_STRICT_MKSTEMP], [1], [Silly mkstemp()])
Damien Millere8328192003-01-07 15:18:32 +11002261 ],
2262 [
Tim Rice648f8762011-01-26 12:38:57 -08002263 AC_MSG_RESULT([yes])
2264 AC_DEFINE([HAVE_STRICT_MKSTEMP])
Damien Millera8e06ce2003-11-21 23:48:55 +11002265 ]
Damien Millere8328192003-01-07 15:18:32 +11002266)
2267fi
2268
Darren Tucker70a3d552003-08-21 17:58:29 +10002269dnl make sure that openpty does not reacquire controlling terminal
2270if test ! -z "$check_for_openpty_ctty_bug"; then
Tim Rice648f8762011-01-26 12:38:57 -08002271 AC_MSG_CHECKING([if openpty correctly handles controlling tty])
Darren Tucker314d89e2005-10-17 23:29:23 +10002272 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002273 [AC_LANG_PROGRAM([[
Darren Tucker70a3d552003-08-21 17:58:29 +10002274#include <stdio.h>
2275#include <sys/fcntl.h>
2276#include <sys/types.h>
2277#include <sys/wait.h>
Tim Rice648f8762011-01-26 12:38:57 -08002278 ]], [[
Darren Tucker70a3d552003-08-21 17:58:29 +10002279 pid_t pid;
2280 int fd, ptyfd, ttyfd, status;
2281
2282 pid = fork();
2283 if (pid < 0) { /* failed */
2284 exit(1);
2285 } else if (pid > 0) { /* parent */
2286 waitpid(pid, &status, 0);
Damien Millera8e06ce2003-11-21 23:48:55 +11002287 if (WIFEXITED(status))
Darren Tucker70a3d552003-08-21 17:58:29 +10002288 exit(WEXITSTATUS(status));
2289 else
2290 exit(2);
2291 } else { /* child */
2292 close(0); close(1); close(2);
2293 setsid();
2294 openpty(&ptyfd, &ttyfd, NULL, NULL, NULL);
2295 fd = open("/dev/tty", O_RDWR | O_NOCTTY);
2296 if (fd >= 0)
2297 exit(3); /* Acquired ctty: broken */
2298 else
2299 exit(0); /* Did not acquire ctty: OK */
2300 }
Darren Tucker314d89e2005-10-17 23:29:23 +10002301 ]])],
Darren Tucker70a3d552003-08-21 17:58:29 +10002302 [
Tim Rice648f8762011-01-26 12:38:57 -08002303 AC_MSG_RESULT([yes])
Darren Tucker70a3d552003-08-21 17:58:29 +10002304 ],
2305 [
Tim Rice648f8762011-01-26 12:38:57 -08002306 AC_MSG_RESULT([no])
2307 AC_DEFINE([SSHD_ACQUIRES_CTTY])
Darren Tucker314d89e2005-10-17 23:29:23 +10002308 ],
2309 [
Tim Rice648f8762011-01-26 12:38:57 -08002310 AC_MSG_RESULT([cross-compiling, assuming yes])
Darren Tucker70a3d552003-08-21 17:58:29 +10002311 ]
2312 )
2313fi
2314
Tim Rice8bb561b2005-03-17 16:23:19 -08002315if test "x$ac_cv_func_getaddrinfo" = "xyes" && \
2316 test "x$check_for_hpux_broken_getaddrinfo" = "x1"; then
Tim Rice648f8762011-01-26 12:38:57 -08002317 AC_MSG_CHECKING([if getaddrinfo seems to work])
Darren Tucker314d89e2005-10-17 23:29:23 +10002318 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002319 [AC_LANG_PROGRAM([[
Darren Tucker4398cf52004-04-06 21:39:02 +10002320#include <stdio.h>
2321#include <sys/socket.h>
2322#include <netdb.h>
2323#include <errno.h>
2324#include <netinet/in.h>
2325
2326#define TEST_PORT "2222"
Tim Rice648f8762011-01-26 12:38:57 -08002327 ]], [[
Darren Tucker4398cf52004-04-06 21:39:02 +10002328 int err, sock;
2329 struct addrinfo *gai_ai, *ai, hints;
2330 char ntop[NI_MAXHOST], strport[NI_MAXSERV], *name = NULL;
2331
2332 memset(&hints, 0, sizeof(hints));
2333 hints.ai_family = PF_UNSPEC;
2334 hints.ai_socktype = SOCK_STREAM;
2335 hints.ai_flags = AI_PASSIVE;
2336
2337 err = getaddrinfo(name, TEST_PORT, &hints, &gai_ai);
2338 if (err != 0) {
2339 fprintf(stderr, "getaddrinfo failed (%s)", gai_strerror(err));
2340 exit(1);
2341 }
2342
2343 for (ai = gai_ai; ai != NULL; ai = ai->ai_next) {
2344 if (ai->ai_family != AF_INET6)
2345 continue;
2346
2347 err = getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop,
2348 sizeof(ntop), strport, sizeof(strport),
2349 NI_NUMERICHOST|NI_NUMERICSERV);
2350
2351 if (err != 0) {
2352 if (err == EAI_SYSTEM)
2353 perror("getnameinfo EAI_SYSTEM");
2354 else
2355 fprintf(stderr, "getnameinfo failed: %s\n",
2356 gai_strerror(err));
2357 exit(2);
2358 }
2359
2360 sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
2361 if (sock < 0)
2362 perror("socket");
2363 if (bind(sock, ai->ai_addr, ai->ai_addrlen) < 0) {
2364 if (errno == EBADF)
2365 exit(3);
2366 }
2367 }
2368 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10002369 ]])],
Darren Tucker4398cf52004-04-06 21:39:02 +10002370 [
Tim Rice648f8762011-01-26 12:38:57 -08002371 AC_MSG_RESULT([yes])
Darren Tucker4398cf52004-04-06 21:39:02 +10002372 ],
2373 [
Tim Rice648f8762011-01-26 12:38:57 -08002374 AC_MSG_RESULT([no])
2375 AC_DEFINE([BROKEN_GETADDRINFO])
Darren Tucker314d89e2005-10-17 23:29:23 +10002376 ],
2377 [
Tim Rice648f8762011-01-26 12:38:57 -08002378 AC_MSG_RESULT([cross-compiling, assuming yes])
Darren Tucker4398cf52004-04-06 21:39:02 +10002379 ]
2380 )
2381fi
2382
Tim Rice8bb561b2005-03-17 16:23:19 -08002383if test "x$ac_cv_func_getaddrinfo" = "xyes" && \
2384 test "x$check_for_aix_broken_getaddrinfo" = "x1"; then
Tim Rice648f8762011-01-26 12:38:57 -08002385 AC_MSG_CHECKING([if getaddrinfo seems to work])
Darren Tucker314d89e2005-10-17 23:29:23 +10002386 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002387 [AC_LANG_PROGRAM([[
Darren Tucker691d5232005-02-15 21:45:57 +11002388#include <stdio.h>
2389#include <sys/socket.h>
2390#include <netdb.h>
2391#include <errno.h>
2392#include <netinet/in.h>
2393
2394#define TEST_PORT "2222"
Tim Rice648f8762011-01-26 12:38:57 -08002395 ]], [[
Darren Tucker691d5232005-02-15 21:45:57 +11002396 int err, sock;
2397 struct addrinfo *gai_ai, *ai, hints;
2398 char ntop[NI_MAXHOST], strport[NI_MAXSERV], *name = NULL;
2399
2400 memset(&hints, 0, sizeof(hints));
2401 hints.ai_family = PF_UNSPEC;
2402 hints.ai_socktype = SOCK_STREAM;
2403 hints.ai_flags = AI_PASSIVE;
2404
2405 err = getaddrinfo(name, TEST_PORT, &hints, &gai_ai);
2406 if (err != 0) {
2407 fprintf(stderr, "getaddrinfo failed (%s)", gai_strerror(err));
2408 exit(1);
2409 }
2410
2411 for (ai = gai_ai; ai != NULL; ai = ai->ai_next) {
2412 if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6)
2413 continue;
2414
2415 err = getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop,
2416 sizeof(ntop), strport, sizeof(strport),
2417 NI_NUMERICHOST|NI_NUMERICSERV);
2418
2419 if (ai->ai_family == AF_INET && err != 0) {
2420 perror("getnameinfo");
2421 exit(2);
2422 }
2423 }
2424 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10002425 ]])],
Darren Tucker691d5232005-02-15 21:45:57 +11002426 [
Tim Rice648f8762011-01-26 12:38:57 -08002427 AC_MSG_RESULT([yes])
2428 AC_DEFINE([AIX_GETNAMEINFO_HACK], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07002429 [Define if you have a getaddrinfo that fails
2430 for the all-zeros IPv6 address])
Darren Tucker691d5232005-02-15 21:45:57 +11002431 ],
2432 [
Tim Rice648f8762011-01-26 12:38:57 -08002433 AC_MSG_RESULT([no])
2434 AC_DEFINE([BROKEN_GETADDRINFO])
Darren Tucker314d89e2005-10-17 23:29:23 +10002435 ],
Darren Tucker8b272ab2006-06-27 11:20:28 +10002436 [
Tim Rice648f8762011-01-26 12:38:57 -08002437 AC_MSG_RESULT([cross-compiling, assuming no])
Darren Tucker691d5232005-02-15 21:45:57 +11002438 ]
2439 )
2440fi
2441
Darren Tuckere50e8c92015-02-21 15:10:33 +11002442if test "x$ac_cv_func_getaddrinfo" = "xyes"; then
2443 AC_CHECK_DECLS(AI_NUMERICSERV, , ,
2444 [#include <sys/types.h>
2445 #include <sys/socket.h>
2446 #include <netdb.h>])
2447fi
2448
Darren Tuckera56f1912004-11-02 20:30:54 +11002449if test "x$check_for_conflicting_getspnam" = "x1"; then
Tim Rice648f8762011-01-26 12:38:57 -08002450 AC_MSG_CHECKING([for conflicting getspnam in shadow.h])
2451 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <shadow.h> ]],
2452 [[ exit(0); ]])],
Darren Tuckera56f1912004-11-02 20:30:54 +11002453 [
Tim Rice648f8762011-01-26 12:38:57 -08002454 AC_MSG_RESULT([no])
Darren Tuckera56f1912004-11-02 20:30:54 +11002455 ],
2456 [
Tim Rice648f8762011-01-26 12:38:57 -08002457 AC_MSG_RESULT([yes])
2458 AC_DEFINE([GETSPNAM_CONFLICTING_DEFS], [1],
Darren Tuckera56f1912004-11-02 20:30:54 +11002459 [Conflicting defs for getspnam])
2460 ]
2461 )
2462fi
2463
Darren Tucker20e5e8b2016-08-02 12:16:34 +10002464dnl NetBSD added an strnvis and unfortunately made it incompatible with the
2465dnl existing one in OpenBSD and Linux's libbsd (the former having existed
2466dnl for over ten years). Despite this incompatibility being reported during
2467dnl development (see http://gnats.netbsd.org/44977) they still shipped it.
2468dnl Even more unfortunately FreeBSD and later MacOS picked up this incompatible
2469dnl implementation. Try to detect this mess, and assume the only safe option
2470dnl if we're cross compiling.
2471dnl
2472dnl OpenBSD, 2001: strnvis(char *dst, const char *src, size_t dlen, int flag);
2473dnl NetBSD: 2012, strnvis(char *dst, size_t dlen, const char *src, int flag);
2474if test "x$ac_cv_func_strnvis" = "xyes"; then
2475 AC_MSG_CHECKING([for working strnvis])
2476 AC_RUN_IFELSE(
2477 [AC_LANG_PROGRAM([[
2478#include <signal.h>
2479#include <stdlib.h>
2480#include <string.h>
2481#include <vis.h>
2482static void sighandler(int sig) { _exit(1); }
2483 ]], [[
2484 char dst[16];
2485
2486 signal(SIGSEGV, sighandler);
2487 if (strnvis(dst, "src", 4, 0) && strcmp(dst, "src") == 0)
2488 exit(0);
2489 exit(1)
2490 ]])],
2491 [AC_MSG_RESULT([yes])],
2492 [AC_MSG_RESULT([no])
2493 AC_DEFINE([BROKEN_STRNVIS], [1], [strnvis detected broken])],
2494 [AC_MSG_WARN([cross compiling: assuming broken])
2495 AC_DEFINE([BROKEN_STRNVIS], [1], [strnvis assumed broken])]
2496 )
2497fi
2498
Darren Tuckerc7b5a472018-02-25 23:55:41 +11002499AC_CHECK_FUNCS([getpgrp],[
2500 AC_MSG_CHECKING([if getpgrp accepts zero args])
2501 AC_COMPILE_IFELSE(
2502 [AC_LANG_PROGRAM([[$ac_includes_default]], [[ getpgrp(); ]])],
2503 [ AC_MSG_RESULT([yes])
2504 AC_DEFINE([GETPGRP_VOID], [1], [getpgrp takes zero args])],
2505 [ AC_MSG_RESULT([no])
2506 AC_DEFINE([GETPGRP_VOID], [0], [getpgrp takes one arg])]
2507 )
2508])
Damien Miller606f8802000-09-16 15:39:56 +11002509
Tim Riceaef73712002-05-11 13:17:42 -07002510# Search for OpenSSL
2511saved_CPPFLAGS="$CPPFLAGS"
2512saved_LDFLAGS="$LDFLAGS"
Tim Rice648f8762011-01-26 12:38:57 -08002513AC_ARG_WITH([ssl-dir],
Damien Millera22ba012000-03-02 23:09:20 +11002514 [ --with-ssl-dir=PATH Specify path to OpenSSL installation ],
2515 [
Damien Miller72ef7c12015-01-15 02:21:31 +11002516 if test "x$openssl" = "xno" ; then
2517 AC_MSG_ERROR([cannot use --with-ssl-dir when OpenSSL disabled])
2518 fi
Ben Lindstrom23e13712000-10-29 22:49:19 +00002519 if test "x$withval" != "xno" ; then
Darren Tuckerc7e38d52005-02-09 22:12:30 +11002520 case "$withval" in
2521 # Relative paths
2522 ./*|../*) withval="`pwd`/$withval"
2523 esac
Tim Riceaef73712002-05-11 13:17:42 -07002524 if test -d "$withval/lib"; then
Darren Tucker2f0bad22019-01-21 21:28:27 +11002525 if test -n "${rpath_opt}"; then
2526 LDFLAGS="-L${withval}/lib ${rpath_opt}${withval}/lib ${LDFLAGS}"
Tim Riceaef73712002-05-11 13:17:42 -07002527 else
2528 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
2529 fi
Darren Tucker9f8703b2010-04-23 11:12:06 +10002530 elif test -d "$withval/lib64"; then
Darren Tucker2f0bad22019-01-21 21:28:27 +11002531 if test -n "${rpath_opt}"; then
2532 LDFLAGS="-L${withval}/lib64 ${rpath_opt}${withval}/lib64 ${LDFLAGS}"
Darren Tucker9f8703b2010-04-23 11:12:06 +10002533 else
2534 LDFLAGS="-L${withval}/lib64 ${LDFLAGS}"
2535 fi
Tim Riceaef73712002-05-11 13:17:42 -07002536 else
Darren Tucker2f0bad22019-01-21 21:28:27 +11002537 if test -n "${rpath_opt}"; then
2538 LDFLAGS="-L${withval} ${rpath_opt}${withval} ${LDFLAGS}"
Tim Riceaef73712002-05-11 13:17:42 -07002539 else
2540 LDFLAGS="-L${withval} ${LDFLAGS}"
2541 fi
2542 fi
2543 if test -d "$withval/include"; then
2544 CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
2545 else
2546 CPPFLAGS="-I${withval} ${CPPFLAGS}"
2547 fi
Damien Millera22ba012000-03-02 23:09:20 +11002548 fi
2549 ]
2550)
Damien Millerb9c56672014-05-15 14:43:37 +10002551
Tim Rice648f8762011-01-26 12:38:57 -08002552AC_ARG_WITH([openssl-header-check],
Damien Miller9975e482007-03-05 11:51:27 +11002553 [ --without-openssl-header-check Disable OpenSSL version consistency check],
Damien Millerec932372002-01-22 22:16:03 +11002554 [
Damien Miller72ef7c12015-01-15 02:21:31 +11002555 if test "x$withval" = "xno" ; then
2556 openssl_check_nonfatal=1
Damien Miller9975e482007-03-05 11:51:27 +11002557 fi
Damien Millerec932372002-01-22 22:16:03 +11002558 ]
2559)
2560
Damien Miller72ef7c12015-01-15 02:21:31 +11002561openssl_engine=no
Tim Rice648f8762011-01-26 12:38:57 -08002562AC_ARG_WITH([ssl-engine],
Darren Tuckerfabdb6c2006-02-20 20:17:35 +11002563 [ --with-ssl-engine Enable OpenSSL (hardware) ENGINE support ],
Damien Miller72ef7c12015-01-15 02:21:31 +11002564 [
Damien Miller72ef7c12015-01-15 02:21:31 +11002565 if test "x$withval" != "xno" ; then
Darren Tuckerb5fa0cd2015-12-15 15:10:32 +11002566 if test "x$openssl" = "xno" ; then
2567 AC_MSG_ERROR([cannot use --with-ssl-engine when OpenSSL disabled])
2568 fi
Damien Miller72ef7c12015-01-15 02:21:31 +11002569 openssl_engine=yes
2570 fi
2571 ]
2572)
2573
2574if test "x$openssl" = "xyes" ; then
2575 LIBS="-lcrypto $LIBS"
Darren Tucker8d8340e2018-11-16 13:32:13 +11002576 AC_TRY_LINK_FUNC([RAND_add], ,
2577 [AC_MSG_ERROR([*** working libcrypto not found, check config.log])])
2578 AC_CHECK_HEADER([openssl/opensslv.h], ,
2579 [AC_MSG_ERROR([*** OpenSSL headers missing - please install first or check config.log ***])])
Damien Miller72ef7c12015-01-15 02:21:31 +11002580
2581 # Determine OpenSSL header version
2582 AC_MSG_CHECKING([OpenSSL header version])
2583 AC_RUN_IFELSE(
2584 [AC_LANG_PROGRAM([[
Darren Tucker15605962015-11-10 11:14:47 +11002585 #include <stdlib.h>
Damien Miller72ef7c12015-01-15 02:21:31 +11002586 #include <stdio.h>
2587 #include <string.h>
2588 #include <openssl/opensslv.h>
2589 #define DATA "conftest.sslincver"
2590 ]], [[
2591 FILE *fd;
2592 int rc;
2593
2594 fd = fopen(DATA,"w");
2595 if(fd == NULL)
2596 exit(1);
2597
Darren Tuckerb3413532016-04-04 11:09:21 +10002598 if ((rc = fprintf(fd, "%08lx (%s)\n",
2599 (unsigned long)OPENSSL_VERSION_NUMBER,
2600 OPENSSL_VERSION_TEXT)) < 0)
Damien Miller72ef7c12015-01-15 02:21:31 +11002601 exit(1);
2602
2603 exit(0);
2604 ]])],
2605 [
2606 ssl_header_ver=`cat conftest.sslincver`
2607 AC_MSG_RESULT([$ssl_header_ver])
2608 ],
2609 [
2610 AC_MSG_RESULT([not found])
2611 AC_MSG_ERROR([OpenSSL version header not found.])
2612 ],
2613 [
2614 AC_MSG_WARN([cross compiling: not checking])
2615 ]
2616 )
2617
Darren Tucker262d81a2018-10-27 16:45:59 +11002618 # Determining OpenSSL library version is version dependent.
2619 AC_CHECK_FUNCS([OpenSSL_version OpenSSL_version_num])
2620
Damien Miller72ef7c12015-01-15 02:21:31 +11002621 # Determine OpenSSL library version
2622 AC_MSG_CHECKING([OpenSSL library version])
2623 AC_RUN_IFELSE(
2624 [AC_LANG_PROGRAM([[
2625 #include <stdio.h>
2626 #include <string.h>
2627 #include <openssl/opensslv.h>
2628 #include <openssl/crypto.h>
2629 #define DATA "conftest.ssllibver"
2630 ]], [[
2631 FILE *fd;
2632 int rc;
2633
2634 fd = fopen(DATA,"w");
2635 if(fd == NULL)
2636 exit(1);
Darren Tucker262d81a2018-10-27 16:45:59 +11002637#ifndef OPENSSL_VERSION
2638# define OPENSSL_VERSION SSLEAY_VERSION
2639#endif
2640#ifndef HAVE_OPENSSL_VERSION
Damien Miller406a24b2018-10-26 13:43:28 +11002641# define OpenSSL_version SSLeay_version
Darren Tucker262d81a2018-10-27 16:45:59 +11002642#endif
2643#ifndef HAVE_OPENSSL_VERSION_NUM
2644# define OpenSSL_version_num SSLeay
Damien Miller406a24b2018-10-26 13:43:28 +11002645#endif
Damien Miller859754b2018-10-23 17:10:41 +11002646 if ((rc = fprintf(fd, "%08lx (%s)\n",
2647 (unsigned long)OpenSSL_version_num(),
2648 OpenSSL_version(OPENSSL_VERSION))) < 0)
Damien Miller72ef7c12015-01-15 02:21:31 +11002649 exit(1);
2650
2651 exit(0);
2652 ]])],
2653 [
2654 ssl_library_ver=`cat conftest.ssllibver`
2655 # Check version is supported.
2656 case "$ssl_library_ver" in
Damien Milleraede1c32018-10-17 11:01:20 +11002657 10000*|0*)
2658 AC_MSG_ERROR([OpenSSL >= 1.0.1 required (have "$ssl_library_ver")])
2659 ;;
2660 100*) ;; # 1.0.x
Damien Miller28c7b2c2018-11-23 10:45:20 +11002661 101000[[0123456]]*)
Damien Milleraede1c32018-10-17 11:01:20 +11002662 # https://github.com/openssl/openssl/pull/4613
2663 AC_MSG_ERROR([OpenSSL 1.1.x versions prior to 1.1.0g have a bug that breaks their use with OpenSSH (have "$ssl_library_ver")])
2664 ;;
2665 101*) ;; # 1.1.x
2666 200*) ;; # LibreSSL
Darren Tuckerc882d742019-01-22 20:38:40 +11002667 300*) ;; # OpenSSL development branch.
Damien Milleraede1c32018-10-17 11:01:20 +11002668 *)
Darren Tuckerc882d742019-01-22 20:38:40 +11002669 AC_MSG_ERROR([Unknown/unsupported OpenSSL version ("$ssl_library_ver")])
Damien Milleraede1c32018-10-17 11:01:20 +11002670 ;;
Damien Miller72ef7c12015-01-15 02:21:31 +11002671 esac
2672 AC_MSG_RESULT([$ssl_library_ver])
2673 ],
2674 [
2675 AC_MSG_RESULT([not found])
2676 AC_MSG_ERROR([OpenSSL library not found.])
2677 ],
2678 [
2679 AC_MSG_WARN([cross compiling: not checking])
2680 ]
2681 )
2682
2683 # Sanity check OpenSSL headers
2684 AC_MSG_CHECKING([whether OpenSSL's headers match the library])
2685 AC_RUN_IFELSE(
2686 [AC_LANG_PROGRAM([[
2687 #include <string.h>
2688 #include <openssl/opensslv.h>
Darren Tuckerc1d7e542015-12-15 14:27:09 +11002689 #include <openssl/crypto.h>
Damien Miller72ef7c12015-01-15 02:21:31 +11002690 ]], [[
Darren Tucker262d81a2018-10-27 16:45:59 +11002691#ifndef HAVE_OPENSSL_VERSION_NUM
2692# define OpenSSL_version_num SSLeay
Damien Miller406a24b2018-10-26 13:43:28 +11002693#endif
Damien Miller859754b2018-10-23 17:10:41 +11002694 exit(OpenSSL_version_num() == OPENSSL_VERSION_NUMBER ? 0 : 1);
Damien Miller72ef7c12015-01-15 02:21:31 +11002695 ]])],
2696 [
2697 AC_MSG_RESULT([yes])
2698 ],
2699 [
2700 AC_MSG_RESULT([no])
2701 if test "x$openssl_check_nonfatal" = "x"; then
2702 AC_MSG_ERROR([Your OpenSSL headers do not match your
2703 library. Check config.log for details.
2704 If you are sure your installation is consistent, you can disable the check
2705 by running "./configure --without-openssl-header-check".
2706 Also see contrib/findssl.sh for help identifying header/library mismatches.
2707 ])
2708 else
2709 AC_MSG_WARN([Your OpenSSL headers do not match your
2710 library. Check config.log for details.
2711 Also see contrib/findssl.sh for help identifying header/library mismatches.])
2712 fi
2713 ],
2714 [
2715 AC_MSG_WARN([cross compiling: not checking])
2716 ]
2717 )
2718
2719 AC_MSG_CHECKING([if programs using OpenSSL functions will link])
2720 AC_LINK_IFELSE(
Damien Miller42c5ec42018-11-23 10:40:06 +11002721 [AC_LANG_PROGRAM([[ #include <openssl/err.h> ]],
2722 [[ ERR_load_crypto_strings(); ]])],
Damien Miller72ef7c12015-01-15 02:21:31 +11002723 [
2724 AC_MSG_RESULT([yes])
2725 ],
2726 [
2727 AC_MSG_RESULT([no])
2728 saved_LIBS="$LIBS"
2729 LIBS="$LIBS -ldl"
2730 AC_MSG_CHECKING([if programs using OpenSSL need -ldl])
2731 AC_LINK_IFELSE(
Damien Miller42c5ec42018-11-23 10:40:06 +11002732 [AC_LANG_PROGRAM([[ #include <openssl/err.h> ]],
2733 [[ ERR_load_crypto_strings(); ]])],
Damien Miller72ef7c12015-01-15 02:21:31 +11002734 [
2735 AC_MSG_RESULT([yes])
2736 ],
2737 [
2738 AC_MSG_RESULT([no])
2739 LIBS="$saved_LIBS"
2740 ]
2741 )
2742 ]
2743 )
2744
2745 AC_CHECK_FUNCS([ \
2746 BN_is_prime_ex \
2747 DSA_generate_parameters_ex \
Damien Miller42c5ec42018-11-23 10:40:06 +11002748 EVP_CIPHER_CTX_ctrl \
Damien Miller72ef7c12015-01-15 02:21:31 +11002749 EVP_DigestFinal_ex \
Damien Miller42c5ec42018-11-23 10:40:06 +11002750 EVP_DigestInit_ex \
Damien Miller72ef7c12015-01-15 02:21:31 +11002751 EVP_MD_CTX_cleanup \
2752 EVP_MD_CTX_copy_ex \
Damien Miller42c5ec42018-11-23 10:40:06 +11002753 EVP_MD_CTX_init \
Damien Miller72ef7c12015-01-15 02:21:31 +11002754 HMAC_CTX_init \
2755 RSA_generate_key_ex \
2756 RSA_get_default_method \
Darren Tucker1801cd12018-11-08 15:03:11 +11002757 ])
Darren Tucker98f878d2018-11-25 14:05:08 +11002758
2759 # OpenSSL_add_all_algorithms may be a macro.
2760 AC_CHECK_FUNC(OpenSSL_add_all_algorithms,
2761 AC_DEFINE(HAVE_OPENSSL_ADD_ALL_ALGORITHMS, 1, [as a function]),
2762 AC_CHECK_DECL(OpenSSL_add_all_algorithms,
2763 AC_DEFINE(HAVE_OPENSSL_ADD_ALL_ALGORITHMS, 1, [as a macro]), ,
2764 [[#include <openssl/evp.h>]]
2765 )
2766 )
2767
Darren Tucker1801cd12018-11-08 15:03:11 +11002768 # LibreSSL/OpenSSL 1.1x API
2769 AC_CHECK_FUNCS([ \
Darren Tuckerd0d1dfa2018-11-16 14:11:44 +11002770 OPENSSL_init_crypto \
Darren Tucker1801cd12018-11-08 15:03:11 +11002771 DH_get0_key \
2772 DH_get0_pqg \
2773 DH_set0_key \
2774 DH_set_length \
2775 DH_set0_pqg \
2776 DSA_get0_key \
2777 DSA_get0_pqg \
2778 DSA_set0_key \
2779 DSA_set0_pqg \
2780 DSA_SIG_get0 \
2781 DSA_SIG_set0 \
2782 ECDSA_SIG_get0 \
2783 ECDSA_SIG_set0 \
2784 EVP_CIPHER_CTX_iv \
2785 EVP_CIPHER_CTX_iv_noconst \
2786 EVP_CIPHER_CTX_get_iv \
2787 EVP_CIPHER_CTX_set_iv \
2788 RSA_get0_crt_params \
2789 RSA_get0_factors \
2790 RSA_get0_key \
2791 RSA_set0_crt_params \
2792 RSA_set0_factors \
2793 RSA_set0_key \
2794 RSA_meth_free \
2795 RSA_meth_dup \
2796 RSA_meth_set1_name \
2797 RSA_meth_get_finish \
2798 RSA_meth_set_priv_enc \
2799 RSA_meth_set_priv_dec \
2800 RSA_meth_set_finish \
2801 EVP_PKEY_get0_RSA \
2802 EVP_MD_CTX_new \
2803 EVP_MD_CTX_free \
Damien Miller72ef7c12015-01-15 02:21:31 +11002804 ])
2805
2806 if test "x$openssl_engine" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08002807 AC_MSG_CHECKING([for OpenSSL ENGINE support])
2808 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller72ef7c12015-01-15 02:21:31 +11002809 #include <openssl/engine.h>
Tim Rice648f8762011-01-26 12:38:57 -08002810 ]], [[
Damien Miller72ef7c12015-01-15 02:21:31 +11002811 ENGINE_load_builtin_engines();
2812 ENGINE_register_all_complete();
Tim Rice648f8762011-01-26 12:38:57 -08002813 ]])],
2814 [ AC_MSG_RESULT([yes])
2815 AC_DEFINE([USE_OPENSSL_ENGINE], [1],
Darren Tuckerfabdb6c2006-02-20 20:17:35 +11002816 [Enable OpenSSL engine support])
Tim Rice648f8762011-01-26 12:38:57 -08002817 ], [ AC_MSG_ERROR([OpenSSL ENGINE support not found])
2818 ])
Damien Miller72ef7c12015-01-15 02:21:31 +11002819 fi
Darren Tuckerfabdb6c2006-02-20 20:17:35 +11002820
Damien Miller72ef7c12015-01-15 02:21:31 +11002821 # Check for OpenSSL without EVP_aes_{192,256}_cbc
2822 AC_MSG_CHECKING([whether OpenSSL has crippled AES support])
2823 AC_LINK_IFELSE(
Darren Tucker37bcef52013-11-09 18:39:25 +11002824 [AC_LANG_PROGRAM([[
Damien Miller72ef7c12015-01-15 02:21:31 +11002825 #include <string.h>
2826 #include <openssl/evp.h>
2827 ]], [[
2828 exit(EVP_aes_192_cbc() == NULL || EVP_aes_256_cbc() == NULL);
2829 ]])],
2830 [
2831 AC_MSG_RESULT([no])
2832 ],
2833 [
2834 AC_MSG_RESULT([yes])
2835 AC_DEFINE([OPENSSL_LOBOTOMISED_AES], [1],
2836 [libcrypto is missing AES 192 and 256 bit functions])
2837 ]
2838 )
2839
2840 # Check for OpenSSL with EVP_aes_*ctr
2841 AC_MSG_CHECKING([whether OpenSSL has AES CTR via EVP])
2842 AC_LINK_IFELSE(
2843 [AC_LANG_PROGRAM([[
2844 #include <string.h>
2845 #include <openssl/evp.h>
2846 ]], [[
2847 exit(EVP_aes_128_ctr() == NULL ||
2848 EVP_aes_192_cbc() == NULL ||
2849 EVP_aes_256_cbc() == NULL);
2850 ]])],
2851 [
2852 AC_MSG_RESULT([yes])
2853 AC_DEFINE([OPENSSL_HAVE_EVPCTR], [1],
2854 [libcrypto has EVP AES CTR])
2855 ],
2856 [
2857 AC_MSG_RESULT([no])
2858 ]
2859 )
2860
2861 # Check for OpenSSL with EVP_aes_*gcm
2862 AC_MSG_CHECKING([whether OpenSSL has AES GCM via EVP])
2863 AC_LINK_IFELSE(
2864 [AC_LANG_PROGRAM([[
2865 #include <string.h>
2866 #include <openssl/evp.h>
2867 ]], [[
2868 exit(EVP_aes_128_gcm() == NULL ||
2869 EVP_aes_256_gcm() == NULL ||
2870 EVP_CTRL_GCM_SET_IV_FIXED == 0 ||
2871 EVP_CTRL_GCM_IV_GEN == 0 ||
2872 EVP_CTRL_GCM_SET_TAG == 0 ||
2873 EVP_CTRL_GCM_GET_TAG == 0 ||
2874 EVP_CIPHER_CTX_ctrl(NULL, 0, 0, NULL) == 0);
2875 ]])],
2876 [
2877 AC_MSG_RESULT([yes])
2878 AC_DEFINE([OPENSSL_HAVE_EVPGCM], [1],
2879 [libcrypto has EVP AES GCM])
2880 ],
2881 [
2882 AC_MSG_RESULT([no])
2883 unsupported_algorithms="$unsupported_cipers \
Damien Miller679ce882016-07-15 13:44:38 +10002884 aes128-gcm@openssh.com \
2885 aes256-gcm@openssh.com"
Damien Miller72ef7c12015-01-15 02:21:31 +11002886 ]
2887 )
2888
Damien Miller72ef7c12015-01-15 02:21:31 +11002889 AC_MSG_CHECKING([if EVP_DigestUpdate returns an int])
2890 AC_LINK_IFELSE(
2891 [AC_LANG_PROGRAM([[
2892 #include <string.h>
2893 #include <openssl/evp.h>
2894 ]], [[
2895 if(EVP_DigestUpdate(NULL, NULL,0))
2896 exit(0);
2897 ]])],
2898 [
2899 AC_MSG_RESULT([yes])
2900 ],
2901 [
2902 AC_MSG_RESULT([no])
2903 AC_DEFINE([OPENSSL_EVP_DIGESTUPDATE_VOID], [1],
2904 [Define if EVP_DigestUpdate returns void])
2905 ]
2906 )
2907
2908 # Some systems want crypt() from libcrypt, *not* the version in OpenSSL,
2909 # because the system crypt() is more featureful.
2910 if test "x$check_for_libcrypt_before" = "x1"; then
2911 AC_CHECK_LIB([crypt], [crypt])
2912 fi
2913
2914 # Some Linux systems (Slackware) need crypt() from libcrypt, *not* the
2915 # version in OpenSSL.
2916 if test "x$check_for_libcrypt_later" = "x1"; then
2917 AC_CHECK_LIB([crypt], [crypt], [LIBS="$LIBS -lcrypt"])
2918 fi
Damien Miller00797e82015-03-04 05:02:45 +11002919 AC_CHECK_FUNCS([crypt DES_crypt])
Damien Miller72ef7c12015-01-15 02:21:31 +11002920
Darren Tucker11cba2a2019-07-23 21:51:22 +10002921 # Check for SHA256, SHA384 and SHA512 support in OpenSSL
2922 AC_CHECK_FUNCS([EVP_sha256 EVP_sha384 EVP_sha512])
2923
Damien Miller72ef7c12015-01-15 02:21:31 +11002924 # Check complete ECC support in OpenSSL
2925 AC_MSG_CHECKING([whether OpenSSL has NID_X9_62_prime256v1])
2926 AC_LINK_IFELSE(
2927 [AC_LANG_PROGRAM([[
2928 #include <openssl/ec.h>
2929 #include <openssl/ecdh.h>
2930 #include <openssl/ecdsa.h>
2931 #include <openssl/evp.h>
2932 #include <openssl/objects.h>
2933 #include <openssl/opensslv.h>
Damien Miller72ef7c12015-01-15 02:21:31 +11002934 ]], [[
2935 EC_KEY *e = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
2936 const EVP_MD *m = EVP_sha256(); /* We need this too */
Darren Tucker37bcef52013-11-09 18:39:25 +11002937 ]])],
2938 [ AC_MSG_RESULT([yes])
Damien Miller72ef7c12015-01-15 02:21:31 +11002939 enable_nistp256=1 ],
2940 [ AC_MSG_RESULT([no]) ]
2941 )
Darren Tucker37bcef52013-11-09 18:39:25 +11002942
Damien Miller72ef7c12015-01-15 02:21:31 +11002943 AC_MSG_CHECKING([whether OpenSSL has NID_secp384r1])
2944 AC_LINK_IFELSE(
2945 [AC_LANG_PROGRAM([[
2946 #include <openssl/ec.h>
2947 #include <openssl/ecdh.h>
2948 #include <openssl/ecdsa.h>
2949 #include <openssl/evp.h>
2950 #include <openssl/objects.h>
2951 #include <openssl/opensslv.h>
Damien Miller72ef7c12015-01-15 02:21:31 +11002952 ]], [[
2953 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp384r1);
2954 const EVP_MD *m = EVP_sha384(); /* We need this too */
2955 ]])],
2956 [ AC_MSG_RESULT([yes])
2957 enable_nistp384=1 ],
2958 [ AC_MSG_RESULT([no]) ]
2959 )
Darren Tucker37bcef52013-11-09 18:39:25 +11002960
Damien Miller72ef7c12015-01-15 02:21:31 +11002961 AC_MSG_CHECKING([whether OpenSSL has NID_secp521r1])
2962 AC_LINK_IFELSE(
2963 [AC_LANG_PROGRAM([[
2964 #include <openssl/ec.h>
2965 #include <openssl/ecdh.h>
2966 #include <openssl/ecdsa.h>
2967 #include <openssl/evp.h>
2968 #include <openssl/objects.h>
2969 #include <openssl/opensslv.h>
Damien Miller72ef7c12015-01-15 02:21:31 +11002970 ]], [[
2971 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1);
2972 const EVP_MD *m = EVP_sha512(); /* We need this too */
2973 ]])],
2974 [ AC_MSG_RESULT([yes])
2975 AC_MSG_CHECKING([if OpenSSL's NID_secp521r1 is functional])
2976 AC_RUN_IFELSE(
2977 [AC_LANG_PROGRAM([[
2978 #include <openssl/ec.h>
2979 #include <openssl/ecdh.h>
2980 #include <openssl/ecdsa.h>
2981 #include <openssl/evp.h>
2982 #include <openssl/objects.h>
2983 #include <openssl/opensslv.h>
2984 ]],[[
2985 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1);
2986 const EVP_MD *m = EVP_sha512(); /* We need this too */
2987 exit(e == NULL || m == NULL);
2988 ]])],
2989 [ AC_MSG_RESULT([yes])
2990 enable_nistp521=1 ],
2991 [ AC_MSG_RESULT([no]) ],
2992 [ AC_MSG_WARN([cross-compiling: assuming yes])
2993 enable_nistp521=1 ]
2994 )],
2995 AC_MSG_RESULT([no])
2996 )
Darren Tucker37bcef52013-11-09 18:39:25 +11002997
Damien Miller72ef7c12015-01-15 02:21:31 +11002998 COMMENT_OUT_ECC="#no ecc#"
2999 TEST_SSH_ECC=no
3000
3001 if test x$enable_nistp256 = x1 || test x$enable_nistp384 = x1 || \
3002 test x$enable_nistp521 = x1; then
3003 AC_DEFINE(OPENSSL_HAS_ECC, [1], [OpenSSL has ECC])
Damien Millere2cb4452019-01-21 11:32:28 +11003004 AC_CHECK_FUNCS([EC_KEY_METHOD_new])
Darren Tuckerf5cc5812019-11-02 16:39:38 +11003005 openssl_ecc=yes
3006 else
3007 openssl_ecc=no
Damien Miller72ef7c12015-01-15 02:21:31 +11003008 fi
3009 if test x$enable_nistp256 = x1; then
3010 AC_DEFINE([OPENSSL_HAS_NISTP256], [1],
3011 [libcrypto has NID_X9_62_prime256v1])
3012 TEST_SSH_ECC=yes
3013 COMMENT_OUT_ECC=""
3014 else
Damien Miller679ce882016-07-15 13:44:38 +10003015 unsupported_algorithms="$unsupported_algorithms \
3016 ecdsa-sha2-nistp256 \
3017 ecdh-sha2-nistp256 \
3018 ecdsa-sha2-nistp256-cert-v01@openssh.com"
Damien Miller72ef7c12015-01-15 02:21:31 +11003019 fi
3020 if test x$enable_nistp384 = x1; then
3021 AC_DEFINE([OPENSSL_HAS_NISTP384], [1], [libcrypto has NID_secp384r1])
3022 TEST_SSH_ECC=yes
3023 COMMENT_OUT_ECC=""
3024 else
Damien Miller679ce882016-07-15 13:44:38 +10003025 unsupported_algorithms="$unsupported_algorithms \
3026 ecdsa-sha2-nistp384 \
3027 ecdh-sha2-nistp384 \
3028 ecdsa-sha2-nistp384-cert-v01@openssh.com"
Damien Miller72ef7c12015-01-15 02:21:31 +11003029 fi
3030 if test x$enable_nistp521 = x1; then
3031 AC_DEFINE([OPENSSL_HAS_NISTP521], [1], [libcrypto has NID_secp521r1])
3032 TEST_SSH_ECC=yes
3033 COMMENT_OUT_ECC=""
3034 else
Damien Miller679ce882016-07-15 13:44:38 +10003035 unsupported_algorithms="$unsupported_algorithms \
3036 ecdh-sha2-nistp521 \
3037 ecdsa-sha2-nistp521 \
3038 ecdsa-sha2-nistp521-cert-v01@openssh.com"
Damien Miller72ef7c12015-01-15 02:21:31 +11003039 fi
3040
3041 AC_SUBST([TEST_SSH_ECC])
3042 AC_SUBST([COMMENT_OUT_ECC])
3043else
3044 AC_CHECK_LIB([crypt], [crypt], [LIBS="$LIBS -lcrypt"])
Damien Miller00797e82015-03-04 05:02:45 +11003045 AC_CHECK_FUNCS([crypt])
Damien Miller72ef7c12015-01-15 02:21:31 +11003046fi
Damien Miller6af914a2010-09-10 11:39:26 +10003047
Darren Tuckerf5cc5812019-11-02 16:39:38 +11003048# PKCS11/U2F depend on OpenSSL and dlopen().
3049enable_pkcs11=yes
3050enable_sk=yes
3051if test "x$openssl" != "xyes" ; then
3052 enable_pkcs11="disabled; missing libcrypto"
3053 enable_sk="disabled; missing libcrypto"
3054fi
3055if test "x$openssl_ecc" != "xyes" ; then
3056 enable_sk="disabled; OpenSSL has no ECC support"
3057fi
3058if test "x$ac_cv_func_dlopen" != "xyes" ; then
3059 enable_pkcs11="disabled; missing dlopen(3)"
3060 enable_sk="disabled; missing dlopen(3)"
3061fi
3062if test "x$ac_cv_have_decl_RTLD_NOW" != "xyes" ; then
3063 enable_pkcs11="disabled; missing RTLD_NOW"
3064 enable_sk="disabled; missing RTLD_NOW"
3065fi
3066if test ! -z "$disable_pkcs11" ; then
3067 enable_pkcs11="disabled by user"
3068fi
3069if test ! -z "$disable_sk" ; then
3070 enable_sk="disabled by user"
3071fi
3072
3073AC_MSG_CHECKING([whether to enable PKCS11])
3074if test "x$enable_pkcs11" = "xyes" ; then
3075 AC_DEFINE([ENABLE_PKCS11], [], [Enable for PKCS#11 support])
3076fi
3077AC_MSG_RESULT([$enable_pkcs11])
3078
3079AC_MSG_CHECKING([whether to enable U2F])
3080if test "x$enable_sk" = "xyes" ; then
3081 AC_DEFINE([ENABLE_SK], [], [Enable for U2F/FIDO support])
3082fi
3083AC_MSG_RESULT([$enable_sk])
3084
djm@openbsd.org6bff9522019-11-14 21:27:29 +00003085# Now check for built-in security key support.
Damien Miller5c0bc272019-11-15 16:08:00 +11003086if test "x$enable_sk" = "xyes" -a "x$enable_sk_internal" = "xyes" ; then
djm@openbsd.org6bff9522019-11-14 21:27:29 +00003087 AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no])
3088 use_pkgconfig_for_libfido2=
3089 if test "x$PKGCONFIG" != "xno"; then
3090 AC_MSG_CHECKING([if $PKGCONFIG knows about libfido2])
3091 if "$PKGCONFIG" libfido2; then
3092 AC_MSG_RESULT([yes])
3093 use_pkgconfig_for_libfido2=yes
3094 else
3095 AC_MSG_RESULT([no])
3096 fi
3097 fi
3098 if test "x$use_pkgconfig_for_libfido2" = "xyes"; then
3099 LIBFIDO2=`$PKGCONFIG --libs libfido2`
3100 CPPFLAGS="$CPPFLAGS `$PKGCONFIG --cflags libfido2`"
3101 else
3102 LIBFIDO2="-lfido2 -lcbor"
3103 fi
3104 OTHERLIBS=`echo $LIBFIDO2 | sed 's/-lfido2//'`
3105 AC_CHECK_LIB([fido2], [fido_init],
3106 [
djm@openbsd.org6bff9522019-11-14 21:27:29 +00003107 AC_SUBST([LIBFIDO2])
3108 AC_DEFINE([ENABLE_SK_INTERNAL], [],
3109 [Enable for built-in U2F/FIDO support])
3110 enable_sk="built-in"
Damien Miller63a5b242019-11-15 11:21:26 +11003111 ], [ ],
djm@openbsd.org6bff9522019-11-14 21:27:29 +00003112 [ $OTHERLIBS ]
3113 )
3114fi
3115
Damien Miller00f9cd22014-07-15 10:41:38 +10003116AC_CHECK_FUNCS([ \
3117 arc4random \
3118 arc4random_buf \
3119 arc4random_stir \
3120 arc4random_uniform \
3121])
3122
Tim Rice99203ec2007-03-26 09:35:28 -07003123saved_LIBS="$LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08003124AC_CHECK_LIB([iaf], [ia_openinfo], [
Tim Rice99203ec2007-03-26 09:35:28 -07003125 LIBS="$LIBS -liaf"
Tim Rice648f8762011-01-26 12:38:57 -08003126 AC_CHECK_FUNCS([set_id], [SSHDLIBS="$SSHDLIBS -liaf"
3127 AC_DEFINE([HAVE_LIBIAF], [1],
Tim Ricee1d93702016-05-31 11:13:22 -07003128 [Define if system has libiaf that supports set_id])
Tim Rice0eeaf122007-09-10 16:24:17 -07003129 ])
Tim Rice99203ec2007-03-26 09:35:28 -07003130])
3131LIBS="$saved_LIBS"
Damien Miller6c21c512002-01-22 21:57:53 +11003132
3133### Configure cryptographic random number support
3134
Damien Miller10479cc2018-04-10 10:19:02 +10003135# Check whether OpenSSL seeds itself
Damien Miller72ef7c12015-01-15 02:21:31 +11003136if test "x$openssl" = "xyes" ; then
3137 AC_MSG_CHECKING([whether OpenSSL's PRNG is internally seeded])
3138 AC_RUN_IFELSE(
3139 [AC_LANG_PROGRAM([[
3140 #include <string.h>
3141 #include <openssl/rand.h>
3142 ]], [[
3143 exit(RAND_status() == 1 ? 0 : 1);
3144 ]])],
3145 [
3146 OPENSSL_SEEDS_ITSELF=yes
3147 AC_MSG_RESULT([yes])
3148 ],
3149 [
3150 AC_MSG_RESULT([no])
3151 ],
3152 [
3153 AC_MSG_WARN([cross compiling: assuming yes])
3154 # This is safe, since we will fatal() at runtime if
3155 # OpenSSL is not seeded correctly.
3156 OPENSSL_SEEDS_ITSELF=yes
3157 ]
3158 )
3159fi
Damien Miller6c21c512002-01-22 21:57:53 +11003160
Damien Millerf22019b2011-05-05 13:48:37 +10003161# PRNGD TCP socket
3162AC_ARG_WITH([prngd-port],
3163 [ --with-prngd-port=PORT read entropy from PRNGD/EGD TCP localhost:PORT],
3164 [
3165 case "$withval" in
3166 no)
3167 withval=""
3168 ;;
3169 [[0-9]]*)
3170 ;;
3171 *)
3172 AC_MSG_ERROR([You must specify a numeric port number for --with-prngd-port])
3173 ;;
3174 esac
3175 if test ! -z "$withval" ; then
3176 PRNGD_PORT="$withval"
3177 AC_DEFINE_UNQUOTED([PRNGD_PORT], [$PRNGD_PORT],
3178 [Port number of PRNGD/EGD random number socket])
3179 fi
3180 ]
3181)
3182
3183# PRNGD Unix domain socket
3184AC_ARG_WITH([prngd-socket],
3185 [ --with-prngd-socket=FILE read entropy from PRNGD/EGD socket FILE (default=/var/run/egd-pool)],
3186 [
3187 case "$withval" in
3188 yes)
3189 withval="/var/run/egd-pool"
3190 ;;
3191 no)
3192 withval=""
3193 ;;
3194 /*)
3195 ;;
3196 *)
3197 AC_MSG_ERROR([You must specify an absolute path to the entropy socket])
3198 ;;
3199 esac
3200
3201 if test ! -z "$withval" ; then
3202 if test ! -z "$PRNGD_PORT" ; then
3203 AC_MSG_ERROR([You may not specify both a PRNGD/EGD port and socket])
3204 fi
3205 if test ! -r "$withval" ; then
3206 AC_MSG_WARN([Entropy socket is not readable])
3207 fi
3208 PRNGD_SOCKET="$withval"
3209 AC_DEFINE_UNQUOTED([PRNGD_SOCKET], ["$PRNGD_SOCKET"],
3210 [Location of PRNGD/EGD random number socket])
3211 fi
3212 ],
3213 [
3214 # Check for existing socket only if we don't have a random device already
3215 if test "x$OPENSSL_SEEDS_ITSELF" != "xyes" ; then
3216 AC_MSG_CHECKING([for PRNGD/EGD socket])
3217 # Insert other locations here
3218 for sock in /var/run/egd-pool /dev/egd-pool /etc/entropy; do
3219 if test -r $sock && $TEST_MINUS_S_SH -c "test -S $sock -o -p $sock" ; then
3220 PRNGD_SOCKET="$sock"
3221 AC_DEFINE_UNQUOTED([PRNGD_SOCKET], ["$PRNGD_SOCKET"])
3222 break;
3223 fi
3224 done
3225 if test ! -z "$PRNGD_SOCKET" ; then
3226 AC_MSG_RESULT([$PRNGD_SOCKET])
3227 else
3228 AC_MSG_RESULT([not found])
3229 fi
3230 fi
3231 ]
3232)
3233
3234# Which randomness source do we use?
3235if test ! -z "$PRNGD_PORT" ; then
3236 RAND_MSG="PRNGd port $PRNGD_PORT"
3237elif test ! -z "$PRNGD_SOCKET" ; then
3238 RAND_MSG="PRNGd socket $PRNGD_SOCKET"
3239elif test ! -z "$OPENSSL_SEEDS_ITSELF" ; then
3240 AC_DEFINE([OPENSSL_PRNG_ONLY], [1],
Damien Miller72ef7c12015-01-15 02:21:31 +11003241 [Define if you want the OpenSSL internally seeded PRNG only])
Damien Millerf22019b2011-05-05 13:48:37 +10003242 RAND_MSG="OpenSSL internal ONLY"
Damien Miller72ef7c12015-01-15 02:21:31 +11003243elif test "x$openssl" = "xno" ; then
3244 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 +10003245else
3246 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])
3247fi
3248
Darren Tucker3e6bde42006-08-20 20:03:50 +10003249# Check for PAM libs
3250PAM_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08003251AC_ARG_WITH([pam],
Darren Tucker3e6bde42006-08-20 20:03:50 +10003252 [ --with-pam Enable PAM support ],
3253 [
3254 if test "x$withval" != "xno" ; then
3255 if test "x$ac_cv_header_security_pam_appl_h" != "xyes" && \
3256 test "x$ac_cv_header_pam_pam_appl_h" != "xyes" ; then
3257 AC_MSG_ERROR([PAM headers not found])
3258 fi
3259
3260 saved_LIBS="$LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08003261 AC_CHECK_LIB([dl], [dlopen], , )
3262 AC_CHECK_LIB([pam], [pam_set_item], , [AC_MSG_ERROR([*** libpam missing])])
3263 AC_CHECK_FUNCS([pam_getenvlist])
3264 AC_CHECK_FUNCS([pam_putenv])
Darren Tucker3e6bde42006-08-20 20:03:50 +10003265 LIBS="$saved_LIBS"
3266
3267 PAM_MSG="yes"
3268
Darren Tucker20e9f972007-03-25 18:26:01 +10003269 SSHDLIBS="$SSHDLIBS -lpam"
Tim Rice648f8762011-01-26 12:38:57 -08003270 AC_DEFINE([USE_PAM], [1],
Darren Tucker3e6bde42006-08-20 20:03:50 +10003271 [Define if you want to enable PAM support])
Darren Tucker639bbe82006-08-20 20:17:53 +10003272
Darren Tucker3e6bde42006-08-20 20:03:50 +10003273 if test $ac_cv_lib_dl_dlopen = yes; then
Darren Tucker639bbe82006-08-20 20:17:53 +10003274 case "$LIBS" in
3275 *-ldl*)
3276 # libdl already in LIBS
3277 ;;
3278 *)
Darren Tucker20e9f972007-03-25 18:26:01 +10003279 SSHDLIBS="$SSHDLIBS -ldl"
Darren Tucker639bbe82006-08-20 20:17:53 +10003280 ;;
3281 esac
Darren Tucker3e6bde42006-08-20 20:03:50 +10003282 fi
Darren Tucker3e6bde42006-08-20 20:03:50 +10003283 fi
3284 ]
3285)
3286
Damien Miller8bd81e12016-08-16 13:30:56 +10003287AC_ARG_WITH([pam-service],
3288 [ --with-pam-service=name Specify PAM service name ],
3289 [
3290 if test "x$withval" != "xno" && \
3291 test "x$withval" != "xyes" ; then
3292 AC_DEFINE_UNQUOTED([SSHD_PAM_SERVICE],
3293 ["$withval"], [sshd PAM service name])
3294 fi
3295 ]
3296)
3297
Darren Tucker3e6bde42006-08-20 20:03:50 +10003298# Check for older PAM
3299if test "x$PAM_MSG" = "xyes" ; then
3300 # Check PAM strerror arguments (old PAM)
3301 AC_MSG_CHECKING([whether pam_strerror takes only one argument])
Tim Rice648f8762011-01-26 12:38:57 -08003302 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker3e6bde42006-08-20 20:03:50 +10003303#include <stdlib.h>
3304#if defined(HAVE_SECURITY_PAM_APPL_H)
3305#include <security/pam_appl.h>
3306#elif defined (HAVE_PAM_PAM_APPL_H)
3307#include <pam/pam_appl.h>
3308#endif
Tim Rice648f8762011-01-26 12:38:57 -08003309 ]], [[
3310(void)pam_strerror((pam_handle_t *)NULL, -1);
3311 ]])], [AC_MSG_RESULT([no])], [
3312 AC_DEFINE([HAVE_OLD_PAM], [1],
Darren Tucker3e6bde42006-08-20 20:03:50 +10003313 [Define if you have an old version of PAM
3314 which takes only one argument to pam_strerror])
Tim Rice648f8762011-01-26 12:38:57 -08003315 AC_MSG_RESULT([yes])
Darren Tucker3e6bde42006-08-20 20:03:50 +10003316 PAM_MSG="yes (old library)"
Damien Miller72ef7c12015-01-15 02:21:31 +11003317
Tim Rice648f8762011-01-26 12:38:57 -08003318 ])
Darren Tucker3e6bde42006-08-20 20:03:50 +10003319fi
Damien Miller6c21c512002-01-22 21:57:53 +11003320
Damien Miller6482d902014-05-27 14:34:42 +10003321case "$host" in
3322*-*-cygwin*)
3323 SSH_PRIVSEP_USER=CYGWIN_SSH_PRIVSEP_USER
3324 ;;
3325*)
3326 SSH_PRIVSEP_USER=sshd
3327 ;;
3328esac
Tim Rice648f8762011-01-26 12:38:57 -08003329AC_ARG_WITH([privsep-user],
Kevin Stevesc81e1292002-05-13 03:51:40 +00003330 [ --with-privsep-user=user Specify non-privileged user for privilege separation],
Kevin Steves7ff91122002-04-07 19:22:54 +00003331 [
Tim Rice35cc69d2005-03-17 16:44:25 -08003332 if test -n "$withval" && test "x$withval" != "xno" && \
3333 test "x${withval}" != "xyes"; then
Damien Millerd3f6ad22002-06-25 10:24:47 +10003334 SSH_PRIVSEP_USER=$withval
Kevin Steves7ff91122002-04-07 19:22:54 +00003335 fi
Tim Riceeae17cc2005-03-17 16:52:20 -08003336 ]
Kevin Steves7ff91122002-04-07 19:22:54 +00003337)
Damien Miller6482d902014-05-27 14:34:42 +10003338if test "x$SSH_PRIVSEP_USER" = "xCYGWIN_SSH_PRIVSEP_USER" ; then
3339 AC_DEFINE_UNQUOTED([SSH_PRIVSEP_USER], [CYGWIN_SSH_PRIVSEP_USER],
3340 [Cygwin function to fetch non-privileged user for privilege separation])
3341else
3342 AC_DEFINE_UNQUOTED([SSH_PRIVSEP_USER], ["$SSH_PRIVSEP_USER"],
3343 [non-privileged user for privilege separation])
3344fi
Tim Rice648f8762011-01-26 12:38:57 -08003345AC_SUBST([SSH_PRIVSEP_USER])
Kevin Steves7ff91122002-04-07 19:22:54 +00003346
Damien Miller91f40d82013-02-22 11:37:00 +11003347if test "x$have_linux_no_new_privs" = "x1" ; then
3348AC_CHECK_DECL([SECCOMP_MODE_FILTER], [have_seccomp_filter=1], , [
3349 #include <sys/types.h>
3350 #include <linux/seccomp.h>
3351])
3352fi
3353if test "x$have_seccomp_filter" = "x1" ; then
3354AC_MSG_CHECKING([kernel for seccomp_filter support])
3355AC_LINK_IFELSE([AC_LANG_PROGRAM([[
3356 #include <errno.h>
3357 #include <elf.h>
3358 #include <linux/audit.h>
3359 #include <linux/seccomp.h>
3360 #include <stdlib.h>
3361 #include <sys/prctl.h>
3362 ]],
3363 [[ int i = $seccomp_audit_arch;
3364 errno = 0;
3365 prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, NULL, 0, 0);
3366 exit(errno == EFAULT ? 0 : 1); ]])],
3367 [ AC_MSG_RESULT([yes]) ], [
3368 AC_MSG_RESULT([no])
3369 # Disable seccomp filter as a target
3370 have_seccomp_filter=0
3371 ]
3372)
3373fi
3374
Damien Miller69ff1df2011-06-23 08:30:03 +10003375# Decide which sandbox style to use
3376sandbox_arg=""
3377AC_ARG_WITH([sandbox],
deraadt@openbsd.org2539dce2015-10-09 01:37:08 +00003378 [ --with-sandbox=style Specify privilege separation sandbox (no, capsicum, darwin, rlimit, seccomp_filter, systrace, pledge)],
Damien Miller69ff1df2011-06-23 08:30:03 +10003379 [
3380 if test "x$withval" = "xyes" ; then
3381 sandbox_arg=""
3382 else
3383 sandbox_arg="$withval"
3384 fi
3385 ]
3386)
Darren Tucker60395f92012-07-03 14:31:18 +10003387
3388# Some platforms (seems to be the ones that have a kernel poll(2)-type
3389# function with which they implement select(2)) use an extra file descriptor
3390# when calling select(2), which means we can't use the rlimit sandbox.
3391AC_MSG_CHECKING([if select works with descriptor rlimit])
3392AC_RUN_IFELSE(
3393 [AC_LANG_PROGRAM([[
3394#include <sys/types.h>
3395#ifdef HAVE_SYS_TIME_H
3396# include <sys/time.h>
3397#endif
3398#include <sys/resource.h>
3399#ifdef HAVE_SYS_SELECT_H
3400# include <sys/select.h>
3401#endif
3402#include <errno.h>
3403#include <fcntl.h>
3404#include <stdlib.h>
3405 ]],[[
3406 struct rlimit rl_zero;
3407 int fd, r;
3408 fd_set fds;
Damien Millere4f43472013-03-08 12:14:22 +11003409 struct timeval tv;
Darren Tucker60395f92012-07-03 14:31:18 +10003410
3411 fd = open("/dev/null", O_RDONLY);
3412 FD_ZERO(&fds);
3413 FD_SET(fd, &fds);
3414 rl_zero.rlim_cur = rl_zero.rlim_max = 0;
3415 setrlimit(RLIMIT_FSIZE, &rl_zero);
3416 setrlimit(RLIMIT_NOFILE, &rl_zero);
Damien Millere4f43472013-03-08 12:14:22 +11003417 tv.tv_sec = 1;
3418 tv.tv_usec = 0;
3419 r = select(fd+1, &fds, NULL, NULL, &tv);
Darren Tucker60395f92012-07-03 14:31:18 +10003420 exit (r == -1 ? 1 : 0);
3421 ]])],
3422 [AC_MSG_RESULT([yes])
3423 select_works_with_rlimit=yes],
3424 [AC_MSG_RESULT([no])
3425 select_works_with_rlimit=no],
Mike Frysingerdcc714c2017-05-24 23:21:19 -04003426 [AC_MSG_WARN([cross compiling: assuming yes])
3427 select_works_with_rlimit=yes]
Darren Tucker60395f92012-07-03 14:31:18 +10003428)
3429
Darren Tuckerff008de2013-03-06 17:48:48 +11003430AC_MSG_CHECKING([if setrlimit(RLIMIT_NOFILE,{0,0}) works])
3431AC_RUN_IFELSE(
3432 [AC_LANG_PROGRAM([[
3433#include <sys/types.h>
3434#ifdef HAVE_SYS_TIME_H
3435# include <sys/time.h>
3436#endif
3437#include <sys/resource.h>
3438#include <errno.h>
3439#include <stdlib.h>
3440 ]],[[
3441 struct rlimit rl_zero;
Darren Tucker34e87fb2019-04-30 12:27:57 +10003442 int r;
Darren Tuckerff008de2013-03-06 17:48:48 +11003443
3444 rl_zero.rlim_cur = rl_zero.rlim_max = 0;
3445 r = setrlimit(RLIMIT_NOFILE, &rl_zero);
3446 exit (r == -1 ? 1 : 0);
3447 ]])],
3448 [AC_MSG_RESULT([yes])
3449 rlimit_nofile_zero_works=yes],
3450 [AC_MSG_RESULT([no])
3451 rlimit_nofile_zero_works=no],
Mike Frysingerdcc714c2017-05-24 23:21:19 -04003452 [AC_MSG_WARN([cross compiling: assuming yes])
3453 rlimit_nofile_zero_works=yes]
Darren Tuckerff008de2013-03-06 17:48:48 +11003454)
3455
Darren Tuckerd545a4b2012-07-03 22:48:31 +10003456AC_MSG_CHECKING([if setrlimit RLIMIT_FSIZE works])
3457AC_RUN_IFELSE(
3458 [AC_LANG_PROGRAM([[
3459#include <sys/types.h>
3460#include <sys/resource.h>
3461#include <stdlib.h>
3462 ]],[[
3463 struct rlimit rl_zero;
3464
3465 rl_zero.rlim_cur = rl_zero.rlim_max = 0;
3466 exit(setrlimit(RLIMIT_FSIZE, &rl_zero) != 0);
3467 ]])],
3468 [AC_MSG_RESULT([yes])],
3469 [AC_MSG_RESULT([no])
3470 AC_DEFINE(SANDBOX_SKIP_RLIMIT_FSIZE, 1,
3471 [setrlimit RLIMIT_FSIZE works])],
3472 [AC_MSG_WARN([cross compiling: assuming yes])]
3473)
3474
deraadt@openbsd.org2539dce2015-10-09 01:37:08 +00003475if test "x$sandbox_arg" = "xpledge" || \
3476 ( test -z "$sandbox_arg" && test "x$ac_cv_func_pledge" = "xyes" ) ; then
3477 test "x$ac_cv_func_pledge" != "xyes" && \
3478 AC_MSG_ERROR([pledge sandbox requires pledge(2) support])
3479 SANDBOX_STYLE="pledge"
Damien Millerfafe1d82015-10-14 09:22:15 -07003480 AC_DEFINE([SANDBOX_PLEDGE], [1], [Sandbox using pledge(2)])
Damien Miller9846a2f2015-10-08 04:30:48 +11003481elif test "x$sandbox_arg" = "xsystrace" || \
Damien Miller69ff1df2011-06-23 08:30:03 +10003482 ( test -z "$sandbox_arg" && test "x$have_systr_policy_kill" = "x1" ) ; then
Damien Miller1a91c0f2011-08-17 11:59:25 +10003483 test "x$have_systr_policy_kill" != "x1" && \
3484 AC_MSG_ERROR([systrace sandbox requires systrace headers and SYSTR_POLICY_KILL support])
Damien Miller69ff1df2011-06-23 08:30:03 +10003485 SANDBOX_STYLE="systrace"
3486 AC_DEFINE([SANDBOX_SYSTRACE], [1], [Sandbox using systrace(4)])
Damien Millercd5e52e2011-06-27 07:18:18 +10003487elif test "x$sandbox_arg" = "xdarwin" || \
3488 ( test -z "$sandbox_arg" && test "x$ac_cv_func_sandbox_init" = "xyes" && \
3489 test "x$ac_cv_header_sandbox_h" = "xyes") ; then
Damien Miller1a91c0f2011-08-17 11:59:25 +10003490 test "x$ac_cv_func_sandbox_init" != "xyes" -o \
3491 "x$ac_cv_header_sandbox_h" != "xyes" && \
3492 AC_MSG_ERROR([Darwin seatbelt sandbox requires sandbox.h and sandbox_init function])
Damien Millercd5e52e2011-06-27 07:18:18 +10003493 SANDBOX_STYLE="darwin"
3494 AC_DEFINE([SANDBOX_DARWIN], [1], [Sandbox using Darwin sandbox_init(3)])
Damien Millere0956e32012-04-04 11:27:54 +10003495elif test "x$sandbox_arg" = "xseccomp_filter" || \
3496 ( test -z "$sandbox_arg" && \
Darren Tuckerd0494fd2012-05-19 14:25:39 +10003497 test "x$have_seccomp_filter" = "x1" && \
Damien Miller91f40d82013-02-22 11:37:00 +11003498 test "x$ac_cv_header_elf_h" = "xyes" && \
Damien Millere0956e32012-04-04 11:27:54 +10003499 test "x$ac_cv_header_linux_audit_h" = "xyes" && \
Damien Miller91f40d82013-02-22 11:37:00 +11003500 test "x$ac_cv_header_linux_filter_h" = "xyes" && \
3501 test "x$seccomp_audit_arch" != "x" && \
Damien Millere0956e32012-04-04 11:27:54 +10003502 test "x$have_linux_no_new_privs" = "x1" && \
3503 test "x$ac_cv_func_prctl" = "xyes" ) ; then
Damien Miller91f40d82013-02-22 11:37:00 +11003504 test "x$seccomp_audit_arch" = "x" && \
Damien Millere0956e32012-04-04 11:27:54 +10003505 AC_MSG_ERROR([seccomp_filter sandbox not supported on $host])
3506 test "x$have_linux_no_new_privs" != "x1" && \
3507 AC_MSG_ERROR([seccomp_filter sandbox requires PR_SET_NO_NEW_PRIVS])
3508 test "x$have_seccomp_filter" != "x1" && \
3509 AC_MSG_ERROR([seccomp_filter sandbox requires seccomp headers])
3510 test "x$ac_cv_func_prctl" != "xyes" && \
3511 AC_MSG_ERROR([seccomp_filter sandbox requires prctl function])
3512 SANDBOX_STYLE="seccomp_filter"
3513 AC_DEFINE([SANDBOX_SECCOMP_FILTER], [1], [Sandbox using seccomp filter])
Damien Millerf62ecef2014-01-25 12:34:38 +11003514elif test "x$sandbox_arg" = "xcapsicum" || \
3515 ( test -z "$sandbox_arg" && \
Darren Tuckerdd9d9b32017-08-28 16:48:27 +10003516 test "x$ac_cv_header_sys_capsicum_h" = "xyes" && \
Damien Miller603b8f42014-01-25 13:16:59 +11003517 test "x$ac_cv_func_cap_rights_limit" = "xyes") ; then
Darren Tuckerdd9d9b32017-08-28 16:48:27 +10003518 test "x$ac_cv_header_sys_capsicum_h" != "xyes" && \
3519 AC_MSG_ERROR([capsicum sandbox requires sys/capsicum.h header])
Damien Miller603b8f42014-01-25 13:16:59 +11003520 test "x$ac_cv_func_cap_rights_limit" != "xyes" && \
Damien Millerc96d8532014-01-25 13:12:28 +11003521 AC_MSG_ERROR([capsicum sandbox requires cap_rights_limit function])
Damien Millerf62ecef2014-01-25 12:34:38 +11003522 SANDBOX_STYLE="capsicum"
3523 AC_DEFINE([SANDBOX_CAPSICUM], [1], [Sandbox using capsicum])
Damien Miller69ff1df2011-06-23 08:30:03 +10003524elif test "x$sandbox_arg" = "xrlimit" || \
Darren Tucker60395f92012-07-03 14:31:18 +10003525 ( test -z "$sandbox_arg" && test "x$ac_cv_func_setrlimit" = "xyes" && \
Darren Tuckerff008de2013-03-06 17:48:48 +11003526 test "x$select_works_with_rlimit" = "xyes" && \
3527 test "x$rlimit_nofile_zero_works" = "xyes" ) ; then
Damien Miller1a91c0f2011-08-17 11:59:25 +10003528 test "x$ac_cv_func_setrlimit" != "xyes" && \
3529 AC_MSG_ERROR([rlimit sandbox requires setrlimit function])
Darren Tucker60395f92012-07-03 14:31:18 +10003530 test "x$select_works_with_rlimit" != "xyes" && \
3531 AC_MSG_ERROR([rlimit sandbox requires select to work with rlimit])
Damien Miller69ff1df2011-06-23 08:30:03 +10003532 SANDBOX_STYLE="rlimit"
3533 AC_DEFINE([SANDBOX_RLIMIT], [1], [Sandbox using setrlimit(2)])
Damien Miller4626cba2016-01-08 14:24:56 +11003534elif test "x$sandbox_arg" = "xsolaris" || \
3535 ( test -z "$sandbox_arg" && test "x$SOLARIS_PRIVS" = "xyes" ) ; then
3536 SANDBOX_STYLE="solaris"
3537 AC_DEFINE([SANDBOX_SOLARIS], [1], [Sandbox using Solaris/Illumos privileges])
Damien Miller69ff1df2011-06-23 08:30:03 +10003538elif test -z "$sandbox_arg" || test "x$sandbox_arg" = "xno" || \
3539 test "x$sandbox_arg" = "xnone" || test "x$sandbox_arg" = "xnull" ; then
3540 SANDBOX_STYLE="none"
3541 AC_DEFINE([SANDBOX_NULL], [1], [no privsep sandboxing])
3542else
Tim Ricea6e60612011-08-17 21:48:22 -07003543 AC_MSG_ERROR([unsupported --with-sandbox])
Damien Miller69ff1df2011-06-23 08:30:03 +10003544fi
3545
Ben Lindstromb5628642000-10-18 00:02:25 +00003546# Cheap hack to ensure NEWS-OS libraries are arranged right.
3547if test ! -z "$SONY" ; then
3548 LIBS="$LIBS -liberty";
3549fi
3550
Damien Miller57f39152005-11-24 19:58:19 +11003551# Check for long long datatypes
3552AC_CHECK_TYPES([long long, unsigned long long, long double])
3553
3554# Check datatype sizes
Dag-Erling Smørgravd0153c72018-10-09 23:03:40 +02003555AC_CHECK_SIZEOF([short int])
3556AC_CHECK_SIZEOF([int])
3557AC_CHECK_SIZEOF([long int])
3558AC_CHECK_SIZEOF([long long int])
Damien Millerc6398ef1999-11-20 12:18:40 +11003559
Damien Millerfa2bb692002-04-23 23:22:25 +10003560# Sanity check long long for some platforms (AIX)
3561if test "x$ac_cv_sizeof_long_long_int" = "x4" ; then
3562 ac_cv_sizeof_long_long_int=0
3563fi
3564
Darren Tucker537f1ed2005-10-25 18:38:33 +10003565# compute LLONG_MIN and LLONG_MAX if we don't know them.
3566if test -z "$have_llong_max"; then
3567 AC_MSG_CHECKING([for max value of long long])
3568 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08003569 [AC_LANG_PROGRAM([[
Darren Tucker537f1ed2005-10-25 18:38:33 +10003570#include <stdio.h>
3571/* Why is this so damn hard? */
3572#ifdef __GNUC__
3573# undef __GNUC__
3574#endif
3575#define __USE_ISOC99
3576#include <limits.h>
3577#define DATA "conftest.llminmax"
Darren Tuckerd1450db2006-03-13 19:06:51 +11003578#define my_abs(a) ((a) < 0 ? ((a) * -1) : (a))
3579
3580/*
3581 * printf in libc on some platforms (eg old Tru64) does not understand %lld so
3582 * we do this the hard way.
3583 */
3584static int
3585fprint_ll(FILE *f, long long n)
3586{
3587 unsigned int i;
3588 int l[sizeof(long long) * 8];
3589
3590 if (n < 0)
3591 if (fprintf(f, "-") < 0)
3592 return -1;
3593 for (i = 0; n != 0; i++) {
3594 l[i] = my_abs(n % 10);
3595 n /= 10;
3596 }
3597 do {
3598 if (fprintf(f, "%d", l[--i]) < 0)
3599 return -1;
3600 } while (i != 0);
3601 if (fprintf(f, " ") < 0)
3602 return -1;
3603 return 0;
3604}
Tim Rice648f8762011-01-26 12:38:57 -08003605 ]], [[
Darren Tucker537f1ed2005-10-25 18:38:33 +10003606 FILE *f;
3607 long long i, llmin, llmax = 0;
3608
3609 if((f = fopen(DATA,"w")) == NULL)
3610 exit(1);
3611
3612#if defined(LLONG_MIN) && defined(LLONG_MAX)
3613 fprintf(stderr, "Using system header for LLONG_MIN and LLONG_MAX\n");
3614 llmin = LLONG_MIN;
3615 llmax = LLONG_MAX;
3616#else
3617 fprintf(stderr, "Calculating LLONG_MIN and LLONG_MAX\n");
3618 /* This will work on one's complement and two's complement */
3619 for (i = 1; i > llmax; i <<= 1, i++)
3620 llmax = i;
3621 llmin = llmax + 1LL; /* wrap */
3622#endif
3623
3624 /* Sanity check */
3625 if (llmin + 1 < llmin || llmin - 1 < llmin || llmax + 1 > llmax
Darren Tuckerd1450db2006-03-13 19:06:51 +11003626 || llmax - 1 > llmax || llmin == llmax || llmin == 0
3627 || llmax == 0 || llmax < LONG_MAX || llmin > LONG_MIN) {
Darren Tucker537f1ed2005-10-25 18:38:33 +10003628 fprintf(f, "unknown unknown\n");
3629 exit(2);
3630 }
3631
Darren Tuckerd1450db2006-03-13 19:06:51 +11003632 if (fprint_ll(f, llmin) < 0)
Darren Tucker537f1ed2005-10-25 18:38:33 +10003633 exit(3);
Darren Tuckerd1450db2006-03-13 19:06:51 +11003634 if (fprint_ll(f, llmax) < 0)
3635 exit(4);
3636 if (fclose(f) < 0)
3637 exit(5);
Darren Tucker537f1ed2005-10-25 18:38:33 +10003638 exit(0);
Darren Tucker537f1ed2005-10-25 18:38:33 +10003639 ]])],
3640 [
3641 llong_min=`$AWK '{print $1}' conftest.llminmax`
3642 llong_max=`$AWK '{print $2}' conftest.llminmax`
3643
Tim Rice648f8762011-01-26 12:38:57 -08003644 AC_MSG_RESULT([$llong_max])
3645 AC_DEFINE_UNQUOTED([LLONG_MAX], [${llong_max}LL],
Darren Tucker537f1ed2005-10-25 18:38:33 +10003646 [max value of long long calculated by configure])
3647 AC_MSG_CHECKING([for min value of long long])
Tim Rice648f8762011-01-26 12:38:57 -08003648 AC_MSG_RESULT([$llong_min])
3649 AC_DEFINE_UNQUOTED([LLONG_MIN], [${llong_min}LL],
Darren Tucker537f1ed2005-10-25 18:38:33 +10003650 [min value of long long calculated by configure])
3651 ],
3652 [
Tim Rice648f8762011-01-26 12:38:57 -08003653 AC_MSG_RESULT([not found])
Darren Tucker537f1ed2005-10-25 18:38:33 +10003654 ],
3655 [
3656 AC_MSG_WARN([cross compiling: not checking])
3657 ]
3658 )
3659fi
3660
Darren Tucker29125962019-10-28 16:06:59 +11003661AC_CHECK_DECLS([UINT32_MAX], , , [[
3662#ifdef HAVE_SYS_LIMITS_H
3663# include <sys/limits.h>
3664#endif
3665#ifdef HAVE_LIMITS_H
3666# include <limits.h>
3667#endif
3668#ifdef HAVE_STDINT_H
3669# include <stdint.h>
3670#endif
3671]])
Darren Tucker537f1ed2005-10-25 18:38:33 +10003672
Damien Millera22ba012000-03-02 23:09:20 +11003673# More checks for data types
Damien Millercaf6dd62000-08-29 11:33:50 +11003674AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [
Tim Rice648f8762011-01-26 12:38:57 -08003675 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3676 [[ u_int a; a = 1;]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003677 [ ac_cv_have_u_int="yes" ], [ ac_cv_have_u_int="no"
Tim Rice648f8762011-01-26 12:38:57 -08003678 ])
Damien Millercaf6dd62000-08-29 11:33:50 +11003679])
3680if test "x$ac_cv_have_u_int" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003681 AC_DEFINE([HAVE_U_INT], [1], [define if you have u_int data type])
Damien Millercaf6dd62000-08-29 11:33:50 +11003682 have_u_int=1
3683fi
3684
Damien Miller61e50f12000-05-08 20:49:37 +10003685AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003686 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3687 [[ int8_t a; int16_t b; int32_t c; a = b = c = 1;]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003688 [ ac_cv_have_intxx_t="yes" ], [ ac_cv_have_intxx_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003689 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003690])
3691if test "x$ac_cv_have_intxx_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003692 AC_DEFINE([HAVE_INTXX_T], [1], [define if you have intxx_t data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003693 have_intxx_t=1
3694fi
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003695
3696if (test -z "$have_intxx_t" && \
Damien Millera8e06ce2003-11-21 23:48:55 +11003697 test "x$ac_cv_header_stdint_h" = "xyes")
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003698then
3699 AC_MSG_CHECKING([for intXX_t types in stdint.h])
Tim Rice648f8762011-01-26 12:38:57 -08003700 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdint.h> ]],
3701 [[ int8_t a; int16_t b; int32_t c; a = b = c = 1;]])],
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003702 [
Tim Rice648f8762011-01-26 12:38:57 -08003703 AC_DEFINE([HAVE_INTXX_T])
3704 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003705 ], [ AC_MSG_RESULT([no])
Tim Rice648f8762011-01-26 12:38:57 -08003706 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003707fi
3708
Damien Miller578783e2000-09-23 14:12:24 +11003709AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003710 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Tim Rice907881e2002-07-18 11:44:50 -07003711#include <sys/types.h>
3712#ifdef HAVE_STDINT_H
3713# include <stdint.h>
3714#endif
3715#include <sys/socket.h>
3716#ifdef HAVE_SYS_BITYPES_H
3717# include <sys/bitypes.h>
3718#endif
Tim Rice648f8762011-01-26 12:38:57 -08003719 ]], [[
3720int64_t a; a = 1;
3721 ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003722 [ ac_cv_have_int64_t="yes" ], [ ac_cv_have_int64_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003723 ])
Damien Miller578783e2000-09-23 14:12:24 +11003724])
3725if test "x$ac_cv_have_int64_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003726 AC_DEFINE([HAVE_INT64_T], [1], [define if you have int64_t data type])
Tim Rice4cec93f2002-02-26 08:40:48 -08003727fi
3728
Damien Miller61e50f12000-05-08 20:49:37 +10003729AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003730 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3731 [[ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003732 [ ac_cv_have_u_intxx_t="yes" ], [ ac_cv_have_u_intxx_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003733 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003734])
3735if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003736 AC_DEFINE([HAVE_U_INTXX_T], [1], [define if you have u_intxx_t data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003737 have_u_intxx_t=1
3738fi
Damien Millerc6398ef1999-11-20 12:18:40 +11003739
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003740if test -z "$have_u_intxx_t" ; then
3741 AC_MSG_CHECKING([for u_intXX_t types in sys/socket.h])
Tim Rice648f8762011-01-26 12:38:57 -08003742 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/socket.h> ]],
3743 [[ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;]])],
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003744 [
Tim Rice648f8762011-01-26 12:38:57 -08003745 AC_DEFINE([HAVE_U_INTXX_T])
3746 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003747 ], [ AC_MSG_RESULT([no])
Tim Rice648f8762011-01-26 12:38:57 -08003748 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003749fi
3750
Damien Miller578783e2000-09-23 14:12:24 +11003751AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003752 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3753 [[ u_int64_t a; a = 1;]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003754 [ ac_cv_have_u_int64_t="yes" ], [ ac_cv_have_u_int64_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003755 ])
Damien Miller578783e2000-09-23 14:12:24 +11003756])
3757if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003758 AC_DEFINE([HAVE_U_INT64_T], [1], [define if you have u_int64_t data type])
Damien Miller578783e2000-09-23 14:12:24 +11003759 have_u_int64_t=1
3760fi
3761
Damien Millerc2868192014-01-30 10:21:19 +11003762if (test -z "$have_u_int64_t" && \
3763 test "x$ac_cv_header_sys_bitypes_h" = "xyes")
3764then
Tim Rice4cec93f2002-02-26 08:40:48 -08003765 AC_MSG_CHECKING([for u_int64_t type in sys/bitypes.h])
Tim Rice648f8762011-01-26 12:38:57 -08003766 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/bitypes.h> ]],
3767 [[ u_int64_t a; a = 1]])],
Tim Rice4cec93f2002-02-26 08:40:48 -08003768 [
Tim Rice648f8762011-01-26 12:38:57 -08003769 AC_DEFINE([HAVE_U_INT64_T])
3770 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003771 ], [ AC_MSG_RESULT([no])
Tim Rice648f8762011-01-26 12:38:57 -08003772 ])
Tim Rice4cec93f2002-02-26 08:40:48 -08003773fi
3774
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003775if test -z "$have_u_intxx_t" ; then
3776 AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003777 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003778#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08003779 ]], [[
3780 uint8_t a;
3781 uint16_t b;
3782 uint32_t c;
3783 a = b = c = 1;
3784 ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003785 [ ac_cv_have_uintxx_t="yes" ], [ ac_cv_have_uintxx_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003786 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003787 ])
3788 if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003789 AC_DEFINE([HAVE_UINTXX_T], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003790 [define if you have uintxx_t data type])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003791 fi
3792fi
3793
Damien Millerc2868192014-01-30 10:21:19 +11003794if (test -z "$have_uintxx_t" && \
3795 test "x$ac_cv_header_stdint_h" = "xyes")
3796then
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003797 AC_MSG_CHECKING([for uintXX_t types in stdint.h])
Tim Rice648f8762011-01-26 12:38:57 -08003798 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdint.h> ]],
3799 [[ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;]])],
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003800 [
Tim Rice648f8762011-01-26 12:38:57 -08003801 AC_DEFINE([HAVE_UINTXX_T])
3802 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003803 ], [ AC_MSG_RESULT([no])
Tim Rice648f8762011-01-26 12:38:57 -08003804 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003805fi
3806
Damien Millerc2868192014-01-30 10:21:19 +11003807if (test -z "$have_uintxx_t" && \
3808 test "x$ac_cv_header_inttypes_h" = "xyes")
3809then
Darren Tucker6d725682014-01-17 19:17:34 +11003810 AC_MSG_CHECKING([for uintXX_t types in inttypes.h])
3811 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <inttypes.h> ]],
3812 [[ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;]])],
3813 [
3814 AC_DEFINE([HAVE_UINTXX_T])
3815 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003816 ], [ AC_MSG_RESULT([no])
Darren Tucker6d725682014-01-17 19:17:34 +11003817 ])
3818fi
3819
Damien Milleredb82922000-06-20 13:25:52 +10003820if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
Damien Millera8e06ce2003-11-21 23:48:55 +11003821 test "x$ac_cv_header_sys_bitypes_h" = "xyes")
Damien Millerb29ea912000-01-15 14:12:03 +11003822then
3823 AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
Tim Rice648f8762011-01-26 12:38:57 -08003824 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller61e50f12000-05-08 20:49:37 +10003825#include <sys/bitypes.h>
Tim Rice648f8762011-01-26 12:38:57 -08003826 ]], [[
Damien Miller70494d12000-04-03 15:57:06 +10003827 int8_t a; int16_t b; int32_t c;
3828 u_int8_t e; u_int16_t f; u_int32_t g;
3829 a = b = c = e = f = g = 1;
Tim Rice648f8762011-01-26 12:38:57 -08003830 ]])],
Damien Millerb29ea912000-01-15 14:12:03 +11003831 [
Tim Rice648f8762011-01-26 12:38:57 -08003832 AC_DEFINE([HAVE_U_INTXX_T])
3833 AC_DEFINE([HAVE_INTXX_T])
3834 AC_MSG_RESULT([yes])
3835 ], [AC_MSG_RESULT([no])
3836 ])
Damien Millerb29ea912000-01-15 14:12:03 +11003837fi
3838
Damien Miller58be7382001-09-15 21:31:54 +10003839
3840AC_CACHE_CHECK([for u_char], ac_cv_have_u_char, [
Tim Rice648f8762011-01-26 12:38:57 -08003841 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3842 [[ u_char foo; foo = 125; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003843 [ ac_cv_have_u_char="yes" ], [ ac_cv_have_u_char="no"
Tim Rice648f8762011-01-26 12:38:57 -08003844 ])
Damien Miller58be7382001-09-15 21:31:54 +10003845])
3846if test "x$ac_cv_have_u_char" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003847 AC_DEFINE([HAVE_U_CHAR], [1], [define if you have u_char data type])
Damien Miller58be7382001-09-15 21:31:54 +10003848fi
3849
Darren Tucker007e3b32013-11-03 18:43:55 +11003850AC_CHECK_TYPES([intmax_t, uintmax_t], , , [
3851#include <sys/types.h>
3852#include <stdint.h>
3853])
3854
Tim Rice13aae5e2001-10-21 17:53:58 -07003855TYPE_SOCKLEN_T
Damien Miller74d0d4a1999-12-29 02:24:35 +11003856
Tim Rice648f8762011-01-26 12:38:57 -08003857AC_CHECK_TYPES([sig_atomic_t], , , [#include <signal.h>])
3858AC_CHECK_TYPES([fsblkcnt_t, fsfilcnt_t], , , [
Darren Tucker598eaa62008-06-09 03:32:29 +10003859#include <sys/types.h>
3860#ifdef HAVE_SYS_BITYPES_H
3861#include <sys/bitypes.h>
3862#endif
3863#ifdef HAVE_SYS_STATFS_H
3864#include <sys/statfs.h>
3865#endif
3866#ifdef HAVE_SYS_STATVFS_H
3867#include <sys/statvfs.h>
3868#endif
3869])
Tim Rice4cec93f2002-02-26 08:40:48 -08003870
Darren Tuckerd561b0b2019-10-28 16:09:04 +11003871AC_CHECK_MEMBERS([struct statfs.f_files, struct statfs.f_flags], [], [], [[
Darren Tucker382c18c2019-11-03 00:09:21 +11003872#include <sys/param.h>
Darren Tucker11057562018-02-25 11:22:57 +11003873#include <sys/types.h>
3874#ifdef HAVE_SYS_BITYPES_H
3875#include <sys/bitypes.h>
3876#endif
3877#ifdef HAVE_SYS_STATFS_H
3878#include <sys/statfs.h>
3879#endif
3880#ifdef HAVE_SYS_STATVFS_H
3881#include <sys/statvfs.h>
3882#endif
3883#ifdef HAVE_SYS_VFS_H
3884#include <sys/vfs.h>
3885#endif
Darren Tucker382c18c2019-11-03 00:09:21 +11003886#ifdef HAVE_SYS_MOUNT_H
3887#include <sys/mount.h>
3888#endif
Darren Tucker11057562018-02-25 11:22:57 +11003889]])
3890
3891
Tim Rice648f8762011-01-26 12:38:57 -08003892AC_CHECK_TYPES([in_addr_t, in_port_t], , ,
Damien Miller848b9932005-02-24 12:12:34 +11003893[#include <sys/types.h>
3894#include <netinet/in.h>])
Darren Tuckerd9f88912005-02-20 21:01:48 +11003895
Damien Miller61e50f12000-05-08 20:49:37 +10003896AC_CACHE_CHECK([for size_t], ac_cv_have_size_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003897 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3898 [[ size_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003899 [ ac_cv_have_size_t="yes" ], [ ac_cv_have_size_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003900 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003901])
3902if test "x$ac_cv_have_size_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003903 AC_DEFINE([HAVE_SIZE_T], [1], [define if you have size_t data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003904fi
Damien Miller95058511999-12-29 10:36:45 +11003905
Damien Miller615f9392000-05-17 22:53:33 +10003906AC_CACHE_CHECK([for ssize_t], ac_cv_have_ssize_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003907 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3908 [[ ssize_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003909 [ ac_cv_have_ssize_t="yes" ], [ ac_cv_have_ssize_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003910 ])
Damien Miller615f9392000-05-17 22:53:33 +10003911])
3912if test "x$ac_cv_have_ssize_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003913 AC_DEFINE([HAVE_SSIZE_T], [1], [define if you have ssize_t data type])
Damien Miller615f9392000-05-17 22:53:33 +10003914fi
3915
Ben Lindstrom0d5af602001-01-09 00:50:29 +00003916AC_CACHE_CHECK([for clock_t], ac_cv_have_clock_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003917 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <time.h> ]],
3918 [[ clock_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003919 [ ac_cv_have_clock_t="yes" ], [ ac_cv_have_clock_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003920 ])
Ben Lindstrom0d5af602001-01-09 00:50:29 +00003921])
3922if test "x$ac_cv_have_clock_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003923 AC_DEFINE([HAVE_CLOCK_T], [1], [define if you have clock_t data type])
Ben Lindstrom0d5af602001-01-09 00:50:29 +00003924fi
3925
Damien Millerb54b40e2000-06-23 08:23:34 +10003926AC_CACHE_CHECK([for sa_family_t], ac_cv_have_sa_family_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003927 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Millerb54b40e2000-06-23 08:23:34 +10003928#include <sys/types.h>
3929#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08003930 ]], [[ sa_family_t foo; foo = 1235; ]])],
3931 [ ac_cv_have_sa_family_t="yes" ],
3932 [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller78315eb2000-09-29 23:01:36 +11003933#include <sys/types.h>
3934#include <sys/socket.h>
3935#include <netinet/in.h>
Tim Rice648f8762011-01-26 12:38:57 -08003936 ]], [[ sa_family_t foo; foo = 1235; ]])],
Damien Miller78315eb2000-09-29 23:01:36 +11003937 [ ac_cv_have_sa_family_t="yes" ],
Damien Millerb54b40e2000-06-23 08:23:34 +10003938 [ ac_cv_have_sa_family_t="no" ]
3939 )
Tim Rice648f8762011-01-26 12:38:57 -08003940 ])
Damien Millerb54b40e2000-06-23 08:23:34 +10003941])
3942if test "x$ac_cv_have_sa_family_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003943 AC_DEFINE([HAVE_SA_FAMILY_T], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003944 [define if you have sa_family_t data type])
Damien Millerb54b40e2000-06-23 08:23:34 +10003945fi
3946
Damien Miller0f91b4e2000-06-18 15:43:25 +10003947AC_CACHE_CHECK([for pid_t], ac_cv_have_pid_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003948 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3949 [[ pid_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003950 [ ac_cv_have_pid_t="yes" ], [ ac_cv_have_pid_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003951 ])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003952])
3953if test "x$ac_cv_have_pid_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003954 AC_DEFINE([HAVE_PID_T], [1], [define if you have pid_t data type])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003955fi
3956
3957AC_CACHE_CHECK([for mode_t], ac_cv_have_mode_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003958 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3959 [[ mode_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003960 [ ac_cv_have_mode_t="yes" ], [ ac_cv_have_mode_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003961 ])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003962])
3963if test "x$ac_cv_have_mode_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003964 AC_DEFINE([HAVE_MODE_T], [1], [define if you have mode_t data type])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003965fi
3966
Damien Miller61e50f12000-05-08 20:49:37 +10003967
3968AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_have_struct_sockaddr_storage, [
Tim Rice648f8762011-01-26 12:38:57 -08003969 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10003970#include <sys/types.h>
3971#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08003972 ]], [[ struct sockaddr_storage s; ]])],
3973 [ ac_cv_have_struct_sockaddr_storage="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003974 [ ac_cv_have_struct_sockaddr_storage="no"
Tim Rice648f8762011-01-26 12:38:57 -08003975 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003976])
3977if test "x$ac_cv_have_struct_sockaddr_storage" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003978 AC_DEFINE([HAVE_STRUCT_SOCKADDR_STORAGE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003979 [define if you have struct sockaddr_storage data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003980fi
Damien Miller34132e52000-01-14 15:45:46 +11003981
Damien Miller61e50f12000-05-08 20:49:37 +10003982AC_CACHE_CHECK([for struct sockaddr_in6], ac_cv_have_struct_sockaddr_in6, [
Tim Rice648f8762011-01-26 12:38:57 -08003983 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller7b22d652000-06-18 14:07:04 +10003984#include <sys/types.h>
Damien Miller61e50f12000-05-08 20:49:37 +10003985#include <netinet/in.h>
Tim Rice648f8762011-01-26 12:38:57 -08003986 ]], [[ struct sockaddr_in6 s; s.sin6_family = 0; ]])],
3987 [ ac_cv_have_struct_sockaddr_in6="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003988 [ ac_cv_have_struct_sockaddr_in6="no"
Tim Rice648f8762011-01-26 12:38:57 -08003989 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003990])
3991if test "x$ac_cv_have_struct_sockaddr_in6" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003992 AC_DEFINE([HAVE_STRUCT_SOCKADDR_IN6], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003993 [define if you have struct sockaddr_in6 data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003994fi
Damien Miller34132e52000-01-14 15:45:46 +11003995
Damien Miller61e50f12000-05-08 20:49:37 +10003996AC_CACHE_CHECK([for struct in6_addr], ac_cv_have_struct_in6_addr, [
Tim Rice648f8762011-01-26 12:38:57 -08003997 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller7b22d652000-06-18 14:07:04 +10003998#include <sys/types.h>
Damien Miller61e50f12000-05-08 20:49:37 +10003999#include <netinet/in.h>
Tim Rice648f8762011-01-26 12:38:57 -08004000 ]], [[ struct in6_addr s; s.s6_addr[0] = 0; ]])],
4001 [ ac_cv_have_struct_in6_addr="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004002 [ ac_cv_have_struct_in6_addr="no"
Tim Rice648f8762011-01-26 12:38:57 -08004003 ])
Damien Miller61e50f12000-05-08 20:49:37 +10004004])
4005if test "x$ac_cv_have_struct_in6_addr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004006 AC_DEFINE([HAVE_STRUCT_IN6_ADDR], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004007 [define if you have struct in6_addr data type])
Tim Rice0f4d2c02008-11-18 21:26:41 -08004008
4009dnl Now check for sin6_scope_id
Tim Rice648f8762011-01-26 12:38:57 -08004010 AC_CHECK_MEMBERS([struct sockaddr_in6.sin6_scope_id], , ,
Tim Rice0f4d2c02008-11-18 21:26:41 -08004011 [
4012#ifdef HAVE_SYS_TYPES_H
4013#include <sys/types.h>
4014#endif
4015#include <netinet/in.h>
4016 ])
Damien Miller61e50f12000-05-08 20:49:37 +10004017fi
Damien Miller34132e52000-01-14 15:45:46 +11004018
Damien Miller61e50f12000-05-08 20:49:37 +10004019AC_CACHE_CHECK([for struct addrinfo], ac_cv_have_struct_addrinfo, [
Tim Rice648f8762011-01-26 12:38:57 -08004020 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10004021#include <sys/types.h>
4022#include <sys/socket.h>
4023#include <netdb.h>
Tim Rice648f8762011-01-26 12:38:57 -08004024 ]], [[ struct addrinfo s; s.ai_flags = AI_PASSIVE; ]])],
4025 [ ac_cv_have_struct_addrinfo="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004026 [ ac_cv_have_struct_addrinfo="no"
Tim Rice648f8762011-01-26 12:38:57 -08004027 ])
Damien Miller61e50f12000-05-08 20:49:37 +10004028])
4029if test "x$ac_cv_have_struct_addrinfo" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004030 AC_DEFINE([HAVE_STRUCT_ADDRINFO], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004031 [define if you have struct addrinfo data type])
Damien Miller61e50f12000-05-08 20:49:37 +10004032fi
4033
Darren Tuckere0cedca2020-01-14 09:42:52 +11004034AC_HEADER_TIME
4035
Ben Lindstrom42202bc2001-01-15 02:34:37 +00004036AC_CACHE_CHECK([for struct timeval], ac_cv_have_struct_timeval, [
Tim Rice648f8762011-01-26 12:38:57 -08004037 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/time.h> ]],
4038 [[ struct timeval tv; tv.tv_sec = 1;]])],
4039 [ ac_cv_have_struct_timeval="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004040 [ ac_cv_have_struct_timeval="no"
Tim Rice648f8762011-01-26 12:38:57 -08004041 ])
Ben Lindstrom42202bc2001-01-15 02:34:37 +00004042])
4043if test "x$ac_cv_have_struct_timeval" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004044 AC_DEFINE([HAVE_STRUCT_TIMEVAL], [1], [define if you have struct timeval])
Ben Lindstrom42202bc2001-01-15 02:34:37 +00004045 have_struct_timeval=1
4046fi
4047
Darren Tuckere0cedca2020-01-14 09:42:52 +11004048AC_CACHE_CHECK([for struct timespec], ac_cv_have_struct_timespec, [
4049 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4050 #ifdef TIME_WITH_SYS_TIME
4051 # include <sys/time.h>
4052 # include <time.h>
4053 #else
4054 # ifdef HAVE_SYS_TIME_H
4055 # include <sys/time.h>
4056 # else
4057 # include <time.h>
4058 # endif
4059 #endif
4060 ]],
4061 [[ struct timespec ts; ts.tv_sec = 1;]])],
4062 [ ac_cv_have_struct_timespec="yes" ],
4063 [ ac_cv_have_struct_timespec="no"
4064 ])
4065])
4066if test "x$ac_cv_have_struct_timespec" = "xyes" ; then
4067 AC_DEFINE([HAVE_STRUCT_TIMESPEC], [1], [define if you have struct timespec])
4068 have_struct_timespec=1
4069fi
Tim Rice4e4dc562003-03-18 10:21:40 -08004070
Damien Miller10479cc2018-04-10 10:19:02 +10004071# We need int64_t or else certain parts of the compile will fail.
Tim Rice8bb561b2005-03-17 16:23:19 -08004072if test "x$ac_cv_have_int64_t" = "xno" && \
4073 test "x$ac_cv_sizeof_long_int" != "x8" && \
4074 test "x$ac_cv_sizeof_long_long_int" = "x0" ; then
Ben Lindstrom5bd6eb72003-03-21 00:34:34 +00004075 echo "OpenSSH requires int64_t support. Contact your vendor or install"
4076 echo "an alternative compiler (I.E., GCC) before continuing."
4077 echo ""
4078 exit 1;
Tim Ricebee3f222001-03-11 17:32:12 -08004079else
4080dnl test snprintf (broken on SCO w/gcc)
Darren Tuckera0c2b392004-09-11 23:26:37 +10004081 AC_RUN_IFELSE(
Darren Tucker623d92f2004-09-12 22:36:15 +10004082 [AC_LANG_SOURCE([[
Tim Ricebee3f222001-03-11 17:32:12 -08004083#include <stdio.h>
4084#include <string.h>
4085#ifdef HAVE_SNPRINTF
4086main()
4087{
4088 char buf[50];
4089 char expected_out[50];
4090 int mazsize = 50 ;
4091#if (SIZEOF_LONG_INT == 8)
4092 long int num = 0x7fffffffffffffff;
4093#else
Kevin Steves6482ec82001-07-15 02:09:28 +00004094 long long num = 0x7fffffffffffffffll;
Tim Ricebee3f222001-03-11 17:32:12 -08004095#endif
4096 strcpy(expected_out, "9223372036854775807");
4097 snprintf(buf, mazsize, "%lld", num);
4098 if(strcmp(buf, expected_out) != 0)
Damien Millera8e06ce2003-11-21 23:48:55 +11004099 exit(1);
Tim Ricebee3f222001-03-11 17:32:12 -08004100 exit(0);
4101}
4102#else
4103main() { exit(0); }
4104#endif
Tim Rice648f8762011-01-26 12:38:57 -08004105 ]])], [ true ], [ AC_DEFINE([BROKEN_SNPRINTF]) ],
Darren Tuckera0c2b392004-09-11 23:26:37 +10004106 AC_MSG_WARN([cross compiling: Assuming working snprintf()])
Tim Ricebee3f222001-03-11 17:32:12 -08004107 )
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00004108fi
4109
Damien Miller78315eb2000-09-29 23:01:36 +11004110dnl Checks for structure members
Tim Rice648f8762011-01-26 12:38:57 -08004111OSSH_CHECK_HEADER_FOR_FIELD([ut_host], [utmp.h], [HAVE_HOST_IN_UTMP])
4112OSSH_CHECK_HEADER_FOR_FIELD([ut_host], [utmpx.h], [HAVE_HOST_IN_UTMPX])
4113OSSH_CHECK_HEADER_FOR_FIELD([syslen], [utmpx.h], [HAVE_SYSLEN_IN_UTMPX])
4114OSSH_CHECK_HEADER_FOR_FIELD([ut_pid], [utmp.h], [HAVE_PID_IN_UTMP])
4115OSSH_CHECK_HEADER_FOR_FIELD([ut_type], [utmp.h], [HAVE_TYPE_IN_UTMP])
4116OSSH_CHECK_HEADER_FOR_FIELD([ut_type], [utmpx.h], [HAVE_TYPE_IN_UTMPX])
4117OSSH_CHECK_HEADER_FOR_FIELD([ut_tv], [utmp.h], [HAVE_TV_IN_UTMP])
4118OSSH_CHECK_HEADER_FOR_FIELD([ut_id], [utmp.h], [HAVE_ID_IN_UTMP])
4119OSSH_CHECK_HEADER_FOR_FIELD([ut_id], [utmpx.h], [HAVE_ID_IN_UTMPX])
4120OSSH_CHECK_HEADER_FOR_FIELD([ut_addr], [utmp.h], [HAVE_ADDR_IN_UTMP])
4121OSSH_CHECK_HEADER_FOR_FIELD([ut_addr], [utmpx.h], [HAVE_ADDR_IN_UTMPX])
4122OSSH_CHECK_HEADER_FOR_FIELD([ut_addr_v6], [utmp.h], [HAVE_ADDR_V6_IN_UTMP])
4123OSSH_CHECK_HEADER_FOR_FIELD([ut_addr_v6], [utmpx.h], [HAVE_ADDR_V6_IN_UTMPX])
4124OSSH_CHECK_HEADER_FOR_FIELD([ut_exit], [utmp.h], [HAVE_EXIT_IN_UTMP])
4125OSSH_CHECK_HEADER_FOR_FIELD([ut_time], [utmp.h], [HAVE_TIME_IN_UTMP])
4126OSSH_CHECK_HEADER_FOR_FIELD([ut_time], [utmpx.h], [HAVE_TIME_IN_UTMPX])
4127OSSH_CHECK_HEADER_FOR_FIELD([ut_tv], [utmpx.h], [HAVE_TV_IN_UTMPX])
Tim Rice13aae5e2001-10-21 17:53:58 -07004128
4129AC_CHECK_MEMBERS([struct stat.st_blksize])
Damien Millerbcd14852017-06-10 23:41:25 +10004130AC_CHECK_MEMBERS([struct stat.st_mtim])
4131AC_CHECK_MEMBERS([struct stat.st_mtime])
Damien Miller6332da22013-04-23 14:25:52 +10004132AC_CHECK_MEMBERS([struct passwd.pw_gecos, struct passwd.pw_class,
4133struct passwd.pw_change, struct passwd.pw_expire],
4134[], [], [[
4135#include <sys/types.h>
4136#include <pwd.h>
4137]])
4138
Tim Rice648f8762011-01-26 12:38:57 -08004139AC_CHECK_MEMBER([struct __res_state.retrans], [], [AC_DEFINE([__res_state], [state],
Darren Tucker58e298d2005-11-25 13:14:58 +11004140 [Define if we don't have struct __res_state in resolv.h])],
Damien Miller6332da22013-04-23 14:25:52 +10004141[[
Darren Tucker58e298d2005-11-25 13:14:58 +11004142#include <stdio.h>
4143#if HAVE_SYS_TYPES_H
4144# include <sys/types.h>
4145#endif
4146#include <netinet/in.h>
4147#include <arpa/nameser.h>
4148#include <resolv.h>
Damien Miller6332da22013-04-23 14:25:52 +10004149]])
andre2ff7b5d2000-06-03 14:57:40 +00004150
Damien Miller61e50f12000-05-08 20:49:37 +10004151AC_CACHE_CHECK([for ss_family field in struct sockaddr_storage],
4152 ac_cv_have_ss_family_in_struct_ss, [
Tim Rice648f8762011-01-26 12:38:57 -08004153 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10004154#include <sys/types.h>
4155#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08004156 ]], [[ struct sockaddr_storage s; s.ss_family = 1; ]])],
4157 [ ac_cv_have_ss_family_in_struct_ss="yes" ],
4158 [ ac_cv_have_ss_family_in_struct_ss="no" ])
Damien Miller61e50f12000-05-08 20:49:37 +10004159])
4160if test "x$ac_cv_have_ss_family_in_struct_ss" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004161 AC_DEFINE([HAVE_SS_FAMILY_IN_SS], [1], [Fields in struct sockaddr_storage])
Damien Miller61e50f12000-05-08 20:49:37 +10004162fi
4163
Damien Miller61e50f12000-05-08 20:49:37 +10004164AC_CACHE_CHECK([for __ss_family field in struct sockaddr_storage],
4165 ac_cv_have___ss_family_in_struct_ss, [
Tim Rice648f8762011-01-26 12:38:57 -08004166 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10004167#include <sys/types.h>
4168#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08004169 ]], [[ struct sockaddr_storage s; s.__ss_family = 1; ]])],
4170 [ ac_cv_have___ss_family_in_struct_ss="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004171 [ ac_cv_have___ss_family_in_struct_ss="no"
Tim Rice648f8762011-01-26 12:38:57 -08004172 ])
Damien Miller61e50f12000-05-08 20:49:37 +10004173])
4174if test "x$ac_cv_have___ss_family_in_struct_ss" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004175 AC_DEFINE([HAVE___SS_FAMILY_IN_SS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004176 [Fields in struct sockaddr_storage])
Damien Miller61e50f12000-05-08 20:49:37 +10004177fi
Damien Millerbf1c9b21999-12-09 10:16:54 +11004178
Tim Rice28bbb0c2002-05-27 17:37:32 -07004179dnl make sure we're using the real structure members and not defines
Kevin Steves939c9db2002-03-22 17:23:25 +00004180AC_CACHE_CHECK([for msg_accrights field in struct msghdr],
4181 ac_cv_have_accrights_in_msghdr, [
Tim Rice648f8762011-01-26 12:38:57 -08004182 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Tim Riceae49fe62002-04-12 10:26:21 -07004183#include <sys/types.h>
Kevin Steves939c9db2002-03-22 17:23:25 +00004184#include <sys/socket.h>
4185#include <sys/uio.h>
Tim Rice648f8762011-01-26 12:38:57 -08004186 ]], [[
Tim Rice28bbb0c2002-05-27 17:37:32 -07004187#ifdef msg_accrights
Darren Tuckera0c2b392004-09-11 23:26:37 +10004188#error "msg_accrights is a macro"
Tim Rice28bbb0c2002-05-27 17:37:32 -07004189exit(1);
4190#endif
4191struct msghdr m;
4192m.msg_accrights = 0;
4193exit(0);
Tim Rice648f8762011-01-26 12:38:57 -08004194 ]])],
Kevin Steves939c9db2002-03-22 17:23:25 +00004195 [ ac_cv_have_accrights_in_msghdr="yes" ],
4196 [ ac_cv_have_accrights_in_msghdr="no" ]
4197 )
4198])
4199if test "x$ac_cv_have_accrights_in_msghdr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004200 AC_DEFINE([HAVE_ACCRIGHTS_IN_MSGHDR], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004201 [Define if your system uses access rights style
4202 file descriptor passing])
Kevin Steves939c9db2002-03-22 17:23:25 +00004203fi
4204
Tim Rice648f8762011-01-26 12:38:57 -08004205AC_MSG_CHECKING([if struct statvfs.f_fsid is integral type])
4206AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckere1a3ddf2012-05-04 11:05:45 +10004207#include <sys/param.h>
Darren Tucker32780622009-06-16 16:11:02 +10004208#include <sys/stat.h>
4209#ifdef HAVE_SYS_TIME_H
4210# include <sys/time.h>
4211#endif
4212#ifdef HAVE_SYS_MOUNT_H
4213#include <sys/mount.h>
4214#endif
4215#ifdef HAVE_SYS_STATVFS_H
4216#include <sys/statvfs.h>
4217#endif
Tim Rice648f8762011-01-26 12:38:57 -08004218 ]], [[ struct statvfs s; s.f_fsid = 0; ]])],
4219 [ AC_MSG_RESULT([yes]) ],
4220 [ AC_MSG_RESULT([no])
Darren Tucker32780622009-06-16 16:11:02 +10004221
Tim Rice648f8762011-01-26 12:38:57 -08004222 AC_MSG_CHECKING([if fsid_t has member val])
4223 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker32780622009-06-16 16:11:02 +10004224#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08004225#include <sys/statvfs.h>
4226 ]], [[ fsid_t t; t.val[0] = 0; ]])],
4227 [ AC_MSG_RESULT([yes])
4228 AC_DEFINE([FSID_HAS_VAL], [1], [fsid_t has member val]) ],
4229 [ AC_MSG_RESULT([no]) ])
Darren Tucker32780622009-06-16 16:11:02 +10004230
Tim Rice648f8762011-01-26 12:38:57 -08004231 AC_MSG_CHECKING([if f_fsid has member __val])
4232 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker32780622009-06-16 16:11:02 +10004233#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08004234#include <sys/statvfs.h>
4235 ]], [[ fsid_t t; t.__val[0] = 0; ]])],
4236 [ AC_MSG_RESULT([yes])
4237 AC_DEFINE([FSID_HAS___VAL], [1], [fsid_t has member __val]) ],
4238 [ AC_MSG_RESULT([no]) ])
Darren Tucker32780622009-06-16 16:11:02 +10004239])
Darren Tucker77001382008-06-09 06:17:53 +10004240
Kevin Stevesa44e0352002-04-07 16:18:03 +00004241AC_CACHE_CHECK([for msg_control field in struct msghdr],
4242 ac_cv_have_control_in_msghdr, [
Tim Rice648f8762011-01-26 12:38:57 -08004243 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Tim Riceae49fe62002-04-12 10:26:21 -07004244#include <sys/types.h>
Kevin Stevesa44e0352002-04-07 16:18:03 +00004245#include <sys/socket.h>
4246#include <sys/uio.h>
Tim Rice648f8762011-01-26 12:38:57 -08004247 ]], [[
Tim Rice28bbb0c2002-05-27 17:37:32 -07004248#ifdef msg_control
Darren Tuckera0c2b392004-09-11 23:26:37 +10004249#error "msg_control is a macro"
Tim Rice28bbb0c2002-05-27 17:37:32 -07004250exit(1);
4251#endif
4252struct msghdr m;
4253m.msg_control = 0;
4254exit(0);
Tim Rice648f8762011-01-26 12:38:57 -08004255 ]])],
Kevin Stevesa44e0352002-04-07 16:18:03 +00004256 [ ac_cv_have_control_in_msghdr="yes" ],
4257 [ ac_cv_have_control_in_msghdr="no" ]
4258 )
4259])
4260if test "x$ac_cv_have_control_in_msghdr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004261 AC_DEFINE([HAVE_CONTROL_IN_MSGHDR], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004262 [Define if your system uses ancillary data style
4263 file descriptor passing])
Kevin Stevesa44e0352002-04-07 16:18:03 +00004264fi
4265
Damien Miller61e50f12000-05-08 20:49:37 +10004266AC_CACHE_CHECK([if libc defines __progname], ac_cv_libc_defines___progname, [
Tim Rice648f8762011-01-26 12:38:57 -08004267 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
4268 [[ extern char *__progname; printf("%s", __progname); ]])],
4269 [ ac_cv_libc_defines___progname="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004270 [ ac_cv_libc_defines___progname="no"
Tim Rice648f8762011-01-26 12:38:57 -08004271 ])
Damien Miller61e50f12000-05-08 20:49:37 +10004272])
4273if test "x$ac_cv_libc_defines___progname" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004274 AC_DEFINE([HAVE___PROGNAME], [1], [Define if libc defines __progname])
Damien Miller61e50f12000-05-08 20:49:37 +10004275fi
4276
Kevin Steves4846f4a2002-03-22 18:19:53 +00004277AC_CACHE_CHECK([whether $CC implements __FUNCTION__], ac_cv_cc_implements___FUNCTION__, [
Tim Rice648f8762011-01-26 12:38:57 -08004278 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]],
4279 [[ printf("%s", __FUNCTION__); ]])],
4280 [ ac_cv_cc_implements___FUNCTION__="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004281 [ ac_cv_cc_implements___FUNCTION__="no"
Tim Rice648f8762011-01-26 12:38:57 -08004282 ])
Kevin Steves4846f4a2002-03-22 18:19:53 +00004283])
4284if test "x$ac_cv_cc_implements___FUNCTION__" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004285 AC_DEFINE([HAVE___FUNCTION__], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004286 [Define if compiler implements __FUNCTION__])
Kevin Steves4846f4a2002-03-22 18:19:53 +00004287fi
4288
4289AC_CACHE_CHECK([whether $CC implements __func__], ac_cv_cc_implements___func__, [
Tim Rice648f8762011-01-26 12:38:57 -08004290 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]],
4291 [[ printf("%s", __func__); ]])],
4292 [ ac_cv_cc_implements___func__="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004293 [ ac_cv_cc_implements___func__="no"
Tim Rice648f8762011-01-26 12:38:57 -08004294 ])
Kevin Steves4846f4a2002-03-22 18:19:53 +00004295])
4296if test "x$ac_cv_cc_implements___func__" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004297 AC_DEFINE([HAVE___func__], [1], [Define if compiler implements __func__])
Kevin Steves4846f4a2002-03-22 18:19:53 +00004298fi
4299
Damien Miller57f39152005-11-24 19:58:19 +11004300AC_CACHE_CHECK([whether va_copy exists], ac_cv_have_va_copy, [
Tim Rice648f8762011-01-26 12:38:57 -08004301 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4302#include <stdarg.h>
4303va_list x,y;
4304 ]], [[ va_copy(x,y); ]])],
4305 [ ac_cv_have_va_copy="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004306 [ ac_cv_have_va_copy="no"
Tim Rice648f8762011-01-26 12:38:57 -08004307 ])
Damien Miller57f39152005-11-24 19:58:19 +11004308])
4309if test "x$ac_cv_have_va_copy" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004310 AC_DEFINE([HAVE_VA_COPY], [1], [Define if va_copy exists])
Damien Miller57f39152005-11-24 19:58:19 +11004311fi
4312
4313AC_CACHE_CHECK([whether __va_copy exists], ac_cv_have___va_copy, [
Tim Rice648f8762011-01-26 12:38:57 -08004314 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4315#include <stdarg.h>
4316va_list x,y;
4317 ]], [[ __va_copy(x,y); ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07004318 [ ac_cv_have___va_copy="yes" ], [ ac_cv_have___va_copy="no"
Tim Rice648f8762011-01-26 12:38:57 -08004319 ])
Damien Miller57f39152005-11-24 19:58:19 +11004320])
4321if test "x$ac_cv_have___va_copy" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004322 AC_DEFINE([HAVE___VA_COPY], [1], [Define if __va_copy exists])
Damien Miller57f39152005-11-24 19:58:19 +11004323fi
4324
Damien Miller4f8e6692001-07-14 13:22:53 +10004325AC_CACHE_CHECK([whether getopt has optreset support],
4326 ac_cv_have_getopt_optreset, [
Tim Rice648f8762011-01-26 12:38:57 -08004327 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <getopt.h> ]],
4328 [[ extern int optreset; optreset = 0; ]])],
4329 [ ac_cv_have_getopt_optreset="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004330 [ ac_cv_have_getopt_optreset="no"
Tim Rice648f8762011-01-26 12:38:57 -08004331 ])
Damien Miller4f8e6692001-07-14 13:22:53 +10004332])
4333if test "x$ac_cv_have_getopt_optreset" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004334 AC_DEFINE([HAVE_GETOPT_OPTRESET], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004335 [Define if your getopt(3) defines and uses optreset])
Damien Miller4f8e6692001-07-14 13:22:53 +10004336fi
Damien Millera22ba012000-03-02 23:09:20 +11004337
Damien Millerecbb26d2000-07-15 14:59:14 +10004338AC_CACHE_CHECK([if libc defines sys_errlist], ac_cv_libc_defines_sys_errlist, [
Tim Rice648f8762011-01-26 12:38:57 -08004339 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
4340[[ extern const char *const sys_errlist[]; printf("%s", sys_errlist[0]);]])],
4341 [ ac_cv_libc_defines_sys_errlist="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004342 [ ac_cv_libc_defines_sys_errlist="no"
Tim Rice648f8762011-01-26 12:38:57 -08004343 ])
Damien Millerecbb26d2000-07-15 14:59:14 +10004344])
4345if test "x$ac_cv_libc_defines_sys_errlist" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004346 AC_DEFINE([HAVE_SYS_ERRLIST], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004347 [Define if your system defines sys_errlist[]])
Damien Millerecbb26d2000-07-15 14:59:14 +10004348fi
4349
4350
Damien Miller11fa2cc2000-08-16 10:35:58 +10004351AC_CACHE_CHECK([if libc defines sys_nerr], ac_cv_libc_defines_sys_nerr, [
Tim Rice648f8762011-01-26 12:38:57 -08004352 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
4353[[ extern int sys_nerr; printf("%i", sys_nerr);]])],
4354 [ ac_cv_libc_defines_sys_nerr="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004355 [ ac_cv_libc_defines_sys_nerr="no"
Tim Rice648f8762011-01-26 12:38:57 -08004356 ])
Damien Miller11fa2cc2000-08-16 10:35:58 +10004357])
4358if test "x$ac_cv_libc_defines_sys_nerr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004359 AC_DEFINE([HAVE_SYS_NERR], [1], [Define if your system defines sys_nerr])
Damien Miller11fa2cc2000-08-16 10:35:58 +10004360fi
4361
Darren Tucker5f88d342003-10-15 16:57:57 +10004362# Check libraries needed by DNS fingerprint support
Tim Rice648f8762011-01-26 12:38:57 -08004363AC_SEARCH_LIBS([getrrsetbyname], [resolv],
4364 [AC_DEFINE([HAVE_GETRRSETBYNAME], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004365 [Define if getrrsetbyname() exists])],
Damien Miller7abe09b2003-05-15 10:53:49 +10004366 [
Darren Tucker5f88d342003-10-15 16:57:57 +10004367 # Needed by our getrrsetbyname()
Tim Rice648f8762011-01-26 12:38:57 -08004368 AC_SEARCH_LIBS([res_query], [resolv])
4369 AC_SEARCH_LIBS([dn_expand], [resolv])
4370 AC_MSG_CHECKING([if res_query will link])
4371 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckere02b49a2009-09-11 14:56:08 +10004372#include <sys/types.h>
4373#include <netinet/in.h>
4374#include <arpa/nameser.h>
4375#include <netdb.h>
4376#include <resolv.h>
Tim Rice648f8762011-01-26 12:38:57 -08004377 ]], [[
Darren Tuckere02b49a2009-09-11 14:56:08 +10004378 res_query (0, 0, 0, 0, 0);
Tim Rice648f8762011-01-26 12:38:57 -08004379 ]])],
4380 AC_MSG_RESULT([yes]),
4381 [AC_MSG_RESULT([no])
Darren Tucker8e968a52004-05-13 11:56:16 +10004382 saved_LIBS="$LIBS"
4383 LIBS="$LIBS -lresolv"
Tim Rice648f8762011-01-26 12:38:57 -08004384 AC_MSG_CHECKING([for res_query in -lresolv])
4385 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckere02b49a2009-09-11 14:56:08 +10004386#include <sys/types.h>
4387#include <netinet/in.h>
4388#include <arpa/nameser.h>
4389#include <netdb.h>
Darren Tucker8e968a52004-05-13 11:56:16 +10004390#include <resolv.h>
Tim Rice648f8762011-01-26 12:38:57 -08004391 ]], [[
Darren Tucker8e968a52004-05-13 11:56:16 +10004392 res_query (0, 0, 0, 0, 0);
Tim Rice648f8762011-01-26 12:38:57 -08004393 ]])],
4394 [AC_MSG_RESULT([yes])],
Darren Tucker8e968a52004-05-13 11:56:16 +10004395 [LIBS="$saved_LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08004396 AC_MSG_RESULT([no])])
Darren Tucker8e968a52004-05-13 11:56:16 +10004397 ])
Tim Rice648f8762011-01-26 12:38:57 -08004398 AC_CHECK_FUNCS([_getshort _getlong])
Darren Tuckerd886e1c2005-06-01 18:57:45 +10004399 AC_CHECK_DECLS([_getshort, _getlong], , ,
Tim Ricefcc7ff12005-06-02 20:28:29 -07004400 [#include <sys/types.h>
4401 #include <arpa/nameser.h>])
Tim Rice648f8762011-01-26 12:38:57 -08004402 AC_CHECK_MEMBER([HEADER.ad],
4403 [AC_DEFINE([HAVE_HEADER_AD], [1],
4404 [Define if HEADER.ad exists in arpa/nameser.h])], ,
Darren Tucker5f88d342003-10-15 16:57:57 +10004405 [#include <arpa/nameser.h>])
4406 ])
Damien Miller7abe09b2003-05-15 10:53:49 +10004407
Tim Rice648f8762011-01-26 12:38:57 -08004408AC_MSG_CHECKING([if struct __res_state _res is an extern])
4409AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckercc40d5e2007-04-29 13:58:06 +10004410#include <stdio.h>
4411#if HAVE_SYS_TYPES_H
4412# include <sys/types.h>
4413#endif
4414#include <netinet/in.h>
4415#include <arpa/nameser.h>
4416#include <resolv.h>
4417extern struct __res_state _res;
Darren Tucker7ad8b282015-09-11 13:11:02 +10004418 ]], [[
4419struct __res_state *volatile p = &_res; /* force resolution of _res */
4420return 0;
4421 ]],)],
Tim Rice648f8762011-01-26 12:38:57 -08004422 [AC_MSG_RESULT([yes])
4423 AC_DEFINE([HAVE__RES_EXTERN], [1],
Darren Tuckercc40d5e2007-04-29 13:58:06 +10004424 [Define if you have struct __res_state _res as an extern])
4425 ],
Tim Rice648f8762011-01-26 12:38:57 -08004426 [ AC_MSG_RESULT([no]) ]
Darren Tuckercc40d5e2007-04-29 13:58:06 +10004427)
4428
Damien Miller73b42d22006-04-22 21:26:08 +10004429# Check whether user wants SELinux support
4430SELINUX_MSG="no"
4431LIBSELINUX=""
Tim Rice648f8762011-01-26 12:38:57 -08004432AC_ARG_WITH([selinux],
Damien Miller5b1c8b32008-03-27 12:33:07 +11004433 [ --with-selinux Enable SELinux support],
Damien Miller73b42d22006-04-22 21:26:08 +10004434 [ if test "x$withval" != "xno" ; then
Darren Tucker20e9f972007-03-25 18:26:01 +10004435 save_LIBS="$LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08004436 AC_DEFINE([WITH_SELINUX], [1],
4437 [Define if you want SELinux support.])
Damien Miller73b42d22006-04-22 21:26:08 +10004438 SELINUX_MSG="yes"
4439 AC_CHECK_HEADER([selinux/selinux.h], ,
Tim Rice648f8762011-01-26 12:38:57 -08004440 AC_MSG_ERROR([SELinux support requires selinux.h header]))
4441 AC_CHECK_LIB([selinux], [setexeccon],
Damien Miller1d2bfc42010-02-10 10:19:29 +11004442 [ LIBSELINUX="-lselinux"
4443 LIBS="$LIBS -lselinux"
4444 ],
Tim Rice648f8762011-01-26 12:38:57 -08004445 AC_MSG_ERROR([SELinux support requires libselinux library]))
Damien Miller71adf122011-01-25 12:16:15 +11004446 SSHLIBS="$SSHLIBS $LIBSELINUX"
Darren Tucker20e9f972007-03-25 18:26:01 +10004447 SSHDLIBS="$SSHDLIBS $LIBSELINUX"
Tim Rice648f8762011-01-26 12:38:57 -08004448 AC_CHECK_FUNCS([getseuserbyname get_default_context_with_level])
Darren Tuckeradc947d2006-10-07 09:07:20 +10004449 LIBS="$save_LIBS"
Damien Miller73b42d22006-04-22 21:26:08 +10004450 fi ]
4451)
Tim Rice648f8762011-01-26 12:38:57 -08004452AC_SUBST([SSHLIBS])
4453AC_SUBST([SSHDLIBS])
Damien Miller73b42d22006-04-22 21:26:08 +10004454
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004455# Check whether user wants Kerberos 5 support
Damien Millera8e06ce2003-11-21 23:48:55 +11004456KRB5_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08004457AC_ARG_WITH([kerberos5],
Damien Millera8e06ce2003-11-21 23:48:55 +11004458 [ --with-kerberos5=PATH Enable Kerberos 5 support],
Darren Tucker1d3ca582004-01-22 12:05:34 +11004459 [ if test "x$withval" != "xno" ; then
4460 if test "x$withval" = "xyes" ; then
4461 KRB5ROOT="/usr/local"
4462 else
4463 KRB5ROOT=${withval}
4464 fi
4465
Tim Rice648f8762011-01-26 12:38:57 -08004466 AC_DEFINE([KRB5], [1], [Define if you want Kerberos 5 support])
Darren Tucker1d3ca582004-01-22 12:05:34 +11004467 KRB5_MSG="yes"
4468
Darren Tucker4089fc12016-12-08 12:57:24 +11004469 AC_PATH_TOOL([KRB5CONF], [krb5-config],
Darren Tuckerdad48e72009-09-01 18:26:00 +10004470 [$KRB5ROOT/bin/krb5-config],
4471 [$KRB5ROOT/bin:$PATH])
4472 if test -x $KRB5CONF ; then
Darren Tucker964de182013-02-22 10:39:59 +11004473 K5CFLAGS="`$KRB5CONF --cflags`"
4474 K5LIBS="`$KRB5CONF --libs`"
4475 CPPFLAGS="$CPPFLAGS $K5CFLAGS"
Darren Tucker1d3ca582004-01-22 12:05:34 +11004476
Tim Rice648f8762011-01-26 12:38:57 -08004477 AC_MSG_CHECKING([for gssapi support])
Darren Tucker1d3ca582004-01-22 12:05:34 +11004478 if $KRB5CONF | grep gssapi >/dev/null ; then
Tim Rice648f8762011-01-26 12:38:57 -08004479 AC_MSG_RESULT([yes])
4480 AC_DEFINE([GSSAPI], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004481 [Define this if you want GSSAPI
4482 support in the version 2 protocol])
Darren Tucker964de182013-02-22 10:39:59 +11004483 GSSCFLAGS="`$KRB5CONF --cflags gssapi`"
4484 GSSLIBS="`$KRB5CONF --libs gssapi`"
4485 CPPFLAGS="$CPPFLAGS $GSSCFLAGS"
Damien Millera8e06ce2003-11-21 23:48:55 +11004486 else
Tim Rice648f8762011-01-26 12:38:57 -08004487 AC_MSG_RESULT([no])
Damien Millera8e06ce2003-11-21 23:48:55 +11004488 fi
Tim Rice648f8762011-01-26 12:38:57 -08004489 AC_MSG_CHECKING([whether we are using Heimdal])
4490 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <krb5.h>
4491 ]], [[ char *tmp = heimdal_version; ]])],
4492 [ AC_MSG_RESULT([yes])
4493 AC_DEFINE([HEIMDAL], [1],
4494 [Define this if you are using the Heimdal
4495 version of Kerberos V5]) ],
4496 [AC_MSG_RESULT([no])
4497 ])
Darren Tucker1d3ca582004-01-22 12:05:34 +11004498 else
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004499 CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include"
Damien Millera8e06ce2003-11-21 23:48:55 +11004500 LDFLAGS="$LDFLAGS -L${KRB5ROOT}/lib"
Tim Rice648f8762011-01-26 12:38:57 -08004501 AC_MSG_CHECKING([whether we are using Heimdal])
4502 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <krb5.h>
4503 ]], [[ char *tmp = heimdal_version; ]])],
4504 [ AC_MSG_RESULT([yes])
4505 AC_DEFINE([HEIMDAL])
Damien Miller41bccf72011-01-02 21:53:07 +11004506 K5LIBS="-lkrb5"
Damien Miller5561e0b2004-04-20 20:28:55 +10004507 K5LIBS="$K5LIBS -lcom_err -lasn1"
Tim Rice648f8762011-01-26 12:38:57 -08004508 AC_CHECK_LIB([roken], [net_write],
Damien Miller5561e0b2004-04-20 20:28:55 +10004509 [K5LIBS="$K5LIBS -lroken"])
Tim Rice648f8762011-01-26 12:38:57 -08004510 AC_CHECK_LIB([des], [des_cbc_encrypt],
Damien Miller41bccf72011-01-02 21:53:07 +11004511 [K5LIBS="$K5LIBS -ldes"])
Tim Rice648f8762011-01-26 12:38:57 -08004512 ], [ AC_MSG_RESULT([no])
Damien Millera8e06ce2003-11-21 23:48:55 +11004513 K5LIBS="-lkrb5 -lk5crypto -lcom_err"
Tim Rice648f8762011-01-26 12:38:57 -08004514 ])
4515 AC_SEARCH_LIBS([dn_expand], [resolv])
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004516
Tim Rice648f8762011-01-26 12:38:57 -08004517 AC_CHECK_LIB([gssapi_krb5], [gss_init_sec_context],
4518 [ AC_DEFINE([GSSAPI])
Darren Tucker964de182013-02-22 10:39:59 +11004519 GSSLIBS="-lgssapi_krb5" ],
Tim Rice648f8762011-01-26 12:38:57 -08004520 [ AC_CHECK_LIB([gssapi], [gss_init_sec_context],
4521 [ AC_DEFINE([GSSAPI])
Darren Tucker964de182013-02-22 10:39:59 +11004522 GSSLIBS="-lgssapi" ],
Darren Tuckera2b5a4c2013-02-22 10:43:15 +11004523 [ AC_CHECK_LIB([gss], [gss_init_sec_context],
4524 [ AC_DEFINE([GSSAPI])
4525 GSSLIBS="-lgss" ],
4526 AC_MSG_WARN([Cannot find any suitable gss-api library - build may fail]))
4527 ])
Darren Tucker964de182013-02-22 10:39:59 +11004528 ])
Tim Riceeae17cc2005-03-17 16:52:20 -08004529
Tim Rice648f8762011-01-26 12:38:57 -08004530 AC_CHECK_HEADER([gssapi.h], ,
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004531 [ unset ac_cv_header_gssapi_h
Damien Millera8e06ce2003-11-21 23:48:55 +11004532 CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
Tim Rice648f8762011-01-26 12:38:57 -08004533 AC_CHECK_HEADERS([gssapi.h], ,
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004534 AC_MSG_WARN([Cannot find any suitable gss-api header - build may fail])
Damien Millera8e06ce2003-11-21 23:48:55 +11004535 )
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004536 ]
4537 )
4538
4539 oldCPP="$CPPFLAGS"
4540 CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
Tim Rice648f8762011-01-26 12:38:57 -08004541 AC_CHECK_HEADER([gssapi_krb5.h], ,
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004542 [ CPPFLAGS="$oldCPP" ])
4543
Damien Millera8e06ce2003-11-21 23:48:55 +11004544 fi
Darren Tucker2f0bad22019-01-21 21:28:27 +11004545 if test -n "${rpath_opt}" ; then
4546 LDFLAGS="$LDFLAGS ${rpath_opt}${KRB5ROOT}/lib"
Darren Tucker1d3ca582004-01-22 12:05:34 +11004547 fi
4548 if test ! -z "$blibpath" ; then
4549 blibpath="$blibpath:${KRB5ROOT}/lib"
4550 fi
Tim Ricefd9e9e32005-09-12 17:36:10 -07004551
Tim Rice648f8762011-01-26 12:38:57 -08004552 AC_CHECK_HEADERS([gssapi.h gssapi/gssapi.h])
4553 AC_CHECK_HEADERS([gssapi_krb5.h gssapi/gssapi_krb5.h])
4554 AC_CHECK_HEADERS([gssapi_generic.h gssapi/gssapi_generic.h])
Tim Ricefd9e9e32005-09-12 17:36:10 -07004555
Tim Rice648f8762011-01-26 12:38:57 -08004556 AC_SEARCH_LIBS([k_hasafs], [kafs], [AC_DEFINE([USE_AFS], [1],
4557 [Define this if you want to use libkafs' AFS support])])
Darren Tucker03978c62013-02-25 11:24:44 +11004558
4559 AC_CHECK_DECLS([GSS_C_NT_HOSTBASED_SERVICE], [], [], [[
4560#ifdef HAVE_GSSAPI_H
4561# include <gssapi.h>
4562#elif defined(HAVE_GSSAPI_GSSAPI_H)
4563# include <gssapi/gssapi.h>
4564#endif
4565
4566#ifdef HAVE_GSSAPI_GENERIC_H
4567# include <gssapi_generic.h>
4568#elif defined(HAVE_GSSAPI_GSSAPI_GENERIC_H)
4569# include <gssapi/gssapi_generic.h>
4570#endif
4571 ]])
Darren Tuckerf3ab2c52013-08-04 21:48:41 +10004572 saved_LIBS="$LIBS"
4573 LIBS="$LIBS $K5LIBS"
4574 AC_CHECK_FUNCS([krb5_cc_new_unique krb5_get_error_message krb5_free_error_message])
4575 LIBS="$saved_LIBS"
4576
Darren Tucker0d27ed12004-02-24 10:37:33 +11004577 fi
Darren Tucker0d27ed12004-02-24 10:37:33 +11004578 ]
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004579)
Darren Tucker964de182013-02-22 10:39:59 +11004580AC_SUBST([GSSLIBS])
4581AC_SUBST([K5LIBS])
Damien Millerc79bc0d2001-03-28 13:03:42 +10004582
Damien Millera22ba012000-03-02 23:09:20 +11004583# Looking for programs, paths and files
Damien Millera22ba012000-03-02 23:09:20 +11004584
Damien Millerf58c6722002-05-13 13:15:42 +10004585PRIVSEP_PATH=/var/empty
Tim Rice648f8762011-01-26 12:38:57 -08004586AC_ARG_WITH([privsep-path],
Tim Ricecbb90662002-07-08 19:17:10 -07004587 [ --with-privsep-path=xxx Path for privilege separation chroot (default=/var/empty)],
Damien Millerf58c6722002-05-13 13:15:42 +10004588 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004589 if test -n "$withval" && test "x$withval" != "xno" && \
4590 test "x${withval}" != "xyes"; then
Damien Millerf58c6722002-05-13 13:15:42 +10004591 PRIVSEP_PATH=$withval
4592 fi
4593 ]
4594)
Tim Rice648f8762011-01-26 12:38:57 -08004595AC_SUBST([PRIVSEP_PATH])
Damien Millerf58c6722002-05-13 13:15:42 +10004596
Tim Rice648f8762011-01-26 12:38:57 -08004597AC_ARG_WITH([xauth],
Damien Millera22ba012000-03-02 23:09:20 +11004598 [ --with-xauth=PATH Specify path to xauth program ],
4599 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004600 if test -n "$withval" && test "x$withval" != "xno" && \
4601 test "x${withval}" != "xyes"; then
Damien Miller7b22d652000-06-18 14:07:04 +10004602 xauth_path=$withval
Damien Millera22ba012000-03-02 23:09:20 +11004603 fi
4604 ],
4605 [
Tim Ricee22be3b2002-07-17 19:20:07 -07004606 TestPath="$PATH"
4607 TestPath="${TestPath}${PATH_SEPARATOR}/usr/X/bin"
4608 TestPath="${TestPath}${PATH_SEPARATOR}/usr/bin/X11"
4609 TestPath="${TestPath}${PATH_SEPARATOR}/usr/X11R6/bin"
4610 TestPath="${TestPath}${PATH_SEPARATOR}/usr/openwin/bin"
Tim Rice648f8762011-01-26 12:38:57 -08004611 AC_PATH_PROG([xauth_path], [xauth], , [$TestPath])
Damien Milleredb82922000-06-20 13:25:52 +10004612 if (test ! -z "$xauth_path" && test -x "/usr/openwin/bin/xauth") ; then
Damien Millera22ba012000-03-02 23:09:20 +11004613 xauth_path="/usr/openwin/bin/xauth"
4614 fi
4615 ]
4616)
4617
Damien Miller7d901272003-01-13 16:55:22 +11004618STRIP_OPT=-s
Tim Rice648f8762011-01-26 12:38:57 -08004619AC_ARG_ENABLE([strip],
Damien Miller7d901272003-01-13 16:55:22 +11004620 [ --disable-strip Disable calling strip(1) on install],
4621 [
4622 if test "x$enableval" = "xno" ; then
4623 STRIP_OPT=
4624 fi
4625 ]
4626)
Tim Rice648f8762011-01-26 12:38:57 -08004627AC_SUBST([STRIP_OPT])
Damien Miller7d901272003-01-13 16:55:22 +11004628
Damien Millera19cf472000-11-29 13:28:50 +11004629if test -z "$xauth_path" ; then
4630 XAUTH_PATH="undefined"
Tim Rice648f8762011-01-26 12:38:57 -08004631 AC_SUBST([XAUTH_PATH])
Damien Millera19cf472000-11-29 13:28:50 +11004632else
Tim Rice648f8762011-01-26 12:38:57 -08004633 AC_DEFINE_UNQUOTED([XAUTH_PATH], ["$xauth_path"],
Tim Rice7df8d392005-09-19 09:33:39 -07004634 [Define if xauth is found in your path])
Damien Millera19cf472000-11-29 13:28:50 +11004635 XAUTH_PATH=$xauth_path
Tim Rice648f8762011-01-26 12:38:57 -08004636 AC_SUBST([XAUTH_PATH])
Damien Millera22ba012000-03-02 23:09:20 +11004637fi
Damien Millera22ba012000-03-02 23:09:20 +11004638
Tim Rice90f42b02011-06-02 18:17:49 -07004639dnl # --with-maildir=/path/to/mail gets top priority.
4640dnl # if maildir is set in the platform case statement above we use that.
4641dnl # Otherwise we run a program to get the dir from system headers.
4642dnl # We first look for _PATH_MAILDIR then MAILDIR then _PATH_MAIL
4643dnl # If we find _PATH_MAILDIR we do nothing because that is what
4644dnl # session.c expects anyway. Otherwise we set to the value found
4645dnl # stripping any trailing slash. If for some strage reason our program
4646dnl # does not find what it needs, we default to /var/spool/mail.
4647# Check for mail directory
4648AC_ARG_WITH([maildir],
4649 [ --with-maildir=/path/to/mail Specify your system mail directory],
4650 [
4651 if test "X$withval" != X && test "x$withval" != xno && \
4652 test "x${withval}" != xyes; then
4653 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$withval"],
4654 [Set this to your mail directory if you do not have _PATH_MAILDIR])
4655 fi
4656 ],[
4657 if test "X$maildir" != "X"; then
4658 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$maildir"])
4659 else
4660 AC_MSG_CHECKING([Discovering system mail directory])
4661 AC_RUN_IFELSE(
4662 [AC_LANG_PROGRAM([[
4663#include <stdio.h>
4664#include <string.h>
4665#ifdef HAVE_PATHS_H
4666#include <paths.h>
4667#endif
4668#ifdef HAVE_MAILLOCK_H
4669#include <maillock.h>
4670#endif
4671#define DATA "conftest.maildir"
4672 ]], [[
4673 FILE *fd;
4674 int rc;
4675
4676 fd = fopen(DATA,"w");
4677 if(fd == NULL)
4678 exit(1);
4679
4680#if defined (_PATH_MAILDIR)
4681 if ((rc = fprintf(fd ,"_PATH_MAILDIR:%s\n", _PATH_MAILDIR)) <0)
4682 exit(1);
4683#elif defined (MAILDIR)
4684 if ((rc = fprintf(fd ,"MAILDIR:%s\n", MAILDIR)) <0)
4685 exit(1);
4686#elif defined (_PATH_MAIL)
4687 if ((rc = fprintf(fd ,"_PATH_MAIL:%s\n", _PATH_MAIL)) <0)
4688 exit(1);
4689#else
4690 exit (2);
4691#endif
4692
4693 exit(0);
4694 ]])],
4695 [
Tim Ricee1d93702016-05-31 11:13:22 -07004696 maildir_what=`awk -F: '{print $1}' conftest.maildir`
Tim Rice90f42b02011-06-02 18:17:49 -07004697 maildir=`awk -F: '{print $2}' conftest.maildir \
4698 | sed 's|/$||'`
4699 AC_MSG_RESULT([Using: $maildir from $maildir_what])
4700 if test "x$maildir_what" != "x_PATH_MAILDIR"; then
4701 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$maildir"])
4702 fi
4703 ],
4704 [
4705 if test "X$ac_status" = "X2";then
4706# our test program didn't find it. Default to /var/spool/mail
4707 AC_MSG_RESULT([Using: default value of /var/spool/mail])
4708 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["/var/spool/mail"])
4709 else
4710 AC_MSG_RESULT([*** not found ***])
4711 fi
4712 ],
4713 [
4714 AC_MSG_WARN([cross compiling: use --with-maildir=/path/to/mail])
4715 ]
4716 )
4717 fi
4718 ]
4719) # maildir
Damien Millera22ba012000-03-02 23:09:20 +11004720
Darren Tucker623d92f2004-09-12 22:36:15 +10004721if test ! -z "$cross_compiling" && test "x$cross_compiling" = "xyes"; then
Darren Tuckera0c2b392004-09-11 23:26:37 +10004722 AC_MSG_WARN([cross compiling: Disabling /dev/ptmx test])
4723 disable_ptmx_check=yes
4724fi
Damien Millera22ba012000-03-02 23:09:20 +11004725if test -z "$no_dev_ptmx" ; then
Kevin Steves0ea1d9d2002-04-25 18:17:04 +00004726 if test "x$disable_ptmx_check" != "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004727 AC_CHECK_FILE(["/dev/ptmx"],
Kevin Steves0ea1d9d2002-04-25 18:17:04 +00004728 [
Tim Rice648f8762011-01-26 12:38:57 -08004729 AC_DEFINE_UNQUOTED([HAVE_DEV_PTMX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004730 [Define if you have /dev/ptmx])
Kevin Steves0ea1d9d2002-04-25 18:17:04 +00004731 have_dev_ptmx=1
4732 ]
4733 )
4734 fi
Damien Millera22ba012000-03-02 23:09:20 +11004735fi
Darren Tuckera0c2b392004-09-11 23:26:37 +10004736
Darren Tucker623d92f2004-09-12 22:36:15 +10004737if test ! -z "$cross_compiling" && test "x$cross_compiling" != "xyes"; then
Tim Rice648f8762011-01-26 12:38:57 -08004738 AC_CHECK_FILE(["/dev/ptc"],
Darren Tuckera0c2b392004-09-11 23:26:37 +10004739 [
Tim Rice648f8762011-01-26 12:38:57 -08004740 AC_DEFINE_UNQUOTED([HAVE_DEV_PTS_AND_PTC], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004741 [Define if you have /dev/ptc])
Darren Tuckera0c2b392004-09-11 23:26:37 +10004742 have_dev_ptc=1
4743 ]
4744 )
4745else
4746 AC_MSG_WARN([cross compiling: Disabling /dev/ptc test])
4747fi
Damien Miller204ad072000-03-02 23:56:12 +11004748
Damien Millera22ba012000-03-02 23:09:20 +11004749# Options from here on. Some of these are preset by platform above
Tim Rice648f8762011-01-26 12:38:57 -08004750AC_ARG_WITH([mantype],
Damien Miller897741e2001-04-16 10:41:46 +10004751 [ --with-mantype=man|cat|doc Set man page type],
Damien Miller670a4b82000-01-22 13:53:11 +11004752 [
Damien Miller897741e2001-04-16 10:41:46 +10004753 case "$withval" in
4754 man|cat|doc)
4755 MANTYPE=$withval
4756 ;;
4757 *)
Tim Rice648f8762011-01-26 12:38:57 -08004758 AC_MSG_ERROR([invalid man type: $withval])
Damien Miller897741e2001-04-16 10:41:46 +10004759 ;;
4760 esac
Damien Miller670a4b82000-01-22 13:53:11 +11004761 ]
4762)
Ben Lindstrombc709922001-04-18 18:04:21 +00004763if test -z "$MANTYPE"; then
Darren Tucker285546b2019-05-10 15:04:42 +10004764 if ${MANDOC} ${srcdir}/ssh.1 >/dev/null 2>&1; then
4765 MANTYPE=doc
4766 elif ${NROFF} -mdoc ${srcdir}/ssh.1 >/dev/null 2>&1; then
Ben Lindstrombc709922001-04-18 18:04:21 +00004767 MANTYPE=doc
4768 elif ${NROFF} -man ${srcdir}/ssh.1 >/dev/null 2>&1; then
4769 MANTYPE=man
4770 else
4771 MANTYPE=cat
4772 fi
4773fi
Tim Rice648f8762011-01-26 12:38:57 -08004774AC_SUBST([MANTYPE])
Ben Lindstrombc709922001-04-18 18:04:21 +00004775if test "$MANTYPE" = "doc"; then
4776 mansubdir=man;
4777else
4778 mansubdir=$MANTYPE;
4779fi
Tim Rice648f8762011-01-26 12:38:57 -08004780AC_SUBST([mansubdir])
Damien Miller8bdeee21999-12-30 15:50:54 +11004781
Damien Millera22ba012000-03-02 23:09:20 +11004782# Check whether to enable MD5 passwords
Damien Millera8e06ce2003-11-21 23:48:55 +11004783MD5_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08004784AC_ARG_WITH([md5-passwords],
Damien Millerdd1c7ba1999-11-19 15:53:20 +11004785 [ --with-md5-passwords Enable use of MD5 passwords],
Damien Miller8bdeee21999-12-30 15:50:54 +11004786 [
Damien Millerb85dcad2000-03-11 11:37:00 +11004787 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004788 AC_DEFINE([HAVE_MD5_PASSWORDS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004789 [Define if you want to allow MD5 passwords])
Damien Millera8e06ce2003-11-21 23:48:55 +11004790 MD5_MSG="yes"
Damien Miller8bdeee21999-12-30 15:50:54 +11004791 fi
4792 ]
Damien Millerdd1c7ba1999-11-19 15:53:20 +11004793)
4794
Damien Millera22ba012000-03-02 23:09:20 +11004795# Whether to disable shadow password support
Tim Rice648f8762011-01-26 12:38:57 -08004796AC_ARG_WITH([shadow],
Damien Miller76112de1999-12-21 11:18:08 +11004797 [ --without-shadow Disable shadow password support],
4798 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004799 if test "x$withval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004800 AC_DEFINE([DISABLE_SHADOW])
Damien Miller1f335fb2000-06-26 11:31:33 +10004801 disable_shadow=yes
Damien Miller76112de1999-12-21 11:18:08 +11004802 fi
4803 ]
4804)
4805
Damien Miller1f335fb2000-06-26 11:31:33 +10004806if test -z "$disable_shadow" ; then
4807 AC_MSG_CHECKING([if the systems has expire shadow information])
Tim Rice648f8762011-01-26 12:38:57 -08004808 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller1f335fb2000-06-26 11:31:33 +10004809#include <sys/types.h>
4810#include <shadow.h>
Tim Rice648f8762011-01-26 12:38:57 -08004811struct spwd sp;
4812 ]], [[ sp.sp_expire = sp.sp_lstchg = sp.sp_inact = 0; ]])],
4813 [ sp_expire_available=yes ], [
4814 ])
Damien Miller1f335fb2000-06-26 11:31:33 +10004815
4816 if test "x$sp_expire_available" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004817 AC_MSG_RESULT([yes])
4818 AC_DEFINE([HAS_SHADOW_EXPIRE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004819 [Define if you want to use shadow password expire field])
Damien Miller1f335fb2000-06-26 11:31:33 +10004820 else
Tim Rice648f8762011-01-26 12:38:57 -08004821 AC_MSG_RESULT([no])
Damien Miller1f335fb2000-06-26 11:31:33 +10004822 fi
4823fi
4824
Damien Millera22ba012000-03-02 23:09:20 +11004825# Use ip address instead of hostname in $DISPLAY
Damien Miller9a947342000-08-30 10:03:33 +11004826if test ! -z "$IPADDR_IN_DISPLAY" ; then
4827 DISPLAY_HACK_MSG="yes"
Tim Rice648f8762011-01-26 12:38:57 -08004828 AC_DEFINE([IPADDR_IN_DISPLAY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004829 [Define if you need to use IP address
4830 instead of hostname in $DISPLAY])
Damien Miller9a947342000-08-30 10:03:33 +11004831else
Damien Millera8e06ce2003-11-21 23:48:55 +11004832 DISPLAY_HACK_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08004833 AC_ARG_WITH([ipaddr-display],
Tim Rice6397eed2015-06-03 21:41:11 -07004834 [ --with-ipaddr-display Use ip address instead of hostname in $DISPLAY],
Damien Miller9a947342000-08-30 10:03:33 +11004835 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004836 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004837 AC_DEFINE([IPADDR_IN_DISPLAY])
Damien Millera8e06ce2003-11-21 23:48:55 +11004838 DISPLAY_HACK_MSG="yes"
Damien Miller9a947342000-08-30 10:03:33 +11004839 fi
4840 ]
4841 )
4842fi
Damien Miller76112de1999-12-21 11:18:08 +11004843
Darren Tuckere1a790d2003-09-16 11:52:19 +10004844# check for /etc/default/login and use it if present.
Tim Rice648f8762011-01-26 12:38:57 -08004845AC_ARG_ENABLE([etc-default-login],
Darren Tucker1b6f2292005-02-11 16:11:49 +11004846 [ --disable-etc-default-login Disable using PATH from /etc/default/login [no]],
Darren Tucker2f9573d2005-02-10 22:28:54 +11004847 [ if test "x$enableval" = "xno"; then
4848 AC_MSG_NOTICE([/etc/default/login handling disabled])
4849 etc_default_login=no
4850 else
4851 etc_default_login=yes
4852 fi ],
Darren Tucker314d89e2005-10-17 23:29:23 +10004853 [ if test ! -z "$cross_compiling" && test "x$cross_compiling" = "xyes";
4854 then
4855 AC_MSG_WARN([cross compiling: not checking /etc/default/login])
4856 etc_default_login=no
4857 else
4858 etc_default_login=yes
4859 fi ]
Darren Tucker2f9573d2005-02-10 22:28:54 +11004860)
Darren Tuckere1a790d2003-09-16 11:52:19 +10004861
Darren Tucker2f9573d2005-02-10 22:28:54 +11004862if test "x$etc_default_login" != "xno"; then
Tim Rice648f8762011-01-26 12:38:57 -08004863 AC_CHECK_FILE(["/etc/default/login"],
Darren Tucker2f9573d2005-02-10 22:28:54 +11004864 [ external_path_file=/etc/default/login ])
Darren Tucker314d89e2005-10-17 23:29:23 +10004865 if test "x$external_path_file" = "x/etc/default/login"; then
Tim Rice648f8762011-01-26 12:38:57 -08004866 AC_DEFINE([HAVE_ETC_DEFAULT_LOGIN], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004867 [Define if your system has /etc/default/login])
Darren Tuckera0c2b392004-09-11 23:26:37 +10004868 fi
Darren Tucker2f9573d2005-02-10 22:28:54 +11004869fi
Darren Tuckere1a790d2003-09-16 11:52:19 +10004870
Tim Rice43a1c132002-04-17 21:19:14 -07004871dnl BSD systems use /etc/login.conf so --with-default-path= has no effect
Tim Rice8bb561b2005-03-17 16:23:19 -08004872if test $ac_cv_func_login_getcapbool = "yes" && \
4873 test $ac_cv_header_login_cap_h = "yes" ; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10004874 external_path_file=/etc/login.conf
Tim Rice43a1c132002-04-17 21:19:14 -07004875fi
Darren Tuckere1a790d2003-09-16 11:52:19 +10004876
Damien Millera22ba012000-03-02 23:09:20 +11004877# Whether to mess with the default path
Damien Millera8e06ce2003-11-21 23:48:55 +11004878SERVER_PATH_MSG="(default)"
Tim Rice648f8762011-01-26 12:38:57 -08004879AC_ARG_WITH([default-path],
Tim Rice6397eed2015-06-03 21:41:11 -07004880 [ --with-default-path= Specify default $PATH environment for server],
Damien Miller5a3e6831999-12-27 09:48:56 +11004881 [
Darren Tuckere1a790d2003-09-16 11:52:19 +10004882 if test "x$external_path_file" = "x/etc/login.conf" ; then
Tim Rice43a1c132002-04-17 21:19:14 -07004883 AC_MSG_WARN([
4884--with-default-path=PATH has no effect on this system.
4885Edit /etc/login.conf instead.])
Tim Riceeae17cc2005-03-17 16:52:20 -08004886 elif test "x$withval" != "xno" ; then
Tim Riceb925b4b2003-09-15 22:40:49 -07004887 if test ! -z "$external_path_file" ; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10004888 AC_MSG_WARN([
4889--with-default-path=PATH will only be used if PATH is not defined in
4890$external_path_file .])
4891 fi
Tim Rice59ea0a02001-03-10 13:50:45 -08004892 user_path="$withval"
Damien Millera8e06ce2003-11-21 23:48:55 +11004893 SERVER_PATH_MSG="$withval"
Damien Miller5a3e6831999-12-27 09:48:56 +11004894 fi
Tim Rice59ea0a02001-03-10 13:50:45 -08004895 ],
Darren Tuckere1a790d2003-09-16 11:52:19 +10004896 [ if test "x$external_path_file" = "x/etc/login.conf" ; then
4897 AC_MSG_WARN([Make sure the path to scp is in /etc/login.conf])
Tim Rice43a1c132002-04-17 21:19:14 -07004898 else
Tim Riceb925b4b2003-09-15 22:40:49 -07004899 if test ! -z "$external_path_file" ; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10004900 AC_MSG_WARN([
4901If PATH is defined in $external_path_file, ensure the path to scp is included,
4902otherwise scp will not work.])
4903 fi
Darren Tucker314d89e2005-10-17 23:29:23 +10004904 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08004905 [AC_LANG_PROGRAM([[
Tim Rice59ea0a02001-03-10 13:50:45 -08004906/* find out what STDPATH is */
4907#include <stdio.h>
Tim Rice59ea0a02001-03-10 13:50:45 -08004908#ifdef HAVE_PATHS_H
4909# include <paths.h>
4910#endif
4911#ifndef _PATH_STDPATH
Tim Rice1c9e6882002-11-22 13:29:01 -08004912# ifdef _PATH_USERPATH /* Irix */
4913# define _PATH_STDPATH _PATH_USERPATH
4914# else
4915# define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
4916# endif
Tim Rice59ea0a02001-03-10 13:50:45 -08004917#endif
4918#include <sys/types.h>
4919#include <sys/stat.h>
4920#include <fcntl.h>
4921#define DATA "conftest.stdpath"
Tim Rice648f8762011-01-26 12:38:57 -08004922 ]], [[
Tim Rice59ea0a02001-03-10 13:50:45 -08004923 FILE *fd;
4924 int rc;
Tim Riceeae17cc2005-03-17 16:52:20 -08004925
Tim Rice59ea0a02001-03-10 13:50:45 -08004926 fd = fopen(DATA,"w");
4927 if(fd == NULL)
4928 exit(1);
Tim Riceeae17cc2005-03-17 16:52:20 -08004929
Tim Rice59ea0a02001-03-10 13:50:45 -08004930 if ((rc = fprintf(fd,"%s", _PATH_STDPATH)) < 0)
4931 exit(1);
4932
4933 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10004934 ]])],
4935 [ user_path=`cat conftest.stdpath` ],
Tim Rice59ea0a02001-03-10 13:50:45 -08004936 [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ],
4937 [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ]
4938 )
4939# make sure $bindir is in USER_PATH so scp will work
Damien Miller77eab7b2012-07-06 11:49:28 +10004940 t_bindir="${bindir}"
4941 while echo "${t_bindir}" | egrep '\$\{|NONE/' >/dev/null 2>&1; do
4942 t_bindir=`eval echo ${t_bindir}`
4943 case $t_bindir in
4944 NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$prefix~"` ;;
4945 esac
4946 case $t_bindir in
4947 NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$ac_default_prefix~"` ;;
4948 esac
4949 done
Tim Rice59ea0a02001-03-10 13:50:45 -08004950 echo $user_path | grep ":$t_bindir" > /dev/null 2>&1
4951 if test $? -ne 0 ; then
4952 echo $user_path | grep "^$t_bindir" > /dev/null 2>&1
4953 if test $? -ne 0 ; then
4954 user_path=$user_path:$t_bindir
Tim Rice648f8762011-01-26 12:38:57 -08004955 AC_MSG_RESULT([Adding $t_bindir to USER_PATH so scp will work])
Tim Rice59ea0a02001-03-10 13:50:45 -08004956 fi
4957 fi
Tim Rice43a1c132002-04-17 21:19:14 -07004958 fi ]
Damien Miller5a3e6831999-12-27 09:48:56 +11004959)
Darren Tuckere1a790d2003-09-16 11:52:19 +10004960if test "x$external_path_file" != "x/etc/login.conf" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004961 AC_DEFINE_UNQUOTED([USER_PATH], ["$user_path"], [Specify default $PATH])
4962 AC_SUBST([user_path])
Tim Rice43a1c132002-04-17 21:19:14 -07004963fi
Damien Miller5a3e6831999-12-27 09:48:56 +11004964
Damien Millera18bbd32002-05-13 10:48:57 +10004965# Set superuser path separately to user path
Tim Rice648f8762011-01-26 12:38:57 -08004966AC_ARG_WITH([superuser-path],
Damien Millera18bbd32002-05-13 10:48:57 +10004967 [ --with-superuser-path= Specify different path for super-user],
4968 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004969 if test -n "$withval" && test "x$withval" != "xno" && \
4970 test "x${withval}" != "xyes"; then
Tim Rice648f8762011-01-26 12:38:57 -08004971 AC_DEFINE_UNQUOTED([SUPERUSER_PATH], ["$withval"],
Tim Rice7df8d392005-09-19 09:33:39 -07004972 [Define if you want a different $PATH
4973 for the superuser])
Damien Millera18bbd32002-05-13 10:48:57 +10004974 superuser_path=$withval
4975 fi
4976 ]
4977)
4978
4979
Damien Miller61e50f12000-05-08 20:49:37 +10004980AC_MSG_CHECKING([if we need to convert IPv4 in IPv6-mapped addresses])
Damien Millera8e06ce2003-11-21 23:48:55 +11004981IPV4_IN6_HACK_MSG="no"
Damien Miller7bcb0892000-03-11 20:45:40 +11004982AC_ARG_WITH(4in6,
4983 [ --with-4in6 Check for and convert IPv4 in IPv6 mapped addresses],
4984 [
4985 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004986 AC_MSG_RESULT([yes])
4987 AC_DEFINE([IPV4_IN_IPV6], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004988 [Detect IPv4 in IPv6 mapped addresses
4989 and treat as IPv4])
Damien Millera8e06ce2003-11-21 23:48:55 +11004990 IPV4_IN6_HACK_MSG="yes"
Damien Miller7bcb0892000-03-11 20:45:40 +11004991 else
Tim Rice648f8762011-01-26 12:38:57 -08004992 AC_MSG_RESULT([no])
Damien Miller7bcb0892000-03-11 20:45:40 +11004993 fi
Tim Rice648f8762011-01-26 12:38:57 -08004994 ], [
Damien Miller7bcb0892000-03-11 20:45:40 +11004995 if test "x$inet6_default_4in6" = "xyes"; then
4996 AC_MSG_RESULT([yes (default)])
Tim Rice648f8762011-01-26 12:38:57 -08004997 AC_DEFINE([IPV4_IN_IPV6])
Damien Millera8e06ce2003-11-21 23:48:55 +11004998 IPV4_IN6_HACK_MSG="yes"
Damien Miller7bcb0892000-03-11 20:45:40 +11004999 else
5000 AC_MSG_RESULT([no (default)])
5001 fi
5002 ]
5003)
5004
Damien Miller60396b02001-02-18 17:01:00 +11005005# Whether to enable BSD auth support
Damien Miller6c21c512002-01-22 21:57:53 +11005006BSD_AUTH_MSG=no
Tim Rice648f8762011-01-26 12:38:57 -08005007AC_ARG_WITH([bsd-auth],
Damien Miller60396b02001-02-18 17:01:00 +11005008 [ --with-bsd-auth Enable BSD auth support],
5009 [
Tim Riceeae17cc2005-03-17 16:52:20 -08005010 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08005011 AC_DEFINE([BSD_AUTH], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07005012 [Define if you have BSD auth support])
Damien Miller6c21c512002-01-22 21:57:53 +11005013 BSD_AUTH_MSG=yes
Damien Miller60396b02001-02-18 17:01:00 +11005014 fi
5015 ]
5016)
5017
Damien Millera22ba012000-03-02 23:09:20 +11005018# Where to place sshd.pid
Damien Millerb13c73e2000-01-17 22:02:17 +11005019piddir=/var/run
Damien Miller78315eb2000-09-29 23:01:36 +11005020# make sure the directory exists
Tim Riceeae17cc2005-03-17 16:52:20 -08005021if test ! -d $piddir ; then
Damien Miller78315eb2000-09-29 23:01:36 +11005022 piddir=`eval echo ${sysconfdir}`
5023 case $piddir in
Damien Millera8e06ce2003-11-21 23:48:55 +11005024 NONE/*) piddir=`echo $piddir | sed "s~NONE~$ac_default_prefix~"` ;;
Damien Miller78315eb2000-09-29 23:01:36 +11005025 esac
5026fi
5027
Tim Rice648f8762011-01-26 12:38:57 -08005028AC_ARG_WITH([pid-dir],
Darren Tucker075e2582018-02-13 17:36:43 +11005029 [ --with-pid-dir=PATH Specify location of sshd.pid file],
Tim Rice88f2ab52002-03-17 12:17:34 -08005030 [
Tim Rice35cc69d2005-03-17 16:44:25 -08005031 if test -n "$withval" && test "x$withval" != "xno" && \
5032 test "x${withval}" != "xyes"; then
Tim Rice88f2ab52002-03-17 12:17:34 -08005033 piddir=$withval
Tim Riceeae17cc2005-03-17 16:52:20 -08005034 if test ! -d $piddir ; then
Tim Rice88f2ab52002-03-17 12:17:34 -08005035 AC_MSG_WARN([** no $piddir directory on this system **])
5036 fi
5037 fi
5038 ]
5039)
5040
Tim Ricee1d93702016-05-31 11:13:22 -07005041AC_DEFINE_UNQUOTED([_PATH_SSH_PIDDIR], ["$piddir"],
Tim Rice648f8762011-01-26 12:38:57 -08005042 [Specify location of ssh.pid])
5043AC_SUBST([piddir])
Damien Miller5eed6a22000-01-16 12:05:18 +11005044
andre2ff7b5d2000-06-03 14:57:40 +00005045dnl allow user to disable some login recording features
Tim Rice648f8762011-01-26 12:38:57 -08005046AC_ARG_ENABLE([lastlog],
andre43ca7e22000-06-19 08:23:46 +00005047 [ --disable-lastlog disable use of lastlog even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10005048 [
5049 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08005050 AC_DEFINE([DISABLE_LASTLOG])
Darren Tuckera3020db2003-06-28 12:54:33 +10005051 fi
5052 ]
andre2ff7b5d2000-06-03 14:57:40 +00005053)
Tim Rice648f8762011-01-26 12:38:57 -08005054AC_ARG_ENABLE([utmp],
andre43ca7e22000-06-19 08:23:46 +00005055 [ --disable-utmp disable use of utmp even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10005056 [
5057 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08005058 AC_DEFINE([DISABLE_UTMP])
Darren Tuckera3020db2003-06-28 12:54:33 +10005059 fi
5060 ]
andre2ff7b5d2000-06-03 14:57:40 +00005061)
Tim Rice648f8762011-01-26 12:38:57 -08005062AC_ARG_ENABLE([utmpx],
andre43ca7e22000-06-19 08:23:46 +00005063 [ --disable-utmpx disable use of utmpx even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10005064 [
5065 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08005066 AC_DEFINE([DISABLE_UTMPX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07005067 [Define if you don't want to use utmpx])
Darren Tuckera3020db2003-06-28 12:54:33 +10005068 fi
5069 ]
andre2ff7b5d2000-06-03 14:57:40 +00005070)
Tim Rice648f8762011-01-26 12:38:57 -08005071AC_ARG_ENABLE([wtmp],
andre43ca7e22000-06-19 08:23:46 +00005072 [ --disable-wtmp disable use of wtmp even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10005073 [
5074 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08005075 AC_DEFINE([DISABLE_WTMP])
Darren Tuckera3020db2003-06-28 12:54:33 +10005076 fi
5077 ]
andre2ff7b5d2000-06-03 14:57:40 +00005078)
Tim Rice648f8762011-01-26 12:38:57 -08005079AC_ARG_ENABLE([wtmpx],
andre43ca7e22000-06-19 08:23:46 +00005080 [ --disable-wtmpx disable use of wtmpx even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10005081 [
5082 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08005083 AC_DEFINE([DISABLE_WTMPX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07005084 [Define if you don't want to use wtmpx])
Darren Tuckera3020db2003-06-28 12:54:33 +10005085 fi
5086 ]
andre2ff7b5d2000-06-03 14:57:40 +00005087)
Tim Rice648f8762011-01-26 12:38:57 -08005088AC_ARG_ENABLE([libutil],
andre43ca7e22000-06-19 08:23:46 +00005089 [ --disable-libutil disable use of libutil (login() etc.) [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10005090 [
5091 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08005092 AC_DEFINE([DISABLE_LOGIN])
Darren Tuckera3020db2003-06-28 12:54:33 +10005093 fi
5094 ]
andre2ff7b5d2000-06-03 14:57:40 +00005095)
Tim Rice648f8762011-01-26 12:38:57 -08005096AC_ARG_ENABLE([pututline],
andre43ca7e22000-06-19 08:23:46 +00005097 [ --disable-pututline disable use of pututline() etc. ([uw]tmp) [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10005098 [
5099 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08005100 AC_DEFINE([DISABLE_PUTUTLINE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07005101 [Define if you don't want to use pututline()
5102 etc. to write [uw]tmp])
Darren Tuckera3020db2003-06-28 12:54:33 +10005103 fi
5104 ]
andre2ff7b5d2000-06-03 14:57:40 +00005105)
Tim Rice648f8762011-01-26 12:38:57 -08005106AC_ARG_ENABLE([pututxline],
andre43ca7e22000-06-19 08:23:46 +00005107 [ --disable-pututxline disable use of pututxline() etc. ([uw]tmpx) [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10005108 [
5109 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08005110 AC_DEFINE([DISABLE_PUTUTXLINE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07005111 [Define if you don't want to use pututxline()
5112 etc. to write [uw]tmpx])
Darren Tuckera3020db2003-06-28 12:54:33 +10005113 fi
5114 ]
andre2ff7b5d2000-06-03 14:57:40 +00005115)
Tim Rice648f8762011-01-26 12:38:57 -08005116AC_ARG_WITH([lastlog],
andre43ca7e22000-06-19 08:23:46 +00005117 [ --with-lastlog=FILE|DIR specify lastlog location [common locations]],
Damien Miller709528a2001-01-31 09:57:55 +11005118 [
Tim Riceeae17cc2005-03-17 16:52:20 -08005119 if test "x$withval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08005120 AC_DEFINE([DISABLE_LASTLOG])
Tim Rice35cc69d2005-03-17 16:44:25 -08005121 elif test -n "$withval" && test "x${withval}" != "xyes"; then
Damien Miller709528a2001-01-31 09:57:55 +11005122 conf_lastlog_location=$withval
5123 fi
5124 ]
5125)
andre2ff7b5d2000-06-03 14:57:40 +00005126
5127dnl lastlog, [uw]tmpx? detection
5128dnl NOTE: set the paths in the platform section to avoid the
5129dnl need for command-line parameters
5130dnl lastlog and [uw]tmp are subject to a file search if all else fails
5131
5132dnl lastlog detection
5133dnl NOTE: the code itself will detect if lastlog is a directory
5134AC_MSG_CHECKING([if your system defines LASTLOG_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08005135AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00005136#include <sys/types.h>
5137#include <utmp.h>
5138#ifdef HAVE_LASTLOG_H
5139# include <lastlog.h>
5140#endif
Damien Miller2994e082000-06-04 15:51:47 +10005141#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00005142# include <paths.h>
5143#endif
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00005144#ifdef HAVE_LOGIN_H
5145# include <login.h>
5146#endif
Tim Rice648f8762011-01-26 12:38:57 -08005147 ]], [[ char *lastlog = LASTLOG_FILE; ]])],
5148 [ AC_MSG_RESULT([yes]) ],
5149 [
5150 AC_MSG_RESULT([no])
Damien Miller2994e082000-06-04 15:51:47 +10005151 AC_MSG_CHECKING([if your system defines _PATH_LASTLOG])
Tim Rice648f8762011-01-26 12:38:57 -08005152 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller2994e082000-06-04 15:51:47 +10005153#include <sys/types.h>
5154#include <utmp.h>
5155#ifdef HAVE_LASTLOG_H
5156# include <lastlog.h>
5157#endif
5158#ifdef HAVE_PATHS_H
5159# include <paths.h>
5160#endif
Tim Rice648f8762011-01-26 12:38:57 -08005161 ]], [[ char *lastlog = _PATH_LASTLOG; ]])],
5162 [ AC_MSG_RESULT([yes]) ],
Damien Miller2994e082000-06-04 15:51:47 +10005163 [
Tim Rice648f8762011-01-26 12:38:57 -08005164 AC_MSG_RESULT([no])
Damien Miller2994e082000-06-04 15:51:47 +10005165 system_lastlog_path=no
5166 ])
Tim Rice648f8762011-01-26 12:38:57 -08005167])
Damien Miller2994e082000-06-04 15:51:47 +10005168
andre2ff7b5d2000-06-03 14:57:40 +00005169if test -z "$conf_lastlog_location"; then
5170 if test x"$system_lastlog_path" = x"no" ; then
5171 for f in /var/log/lastlog /usr/adm/lastlog /var/adm/lastlog /etc/security/lastlog ; do
Damien Milleredb82922000-06-20 13:25:52 +10005172 if (test -d "$f" || test -f "$f") ; then
andre2ff7b5d2000-06-03 14:57:40 +00005173 conf_lastlog_location=$f
5174 fi
5175 done
5176 if test -z "$conf_lastlog_location"; then
andre45cad512000-06-12 23:27:31 +00005177 AC_MSG_WARN([** Cannot find lastlog **])
5178 dnl Don't define DISABLE_LASTLOG - that means we don't try wtmp/wtmpx
andre2ff7b5d2000-06-03 14:57:40 +00005179 fi
5180 fi
5181fi
5182
5183if test -n "$conf_lastlog_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08005184 AC_DEFINE_UNQUOTED([CONF_LASTLOG_FILE], ["$conf_lastlog_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07005185 [Define if you want to specify the path to your lastlog file])
Tim Riceeae17cc2005-03-17 16:52:20 -08005186fi
andre2ff7b5d2000-06-03 14:57:40 +00005187
5188dnl utmp detection
5189AC_MSG_CHECKING([if your system defines UTMP_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08005190AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00005191#include <sys/types.h>
5192#include <utmp.h>
Damien Miller2994e082000-06-04 15:51:47 +10005193#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00005194# include <paths.h>
5195#endif
Tim Rice648f8762011-01-26 12:38:57 -08005196 ]], [[ char *utmp = UTMP_FILE; ]])],
5197 [ AC_MSG_RESULT([yes]) ],
5198 [ AC_MSG_RESULT([no])
Tim Ricee1d93702016-05-31 11:13:22 -07005199 system_utmp_path=no
Tim Rice648f8762011-01-26 12:38:57 -08005200])
andre2ff7b5d2000-06-03 14:57:40 +00005201if test -z "$conf_utmp_location"; then
5202 if test x"$system_utmp_path" = x"no" ; then
5203 for f in /etc/utmp /usr/adm/utmp /var/run/utmp; do
5204 if test -f $f ; then
5205 conf_utmp_location=$f
5206 fi
5207 done
5208 if test -z "$conf_utmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08005209 AC_DEFINE([DISABLE_UTMP])
andre2ff7b5d2000-06-03 14:57:40 +00005210 fi
5211 fi
5212fi
5213if test -n "$conf_utmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08005214 AC_DEFINE_UNQUOTED([CONF_UTMP_FILE], ["$conf_utmp_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07005215 [Define if you want to specify the path to your utmp file])
Tim Riceeae17cc2005-03-17 16:52:20 -08005216fi
andre2ff7b5d2000-06-03 14:57:40 +00005217
5218dnl wtmp detection
5219AC_MSG_CHECKING([if your system defines WTMP_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08005220AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00005221#include <sys/types.h>
5222#include <utmp.h>
Damien Miller2994e082000-06-04 15:51:47 +10005223#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00005224# include <paths.h>
5225#endif
Tim Rice648f8762011-01-26 12:38:57 -08005226 ]], [[ char *wtmp = WTMP_FILE; ]])],
5227 [ AC_MSG_RESULT([yes]) ],
5228 [ AC_MSG_RESULT([no])
Tim Ricee1d93702016-05-31 11:13:22 -07005229 system_wtmp_path=no
Tim Rice648f8762011-01-26 12:38:57 -08005230])
andre2ff7b5d2000-06-03 14:57:40 +00005231if test -z "$conf_wtmp_location"; then
5232 if test x"$system_wtmp_path" = x"no" ; then
5233 for f in /usr/adm/wtmp /var/log/wtmp; do
5234 if test -f $f ; then
5235 conf_wtmp_location=$f
5236 fi
5237 done
5238 if test -z "$conf_wtmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08005239 AC_DEFINE([DISABLE_WTMP])
andre2ff7b5d2000-06-03 14:57:40 +00005240 fi
5241 fi
5242fi
5243if test -n "$conf_wtmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08005244 AC_DEFINE_UNQUOTED([CONF_WTMP_FILE], ["$conf_wtmp_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07005245 [Define if you want to specify the path to your wtmp file])
Tim Riceeae17cc2005-03-17 16:52:20 -08005246fi
andre2ff7b5d2000-06-03 14:57:40 +00005247
andre2ff7b5d2000-06-03 14:57:40 +00005248dnl wtmpx detection
5249AC_MSG_CHECKING([if your system defines WTMPX_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08005250AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00005251#include <sys/types.h>
5252#include <utmp.h>
5253#ifdef HAVE_UTMPX_H
5254#include <utmpx.h>
5255#endif
Damien Miller2994e082000-06-04 15:51:47 +10005256#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00005257# include <paths.h>
5258#endif
Tim Rice648f8762011-01-26 12:38:57 -08005259 ]], [[ char *wtmpx = WTMPX_FILE; ]])],
5260 [ AC_MSG_RESULT([yes]) ],
5261 [ AC_MSG_RESULT([no])
Tim Ricee1d93702016-05-31 11:13:22 -07005262 system_wtmpx_path=no
Tim Rice648f8762011-01-26 12:38:57 -08005263])
andre2ff7b5d2000-06-03 14:57:40 +00005264if test -z "$conf_wtmpx_location"; then
5265 if test x"$system_wtmpx_path" = x"no" ; then
Tim Rice648f8762011-01-26 12:38:57 -08005266 AC_DEFINE([DISABLE_WTMPX])
andre2ff7b5d2000-06-03 14:57:40 +00005267 fi
5268else
Tim Rice648f8762011-01-26 12:38:57 -08005269 AC_DEFINE_UNQUOTED([CONF_WTMPX_FILE], ["$conf_wtmpx_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07005270 [Define if you want to specify the path to your wtmpx file])
Tim Riceeae17cc2005-03-17 16:52:20 -08005271fi
andre2ff7b5d2000-06-03 14:57:40 +00005272
Damien Miller4018c192000-04-30 09:30:44 +10005273
Damien Miller29ea30d2000-03-17 10:54:15 +11005274if test ! -z "$blibpath" ; then
Damien Millereab4bae2003-04-29 23:22:40 +10005275 LDFLAGS="$LDFLAGS $blibflags$blibpath"
5276 AC_MSG_WARN([Please check and edit blibpath in LDFLAGS in Makefile])
Damien Miller29ea30d2000-03-17 10:54:15 +11005277fi
5278
Damien Millera2438bb2013-03-15 10:23:07 +11005279AC_CHECK_MEMBER([struct lastlog.ll_line], [], [
Tim Riceaa86c392013-03-16 20:55:46 -07005280 if test x$SKIP_DISABLE_LASTLOG_DEFINE != "xyes" ; then
Damien Millera2438bb2013-03-15 10:23:07 +11005281 AC_DEFINE([DISABLE_LASTLOG])
Tim Riceaa86c392013-03-16 20:55:46 -07005282 fi
Damien Millera2438bb2013-03-15 10:23:07 +11005283 ], [
5284#ifdef HAVE_SYS_TYPES_H
5285#include <sys/types.h>
5286#endif
5287#ifdef HAVE_UTMP_H
5288#include <utmp.h>
5289#endif
5290#ifdef HAVE_UTMPX_H
5291#include <utmpx.h>
5292#endif
5293#ifdef HAVE_LASTLOG_H
5294#include <lastlog.h>
5295#endif
5296 ])
5297
5298AC_CHECK_MEMBER([struct utmp.ut_line], [], [
5299 AC_DEFINE([DISABLE_UTMP])
5300 AC_DEFINE([DISABLE_WTMP])
5301 ], [
5302#ifdef HAVE_SYS_TYPES_H
5303#include <sys/types.h>
5304#endif
5305#ifdef HAVE_UTMP_H
5306#include <utmp.h>
5307#endif
5308#ifdef HAVE_UTMPX_H
5309#include <utmpx.h>
5310#endif
5311#ifdef HAVE_LASTLOG_H
5312#include <lastlog.h>
5313#endif
5314 ])
5315
Darren Tucker7da23cb2005-08-03 00:20:15 +10005316dnl Adding -Werror to CFLAGS early prevents configure tests from running.
5317dnl Add now.
5318CFLAGS="$CFLAGS $werror_flags"
5319
Darren Tucker627337d2010-04-10 22:58:01 +10005320if test "x$ac_cv_func_getaddrinfo" != "xyes" ; then
5321 TEST_SSH_IPV6=no
5322else
5323 TEST_SSH_IPV6=yes
5324fi
Tim Rice648f8762011-01-26 12:38:57 -08005325AC_CHECK_DECL([BROKEN_GETADDRINFO], [TEST_SSH_IPV6=no])
5326AC_SUBST([TEST_SSH_IPV6], [$TEST_SSH_IPV6])
Darren Tucker47b8c992016-12-08 15:48:34 +11005327AC_SUBST([TEST_SSH_UTF8], [$TEST_SSH_UTF8])
Darren Tucker882abfd2013-11-09 00:17:41 +11005328AC_SUBST([TEST_MALLOC_OPTIONS], [$TEST_MALLOC_OPTIONS])
Darren Tucker6d8bd572013-06-11 11:26:10 +10005329AC_SUBST([UNSUPPORTED_ALGORITHMS], [$unsupported_algorithms])
Darren Tucker79c0e1d2017-12-11 14:38:33 +11005330AC_SUBST([DEPEND], [$(cat $srcdir/.depend)])
Darren Tucker5d376902008-06-11 04:15:05 +10005331
Damien Millerde35c382017-09-08 12:38:31 +10005332CFLAGS="${CFLAGS} ${CFLAGS_AFTER}"
5333LDFLAGS="${LDFLAGS} ${LDFLAGS_AFTER}"
5334
Damien Miller44384812019-11-29 15:10:21 +11005335# Make a copy of CFLAGS/LDFLAGS without PIE options.
5336LDFLAGS_NOPIE=`echo "$LDFLAGS" | sed 's/ -pie//'`
Damien Millerb2180552019-11-29 12:32:23 +11005337CFLAGS_NOPIE=`echo "$CFLAGS" | sed 's/ -fPIE//'`
Damien Miller44384812019-11-29 15:10:21 +11005338AC_SUBST([LDFLAGS_NOPIE])
Damien Millerb2180552019-11-29 12:32:23 +11005339AC_SUBST([CFLAGS_NOPIE])
5340
Damien Millerbac2d8a2000-09-05 16:13:06 +11005341AC_EXEEXT
Damien Miller223897a2006-09-12 21:54:10 +10005342AC_CONFIG_FILES([Makefile buildpkg.sh opensshd.init openssh.xml \
5343 openbsd-compat/Makefile openbsd-compat/regress/Makefile \
Damien Millerf22019b2011-05-05 13:48:37 +10005344 survey.sh])
Tim Rice13aae5e2001-10-21 17:53:58 -07005345AC_OUTPUT
Damien Miller0437b332000-05-02 09:56:41 +10005346
Damien Miller7b22d652000-06-18 14:07:04 +10005347# Print summary of options
5348
Damien Miller7b22d652000-06-18 14:07:04 +10005349# Someone please show me a better way :)
5350A=`eval echo ${prefix}` ; A=`eval echo ${A}`
5351B=`eval echo ${bindir}` ; B=`eval echo ${B}`
5352C=`eval echo ${sbindir}` ; C=`eval echo ${C}`
5353D=`eval echo ${sysconfdir}` ; D=`eval echo ${D}`
Kevin Stevese0f49142000-10-14 17:51:48 +00005354E=`eval echo ${libexecdir}/ssh-askpass` ; E=`eval echo ${E}`
Ben Lindstrombc709922001-04-18 18:04:21 +00005355F=`eval echo ${mandir}/${mansubdir}X` ; F=`eval echo ${F}`
Damien Miller7b22d652000-06-18 14:07:04 +10005356G=`eval echo ${piddir}` ; G=`eval echo ${G}`
Damien Millerf58c6722002-05-13 13:15:42 +10005357H=`eval echo ${PRIVSEP_PATH}` ; H=`eval echo ${H}`
5358I=`eval echo ${user_path}` ; I=`eval echo ${I}`
5359J=`eval echo ${superuser_path}` ; J=`eval echo ${J}`
Damien Miller7b22d652000-06-18 14:07:04 +10005360
5361echo ""
Kevin Steves393d2f72001-04-08 22:50:43 +00005362echo "OpenSSH has been configured with the following options:"
Damien Millerf58c6722002-05-13 13:15:42 +10005363echo " User binaries: $B"
5364echo " System binaries: $C"
5365echo " Configuration files: $D"
5366echo " Askpass program: $E"
5367echo " Manual pages: $F"
5368echo " PID file: $G"
5369echo " Privilege separation chroot path: $H"
Darren Tuckere1a790d2003-09-16 11:52:19 +10005370if test "x$external_path_file" = "x/etc/login.conf" ; then
5371echo " At runtime, sshd will use the path defined in $external_path_file"
5372echo " Make sure the path to scp is present, otherwise scp will not work"
Tim Rice43a1c132002-04-17 21:19:14 -07005373else
Damien Millerf58c6722002-05-13 13:15:42 +10005374echo " sshd default user PATH: $I"
Tim Riceb925b4b2003-09-15 22:40:49 -07005375 if test ! -z "$external_path_file"; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10005376echo " (If PATH is set in $external_path_file it will be used instead. If"
5377echo " used, ensure the path to scp is present, otherwise scp will not work.)"
5378 fi
Tim Rice43a1c132002-04-17 21:19:14 -07005379fi
Damien Millera18bbd32002-05-13 10:48:57 +10005380if test ! -z "$superuser_path" ; then
Damien Millerf58c6722002-05-13 13:15:42 +10005381echo " sshd superuser user PATH: $J"
Damien Millera18bbd32002-05-13 10:48:57 +10005382fi
Damien Millerf58c6722002-05-13 13:15:42 +10005383echo " Manpage format: $MANTYPE"
Damien Miller7abe09b2003-05-15 10:53:49 +10005384echo " PAM support: $PAM_MSG"
Damien Miller1b06dc32006-08-31 03:24:41 +10005385echo " OSF SIA support: $SIA_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10005386echo " KerberosV support: $KRB5_MSG"
Damien Miller73b42d22006-04-22 21:26:08 +10005387echo " SELinux support: $SELINUX_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10005388echo " MD5 password support: $MD5_MSG"
Darren Tucker16bcc1c2004-11-07 20:14:34 +11005389echo " libedit support: $LIBEDIT_MSG"
Damien Miller523db852017-02-03 16:01:22 +11005390echo " libldns support: $LDNS_MSG"
Damien Miller1b06dc32006-08-31 03:24:41 +10005391echo " Solaris process contract support: $SPC_MSG"
Darren Tucker97528352010-11-05 12:03:05 +11005392echo " Solaris project support: $SP_MSG"
Damien Miller4626cba2016-01-08 14:24:56 +11005393echo " Solaris privilege support: $SPP_MSG"
Damien Miller903e1152002-05-13 14:41:31 +10005394echo " IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10005395echo " Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG"
5396echo " BSD Auth support: $BSD_AUTH_MSG"
5397echo " Random number source: $RAND_MSG"
Damien Miller69ff1df2011-06-23 08:30:03 +10005398echo " Privsep sandbox style: $SANDBOX_STYLE"
Damien Miller764d51e2019-11-01 13:34:49 +11005399echo " PKCS#11 support: $enable_pkcs11"
5400echo " U2F/FIDO support: $enable_sk"
Damien Miller60396b02001-02-18 17:01:00 +11005401
Damien Miller7b22d652000-06-18 14:07:04 +10005402echo ""
5403
Ben Lindstrom28bfc0d2000-12-18 19:58:57 +00005404echo " Host: ${host}"
5405echo " Compiler: ${CC}"
5406echo " Compiler flags: ${CFLAGS}"
5407echo "Preprocessor flags: ${CPPFLAGS}"
5408echo " Linker flags: ${LDFLAGS}"
Darren Tucker20e9f972007-03-25 18:26:01 +10005409echo " Libraries: ${LIBS}"
5410if test ! -z "${SSHDLIBS}"; then
5411echo " +for sshd: ${SSHDLIBS}"
5412fi
Damien Miller71adf122011-01-25 12:16:15 +11005413if test ! -z "${SSHLIBS}"; then
5414echo " +for ssh: ${SSHLIBS}"
5415fi
Damien Miller7b22d652000-06-18 14:07:04 +10005416
5417echo ""
5418
Tim Rice6f1f7582004-05-30 21:38:51 -07005419if test "x$MAKE_PACKAGE_SUPPORTED" = "xyes" ; then
Darren Tuckercf59d312004-08-29 21:18:09 +10005420 echo "SVR4 style packages are supported with \"make package\""
5421 echo ""
Tim Rice6f1f7582004-05-30 21:38:51 -07005422fi
5423
Damien Miller82cf0ce2000-12-20 13:34:48 +11005424if test "x$PAM_MSG" = "xyes" ; then
Damien Miller6c21c512002-01-22 21:57:53 +11005425 echo "PAM is enabled. You may need to install a PAM control file "
5426 echo "for sshd, otherwise password authentication may fail. "
Damien Millera8e06ce2003-11-21 23:48:55 +11005427 echo "Example PAM control files can be found in the contrib/ "
Damien Miller6c21c512002-01-22 21:57:53 +11005428 echo "subdirectory"
Damien Miller6f9c3372000-10-25 10:06:04 +11005429 echo ""
5430fi
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00005431
Damien Millerb4097182004-05-23 14:09:40 +10005432if test ! -z "$NO_PEERCHECK" ; then
Darren Tucker164aa302007-03-21 21:39:57 +11005433 echo "WARNING: the operating system that you are using does not"
5434 echo "appear to support getpeereid(), getpeerucred() or the"
5435 echo "SO_PEERCRED getsockopt() option. These facilities are used to"
5436 echo "enforce security checks to prevent unauthorised connections to"
5437 echo "ssh-agent. Their absence increases the risk that a malicious"
5438 echo "user can connect to your agent."
Damien Millerb4097182004-05-23 14:09:40 +10005439 echo ""
5440fi
5441
Darren Tuckerd9f88912005-02-20 21:01:48 +11005442if test "$AUDIT_MODULE" = "bsm" ; then
5443 echo "WARNING: BSM audit support is currently considered EXPERIMENTAL."
5444 echo "See the Solaris section in README.platform for details."
5445fi