blob: 3814db66b35a76bc3ff22345ce363cc78c36d884 [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])
167 OSSH_CHECK_CFLAG_COMPILE([-fno-strict-aliasing])
Darren Tuckerfd994372014-01-17 09:53:24 +1100168 if test "x$use_toolchain_hardening" = "x1"; then
Darren Tucker3377df02018-02-11 09:32:37 +1100169 OSSH_CHECK_CFLAG_COMPILE([-mretpoline]) # clang
Darren Tucker174bed62018-02-13 18:12:47 +1100170 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,retpolineplt])
Damien Miller161af8f2017-09-19 10:18:56 +1000171 OSSH_CHECK_CFLAG_COMPILE([-D_FORTIFY_SOURCE=2])
Darren Tuckerfd994372014-01-17 09:53:24 +1100172 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,relro])
173 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,now])
174 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,noexecstack])
Damien Miller5c2ff5e2014-01-22 21:30:12 +1100175 # NB. -ftrapv expects certain support functions to be present in
176 # the compiler library (libgcc or similar) to detect integer operations
177 # that can overflow. We must check that the result of enabling it
178 # actually links. The test program compiled/linked includes a number
179 # of integer operations that should exercise this.
180 OSSH_CHECK_CFLAG_LINK([-ftrapv])
Darren Tuckerfd994372014-01-17 09:53:24 +1100181 fi
Tim Rice648f8762011-01-26 12:38:57 -0800182 AC_MSG_CHECKING([gcc version])
Darren Tucker3f9545e2005-11-12 15:20:52 +1100183 GCC_VER=`$CC -v 2>&1 | $AWK '/gcc version /{print $3}'`
Tim Rice3db1e3f2005-08-23 17:11:26 -0700184 case $GCC_VER in
Darren Tucker391de5c2007-04-29 14:49:21 +1000185 1.*) no_attrib_nonnull=1 ;;
186 2.8* | 2.9*)
Darren Tucker391de5c2007-04-29 14:49:21 +1000187 no_attrib_nonnull=1
188 ;;
189 2.*) no_attrib_nonnull=1 ;;
Darren Tuckerf0324352005-11-10 21:30:36 +1100190 *) ;;
Tim Rice3db1e3f2005-08-23 17:11:26 -0700191 esac
Tim Rice648f8762011-01-26 12:38:57 -0800192 AC_MSG_RESULT([$GCC_VER])
Damien Millerde3cb0a2005-05-26 20:48:25 +1000193
Tim Rice648f8762011-01-26 12:38:57 -0800194 AC_MSG_CHECKING([if $CC accepts -fno-builtin-memset])
Darren Tucker330c93f2008-06-16 02:27:48 +1000195 saved_CFLAGS="$CFLAGS"
196 CFLAGS="$CFLAGS -fno-builtin-memset"
Tim Rice648f8762011-01-26 12:38:57 -0800197 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <string.h> ]],
198 [[ char b[10]; memset(b, 0, sizeof(b)); ]])],
199 [ AC_MSG_RESULT([yes]) ],
200 [ AC_MSG_RESULT([no])
Darren Tucker330c93f2008-06-16 02:27:48 +1000201 CFLAGS="$saved_CFLAGS" ]
Tim Rice648f8762011-01-26 12:38:57 -0800202 )
Darren Tucker330c93f2008-06-16 02:27:48 +1000203
Darren Tuckerb7918af2008-03-09 11:34:23 +1100204 # -fstack-protector-all doesn't always work for some GCC versions
Darren Tuckerfe1cf972008-03-09 22:50:50 +1100205 # and/or platforms, so we test if we can. If it's not supported
Damien Miller7df2e402008-12-08 09:35:36 +1100206 # on a given platform gcc will emit a warning so we use -Werror.
Darren Tuckerb7918af2008-03-09 11:34:23 +1100207 if test "x$use_stack_protector" = "x1"; then
Darren Tuckerfd994372014-01-17 09:53:24 +1100208 for t in -fstack-protector-strong -fstack-protector-all \
209 -fstack-protector; do
Tim Rice648f8762011-01-26 12:38:57 -0800210 AC_MSG_CHECKING([if $CC supports $t])
Darren Tuckerb7918af2008-03-09 11:34:23 +1100211 saved_CFLAGS="$CFLAGS"
212 saved_LDFLAGS="$LDFLAGS"
Darren Tuckerfe1cf972008-03-09 22:50:50 +1100213 CFLAGS="$CFLAGS $t -Werror"
214 LDFLAGS="$LDFLAGS $t -Werror"
215 AC_LINK_IFELSE(
Darren Tucker9239a182019-10-24 14:39:49 +1100216 [AC_LANG_PROGRAM([[
217 #include <stdio.h>
218 int func (int t) {char b[100]; snprintf(b,sizeof b,"%d",t); return t;}
219 ]],
Tim Rice648f8762011-01-26 12:38:57 -0800220 [[
221 char x[256];
Darren Tucker9239a182019-10-24 14:39:49 +1100222 snprintf(x, sizeof(x), "XXX%d", func(1));
Tim Rice648f8762011-01-26 12:38:57 -0800223 ]])],
224 [ AC_MSG_RESULT([yes])
Darren Tuckerfe1cf972008-03-09 22:50:50 +1100225 CFLAGS="$saved_CFLAGS $t"
226 LDFLAGS="$saved_LDFLAGS $t"
Tim Rice648f8762011-01-26 12:38:57 -0800227 AC_MSG_CHECKING([if $t works])
Darren Tuckerb7918af2008-03-09 11:34:23 +1100228 AC_RUN_IFELSE(
Darren Tucker9239a182019-10-24 14:39:49 +1100229 [AC_LANG_PROGRAM([[
230 #include <stdio.h>
231 int func (int t) {char b[100]; snprintf(b,sizeof b,"%d",t); return t;}
232 ]],
Tim Rice648f8762011-01-26 12:38:57 -0800233 [[
234 char x[256];
Darren Tucker9239a182019-10-24 14:39:49 +1100235 snprintf(x, sizeof(x), "XXX%d", func(1));
Tim Rice648f8762011-01-26 12:38:57 -0800236 ]])],
237 [ AC_MSG_RESULT([yes])
Darren Tuckerb7918af2008-03-09 11:34:23 +1100238 break ],
Tim Rice648f8762011-01-26 12:38:57 -0800239 [ AC_MSG_RESULT([no]) ],
Darren Tuckerb7918af2008-03-09 11:34:23 +1100240 [ AC_MSG_WARN([cross compiling: cannot test])
241 break ]
Darren Tuckerfe1cf972008-03-09 22:50:50 +1100242 )
Darren Tuckerb7918af2008-03-09 11:34:23 +1100243 ],
Tim Rice648f8762011-01-26 12:38:57 -0800244 [ AC_MSG_RESULT([no]) ]
Darren Tuckerb7918af2008-03-09 11:34:23 +1100245 )
246 CFLAGS="$saved_CFLAGS"
247 LDFLAGS="$saved_LDFLAGS"
248 done
249 fi
Darren Tucker319b3d92007-12-02 21:02:22 +1100250
Darren Tucker67b37032005-06-03 17:58:31 +1000251 if test -z "$have_llong_max"; then
252 # retry LLONG_MAX with -std=gnu99, needed on some Linuxes
253 unset ac_cv_have_decl_LLONG_MAX
254 saved_CFLAGS="$CFLAGS"
255 CFLAGS="$CFLAGS -std=gnu99"
Tim Rice648f8762011-01-26 12:38:57 -0800256 AC_CHECK_DECL([LLONG_MAX],
Darren Tucker67b37032005-06-03 17:58:31 +1000257 [have_llong_max=1],
258 [CFLAGS="$saved_CFLAGS"],
259 [#include <limits.h>]
260 )
261 fi
Damien Miller166bd442000-03-16 10:48:25 +1100262fi
263
Darren Tucker951b53b2013-02-08 11:50:09 +1100264AC_MSG_CHECKING([if compiler allows __attribute__ on return types])
265AC_COMPILE_IFELSE(
266 [AC_LANG_PROGRAM([[
267#include <stdlib.h>
268__attribute__((__unused__)) static void foo(void){return;}]],
269 [[ exit(0); ]])],
270 [ AC_MSG_RESULT([yes]) ],
271 [ AC_MSG_RESULT([no])
272 AC_DEFINE(NO_ATTRIBUTE_ON_RETURN_TYPE, 1,
273 [compiler does not accept __attribute__ on return types]) ]
274)
275
Darren Tucker1323f122018-02-27 08:41:25 +1100276AC_MSG_CHECKING([if compiler allows __attribute__ prototype args])
277AC_COMPILE_IFELSE(
278 [AC_LANG_PROGRAM([[
279#include <stdlib.h>
280typedef void foo(const char *, ...) __attribute__((format(printf, 1, 2)));]],
281 [[ exit(0); ]])],
282 [ AC_MSG_RESULT([yes]) ],
283 [ AC_MSG_RESULT([no])
284 AC_DEFINE(NO_ATTRIBUTE_ON_PROTOTYPE_ARGS, 1,
Damien Miller10479cc2018-04-10 10:19:02 +1000285 [compiler does not accept __attribute__ on prototype args]) ]
Darren Tucker1323f122018-02-27 08:41:25 +1100286)
287
Darren Tucker391de5c2007-04-29 14:49:21 +1000288if test "x$no_attrib_nonnull" != "x1" ; then
Tim Rice648f8762011-01-26 12:38:57 -0800289 AC_DEFINE([HAVE_ATTRIBUTE__NONNULL__], [1], [Have attribute nonnull])
Darren Tucker391de5c2007-04-29 14:49:21 +1000290fi
291
Tim Rice648f8762011-01-26 12:38:57 -0800292AC_ARG_WITH([rpath],
Tim Rice88368a32003-12-08 12:35:59 -0800293 [ --without-rpath Disable auto-added -R linker paths],
294 [
Tim Riceeae17cc2005-03-17 16:52:20 -0800295 if test "x$withval" = "xno" ; then
Darren Tucker2f0bad22019-01-21 21:28:27 +1100296 rpath_opt=""
297 elif test "x$withval" = "xyes" ; then
298 rpath_opt="-R"
299 else
300 rpath_opt="$withval"
Tim Rice88368a32003-12-08 12:35:59 -0800301 fi
302 ]
303)
304
Tim Rice1cfab232006-10-03 09:34:35 -0700305# Allow user to specify flags
Tim Rice648f8762011-01-26 12:38:57 -0800306AC_ARG_WITH([cflags],
Tim Rice1cfab232006-10-03 09:34:35 -0700307 [ --with-cflags Specify additional flags to pass to compiler],
308 [
309 if test -n "$withval" && test "x$withval" != "xno" && \
310 test "x${withval}" != "xyes"; then
311 CFLAGS="$CFLAGS $withval"
312 fi
313 ]
314)
Damien Millerde35c382017-09-08 12:38:31 +1000315
316AC_ARG_WITH([cflags-after],
317 [ --with-cflags-after Specify additional flags to pass to compiler after configure],
318 [
319 if test -n "$withval" && test "x$withval" != "xno" && \
320 test "x${withval}" != "xyes"; then
321 CFLAGS_AFTER="$withval"
322 fi
323 ]
324)
Tim Rice648f8762011-01-26 12:38:57 -0800325AC_ARG_WITH([cppflags],
Tim Rice1cfab232006-10-03 09:34:35 -0700326 [ --with-cppflags Specify additional flags to pass to preprocessor] ,
327 [
328 if test -n "$withval" && test "x$withval" != "xno" && \
329 test "x${withval}" != "xyes"; then
330 CPPFLAGS="$CPPFLAGS $withval"
331 fi
332 ]
333)
Tim Rice648f8762011-01-26 12:38:57 -0800334AC_ARG_WITH([ldflags],
Tim Rice1cfab232006-10-03 09:34:35 -0700335 [ --with-ldflags Specify additional flags to pass to linker],
336 [
337 if test -n "$withval" && test "x$withval" != "xno" && \
338 test "x${withval}" != "xyes"; then
339 LDFLAGS="$LDFLAGS $withval"
340 fi
341 ]
342)
Damien Millerde35c382017-09-08 12:38:31 +1000343AC_ARG_WITH([ldflags-after],
344 [ --with-ldflags-after Specify additional flags to pass to linker after configure],
345 [
346 if test -n "$withval" && test "x$withval" != "xno" && \
347 test "x${withval}" != "xyes"; then
348 LDFLAGS_AFTER="$withval"
349 fi
350 ]
351)
Tim Rice648f8762011-01-26 12:38:57 -0800352AC_ARG_WITH([libs],
Tim Rice1cfab232006-10-03 09:34:35 -0700353 [ --with-libs Specify additional libraries to link with],
354 [
355 if test -n "$withval" && test "x$withval" != "xno" && \
356 test "x${withval}" != "xyes"; then
357 LIBS="$LIBS $withval"
358 fi
359 ]
360)
Tim Rice648f8762011-01-26 12:38:57 -0800361AC_ARG_WITH([Werror],
Tim Rice1cfab232006-10-03 09:34:35 -0700362 [ --with-Werror Build main code with -Werror],
363 [
364 if test -n "$withval" && test "x$withval" != "xno"; then
365 werror_flags="-Werror"
366 if test "x${withval}" != "xyes"; then
367 werror_flags="$withval"
368 fi
369 fi
370 ]
371)
372
Tim Rice648f8762011-01-26 12:38:57 -0800373AC_CHECK_HEADERS([ \
Damien Miller1ff130d2013-12-07 11:51:51 +1100374 blf.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700375 bstring.h \
376 crypt.h \
377 crypto/sha2.h \
378 dirent.h \
379 endian.h \
Damien Miller91f40d82013-02-22 11:37:00 +1100380 elf.h \
Darren Tucker6310ef22016-07-13 14:42:35 +1000381 err.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700382 features.h \
383 fcntl.h \
384 floatingpoint.h \
Darren Tucker0e3c5bc2019-11-01 18:24:29 +1100385 fnmatch.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700386 getopt.h \
387 glob.h \
388 ia.h \
389 iaf.h \
Darren Tuckerb59162d2018-02-23 15:20:42 +1100390 ifaddrs.h \
Darren Tucker6d725682014-01-17 19:17:34 +1100391 inttypes.h \
Darren Tuckerf3f2cc82016-07-11 17:23:38 +1000392 langinfo.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700393 limits.h \
Darren Tuckerae133d42013-06-06 08:30:20 +1000394 locale.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700395 login.h \
396 maillock.h \
397 ndir.h \
398 net/if_tun.h \
399 netdb.h \
400 netgroup.h \
401 pam/pam_appl.h \
402 paths.h \
Darren Tuckerfebf0f52007-06-25 22:15:12 +1000403 poll.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700404 pty.h \
405 readpassphrase.h \
406 rpc/types.h \
407 security/pam_appl.h \
408 sha2.h \
409 shadow.h \
410 stddef.h \
411 stdint.h \
412 string.h \
413 strings.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700414 sys/bitypes.h \
415 sys/bsdtty.h \
416 sys/cdefs.h \
417 sys/dir.h \
Damien Millerf8854742018-02-26 12:18:14 +1100418 sys/file.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700419 sys/mman.h \
Darren Tuckerce066f62018-02-22 20:45:09 +1100420 sys/label.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700421 sys/ndir.h \
Darren Tucker7c92a652007-09-27 07:00:09 +1000422 sys/poll.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700423 sys/prctl.h \
424 sys/pstat.h \
Darren Tucker5ee3fb52016-11-01 08:12:33 +1100425 sys/ptrace.h \
Damien Millerafa6e792018-04-13 13:31:42 +1000426 sys/random.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700427 sys/select.h \
428 sys/stat.h \
429 sys/stream.h \
430 sys/stropts.h \
431 sys/strtio.h \
Darren Tucker5b2e2ba2008-06-08 09:25:28 +1000432 sys/statvfs.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700433 sys/sysmacros.h \
434 sys/time.h \
435 sys/timers.h \
Darren Tucker11057562018-02-25 11:22:57 +1100436 sys/vfs.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700437 time.h \
438 tmpdir.h \
439 ttyent.h \
Tim Riceaa8954f2007-05-09 15:57:43 -0700440 ucred.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700441 unistd.h \
442 usersec.h \
443 util.h \
444 utime.h \
445 utmp.h \
446 utmpx.h \
447 vis.h \
Darren Tuckerf3f2cc82016-07-11 17:23:38 +1000448 wchar.h \
Tim Rice648f8762011-01-26 12:38:57 -0800449])
Tim Rice1cfab232006-10-03 09:34:35 -0700450
Darren Tuckerce066f62018-02-22 20:45:09 +1100451# On some platforms (eg SunOS4) sys/audit.h requires sys/[time|types|label.h]
452# to be included first.
453AC_CHECK_HEADERS([sys/audit.h], [], [], [
454#ifdef HAVE_SYS_TIME_H
455# include <sys/time.h>
456#endif
457#ifdef HAVE_SYS_TYPES_H
458# include <sys/types.h>
459#endif
460#ifdef HAVE_SYS_LABEL_H
461# include <sys/label.h>
462#endif
463])
464
Darren Tuckerdd9d9b32017-08-28 16:48:27 +1000465# sys/capsicum.h requires sys/types.h
466AC_CHECK_HEADERS([sys/capsicum.h], [], [], [
467#ifdef HAVE_SYS_TYPES_H
468# include <sys/types.h>
469#endif
470])
471
Darren Tuckerfa1b8342017-11-03 14:09:45 +1100472# net/route.h requires sys/socket.h and sys/types.h.
473# sys/sysctl.h also requires sys/param.h
474AC_CHECK_HEADERS([net/route.h sys/sysctl.h], [], [], [
475#ifdef HAVE_SYS_TYPES_H
476# include <sys/types.h>
477#endif
478#include <sys/param.h>
Damien Miller32354732017-10-25 11:25:43 +1100479#include <sys/socket.h>
480])
481
Tim Rice1cfab232006-10-03 09:34:35 -0700482# lastlog.h requires sys/time.h to be included first on Solaris
Tim Rice648f8762011-01-26 12:38:57 -0800483AC_CHECK_HEADERS([lastlog.h], [], [], [
Tim Rice1cfab232006-10-03 09:34:35 -0700484#ifdef HAVE_SYS_TIME_H
485# include <sys/time.h>
486#endif
487])
488
489# sys/ptms.h requires sys/stream.h to be included first on Solaris
Tim Rice648f8762011-01-26 12:38:57 -0800490AC_CHECK_HEADERS([sys/ptms.h], [], [], [
Tim Rice1cfab232006-10-03 09:34:35 -0700491#ifdef HAVE_SYS_STREAM_H
492# include <sys/stream.h>
493#endif
494])
495
496# login_cap.h requires sys/types.h on NetBSD
Tim Rice648f8762011-01-26 12:38:57 -0800497AC_CHECK_HEADERS([login_cap.h], [], [], [
Tim Rice1cfab232006-10-03 09:34:35 -0700498#include <sys/types.h>
499])
500
Darren Tuckerc4b22ca2009-07-12 21:56:29 +1000501# older BSDs need sys/param.h before sys/mount.h
Tim Rice648f8762011-01-26 12:38:57 -0800502AC_CHECK_HEADERS([sys/mount.h], [], [], [
Darren Tuckerc4b22ca2009-07-12 21:56:29 +1000503#include <sys/param.h>
504])
505
Darren Tuckeref4901c2013-06-03 01:59:13 +1000506# Android requires sys/socket.h to be included before sys/un.h
507AC_CHECK_HEADERS([sys/un.h], [], [], [
Darren Tucker0b43ffe2013-06-03 09:30:44 +1000508#include <sys/types.h>
Darren Tucker16cac192013-06-04 12:55:24 +1000509#include <sys/socket.h>
Darren Tuckeref4901c2013-06-03 01:59:13 +1000510])
511
Damien Miller1b06dc32006-08-31 03:24:41 +1000512# Messages for features tested for in target-specific section
513SIA_MSG="no"
514SPC_MSG="no"
Darren Tucker97528352010-11-05 12:03:05 +1100515SP_MSG="no"
Damien Miller4626cba2016-01-08 14:24:56 +1100516SPP_MSG="no"
517
518# Support for Solaris/Illumos privileges (this test is used by both
519# the --with-solaris-privs option and --with-sandbox=solaris).
520SOLARIS_PRIVS="no"
Damien Miller1b06dc32006-08-31 03:24:41 +1000521
Damien Millera22ba012000-03-02 23:09:20 +1100522# Check for some target-specific stuff
Damien Miller76112de1999-12-21 11:18:08 +1100523case "$host" in
Damien Miller75b1d102000-01-07 14:01:41 +1100524*-*-aix*)
Darren Tucker9216c372006-09-18 23:17:40 +1000525 # Some versions of VAC won't allow macro redefinitions at
526 # -qlanglevel=ansi, and autoconf 2.60 sometimes insists on using that
527 # particularly with older versions of vac or xlc.
Damien Miller10479cc2018-04-10 10:19:02 +1000528 # It also throws errors about null macro arguments, but these are
Darren Tucker9216c372006-09-18 23:17:40 +1000529 # not fatal.
Tim Rice648f8762011-01-26 12:38:57 -0800530 AC_MSG_CHECKING([if compiler allows macro redefinitions])
Darren Tucker9216c372006-09-18 23:17:40 +1000531 AC_COMPILE_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -0800532 [AC_LANG_PROGRAM([[
Darren Tucker9216c372006-09-18 23:17:40 +1000533#define testmacro foo
Tim Rice648f8762011-01-26 12:38:57 -0800534#define testmacro bar]],
535 [[ exit(0); ]])],
536 [ AC_MSG_RESULT([yes]) ],
537 [ AC_MSG_RESULT([no])
Darren Tucker9216c372006-09-18 23:17:40 +1000538 CC="`echo $CC | sed 's/-qlanglvl\=ansi//g'`"
Darren Tucker9216c372006-09-18 23:17:40 +1000539 CFLAGS="`echo $CFLAGS | sed 's/-qlanglvl\=ansi//g'`"
540 CPPFLAGS="`echo $CPPFLAGS | sed 's/-qlanglvl\=ansi//g'`"
541 ]
542 )
543
Damien Millera8e06ce2003-11-21 23:48:55 +1100544 AC_MSG_CHECKING([how to specify blibpath for linker ($LD)])
Damien Millereab4bae2003-04-29 23:22:40 +1000545 if (test -z "$blibpath"); then
Tim Ricefcb62202004-01-23 18:35:16 -0800546 blibpath="/usr/lib:/lib"
Damien Miller29ea30d2000-03-17 10:54:15 +1100547 fi
Damien Millereab4bae2003-04-29 23:22:40 +1000548 saved_LDFLAGS="$LDFLAGS"
Darren Tuckerbdc12122006-07-06 11:56:25 +1000549 if test "$GCC" = "yes"; then
550 flags="-Wl,-blibpath: -Wl,-rpath, -blibpath:"
551 else
552 flags="-blibpath: -Wl,-blibpath: -Wl,-rpath,"
553 fi
554 for tryflags in $flags ;do
Damien Millereab4bae2003-04-29 23:22:40 +1000555 if (test -z "$blibflags"); then
556 LDFLAGS="$saved_LDFLAGS $tryflags$blibpath"
Tim Rice648f8762011-01-26 12:38:57 -0800557 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
558 [blibflags=$tryflags], [])
Damien Millereab4bae2003-04-29 23:22:40 +1000559 fi
560 done
561 if (test -z "$blibflags"); then
Tim Rice648f8762011-01-26 12:38:57 -0800562 AC_MSG_RESULT([not found])
Damien Millereab4bae2003-04-29 23:22:40 +1000563 AC_MSG_ERROR([*** must be able to specify blibpath on AIX - check config.log])
564 else
Tim Rice648f8762011-01-26 12:38:57 -0800565 AC_MSG_RESULT([$blibflags])
Damien Millereab4bae2003-04-29 23:22:40 +1000566 fi
567 LDFLAGS="$saved_LDFLAGS"
Darren Tucker5c6a91a2003-07-14 16:21:44 +1000568 dnl Check for authenticate. Might be in libs.a on older AIXes
Tim Rice648f8762011-01-26 12:38:57 -0800569 AC_CHECK_FUNC([authenticate], [AC_DEFINE([WITH_AIXAUTHENTICATE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700570 [Define if you want to enable AIX4's authenticate function])],
Tim Rice648f8762011-01-26 12:38:57 -0800571 [AC_CHECK_LIB([s], [authenticate],
572 [ AC_DEFINE([WITH_AIXAUTHENTICATE])
Tim Ricee958ed32002-07-05 07:12:33 -0700573 LIBS="$LIBS -ls"
574 ])
575 ])
Darren Tucker3c774c52005-02-16 22:49:31 +1100576 dnl Check for various auth function declarations in headers.
Darren Tucker04cfbe02005-02-20 23:27:11 +1100577 AC_CHECK_DECLS([authenticate, loginrestrictions, loginsuccess,
Darren Tuckere66519d2005-03-21 22:46:34 +1100578 passwdexpired, setauthdb], , , [#include <usersec.h>])
Darren Tucker5c6a91a2003-07-14 16:21:44 +1000579 dnl Check if loginfailed is declared and takes 4 arguments (AIX >= 5.2)
Tim Rice648f8762011-01-26 12:38:57 -0800580 AC_CHECK_DECLS([loginfailed],
581 [AC_MSG_CHECKING([if loginfailed takes 4 arguments])
582 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <usersec.h> ]],
583 [[ (void)loginfailed("user","host","tty",0); ]])],
584 [AC_MSG_RESULT([yes])
585 AC_DEFINE([AIX_LOGINFAILED_4ARG], [1],
586 [Define if your AIX loginfailed() function
587 takes 4 arguments (AIX >= 5.2)])], [AC_MSG_RESULT([no])
588 ])],
589 [],
590 [#include <usersec.h>]
Darren Tucker5c6a91a2003-07-14 16:21:44 +1000591 )
Tim Rice648f8762011-01-26 12:38:57 -0800592 AC_CHECK_FUNCS([getgrset setauthdb])
593 AC_CHECK_DECL([F_CLOSEM],
594 AC_DEFINE([HAVE_FCNTL_CLOSEM], [1], [Use F_CLOSEM fcntl for closefrom]),
Darren Tucker3083bc22006-08-17 19:35:49 +1000595 [],
596 [ #include <limits.h>
597 #include <fcntl.h> ]
598 )
Darren Tucker691d5232005-02-15 21:45:57 +1100599 check_for_aix_broken_getaddrinfo=1
Tim Rice648f8762011-01-26 12:38:57 -0800600 AC_DEFINE([SETEUID_BREAKS_SETUID], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700601 [Define if your platform breaks doing a seteuid before a setuid])
Tim Rice648f8762011-01-26 12:38:57 -0800602 AC_DEFINE([BROKEN_SETREUID], [1], [Define if your setreuid() is broken])
603 AC_DEFINE([BROKEN_SETREGID], [1], [Define if your setregid() is broken])
andre60f3c982000-06-03 16:18:19 +0000604 dnl AIX handles lastlog as part of its login message
Tim Rice648f8762011-01-26 12:38:57 -0800605 AC_DEFINE([DISABLE_LASTLOG], [1], [Define if you don't want to use lastlog])
606 AC_DEFINE([LOGIN_NEEDS_UTMPX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700607 [Some systems need a utmpx entry for /bin/login to work])
Tim Rice648f8762011-01-26 12:38:57 -0800608 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV],
Tim Rice7df8d392005-09-19 09:33:39 -0700609 [Define to a Set Process Title type if your system is
610 supported by bsd-setproctitle.c])
Tim Rice648f8762011-01-26 12:38:57 -0800611 AC_DEFINE([SSHPAM_CHAUTHTOK_NEEDS_RUID], [1],
Darren Tucker91d25a02005-11-26 22:24:09 +1100612 [AIX 5.2 and 5.3 (and presumably newer) require this])
Tim Rice648f8762011-01-26 12:38:57 -0800613 AC_DEFINE([PTY_ZEROREAD], [1], [read(1) can return 0 for a non-closed fd])
Darren Tuckeraa97d132013-03-12 11:31:05 +1100614 AC_DEFINE([PLATFORM_SYS_DIR_UID], 2, [System dirs owned by bin (uid 2)])
Darren Tucker2c71ca12018-03-30 18:23:07 +1100615 AC_DEFINE([BROKEN_STRNDUP], 1, [strndup broken, see APAR IY61211])
616 AC_DEFINE([BROKEN_STRNLEN], 1, [strnlen broken, see APAR IY62551])
Damien Miller75b1d102000-01-07 14:01:41 +1100617 ;;
Darren Tucker898ac932013-06-03 02:03:25 +1000618*-*-android*)
619 AC_DEFINE([DISABLE_UTMP], [1], [Define if you don't want to use utmp])
620 AC_DEFINE([DISABLE_WTMP], [1], [Define if you don't want to use wtmp])
621 ;;
Damien Millerbac2d8a2000-09-05 16:13:06 +1100622*-*-cygwin*)
Damien Millerc8936ac2003-02-11 10:04:03 +1100623 check_for_libcrypt_later=1
Darren Tucker573e3872007-03-02 17:50:03 +1100624 LIBS="$LIBS /usr/lib/textreadmode.o"
Tim Rice648f8762011-01-26 12:38:57 -0800625 AC_DEFINE([HAVE_CYGWIN], [1], [Define if you are on Cygwin])
626 AC_DEFINE([USE_PIPES], [1], [Use PIPES instead of a socketpair()])
Damien Miller4626cba2016-01-08 14:24:56 +1100627 AC_DEFINE([NO_UID_RESTORATION_TEST], [1],
628 [Define to disable UID restoration test])
Tim Rice648f8762011-01-26 12:38:57 -0800629 AC_DEFINE([DISABLE_SHADOW], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700630 [Define if you want to disable shadow passwords])
Tim Rice648f8762011-01-26 12:38:57 -0800631 AC_DEFINE([NO_X11_UNIX_SOCKETS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700632 [Define if X11 doesn't support AF_UNIX sockets on that system])
Tim Rice648f8762011-01-26 12:38:57 -0800633 AC_DEFINE([DISABLE_FD_PASSING], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700634 [Define if your platform needs to skip post auth
635 file descriptor passing])
Tim Rice648f8762011-01-26 12:38:57 -0800636 AC_DEFINE([SSH_IOBUFSZ], [65535], [Windows is sensitive to read buffer size])
Darren Tuckerfdce3732014-01-18 21:12:42 +1100637 AC_DEFINE([FILESYSTEM_NO_BACKSLASH], [1], [File names may not contain backslash characters])
638 # Cygwin defines optargs, optargs as declspec(dllimport) for historical
639 # reasons which cause compile warnings, so we disable those warnings.
640 OSSH_CHECK_CFLAG_COMPILE([-Wno-attributes])
Damien Millerbac2d8a2000-09-05 16:13:06 +1100641 ;;
Ben Lindstrom58055132001-02-15 18:34:29 +0000642*-*-dgux*)
Tim Rice648f8762011-01-26 12:38:57 -0800643 AC_DEFINE([IP_TOS_IS_BROKEN], [1],
Tim Ricea74000e2009-03-18 11:25:02 -0700644 [Define if your system choked on IP TOS setting])
Tim Rice648f8762011-01-26 12:38:57 -0800645 AC_DEFINE([SETEUID_BREAKS_SETUID])
646 AC_DEFINE([BROKEN_SETREUID])
647 AC_DEFINE([BROKEN_SETREGID])
Ben Lindstrom58055132001-02-15 18:34:29 +0000648 ;;
Ben Lindstromfed7bb42001-07-15 18:30:42 +0000649*-*-darwin*)
Damien Miller852472a2014-01-22 16:31:18 +1100650 use_pie=auto
Tim Rice648f8762011-01-26 12:38:57 -0800651 AC_MSG_CHECKING([if we have working getaddrinfo])
652 AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <mach-o/dyld.h>
Damien Millerfc93d4b2002-09-04 23:26:29 +1000653main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
654 exit(0);
655 else
656 exit(1);
Tim Rice648f8762011-01-26 12:38:57 -0800657}
658 ]])],
659 [AC_MSG_RESULT([working])],
660 [AC_MSG_RESULT([buggy])
661 AC_DEFINE([BROKEN_GETADDRINFO], [1],
662 [getaddrinfo is broken (if present)])
663 ],
664 [AC_MSG_RESULT([assume it is working])])
665 AC_DEFINE([SETEUID_BREAKS_SETUID])
666 AC_DEFINE([BROKEN_SETREUID])
667 AC_DEFINE([BROKEN_SETREGID])
668 AC_DEFINE([BROKEN_GLOB], [1], [OS X glob does not do what we expect])
669 AC_DEFINE_UNQUOTED([BIND_8_COMPAT], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700670 [Define if your resolver libs need this for getrrsetbyname])
Tim Rice648f8762011-01-26 12:38:57 -0800671 AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
672 AC_DEFINE([SSH_TUN_COMPAT_AF], [1],
Darren Tucker3eb48342006-06-23 21:05:12 +1000673 [Use tunnel device compatibility to OpenBSD])
Tim Rice648f8762011-01-26 12:38:57 -0800674 AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
Darren Tucker3eb48342006-06-23 21:05:12 +1000675 [Prepend the address family to IP tunnel traffic])
Tim Rice648f8762011-01-26 12:38:57 -0800676 m4_pattern_allow([AU_IPv])
Tim Ricee1d93702016-05-31 11:13:22 -0700677 AC_CHECK_DECL([AU_IPv4], [],
Tim Rice648f8762011-01-26 12:38:57 -0800678 AC_DEFINE([AU_IPv4], [0], [System only supports IPv4 audit records])
Darren Tuckeracada072008-02-25 21:05:04 +1100679 [#include <bsm/audit.h>]
Tim Rice648f8762011-01-26 12:38:57 -0800680 AC_DEFINE([LASTLOG_WRITE_PUTUTXLINE], [1],
Damien Miller20e231f2009-02-12 13:12:21 +1100681 [Define if pututxline updates lastlog too])
Darren Tuckeracada072008-02-25 21:05:04 +1100682 )
Damien Millerc09182f2011-06-03 12:11:38 +1000683 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV],
684 [Define to a Set Process Title type if your system is
685 supported by bsd-setproctitle.c])
Damien Millercd5e52e2011-06-27 07:18:18 +1000686 AC_CHECK_FUNCS([sandbox_init])
687 AC_CHECK_HEADERS([sandbox.h])
Damien Miller39f303b2016-02-23 12:56:59 +1100688 AC_CHECK_LIB([sandbox], [sandbox_apply], [
689 SSHDLIBS="$SSHDLIBS -lsandbox"
690 ])
Damien Miller28744182019-08-30 13:21:38 +1000691 # proc_pidinfo()-based closefrom() replacement.
692 AC_CHECK_HEADERS([libproc.h])
693 AC_CHECK_FUNCS([proc_pidinfo])
Ben Lindstromfed7bb42001-07-15 18:30:42 +0000694 ;;
Darren Tucker57b29202006-09-10 20:25:51 +1000695*-*-dragonfly*)
696 SSHDLIBS="$SSHDLIBS -lcrypt"
Darren Tucker882abfd2013-11-09 00:17:41 +1100697 TEST_MALLOC_OPTIONS="AFGJPRX"
Darren Tucker57b29202006-09-10 20:25:51 +1000698 ;;
Tim Ricee1d93702016-05-31 11:13:22 -0700699*-*-haiku*)
Darren Tucker5faa52d2016-08-02 15:22:40 +1000700 LIBS="$LIBS -lbsd "
Darren Tuckerbb4f0032019-11-01 15:06:16 +1100701 CFLAGS="$CFLAGS -D_BSD_SOURCE"
Darren Tucker5faa52d2016-08-02 15:22:40 +1000702 AC_CHECK_LIB([network], [socket])
703 AC_DEFINE([HAVE_U_INT64_T])
Darren Tuckerbb4f0032019-11-01 15:06:16 +1100704 AC_DEFINE([DISABLE_UTMPX], [1], [no utmpx])
Darren Tucker5faa52d2016-08-02 15:22:40 +1000705 MANTYPE=man
706 ;;
Darren Tuckerfd333282005-05-28 18:31:42 +1000707*-*-hpux*)
708 # first we define all of the options common to all HP-UX releases
Kevin Steves315f8b72001-06-28 00:24:41 +0000709 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
Damien Miller9a947342000-08-30 10:03:33 +1100710 IPADDR_IN_DISPLAY=yes
Tim Rice648f8762011-01-26 12:38:57 -0800711 AC_DEFINE([USE_PIPES])
Tim Rice648f8762011-01-26 12:38:57 -0800712 AC_DEFINE([LOGIN_NEEDS_UTMPX])
713 AC_DEFINE([LOCKED_PASSWD_STRING], ["*"],
Tim Rice7df8d392005-09-19 09:33:39 -0700714 [String used in /etc/passwd to denote locked account])
Tim Rice648f8762011-01-26 12:38:57 -0800715 AC_DEFINE([SPT_TYPE], [SPT_PSTAT])
Darren Tuckeraa97d132013-03-12 11:31:05 +1100716 AC_DEFINE([PLATFORM_SYS_DIR_UID], 2, [System dirs owned by bin (uid 2)])
Tim Rice90f42b02011-06-02 18:17:49 -0700717 maildir="/var/mail"
Tim Ricef028f1e2002-07-19 12:41:10 -0700718 LIBS="$LIBS -lsec"
Tim Rice648f8762011-01-26 12:38:57 -0800719 AC_CHECK_LIB([xnet], [t_error], ,
720 [AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***])])
Darren Tuckerfd333282005-05-28 18:31:42 +1000721
722 # next, we define all of the options specific to major releases
723 case "$host" in
724 *-*-hpux10*)
725 if test -z "$GCC"; then
726 CFLAGS="$CFLAGS -Ae"
727 fi
728 ;;
729 *-*-hpux11*)
Tim Rice648f8762011-01-26 12:38:57 -0800730 AC_DEFINE([PAM_SUN_CODEBASE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700731 [Define if you are using Solaris-derived PAM which
732 passes pam_messages to the conversation function
733 with an extra level of indirection])
Tim Rice648f8762011-01-26 12:38:57 -0800734 AC_DEFINE([DISABLE_UTMP], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700735 [Define if you don't want to use utmp])
Tim Rice648f8762011-01-26 12:38:57 -0800736 AC_DEFINE([USE_BTMP], [1], [Use btmp to log bad logins])
Darren Tuckerfd333282005-05-28 18:31:42 +1000737 check_for_hpux_broken_getaddrinfo=1
738 check_for_conflicting_getspnam=1
739 ;;
740 esac
741
742 # lastly, we define options specific to minor releases
743 case "$host" in
744 *-*-hpux10.26)
Tim Rice648f8762011-01-26 12:38:57 -0800745 AC_DEFINE([HAVE_SECUREWARE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700746 [Define if you have SecureWare-based
747 protected password database])
Darren Tuckerfd333282005-05-28 18:31:42 +1000748 disable_ptmx_check=yes
749 LIBS="$LIBS -lsecpw"
750 ;;
751 esac
Damien Miller1bead332000-04-30 00:47:29 +1000752 ;;
Damien Millerbeb4ba51999-12-28 15:09:35 +1100753*-*-irix5*)
Damien Miller190d5a82000-09-30 09:43:19 +1100754 PATH="$PATH:/usr/etc"
Tim Rice648f8762011-01-26 12:38:57 -0800755 AC_DEFINE([BROKEN_INET_NTOA], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700756 [Define if you system's inet_ntoa is busted
757 (e.g. Irix gcc issue)])
Tim Rice648f8762011-01-26 12:38:57 -0800758 AC_DEFINE([SETEUID_BREAKS_SETUID])
759 AC_DEFINE([BROKEN_SETREUID])
760 AC_DEFINE([BROKEN_SETREGID])
761 AC_DEFINE([WITH_ABBREV_NO_TTY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700762 [Define if you shouldn't strip 'tty' from your
763 ttyname in [uw]tmp])
Tim Rice648f8762011-01-26 12:38:57 -0800764 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Damien Miller1808f382000-01-06 12:03:12 +1100765 ;;
766*-*-irix6*)
Damien Miller190d5a82000-09-30 09:43:19 +1100767 PATH="$PATH:/usr/etc"
Tim Rice648f8762011-01-26 12:38:57 -0800768 AC_DEFINE([WITH_IRIX_ARRAY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700769 [Define if you have/want arrays
Damien Miller10479cc2018-04-10 10:19:02 +1000770 (cluster-wide session management, not C arrays)])
Tim Rice648f8762011-01-26 12:38:57 -0800771 AC_DEFINE([WITH_IRIX_PROJECT], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700772 [Define if you want IRIX project management])
Tim Rice648f8762011-01-26 12:38:57 -0800773 AC_DEFINE([WITH_IRIX_AUDIT], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700774 [Define if you want IRIX audit trails])
Tim Rice648f8762011-01-26 12:38:57 -0800775 AC_CHECK_FUNC([jlimit_startjob], [AC_DEFINE([WITH_IRIX_JOBS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700776 [Define if you want IRIX kernel jobs])])
Tim Rice648f8762011-01-26 12:38:57 -0800777 AC_DEFINE([BROKEN_INET_NTOA])
778 AC_DEFINE([SETEUID_BREAKS_SETUID])
779 AC_DEFINE([BROKEN_SETREUID])
780 AC_DEFINE([BROKEN_SETREGID])
781 AC_DEFINE([BROKEN_UPDWTMPX], [1], [updwtmpx is broken (if present)])
782 AC_DEFINE([WITH_ABBREV_NO_TTY])
783 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Damien Millerbeb4ba51999-12-28 15:09:35 +1100784 ;;
Damien Miller90551722009-02-16 15:37:03 +1100785*-*-k*bsd*-gnu | *-*-kopensolaris*-gnu)
786 check_for_libcrypt_later=1
Tim Rice648f8762011-01-26 12:38:57 -0800787 AC_DEFINE([PAM_TTY_KLUDGE])
788 AC_DEFINE([LOCKED_PASSWD_PREFIX], ["!"])
789 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV])
790 AC_DEFINE([_PATH_BTMP], ["/var/log/btmp"], [log for bad login attempts])
791 AC_DEFINE([USE_BTMP], [1], [Use btmp to log bad logins])
Damien Miller90551722009-02-16 15:37:03 +1100792 ;;
Damien Millerb29ea912000-01-15 14:12:03 +1100793*-*-linux*)
794 no_dev_ptmx=1
Damien Miller852472a2014-01-22 16:31:18 +1100795 use_pie=auto
Damien Millera64b57a2001-01-17 10:44:13 +1100796 check_for_libcrypt_later=1
Darren Tucker70a3d552003-08-21 17:58:29 +1000797 check_for_openpty_ctty_bug=1
Darren Tuckerc61d5ec2017-02-03 14:10:34 +1100798 dnl Target SUSv3/POSIX.1-2001 plus BSD specifics.
799 dnl _DEFAULT_SOURCE is the new name for _BSD_SOURCE
800 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_DEFAULT_SOURCE"
Tim Rice648f8762011-01-26 12:38:57 -0800801 AC_DEFINE([PAM_TTY_KLUDGE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700802 [Work around problematic Linux PAM modules handling of PAM_TTY])
Tim Rice648f8762011-01-26 12:38:57 -0800803 AC_DEFINE([LOCKED_PASSWD_PREFIX], ["!"],
Tim Rice7df8d392005-09-19 09:33:39 -0700804 [String used in /etc/passwd to denote locked account])
Tim Rice648f8762011-01-26 12:38:57 -0800805 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV])
806 AC_DEFINE([LINK_OPNOTSUPP_ERRNO], [EPERM],
Tim Rice7df8d392005-09-19 09:33:39 -0700807 [Define to whatever link() returns for "not supported"
808 if it doesn't return EOPNOTSUPP.])
Tim Rice648f8762011-01-26 12:38:57 -0800809 AC_DEFINE([_PATH_BTMP], ["/var/log/btmp"], [log for bad login attempts])
810 AC_DEFINE([USE_BTMP])
811 AC_DEFINE([LINUX_OOM_ADJUST], [1], [Adjust Linux out-of-memory killer])
Damien Miller7bcb0892000-03-11 20:45:40 +1100812 inet6_default_4in6=yes
Darren Tucker3c016542003-05-02 20:48:21 +1000813 case `uname -r` in
Darren Tuckerc437cda2003-05-10 17:05:46 +1000814 1.*|2.0.*)
Tim Rice648f8762011-01-26 12:38:57 -0800815 AC_DEFINE([BROKEN_CMSG_TYPE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700816 [Define if cmsg_type is not passed correctly])
Darren Tucker3c016542003-05-02 20:48:21 +1000817 ;;
Darren Tucker3c016542003-05-02 20:48:21 +1000818 esac
Damien Miller89e03ba2005-12-31 16:42:03 +1100819 # tun(4) forwarding compat code
Tim Rice648f8762011-01-26 12:38:57 -0800820 AC_CHECK_HEADERS([linux/if_tun.h])
Damien Millerbd4e4102006-01-01 21:03:30 +1100821 if test "x$ac_cv_header_linux_if_tun_h" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -0800822 AC_DEFINE([SSH_TUN_LINUX], [1],
Damien Miller89e03ba2005-12-31 16:42:03 +1100823 [Open tunnel devices the Linux tun/tap way])
Tim Rice648f8762011-01-26 12:38:57 -0800824 AC_DEFINE([SSH_TUN_COMPAT_AF], [1],
Damien Miller89e03ba2005-12-31 16:42:03 +1100825 [Use tunnel device compatibility to OpenBSD])
Tim Rice648f8762011-01-26 12:38:57 -0800826 AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
Damien Miller89e03ba2005-12-31 16:42:03 +1100827 [Prepend the address family to IP tunnel traffic])
828 fi
Darren Tucker81c9ccd2017-11-03 14:52:51 +1100829 AC_CHECK_HEADER([linux/if.h],
830 AC_DEFINE([SYS_RDOMAIN_LINUX], [1],
Darren Tucker24d2a332018-02-11 21:20:39 +1300831 [Support routing domains using Linux VRF]), [], [
832#ifdef HAVE_SYS_TYPES_H
Damien Miller87294982019-07-10 09:43:19 +1000833# include <sys/types.h>
Darren Tucker24d2a332018-02-11 21:20:39 +1300834#endif
835 ])
Darren Tucker60395f92012-07-03 14:31:18 +1000836 AC_CHECK_HEADERS([linux/seccomp.h linux/filter.h linux/audit.h], [],
837 [], [#include <linux/types.h>])
Vicente Olivert Riera58008672017-06-20 16:42:11 +0100838 # Obtain MIPS ABI
839 case "$host" in
840 mips*)
Darren Tuckerfbd733a2018-03-12 19:17:26 +1100841 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Vicente Olivert Riera58008672017-06-20 16:42:11 +0100842#if _MIPS_SIM != _ABIO32
843#error
844#endif
Darren Tuckerfbd733a2018-03-12 19:17:26 +1100845 ]])],[mips_abi="o32"],[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Vicente Olivert Riera58008672017-06-20 16:42:11 +0100846#if _MIPS_SIM != _ABIN32
847#error
848#endif
Darren Tuckerfbd733a2018-03-12 19:17:26 +1100849 ]])],[mips_abi="n32"],[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Vicente Olivert Riera58008672017-06-20 16:42:11 +0100850#if _MIPS_SIM != _ABI64
851#error
852#endif
Darren Tuckerfbd733a2018-03-12 19:17:26 +1100853 ]])],[mips_abi="n64"],[AC_MSG_ERROR([unknown MIPS ABI])
Vicente Olivert Riera58008672017-06-20 16:42:11 +0100854 ])
855 ])
856 ])
857 ;;
858 esac
Damien Miller91f40d82013-02-22 11:37:00 +1100859 AC_MSG_CHECKING([for seccomp architecture])
860 seccomp_audit_arch=
Damien Millere0956e32012-04-04 11:27:54 +1000861 case "$host" in
862 x86_64-*)
Damien Miller91f40d82013-02-22 11:37:00 +1100863 seccomp_audit_arch=AUDIT_ARCH_X86_64
Damien Millere0956e32012-04-04 11:27:54 +1000864 ;;
865 i*86-*)
Damien Miller91f40d82013-02-22 11:37:00 +1100866 seccomp_audit_arch=AUDIT_ARCH_I386
Damien Millere0956e32012-04-04 11:27:54 +1000867 ;;
Damien Miller99f33d72015-06-17 10:50:51 +1000868 arm*-*)
Damien Miller91f40d82013-02-22 11:37:00 +1100869 seccomp_audit_arch=AUDIT_ARCH_ARM
Damien Miller99f33d72015-06-17 10:50:51 +1000870 ;;
871 aarch64*-*)
872 seccomp_audit_arch=AUDIT_ARCH_AARCH64
Damien Miller5c15e222015-06-18 15:07:56 +1000873 ;;
Damien Millerb9c50612016-07-08 13:59:13 +1000874 s390x-*)
875 seccomp_audit_arch=AUDIT_ARCH_S390X
876 ;;
877 s390-*)
878 seccomp_audit_arch=AUDIT_ARCH_S390
879 ;;
880 powerpc64-*)
881 seccomp_audit_arch=AUDIT_ARCH_PPC64
882 ;;
883 powerpc64le-*)
884 seccomp_audit_arch=AUDIT_ARCH_PPC64LE
885 ;;
886 mips-*)
887 seccomp_audit_arch=AUDIT_ARCH_MIPS
888 ;;
889 mipsel-*)
890 seccomp_audit_arch=AUDIT_ARCH_MIPSEL
891 ;;
892 mips64-*)
Vicente Olivert Riera45011512017-06-20 16:42:28 +0100893 case "$mips_abi" in
894 "n32")
895 seccomp_audit_arch=AUDIT_ARCH_MIPS64N32
896 ;;
897 "n64")
898 seccomp_audit_arch=AUDIT_ARCH_MIPS64
899 ;;
900 esac
Damien Millerb9c50612016-07-08 13:59:13 +1000901 ;;
902 mips64el-*)
Vicente Olivert Riera45011512017-06-20 16:42:28 +0100903 case "$mips_abi" in
904 "n32")
905 seccomp_audit_arch=AUDIT_ARCH_MIPSEL64N32
906 ;;
907 "n64")
908 seccomp_audit_arch=AUDIT_ARCH_MIPSEL64
909 ;;
910 esac
Damien Millerb9c50612016-07-08 13:59:13 +1000911 ;;
Damien Millere0956e32012-04-04 11:27:54 +1000912 esac
Damien Miller91f40d82013-02-22 11:37:00 +1100913 if test "x$seccomp_audit_arch" != "x" ; then
914 AC_MSG_RESULT(["$seccomp_audit_arch"])
Damien Miller99f33d72015-06-17 10:50:51 +1000915 AC_DEFINE_UNQUOTED([SECCOMP_AUDIT_ARCH], [$seccomp_audit_arch],
916 [Specify the system call convention in use])
Damien Miller91f40d82013-02-22 11:37:00 +1100917 else
918 AC_MSG_RESULT([architecture not supported])
919 fi
Damien Millerb29ea912000-01-15 14:12:03 +1100920 ;;
Ben Lindstromb5628642000-10-18 00:02:25 +0000921mips-sony-bsd|mips-sony-newsos4)
Tim Rice648f8762011-01-26 12:38:57 -0800922 AC_DEFINE([NEED_SETPGRP], [1], [Need setpgrp to acquire controlling tty])
Ben Lindstromb5628642000-10-18 00:02:25 +0000923 SONY=1
Ben Lindstromb5628642000-10-18 00:02:25 +0000924 ;;
Damien Milleree1c0b32000-01-21 00:18:15 +1100925*-*-netbsd*)
Damien Millerfc93d4b2002-09-04 23:26:29 +1000926 check_for_libcrypt_before=1
Tim Riceeae17cc2005-03-17 16:52:20 -0800927 if test "x$withval" != "xno" ; then
Darren Tucker2f0bad22019-01-21 21:28:27 +1100928 rpath_opt="-R"
Tim Rice88368a32003-12-08 12:35:59 -0800929 fi
Damien Miller99522ba2016-07-28 08:54:27 +1000930 CPPFLAGS="$CPPFLAGS -D_OPENBSD_SOURCE"
Tim Rice648f8762011-01-26 12:38:57 -0800931 AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
Damien Miller2dcddbf2006-01-01 19:47:05 +1100932 AC_CHECK_HEADER([net/if_tap.h], ,
Tim Rice648f8762011-01-26 12:38:57 -0800933 AC_DEFINE([SSH_TUN_NO_L2], [1], [No layer 2 tunnel support]))
934 AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
Damien Miller2dcddbf2006-01-01 19:47:05 +1100935 [Prepend the address family to IP tunnel traffic])
Darren Tucker882abfd2013-11-09 00:17:41 +1100936 TEST_MALLOC_OPTIONS="AJRX"
Damien Millerf5bbd3b2014-01-30 11:26:46 +1100937 AC_DEFINE([BROKEN_READ_COMPARISON], [1],
938 [NetBSD read function is sometimes redirected, breaking atomicio comparisons against it])
Damien Milleree1c0b32000-01-21 00:18:15 +1100939 ;;
Damien Millerfbd884a2001-02-27 08:39:07 +1100940*-*-freebsd*)
941 check_for_libcrypt_later=1
Tim Rice648f8762011-01-26 12:38:57 -0800942 AC_DEFINE([LOCKED_PASSWD_PREFIX], ["*LOCKED*"], [Account locked with pw(1)])
943 AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
Damien Miller2dcddbf2006-01-01 19:47:05 +1100944 AC_CHECK_HEADER([net/if_tap.h], ,
Tim Rice648f8762011-01-26 12:38:57 -0800945 AC_DEFINE([SSH_TUN_NO_L2], [1], [No layer 2 tunnel support]))
946 AC_DEFINE([BROKEN_GLOB], [1], [FreeBSD glob does not do what we need])
Darren Tucker882abfd2013-11-09 00:17:41 +1100947 TEST_MALLOC_OPTIONS="AJRX"
Damien Miller2035b222014-01-26 09:39:53 +1100948 # Preauth crypto occasionally uses file descriptors for crypto offload
949 # and will crash if they cannot be opened.
Damien Miller5b447c02014-01-26 09:46:53 +1100950 AC_DEFINE([SANDBOX_SKIP_RLIMIT_NOFILE], [1],
Tim Rice03ae0812014-02-21 09:09:34 -0800951 [define if setrlimit RLIMIT_NOFILE breaks things])
Damien Millerfbd884a2001-02-27 08:39:07 +1100952 ;;
Darren Tuckered9eb022003-09-22 11:18:47 +1000953*-*-bsdi*)
Tim Rice648f8762011-01-26 12:38:57 -0800954 AC_DEFINE([SETEUID_BREAKS_SETUID])
955 AC_DEFINE([BROKEN_SETREUID])
956 AC_DEFINE([BROKEN_SETREGID])
Darren Tuckered9eb022003-09-22 11:18:47 +1000957 ;;
Damien Miller0f91b4e2000-06-18 15:43:25 +1000958*-next-*)
Damien Miller0f91b4e2000-06-18 15:43:25 +1000959 conf_lastlog_location="/usr/adm/lastlog"
Damien Millere5192fa2000-08-29 14:30:37 +1100960 conf_utmp_location=/etc/utmp
961 conf_wtmp_location=/usr/adm/wtmp
Tim Rice90f42b02011-06-02 18:17:49 -0700962 maildir=/usr/spool/mail
Tim Rice648f8762011-01-26 12:38:57 -0800963 AC_DEFINE([HAVE_NEXT], [1], [Define if you are on NeXT])
Tim Rice648f8762011-01-26 12:38:57 -0800964 AC_DEFINE([USE_PIPES])
965 AC_DEFINE([BROKEN_SAVED_UIDS], [1], [Needed for NeXT])
Damien Miller0f91b4e2000-06-18 15:43:25 +1000966 ;;
Darren Tucker4a422572005-07-14 17:22:11 +1000967*-*-openbsd*)
Damien Miller852472a2014-01-22 16:31:18 +1100968 use_pie=auto
Tim Rice648f8762011-01-26 12:38:57 -0800969 AC_DEFINE([HAVE_ATTRIBUTE__SENTINEL__], [1], [OpenBSD's gcc has sentinel])
970 AC_DEFINE([HAVE_ATTRIBUTE__BOUNDED__], [1], [OpenBSD's gcc has bounded])
971 AC_DEFINE([SSH_TUN_OPENBSD], [1], [Open tunnel devices the OpenBSD way])
972 AC_DEFINE([SYSLOG_R_SAFE_IN_SIGHAND], [1],
Damien Millerbb598142006-08-19 08:38:23 +1000973 [syslog_r function is safe to use in in a signal handler])
Darren Tucker882abfd2013-11-09 00:17:41 +1100974 TEST_MALLOC_OPTIONS="AFGJPRX"
Darren Tucker4a422572005-07-14 17:22:11 +1000975 ;;
Damien Miller75b1d102000-01-07 14:01:41 +1100976*-*-solaris*)
Tim Riceeae17cc2005-03-17 16:52:20 -0800977 if test "x$withval" != "xno" ; then
Darren Tucker2f0bad22019-01-21 21:28:27 +1100978 rpath_opt="-R"
Tim Ricead4a1882004-02-29 15:53:37 -0800979 fi
Tim Rice648f8762011-01-26 12:38:57 -0800980 AC_DEFINE([PAM_SUN_CODEBASE])
981 AC_DEFINE([LOGIN_NEEDS_UTMPX])
Tim Rice648f8762011-01-26 12:38:57 -0800982 AC_DEFINE([PAM_TTY_KLUDGE])
983 AC_DEFINE([SSHPAM_CHAUTHTOK_NEEDS_RUID], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700984 [Define if pam_chauthtok wants real uid set
985 to the unpriv'ed user])
Tim Rice648f8762011-01-26 12:38:57 -0800986 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Darren Tuckerc437cda2003-05-10 17:05:46 +1000987 # Pushing STREAMS modules will cause sshd to acquire a controlling tty.
Tim Rice648f8762011-01-26 12:38:57 -0800988 AC_DEFINE([SSHD_ACQUIRES_CTTY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700989 [Define if sshd somehow reacquires a controlling TTY
990 after setsid()])
Tim Rice648f8762011-01-26 12:38:57 -0800991 AC_DEFINE([PASSWD_NEEDS_USERNAME], [1], [must supply username to passwd
Darren Tucker0249f932006-06-24 12:10:07 +1000992 in case the name is longer than 8 chars])
Tim Rice648f8762011-01-26 12:38:57 -0800993 AC_DEFINE([BROKEN_TCGETATTR_ICANON], [1], [tcgetattr with ICANON may hang])
Darren Tuckere1a790d2003-09-16 11:52:19 +1000994 external_path_file=/etc/default/login
andre2ff7b5d2000-06-03 14:57:40 +0000995 # hardwire lastlog location (can't detect it on some versions)
996 conf_lastlog_location="/var/adm/lastlog"
Tim Rice648f8762011-01-26 12:38:57 -0800997 AC_MSG_CHECKING([for obsolete utmp and wtmp in solaris2.x])
Damien Millera1cb6442000-06-09 11:58:35 +1000998 sol2ver=`echo "$host"| sed -e 's/.*[[0-9]]\.//'`
999 if test "$sol2ver" -ge 8; then
Tim Rice648f8762011-01-26 12:38:57 -08001000 AC_MSG_RESULT([yes])
1001 AC_DEFINE([DISABLE_UTMP])
1002 AC_DEFINE([DISABLE_WTMP], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001003 [Define if you don't want to use wtmp])
Damien Millera1cb6442000-06-09 11:58:35 +10001004 else
Tim Rice648f8762011-01-26 12:38:57 -08001005 AC_MSG_RESULT([no])
Damien Millera1cb6442000-06-09 11:58:35 +10001006 fi
Darren Tuckera86ec4d2016-06-14 10:48:27 +10001007 AC_CHECK_FUNCS([setpflags])
Darren Tucker907091a2016-02-19 09:05:39 +11001008 AC_CHECK_FUNCS([setppriv])
1009 AC_CHECK_FUNCS([priv_basicset])
1010 AC_CHECK_HEADERS([priv.h])
Tim Rice648f8762011-01-26 12:38:57 -08001011 AC_ARG_WITH([solaris-contracts],
Damien Miller1b06dc32006-08-31 03:24:41 +10001012 [ --with-solaris-contracts Enable Solaris process contracts (experimental)],
1013 [
Tim Rice648f8762011-01-26 12:38:57 -08001014 AC_CHECK_LIB([contract], [ct_tmpl_activate],
1015 [ AC_DEFINE([USE_SOLARIS_PROCESS_CONTRACTS], [1],
Damien Miller1b06dc32006-08-31 03:24:41 +10001016 [Define if you have Solaris process contracts])
Damien Miller4626cba2016-01-08 14:24:56 +11001017 LIBS="$LIBS -lcontract"
Damien Miller1b06dc32006-08-31 03:24:41 +10001018 SPC_MSG="yes" ], )
1019 ],
1020 )
Tim Rice648f8762011-01-26 12:38:57 -08001021 AC_ARG_WITH([solaris-projects],
Darren Tucker97528352010-11-05 12:03:05 +11001022 [ --with-solaris-projects Enable Solaris projects (experimental)],
1023 [
Tim Rice648f8762011-01-26 12:38:57 -08001024 AC_CHECK_LIB([project], [setproject],
1025 [ AC_DEFINE([USE_SOLARIS_PROJECTS], [1],
Darren Tucker97528352010-11-05 12:03:05 +11001026 [Define if you have Solaris projects])
Damien Miller4626cba2016-01-08 14:24:56 +11001027 LIBS="$LIBS -lproject"
Darren Tucker97528352010-11-05 12:03:05 +11001028 SP_MSG="yes" ], )
1029 ],
1030 )
Damien Miller4626cba2016-01-08 14:24:56 +11001031 AC_ARG_WITH([solaris-privs],
1032 [ --with-solaris-privs Enable Solaris/Illumos privileges (experimental)],
1033 [
1034 AC_MSG_CHECKING([for Solaris/Illumos privilege support])
Darren Tucker907091a2016-02-19 09:05:39 +11001035 if test "x$ac_cv_func_setppriv" = "xyes" -a \
1036 "x$ac_cv_header_priv_h" = "xyes" ; then
1037 SOLARIS_PRIVS=yes
Damien Miller4626cba2016-01-08 14:24:56 +11001038 AC_MSG_RESULT([found])
1039 AC_DEFINE([NO_UID_RESTORATION_TEST], [1],
1040 [Define to disable UID restoration test])
1041 AC_DEFINE([USE_SOLARIS_PRIVS], [1],
1042 [Define if you have Solaris privileges])
1043 SPP_MSG="yes"
1044 else
1045 AC_MSG_RESULT([not found])
1046 AC_MSG_ERROR([*** must have support for Solaris privileges to use --with-solaris-privs])
1047 fi
1048 ],
1049 )
Tim Rice5ab9b632013-06-02 14:05:48 -07001050 TEST_SHELL=$SHELL # let configure find us a capable shell
Damien Miller75b1d102000-01-07 14:01:41 +11001051 ;;
Damien Millerdfc83f42000-05-20 15:02:59 +10001052*-*-sunos4*)
Ben Lindstrom28bfc0d2000-12-18 19:58:57 +00001053 CPPFLAGS="$CPPFLAGS -DSUNOS4"
Tim Rice648f8762011-01-26 12:38:57 -08001054 AC_CHECK_FUNCS([getpwanam])
1055 AC_DEFINE([PAM_SUN_CODEBASE])
Damien Miller36ccb5c2000-08-09 16:34:27 +10001056 conf_utmp_location=/etc/utmp
1057 conf_wtmp_location=/var/adm/wtmp
1058 conf_lastlog_location=/var/adm/lastlog
Tim Rice648f8762011-01-26 12:38:57 -08001059 AC_DEFINE([USE_PIPES])
Darren Tuckerc0a0c3f2018-03-05 20:03:07 +11001060 AC_DEFINE([DISABLE_UTMPX], [1], [no utmpx])
Damien Millerdfc83f42000-05-20 15:02:59 +10001061 ;;
Ben Lindstrom603bdfd2001-02-12 07:29:45 +00001062*-ncr-sysv*)
Tim Rice13aae5e2001-10-21 17:53:58 -07001063 LIBS="$LIBS -lc89"
Tim Rice648f8762011-01-26 12:38:57 -08001064 AC_DEFINE([USE_PIPES])
1065 AC_DEFINE([SSHD_ACQUIRES_CTTY])
1066 AC_DEFINE([SETEUID_BREAKS_SETUID])
1067 AC_DEFINE([BROKEN_SETREUID])
1068 AC_DEFINE([BROKEN_SETREGID])
Ben Lindstrom603bdfd2001-02-12 07:29:45 +00001069 ;;
Damien Miller2ae714f2000-07-11 09:29:50 +10001070*-sni-sysv*)
Tim Riceffdf4aa2001-10-27 10:45:36 -07001071 # /usr/ucblib MUST NOT be searched on ReliantUNIX
Tim Rice648f8762011-01-26 12:38:57 -08001072 AC_CHECK_LIB([dl], [dlsym], ,)
Darren Tucker79d09fa2005-11-24 22:34:54 +11001073 # -lresolv needs to be at the end of LIBS or DNS lookups break
Tim Rice648f8762011-01-26 12:38:57 -08001074 AC_CHECK_LIB([resolv], [res_query], [ LIBS="$LIBS -lresolv" ])
Damien Millerfd9885e2001-01-10 08:16:53 +11001075 IPADDR_IN_DISPLAY=yes
Tim Rice648f8762011-01-26 12:38:57 -08001076 AC_DEFINE([USE_PIPES])
1077 AC_DEFINE([IP_TOS_IS_BROKEN])
1078 AC_DEFINE([SETEUID_BREAKS_SETUID])
1079 AC_DEFINE([BROKEN_SETREUID])
1080 AC_DEFINE([BROKEN_SETREGID])
1081 AC_DEFINE([SSHD_ACQUIRES_CTTY])
Darren Tuckere1a790d2003-09-16 11:52:19 +10001082 external_path_file=/etc/default/login
Tim Riceffdf4aa2001-10-27 10:45:36 -07001083 # /usr/ucblib/libucb.a no longer needed on ReliantUNIX
1084 # Attention: always take care to bind libsocket and libnsl before libc,
1085 # otherwise you will find lots of "SIOCGPGRP errno 22" on syslog
Damien Miller2ae714f2000-07-11 09:29:50 +10001086 ;;
Tim Rice0f83d292004-12-08 18:29:58 -08001087# UnixWare 1.x, UnixWare 2.x, and others based on code from Univel.
Damien Miller78315eb2000-09-29 23:01:36 +11001088*-*-sysv4.2*)
Tim Rice648f8762011-01-26 12:38:57 -08001089 AC_DEFINE([USE_PIPES])
1090 AC_DEFINE([SETEUID_BREAKS_SETUID])
1091 AC_DEFINE([BROKEN_SETREUID])
1092 AC_DEFINE([BROKEN_SETREGID])
1093 AC_DEFINE([PASSWD_NEEDS_USERNAME], [1], [must supply username to passwd])
1094 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Tim Rice5ab9b632013-06-02 14:05:48 -07001095 TEST_SHELL=$SHELL # let configure find us a capable shell
Damien Miller78315eb2000-09-29 23:01:36 +11001096 ;;
Tim Rice0f83d292004-12-08 18:29:58 -08001097# UnixWare 7.x, OpenUNIX 8
Damien Miller78315eb2000-09-29 23:01:36 +11001098*-*-sysv5*)
Tim Rice641ebf12010-01-17 17:05:39 -08001099 CPPFLAGS="$CPPFLAGS -Dvsnprintf=_xvsnprintf -Dsnprintf=_xsnprintf"
Tim Rice648f8762011-01-26 12:38:57 -08001100 AC_DEFINE([UNIXWARE_LONG_PASSWORDS], [1], [Support passwords > 8 chars])
1101 AC_DEFINE([USE_PIPES])
1102 AC_DEFINE([SETEUID_BREAKS_SETUID])
1103 AC_DEFINE([BROKEN_GETADDRINFO])
1104 AC_DEFINE([BROKEN_SETREUID])
1105 AC_DEFINE([BROKEN_SETREGID])
1106 AC_DEFINE([PASSWD_NEEDS_USERNAME])
Tim Rice8433d512017-07-11 18:47:56 -07001107 AC_DEFINE([BROKEN_TCGETATTR_ICANON])
Tim Rice5ab9b632013-06-02 14:05:48 -07001108 TEST_SHELL=$SHELL # let configure find us a capable shell
Tim Rice4afeaf32018-03-25 10:00:21 -07001109 check_for_libcrypt_later=1
Tim Rice4dbacff2005-06-01 20:09:28 -07001110 case "$host" in
1111 *-*-sysv5SCO_SV*) # SCO OpenServer 6.x
Tim Rice90f42b02011-06-02 18:17:49 -07001112 maildir=/var/spool/mail
Tim Rice648f8762011-01-26 12:38:57 -08001113 AC_DEFINE([BROKEN_UPDWTMPX])
1114 AC_CHECK_LIB([prot], [getluid], [ LIBS="$LIBS -lprot"
1115 AC_CHECK_FUNCS([getluid setluid], , , [-lprot])
Tim Rice648f8762011-01-26 12:38:57 -08001116 ], , )
Tim Rice4dbacff2005-06-01 20:09:28 -07001117 ;;
Tim Rice648f8762011-01-26 12:38:57 -08001118 *) AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Tim Rice46259d82005-11-28 18:40:34 -08001119 ;;
Tim Rice4dbacff2005-06-01 20:09:28 -07001120 esac
Damien Miller78315eb2000-09-29 23:01:36 +11001121 ;;
Damien Miller75b1d102000-01-07 14:01:41 +11001122*-*-sysv*)
Damien Miller75b1d102000-01-07 14:01:41 +11001123 ;;
Tim Rice0f83d292004-12-08 18:29:58 -08001124# SCO UNIX and OEM versions of SCO UNIX
Damien Miller78315eb2000-09-29 23:01:36 +11001125*-*-sco3.2v4*)
Tim Ricec390c8d2005-03-07 01:21:37 -08001126 AC_MSG_ERROR("This Platform is no longer supported.")
Damien Miller78315eb2000-09-29 23:01:36 +11001127 ;;
Tim Rice0f83d292004-12-08 18:29:58 -08001128# SCO OpenServer 5.x
Damien Miller78315eb2000-09-29 23:01:36 +11001129*-*-sco3.2v5*)
Tim Rice89fe3f32003-01-19 20:20:24 -08001130 if test -z "$GCC"; then
1131 CFLAGS="$CFLAGS -belf"
1132 fi
Damien Miller5dfe9762001-02-16 12:05:39 +11001133 LIBS="$LIBS -lprot -lx -ltinfo -lm"
Damien Millera66626b2000-06-13 18:57:53 +10001134 no_dev_ptmx=1
Tim Rice648f8762011-01-26 12:38:57 -08001135 AC_DEFINE([USE_PIPES])
1136 AC_DEFINE([HAVE_SECUREWARE])
1137 AC_DEFINE([DISABLE_SHADOW])
1138 AC_DEFINE([DISABLE_FD_PASSING])
1139 AC_DEFINE([SETEUID_BREAKS_SETUID])
1140 AC_DEFINE([BROKEN_GETADDRINFO])
1141 AC_DEFINE([BROKEN_SETREUID])
1142 AC_DEFINE([BROKEN_SETREGID])
1143 AC_DEFINE([WITH_ABBREV_NO_TTY])
1144 AC_DEFINE([BROKEN_UPDWTMPX])
1145 AC_DEFINE([PASSWD_NEEDS_USERNAME])
1146 AC_CHECK_FUNCS([getluid setluid])
Tim Rice07183b82001-04-25 21:40:28 -07001147 MANTYPE=man
Tim Rice5ab9b632013-06-02 14:05:48 -07001148 TEST_SHELL=$SHELL # let configure find us a capable shell
Tim Riceaa86c392013-03-16 20:55:46 -07001149 SKIP_DISABLE_LASTLOG_DEFINE=yes
Damien Millera66626b2000-06-13 18:57:53 +10001150 ;;
Damien Millerb8c656e2000-06-28 15:22:41 +10001151*-dec-osf*)
Tim Rice648f8762011-01-26 12:38:57 -08001152 AC_MSG_CHECKING([for Digital Unix SIA])
Ben Lindstrom72af2ef2001-05-08 20:42:28 +00001153 no_osfsia=""
Tim Rice648f8762011-01-26 12:38:57 -08001154 AC_ARG_WITH([osfsia],
Ben Lindstrom72af2ef2001-05-08 20:42:28 +00001155 [ --with-osfsia Enable Digital Unix SIA],
1156 [
1157 if test "x$withval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08001158 AC_MSG_RESULT([disabled])
Ben Lindstrom72af2ef2001-05-08 20:42:28 +00001159 no_osfsia=1
1160 fi
1161 ],
1162 )
1163 if test -z "$no_osfsia" ; then
Damien Millerb8c656e2000-06-28 15:22:41 +10001164 if test -f /etc/sia/matrix.conf; then
Tim Rice648f8762011-01-26 12:38:57 -08001165 AC_MSG_RESULT([yes])
1166 AC_DEFINE([HAVE_OSF_SIA], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001167 [Define if you have Digital Unix Security
1168 Integration Architecture])
Tim Rice648f8762011-01-26 12:38:57 -08001169 AC_DEFINE([DISABLE_LOGIN], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001170 [Define if you don't want to use your
1171 system's login() call])
Tim Rice648f8762011-01-26 12:38:57 -08001172 AC_DEFINE([DISABLE_FD_PASSING])
Damien Millerb8c656e2000-06-28 15:22:41 +10001173 LIBS="$LIBS -lsecurity -ldb -lm -laud"
Damien Miller1b06dc32006-08-31 03:24:41 +10001174 SIA_MSG="yes"
Damien Millerb8c656e2000-06-28 15:22:41 +10001175 else
Tim Rice648f8762011-01-26 12:38:57 -08001176 AC_MSG_RESULT([no])
1177 AC_DEFINE([LOCKED_PASSWD_SUBSTR], ["Nologin"],
Tim Rice7df8d392005-09-19 09:33:39 -07001178 [String used in /etc/passwd to denote locked account])
Damien Millerb8c656e2000-06-28 15:22:41 +10001179 fi
1180 fi
Tim Rice648f8762011-01-26 12:38:57 -08001181 AC_DEFINE([BROKEN_GETADDRINFO])
1182 AC_DEFINE([SETEUID_BREAKS_SETUID])
1183 AC_DEFINE([BROKEN_SETREUID])
1184 AC_DEFINE([BROKEN_SETREGID])
1185 AC_DEFINE([BROKEN_READV_COMPARISON], [1], [Can't do comparisons on readv])
Damien Millerb8c656e2000-06-28 15:22:41 +10001186 ;;
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00001187
Tim Rice70335a62006-02-04 17:42:58 -08001188*-*-nto-qnx*)
Tim Rice648f8762011-01-26 12:38:57 -08001189 AC_DEFINE([USE_PIPES])
1190 AC_DEFINE([NO_X11_UNIX_SOCKETS])
Tim Rice648f8762011-01-26 12:38:57 -08001191 AC_DEFINE([DISABLE_LASTLOG])
1192 AC_DEFINE([SSHD_ACQUIRES_CTTY])
1193 AC_DEFINE([BROKEN_SHADOW_EXPIRE], [1], [QNX shadow support is broken])
Tim Rice2f993462006-02-11 18:37:48 -08001194 enable_etc_default_login=no # has incompatible /etc/default/login
Darren Tucker8acb3b62007-08-10 14:36:12 +10001195 case "$host" in
1196 *-*-nto-qnx6*)
Tim Rice648f8762011-01-26 12:38:57 -08001197 AC_DEFINE([DISABLE_FD_PASSING])
Darren Tucker8acb3b62007-08-10 14:36:12 +10001198 ;;
1199 esac
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00001200 ;;
Darren Tucker2be1cbb2005-05-27 21:13:40 +10001201
1202*-*-ultrix*)
Tim Rice648f8762011-01-26 12:38:57 -08001203 AC_DEFINE([BROKEN_GETGROUPS], [1], [getgroups(0,NULL) will return -1])
Darren Tucker9cac1512019-11-01 18:26:07 +11001204 AC_DEFINE([NEED_SETPGRP], [1], [Need setpgrp to for controlling tty])
Tim Rice648f8762011-01-26 12:38:57 -08001205 AC_DEFINE([HAVE_SYS_SYSLOG_H], [1], [Force use of sys/syslog.h on Ultrix])
Darren Tucker9cac1512019-11-01 18:26:07 +11001206 AC_DEFINE([DISABLE_UTMPX], [1], [Disable utmpx])
1207 # DISABLE_FD_PASSING so that we call setpgrp as root, otherwise we
1208 # don't get a controlling tty.
1209 AC_DEFINE([DISABLE_FD_PASSING], [1], [Need to call setpgrp as root])
1210 AC_DEFINE([realpath(x, y)], [(sftp_realpath((x),(y)))], [no realpath])
1211 # On Ultrix netinet/ip.h is not protected against multiple includes,
1212 # so we create our own wrapper and put it where the compiler will
1213 # find it.
1214 AC_MSG_WARN([creating compat wrapper for netinet/ip.h])
1215 mkdir -p netinet
1216 cat >netinet/ip.h <<EOD
1217#ifndef _SSH_COMPAT_NETINET_IP_H
1218#define _SSH_COMPAT_NETINET_IP_H
1219#include "/usr/include/netinet/ip.h"
1220#endif
1221EOD
Tim Ricefcc7ff12005-06-02 20:28:29 -07001222 ;;
Darren Tucker93e7e8f2005-08-23 08:06:55 +10001223
1224*-*-lynxos)
Darren Tucker5faa52d2016-08-02 15:22:40 +10001225 CFLAGS="$CFLAGS -D__NO_INCLUDE_WARN__"
1226 AC_DEFINE([BROKEN_SETVBUF], [1],
1227 [LynxOS has broken setvbuf() implementation])
1228 ;;
Damien Miller76112de1999-12-21 11:18:08 +11001229esac
1230
Tim Rice648f8762011-01-26 12:38:57 -08001231AC_MSG_CHECKING([compiler and flags for sanity])
1232AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]], [[ exit(0); ]])],
1233 [ AC_MSG_RESULT([yes]) ],
Darren Tucker6eb93042003-06-29 21:30:41 +10001234 [
Tim Rice648f8762011-01-26 12:38:57 -08001235 AC_MSG_RESULT([no])
Darren Tucker6eb93042003-06-29 21:30:41 +10001236 AC_MSG_ERROR([*** compiler cannot create working executables, check config.log ***])
Darren Tuckera0c2b392004-09-11 23:26:37 +10001237 ],
1238 [ AC_MSG_WARN([cross compiling: not checking compiler sanity]) ]
Darren Tucker6eb93042003-06-29 21:30:41 +10001239)
1240
Darren Tucker0c9653f2005-05-28 15:58:14 +10001241dnl Checks for header files.
Damien Millera22ba012000-03-02 23:09:20 +11001242# Checks for libraries.
Tim Rice648f8762011-01-26 12:38:57 -08001243AC_CHECK_FUNC([setsockopt], , [AC_CHECK_LIB([socket], [setsockopt])])
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00001244
Tim Rice1e1ef642003-09-11 22:19:31 -07001245dnl IRIX and Solaris 2.5.1 have dirname() in libgen
Tim Rice648f8762011-01-26 12:38:57 -08001246AC_CHECK_FUNCS([dirname], [AC_CHECK_HEADERS([libgen.h])] , [
1247 AC_CHECK_LIB([gen], [dirname], [
Tim Rice1e1ef642003-09-11 22:19:31 -07001248 AC_CACHE_CHECK([for broken dirname],
1249 ac_cv_have_broken_dirname, [
1250 save_LIBS="$LIBS"
1251 LIBS="$LIBS -lgen"
Darren Tucker314d89e2005-10-17 23:29:23 +10001252 AC_RUN_IFELSE(
1253 [AC_LANG_SOURCE([[
Tim Rice1e1ef642003-09-11 22:19:31 -07001254#include <libgen.h>
1255#include <string.h>
1256
1257int main(int argc, char **argv) {
1258 char *s, buf[32];
1259
1260 strncpy(buf,"/etc", 32);
1261 s = dirname(buf);
1262 if (!s || strncmp(s, "/", 32) != 0) {
1263 exit(1);
1264 } else {
1265 exit(0);
1266 }
1267}
Darren Tucker314d89e2005-10-17 23:29:23 +10001268 ]])],
Tim Rice1e1ef642003-09-11 22:19:31 -07001269 [ ac_cv_have_broken_dirname="no" ],
Darren Tucker314d89e2005-10-17 23:29:23 +10001270 [ ac_cv_have_broken_dirname="yes" ],
1271 [ ac_cv_have_broken_dirname="no" ],
Tim Rice1e1ef642003-09-11 22:19:31 -07001272 )
1273 LIBS="$save_LIBS"
1274 ])
1275 if test "x$ac_cv_have_broken_dirname" = "xno" ; then
1276 LIBS="$LIBS -lgen"
Tim Rice648f8762011-01-26 12:38:57 -08001277 AC_DEFINE([HAVE_DIRNAME])
1278 AC_CHECK_HEADERS([libgen.h])
Tim Rice1e1ef642003-09-11 22:19:31 -07001279 fi
1280 ])
1281])
1282
Tim Rice648f8762011-01-26 12:38:57 -08001283AC_CHECK_FUNC([getspnam], ,
1284 [AC_CHECK_LIB([gen], [getspnam], [LIBS="$LIBS -lgen"])])
1285AC_SEARCH_LIBS([basename], [gen], [AC_DEFINE([HAVE_BASENAME], [1],
1286 [Define if you have the basename function.])])
Tim Rice1e1ef642003-09-11 22:19:31 -07001287
Tim Rice13aae5e2001-10-21 17:53:58 -07001288dnl zlib is required
Tim Rice648f8762011-01-26 12:38:57 -08001289AC_ARG_WITH([zlib],
Tim Rice13aae5e2001-10-21 17:53:58 -07001290 [ --with-zlib=PATH Use zlib in PATH],
Darren Tucker86a5f8d2005-03-21 09:55:17 +11001291 [ if test "x$withval" = "xno" ; then
1292 AC_MSG_ERROR([*** zlib is required ***])
1293 elif test "x$withval" != "xyes"; then
Tim Rice13aae5e2001-10-21 17:53:58 -07001294 if test -d "$withval/lib"; then
Darren Tucker2f0bad22019-01-21 21:28:27 +11001295 if test -n "${rpath_opt}"; then
1296 LDFLAGS="-L${withval}/lib ${rpath_opt}${withval}/lib ${LDFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001297 else
Tim Rice02cebcd2001-10-25 10:01:30 -07001298 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001299 fi
1300 else
Darren Tucker2f0bad22019-01-21 21:28:27 +11001301 if test -n "${rpath_opt}"; then
1302 LDFLAGS="-L${withval} ${rpath_opt}${withval} ${LDFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001303 else
Tim Rice02cebcd2001-10-25 10:01:30 -07001304 LDFLAGS="-L${withval} ${LDFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001305 fi
1306 fi
1307 if test -d "$withval/include"; then
Tim Rice02cebcd2001-10-25 10:01:30 -07001308 CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001309 else
Tim Rice02cebcd2001-10-25 10:01:30 -07001310 CPPFLAGS="-I${withval} ${CPPFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001311 fi
Darren Tucker86a5f8d2005-03-21 09:55:17 +11001312 fi ]
Tim Rice13aae5e2001-10-21 17:53:58 -07001313)
1314
Tim Rice648f8762011-01-26 12:38:57 -08001315AC_CHECK_HEADER([zlib.h], ,[AC_MSG_ERROR([*** zlib.h missing - please install first or check config.log ***])])
1316AC_CHECK_LIB([z], [deflate], ,
Tim Ricefcb62202004-01-23 18:35:16 -08001317 [
1318 saved_CPPFLAGS="$CPPFLAGS"
1319 saved_LDFLAGS="$LDFLAGS"
1320 save_LIBS="$LIBS"
1321 dnl Check default zlib install dir
Darren Tucker2f0bad22019-01-21 21:28:27 +11001322 if test -n "${rpath_opt}"; then
1323 LDFLAGS="-L/usr/local/lib ${rpath_opt}/usr/local/lib ${saved_LDFLAGS}"
Tim Ricefcb62202004-01-23 18:35:16 -08001324 else
1325 LDFLAGS="-L/usr/local/lib ${saved_LDFLAGS}"
1326 fi
1327 CPPFLAGS="-I/usr/local/include ${saved_CPPFLAGS}"
1328 LIBS="$LIBS -lz"
Tim Rice648f8762011-01-26 12:38:57 -08001329 AC_TRY_LINK_FUNC([deflate], [AC_DEFINE([HAVE_LIBZ])],
Tim Ricefcb62202004-01-23 18:35:16 -08001330 [
1331 AC_MSG_ERROR([*** zlib missing - please install first or check config.log ***])
1332 ]
1333 )
1334 ]
1335)
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001336
Tim Rice648f8762011-01-26 12:38:57 -08001337AC_ARG_WITH([zlib-version-check],
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001338 [ --without-zlib-version-check Disable zlib version check],
1339 [ if test "x$withval" = "xno" ; then
1340 zlib_check_nonfatal=1
1341 fi
1342 ]
1343)
1344
Tim Rice648f8762011-01-26 12:38:57 -08001345AC_MSG_CHECKING([for possibly buggy zlib])
1346AC_RUN_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001347#include <stdio.h>
Darren Tuckerc8a0f272013-03-22 12:49:14 +11001348#include <stdlib.h>
Darren Tucker2dcd2392004-01-23 17:13:33 +11001349#include <zlib.h>
Tim Rice648f8762011-01-26 12:38:57 -08001350 ]],
1351 [[
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001352 int a=0, b=0, c=0, d=0, n, v;
1353 n = sscanf(ZLIB_VERSION, "%d.%d.%d.%d", &a, &b, &c, &d);
1354 if (n != 3 && n != 4)
Darren Tucker2dcd2392004-01-23 17:13:33 +11001355 exit(1);
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001356 v = a*1000000 + b*10000 + c*100 + d;
1357 fprintf(stderr, "found zlib version %s (%d)\n", ZLIB_VERSION, v);
1358
1359 /* 1.1.4 is OK */
1360 if (a == 1 && b == 1 && c >= 4)
Darren Tucker2dcd2392004-01-23 17:13:33 +11001361 exit(0);
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001362
Darren Tucker41097ed2005-07-25 15:24:21 +10001363 /* 1.2.3 and up are OK */
1364 if (v >= 1020300)
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001365 exit(0);
1366
Darren Tucker2dcd2392004-01-23 17:13:33 +11001367 exit(2);
Darren Tucker623d92f2004-09-12 22:36:15 +10001368 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001369 AC_MSG_RESULT([no]),
1370 [ AC_MSG_RESULT([yes])
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001371 if test -z "$zlib_check_nonfatal" ; then
1372 AC_MSG_ERROR([*** zlib too old - check config.log ***
1373Your reported zlib version has known security problems. It's possible your
1374vendor has fixed these problems without changing the version number. If you
1375are sure this is the case, you can disable the check by running
1376"./configure --without-zlib-version-check".
Darren Tuckerac1910f2005-07-26 12:00:42 +10001377If you are in doubt, upgrade zlib to version 1.2.3 or greater.
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001378See http://www.gzip.org/zlib/ for details.])
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001379 else
1380 AC_MSG_WARN([zlib version may have security problems])
1381 fi
Darren Tuckera0c2b392004-09-11 23:26:37 +10001382 ],
1383 [ AC_MSG_WARN([cross compiling: not checking zlib version]) ]
Darren Tucker2dcd2392004-01-23 17:13:33 +11001384)
Damien Miller6f9c3372000-10-25 10:06:04 +11001385
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00001386dnl UnixWare 2.x
Tim Rice648f8762011-01-26 12:38:57 -08001387AC_CHECK_FUNC([strcasecmp],
1388 [], [ AC_CHECK_LIB([resolv], [strcasecmp], [LIBS="$LIBS -lresolv"]) ]
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00001389)
Tim Rice648f8762011-01-26 12:38:57 -08001390AC_CHECK_FUNCS([utimes],
1391 [], [ AC_CHECK_LIB([c89], [utimes], [AC_DEFINE([HAVE_UTIMES])
Tim Ricecbb90662002-07-08 19:17:10 -07001392 LIBS="$LIBS -lc89"]) ]
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00001393)
Damien Millerab18c411999-11-11 10:40:23 +11001394
Tim Ricee589a292001-11-03 11:09:32 -08001395dnl Checks for libutil functions
Damien Millerb87f6b72013-02-23 09:12:23 +11001396AC_CHECK_HEADERS([bsd/libutil.h libutil.h])
Damien Miller398c0ff2012-04-19 21:46:35 +10001397AC_SEARCH_LIBS([fmt_scaled], [util bsd])
Darren Tuckere194ba42013-05-16 20:47:31 +10001398AC_SEARCH_LIBS([scan_scaled], [util bsd])
Damien Miller398c0ff2012-04-19 21:46:35 +10001399AC_SEARCH_LIBS([login], [util bsd])
1400AC_SEARCH_LIBS([logout], [util bsd])
1401AC_SEARCH_LIBS([logwtmp], [util bsd])
1402AC_SEARCH_LIBS([openpty], [util bsd])
1403AC_SEARCH_LIBS([updwtmp], [util bsd])
Darren Tuckere194ba42013-05-16 20:47:31 +10001404AC_CHECK_FUNCS([fmt_scaled scan_scaled login logout openpty updwtmp logwtmp])
Tim Ricee589a292001-11-03 11:09:32 -08001405
Darren Tucker2fee9092016-02-17 09:48:15 +11001406# On some platforms, inet_ntop and gethostbyname may be found in libresolv
1407# or libnsl.
Damien Millerab039492014-01-28 15:07:10 +11001408AC_SEARCH_LIBS([inet_ntop], [resolv nsl])
Darren Tucker2fee9092016-02-17 09:48:15 +11001409AC_SEARCH_LIBS([gethostbyname], [resolv nsl])
Damien Millerab039492014-01-28 15:07:10 +11001410
Darren Tucker74c1c362017-09-27 07:44:41 +10001411# "Particular Function Checks"
1412# see https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Particular-Functions.html
Ben Lindstrom8697e082001-02-24 21:41:10 +00001413AC_FUNC_STRFTIME
Darren Tucker74c1c362017-09-27 07:44:41 +10001414AC_FUNC_MALLOC
1415AC_FUNC_REALLOC
1416# autoconf doesn't have AC_FUNC_CALLOC so fake it if malloc returns NULL;
Darren Tuckere9dede02018-02-25 10:20:31 +11001417AC_MSG_CHECKING([if calloc(0, N) returns non-null])
1418AC_RUN_IFELSE(
1419 [AC_LANG_PROGRAM(
1420 [[ #include <stdlib.h> ]],
1421 [[ void *p = calloc(0, 1); exit(p == NULL); ]]
1422 )],
1423 [ func_calloc_0_nonnull=yes ],
1424 [ func_calloc_0_nonnull=no ],
1425 [ AC_MSG_WARN([cross compiling: assuming same as malloc])
1426 func_calloc_0_nonnull="$ac_cv_func_malloc_0_nonnull"]
1427)
1428AC_MSG_RESULT([$func_calloc_0_nonnull])
1429
Darren Tuckerd97874c2018-04-13 13:43:55 +10001430if test "x$func_calloc_0_nonnull" = "xyes"; then
Darren Tuckere9dede02018-02-25 10:20:31 +11001431 AC_DEFINE(HAVE_CALLOC, 1, [calloc(0, x) returns non-null])
1432else
1433 AC_DEFINE(HAVE_CALLOC, 0, [calloc(0, x) returns NULL])
Darren Tucker74c1c362017-09-27 07:44:41 +10001434 AC_DEFINE(calloc, rpl_calloc,
1435 [Define to rpl_calloc if the replacement function should be used.])
1436fi
Ben Lindstrom8697e082001-02-24 21:41:10 +00001437
Damien Miller3c027682001-03-14 11:39:45 +11001438# Check for ALTDIRFUNC glob() extension
Tim Rice648f8762011-01-26 12:38:57 -08001439AC_MSG_CHECKING([for GLOB_ALTDIRFUNC support])
1440AC_EGREP_CPP([FOUNDIT],
Damien Miller3c027682001-03-14 11:39:45 +11001441 [
1442 #include <glob.h>
1443 #ifdef GLOB_ALTDIRFUNC
1444 FOUNDIT
1445 #endif
Damien Millera8e06ce2003-11-21 23:48:55 +11001446 ],
Damien Miller3c027682001-03-14 11:39:45 +11001447 [
Tim Rice648f8762011-01-26 12:38:57 -08001448 AC_DEFINE([GLOB_HAS_ALTDIRFUNC], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001449 [Define if your system glob() function has
1450 the GLOB_ALTDIRFUNC extension])
Tim Rice648f8762011-01-26 12:38:57 -08001451 AC_MSG_RESULT([yes])
Damien Miller3c027682001-03-14 11:39:45 +11001452 ],
1453 [
Tim Rice648f8762011-01-26 12:38:57 -08001454 AC_MSG_RESULT([no])
Damien Miller3c027682001-03-14 11:39:45 +11001455 ]
1456)
Damien Millerab18c411999-11-11 10:40:23 +11001457
Ben Lindstrom45b14db2001-03-17 01:15:38 +00001458# Check for g.gl_matchc glob() extension
Tim Rice648f8762011-01-26 12:38:57 -08001459AC_MSG_CHECKING([for gl_matchc field in glob_t])
1460AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <glob.h> ]],
1461 [[ glob_t g; g.gl_matchc = 1; ]])],
Damien Millera8e06ce2003-11-21 23:48:55 +11001462 [
Tim Rice648f8762011-01-26 12:38:57 -08001463 AC_DEFINE([GLOB_HAS_GL_MATCHC], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001464 [Define if your system glob() function has
1465 gl_matchc options in glob_t])
Tim Rice648f8762011-01-26 12:38:57 -08001466 AC_MSG_RESULT([yes])
1467 ], [
1468 AC_MSG_RESULT([no])
1469])
Ben Lindstrom45b14db2001-03-17 01:15:38 +00001470
Damien Millera6e121a2010-10-07 21:39:17 +11001471# Check for g.gl_statv glob() extension
Tim Rice648f8762011-01-26 12:38:57 -08001472AC_MSG_CHECKING([for gl_statv and GLOB_KEEPSTAT extensions for glob])
1473AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <glob.h> ]], [[
Damien Millera6e121a2010-10-07 21:39:17 +11001474#ifndef GLOB_KEEPSTAT
1475#error "glob does not support GLOB_KEEPSTAT extension"
1476#endif
1477glob_t g;
1478g.gl_statv = NULL;
Tim Rice648f8762011-01-26 12:38:57 -08001479]])],
Damien Millera6e121a2010-10-07 21:39:17 +11001480 [
Tim Rice648f8762011-01-26 12:38:57 -08001481 AC_DEFINE([GLOB_HAS_GL_STATV], [1],
Damien Millera6e121a2010-10-07 21:39:17 +11001482 [Define if your system glob() function has
1483 gl_statv options in glob_t])
Tim Rice648f8762011-01-26 12:38:57 -08001484 AC_MSG_RESULT([yes])
1485 ], [
1486 AC_MSG_RESULT([no])
Damien Miller72ef7c12015-01-15 02:21:31 +11001487
Tim Rice648f8762011-01-26 12:38:57 -08001488])
Damien Millera6e121a2010-10-07 21:39:17 +11001489
Tim Rice648f8762011-01-26 12:38:57 -08001490AC_CHECK_DECLS([GLOB_NOMATCH], , , [#include <glob.h>])
Darren Tucker096faec2006-09-01 20:29:10 +10001491
Darren Tucker7df91b02016-07-14 12:25:24 +10001492AC_CHECK_DECL([VIS_ALL], ,
1493 AC_DEFINE(BROKEN_STRNVIS, 1, [missing VIS_ALL]), [#include <vis.h>])
1494
Damien Miller18bb4732001-03-28 14:35:30 +10001495AC_MSG_CHECKING([whether struct dirent allocates space for d_name])
Darren Tuckera0c2b392004-09-11 23:26:37 +10001496AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001497 [AC_LANG_PROGRAM([[
Damien Miller18bb4732001-03-28 14:35:30 +10001498#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08001499#include <dirent.h>]],
1500 [[
1501 struct dirent d;
1502 exit(sizeof(d.d_name)<=sizeof(char));
Darren Tucker623d92f2004-09-12 22:36:15 +10001503 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001504 [AC_MSG_RESULT([yes])],
Damien Miller18bb4732001-03-28 14:35:30 +10001505 [
Tim Rice648f8762011-01-26 12:38:57 -08001506 AC_MSG_RESULT([no])
1507 AC_DEFINE([BROKEN_ONE_BYTE_DIRENT_D_NAME], [1],
Darren Tucker79d09fa2005-11-24 22:34:54 +11001508 [Define if your struct dirent expects you to
Tim Rice7df8d392005-09-19 09:33:39 -07001509 allocate extra space for d_name])
Darren Tuckera0c2b392004-09-11 23:26:37 +10001510 ],
Tim Riceeae17cc2005-03-17 16:52:20 -08001511 [
Darren Tuckera0c2b392004-09-11 23:26:37 +10001512 AC_MSG_WARN([cross compiling: assuming BROKEN_ONE_BYTE_DIRENT_D_NAME])
Tim Rice648f8762011-01-26 12:38:57 -08001513 AC_DEFINE([BROKEN_ONE_BYTE_DIRENT_D_NAME])
Damien Miller18bb4732001-03-28 14:35:30 +10001514 ]
1515)
1516
Damien Miller36f49652004-08-15 18:40:59 +10001517AC_MSG_CHECKING([for /proc/pid/fd directory])
1518if test -d "/proc/$$/fd" ; then
Tim Rice648f8762011-01-26 12:38:57 -08001519 AC_DEFINE([HAVE_PROC_PID], [1], [Define if you have /proc/$pid/fd])
1520 AC_MSG_RESULT([yes])
Damien Miller36f49652004-08-15 18:40:59 +10001521else
Tim Rice648f8762011-01-26 12:38:57 -08001522 AC_MSG_RESULT([no])
Damien Miller36f49652004-08-15 18:40:59 +10001523fi
1524
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001525# Check whether user wants to use ldns
1526LDNS_MSG="no"
1527AC_ARG_WITH(ldns,
1528 [ --with-ldns[[=PATH]] Use ldns for DNSSEC support (optionally in PATH)],
Damien Miller523db852017-02-03 16:01:22 +11001529 [
1530 ldns=""
1531 if test "x$withval" = "xyes" ; then
1532 AC_PATH_TOOL([LDNSCONFIG], [ldns-config], [no])
Darren Tuckerf001de82017-12-11 13:42:51 +11001533 if test "x$LDNSCONFIG" = "xno"; then
Damien Miller523db852017-02-03 16:01:22 +11001534 CPPFLAGS="$CPPFLAGS -I${withval}/include"
1535 LDFLAGS="$LDFLAGS -L${withval}/lib"
1536 LIBS="-lldns $LIBS"
1537 ldns=yes
1538 else
1539 LIBS="$LIBS `$LDNSCONFIG --libs`"
1540 CPPFLAGS="$CPPFLAGS `$LDNSCONFIG --cflags`"
Darren Tucker7af27bf2017-03-24 09:44:56 +11001541 ldns=yes
Damien Miller523db852017-02-03 16:01:22 +11001542 fi
1543 elif test "x$withval" != "xno" ; then
1544 CPPFLAGS="$CPPFLAGS -I${withval}/include"
1545 LDFLAGS="$LDFLAGS -L${withval}/lib"
1546 LIBS="-lldns $LIBS"
1547 ldns=yes
1548 fi
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001549
Damien Miller523db852017-02-03 16:01:22 +11001550 # Verify that it works.
1551 if test "x$ldns" = "xyes" ; then
1552 AC_DEFINE(HAVE_LDNS, 1, [Define if you want ldns support])
1553 LDNS_MSG="yes"
1554 AC_MSG_CHECKING([for ldns support])
1555 AC_LINK_IFELSE(
1556 [AC_LANG_SOURCE([[
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001557#include <stdio.h>
1558#include <stdlib.h>
1559#include <stdint.h>
1560#include <ldns/ldns.h>
1561int main() { ldns_status status = ldns_verify_trusted(NULL, NULL, NULL, NULL); status=LDNS_STATUS_OK; exit(0); }
Damien Miller523db852017-02-03 16:01:22 +11001562 ]])
1563 ],
1564 [AC_MSG_RESULT(yes)],
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001565 [
1566 AC_MSG_RESULT(no)
1567 AC_MSG_ERROR([** Incomplete or missing ldns libraries.])
1568 ])
Damien Miller523db852017-02-03 16:01:22 +11001569 fi
1570])
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001571
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001572# Check whether user wants libedit support
1573LIBEDIT_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08001574AC_ARG_WITH([libedit],
Darren Tucker1b6f2292005-02-11 16:11:49 +11001575 [ --with-libedit[[=PATH]] Enable libedit support for sftp],
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001576 [ if test "x$withval" != "xno" ; then
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001577 if test "x$withval" = "xyes" ; then
Darren Tucker59353892012-05-19 15:24:37 +10001578 AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no])
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001579 if test "x$PKGCONFIG" != "xno"; then
Tim Rice648f8762011-01-26 12:38:57 -08001580 AC_MSG_CHECKING([if $PKGCONFIG knows about libedit])
Tim Ricee1d93702016-05-31 11:13:22 -07001581 if "$PKGCONFIG" libedit; then
Tim Rice648f8762011-01-26 12:38:57 -08001582 AC_MSG_RESULT([yes])
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001583 use_pkgconfig_for_libedit=yes
1584 else
Tim Rice648f8762011-01-26 12:38:57 -08001585 AC_MSG_RESULT([no])
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001586 fi
1587 fi
1588 else
Darren Tuckerc373a562005-09-22 20:15:08 +10001589 CPPFLAGS="$CPPFLAGS -I${withval}/include"
Darren Tucker2f0bad22019-01-21 21:28:27 +11001590 if test -n "${rpath_opt}"; then
1591 LDFLAGS="-L${withval}/lib ${rpath_opt}${withval}/lib ${LDFLAGS}"
Darren Tuckerc373a562005-09-22 20:15:08 +10001592 else
1593 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
1594 fi
Darren Tucker1df61452005-03-21 09:58:07 +11001595 fi
Damien Miller1f789802010-10-11 22:35:22 +11001596 if test "x$use_pkgconfig_for_libedit" = "xyes"; then
Darren Tucker8369c8e2013-12-05 11:00:16 +11001597 LIBEDIT=`$PKGCONFIG --libs libedit`
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001598 CPPFLAGS="$CPPFLAGS `$PKGCONFIG --cflags libedit`"
1599 else
1600 LIBEDIT="-ledit -lcurses"
1601 fi
1602 OTHERLIBS=`echo $LIBEDIT | sed 's/-ledit//'`
Tim Rice648f8762011-01-26 12:38:57 -08001603 AC_CHECK_LIB([edit], [el_init],
1604 [ AC_DEFINE([USE_LIBEDIT], [1], [Use libedit for sftp])
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001605 LIBEDIT_MSG="yes"
Tim Rice648f8762011-01-26 12:38:57 -08001606 AC_SUBST([LIBEDIT])
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001607 ],
Tim Rice648f8762011-01-26 12:38:57 -08001608 [ AC_MSG_ERROR([libedit not found]) ],
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001609 [ $OTHERLIBS ]
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001610 )
Tim Rice648f8762011-01-26 12:38:57 -08001611 AC_MSG_CHECKING([if libedit version is compatible])
Tim Ricec1819c82005-08-15 17:48:40 -07001612 AC_COMPILE_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001613 [AC_LANG_PROGRAM([[ #include <histedit.h> ]],
1614 [[
Darren Tuckerc7572b22005-08-10 20:34:15 +10001615 int i = H_SETSIZE;
1616 el_init("", NULL, NULL, NULL);
1617 exit(0);
Tim Ricec1819c82005-08-15 17:48:40 -07001618 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001619 [ AC_MSG_RESULT([yes]) ],
1620 [ AC_MSG_RESULT([no])
1621 AC_MSG_ERROR([libedit version is not compatible]) ]
Darren Tuckerc7572b22005-08-10 20:34:15 +10001622 )
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001623 fi ]
1624)
1625
Darren Tuckerd9f88912005-02-20 21:01:48 +11001626AUDIT_MODULE=none
Tim Rice648f8762011-01-26 12:38:57 -08001627AC_ARG_WITH([audit],
Darren Tuckerea52a822011-01-17 21:15:27 +11001628 [ --with-audit=module Enable audit support (modules=debug,bsm,linux)],
Darren Tuckerd9f88912005-02-20 21:01:48 +11001629 [
Tim Rice648f8762011-01-26 12:38:57 -08001630 AC_MSG_CHECKING([for supported audit module])
Darren Tuckerd9f88912005-02-20 21:01:48 +11001631 case "$withval" in
1632 bsm)
Tim Rice648f8762011-01-26 12:38:57 -08001633 AC_MSG_RESULT([bsm])
Darren Tuckerd9f88912005-02-20 21:01:48 +11001634 AUDIT_MODULE=bsm
1635 dnl Checks for headers, libs and functions
Tim Rice648f8762011-01-26 12:38:57 -08001636 AC_CHECK_HEADERS([bsm/audit.h], [],
1637 [AC_MSG_ERROR([BSM enabled and bsm/audit.h not found])],
Darren Tucker6d0d6fb2006-09-09 01:05:21 +10001638 [
1639#ifdef HAVE_TIME_H
1640# include <time.h>
1641#endif
1642 ]
1643)
Tim Rice648f8762011-01-26 12:38:57 -08001644 AC_CHECK_LIB([bsm], [getaudit], [],
1645 [AC_MSG_ERROR([BSM enabled and required library not found])])
1646 AC_CHECK_FUNCS([getaudit], [],
1647 [AC_MSG_ERROR([BSM enabled and required function not found])])
Darren Tuckerd9f88912005-02-20 21:01:48 +11001648 # These are optional
Tim Rice648f8762011-01-26 12:38:57 -08001649 AC_CHECK_FUNCS([getaudit_addr aug_get_machine])
1650 AC_DEFINE([USE_BSM_AUDIT], [1], [Use BSM audit module])
Darren Tucker1fcec9d2013-12-19 11:00:12 +11001651 if test "$sol2ver" -ge 11; then
Tim Ricee1d93702016-05-31 11:13:22 -07001652 SSHDLIBS="$SSHDLIBS -lscf"
1653 AC_DEFINE([BROKEN_BSM_API], [1],
1654 [The system has incomplete BSM API])
Darren Tucker93a2d412012-02-24 10:40:41 +11001655 fi
Darren Tuckerd9f88912005-02-20 21:01:48 +11001656 ;;
Darren Tuckerea52a822011-01-17 21:15:27 +11001657 linux)
Tim Rice648f8762011-01-26 12:38:57 -08001658 AC_MSG_RESULT([linux])
Darren Tuckerea52a822011-01-17 21:15:27 +11001659 AUDIT_MODULE=linux
1660 dnl Checks for headers, libs and functions
Tim Rice648f8762011-01-26 12:38:57 -08001661 AC_CHECK_HEADERS([libaudit.h])
Darren Tuckerea52a822011-01-17 21:15:27 +11001662 SSHDLIBS="$SSHDLIBS -laudit"
Tim Rice648f8762011-01-26 12:38:57 -08001663 AC_DEFINE([USE_LINUX_AUDIT], [1], [Use Linux audit module])
Darren Tuckerea52a822011-01-17 21:15:27 +11001664 ;;
Darren Tuckerd9f88912005-02-20 21:01:48 +11001665 debug)
1666 AUDIT_MODULE=debug
Tim Rice648f8762011-01-26 12:38:57 -08001667 AC_MSG_RESULT([debug])
1668 AC_DEFINE([SSH_AUDIT_EVENTS], [1], [Use audit debugging module])
Darren Tuckerd9f88912005-02-20 21:01:48 +11001669 ;;
Tim Rice8bc6b902005-08-09 10:09:53 -07001670 no)
Tim Rice648f8762011-01-26 12:38:57 -08001671 AC_MSG_RESULT([no])
Tim Rice8bc6b902005-08-09 10:09:53 -07001672 ;;
Darren Tuckerd9f88912005-02-20 21:01:48 +11001673 *)
1674 AC_MSG_ERROR([Unknown audit module $withval])
1675 ;;
1676 esac ]
1677)
1678
Darren Tucker096118d2014-01-21 12:48:51 +11001679AC_ARG_WITH([pie],
Damien Miller76c04802015-01-13 19:38:18 +11001680 [ --with-pie Build Position Independent Executables if possible], [
Darren Tucker096118d2014-01-21 12:48:51 +11001681 if test "x$withval" = "xno"; then
Damien Miller852472a2014-01-22 16:31:18 +11001682 use_pie=no
Darren Tucker096118d2014-01-21 12:48:51 +11001683 fi
1684 if test "x$withval" = "xyes"; then
Damien Miller852472a2014-01-22 16:31:18 +11001685 use_pie=yes
Darren Tucker096118d2014-01-21 12:48:51 +11001686 fi
1687 ]
1688)
Damien Miller852472a2014-01-22 16:31:18 +11001689if test "x$use_pie" = "x"; then
1690 use_pie=no
1691fi
1692if test "x$use_toolchain_hardening" != "x1" && test "x$use_pie" = "xauto"; then
1693 # Turn off automatic PIE when toolchain hardening is off.
1694 use_pie=no
1695fi
Damien Millerc161fc92014-01-29 21:01:33 +11001696if test "x$use_pie" = "xauto"; then
Damien Miller852472a2014-01-22 16:31:18 +11001697 # Automatic PIE requires gcc >= 4.x
1698 AC_MSG_CHECKING([for gcc >= 4.x])
1699 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1700#if !defined(__GNUC__) || __GNUC__ < 4
1701#error gcc is too old
1702#endif
1703]])],
1704 [ AC_MSG_RESULT([yes]) ],
1705 [ AC_MSG_RESULT([no])
1706 use_pie=no ]
1707)
1708fi
1709if test "x$use_pie" != "xno"; then
Damien Miller5c2ff5e2014-01-22 21:30:12 +11001710 SAVED_CFLAGS="$CFLAGS"
1711 SAVED_LDFLAGS="$LDFLAGS"
Darren Tucker096118d2014-01-21 12:48:51 +11001712 OSSH_CHECK_CFLAG_COMPILE([-fPIE])
1713 OSSH_CHECK_LDFLAG_LINK([-pie])
Damien Miller5c2ff5e2014-01-22 21:30:12 +11001714 # We use both -fPIE and -pie or neither.
1715 AC_MSG_CHECKING([whether both -fPIE and -pie are supported])
1716 if echo "x $CFLAGS" | grep ' -fPIE' >/dev/null 2>&1 && \
1717 echo "x $LDFLAGS" | grep ' -pie' >/dev/null 2>&1 ; then
1718 AC_MSG_RESULT([yes])
1719 else
1720 AC_MSG_RESULT([no])
1721 CFLAGS="$SAVED_CFLAGS"
1722 LDFLAGS="$SAVED_LDFLAGS"
1723 fi
Darren Tucker096118d2014-01-21 12:48:51 +11001724fi
1725
Damien Millerfe1f1432003-02-24 15:45:42 +11001726dnl Checks for library functions. Please keep in alphabetical order
Tim Rice648f8762011-01-26 12:38:57 -08001727AC_CHECK_FUNCS([ \
Damien Miller1ff130d2013-12-07 11:51:51 +11001728 Blowfish_initstate \
1729 Blowfish_expandstate \
1730 Blowfish_expand0state \
1731 Blowfish_stream2word \
Darren Tucker11cba2a2019-07-23 21:51:22 +10001732 SHA256Update \
1733 SHA384Update \
1734 SHA512Update \
Damien Miller57f39152005-11-24 19:58:19 +11001735 asprintf \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001736 b64_ntop \
1737 __b64_ntop \
1738 b64_pton \
1739 __b64_pton \
1740 bcopy \
Damien Millera9134422013-12-07 11:35:36 +11001741 bcrypt_pbkdf \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001742 bindresvport_sa \
Damien Miller1ff130d2013-12-07 11:51:51 +11001743 blf_enc \
Darren Tuckera9004422018-02-24 20:25:22 +11001744 bzero \
Damien Millerc96d8532014-01-25 13:12:28 +11001745 cap_rights_limit \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001746 clock \
1747 closefrom \
1748 dirfd \
Darren Tuckerefdf5342013-05-30 08:29:08 +10001749 endgrent \
Darren Tucker6310ef22016-07-13 14:42:35 +10001750 err \
1751 errx \
Damien Miller1d2c4562014-02-04 11:18:20 +11001752 explicit_bzero \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001753 fchmod \
Darren Tuckera6258e52019-01-18 11:09:01 +11001754 fchmodat \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001755 fchown \
Darren Tuckera6258e52019-01-18 11:09:01 +11001756 fchownat \
Darren Tuckercd3ab572018-02-26 14:37:06 +11001757 flock \
Darren Tucker0e3c5bc2019-11-01 18:24:29 +11001758 fnmatch \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001759 freeaddrinfo \
Damien Millerb7956912017-09-19 12:29:23 +10001760 freezero \
Darren Tuckera5cf1e22014-01-17 18:10:58 +11001761 fstatfs \
Darren Tucker598eaa62008-06-09 03:32:29 +10001762 fstatvfs \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001763 futimes \
1764 getaddrinfo \
1765 getcwd \
1766 getgrouplist \
Darren Tucker6301e6c2018-07-02 21:16:58 +10001767 getline \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001768 getnameinfo \
1769 getopt \
Damien Miller151c6e42017-06-01 15:25:13 +10001770 getpagesize \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001771 getpeereid \
Darren Tucker164aa302007-03-21 21:39:57 +11001772 getpeerucred \
Darren Tucker3c4a24c2013-02-15 11:41:35 +11001773 getpgid \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001774 _getpty \
1775 getrlimit \
Damien Millerafa6e792018-04-13 13:31:42 +10001776 getrandom \
Darren Tuckerb39593a2018-02-25 13:25:15 +11001777 getsid \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001778 getttyent \
1779 glob \
Darren Tucker909a3902010-01-15 12:38:30 +11001780 group_from_gid \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001781 inet_aton \
1782 inet_ntoa \
1783 inet_ntop \
1784 innetgr \
Darren Tuckerd38f05d2017-03-20 13:38:27 +11001785 llabs \
Darren Tucker1bcd1162019-10-29 19:45:03 +11001786 localtime_r \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001787 login_getcapbool \
1788 md5_crypt \
Darren Tucker45478892019-07-16 09:20:23 +10001789 memmem \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001790 memmove \
Damien Miller3d673d12014-08-27 06:32:01 +10001791 memset_s \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001792 mkdtemp \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001793 ngetaddrinfo \
1794 nsleep \
1795 ogetaddrinfo \
1796 openlog_r \
Darren Tucker3ddd15e2015-11-30 07:23:53 +11001797 pledge \
Darren Tuckerfebf0f52007-06-25 22:15:12 +10001798 poll \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001799 prctl \
1800 pstat \
Darren Tucker6c8c9a62018-02-24 20:46:37 +11001801 raise \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001802 readpassphrase \
Darren Tucker642652d2014-12-10 01:32:23 +11001803 reallocarray \
Darren Tucker79d46de2019-11-01 15:22:32 +11001804 realpath \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001805 recvmsg \
Damien Miller151c6e42017-06-01 15:25:13 +10001806 recallocarray \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001807 rresvport_af \
1808 sendmsg \
1809 setdtablesize \
1810 setegid \
1811 setenv \
1812 seteuid \
Darren Tucker909a3902010-01-15 12:38:30 +11001813 setgroupent \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001814 setgroups \
Darren Tucker34f702a2012-07-04 08:50:09 +10001815 setlinebuf \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001816 setlogin \
Darren Tucker909a3902010-01-15 12:38:30 +11001817 setpassent\
Darren Tucker0c9653f2005-05-28 15:58:14 +10001818 setpcred \
1819 setproctitle \
1820 setregid \
1821 setreuid \
1822 setrlimit \
1823 setsid \
1824 setvbuf \
1825 sigaction \
1826 sigvec \
1827 snprintf \
1828 socketpair \
Darren Tucker5b2e2ba2008-06-08 09:25:28 +10001829 statfs \
1830 statvfs \
Darren Tuckerafec0772016-12-13 10:23:03 +11001831 strcasestr \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001832 strdup \
1833 strerror \
1834 strlcat \
1835 strlcpy \
1836 strmode \
Darren Tucker33561e62018-03-03 14:56:09 +11001837 strndup \
Darren Tuckerb54f50e2011-09-29 23:17:18 +10001838 strnlen \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001839 strnvis \
Darren Tuckeraa74f672010-08-16 13:15:23 +10001840 strptime \
Darren Tucker44fc3342017-09-25 09:48:10 +10001841 strsignal \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001842 strtonum \
Darren Tucker81eb5d52005-06-01 21:39:33 +10001843 strtoll \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001844 strtoul \
Darren Tucker8e6fb782013-02-15 12:13:01 +11001845 strtoull \
Damien Miller34a17692007-06-11 14:15:42 +10001846 swap32 \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001847 sysconf \
1848 tcgetpgrp \
Damien Milleraa180632010-10-07 21:25:27 +11001849 timingsafe_bcmp \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001850 truncate \
1851 unsetenv \
1852 updwtmpx \
Darren Tucker091093d2019-01-18 12:11:42 +13001853 utimensat \
Darren Tucker909a3902010-01-15 12:38:30 +11001854 user_from_uid \
Damien Millerf4db77d2013-03-15 10:34:25 +11001855 usleep \
Damien Miller57f39152005-11-24 19:58:19 +11001856 vasprintf \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001857 vsnprintf \
1858 waitpid \
Darren Tucker6310ef22016-07-13 14:42:35 +10001859 warn \
Tim Rice648f8762011-01-26 12:38:57 -08001860])
Tim Rice13aae5e2001-10-21 17:53:58 -07001861
Darren Tuckera9004422018-02-24 20:25:22 +11001862AC_CHECK_DECLS([bzero])
1863
Darren Tuckerc61d5ec2017-02-03 14:10:34 +11001864dnl Wide character support.
Darren Tuckera2333582016-07-14 10:59:09 +10001865AC_CHECK_FUNCS([mblen mbtowc nl_langinfo wcwidth])
Darren Tuckera2333582016-07-14 10:59:09 +10001866
Darren Tucker10e290e2016-12-13 13:51:32 +11001867TEST_SSH_UTF8=${TEST_SSH_UTF8:=yes}
Darren Tucker47b8c992016-12-08 15:48:34 +11001868AC_MSG_CHECKING([for utf8 locale support])
1869AC_RUN_IFELSE(
1870 [AC_LANG_PROGRAM([[
1871#include <locale.h>
Darren Tuckerc3599502016-12-09 12:52:02 +11001872#include <stdlib.h>
Darren Tucker47b8c992016-12-08 15:48:34 +11001873 ]], [[
1874 char *loc = setlocale(LC_CTYPE, "en_US.UTF-8");
1875 if (loc != NULL)
1876 exit(0);
1877 exit(1);
1878 ]])],
1879 AC_MSG_RESULT(yes),
1880 [AC_MSG_RESULT(no)
1881 TEST_SSH_UTF8=no],
1882 AC_MSG_WARN([cross compiling: assuming yes])
1883)
1884
Tim Ricec7a8af02010-11-08 14:26:23 -08001885AC_LINK_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001886 [AC_LANG_PROGRAM(
1887 [[ #include <ctype.h> ]],
1888 [[ return (isblank('a')); ]])],
1889 [AC_DEFINE([HAVE_ISBLANK], [1], [Define if you have isblank(3C).])
Tim Ricec7a8af02010-11-08 14:26:23 -08001890])
1891
Damien Miller5fbe93f2016-07-15 13:54:31 +10001892disable_pkcs11=
1893AC_ARG_ENABLE([pkcs11],
1894 [ --disable-pkcs11 disable PKCS#11 support code [no]],
1895 [
1896 if test "x$enableval" = "xno" ; then
1897 disable_pkcs11=1
1898 fi
1899 ]
1900)
1901
Damien Miller764d51e2019-11-01 13:34:49 +11001902disable_sk=
1903AC_ARG_ENABLE([security-key],
1904 [ --disable-security-key disable U2F/FIDO support code [no]],
1905 [
1906 if test "x$enableval" = "xno" ; then
1907 disable_sk=1
1908 fi
1909 ]
1910)
1911
Damien Miller764d51e2019-11-01 13:34:49 +11001912AC_SEARCH_LIBS([dlopen], [dl])
1913AC_CHECK_FUNCS([dlopen])
1914AC_CHECK_DECL([RTLD_NOW], [], [], [#include <dlfcn.h>])
1915
Darren Tuckerd5e082f2003-09-22 12:08:23 +10001916# IRIX has a const char return value for gai_strerror()
Tim Rice648f8762011-01-26 12:38:57 -08001917AC_CHECK_FUNCS([gai_strerror], [
1918 AC_DEFINE([HAVE_GAI_STRERROR])
1919 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckerd5e082f2003-09-22 12:08:23 +10001920#include <sys/types.h>
1921#include <sys/socket.h>
1922#include <netdb.h>
1923
Tim Rice648f8762011-01-26 12:38:57 -08001924const char *gai_strerror(int);
1925 ]], [[
1926 char *str;
1927 str = gai_strerror(0);
1928 ]])], [
1929 AC_DEFINE([HAVE_CONST_GAI_STRERROR_PROTO], [1],
1930 [Define if gai_strerror() returns const char *])], [])])
Darren Tuckerd5e082f2003-09-22 12:08:23 +10001931
Tim Rice648f8762011-01-26 12:38:57 -08001932AC_SEARCH_LIBS([nanosleep], [rt posix4], [AC_DEFINE([HAVE_NANOSLEEP], [1],
1933 [Some systems put nanosleep outside of libc])])
Damien Millercd6853c2003-01-28 11:33:42 +11001934
Darren Tuckera7108912013-06-02 08:18:31 +10001935AC_SEARCH_LIBS([clock_gettime], [rt],
1936 [AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Have clock_gettime])])
1937
Darren Tuckerf1159b52003-07-07 19:44:01 +10001938dnl Make sure prototypes are defined for these before using them.
Tim Rice648f8762011-01-26 12:38:57 -08001939AC_CHECK_DECL([strsep],
1940 [AC_CHECK_FUNCS([strsep])],
Darren Tucker390b6d52005-05-28 16:54:36 +10001941 [],
1942 [
1943#ifdef HAVE_STRING_H
1944# include <string.h>
1945#endif
1946 ])
Ben Lindstrom3e006472002-10-16 00:24:03 +00001947
Darren Tuckerb2427c82003-09-10 15:22:44 +10001948dnl tcsendbreak might be a macro
Tim Rice648f8762011-01-26 12:38:57 -08001949AC_CHECK_DECL([tcsendbreak],
1950 [AC_DEFINE([HAVE_TCSENDBREAK])],
1951 [AC_CHECK_FUNCS([tcsendbreak])],
Darren Tuckerb2427c82003-09-10 15:22:44 +10001952 [#include <termios.h>]
1953)
1954
Tim Rice648f8762011-01-26 12:38:57 -08001955AC_CHECK_DECLS([h_errno], , ,[#include <netdb.h>])
Darren Tucker5bb14002004-04-23 18:53:10 +10001956
Tim Rice648f8762011-01-26 12:38:57 -08001957AC_CHECK_DECLS([SHUT_RD], , ,
Darren Tucker128a0892006-07-12 19:02:56 +10001958 [
1959#include <sys/types.h>
1960#include <sys/socket.h>
1961 ])
Darren Tucker248469b2006-07-12 14:14:31 +10001962
Tim Rice648f8762011-01-26 12:38:57 -08001963AC_CHECK_DECLS([O_NONBLOCK], , ,
Darren Tucker248469b2006-07-12 14:14:31 +10001964 [
1965#include <sys/types.h>
1966#ifdef HAVE_SYS_STAT_H
1967# include <sys/stat.h>
1968#endif
1969#ifdef HAVE_FCNTL_H
1970# include <fcntl.h>
1971#endif
1972 ])
1973
Darren Tucker2eb40412018-02-24 21:06:48 +11001974AC_CHECK_DECLS([readv, writev], , , [
Darren Tuckered0b5922006-09-03 22:44:49 +10001975#include <sys/types.h>
1976#include <sys/uio.h>
1977#include <unistd.h>
1978 ])
1979
Tim Rice648f8762011-01-26 12:38:57 -08001980AC_CHECK_DECLS([MAXSYMLINKS], , , [
Darren Tucker6d862a52007-04-29 14:39:02 +10001981#include <sys/param.h>
1982 ])
1983
Tim Rice648f8762011-01-26 12:38:57 -08001984AC_CHECK_DECLS([offsetof], , , [
Darren Tuckerdca0edf2007-04-29 15:06:44 +10001985#include <stddef.h>
1986 ])
1987
Darren Tuckerc7aad002013-06-02 07:18:47 +10001988# extra bits for select(2)
1989AC_CHECK_DECLS([howmany, NFDBITS], [], [], [[
1990#include <sys/param.h>
1991#include <sys/types.h>
1992#ifdef HAVE_SYS_SYSMACROS_H
1993#include <sys/sysmacros.h>
1994#endif
1995#ifdef HAVE_SYS_SELECT_H
1996#include <sys/select.h>
1997#endif
1998#ifdef HAVE_SYS_TIME_H
1999#include <sys/time.h>
2000#endif
2001#ifdef HAVE_UNISTD_H
2002#include <unistd.h>
2003#endif
2004 ]])
2005AC_CHECK_TYPES([fd_mask], [], [], [[
2006#include <sys/param.h>
2007#include <sys/types.h>
2008#ifdef HAVE_SYS_SELECT_H
2009#include <sys/select.h>
2010#endif
2011#ifdef HAVE_SYS_TIME_H
2012#include <sys/time.h>
2013#endif
2014#ifdef HAVE_UNISTD_H
2015#include <unistd.h>
2016#endif
2017 ]])
2018
Tim Rice648f8762011-01-26 12:38:57 -08002019AC_CHECK_FUNCS([setresuid], [
Darren Tucker2a6b0292003-12-31 14:59:17 +11002020 dnl Some platorms have setresuid that isn't implemented, test for this
Tim Rice648f8762011-01-26 12:38:57 -08002021 AC_MSG_CHECKING([if setresuid seems to work])
Darren Tucker623d92f2004-09-12 22:36:15 +10002022 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002023 [AC_LANG_PROGRAM([[
Darren Tuckere937be32003-12-17 18:53:26 +11002024#include <stdlib.h>
2025#include <errno.h>
Tim Rice648f8762011-01-26 12:38:57 -08002026 ]], [[
2027 errno=0;
2028 setresuid(0,0,0);
2029 if (errno==ENOSYS)
2030 exit(1);
2031 else
2032 exit(0);
Darren Tucker623d92f2004-09-12 22:36:15 +10002033 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08002034 [AC_MSG_RESULT([yes])],
2035 [AC_DEFINE([BROKEN_SETRESUID], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07002036 [Define if your setresuid() is broken])
Tim Rice648f8762011-01-26 12:38:57 -08002037 AC_MSG_RESULT([not implemented])],
Darren Tuckera0c2b392004-09-11 23:26:37 +10002038 [AC_MSG_WARN([cross compiling: not checking setresuid])]
Darren Tucker2a6b0292003-12-31 14:59:17 +11002039 )
2040])
Darren Tuckere937be32003-12-17 18:53:26 +11002041
Tim Rice648f8762011-01-26 12:38:57 -08002042AC_CHECK_FUNCS([setresgid], [
Darren Tucker2a6b0292003-12-31 14:59:17 +11002043 dnl Some platorms have setresgid that isn't implemented, test for this
Tim Rice648f8762011-01-26 12:38:57 -08002044 AC_MSG_CHECKING([if setresgid seems to work])
Darren Tucker623d92f2004-09-12 22:36:15 +10002045 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002046 [AC_LANG_PROGRAM([[
Darren Tuckere937be32003-12-17 18:53:26 +11002047#include <stdlib.h>
2048#include <errno.h>
Tim Rice648f8762011-01-26 12:38:57 -08002049 ]], [[
2050 errno=0;
2051 setresgid(0,0,0);
2052 if (errno==ENOSYS)
2053 exit(1);
2054 else
2055 exit(0);
Darren Tucker623d92f2004-09-12 22:36:15 +10002056 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08002057 [AC_MSG_RESULT([yes])],
2058 [AC_DEFINE([BROKEN_SETRESGID], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07002059 [Define if your setresgid() is broken])
Tim Rice648f8762011-01-26 12:38:57 -08002060 AC_MSG_RESULT([not implemented])],
Darren Tuckera0c2b392004-09-11 23:26:37 +10002061 [AC_MSG_WARN([cross compiling: not checking setresuid])]
Darren Tucker2a6b0292003-12-31 14:59:17 +11002062 )
2063])
Darren Tuckere937be32003-12-17 18:53:26 +11002064
Darren Tucker58fd4c52018-03-05 19:28:08 +11002065AC_MSG_CHECKING([for working fflush(NULL)])
2066AC_RUN_IFELSE(
2067 [AC_LANG_PROGRAM([[#include <stdio.h>]], [[fflush(NULL); exit(0);]])],
2068 AC_MSG_RESULT([yes]),
2069 [AC_MSG_RESULT([no])
2070 AC_DEFINE([FFLUSH_NULL_BUG], [1],
2071 [define if fflush(NULL) does not work])],
2072 AC_MSG_WARN([cross compiling: assuming working])
2073)
2074
Damien Millerad833b32000-08-23 10:46:23 +10002075dnl Checks for time functions
Tim Rice648f8762011-01-26 12:38:57 -08002076AC_CHECK_FUNCS([gettimeofday time])
Damien Millerad833b32000-08-23 10:46:23 +10002077dnl Checks for utmp functions
Tim Rice648f8762011-01-26 12:38:57 -08002078AC_CHECK_FUNCS([endutent getutent getutid getutline pututline setutent])
2079AC_CHECK_FUNCS([utmpname])
Damien Millerad833b32000-08-23 10:46:23 +10002080dnl Checks for utmpx functions
Tim Rice648f8762011-01-26 12:38:57 -08002081AC_CHECK_FUNCS([endutxent getutxent getutxid getutxline getutxuser pututxline])
2082AC_CHECK_FUNCS([setutxdb setutxent utmpxname])
Damien Miller20e231f2009-02-12 13:12:21 +11002083dnl Checks for lastlog functions
Tim Rice648f8762011-01-26 12:38:57 -08002084AC_CHECK_FUNCS([getlastlogxbyname])
Damien Millercedfecc1999-11-15 14:36:53 +11002085
Tim Rice648f8762011-01-26 12:38:57 -08002086AC_CHECK_FUNC([daemon],
2087 [AC_DEFINE([HAVE_DAEMON], [1], [Define if your libraries define daemon()])],
2088 [AC_CHECK_LIB([bsd], [daemon],
2089 [LIBS="$LIBS -lbsd"; AC_DEFINE([HAVE_DAEMON])])]
Damien Miller04f80141999-11-19 15:32:34 +11002090)
2091
Tim Rice648f8762011-01-26 12:38:57 -08002092AC_CHECK_FUNC([getpagesize],
2093 [AC_DEFINE([HAVE_GETPAGESIZE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07002094 [Define if your libraries define getpagesize()])],
Tim Rice648f8762011-01-26 12:38:57 -08002095 [AC_CHECK_LIB([ucb], [getpagesize],
2096 [LIBS="$LIBS -lucb"; AC_DEFINE([HAVE_GETPAGESIZE])])]
Damien Miller9fb07e42000-03-05 16:22:59 +11002097)
2098
Damien Millercb170cb2000-07-01 16:52:55 +10002099# Check for broken snprintf
2100if test "x$ac_cv_func_snprintf" = "xyes" ; then
2101 AC_MSG_CHECKING([whether snprintf correctly terminates long strings])
Darren Tuckera0c2b392004-09-11 23:26:37 +10002102 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002103 [AC_LANG_PROGRAM([[ #include <stdio.h> ]],
2104 [[
2105 char b[5];
2106 snprintf(b,5,"123456789");
Tim Ricee1d93702016-05-31 11:13:22 -07002107 exit(b[4]!='\0');
Darren Tucker623d92f2004-09-12 22:36:15 +10002108 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08002109 [AC_MSG_RESULT([yes])],
Damien Millercb170cb2000-07-01 16:52:55 +10002110 [
Tim Rice648f8762011-01-26 12:38:57 -08002111 AC_MSG_RESULT([no])
2112 AC_DEFINE([BROKEN_SNPRINTF], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07002113 [Define if your snprintf is busted])
Damien Millercb170cb2000-07-01 16:52:55 +10002114 AC_MSG_WARN([****** Your snprintf() function is broken, complain to your vendor])
Darren Tuckera0c2b392004-09-11 23:26:37 +10002115 ],
2116 [ AC_MSG_WARN([cross compiling: Assuming working snprintf()]) ]
Damien Millercb170cb2000-07-01 16:52:55 +10002117 )
2118fi
2119
Darren Tuckere5261272018-10-12 16:43:35 +11002120if test "x$ac_cv_func_snprintf" = "xyes" ; then
2121 AC_MSG_CHECKING([whether snprintf understands %zu])
2122 AC_RUN_IFELSE(
2123 [AC_LANG_PROGRAM([[
2124#include <sys/types.h>
2125#include <stdio.h>
2126 ]],
2127 [[
2128 size_t a = 1, b = 2;
2129 char z[128];
2130 snprintf(z, sizeof z, "%zu%zu", a, b);
2131 exit(strcmp(z, "12"));
2132 ]])],
2133 [AC_MSG_RESULT([yes])],
2134 [
2135 AC_MSG_RESULT([no])
2136 AC_DEFINE([BROKEN_SNPRINTF], [1],
2137 [snprintf does not understand %zu])
2138 ],
2139 [ AC_MSG_WARN([cross compiling: Assuming working snprintf()]) ]
2140 )
2141fi
2142
Damien Millerd244a582014-08-23 17:06:49 +10002143# We depend on vsnprintf returning the right thing on overflow: the
2144# number of characters it tried to create (as per SUSv3)
2145if test "x$ac_cv_func_vsnprintf" = "xyes" ; then
Damien Miller57f39152005-11-24 19:58:19 +11002146 AC_MSG_CHECKING([whether vsnprintf returns correct values on overflow])
2147 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002148 [AC_LANG_PROGRAM([[
Damien Miller57f39152005-11-24 19:58:19 +11002149#include <sys/types.h>
2150#include <stdio.h>
2151#include <stdarg.h>
2152
Damien Millerd244a582014-08-23 17:06:49 +10002153int x_snprintf(char *str, size_t count, const char *fmt, ...)
Damien Miller57f39152005-11-24 19:58:19 +11002154{
Damien Millerd244a582014-08-23 17:06:49 +10002155 size_t ret;
2156 va_list ap;
2157
2158 va_start(ap, fmt);
2159 ret = vsnprintf(str, count, fmt, ap);
2160 va_end(ap);
Damien Miller57f39152005-11-24 19:58:19 +11002161 return ret;
2162}
Tim Rice648f8762011-01-26 12:38:57 -08002163 ]], [[
Damien Millerd244a582014-08-23 17:06:49 +10002164char x[1];
2165if (x_snprintf(x, 1, "%s %d", "hello", 12345) != 11)
2166 return 1;
2167if (x_snprintf(NULL, 0, "%s %d", "hello", 12345) != 11)
2168 return 1;
2169return 0;
Tim Rice648f8762011-01-26 12:38:57 -08002170 ]])],
2171 [AC_MSG_RESULT([yes])],
Damien Miller57f39152005-11-24 19:58:19 +11002172 [
Tim Rice648f8762011-01-26 12:38:57 -08002173 AC_MSG_RESULT([no])
2174 AC_DEFINE([BROKEN_SNPRINTF], [1],
Damien Miller57f39152005-11-24 19:58:19 +11002175 [Define if your snprintf is busted])
2176 AC_MSG_WARN([****** Your vsnprintf() function is broken, complain to your vendor])
2177 ],
2178 [ AC_MSG_WARN([cross compiling: Assuming working vsnprintf()]) ]
2179 )
2180fi
2181
Darren Tuckerd40c66c2005-12-17 22:32:03 +11002182# On systems where [v]snprintf is broken, but is declared in stdio,
2183# check that the fmt argument is const char * or just char *.
2184# This is only useful for when BROKEN_SNPRINTF
2185AC_MSG_CHECKING([whether snprintf can declare const char *fmt])
Tim Rice648f8762011-01-26 12:38:57 -08002186AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2187#include <stdio.h>
2188int snprintf(char *a, size_t b, const char *c, ...) { return 0; }
2189 ]], [[
2190 snprintf(0, 0, 0);
2191 ]])],
2192 [AC_MSG_RESULT([yes])
2193 AC_DEFINE([SNPRINTF_CONST], [const],
Darren Tuckerd40c66c2005-12-17 22:32:03 +11002194 [Define as const if snprintf() can declare const char *fmt])],
Tim Rice648f8762011-01-26 12:38:57 -08002195 [AC_MSG_RESULT([no])
2196 AC_DEFINE([SNPRINTF_CONST], [/* not const */])])
Darren Tuckerd40c66c2005-12-17 22:32:03 +11002197
Damien Millerb4097182004-05-23 14:09:40 +10002198# Check for missing getpeereid (or equiv) support
2199NO_PEERCHECK=""
Darren Tucker164aa302007-03-21 21:39:57 +11002200if test "x$ac_cv_func_getpeereid" != "xyes" -a "x$ac_cv_func_getpeerucred" != "xyes"; then
Damien Millerb4097182004-05-23 14:09:40 +10002201 AC_MSG_CHECKING([whether system supports SO_PEERCRED getsockopt])
Tim Rice648f8762011-01-26 12:38:57 -08002202 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2203#include <sys/types.h>
2204#include <sys/socket.h>]], [[int i = SO_PEERCRED;]])],
2205 [ AC_MSG_RESULT([yes])
2206 AC_DEFINE([HAVE_SO_PEERCRED], [1], [Have PEERCRED socket option])
2207 ], [AC_MSG_RESULT([no])
2208 NO_PEERCHECK=1
2209 ])
Damien Millerb4097182004-05-23 14:09:40 +10002210fi
2211
Damien Millere8328192003-01-07 15:18:32 +11002212dnl see whether mkstemp() requires XXXXXX
2213if test "x$ac_cv_func_mkdtemp" = "xyes" ; then
2214AC_MSG_CHECKING([for (overly) strict mkstemp])
Darren Tucker314d89e2005-10-17 23:29:23 +10002215AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002216 [AC_LANG_PROGRAM([[
Damien Millere8328192003-01-07 15:18:32 +11002217#include <stdlib.h>
Tim Rice648f8762011-01-26 12:38:57 -08002218 ]], [[
2219 char template[]="conftest.mkstemp-test";
2220 if (mkstemp(template) == -1)
2221 exit(1);
2222 unlink(template);
2223 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10002224 ]])],
Damien Millere8328192003-01-07 15:18:32 +11002225 [
Tim Rice648f8762011-01-26 12:38:57 -08002226 AC_MSG_RESULT([no])
Damien Millere8328192003-01-07 15:18:32 +11002227 ],
Damien Millera8e06ce2003-11-21 23:48:55 +11002228 [
Tim Rice648f8762011-01-26 12:38:57 -08002229 AC_MSG_RESULT([yes])
2230 AC_DEFINE([HAVE_STRICT_MKSTEMP], [1], [Silly mkstemp()])
Damien Millere8328192003-01-07 15:18:32 +11002231 ],
2232 [
Tim Rice648f8762011-01-26 12:38:57 -08002233 AC_MSG_RESULT([yes])
2234 AC_DEFINE([HAVE_STRICT_MKSTEMP])
Damien Millera8e06ce2003-11-21 23:48:55 +11002235 ]
Damien Millere8328192003-01-07 15:18:32 +11002236)
2237fi
2238
Darren Tucker70a3d552003-08-21 17:58:29 +10002239dnl make sure that openpty does not reacquire controlling terminal
2240if test ! -z "$check_for_openpty_ctty_bug"; then
Tim Rice648f8762011-01-26 12:38:57 -08002241 AC_MSG_CHECKING([if openpty correctly handles controlling tty])
Darren Tucker314d89e2005-10-17 23:29:23 +10002242 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002243 [AC_LANG_PROGRAM([[
Darren Tucker70a3d552003-08-21 17:58:29 +10002244#include <stdio.h>
2245#include <sys/fcntl.h>
2246#include <sys/types.h>
2247#include <sys/wait.h>
Tim Rice648f8762011-01-26 12:38:57 -08002248 ]], [[
Darren Tucker70a3d552003-08-21 17:58:29 +10002249 pid_t pid;
2250 int fd, ptyfd, ttyfd, status;
2251
2252 pid = fork();
2253 if (pid < 0) { /* failed */
2254 exit(1);
2255 } else if (pid > 0) { /* parent */
2256 waitpid(pid, &status, 0);
Damien Millera8e06ce2003-11-21 23:48:55 +11002257 if (WIFEXITED(status))
Darren Tucker70a3d552003-08-21 17:58:29 +10002258 exit(WEXITSTATUS(status));
2259 else
2260 exit(2);
2261 } else { /* child */
2262 close(0); close(1); close(2);
2263 setsid();
2264 openpty(&ptyfd, &ttyfd, NULL, NULL, NULL);
2265 fd = open("/dev/tty", O_RDWR | O_NOCTTY);
2266 if (fd >= 0)
2267 exit(3); /* Acquired ctty: broken */
2268 else
2269 exit(0); /* Did not acquire ctty: OK */
2270 }
Darren Tucker314d89e2005-10-17 23:29:23 +10002271 ]])],
Darren Tucker70a3d552003-08-21 17:58:29 +10002272 [
Tim Rice648f8762011-01-26 12:38:57 -08002273 AC_MSG_RESULT([yes])
Darren Tucker70a3d552003-08-21 17:58:29 +10002274 ],
2275 [
Tim Rice648f8762011-01-26 12:38:57 -08002276 AC_MSG_RESULT([no])
2277 AC_DEFINE([SSHD_ACQUIRES_CTTY])
Darren Tucker314d89e2005-10-17 23:29:23 +10002278 ],
2279 [
Tim Rice648f8762011-01-26 12:38:57 -08002280 AC_MSG_RESULT([cross-compiling, assuming yes])
Darren Tucker70a3d552003-08-21 17:58:29 +10002281 ]
2282 )
2283fi
2284
Tim Rice8bb561b2005-03-17 16:23:19 -08002285if test "x$ac_cv_func_getaddrinfo" = "xyes" && \
2286 test "x$check_for_hpux_broken_getaddrinfo" = "x1"; then
Tim Rice648f8762011-01-26 12:38:57 -08002287 AC_MSG_CHECKING([if getaddrinfo seems to work])
Darren Tucker314d89e2005-10-17 23:29:23 +10002288 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002289 [AC_LANG_PROGRAM([[
Darren Tucker4398cf52004-04-06 21:39:02 +10002290#include <stdio.h>
2291#include <sys/socket.h>
2292#include <netdb.h>
2293#include <errno.h>
2294#include <netinet/in.h>
2295
2296#define TEST_PORT "2222"
Tim Rice648f8762011-01-26 12:38:57 -08002297 ]], [[
Darren Tucker4398cf52004-04-06 21:39:02 +10002298 int err, sock;
2299 struct addrinfo *gai_ai, *ai, hints;
2300 char ntop[NI_MAXHOST], strport[NI_MAXSERV], *name = NULL;
2301
2302 memset(&hints, 0, sizeof(hints));
2303 hints.ai_family = PF_UNSPEC;
2304 hints.ai_socktype = SOCK_STREAM;
2305 hints.ai_flags = AI_PASSIVE;
2306
2307 err = getaddrinfo(name, TEST_PORT, &hints, &gai_ai);
2308 if (err != 0) {
2309 fprintf(stderr, "getaddrinfo failed (%s)", gai_strerror(err));
2310 exit(1);
2311 }
2312
2313 for (ai = gai_ai; ai != NULL; ai = ai->ai_next) {
2314 if (ai->ai_family != AF_INET6)
2315 continue;
2316
2317 err = getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop,
2318 sizeof(ntop), strport, sizeof(strport),
2319 NI_NUMERICHOST|NI_NUMERICSERV);
2320
2321 if (err != 0) {
2322 if (err == EAI_SYSTEM)
2323 perror("getnameinfo EAI_SYSTEM");
2324 else
2325 fprintf(stderr, "getnameinfo failed: %s\n",
2326 gai_strerror(err));
2327 exit(2);
2328 }
2329
2330 sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
2331 if (sock < 0)
2332 perror("socket");
2333 if (bind(sock, ai->ai_addr, ai->ai_addrlen) < 0) {
2334 if (errno == EBADF)
2335 exit(3);
2336 }
2337 }
2338 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10002339 ]])],
Darren Tucker4398cf52004-04-06 21:39:02 +10002340 [
Tim Rice648f8762011-01-26 12:38:57 -08002341 AC_MSG_RESULT([yes])
Darren Tucker4398cf52004-04-06 21:39:02 +10002342 ],
2343 [
Tim Rice648f8762011-01-26 12:38:57 -08002344 AC_MSG_RESULT([no])
2345 AC_DEFINE([BROKEN_GETADDRINFO])
Darren Tucker314d89e2005-10-17 23:29:23 +10002346 ],
2347 [
Tim Rice648f8762011-01-26 12:38:57 -08002348 AC_MSG_RESULT([cross-compiling, assuming yes])
Darren Tucker4398cf52004-04-06 21:39:02 +10002349 ]
2350 )
2351fi
2352
Tim Rice8bb561b2005-03-17 16:23:19 -08002353if test "x$ac_cv_func_getaddrinfo" = "xyes" && \
2354 test "x$check_for_aix_broken_getaddrinfo" = "x1"; then
Tim Rice648f8762011-01-26 12:38:57 -08002355 AC_MSG_CHECKING([if getaddrinfo seems to work])
Darren Tucker314d89e2005-10-17 23:29:23 +10002356 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002357 [AC_LANG_PROGRAM([[
Darren Tucker691d5232005-02-15 21:45:57 +11002358#include <stdio.h>
2359#include <sys/socket.h>
2360#include <netdb.h>
2361#include <errno.h>
2362#include <netinet/in.h>
2363
2364#define TEST_PORT "2222"
Tim Rice648f8762011-01-26 12:38:57 -08002365 ]], [[
Darren Tucker691d5232005-02-15 21:45:57 +11002366 int err, sock;
2367 struct addrinfo *gai_ai, *ai, hints;
2368 char ntop[NI_MAXHOST], strport[NI_MAXSERV], *name = NULL;
2369
2370 memset(&hints, 0, sizeof(hints));
2371 hints.ai_family = PF_UNSPEC;
2372 hints.ai_socktype = SOCK_STREAM;
2373 hints.ai_flags = AI_PASSIVE;
2374
2375 err = getaddrinfo(name, TEST_PORT, &hints, &gai_ai);
2376 if (err != 0) {
2377 fprintf(stderr, "getaddrinfo failed (%s)", gai_strerror(err));
2378 exit(1);
2379 }
2380
2381 for (ai = gai_ai; ai != NULL; ai = ai->ai_next) {
2382 if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6)
2383 continue;
2384
2385 err = getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop,
2386 sizeof(ntop), strport, sizeof(strport),
2387 NI_NUMERICHOST|NI_NUMERICSERV);
2388
2389 if (ai->ai_family == AF_INET && err != 0) {
2390 perror("getnameinfo");
2391 exit(2);
2392 }
2393 }
2394 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10002395 ]])],
Darren Tucker691d5232005-02-15 21:45:57 +11002396 [
Tim Rice648f8762011-01-26 12:38:57 -08002397 AC_MSG_RESULT([yes])
2398 AC_DEFINE([AIX_GETNAMEINFO_HACK], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07002399 [Define if you have a getaddrinfo that fails
2400 for the all-zeros IPv6 address])
Darren Tucker691d5232005-02-15 21:45:57 +11002401 ],
2402 [
Tim Rice648f8762011-01-26 12:38:57 -08002403 AC_MSG_RESULT([no])
2404 AC_DEFINE([BROKEN_GETADDRINFO])
Darren Tucker314d89e2005-10-17 23:29:23 +10002405 ],
Darren Tucker8b272ab2006-06-27 11:20:28 +10002406 [
Tim Rice648f8762011-01-26 12:38:57 -08002407 AC_MSG_RESULT([cross-compiling, assuming no])
Darren Tucker691d5232005-02-15 21:45:57 +11002408 ]
2409 )
2410fi
2411
Darren Tuckere50e8c92015-02-21 15:10:33 +11002412if test "x$ac_cv_func_getaddrinfo" = "xyes"; then
2413 AC_CHECK_DECLS(AI_NUMERICSERV, , ,
2414 [#include <sys/types.h>
2415 #include <sys/socket.h>
2416 #include <netdb.h>])
2417fi
2418
Darren Tuckera56f1912004-11-02 20:30:54 +11002419if test "x$check_for_conflicting_getspnam" = "x1"; then
Tim Rice648f8762011-01-26 12:38:57 -08002420 AC_MSG_CHECKING([for conflicting getspnam in shadow.h])
2421 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <shadow.h> ]],
2422 [[ exit(0); ]])],
Darren Tuckera56f1912004-11-02 20:30:54 +11002423 [
Tim Rice648f8762011-01-26 12:38:57 -08002424 AC_MSG_RESULT([no])
Darren Tuckera56f1912004-11-02 20:30:54 +11002425 ],
2426 [
Tim Rice648f8762011-01-26 12:38:57 -08002427 AC_MSG_RESULT([yes])
2428 AC_DEFINE([GETSPNAM_CONFLICTING_DEFS], [1],
Darren Tuckera56f1912004-11-02 20:30:54 +11002429 [Conflicting defs for getspnam])
2430 ]
2431 )
2432fi
2433
Darren Tucker20e5e8b2016-08-02 12:16:34 +10002434dnl NetBSD added an strnvis and unfortunately made it incompatible with the
2435dnl existing one in OpenBSD and Linux's libbsd (the former having existed
2436dnl for over ten years). Despite this incompatibility being reported during
2437dnl development (see http://gnats.netbsd.org/44977) they still shipped it.
2438dnl Even more unfortunately FreeBSD and later MacOS picked up this incompatible
2439dnl implementation. Try to detect this mess, and assume the only safe option
2440dnl if we're cross compiling.
2441dnl
2442dnl OpenBSD, 2001: strnvis(char *dst, const char *src, size_t dlen, int flag);
2443dnl NetBSD: 2012, strnvis(char *dst, size_t dlen, const char *src, int flag);
2444if test "x$ac_cv_func_strnvis" = "xyes"; then
2445 AC_MSG_CHECKING([for working strnvis])
2446 AC_RUN_IFELSE(
2447 [AC_LANG_PROGRAM([[
2448#include <signal.h>
2449#include <stdlib.h>
2450#include <string.h>
2451#include <vis.h>
2452static void sighandler(int sig) { _exit(1); }
2453 ]], [[
2454 char dst[16];
2455
2456 signal(SIGSEGV, sighandler);
2457 if (strnvis(dst, "src", 4, 0) && strcmp(dst, "src") == 0)
2458 exit(0);
2459 exit(1)
2460 ]])],
2461 [AC_MSG_RESULT([yes])],
2462 [AC_MSG_RESULT([no])
2463 AC_DEFINE([BROKEN_STRNVIS], [1], [strnvis detected broken])],
2464 [AC_MSG_WARN([cross compiling: assuming broken])
2465 AC_DEFINE([BROKEN_STRNVIS], [1], [strnvis assumed broken])]
2466 )
2467fi
2468
Darren Tuckerc7b5a472018-02-25 23:55:41 +11002469AC_CHECK_FUNCS([getpgrp],[
2470 AC_MSG_CHECKING([if getpgrp accepts zero args])
2471 AC_COMPILE_IFELSE(
2472 [AC_LANG_PROGRAM([[$ac_includes_default]], [[ getpgrp(); ]])],
2473 [ AC_MSG_RESULT([yes])
2474 AC_DEFINE([GETPGRP_VOID], [1], [getpgrp takes zero args])],
2475 [ AC_MSG_RESULT([no])
2476 AC_DEFINE([GETPGRP_VOID], [0], [getpgrp takes one arg])]
2477 )
2478])
Damien Miller606f8802000-09-16 15:39:56 +11002479
Tim Riceaef73712002-05-11 13:17:42 -07002480# Search for OpenSSL
2481saved_CPPFLAGS="$CPPFLAGS"
2482saved_LDFLAGS="$LDFLAGS"
Tim Rice648f8762011-01-26 12:38:57 -08002483AC_ARG_WITH([ssl-dir],
Damien Millera22ba012000-03-02 23:09:20 +11002484 [ --with-ssl-dir=PATH Specify path to OpenSSL installation ],
2485 [
Damien Miller72ef7c12015-01-15 02:21:31 +11002486 if test "x$openssl" = "xno" ; then
2487 AC_MSG_ERROR([cannot use --with-ssl-dir when OpenSSL disabled])
2488 fi
Ben Lindstrom23e13712000-10-29 22:49:19 +00002489 if test "x$withval" != "xno" ; then
Darren Tuckerc7e38d52005-02-09 22:12:30 +11002490 case "$withval" in
2491 # Relative paths
2492 ./*|../*) withval="`pwd`/$withval"
2493 esac
Tim Riceaef73712002-05-11 13:17:42 -07002494 if test -d "$withval/lib"; then
Darren Tucker2f0bad22019-01-21 21:28:27 +11002495 if test -n "${rpath_opt}"; then
2496 LDFLAGS="-L${withval}/lib ${rpath_opt}${withval}/lib ${LDFLAGS}"
Tim Riceaef73712002-05-11 13:17:42 -07002497 else
2498 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
2499 fi
Darren Tucker9f8703b2010-04-23 11:12:06 +10002500 elif test -d "$withval/lib64"; then
Darren Tucker2f0bad22019-01-21 21:28:27 +11002501 if test -n "${rpath_opt}"; then
2502 LDFLAGS="-L${withval}/lib64 ${rpath_opt}${withval}/lib64 ${LDFLAGS}"
Darren Tucker9f8703b2010-04-23 11:12:06 +10002503 else
2504 LDFLAGS="-L${withval}/lib64 ${LDFLAGS}"
2505 fi
Tim Riceaef73712002-05-11 13:17:42 -07002506 else
Darren Tucker2f0bad22019-01-21 21:28:27 +11002507 if test -n "${rpath_opt}"; then
2508 LDFLAGS="-L${withval} ${rpath_opt}${withval} ${LDFLAGS}"
Tim Riceaef73712002-05-11 13:17:42 -07002509 else
2510 LDFLAGS="-L${withval} ${LDFLAGS}"
2511 fi
2512 fi
2513 if test -d "$withval/include"; then
2514 CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
2515 else
2516 CPPFLAGS="-I${withval} ${CPPFLAGS}"
2517 fi
Damien Millera22ba012000-03-02 23:09:20 +11002518 fi
2519 ]
2520)
Damien Millerb9c56672014-05-15 14:43:37 +10002521
Tim Rice648f8762011-01-26 12:38:57 -08002522AC_ARG_WITH([openssl-header-check],
Damien Miller9975e482007-03-05 11:51:27 +11002523 [ --without-openssl-header-check Disable OpenSSL version consistency check],
Damien Millerec932372002-01-22 22:16:03 +11002524 [
Damien Miller72ef7c12015-01-15 02:21:31 +11002525 if test "x$withval" = "xno" ; then
2526 openssl_check_nonfatal=1
Damien Miller9975e482007-03-05 11:51:27 +11002527 fi
Damien Millerec932372002-01-22 22:16:03 +11002528 ]
2529)
2530
Damien Miller72ef7c12015-01-15 02:21:31 +11002531openssl_engine=no
Tim Rice648f8762011-01-26 12:38:57 -08002532AC_ARG_WITH([ssl-engine],
Darren Tuckerfabdb6c2006-02-20 20:17:35 +11002533 [ --with-ssl-engine Enable OpenSSL (hardware) ENGINE support ],
Damien Miller72ef7c12015-01-15 02:21:31 +11002534 [
Damien Miller72ef7c12015-01-15 02:21:31 +11002535 if test "x$withval" != "xno" ; then
Darren Tuckerb5fa0cd2015-12-15 15:10:32 +11002536 if test "x$openssl" = "xno" ; then
2537 AC_MSG_ERROR([cannot use --with-ssl-engine when OpenSSL disabled])
2538 fi
Damien Miller72ef7c12015-01-15 02:21:31 +11002539 openssl_engine=yes
2540 fi
2541 ]
2542)
2543
2544if test "x$openssl" = "xyes" ; then
2545 LIBS="-lcrypto $LIBS"
Darren Tucker8d8340e2018-11-16 13:32:13 +11002546 AC_TRY_LINK_FUNC([RAND_add], ,
2547 [AC_MSG_ERROR([*** working libcrypto not found, check config.log])])
2548 AC_CHECK_HEADER([openssl/opensslv.h], ,
2549 [AC_MSG_ERROR([*** OpenSSL headers missing - please install first or check config.log ***])])
Damien Miller72ef7c12015-01-15 02:21:31 +11002550
2551 # Determine OpenSSL header version
2552 AC_MSG_CHECKING([OpenSSL header version])
2553 AC_RUN_IFELSE(
2554 [AC_LANG_PROGRAM([[
Darren Tucker15605962015-11-10 11:14:47 +11002555 #include <stdlib.h>
Damien Miller72ef7c12015-01-15 02:21:31 +11002556 #include <stdio.h>
2557 #include <string.h>
2558 #include <openssl/opensslv.h>
2559 #define DATA "conftest.sslincver"
2560 ]], [[
2561 FILE *fd;
2562 int rc;
2563
2564 fd = fopen(DATA,"w");
2565 if(fd == NULL)
2566 exit(1);
2567
Darren Tuckerb3413532016-04-04 11:09:21 +10002568 if ((rc = fprintf(fd, "%08lx (%s)\n",
2569 (unsigned long)OPENSSL_VERSION_NUMBER,
2570 OPENSSL_VERSION_TEXT)) < 0)
Damien Miller72ef7c12015-01-15 02:21:31 +11002571 exit(1);
2572
2573 exit(0);
2574 ]])],
2575 [
2576 ssl_header_ver=`cat conftest.sslincver`
2577 AC_MSG_RESULT([$ssl_header_ver])
2578 ],
2579 [
2580 AC_MSG_RESULT([not found])
2581 AC_MSG_ERROR([OpenSSL version header not found.])
2582 ],
2583 [
2584 AC_MSG_WARN([cross compiling: not checking])
2585 ]
2586 )
2587
Darren Tucker262d81a2018-10-27 16:45:59 +11002588 # Determining OpenSSL library version is version dependent.
2589 AC_CHECK_FUNCS([OpenSSL_version OpenSSL_version_num])
2590
Damien Miller72ef7c12015-01-15 02:21:31 +11002591 # Determine OpenSSL library version
2592 AC_MSG_CHECKING([OpenSSL library version])
2593 AC_RUN_IFELSE(
2594 [AC_LANG_PROGRAM([[
2595 #include <stdio.h>
2596 #include <string.h>
2597 #include <openssl/opensslv.h>
2598 #include <openssl/crypto.h>
2599 #define DATA "conftest.ssllibver"
2600 ]], [[
2601 FILE *fd;
2602 int rc;
2603
2604 fd = fopen(DATA,"w");
2605 if(fd == NULL)
2606 exit(1);
Darren Tucker262d81a2018-10-27 16:45:59 +11002607#ifndef OPENSSL_VERSION
2608# define OPENSSL_VERSION SSLEAY_VERSION
2609#endif
2610#ifndef HAVE_OPENSSL_VERSION
Damien Miller406a24b2018-10-26 13:43:28 +11002611# define OpenSSL_version SSLeay_version
Darren Tucker262d81a2018-10-27 16:45:59 +11002612#endif
2613#ifndef HAVE_OPENSSL_VERSION_NUM
2614# define OpenSSL_version_num SSLeay
Damien Miller406a24b2018-10-26 13:43:28 +11002615#endif
Damien Miller859754b2018-10-23 17:10:41 +11002616 if ((rc = fprintf(fd, "%08lx (%s)\n",
2617 (unsigned long)OpenSSL_version_num(),
2618 OpenSSL_version(OPENSSL_VERSION))) < 0)
Damien Miller72ef7c12015-01-15 02:21:31 +11002619 exit(1);
2620
2621 exit(0);
2622 ]])],
2623 [
2624 ssl_library_ver=`cat conftest.ssllibver`
2625 # Check version is supported.
2626 case "$ssl_library_ver" in
Damien Milleraede1c32018-10-17 11:01:20 +11002627 10000*|0*)
2628 AC_MSG_ERROR([OpenSSL >= 1.0.1 required (have "$ssl_library_ver")])
2629 ;;
2630 100*) ;; # 1.0.x
Damien Miller28c7b2c2018-11-23 10:45:20 +11002631 101000[[0123456]]*)
Damien Milleraede1c32018-10-17 11:01:20 +11002632 # https://github.com/openssl/openssl/pull/4613
2633 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")])
2634 ;;
2635 101*) ;; # 1.1.x
2636 200*) ;; # LibreSSL
Darren Tuckerc882d742019-01-22 20:38:40 +11002637 300*) ;; # OpenSSL development branch.
Damien Milleraede1c32018-10-17 11:01:20 +11002638 *)
Darren Tuckerc882d742019-01-22 20:38:40 +11002639 AC_MSG_ERROR([Unknown/unsupported OpenSSL version ("$ssl_library_ver")])
Damien Milleraede1c32018-10-17 11:01:20 +11002640 ;;
Damien Miller72ef7c12015-01-15 02:21:31 +11002641 esac
2642 AC_MSG_RESULT([$ssl_library_ver])
2643 ],
2644 [
2645 AC_MSG_RESULT([not found])
2646 AC_MSG_ERROR([OpenSSL library not found.])
2647 ],
2648 [
2649 AC_MSG_WARN([cross compiling: not checking])
2650 ]
2651 )
2652
2653 # Sanity check OpenSSL headers
2654 AC_MSG_CHECKING([whether OpenSSL's headers match the library])
2655 AC_RUN_IFELSE(
2656 [AC_LANG_PROGRAM([[
2657 #include <string.h>
2658 #include <openssl/opensslv.h>
Darren Tuckerc1d7e542015-12-15 14:27:09 +11002659 #include <openssl/crypto.h>
Damien Miller72ef7c12015-01-15 02:21:31 +11002660 ]], [[
Darren Tucker262d81a2018-10-27 16:45:59 +11002661#ifndef HAVE_OPENSSL_VERSION_NUM
2662# define OpenSSL_version_num SSLeay
Damien Miller406a24b2018-10-26 13:43:28 +11002663#endif
Damien Miller859754b2018-10-23 17:10:41 +11002664 exit(OpenSSL_version_num() == OPENSSL_VERSION_NUMBER ? 0 : 1);
Damien Miller72ef7c12015-01-15 02:21:31 +11002665 ]])],
2666 [
2667 AC_MSG_RESULT([yes])
2668 ],
2669 [
2670 AC_MSG_RESULT([no])
2671 if test "x$openssl_check_nonfatal" = "x"; then
2672 AC_MSG_ERROR([Your OpenSSL headers do not match your
2673 library. Check config.log for details.
2674 If you are sure your installation is consistent, you can disable the check
2675 by running "./configure --without-openssl-header-check".
2676 Also see contrib/findssl.sh for help identifying header/library mismatches.
2677 ])
2678 else
2679 AC_MSG_WARN([Your OpenSSL headers do not match your
2680 library. Check config.log for details.
2681 Also see contrib/findssl.sh for help identifying header/library mismatches.])
2682 fi
2683 ],
2684 [
2685 AC_MSG_WARN([cross compiling: not checking])
2686 ]
2687 )
2688
2689 AC_MSG_CHECKING([if programs using OpenSSL functions will link])
2690 AC_LINK_IFELSE(
Damien Miller42c5ec42018-11-23 10:40:06 +11002691 [AC_LANG_PROGRAM([[ #include <openssl/err.h> ]],
2692 [[ ERR_load_crypto_strings(); ]])],
Damien Miller72ef7c12015-01-15 02:21:31 +11002693 [
2694 AC_MSG_RESULT([yes])
2695 ],
2696 [
2697 AC_MSG_RESULT([no])
2698 saved_LIBS="$LIBS"
2699 LIBS="$LIBS -ldl"
2700 AC_MSG_CHECKING([if programs using OpenSSL need -ldl])
2701 AC_LINK_IFELSE(
Damien Miller42c5ec42018-11-23 10:40:06 +11002702 [AC_LANG_PROGRAM([[ #include <openssl/err.h> ]],
2703 [[ ERR_load_crypto_strings(); ]])],
Damien Miller72ef7c12015-01-15 02:21:31 +11002704 [
2705 AC_MSG_RESULT([yes])
2706 ],
2707 [
2708 AC_MSG_RESULT([no])
2709 LIBS="$saved_LIBS"
2710 ]
2711 )
2712 ]
2713 )
2714
2715 AC_CHECK_FUNCS([ \
2716 BN_is_prime_ex \
2717 DSA_generate_parameters_ex \
Damien Miller42c5ec42018-11-23 10:40:06 +11002718 EVP_CIPHER_CTX_ctrl \
Damien Miller72ef7c12015-01-15 02:21:31 +11002719 EVP_DigestFinal_ex \
Damien Miller42c5ec42018-11-23 10:40:06 +11002720 EVP_DigestInit_ex \
Damien Miller72ef7c12015-01-15 02:21:31 +11002721 EVP_MD_CTX_cleanup \
2722 EVP_MD_CTX_copy_ex \
Damien Miller42c5ec42018-11-23 10:40:06 +11002723 EVP_MD_CTX_init \
Damien Miller72ef7c12015-01-15 02:21:31 +11002724 HMAC_CTX_init \
2725 RSA_generate_key_ex \
2726 RSA_get_default_method \
Darren Tucker1801cd12018-11-08 15:03:11 +11002727 ])
Darren Tucker98f878d2018-11-25 14:05:08 +11002728
2729 # OpenSSL_add_all_algorithms may be a macro.
2730 AC_CHECK_FUNC(OpenSSL_add_all_algorithms,
2731 AC_DEFINE(HAVE_OPENSSL_ADD_ALL_ALGORITHMS, 1, [as a function]),
2732 AC_CHECK_DECL(OpenSSL_add_all_algorithms,
2733 AC_DEFINE(HAVE_OPENSSL_ADD_ALL_ALGORITHMS, 1, [as a macro]), ,
2734 [[#include <openssl/evp.h>]]
2735 )
2736 )
2737
Darren Tucker1801cd12018-11-08 15:03:11 +11002738 # LibreSSL/OpenSSL 1.1x API
2739 AC_CHECK_FUNCS([ \
Darren Tuckerd0d1dfa2018-11-16 14:11:44 +11002740 OPENSSL_init_crypto \
Darren Tucker1801cd12018-11-08 15:03:11 +11002741 DH_get0_key \
2742 DH_get0_pqg \
2743 DH_set0_key \
2744 DH_set_length \
2745 DH_set0_pqg \
2746 DSA_get0_key \
2747 DSA_get0_pqg \
2748 DSA_set0_key \
2749 DSA_set0_pqg \
2750 DSA_SIG_get0 \
2751 DSA_SIG_set0 \
2752 ECDSA_SIG_get0 \
2753 ECDSA_SIG_set0 \
2754 EVP_CIPHER_CTX_iv \
2755 EVP_CIPHER_CTX_iv_noconst \
2756 EVP_CIPHER_CTX_get_iv \
2757 EVP_CIPHER_CTX_set_iv \
2758 RSA_get0_crt_params \
2759 RSA_get0_factors \
2760 RSA_get0_key \
2761 RSA_set0_crt_params \
2762 RSA_set0_factors \
2763 RSA_set0_key \
2764 RSA_meth_free \
2765 RSA_meth_dup \
2766 RSA_meth_set1_name \
2767 RSA_meth_get_finish \
2768 RSA_meth_set_priv_enc \
2769 RSA_meth_set_priv_dec \
2770 RSA_meth_set_finish \
2771 EVP_PKEY_get0_RSA \
2772 EVP_MD_CTX_new \
2773 EVP_MD_CTX_free \
Damien Miller72ef7c12015-01-15 02:21:31 +11002774 ])
2775
2776 if test "x$openssl_engine" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08002777 AC_MSG_CHECKING([for OpenSSL ENGINE support])
2778 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller72ef7c12015-01-15 02:21:31 +11002779 #include <openssl/engine.h>
Tim Rice648f8762011-01-26 12:38:57 -08002780 ]], [[
Damien Miller72ef7c12015-01-15 02:21:31 +11002781 ENGINE_load_builtin_engines();
2782 ENGINE_register_all_complete();
Tim Rice648f8762011-01-26 12:38:57 -08002783 ]])],
2784 [ AC_MSG_RESULT([yes])
2785 AC_DEFINE([USE_OPENSSL_ENGINE], [1],
Darren Tuckerfabdb6c2006-02-20 20:17:35 +11002786 [Enable OpenSSL engine support])
Tim Rice648f8762011-01-26 12:38:57 -08002787 ], [ AC_MSG_ERROR([OpenSSL ENGINE support not found])
2788 ])
Damien Miller72ef7c12015-01-15 02:21:31 +11002789 fi
Darren Tuckerfabdb6c2006-02-20 20:17:35 +11002790
Damien Miller72ef7c12015-01-15 02:21:31 +11002791 # Check for OpenSSL without EVP_aes_{192,256}_cbc
2792 AC_MSG_CHECKING([whether OpenSSL has crippled AES support])
2793 AC_LINK_IFELSE(
Darren Tucker37bcef52013-11-09 18:39:25 +11002794 [AC_LANG_PROGRAM([[
Damien Miller72ef7c12015-01-15 02:21:31 +11002795 #include <string.h>
2796 #include <openssl/evp.h>
2797 ]], [[
2798 exit(EVP_aes_192_cbc() == NULL || EVP_aes_256_cbc() == NULL);
2799 ]])],
2800 [
2801 AC_MSG_RESULT([no])
2802 ],
2803 [
2804 AC_MSG_RESULT([yes])
2805 AC_DEFINE([OPENSSL_LOBOTOMISED_AES], [1],
2806 [libcrypto is missing AES 192 and 256 bit functions])
2807 ]
2808 )
2809
2810 # Check for OpenSSL with EVP_aes_*ctr
2811 AC_MSG_CHECKING([whether OpenSSL has AES CTR via EVP])
2812 AC_LINK_IFELSE(
2813 [AC_LANG_PROGRAM([[
2814 #include <string.h>
2815 #include <openssl/evp.h>
2816 ]], [[
2817 exit(EVP_aes_128_ctr() == NULL ||
2818 EVP_aes_192_cbc() == NULL ||
2819 EVP_aes_256_cbc() == NULL);
2820 ]])],
2821 [
2822 AC_MSG_RESULT([yes])
2823 AC_DEFINE([OPENSSL_HAVE_EVPCTR], [1],
2824 [libcrypto has EVP AES CTR])
2825 ],
2826 [
2827 AC_MSG_RESULT([no])
2828 ]
2829 )
2830
2831 # Check for OpenSSL with EVP_aes_*gcm
2832 AC_MSG_CHECKING([whether OpenSSL has AES GCM via EVP])
2833 AC_LINK_IFELSE(
2834 [AC_LANG_PROGRAM([[
2835 #include <string.h>
2836 #include <openssl/evp.h>
2837 ]], [[
2838 exit(EVP_aes_128_gcm() == NULL ||
2839 EVP_aes_256_gcm() == NULL ||
2840 EVP_CTRL_GCM_SET_IV_FIXED == 0 ||
2841 EVP_CTRL_GCM_IV_GEN == 0 ||
2842 EVP_CTRL_GCM_SET_TAG == 0 ||
2843 EVP_CTRL_GCM_GET_TAG == 0 ||
2844 EVP_CIPHER_CTX_ctrl(NULL, 0, 0, NULL) == 0);
2845 ]])],
2846 [
2847 AC_MSG_RESULT([yes])
2848 AC_DEFINE([OPENSSL_HAVE_EVPGCM], [1],
2849 [libcrypto has EVP AES GCM])
2850 ],
2851 [
2852 AC_MSG_RESULT([no])
2853 unsupported_algorithms="$unsupported_cipers \
Damien Miller679ce882016-07-15 13:44:38 +10002854 aes128-gcm@openssh.com \
2855 aes256-gcm@openssh.com"
Damien Miller72ef7c12015-01-15 02:21:31 +11002856 ]
2857 )
2858
Damien Miller72ef7c12015-01-15 02:21:31 +11002859 AC_MSG_CHECKING([if EVP_DigestUpdate returns an int])
2860 AC_LINK_IFELSE(
2861 [AC_LANG_PROGRAM([[
2862 #include <string.h>
2863 #include <openssl/evp.h>
2864 ]], [[
2865 if(EVP_DigestUpdate(NULL, NULL,0))
2866 exit(0);
2867 ]])],
2868 [
2869 AC_MSG_RESULT([yes])
2870 ],
2871 [
2872 AC_MSG_RESULT([no])
2873 AC_DEFINE([OPENSSL_EVP_DIGESTUPDATE_VOID], [1],
2874 [Define if EVP_DigestUpdate returns void])
2875 ]
2876 )
2877
2878 # Some systems want crypt() from libcrypt, *not* the version in OpenSSL,
2879 # because the system crypt() is more featureful.
2880 if test "x$check_for_libcrypt_before" = "x1"; then
2881 AC_CHECK_LIB([crypt], [crypt])
2882 fi
2883
2884 # Some Linux systems (Slackware) need crypt() from libcrypt, *not* the
2885 # version in OpenSSL.
2886 if test "x$check_for_libcrypt_later" = "x1"; then
2887 AC_CHECK_LIB([crypt], [crypt], [LIBS="$LIBS -lcrypt"])
2888 fi
Damien Miller00797e82015-03-04 05:02:45 +11002889 AC_CHECK_FUNCS([crypt DES_crypt])
Damien Miller72ef7c12015-01-15 02:21:31 +11002890
Darren Tucker11cba2a2019-07-23 21:51:22 +10002891 # Check for SHA256, SHA384 and SHA512 support in OpenSSL
2892 AC_CHECK_FUNCS([EVP_sha256 EVP_sha384 EVP_sha512])
2893
Damien Miller72ef7c12015-01-15 02:21:31 +11002894 # Search for RIPE-MD support in OpenSSL
2895 AC_CHECK_FUNCS([EVP_ripemd160], ,
2896 [unsupported_algorithms="$unsupported_algorithms \
Damien Miller679ce882016-07-15 13:44:38 +10002897 hmac-ripemd160 \
2898 hmac-ripemd160@openssh.com \
Damien Miller72ef7c12015-01-15 02:21:31 +11002899 hmac-ripemd160-etm@openssh.com"
2900 ]
2901 )
2902
2903 # Check complete ECC support in OpenSSL
2904 AC_MSG_CHECKING([whether OpenSSL has NID_X9_62_prime256v1])
2905 AC_LINK_IFELSE(
2906 [AC_LANG_PROGRAM([[
2907 #include <openssl/ec.h>
2908 #include <openssl/ecdh.h>
2909 #include <openssl/ecdsa.h>
2910 #include <openssl/evp.h>
2911 #include <openssl/objects.h>
2912 #include <openssl/opensslv.h>
Damien Miller72ef7c12015-01-15 02:21:31 +11002913 ]], [[
2914 EC_KEY *e = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
2915 const EVP_MD *m = EVP_sha256(); /* We need this too */
Darren Tucker37bcef52013-11-09 18:39:25 +11002916 ]])],
2917 [ AC_MSG_RESULT([yes])
Damien Miller72ef7c12015-01-15 02:21:31 +11002918 enable_nistp256=1 ],
2919 [ AC_MSG_RESULT([no]) ]
2920 )
Darren Tucker37bcef52013-11-09 18:39:25 +11002921
Damien Miller72ef7c12015-01-15 02:21:31 +11002922 AC_MSG_CHECKING([whether OpenSSL has NID_secp384r1])
2923 AC_LINK_IFELSE(
2924 [AC_LANG_PROGRAM([[
2925 #include <openssl/ec.h>
2926 #include <openssl/ecdh.h>
2927 #include <openssl/ecdsa.h>
2928 #include <openssl/evp.h>
2929 #include <openssl/objects.h>
2930 #include <openssl/opensslv.h>
Damien Miller72ef7c12015-01-15 02:21:31 +11002931 ]], [[
2932 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp384r1);
2933 const EVP_MD *m = EVP_sha384(); /* We need this too */
2934 ]])],
2935 [ AC_MSG_RESULT([yes])
2936 enable_nistp384=1 ],
2937 [ AC_MSG_RESULT([no]) ]
2938 )
Darren Tucker37bcef52013-11-09 18:39:25 +11002939
Damien Miller72ef7c12015-01-15 02:21:31 +11002940 AC_MSG_CHECKING([whether OpenSSL has NID_secp521r1])
2941 AC_LINK_IFELSE(
2942 [AC_LANG_PROGRAM([[
2943 #include <openssl/ec.h>
2944 #include <openssl/ecdh.h>
2945 #include <openssl/ecdsa.h>
2946 #include <openssl/evp.h>
2947 #include <openssl/objects.h>
2948 #include <openssl/opensslv.h>
Damien Miller72ef7c12015-01-15 02:21:31 +11002949 ]], [[
2950 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1);
2951 const EVP_MD *m = EVP_sha512(); /* We need this too */
2952 ]])],
2953 [ AC_MSG_RESULT([yes])
2954 AC_MSG_CHECKING([if OpenSSL's NID_secp521r1 is functional])
2955 AC_RUN_IFELSE(
2956 [AC_LANG_PROGRAM([[
2957 #include <openssl/ec.h>
2958 #include <openssl/ecdh.h>
2959 #include <openssl/ecdsa.h>
2960 #include <openssl/evp.h>
2961 #include <openssl/objects.h>
2962 #include <openssl/opensslv.h>
2963 ]],[[
2964 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1);
2965 const EVP_MD *m = EVP_sha512(); /* We need this too */
2966 exit(e == NULL || m == NULL);
2967 ]])],
2968 [ AC_MSG_RESULT([yes])
2969 enable_nistp521=1 ],
2970 [ AC_MSG_RESULT([no]) ],
2971 [ AC_MSG_WARN([cross-compiling: assuming yes])
2972 enable_nistp521=1 ]
2973 )],
2974 AC_MSG_RESULT([no])
2975 )
Darren Tucker37bcef52013-11-09 18:39:25 +11002976
Damien Miller72ef7c12015-01-15 02:21:31 +11002977 COMMENT_OUT_ECC="#no ecc#"
2978 TEST_SSH_ECC=no
2979
2980 if test x$enable_nistp256 = x1 || test x$enable_nistp384 = x1 || \
2981 test x$enable_nistp521 = x1; then
2982 AC_DEFINE(OPENSSL_HAS_ECC, [1], [OpenSSL has ECC])
Damien Millere2cb4452019-01-21 11:32:28 +11002983 AC_CHECK_FUNCS([EC_KEY_METHOD_new])
Darren Tuckerf5cc5812019-11-02 16:39:38 +11002984 openssl_ecc=yes
2985 else
2986 openssl_ecc=no
Damien Miller72ef7c12015-01-15 02:21:31 +11002987 fi
2988 if test x$enable_nistp256 = x1; then
2989 AC_DEFINE([OPENSSL_HAS_NISTP256], [1],
2990 [libcrypto has NID_X9_62_prime256v1])
2991 TEST_SSH_ECC=yes
2992 COMMENT_OUT_ECC=""
2993 else
Damien Miller679ce882016-07-15 13:44:38 +10002994 unsupported_algorithms="$unsupported_algorithms \
2995 ecdsa-sha2-nistp256 \
2996 ecdh-sha2-nistp256 \
2997 ecdsa-sha2-nistp256-cert-v01@openssh.com"
Damien Miller72ef7c12015-01-15 02:21:31 +11002998 fi
2999 if test x$enable_nistp384 = x1; then
3000 AC_DEFINE([OPENSSL_HAS_NISTP384], [1], [libcrypto has NID_secp384r1])
3001 TEST_SSH_ECC=yes
3002 COMMENT_OUT_ECC=""
3003 else
Damien Miller679ce882016-07-15 13:44:38 +10003004 unsupported_algorithms="$unsupported_algorithms \
3005 ecdsa-sha2-nistp384 \
3006 ecdh-sha2-nistp384 \
3007 ecdsa-sha2-nistp384-cert-v01@openssh.com"
Damien Miller72ef7c12015-01-15 02:21:31 +11003008 fi
3009 if test x$enable_nistp521 = x1; then
3010 AC_DEFINE([OPENSSL_HAS_NISTP521], [1], [libcrypto has NID_secp521r1])
3011 TEST_SSH_ECC=yes
3012 COMMENT_OUT_ECC=""
3013 else
Damien Miller679ce882016-07-15 13:44:38 +10003014 unsupported_algorithms="$unsupported_algorithms \
3015 ecdh-sha2-nistp521 \
3016 ecdsa-sha2-nistp521 \
3017 ecdsa-sha2-nistp521-cert-v01@openssh.com"
Damien Miller72ef7c12015-01-15 02:21:31 +11003018 fi
3019
3020 AC_SUBST([TEST_SSH_ECC])
3021 AC_SUBST([COMMENT_OUT_ECC])
3022else
3023 AC_CHECK_LIB([crypt], [crypt], [LIBS="$LIBS -lcrypt"])
Damien Miller00797e82015-03-04 05:02:45 +11003024 AC_CHECK_FUNCS([crypt])
Damien Miller72ef7c12015-01-15 02:21:31 +11003025fi
Damien Miller6af914a2010-09-10 11:39:26 +10003026
Darren Tuckerf5cc5812019-11-02 16:39:38 +11003027# PKCS11/U2F depend on OpenSSL and dlopen().
3028enable_pkcs11=yes
3029enable_sk=yes
3030if test "x$openssl" != "xyes" ; then
3031 enable_pkcs11="disabled; missing libcrypto"
3032 enable_sk="disabled; missing libcrypto"
3033fi
3034if test "x$openssl_ecc" != "xyes" ; then
3035 enable_sk="disabled; OpenSSL has no ECC support"
3036fi
3037if test "x$ac_cv_func_dlopen" != "xyes" ; then
3038 enable_pkcs11="disabled; missing dlopen(3)"
3039 enable_sk="disabled; missing dlopen(3)"
3040fi
3041if test "x$ac_cv_have_decl_RTLD_NOW" != "xyes" ; then
3042 enable_pkcs11="disabled; missing RTLD_NOW"
3043 enable_sk="disabled; missing RTLD_NOW"
3044fi
3045if test ! -z "$disable_pkcs11" ; then
3046 enable_pkcs11="disabled by user"
3047fi
3048if test ! -z "$disable_sk" ; then
3049 enable_sk="disabled by user"
3050fi
3051
3052AC_MSG_CHECKING([whether to enable PKCS11])
3053if test "x$enable_pkcs11" = "xyes" ; then
3054 AC_DEFINE([ENABLE_PKCS11], [], [Enable for PKCS#11 support])
3055fi
3056AC_MSG_RESULT([$enable_pkcs11])
3057
3058AC_MSG_CHECKING([whether to enable U2F])
3059if test "x$enable_sk" = "xyes" ; then
3060 AC_DEFINE([ENABLE_SK], [], [Enable for U2F/FIDO support])
3061fi
3062AC_MSG_RESULT([$enable_sk])
3063
djm@openbsd.org6bff9522019-11-14 21:27:29 +00003064# Now check for built-in security key support.
3065if test "x$enable_sk" = "xyes" ; then
3066 AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no])
3067 use_pkgconfig_for_libfido2=
3068 if test "x$PKGCONFIG" != "xno"; then
3069 AC_MSG_CHECKING([if $PKGCONFIG knows about libfido2])
3070 if "$PKGCONFIG" libfido2; then
3071 AC_MSG_RESULT([yes])
3072 use_pkgconfig_for_libfido2=yes
3073 else
3074 AC_MSG_RESULT([no])
3075 fi
3076 fi
3077 if test "x$use_pkgconfig_for_libfido2" = "xyes"; then
3078 LIBFIDO2=`$PKGCONFIG --libs libfido2`
3079 CPPFLAGS="$CPPFLAGS `$PKGCONFIG --cflags libfido2`"
3080 else
3081 LIBFIDO2="-lfido2 -lcbor"
3082 fi
3083 OTHERLIBS=`echo $LIBFIDO2 | sed 's/-lfido2//'`
3084 AC_CHECK_LIB([fido2], [fido_init],
3085 [
3086 LIBS="$LIBS $LIBFIDO2" # XXX avoid linking to all.
3087 AC_SUBST([LIBFIDO2])
3088 AC_DEFINE([ENABLE_SK_INTERNAL], [],
3089 [Enable for built-in U2F/FIDO support])
3090 enable_sk="built-in"
Damien Miller63a5b242019-11-15 11:21:26 +11003091 ], [ ],
djm@openbsd.org6bff9522019-11-14 21:27:29 +00003092 [ $OTHERLIBS ]
3093 )
3094fi
3095
Damien Miller00f9cd22014-07-15 10:41:38 +10003096AC_CHECK_FUNCS([ \
3097 arc4random \
3098 arc4random_buf \
3099 arc4random_stir \
3100 arc4random_uniform \
3101])
3102
Tim Rice99203ec2007-03-26 09:35:28 -07003103saved_LIBS="$LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08003104AC_CHECK_LIB([iaf], [ia_openinfo], [
Tim Rice99203ec2007-03-26 09:35:28 -07003105 LIBS="$LIBS -liaf"
Tim Rice648f8762011-01-26 12:38:57 -08003106 AC_CHECK_FUNCS([set_id], [SSHDLIBS="$SSHDLIBS -liaf"
3107 AC_DEFINE([HAVE_LIBIAF], [1],
Tim Ricee1d93702016-05-31 11:13:22 -07003108 [Define if system has libiaf that supports set_id])
Tim Rice0eeaf122007-09-10 16:24:17 -07003109 ])
Tim Rice99203ec2007-03-26 09:35:28 -07003110])
3111LIBS="$saved_LIBS"
Damien Miller6c21c512002-01-22 21:57:53 +11003112
3113### Configure cryptographic random number support
3114
Damien Miller10479cc2018-04-10 10:19:02 +10003115# Check whether OpenSSL seeds itself
Damien Miller72ef7c12015-01-15 02:21:31 +11003116if test "x$openssl" = "xyes" ; then
3117 AC_MSG_CHECKING([whether OpenSSL's PRNG is internally seeded])
3118 AC_RUN_IFELSE(
3119 [AC_LANG_PROGRAM([[
3120 #include <string.h>
3121 #include <openssl/rand.h>
3122 ]], [[
3123 exit(RAND_status() == 1 ? 0 : 1);
3124 ]])],
3125 [
3126 OPENSSL_SEEDS_ITSELF=yes
3127 AC_MSG_RESULT([yes])
3128 ],
3129 [
3130 AC_MSG_RESULT([no])
3131 ],
3132 [
3133 AC_MSG_WARN([cross compiling: assuming yes])
3134 # This is safe, since we will fatal() at runtime if
3135 # OpenSSL is not seeded correctly.
3136 OPENSSL_SEEDS_ITSELF=yes
3137 ]
3138 )
3139fi
Damien Miller6c21c512002-01-22 21:57:53 +11003140
Damien Millerf22019b2011-05-05 13:48:37 +10003141# PRNGD TCP socket
3142AC_ARG_WITH([prngd-port],
3143 [ --with-prngd-port=PORT read entropy from PRNGD/EGD TCP localhost:PORT],
3144 [
3145 case "$withval" in
3146 no)
3147 withval=""
3148 ;;
3149 [[0-9]]*)
3150 ;;
3151 *)
3152 AC_MSG_ERROR([You must specify a numeric port number for --with-prngd-port])
3153 ;;
3154 esac
3155 if test ! -z "$withval" ; then
3156 PRNGD_PORT="$withval"
3157 AC_DEFINE_UNQUOTED([PRNGD_PORT], [$PRNGD_PORT],
3158 [Port number of PRNGD/EGD random number socket])
3159 fi
3160 ]
3161)
3162
3163# PRNGD Unix domain socket
3164AC_ARG_WITH([prngd-socket],
3165 [ --with-prngd-socket=FILE read entropy from PRNGD/EGD socket FILE (default=/var/run/egd-pool)],
3166 [
3167 case "$withval" in
3168 yes)
3169 withval="/var/run/egd-pool"
3170 ;;
3171 no)
3172 withval=""
3173 ;;
3174 /*)
3175 ;;
3176 *)
3177 AC_MSG_ERROR([You must specify an absolute path to the entropy socket])
3178 ;;
3179 esac
3180
3181 if test ! -z "$withval" ; then
3182 if test ! -z "$PRNGD_PORT" ; then
3183 AC_MSG_ERROR([You may not specify both a PRNGD/EGD port and socket])
3184 fi
3185 if test ! -r "$withval" ; then
3186 AC_MSG_WARN([Entropy socket is not readable])
3187 fi
3188 PRNGD_SOCKET="$withval"
3189 AC_DEFINE_UNQUOTED([PRNGD_SOCKET], ["$PRNGD_SOCKET"],
3190 [Location of PRNGD/EGD random number socket])
3191 fi
3192 ],
3193 [
3194 # Check for existing socket only if we don't have a random device already
3195 if test "x$OPENSSL_SEEDS_ITSELF" != "xyes" ; then
3196 AC_MSG_CHECKING([for PRNGD/EGD socket])
3197 # Insert other locations here
3198 for sock in /var/run/egd-pool /dev/egd-pool /etc/entropy; do
3199 if test -r $sock && $TEST_MINUS_S_SH -c "test -S $sock -o -p $sock" ; then
3200 PRNGD_SOCKET="$sock"
3201 AC_DEFINE_UNQUOTED([PRNGD_SOCKET], ["$PRNGD_SOCKET"])
3202 break;
3203 fi
3204 done
3205 if test ! -z "$PRNGD_SOCKET" ; then
3206 AC_MSG_RESULT([$PRNGD_SOCKET])
3207 else
3208 AC_MSG_RESULT([not found])
3209 fi
3210 fi
3211 ]
3212)
3213
3214# Which randomness source do we use?
3215if test ! -z "$PRNGD_PORT" ; then
3216 RAND_MSG="PRNGd port $PRNGD_PORT"
3217elif test ! -z "$PRNGD_SOCKET" ; then
3218 RAND_MSG="PRNGd socket $PRNGD_SOCKET"
3219elif test ! -z "$OPENSSL_SEEDS_ITSELF" ; then
3220 AC_DEFINE([OPENSSL_PRNG_ONLY], [1],
Damien Miller72ef7c12015-01-15 02:21:31 +11003221 [Define if you want the OpenSSL internally seeded PRNG only])
Damien Millerf22019b2011-05-05 13:48:37 +10003222 RAND_MSG="OpenSSL internal ONLY"
Damien Miller72ef7c12015-01-15 02:21:31 +11003223elif test "x$openssl" = "xno" ; then
3224 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 +10003225else
3226 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])
3227fi
3228
Darren Tucker3e6bde42006-08-20 20:03:50 +10003229# Check for PAM libs
3230PAM_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08003231AC_ARG_WITH([pam],
Darren Tucker3e6bde42006-08-20 20:03:50 +10003232 [ --with-pam Enable PAM support ],
3233 [
3234 if test "x$withval" != "xno" ; then
3235 if test "x$ac_cv_header_security_pam_appl_h" != "xyes" && \
3236 test "x$ac_cv_header_pam_pam_appl_h" != "xyes" ; then
3237 AC_MSG_ERROR([PAM headers not found])
3238 fi
3239
3240 saved_LIBS="$LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08003241 AC_CHECK_LIB([dl], [dlopen], , )
3242 AC_CHECK_LIB([pam], [pam_set_item], , [AC_MSG_ERROR([*** libpam missing])])
3243 AC_CHECK_FUNCS([pam_getenvlist])
3244 AC_CHECK_FUNCS([pam_putenv])
Darren Tucker3e6bde42006-08-20 20:03:50 +10003245 LIBS="$saved_LIBS"
3246
3247 PAM_MSG="yes"
3248
Darren Tucker20e9f972007-03-25 18:26:01 +10003249 SSHDLIBS="$SSHDLIBS -lpam"
Tim Rice648f8762011-01-26 12:38:57 -08003250 AC_DEFINE([USE_PAM], [1],
Darren Tucker3e6bde42006-08-20 20:03:50 +10003251 [Define if you want to enable PAM support])
Darren Tucker639bbe82006-08-20 20:17:53 +10003252
Darren Tucker3e6bde42006-08-20 20:03:50 +10003253 if test $ac_cv_lib_dl_dlopen = yes; then
Darren Tucker639bbe82006-08-20 20:17:53 +10003254 case "$LIBS" in
3255 *-ldl*)
3256 # libdl already in LIBS
3257 ;;
3258 *)
Darren Tucker20e9f972007-03-25 18:26:01 +10003259 SSHDLIBS="$SSHDLIBS -ldl"
Darren Tucker639bbe82006-08-20 20:17:53 +10003260 ;;
3261 esac
Darren Tucker3e6bde42006-08-20 20:03:50 +10003262 fi
Darren Tucker3e6bde42006-08-20 20:03:50 +10003263 fi
3264 ]
3265)
3266
Damien Miller8bd81e12016-08-16 13:30:56 +10003267AC_ARG_WITH([pam-service],
3268 [ --with-pam-service=name Specify PAM service name ],
3269 [
3270 if test "x$withval" != "xno" && \
3271 test "x$withval" != "xyes" ; then
3272 AC_DEFINE_UNQUOTED([SSHD_PAM_SERVICE],
3273 ["$withval"], [sshd PAM service name])
3274 fi
3275 ]
3276)
3277
Darren Tucker3e6bde42006-08-20 20:03:50 +10003278# Check for older PAM
3279if test "x$PAM_MSG" = "xyes" ; then
3280 # Check PAM strerror arguments (old PAM)
3281 AC_MSG_CHECKING([whether pam_strerror takes only one argument])
Tim Rice648f8762011-01-26 12:38:57 -08003282 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker3e6bde42006-08-20 20:03:50 +10003283#include <stdlib.h>
3284#if defined(HAVE_SECURITY_PAM_APPL_H)
3285#include <security/pam_appl.h>
3286#elif defined (HAVE_PAM_PAM_APPL_H)
3287#include <pam/pam_appl.h>
3288#endif
Tim Rice648f8762011-01-26 12:38:57 -08003289 ]], [[
3290(void)pam_strerror((pam_handle_t *)NULL, -1);
3291 ]])], [AC_MSG_RESULT([no])], [
3292 AC_DEFINE([HAVE_OLD_PAM], [1],
Darren Tucker3e6bde42006-08-20 20:03:50 +10003293 [Define if you have an old version of PAM
3294 which takes only one argument to pam_strerror])
Tim Rice648f8762011-01-26 12:38:57 -08003295 AC_MSG_RESULT([yes])
Darren Tucker3e6bde42006-08-20 20:03:50 +10003296 PAM_MSG="yes (old library)"
Damien Miller72ef7c12015-01-15 02:21:31 +11003297
Tim Rice648f8762011-01-26 12:38:57 -08003298 ])
Darren Tucker3e6bde42006-08-20 20:03:50 +10003299fi
Damien Miller6c21c512002-01-22 21:57:53 +11003300
Damien Miller6482d902014-05-27 14:34:42 +10003301case "$host" in
3302*-*-cygwin*)
3303 SSH_PRIVSEP_USER=CYGWIN_SSH_PRIVSEP_USER
3304 ;;
3305*)
3306 SSH_PRIVSEP_USER=sshd
3307 ;;
3308esac
Tim Rice648f8762011-01-26 12:38:57 -08003309AC_ARG_WITH([privsep-user],
Kevin Stevesc81e1292002-05-13 03:51:40 +00003310 [ --with-privsep-user=user Specify non-privileged user for privilege separation],
Kevin Steves7ff91122002-04-07 19:22:54 +00003311 [
Tim Rice35cc69d2005-03-17 16:44:25 -08003312 if test -n "$withval" && test "x$withval" != "xno" && \
3313 test "x${withval}" != "xyes"; then
Damien Millerd3f6ad22002-06-25 10:24:47 +10003314 SSH_PRIVSEP_USER=$withval
Kevin Steves7ff91122002-04-07 19:22:54 +00003315 fi
Tim Riceeae17cc2005-03-17 16:52:20 -08003316 ]
Kevin Steves7ff91122002-04-07 19:22:54 +00003317)
Damien Miller6482d902014-05-27 14:34:42 +10003318if test "x$SSH_PRIVSEP_USER" = "xCYGWIN_SSH_PRIVSEP_USER" ; then
3319 AC_DEFINE_UNQUOTED([SSH_PRIVSEP_USER], [CYGWIN_SSH_PRIVSEP_USER],
3320 [Cygwin function to fetch non-privileged user for privilege separation])
3321else
3322 AC_DEFINE_UNQUOTED([SSH_PRIVSEP_USER], ["$SSH_PRIVSEP_USER"],
3323 [non-privileged user for privilege separation])
3324fi
Tim Rice648f8762011-01-26 12:38:57 -08003325AC_SUBST([SSH_PRIVSEP_USER])
Kevin Steves7ff91122002-04-07 19:22:54 +00003326
Damien Miller91f40d82013-02-22 11:37:00 +11003327if test "x$have_linux_no_new_privs" = "x1" ; then
3328AC_CHECK_DECL([SECCOMP_MODE_FILTER], [have_seccomp_filter=1], , [
3329 #include <sys/types.h>
3330 #include <linux/seccomp.h>
3331])
3332fi
3333if test "x$have_seccomp_filter" = "x1" ; then
3334AC_MSG_CHECKING([kernel for seccomp_filter support])
3335AC_LINK_IFELSE([AC_LANG_PROGRAM([[
3336 #include <errno.h>
3337 #include <elf.h>
3338 #include <linux/audit.h>
3339 #include <linux/seccomp.h>
3340 #include <stdlib.h>
3341 #include <sys/prctl.h>
3342 ]],
3343 [[ int i = $seccomp_audit_arch;
3344 errno = 0;
3345 prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, NULL, 0, 0);
3346 exit(errno == EFAULT ? 0 : 1); ]])],
3347 [ AC_MSG_RESULT([yes]) ], [
3348 AC_MSG_RESULT([no])
3349 # Disable seccomp filter as a target
3350 have_seccomp_filter=0
3351 ]
3352)
3353fi
3354
Damien Miller69ff1df2011-06-23 08:30:03 +10003355# Decide which sandbox style to use
3356sandbox_arg=""
3357AC_ARG_WITH([sandbox],
deraadt@openbsd.org2539dce2015-10-09 01:37:08 +00003358 [ --with-sandbox=style Specify privilege separation sandbox (no, capsicum, darwin, rlimit, seccomp_filter, systrace, pledge)],
Damien Miller69ff1df2011-06-23 08:30:03 +10003359 [
3360 if test "x$withval" = "xyes" ; then
3361 sandbox_arg=""
3362 else
3363 sandbox_arg="$withval"
3364 fi
3365 ]
3366)
Darren Tucker60395f92012-07-03 14:31:18 +10003367
3368# Some platforms (seems to be the ones that have a kernel poll(2)-type
3369# function with which they implement select(2)) use an extra file descriptor
3370# when calling select(2), which means we can't use the rlimit sandbox.
3371AC_MSG_CHECKING([if select works with descriptor rlimit])
3372AC_RUN_IFELSE(
3373 [AC_LANG_PROGRAM([[
3374#include <sys/types.h>
3375#ifdef HAVE_SYS_TIME_H
3376# include <sys/time.h>
3377#endif
3378#include <sys/resource.h>
3379#ifdef HAVE_SYS_SELECT_H
3380# include <sys/select.h>
3381#endif
3382#include <errno.h>
3383#include <fcntl.h>
3384#include <stdlib.h>
3385 ]],[[
3386 struct rlimit rl_zero;
3387 int fd, r;
3388 fd_set fds;
Damien Millere4f43472013-03-08 12:14:22 +11003389 struct timeval tv;
Darren Tucker60395f92012-07-03 14:31:18 +10003390
3391 fd = open("/dev/null", O_RDONLY);
3392 FD_ZERO(&fds);
3393 FD_SET(fd, &fds);
3394 rl_zero.rlim_cur = rl_zero.rlim_max = 0;
3395 setrlimit(RLIMIT_FSIZE, &rl_zero);
3396 setrlimit(RLIMIT_NOFILE, &rl_zero);
Damien Millere4f43472013-03-08 12:14:22 +11003397 tv.tv_sec = 1;
3398 tv.tv_usec = 0;
3399 r = select(fd+1, &fds, NULL, NULL, &tv);
Darren Tucker60395f92012-07-03 14:31:18 +10003400 exit (r == -1 ? 1 : 0);
3401 ]])],
3402 [AC_MSG_RESULT([yes])
3403 select_works_with_rlimit=yes],
3404 [AC_MSG_RESULT([no])
3405 select_works_with_rlimit=no],
Mike Frysingerdcc714c2017-05-24 23:21:19 -04003406 [AC_MSG_WARN([cross compiling: assuming yes])
3407 select_works_with_rlimit=yes]
Darren Tucker60395f92012-07-03 14:31:18 +10003408)
3409
Darren Tuckerff008de2013-03-06 17:48:48 +11003410AC_MSG_CHECKING([if setrlimit(RLIMIT_NOFILE,{0,0}) works])
3411AC_RUN_IFELSE(
3412 [AC_LANG_PROGRAM([[
3413#include <sys/types.h>
3414#ifdef HAVE_SYS_TIME_H
3415# include <sys/time.h>
3416#endif
3417#include <sys/resource.h>
3418#include <errno.h>
3419#include <stdlib.h>
3420 ]],[[
3421 struct rlimit rl_zero;
Darren Tucker34e87fb2019-04-30 12:27:57 +10003422 int r;
Darren Tuckerff008de2013-03-06 17:48:48 +11003423
3424 rl_zero.rlim_cur = rl_zero.rlim_max = 0;
3425 r = setrlimit(RLIMIT_NOFILE, &rl_zero);
3426 exit (r == -1 ? 1 : 0);
3427 ]])],
3428 [AC_MSG_RESULT([yes])
3429 rlimit_nofile_zero_works=yes],
3430 [AC_MSG_RESULT([no])
3431 rlimit_nofile_zero_works=no],
Mike Frysingerdcc714c2017-05-24 23:21:19 -04003432 [AC_MSG_WARN([cross compiling: assuming yes])
3433 rlimit_nofile_zero_works=yes]
Darren Tuckerff008de2013-03-06 17:48:48 +11003434)
3435
Darren Tuckerd545a4b2012-07-03 22:48:31 +10003436AC_MSG_CHECKING([if setrlimit RLIMIT_FSIZE works])
3437AC_RUN_IFELSE(
3438 [AC_LANG_PROGRAM([[
3439#include <sys/types.h>
3440#include <sys/resource.h>
3441#include <stdlib.h>
3442 ]],[[
3443 struct rlimit rl_zero;
3444
3445 rl_zero.rlim_cur = rl_zero.rlim_max = 0;
3446 exit(setrlimit(RLIMIT_FSIZE, &rl_zero) != 0);
3447 ]])],
3448 [AC_MSG_RESULT([yes])],
3449 [AC_MSG_RESULT([no])
3450 AC_DEFINE(SANDBOX_SKIP_RLIMIT_FSIZE, 1,
3451 [setrlimit RLIMIT_FSIZE works])],
3452 [AC_MSG_WARN([cross compiling: assuming yes])]
3453)
3454
deraadt@openbsd.org2539dce2015-10-09 01:37:08 +00003455if test "x$sandbox_arg" = "xpledge" || \
3456 ( test -z "$sandbox_arg" && test "x$ac_cv_func_pledge" = "xyes" ) ; then
3457 test "x$ac_cv_func_pledge" != "xyes" && \
3458 AC_MSG_ERROR([pledge sandbox requires pledge(2) support])
3459 SANDBOX_STYLE="pledge"
Damien Millerfafe1d82015-10-14 09:22:15 -07003460 AC_DEFINE([SANDBOX_PLEDGE], [1], [Sandbox using pledge(2)])
Damien Miller9846a2f2015-10-08 04:30:48 +11003461elif test "x$sandbox_arg" = "xsystrace" || \
Damien Miller69ff1df2011-06-23 08:30:03 +10003462 ( test -z "$sandbox_arg" && test "x$have_systr_policy_kill" = "x1" ) ; then
Damien Miller1a91c0f2011-08-17 11:59:25 +10003463 test "x$have_systr_policy_kill" != "x1" && \
3464 AC_MSG_ERROR([systrace sandbox requires systrace headers and SYSTR_POLICY_KILL support])
Damien Miller69ff1df2011-06-23 08:30:03 +10003465 SANDBOX_STYLE="systrace"
3466 AC_DEFINE([SANDBOX_SYSTRACE], [1], [Sandbox using systrace(4)])
Damien Millercd5e52e2011-06-27 07:18:18 +10003467elif test "x$sandbox_arg" = "xdarwin" || \
3468 ( test -z "$sandbox_arg" && test "x$ac_cv_func_sandbox_init" = "xyes" && \
3469 test "x$ac_cv_header_sandbox_h" = "xyes") ; then
Damien Miller1a91c0f2011-08-17 11:59:25 +10003470 test "x$ac_cv_func_sandbox_init" != "xyes" -o \
3471 "x$ac_cv_header_sandbox_h" != "xyes" && \
3472 AC_MSG_ERROR([Darwin seatbelt sandbox requires sandbox.h and sandbox_init function])
Damien Millercd5e52e2011-06-27 07:18:18 +10003473 SANDBOX_STYLE="darwin"
3474 AC_DEFINE([SANDBOX_DARWIN], [1], [Sandbox using Darwin sandbox_init(3)])
Damien Millere0956e32012-04-04 11:27:54 +10003475elif test "x$sandbox_arg" = "xseccomp_filter" || \
3476 ( test -z "$sandbox_arg" && \
Darren Tuckerd0494fd2012-05-19 14:25:39 +10003477 test "x$have_seccomp_filter" = "x1" && \
Damien Miller91f40d82013-02-22 11:37:00 +11003478 test "x$ac_cv_header_elf_h" = "xyes" && \
Damien Millere0956e32012-04-04 11:27:54 +10003479 test "x$ac_cv_header_linux_audit_h" = "xyes" && \
Damien Miller91f40d82013-02-22 11:37:00 +11003480 test "x$ac_cv_header_linux_filter_h" = "xyes" && \
3481 test "x$seccomp_audit_arch" != "x" && \
Damien Millere0956e32012-04-04 11:27:54 +10003482 test "x$have_linux_no_new_privs" = "x1" && \
3483 test "x$ac_cv_func_prctl" = "xyes" ) ; then
Damien Miller91f40d82013-02-22 11:37:00 +11003484 test "x$seccomp_audit_arch" = "x" && \
Damien Millere0956e32012-04-04 11:27:54 +10003485 AC_MSG_ERROR([seccomp_filter sandbox not supported on $host])
3486 test "x$have_linux_no_new_privs" != "x1" && \
3487 AC_MSG_ERROR([seccomp_filter sandbox requires PR_SET_NO_NEW_PRIVS])
3488 test "x$have_seccomp_filter" != "x1" && \
3489 AC_MSG_ERROR([seccomp_filter sandbox requires seccomp headers])
3490 test "x$ac_cv_func_prctl" != "xyes" && \
3491 AC_MSG_ERROR([seccomp_filter sandbox requires prctl function])
3492 SANDBOX_STYLE="seccomp_filter"
3493 AC_DEFINE([SANDBOX_SECCOMP_FILTER], [1], [Sandbox using seccomp filter])
Damien Millerf62ecef2014-01-25 12:34:38 +11003494elif test "x$sandbox_arg" = "xcapsicum" || \
3495 ( test -z "$sandbox_arg" && \
Darren Tuckerdd9d9b32017-08-28 16:48:27 +10003496 test "x$ac_cv_header_sys_capsicum_h" = "xyes" && \
Damien Miller603b8f42014-01-25 13:16:59 +11003497 test "x$ac_cv_func_cap_rights_limit" = "xyes") ; then
Darren Tuckerdd9d9b32017-08-28 16:48:27 +10003498 test "x$ac_cv_header_sys_capsicum_h" != "xyes" && \
3499 AC_MSG_ERROR([capsicum sandbox requires sys/capsicum.h header])
Damien Miller603b8f42014-01-25 13:16:59 +11003500 test "x$ac_cv_func_cap_rights_limit" != "xyes" && \
Damien Millerc96d8532014-01-25 13:12:28 +11003501 AC_MSG_ERROR([capsicum sandbox requires cap_rights_limit function])
Damien Millerf62ecef2014-01-25 12:34:38 +11003502 SANDBOX_STYLE="capsicum"
3503 AC_DEFINE([SANDBOX_CAPSICUM], [1], [Sandbox using capsicum])
Damien Miller69ff1df2011-06-23 08:30:03 +10003504elif test "x$sandbox_arg" = "xrlimit" || \
Darren Tucker60395f92012-07-03 14:31:18 +10003505 ( test -z "$sandbox_arg" && test "x$ac_cv_func_setrlimit" = "xyes" && \
Darren Tuckerff008de2013-03-06 17:48:48 +11003506 test "x$select_works_with_rlimit" = "xyes" && \
3507 test "x$rlimit_nofile_zero_works" = "xyes" ) ; then
Damien Miller1a91c0f2011-08-17 11:59:25 +10003508 test "x$ac_cv_func_setrlimit" != "xyes" && \
3509 AC_MSG_ERROR([rlimit sandbox requires setrlimit function])
Darren Tucker60395f92012-07-03 14:31:18 +10003510 test "x$select_works_with_rlimit" != "xyes" && \
3511 AC_MSG_ERROR([rlimit sandbox requires select to work with rlimit])
Damien Miller69ff1df2011-06-23 08:30:03 +10003512 SANDBOX_STYLE="rlimit"
3513 AC_DEFINE([SANDBOX_RLIMIT], [1], [Sandbox using setrlimit(2)])
Damien Miller4626cba2016-01-08 14:24:56 +11003514elif test "x$sandbox_arg" = "xsolaris" || \
3515 ( test -z "$sandbox_arg" && test "x$SOLARIS_PRIVS" = "xyes" ) ; then
3516 SANDBOX_STYLE="solaris"
3517 AC_DEFINE([SANDBOX_SOLARIS], [1], [Sandbox using Solaris/Illumos privileges])
Damien Miller69ff1df2011-06-23 08:30:03 +10003518elif test -z "$sandbox_arg" || test "x$sandbox_arg" = "xno" || \
3519 test "x$sandbox_arg" = "xnone" || test "x$sandbox_arg" = "xnull" ; then
3520 SANDBOX_STYLE="none"
3521 AC_DEFINE([SANDBOX_NULL], [1], [no privsep sandboxing])
3522else
Tim Ricea6e60612011-08-17 21:48:22 -07003523 AC_MSG_ERROR([unsupported --with-sandbox])
Damien Miller69ff1df2011-06-23 08:30:03 +10003524fi
3525
Ben Lindstromb5628642000-10-18 00:02:25 +00003526# Cheap hack to ensure NEWS-OS libraries are arranged right.
3527if test ! -z "$SONY" ; then
3528 LIBS="$LIBS -liberty";
3529fi
3530
Damien Miller57f39152005-11-24 19:58:19 +11003531# Check for long long datatypes
3532AC_CHECK_TYPES([long long, unsigned long long, long double])
3533
3534# Check datatype sizes
Dag-Erling Smørgravd0153c72018-10-09 23:03:40 +02003535AC_CHECK_SIZEOF([short int])
3536AC_CHECK_SIZEOF([int])
3537AC_CHECK_SIZEOF([long int])
3538AC_CHECK_SIZEOF([long long int])
Damien Millerc6398ef1999-11-20 12:18:40 +11003539
Damien Millerfa2bb692002-04-23 23:22:25 +10003540# Sanity check long long for some platforms (AIX)
3541if test "x$ac_cv_sizeof_long_long_int" = "x4" ; then
3542 ac_cv_sizeof_long_long_int=0
3543fi
3544
Darren Tucker537f1ed2005-10-25 18:38:33 +10003545# compute LLONG_MIN and LLONG_MAX if we don't know them.
3546if test -z "$have_llong_max"; then
3547 AC_MSG_CHECKING([for max value of long long])
3548 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08003549 [AC_LANG_PROGRAM([[
Darren Tucker537f1ed2005-10-25 18:38:33 +10003550#include <stdio.h>
3551/* Why is this so damn hard? */
3552#ifdef __GNUC__
3553# undef __GNUC__
3554#endif
3555#define __USE_ISOC99
3556#include <limits.h>
3557#define DATA "conftest.llminmax"
Darren Tuckerd1450db2006-03-13 19:06:51 +11003558#define my_abs(a) ((a) < 0 ? ((a) * -1) : (a))
3559
3560/*
3561 * printf in libc on some platforms (eg old Tru64) does not understand %lld so
3562 * we do this the hard way.
3563 */
3564static int
3565fprint_ll(FILE *f, long long n)
3566{
3567 unsigned int i;
3568 int l[sizeof(long long) * 8];
3569
3570 if (n < 0)
3571 if (fprintf(f, "-") < 0)
3572 return -1;
3573 for (i = 0; n != 0; i++) {
3574 l[i] = my_abs(n % 10);
3575 n /= 10;
3576 }
3577 do {
3578 if (fprintf(f, "%d", l[--i]) < 0)
3579 return -1;
3580 } while (i != 0);
3581 if (fprintf(f, " ") < 0)
3582 return -1;
3583 return 0;
3584}
Tim Rice648f8762011-01-26 12:38:57 -08003585 ]], [[
Darren Tucker537f1ed2005-10-25 18:38:33 +10003586 FILE *f;
3587 long long i, llmin, llmax = 0;
3588
3589 if((f = fopen(DATA,"w")) == NULL)
3590 exit(1);
3591
3592#if defined(LLONG_MIN) && defined(LLONG_MAX)
3593 fprintf(stderr, "Using system header for LLONG_MIN and LLONG_MAX\n");
3594 llmin = LLONG_MIN;
3595 llmax = LLONG_MAX;
3596#else
3597 fprintf(stderr, "Calculating LLONG_MIN and LLONG_MAX\n");
3598 /* This will work on one's complement and two's complement */
3599 for (i = 1; i > llmax; i <<= 1, i++)
3600 llmax = i;
3601 llmin = llmax + 1LL; /* wrap */
3602#endif
3603
3604 /* Sanity check */
3605 if (llmin + 1 < llmin || llmin - 1 < llmin || llmax + 1 > llmax
Darren Tuckerd1450db2006-03-13 19:06:51 +11003606 || llmax - 1 > llmax || llmin == llmax || llmin == 0
3607 || llmax == 0 || llmax < LONG_MAX || llmin > LONG_MIN) {
Darren Tucker537f1ed2005-10-25 18:38:33 +10003608 fprintf(f, "unknown unknown\n");
3609 exit(2);
3610 }
3611
Darren Tuckerd1450db2006-03-13 19:06:51 +11003612 if (fprint_ll(f, llmin) < 0)
Darren Tucker537f1ed2005-10-25 18:38:33 +10003613 exit(3);
Darren Tuckerd1450db2006-03-13 19:06:51 +11003614 if (fprint_ll(f, llmax) < 0)
3615 exit(4);
3616 if (fclose(f) < 0)
3617 exit(5);
Darren Tucker537f1ed2005-10-25 18:38:33 +10003618 exit(0);
Darren Tucker537f1ed2005-10-25 18:38:33 +10003619 ]])],
3620 [
3621 llong_min=`$AWK '{print $1}' conftest.llminmax`
3622 llong_max=`$AWK '{print $2}' conftest.llminmax`
3623
Tim Rice648f8762011-01-26 12:38:57 -08003624 AC_MSG_RESULT([$llong_max])
3625 AC_DEFINE_UNQUOTED([LLONG_MAX], [${llong_max}LL],
Darren Tucker537f1ed2005-10-25 18:38:33 +10003626 [max value of long long calculated by configure])
3627 AC_MSG_CHECKING([for min value of long long])
Tim Rice648f8762011-01-26 12:38:57 -08003628 AC_MSG_RESULT([$llong_min])
3629 AC_DEFINE_UNQUOTED([LLONG_MIN], [${llong_min}LL],
Darren Tucker537f1ed2005-10-25 18:38:33 +10003630 [min value of long long calculated by configure])
3631 ],
3632 [
Tim Rice648f8762011-01-26 12:38:57 -08003633 AC_MSG_RESULT([not found])
Darren Tucker537f1ed2005-10-25 18:38:33 +10003634 ],
3635 [
3636 AC_MSG_WARN([cross compiling: not checking])
3637 ]
3638 )
3639fi
3640
Darren Tucker29125962019-10-28 16:06:59 +11003641AC_CHECK_DECLS([UINT32_MAX], , , [[
3642#ifdef HAVE_SYS_LIMITS_H
3643# include <sys/limits.h>
3644#endif
3645#ifdef HAVE_LIMITS_H
3646# include <limits.h>
3647#endif
3648#ifdef HAVE_STDINT_H
3649# include <stdint.h>
3650#endif
3651]])
Darren Tucker537f1ed2005-10-25 18:38:33 +10003652
Damien Millera22ba012000-03-02 23:09:20 +11003653# More checks for data types
Damien Millercaf6dd62000-08-29 11:33:50 +11003654AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [
Tim Rice648f8762011-01-26 12:38:57 -08003655 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3656 [[ u_int a; a = 1;]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003657 [ ac_cv_have_u_int="yes" ], [ ac_cv_have_u_int="no"
Tim Rice648f8762011-01-26 12:38:57 -08003658 ])
Damien Millercaf6dd62000-08-29 11:33:50 +11003659])
3660if test "x$ac_cv_have_u_int" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003661 AC_DEFINE([HAVE_U_INT], [1], [define if you have u_int data type])
Damien Millercaf6dd62000-08-29 11:33:50 +11003662 have_u_int=1
3663fi
3664
Damien Miller61e50f12000-05-08 20:49:37 +10003665AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003666 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3667 [[ int8_t a; int16_t b; int32_t c; a = b = c = 1;]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003668 [ ac_cv_have_intxx_t="yes" ], [ ac_cv_have_intxx_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003669 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003670])
3671if test "x$ac_cv_have_intxx_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003672 AC_DEFINE([HAVE_INTXX_T], [1], [define if you have intxx_t data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003673 have_intxx_t=1
3674fi
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003675
3676if (test -z "$have_intxx_t" && \
Damien Millera8e06ce2003-11-21 23:48:55 +11003677 test "x$ac_cv_header_stdint_h" = "xyes")
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003678then
3679 AC_MSG_CHECKING([for intXX_t types in stdint.h])
Tim Rice648f8762011-01-26 12:38:57 -08003680 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdint.h> ]],
3681 [[ int8_t a; int16_t b; int32_t c; a = b = c = 1;]])],
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003682 [
Tim Rice648f8762011-01-26 12:38:57 -08003683 AC_DEFINE([HAVE_INTXX_T])
3684 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003685 ], [ AC_MSG_RESULT([no])
Tim Rice648f8762011-01-26 12:38:57 -08003686 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003687fi
3688
Damien Miller578783e2000-09-23 14:12:24 +11003689AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003690 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Tim Rice907881e2002-07-18 11:44:50 -07003691#include <sys/types.h>
3692#ifdef HAVE_STDINT_H
3693# include <stdint.h>
3694#endif
3695#include <sys/socket.h>
3696#ifdef HAVE_SYS_BITYPES_H
3697# include <sys/bitypes.h>
3698#endif
Tim Rice648f8762011-01-26 12:38:57 -08003699 ]], [[
3700int64_t a; a = 1;
3701 ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003702 [ ac_cv_have_int64_t="yes" ], [ ac_cv_have_int64_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003703 ])
Damien Miller578783e2000-09-23 14:12:24 +11003704])
3705if test "x$ac_cv_have_int64_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003706 AC_DEFINE([HAVE_INT64_T], [1], [define if you have int64_t data type])
Tim Rice4cec93f2002-02-26 08:40:48 -08003707fi
3708
Damien Miller61e50f12000-05-08 20:49:37 +10003709AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003710 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3711 [[ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003712 [ ac_cv_have_u_intxx_t="yes" ], [ ac_cv_have_u_intxx_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003713 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003714])
3715if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003716 AC_DEFINE([HAVE_U_INTXX_T], [1], [define if you have u_intxx_t data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003717 have_u_intxx_t=1
3718fi
Damien Millerc6398ef1999-11-20 12:18:40 +11003719
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003720if test -z "$have_u_intxx_t" ; then
3721 AC_MSG_CHECKING([for u_intXX_t types in sys/socket.h])
Tim Rice648f8762011-01-26 12:38:57 -08003722 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/socket.h> ]],
3723 [[ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;]])],
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003724 [
Tim Rice648f8762011-01-26 12:38:57 -08003725 AC_DEFINE([HAVE_U_INTXX_T])
3726 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003727 ], [ AC_MSG_RESULT([no])
Tim Rice648f8762011-01-26 12:38:57 -08003728 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003729fi
3730
Damien Miller578783e2000-09-23 14:12:24 +11003731AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003732 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3733 [[ u_int64_t a; a = 1;]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003734 [ ac_cv_have_u_int64_t="yes" ], [ ac_cv_have_u_int64_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003735 ])
Damien Miller578783e2000-09-23 14:12:24 +11003736])
3737if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003738 AC_DEFINE([HAVE_U_INT64_T], [1], [define if you have u_int64_t data type])
Damien Miller578783e2000-09-23 14:12:24 +11003739 have_u_int64_t=1
3740fi
3741
Damien Millerc2868192014-01-30 10:21:19 +11003742if (test -z "$have_u_int64_t" && \
3743 test "x$ac_cv_header_sys_bitypes_h" = "xyes")
3744then
Tim Rice4cec93f2002-02-26 08:40:48 -08003745 AC_MSG_CHECKING([for u_int64_t type in sys/bitypes.h])
Tim Rice648f8762011-01-26 12:38:57 -08003746 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/bitypes.h> ]],
3747 [[ u_int64_t a; a = 1]])],
Tim Rice4cec93f2002-02-26 08:40:48 -08003748 [
Tim Rice648f8762011-01-26 12:38:57 -08003749 AC_DEFINE([HAVE_U_INT64_T])
3750 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003751 ], [ AC_MSG_RESULT([no])
Tim Rice648f8762011-01-26 12:38:57 -08003752 ])
Tim Rice4cec93f2002-02-26 08:40:48 -08003753fi
3754
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003755if test -z "$have_u_intxx_t" ; then
3756 AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003757 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003758#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08003759 ]], [[
3760 uint8_t a;
3761 uint16_t b;
3762 uint32_t c;
3763 a = b = c = 1;
3764 ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003765 [ ac_cv_have_uintxx_t="yes" ], [ ac_cv_have_uintxx_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003766 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003767 ])
3768 if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003769 AC_DEFINE([HAVE_UINTXX_T], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003770 [define if you have uintxx_t data type])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003771 fi
3772fi
3773
Damien Millerc2868192014-01-30 10:21:19 +11003774if (test -z "$have_uintxx_t" && \
3775 test "x$ac_cv_header_stdint_h" = "xyes")
3776then
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003777 AC_MSG_CHECKING([for uintXX_t types in stdint.h])
Tim Rice648f8762011-01-26 12:38:57 -08003778 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdint.h> ]],
3779 [[ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;]])],
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003780 [
Tim Rice648f8762011-01-26 12:38:57 -08003781 AC_DEFINE([HAVE_UINTXX_T])
3782 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003783 ], [ AC_MSG_RESULT([no])
Tim Rice648f8762011-01-26 12:38:57 -08003784 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003785fi
3786
Damien Millerc2868192014-01-30 10:21:19 +11003787if (test -z "$have_uintxx_t" && \
3788 test "x$ac_cv_header_inttypes_h" = "xyes")
3789then
Darren Tucker6d725682014-01-17 19:17:34 +11003790 AC_MSG_CHECKING([for uintXX_t types in inttypes.h])
3791 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <inttypes.h> ]],
3792 [[ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;]])],
3793 [
3794 AC_DEFINE([HAVE_UINTXX_T])
3795 AC_MSG_RESULT([yes])
Tim Ricee1d93702016-05-31 11:13:22 -07003796 ], [ AC_MSG_RESULT([no])
Darren Tucker6d725682014-01-17 19:17:34 +11003797 ])
3798fi
3799
Damien Milleredb82922000-06-20 13:25:52 +10003800if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
Damien Millera8e06ce2003-11-21 23:48:55 +11003801 test "x$ac_cv_header_sys_bitypes_h" = "xyes")
Damien Millerb29ea912000-01-15 14:12:03 +11003802then
3803 AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
Tim Rice648f8762011-01-26 12:38:57 -08003804 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller61e50f12000-05-08 20:49:37 +10003805#include <sys/bitypes.h>
Tim Rice648f8762011-01-26 12:38:57 -08003806 ]], [[
Damien Miller70494d12000-04-03 15:57:06 +10003807 int8_t a; int16_t b; int32_t c;
3808 u_int8_t e; u_int16_t f; u_int32_t g;
3809 a = b = c = e = f = g = 1;
Tim Rice648f8762011-01-26 12:38:57 -08003810 ]])],
Damien Millerb29ea912000-01-15 14:12:03 +11003811 [
Tim Rice648f8762011-01-26 12:38:57 -08003812 AC_DEFINE([HAVE_U_INTXX_T])
3813 AC_DEFINE([HAVE_INTXX_T])
3814 AC_MSG_RESULT([yes])
3815 ], [AC_MSG_RESULT([no])
3816 ])
Damien Millerb29ea912000-01-15 14:12:03 +11003817fi
3818
Damien Miller58be7382001-09-15 21:31:54 +10003819
3820AC_CACHE_CHECK([for u_char], ac_cv_have_u_char, [
Tim Rice648f8762011-01-26 12:38:57 -08003821 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3822 [[ u_char foo; foo = 125; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003823 [ ac_cv_have_u_char="yes" ], [ ac_cv_have_u_char="no"
Tim Rice648f8762011-01-26 12:38:57 -08003824 ])
Damien Miller58be7382001-09-15 21:31:54 +10003825])
3826if test "x$ac_cv_have_u_char" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003827 AC_DEFINE([HAVE_U_CHAR], [1], [define if you have u_char data type])
Damien Miller58be7382001-09-15 21:31:54 +10003828fi
3829
Darren Tucker007e3b32013-11-03 18:43:55 +11003830AC_CHECK_TYPES([intmax_t, uintmax_t], , , [
3831#include <sys/types.h>
3832#include <stdint.h>
3833])
3834
Tim Rice13aae5e2001-10-21 17:53:58 -07003835TYPE_SOCKLEN_T
Damien Miller74d0d4a1999-12-29 02:24:35 +11003836
Tim Rice648f8762011-01-26 12:38:57 -08003837AC_CHECK_TYPES([sig_atomic_t], , , [#include <signal.h>])
3838AC_CHECK_TYPES([fsblkcnt_t, fsfilcnt_t], , , [
Darren Tucker598eaa62008-06-09 03:32:29 +10003839#include <sys/types.h>
3840#ifdef HAVE_SYS_BITYPES_H
3841#include <sys/bitypes.h>
3842#endif
3843#ifdef HAVE_SYS_STATFS_H
3844#include <sys/statfs.h>
3845#endif
3846#ifdef HAVE_SYS_STATVFS_H
3847#include <sys/statvfs.h>
3848#endif
3849])
Tim Rice4cec93f2002-02-26 08:40:48 -08003850
Darren Tuckerd561b0b2019-10-28 16:09:04 +11003851AC_CHECK_MEMBERS([struct statfs.f_files, struct statfs.f_flags], [], [], [[
Darren Tucker382c18c2019-11-03 00:09:21 +11003852#include <sys/param.h>
Darren Tucker11057562018-02-25 11:22:57 +11003853#include <sys/types.h>
3854#ifdef HAVE_SYS_BITYPES_H
3855#include <sys/bitypes.h>
3856#endif
3857#ifdef HAVE_SYS_STATFS_H
3858#include <sys/statfs.h>
3859#endif
3860#ifdef HAVE_SYS_STATVFS_H
3861#include <sys/statvfs.h>
3862#endif
3863#ifdef HAVE_SYS_VFS_H
3864#include <sys/vfs.h>
3865#endif
Darren Tucker382c18c2019-11-03 00:09:21 +11003866#ifdef HAVE_SYS_MOUNT_H
3867#include <sys/mount.h>
3868#endif
Darren Tucker11057562018-02-25 11:22:57 +11003869]])
3870
3871
Tim Rice648f8762011-01-26 12:38:57 -08003872AC_CHECK_TYPES([in_addr_t, in_port_t], , ,
Damien Miller848b9932005-02-24 12:12:34 +11003873[#include <sys/types.h>
3874#include <netinet/in.h>])
Darren Tuckerd9f88912005-02-20 21:01:48 +11003875
Damien Miller61e50f12000-05-08 20:49:37 +10003876AC_CACHE_CHECK([for size_t], ac_cv_have_size_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003877 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3878 [[ size_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003879 [ ac_cv_have_size_t="yes" ], [ ac_cv_have_size_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003880 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003881])
3882if test "x$ac_cv_have_size_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003883 AC_DEFINE([HAVE_SIZE_T], [1], [define if you have size_t data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003884fi
Damien Miller95058511999-12-29 10:36:45 +11003885
Damien Miller615f9392000-05-17 22:53:33 +10003886AC_CACHE_CHECK([for ssize_t], ac_cv_have_ssize_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003887 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3888 [[ ssize_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003889 [ ac_cv_have_ssize_t="yes" ], [ ac_cv_have_ssize_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003890 ])
Damien Miller615f9392000-05-17 22:53:33 +10003891])
3892if test "x$ac_cv_have_ssize_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003893 AC_DEFINE([HAVE_SSIZE_T], [1], [define if you have ssize_t data type])
Damien Miller615f9392000-05-17 22:53:33 +10003894fi
3895
Ben Lindstrom0d5af602001-01-09 00:50:29 +00003896AC_CACHE_CHECK([for clock_t], ac_cv_have_clock_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003897 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <time.h> ]],
3898 [[ clock_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003899 [ ac_cv_have_clock_t="yes" ], [ ac_cv_have_clock_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003900 ])
Ben Lindstrom0d5af602001-01-09 00:50:29 +00003901])
3902if test "x$ac_cv_have_clock_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003903 AC_DEFINE([HAVE_CLOCK_T], [1], [define if you have clock_t data type])
Ben Lindstrom0d5af602001-01-09 00:50:29 +00003904fi
3905
Damien Millerb54b40e2000-06-23 08:23:34 +10003906AC_CACHE_CHECK([for sa_family_t], ac_cv_have_sa_family_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003907 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Millerb54b40e2000-06-23 08:23:34 +10003908#include <sys/types.h>
3909#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08003910 ]], [[ sa_family_t foo; foo = 1235; ]])],
3911 [ ac_cv_have_sa_family_t="yes" ],
3912 [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller78315eb2000-09-29 23:01:36 +11003913#include <sys/types.h>
3914#include <sys/socket.h>
3915#include <netinet/in.h>
Tim Rice648f8762011-01-26 12:38:57 -08003916 ]], [[ sa_family_t foo; foo = 1235; ]])],
Damien Miller78315eb2000-09-29 23:01:36 +11003917 [ ac_cv_have_sa_family_t="yes" ],
Damien Millerb54b40e2000-06-23 08:23:34 +10003918 [ ac_cv_have_sa_family_t="no" ]
3919 )
Tim Rice648f8762011-01-26 12:38:57 -08003920 ])
Damien Millerb54b40e2000-06-23 08:23:34 +10003921])
3922if test "x$ac_cv_have_sa_family_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003923 AC_DEFINE([HAVE_SA_FAMILY_T], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003924 [define if you have sa_family_t data type])
Damien Millerb54b40e2000-06-23 08:23:34 +10003925fi
3926
Damien Miller0f91b4e2000-06-18 15:43:25 +10003927AC_CACHE_CHECK([for pid_t], ac_cv_have_pid_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003928 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3929 [[ pid_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003930 [ ac_cv_have_pid_t="yes" ], [ ac_cv_have_pid_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003931 ])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003932])
3933if test "x$ac_cv_have_pid_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003934 AC_DEFINE([HAVE_PID_T], [1], [define if you have pid_t data type])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003935fi
3936
3937AC_CACHE_CHECK([for mode_t], ac_cv_have_mode_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003938 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3939 [[ mode_t foo; foo = 1235; ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07003940 [ ac_cv_have_mode_t="yes" ], [ ac_cv_have_mode_t="no"
Tim Rice648f8762011-01-26 12:38:57 -08003941 ])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003942])
3943if test "x$ac_cv_have_mode_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003944 AC_DEFINE([HAVE_MODE_T], [1], [define if you have mode_t data type])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003945fi
3946
Damien Miller61e50f12000-05-08 20:49:37 +10003947
3948AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_have_struct_sockaddr_storage, [
Tim Rice648f8762011-01-26 12:38:57 -08003949 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10003950#include <sys/types.h>
3951#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08003952 ]], [[ struct sockaddr_storage s; ]])],
3953 [ ac_cv_have_struct_sockaddr_storage="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003954 [ ac_cv_have_struct_sockaddr_storage="no"
Tim Rice648f8762011-01-26 12:38:57 -08003955 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003956])
3957if test "x$ac_cv_have_struct_sockaddr_storage" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003958 AC_DEFINE([HAVE_STRUCT_SOCKADDR_STORAGE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003959 [define if you have struct sockaddr_storage data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003960fi
Damien Miller34132e52000-01-14 15:45:46 +11003961
Damien Miller61e50f12000-05-08 20:49:37 +10003962AC_CACHE_CHECK([for struct sockaddr_in6], ac_cv_have_struct_sockaddr_in6, [
Tim Rice648f8762011-01-26 12:38:57 -08003963 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller7b22d652000-06-18 14:07:04 +10003964#include <sys/types.h>
Damien Miller61e50f12000-05-08 20:49:37 +10003965#include <netinet/in.h>
Tim Rice648f8762011-01-26 12:38:57 -08003966 ]], [[ struct sockaddr_in6 s; s.sin6_family = 0; ]])],
3967 [ ac_cv_have_struct_sockaddr_in6="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003968 [ ac_cv_have_struct_sockaddr_in6="no"
Tim Rice648f8762011-01-26 12:38:57 -08003969 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003970])
3971if test "x$ac_cv_have_struct_sockaddr_in6" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003972 AC_DEFINE([HAVE_STRUCT_SOCKADDR_IN6], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003973 [define if you have struct sockaddr_in6 data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003974fi
Damien Miller34132e52000-01-14 15:45:46 +11003975
Damien Miller61e50f12000-05-08 20:49:37 +10003976AC_CACHE_CHECK([for struct in6_addr], ac_cv_have_struct_in6_addr, [
Tim Rice648f8762011-01-26 12:38:57 -08003977 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller7b22d652000-06-18 14:07:04 +10003978#include <sys/types.h>
Damien Miller61e50f12000-05-08 20:49:37 +10003979#include <netinet/in.h>
Tim Rice648f8762011-01-26 12:38:57 -08003980 ]], [[ struct in6_addr s; s.s6_addr[0] = 0; ]])],
3981 [ ac_cv_have_struct_in6_addr="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07003982 [ ac_cv_have_struct_in6_addr="no"
Tim Rice648f8762011-01-26 12:38:57 -08003983 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003984])
3985if test "x$ac_cv_have_struct_in6_addr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003986 AC_DEFINE([HAVE_STRUCT_IN6_ADDR], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003987 [define if you have struct in6_addr data type])
Tim Rice0f4d2c02008-11-18 21:26:41 -08003988
3989dnl Now check for sin6_scope_id
Tim Rice648f8762011-01-26 12:38:57 -08003990 AC_CHECK_MEMBERS([struct sockaddr_in6.sin6_scope_id], , ,
Tim Rice0f4d2c02008-11-18 21:26:41 -08003991 [
3992#ifdef HAVE_SYS_TYPES_H
3993#include <sys/types.h>
3994#endif
3995#include <netinet/in.h>
3996 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003997fi
Damien Miller34132e52000-01-14 15:45:46 +11003998
Damien Miller61e50f12000-05-08 20:49:37 +10003999AC_CACHE_CHECK([for struct addrinfo], ac_cv_have_struct_addrinfo, [
Tim Rice648f8762011-01-26 12:38:57 -08004000 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10004001#include <sys/types.h>
4002#include <sys/socket.h>
4003#include <netdb.h>
Tim Rice648f8762011-01-26 12:38:57 -08004004 ]], [[ struct addrinfo s; s.ai_flags = AI_PASSIVE; ]])],
4005 [ ac_cv_have_struct_addrinfo="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004006 [ ac_cv_have_struct_addrinfo="no"
Tim Rice648f8762011-01-26 12:38:57 -08004007 ])
Damien Miller61e50f12000-05-08 20:49:37 +10004008])
4009if test "x$ac_cv_have_struct_addrinfo" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004010 AC_DEFINE([HAVE_STRUCT_ADDRINFO], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004011 [define if you have struct addrinfo data type])
Damien Miller61e50f12000-05-08 20:49:37 +10004012fi
4013
Ben Lindstrom42202bc2001-01-15 02:34:37 +00004014AC_CACHE_CHECK([for struct timeval], ac_cv_have_struct_timeval, [
Tim Rice648f8762011-01-26 12:38:57 -08004015 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/time.h> ]],
4016 [[ struct timeval tv; tv.tv_sec = 1;]])],
4017 [ ac_cv_have_struct_timeval="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004018 [ ac_cv_have_struct_timeval="no"
Tim Rice648f8762011-01-26 12:38:57 -08004019 ])
Ben Lindstrom42202bc2001-01-15 02:34:37 +00004020])
4021if test "x$ac_cv_have_struct_timeval" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004022 AC_DEFINE([HAVE_STRUCT_TIMEVAL], [1], [define if you have struct timeval])
Ben Lindstrom42202bc2001-01-15 02:34:37 +00004023 have_struct_timeval=1
4024fi
4025
Tim Rice648f8762011-01-26 12:38:57 -08004026AC_CHECK_TYPES([struct timespec])
Tim Rice4e4dc562003-03-18 10:21:40 -08004027
Damien Miller10479cc2018-04-10 10:19:02 +10004028# We need int64_t or else certain parts of the compile will fail.
Tim Rice8bb561b2005-03-17 16:23:19 -08004029if test "x$ac_cv_have_int64_t" = "xno" && \
4030 test "x$ac_cv_sizeof_long_int" != "x8" && \
4031 test "x$ac_cv_sizeof_long_long_int" = "x0" ; then
Ben Lindstrom5bd6eb72003-03-21 00:34:34 +00004032 echo "OpenSSH requires int64_t support. Contact your vendor or install"
4033 echo "an alternative compiler (I.E., GCC) before continuing."
4034 echo ""
4035 exit 1;
Tim Ricebee3f222001-03-11 17:32:12 -08004036else
4037dnl test snprintf (broken on SCO w/gcc)
Darren Tuckera0c2b392004-09-11 23:26:37 +10004038 AC_RUN_IFELSE(
Darren Tucker623d92f2004-09-12 22:36:15 +10004039 [AC_LANG_SOURCE([[
Tim Ricebee3f222001-03-11 17:32:12 -08004040#include <stdio.h>
4041#include <string.h>
4042#ifdef HAVE_SNPRINTF
4043main()
4044{
4045 char buf[50];
4046 char expected_out[50];
4047 int mazsize = 50 ;
4048#if (SIZEOF_LONG_INT == 8)
4049 long int num = 0x7fffffffffffffff;
4050#else
Kevin Steves6482ec82001-07-15 02:09:28 +00004051 long long num = 0x7fffffffffffffffll;
Tim Ricebee3f222001-03-11 17:32:12 -08004052#endif
4053 strcpy(expected_out, "9223372036854775807");
4054 snprintf(buf, mazsize, "%lld", num);
4055 if(strcmp(buf, expected_out) != 0)
Damien Millera8e06ce2003-11-21 23:48:55 +11004056 exit(1);
Tim Ricebee3f222001-03-11 17:32:12 -08004057 exit(0);
4058}
4059#else
4060main() { exit(0); }
4061#endif
Tim Rice648f8762011-01-26 12:38:57 -08004062 ]])], [ true ], [ AC_DEFINE([BROKEN_SNPRINTF]) ],
Darren Tuckera0c2b392004-09-11 23:26:37 +10004063 AC_MSG_WARN([cross compiling: Assuming working snprintf()])
Tim Ricebee3f222001-03-11 17:32:12 -08004064 )
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00004065fi
4066
Damien Miller78315eb2000-09-29 23:01:36 +11004067dnl Checks for structure members
Tim Rice648f8762011-01-26 12:38:57 -08004068OSSH_CHECK_HEADER_FOR_FIELD([ut_host], [utmp.h], [HAVE_HOST_IN_UTMP])
4069OSSH_CHECK_HEADER_FOR_FIELD([ut_host], [utmpx.h], [HAVE_HOST_IN_UTMPX])
4070OSSH_CHECK_HEADER_FOR_FIELD([syslen], [utmpx.h], [HAVE_SYSLEN_IN_UTMPX])
4071OSSH_CHECK_HEADER_FOR_FIELD([ut_pid], [utmp.h], [HAVE_PID_IN_UTMP])
4072OSSH_CHECK_HEADER_FOR_FIELD([ut_type], [utmp.h], [HAVE_TYPE_IN_UTMP])
4073OSSH_CHECK_HEADER_FOR_FIELD([ut_type], [utmpx.h], [HAVE_TYPE_IN_UTMPX])
4074OSSH_CHECK_HEADER_FOR_FIELD([ut_tv], [utmp.h], [HAVE_TV_IN_UTMP])
4075OSSH_CHECK_HEADER_FOR_FIELD([ut_id], [utmp.h], [HAVE_ID_IN_UTMP])
4076OSSH_CHECK_HEADER_FOR_FIELD([ut_id], [utmpx.h], [HAVE_ID_IN_UTMPX])
4077OSSH_CHECK_HEADER_FOR_FIELD([ut_addr], [utmp.h], [HAVE_ADDR_IN_UTMP])
4078OSSH_CHECK_HEADER_FOR_FIELD([ut_addr], [utmpx.h], [HAVE_ADDR_IN_UTMPX])
4079OSSH_CHECK_HEADER_FOR_FIELD([ut_addr_v6], [utmp.h], [HAVE_ADDR_V6_IN_UTMP])
4080OSSH_CHECK_HEADER_FOR_FIELD([ut_addr_v6], [utmpx.h], [HAVE_ADDR_V6_IN_UTMPX])
4081OSSH_CHECK_HEADER_FOR_FIELD([ut_exit], [utmp.h], [HAVE_EXIT_IN_UTMP])
4082OSSH_CHECK_HEADER_FOR_FIELD([ut_time], [utmp.h], [HAVE_TIME_IN_UTMP])
4083OSSH_CHECK_HEADER_FOR_FIELD([ut_time], [utmpx.h], [HAVE_TIME_IN_UTMPX])
4084OSSH_CHECK_HEADER_FOR_FIELD([ut_tv], [utmpx.h], [HAVE_TV_IN_UTMPX])
Tim Rice13aae5e2001-10-21 17:53:58 -07004085
4086AC_CHECK_MEMBERS([struct stat.st_blksize])
Damien Millerbcd14852017-06-10 23:41:25 +10004087AC_CHECK_MEMBERS([struct stat.st_mtim])
4088AC_CHECK_MEMBERS([struct stat.st_mtime])
Damien Miller6332da22013-04-23 14:25:52 +10004089AC_CHECK_MEMBERS([struct passwd.pw_gecos, struct passwd.pw_class,
4090struct passwd.pw_change, struct passwd.pw_expire],
4091[], [], [[
4092#include <sys/types.h>
4093#include <pwd.h>
4094]])
4095
Tim Rice648f8762011-01-26 12:38:57 -08004096AC_CHECK_MEMBER([struct __res_state.retrans], [], [AC_DEFINE([__res_state], [state],
Darren Tucker58e298d2005-11-25 13:14:58 +11004097 [Define if we don't have struct __res_state in resolv.h])],
Damien Miller6332da22013-04-23 14:25:52 +10004098[[
Darren Tucker58e298d2005-11-25 13:14:58 +11004099#include <stdio.h>
4100#if HAVE_SYS_TYPES_H
4101# include <sys/types.h>
4102#endif
4103#include <netinet/in.h>
4104#include <arpa/nameser.h>
4105#include <resolv.h>
Damien Miller6332da22013-04-23 14:25:52 +10004106]])
andre2ff7b5d2000-06-03 14:57:40 +00004107
Damien Miller61e50f12000-05-08 20:49:37 +10004108AC_CACHE_CHECK([for ss_family field in struct sockaddr_storage],
4109 ac_cv_have_ss_family_in_struct_ss, [
Tim Rice648f8762011-01-26 12:38:57 -08004110 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10004111#include <sys/types.h>
4112#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08004113 ]], [[ struct sockaddr_storage s; s.ss_family = 1; ]])],
4114 [ ac_cv_have_ss_family_in_struct_ss="yes" ],
4115 [ ac_cv_have_ss_family_in_struct_ss="no" ])
Damien Miller61e50f12000-05-08 20:49:37 +10004116])
4117if test "x$ac_cv_have_ss_family_in_struct_ss" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004118 AC_DEFINE([HAVE_SS_FAMILY_IN_SS], [1], [Fields in struct sockaddr_storage])
Damien Miller61e50f12000-05-08 20:49:37 +10004119fi
4120
Damien Miller61e50f12000-05-08 20:49:37 +10004121AC_CACHE_CHECK([for __ss_family field in struct sockaddr_storage],
4122 ac_cv_have___ss_family_in_struct_ss, [
Tim Rice648f8762011-01-26 12:38:57 -08004123 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10004124#include <sys/types.h>
4125#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08004126 ]], [[ struct sockaddr_storage s; s.__ss_family = 1; ]])],
4127 [ ac_cv_have___ss_family_in_struct_ss="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004128 [ ac_cv_have___ss_family_in_struct_ss="no"
Tim Rice648f8762011-01-26 12:38:57 -08004129 ])
Damien Miller61e50f12000-05-08 20:49:37 +10004130])
4131if test "x$ac_cv_have___ss_family_in_struct_ss" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004132 AC_DEFINE([HAVE___SS_FAMILY_IN_SS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004133 [Fields in struct sockaddr_storage])
Damien Miller61e50f12000-05-08 20:49:37 +10004134fi
Damien Millerbf1c9b21999-12-09 10:16:54 +11004135
Tim Rice28bbb0c2002-05-27 17:37:32 -07004136dnl make sure we're using the real structure members and not defines
Kevin Steves939c9db2002-03-22 17:23:25 +00004137AC_CACHE_CHECK([for msg_accrights field in struct msghdr],
4138 ac_cv_have_accrights_in_msghdr, [
Tim Rice648f8762011-01-26 12:38:57 -08004139 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Tim Riceae49fe62002-04-12 10:26:21 -07004140#include <sys/types.h>
Kevin Steves939c9db2002-03-22 17:23:25 +00004141#include <sys/socket.h>
4142#include <sys/uio.h>
Tim Rice648f8762011-01-26 12:38:57 -08004143 ]], [[
Tim Rice28bbb0c2002-05-27 17:37:32 -07004144#ifdef msg_accrights
Darren Tuckera0c2b392004-09-11 23:26:37 +10004145#error "msg_accrights is a macro"
Tim Rice28bbb0c2002-05-27 17:37:32 -07004146exit(1);
4147#endif
4148struct msghdr m;
4149m.msg_accrights = 0;
4150exit(0);
Tim Rice648f8762011-01-26 12:38:57 -08004151 ]])],
Kevin Steves939c9db2002-03-22 17:23:25 +00004152 [ ac_cv_have_accrights_in_msghdr="yes" ],
4153 [ ac_cv_have_accrights_in_msghdr="no" ]
4154 )
4155])
4156if test "x$ac_cv_have_accrights_in_msghdr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004157 AC_DEFINE([HAVE_ACCRIGHTS_IN_MSGHDR], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004158 [Define if your system uses access rights style
4159 file descriptor passing])
Kevin Steves939c9db2002-03-22 17:23:25 +00004160fi
4161
Tim Rice648f8762011-01-26 12:38:57 -08004162AC_MSG_CHECKING([if struct statvfs.f_fsid is integral type])
4163AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckere1a3ddf2012-05-04 11:05:45 +10004164#include <sys/param.h>
Darren Tucker32780622009-06-16 16:11:02 +10004165#include <sys/stat.h>
4166#ifdef HAVE_SYS_TIME_H
4167# include <sys/time.h>
4168#endif
4169#ifdef HAVE_SYS_MOUNT_H
4170#include <sys/mount.h>
4171#endif
4172#ifdef HAVE_SYS_STATVFS_H
4173#include <sys/statvfs.h>
4174#endif
Tim Rice648f8762011-01-26 12:38:57 -08004175 ]], [[ struct statvfs s; s.f_fsid = 0; ]])],
4176 [ AC_MSG_RESULT([yes]) ],
4177 [ AC_MSG_RESULT([no])
Darren Tucker32780622009-06-16 16:11:02 +10004178
Tim Rice648f8762011-01-26 12:38:57 -08004179 AC_MSG_CHECKING([if fsid_t has member val])
4180 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker32780622009-06-16 16:11:02 +10004181#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08004182#include <sys/statvfs.h>
4183 ]], [[ fsid_t t; t.val[0] = 0; ]])],
4184 [ AC_MSG_RESULT([yes])
4185 AC_DEFINE([FSID_HAS_VAL], [1], [fsid_t has member val]) ],
4186 [ AC_MSG_RESULT([no]) ])
Darren Tucker32780622009-06-16 16:11:02 +10004187
Tim Rice648f8762011-01-26 12:38:57 -08004188 AC_MSG_CHECKING([if f_fsid has member __val])
4189 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker32780622009-06-16 16:11:02 +10004190#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08004191#include <sys/statvfs.h>
4192 ]], [[ fsid_t t; t.__val[0] = 0; ]])],
4193 [ AC_MSG_RESULT([yes])
4194 AC_DEFINE([FSID_HAS___VAL], [1], [fsid_t has member __val]) ],
4195 [ AC_MSG_RESULT([no]) ])
Darren Tucker32780622009-06-16 16:11:02 +10004196])
Darren Tucker77001382008-06-09 06:17:53 +10004197
Kevin Stevesa44e0352002-04-07 16:18:03 +00004198AC_CACHE_CHECK([for msg_control field in struct msghdr],
4199 ac_cv_have_control_in_msghdr, [
Tim Rice648f8762011-01-26 12:38:57 -08004200 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Tim Riceae49fe62002-04-12 10:26:21 -07004201#include <sys/types.h>
Kevin Stevesa44e0352002-04-07 16:18:03 +00004202#include <sys/socket.h>
4203#include <sys/uio.h>
Tim Rice648f8762011-01-26 12:38:57 -08004204 ]], [[
Tim Rice28bbb0c2002-05-27 17:37:32 -07004205#ifdef msg_control
Darren Tuckera0c2b392004-09-11 23:26:37 +10004206#error "msg_control is a macro"
Tim Rice28bbb0c2002-05-27 17:37:32 -07004207exit(1);
4208#endif
4209struct msghdr m;
4210m.msg_control = 0;
4211exit(0);
Tim Rice648f8762011-01-26 12:38:57 -08004212 ]])],
Kevin Stevesa44e0352002-04-07 16:18:03 +00004213 [ ac_cv_have_control_in_msghdr="yes" ],
4214 [ ac_cv_have_control_in_msghdr="no" ]
4215 )
4216])
4217if test "x$ac_cv_have_control_in_msghdr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004218 AC_DEFINE([HAVE_CONTROL_IN_MSGHDR], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004219 [Define if your system uses ancillary data style
4220 file descriptor passing])
Kevin Stevesa44e0352002-04-07 16:18:03 +00004221fi
4222
Damien Miller61e50f12000-05-08 20:49:37 +10004223AC_CACHE_CHECK([if libc defines __progname], ac_cv_libc_defines___progname, [
Tim Rice648f8762011-01-26 12:38:57 -08004224 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
4225 [[ extern char *__progname; printf("%s", __progname); ]])],
4226 [ ac_cv_libc_defines___progname="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004227 [ ac_cv_libc_defines___progname="no"
Tim Rice648f8762011-01-26 12:38:57 -08004228 ])
Damien Miller61e50f12000-05-08 20:49:37 +10004229])
4230if test "x$ac_cv_libc_defines___progname" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004231 AC_DEFINE([HAVE___PROGNAME], [1], [Define if libc defines __progname])
Damien Miller61e50f12000-05-08 20:49:37 +10004232fi
4233
Kevin Steves4846f4a2002-03-22 18:19:53 +00004234AC_CACHE_CHECK([whether $CC implements __FUNCTION__], ac_cv_cc_implements___FUNCTION__, [
Tim Rice648f8762011-01-26 12:38:57 -08004235 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]],
4236 [[ printf("%s", __FUNCTION__); ]])],
4237 [ ac_cv_cc_implements___FUNCTION__="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004238 [ ac_cv_cc_implements___FUNCTION__="no"
Tim Rice648f8762011-01-26 12:38:57 -08004239 ])
Kevin Steves4846f4a2002-03-22 18:19:53 +00004240])
4241if test "x$ac_cv_cc_implements___FUNCTION__" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004242 AC_DEFINE([HAVE___FUNCTION__], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004243 [Define if compiler implements __FUNCTION__])
Kevin Steves4846f4a2002-03-22 18:19:53 +00004244fi
4245
4246AC_CACHE_CHECK([whether $CC implements __func__], ac_cv_cc_implements___func__, [
Tim Rice648f8762011-01-26 12:38:57 -08004247 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]],
4248 [[ printf("%s", __func__); ]])],
4249 [ ac_cv_cc_implements___func__="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004250 [ ac_cv_cc_implements___func__="no"
Tim Rice648f8762011-01-26 12:38:57 -08004251 ])
Kevin Steves4846f4a2002-03-22 18:19:53 +00004252])
4253if test "x$ac_cv_cc_implements___func__" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004254 AC_DEFINE([HAVE___func__], [1], [Define if compiler implements __func__])
Kevin Steves4846f4a2002-03-22 18:19:53 +00004255fi
4256
Damien Miller57f39152005-11-24 19:58:19 +11004257AC_CACHE_CHECK([whether va_copy exists], ac_cv_have_va_copy, [
Tim Rice648f8762011-01-26 12:38:57 -08004258 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4259#include <stdarg.h>
4260va_list x,y;
4261 ]], [[ va_copy(x,y); ]])],
4262 [ ac_cv_have_va_copy="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004263 [ ac_cv_have_va_copy="no"
Tim Rice648f8762011-01-26 12:38:57 -08004264 ])
Damien Miller57f39152005-11-24 19:58:19 +11004265])
4266if test "x$ac_cv_have_va_copy" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004267 AC_DEFINE([HAVE_VA_COPY], [1], [Define if va_copy exists])
Damien Miller57f39152005-11-24 19:58:19 +11004268fi
4269
4270AC_CACHE_CHECK([whether __va_copy exists], ac_cv_have___va_copy, [
Tim Rice648f8762011-01-26 12:38:57 -08004271 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4272#include <stdarg.h>
4273va_list x,y;
4274 ]], [[ __va_copy(x,y); ]])],
Tim Ricee1d93702016-05-31 11:13:22 -07004275 [ ac_cv_have___va_copy="yes" ], [ ac_cv_have___va_copy="no"
Tim Rice648f8762011-01-26 12:38:57 -08004276 ])
Damien Miller57f39152005-11-24 19:58:19 +11004277])
4278if test "x$ac_cv_have___va_copy" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004279 AC_DEFINE([HAVE___VA_COPY], [1], [Define if __va_copy exists])
Damien Miller57f39152005-11-24 19:58:19 +11004280fi
4281
Damien Miller4f8e6692001-07-14 13:22:53 +10004282AC_CACHE_CHECK([whether getopt has optreset support],
4283 ac_cv_have_getopt_optreset, [
Tim Rice648f8762011-01-26 12:38:57 -08004284 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <getopt.h> ]],
4285 [[ extern int optreset; optreset = 0; ]])],
4286 [ ac_cv_have_getopt_optreset="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004287 [ ac_cv_have_getopt_optreset="no"
Tim Rice648f8762011-01-26 12:38:57 -08004288 ])
Damien Miller4f8e6692001-07-14 13:22:53 +10004289])
4290if test "x$ac_cv_have_getopt_optreset" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004291 AC_DEFINE([HAVE_GETOPT_OPTRESET], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004292 [Define if your getopt(3) defines and uses optreset])
Damien Miller4f8e6692001-07-14 13:22:53 +10004293fi
Damien Millera22ba012000-03-02 23:09:20 +11004294
Damien Millerecbb26d2000-07-15 14:59:14 +10004295AC_CACHE_CHECK([if libc defines sys_errlist], ac_cv_libc_defines_sys_errlist, [
Tim Rice648f8762011-01-26 12:38:57 -08004296 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
4297[[ extern const char *const sys_errlist[]; printf("%s", sys_errlist[0]);]])],
4298 [ ac_cv_libc_defines_sys_errlist="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004299 [ ac_cv_libc_defines_sys_errlist="no"
Tim Rice648f8762011-01-26 12:38:57 -08004300 ])
Damien Millerecbb26d2000-07-15 14:59:14 +10004301])
4302if test "x$ac_cv_libc_defines_sys_errlist" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004303 AC_DEFINE([HAVE_SYS_ERRLIST], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004304 [Define if your system defines sys_errlist[]])
Damien Millerecbb26d2000-07-15 14:59:14 +10004305fi
4306
4307
Damien Miller11fa2cc2000-08-16 10:35:58 +10004308AC_CACHE_CHECK([if libc defines sys_nerr], ac_cv_libc_defines_sys_nerr, [
Tim Rice648f8762011-01-26 12:38:57 -08004309 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
4310[[ extern int sys_nerr; printf("%i", sys_nerr);]])],
4311 [ ac_cv_libc_defines_sys_nerr="yes" ],
Tim Ricee1d93702016-05-31 11:13:22 -07004312 [ ac_cv_libc_defines_sys_nerr="no"
Tim Rice648f8762011-01-26 12:38:57 -08004313 ])
Damien Miller11fa2cc2000-08-16 10:35:58 +10004314])
4315if test "x$ac_cv_libc_defines_sys_nerr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004316 AC_DEFINE([HAVE_SYS_NERR], [1], [Define if your system defines sys_nerr])
Damien Miller11fa2cc2000-08-16 10:35:58 +10004317fi
4318
Darren Tucker5f88d342003-10-15 16:57:57 +10004319# Check libraries needed by DNS fingerprint support
Tim Rice648f8762011-01-26 12:38:57 -08004320AC_SEARCH_LIBS([getrrsetbyname], [resolv],
4321 [AC_DEFINE([HAVE_GETRRSETBYNAME], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004322 [Define if getrrsetbyname() exists])],
Damien Miller7abe09b2003-05-15 10:53:49 +10004323 [
Darren Tucker5f88d342003-10-15 16:57:57 +10004324 # Needed by our getrrsetbyname()
Tim Rice648f8762011-01-26 12:38:57 -08004325 AC_SEARCH_LIBS([res_query], [resolv])
4326 AC_SEARCH_LIBS([dn_expand], [resolv])
4327 AC_MSG_CHECKING([if res_query will link])
4328 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckere02b49a2009-09-11 14:56:08 +10004329#include <sys/types.h>
4330#include <netinet/in.h>
4331#include <arpa/nameser.h>
4332#include <netdb.h>
4333#include <resolv.h>
Tim Rice648f8762011-01-26 12:38:57 -08004334 ]], [[
Darren Tuckere02b49a2009-09-11 14:56:08 +10004335 res_query (0, 0, 0, 0, 0);
Tim Rice648f8762011-01-26 12:38:57 -08004336 ]])],
4337 AC_MSG_RESULT([yes]),
4338 [AC_MSG_RESULT([no])
Darren Tucker8e968a52004-05-13 11:56:16 +10004339 saved_LIBS="$LIBS"
4340 LIBS="$LIBS -lresolv"
Tim Rice648f8762011-01-26 12:38:57 -08004341 AC_MSG_CHECKING([for res_query in -lresolv])
4342 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckere02b49a2009-09-11 14:56:08 +10004343#include <sys/types.h>
4344#include <netinet/in.h>
4345#include <arpa/nameser.h>
4346#include <netdb.h>
Darren Tucker8e968a52004-05-13 11:56:16 +10004347#include <resolv.h>
Tim Rice648f8762011-01-26 12:38:57 -08004348 ]], [[
Darren Tucker8e968a52004-05-13 11:56:16 +10004349 res_query (0, 0, 0, 0, 0);
Tim Rice648f8762011-01-26 12:38:57 -08004350 ]])],
4351 [AC_MSG_RESULT([yes])],
Darren Tucker8e968a52004-05-13 11:56:16 +10004352 [LIBS="$saved_LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08004353 AC_MSG_RESULT([no])])
Darren Tucker8e968a52004-05-13 11:56:16 +10004354 ])
Tim Rice648f8762011-01-26 12:38:57 -08004355 AC_CHECK_FUNCS([_getshort _getlong])
Darren Tuckerd886e1c2005-06-01 18:57:45 +10004356 AC_CHECK_DECLS([_getshort, _getlong], , ,
Tim Ricefcc7ff12005-06-02 20:28:29 -07004357 [#include <sys/types.h>
4358 #include <arpa/nameser.h>])
Tim Rice648f8762011-01-26 12:38:57 -08004359 AC_CHECK_MEMBER([HEADER.ad],
4360 [AC_DEFINE([HAVE_HEADER_AD], [1],
4361 [Define if HEADER.ad exists in arpa/nameser.h])], ,
Darren Tucker5f88d342003-10-15 16:57:57 +10004362 [#include <arpa/nameser.h>])
4363 ])
Damien Miller7abe09b2003-05-15 10:53:49 +10004364
Tim Rice648f8762011-01-26 12:38:57 -08004365AC_MSG_CHECKING([if struct __res_state _res is an extern])
4366AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckercc40d5e2007-04-29 13:58:06 +10004367#include <stdio.h>
4368#if HAVE_SYS_TYPES_H
4369# include <sys/types.h>
4370#endif
4371#include <netinet/in.h>
4372#include <arpa/nameser.h>
4373#include <resolv.h>
4374extern struct __res_state _res;
Darren Tucker7ad8b282015-09-11 13:11:02 +10004375 ]], [[
4376struct __res_state *volatile p = &_res; /* force resolution of _res */
4377return 0;
4378 ]],)],
Tim Rice648f8762011-01-26 12:38:57 -08004379 [AC_MSG_RESULT([yes])
4380 AC_DEFINE([HAVE__RES_EXTERN], [1],
Darren Tuckercc40d5e2007-04-29 13:58:06 +10004381 [Define if you have struct __res_state _res as an extern])
4382 ],
Tim Rice648f8762011-01-26 12:38:57 -08004383 [ AC_MSG_RESULT([no]) ]
Darren Tuckercc40d5e2007-04-29 13:58:06 +10004384)
4385
Damien Miller73b42d22006-04-22 21:26:08 +10004386# Check whether user wants SELinux support
4387SELINUX_MSG="no"
4388LIBSELINUX=""
Tim Rice648f8762011-01-26 12:38:57 -08004389AC_ARG_WITH([selinux],
Damien Miller5b1c8b32008-03-27 12:33:07 +11004390 [ --with-selinux Enable SELinux support],
Damien Miller73b42d22006-04-22 21:26:08 +10004391 [ if test "x$withval" != "xno" ; then
Darren Tucker20e9f972007-03-25 18:26:01 +10004392 save_LIBS="$LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08004393 AC_DEFINE([WITH_SELINUX], [1],
4394 [Define if you want SELinux support.])
Damien Miller73b42d22006-04-22 21:26:08 +10004395 SELINUX_MSG="yes"
4396 AC_CHECK_HEADER([selinux/selinux.h], ,
Tim Rice648f8762011-01-26 12:38:57 -08004397 AC_MSG_ERROR([SELinux support requires selinux.h header]))
4398 AC_CHECK_LIB([selinux], [setexeccon],
Damien Miller1d2bfc42010-02-10 10:19:29 +11004399 [ LIBSELINUX="-lselinux"
4400 LIBS="$LIBS -lselinux"
4401 ],
Tim Rice648f8762011-01-26 12:38:57 -08004402 AC_MSG_ERROR([SELinux support requires libselinux library]))
Damien Miller71adf122011-01-25 12:16:15 +11004403 SSHLIBS="$SSHLIBS $LIBSELINUX"
Darren Tucker20e9f972007-03-25 18:26:01 +10004404 SSHDLIBS="$SSHDLIBS $LIBSELINUX"
Tim Rice648f8762011-01-26 12:38:57 -08004405 AC_CHECK_FUNCS([getseuserbyname get_default_context_with_level])
Darren Tuckeradc947d2006-10-07 09:07:20 +10004406 LIBS="$save_LIBS"
Damien Miller73b42d22006-04-22 21:26:08 +10004407 fi ]
4408)
Tim Rice648f8762011-01-26 12:38:57 -08004409AC_SUBST([SSHLIBS])
4410AC_SUBST([SSHDLIBS])
Damien Miller73b42d22006-04-22 21:26:08 +10004411
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004412# Check whether user wants Kerberos 5 support
Damien Millera8e06ce2003-11-21 23:48:55 +11004413KRB5_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08004414AC_ARG_WITH([kerberos5],
Damien Millera8e06ce2003-11-21 23:48:55 +11004415 [ --with-kerberos5=PATH Enable Kerberos 5 support],
Darren Tucker1d3ca582004-01-22 12:05:34 +11004416 [ if test "x$withval" != "xno" ; then
4417 if test "x$withval" = "xyes" ; then
4418 KRB5ROOT="/usr/local"
4419 else
4420 KRB5ROOT=${withval}
4421 fi
4422
Tim Rice648f8762011-01-26 12:38:57 -08004423 AC_DEFINE([KRB5], [1], [Define if you want Kerberos 5 support])
Darren Tucker1d3ca582004-01-22 12:05:34 +11004424 KRB5_MSG="yes"
4425
Darren Tucker4089fc12016-12-08 12:57:24 +11004426 AC_PATH_TOOL([KRB5CONF], [krb5-config],
Darren Tuckerdad48e72009-09-01 18:26:00 +10004427 [$KRB5ROOT/bin/krb5-config],
4428 [$KRB5ROOT/bin:$PATH])
4429 if test -x $KRB5CONF ; then
Darren Tucker964de182013-02-22 10:39:59 +11004430 K5CFLAGS="`$KRB5CONF --cflags`"
4431 K5LIBS="`$KRB5CONF --libs`"
4432 CPPFLAGS="$CPPFLAGS $K5CFLAGS"
Darren Tucker1d3ca582004-01-22 12:05:34 +11004433
Tim Rice648f8762011-01-26 12:38:57 -08004434 AC_MSG_CHECKING([for gssapi support])
Darren Tucker1d3ca582004-01-22 12:05:34 +11004435 if $KRB5CONF | grep gssapi >/dev/null ; then
Tim Rice648f8762011-01-26 12:38:57 -08004436 AC_MSG_RESULT([yes])
4437 AC_DEFINE([GSSAPI], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004438 [Define this if you want GSSAPI
4439 support in the version 2 protocol])
Darren Tucker964de182013-02-22 10:39:59 +11004440 GSSCFLAGS="`$KRB5CONF --cflags gssapi`"
4441 GSSLIBS="`$KRB5CONF --libs gssapi`"
4442 CPPFLAGS="$CPPFLAGS $GSSCFLAGS"
Damien Millera8e06ce2003-11-21 23:48:55 +11004443 else
Tim Rice648f8762011-01-26 12:38:57 -08004444 AC_MSG_RESULT([no])
Damien Millera8e06ce2003-11-21 23:48:55 +11004445 fi
Tim Rice648f8762011-01-26 12:38:57 -08004446 AC_MSG_CHECKING([whether we are using Heimdal])
4447 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <krb5.h>
4448 ]], [[ char *tmp = heimdal_version; ]])],
4449 [ AC_MSG_RESULT([yes])
4450 AC_DEFINE([HEIMDAL], [1],
4451 [Define this if you are using the Heimdal
4452 version of Kerberos V5]) ],
4453 [AC_MSG_RESULT([no])
4454 ])
Darren Tucker1d3ca582004-01-22 12:05:34 +11004455 else
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004456 CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include"
Damien Millera8e06ce2003-11-21 23:48:55 +11004457 LDFLAGS="$LDFLAGS -L${KRB5ROOT}/lib"
Tim Rice648f8762011-01-26 12:38:57 -08004458 AC_MSG_CHECKING([whether we are using Heimdal])
4459 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <krb5.h>
4460 ]], [[ char *tmp = heimdal_version; ]])],
4461 [ AC_MSG_RESULT([yes])
4462 AC_DEFINE([HEIMDAL])
Damien Miller41bccf72011-01-02 21:53:07 +11004463 K5LIBS="-lkrb5"
Damien Miller5561e0b2004-04-20 20:28:55 +10004464 K5LIBS="$K5LIBS -lcom_err -lasn1"
Tim Rice648f8762011-01-26 12:38:57 -08004465 AC_CHECK_LIB([roken], [net_write],
Damien Miller5561e0b2004-04-20 20:28:55 +10004466 [K5LIBS="$K5LIBS -lroken"])
Tim Rice648f8762011-01-26 12:38:57 -08004467 AC_CHECK_LIB([des], [des_cbc_encrypt],
Damien Miller41bccf72011-01-02 21:53:07 +11004468 [K5LIBS="$K5LIBS -ldes"])
Tim Rice648f8762011-01-26 12:38:57 -08004469 ], [ AC_MSG_RESULT([no])
Damien Millera8e06ce2003-11-21 23:48:55 +11004470 K5LIBS="-lkrb5 -lk5crypto -lcom_err"
Tim Rice648f8762011-01-26 12:38:57 -08004471 ])
4472 AC_SEARCH_LIBS([dn_expand], [resolv])
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004473
Tim Rice648f8762011-01-26 12:38:57 -08004474 AC_CHECK_LIB([gssapi_krb5], [gss_init_sec_context],
4475 [ AC_DEFINE([GSSAPI])
Darren Tucker964de182013-02-22 10:39:59 +11004476 GSSLIBS="-lgssapi_krb5" ],
Tim Rice648f8762011-01-26 12:38:57 -08004477 [ AC_CHECK_LIB([gssapi], [gss_init_sec_context],
4478 [ AC_DEFINE([GSSAPI])
Darren Tucker964de182013-02-22 10:39:59 +11004479 GSSLIBS="-lgssapi" ],
Darren Tuckera2b5a4c2013-02-22 10:43:15 +11004480 [ AC_CHECK_LIB([gss], [gss_init_sec_context],
4481 [ AC_DEFINE([GSSAPI])
4482 GSSLIBS="-lgss" ],
4483 AC_MSG_WARN([Cannot find any suitable gss-api library - build may fail]))
4484 ])
Darren Tucker964de182013-02-22 10:39:59 +11004485 ])
Tim Riceeae17cc2005-03-17 16:52:20 -08004486
Tim Rice648f8762011-01-26 12:38:57 -08004487 AC_CHECK_HEADER([gssapi.h], ,
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004488 [ unset ac_cv_header_gssapi_h
Damien Millera8e06ce2003-11-21 23:48:55 +11004489 CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
Tim Rice648f8762011-01-26 12:38:57 -08004490 AC_CHECK_HEADERS([gssapi.h], ,
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004491 AC_MSG_WARN([Cannot find any suitable gss-api header - build may fail])
Damien Millera8e06ce2003-11-21 23:48:55 +11004492 )
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004493 ]
4494 )
4495
4496 oldCPP="$CPPFLAGS"
4497 CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
Tim Rice648f8762011-01-26 12:38:57 -08004498 AC_CHECK_HEADER([gssapi_krb5.h], ,
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004499 [ CPPFLAGS="$oldCPP" ])
4500
Damien Millera8e06ce2003-11-21 23:48:55 +11004501 fi
Darren Tucker2f0bad22019-01-21 21:28:27 +11004502 if test -n "${rpath_opt}" ; then
4503 LDFLAGS="$LDFLAGS ${rpath_opt}${KRB5ROOT}/lib"
Darren Tucker1d3ca582004-01-22 12:05:34 +11004504 fi
4505 if test ! -z "$blibpath" ; then
4506 blibpath="$blibpath:${KRB5ROOT}/lib"
4507 fi
Tim Ricefd9e9e32005-09-12 17:36:10 -07004508
Tim Rice648f8762011-01-26 12:38:57 -08004509 AC_CHECK_HEADERS([gssapi.h gssapi/gssapi.h])
4510 AC_CHECK_HEADERS([gssapi_krb5.h gssapi/gssapi_krb5.h])
4511 AC_CHECK_HEADERS([gssapi_generic.h gssapi/gssapi_generic.h])
Tim Ricefd9e9e32005-09-12 17:36:10 -07004512
Tim Rice648f8762011-01-26 12:38:57 -08004513 AC_SEARCH_LIBS([k_hasafs], [kafs], [AC_DEFINE([USE_AFS], [1],
4514 [Define this if you want to use libkafs' AFS support])])
Darren Tucker03978c62013-02-25 11:24:44 +11004515
4516 AC_CHECK_DECLS([GSS_C_NT_HOSTBASED_SERVICE], [], [], [[
4517#ifdef HAVE_GSSAPI_H
4518# include <gssapi.h>
4519#elif defined(HAVE_GSSAPI_GSSAPI_H)
4520# include <gssapi/gssapi.h>
4521#endif
4522
4523#ifdef HAVE_GSSAPI_GENERIC_H
4524# include <gssapi_generic.h>
4525#elif defined(HAVE_GSSAPI_GSSAPI_GENERIC_H)
4526# include <gssapi/gssapi_generic.h>
4527#endif
4528 ]])
Darren Tuckerf3ab2c52013-08-04 21:48:41 +10004529 saved_LIBS="$LIBS"
4530 LIBS="$LIBS $K5LIBS"
4531 AC_CHECK_FUNCS([krb5_cc_new_unique krb5_get_error_message krb5_free_error_message])
4532 LIBS="$saved_LIBS"
4533
Darren Tucker0d27ed12004-02-24 10:37:33 +11004534 fi
Darren Tucker0d27ed12004-02-24 10:37:33 +11004535 ]
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004536)
Darren Tucker964de182013-02-22 10:39:59 +11004537AC_SUBST([GSSLIBS])
4538AC_SUBST([K5LIBS])
Damien Millerc79bc0d2001-03-28 13:03:42 +10004539
Damien Millera22ba012000-03-02 23:09:20 +11004540# Looking for programs, paths and files
Damien Millera22ba012000-03-02 23:09:20 +11004541
Damien Millerf58c6722002-05-13 13:15:42 +10004542PRIVSEP_PATH=/var/empty
Tim Rice648f8762011-01-26 12:38:57 -08004543AC_ARG_WITH([privsep-path],
Tim Ricecbb90662002-07-08 19:17:10 -07004544 [ --with-privsep-path=xxx Path for privilege separation chroot (default=/var/empty)],
Damien Millerf58c6722002-05-13 13:15:42 +10004545 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004546 if test -n "$withval" && test "x$withval" != "xno" && \
4547 test "x${withval}" != "xyes"; then
Damien Millerf58c6722002-05-13 13:15:42 +10004548 PRIVSEP_PATH=$withval
4549 fi
4550 ]
4551)
Tim Rice648f8762011-01-26 12:38:57 -08004552AC_SUBST([PRIVSEP_PATH])
Damien Millerf58c6722002-05-13 13:15:42 +10004553
Tim Rice648f8762011-01-26 12:38:57 -08004554AC_ARG_WITH([xauth],
Damien Millera22ba012000-03-02 23:09:20 +11004555 [ --with-xauth=PATH Specify path to xauth program ],
4556 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004557 if test -n "$withval" && test "x$withval" != "xno" && \
4558 test "x${withval}" != "xyes"; then
Damien Miller7b22d652000-06-18 14:07:04 +10004559 xauth_path=$withval
Damien Millera22ba012000-03-02 23:09:20 +11004560 fi
4561 ],
4562 [
Tim Ricee22be3b2002-07-17 19:20:07 -07004563 TestPath="$PATH"
4564 TestPath="${TestPath}${PATH_SEPARATOR}/usr/X/bin"
4565 TestPath="${TestPath}${PATH_SEPARATOR}/usr/bin/X11"
4566 TestPath="${TestPath}${PATH_SEPARATOR}/usr/X11R6/bin"
4567 TestPath="${TestPath}${PATH_SEPARATOR}/usr/openwin/bin"
Tim Rice648f8762011-01-26 12:38:57 -08004568 AC_PATH_PROG([xauth_path], [xauth], , [$TestPath])
Damien Milleredb82922000-06-20 13:25:52 +10004569 if (test ! -z "$xauth_path" && test -x "/usr/openwin/bin/xauth") ; then
Damien Millera22ba012000-03-02 23:09:20 +11004570 xauth_path="/usr/openwin/bin/xauth"
4571 fi
4572 ]
4573)
4574
Damien Miller7d901272003-01-13 16:55:22 +11004575STRIP_OPT=-s
Tim Rice648f8762011-01-26 12:38:57 -08004576AC_ARG_ENABLE([strip],
Damien Miller7d901272003-01-13 16:55:22 +11004577 [ --disable-strip Disable calling strip(1) on install],
4578 [
4579 if test "x$enableval" = "xno" ; then
4580 STRIP_OPT=
4581 fi
4582 ]
4583)
Tim Rice648f8762011-01-26 12:38:57 -08004584AC_SUBST([STRIP_OPT])
Damien Miller7d901272003-01-13 16:55:22 +11004585
Damien Millera19cf472000-11-29 13:28:50 +11004586if test -z "$xauth_path" ; then
4587 XAUTH_PATH="undefined"
Tim Rice648f8762011-01-26 12:38:57 -08004588 AC_SUBST([XAUTH_PATH])
Damien Millera19cf472000-11-29 13:28:50 +11004589else
Tim Rice648f8762011-01-26 12:38:57 -08004590 AC_DEFINE_UNQUOTED([XAUTH_PATH], ["$xauth_path"],
Tim Rice7df8d392005-09-19 09:33:39 -07004591 [Define if xauth is found in your path])
Damien Millera19cf472000-11-29 13:28:50 +11004592 XAUTH_PATH=$xauth_path
Tim Rice648f8762011-01-26 12:38:57 -08004593 AC_SUBST([XAUTH_PATH])
Damien Millera22ba012000-03-02 23:09:20 +11004594fi
Damien Millera22ba012000-03-02 23:09:20 +11004595
Tim Rice90f42b02011-06-02 18:17:49 -07004596dnl # --with-maildir=/path/to/mail gets top priority.
4597dnl # if maildir is set in the platform case statement above we use that.
4598dnl # Otherwise we run a program to get the dir from system headers.
4599dnl # We first look for _PATH_MAILDIR then MAILDIR then _PATH_MAIL
4600dnl # If we find _PATH_MAILDIR we do nothing because that is what
4601dnl # session.c expects anyway. Otherwise we set to the value found
4602dnl # stripping any trailing slash. If for some strage reason our program
4603dnl # does not find what it needs, we default to /var/spool/mail.
4604# Check for mail directory
4605AC_ARG_WITH([maildir],
4606 [ --with-maildir=/path/to/mail Specify your system mail directory],
4607 [
4608 if test "X$withval" != X && test "x$withval" != xno && \
4609 test "x${withval}" != xyes; then
4610 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$withval"],
4611 [Set this to your mail directory if you do not have _PATH_MAILDIR])
4612 fi
4613 ],[
4614 if test "X$maildir" != "X"; then
4615 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$maildir"])
4616 else
4617 AC_MSG_CHECKING([Discovering system mail directory])
4618 AC_RUN_IFELSE(
4619 [AC_LANG_PROGRAM([[
4620#include <stdio.h>
4621#include <string.h>
4622#ifdef HAVE_PATHS_H
4623#include <paths.h>
4624#endif
4625#ifdef HAVE_MAILLOCK_H
4626#include <maillock.h>
4627#endif
4628#define DATA "conftest.maildir"
4629 ]], [[
4630 FILE *fd;
4631 int rc;
4632
4633 fd = fopen(DATA,"w");
4634 if(fd == NULL)
4635 exit(1);
4636
4637#if defined (_PATH_MAILDIR)
4638 if ((rc = fprintf(fd ,"_PATH_MAILDIR:%s\n", _PATH_MAILDIR)) <0)
4639 exit(1);
4640#elif defined (MAILDIR)
4641 if ((rc = fprintf(fd ,"MAILDIR:%s\n", MAILDIR)) <0)
4642 exit(1);
4643#elif defined (_PATH_MAIL)
4644 if ((rc = fprintf(fd ,"_PATH_MAIL:%s\n", _PATH_MAIL)) <0)
4645 exit(1);
4646#else
4647 exit (2);
4648#endif
4649
4650 exit(0);
4651 ]])],
4652 [
Tim Ricee1d93702016-05-31 11:13:22 -07004653 maildir_what=`awk -F: '{print $1}' conftest.maildir`
Tim Rice90f42b02011-06-02 18:17:49 -07004654 maildir=`awk -F: '{print $2}' conftest.maildir \
4655 | sed 's|/$||'`
4656 AC_MSG_RESULT([Using: $maildir from $maildir_what])
4657 if test "x$maildir_what" != "x_PATH_MAILDIR"; then
4658 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$maildir"])
4659 fi
4660 ],
4661 [
4662 if test "X$ac_status" = "X2";then
4663# our test program didn't find it. Default to /var/spool/mail
4664 AC_MSG_RESULT([Using: default value of /var/spool/mail])
4665 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["/var/spool/mail"])
4666 else
4667 AC_MSG_RESULT([*** not found ***])
4668 fi
4669 ],
4670 [
4671 AC_MSG_WARN([cross compiling: use --with-maildir=/path/to/mail])
4672 ]
4673 )
4674 fi
4675 ]
4676) # maildir
Damien Millera22ba012000-03-02 23:09:20 +11004677
Darren Tucker623d92f2004-09-12 22:36:15 +10004678if test ! -z "$cross_compiling" && test "x$cross_compiling" = "xyes"; then
Darren Tuckera0c2b392004-09-11 23:26:37 +10004679 AC_MSG_WARN([cross compiling: Disabling /dev/ptmx test])
4680 disable_ptmx_check=yes
4681fi
Damien Millera22ba012000-03-02 23:09:20 +11004682if test -z "$no_dev_ptmx" ; then
Kevin Steves0ea1d9d2002-04-25 18:17:04 +00004683 if test "x$disable_ptmx_check" != "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004684 AC_CHECK_FILE(["/dev/ptmx"],
Kevin Steves0ea1d9d2002-04-25 18:17:04 +00004685 [
Tim Rice648f8762011-01-26 12:38:57 -08004686 AC_DEFINE_UNQUOTED([HAVE_DEV_PTMX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004687 [Define if you have /dev/ptmx])
Kevin Steves0ea1d9d2002-04-25 18:17:04 +00004688 have_dev_ptmx=1
4689 ]
4690 )
4691 fi
Damien Millera22ba012000-03-02 23:09:20 +11004692fi
Darren Tuckera0c2b392004-09-11 23:26:37 +10004693
Darren Tucker623d92f2004-09-12 22:36:15 +10004694if test ! -z "$cross_compiling" && test "x$cross_compiling" != "xyes"; then
Tim Rice648f8762011-01-26 12:38:57 -08004695 AC_CHECK_FILE(["/dev/ptc"],
Darren Tuckera0c2b392004-09-11 23:26:37 +10004696 [
Tim Rice648f8762011-01-26 12:38:57 -08004697 AC_DEFINE_UNQUOTED([HAVE_DEV_PTS_AND_PTC], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004698 [Define if you have /dev/ptc])
Darren Tuckera0c2b392004-09-11 23:26:37 +10004699 have_dev_ptc=1
4700 ]
4701 )
4702else
4703 AC_MSG_WARN([cross compiling: Disabling /dev/ptc test])
4704fi
Damien Miller204ad072000-03-02 23:56:12 +11004705
Damien Millera22ba012000-03-02 23:09:20 +11004706# Options from here on. Some of these are preset by platform above
Tim Rice648f8762011-01-26 12:38:57 -08004707AC_ARG_WITH([mantype],
Damien Miller897741e2001-04-16 10:41:46 +10004708 [ --with-mantype=man|cat|doc Set man page type],
Damien Miller670a4b82000-01-22 13:53:11 +11004709 [
Damien Miller897741e2001-04-16 10:41:46 +10004710 case "$withval" in
4711 man|cat|doc)
4712 MANTYPE=$withval
4713 ;;
4714 *)
Tim Rice648f8762011-01-26 12:38:57 -08004715 AC_MSG_ERROR([invalid man type: $withval])
Damien Miller897741e2001-04-16 10:41:46 +10004716 ;;
4717 esac
Damien Miller670a4b82000-01-22 13:53:11 +11004718 ]
4719)
Ben Lindstrombc709922001-04-18 18:04:21 +00004720if test -z "$MANTYPE"; then
Darren Tucker285546b2019-05-10 15:04:42 +10004721 if ${MANDOC} ${srcdir}/ssh.1 >/dev/null 2>&1; then
4722 MANTYPE=doc
4723 elif ${NROFF} -mdoc ${srcdir}/ssh.1 >/dev/null 2>&1; then
Ben Lindstrombc709922001-04-18 18:04:21 +00004724 MANTYPE=doc
4725 elif ${NROFF} -man ${srcdir}/ssh.1 >/dev/null 2>&1; then
4726 MANTYPE=man
4727 else
4728 MANTYPE=cat
4729 fi
4730fi
Tim Rice648f8762011-01-26 12:38:57 -08004731AC_SUBST([MANTYPE])
Ben Lindstrombc709922001-04-18 18:04:21 +00004732if test "$MANTYPE" = "doc"; then
4733 mansubdir=man;
4734else
4735 mansubdir=$MANTYPE;
4736fi
Tim Rice648f8762011-01-26 12:38:57 -08004737AC_SUBST([mansubdir])
Damien Miller8bdeee21999-12-30 15:50:54 +11004738
Damien Millera22ba012000-03-02 23:09:20 +11004739# Check whether to enable MD5 passwords
Damien Millera8e06ce2003-11-21 23:48:55 +11004740MD5_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08004741AC_ARG_WITH([md5-passwords],
Damien Millerdd1c7ba1999-11-19 15:53:20 +11004742 [ --with-md5-passwords Enable use of MD5 passwords],
Damien Miller8bdeee21999-12-30 15:50:54 +11004743 [
Damien Millerb85dcad2000-03-11 11:37:00 +11004744 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004745 AC_DEFINE([HAVE_MD5_PASSWORDS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004746 [Define if you want to allow MD5 passwords])
Damien Millera8e06ce2003-11-21 23:48:55 +11004747 MD5_MSG="yes"
Damien Miller8bdeee21999-12-30 15:50:54 +11004748 fi
4749 ]
Damien Millerdd1c7ba1999-11-19 15:53:20 +11004750)
4751
Damien Millera22ba012000-03-02 23:09:20 +11004752# Whether to disable shadow password support
Tim Rice648f8762011-01-26 12:38:57 -08004753AC_ARG_WITH([shadow],
Damien Miller76112de1999-12-21 11:18:08 +11004754 [ --without-shadow Disable shadow password support],
4755 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004756 if test "x$withval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004757 AC_DEFINE([DISABLE_SHADOW])
Damien Miller1f335fb2000-06-26 11:31:33 +10004758 disable_shadow=yes
Damien Miller76112de1999-12-21 11:18:08 +11004759 fi
4760 ]
4761)
4762
Damien Miller1f335fb2000-06-26 11:31:33 +10004763if test -z "$disable_shadow" ; then
4764 AC_MSG_CHECKING([if the systems has expire shadow information])
Tim Rice648f8762011-01-26 12:38:57 -08004765 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller1f335fb2000-06-26 11:31:33 +10004766#include <sys/types.h>
4767#include <shadow.h>
Tim Rice648f8762011-01-26 12:38:57 -08004768struct spwd sp;
4769 ]], [[ sp.sp_expire = sp.sp_lstchg = sp.sp_inact = 0; ]])],
4770 [ sp_expire_available=yes ], [
4771 ])
Damien Miller1f335fb2000-06-26 11:31:33 +10004772
4773 if test "x$sp_expire_available" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004774 AC_MSG_RESULT([yes])
4775 AC_DEFINE([HAS_SHADOW_EXPIRE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004776 [Define if you want to use shadow password expire field])
Damien Miller1f335fb2000-06-26 11:31:33 +10004777 else
Tim Rice648f8762011-01-26 12:38:57 -08004778 AC_MSG_RESULT([no])
Damien Miller1f335fb2000-06-26 11:31:33 +10004779 fi
4780fi
4781
Damien Millera22ba012000-03-02 23:09:20 +11004782# Use ip address instead of hostname in $DISPLAY
Damien Miller9a947342000-08-30 10:03:33 +11004783if test ! -z "$IPADDR_IN_DISPLAY" ; then
4784 DISPLAY_HACK_MSG="yes"
Tim Rice648f8762011-01-26 12:38:57 -08004785 AC_DEFINE([IPADDR_IN_DISPLAY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004786 [Define if you need to use IP address
4787 instead of hostname in $DISPLAY])
Damien Miller9a947342000-08-30 10:03:33 +11004788else
Damien Millera8e06ce2003-11-21 23:48:55 +11004789 DISPLAY_HACK_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08004790 AC_ARG_WITH([ipaddr-display],
Tim Rice6397eed2015-06-03 21:41:11 -07004791 [ --with-ipaddr-display Use ip address instead of hostname in $DISPLAY],
Damien Miller9a947342000-08-30 10:03:33 +11004792 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004793 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004794 AC_DEFINE([IPADDR_IN_DISPLAY])
Damien Millera8e06ce2003-11-21 23:48:55 +11004795 DISPLAY_HACK_MSG="yes"
Damien Miller9a947342000-08-30 10:03:33 +11004796 fi
4797 ]
4798 )
4799fi
Damien Miller76112de1999-12-21 11:18:08 +11004800
Darren Tuckere1a790d2003-09-16 11:52:19 +10004801# check for /etc/default/login and use it if present.
Tim Rice648f8762011-01-26 12:38:57 -08004802AC_ARG_ENABLE([etc-default-login],
Darren Tucker1b6f2292005-02-11 16:11:49 +11004803 [ --disable-etc-default-login Disable using PATH from /etc/default/login [no]],
Darren Tucker2f9573d2005-02-10 22:28:54 +11004804 [ if test "x$enableval" = "xno"; then
4805 AC_MSG_NOTICE([/etc/default/login handling disabled])
4806 etc_default_login=no
4807 else
4808 etc_default_login=yes
4809 fi ],
Darren Tucker314d89e2005-10-17 23:29:23 +10004810 [ if test ! -z "$cross_compiling" && test "x$cross_compiling" = "xyes";
4811 then
4812 AC_MSG_WARN([cross compiling: not checking /etc/default/login])
4813 etc_default_login=no
4814 else
4815 etc_default_login=yes
4816 fi ]
Darren Tucker2f9573d2005-02-10 22:28:54 +11004817)
Darren Tuckere1a790d2003-09-16 11:52:19 +10004818
Darren Tucker2f9573d2005-02-10 22:28:54 +11004819if test "x$etc_default_login" != "xno"; then
Tim Rice648f8762011-01-26 12:38:57 -08004820 AC_CHECK_FILE(["/etc/default/login"],
Darren Tucker2f9573d2005-02-10 22:28:54 +11004821 [ external_path_file=/etc/default/login ])
Darren Tucker314d89e2005-10-17 23:29:23 +10004822 if test "x$external_path_file" = "x/etc/default/login"; then
Tim Rice648f8762011-01-26 12:38:57 -08004823 AC_DEFINE([HAVE_ETC_DEFAULT_LOGIN], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004824 [Define if your system has /etc/default/login])
Darren Tuckera0c2b392004-09-11 23:26:37 +10004825 fi
Darren Tucker2f9573d2005-02-10 22:28:54 +11004826fi
Darren Tuckere1a790d2003-09-16 11:52:19 +10004827
Tim Rice43a1c132002-04-17 21:19:14 -07004828dnl BSD systems use /etc/login.conf so --with-default-path= has no effect
Tim Rice8bb561b2005-03-17 16:23:19 -08004829if test $ac_cv_func_login_getcapbool = "yes" && \
4830 test $ac_cv_header_login_cap_h = "yes" ; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10004831 external_path_file=/etc/login.conf
Tim Rice43a1c132002-04-17 21:19:14 -07004832fi
Darren Tuckere1a790d2003-09-16 11:52:19 +10004833
Damien Millera22ba012000-03-02 23:09:20 +11004834# Whether to mess with the default path
Damien Millera8e06ce2003-11-21 23:48:55 +11004835SERVER_PATH_MSG="(default)"
Tim Rice648f8762011-01-26 12:38:57 -08004836AC_ARG_WITH([default-path],
Tim Rice6397eed2015-06-03 21:41:11 -07004837 [ --with-default-path= Specify default $PATH environment for server],
Damien Miller5a3e6831999-12-27 09:48:56 +11004838 [
Darren Tuckere1a790d2003-09-16 11:52:19 +10004839 if test "x$external_path_file" = "x/etc/login.conf" ; then
Tim Rice43a1c132002-04-17 21:19:14 -07004840 AC_MSG_WARN([
4841--with-default-path=PATH has no effect on this system.
4842Edit /etc/login.conf instead.])
Tim Riceeae17cc2005-03-17 16:52:20 -08004843 elif test "x$withval" != "xno" ; then
Tim Riceb925b4b2003-09-15 22:40:49 -07004844 if test ! -z "$external_path_file" ; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10004845 AC_MSG_WARN([
4846--with-default-path=PATH will only be used if PATH is not defined in
4847$external_path_file .])
4848 fi
Tim Rice59ea0a02001-03-10 13:50:45 -08004849 user_path="$withval"
Damien Millera8e06ce2003-11-21 23:48:55 +11004850 SERVER_PATH_MSG="$withval"
Damien Miller5a3e6831999-12-27 09:48:56 +11004851 fi
Tim Rice59ea0a02001-03-10 13:50:45 -08004852 ],
Darren Tuckere1a790d2003-09-16 11:52:19 +10004853 [ if test "x$external_path_file" = "x/etc/login.conf" ; then
4854 AC_MSG_WARN([Make sure the path to scp is in /etc/login.conf])
Tim Rice43a1c132002-04-17 21:19:14 -07004855 else
Tim Riceb925b4b2003-09-15 22:40:49 -07004856 if test ! -z "$external_path_file" ; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10004857 AC_MSG_WARN([
4858If PATH is defined in $external_path_file, ensure the path to scp is included,
4859otherwise scp will not work.])
4860 fi
Darren Tucker314d89e2005-10-17 23:29:23 +10004861 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08004862 [AC_LANG_PROGRAM([[
Tim Rice59ea0a02001-03-10 13:50:45 -08004863/* find out what STDPATH is */
4864#include <stdio.h>
Tim Rice59ea0a02001-03-10 13:50:45 -08004865#ifdef HAVE_PATHS_H
4866# include <paths.h>
4867#endif
4868#ifndef _PATH_STDPATH
Tim Rice1c9e6882002-11-22 13:29:01 -08004869# ifdef _PATH_USERPATH /* Irix */
4870# define _PATH_STDPATH _PATH_USERPATH
4871# else
4872# define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
4873# endif
Tim Rice59ea0a02001-03-10 13:50:45 -08004874#endif
4875#include <sys/types.h>
4876#include <sys/stat.h>
4877#include <fcntl.h>
4878#define DATA "conftest.stdpath"
Tim Rice648f8762011-01-26 12:38:57 -08004879 ]], [[
Tim Rice59ea0a02001-03-10 13:50:45 -08004880 FILE *fd;
4881 int rc;
Tim Riceeae17cc2005-03-17 16:52:20 -08004882
Tim Rice59ea0a02001-03-10 13:50:45 -08004883 fd = fopen(DATA,"w");
4884 if(fd == NULL)
4885 exit(1);
Tim Riceeae17cc2005-03-17 16:52:20 -08004886
Tim Rice59ea0a02001-03-10 13:50:45 -08004887 if ((rc = fprintf(fd,"%s", _PATH_STDPATH)) < 0)
4888 exit(1);
4889
4890 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10004891 ]])],
4892 [ user_path=`cat conftest.stdpath` ],
Tim Rice59ea0a02001-03-10 13:50:45 -08004893 [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ],
4894 [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ]
4895 )
4896# make sure $bindir is in USER_PATH so scp will work
Damien Miller77eab7b2012-07-06 11:49:28 +10004897 t_bindir="${bindir}"
4898 while echo "${t_bindir}" | egrep '\$\{|NONE/' >/dev/null 2>&1; do
4899 t_bindir=`eval echo ${t_bindir}`
4900 case $t_bindir in
4901 NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$prefix~"` ;;
4902 esac
4903 case $t_bindir in
4904 NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$ac_default_prefix~"` ;;
4905 esac
4906 done
Tim Rice59ea0a02001-03-10 13:50:45 -08004907 echo $user_path | grep ":$t_bindir" > /dev/null 2>&1
4908 if test $? -ne 0 ; then
4909 echo $user_path | grep "^$t_bindir" > /dev/null 2>&1
4910 if test $? -ne 0 ; then
4911 user_path=$user_path:$t_bindir
Tim Rice648f8762011-01-26 12:38:57 -08004912 AC_MSG_RESULT([Adding $t_bindir to USER_PATH so scp will work])
Tim Rice59ea0a02001-03-10 13:50:45 -08004913 fi
4914 fi
Tim Rice43a1c132002-04-17 21:19:14 -07004915 fi ]
Damien Miller5a3e6831999-12-27 09:48:56 +11004916)
Darren Tuckere1a790d2003-09-16 11:52:19 +10004917if test "x$external_path_file" != "x/etc/login.conf" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004918 AC_DEFINE_UNQUOTED([USER_PATH], ["$user_path"], [Specify default $PATH])
4919 AC_SUBST([user_path])
Tim Rice43a1c132002-04-17 21:19:14 -07004920fi
Damien Miller5a3e6831999-12-27 09:48:56 +11004921
Damien Millera18bbd32002-05-13 10:48:57 +10004922# Set superuser path separately to user path
Tim Rice648f8762011-01-26 12:38:57 -08004923AC_ARG_WITH([superuser-path],
Damien Millera18bbd32002-05-13 10:48:57 +10004924 [ --with-superuser-path= Specify different path for super-user],
4925 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004926 if test -n "$withval" && test "x$withval" != "xno" && \
4927 test "x${withval}" != "xyes"; then
Tim Rice648f8762011-01-26 12:38:57 -08004928 AC_DEFINE_UNQUOTED([SUPERUSER_PATH], ["$withval"],
Tim Rice7df8d392005-09-19 09:33:39 -07004929 [Define if you want a different $PATH
4930 for the superuser])
Damien Millera18bbd32002-05-13 10:48:57 +10004931 superuser_path=$withval
4932 fi
4933 ]
4934)
4935
4936
Damien Miller61e50f12000-05-08 20:49:37 +10004937AC_MSG_CHECKING([if we need to convert IPv4 in IPv6-mapped addresses])
Damien Millera8e06ce2003-11-21 23:48:55 +11004938IPV4_IN6_HACK_MSG="no"
Damien Miller7bcb0892000-03-11 20:45:40 +11004939AC_ARG_WITH(4in6,
4940 [ --with-4in6 Check for and convert IPv4 in IPv6 mapped addresses],
4941 [
4942 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004943 AC_MSG_RESULT([yes])
4944 AC_DEFINE([IPV4_IN_IPV6], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004945 [Detect IPv4 in IPv6 mapped addresses
4946 and treat as IPv4])
Damien Millera8e06ce2003-11-21 23:48:55 +11004947 IPV4_IN6_HACK_MSG="yes"
Damien Miller7bcb0892000-03-11 20:45:40 +11004948 else
Tim Rice648f8762011-01-26 12:38:57 -08004949 AC_MSG_RESULT([no])
Damien Miller7bcb0892000-03-11 20:45:40 +11004950 fi
Tim Rice648f8762011-01-26 12:38:57 -08004951 ], [
Damien Miller7bcb0892000-03-11 20:45:40 +11004952 if test "x$inet6_default_4in6" = "xyes"; then
4953 AC_MSG_RESULT([yes (default)])
Tim Rice648f8762011-01-26 12:38:57 -08004954 AC_DEFINE([IPV4_IN_IPV6])
Damien Millera8e06ce2003-11-21 23:48:55 +11004955 IPV4_IN6_HACK_MSG="yes"
Damien Miller7bcb0892000-03-11 20:45:40 +11004956 else
4957 AC_MSG_RESULT([no (default)])
4958 fi
4959 ]
4960)
4961
Damien Miller60396b02001-02-18 17:01:00 +11004962# Whether to enable BSD auth support
Damien Miller6c21c512002-01-22 21:57:53 +11004963BSD_AUTH_MSG=no
Tim Rice648f8762011-01-26 12:38:57 -08004964AC_ARG_WITH([bsd-auth],
Damien Miller60396b02001-02-18 17:01:00 +11004965 [ --with-bsd-auth Enable BSD auth support],
4966 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004967 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004968 AC_DEFINE([BSD_AUTH], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004969 [Define if you have BSD auth support])
Damien Miller6c21c512002-01-22 21:57:53 +11004970 BSD_AUTH_MSG=yes
Damien Miller60396b02001-02-18 17:01:00 +11004971 fi
4972 ]
4973)
4974
Damien Millera22ba012000-03-02 23:09:20 +11004975# Where to place sshd.pid
Damien Millerb13c73e2000-01-17 22:02:17 +11004976piddir=/var/run
Damien Miller78315eb2000-09-29 23:01:36 +11004977# make sure the directory exists
Tim Riceeae17cc2005-03-17 16:52:20 -08004978if test ! -d $piddir ; then
Damien Miller78315eb2000-09-29 23:01:36 +11004979 piddir=`eval echo ${sysconfdir}`
4980 case $piddir in
Damien Millera8e06ce2003-11-21 23:48:55 +11004981 NONE/*) piddir=`echo $piddir | sed "s~NONE~$ac_default_prefix~"` ;;
Damien Miller78315eb2000-09-29 23:01:36 +11004982 esac
4983fi
4984
Tim Rice648f8762011-01-26 12:38:57 -08004985AC_ARG_WITH([pid-dir],
Darren Tucker075e2582018-02-13 17:36:43 +11004986 [ --with-pid-dir=PATH Specify location of sshd.pid file],
Tim Rice88f2ab52002-03-17 12:17:34 -08004987 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004988 if test -n "$withval" && test "x$withval" != "xno" && \
4989 test "x${withval}" != "xyes"; then
Tim Rice88f2ab52002-03-17 12:17:34 -08004990 piddir=$withval
Tim Riceeae17cc2005-03-17 16:52:20 -08004991 if test ! -d $piddir ; then
Tim Rice88f2ab52002-03-17 12:17:34 -08004992 AC_MSG_WARN([** no $piddir directory on this system **])
4993 fi
4994 fi
4995 ]
4996)
4997
Tim Ricee1d93702016-05-31 11:13:22 -07004998AC_DEFINE_UNQUOTED([_PATH_SSH_PIDDIR], ["$piddir"],
Tim Rice648f8762011-01-26 12:38:57 -08004999 [Specify location of ssh.pid])
5000AC_SUBST([piddir])
Damien Miller5eed6a22000-01-16 12:05:18 +11005001
andre2ff7b5d2000-06-03 14:57:40 +00005002dnl allow user to disable some login recording features
Tim Rice648f8762011-01-26 12:38:57 -08005003AC_ARG_ENABLE([lastlog],
andre43ca7e22000-06-19 08:23:46 +00005004 [ --disable-lastlog disable use of lastlog even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10005005 [
5006 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08005007 AC_DEFINE([DISABLE_LASTLOG])
Darren Tuckera3020db2003-06-28 12:54:33 +10005008 fi
5009 ]
andre2ff7b5d2000-06-03 14:57:40 +00005010)
Tim Rice648f8762011-01-26 12:38:57 -08005011AC_ARG_ENABLE([utmp],
andre43ca7e22000-06-19 08:23:46 +00005012 [ --disable-utmp disable use of utmp even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10005013 [
5014 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08005015 AC_DEFINE([DISABLE_UTMP])
Darren Tuckera3020db2003-06-28 12:54:33 +10005016 fi
5017 ]
andre2ff7b5d2000-06-03 14:57:40 +00005018)
Tim Rice648f8762011-01-26 12:38:57 -08005019AC_ARG_ENABLE([utmpx],
andre43ca7e22000-06-19 08:23:46 +00005020 [ --disable-utmpx disable use of utmpx even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10005021 [
5022 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08005023 AC_DEFINE([DISABLE_UTMPX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07005024 [Define if you don't want to use utmpx])
Darren Tuckera3020db2003-06-28 12:54:33 +10005025 fi
5026 ]
andre2ff7b5d2000-06-03 14:57:40 +00005027)
Tim Rice648f8762011-01-26 12:38:57 -08005028AC_ARG_ENABLE([wtmp],
andre43ca7e22000-06-19 08:23:46 +00005029 [ --disable-wtmp disable use of wtmp even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10005030 [
5031 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08005032 AC_DEFINE([DISABLE_WTMP])
Darren Tuckera3020db2003-06-28 12:54:33 +10005033 fi
5034 ]
andre2ff7b5d2000-06-03 14:57:40 +00005035)
Tim Rice648f8762011-01-26 12:38:57 -08005036AC_ARG_ENABLE([wtmpx],
andre43ca7e22000-06-19 08:23:46 +00005037 [ --disable-wtmpx disable use of wtmpx even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10005038 [
5039 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08005040 AC_DEFINE([DISABLE_WTMPX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07005041 [Define if you don't want to use wtmpx])
Darren Tuckera3020db2003-06-28 12:54:33 +10005042 fi
5043 ]
andre2ff7b5d2000-06-03 14:57:40 +00005044)
Tim Rice648f8762011-01-26 12:38:57 -08005045AC_ARG_ENABLE([libutil],
andre43ca7e22000-06-19 08:23:46 +00005046 [ --disable-libutil disable use of libutil (login() etc.) [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10005047 [
5048 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08005049 AC_DEFINE([DISABLE_LOGIN])
Darren Tuckera3020db2003-06-28 12:54:33 +10005050 fi
5051 ]
andre2ff7b5d2000-06-03 14:57:40 +00005052)
Tim Rice648f8762011-01-26 12:38:57 -08005053AC_ARG_ENABLE([pututline],
andre43ca7e22000-06-19 08:23:46 +00005054 [ --disable-pututline disable use of pututline() etc. ([uw]tmp) [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10005055 [
5056 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08005057 AC_DEFINE([DISABLE_PUTUTLINE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07005058 [Define if you don't want to use pututline()
5059 etc. to write [uw]tmp])
Darren Tuckera3020db2003-06-28 12:54:33 +10005060 fi
5061 ]
andre2ff7b5d2000-06-03 14:57:40 +00005062)
Tim Rice648f8762011-01-26 12:38:57 -08005063AC_ARG_ENABLE([pututxline],
andre43ca7e22000-06-19 08:23:46 +00005064 [ --disable-pututxline disable use of pututxline() etc. ([uw]tmpx) [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10005065 [
5066 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08005067 AC_DEFINE([DISABLE_PUTUTXLINE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07005068 [Define if you don't want to use pututxline()
5069 etc. to write [uw]tmpx])
Darren Tuckera3020db2003-06-28 12:54:33 +10005070 fi
5071 ]
andre2ff7b5d2000-06-03 14:57:40 +00005072)
Tim Rice648f8762011-01-26 12:38:57 -08005073AC_ARG_WITH([lastlog],
andre43ca7e22000-06-19 08:23:46 +00005074 [ --with-lastlog=FILE|DIR specify lastlog location [common locations]],
Damien Miller709528a2001-01-31 09:57:55 +11005075 [
Tim Riceeae17cc2005-03-17 16:52:20 -08005076 if test "x$withval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08005077 AC_DEFINE([DISABLE_LASTLOG])
Tim Rice35cc69d2005-03-17 16:44:25 -08005078 elif test -n "$withval" && test "x${withval}" != "xyes"; then
Damien Miller709528a2001-01-31 09:57:55 +11005079 conf_lastlog_location=$withval
5080 fi
5081 ]
5082)
andre2ff7b5d2000-06-03 14:57:40 +00005083
5084dnl lastlog, [uw]tmpx? detection
5085dnl NOTE: set the paths in the platform section to avoid the
5086dnl need for command-line parameters
5087dnl lastlog and [uw]tmp are subject to a file search if all else fails
5088
5089dnl lastlog detection
5090dnl NOTE: the code itself will detect if lastlog is a directory
5091AC_MSG_CHECKING([if your system defines LASTLOG_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08005092AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00005093#include <sys/types.h>
5094#include <utmp.h>
5095#ifdef HAVE_LASTLOG_H
5096# include <lastlog.h>
5097#endif
Damien Miller2994e082000-06-04 15:51:47 +10005098#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00005099# include <paths.h>
5100#endif
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00005101#ifdef HAVE_LOGIN_H
5102# include <login.h>
5103#endif
Tim Rice648f8762011-01-26 12:38:57 -08005104 ]], [[ char *lastlog = LASTLOG_FILE; ]])],
5105 [ AC_MSG_RESULT([yes]) ],
5106 [
5107 AC_MSG_RESULT([no])
Damien Miller2994e082000-06-04 15:51:47 +10005108 AC_MSG_CHECKING([if your system defines _PATH_LASTLOG])
Tim Rice648f8762011-01-26 12:38:57 -08005109 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller2994e082000-06-04 15:51:47 +10005110#include <sys/types.h>
5111#include <utmp.h>
5112#ifdef HAVE_LASTLOG_H
5113# include <lastlog.h>
5114#endif
5115#ifdef HAVE_PATHS_H
5116# include <paths.h>
5117#endif
Tim Rice648f8762011-01-26 12:38:57 -08005118 ]], [[ char *lastlog = _PATH_LASTLOG; ]])],
5119 [ AC_MSG_RESULT([yes]) ],
Damien Miller2994e082000-06-04 15:51:47 +10005120 [
Tim Rice648f8762011-01-26 12:38:57 -08005121 AC_MSG_RESULT([no])
Damien Miller2994e082000-06-04 15:51:47 +10005122 system_lastlog_path=no
5123 ])
Tim Rice648f8762011-01-26 12:38:57 -08005124])
Damien Miller2994e082000-06-04 15:51:47 +10005125
andre2ff7b5d2000-06-03 14:57:40 +00005126if test -z "$conf_lastlog_location"; then
5127 if test x"$system_lastlog_path" = x"no" ; then
5128 for f in /var/log/lastlog /usr/adm/lastlog /var/adm/lastlog /etc/security/lastlog ; do
Damien Milleredb82922000-06-20 13:25:52 +10005129 if (test -d "$f" || test -f "$f") ; then
andre2ff7b5d2000-06-03 14:57:40 +00005130 conf_lastlog_location=$f
5131 fi
5132 done
5133 if test -z "$conf_lastlog_location"; then
andre45cad512000-06-12 23:27:31 +00005134 AC_MSG_WARN([** Cannot find lastlog **])
5135 dnl Don't define DISABLE_LASTLOG - that means we don't try wtmp/wtmpx
andre2ff7b5d2000-06-03 14:57:40 +00005136 fi
5137 fi
5138fi
5139
5140if test -n "$conf_lastlog_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08005141 AC_DEFINE_UNQUOTED([CONF_LASTLOG_FILE], ["$conf_lastlog_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07005142 [Define if you want to specify the path to your lastlog file])
Tim Riceeae17cc2005-03-17 16:52:20 -08005143fi
andre2ff7b5d2000-06-03 14:57:40 +00005144
5145dnl utmp detection
5146AC_MSG_CHECKING([if your system defines UTMP_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08005147AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00005148#include <sys/types.h>
5149#include <utmp.h>
Damien Miller2994e082000-06-04 15:51:47 +10005150#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00005151# include <paths.h>
5152#endif
Tim Rice648f8762011-01-26 12:38:57 -08005153 ]], [[ char *utmp = UTMP_FILE; ]])],
5154 [ AC_MSG_RESULT([yes]) ],
5155 [ AC_MSG_RESULT([no])
Tim Ricee1d93702016-05-31 11:13:22 -07005156 system_utmp_path=no
Tim Rice648f8762011-01-26 12:38:57 -08005157])
andre2ff7b5d2000-06-03 14:57:40 +00005158if test -z "$conf_utmp_location"; then
5159 if test x"$system_utmp_path" = x"no" ; then
5160 for f in /etc/utmp /usr/adm/utmp /var/run/utmp; do
5161 if test -f $f ; then
5162 conf_utmp_location=$f
5163 fi
5164 done
5165 if test -z "$conf_utmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08005166 AC_DEFINE([DISABLE_UTMP])
andre2ff7b5d2000-06-03 14:57:40 +00005167 fi
5168 fi
5169fi
5170if test -n "$conf_utmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08005171 AC_DEFINE_UNQUOTED([CONF_UTMP_FILE], ["$conf_utmp_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07005172 [Define if you want to specify the path to your utmp file])
Tim Riceeae17cc2005-03-17 16:52:20 -08005173fi
andre2ff7b5d2000-06-03 14:57:40 +00005174
5175dnl wtmp detection
5176AC_MSG_CHECKING([if your system defines WTMP_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08005177AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00005178#include <sys/types.h>
5179#include <utmp.h>
Damien Miller2994e082000-06-04 15:51:47 +10005180#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00005181# include <paths.h>
5182#endif
Tim Rice648f8762011-01-26 12:38:57 -08005183 ]], [[ char *wtmp = WTMP_FILE; ]])],
5184 [ AC_MSG_RESULT([yes]) ],
5185 [ AC_MSG_RESULT([no])
Tim Ricee1d93702016-05-31 11:13:22 -07005186 system_wtmp_path=no
Tim Rice648f8762011-01-26 12:38:57 -08005187])
andre2ff7b5d2000-06-03 14:57:40 +00005188if test -z "$conf_wtmp_location"; then
5189 if test x"$system_wtmp_path" = x"no" ; then
5190 for f in /usr/adm/wtmp /var/log/wtmp; do
5191 if test -f $f ; then
5192 conf_wtmp_location=$f
5193 fi
5194 done
5195 if test -z "$conf_wtmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08005196 AC_DEFINE([DISABLE_WTMP])
andre2ff7b5d2000-06-03 14:57:40 +00005197 fi
5198 fi
5199fi
5200if test -n "$conf_wtmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08005201 AC_DEFINE_UNQUOTED([CONF_WTMP_FILE], ["$conf_wtmp_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07005202 [Define if you want to specify the path to your wtmp file])
Tim Riceeae17cc2005-03-17 16:52:20 -08005203fi
andre2ff7b5d2000-06-03 14:57:40 +00005204
andre2ff7b5d2000-06-03 14:57:40 +00005205dnl wtmpx detection
5206AC_MSG_CHECKING([if your system defines WTMPX_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08005207AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00005208#include <sys/types.h>
5209#include <utmp.h>
5210#ifdef HAVE_UTMPX_H
5211#include <utmpx.h>
5212#endif
Damien Miller2994e082000-06-04 15:51:47 +10005213#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00005214# include <paths.h>
5215#endif
Tim Rice648f8762011-01-26 12:38:57 -08005216 ]], [[ char *wtmpx = WTMPX_FILE; ]])],
5217 [ AC_MSG_RESULT([yes]) ],
5218 [ AC_MSG_RESULT([no])
Tim Ricee1d93702016-05-31 11:13:22 -07005219 system_wtmpx_path=no
Tim Rice648f8762011-01-26 12:38:57 -08005220])
andre2ff7b5d2000-06-03 14:57:40 +00005221if test -z "$conf_wtmpx_location"; then
5222 if test x"$system_wtmpx_path" = x"no" ; then
Tim Rice648f8762011-01-26 12:38:57 -08005223 AC_DEFINE([DISABLE_WTMPX])
andre2ff7b5d2000-06-03 14:57:40 +00005224 fi
5225else
Tim Rice648f8762011-01-26 12:38:57 -08005226 AC_DEFINE_UNQUOTED([CONF_WTMPX_FILE], ["$conf_wtmpx_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07005227 [Define if you want to specify the path to your wtmpx file])
Tim Riceeae17cc2005-03-17 16:52:20 -08005228fi
andre2ff7b5d2000-06-03 14:57:40 +00005229
Damien Miller4018c192000-04-30 09:30:44 +10005230
Damien Miller29ea30d2000-03-17 10:54:15 +11005231if test ! -z "$blibpath" ; then
Damien Millereab4bae2003-04-29 23:22:40 +10005232 LDFLAGS="$LDFLAGS $blibflags$blibpath"
5233 AC_MSG_WARN([Please check and edit blibpath in LDFLAGS in Makefile])
Damien Miller29ea30d2000-03-17 10:54:15 +11005234fi
5235
Damien Millera2438bb2013-03-15 10:23:07 +11005236AC_CHECK_MEMBER([struct lastlog.ll_line], [], [
Tim Riceaa86c392013-03-16 20:55:46 -07005237 if test x$SKIP_DISABLE_LASTLOG_DEFINE != "xyes" ; then
Damien Millera2438bb2013-03-15 10:23:07 +11005238 AC_DEFINE([DISABLE_LASTLOG])
Tim Riceaa86c392013-03-16 20:55:46 -07005239 fi
Damien Millera2438bb2013-03-15 10:23:07 +11005240 ], [
5241#ifdef HAVE_SYS_TYPES_H
5242#include <sys/types.h>
5243#endif
5244#ifdef HAVE_UTMP_H
5245#include <utmp.h>
5246#endif
5247#ifdef HAVE_UTMPX_H
5248#include <utmpx.h>
5249#endif
5250#ifdef HAVE_LASTLOG_H
5251#include <lastlog.h>
5252#endif
5253 ])
5254
5255AC_CHECK_MEMBER([struct utmp.ut_line], [], [
5256 AC_DEFINE([DISABLE_UTMP])
5257 AC_DEFINE([DISABLE_WTMP])
5258 ], [
5259#ifdef HAVE_SYS_TYPES_H
5260#include <sys/types.h>
5261#endif
5262#ifdef HAVE_UTMP_H
5263#include <utmp.h>
5264#endif
5265#ifdef HAVE_UTMPX_H
5266#include <utmpx.h>
5267#endif
5268#ifdef HAVE_LASTLOG_H
5269#include <lastlog.h>
5270#endif
5271 ])
5272
Darren Tucker7da23cb2005-08-03 00:20:15 +10005273dnl Adding -Werror to CFLAGS early prevents configure tests from running.
5274dnl Add now.
5275CFLAGS="$CFLAGS $werror_flags"
5276
Darren Tucker627337d2010-04-10 22:58:01 +10005277if test "x$ac_cv_func_getaddrinfo" != "xyes" ; then
5278 TEST_SSH_IPV6=no
5279else
5280 TEST_SSH_IPV6=yes
5281fi
Tim Rice648f8762011-01-26 12:38:57 -08005282AC_CHECK_DECL([BROKEN_GETADDRINFO], [TEST_SSH_IPV6=no])
5283AC_SUBST([TEST_SSH_IPV6], [$TEST_SSH_IPV6])
Darren Tucker47b8c992016-12-08 15:48:34 +11005284AC_SUBST([TEST_SSH_UTF8], [$TEST_SSH_UTF8])
Darren Tucker882abfd2013-11-09 00:17:41 +11005285AC_SUBST([TEST_MALLOC_OPTIONS], [$TEST_MALLOC_OPTIONS])
Darren Tucker6d8bd572013-06-11 11:26:10 +10005286AC_SUBST([UNSUPPORTED_ALGORITHMS], [$unsupported_algorithms])
Darren Tucker79c0e1d2017-12-11 14:38:33 +11005287AC_SUBST([DEPEND], [$(cat $srcdir/.depend)])
Darren Tucker5d376902008-06-11 04:15:05 +10005288
Damien Millerde35c382017-09-08 12:38:31 +10005289CFLAGS="${CFLAGS} ${CFLAGS_AFTER}"
5290LDFLAGS="${LDFLAGS} ${LDFLAGS_AFTER}"
5291
Damien Millerbac2d8a2000-09-05 16:13:06 +11005292AC_EXEEXT
Damien Miller223897a2006-09-12 21:54:10 +10005293AC_CONFIG_FILES([Makefile buildpkg.sh opensshd.init openssh.xml \
5294 openbsd-compat/Makefile openbsd-compat/regress/Makefile \
Damien Millerf22019b2011-05-05 13:48:37 +10005295 survey.sh])
Tim Rice13aae5e2001-10-21 17:53:58 -07005296AC_OUTPUT
Damien Miller0437b332000-05-02 09:56:41 +10005297
Damien Miller7b22d652000-06-18 14:07:04 +10005298# Print summary of options
5299
Damien Miller7b22d652000-06-18 14:07:04 +10005300# Someone please show me a better way :)
5301A=`eval echo ${prefix}` ; A=`eval echo ${A}`
5302B=`eval echo ${bindir}` ; B=`eval echo ${B}`
5303C=`eval echo ${sbindir}` ; C=`eval echo ${C}`
5304D=`eval echo ${sysconfdir}` ; D=`eval echo ${D}`
Kevin Stevese0f49142000-10-14 17:51:48 +00005305E=`eval echo ${libexecdir}/ssh-askpass` ; E=`eval echo ${E}`
Ben Lindstrombc709922001-04-18 18:04:21 +00005306F=`eval echo ${mandir}/${mansubdir}X` ; F=`eval echo ${F}`
Damien Miller7b22d652000-06-18 14:07:04 +10005307G=`eval echo ${piddir}` ; G=`eval echo ${G}`
Damien Millerf58c6722002-05-13 13:15:42 +10005308H=`eval echo ${PRIVSEP_PATH}` ; H=`eval echo ${H}`
5309I=`eval echo ${user_path}` ; I=`eval echo ${I}`
5310J=`eval echo ${superuser_path}` ; J=`eval echo ${J}`
Damien Miller7b22d652000-06-18 14:07:04 +10005311
5312echo ""
Kevin Steves393d2f72001-04-08 22:50:43 +00005313echo "OpenSSH has been configured with the following options:"
Damien Millerf58c6722002-05-13 13:15:42 +10005314echo " User binaries: $B"
5315echo " System binaries: $C"
5316echo " Configuration files: $D"
5317echo " Askpass program: $E"
5318echo " Manual pages: $F"
5319echo " PID file: $G"
5320echo " Privilege separation chroot path: $H"
Darren Tuckere1a790d2003-09-16 11:52:19 +10005321if test "x$external_path_file" = "x/etc/login.conf" ; then
5322echo " At runtime, sshd will use the path defined in $external_path_file"
5323echo " Make sure the path to scp is present, otherwise scp will not work"
Tim Rice43a1c132002-04-17 21:19:14 -07005324else
Damien Millerf58c6722002-05-13 13:15:42 +10005325echo " sshd default user PATH: $I"
Tim Riceb925b4b2003-09-15 22:40:49 -07005326 if test ! -z "$external_path_file"; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10005327echo " (If PATH is set in $external_path_file it will be used instead. If"
5328echo " used, ensure the path to scp is present, otherwise scp will not work.)"
5329 fi
Tim Rice43a1c132002-04-17 21:19:14 -07005330fi
Damien Millera18bbd32002-05-13 10:48:57 +10005331if test ! -z "$superuser_path" ; then
Damien Millerf58c6722002-05-13 13:15:42 +10005332echo " sshd superuser user PATH: $J"
Damien Millera18bbd32002-05-13 10:48:57 +10005333fi
Damien Millerf58c6722002-05-13 13:15:42 +10005334echo " Manpage format: $MANTYPE"
Damien Miller7abe09b2003-05-15 10:53:49 +10005335echo " PAM support: $PAM_MSG"
Damien Miller1b06dc32006-08-31 03:24:41 +10005336echo " OSF SIA support: $SIA_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10005337echo " KerberosV support: $KRB5_MSG"
Damien Miller73b42d22006-04-22 21:26:08 +10005338echo " SELinux support: $SELINUX_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10005339echo " MD5 password support: $MD5_MSG"
Darren Tucker16bcc1c2004-11-07 20:14:34 +11005340echo " libedit support: $LIBEDIT_MSG"
Damien Miller523db852017-02-03 16:01:22 +11005341echo " libldns support: $LDNS_MSG"
Damien Miller1b06dc32006-08-31 03:24:41 +10005342echo " Solaris process contract support: $SPC_MSG"
Darren Tucker97528352010-11-05 12:03:05 +11005343echo " Solaris project support: $SP_MSG"
Damien Miller4626cba2016-01-08 14:24:56 +11005344echo " Solaris privilege support: $SPP_MSG"
Damien Miller903e1152002-05-13 14:41:31 +10005345echo " IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10005346echo " Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG"
5347echo " BSD Auth support: $BSD_AUTH_MSG"
5348echo " Random number source: $RAND_MSG"
Damien Miller69ff1df2011-06-23 08:30:03 +10005349echo " Privsep sandbox style: $SANDBOX_STYLE"
Damien Miller764d51e2019-11-01 13:34:49 +11005350echo " PKCS#11 support: $enable_pkcs11"
5351echo " U2F/FIDO support: $enable_sk"
Damien Miller60396b02001-02-18 17:01:00 +11005352
Damien Miller7b22d652000-06-18 14:07:04 +10005353echo ""
5354
Ben Lindstrom28bfc0d2000-12-18 19:58:57 +00005355echo " Host: ${host}"
5356echo " Compiler: ${CC}"
5357echo " Compiler flags: ${CFLAGS}"
5358echo "Preprocessor flags: ${CPPFLAGS}"
5359echo " Linker flags: ${LDFLAGS}"
Darren Tucker20e9f972007-03-25 18:26:01 +10005360echo " Libraries: ${LIBS}"
5361if test ! -z "${SSHDLIBS}"; then
5362echo " +for sshd: ${SSHDLIBS}"
5363fi
Damien Miller71adf122011-01-25 12:16:15 +11005364if test ! -z "${SSHLIBS}"; then
5365echo " +for ssh: ${SSHLIBS}"
5366fi
Damien Miller7b22d652000-06-18 14:07:04 +10005367
5368echo ""
5369
Tim Rice6f1f7582004-05-30 21:38:51 -07005370if test "x$MAKE_PACKAGE_SUPPORTED" = "xyes" ; then
Darren Tuckercf59d312004-08-29 21:18:09 +10005371 echo "SVR4 style packages are supported with \"make package\""
5372 echo ""
Tim Rice6f1f7582004-05-30 21:38:51 -07005373fi
5374
Damien Miller82cf0ce2000-12-20 13:34:48 +11005375if test "x$PAM_MSG" = "xyes" ; then
Damien Miller6c21c512002-01-22 21:57:53 +11005376 echo "PAM is enabled. You may need to install a PAM control file "
5377 echo "for sshd, otherwise password authentication may fail. "
Damien Millera8e06ce2003-11-21 23:48:55 +11005378 echo "Example PAM control files can be found in the contrib/ "
Damien Miller6c21c512002-01-22 21:57:53 +11005379 echo "subdirectory"
Damien Miller6f9c3372000-10-25 10:06:04 +11005380 echo ""
5381fi
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00005382
Damien Millerb4097182004-05-23 14:09:40 +10005383if test ! -z "$NO_PEERCHECK" ; then
Darren Tucker164aa302007-03-21 21:39:57 +11005384 echo "WARNING: the operating system that you are using does not"
5385 echo "appear to support getpeereid(), getpeerucred() or the"
5386 echo "SO_PEERCRED getsockopt() option. These facilities are used to"
5387 echo "enforce security checks to prevent unauthorised connections to"
5388 echo "ssh-agent. Their absence increases the risk that a malicious"
5389 echo "user can connect to your agent."
Damien Millerb4097182004-05-23 14:09:40 +10005390 echo ""
5391fi
5392
Darren Tuckerd9f88912005-02-20 21:01:48 +11005393if test "$AUDIT_MODULE" = "bsm" ; then
5394 echo "WARNING: BSM audit support is currently considered EXPERIMENTAL."
5395 echo "See the Solaris section in README.platform for details."
5396fi