blob: cb66f54b1d2e73978cf6f67256102693c61c336c [file] [log] [blame]
Damien Miller3d673d12014-08-27 06:32:01 +10001# $Id: configure.ac,v 1.583 2014/08/26 20:32:01 djm Exp $
Damien Miller4fefe242004-03-11 14:20:10 +11002#
3# Copyright (c) 1999-2004 Damien Miller
4#
5# Permission to use, copy, modify, and distribute this software for any
6# purpose with or without fee is hereby granted, provided that the above
7# copyright notice and this permission notice appear in all copies.
8#
9# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Damien Millere9cf3572001-02-09 12:55:35 +110016
Tim Rice648f8762011-01-26 12:38:57 -080017AC_INIT([OpenSSH], [Portable], [openssh-unix-dev@mindrot.org])
Damien Miller3d673d12014-08-27 06:32:01 +100018AC_REVISION($Revision: 1.583 $)
Tim Rice13aae5e2001-10-21 17:53:58 -070019AC_CONFIG_SRCDIR([ssh.c])
Tim Rice648f8762011-01-26 12:38:57 -080020AC_LANG([C])
Damien Miller7f6ea021999-10-28 13:25:17 +100021
Tim Rice648f8762011-01-26 12:38:57 -080022AC_CONFIG_HEADER([config.h])
Damien Miller856799b2000-03-15 21:18:10 +110023AC_PROG_CC
Damien Miller76112de1999-12-21 11:18:08 +110024AC_CANONICAL_HOST
Damien Miller4df5c762001-02-28 08:14:22 +110025AC_C_BIGENDIAN
Damien Miller7f6ea021999-10-28 13:25:17 +100026
Damien Millera22ba012000-03-02 23:09:20 +110027# Checks for programs.
Darren Tucker167bd9c2003-09-07 12:34:54 +100028AC_PROG_AWK
Damien Millerab18c411999-11-11 10:40:23 +110029AC_PROG_CPP
Damien Miller7f6ea021999-10-28 13:25:17 +100030AC_PROG_RANLIB
Damien Millerd8087f61999-11-25 12:31:26 +110031AC_PROG_INSTALL
Tim Ricefd80ddc2006-02-02 19:11:56 -080032AC_PROG_EGREP
Tim Rice648f8762011-01-26 12:38:57 -080033AC_PATH_PROG([AR], [ar])
34AC_PATH_PROG([CAT], [cat])
35AC_PATH_PROG([KILL], [kill])
36AC_PATH_PROGS([PERL], [perl5 perl])
37AC_PATH_PROG([SED], [sed])
38AC_SUBST([PERL])
39AC_PATH_PROG([ENT], [ent])
40AC_SUBST([ENT])
41AC_PATH_PROG([TEST_MINUS_S_SH], [bash])
42AC_PATH_PROG([TEST_MINUS_S_SH], [ksh])
43AC_PATH_PROG([TEST_MINUS_S_SH], [sh])
44AC_PATH_PROG([SH], [sh])
45AC_PATH_PROG([GROFF], [groff])
46AC_PATH_PROG([NROFF], [nroff])
47AC_PATH_PROG([MANDOC], [mandoc])
48AC_SUBST([TEST_SHELL], [sh])
Damien Miller2e1b0821999-12-25 10:11:29 +110049
Damien Miller30a69e72011-01-04 08:16:27 +110050dnl select manpage formatter
51if test "x$MANDOC" != "x" ; then
52 MANFMT="$MANDOC"
53elif test "x$NROFF" != "x" ; then
54 MANFMT="$NROFF -mandoc"
55elif test "x$GROFF" != "x" ; then
56 MANFMT="$GROFF -mandoc -Tascii"
57else
58 AC_MSG_WARN([no manpage formatted found])
59 MANFMT="false"
60fi
Tim Rice648f8762011-01-26 12:38:57 -080061AC_SUBST([MANFMT])
Damien Miller30a69e72011-01-04 08:16:27 +110062
Tim Rice6f1f7582004-05-30 21:38:51 -070063dnl for buildpkg.sh
Tim Rice648f8762011-01-26 12:38:57 -080064AC_PATH_PROG([PATH_GROUPADD_PROG], [groupadd], [groupadd],
Tim Rice6f1f7582004-05-30 21:38:51 -070065 [/usr/sbin${PATH_SEPARATOR}/etc])
Tim Rice648f8762011-01-26 12:38:57 -080066AC_PATH_PROG([PATH_USERADD_PROG], [useradd], [useradd],
Tim Rice6f1f7582004-05-30 21:38:51 -070067 [/usr/sbin${PATH_SEPARATOR}/etc])
Tim Rice648f8762011-01-26 12:38:57 -080068AC_CHECK_PROG([MAKE_PACKAGE_SUPPORTED], [pkgmk], [yes], [no])
Darren Tuckerfbea7642006-01-30 00:22:39 +110069if test -x /sbin/sh; then
Tim Rice648f8762011-01-26 12:38:57 -080070 AC_SUBST([STARTUP_SCRIPT_SHELL], [/sbin/sh])
Darren Tuckerfbea7642006-01-30 00:22:39 +110071else
Tim Rice648f8762011-01-26 12:38:57 -080072 AC_SUBST([STARTUP_SCRIPT_SHELL], [/bin/sh])
Darren Tuckerfbea7642006-01-30 00:22:39 +110073fi
Tim Rice6f1f7582004-05-30 21:38:51 -070074
Damien Millere8bb4502001-09-25 16:39:35 +100075# System features
76AC_SYS_LARGEFILE
77
Damien Miller3f62aba2000-11-29 11:56:35 +110078if test -z "$AR" ; then
79 AC_MSG_ERROR([*** 'ar' missing, please install or fix your \$PATH ***])
80fi
81
Damien Millerad833b32000-08-23 10:46:23 +100082# Use LOGIN_PROGRAM from environment if possible
83if test ! -z "$LOGIN_PROGRAM" ; then
Tim Rice648f8762011-01-26 12:38:57 -080084 AC_DEFINE_UNQUOTED([LOGIN_PROGRAM_FALLBACK], ["$LOGIN_PROGRAM"],
Tim Rice7df8d392005-09-19 09:33:39 -070085 [If your header files don't define LOGIN_PROGRAM,
86 then use this (detected) from environment and PATH])
Damien Millerad833b32000-08-23 10:46:23 +100087else
88 # Search for login
Tim Rice648f8762011-01-26 12:38:57 -080089 AC_PATH_PROG([LOGIN_PROGRAM_FALLBACK], [login])
Damien Millerad833b32000-08-23 10:46:23 +100090 if test ! -z "$LOGIN_PROGRAM_FALLBACK" ; then
Tim Rice648f8762011-01-26 12:38:57 -080091 AC_DEFINE_UNQUOTED([LOGIN_PROGRAM_FALLBACK], ["$LOGIN_PROGRAM_FALLBACK"])
Damien Millerad833b32000-08-23 10:46:23 +100092 fi
93fi
94
Tim Rice648f8762011-01-26 12:38:57 -080095AC_PATH_PROG([PATH_PASSWD_PROG], [passwd])
Darren Tucker23bc8d02004-02-06 16:24:31 +110096if test ! -z "$PATH_PASSWD_PROG" ; then
Tim Rice648f8762011-01-26 12:38:57 -080097 AC_DEFINE_UNQUOTED([_PATH_PASSWD_PROG], ["$PATH_PASSWD_PROG"],
Tim Rice7df8d392005-09-19 09:33:39 -070098 [Full path of your "passwd" program])
Darren Tucker23bc8d02004-02-06 16:24:31 +110099fi
100
Damien Miller166bd442000-03-16 10:48:25 +1100101if test -z "$LD" ; then
102 LD=$CC
103fi
Tim Rice648f8762011-01-26 12:38:57 -0800104AC_SUBST([LD])
Tim Riceeae17cc2005-03-17 16:52:20 -0800105
Damien Miller166bd442000-03-16 10:48:25 +1100106AC_C_INLINE
Darren Tucker67b37032005-06-03 17:58:31 +1000107
Tim Rice648f8762011-01-26 12:38:57 -0800108AC_CHECK_DECL([LLONG_MAX], [have_llong_max=1], , [#include <limits.h>])
Damien Miller69ff1df2011-06-23 08:30:03 +1000109AC_CHECK_DECL([SYSTR_POLICY_KILL], [have_systr_policy_kill=1], , [
110 #include <sys/types.h>
111 #include <sys/param.h>
112 #include <dev/systrace.h>
113])
114AC_CHECK_DECL([RLIMIT_NPROC],
115 [AC_DEFINE([HAVE_RLIMIT_NPROC], [], [sys/resource.h has RLIMIT_NPROC])], , [
116 #include <sys/types.h>
117 #include <sys/resource.h>
118])
Damien Millere0956e32012-04-04 11:27:54 +1000119AC_CHECK_DECL([PR_SET_NO_NEW_PRIVS], [have_linux_no_new_privs=1], , [
120 #include <sys/types.h>
121 #include <linux/prctl.h>
122])
Damien Miller868ea1e2014-01-17 16:47:04 +1100123
Damien Miller72ef7c12015-01-15 02:21:31 +1100124openssl=yes
Damien Miller76c04802015-01-13 19:38:18 +1100125ssh1=yes
Damien Miller72ef7c12015-01-15 02:21:31 +1100126AC_ARG_WITH([openssl],
127 [ --without-openssl Disable use of OpenSSL; use only limited internal crypto **EXPERIMENTAL** ],
Damien Miller76c04802015-01-13 19:38:18 +1100128 [ if test "x$withval" = "xno" ; then
Damien Miller72ef7c12015-01-15 02:21:31 +1100129 openssl=no
Damien Miller76c04802015-01-13 19:38:18 +1100130 ssh1=no
131 fi
132 ]
133)
Damien Miller72ef7c12015-01-15 02:21:31 +1100134AC_MSG_CHECKING([whether OpenSSL will be used for cryptography])
135if test "x$openssl" = "xyes" ; then
136 AC_MSG_RESULT([yes])
137 AC_DEFINE_UNQUOTED([WITH_OPENSSL], [1], [use libcrypto for cryptography])
138else
139 AC_MSG_RESULT([no])
140fi
141
142AC_ARG_WITH([ssh1],
143 [ --without-ssh1 Disable support for SSH protocol 1],
144 [
145 if test "x$withval" = "xno" ; then
146 ssh1=no
147 elif test "x$openssl" = "xno" ; then
148 AC_MSG_ERROR([Cannot enable SSH protocol 1 with OpenSSL disabled])
149 fi
150 ]
151)
Damien Miller76c04802015-01-13 19:38:18 +1100152AC_MSG_CHECKING([whether SSH protocol 1 support is enabled])
153if test "x$ssh1" = "xyes" ; then
154 AC_MSG_RESULT([yes])
155 AC_DEFINE_UNQUOTED([WITH_SSH1], [1], [include SSH protocol version 1 support])
156else
157 AC_MSG_RESULT([no])
158fi
159
Darren Tuckerb7918af2008-03-09 11:34:23 +1100160use_stack_protector=1
Darren Tuckerfd994372014-01-17 09:53:24 +1100161use_toolchain_hardening=1
Tim Rice648f8762011-01-26 12:38:57 -0800162AC_ARG_WITH([stackprotect],
Damien Millerda3155e2008-03-27 12:30:18 +1100163 [ --without-stackprotect Don't use compiler's stack protection], [
Darren Tuckerb7918af2008-03-09 11:34:23 +1100164 if test "x$withval" = "xno"; then
165 use_stack_protector=0
166 fi ])
Darren Tuckerfd994372014-01-17 09:53:24 +1100167AC_ARG_WITH([hardening],
168 [ --without-hardening Don't use toolchain hardening flags], [
169 if test "x$withval" = "xno"; then
Darren Tuckerfd994372014-01-17 09:53:24 +1100170 use_toolchain_hardening=0
171 fi ])
Darren Tuckerb7918af2008-03-09 11:34:23 +1100172
Darren Tuckerfd994372014-01-17 09:53:24 +1100173# We use -Werror for the tests only so that we catch warnings like "this is
174# on by default" for things like -fPIE.
175AC_MSG_CHECKING([if $CC supports -Werror])
176saved_CFLAGS="$CFLAGS"
177CFLAGS="$CFLAGS -Werror"
178AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int main(void) { return 0; }]])],
179 [ AC_MSG_RESULT([yes])
180 WERROR="-Werror"],
181 [ AC_MSG_RESULT([no])
182 WERROR="" ]
183)
184CFLAGS="$saved_CFLAGS"
Damien Miller134d02a2011-01-12 16:00:37 +1100185
Damien Millera8e06ce2003-11-21 23:48:55 +1100186if test "$GCC" = "yes" || test "$GCC" = "egcs"; then
Darren Tuckerfd994372014-01-17 09:53:24 +1100187 OSSH_CHECK_CFLAG_COMPILE([-Qunused-arguments])
188 OSSH_CHECK_CFLAG_COMPILE([-Wunknown-warning-option])
Damien Millerb1763622011-05-20 11:45:25 +1000189 OSSH_CHECK_CFLAG_COMPILE([-Wall])
190 OSSH_CHECK_CFLAG_COMPILE([-Wpointer-arith])
191 OSSH_CHECK_CFLAG_COMPILE([-Wuninitialized])
192 OSSH_CHECK_CFLAG_COMPILE([-Wsign-compare])
193 OSSH_CHECK_CFLAG_COMPILE([-Wformat-security])
Darren Tuckerabbc7a72013-05-10 13:54:23 +1000194 OSSH_CHECK_CFLAG_COMPILE([-Wsizeof-pointer-memaccess])
Damien Millerb1763622011-05-20 11:45:25 +1000195 OSSH_CHECK_CFLAG_COMPILE([-Wpointer-sign], [-Wno-pointer-sign])
196 OSSH_CHECK_CFLAG_COMPILE([-Wunused-result], [-Wno-unused-result])
197 OSSH_CHECK_CFLAG_COMPILE([-fno-strict-aliasing])
Darren Tucker4a725ef2011-11-21 16:38:48 +1100198 OSSH_CHECK_CFLAG_COMPILE([-D_FORTIFY_SOURCE=2])
Darren Tuckerfd994372014-01-17 09:53:24 +1100199 if test "x$use_toolchain_hardening" = "x1"; then
Darren Tuckerfd994372014-01-17 09:53:24 +1100200 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,relro])
201 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,now])
202 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,noexecstack])
Damien Miller5c2ff5e2014-01-22 21:30:12 +1100203 # NB. -ftrapv expects certain support functions to be present in
204 # the compiler library (libgcc or similar) to detect integer operations
205 # that can overflow. We must check that the result of enabling it
206 # actually links. The test program compiled/linked includes a number
207 # of integer operations that should exercise this.
208 OSSH_CHECK_CFLAG_LINK([-ftrapv])
Darren Tuckerfd994372014-01-17 09:53:24 +1100209 fi
Tim Rice648f8762011-01-26 12:38:57 -0800210 AC_MSG_CHECKING([gcc version])
Darren Tucker3f9545e2005-11-12 15:20:52 +1100211 GCC_VER=`$CC -v 2>&1 | $AWK '/gcc version /{print $3}'`
Tim Rice3db1e3f2005-08-23 17:11:26 -0700212 case $GCC_VER in
Darren Tucker391de5c2007-04-29 14:49:21 +1000213 1.*) no_attrib_nonnull=1 ;;
214 2.8* | 2.9*)
Darren Tucker391de5c2007-04-29 14:49:21 +1000215 no_attrib_nonnull=1
216 ;;
217 2.*) no_attrib_nonnull=1 ;;
Darren Tuckerf0324352005-11-10 21:30:36 +1100218 *) ;;
Tim Rice3db1e3f2005-08-23 17:11:26 -0700219 esac
Tim Rice648f8762011-01-26 12:38:57 -0800220 AC_MSG_RESULT([$GCC_VER])
Damien Millerde3cb0a2005-05-26 20:48:25 +1000221
Tim Rice648f8762011-01-26 12:38:57 -0800222 AC_MSG_CHECKING([if $CC accepts -fno-builtin-memset])
Darren Tucker330c93f2008-06-16 02:27:48 +1000223 saved_CFLAGS="$CFLAGS"
224 CFLAGS="$CFLAGS -fno-builtin-memset"
Tim Rice648f8762011-01-26 12:38:57 -0800225 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <string.h> ]],
226 [[ char b[10]; memset(b, 0, sizeof(b)); ]])],
227 [ AC_MSG_RESULT([yes]) ],
228 [ AC_MSG_RESULT([no])
Darren Tucker330c93f2008-06-16 02:27:48 +1000229 CFLAGS="$saved_CFLAGS" ]
Tim Rice648f8762011-01-26 12:38:57 -0800230 )
Darren Tucker330c93f2008-06-16 02:27:48 +1000231
Darren Tuckerb7918af2008-03-09 11:34:23 +1100232 # -fstack-protector-all doesn't always work for some GCC versions
Darren Tuckerfe1cf972008-03-09 22:50:50 +1100233 # and/or platforms, so we test if we can. If it's not supported
Damien Miller7df2e402008-12-08 09:35:36 +1100234 # on a given platform gcc will emit a warning so we use -Werror.
Darren Tuckerb7918af2008-03-09 11:34:23 +1100235 if test "x$use_stack_protector" = "x1"; then
Darren Tuckerfd994372014-01-17 09:53:24 +1100236 for t in -fstack-protector-strong -fstack-protector-all \
237 -fstack-protector; do
Tim Rice648f8762011-01-26 12:38:57 -0800238 AC_MSG_CHECKING([if $CC supports $t])
Darren Tuckerb7918af2008-03-09 11:34:23 +1100239 saved_CFLAGS="$CFLAGS"
240 saved_LDFLAGS="$LDFLAGS"
Darren Tuckerfe1cf972008-03-09 22:50:50 +1100241 CFLAGS="$CFLAGS $t -Werror"
242 LDFLAGS="$LDFLAGS $t -Werror"
243 AC_LINK_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -0800244 [AC_LANG_PROGRAM([[ #include <stdio.h> ]],
245 [[
246 char x[256];
247 snprintf(x, sizeof(x), "XXX");
248 ]])],
249 [ AC_MSG_RESULT([yes])
Darren Tuckerfe1cf972008-03-09 22:50:50 +1100250 CFLAGS="$saved_CFLAGS $t"
251 LDFLAGS="$saved_LDFLAGS $t"
Tim Rice648f8762011-01-26 12:38:57 -0800252 AC_MSG_CHECKING([if $t works])
Darren Tuckerb7918af2008-03-09 11:34:23 +1100253 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -0800254 [AC_LANG_PROGRAM([[ #include <stdio.h> ]],
255 [[
256 char x[256];
257 snprintf(x, sizeof(x), "XXX");
258 ]])],
259 [ AC_MSG_RESULT([yes])
Darren Tuckerb7918af2008-03-09 11:34:23 +1100260 break ],
Tim Rice648f8762011-01-26 12:38:57 -0800261 [ AC_MSG_RESULT([no]) ],
Darren Tuckerb7918af2008-03-09 11:34:23 +1100262 [ AC_MSG_WARN([cross compiling: cannot test])
263 break ]
Darren Tuckerfe1cf972008-03-09 22:50:50 +1100264 )
Darren Tuckerb7918af2008-03-09 11:34:23 +1100265 ],
Tim Rice648f8762011-01-26 12:38:57 -0800266 [ AC_MSG_RESULT([no]) ]
Darren Tuckerb7918af2008-03-09 11:34:23 +1100267 )
268 CFLAGS="$saved_CFLAGS"
269 LDFLAGS="$saved_LDFLAGS"
270 done
271 fi
Darren Tucker319b3d92007-12-02 21:02:22 +1100272
Darren Tucker67b37032005-06-03 17:58:31 +1000273 if test -z "$have_llong_max"; then
274 # retry LLONG_MAX with -std=gnu99, needed on some Linuxes
275 unset ac_cv_have_decl_LLONG_MAX
276 saved_CFLAGS="$CFLAGS"
277 CFLAGS="$CFLAGS -std=gnu99"
Tim Rice648f8762011-01-26 12:38:57 -0800278 AC_CHECK_DECL([LLONG_MAX],
Darren Tucker67b37032005-06-03 17:58:31 +1000279 [have_llong_max=1],
280 [CFLAGS="$saved_CFLAGS"],
281 [#include <limits.h>]
282 )
283 fi
Damien Miller166bd442000-03-16 10:48:25 +1100284fi
285
Darren Tucker951b53b2013-02-08 11:50:09 +1100286AC_MSG_CHECKING([if compiler allows __attribute__ on return types])
287AC_COMPILE_IFELSE(
288 [AC_LANG_PROGRAM([[
289#include <stdlib.h>
290__attribute__((__unused__)) static void foo(void){return;}]],
291 [[ exit(0); ]])],
292 [ AC_MSG_RESULT([yes]) ],
293 [ AC_MSG_RESULT([no])
294 AC_DEFINE(NO_ATTRIBUTE_ON_RETURN_TYPE, 1,
295 [compiler does not accept __attribute__ on return types]) ]
296)
297
Darren Tucker391de5c2007-04-29 14:49:21 +1000298if test "x$no_attrib_nonnull" != "x1" ; then
Tim Rice648f8762011-01-26 12:38:57 -0800299 AC_DEFINE([HAVE_ATTRIBUTE__NONNULL__], [1], [Have attribute nonnull])
Darren Tucker391de5c2007-04-29 14:49:21 +1000300fi
301
Tim Rice648f8762011-01-26 12:38:57 -0800302AC_ARG_WITH([rpath],
Tim Rice88368a32003-12-08 12:35:59 -0800303 [ --without-rpath Disable auto-added -R linker paths],
304 [
Tim Riceeae17cc2005-03-17 16:52:20 -0800305 if test "x$withval" = "xno" ; then
Tim Rice88368a32003-12-08 12:35:59 -0800306 need_dash_r=""
307 fi
308 if test "x$withval" = "xyes" ; then
309 need_dash_r=1
310 fi
311 ]
312)
313
Tim Rice1cfab232006-10-03 09:34:35 -0700314# Allow user to specify flags
Tim Rice648f8762011-01-26 12:38:57 -0800315AC_ARG_WITH([cflags],
Tim Rice1cfab232006-10-03 09:34:35 -0700316 [ --with-cflags Specify additional flags to pass to compiler],
317 [
318 if test -n "$withval" && test "x$withval" != "xno" && \
319 test "x${withval}" != "xyes"; then
320 CFLAGS="$CFLAGS $withval"
321 fi
322 ]
323)
Tim Rice648f8762011-01-26 12:38:57 -0800324AC_ARG_WITH([cppflags],
Tim Rice1cfab232006-10-03 09:34:35 -0700325 [ --with-cppflags Specify additional flags to pass to preprocessor] ,
326 [
327 if test -n "$withval" && test "x$withval" != "xno" && \
328 test "x${withval}" != "xyes"; then
329 CPPFLAGS="$CPPFLAGS $withval"
330 fi
331 ]
332)
Tim Rice648f8762011-01-26 12:38:57 -0800333AC_ARG_WITH([ldflags],
Tim Rice1cfab232006-10-03 09:34:35 -0700334 [ --with-ldflags Specify additional flags to pass to linker],
335 [
336 if test -n "$withval" && test "x$withval" != "xno" && \
337 test "x${withval}" != "xyes"; then
338 LDFLAGS="$LDFLAGS $withval"
339 fi
340 ]
341)
Tim Rice648f8762011-01-26 12:38:57 -0800342AC_ARG_WITH([libs],
Tim Rice1cfab232006-10-03 09:34:35 -0700343 [ --with-libs Specify additional libraries to link with],
344 [
345 if test -n "$withval" && test "x$withval" != "xno" && \
346 test "x${withval}" != "xyes"; then
347 LIBS="$LIBS $withval"
348 fi
349 ]
350)
Tim Rice648f8762011-01-26 12:38:57 -0800351AC_ARG_WITH([Werror],
Tim Rice1cfab232006-10-03 09:34:35 -0700352 [ --with-Werror Build main code with -Werror],
353 [
354 if test -n "$withval" && test "x$withval" != "xno"; then
355 werror_flags="-Werror"
356 if test "x${withval}" != "xyes"; then
357 werror_flags="$withval"
358 fi
359 fi
360 ]
361)
362
Tim Rice648f8762011-01-26 12:38:57 -0800363AC_CHECK_HEADERS([ \
Damien Miller1ff130d2013-12-07 11:51:51 +1100364 blf.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700365 bstring.h \
366 crypt.h \
367 crypto/sha2.h \
368 dirent.h \
369 endian.h \
Damien Miller91f40d82013-02-22 11:37:00 +1100370 elf.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700371 features.h \
372 fcntl.h \
373 floatingpoint.h \
374 getopt.h \
375 glob.h \
376 ia.h \
377 iaf.h \
Darren Tucker6d725682014-01-17 19:17:34 +1100378 inttypes.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700379 limits.h \
Darren Tuckerae133d42013-06-06 08:30:20 +1000380 locale.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700381 login.h \
382 maillock.h \
383 ndir.h \
384 net/if_tun.h \
385 netdb.h \
386 netgroup.h \
387 pam/pam_appl.h \
388 paths.h \
Darren Tuckerfebf0f52007-06-25 22:15:12 +1000389 poll.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700390 pty.h \
391 readpassphrase.h \
392 rpc/types.h \
393 security/pam_appl.h \
394 sha2.h \
395 shadow.h \
396 stddef.h \
397 stdint.h \
398 string.h \
399 strings.h \
400 sys/audit.h \
401 sys/bitypes.h \
402 sys/bsdtty.h \
Damien Millerc96d8532014-01-25 13:12:28 +1100403 sys/capability.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700404 sys/cdefs.h \
405 sys/dir.h \
406 sys/mman.h \
407 sys/ndir.h \
Darren Tucker7c92a652007-09-27 07:00:09 +1000408 sys/poll.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700409 sys/prctl.h \
410 sys/pstat.h \
411 sys/select.h \
412 sys/stat.h \
413 sys/stream.h \
414 sys/stropts.h \
415 sys/strtio.h \
Darren Tucker5b2e2ba2008-06-08 09:25:28 +1000416 sys/statvfs.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700417 sys/sysmacros.h \
418 sys/time.h \
419 sys/timers.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700420 time.h \
421 tmpdir.h \
422 ttyent.h \
Tim Riceaa8954f2007-05-09 15:57:43 -0700423 ucred.h \
Tim Rice1cfab232006-10-03 09:34:35 -0700424 unistd.h \
425 usersec.h \
426 util.h \
427 utime.h \
428 utmp.h \
429 utmpx.h \
430 vis.h \
Tim Rice648f8762011-01-26 12:38:57 -0800431])
Tim Rice1cfab232006-10-03 09:34:35 -0700432
433# lastlog.h requires sys/time.h to be included first on Solaris
Tim Rice648f8762011-01-26 12:38:57 -0800434AC_CHECK_HEADERS([lastlog.h], [], [], [
Tim Rice1cfab232006-10-03 09:34:35 -0700435#ifdef HAVE_SYS_TIME_H
436# include <sys/time.h>
437#endif
438])
439
440# sys/ptms.h requires sys/stream.h to be included first on Solaris
Tim Rice648f8762011-01-26 12:38:57 -0800441AC_CHECK_HEADERS([sys/ptms.h], [], [], [
Tim Rice1cfab232006-10-03 09:34:35 -0700442#ifdef HAVE_SYS_STREAM_H
443# include <sys/stream.h>
444#endif
445])
446
447# login_cap.h requires sys/types.h on NetBSD
Tim Rice648f8762011-01-26 12:38:57 -0800448AC_CHECK_HEADERS([login_cap.h], [], [], [
Tim Rice1cfab232006-10-03 09:34:35 -0700449#include <sys/types.h>
450])
451
Darren Tuckerc4b22ca2009-07-12 21:56:29 +1000452# older BSDs need sys/param.h before sys/mount.h
Tim Rice648f8762011-01-26 12:38:57 -0800453AC_CHECK_HEADERS([sys/mount.h], [], [], [
Darren Tuckerc4b22ca2009-07-12 21:56:29 +1000454#include <sys/param.h>
455])
456
Darren Tuckeref4901c2013-06-03 01:59:13 +1000457# Android requires sys/socket.h to be included before sys/un.h
458AC_CHECK_HEADERS([sys/un.h], [], [], [
Darren Tucker0b43ffe2013-06-03 09:30:44 +1000459#include <sys/types.h>
Darren Tucker16cac192013-06-04 12:55:24 +1000460#include <sys/socket.h>
Darren Tuckeref4901c2013-06-03 01:59:13 +1000461])
462
Damien Miller1b06dc32006-08-31 03:24:41 +1000463# Messages for features tested for in target-specific section
464SIA_MSG="no"
465SPC_MSG="no"
Darren Tucker97528352010-11-05 12:03:05 +1100466SP_MSG="no"
Damien Miller1b06dc32006-08-31 03:24:41 +1000467
Damien Millera22ba012000-03-02 23:09:20 +1100468# Check for some target-specific stuff
Damien Miller76112de1999-12-21 11:18:08 +1100469case "$host" in
Damien Miller75b1d102000-01-07 14:01:41 +1100470*-*-aix*)
Darren Tucker9216c372006-09-18 23:17:40 +1000471 # Some versions of VAC won't allow macro redefinitions at
472 # -qlanglevel=ansi, and autoconf 2.60 sometimes insists on using that
473 # particularly with older versions of vac or xlc.
474 # It also throws errors about null macro argments, but these are
475 # not fatal.
Tim Rice648f8762011-01-26 12:38:57 -0800476 AC_MSG_CHECKING([if compiler allows macro redefinitions])
Darren Tucker9216c372006-09-18 23:17:40 +1000477 AC_COMPILE_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -0800478 [AC_LANG_PROGRAM([[
Darren Tucker9216c372006-09-18 23:17:40 +1000479#define testmacro foo
Tim Rice648f8762011-01-26 12:38:57 -0800480#define testmacro bar]],
481 [[ exit(0); ]])],
482 [ AC_MSG_RESULT([yes]) ],
483 [ AC_MSG_RESULT([no])
Darren Tucker9216c372006-09-18 23:17:40 +1000484 CC="`echo $CC | sed 's/-qlanglvl\=ansi//g'`"
485 LD="`echo $LD | sed 's/-qlanglvl\=ansi//g'`"
486 CFLAGS="`echo $CFLAGS | sed 's/-qlanglvl\=ansi//g'`"
487 CPPFLAGS="`echo $CPPFLAGS | sed 's/-qlanglvl\=ansi//g'`"
488 ]
489 )
490
Damien Millera8e06ce2003-11-21 23:48:55 +1100491 AC_MSG_CHECKING([how to specify blibpath for linker ($LD)])
Damien Millereab4bae2003-04-29 23:22:40 +1000492 if (test -z "$blibpath"); then
Tim Ricefcb62202004-01-23 18:35:16 -0800493 blibpath="/usr/lib:/lib"
Damien Miller29ea30d2000-03-17 10:54:15 +1100494 fi
Damien Millereab4bae2003-04-29 23:22:40 +1000495 saved_LDFLAGS="$LDFLAGS"
Darren Tuckerbdc12122006-07-06 11:56:25 +1000496 if test "$GCC" = "yes"; then
497 flags="-Wl,-blibpath: -Wl,-rpath, -blibpath:"
498 else
499 flags="-blibpath: -Wl,-blibpath: -Wl,-rpath,"
500 fi
501 for tryflags in $flags ;do
Damien Millereab4bae2003-04-29 23:22:40 +1000502 if (test -z "$blibflags"); then
503 LDFLAGS="$saved_LDFLAGS $tryflags$blibpath"
Tim Rice648f8762011-01-26 12:38:57 -0800504 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
505 [blibflags=$tryflags], [])
Damien Millereab4bae2003-04-29 23:22:40 +1000506 fi
507 done
508 if (test -z "$blibflags"); then
Tim Rice648f8762011-01-26 12:38:57 -0800509 AC_MSG_RESULT([not found])
Damien Millereab4bae2003-04-29 23:22:40 +1000510 AC_MSG_ERROR([*** must be able to specify blibpath on AIX - check config.log])
511 else
Tim Rice648f8762011-01-26 12:38:57 -0800512 AC_MSG_RESULT([$blibflags])
Damien Millereab4bae2003-04-29 23:22:40 +1000513 fi
514 LDFLAGS="$saved_LDFLAGS"
Darren Tucker5c6a91a2003-07-14 16:21:44 +1000515 dnl Check for authenticate. Might be in libs.a on older AIXes
Tim Rice648f8762011-01-26 12:38:57 -0800516 AC_CHECK_FUNC([authenticate], [AC_DEFINE([WITH_AIXAUTHENTICATE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700517 [Define if you want to enable AIX4's authenticate function])],
Tim Rice648f8762011-01-26 12:38:57 -0800518 [AC_CHECK_LIB([s], [authenticate],
519 [ AC_DEFINE([WITH_AIXAUTHENTICATE])
Tim Ricee958ed32002-07-05 07:12:33 -0700520 LIBS="$LIBS -ls"
521 ])
522 ])
Darren Tucker3c774c52005-02-16 22:49:31 +1100523 dnl Check for various auth function declarations in headers.
Darren Tucker04cfbe02005-02-20 23:27:11 +1100524 AC_CHECK_DECLS([authenticate, loginrestrictions, loginsuccess,
Darren Tuckere66519d2005-03-21 22:46:34 +1100525 passwdexpired, setauthdb], , , [#include <usersec.h>])
Darren Tucker5c6a91a2003-07-14 16:21:44 +1000526 dnl Check if loginfailed is declared and takes 4 arguments (AIX >= 5.2)
Tim Rice648f8762011-01-26 12:38:57 -0800527 AC_CHECK_DECLS([loginfailed],
528 [AC_MSG_CHECKING([if loginfailed takes 4 arguments])
529 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <usersec.h> ]],
530 [[ (void)loginfailed("user","host","tty",0); ]])],
531 [AC_MSG_RESULT([yes])
532 AC_DEFINE([AIX_LOGINFAILED_4ARG], [1],
533 [Define if your AIX loginfailed() function
534 takes 4 arguments (AIX >= 5.2)])], [AC_MSG_RESULT([no])
535 ])],
536 [],
537 [#include <usersec.h>]
Darren Tucker5c6a91a2003-07-14 16:21:44 +1000538 )
Tim Rice648f8762011-01-26 12:38:57 -0800539 AC_CHECK_FUNCS([getgrset setauthdb])
540 AC_CHECK_DECL([F_CLOSEM],
541 AC_DEFINE([HAVE_FCNTL_CLOSEM], [1], [Use F_CLOSEM fcntl for closefrom]),
Darren Tucker3083bc22006-08-17 19:35:49 +1000542 [],
543 [ #include <limits.h>
544 #include <fcntl.h> ]
545 )
Darren Tucker691d5232005-02-15 21:45:57 +1100546 check_for_aix_broken_getaddrinfo=1
Tim Rice648f8762011-01-26 12:38:57 -0800547 AC_DEFINE([BROKEN_REALPATH], [1], [Define if you have a broken realpath.])
548 AC_DEFINE([SETEUID_BREAKS_SETUID], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700549 [Define if your platform breaks doing a seteuid before a setuid])
Tim Rice648f8762011-01-26 12:38:57 -0800550 AC_DEFINE([BROKEN_SETREUID], [1], [Define if your setreuid() is broken])
551 AC_DEFINE([BROKEN_SETREGID], [1], [Define if your setregid() is broken])
andre60f3c982000-06-03 16:18:19 +0000552 dnl AIX handles lastlog as part of its login message
Tim Rice648f8762011-01-26 12:38:57 -0800553 AC_DEFINE([DISABLE_LASTLOG], [1], [Define if you don't want to use lastlog])
554 AC_DEFINE([LOGIN_NEEDS_UTMPX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700555 [Some systems need a utmpx entry for /bin/login to work])
Tim Rice648f8762011-01-26 12:38:57 -0800556 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV],
Tim Rice7df8d392005-09-19 09:33:39 -0700557 [Define to a Set Process Title type if your system is
558 supported by bsd-setproctitle.c])
Tim Rice648f8762011-01-26 12:38:57 -0800559 AC_DEFINE([SSHPAM_CHAUTHTOK_NEEDS_RUID], [1],
Darren Tucker91d25a02005-11-26 22:24:09 +1100560 [AIX 5.2 and 5.3 (and presumably newer) require this])
Tim Rice648f8762011-01-26 12:38:57 -0800561 AC_DEFINE([PTY_ZEROREAD], [1], [read(1) can return 0 for a non-closed fd])
Darren Tuckeraa97d132013-03-12 11:31:05 +1100562 AC_DEFINE([PLATFORM_SYS_DIR_UID], 2, [System dirs owned by bin (uid 2)])
Damien Miller75b1d102000-01-07 14:01:41 +1100563 ;;
Darren Tucker898ac932013-06-03 02:03:25 +1000564*-*-android*)
565 AC_DEFINE([DISABLE_UTMP], [1], [Define if you don't want to use utmp])
566 AC_DEFINE([DISABLE_WTMP], [1], [Define if you don't want to use wtmp])
567 ;;
Damien Millerbac2d8a2000-09-05 16:13:06 +1100568*-*-cygwin*)
Damien Millerc8936ac2003-02-11 10:04:03 +1100569 check_for_libcrypt_later=1
Darren Tucker573e3872007-03-02 17:50:03 +1100570 LIBS="$LIBS /usr/lib/textreadmode.o"
Tim Rice648f8762011-01-26 12:38:57 -0800571 AC_DEFINE([HAVE_CYGWIN], [1], [Define if you are on Cygwin])
572 AC_DEFINE([USE_PIPES], [1], [Use PIPES instead of a socketpair()])
573 AC_DEFINE([DISABLE_SHADOW], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700574 [Define if you want to disable shadow passwords])
Tim Rice648f8762011-01-26 12:38:57 -0800575 AC_DEFINE([NO_X11_UNIX_SOCKETS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700576 [Define if X11 doesn't support AF_UNIX sockets on that system])
Tim Rice648f8762011-01-26 12:38:57 -0800577 AC_DEFINE([NO_IPPORT_RESERVED_CONCEPT], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700578 [Define if the concept of ports only accessible to
579 superusers isn't known])
Tim Rice648f8762011-01-26 12:38:57 -0800580 AC_DEFINE([DISABLE_FD_PASSING], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700581 [Define if your platform needs to skip post auth
582 file descriptor passing])
Tim Rice648f8762011-01-26 12:38:57 -0800583 AC_DEFINE([SSH_IOBUFSZ], [65535], [Windows is sensitive to read buffer size])
Darren Tuckerfdce3732014-01-18 21:12:42 +1100584 AC_DEFINE([FILESYSTEM_NO_BACKSLASH], [1], [File names may not contain backslash characters])
585 # Cygwin defines optargs, optargs as declspec(dllimport) for historical
586 # reasons which cause compile warnings, so we disable those warnings.
587 OSSH_CHECK_CFLAG_COMPILE([-Wno-attributes])
Damien Millerbac2d8a2000-09-05 16:13:06 +1100588 ;;
Ben Lindstrom58055132001-02-15 18:34:29 +0000589*-*-dgux*)
Tim Rice648f8762011-01-26 12:38:57 -0800590 AC_DEFINE([IP_TOS_IS_BROKEN], [1],
Tim Ricea74000e2009-03-18 11:25:02 -0700591 [Define if your system choked on IP TOS setting])
Tim Rice648f8762011-01-26 12:38:57 -0800592 AC_DEFINE([SETEUID_BREAKS_SETUID])
593 AC_DEFINE([BROKEN_SETREUID])
594 AC_DEFINE([BROKEN_SETREGID])
Ben Lindstrom58055132001-02-15 18:34:29 +0000595 ;;
Ben Lindstromfed7bb42001-07-15 18:30:42 +0000596*-*-darwin*)
Damien Miller852472a2014-01-22 16:31:18 +1100597 use_pie=auto
Tim Rice648f8762011-01-26 12:38:57 -0800598 AC_MSG_CHECKING([if we have working getaddrinfo])
599 AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <mach-o/dyld.h>
Damien Millerfc93d4b2002-09-04 23:26:29 +1000600main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
601 exit(0);
602 else
603 exit(1);
Tim Rice648f8762011-01-26 12:38:57 -0800604}
605 ]])],
606 [AC_MSG_RESULT([working])],
607 [AC_MSG_RESULT([buggy])
608 AC_DEFINE([BROKEN_GETADDRINFO], [1],
609 [getaddrinfo is broken (if present)])
610 ],
611 [AC_MSG_RESULT([assume it is working])])
612 AC_DEFINE([SETEUID_BREAKS_SETUID])
613 AC_DEFINE([BROKEN_SETREUID])
614 AC_DEFINE([BROKEN_SETREGID])
615 AC_DEFINE([BROKEN_GLOB], [1], [OS X glob does not do what we expect])
616 AC_DEFINE_UNQUOTED([BIND_8_COMPAT], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700617 [Define if your resolver libs need this for getrrsetbyname])
Tim Rice648f8762011-01-26 12:38:57 -0800618 AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
619 AC_DEFINE([SSH_TUN_COMPAT_AF], [1],
Darren Tucker3eb48342006-06-23 21:05:12 +1000620 [Use tunnel device compatibility to OpenBSD])
Tim Rice648f8762011-01-26 12:38:57 -0800621 AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
Darren Tucker3eb48342006-06-23 21:05:12 +1000622 [Prepend the address family to IP tunnel traffic])
Tim Rice648f8762011-01-26 12:38:57 -0800623 m4_pattern_allow([AU_IPv])
624 AC_CHECK_DECL([AU_IPv4], [],
625 AC_DEFINE([AU_IPv4], [0], [System only supports IPv4 audit records])
Darren Tuckeracada072008-02-25 21:05:04 +1100626 [#include <bsm/audit.h>]
Tim Rice648f8762011-01-26 12:38:57 -0800627 AC_DEFINE([LASTLOG_WRITE_PUTUTXLINE], [1],
Damien Miller20e231f2009-02-12 13:12:21 +1100628 [Define if pututxline updates lastlog too])
Darren Tuckeracada072008-02-25 21:05:04 +1100629 )
Damien Millerc09182f2011-06-03 12:11:38 +1000630 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV],
631 [Define to a Set Process Title type if your system is
632 supported by bsd-setproctitle.c])
Damien Millercd5e52e2011-06-27 07:18:18 +1000633 AC_CHECK_FUNCS([sandbox_init])
634 AC_CHECK_HEADERS([sandbox.h])
Ben Lindstromfed7bb42001-07-15 18:30:42 +0000635 ;;
Darren Tucker57b29202006-09-10 20:25:51 +1000636*-*-dragonfly*)
637 SSHDLIBS="$SSHDLIBS -lcrypt"
Darren Tucker882abfd2013-11-09 00:17:41 +1100638 TEST_MALLOC_OPTIONS="AFGJPRX"
Darren Tucker57b29202006-09-10 20:25:51 +1000639 ;;
Darren Tuckera83d90f2010-03-26 10:27:33 +1100640*-*-haiku*)
641 LIBS="$LIBS -lbsd "
Tim Rice648f8762011-01-26 12:38:57 -0800642 AC_CHECK_LIB([network], [socket])
643 AC_DEFINE([HAVE_U_INT64_T])
Darren Tuckera83d90f2010-03-26 10:27:33 +1100644 MANTYPE=man
645 ;;
Darren Tuckerfd333282005-05-28 18:31:42 +1000646*-*-hpux*)
647 # first we define all of the options common to all HP-UX releases
Kevin Steves315f8b72001-06-28 00:24:41 +0000648 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
Damien Miller9a947342000-08-30 10:03:33 +1100649 IPADDR_IN_DISPLAY=yes
Tim Rice648f8762011-01-26 12:38:57 -0800650 AC_DEFINE([USE_PIPES])
651 AC_DEFINE([LOGIN_NO_ENDOPT], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700652 [Define if your login program cannot handle end of options ("--")])
Tim Rice648f8762011-01-26 12:38:57 -0800653 AC_DEFINE([LOGIN_NEEDS_UTMPX])
654 AC_DEFINE([LOCKED_PASSWD_STRING], ["*"],
Tim Rice7df8d392005-09-19 09:33:39 -0700655 [String used in /etc/passwd to denote locked account])
Tim Rice648f8762011-01-26 12:38:57 -0800656 AC_DEFINE([SPT_TYPE], [SPT_PSTAT])
Darren Tuckeraa97d132013-03-12 11:31:05 +1100657 AC_DEFINE([PLATFORM_SYS_DIR_UID], 2, [System dirs owned by bin (uid 2)])
Tim Rice90f42b02011-06-02 18:17:49 -0700658 maildir="/var/mail"
Tim Ricef028f1e2002-07-19 12:41:10 -0700659 LIBS="$LIBS -lsec"
Tim Rice648f8762011-01-26 12:38:57 -0800660 AC_CHECK_LIB([xnet], [t_error], ,
661 [AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***])])
Darren Tuckerfd333282005-05-28 18:31:42 +1000662
663 # next, we define all of the options specific to major releases
664 case "$host" in
665 *-*-hpux10*)
666 if test -z "$GCC"; then
667 CFLAGS="$CFLAGS -Ae"
668 fi
669 ;;
670 *-*-hpux11*)
Tim Rice648f8762011-01-26 12:38:57 -0800671 AC_DEFINE([PAM_SUN_CODEBASE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700672 [Define if you are using Solaris-derived PAM which
673 passes pam_messages to the conversation function
674 with an extra level of indirection])
Tim Rice648f8762011-01-26 12:38:57 -0800675 AC_DEFINE([DISABLE_UTMP], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700676 [Define if you don't want to use utmp])
Tim Rice648f8762011-01-26 12:38:57 -0800677 AC_DEFINE([USE_BTMP], [1], [Use btmp to log bad logins])
Darren Tuckerfd333282005-05-28 18:31:42 +1000678 check_for_hpux_broken_getaddrinfo=1
679 check_for_conflicting_getspnam=1
680 ;;
681 esac
682
683 # lastly, we define options specific to minor releases
684 case "$host" in
685 *-*-hpux10.26)
Tim Rice648f8762011-01-26 12:38:57 -0800686 AC_DEFINE([HAVE_SECUREWARE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700687 [Define if you have SecureWare-based
688 protected password database])
Darren Tuckerfd333282005-05-28 18:31:42 +1000689 disable_ptmx_check=yes
690 LIBS="$LIBS -lsecpw"
691 ;;
692 esac
Damien Miller1bead332000-04-30 00:47:29 +1000693 ;;
Damien Millerbeb4ba51999-12-28 15:09:35 +1100694*-*-irix5*)
Damien Miller190d5a82000-09-30 09:43:19 +1100695 PATH="$PATH:/usr/etc"
Tim Rice648f8762011-01-26 12:38:57 -0800696 AC_DEFINE([BROKEN_INET_NTOA], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700697 [Define if you system's inet_ntoa is busted
698 (e.g. Irix gcc issue)])
Tim Rice648f8762011-01-26 12:38:57 -0800699 AC_DEFINE([SETEUID_BREAKS_SETUID])
700 AC_DEFINE([BROKEN_SETREUID])
701 AC_DEFINE([BROKEN_SETREGID])
702 AC_DEFINE([WITH_ABBREV_NO_TTY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700703 [Define if you shouldn't strip 'tty' from your
704 ttyname in [uw]tmp])
Tim Rice648f8762011-01-26 12:38:57 -0800705 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Damien Miller1808f382000-01-06 12:03:12 +1100706 ;;
707*-*-irix6*)
Damien Miller190d5a82000-09-30 09:43:19 +1100708 PATH="$PATH:/usr/etc"
Tim Rice648f8762011-01-26 12:38:57 -0800709 AC_DEFINE([WITH_IRIX_ARRAY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700710 [Define if you have/want arrays
711 (cluster-wide session managment, not C arrays)])
Tim Rice648f8762011-01-26 12:38:57 -0800712 AC_DEFINE([WITH_IRIX_PROJECT], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700713 [Define if you want IRIX project management])
Tim Rice648f8762011-01-26 12:38:57 -0800714 AC_DEFINE([WITH_IRIX_AUDIT], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700715 [Define if you want IRIX audit trails])
Tim Rice648f8762011-01-26 12:38:57 -0800716 AC_CHECK_FUNC([jlimit_startjob], [AC_DEFINE([WITH_IRIX_JOBS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700717 [Define if you want IRIX kernel jobs])])
Tim Rice648f8762011-01-26 12:38:57 -0800718 AC_DEFINE([BROKEN_INET_NTOA])
719 AC_DEFINE([SETEUID_BREAKS_SETUID])
720 AC_DEFINE([BROKEN_SETREUID])
721 AC_DEFINE([BROKEN_SETREGID])
722 AC_DEFINE([BROKEN_UPDWTMPX], [1], [updwtmpx is broken (if present)])
723 AC_DEFINE([WITH_ABBREV_NO_TTY])
724 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Damien Millerbeb4ba51999-12-28 15:09:35 +1100725 ;;
Damien Miller90551722009-02-16 15:37:03 +1100726*-*-k*bsd*-gnu | *-*-kopensolaris*-gnu)
727 check_for_libcrypt_later=1
Tim Rice648f8762011-01-26 12:38:57 -0800728 AC_DEFINE([PAM_TTY_KLUDGE])
729 AC_DEFINE([LOCKED_PASSWD_PREFIX], ["!"])
730 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV])
731 AC_DEFINE([_PATH_BTMP], ["/var/log/btmp"], [log for bad login attempts])
732 AC_DEFINE([USE_BTMP], [1], [Use btmp to log bad logins])
Damien Miller90551722009-02-16 15:37:03 +1100733 ;;
Damien Millerb29ea912000-01-15 14:12:03 +1100734*-*-linux*)
735 no_dev_ptmx=1
Damien Miller852472a2014-01-22 16:31:18 +1100736 use_pie=auto
Damien Millera64b57a2001-01-17 10:44:13 +1100737 check_for_libcrypt_later=1
Darren Tucker70a3d552003-08-21 17:58:29 +1000738 check_for_openpty_ctty_bug=1
Tim Rice648f8762011-01-26 12:38:57 -0800739 AC_DEFINE([PAM_TTY_KLUDGE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700740 [Work around problematic Linux PAM modules handling of PAM_TTY])
Tim Rice648f8762011-01-26 12:38:57 -0800741 AC_DEFINE([LOCKED_PASSWD_PREFIX], ["!"],
Tim Rice7df8d392005-09-19 09:33:39 -0700742 [String used in /etc/passwd to denote locked account])
Tim Rice648f8762011-01-26 12:38:57 -0800743 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV])
744 AC_DEFINE([LINK_OPNOTSUPP_ERRNO], [EPERM],
Tim Rice7df8d392005-09-19 09:33:39 -0700745 [Define to whatever link() returns for "not supported"
746 if it doesn't return EOPNOTSUPP.])
Tim Rice648f8762011-01-26 12:38:57 -0800747 AC_DEFINE([_PATH_BTMP], ["/var/log/btmp"], [log for bad login attempts])
748 AC_DEFINE([USE_BTMP])
749 AC_DEFINE([LINUX_OOM_ADJUST], [1], [Adjust Linux out-of-memory killer])
Damien Miller7bcb0892000-03-11 20:45:40 +1100750 inet6_default_4in6=yes
Darren Tucker3c016542003-05-02 20:48:21 +1000751 case `uname -r` in
Darren Tuckerc437cda2003-05-10 17:05:46 +1000752 1.*|2.0.*)
Tim Rice648f8762011-01-26 12:38:57 -0800753 AC_DEFINE([BROKEN_CMSG_TYPE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700754 [Define if cmsg_type is not passed correctly])
Darren Tucker3c016542003-05-02 20:48:21 +1000755 ;;
Darren Tucker3c016542003-05-02 20:48:21 +1000756 esac
Damien Miller89e03ba2005-12-31 16:42:03 +1100757 # tun(4) forwarding compat code
Tim Rice648f8762011-01-26 12:38:57 -0800758 AC_CHECK_HEADERS([linux/if_tun.h])
Damien Millerbd4e4102006-01-01 21:03:30 +1100759 if test "x$ac_cv_header_linux_if_tun_h" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -0800760 AC_DEFINE([SSH_TUN_LINUX], [1],
Damien Miller89e03ba2005-12-31 16:42:03 +1100761 [Open tunnel devices the Linux tun/tap way])
Tim Rice648f8762011-01-26 12:38:57 -0800762 AC_DEFINE([SSH_TUN_COMPAT_AF], [1],
Damien Miller89e03ba2005-12-31 16:42:03 +1100763 [Use tunnel device compatibility to OpenBSD])
Tim Rice648f8762011-01-26 12:38:57 -0800764 AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
Damien Miller89e03ba2005-12-31 16:42:03 +1100765 [Prepend the address family to IP tunnel traffic])
766 fi
Darren Tucker60395f92012-07-03 14:31:18 +1000767 AC_CHECK_HEADERS([linux/seccomp.h linux/filter.h linux/audit.h], [],
768 [], [#include <linux/types.h>])
Damien Millere0956e32012-04-04 11:27:54 +1000769 AC_CHECK_FUNCS([prctl])
Damien Miller91f40d82013-02-22 11:37:00 +1100770 AC_MSG_CHECKING([for seccomp architecture])
771 seccomp_audit_arch=
Damien Millere0956e32012-04-04 11:27:54 +1000772 case "$host" in
773 x86_64-*)
Damien Miller91f40d82013-02-22 11:37:00 +1100774 seccomp_audit_arch=AUDIT_ARCH_X86_64
Damien Millere0956e32012-04-04 11:27:54 +1000775 ;;
776 i*86-*)
Damien Miller91f40d82013-02-22 11:37:00 +1100777 seccomp_audit_arch=AUDIT_ARCH_I386
Damien Millere0956e32012-04-04 11:27:54 +1000778 ;;
Damien Miller91f40d82013-02-22 11:37:00 +1100779 arm*-*)
780 seccomp_audit_arch=AUDIT_ARCH_ARM
781 ;;
Damien Millere0956e32012-04-04 11:27:54 +1000782 esac
Damien Miller91f40d82013-02-22 11:37:00 +1100783 if test "x$seccomp_audit_arch" != "x" ; then
784 AC_MSG_RESULT(["$seccomp_audit_arch"])
785 AC_DEFINE_UNQUOTED([SECCOMP_AUDIT_ARCH], [$seccomp_audit_arch],
786 [Specify the system call convention in use])
787 else
788 AC_MSG_RESULT([architecture not supported])
789 fi
Damien Millerb29ea912000-01-15 14:12:03 +1100790 ;;
Ben Lindstromb5628642000-10-18 00:02:25 +0000791mips-sony-bsd|mips-sony-newsos4)
Tim Rice648f8762011-01-26 12:38:57 -0800792 AC_DEFINE([NEED_SETPGRP], [1], [Need setpgrp to acquire controlling tty])
Ben Lindstromb5628642000-10-18 00:02:25 +0000793 SONY=1
Ben Lindstromb5628642000-10-18 00:02:25 +0000794 ;;
Damien Milleree1c0b32000-01-21 00:18:15 +1100795*-*-netbsd*)
Damien Millerfc93d4b2002-09-04 23:26:29 +1000796 check_for_libcrypt_before=1
Tim Riceeae17cc2005-03-17 16:52:20 -0800797 if test "x$withval" != "xno" ; then
Tim Rice88368a32003-12-08 12:35:59 -0800798 need_dash_r=1
799 fi
Tim Rice648f8762011-01-26 12:38:57 -0800800 AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
Damien Miller2dcddbf2006-01-01 19:47:05 +1100801 AC_CHECK_HEADER([net/if_tap.h], ,
Tim Rice648f8762011-01-26 12:38:57 -0800802 AC_DEFINE([SSH_TUN_NO_L2], [1], [No layer 2 tunnel support]))
803 AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
Damien Miller2dcddbf2006-01-01 19:47:05 +1100804 [Prepend the address family to IP tunnel traffic])
Darren Tucker882abfd2013-11-09 00:17:41 +1100805 TEST_MALLOC_OPTIONS="AJRX"
Darren Tucker42a09252014-01-23 23:14:39 +1100806 AC_DEFINE([BROKEN_STRNVIS], [1],
807 [NetBSD strnvis argument order is swapped compared to OpenBSD])
Damien Millerf5bbd3b2014-01-30 11:26:46 +1100808 AC_DEFINE([BROKEN_READ_COMPARISON], [1],
809 [NetBSD read function is sometimes redirected, breaking atomicio comparisons against it])
Damien Milleree1c0b32000-01-21 00:18:15 +1100810 ;;
Damien Millerfbd884a2001-02-27 08:39:07 +1100811*-*-freebsd*)
812 check_for_libcrypt_later=1
Tim Rice648f8762011-01-26 12:38:57 -0800813 AC_DEFINE([LOCKED_PASSWD_PREFIX], ["*LOCKED*"], [Account locked with pw(1)])
814 AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
Damien Miller2dcddbf2006-01-01 19:47:05 +1100815 AC_CHECK_HEADER([net/if_tap.h], ,
Tim Rice648f8762011-01-26 12:38:57 -0800816 AC_DEFINE([SSH_TUN_NO_L2], [1], [No layer 2 tunnel support]))
817 AC_DEFINE([BROKEN_GLOB], [1], [FreeBSD glob does not do what we need])
Darren Tucker42a09252014-01-23 23:14:39 +1100818 AC_DEFINE([BROKEN_STRNVIS], [1],
819 [FreeBSD strnvis argument order is swapped compared to OpenBSD])
Darren Tucker882abfd2013-11-09 00:17:41 +1100820 TEST_MALLOC_OPTIONS="AJRX"
Damien Miller2035b222014-01-26 09:39:53 +1100821 # Preauth crypto occasionally uses file descriptors for crypto offload
822 # and will crash if they cannot be opened.
Damien Miller5b447c02014-01-26 09:46:53 +1100823 AC_DEFINE([SANDBOX_SKIP_RLIMIT_NOFILE], [1],
Tim Rice03ae0812014-02-21 09:09:34 -0800824 [define if setrlimit RLIMIT_NOFILE breaks things])
Damien Millerfbd884a2001-02-27 08:39:07 +1100825 ;;
Darren Tuckered9eb022003-09-22 11:18:47 +1000826*-*-bsdi*)
Tim Rice648f8762011-01-26 12:38:57 -0800827 AC_DEFINE([SETEUID_BREAKS_SETUID])
828 AC_DEFINE([BROKEN_SETREUID])
829 AC_DEFINE([BROKEN_SETREGID])
Darren Tuckered9eb022003-09-22 11:18:47 +1000830 ;;
Damien Miller0f91b4e2000-06-18 15:43:25 +1000831*-next-*)
Damien Miller0f91b4e2000-06-18 15:43:25 +1000832 conf_lastlog_location="/usr/adm/lastlog"
Damien Millere5192fa2000-08-29 14:30:37 +1100833 conf_utmp_location=/etc/utmp
834 conf_wtmp_location=/usr/adm/wtmp
Tim Rice90f42b02011-06-02 18:17:49 -0700835 maildir=/usr/spool/mail
Tim Rice648f8762011-01-26 12:38:57 -0800836 AC_DEFINE([HAVE_NEXT], [1], [Define if you are on NeXT])
837 AC_DEFINE([BROKEN_REALPATH])
838 AC_DEFINE([USE_PIPES])
839 AC_DEFINE([BROKEN_SAVED_UIDS], [1], [Needed for NeXT])
Damien Miller0f91b4e2000-06-18 15:43:25 +1000840 ;;
Darren Tucker4a422572005-07-14 17:22:11 +1000841*-*-openbsd*)
Damien Miller852472a2014-01-22 16:31:18 +1100842 use_pie=auto
Tim Rice648f8762011-01-26 12:38:57 -0800843 AC_DEFINE([HAVE_ATTRIBUTE__SENTINEL__], [1], [OpenBSD's gcc has sentinel])
844 AC_DEFINE([HAVE_ATTRIBUTE__BOUNDED__], [1], [OpenBSD's gcc has bounded])
845 AC_DEFINE([SSH_TUN_OPENBSD], [1], [Open tunnel devices the OpenBSD way])
846 AC_DEFINE([SYSLOG_R_SAFE_IN_SIGHAND], [1],
Damien Millerbb598142006-08-19 08:38:23 +1000847 [syslog_r function is safe to use in in a signal handler])
Darren Tucker882abfd2013-11-09 00:17:41 +1100848 TEST_MALLOC_OPTIONS="AFGJPRX"
Darren Tucker4a422572005-07-14 17:22:11 +1000849 ;;
Damien Miller75b1d102000-01-07 14:01:41 +1100850*-*-solaris*)
Tim Riceeae17cc2005-03-17 16:52:20 -0800851 if test "x$withval" != "xno" ; then
Tim Ricead4a1882004-02-29 15:53:37 -0800852 need_dash_r=1
853 fi
Tim Rice648f8762011-01-26 12:38:57 -0800854 AC_DEFINE([PAM_SUN_CODEBASE])
855 AC_DEFINE([LOGIN_NEEDS_UTMPX])
856 AC_DEFINE([LOGIN_NEEDS_TERM], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700857 [Some versions of /bin/login need the TERM supplied
858 on the commandline])
Tim Rice648f8762011-01-26 12:38:57 -0800859 AC_DEFINE([PAM_TTY_KLUDGE])
860 AC_DEFINE([SSHPAM_CHAUTHTOK_NEEDS_RUID], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700861 [Define if pam_chauthtok wants real uid set
862 to the unpriv'ed user])
Tim Rice648f8762011-01-26 12:38:57 -0800863 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Darren Tuckerc437cda2003-05-10 17:05:46 +1000864 # Pushing STREAMS modules will cause sshd to acquire a controlling tty.
Tim Rice648f8762011-01-26 12:38:57 -0800865 AC_DEFINE([SSHD_ACQUIRES_CTTY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700866 [Define if sshd somehow reacquires a controlling TTY
867 after setsid()])
Tim Rice648f8762011-01-26 12:38:57 -0800868 AC_DEFINE([PASSWD_NEEDS_USERNAME], [1], [must supply username to passwd
Darren Tucker0249f932006-06-24 12:10:07 +1000869 in case the name is longer than 8 chars])
Tim Rice648f8762011-01-26 12:38:57 -0800870 AC_DEFINE([BROKEN_TCGETATTR_ICANON], [1], [tcgetattr with ICANON may hang])
Darren Tuckere1a790d2003-09-16 11:52:19 +1000871 external_path_file=/etc/default/login
andre2ff7b5d2000-06-03 14:57:40 +0000872 # hardwire lastlog location (can't detect it on some versions)
873 conf_lastlog_location="/var/adm/lastlog"
Tim Rice648f8762011-01-26 12:38:57 -0800874 AC_MSG_CHECKING([for obsolete utmp and wtmp in solaris2.x])
Damien Millera1cb6442000-06-09 11:58:35 +1000875 sol2ver=`echo "$host"| sed -e 's/.*[[0-9]]\.//'`
876 if test "$sol2ver" -ge 8; then
Tim Rice648f8762011-01-26 12:38:57 -0800877 AC_MSG_RESULT([yes])
878 AC_DEFINE([DISABLE_UTMP])
879 AC_DEFINE([DISABLE_WTMP], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700880 [Define if you don't want to use wtmp])
Damien Millera1cb6442000-06-09 11:58:35 +1000881 else
Tim Rice648f8762011-01-26 12:38:57 -0800882 AC_MSG_RESULT([no])
Damien Millera1cb6442000-06-09 11:58:35 +1000883 fi
Tim Rice648f8762011-01-26 12:38:57 -0800884 AC_ARG_WITH([solaris-contracts],
Damien Miller1b06dc32006-08-31 03:24:41 +1000885 [ --with-solaris-contracts Enable Solaris process contracts (experimental)],
886 [
Tim Rice648f8762011-01-26 12:38:57 -0800887 AC_CHECK_LIB([contract], [ct_tmpl_activate],
888 [ AC_DEFINE([USE_SOLARIS_PROCESS_CONTRACTS], [1],
Damien Miller1b06dc32006-08-31 03:24:41 +1000889 [Define if you have Solaris process contracts])
890 SSHDLIBS="$SSHDLIBS -lcontract"
Damien Miller1b06dc32006-08-31 03:24:41 +1000891 SPC_MSG="yes" ], )
892 ],
893 )
Tim Rice648f8762011-01-26 12:38:57 -0800894 AC_ARG_WITH([solaris-projects],
Darren Tucker97528352010-11-05 12:03:05 +1100895 [ --with-solaris-projects Enable Solaris projects (experimental)],
896 [
Tim Rice648f8762011-01-26 12:38:57 -0800897 AC_CHECK_LIB([project], [setproject],
898 [ AC_DEFINE([USE_SOLARIS_PROJECTS], [1],
Darren Tucker97528352010-11-05 12:03:05 +1100899 [Define if you have Solaris projects])
900 SSHDLIBS="$SSHDLIBS -lproject"
Darren Tucker97528352010-11-05 12:03:05 +1100901 SP_MSG="yes" ], )
902 ],
903 )
Tim Rice5ab9b632013-06-02 14:05:48 -0700904 TEST_SHELL=$SHELL # let configure find us a capable shell
Damien Miller75b1d102000-01-07 14:01:41 +1100905 ;;
Damien Millerdfc83f42000-05-20 15:02:59 +1000906*-*-sunos4*)
Ben Lindstrom28bfc0d2000-12-18 19:58:57 +0000907 CPPFLAGS="$CPPFLAGS -DSUNOS4"
Tim Rice648f8762011-01-26 12:38:57 -0800908 AC_CHECK_FUNCS([getpwanam])
909 AC_DEFINE([PAM_SUN_CODEBASE])
Damien Miller36ccb5c2000-08-09 16:34:27 +1000910 conf_utmp_location=/etc/utmp
911 conf_wtmp_location=/var/adm/wtmp
912 conf_lastlog_location=/var/adm/lastlog
Tim Rice648f8762011-01-26 12:38:57 -0800913 AC_DEFINE([USE_PIPES])
Damien Millerdfc83f42000-05-20 15:02:59 +1000914 ;;
Ben Lindstrom603bdfd2001-02-12 07:29:45 +0000915*-ncr-sysv*)
Tim Rice13aae5e2001-10-21 17:53:58 -0700916 LIBS="$LIBS -lc89"
Tim Rice648f8762011-01-26 12:38:57 -0800917 AC_DEFINE([USE_PIPES])
918 AC_DEFINE([SSHD_ACQUIRES_CTTY])
919 AC_DEFINE([SETEUID_BREAKS_SETUID])
920 AC_DEFINE([BROKEN_SETREUID])
921 AC_DEFINE([BROKEN_SETREGID])
Ben Lindstrom603bdfd2001-02-12 07:29:45 +0000922 ;;
Damien Miller2ae714f2000-07-11 09:29:50 +1000923*-sni-sysv*)
Tim Riceffdf4aa2001-10-27 10:45:36 -0700924 # /usr/ucblib MUST NOT be searched on ReliantUNIX
Tim Rice648f8762011-01-26 12:38:57 -0800925 AC_CHECK_LIB([dl], [dlsym], ,)
Darren Tucker79d09fa2005-11-24 22:34:54 +1100926 # -lresolv needs to be at the end of LIBS or DNS lookups break
Tim Rice648f8762011-01-26 12:38:57 -0800927 AC_CHECK_LIB([resolv], [res_query], [ LIBS="$LIBS -lresolv" ])
Damien Millerfd9885e2001-01-10 08:16:53 +1100928 IPADDR_IN_DISPLAY=yes
Tim Rice648f8762011-01-26 12:38:57 -0800929 AC_DEFINE([USE_PIPES])
930 AC_DEFINE([IP_TOS_IS_BROKEN])
931 AC_DEFINE([SETEUID_BREAKS_SETUID])
932 AC_DEFINE([BROKEN_SETREUID])
933 AC_DEFINE([BROKEN_SETREGID])
934 AC_DEFINE([SSHD_ACQUIRES_CTTY])
Darren Tuckere1a790d2003-09-16 11:52:19 +1000935 external_path_file=/etc/default/login
Tim Riceffdf4aa2001-10-27 10:45:36 -0700936 # /usr/ucblib/libucb.a no longer needed on ReliantUNIX
937 # Attention: always take care to bind libsocket and libnsl before libc,
938 # otherwise you will find lots of "SIOCGPGRP errno 22" on syslog
Damien Miller2ae714f2000-07-11 09:29:50 +1000939 ;;
Tim Rice0f83d292004-12-08 18:29:58 -0800940# UnixWare 1.x, UnixWare 2.x, and others based on code from Univel.
Damien Miller78315eb2000-09-29 23:01:36 +1100941*-*-sysv4.2*)
Tim Rice648f8762011-01-26 12:38:57 -0800942 AC_DEFINE([USE_PIPES])
943 AC_DEFINE([SETEUID_BREAKS_SETUID])
944 AC_DEFINE([BROKEN_SETREUID])
945 AC_DEFINE([BROKEN_SETREGID])
946 AC_DEFINE([PASSWD_NEEDS_USERNAME], [1], [must supply username to passwd])
947 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Tim Rice5ab9b632013-06-02 14:05:48 -0700948 TEST_SHELL=$SHELL # let configure find us a capable shell
Damien Miller78315eb2000-09-29 23:01:36 +1100949 ;;
Tim Rice0f83d292004-12-08 18:29:58 -0800950# UnixWare 7.x, OpenUNIX 8
Damien Miller78315eb2000-09-29 23:01:36 +1100951*-*-sysv5*)
Tim Rice641ebf12010-01-17 17:05:39 -0800952 CPPFLAGS="$CPPFLAGS -Dvsnprintf=_xvsnprintf -Dsnprintf=_xsnprintf"
Tim Rice648f8762011-01-26 12:38:57 -0800953 AC_DEFINE([UNIXWARE_LONG_PASSWORDS], [1], [Support passwords > 8 chars])
954 AC_DEFINE([USE_PIPES])
955 AC_DEFINE([SETEUID_BREAKS_SETUID])
956 AC_DEFINE([BROKEN_GETADDRINFO])
957 AC_DEFINE([BROKEN_SETREUID])
958 AC_DEFINE([BROKEN_SETREGID])
959 AC_DEFINE([PASSWD_NEEDS_USERNAME])
Tim Rice5ab9b632013-06-02 14:05:48 -0700960 TEST_SHELL=$SHELL # let configure find us a capable shell
Tim Rice4dbacff2005-06-01 20:09:28 -0700961 case "$host" in
962 *-*-sysv5SCO_SV*) # SCO OpenServer 6.x
Tim Rice90f42b02011-06-02 18:17:49 -0700963 maildir=/var/spool/mail
Tim Rice648f8762011-01-26 12:38:57 -0800964 AC_DEFINE([BROKEN_LIBIAF], [1],
Tim Rice7df8d392005-09-19 09:33:39 -0700965 [ia_uinfo routines not supported by OS yet])
Tim Rice648f8762011-01-26 12:38:57 -0800966 AC_DEFINE([BROKEN_UPDWTMPX])
967 AC_CHECK_LIB([prot], [getluid], [ LIBS="$LIBS -lprot"
968 AC_CHECK_FUNCS([getluid setluid], , , [-lprot])
969 AC_DEFINE([HAVE_SECUREWARE])
970 AC_DEFINE([DISABLE_SHADOW])
971 ], , )
Tim Rice4dbacff2005-06-01 20:09:28 -0700972 ;;
Tim Rice648f8762011-01-26 12:38:57 -0800973 *) AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
Tim Rice26767912009-01-07 20:50:08 -0800974 check_for_libcrypt_later=1
Tim Rice46259d82005-11-28 18:40:34 -0800975 ;;
Tim Rice4dbacff2005-06-01 20:09:28 -0700976 esac
Damien Miller78315eb2000-09-29 23:01:36 +1100977 ;;
Damien Miller75b1d102000-01-07 14:01:41 +1100978*-*-sysv*)
Damien Miller75b1d102000-01-07 14:01:41 +1100979 ;;
Tim Rice0f83d292004-12-08 18:29:58 -0800980# SCO UNIX and OEM versions of SCO UNIX
Damien Miller78315eb2000-09-29 23:01:36 +1100981*-*-sco3.2v4*)
Tim Ricec390c8d2005-03-07 01:21:37 -0800982 AC_MSG_ERROR("This Platform is no longer supported.")
Damien Miller78315eb2000-09-29 23:01:36 +1100983 ;;
Tim Rice0f83d292004-12-08 18:29:58 -0800984# SCO OpenServer 5.x
Damien Miller78315eb2000-09-29 23:01:36 +1100985*-*-sco3.2v5*)
Tim Rice89fe3f32003-01-19 20:20:24 -0800986 if test -z "$GCC"; then
987 CFLAGS="$CFLAGS -belf"
988 fi
Damien Miller5dfe9762001-02-16 12:05:39 +1100989 LIBS="$LIBS -lprot -lx -ltinfo -lm"
Damien Millera66626b2000-06-13 18:57:53 +1000990 no_dev_ptmx=1
Tim Rice648f8762011-01-26 12:38:57 -0800991 AC_DEFINE([USE_PIPES])
992 AC_DEFINE([HAVE_SECUREWARE])
993 AC_DEFINE([DISABLE_SHADOW])
994 AC_DEFINE([DISABLE_FD_PASSING])
995 AC_DEFINE([SETEUID_BREAKS_SETUID])
996 AC_DEFINE([BROKEN_GETADDRINFO])
997 AC_DEFINE([BROKEN_SETREUID])
998 AC_DEFINE([BROKEN_SETREGID])
999 AC_DEFINE([WITH_ABBREV_NO_TTY])
1000 AC_DEFINE([BROKEN_UPDWTMPX])
1001 AC_DEFINE([PASSWD_NEEDS_USERNAME])
1002 AC_CHECK_FUNCS([getluid setluid])
Tim Rice07183b82001-04-25 21:40:28 -07001003 MANTYPE=man
Tim Rice5ab9b632013-06-02 14:05:48 -07001004 TEST_SHELL=$SHELL # let configure find us a capable shell
Tim Riceaa86c392013-03-16 20:55:46 -07001005 SKIP_DISABLE_LASTLOG_DEFINE=yes
Damien Millera66626b2000-06-13 18:57:53 +10001006 ;;
Ben Lindstrom232ccf72002-07-22 23:34:25 +00001007*-*-unicosmk*)
Tim Rice648f8762011-01-26 12:38:57 -08001008 AC_DEFINE([NO_SSH_LASTLOG], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001009 [Define if you don't want to use lastlog in session.c])
Tim Rice648f8762011-01-26 12:38:57 -08001010 AC_DEFINE([SETEUID_BREAKS_SETUID])
1011 AC_DEFINE([BROKEN_SETREUID])
1012 AC_DEFINE([BROKEN_SETREGID])
1013 AC_DEFINE([USE_PIPES])
1014 AC_DEFINE([DISABLE_FD_PASSING])
Ben Lindstrom232ccf72002-07-22 23:34:25 +00001015 LDFLAGS="$LDFLAGS"
1016 LIBS="$LIBS -lgen -lrsc -lshare -luex -lacm"
1017 MANTYPE=cat
Ben Lindstrom762104e2002-07-23 00:00:05 +00001018 ;;
Darren Tucker9f7ffc52003-09-10 11:39:05 +10001019*-*-unicosmp*)
Tim Rice648f8762011-01-26 12:38:57 -08001020 AC_DEFINE([SETEUID_BREAKS_SETUID])
1021 AC_DEFINE([BROKEN_SETREUID])
1022 AC_DEFINE([BROKEN_SETREGID])
1023 AC_DEFINE([WITH_ABBREV_NO_TTY])
1024 AC_DEFINE([USE_PIPES])
1025 AC_DEFINE([DISABLE_FD_PASSING])
Darren Tucker9f7ffc52003-09-10 11:39:05 +10001026 LDFLAGS="$LDFLAGS"
Darren Tucker2df33432004-01-30 14:34:21 +11001027 LIBS="$LIBS -lgen -lacid -ldb"
Darren Tucker9f7ffc52003-09-10 11:39:05 +10001028 MANTYPE=cat
1029 ;;
Ben Lindstromd9e08242001-07-22 19:32:00 +00001030*-*-unicos*)
Tim Rice648f8762011-01-26 12:38:57 -08001031 AC_DEFINE([SETEUID_BREAKS_SETUID])
1032 AC_DEFINE([BROKEN_SETREUID])
1033 AC_DEFINE([BROKEN_SETREGID])
1034 AC_DEFINE([USE_PIPES])
1035 AC_DEFINE([DISABLE_FD_PASSING])
1036 AC_DEFINE([NO_SSH_LASTLOG])
Ben Lindstrom232ccf72002-07-22 23:34:25 +00001037 LDFLAGS="$LDFLAGS -Wl,-Dmsglevel=334:fatal"
1038 LIBS="$LIBS -lgen -lrsc -lshare -luex -lacm"
1039 MANTYPE=cat
Tim Ricee991e3c2001-08-07 15:29:07 -07001040 ;;
Damien Millerb8c656e2000-06-28 15:22:41 +10001041*-dec-osf*)
Tim Rice648f8762011-01-26 12:38:57 -08001042 AC_MSG_CHECKING([for Digital Unix SIA])
Ben Lindstrom72af2ef2001-05-08 20:42:28 +00001043 no_osfsia=""
Tim Rice648f8762011-01-26 12:38:57 -08001044 AC_ARG_WITH([osfsia],
Ben Lindstrom72af2ef2001-05-08 20:42:28 +00001045 [ --with-osfsia Enable Digital Unix SIA],
1046 [
1047 if test "x$withval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08001048 AC_MSG_RESULT([disabled])
Ben Lindstrom72af2ef2001-05-08 20:42:28 +00001049 no_osfsia=1
1050 fi
1051 ],
1052 )
1053 if test -z "$no_osfsia" ; then
Damien Millerb8c656e2000-06-28 15:22:41 +10001054 if test -f /etc/sia/matrix.conf; then
Tim Rice648f8762011-01-26 12:38:57 -08001055 AC_MSG_RESULT([yes])
1056 AC_DEFINE([HAVE_OSF_SIA], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001057 [Define if you have Digital Unix Security
1058 Integration Architecture])
Tim Rice648f8762011-01-26 12:38:57 -08001059 AC_DEFINE([DISABLE_LOGIN], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001060 [Define if you don't want to use your
1061 system's login() call])
Tim Rice648f8762011-01-26 12:38:57 -08001062 AC_DEFINE([DISABLE_FD_PASSING])
Damien Millerb8c656e2000-06-28 15:22:41 +10001063 LIBS="$LIBS -lsecurity -ldb -lm -laud"
Damien Miller1b06dc32006-08-31 03:24:41 +10001064 SIA_MSG="yes"
Damien Millerb8c656e2000-06-28 15:22:41 +10001065 else
Tim Rice648f8762011-01-26 12:38:57 -08001066 AC_MSG_RESULT([no])
1067 AC_DEFINE([LOCKED_PASSWD_SUBSTR], ["Nologin"],
Tim Rice7df8d392005-09-19 09:33:39 -07001068 [String used in /etc/passwd to denote locked account])
Damien Millerb8c656e2000-06-28 15:22:41 +10001069 fi
1070 fi
Tim Rice648f8762011-01-26 12:38:57 -08001071 AC_DEFINE([BROKEN_GETADDRINFO])
1072 AC_DEFINE([SETEUID_BREAKS_SETUID])
1073 AC_DEFINE([BROKEN_SETREUID])
1074 AC_DEFINE([BROKEN_SETREGID])
1075 AC_DEFINE([BROKEN_READV_COMPARISON], [1], [Can't do comparisons on readv])
Damien Millerb8c656e2000-06-28 15:22:41 +10001076 ;;
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00001077
Tim Rice70335a62006-02-04 17:42:58 -08001078*-*-nto-qnx*)
Tim Rice648f8762011-01-26 12:38:57 -08001079 AC_DEFINE([USE_PIPES])
1080 AC_DEFINE([NO_X11_UNIX_SOCKETS])
Tim Rice648f8762011-01-26 12:38:57 -08001081 AC_DEFINE([DISABLE_LASTLOG])
1082 AC_DEFINE([SSHD_ACQUIRES_CTTY])
1083 AC_DEFINE([BROKEN_SHADOW_EXPIRE], [1], [QNX shadow support is broken])
Tim Rice2f993462006-02-11 18:37:48 -08001084 enable_etc_default_login=no # has incompatible /etc/default/login
Darren Tucker8acb3b62007-08-10 14:36:12 +10001085 case "$host" in
1086 *-*-nto-qnx6*)
Tim Rice648f8762011-01-26 12:38:57 -08001087 AC_DEFINE([DISABLE_FD_PASSING])
Darren Tucker8acb3b62007-08-10 14:36:12 +10001088 ;;
1089 esac
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00001090 ;;
Darren Tucker2be1cbb2005-05-27 21:13:40 +10001091
1092*-*-ultrix*)
Tim Rice648f8762011-01-26 12:38:57 -08001093 AC_DEFINE([BROKEN_GETGROUPS], [1], [getgroups(0,NULL) will return -1])
1094 AC_DEFINE([BROKEN_MMAP], [1], [Ultrix mmap can't map files])
1095 AC_DEFINE([NEED_SETPGRP])
1096 AC_DEFINE([HAVE_SYS_SYSLOG_H], [1], [Force use of sys/syslog.h on Ultrix])
Tim Ricefcc7ff12005-06-02 20:28:29 -07001097 ;;
Darren Tucker93e7e8f2005-08-23 08:06:55 +10001098
1099*-*-lynxos)
1100 CFLAGS="$CFLAGS -D__NO_INCLUDE_WARN__"
Tim Rice648f8762011-01-26 12:38:57 -08001101 AC_DEFINE([BROKEN_SETVBUF], [1], [LynxOS has broken setvbuf() implementation])
Darren Tucker93e7e8f2005-08-23 08:06:55 +10001102 ;;
Damien Miller76112de1999-12-21 11:18:08 +11001103esac
1104
Tim Rice648f8762011-01-26 12:38:57 -08001105AC_MSG_CHECKING([compiler and flags for sanity])
1106AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]], [[ exit(0); ]])],
1107 [ AC_MSG_RESULT([yes]) ],
Darren Tucker6eb93042003-06-29 21:30:41 +10001108 [
Tim Rice648f8762011-01-26 12:38:57 -08001109 AC_MSG_RESULT([no])
Darren Tucker6eb93042003-06-29 21:30:41 +10001110 AC_MSG_ERROR([*** compiler cannot create working executables, check config.log ***])
Darren Tuckera0c2b392004-09-11 23:26:37 +10001111 ],
1112 [ AC_MSG_WARN([cross compiling: not checking compiler sanity]) ]
Darren Tucker6eb93042003-06-29 21:30:41 +10001113)
1114
Darren Tucker0c9653f2005-05-28 15:58:14 +10001115dnl Checks for header files.
Damien Millera22ba012000-03-02 23:09:20 +11001116# Checks for libraries.
Tim Rice648f8762011-01-26 12:38:57 -08001117AC_CHECK_FUNC([yp_match], , [AC_CHECK_LIB([nsl], [yp_match])])
1118AC_CHECK_FUNC([setsockopt], , [AC_CHECK_LIB([socket], [setsockopt])])
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00001119
Tim Rice1e1ef642003-09-11 22:19:31 -07001120dnl IRIX and Solaris 2.5.1 have dirname() in libgen
Tim Rice648f8762011-01-26 12:38:57 -08001121AC_CHECK_FUNCS([dirname], [AC_CHECK_HEADERS([libgen.h])] , [
1122 AC_CHECK_LIB([gen], [dirname], [
Tim Rice1e1ef642003-09-11 22:19:31 -07001123 AC_CACHE_CHECK([for broken dirname],
1124 ac_cv_have_broken_dirname, [
1125 save_LIBS="$LIBS"
1126 LIBS="$LIBS -lgen"
Darren Tucker314d89e2005-10-17 23:29:23 +10001127 AC_RUN_IFELSE(
1128 [AC_LANG_SOURCE([[
Tim Rice1e1ef642003-09-11 22:19:31 -07001129#include <libgen.h>
1130#include <string.h>
1131
1132int main(int argc, char **argv) {
1133 char *s, buf[32];
1134
1135 strncpy(buf,"/etc", 32);
1136 s = dirname(buf);
1137 if (!s || strncmp(s, "/", 32) != 0) {
1138 exit(1);
1139 } else {
1140 exit(0);
1141 }
1142}
Darren Tucker314d89e2005-10-17 23:29:23 +10001143 ]])],
Tim Rice1e1ef642003-09-11 22:19:31 -07001144 [ ac_cv_have_broken_dirname="no" ],
Darren Tucker314d89e2005-10-17 23:29:23 +10001145 [ ac_cv_have_broken_dirname="yes" ],
1146 [ ac_cv_have_broken_dirname="no" ],
Tim Rice1e1ef642003-09-11 22:19:31 -07001147 )
1148 LIBS="$save_LIBS"
1149 ])
1150 if test "x$ac_cv_have_broken_dirname" = "xno" ; then
1151 LIBS="$LIBS -lgen"
Tim Rice648f8762011-01-26 12:38:57 -08001152 AC_DEFINE([HAVE_DIRNAME])
1153 AC_CHECK_HEADERS([libgen.h])
Tim Rice1e1ef642003-09-11 22:19:31 -07001154 fi
1155 ])
1156])
1157
Tim Rice648f8762011-01-26 12:38:57 -08001158AC_CHECK_FUNC([getspnam], ,
1159 [AC_CHECK_LIB([gen], [getspnam], [LIBS="$LIBS -lgen"])])
1160AC_SEARCH_LIBS([basename], [gen], [AC_DEFINE([HAVE_BASENAME], [1],
1161 [Define if you have the basename function.])])
Tim Rice1e1ef642003-09-11 22:19:31 -07001162
Tim Rice13aae5e2001-10-21 17:53:58 -07001163dnl zlib is required
Tim Rice648f8762011-01-26 12:38:57 -08001164AC_ARG_WITH([zlib],
Tim Rice13aae5e2001-10-21 17:53:58 -07001165 [ --with-zlib=PATH Use zlib in PATH],
Darren Tucker86a5f8d2005-03-21 09:55:17 +11001166 [ if test "x$withval" = "xno" ; then
1167 AC_MSG_ERROR([*** zlib is required ***])
1168 elif test "x$withval" != "xyes"; then
Tim Rice13aae5e2001-10-21 17:53:58 -07001169 if test -d "$withval/lib"; then
1170 if test -n "${need_dash_r}"; then
Tim Rice02cebcd2001-10-25 10:01:30 -07001171 LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001172 else
Tim Rice02cebcd2001-10-25 10:01:30 -07001173 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001174 fi
1175 else
1176 if test -n "${need_dash_r}"; then
Tim Rice02cebcd2001-10-25 10:01:30 -07001177 LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001178 else
Tim Rice02cebcd2001-10-25 10:01:30 -07001179 LDFLAGS="-L${withval} ${LDFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001180 fi
1181 fi
1182 if test -d "$withval/include"; then
Tim Rice02cebcd2001-10-25 10:01:30 -07001183 CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001184 else
Tim Rice02cebcd2001-10-25 10:01:30 -07001185 CPPFLAGS="-I${withval} ${CPPFLAGS}"
Tim Rice13aae5e2001-10-21 17:53:58 -07001186 fi
Darren Tucker86a5f8d2005-03-21 09:55:17 +11001187 fi ]
Tim Rice13aae5e2001-10-21 17:53:58 -07001188)
1189
Tim Rice648f8762011-01-26 12:38:57 -08001190AC_CHECK_HEADER([zlib.h], ,[AC_MSG_ERROR([*** zlib.h missing - please install first or check config.log ***])])
1191AC_CHECK_LIB([z], [deflate], ,
Tim Ricefcb62202004-01-23 18:35:16 -08001192 [
1193 saved_CPPFLAGS="$CPPFLAGS"
1194 saved_LDFLAGS="$LDFLAGS"
1195 save_LIBS="$LIBS"
1196 dnl Check default zlib install dir
1197 if test -n "${need_dash_r}"; then
1198 LDFLAGS="-L/usr/local/lib -R/usr/local/lib ${saved_LDFLAGS}"
1199 else
1200 LDFLAGS="-L/usr/local/lib ${saved_LDFLAGS}"
1201 fi
1202 CPPFLAGS="-I/usr/local/include ${saved_CPPFLAGS}"
1203 LIBS="$LIBS -lz"
Tim Rice648f8762011-01-26 12:38:57 -08001204 AC_TRY_LINK_FUNC([deflate], [AC_DEFINE([HAVE_LIBZ])],
Tim Ricefcb62202004-01-23 18:35:16 -08001205 [
1206 AC_MSG_ERROR([*** zlib missing - please install first or check config.log ***])
1207 ]
1208 )
1209 ]
1210)
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001211
Tim Rice648f8762011-01-26 12:38:57 -08001212AC_ARG_WITH([zlib-version-check],
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001213 [ --without-zlib-version-check Disable zlib version check],
1214 [ if test "x$withval" = "xno" ; then
1215 zlib_check_nonfatal=1
1216 fi
1217 ]
1218)
1219
Tim Rice648f8762011-01-26 12:38:57 -08001220AC_MSG_CHECKING([for possibly buggy zlib])
1221AC_RUN_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001222#include <stdio.h>
Darren Tuckerc8a0f272013-03-22 12:49:14 +11001223#include <stdlib.h>
Darren Tucker2dcd2392004-01-23 17:13:33 +11001224#include <zlib.h>
Tim Rice648f8762011-01-26 12:38:57 -08001225 ]],
1226 [[
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001227 int a=0, b=0, c=0, d=0, n, v;
1228 n = sscanf(ZLIB_VERSION, "%d.%d.%d.%d", &a, &b, &c, &d);
1229 if (n != 3 && n != 4)
Darren Tucker2dcd2392004-01-23 17:13:33 +11001230 exit(1);
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001231 v = a*1000000 + b*10000 + c*100 + d;
1232 fprintf(stderr, "found zlib version %s (%d)\n", ZLIB_VERSION, v);
1233
1234 /* 1.1.4 is OK */
1235 if (a == 1 && b == 1 && c >= 4)
Darren Tucker2dcd2392004-01-23 17:13:33 +11001236 exit(0);
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001237
Darren Tucker41097ed2005-07-25 15:24:21 +10001238 /* 1.2.3 and up are OK */
1239 if (v >= 1020300)
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001240 exit(0);
1241
Darren Tucker2dcd2392004-01-23 17:13:33 +11001242 exit(2);
Darren Tucker623d92f2004-09-12 22:36:15 +10001243 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001244 AC_MSG_RESULT([no]),
1245 [ AC_MSG_RESULT([yes])
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001246 if test -z "$zlib_check_nonfatal" ; then
1247 AC_MSG_ERROR([*** zlib too old - check config.log ***
1248Your reported zlib version has known security problems. It's possible your
1249vendor has fixed these problems without changing the version number. If you
1250are sure this is the case, you can disable the check by running
1251"./configure --without-zlib-version-check".
Darren Tuckerac1910f2005-07-26 12:00:42 +10001252If you are in doubt, upgrade zlib to version 1.2.3 or greater.
Darren Tucker2f0b5c42005-04-24 17:52:22 +10001253See http://www.gzip.org/zlib/ for details.])
Darren Tuckerdcc736b2004-01-30 14:20:59 +11001254 else
1255 AC_MSG_WARN([zlib version may have security problems])
1256 fi
Darren Tuckera0c2b392004-09-11 23:26:37 +10001257 ],
1258 [ AC_MSG_WARN([cross compiling: not checking zlib version]) ]
Darren Tucker2dcd2392004-01-23 17:13:33 +11001259)
Damien Miller6f9c3372000-10-25 10:06:04 +11001260
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00001261dnl UnixWare 2.x
Tim Rice648f8762011-01-26 12:38:57 -08001262AC_CHECK_FUNC([strcasecmp],
1263 [], [ AC_CHECK_LIB([resolv], [strcasecmp], [LIBS="$LIBS -lresolv"]) ]
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00001264)
Tim Rice648f8762011-01-26 12:38:57 -08001265AC_CHECK_FUNCS([utimes],
1266 [], [ AC_CHECK_LIB([c89], [utimes], [AC_DEFINE([HAVE_UTIMES])
Tim Ricecbb90662002-07-08 19:17:10 -07001267 LIBS="$LIBS -lc89"]) ]
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00001268)
Damien Millerab18c411999-11-11 10:40:23 +11001269
Tim Ricee589a292001-11-03 11:09:32 -08001270dnl Checks for libutil functions
Damien Millerb87f6b72013-02-23 09:12:23 +11001271AC_CHECK_HEADERS([bsd/libutil.h libutil.h])
Damien Miller398c0ff2012-04-19 21:46:35 +10001272AC_SEARCH_LIBS([fmt_scaled], [util bsd])
Darren Tuckere194ba42013-05-16 20:47:31 +10001273AC_SEARCH_LIBS([scan_scaled], [util bsd])
Damien Miller398c0ff2012-04-19 21:46:35 +10001274AC_SEARCH_LIBS([login], [util bsd])
1275AC_SEARCH_LIBS([logout], [util bsd])
1276AC_SEARCH_LIBS([logwtmp], [util bsd])
1277AC_SEARCH_LIBS([openpty], [util bsd])
1278AC_SEARCH_LIBS([updwtmp], [util bsd])
Darren Tuckere194ba42013-05-16 20:47:31 +10001279AC_CHECK_FUNCS([fmt_scaled scan_scaled login logout openpty updwtmp logwtmp])
Tim Ricee589a292001-11-03 11:09:32 -08001280
Damien Millerab039492014-01-28 15:07:10 +11001281# On some platforms, inet_ntop may be found in libresolv or libnsl.
1282AC_SEARCH_LIBS([inet_ntop], [resolv nsl])
1283
Ben Lindstrom8697e082001-02-24 21:41:10 +00001284AC_FUNC_STRFTIME
1285
Damien Miller3c027682001-03-14 11:39:45 +11001286# Check for ALTDIRFUNC glob() extension
Tim Rice648f8762011-01-26 12:38:57 -08001287AC_MSG_CHECKING([for GLOB_ALTDIRFUNC support])
1288AC_EGREP_CPP([FOUNDIT],
Damien Miller3c027682001-03-14 11:39:45 +11001289 [
1290 #include <glob.h>
1291 #ifdef GLOB_ALTDIRFUNC
1292 FOUNDIT
1293 #endif
Damien Millera8e06ce2003-11-21 23:48:55 +11001294 ],
Damien Miller3c027682001-03-14 11:39:45 +11001295 [
Tim Rice648f8762011-01-26 12:38:57 -08001296 AC_DEFINE([GLOB_HAS_ALTDIRFUNC], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001297 [Define if your system glob() function has
1298 the GLOB_ALTDIRFUNC extension])
Tim Rice648f8762011-01-26 12:38:57 -08001299 AC_MSG_RESULT([yes])
Damien Miller3c027682001-03-14 11:39:45 +11001300 ],
1301 [
Tim Rice648f8762011-01-26 12:38:57 -08001302 AC_MSG_RESULT([no])
Damien Miller3c027682001-03-14 11:39:45 +11001303 ]
1304)
Damien Millerab18c411999-11-11 10:40:23 +11001305
Ben Lindstrom45b14db2001-03-17 01:15:38 +00001306# Check for g.gl_matchc glob() extension
Tim Rice648f8762011-01-26 12:38:57 -08001307AC_MSG_CHECKING([for gl_matchc field in glob_t])
1308AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <glob.h> ]],
1309 [[ glob_t g; g.gl_matchc = 1; ]])],
Damien Millera8e06ce2003-11-21 23:48:55 +11001310 [
Tim Rice648f8762011-01-26 12:38:57 -08001311 AC_DEFINE([GLOB_HAS_GL_MATCHC], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001312 [Define if your system glob() function has
1313 gl_matchc options in glob_t])
Tim Rice648f8762011-01-26 12:38:57 -08001314 AC_MSG_RESULT([yes])
1315 ], [
1316 AC_MSG_RESULT([no])
1317])
Ben Lindstrom45b14db2001-03-17 01:15:38 +00001318
Damien Millera6e121a2010-10-07 21:39:17 +11001319# Check for g.gl_statv glob() extension
Tim Rice648f8762011-01-26 12:38:57 -08001320AC_MSG_CHECKING([for gl_statv and GLOB_KEEPSTAT extensions for glob])
1321AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <glob.h> ]], [[
Damien Millera6e121a2010-10-07 21:39:17 +11001322#ifndef GLOB_KEEPSTAT
1323#error "glob does not support GLOB_KEEPSTAT extension"
1324#endif
1325glob_t g;
1326g.gl_statv = NULL;
Tim Rice648f8762011-01-26 12:38:57 -08001327]])],
Damien Millera6e121a2010-10-07 21:39:17 +11001328 [
Tim Rice648f8762011-01-26 12:38:57 -08001329 AC_DEFINE([GLOB_HAS_GL_STATV], [1],
Damien Millera6e121a2010-10-07 21:39:17 +11001330 [Define if your system glob() function has
1331 gl_statv options in glob_t])
Tim Rice648f8762011-01-26 12:38:57 -08001332 AC_MSG_RESULT([yes])
1333 ], [
1334 AC_MSG_RESULT([no])
Damien Miller72ef7c12015-01-15 02:21:31 +11001335
Tim Rice648f8762011-01-26 12:38:57 -08001336])
Damien Millera6e121a2010-10-07 21:39:17 +11001337
Tim Rice648f8762011-01-26 12:38:57 -08001338AC_CHECK_DECLS([GLOB_NOMATCH], , , [#include <glob.h>])
Darren Tucker096faec2006-09-01 20:29:10 +10001339
Damien Miller18bb4732001-03-28 14:35:30 +10001340AC_MSG_CHECKING([whether struct dirent allocates space for d_name])
Darren Tuckera0c2b392004-09-11 23:26:37 +10001341AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001342 [AC_LANG_PROGRAM([[
Damien Miller18bb4732001-03-28 14:35:30 +10001343#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08001344#include <dirent.h>]],
1345 [[
1346 struct dirent d;
1347 exit(sizeof(d.d_name)<=sizeof(char));
Darren Tucker623d92f2004-09-12 22:36:15 +10001348 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001349 [AC_MSG_RESULT([yes])],
Damien Miller18bb4732001-03-28 14:35:30 +10001350 [
Tim Rice648f8762011-01-26 12:38:57 -08001351 AC_MSG_RESULT([no])
1352 AC_DEFINE([BROKEN_ONE_BYTE_DIRENT_D_NAME], [1],
Darren Tucker79d09fa2005-11-24 22:34:54 +11001353 [Define if your struct dirent expects you to
Tim Rice7df8d392005-09-19 09:33:39 -07001354 allocate extra space for d_name])
Darren Tuckera0c2b392004-09-11 23:26:37 +10001355 ],
Tim Riceeae17cc2005-03-17 16:52:20 -08001356 [
Darren Tuckera0c2b392004-09-11 23:26:37 +10001357 AC_MSG_WARN([cross compiling: assuming BROKEN_ONE_BYTE_DIRENT_D_NAME])
Tim Rice648f8762011-01-26 12:38:57 -08001358 AC_DEFINE([BROKEN_ONE_BYTE_DIRENT_D_NAME])
Damien Miller18bb4732001-03-28 14:35:30 +10001359 ]
1360)
1361
Damien Miller36f49652004-08-15 18:40:59 +10001362AC_MSG_CHECKING([for /proc/pid/fd directory])
1363if test -d "/proc/$$/fd" ; then
Tim Rice648f8762011-01-26 12:38:57 -08001364 AC_DEFINE([HAVE_PROC_PID], [1], [Define if you have /proc/$pid/fd])
1365 AC_MSG_RESULT([yes])
Damien Miller36f49652004-08-15 18:40:59 +10001366else
Tim Rice648f8762011-01-26 12:38:57 -08001367 AC_MSG_RESULT([no])
Damien Miller36f49652004-08-15 18:40:59 +10001368fi
1369
Damien Millerc547bf12001-02-16 10:18:12 +11001370# Check whether user wants S/Key support
Damien Millera8e06ce2003-11-21 23:48:55 +11001371SKEY_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08001372AC_ARG_WITH([skey],
Darren Tucker1b6f2292005-02-11 16:11:49 +11001373 [ --with-skey[[=PATH]] Enable S/Key support (optionally in PATH)],
Damien Millerc547bf12001-02-16 10:18:12 +11001374 [
1375 if test "x$withval" != "xno" ; then
1376
1377 if test "x$withval" != "xyes" ; then
1378 CPPFLAGS="$CPPFLAGS -I${withval}/include"
1379 LDFLAGS="$LDFLAGS -L${withval}/lib"
1380 fi
1381
Tim Rice648f8762011-01-26 12:38:57 -08001382 AC_DEFINE([SKEY], [1], [Define if you want S/Key support])
Damien Millerc547bf12001-02-16 10:18:12 +11001383 LIBS="-lskey $LIBS"
Damien Millera8e06ce2003-11-21 23:48:55 +11001384 SKEY_MSG="yes"
Tim Riceeae17cc2005-03-17 16:52:20 -08001385
Tim Rice4cec93f2002-02-26 08:40:48 -08001386 AC_MSG_CHECKING([for s/key support])
Darren Tucker314d89e2005-10-17 23:29:23 +10001387 AC_LINK_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001388 [AC_LANG_PROGRAM([[
Tim Rice4cec93f2002-02-26 08:40:48 -08001389#include <stdio.h>
1390#include <skey.h>
Tim Rice648f8762011-01-26 12:38:57 -08001391 ]], [[
1392 char *ff = skey_keyinfo(""); ff="";
1393 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10001394 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001395 [AC_MSG_RESULT([yes])],
Tim Rice4cec93f2002-02-26 08:40:48 -08001396 [
Tim Rice648f8762011-01-26 12:38:57 -08001397 AC_MSG_RESULT([no])
Damien Millerc547bf12001-02-16 10:18:12 +11001398 AC_MSG_ERROR([** Incomplete or missing s/key libraries.])
1399 ])
Tim Rice648f8762011-01-26 12:38:57 -08001400 AC_MSG_CHECKING([if skeychallenge takes 4 arguments])
1401 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1402#include <stdio.h>
1403#include <skey.h>
1404 ]], [[
1405 (void)skeychallenge(NULL,"name","",0);
1406 ]])],
1407 [
1408 AC_MSG_RESULT([yes])
1409 AC_DEFINE([SKEYCHALLENGE_4ARG], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001410 [Define if your skeychallenge()
1411 function takes 4 arguments (NetBSD)])],
Tim Rice648f8762011-01-26 12:38:57 -08001412 [
1413 AC_MSG_RESULT([no])
1414 ])
Damien Millerc547bf12001-02-16 10:18:12 +11001415 fi
1416 ]
1417)
1418
Darren Tuckeraa3cbd12011-11-04 11:25:24 +11001419# Check whether user wants to use ldns
1420LDNS_MSG="no"
1421AC_ARG_WITH(ldns,
1422 [ --with-ldns[[=PATH]] Use ldns for DNSSEC support (optionally in PATH)],
1423 [
1424 if test "x$withval" != "xno" ; then
1425
1426 if test "x$withval" != "xyes" ; then
1427 CPPFLAGS="$CPPFLAGS -I${withval}/include"
1428 LDFLAGS="$LDFLAGS -L${withval}/lib"
1429 fi
1430
1431 AC_DEFINE(HAVE_LDNS, 1, [Define if you want ldns support])
1432 LIBS="-lldns $LIBS"
1433 LDNS_MSG="yes"
1434
1435 AC_MSG_CHECKING([for ldns support])
1436 AC_LINK_IFELSE(
1437 [AC_LANG_SOURCE([[
1438#include <stdio.h>
1439#include <stdlib.h>
1440#include <stdint.h>
1441#include <ldns/ldns.h>
1442int main() { ldns_status status = ldns_verify_trusted(NULL, NULL, NULL, NULL); status=LDNS_STATUS_OK; exit(0); }
1443 ]])
1444 ],
1445 [AC_MSG_RESULT(yes)],
1446 [
1447 AC_MSG_RESULT(no)
1448 AC_MSG_ERROR([** Incomplete or missing ldns libraries.])
1449 ])
1450 fi
1451 ]
1452)
1453
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001454# Check whether user wants libedit support
1455LIBEDIT_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08001456AC_ARG_WITH([libedit],
Darren Tucker1b6f2292005-02-11 16:11:49 +11001457 [ --with-libedit[[=PATH]] Enable libedit support for sftp],
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001458 [ if test "x$withval" != "xno" ; then
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001459 if test "x$withval" = "xyes" ; then
Darren Tucker59353892012-05-19 15:24:37 +10001460 AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no])
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001461 if test "x$PKGCONFIG" != "xno"; then
Tim Rice648f8762011-01-26 12:38:57 -08001462 AC_MSG_CHECKING([if $PKGCONFIG knows about libedit])
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001463 if "$PKGCONFIG" libedit; then
Tim Rice648f8762011-01-26 12:38:57 -08001464 AC_MSG_RESULT([yes])
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001465 use_pkgconfig_for_libedit=yes
1466 else
Tim Rice648f8762011-01-26 12:38:57 -08001467 AC_MSG_RESULT([no])
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001468 fi
1469 fi
1470 else
Darren Tuckerc373a562005-09-22 20:15:08 +10001471 CPPFLAGS="$CPPFLAGS -I${withval}/include"
1472 if test -n "${need_dash_r}"; then
1473 LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
1474 else
1475 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
1476 fi
Darren Tucker1df61452005-03-21 09:58:07 +11001477 fi
Damien Miller1f789802010-10-11 22:35:22 +11001478 if test "x$use_pkgconfig_for_libedit" = "xyes"; then
Darren Tucker8369c8e2013-12-05 11:00:16 +11001479 LIBEDIT=`$PKGCONFIG --libs libedit`
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001480 CPPFLAGS="$CPPFLAGS `$PKGCONFIG --cflags libedit`"
1481 else
1482 LIBEDIT="-ledit -lcurses"
1483 fi
1484 OTHERLIBS=`echo $LIBEDIT | sed 's/-ledit//'`
Tim Rice648f8762011-01-26 12:38:57 -08001485 AC_CHECK_LIB([edit], [el_init],
1486 [ AC_DEFINE([USE_LIBEDIT], [1], [Use libedit for sftp])
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001487 LIBEDIT_MSG="yes"
Tim Rice648f8762011-01-26 12:38:57 -08001488 AC_SUBST([LIBEDIT])
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001489 ],
Tim Rice648f8762011-01-26 12:38:57 -08001490 [ AC_MSG_ERROR([libedit not found]) ],
Darren Tuckerc4ccb122010-04-09 14:04:35 +10001491 [ $OTHERLIBS ]
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001492 )
Tim Rice648f8762011-01-26 12:38:57 -08001493 AC_MSG_CHECKING([if libedit version is compatible])
Tim Ricec1819c82005-08-15 17:48:40 -07001494 AC_COMPILE_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001495 [AC_LANG_PROGRAM([[ #include <histedit.h> ]],
1496 [[
Darren Tuckerc7572b22005-08-10 20:34:15 +10001497 int i = H_SETSIZE;
1498 el_init("", NULL, NULL, NULL);
1499 exit(0);
Tim Ricec1819c82005-08-15 17:48:40 -07001500 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001501 [ AC_MSG_RESULT([yes]) ],
1502 [ AC_MSG_RESULT([no])
1503 AC_MSG_ERROR([libedit version is not compatible]) ]
Darren Tuckerc7572b22005-08-10 20:34:15 +10001504 )
Darren Tucker16bcc1c2004-11-07 20:14:34 +11001505 fi ]
1506)
1507
Darren Tuckerd9f88912005-02-20 21:01:48 +11001508AUDIT_MODULE=none
Tim Rice648f8762011-01-26 12:38:57 -08001509AC_ARG_WITH([audit],
Darren Tuckerea52a822011-01-17 21:15:27 +11001510 [ --with-audit=module Enable audit support (modules=debug,bsm,linux)],
Darren Tuckerd9f88912005-02-20 21:01:48 +11001511 [
Tim Rice648f8762011-01-26 12:38:57 -08001512 AC_MSG_CHECKING([for supported audit module])
Darren Tuckerd9f88912005-02-20 21:01:48 +11001513 case "$withval" in
1514 bsm)
Tim Rice648f8762011-01-26 12:38:57 -08001515 AC_MSG_RESULT([bsm])
Darren Tuckerd9f88912005-02-20 21:01:48 +11001516 AUDIT_MODULE=bsm
1517 dnl Checks for headers, libs and functions
Tim Rice648f8762011-01-26 12:38:57 -08001518 AC_CHECK_HEADERS([bsm/audit.h], [],
1519 [AC_MSG_ERROR([BSM enabled and bsm/audit.h not found])],
Darren Tucker6d0d6fb2006-09-09 01:05:21 +10001520 [
1521#ifdef HAVE_TIME_H
1522# include <time.h>
1523#endif
1524 ]
1525)
Tim Rice648f8762011-01-26 12:38:57 -08001526 AC_CHECK_LIB([bsm], [getaudit], [],
1527 [AC_MSG_ERROR([BSM enabled and required library not found])])
1528 AC_CHECK_FUNCS([getaudit], [],
1529 [AC_MSG_ERROR([BSM enabled and required function not found])])
Darren Tuckerd9f88912005-02-20 21:01:48 +11001530 # These are optional
Tim Rice648f8762011-01-26 12:38:57 -08001531 AC_CHECK_FUNCS([getaudit_addr aug_get_machine])
1532 AC_DEFINE([USE_BSM_AUDIT], [1], [Use BSM audit module])
Darren Tucker1fcec9d2013-12-19 11:00:12 +11001533 if test "$sol2ver" -ge 11; then
Darren Tucker93a2d412012-02-24 10:40:41 +11001534 SSHDLIBS="$SSHDLIBS -lscf"
1535 AC_DEFINE([BROKEN_BSM_API], [1],
1536 [The system has incomplete BSM API])
1537 fi
Darren Tuckerd9f88912005-02-20 21:01:48 +11001538 ;;
Darren Tuckerea52a822011-01-17 21:15:27 +11001539 linux)
Tim Rice648f8762011-01-26 12:38:57 -08001540 AC_MSG_RESULT([linux])
Darren Tuckerea52a822011-01-17 21:15:27 +11001541 AUDIT_MODULE=linux
1542 dnl Checks for headers, libs and functions
Tim Rice648f8762011-01-26 12:38:57 -08001543 AC_CHECK_HEADERS([libaudit.h])
Darren Tuckerea52a822011-01-17 21:15:27 +11001544 SSHDLIBS="$SSHDLIBS -laudit"
Tim Rice648f8762011-01-26 12:38:57 -08001545 AC_DEFINE([USE_LINUX_AUDIT], [1], [Use Linux audit module])
Darren Tuckerea52a822011-01-17 21:15:27 +11001546 ;;
Darren Tuckerd9f88912005-02-20 21:01:48 +11001547 debug)
1548 AUDIT_MODULE=debug
Tim Rice648f8762011-01-26 12:38:57 -08001549 AC_MSG_RESULT([debug])
1550 AC_DEFINE([SSH_AUDIT_EVENTS], [1], [Use audit debugging module])
Darren Tuckerd9f88912005-02-20 21:01:48 +11001551 ;;
Tim Rice8bc6b902005-08-09 10:09:53 -07001552 no)
Tim Rice648f8762011-01-26 12:38:57 -08001553 AC_MSG_RESULT([no])
Tim Rice8bc6b902005-08-09 10:09:53 -07001554 ;;
Darren Tuckerd9f88912005-02-20 21:01:48 +11001555 *)
1556 AC_MSG_ERROR([Unknown audit module $withval])
1557 ;;
1558 esac ]
1559)
1560
Darren Tucker096118d2014-01-21 12:48:51 +11001561AC_ARG_WITH([pie],
Damien Miller76c04802015-01-13 19:38:18 +11001562 [ --with-pie Build Position Independent Executables if possible], [
Darren Tucker096118d2014-01-21 12:48:51 +11001563 if test "x$withval" = "xno"; then
Damien Miller852472a2014-01-22 16:31:18 +11001564 use_pie=no
Darren Tucker096118d2014-01-21 12:48:51 +11001565 fi
1566 if test "x$withval" = "xyes"; then
Damien Miller852472a2014-01-22 16:31:18 +11001567 use_pie=yes
Darren Tucker096118d2014-01-21 12:48:51 +11001568 fi
1569 ]
1570)
Damien Miller852472a2014-01-22 16:31:18 +11001571if test "x$use_pie" = "x"; then
1572 use_pie=no
1573fi
1574if test "x$use_toolchain_hardening" != "x1" && test "x$use_pie" = "xauto"; then
1575 # Turn off automatic PIE when toolchain hardening is off.
1576 use_pie=no
1577fi
Damien Millerc161fc92014-01-29 21:01:33 +11001578if test "x$use_pie" = "xauto"; then
Damien Miller852472a2014-01-22 16:31:18 +11001579 # Automatic PIE requires gcc >= 4.x
1580 AC_MSG_CHECKING([for gcc >= 4.x])
1581 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1582#if !defined(__GNUC__) || __GNUC__ < 4
1583#error gcc is too old
1584#endif
1585]])],
1586 [ AC_MSG_RESULT([yes]) ],
1587 [ AC_MSG_RESULT([no])
1588 use_pie=no ]
1589)
1590fi
1591if test "x$use_pie" != "xno"; then
Damien Miller5c2ff5e2014-01-22 21:30:12 +11001592 SAVED_CFLAGS="$CFLAGS"
1593 SAVED_LDFLAGS="$LDFLAGS"
Darren Tucker096118d2014-01-21 12:48:51 +11001594 OSSH_CHECK_CFLAG_COMPILE([-fPIE])
1595 OSSH_CHECK_LDFLAG_LINK([-pie])
Damien Miller5c2ff5e2014-01-22 21:30:12 +11001596 # We use both -fPIE and -pie or neither.
1597 AC_MSG_CHECKING([whether both -fPIE and -pie are supported])
1598 if echo "x $CFLAGS" | grep ' -fPIE' >/dev/null 2>&1 && \
1599 echo "x $LDFLAGS" | grep ' -pie' >/dev/null 2>&1 ; then
1600 AC_MSG_RESULT([yes])
1601 else
1602 AC_MSG_RESULT([no])
1603 CFLAGS="$SAVED_CFLAGS"
1604 LDFLAGS="$SAVED_LDFLAGS"
1605 fi
Darren Tucker096118d2014-01-21 12:48:51 +11001606fi
1607
Damien Millerfe1f1432003-02-24 15:45:42 +11001608dnl Checks for library functions. Please keep in alphabetical order
Tim Rice648f8762011-01-26 12:38:57 -08001609AC_CHECK_FUNCS([ \
Damien Miller1ff130d2013-12-07 11:51:51 +11001610 Blowfish_initstate \
1611 Blowfish_expandstate \
1612 Blowfish_expand0state \
1613 Blowfish_stream2word \
Damien Miller57f39152005-11-24 19:58:19 +11001614 asprintf \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001615 b64_ntop \
1616 __b64_ntop \
1617 b64_pton \
1618 __b64_pton \
1619 bcopy \
Damien Millera9134422013-12-07 11:35:36 +11001620 bcrypt_pbkdf \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001621 bindresvport_sa \
Damien Miller1ff130d2013-12-07 11:51:51 +11001622 blf_enc \
Damien Millerc96d8532014-01-25 13:12:28 +11001623 cap_rights_limit \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001624 clock \
1625 closefrom \
1626 dirfd \
Darren Tuckerefdf5342013-05-30 08:29:08 +10001627 endgrent \
Damien Miller1d2c4562014-02-04 11:18:20 +11001628 explicit_bzero \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001629 fchmod \
1630 fchown \
1631 freeaddrinfo \
Darren Tuckera5cf1e22014-01-17 18:10:58 +11001632 fstatfs \
Darren Tucker598eaa62008-06-09 03:32:29 +10001633 fstatvfs \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001634 futimes \
1635 getaddrinfo \
1636 getcwd \
1637 getgrouplist \
1638 getnameinfo \
1639 getopt \
1640 getpeereid \
Darren Tucker164aa302007-03-21 21:39:57 +11001641 getpeerucred \
Darren Tucker3c4a24c2013-02-15 11:41:35 +11001642 getpgid \
1643 getpgrp \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001644 _getpty \
1645 getrlimit \
1646 getttyent \
1647 glob \
Darren Tucker909a3902010-01-15 12:38:30 +11001648 group_from_gid \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001649 inet_aton \
1650 inet_ntoa \
1651 inet_ntop \
1652 innetgr \
1653 login_getcapbool \
Darren Tuckerae133d42013-06-06 08:30:20 +10001654 mblen \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001655 md5_crypt \
1656 memmove \
Damien Miller3d673d12014-08-27 06:32:01 +10001657 memset_s \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001658 mkdtemp \
1659 mmap \
1660 ngetaddrinfo \
1661 nsleep \
1662 ogetaddrinfo \
1663 openlog_r \
Darren Tuckerfebf0f52007-06-25 22:15:12 +10001664 poll \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001665 prctl \
1666 pstat \
1667 readpassphrase \
Darren Tucker642652d2014-12-10 01:32:23 +11001668 reallocarray \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001669 realpath \
1670 recvmsg \
1671 rresvport_af \
1672 sendmsg \
1673 setdtablesize \
1674 setegid \
1675 setenv \
1676 seteuid \
Darren Tucker909a3902010-01-15 12:38:30 +11001677 setgroupent \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001678 setgroups \
Darren Tucker34f702a2012-07-04 08:50:09 +10001679 setlinebuf \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001680 setlogin \
Darren Tucker909a3902010-01-15 12:38:30 +11001681 setpassent\
Darren Tucker0c9653f2005-05-28 15:58:14 +10001682 setpcred \
1683 setproctitle \
1684 setregid \
1685 setreuid \
1686 setrlimit \
1687 setsid \
1688 setvbuf \
1689 sigaction \
1690 sigvec \
1691 snprintf \
1692 socketpair \
Darren Tucker5b2e2ba2008-06-08 09:25:28 +10001693 statfs \
1694 statvfs \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001695 strdup \
1696 strerror \
1697 strlcat \
1698 strlcpy \
1699 strmode \
Darren Tuckerb54f50e2011-09-29 23:17:18 +10001700 strnlen \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001701 strnvis \
Darren Tuckeraa74f672010-08-16 13:15:23 +10001702 strptime \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001703 strtonum \
Darren Tucker81eb5d52005-06-01 21:39:33 +10001704 strtoll \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001705 strtoul \
Darren Tucker8e6fb782013-02-15 12:13:01 +11001706 strtoull \
Damien Miller34a17692007-06-11 14:15:42 +10001707 swap32 \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001708 sysconf \
1709 tcgetpgrp \
Damien Milleraa180632010-10-07 21:25:27 +11001710 timingsafe_bcmp \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001711 truncate \
1712 unsetenv \
1713 updwtmpx \
Darren Tucker909a3902010-01-15 12:38:30 +11001714 user_from_uid \
Damien Millerf4db77d2013-03-15 10:34:25 +11001715 usleep \
Damien Miller57f39152005-11-24 19:58:19 +11001716 vasprintf \
Darren Tucker0c9653f2005-05-28 15:58:14 +10001717 vsnprintf \
1718 waitpid \
Tim Rice648f8762011-01-26 12:38:57 -08001719])
Tim Rice13aae5e2001-10-21 17:53:58 -07001720
Tim Ricec7a8af02010-11-08 14:26:23 -08001721AC_LINK_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001722 [AC_LANG_PROGRAM(
1723 [[ #include <ctype.h> ]],
1724 [[ return (isblank('a')); ]])],
1725 [AC_DEFINE([HAVE_ISBLANK], [1], [Define if you have isblank(3C).])
Tim Ricec7a8af02010-11-08 14:26:23 -08001726])
1727
Damien Miller72ef7c12015-01-15 02:21:31 +11001728# PKCS11 depends on OpenSSL.
1729if test "x$openssl" = "xyes" ; then
1730 # PKCS#11 support requires dlopen() and co
1731 AC_SEARCH_LIBS([dlopen], [dl],
1732 [AC_DEFINE([ENABLE_PKCS11], [], [Enable for PKCS#11 support])]
1733 )
1734fi
Damien Millerb3c9f782010-02-12 10:11:34 +11001735
Darren Tuckerd5e082f2003-09-22 12:08:23 +10001736# IRIX has a const char return value for gai_strerror()
Tim Rice648f8762011-01-26 12:38:57 -08001737AC_CHECK_FUNCS([gai_strerror], [
1738 AC_DEFINE([HAVE_GAI_STRERROR])
1739 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckerd5e082f2003-09-22 12:08:23 +10001740#include <sys/types.h>
1741#include <sys/socket.h>
1742#include <netdb.h>
1743
Tim Rice648f8762011-01-26 12:38:57 -08001744const char *gai_strerror(int);
1745 ]], [[
1746 char *str;
1747 str = gai_strerror(0);
1748 ]])], [
1749 AC_DEFINE([HAVE_CONST_GAI_STRERROR_PROTO], [1],
1750 [Define if gai_strerror() returns const char *])], [])])
Darren Tuckerd5e082f2003-09-22 12:08:23 +10001751
Tim Rice648f8762011-01-26 12:38:57 -08001752AC_SEARCH_LIBS([nanosleep], [rt posix4], [AC_DEFINE([HAVE_NANOSLEEP], [1],
1753 [Some systems put nanosleep outside of libc])])
Damien Millercd6853c2003-01-28 11:33:42 +11001754
Darren Tuckera7108912013-06-02 08:18:31 +10001755AC_SEARCH_LIBS([clock_gettime], [rt],
1756 [AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Have clock_gettime])])
1757
Darren Tuckerf1159b52003-07-07 19:44:01 +10001758dnl Make sure prototypes are defined for these before using them.
Tim Rice648f8762011-01-26 12:38:57 -08001759AC_CHECK_DECL([getrusage], [AC_CHECK_FUNCS([getrusage])])
1760AC_CHECK_DECL([strsep],
1761 [AC_CHECK_FUNCS([strsep])],
Darren Tucker390b6d52005-05-28 16:54:36 +10001762 [],
1763 [
1764#ifdef HAVE_STRING_H
1765# include <string.h>
1766#endif
1767 ])
Ben Lindstrom3e006472002-10-16 00:24:03 +00001768
Darren Tuckerb2427c82003-09-10 15:22:44 +10001769dnl tcsendbreak might be a macro
Tim Rice648f8762011-01-26 12:38:57 -08001770AC_CHECK_DECL([tcsendbreak],
1771 [AC_DEFINE([HAVE_TCSENDBREAK])],
1772 [AC_CHECK_FUNCS([tcsendbreak])],
Darren Tuckerb2427c82003-09-10 15:22:44 +10001773 [#include <termios.h>]
1774)
1775
Tim Rice648f8762011-01-26 12:38:57 -08001776AC_CHECK_DECLS([h_errno], , ,[#include <netdb.h>])
Darren Tucker5bb14002004-04-23 18:53:10 +10001777
Tim Rice648f8762011-01-26 12:38:57 -08001778AC_CHECK_DECLS([SHUT_RD], , ,
Darren Tucker128a0892006-07-12 19:02:56 +10001779 [
1780#include <sys/types.h>
1781#include <sys/socket.h>
1782 ])
Darren Tucker248469b2006-07-12 14:14:31 +10001783
Tim Rice648f8762011-01-26 12:38:57 -08001784AC_CHECK_DECLS([O_NONBLOCK], , ,
Darren Tucker248469b2006-07-12 14:14:31 +10001785 [
1786#include <sys/types.h>
1787#ifdef HAVE_SYS_STAT_H
1788# include <sys/stat.h>
1789#endif
1790#ifdef HAVE_FCNTL_H
1791# include <fcntl.h>
1792#endif
1793 ])
1794
Tim Rice648f8762011-01-26 12:38:57 -08001795AC_CHECK_DECLS([writev], , , [
Darren Tuckered0b5922006-09-03 22:44:49 +10001796#include <sys/types.h>
1797#include <sys/uio.h>
1798#include <unistd.h>
1799 ])
1800
Tim Rice648f8762011-01-26 12:38:57 -08001801AC_CHECK_DECLS([MAXSYMLINKS], , , [
Darren Tucker6d862a52007-04-29 14:39:02 +10001802#include <sys/param.h>
1803 ])
1804
Tim Rice648f8762011-01-26 12:38:57 -08001805AC_CHECK_DECLS([offsetof], , , [
Darren Tuckerdca0edf2007-04-29 15:06:44 +10001806#include <stddef.h>
1807 ])
1808
Darren Tuckerc7aad002013-06-02 07:18:47 +10001809# extra bits for select(2)
1810AC_CHECK_DECLS([howmany, NFDBITS], [], [], [[
1811#include <sys/param.h>
1812#include <sys/types.h>
1813#ifdef HAVE_SYS_SYSMACROS_H
1814#include <sys/sysmacros.h>
1815#endif
1816#ifdef HAVE_SYS_SELECT_H
1817#include <sys/select.h>
1818#endif
1819#ifdef HAVE_SYS_TIME_H
1820#include <sys/time.h>
1821#endif
1822#ifdef HAVE_UNISTD_H
1823#include <unistd.h>
1824#endif
1825 ]])
1826AC_CHECK_TYPES([fd_mask], [], [], [[
1827#include <sys/param.h>
1828#include <sys/types.h>
1829#ifdef HAVE_SYS_SELECT_H
1830#include <sys/select.h>
1831#endif
1832#ifdef HAVE_SYS_TIME_H
1833#include <sys/time.h>
1834#endif
1835#ifdef HAVE_UNISTD_H
1836#include <unistd.h>
1837#endif
1838 ]])
1839
Tim Rice648f8762011-01-26 12:38:57 -08001840AC_CHECK_FUNCS([setresuid], [
Darren Tucker2a6b0292003-12-31 14:59:17 +11001841 dnl Some platorms have setresuid that isn't implemented, test for this
Tim Rice648f8762011-01-26 12:38:57 -08001842 AC_MSG_CHECKING([if setresuid seems to work])
Darren Tucker623d92f2004-09-12 22:36:15 +10001843 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001844 [AC_LANG_PROGRAM([[
Darren Tuckere937be32003-12-17 18:53:26 +11001845#include <stdlib.h>
1846#include <errno.h>
Tim Rice648f8762011-01-26 12:38:57 -08001847 ]], [[
1848 errno=0;
1849 setresuid(0,0,0);
1850 if (errno==ENOSYS)
1851 exit(1);
1852 else
1853 exit(0);
Darren Tucker623d92f2004-09-12 22:36:15 +10001854 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001855 [AC_MSG_RESULT([yes])],
1856 [AC_DEFINE([BROKEN_SETRESUID], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001857 [Define if your setresuid() is broken])
Tim Rice648f8762011-01-26 12:38:57 -08001858 AC_MSG_RESULT([not implemented])],
Darren Tuckera0c2b392004-09-11 23:26:37 +10001859 [AC_MSG_WARN([cross compiling: not checking setresuid])]
Darren Tucker2a6b0292003-12-31 14:59:17 +11001860 )
1861])
Darren Tuckere937be32003-12-17 18:53:26 +11001862
Tim Rice648f8762011-01-26 12:38:57 -08001863AC_CHECK_FUNCS([setresgid], [
Darren Tucker2a6b0292003-12-31 14:59:17 +11001864 dnl Some platorms have setresgid that isn't implemented, test for this
Tim Rice648f8762011-01-26 12:38:57 -08001865 AC_MSG_CHECKING([if setresgid seems to work])
Darren Tucker623d92f2004-09-12 22:36:15 +10001866 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001867 [AC_LANG_PROGRAM([[
Darren Tuckere937be32003-12-17 18:53:26 +11001868#include <stdlib.h>
1869#include <errno.h>
Tim Rice648f8762011-01-26 12:38:57 -08001870 ]], [[
1871 errno=0;
1872 setresgid(0,0,0);
1873 if (errno==ENOSYS)
1874 exit(1);
1875 else
1876 exit(0);
Darren Tucker623d92f2004-09-12 22:36:15 +10001877 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001878 [AC_MSG_RESULT([yes])],
1879 [AC_DEFINE([BROKEN_SETRESGID], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001880 [Define if your setresgid() is broken])
Tim Rice648f8762011-01-26 12:38:57 -08001881 AC_MSG_RESULT([not implemented])],
Darren Tuckera0c2b392004-09-11 23:26:37 +10001882 [AC_MSG_WARN([cross compiling: not checking setresuid])]
Darren Tucker2a6b0292003-12-31 14:59:17 +11001883 )
1884])
Darren Tuckere937be32003-12-17 18:53:26 +11001885
Damien Millerad833b32000-08-23 10:46:23 +10001886dnl Checks for time functions
Tim Rice648f8762011-01-26 12:38:57 -08001887AC_CHECK_FUNCS([gettimeofday time])
Damien Millerad833b32000-08-23 10:46:23 +10001888dnl Checks for utmp functions
Tim Rice648f8762011-01-26 12:38:57 -08001889AC_CHECK_FUNCS([endutent getutent getutid getutline pututline setutent])
1890AC_CHECK_FUNCS([utmpname])
Damien Millerad833b32000-08-23 10:46:23 +10001891dnl Checks for utmpx functions
Tim Rice648f8762011-01-26 12:38:57 -08001892AC_CHECK_FUNCS([endutxent getutxent getutxid getutxline getutxuser pututxline])
1893AC_CHECK_FUNCS([setutxdb setutxent utmpxname])
Damien Miller20e231f2009-02-12 13:12:21 +11001894dnl Checks for lastlog functions
Tim Rice648f8762011-01-26 12:38:57 -08001895AC_CHECK_FUNCS([getlastlogxbyname])
Damien Millercedfecc1999-11-15 14:36:53 +11001896
Tim Rice648f8762011-01-26 12:38:57 -08001897AC_CHECK_FUNC([daemon],
1898 [AC_DEFINE([HAVE_DAEMON], [1], [Define if your libraries define daemon()])],
1899 [AC_CHECK_LIB([bsd], [daemon],
1900 [LIBS="$LIBS -lbsd"; AC_DEFINE([HAVE_DAEMON])])]
Damien Miller04f80141999-11-19 15:32:34 +11001901)
1902
Tim Rice648f8762011-01-26 12:38:57 -08001903AC_CHECK_FUNC([getpagesize],
1904 [AC_DEFINE([HAVE_GETPAGESIZE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001905 [Define if your libraries define getpagesize()])],
Tim Rice648f8762011-01-26 12:38:57 -08001906 [AC_CHECK_LIB([ucb], [getpagesize],
1907 [LIBS="$LIBS -lucb"; AC_DEFINE([HAVE_GETPAGESIZE])])]
Damien Miller9fb07e42000-03-05 16:22:59 +11001908)
1909
Damien Millercb170cb2000-07-01 16:52:55 +10001910# Check for broken snprintf
1911if test "x$ac_cv_func_snprintf" = "xyes" ; then
1912 AC_MSG_CHECKING([whether snprintf correctly terminates long strings])
Darren Tuckera0c2b392004-09-11 23:26:37 +10001913 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001914 [AC_LANG_PROGRAM([[ #include <stdio.h> ]],
1915 [[
1916 char b[5];
1917 snprintf(b,5,"123456789");
1918 exit(b[4]!='\0');
Darren Tucker623d92f2004-09-12 22:36:15 +10001919 ]])],
Tim Rice648f8762011-01-26 12:38:57 -08001920 [AC_MSG_RESULT([yes])],
Damien Millercb170cb2000-07-01 16:52:55 +10001921 [
Tim Rice648f8762011-01-26 12:38:57 -08001922 AC_MSG_RESULT([no])
1923 AC_DEFINE([BROKEN_SNPRINTF], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07001924 [Define if your snprintf is busted])
Damien Millercb170cb2000-07-01 16:52:55 +10001925 AC_MSG_WARN([****** Your snprintf() function is broken, complain to your vendor])
Darren Tuckera0c2b392004-09-11 23:26:37 +10001926 ],
1927 [ AC_MSG_WARN([cross compiling: Assuming working snprintf()]) ]
Damien Millercb170cb2000-07-01 16:52:55 +10001928 )
1929fi
1930
Damien Millerd244a582014-08-23 17:06:49 +10001931# We depend on vsnprintf returning the right thing on overflow: the
1932# number of characters it tried to create (as per SUSv3)
1933if test "x$ac_cv_func_vsnprintf" = "xyes" ; then
Damien Miller57f39152005-11-24 19:58:19 +11001934 AC_MSG_CHECKING([whether vsnprintf returns correct values on overflow])
1935 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08001936 [AC_LANG_PROGRAM([[
Damien Miller57f39152005-11-24 19:58:19 +11001937#include <sys/types.h>
1938#include <stdio.h>
1939#include <stdarg.h>
1940
Damien Millerd244a582014-08-23 17:06:49 +10001941int x_snprintf(char *str, size_t count, const char *fmt, ...)
Damien Miller57f39152005-11-24 19:58:19 +11001942{
Damien Millerd244a582014-08-23 17:06:49 +10001943 size_t ret;
1944 va_list ap;
1945
1946 va_start(ap, fmt);
1947 ret = vsnprintf(str, count, fmt, ap);
1948 va_end(ap);
Damien Miller57f39152005-11-24 19:58:19 +11001949 return ret;
1950}
Tim Rice648f8762011-01-26 12:38:57 -08001951 ]], [[
Damien Millerd244a582014-08-23 17:06:49 +10001952char x[1];
1953if (x_snprintf(x, 1, "%s %d", "hello", 12345) != 11)
1954 return 1;
1955if (x_snprintf(NULL, 0, "%s %d", "hello", 12345) != 11)
1956 return 1;
1957return 0;
Tim Rice648f8762011-01-26 12:38:57 -08001958 ]])],
1959 [AC_MSG_RESULT([yes])],
Damien Miller57f39152005-11-24 19:58:19 +11001960 [
Tim Rice648f8762011-01-26 12:38:57 -08001961 AC_MSG_RESULT([no])
1962 AC_DEFINE([BROKEN_SNPRINTF], [1],
Damien Miller57f39152005-11-24 19:58:19 +11001963 [Define if your snprintf is busted])
1964 AC_MSG_WARN([****** Your vsnprintf() function is broken, complain to your vendor])
1965 ],
1966 [ AC_MSG_WARN([cross compiling: Assuming working vsnprintf()]) ]
1967 )
1968fi
1969
Darren Tuckerd40c66c2005-12-17 22:32:03 +11001970# On systems where [v]snprintf is broken, but is declared in stdio,
1971# check that the fmt argument is const char * or just char *.
1972# This is only useful for when BROKEN_SNPRINTF
1973AC_MSG_CHECKING([whether snprintf can declare const char *fmt])
Tim Rice648f8762011-01-26 12:38:57 -08001974AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1975#include <stdio.h>
1976int snprintf(char *a, size_t b, const char *c, ...) { return 0; }
1977 ]], [[
1978 snprintf(0, 0, 0);
1979 ]])],
1980 [AC_MSG_RESULT([yes])
1981 AC_DEFINE([SNPRINTF_CONST], [const],
Darren Tuckerd40c66c2005-12-17 22:32:03 +11001982 [Define as const if snprintf() can declare const char *fmt])],
Tim Rice648f8762011-01-26 12:38:57 -08001983 [AC_MSG_RESULT([no])
1984 AC_DEFINE([SNPRINTF_CONST], [/* not const */])])
Darren Tuckerd40c66c2005-12-17 22:32:03 +11001985
Damien Millerb4097182004-05-23 14:09:40 +10001986# Check for missing getpeereid (or equiv) support
1987NO_PEERCHECK=""
Darren Tucker164aa302007-03-21 21:39:57 +11001988if test "x$ac_cv_func_getpeereid" != "xyes" -a "x$ac_cv_func_getpeerucred" != "xyes"; then
Damien Millerb4097182004-05-23 14:09:40 +10001989 AC_MSG_CHECKING([whether system supports SO_PEERCRED getsockopt])
Tim Rice648f8762011-01-26 12:38:57 -08001990 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1991#include <sys/types.h>
1992#include <sys/socket.h>]], [[int i = SO_PEERCRED;]])],
1993 [ AC_MSG_RESULT([yes])
1994 AC_DEFINE([HAVE_SO_PEERCRED], [1], [Have PEERCRED socket option])
1995 ], [AC_MSG_RESULT([no])
1996 NO_PEERCHECK=1
1997 ])
Damien Millerb4097182004-05-23 14:09:40 +10001998fi
1999
Damien Millere8328192003-01-07 15:18:32 +11002000dnl see whether mkstemp() requires XXXXXX
2001if test "x$ac_cv_func_mkdtemp" = "xyes" ; then
2002AC_MSG_CHECKING([for (overly) strict mkstemp])
Darren Tucker314d89e2005-10-17 23:29:23 +10002003AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002004 [AC_LANG_PROGRAM([[
Damien Millere8328192003-01-07 15:18:32 +11002005#include <stdlib.h>
Tim Rice648f8762011-01-26 12:38:57 -08002006 ]], [[
2007 char template[]="conftest.mkstemp-test";
2008 if (mkstemp(template) == -1)
2009 exit(1);
2010 unlink(template);
2011 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10002012 ]])],
Damien Millere8328192003-01-07 15:18:32 +11002013 [
Tim Rice648f8762011-01-26 12:38:57 -08002014 AC_MSG_RESULT([no])
Damien Millere8328192003-01-07 15:18:32 +11002015 ],
Damien Millera8e06ce2003-11-21 23:48:55 +11002016 [
Tim Rice648f8762011-01-26 12:38:57 -08002017 AC_MSG_RESULT([yes])
2018 AC_DEFINE([HAVE_STRICT_MKSTEMP], [1], [Silly mkstemp()])
Damien Millere8328192003-01-07 15:18:32 +11002019 ],
2020 [
Tim Rice648f8762011-01-26 12:38:57 -08002021 AC_MSG_RESULT([yes])
2022 AC_DEFINE([HAVE_STRICT_MKSTEMP])
Damien Millera8e06ce2003-11-21 23:48:55 +11002023 ]
Damien Millere8328192003-01-07 15:18:32 +11002024)
2025fi
2026
Darren Tucker70a3d552003-08-21 17:58:29 +10002027dnl make sure that openpty does not reacquire controlling terminal
2028if test ! -z "$check_for_openpty_ctty_bug"; then
Tim Rice648f8762011-01-26 12:38:57 -08002029 AC_MSG_CHECKING([if openpty correctly handles controlling tty])
Darren Tucker314d89e2005-10-17 23:29:23 +10002030 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002031 [AC_LANG_PROGRAM([[
Darren Tucker70a3d552003-08-21 17:58:29 +10002032#include <stdio.h>
2033#include <sys/fcntl.h>
2034#include <sys/types.h>
2035#include <sys/wait.h>
Tim Rice648f8762011-01-26 12:38:57 -08002036 ]], [[
Darren Tucker70a3d552003-08-21 17:58:29 +10002037 pid_t pid;
2038 int fd, ptyfd, ttyfd, status;
2039
2040 pid = fork();
2041 if (pid < 0) { /* failed */
2042 exit(1);
2043 } else if (pid > 0) { /* parent */
2044 waitpid(pid, &status, 0);
Damien Millera8e06ce2003-11-21 23:48:55 +11002045 if (WIFEXITED(status))
Darren Tucker70a3d552003-08-21 17:58:29 +10002046 exit(WEXITSTATUS(status));
2047 else
2048 exit(2);
2049 } else { /* child */
2050 close(0); close(1); close(2);
2051 setsid();
2052 openpty(&ptyfd, &ttyfd, NULL, NULL, NULL);
2053 fd = open("/dev/tty", O_RDWR | O_NOCTTY);
2054 if (fd >= 0)
2055 exit(3); /* Acquired ctty: broken */
2056 else
2057 exit(0); /* Did not acquire ctty: OK */
2058 }
Darren Tucker314d89e2005-10-17 23:29:23 +10002059 ]])],
Darren Tucker70a3d552003-08-21 17:58:29 +10002060 [
Tim Rice648f8762011-01-26 12:38:57 -08002061 AC_MSG_RESULT([yes])
Darren Tucker70a3d552003-08-21 17:58:29 +10002062 ],
2063 [
Tim Rice648f8762011-01-26 12:38:57 -08002064 AC_MSG_RESULT([no])
2065 AC_DEFINE([SSHD_ACQUIRES_CTTY])
Darren Tucker314d89e2005-10-17 23:29:23 +10002066 ],
2067 [
Tim Rice648f8762011-01-26 12:38:57 -08002068 AC_MSG_RESULT([cross-compiling, assuming yes])
Darren Tucker70a3d552003-08-21 17:58:29 +10002069 ]
2070 )
2071fi
2072
Tim Rice8bb561b2005-03-17 16:23:19 -08002073if test "x$ac_cv_func_getaddrinfo" = "xyes" && \
2074 test "x$check_for_hpux_broken_getaddrinfo" = "x1"; then
Tim Rice648f8762011-01-26 12:38:57 -08002075 AC_MSG_CHECKING([if getaddrinfo seems to work])
Darren Tucker314d89e2005-10-17 23:29:23 +10002076 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002077 [AC_LANG_PROGRAM([[
Darren Tucker4398cf52004-04-06 21:39:02 +10002078#include <stdio.h>
2079#include <sys/socket.h>
2080#include <netdb.h>
2081#include <errno.h>
2082#include <netinet/in.h>
2083
2084#define TEST_PORT "2222"
Tim Rice648f8762011-01-26 12:38:57 -08002085 ]], [[
Darren Tucker4398cf52004-04-06 21:39:02 +10002086 int err, sock;
2087 struct addrinfo *gai_ai, *ai, hints;
2088 char ntop[NI_MAXHOST], strport[NI_MAXSERV], *name = NULL;
2089
2090 memset(&hints, 0, sizeof(hints));
2091 hints.ai_family = PF_UNSPEC;
2092 hints.ai_socktype = SOCK_STREAM;
2093 hints.ai_flags = AI_PASSIVE;
2094
2095 err = getaddrinfo(name, TEST_PORT, &hints, &gai_ai);
2096 if (err != 0) {
2097 fprintf(stderr, "getaddrinfo failed (%s)", gai_strerror(err));
2098 exit(1);
2099 }
2100
2101 for (ai = gai_ai; ai != NULL; ai = ai->ai_next) {
2102 if (ai->ai_family != AF_INET6)
2103 continue;
2104
2105 err = getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop,
2106 sizeof(ntop), strport, sizeof(strport),
2107 NI_NUMERICHOST|NI_NUMERICSERV);
2108
2109 if (err != 0) {
2110 if (err == EAI_SYSTEM)
2111 perror("getnameinfo EAI_SYSTEM");
2112 else
2113 fprintf(stderr, "getnameinfo failed: %s\n",
2114 gai_strerror(err));
2115 exit(2);
2116 }
2117
2118 sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
2119 if (sock < 0)
2120 perror("socket");
2121 if (bind(sock, ai->ai_addr, ai->ai_addrlen) < 0) {
2122 if (errno == EBADF)
2123 exit(3);
2124 }
2125 }
2126 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10002127 ]])],
Darren Tucker4398cf52004-04-06 21:39:02 +10002128 [
Tim Rice648f8762011-01-26 12:38:57 -08002129 AC_MSG_RESULT([yes])
Darren Tucker4398cf52004-04-06 21:39:02 +10002130 ],
2131 [
Tim Rice648f8762011-01-26 12:38:57 -08002132 AC_MSG_RESULT([no])
2133 AC_DEFINE([BROKEN_GETADDRINFO])
Darren Tucker314d89e2005-10-17 23:29:23 +10002134 ],
2135 [
Tim Rice648f8762011-01-26 12:38:57 -08002136 AC_MSG_RESULT([cross-compiling, assuming yes])
Darren Tucker4398cf52004-04-06 21:39:02 +10002137 ]
2138 )
2139fi
2140
Tim Rice8bb561b2005-03-17 16:23:19 -08002141if test "x$ac_cv_func_getaddrinfo" = "xyes" && \
2142 test "x$check_for_aix_broken_getaddrinfo" = "x1"; then
Tim Rice648f8762011-01-26 12:38:57 -08002143 AC_MSG_CHECKING([if getaddrinfo seems to work])
Darren Tucker314d89e2005-10-17 23:29:23 +10002144 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08002145 [AC_LANG_PROGRAM([[
Darren Tucker691d5232005-02-15 21:45:57 +11002146#include <stdio.h>
2147#include <sys/socket.h>
2148#include <netdb.h>
2149#include <errno.h>
2150#include <netinet/in.h>
2151
2152#define TEST_PORT "2222"
Tim Rice648f8762011-01-26 12:38:57 -08002153 ]], [[
Darren Tucker691d5232005-02-15 21:45:57 +11002154 int err, sock;
2155 struct addrinfo *gai_ai, *ai, hints;
2156 char ntop[NI_MAXHOST], strport[NI_MAXSERV], *name = NULL;
2157
2158 memset(&hints, 0, sizeof(hints));
2159 hints.ai_family = PF_UNSPEC;
2160 hints.ai_socktype = SOCK_STREAM;
2161 hints.ai_flags = AI_PASSIVE;
2162
2163 err = getaddrinfo(name, TEST_PORT, &hints, &gai_ai);
2164 if (err != 0) {
2165 fprintf(stderr, "getaddrinfo failed (%s)", gai_strerror(err));
2166 exit(1);
2167 }
2168
2169 for (ai = gai_ai; ai != NULL; ai = ai->ai_next) {
2170 if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6)
2171 continue;
2172
2173 err = getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop,
2174 sizeof(ntop), strport, sizeof(strport),
2175 NI_NUMERICHOST|NI_NUMERICSERV);
2176
2177 if (ai->ai_family == AF_INET && err != 0) {
2178 perror("getnameinfo");
2179 exit(2);
2180 }
2181 }
2182 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10002183 ]])],
Darren Tucker691d5232005-02-15 21:45:57 +11002184 [
Tim Rice648f8762011-01-26 12:38:57 -08002185 AC_MSG_RESULT([yes])
2186 AC_DEFINE([AIX_GETNAMEINFO_HACK], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07002187 [Define if you have a getaddrinfo that fails
2188 for the all-zeros IPv6 address])
Darren Tucker691d5232005-02-15 21:45:57 +11002189 ],
2190 [
Tim Rice648f8762011-01-26 12:38:57 -08002191 AC_MSG_RESULT([no])
2192 AC_DEFINE([BROKEN_GETADDRINFO])
Darren Tucker314d89e2005-10-17 23:29:23 +10002193 ],
Darren Tucker8b272ab2006-06-27 11:20:28 +10002194 [
Tim Rice648f8762011-01-26 12:38:57 -08002195 AC_MSG_RESULT([cross-compiling, assuming no])
Darren Tucker691d5232005-02-15 21:45:57 +11002196 ]
2197 )
2198fi
2199
Darren Tuckera56f1912004-11-02 20:30:54 +11002200if test "x$check_for_conflicting_getspnam" = "x1"; then
Tim Rice648f8762011-01-26 12:38:57 -08002201 AC_MSG_CHECKING([for conflicting getspnam in shadow.h])
2202 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <shadow.h> ]],
2203 [[ exit(0); ]])],
Darren Tuckera56f1912004-11-02 20:30:54 +11002204 [
Tim Rice648f8762011-01-26 12:38:57 -08002205 AC_MSG_RESULT([no])
Darren Tuckera56f1912004-11-02 20:30:54 +11002206 ],
2207 [
Tim Rice648f8762011-01-26 12:38:57 -08002208 AC_MSG_RESULT([yes])
2209 AC_DEFINE([GETSPNAM_CONFLICTING_DEFS], [1],
Darren Tuckera56f1912004-11-02 20:30:54 +11002210 [Conflicting defs for getspnam])
2211 ]
2212 )
2213fi
2214
Damien Miller606f8802000-09-16 15:39:56 +11002215AC_FUNC_GETPGRP
2216
Tim Riceaef73712002-05-11 13:17:42 -07002217# Search for OpenSSL
2218saved_CPPFLAGS="$CPPFLAGS"
2219saved_LDFLAGS="$LDFLAGS"
Tim Rice648f8762011-01-26 12:38:57 -08002220AC_ARG_WITH([ssl-dir],
Damien Millera22ba012000-03-02 23:09:20 +11002221 [ --with-ssl-dir=PATH Specify path to OpenSSL installation ],
2222 [
Damien Miller72ef7c12015-01-15 02:21:31 +11002223 if test "x$openssl" = "xno" ; then
2224 AC_MSG_ERROR([cannot use --with-ssl-dir when OpenSSL disabled])
2225 fi
Ben Lindstrom23e13712000-10-29 22:49:19 +00002226 if test "x$withval" != "xno" ; then
Darren Tuckerc7e38d52005-02-09 22:12:30 +11002227 case "$withval" in
2228 # Relative paths
2229 ./*|../*) withval="`pwd`/$withval"
2230 esac
Tim Riceaef73712002-05-11 13:17:42 -07002231 if test -d "$withval/lib"; then
2232 if test -n "${need_dash_r}"; then
2233 LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
2234 else
2235 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
2236 fi
Darren Tucker9f8703b2010-04-23 11:12:06 +10002237 elif test -d "$withval/lib64"; then
2238 if test -n "${need_dash_r}"; then
2239 LDFLAGS="-L${withval}/lib64 -R${withval}/lib64 ${LDFLAGS}"
2240 else
2241 LDFLAGS="-L${withval}/lib64 ${LDFLAGS}"
2242 fi
Tim Riceaef73712002-05-11 13:17:42 -07002243 else
2244 if test -n "${need_dash_r}"; then
2245 LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
2246 else
2247 LDFLAGS="-L${withval} ${LDFLAGS}"
2248 fi
2249 fi
2250 if test -d "$withval/include"; then
2251 CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
2252 else
2253 CPPFLAGS="-I${withval} ${CPPFLAGS}"
2254 fi
Damien Millera22ba012000-03-02 23:09:20 +11002255 fi
2256 ]
2257)
Damien Millerb9c56672014-05-15 14:43:37 +10002258
Tim Rice648f8762011-01-26 12:38:57 -08002259AC_ARG_WITH([openssl-header-check],
Damien Miller9975e482007-03-05 11:51:27 +11002260 [ --without-openssl-header-check Disable OpenSSL version consistency check],
Damien Millerec932372002-01-22 22:16:03 +11002261 [
Damien Miller72ef7c12015-01-15 02:21:31 +11002262 if test "x$withval" = "xno" ; then
2263 openssl_check_nonfatal=1
Damien Miller9975e482007-03-05 11:51:27 +11002264 fi
Damien Millerec932372002-01-22 22:16:03 +11002265 ]
2266)
2267
Damien Miller72ef7c12015-01-15 02:21:31 +11002268openssl_engine=no
Tim Rice648f8762011-01-26 12:38:57 -08002269AC_ARG_WITH([ssl-engine],
Darren Tuckerfabdb6c2006-02-20 20:17:35 +11002270 [ --with-ssl-engine Enable OpenSSL (hardware) ENGINE support ],
Damien Miller72ef7c12015-01-15 02:21:31 +11002271 [
2272 if test "x$openssl" = "xno" ; then
2273 AC_MSG_ERROR([cannot use --with-ssl-engine when OpenSSL disabled])
2274 fi
2275 if test "x$withval" != "xno" ; then
2276 openssl_engine=yes
2277 fi
2278 ]
2279)
2280
2281if test "x$openssl" = "xyes" ; then
2282 LIBS="-lcrypto $LIBS"
2283 AC_TRY_LINK_FUNC([RAND_add], [AC_DEFINE([HAVE_OPENSSL], [1],
2284 [Define if your ssl headers are included
2285 with #include <openssl/header.h>])],
2286 [
2287 dnl Check default openssl install dir
2288 if test -n "${need_dash_r}"; then
2289 LDFLAGS="-L/usr/local/ssl/lib -R/usr/local/ssl/lib ${saved_LDFLAGS}"
2290 else
2291 LDFLAGS="-L/usr/local/ssl/lib ${saved_LDFLAGS}"
2292 fi
2293 CPPFLAGS="-I/usr/local/ssl/include ${saved_CPPFLAGS}"
2294 AC_CHECK_HEADER([openssl/opensslv.h], ,
2295 [AC_MSG_ERROR([*** OpenSSL headers missing - please install first or check config.log ***])])
2296 AC_TRY_LINK_FUNC([RAND_add], [AC_DEFINE([HAVE_OPENSSL])],
2297 [
2298 AC_MSG_ERROR([*** Can't find recent OpenSSL libcrypto (see config.log for details) ***])
2299 ]
2300 )
2301 ]
2302 )
2303
2304 # Determine OpenSSL header version
2305 AC_MSG_CHECKING([OpenSSL header version])
2306 AC_RUN_IFELSE(
2307 [AC_LANG_PROGRAM([[
2308 #include <stdio.h>
2309 #include <string.h>
2310 #include <openssl/opensslv.h>
2311 #define DATA "conftest.sslincver"
2312 ]], [[
2313 FILE *fd;
2314 int rc;
2315
2316 fd = fopen(DATA,"w");
2317 if(fd == NULL)
2318 exit(1);
2319
2320 if ((rc = fprintf(fd ,"%08x (%s)\n", OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_TEXT)) <0)
2321 exit(1);
2322
2323 exit(0);
2324 ]])],
2325 [
2326 ssl_header_ver=`cat conftest.sslincver`
2327 AC_MSG_RESULT([$ssl_header_ver])
2328 ],
2329 [
2330 AC_MSG_RESULT([not found])
2331 AC_MSG_ERROR([OpenSSL version header not found.])
2332 ],
2333 [
2334 AC_MSG_WARN([cross compiling: not checking])
2335 ]
2336 )
2337
2338 # Determine OpenSSL library version
2339 AC_MSG_CHECKING([OpenSSL library version])
2340 AC_RUN_IFELSE(
2341 [AC_LANG_PROGRAM([[
2342 #include <stdio.h>
2343 #include <string.h>
2344 #include <openssl/opensslv.h>
2345 #include <openssl/crypto.h>
2346 #define DATA "conftest.ssllibver"
2347 ]], [[
2348 FILE *fd;
2349 int rc;
2350
2351 fd = fopen(DATA,"w");
2352 if(fd == NULL)
2353 exit(1);
2354
2355 if ((rc = fprintf(fd ,"%08x (%s)\n", SSLeay(),
2356 SSLeay_version(SSLEAY_VERSION))) <0)
2357 exit(1);
2358
2359 exit(0);
2360 ]])],
2361 [
2362 ssl_library_ver=`cat conftest.ssllibver`
2363 # Check version is supported.
2364 case "$ssl_library_ver" in
2365 0090[[0-7]]*|009080[[0-5]]*)
2366 AC_MSG_ERROR([OpenSSL >= 0.9.8f required (have "$ssl_library_ver")])
2367 ;;
2368 *) ;;
2369 esac
2370 AC_MSG_RESULT([$ssl_library_ver])
2371 ],
2372 [
2373 AC_MSG_RESULT([not found])
2374 AC_MSG_ERROR([OpenSSL library not found.])
2375 ],
2376 [
2377 AC_MSG_WARN([cross compiling: not checking])
2378 ]
2379 )
2380
2381 # Sanity check OpenSSL headers
2382 AC_MSG_CHECKING([whether OpenSSL's headers match the library])
2383 AC_RUN_IFELSE(
2384 [AC_LANG_PROGRAM([[
2385 #include <string.h>
2386 #include <openssl/opensslv.h>
2387 ]], [[
2388 exit(SSLeay() == OPENSSL_VERSION_NUMBER ? 0 : 1);
2389 ]])],
2390 [
2391 AC_MSG_RESULT([yes])
2392 ],
2393 [
2394 AC_MSG_RESULT([no])
2395 if test "x$openssl_check_nonfatal" = "x"; then
2396 AC_MSG_ERROR([Your OpenSSL headers do not match your
2397 library. Check config.log for details.
2398 If you are sure your installation is consistent, you can disable the check
2399 by running "./configure --without-openssl-header-check".
2400 Also see contrib/findssl.sh for help identifying header/library mismatches.
2401 ])
2402 else
2403 AC_MSG_WARN([Your OpenSSL headers do not match your
2404 library. Check config.log for details.
2405 Also see contrib/findssl.sh for help identifying header/library mismatches.])
2406 fi
2407 ],
2408 [
2409 AC_MSG_WARN([cross compiling: not checking])
2410 ]
2411 )
2412
2413 AC_MSG_CHECKING([if programs using OpenSSL functions will link])
2414 AC_LINK_IFELSE(
2415 [AC_LANG_PROGRAM([[ #include <openssl/evp.h> ]],
2416 [[ SSLeay_add_all_algorithms(); ]])],
2417 [
2418 AC_MSG_RESULT([yes])
2419 ],
2420 [
2421 AC_MSG_RESULT([no])
2422 saved_LIBS="$LIBS"
2423 LIBS="$LIBS -ldl"
2424 AC_MSG_CHECKING([if programs using OpenSSL need -ldl])
2425 AC_LINK_IFELSE(
2426 [AC_LANG_PROGRAM([[ #include <openssl/evp.h> ]],
2427 [[ SSLeay_add_all_algorithms(); ]])],
2428 [
2429 AC_MSG_RESULT([yes])
2430 ],
2431 [
2432 AC_MSG_RESULT([no])
2433 LIBS="$saved_LIBS"
2434 ]
2435 )
2436 ]
2437 )
2438
2439 AC_CHECK_FUNCS([ \
2440 BN_is_prime_ex \
2441 DSA_generate_parameters_ex \
2442 EVP_DigestInit_ex \
2443 EVP_DigestFinal_ex \
2444 EVP_MD_CTX_init \
2445 EVP_MD_CTX_cleanup \
2446 EVP_MD_CTX_copy_ex \
2447 HMAC_CTX_init \
2448 RSA_generate_key_ex \
2449 RSA_get_default_method \
2450 ])
2451
2452 if test "x$openssl_engine" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08002453 AC_MSG_CHECKING([for OpenSSL ENGINE support])
2454 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller72ef7c12015-01-15 02:21:31 +11002455 #include <openssl/engine.h>
Tim Rice648f8762011-01-26 12:38:57 -08002456 ]], [[
Damien Miller72ef7c12015-01-15 02:21:31 +11002457 ENGINE_load_builtin_engines();
2458 ENGINE_register_all_complete();
Tim Rice648f8762011-01-26 12:38:57 -08002459 ]])],
2460 [ AC_MSG_RESULT([yes])
2461 AC_DEFINE([USE_OPENSSL_ENGINE], [1],
Darren Tuckerfabdb6c2006-02-20 20:17:35 +11002462 [Enable OpenSSL engine support])
Tim Rice648f8762011-01-26 12:38:57 -08002463 ], [ AC_MSG_ERROR([OpenSSL ENGINE support not found])
2464 ])
Damien Miller72ef7c12015-01-15 02:21:31 +11002465 fi
Darren Tuckerfabdb6c2006-02-20 20:17:35 +11002466
Damien Miller72ef7c12015-01-15 02:21:31 +11002467 # Check for OpenSSL without EVP_aes_{192,256}_cbc
2468 AC_MSG_CHECKING([whether OpenSSL has crippled AES support])
2469 AC_LINK_IFELSE(
Darren Tucker37bcef52013-11-09 18:39:25 +11002470 [AC_LANG_PROGRAM([[
Damien Miller72ef7c12015-01-15 02:21:31 +11002471 #include <string.h>
2472 #include <openssl/evp.h>
2473 ]], [[
2474 exit(EVP_aes_192_cbc() == NULL || EVP_aes_256_cbc() == NULL);
2475 ]])],
2476 [
2477 AC_MSG_RESULT([no])
2478 ],
2479 [
2480 AC_MSG_RESULT([yes])
2481 AC_DEFINE([OPENSSL_LOBOTOMISED_AES], [1],
2482 [libcrypto is missing AES 192 and 256 bit functions])
2483 ]
2484 )
2485
2486 # Check for OpenSSL with EVP_aes_*ctr
2487 AC_MSG_CHECKING([whether OpenSSL has AES CTR via EVP])
2488 AC_LINK_IFELSE(
2489 [AC_LANG_PROGRAM([[
2490 #include <string.h>
2491 #include <openssl/evp.h>
2492 ]], [[
2493 exit(EVP_aes_128_ctr() == NULL ||
2494 EVP_aes_192_cbc() == NULL ||
2495 EVP_aes_256_cbc() == NULL);
2496 ]])],
2497 [
2498 AC_MSG_RESULT([yes])
2499 AC_DEFINE([OPENSSL_HAVE_EVPCTR], [1],
2500 [libcrypto has EVP AES CTR])
2501 ],
2502 [
2503 AC_MSG_RESULT([no])
2504 ]
2505 )
2506
2507 # Check for OpenSSL with EVP_aes_*gcm
2508 AC_MSG_CHECKING([whether OpenSSL has AES GCM via EVP])
2509 AC_LINK_IFELSE(
2510 [AC_LANG_PROGRAM([[
2511 #include <string.h>
2512 #include <openssl/evp.h>
2513 ]], [[
2514 exit(EVP_aes_128_gcm() == NULL ||
2515 EVP_aes_256_gcm() == NULL ||
2516 EVP_CTRL_GCM_SET_IV_FIXED == 0 ||
2517 EVP_CTRL_GCM_IV_GEN == 0 ||
2518 EVP_CTRL_GCM_SET_TAG == 0 ||
2519 EVP_CTRL_GCM_GET_TAG == 0 ||
2520 EVP_CIPHER_CTX_ctrl(NULL, 0, 0, NULL) == 0);
2521 ]])],
2522 [
2523 AC_MSG_RESULT([yes])
2524 AC_DEFINE([OPENSSL_HAVE_EVPGCM], [1],
2525 [libcrypto has EVP AES GCM])
2526 ],
2527 [
2528 AC_MSG_RESULT([no])
2529 unsupported_algorithms="$unsupported_cipers \
2530 aes128-gcm@openssh.com aes256-gcm@openssh.com"
2531 ]
2532 )
2533
2534 AC_SEARCH_LIBS([EVP_CIPHER_CTX_ctrl], [crypto],
2535 [AC_DEFINE([HAVE_EVP_CIPHER_CTX_CTRL], [1],
2536 [Define if libcrypto has EVP_CIPHER_CTX_ctrl])])
2537
2538 AC_MSG_CHECKING([if EVP_DigestUpdate returns an int])
2539 AC_LINK_IFELSE(
2540 [AC_LANG_PROGRAM([[
2541 #include <string.h>
2542 #include <openssl/evp.h>
2543 ]], [[
2544 if(EVP_DigestUpdate(NULL, NULL,0))
2545 exit(0);
2546 ]])],
2547 [
2548 AC_MSG_RESULT([yes])
2549 ],
2550 [
2551 AC_MSG_RESULT([no])
2552 AC_DEFINE([OPENSSL_EVP_DIGESTUPDATE_VOID], [1],
2553 [Define if EVP_DigestUpdate returns void])
2554 ]
2555 )
2556
2557 # Some systems want crypt() from libcrypt, *not* the version in OpenSSL,
2558 # because the system crypt() is more featureful.
2559 if test "x$check_for_libcrypt_before" = "x1"; then
2560 AC_CHECK_LIB([crypt], [crypt])
2561 fi
2562
2563 # Some Linux systems (Slackware) need crypt() from libcrypt, *not* the
2564 # version in OpenSSL.
2565 if test "x$check_for_libcrypt_later" = "x1"; then
2566 AC_CHECK_LIB([crypt], [crypt], [LIBS="$LIBS -lcrypt"])
2567 fi
2568
2569 # Search for SHA256 support in libc and/or OpenSSL
2570 AC_CHECK_FUNCS([SHA256_Update EVP_sha256], ,
2571 [unsupported_algorithms="$unsupported_algorithms \
2572 hmac-sha2-256 hmac-sha2-512 \
2573 diffie-hellman-group-exchange-sha256 \
2574 hmac-sha2-256-etm@openssh.com hmac-sha2-512-etm@openssh.com"
2575 ]
2576 )
2577 # Search for RIPE-MD support in OpenSSL
2578 AC_CHECK_FUNCS([EVP_ripemd160], ,
2579 [unsupported_algorithms="$unsupported_algorithms \
2580 hmac-ripemd160
2581 hmac-ripemd160@openssh.com
2582 hmac-ripemd160-etm@openssh.com"
2583 ]
2584 )
2585
2586 # Check complete ECC support in OpenSSL
2587 AC_MSG_CHECKING([whether OpenSSL has NID_X9_62_prime256v1])
2588 AC_LINK_IFELSE(
2589 [AC_LANG_PROGRAM([[
2590 #include <openssl/ec.h>
2591 #include <openssl/ecdh.h>
2592 #include <openssl/ecdsa.h>
2593 #include <openssl/evp.h>
2594 #include <openssl/objects.h>
2595 #include <openssl/opensslv.h>
2596 #if OPENSSL_VERSION_NUMBER < 0x0090807f /* 0.9.8g */
2597 # error "OpenSSL < 0.9.8g has unreliable ECC code"
2598 #endif
2599 ]], [[
2600 EC_KEY *e = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
2601 const EVP_MD *m = EVP_sha256(); /* We need this too */
Darren Tucker37bcef52013-11-09 18:39:25 +11002602 ]])],
2603 [ AC_MSG_RESULT([yes])
Damien Miller72ef7c12015-01-15 02:21:31 +11002604 enable_nistp256=1 ],
2605 [ AC_MSG_RESULT([no]) ]
2606 )
Darren Tucker37bcef52013-11-09 18:39:25 +11002607
Damien Miller72ef7c12015-01-15 02:21:31 +11002608 AC_MSG_CHECKING([whether OpenSSL has NID_secp384r1])
2609 AC_LINK_IFELSE(
2610 [AC_LANG_PROGRAM([[
2611 #include <openssl/ec.h>
2612 #include <openssl/ecdh.h>
2613 #include <openssl/ecdsa.h>
2614 #include <openssl/evp.h>
2615 #include <openssl/objects.h>
2616 #include <openssl/opensslv.h>
2617 #if OPENSSL_VERSION_NUMBER < 0x0090807f /* 0.9.8g */
2618 # error "OpenSSL < 0.9.8g has unreliable ECC code"
2619 #endif
2620 ]], [[
2621 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp384r1);
2622 const EVP_MD *m = EVP_sha384(); /* We need this too */
2623 ]])],
2624 [ AC_MSG_RESULT([yes])
2625 enable_nistp384=1 ],
2626 [ AC_MSG_RESULT([no]) ]
2627 )
Darren Tucker37bcef52013-11-09 18:39:25 +11002628
Damien Miller72ef7c12015-01-15 02:21:31 +11002629 AC_MSG_CHECKING([whether OpenSSL has NID_secp521r1])
2630 AC_LINK_IFELSE(
2631 [AC_LANG_PROGRAM([[
2632 #include <openssl/ec.h>
2633 #include <openssl/ecdh.h>
2634 #include <openssl/ecdsa.h>
2635 #include <openssl/evp.h>
2636 #include <openssl/objects.h>
2637 #include <openssl/opensslv.h>
2638 #if OPENSSL_VERSION_NUMBER < 0x0090807f /* 0.9.8g */
2639 # error "OpenSSL < 0.9.8g has unreliable ECC code"
2640 #endif
2641 ]], [[
2642 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1);
2643 const EVP_MD *m = EVP_sha512(); /* We need this too */
2644 ]])],
2645 [ AC_MSG_RESULT([yes])
2646 AC_MSG_CHECKING([if OpenSSL's NID_secp521r1 is functional])
2647 AC_RUN_IFELSE(
2648 [AC_LANG_PROGRAM([[
2649 #include <openssl/ec.h>
2650 #include <openssl/ecdh.h>
2651 #include <openssl/ecdsa.h>
2652 #include <openssl/evp.h>
2653 #include <openssl/objects.h>
2654 #include <openssl/opensslv.h>
2655 ]],[[
2656 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1);
2657 const EVP_MD *m = EVP_sha512(); /* We need this too */
2658 exit(e == NULL || m == NULL);
2659 ]])],
2660 [ AC_MSG_RESULT([yes])
2661 enable_nistp521=1 ],
2662 [ AC_MSG_RESULT([no]) ],
2663 [ AC_MSG_WARN([cross-compiling: assuming yes])
2664 enable_nistp521=1 ]
2665 )],
2666 AC_MSG_RESULT([no])
2667 )
Darren Tucker37bcef52013-11-09 18:39:25 +11002668
Damien Miller72ef7c12015-01-15 02:21:31 +11002669 COMMENT_OUT_ECC="#no ecc#"
2670 TEST_SSH_ECC=no
2671
2672 if test x$enable_nistp256 = x1 || test x$enable_nistp384 = x1 || \
2673 test x$enable_nistp521 = x1; then
2674 AC_DEFINE(OPENSSL_HAS_ECC, [1], [OpenSSL has ECC])
2675 fi
2676 if test x$enable_nistp256 = x1; then
2677 AC_DEFINE([OPENSSL_HAS_NISTP256], [1],
2678 [libcrypto has NID_X9_62_prime256v1])
2679 TEST_SSH_ECC=yes
2680 COMMENT_OUT_ECC=""
2681 else
2682 unsupported_algorithms="$unsupported_algorithms ecdsa-sha2-nistp256 \
2683 ecdh-sha2-nistp256 ecdsa-sha2-nistp256-cert-v01@openssh.com"
2684 fi
2685 if test x$enable_nistp384 = x1; then
2686 AC_DEFINE([OPENSSL_HAS_NISTP384], [1], [libcrypto has NID_secp384r1])
2687 TEST_SSH_ECC=yes
2688 COMMENT_OUT_ECC=""
2689 else
2690 unsupported_algorithms="$unsupported_algorithms ecdsa-sha2-nistp384 \
2691 ecdh-sha2-nistp384 ecdsa-sha2-nistp384-cert-v01@openssh.com"
2692 fi
2693 if test x$enable_nistp521 = x1; then
2694 AC_DEFINE([OPENSSL_HAS_NISTP521], [1], [libcrypto has NID_secp521r1])
2695 TEST_SSH_ECC=yes
2696 COMMENT_OUT_ECC=""
2697 else
2698 unsupported_algorithms="$unsupported_algorithms ecdh-sha2-nistp521 \
2699 ecdsa-sha2-nistp521 ecdsa-sha2-nistp521-cert-v01@openssh.com"
2700 fi
2701
2702 AC_SUBST([TEST_SSH_ECC])
2703 AC_SUBST([COMMENT_OUT_ECC])
2704else
2705 AC_CHECK_LIB([crypt], [crypt], [LIBS="$LIBS -lcrypt"])
2706 AC_CHECK_FUNCS([crypt DES_crypt])
2707fi
Damien Miller6af914a2010-09-10 11:39:26 +10002708
Damien Miller00f9cd22014-07-15 10:41:38 +10002709AC_CHECK_FUNCS([ \
2710 arc4random \
2711 arc4random_buf \
2712 arc4random_stir \
2713 arc4random_uniform \
2714])
2715
Tim Rice99203ec2007-03-26 09:35:28 -07002716saved_LIBS="$LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08002717AC_CHECK_LIB([iaf], [ia_openinfo], [
Tim Rice99203ec2007-03-26 09:35:28 -07002718 LIBS="$LIBS -liaf"
Tim Rice648f8762011-01-26 12:38:57 -08002719 AC_CHECK_FUNCS([set_id], [SSHDLIBS="$SSHDLIBS -liaf"
2720 AC_DEFINE([HAVE_LIBIAF], [1],
Tim Rice0eeaf122007-09-10 16:24:17 -07002721 [Define if system has libiaf that supports set_id])
2722 ])
Tim Rice99203ec2007-03-26 09:35:28 -07002723])
2724LIBS="$saved_LIBS"
Damien Miller6c21c512002-01-22 21:57:53 +11002725
2726### Configure cryptographic random number support
2727
2728# Check wheter OpenSSL seeds itself
Damien Miller72ef7c12015-01-15 02:21:31 +11002729if test "x$openssl" = "xyes" ; then
2730 AC_MSG_CHECKING([whether OpenSSL's PRNG is internally seeded])
2731 AC_RUN_IFELSE(
2732 [AC_LANG_PROGRAM([[
2733 #include <string.h>
2734 #include <openssl/rand.h>
2735 ]], [[
2736 exit(RAND_status() == 1 ? 0 : 1);
2737 ]])],
2738 [
2739 OPENSSL_SEEDS_ITSELF=yes
2740 AC_MSG_RESULT([yes])
2741 ],
2742 [
2743 AC_MSG_RESULT([no])
2744 ],
2745 [
2746 AC_MSG_WARN([cross compiling: assuming yes])
2747 # This is safe, since we will fatal() at runtime if
2748 # OpenSSL is not seeded correctly.
2749 OPENSSL_SEEDS_ITSELF=yes
2750 ]
2751 )
2752fi
Damien Miller6c21c512002-01-22 21:57:53 +11002753
Damien Millerf22019b2011-05-05 13:48:37 +10002754# PRNGD TCP socket
2755AC_ARG_WITH([prngd-port],
2756 [ --with-prngd-port=PORT read entropy from PRNGD/EGD TCP localhost:PORT],
2757 [
2758 case "$withval" in
2759 no)
2760 withval=""
2761 ;;
2762 [[0-9]]*)
2763 ;;
2764 *)
2765 AC_MSG_ERROR([You must specify a numeric port number for --with-prngd-port])
2766 ;;
2767 esac
2768 if test ! -z "$withval" ; then
2769 PRNGD_PORT="$withval"
2770 AC_DEFINE_UNQUOTED([PRNGD_PORT], [$PRNGD_PORT],
2771 [Port number of PRNGD/EGD random number socket])
2772 fi
2773 ]
2774)
2775
2776# PRNGD Unix domain socket
2777AC_ARG_WITH([prngd-socket],
2778 [ --with-prngd-socket=FILE read entropy from PRNGD/EGD socket FILE (default=/var/run/egd-pool)],
2779 [
2780 case "$withval" in
2781 yes)
2782 withval="/var/run/egd-pool"
2783 ;;
2784 no)
2785 withval=""
2786 ;;
2787 /*)
2788 ;;
2789 *)
2790 AC_MSG_ERROR([You must specify an absolute path to the entropy socket])
2791 ;;
2792 esac
2793
2794 if test ! -z "$withval" ; then
2795 if test ! -z "$PRNGD_PORT" ; then
2796 AC_MSG_ERROR([You may not specify both a PRNGD/EGD port and socket])
2797 fi
2798 if test ! -r "$withval" ; then
2799 AC_MSG_WARN([Entropy socket is not readable])
2800 fi
2801 PRNGD_SOCKET="$withval"
2802 AC_DEFINE_UNQUOTED([PRNGD_SOCKET], ["$PRNGD_SOCKET"],
2803 [Location of PRNGD/EGD random number socket])
2804 fi
2805 ],
2806 [
2807 # Check for existing socket only if we don't have a random device already
2808 if test "x$OPENSSL_SEEDS_ITSELF" != "xyes" ; then
2809 AC_MSG_CHECKING([for PRNGD/EGD socket])
2810 # Insert other locations here
2811 for sock in /var/run/egd-pool /dev/egd-pool /etc/entropy; do
2812 if test -r $sock && $TEST_MINUS_S_SH -c "test -S $sock -o -p $sock" ; then
2813 PRNGD_SOCKET="$sock"
2814 AC_DEFINE_UNQUOTED([PRNGD_SOCKET], ["$PRNGD_SOCKET"])
2815 break;
2816 fi
2817 done
2818 if test ! -z "$PRNGD_SOCKET" ; then
2819 AC_MSG_RESULT([$PRNGD_SOCKET])
2820 else
2821 AC_MSG_RESULT([not found])
2822 fi
2823 fi
2824 ]
2825)
2826
2827# Which randomness source do we use?
2828if test ! -z "$PRNGD_PORT" ; then
2829 RAND_MSG="PRNGd port $PRNGD_PORT"
2830elif test ! -z "$PRNGD_SOCKET" ; then
2831 RAND_MSG="PRNGd socket $PRNGD_SOCKET"
2832elif test ! -z "$OPENSSL_SEEDS_ITSELF" ; then
2833 AC_DEFINE([OPENSSL_PRNG_ONLY], [1],
Damien Miller72ef7c12015-01-15 02:21:31 +11002834 [Define if you want the OpenSSL internally seeded PRNG only])
Damien Millerf22019b2011-05-05 13:48:37 +10002835 RAND_MSG="OpenSSL internal ONLY"
Damien Miller72ef7c12015-01-15 02:21:31 +11002836elif test "x$openssl" = "xno" ; then
2837 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 +10002838else
2839 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])
2840fi
2841
Darren Tucker3e6bde42006-08-20 20:03:50 +10002842# Check for PAM libs
2843PAM_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08002844AC_ARG_WITH([pam],
Darren Tucker3e6bde42006-08-20 20:03:50 +10002845 [ --with-pam Enable PAM support ],
2846 [
2847 if test "x$withval" != "xno" ; then
2848 if test "x$ac_cv_header_security_pam_appl_h" != "xyes" && \
2849 test "x$ac_cv_header_pam_pam_appl_h" != "xyes" ; then
2850 AC_MSG_ERROR([PAM headers not found])
2851 fi
2852
2853 saved_LIBS="$LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08002854 AC_CHECK_LIB([dl], [dlopen], , )
2855 AC_CHECK_LIB([pam], [pam_set_item], , [AC_MSG_ERROR([*** libpam missing])])
2856 AC_CHECK_FUNCS([pam_getenvlist])
2857 AC_CHECK_FUNCS([pam_putenv])
Darren Tucker3e6bde42006-08-20 20:03:50 +10002858 LIBS="$saved_LIBS"
2859
2860 PAM_MSG="yes"
2861
Darren Tucker20e9f972007-03-25 18:26:01 +10002862 SSHDLIBS="$SSHDLIBS -lpam"
Tim Rice648f8762011-01-26 12:38:57 -08002863 AC_DEFINE([USE_PAM], [1],
Darren Tucker3e6bde42006-08-20 20:03:50 +10002864 [Define if you want to enable PAM support])
Darren Tucker639bbe82006-08-20 20:17:53 +10002865
Darren Tucker3e6bde42006-08-20 20:03:50 +10002866 if test $ac_cv_lib_dl_dlopen = yes; then
Darren Tucker639bbe82006-08-20 20:17:53 +10002867 case "$LIBS" in
2868 *-ldl*)
2869 # libdl already in LIBS
2870 ;;
2871 *)
Darren Tucker20e9f972007-03-25 18:26:01 +10002872 SSHDLIBS="$SSHDLIBS -ldl"
Darren Tucker639bbe82006-08-20 20:17:53 +10002873 ;;
2874 esac
Darren Tucker3e6bde42006-08-20 20:03:50 +10002875 fi
Darren Tucker3e6bde42006-08-20 20:03:50 +10002876 fi
2877 ]
2878)
2879
2880# Check for older PAM
2881if test "x$PAM_MSG" = "xyes" ; then
2882 # Check PAM strerror arguments (old PAM)
2883 AC_MSG_CHECKING([whether pam_strerror takes only one argument])
Tim Rice648f8762011-01-26 12:38:57 -08002884 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker3e6bde42006-08-20 20:03:50 +10002885#include <stdlib.h>
2886#if defined(HAVE_SECURITY_PAM_APPL_H)
2887#include <security/pam_appl.h>
2888#elif defined (HAVE_PAM_PAM_APPL_H)
2889#include <pam/pam_appl.h>
2890#endif
Tim Rice648f8762011-01-26 12:38:57 -08002891 ]], [[
2892(void)pam_strerror((pam_handle_t *)NULL, -1);
2893 ]])], [AC_MSG_RESULT([no])], [
2894 AC_DEFINE([HAVE_OLD_PAM], [1],
Darren Tucker3e6bde42006-08-20 20:03:50 +10002895 [Define if you have an old version of PAM
2896 which takes only one argument to pam_strerror])
Tim Rice648f8762011-01-26 12:38:57 -08002897 AC_MSG_RESULT([yes])
Darren Tucker3e6bde42006-08-20 20:03:50 +10002898 PAM_MSG="yes (old library)"
Damien Miller72ef7c12015-01-15 02:21:31 +11002899
Tim Rice648f8762011-01-26 12:38:57 -08002900 ])
Darren Tucker3e6bde42006-08-20 20:03:50 +10002901fi
Damien Miller6c21c512002-01-22 21:57:53 +11002902
Damien Miller6482d902014-05-27 14:34:42 +10002903case "$host" in
2904*-*-cygwin*)
2905 SSH_PRIVSEP_USER=CYGWIN_SSH_PRIVSEP_USER
2906 ;;
2907*)
2908 SSH_PRIVSEP_USER=sshd
2909 ;;
2910esac
Tim Rice648f8762011-01-26 12:38:57 -08002911AC_ARG_WITH([privsep-user],
Kevin Stevesc81e1292002-05-13 03:51:40 +00002912 [ --with-privsep-user=user Specify non-privileged user for privilege separation],
Kevin Steves7ff91122002-04-07 19:22:54 +00002913 [
Tim Rice35cc69d2005-03-17 16:44:25 -08002914 if test -n "$withval" && test "x$withval" != "xno" && \
2915 test "x${withval}" != "xyes"; then
Damien Millerd3f6ad22002-06-25 10:24:47 +10002916 SSH_PRIVSEP_USER=$withval
Kevin Steves7ff91122002-04-07 19:22:54 +00002917 fi
Tim Riceeae17cc2005-03-17 16:52:20 -08002918 ]
Kevin Steves7ff91122002-04-07 19:22:54 +00002919)
Damien Miller6482d902014-05-27 14:34:42 +10002920if test "x$SSH_PRIVSEP_USER" = "xCYGWIN_SSH_PRIVSEP_USER" ; then
2921 AC_DEFINE_UNQUOTED([SSH_PRIVSEP_USER], [CYGWIN_SSH_PRIVSEP_USER],
2922 [Cygwin function to fetch non-privileged user for privilege separation])
2923else
2924 AC_DEFINE_UNQUOTED([SSH_PRIVSEP_USER], ["$SSH_PRIVSEP_USER"],
2925 [non-privileged user for privilege separation])
2926fi
Tim Rice648f8762011-01-26 12:38:57 -08002927AC_SUBST([SSH_PRIVSEP_USER])
Kevin Steves7ff91122002-04-07 19:22:54 +00002928
Damien Miller91f40d82013-02-22 11:37:00 +11002929if test "x$have_linux_no_new_privs" = "x1" ; then
2930AC_CHECK_DECL([SECCOMP_MODE_FILTER], [have_seccomp_filter=1], , [
2931 #include <sys/types.h>
2932 #include <linux/seccomp.h>
2933])
2934fi
2935if test "x$have_seccomp_filter" = "x1" ; then
2936AC_MSG_CHECKING([kernel for seccomp_filter support])
2937AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2938 #include <errno.h>
2939 #include <elf.h>
2940 #include <linux/audit.h>
2941 #include <linux/seccomp.h>
2942 #include <stdlib.h>
2943 #include <sys/prctl.h>
2944 ]],
2945 [[ int i = $seccomp_audit_arch;
2946 errno = 0;
2947 prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, NULL, 0, 0);
2948 exit(errno == EFAULT ? 0 : 1); ]])],
2949 [ AC_MSG_RESULT([yes]) ], [
2950 AC_MSG_RESULT([no])
2951 # Disable seccomp filter as a target
2952 have_seccomp_filter=0
2953 ]
2954)
2955fi
2956
Damien Miller69ff1df2011-06-23 08:30:03 +10002957# Decide which sandbox style to use
2958sandbox_arg=""
2959AC_ARG_WITH([sandbox],
Damien Miller868ea1e2014-01-17 16:47:04 +11002960 [ --with-sandbox=style Specify privilege separation sandbox (no, darwin, rlimit, systrace, seccomp_filter, capsicum)],
Damien Miller69ff1df2011-06-23 08:30:03 +10002961 [
2962 if test "x$withval" = "xyes" ; then
2963 sandbox_arg=""
2964 else
2965 sandbox_arg="$withval"
2966 fi
2967 ]
2968)
Darren Tucker60395f92012-07-03 14:31:18 +10002969
2970# Some platforms (seems to be the ones that have a kernel poll(2)-type
2971# function with which they implement select(2)) use an extra file descriptor
2972# when calling select(2), which means we can't use the rlimit sandbox.
2973AC_MSG_CHECKING([if select works with descriptor rlimit])
2974AC_RUN_IFELSE(
2975 [AC_LANG_PROGRAM([[
2976#include <sys/types.h>
2977#ifdef HAVE_SYS_TIME_H
2978# include <sys/time.h>
2979#endif
2980#include <sys/resource.h>
2981#ifdef HAVE_SYS_SELECT_H
2982# include <sys/select.h>
2983#endif
2984#include <errno.h>
2985#include <fcntl.h>
2986#include <stdlib.h>
2987 ]],[[
2988 struct rlimit rl_zero;
2989 int fd, r;
2990 fd_set fds;
Damien Millere4f43472013-03-08 12:14:22 +11002991 struct timeval tv;
Darren Tucker60395f92012-07-03 14:31:18 +10002992
2993 fd = open("/dev/null", O_RDONLY);
2994 FD_ZERO(&fds);
2995 FD_SET(fd, &fds);
2996 rl_zero.rlim_cur = rl_zero.rlim_max = 0;
2997 setrlimit(RLIMIT_FSIZE, &rl_zero);
2998 setrlimit(RLIMIT_NOFILE, &rl_zero);
Damien Millere4f43472013-03-08 12:14:22 +11002999 tv.tv_sec = 1;
3000 tv.tv_usec = 0;
3001 r = select(fd+1, &fds, NULL, NULL, &tv);
Darren Tucker60395f92012-07-03 14:31:18 +10003002 exit (r == -1 ? 1 : 0);
3003 ]])],
3004 [AC_MSG_RESULT([yes])
3005 select_works_with_rlimit=yes],
3006 [AC_MSG_RESULT([no])
3007 select_works_with_rlimit=no],
3008 [AC_MSG_WARN([cross compiling: assuming yes])]
3009)
3010
Darren Tuckerff008de2013-03-06 17:48:48 +11003011AC_MSG_CHECKING([if setrlimit(RLIMIT_NOFILE,{0,0}) works])
3012AC_RUN_IFELSE(
3013 [AC_LANG_PROGRAM([[
3014#include <sys/types.h>
3015#ifdef HAVE_SYS_TIME_H
3016# include <sys/time.h>
3017#endif
3018#include <sys/resource.h>
3019#include <errno.h>
3020#include <stdlib.h>
3021 ]],[[
3022 struct rlimit rl_zero;
3023 int fd, r;
3024 fd_set fds;
3025
3026 rl_zero.rlim_cur = rl_zero.rlim_max = 0;
3027 r = setrlimit(RLIMIT_NOFILE, &rl_zero);
3028 exit (r == -1 ? 1 : 0);
3029 ]])],
3030 [AC_MSG_RESULT([yes])
3031 rlimit_nofile_zero_works=yes],
3032 [AC_MSG_RESULT([no])
3033 rlimit_nofile_zero_works=no],
3034 [AC_MSG_WARN([cross compiling: assuming yes])]
3035)
3036
Darren Tuckerd545a4b2012-07-03 22:48:31 +10003037AC_MSG_CHECKING([if setrlimit RLIMIT_FSIZE works])
3038AC_RUN_IFELSE(
3039 [AC_LANG_PROGRAM([[
3040#include <sys/types.h>
3041#include <sys/resource.h>
3042#include <stdlib.h>
3043 ]],[[
3044 struct rlimit rl_zero;
3045
3046 rl_zero.rlim_cur = rl_zero.rlim_max = 0;
3047 exit(setrlimit(RLIMIT_FSIZE, &rl_zero) != 0);
3048 ]])],
3049 [AC_MSG_RESULT([yes])],
3050 [AC_MSG_RESULT([no])
3051 AC_DEFINE(SANDBOX_SKIP_RLIMIT_FSIZE, 1,
3052 [setrlimit RLIMIT_FSIZE works])],
3053 [AC_MSG_WARN([cross compiling: assuming yes])]
3054)
3055
Damien Miller69ff1df2011-06-23 08:30:03 +10003056if test "x$sandbox_arg" = "xsystrace" || \
3057 ( test -z "$sandbox_arg" && test "x$have_systr_policy_kill" = "x1" ) ; then
Damien Miller1a91c0f2011-08-17 11:59:25 +10003058 test "x$have_systr_policy_kill" != "x1" && \
3059 AC_MSG_ERROR([systrace sandbox requires systrace headers and SYSTR_POLICY_KILL support])
Damien Miller69ff1df2011-06-23 08:30:03 +10003060 SANDBOX_STYLE="systrace"
3061 AC_DEFINE([SANDBOX_SYSTRACE], [1], [Sandbox using systrace(4)])
Damien Millercd5e52e2011-06-27 07:18:18 +10003062elif test "x$sandbox_arg" = "xdarwin" || \
3063 ( test -z "$sandbox_arg" && test "x$ac_cv_func_sandbox_init" = "xyes" && \
3064 test "x$ac_cv_header_sandbox_h" = "xyes") ; then
Damien Miller1a91c0f2011-08-17 11:59:25 +10003065 test "x$ac_cv_func_sandbox_init" != "xyes" -o \
3066 "x$ac_cv_header_sandbox_h" != "xyes" && \
3067 AC_MSG_ERROR([Darwin seatbelt sandbox requires sandbox.h and sandbox_init function])
Damien Millercd5e52e2011-06-27 07:18:18 +10003068 SANDBOX_STYLE="darwin"
3069 AC_DEFINE([SANDBOX_DARWIN], [1], [Sandbox using Darwin sandbox_init(3)])
Damien Millere0956e32012-04-04 11:27:54 +10003070elif test "x$sandbox_arg" = "xseccomp_filter" || \
3071 ( test -z "$sandbox_arg" && \
Darren Tuckerd0494fd2012-05-19 14:25:39 +10003072 test "x$have_seccomp_filter" = "x1" && \
Damien Miller91f40d82013-02-22 11:37:00 +11003073 test "x$ac_cv_header_elf_h" = "xyes" && \
Damien Millere0956e32012-04-04 11:27:54 +10003074 test "x$ac_cv_header_linux_audit_h" = "xyes" && \
Damien Miller91f40d82013-02-22 11:37:00 +11003075 test "x$ac_cv_header_linux_filter_h" = "xyes" && \
3076 test "x$seccomp_audit_arch" != "x" && \
Damien Millere0956e32012-04-04 11:27:54 +10003077 test "x$have_linux_no_new_privs" = "x1" && \
3078 test "x$ac_cv_func_prctl" = "xyes" ) ; then
Damien Miller91f40d82013-02-22 11:37:00 +11003079 test "x$seccomp_audit_arch" = "x" && \
Damien Millere0956e32012-04-04 11:27:54 +10003080 AC_MSG_ERROR([seccomp_filter sandbox not supported on $host])
3081 test "x$have_linux_no_new_privs" != "x1" && \
3082 AC_MSG_ERROR([seccomp_filter sandbox requires PR_SET_NO_NEW_PRIVS])
3083 test "x$have_seccomp_filter" != "x1" && \
3084 AC_MSG_ERROR([seccomp_filter sandbox requires seccomp headers])
3085 test "x$ac_cv_func_prctl" != "xyes" && \
3086 AC_MSG_ERROR([seccomp_filter sandbox requires prctl function])
3087 SANDBOX_STYLE="seccomp_filter"
3088 AC_DEFINE([SANDBOX_SECCOMP_FILTER], [1], [Sandbox using seccomp filter])
Damien Millerf62ecef2014-01-25 12:34:38 +11003089elif test "x$sandbox_arg" = "xcapsicum" || \
3090 ( test -z "$sandbox_arg" && \
Damien Miller603b8f42014-01-25 13:16:59 +11003091 test "x$ac_cv_header_sys_capability_h" = "xyes" && \
3092 test "x$ac_cv_func_cap_rights_limit" = "xyes") ; then
3093 test "x$ac_cv_header_sys_capability_h" != "xyes" && \
Damien Millerc96d8532014-01-25 13:12:28 +11003094 AC_MSG_ERROR([capsicum sandbox requires sys/capability.h header])
Damien Miller603b8f42014-01-25 13:16:59 +11003095 test "x$ac_cv_func_cap_rights_limit" != "xyes" && \
Damien Millerc96d8532014-01-25 13:12:28 +11003096 AC_MSG_ERROR([capsicum sandbox requires cap_rights_limit function])
Damien Millerf62ecef2014-01-25 12:34:38 +11003097 SANDBOX_STYLE="capsicum"
3098 AC_DEFINE([SANDBOX_CAPSICUM], [1], [Sandbox using capsicum])
Damien Miller69ff1df2011-06-23 08:30:03 +10003099elif test "x$sandbox_arg" = "xrlimit" || \
Darren Tucker60395f92012-07-03 14:31:18 +10003100 ( test -z "$sandbox_arg" && test "x$ac_cv_func_setrlimit" = "xyes" && \
Darren Tuckerff008de2013-03-06 17:48:48 +11003101 test "x$select_works_with_rlimit" = "xyes" && \
3102 test "x$rlimit_nofile_zero_works" = "xyes" ) ; then
Damien Miller1a91c0f2011-08-17 11:59:25 +10003103 test "x$ac_cv_func_setrlimit" != "xyes" && \
3104 AC_MSG_ERROR([rlimit sandbox requires setrlimit function])
Darren Tucker60395f92012-07-03 14:31:18 +10003105 test "x$select_works_with_rlimit" != "xyes" && \
3106 AC_MSG_ERROR([rlimit sandbox requires select to work with rlimit])
Damien Miller69ff1df2011-06-23 08:30:03 +10003107 SANDBOX_STYLE="rlimit"
3108 AC_DEFINE([SANDBOX_RLIMIT], [1], [Sandbox using setrlimit(2)])
3109elif test -z "$sandbox_arg" || test "x$sandbox_arg" = "xno" || \
3110 test "x$sandbox_arg" = "xnone" || test "x$sandbox_arg" = "xnull" ; then
3111 SANDBOX_STYLE="none"
3112 AC_DEFINE([SANDBOX_NULL], [1], [no privsep sandboxing])
3113else
Tim Ricea6e60612011-08-17 21:48:22 -07003114 AC_MSG_ERROR([unsupported --with-sandbox])
Damien Miller69ff1df2011-06-23 08:30:03 +10003115fi
3116
Ben Lindstromb5628642000-10-18 00:02:25 +00003117# Cheap hack to ensure NEWS-OS libraries are arranged right.
3118if test ! -z "$SONY" ; then
3119 LIBS="$LIBS -liberty";
3120fi
3121
Damien Miller57f39152005-11-24 19:58:19 +11003122# Check for long long datatypes
3123AC_CHECK_TYPES([long long, unsigned long long, long double])
3124
3125# Check datatype sizes
Tim Rice648f8762011-01-26 12:38:57 -08003126AC_CHECK_SIZEOF([short int], [2])
3127AC_CHECK_SIZEOF([int], [4])
3128AC_CHECK_SIZEOF([long int], [4])
3129AC_CHECK_SIZEOF([long long int], [8])
Damien Millerc6398ef1999-11-20 12:18:40 +11003130
Damien Millerfa2bb692002-04-23 23:22:25 +10003131# Sanity check long long for some platforms (AIX)
3132if test "x$ac_cv_sizeof_long_long_int" = "x4" ; then
3133 ac_cv_sizeof_long_long_int=0
3134fi
3135
Darren Tucker537f1ed2005-10-25 18:38:33 +10003136# compute LLONG_MIN and LLONG_MAX if we don't know them.
3137if test -z "$have_llong_max"; then
3138 AC_MSG_CHECKING([for max value of long long])
3139 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08003140 [AC_LANG_PROGRAM([[
Darren Tucker537f1ed2005-10-25 18:38:33 +10003141#include <stdio.h>
3142/* Why is this so damn hard? */
3143#ifdef __GNUC__
3144# undef __GNUC__
3145#endif
3146#define __USE_ISOC99
3147#include <limits.h>
3148#define DATA "conftest.llminmax"
Darren Tuckerd1450db2006-03-13 19:06:51 +11003149#define my_abs(a) ((a) < 0 ? ((a) * -1) : (a))
3150
3151/*
3152 * printf in libc on some platforms (eg old Tru64) does not understand %lld so
3153 * we do this the hard way.
3154 */
3155static int
3156fprint_ll(FILE *f, long long n)
3157{
3158 unsigned int i;
3159 int l[sizeof(long long) * 8];
3160
3161 if (n < 0)
3162 if (fprintf(f, "-") < 0)
3163 return -1;
3164 for (i = 0; n != 0; i++) {
3165 l[i] = my_abs(n % 10);
3166 n /= 10;
3167 }
3168 do {
3169 if (fprintf(f, "%d", l[--i]) < 0)
3170 return -1;
3171 } while (i != 0);
3172 if (fprintf(f, " ") < 0)
3173 return -1;
3174 return 0;
3175}
Tim Rice648f8762011-01-26 12:38:57 -08003176 ]], [[
Darren Tucker537f1ed2005-10-25 18:38:33 +10003177 FILE *f;
3178 long long i, llmin, llmax = 0;
3179
3180 if((f = fopen(DATA,"w")) == NULL)
3181 exit(1);
3182
3183#if defined(LLONG_MIN) && defined(LLONG_MAX)
3184 fprintf(stderr, "Using system header for LLONG_MIN and LLONG_MAX\n");
3185 llmin = LLONG_MIN;
3186 llmax = LLONG_MAX;
3187#else
3188 fprintf(stderr, "Calculating LLONG_MIN and LLONG_MAX\n");
3189 /* This will work on one's complement and two's complement */
3190 for (i = 1; i > llmax; i <<= 1, i++)
3191 llmax = i;
3192 llmin = llmax + 1LL; /* wrap */
3193#endif
3194
3195 /* Sanity check */
3196 if (llmin + 1 < llmin || llmin - 1 < llmin || llmax + 1 > llmax
Darren Tuckerd1450db2006-03-13 19:06:51 +11003197 || llmax - 1 > llmax || llmin == llmax || llmin == 0
3198 || llmax == 0 || llmax < LONG_MAX || llmin > LONG_MIN) {
Darren Tucker537f1ed2005-10-25 18:38:33 +10003199 fprintf(f, "unknown unknown\n");
3200 exit(2);
3201 }
3202
Darren Tuckerd1450db2006-03-13 19:06:51 +11003203 if (fprint_ll(f, llmin) < 0)
Darren Tucker537f1ed2005-10-25 18:38:33 +10003204 exit(3);
Darren Tuckerd1450db2006-03-13 19:06:51 +11003205 if (fprint_ll(f, llmax) < 0)
3206 exit(4);
3207 if (fclose(f) < 0)
3208 exit(5);
Darren Tucker537f1ed2005-10-25 18:38:33 +10003209 exit(0);
Darren Tucker537f1ed2005-10-25 18:38:33 +10003210 ]])],
3211 [
3212 llong_min=`$AWK '{print $1}' conftest.llminmax`
3213 llong_max=`$AWK '{print $2}' conftest.llminmax`
3214
Tim Rice648f8762011-01-26 12:38:57 -08003215 AC_MSG_RESULT([$llong_max])
3216 AC_DEFINE_UNQUOTED([LLONG_MAX], [${llong_max}LL],
Darren Tucker537f1ed2005-10-25 18:38:33 +10003217 [max value of long long calculated by configure])
3218 AC_MSG_CHECKING([for min value of long long])
Tim Rice648f8762011-01-26 12:38:57 -08003219 AC_MSG_RESULT([$llong_min])
3220 AC_DEFINE_UNQUOTED([LLONG_MIN], [${llong_min}LL],
Darren Tucker537f1ed2005-10-25 18:38:33 +10003221 [min value of long long calculated by configure])
3222 ],
3223 [
Tim Rice648f8762011-01-26 12:38:57 -08003224 AC_MSG_RESULT([not found])
Darren Tucker537f1ed2005-10-25 18:38:33 +10003225 ],
3226 [
3227 AC_MSG_WARN([cross compiling: not checking])
3228 ]
3229 )
3230fi
3231
3232
Damien Millera22ba012000-03-02 23:09:20 +11003233# More checks for data types
Damien Millercaf6dd62000-08-29 11:33:50 +11003234AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [
Tim Rice648f8762011-01-26 12:38:57 -08003235 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3236 [[ u_int a; a = 1;]])],
3237 [ ac_cv_have_u_int="yes" ], [ ac_cv_have_u_int="no"
3238 ])
Damien Millercaf6dd62000-08-29 11:33:50 +11003239])
3240if test "x$ac_cv_have_u_int" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003241 AC_DEFINE([HAVE_U_INT], [1], [define if you have u_int data type])
Damien Millercaf6dd62000-08-29 11:33:50 +11003242 have_u_int=1
3243fi
3244
Damien Miller61e50f12000-05-08 20:49:37 +10003245AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003246 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3247 [[ int8_t a; int16_t b; int32_t c; a = b = c = 1;]])],
3248 [ ac_cv_have_intxx_t="yes" ], [ ac_cv_have_intxx_t="no"
3249 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003250])
3251if test "x$ac_cv_have_intxx_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003252 AC_DEFINE([HAVE_INTXX_T], [1], [define if you have intxx_t data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003253 have_intxx_t=1
3254fi
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003255
3256if (test -z "$have_intxx_t" && \
Damien Millera8e06ce2003-11-21 23:48:55 +11003257 test "x$ac_cv_header_stdint_h" = "xyes")
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003258then
3259 AC_MSG_CHECKING([for intXX_t types in stdint.h])
Tim Rice648f8762011-01-26 12:38:57 -08003260 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdint.h> ]],
3261 [[ int8_t a; int16_t b; int32_t c; a = b = c = 1;]])],
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003262 [
Tim Rice648f8762011-01-26 12:38:57 -08003263 AC_DEFINE([HAVE_INTXX_T])
3264 AC_MSG_RESULT([yes])
3265 ], [ AC_MSG_RESULT([no])
3266 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003267fi
3268
Damien Miller578783e2000-09-23 14:12:24 +11003269AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003270 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Tim Rice907881e2002-07-18 11:44:50 -07003271#include <sys/types.h>
3272#ifdef HAVE_STDINT_H
3273# include <stdint.h>
3274#endif
3275#include <sys/socket.h>
3276#ifdef HAVE_SYS_BITYPES_H
3277# include <sys/bitypes.h>
3278#endif
Tim Rice648f8762011-01-26 12:38:57 -08003279 ]], [[
3280int64_t a; a = 1;
3281 ]])],
3282 [ ac_cv_have_int64_t="yes" ], [ ac_cv_have_int64_t="no"
3283 ])
Damien Miller578783e2000-09-23 14:12:24 +11003284])
3285if test "x$ac_cv_have_int64_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003286 AC_DEFINE([HAVE_INT64_T], [1], [define if you have int64_t data type])
Tim Rice4cec93f2002-02-26 08:40:48 -08003287fi
3288
Damien Miller61e50f12000-05-08 20:49:37 +10003289AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003290 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3291 [[ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;]])],
3292 [ ac_cv_have_u_intxx_t="yes" ], [ ac_cv_have_u_intxx_t="no"
3293 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003294])
3295if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003296 AC_DEFINE([HAVE_U_INTXX_T], [1], [define if you have u_intxx_t data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003297 have_u_intxx_t=1
3298fi
Damien Millerc6398ef1999-11-20 12:18:40 +11003299
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003300if test -z "$have_u_intxx_t" ; then
3301 AC_MSG_CHECKING([for u_intXX_t types in sys/socket.h])
Tim Rice648f8762011-01-26 12:38:57 -08003302 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/socket.h> ]],
3303 [[ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;]])],
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003304 [
Tim Rice648f8762011-01-26 12:38:57 -08003305 AC_DEFINE([HAVE_U_INTXX_T])
3306 AC_MSG_RESULT([yes])
3307 ], [ AC_MSG_RESULT([no])
3308 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003309fi
3310
Damien Miller578783e2000-09-23 14:12:24 +11003311AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003312 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3313 [[ u_int64_t a; a = 1;]])],
3314 [ ac_cv_have_u_int64_t="yes" ], [ ac_cv_have_u_int64_t="no"
3315 ])
Damien Miller578783e2000-09-23 14:12:24 +11003316])
3317if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003318 AC_DEFINE([HAVE_U_INT64_T], [1], [define if you have u_int64_t data type])
Damien Miller578783e2000-09-23 14:12:24 +11003319 have_u_int64_t=1
3320fi
3321
Damien Millerc2868192014-01-30 10:21:19 +11003322if (test -z "$have_u_int64_t" && \
3323 test "x$ac_cv_header_sys_bitypes_h" = "xyes")
3324then
Tim Rice4cec93f2002-02-26 08:40:48 -08003325 AC_MSG_CHECKING([for u_int64_t type in sys/bitypes.h])
Tim Rice648f8762011-01-26 12:38:57 -08003326 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/bitypes.h> ]],
3327 [[ u_int64_t a; a = 1]])],
Tim Rice4cec93f2002-02-26 08:40:48 -08003328 [
Tim Rice648f8762011-01-26 12:38:57 -08003329 AC_DEFINE([HAVE_U_INT64_T])
3330 AC_MSG_RESULT([yes])
3331 ], [ AC_MSG_RESULT([no])
3332 ])
Tim Rice4cec93f2002-02-26 08:40:48 -08003333fi
3334
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003335if test -z "$have_u_intxx_t" ; then
3336 AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003337 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003338#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08003339 ]], [[
3340 uint8_t a;
3341 uint16_t b;
3342 uint32_t c;
3343 a = b = c = 1;
3344 ]])],
3345 [ ac_cv_have_uintxx_t="yes" ], [ ac_cv_have_uintxx_t="no"
3346 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003347 ])
3348 if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003349 AC_DEFINE([HAVE_UINTXX_T], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003350 [define if you have uintxx_t data type])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003351 fi
3352fi
3353
Damien Millerc2868192014-01-30 10:21:19 +11003354if (test -z "$have_uintxx_t" && \
3355 test "x$ac_cv_header_stdint_h" = "xyes")
3356then
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003357 AC_MSG_CHECKING([for uintXX_t types in stdint.h])
Tim Rice648f8762011-01-26 12:38:57 -08003358 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdint.h> ]],
3359 [[ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;]])],
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003360 [
Tim Rice648f8762011-01-26 12:38:57 -08003361 AC_DEFINE([HAVE_UINTXX_T])
3362 AC_MSG_RESULT([yes])
3363 ], [ AC_MSG_RESULT([no])
3364 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003365fi
3366
Damien Millerc2868192014-01-30 10:21:19 +11003367if (test -z "$have_uintxx_t" && \
3368 test "x$ac_cv_header_inttypes_h" = "xyes")
3369then
Darren Tucker6d725682014-01-17 19:17:34 +11003370 AC_MSG_CHECKING([for uintXX_t types in inttypes.h])
3371 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <inttypes.h> ]],
3372 [[ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;]])],
3373 [
3374 AC_DEFINE([HAVE_UINTXX_T])
3375 AC_MSG_RESULT([yes])
3376 ], [ AC_MSG_RESULT([no])
3377 ])
3378fi
3379
Damien Milleredb82922000-06-20 13:25:52 +10003380if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
Damien Millera8e06ce2003-11-21 23:48:55 +11003381 test "x$ac_cv_header_sys_bitypes_h" = "xyes")
Damien Millerb29ea912000-01-15 14:12:03 +11003382then
3383 AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
Tim Rice648f8762011-01-26 12:38:57 -08003384 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller61e50f12000-05-08 20:49:37 +10003385#include <sys/bitypes.h>
Tim Rice648f8762011-01-26 12:38:57 -08003386 ]], [[
Damien Miller70494d12000-04-03 15:57:06 +10003387 int8_t a; int16_t b; int32_t c;
3388 u_int8_t e; u_int16_t f; u_int32_t g;
3389 a = b = c = e = f = g = 1;
Tim Rice648f8762011-01-26 12:38:57 -08003390 ]])],
Damien Millerb29ea912000-01-15 14:12:03 +11003391 [
Tim Rice648f8762011-01-26 12:38:57 -08003392 AC_DEFINE([HAVE_U_INTXX_T])
3393 AC_DEFINE([HAVE_INTXX_T])
3394 AC_MSG_RESULT([yes])
3395 ], [AC_MSG_RESULT([no])
3396 ])
Damien Millerb29ea912000-01-15 14:12:03 +11003397fi
3398
Damien Miller58be7382001-09-15 21:31:54 +10003399
3400AC_CACHE_CHECK([for u_char], ac_cv_have_u_char, [
Tim Rice648f8762011-01-26 12:38:57 -08003401 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3402 [[ u_char foo; foo = 125; ]])],
3403 [ ac_cv_have_u_char="yes" ], [ ac_cv_have_u_char="no"
3404 ])
Damien Miller58be7382001-09-15 21:31:54 +10003405])
3406if test "x$ac_cv_have_u_char" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003407 AC_DEFINE([HAVE_U_CHAR], [1], [define if you have u_char data type])
Damien Miller58be7382001-09-15 21:31:54 +10003408fi
3409
Darren Tucker007e3b32013-11-03 18:43:55 +11003410AC_CHECK_TYPES([intmax_t, uintmax_t], , , [
3411#include <sys/types.h>
3412#include <stdint.h>
3413])
3414
Tim Rice13aae5e2001-10-21 17:53:58 -07003415TYPE_SOCKLEN_T
Damien Miller74d0d4a1999-12-29 02:24:35 +11003416
Tim Rice648f8762011-01-26 12:38:57 -08003417AC_CHECK_TYPES([sig_atomic_t], , , [#include <signal.h>])
3418AC_CHECK_TYPES([fsblkcnt_t, fsfilcnt_t], , , [
Darren Tucker598eaa62008-06-09 03:32:29 +10003419#include <sys/types.h>
3420#ifdef HAVE_SYS_BITYPES_H
3421#include <sys/bitypes.h>
3422#endif
3423#ifdef HAVE_SYS_STATFS_H
3424#include <sys/statfs.h>
3425#endif
3426#ifdef HAVE_SYS_STATVFS_H
3427#include <sys/statvfs.h>
3428#endif
3429])
Tim Rice4cec93f2002-02-26 08:40:48 -08003430
Tim Rice648f8762011-01-26 12:38:57 -08003431AC_CHECK_TYPES([in_addr_t, in_port_t], , ,
Damien Miller848b9932005-02-24 12:12:34 +11003432[#include <sys/types.h>
3433#include <netinet/in.h>])
Darren Tuckerd9f88912005-02-20 21:01:48 +11003434
Damien Miller61e50f12000-05-08 20:49:37 +10003435AC_CACHE_CHECK([for size_t], ac_cv_have_size_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003436 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3437 [[ size_t foo; foo = 1235; ]])],
3438 [ ac_cv_have_size_t="yes" ], [ ac_cv_have_size_t="no"
3439 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003440])
3441if test "x$ac_cv_have_size_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003442 AC_DEFINE([HAVE_SIZE_T], [1], [define if you have size_t data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003443fi
Damien Miller95058511999-12-29 10:36:45 +11003444
Damien Miller615f9392000-05-17 22:53:33 +10003445AC_CACHE_CHECK([for ssize_t], ac_cv_have_ssize_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003446 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3447 [[ ssize_t foo; foo = 1235; ]])],
3448 [ ac_cv_have_ssize_t="yes" ], [ ac_cv_have_ssize_t="no"
3449 ])
Damien Miller615f9392000-05-17 22:53:33 +10003450])
3451if test "x$ac_cv_have_ssize_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003452 AC_DEFINE([HAVE_SSIZE_T], [1], [define if you have ssize_t data type])
Damien Miller615f9392000-05-17 22:53:33 +10003453fi
3454
Ben Lindstrom0d5af602001-01-09 00:50:29 +00003455AC_CACHE_CHECK([for clock_t], ac_cv_have_clock_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003456 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <time.h> ]],
3457 [[ clock_t foo; foo = 1235; ]])],
3458 [ ac_cv_have_clock_t="yes" ], [ ac_cv_have_clock_t="no"
3459 ])
Ben Lindstrom0d5af602001-01-09 00:50:29 +00003460])
3461if test "x$ac_cv_have_clock_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003462 AC_DEFINE([HAVE_CLOCK_T], [1], [define if you have clock_t data type])
Ben Lindstrom0d5af602001-01-09 00:50:29 +00003463fi
3464
Damien Millerb54b40e2000-06-23 08:23:34 +10003465AC_CACHE_CHECK([for sa_family_t], ac_cv_have_sa_family_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003466 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Millerb54b40e2000-06-23 08:23:34 +10003467#include <sys/types.h>
3468#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08003469 ]], [[ sa_family_t foo; foo = 1235; ]])],
3470 [ ac_cv_have_sa_family_t="yes" ],
3471 [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller78315eb2000-09-29 23:01:36 +11003472#include <sys/types.h>
3473#include <sys/socket.h>
3474#include <netinet/in.h>
Tim Rice648f8762011-01-26 12:38:57 -08003475 ]], [[ sa_family_t foo; foo = 1235; ]])],
Damien Miller78315eb2000-09-29 23:01:36 +11003476 [ ac_cv_have_sa_family_t="yes" ],
Damien Millerb54b40e2000-06-23 08:23:34 +10003477 [ ac_cv_have_sa_family_t="no" ]
3478 )
Tim Rice648f8762011-01-26 12:38:57 -08003479 ])
Damien Millerb54b40e2000-06-23 08:23:34 +10003480])
3481if test "x$ac_cv_have_sa_family_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003482 AC_DEFINE([HAVE_SA_FAMILY_T], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003483 [define if you have sa_family_t data type])
Damien Millerb54b40e2000-06-23 08:23:34 +10003484fi
3485
Damien Miller0f91b4e2000-06-18 15:43:25 +10003486AC_CACHE_CHECK([for pid_t], ac_cv_have_pid_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003487 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3488 [[ pid_t foo; foo = 1235; ]])],
3489 [ ac_cv_have_pid_t="yes" ], [ ac_cv_have_pid_t="no"
3490 ])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003491])
3492if test "x$ac_cv_have_pid_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003493 AC_DEFINE([HAVE_PID_T], [1], [define if you have pid_t data type])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003494fi
3495
3496AC_CACHE_CHECK([for mode_t], ac_cv_have_mode_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003497 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3498 [[ mode_t foo; foo = 1235; ]])],
3499 [ ac_cv_have_mode_t="yes" ], [ ac_cv_have_mode_t="no"
3500 ])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003501])
3502if test "x$ac_cv_have_mode_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003503 AC_DEFINE([HAVE_MODE_T], [1], [define if you have mode_t data type])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003504fi
3505
Damien Miller61e50f12000-05-08 20:49:37 +10003506
3507AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_have_struct_sockaddr_storage, [
Tim Rice648f8762011-01-26 12:38:57 -08003508 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10003509#include <sys/types.h>
3510#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08003511 ]], [[ struct sockaddr_storage s; ]])],
3512 [ ac_cv_have_struct_sockaddr_storage="yes" ],
3513 [ ac_cv_have_struct_sockaddr_storage="no"
3514 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003515])
3516if test "x$ac_cv_have_struct_sockaddr_storage" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003517 AC_DEFINE([HAVE_STRUCT_SOCKADDR_STORAGE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003518 [define if you have struct sockaddr_storage data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003519fi
Damien Miller34132e52000-01-14 15:45:46 +11003520
Damien Miller61e50f12000-05-08 20:49:37 +10003521AC_CACHE_CHECK([for struct sockaddr_in6], ac_cv_have_struct_sockaddr_in6, [
Tim Rice648f8762011-01-26 12:38:57 -08003522 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller7b22d652000-06-18 14:07:04 +10003523#include <sys/types.h>
Damien Miller61e50f12000-05-08 20:49:37 +10003524#include <netinet/in.h>
Tim Rice648f8762011-01-26 12:38:57 -08003525 ]], [[ struct sockaddr_in6 s; s.sin6_family = 0; ]])],
3526 [ ac_cv_have_struct_sockaddr_in6="yes" ],
3527 [ ac_cv_have_struct_sockaddr_in6="no"
3528 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003529])
3530if test "x$ac_cv_have_struct_sockaddr_in6" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003531 AC_DEFINE([HAVE_STRUCT_SOCKADDR_IN6], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003532 [define if you have struct sockaddr_in6 data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003533fi
Damien Miller34132e52000-01-14 15:45:46 +11003534
Damien Miller61e50f12000-05-08 20:49:37 +10003535AC_CACHE_CHECK([for struct in6_addr], ac_cv_have_struct_in6_addr, [
Tim Rice648f8762011-01-26 12:38:57 -08003536 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller7b22d652000-06-18 14:07:04 +10003537#include <sys/types.h>
Damien Miller61e50f12000-05-08 20:49:37 +10003538#include <netinet/in.h>
Tim Rice648f8762011-01-26 12:38:57 -08003539 ]], [[ struct in6_addr s; s.s6_addr[0] = 0; ]])],
3540 [ ac_cv_have_struct_in6_addr="yes" ],
3541 [ ac_cv_have_struct_in6_addr="no"
3542 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003543])
3544if test "x$ac_cv_have_struct_in6_addr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003545 AC_DEFINE([HAVE_STRUCT_IN6_ADDR], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003546 [define if you have struct in6_addr data type])
Tim Rice0f4d2c02008-11-18 21:26:41 -08003547
3548dnl Now check for sin6_scope_id
Tim Rice648f8762011-01-26 12:38:57 -08003549 AC_CHECK_MEMBERS([struct sockaddr_in6.sin6_scope_id], , ,
Tim Rice0f4d2c02008-11-18 21:26:41 -08003550 [
3551#ifdef HAVE_SYS_TYPES_H
3552#include <sys/types.h>
3553#endif
3554#include <netinet/in.h>
3555 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003556fi
Damien Miller34132e52000-01-14 15:45:46 +11003557
Damien Miller61e50f12000-05-08 20:49:37 +10003558AC_CACHE_CHECK([for struct addrinfo], ac_cv_have_struct_addrinfo, [
Tim Rice648f8762011-01-26 12:38:57 -08003559 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10003560#include <sys/types.h>
3561#include <sys/socket.h>
3562#include <netdb.h>
Tim Rice648f8762011-01-26 12:38:57 -08003563 ]], [[ struct addrinfo s; s.ai_flags = AI_PASSIVE; ]])],
3564 [ ac_cv_have_struct_addrinfo="yes" ],
3565 [ ac_cv_have_struct_addrinfo="no"
3566 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003567])
3568if test "x$ac_cv_have_struct_addrinfo" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003569 AC_DEFINE([HAVE_STRUCT_ADDRINFO], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003570 [define if you have struct addrinfo data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003571fi
3572
Ben Lindstrom42202bc2001-01-15 02:34:37 +00003573AC_CACHE_CHECK([for struct timeval], ac_cv_have_struct_timeval, [
Tim Rice648f8762011-01-26 12:38:57 -08003574 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/time.h> ]],
3575 [[ struct timeval tv; tv.tv_sec = 1;]])],
3576 [ ac_cv_have_struct_timeval="yes" ],
3577 [ ac_cv_have_struct_timeval="no"
3578 ])
Ben Lindstrom42202bc2001-01-15 02:34:37 +00003579])
3580if test "x$ac_cv_have_struct_timeval" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003581 AC_DEFINE([HAVE_STRUCT_TIMEVAL], [1], [define if you have struct timeval])
Ben Lindstrom42202bc2001-01-15 02:34:37 +00003582 have_struct_timeval=1
3583fi
3584
Tim Rice648f8762011-01-26 12:38:57 -08003585AC_CHECK_TYPES([struct timespec])
Tim Rice4e4dc562003-03-18 10:21:40 -08003586
Ben Lindstrom5bd6eb72003-03-21 00:34:34 +00003587# We need int64_t or else certian parts of the compile will fail.
Tim Rice8bb561b2005-03-17 16:23:19 -08003588if test "x$ac_cv_have_int64_t" = "xno" && \
3589 test "x$ac_cv_sizeof_long_int" != "x8" && \
3590 test "x$ac_cv_sizeof_long_long_int" = "x0" ; then
Ben Lindstrom5bd6eb72003-03-21 00:34:34 +00003591 echo "OpenSSH requires int64_t support. Contact your vendor or install"
3592 echo "an alternative compiler (I.E., GCC) before continuing."
3593 echo ""
3594 exit 1;
Tim Ricebee3f222001-03-11 17:32:12 -08003595else
3596dnl test snprintf (broken on SCO w/gcc)
Darren Tuckera0c2b392004-09-11 23:26:37 +10003597 AC_RUN_IFELSE(
Darren Tucker623d92f2004-09-12 22:36:15 +10003598 [AC_LANG_SOURCE([[
Tim Ricebee3f222001-03-11 17:32:12 -08003599#include <stdio.h>
3600#include <string.h>
3601#ifdef HAVE_SNPRINTF
3602main()
3603{
3604 char buf[50];
3605 char expected_out[50];
3606 int mazsize = 50 ;
3607#if (SIZEOF_LONG_INT == 8)
3608 long int num = 0x7fffffffffffffff;
3609#else
Kevin Steves6482ec82001-07-15 02:09:28 +00003610 long long num = 0x7fffffffffffffffll;
Tim Ricebee3f222001-03-11 17:32:12 -08003611#endif
3612 strcpy(expected_out, "9223372036854775807");
3613 snprintf(buf, mazsize, "%lld", num);
3614 if(strcmp(buf, expected_out) != 0)
Damien Millera8e06ce2003-11-21 23:48:55 +11003615 exit(1);
Tim Ricebee3f222001-03-11 17:32:12 -08003616 exit(0);
3617}
3618#else
3619main() { exit(0); }
3620#endif
Tim Rice648f8762011-01-26 12:38:57 -08003621 ]])], [ true ], [ AC_DEFINE([BROKEN_SNPRINTF]) ],
Darren Tuckera0c2b392004-09-11 23:26:37 +10003622 AC_MSG_WARN([cross compiling: Assuming working snprintf()])
Tim Ricebee3f222001-03-11 17:32:12 -08003623 )
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00003624fi
3625
Damien Miller78315eb2000-09-29 23:01:36 +11003626dnl Checks for structure members
Tim Rice648f8762011-01-26 12:38:57 -08003627OSSH_CHECK_HEADER_FOR_FIELD([ut_host], [utmp.h], [HAVE_HOST_IN_UTMP])
3628OSSH_CHECK_HEADER_FOR_FIELD([ut_host], [utmpx.h], [HAVE_HOST_IN_UTMPX])
3629OSSH_CHECK_HEADER_FOR_FIELD([syslen], [utmpx.h], [HAVE_SYSLEN_IN_UTMPX])
3630OSSH_CHECK_HEADER_FOR_FIELD([ut_pid], [utmp.h], [HAVE_PID_IN_UTMP])
3631OSSH_CHECK_HEADER_FOR_FIELD([ut_type], [utmp.h], [HAVE_TYPE_IN_UTMP])
3632OSSH_CHECK_HEADER_FOR_FIELD([ut_type], [utmpx.h], [HAVE_TYPE_IN_UTMPX])
3633OSSH_CHECK_HEADER_FOR_FIELD([ut_tv], [utmp.h], [HAVE_TV_IN_UTMP])
3634OSSH_CHECK_HEADER_FOR_FIELD([ut_id], [utmp.h], [HAVE_ID_IN_UTMP])
3635OSSH_CHECK_HEADER_FOR_FIELD([ut_id], [utmpx.h], [HAVE_ID_IN_UTMPX])
3636OSSH_CHECK_HEADER_FOR_FIELD([ut_addr], [utmp.h], [HAVE_ADDR_IN_UTMP])
3637OSSH_CHECK_HEADER_FOR_FIELD([ut_addr], [utmpx.h], [HAVE_ADDR_IN_UTMPX])
3638OSSH_CHECK_HEADER_FOR_FIELD([ut_addr_v6], [utmp.h], [HAVE_ADDR_V6_IN_UTMP])
3639OSSH_CHECK_HEADER_FOR_FIELD([ut_addr_v6], [utmpx.h], [HAVE_ADDR_V6_IN_UTMPX])
3640OSSH_CHECK_HEADER_FOR_FIELD([ut_exit], [utmp.h], [HAVE_EXIT_IN_UTMP])
3641OSSH_CHECK_HEADER_FOR_FIELD([ut_time], [utmp.h], [HAVE_TIME_IN_UTMP])
3642OSSH_CHECK_HEADER_FOR_FIELD([ut_time], [utmpx.h], [HAVE_TIME_IN_UTMPX])
3643OSSH_CHECK_HEADER_FOR_FIELD([ut_tv], [utmpx.h], [HAVE_TV_IN_UTMPX])
Tim Rice13aae5e2001-10-21 17:53:58 -07003644
3645AC_CHECK_MEMBERS([struct stat.st_blksize])
Damien Miller6332da22013-04-23 14:25:52 +10003646AC_CHECK_MEMBERS([struct passwd.pw_gecos, struct passwd.pw_class,
3647struct passwd.pw_change, struct passwd.pw_expire],
3648[], [], [[
3649#include <sys/types.h>
3650#include <pwd.h>
3651]])
3652
Tim Rice648f8762011-01-26 12:38:57 -08003653AC_CHECK_MEMBER([struct __res_state.retrans], [], [AC_DEFINE([__res_state], [state],
Darren Tucker58e298d2005-11-25 13:14:58 +11003654 [Define if we don't have struct __res_state in resolv.h])],
Damien Miller6332da22013-04-23 14:25:52 +10003655[[
Darren Tucker58e298d2005-11-25 13:14:58 +11003656#include <stdio.h>
3657#if HAVE_SYS_TYPES_H
3658# include <sys/types.h>
3659#endif
3660#include <netinet/in.h>
3661#include <arpa/nameser.h>
3662#include <resolv.h>
Damien Miller6332da22013-04-23 14:25:52 +10003663]])
andre2ff7b5d2000-06-03 14:57:40 +00003664
Damien Miller61e50f12000-05-08 20:49:37 +10003665AC_CACHE_CHECK([for ss_family field in struct sockaddr_storage],
3666 ac_cv_have_ss_family_in_struct_ss, [
Tim Rice648f8762011-01-26 12:38:57 -08003667 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10003668#include <sys/types.h>
3669#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08003670 ]], [[ struct sockaddr_storage s; s.ss_family = 1; ]])],
3671 [ ac_cv_have_ss_family_in_struct_ss="yes" ],
3672 [ ac_cv_have_ss_family_in_struct_ss="no" ])
Damien Miller61e50f12000-05-08 20:49:37 +10003673])
3674if test "x$ac_cv_have_ss_family_in_struct_ss" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003675 AC_DEFINE([HAVE_SS_FAMILY_IN_SS], [1], [Fields in struct sockaddr_storage])
Damien Miller61e50f12000-05-08 20:49:37 +10003676fi
3677
Damien Miller61e50f12000-05-08 20:49:37 +10003678AC_CACHE_CHECK([for __ss_family field in struct sockaddr_storage],
3679 ac_cv_have___ss_family_in_struct_ss, [
Tim Rice648f8762011-01-26 12:38:57 -08003680 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10003681#include <sys/types.h>
3682#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08003683 ]], [[ struct sockaddr_storage s; s.__ss_family = 1; ]])],
3684 [ ac_cv_have___ss_family_in_struct_ss="yes" ],
3685 [ ac_cv_have___ss_family_in_struct_ss="no"
3686 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003687])
3688if test "x$ac_cv_have___ss_family_in_struct_ss" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003689 AC_DEFINE([HAVE___SS_FAMILY_IN_SS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003690 [Fields in struct sockaddr_storage])
Damien Miller61e50f12000-05-08 20:49:37 +10003691fi
Damien Millerbf1c9b21999-12-09 10:16:54 +11003692
Tim Rice28bbb0c2002-05-27 17:37:32 -07003693dnl make sure we're using the real structure members and not defines
Kevin Steves939c9db2002-03-22 17:23:25 +00003694AC_CACHE_CHECK([for msg_accrights field in struct msghdr],
3695 ac_cv_have_accrights_in_msghdr, [
Tim Rice648f8762011-01-26 12:38:57 -08003696 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Tim Riceae49fe62002-04-12 10:26:21 -07003697#include <sys/types.h>
Kevin Steves939c9db2002-03-22 17:23:25 +00003698#include <sys/socket.h>
3699#include <sys/uio.h>
Tim Rice648f8762011-01-26 12:38:57 -08003700 ]], [[
Tim Rice28bbb0c2002-05-27 17:37:32 -07003701#ifdef msg_accrights
Darren Tuckera0c2b392004-09-11 23:26:37 +10003702#error "msg_accrights is a macro"
Tim Rice28bbb0c2002-05-27 17:37:32 -07003703exit(1);
3704#endif
3705struct msghdr m;
3706m.msg_accrights = 0;
3707exit(0);
Tim Rice648f8762011-01-26 12:38:57 -08003708 ]])],
Kevin Steves939c9db2002-03-22 17:23:25 +00003709 [ ac_cv_have_accrights_in_msghdr="yes" ],
3710 [ ac_cv_have_accrights_in_msghdr="no" ]
3711 )
3712])
3713if test "x$ac_cv_have_accrights_in_msghdr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003714 AC_DEFINE([HAVE_ACCRIGHTS_IN_MSGHDR], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003715 [Define if your system uses access rights style
3716 file descriptor passing])
Kevin Steves939c9db2002-03-22 17:23:25 +00003717fi
3718
Tim Rice648f8762011-01-26 12:38:57 -08003719AC_MSG_CHECKING([if struct statvfs.f_fsid is integral type])
3720AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckere1a3ddf2012-05-04 11:05:45 +10003721#include <sys/param.h>
Darren Tucker32780622009-06-16 16:11:02 +10003722#include <sys/stat.h>
3723#ifdef HAVE_SYS_TIME_H
3724# include <sys/time.h>
3725#endif
3726#ifdef HAVE_SYS_MOUNT_H
3727#include <sys/mount.h>
3728#endif
3729#ifdef HAVE_SYS_STATVFS_H
3730#include <sys/statvfs.h>
3731#endif
Tim Rice648f8762011-01-26 12:38:57 -08003732 ]], [[ struct statvfs s; s.f_fsid = 0; ]])],
3733 [ AC_MSG_RESULT([yes]) ],
3734 [ AC_MSG_RESULT([no])
Darren Tucker32780622009-06-16 16:11:02 +10003735
Tim Rice648f8762011-01-26 12:38:57 -08003736 AC_MSG_CHECKING([if fsid_t has member val])
3737 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker32780622009-06-16 16:11:02 +10003738#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08003739#include <sys/statvfs.h>
3740 ]], [[ fsid_t t; t.val[0] = 0; ]])],
3741 [ AC_MSG_RESULT([yes])
3742 AC_DEFINE([FSID_HAS_VAL], [1], [fsid_t has member val]) ],
3743 [ AC_MSG_RESULT([no]) ])
Darren Tucker32780622009-06-16 16:11:02 +10003744
Tim Rice648f8762011-01-26 12:38:57 -08003745 AC_MSG_CHECKING([if f_fsid has member __val])
3746 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker32780622009-06-16 16:11:02 +10003747#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08003748#include <sys/statvfs.h>
3749 ]], [[ fsid_t t; t.__val[0] = 0; ]])],
3750 [ AC_MSG_RESULT([yes])
3751 AC_DEFINE([FSID_HAS___VAL], [1], [fsid_t has member __val]) ],
3752 [ AC_MSG_RESULT([no]) ])
Darren Tucker32780622009-06-16 16:11:02 +10003753])
Darren Tucker77001382008-06-09 06:17:53 +10003754
Kevin Stevesa44e0352002-04-07 16:18:03 +00003755AC_CACHE_CHECK([for msg_control field in struct msghdr],
3756 ac_cv_have_control_in_msghdr, [
Tim Rice648f8762011-01-26 12:38:57 -08003757 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Tim Riceae49fe62002-04-12 10:26:21 -07003758#include <sys/types.h>
Kevin Stevesa44e0352002-04-07 16:18:03 +00003759#include <sys/socket.h>
3760#include <sys/uio.h>
Tim Rice648f8762011-01-26 12:38:57 -08003761 ]], [[
Tim Rice28bbb0c2002-05-27 17:37:32 -07003762#ifdef msg_control
Darren Tuckera0c2b392004-09-11 23:26:37 +10003763#error "msg_control is a macro"
Tim Rice28bbb0c2002-05-27 17:37:32 -07003764exit(1);
3765#endif
3766struct msghdr m;
3767m.msg_control = 0;
3768exit(0);
Tim Rice648f8762011-01-26 12:38:57 -08003769 ]])],
Kevin Stevesa44e0352002-04-07 16:18:03 +00003770 [ ac_cv_have_control_in_msghdr="yes" ],
3771 [ ac_cv_have_control_in_msghdr="no" ]
3772 )
3773])
3774if test "x$ac_cv_have_control_in_msghdr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003775 AC_DEFINE([HAVE_CONTROL_IN_MSGHDR], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003776 [Define if your system uses ancillary data style
3777 file descriptor passing])
Kevin Stevesa44e0352002-04-07 16:18:03 +00003778fi
3779
Damien Miller61e50f12000-05-08 20:49:37 +10003780AC_CACHE_CHECK([if libc defines __progname], ac_cv_libc_defines___progname, [
Tim Rice648f8762011-01-26 12:38:57 -08003781 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
3782 [[ extern char *__progname; printf("%s", __progname); ]])],
3783 [ ac_cv_libc_defines___progname="yes" ],
3784 [ ac_cv_libc_defines___progname="no"
3785 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003786])
3787if test "x$ac_cv_libc_defines___progname" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003788 AC_DEFINE([HAVE___PROGNAME], [1], [Define if libc defines __progname])
Damien Miller61e50f12000-05-08 20:49:37 +10003789fi
3790
Kevin Steves4846f4a2002-03-22 18:19:53 +00003791AC_CACHE_CHECK([whether $CC implements __FUNCTION__], ac_cv_cc_implements___FUNCTION__, [
Tim Rice648f8762011-01-26 12:38:57 -08003792 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]],
3793 [[ printf("%s", __FUNCTION__); ]])],
3794 [ ac_cv_cc_implements___FUNCTION__="yes" ],
3795 [ ac_cv_cc_implements___FUNCTION__="no"
3796 ])
Kevin Steves4846f4a2002-03-22 18:19:53 +00003797])
3798if test "x$ac_cv_cc_implements___FUNCTION__" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003799 AC_DEFINE([HAVE___FUNCTION__], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003800 [Define if compiler implements __FUNCTION__])
Kevin Steves4846f4a2002-03-22 18:19:53 +00003801fi
3802
3803AC_CACHE_CHECK([whether $CC implements __func__], ac_cv_cc_implements___func__, [
Tim Rice648f8762011-01-26 12:38:57 -08003804 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]],
3805 [[ printf("%s", __func__); ]])],
3806 [ ac_cv_cc_implements___func__="yes" ],
3807 [ ac_cv_cc_implements___func__="no"
3808 ])
Kevin Steves4846f4a2002-03-22 18:19:53 +00003809])
3810if test "x$ac_cv_cc_implements___func__" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003811 AC_DEFINE([HAVE___func__], [1], [Define if compiler implements __func__])
Kevin Steves4846f4a2002-03-22 18:19:53 +00003812fi
3813
Damien Miller57f39152005-11-24 19:58:19 +11003814AC_CACHE_CHECK([whether va_copy exists], ac_cv_have_va_copy, [
Tim Rice648f8762011-01-26 12:38:57 -08003815 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
3816#include <stdarg.h>
3817va_list x,y;
3818 ]], [[ va_copy(x,y); ]])],
3819 [ ac_cv_have_va_copy="yes" ],
3820 [ ac_cv_have_va_copy="no"
3821 ])
Damien Miller57f39152005-11-24 19:58:19 +11003822])
3823if test "x$ac_cv_have_va_copy" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003824 AC_DEFINE([HAVE_VA_COPY], [1], [Define if va_copy exists])
Damien Miller57f39152005-11-24 19:58:19 +11003825fi
3826
3827AC_CACHE_CHECK([whether __va_copy exists], ac_cv_have___va_copy, [
Tim Rice648f8762011-01-26 12:38:57 -08003828 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
3829#include <stdarg.h>
3830va_list x,y;
3831 ]], [[ __va_copy(x,y); ]])],
3832 [ ac_cv_have___va_copy="yes" ], [ ac_cv_have___va_copy="no"
3833 ])
Damien Miller57f39152005-11-24 19:58:19 +11003834])
3835if test "x$ac_cv_have___va_copy" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003836 AC_DEFINE([HAVE___VA_COPY], [1], [Define if __va_copy exists])
Damien Miller57f39152005-11-24 19:58:19 +11003837fi
3838
Damien Miller4f8e6692001-07-14 13:22:53 +10003839AC_CACHE_CHECK([whether getopt has optreset support],
3840 ac_cv_have_getopt_optreset, [
Tim Rice648f8762011-01-26 12:38:57 -08003841 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <getopt.h> ]],
3842 [[ extern int optreset; optreset = 0; ]])],
3843 [ ac_cv_have_getopt_optreset="yes" ],
3844 [ ac_cv_have_getopt_optreset="no"
3845 ])
Damien Miller4f8e6692001-07-14 13:22:53 +10003846])
3847if test "x$ac_cv_have_getopt_optreset" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003848 AC_DEFINE([HAVE_GETOPT_OPTRESET], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003849 [Define if your getopt(3) defines and uses optreset])
Damien Miller4f8e6692001-07-14 13:22:53 +10003850fi
Damien Millera22ba012000-03-02 23:09:20 +11003851
Damien Millerecbb26d2000-07-15 14:59:14 +10003852AC_CACHE_CHECK([if libc defines sys_errlist], ac_cv_libc_defines_sys_errlist, [
Tim Rice648f8762011-01-26 12:38:57 -08003853 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
3854[[ extern const char *const sys_errlist[]; printf("%s", sys_errlist[0]);]])],
3855 [ ac_cv_libc_defines_sys_errlist="yes" ],
3856 [ ac_cv_libc_defines_sys_errlist="no"
3857 ])
Damien Millerecbb26d2000-07-15 14:59:14 +10003858])
3859if test "x$ac_cv_libc_defines_sys_errlist" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003860 AC_DEFINE([HAVE_SYS_ERRLIST], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003861 [Define if your system defines sys_errlist[]])
Damien Millerecbb26d2000-07-15 14:59:14 +10003862fi
3863
3864
Damien Miller11fa2cc2000-08-16 10:35:58 +10003865AC_CACHE_CHECK([if libc defines sys_nerr], ac_cv_libc_defines_sys_nerr, [
Tim Rice648f8762011-01-26 12:38:57 -08003866 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
3867[[ extern int sys_nerr; printf("%i", sys_nerr);]])],
3868 [ ac_cv_libc_defines_sys_nerr="yes" ],
3869 [ ac_cv_libc_defines_sys_nerr="no"
3870 ])
Damien Miller11fa2cc2000-08-16 10:35:58 +10003871])
3872if test "x$ac_cv_libc_defines_sys_nerr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003873 AC_DEFINE([HAVE_SYS_NERR], [1], [Define if your system defines sys_nerr])
Damien Miller11fa2cc2000-08-16 10:35:58 +10003874fi
3875
Darren Tucker5f88d342003-10-15 16:57:57 +10003876# Check libraries needed by DNS fingerprint support
Tim Rice648f8762011-01-26 12:38:57 -08003877AC_SEARCH_LIBS([getrrsetbyname], [resolv],
3878 [AC_DEFINE([HAVE_GETRRSETBYNAME], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003879 [Define if getrrsetbyname() exists])],
Damien Miller7abe09b2003-05-15 10:53:49 +10003880 [
Darren Tucker5f88d342003-10-15 16:57:57 +10003881 # Needed by our getrrsetbyname()
Tim Rice648f8762011-01-26 12:38:57 -08003882 AC_SEARCH_LIBS([res_query], [resolv])
3883 AC_SEARCH_LIBS([dn_expand], [resolv])
3884 AC_MSG_CHECKING([if res_query will link])
3885 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckere02b49a2009-09-11 14:56:08 +10003886#include <sys/types.h>
3887#include <netinet/in.h>
3888#include <arpa/nameser.h>
3889#include <netdb.h>
3890#include <resolv.h>
Tim Rice648f8762011-01-26 12:38:57 -08003891 ]], [[
Darren Tuckere02b49a2009-09-11 14:56:08 +10003892 res_query (0, 0, 0, 0, 0);
Tim Rice648f8762011-01-26 12:38:57 -08003893 ]])],
3894 AC_MSG_RESULT([yes]),
3895 [AC_MSG_RESULT([no])
Darren Tucker8e968a52004-05-13 11:56:16 +10003896 saved_LIBS="$LIBS"
3897 LIBS="$LIBS -lresolv"
Tim Rice648f8762011-01-26 12:38:57 -08003898 AC_MSG_CHECKING([for res_query in -lresolv])
3899 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckere02b49a2009-09-11 14:56:08 +10003900#include <sys/types.h>
3901#include <netinet/in.h>
3902#include <arpa/nameser.h>
3903#include <netdb.h>
Darren Tucker8e968a52004-05-13 11:56:16 +10003904#include <resolv.h>
Tim Rice648f8762011-01-26 12:38:57 -08003905 ]], [[
Darren Tucker8e968a52004-05-13 11:56:16 +10003906 res_query (0, 0, 0, 0, 0);
Tim Rice648f8762011-01-26 12:38:57 -08003907 ]])],
3908 [AC_MSG_RESULT([yes])],
Darren Tucker8e968a52004-05-13 11:56:16 +10003909 [LIBS="$saved_LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08003910 AC_MSG_RESULT([no])])
Darren Tucker8e968a52004-05-13 11:56:16 +10003911 ])
Tim Rice648f8762011-01-26 12:38:57 -08003912 AC_CHECK_FUNCS([_getshort _getlong])
Darren Tuckerd886e1c2005-06-01 18:57:45 +10003913 AC_CHECK_DECLS([_getshort, _getlong], , ,
Tim Ricefcc7ff12005-06-02 20:28:29 -07003914 [#include <sys/types.h>
3915 #include <arpa/nameser.h>])
Tim Rice648f8762011-01-26 12:38:57 -08003916 AC_CHECK_MEMBER([HEADER.ad],
3917 [AC_DEFINE([HAVE_HEADER_AD], [1],
3918 [Define if HEADER.ad exists in arpa/nameser.h])], ,
Darren Tucker5f88d342003-10-15 16:57:57 +10003919 [#include <arpa/nameser.h>])
3920 ])
Damien Miller7abe09b2003-05-15 10:53:49 +10003921
Tim Rice648f8762011-01-26 12:38:57 -08003922AC_MSG_CHECKING([if struct __res_state _res is an extern])
3923AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckercc40d5e2007-04-29 13:58:06 +10003924#include <stdio.h>
3925#if HAVE_SYS_TYPES_H
3926# include <sys/types.h>
3927#endif
3928#include <netinet/in.h>
3929#include <arpa/nameser.h>
3930#include <resolv.h>
3931extern struct __res_state _res;
Tim Rice648f8762011-01-26 12:38:57 -08003932 ]], [[ ]])],
3933 [AC_MSG_RESULT([yes])
3934 AC_DEFINE([HAVE__RES_EXTERN], [1],
Darren Tuckercc40d5e2007-04-29 13:58:06 +10003935 [Define if you have struct __res_state _res as an extern])
3936 ],
Tim Rice648f8762011-01-26 12:38:57 -08003937 [ AC_MSG_RESULT([no]) ]
Darren Tuckercc40d5e2007-04-29 13:58:06 +10003938)
3939
Damien Miller73b42d22006-04-22 21:26:08 +10003940# Check whether user wants SELinux support
3941SELINUX_MSG="no"
3942LIBSELINUX=""
Tim Rice648f8762011-01-26 12:38:57 -08003943AC_ARG_WITH([selinux],
Damien Miller5b1c8b32008-03-27 12:33:07 +11003944 [ --with-selinux Enable SELinux support],
Damien Miller73b42d22006-04-22 21:26:08 +10003945 [ if test "x$withval" != "xno" ; then
Darren Tucker20e9f972007-03-25 18:26:01 +10003946 save_LIBS="$LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08003947 AC_DEFINE([WITH_SELINUX], [1],
3948 [Define if you want SELinux support.])
Damien Miller73b42d22006-04-22 21:26:08 +10003949 SELINUX_MSG="yes"
3950 AC_CHECK_HEADER([selinux/selinux.h], ,
Tim Rice648f8762011-01-26 12:38:57 -08003951 AC_MSG_ERROR([SELinux support requires selinux.h header]))
3952 AC_CHECK_LIB([selinux], [setexeccon],
Damien Miller1d2bfc42010-02-10 10:19:29 +11003953 [ LIBSELINUX="-lselinux"
3954 LIBS="$LIBS -lselinux"
3955 ],
Tim Rice648f8762011-01-26 12:38:57 -08003956 AC_MSG_ERROR([SELinux support requires libselinux library]))
Damien Miller71adf122011-01-25 12:16:15 +11003957 SSHLIBS="$SSHLIBS $LIBSELINUX"
Darren Tucker20e9f972007-03-25 18:26:01 +10003958 SSHDLIBS="$SSHDLIBS $LIBSELINUX"
Tim Rice648f8762011-01-26 12:38:57 -08003959 AC_CHECK_FUNCS([getseuserbyname get_default_context_with_level])
Darren Tuckeradc947d2006-10-07 09:07:20 +10003960 LIBS="$save_LIBS"
Damien Miller73b42d22006-04-22 21:26:08 +10003961 fi ]
3962)
Tim Rice648f8762011-01-26 12:38:57 -08003963AC_SUBST([SSHLIBS])
3964AC_SUBST([SSHDLIBS])
Damien Miller73b42d22006-04-22 21:26:08 +10003965
Damien Millerfd4c9ee2002-04-13 11:04:40 +10003966# Check whether user wants Kerberos 5 support
Damien Millera8e06ce2003-11-21 23:48:55 +11003967KRB5_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08003968AC_ARG_WITH([kerberos5],
Damien Millera8e06ce2003-11-21 23:48:55 +11003969 [ --with-kerberos5=PATH Enable Kerberos 5 support],
Darren Tucker1d3ca582004-01-22 12:05:34 +11003970 [ if test "x$withval" != "xno" ; then
3971 if test "x$withval" = "xyes" ; then
3972 KRB5ROOT="/usr/local"
3973 else
3974 KRB5ROOT=${withval}
3975 fi
3976
Tim Rice648f8762011-01-26 12:38:57 -08003977 AC_DEFINE([KRB5], [1], [Define if you want Kerberos 5 support])
Darren Tucker1d3ca582004-01-22 12:05:34 +11003978 KRB5_MSG="yes"
3979
Tim Rice648f8762011-01-26 12:38:57 -08003980 AC_PATH_PROG([KRB5CONF], [krb5-config],
Darren Tuckerdad48e72009-09-01 18:26:00 +10003981 [$KRB5ROOT/bin/krb5-config],
3982 [$KRB5ROOT/bin:$PATH])
3983 if test -x $KRB5CONF ; then
Darren Tucker964de182013-02-22 10:39:59 +11003984 K5CFLAGS="`$KRB5CONF --cflags`"
3985 K5LIBS="`$KRB5CONF --libs`"
3986 CPPFLAGS="$CPPFLAGS $K5CFLAGS"
Darren Tucker1d3ca582004-01-22 12:05:34 +11003987
Tim Rice648f8762011-01-26 12:38:57 -08003988 AC_MSG_CHECKING([for gssapi support])
Darren Tucker1d3ca582004-01-22 12:05:34 +11003989 if $KRB5CONF | grep gssapi >/dev/null ; then
Tim Rice648f8762011-01-26 12:38:57 -08003990 AC_MSG_RESULT([yes])
3991 AC_DEFINE([GSSAPI], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003992 [Define this if you want GSSAPI
3993 support in the version 2 protocol])
Darren Tucker964de182013-02-22 10:39:59 +11003994 GSSCFLAGS="`$KRB5CONF --cflags gssapi`"
3995 GSSLIBS="`$KRB5CONF --libs gssapi`"
3996 CPPFLAGS="$CPPFLAGS $GSSCFLAGS"
Damien Millera8e06ce2003-11-21 23:48:55 +11003997 else
Tim Rice648f8762011-01-26 12:38:57 -08003998 AC_MSG_RESULT([no])
Damien Millera8e06ce2003-11-21 23:48:55 +11003999 fi
Tim Rice648f8762011-01-26 12:38:57 -08004000 AC_MSG_CHECKING([whether we are using Heimdal])
4001 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <krb5.h>
4002 ]], [[ char *tmp = heimdal_version; ]])],
4003 [ AC_MSG_RESULT([yes])
4004 AC_DEFINE([HEIMDAL], [1],
4005 [Define this if you are using the Heimdal
4006 version of Kerberos V5]) ],
4007 [AC_MSG_RESULT([no])
4008 ])
Darren Tucker1d3ca582004-01-22 12:05:34 +11004009 else
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004010 CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include"
Damien Millera8e06ce2003-11-21 23:48:55 +11004011 LDFLAGS="$LDFLAGS -L${KRB5ROOT}/lib"
Tim Rice648f8762011-01-26 12:38:57 -08004012 AC_MSG_CHECKING([whether we are using Heimdal])
4013 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <krb5.h>
4014 ]], [[ char *tmp = heimdal_version; ]])],
4015 [ AC_MSG_RESULT([yes])
4016 AC_DEFINE([HEIMDAL])
Damien Miller41bccf72011-01-02 21:53:07 +11004017 K5LIBS="-lkrb5"
Damien Miller5561e0b2004-04-20 20:28:55 +10004018 K5LIBS="$K5LIBS -lcom_err -lasn1"
Tim Rice648f8762011-01-26 12:38:57 -08004019 AC_CHECK_LIB([roken], [net_write],
Damien Miller5561e0b2004-04-20 20:28:55 +10004020 [K5LIBS="$K5LIBS -lroken"])
Tim Rice648f8762011-01-26 12:38:57 -08004021 AC_CHECK_LIB([des], [des_cbc_encrypt],
Damien Miller41bccf72011-01-02 21:53:07 +11004022 [K5LIBS="$K5LIBS -ldes"])
Tim Rice648f8762011-01-26 12:38:57 -08004023 ], [ AC_MSG_RESULT([no])
Damien Millera8e06ce2003-11-21 23:48:55 +11004024 K5LIBS="-lkrb5 -lk5crypto -lcom_err"
Tim Rice648f8762011-01-26 12:38:57 -08004025
4026 ])
4027 AC_SEARCH_LIBS([dn_expand], [resolv])
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004028
Tim Rice648f8762011-01-26 12:38:57 -08004029 AC_CHECK_LIB([gssapi_krb5], [gss_init_sec_context],
4030 [ AC_DEFINE([GSSAPI])
Darren Tucker964de182013-02-22 10:39:59 +11004031 GSSLIBS="-lgssapi_krb5" ],
Tim Rice648f8762011-01-26 12:38:57 -08004032 [ AC_CHECK_LIB([gssapi], [gss_init_sec_context],
4033 [ AC_DEFINE([GSSAPI])
Darren Tucker964de182013-02-22 10:39:59 +11004034 GSSLIBS="-lgssapi" ],
Darren Tuckera2b5a4c2013-02-22 10:43:15 +11004035 [ AC_CHECK_LIB([gss], [gss_init_sec_context],
4036 [ AC_DEFINE([GSSAPI])
4037 GSSLIBS="-lgss" ],
4038 AC_MSG_WARN([Cannot find any suitable gss-api library - build may fail]))
4039 ])
Darren Tucker964de182013-02-22 10:39:59 +11004040 ])
Tim Riceeae17cc2005-03-17 16:52:20 -08004041
Tim Rice648f8762011-01-26 12:38:57 -08004042 AC_CHECK_HEADER([gssapi.h], ,
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004043 [ unset ac_cv_header_gssapi_h
Damien Millera8e06ce2003-11-21 23:48:55 +11004044 CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
Tim Rice648f8762011-01-26 12:38:57 -08004045 AC_CHECK_HEADERS([gssapi.h], ,
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004046 AC_MSG_WARN([Cannot find any suitable gss-api header - build may fail])
Damien Millera8e06ce2003-11-21 23:48:55 +11004047 )
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004048 ]
4049 )
4050
4051 oldCPP="$CPPFLAGS"
4052 CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
Tim Rice648f8762011-01-26 12:38:57 -08004053 AC_CHECK_HEADER([gssapi_krb5.h], ,
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004054 [ CPPFLAGS="$oldCPP" ])
4055
Damien Millera8e06ce2003-11-21 23:48:55 +11004056 fi
Darren Tucker1d3ca582004-01-22 12:05:34 +11004057 if test ! -z "$need_dash_r" ; then
4058 LDFLAGS="$LDFLAGS -R${KRB5ROOT}/lib"
4059 fi
4060 if test ! -z "$blibpath" ; then
4061 blibpath="$blibpath:${KRB5ROOT}/lib"
4062 fi
Tim Ricefd9e9e32005-09-12 17:36:10 -07004063
Tim Rice648f8762011-01-26 12:38:57 -08004064 AC_CHECK_HEADERS([gssapi.h gssapi/gssapi.h])
4065 AC_CHECK_HEADERS([gssapi_krb5.h gssapi/gssapi_krb5.h])
4066 AC_CHECK_HEADERS([gssapi_generic.h gssapi/gssapi_generic.h])
Tim Ricefd9e9e32005-09-12 17:36:10 -07004067
Tim Rice648f8762011-01-26 12:38:57 -08004068 AC_SEARCH_LIBS([k_hasafs], [kafs], [AC_DEFINE([USE_AFS], [1],
4069 [Define this if you want to use libkafs' AFS support])])
Darren Tucker03978c62013-02-25 11:24:44 +11004070
4071 AC_CHECK_DECLS([GSS_C_NT_HOSTBASED_SERVICE], [], [], [[
4072#ifdef HAVE_GSSAPI_H
4073# include <gssapi.h>
4074#elif defined(HAVE_GSSAPI_GSSAPI_H)
4075# include <gssapi/gssapi.h>
4076#endif
4077
4078#ifdef HAVE_GSSAPI_GENERIC_H
4079# include <gssapi_generic.h>
4080#elif defined(HAVE_GSSAPI_GSSAPI_GENERIC_H)
4081# include <gssapi/gssapi_generic.h>
4082#endif
4083 ]])
Darren Tuckerf3ab2c52013-08-04 21:48:41 +10004084 saved_LIBS="$LIBS"
4085 LIBS="$LIBS $K5LIBS"
4086 AC_CHECK_FUNCS([krb5_cc_new_unique krb5_get_error_message krb5_free_error_message])
4087 LIBS="$saved_LIBS"
4088
Darren Tucker0d27ed12004-02-24 10:37:33 +11004089 fi
Darren Tucker0d27ed12004-02-24 10:37:33 +11004090 ]
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004091)
Darren Tucker964de182013-02-22 10:39:59 +11004092AC_SUBST([GSSLIBS])
4093AC_SUBST([K5LIBS])
Damien Millerc79bc0d2001-03-28 13:03:42 +10004094
Damien Millera22ba012000-03-02 23:09:20 +11004095# Looking for programs, paths and files
Damien Millera22ba012000-03-02 23:09:20 +11004096
Damien Millerf58c6722002-05-13 13:15:42 +10004097PRIVSEP_PATH=/var/empty
Tim Rice648f8762011-01-26 12:38:57 -08004098AC_ARG_WITH([privsep-path],
Tim Ricecbb90662002-07-08 19:17:10 -07004099 [ --with-privsep-path=xxx Path for privilege separation chroot (default=/var/empty)],
Damien Millerf58c6722002-05-13 13:15:42 +10004100 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004101 if test -n "$withval" && test "x$withval" != "xno" && \
4102 test "x${withval}" != "xyes"; then
Damien Millerf58c6722002-05-13 13:15:42 +10004103 PRIVSEP_PATH=$withval
4104 fi
4105 ]
4106)
Tim Rice648f8762011-01-26 12:38:57 -08004107AC_SUBST([PRIVSEP_PATH])
Damien Millerf58c6722002-05-13 13:15:42 +10004108
Tim Rice648f8762011-01-26 12:38:57 -08004109AC_ARG_WITH([xauth],
Damien Millera22ba012000-03-02 23:09:20 +11004110 [ --with-xauth=PATH Specify path to xauth program ],
4111 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004112 if test -n "$withval" && test "x$withval" != "xno" && \
4113 test "x${withval}" != "xyes"; then
Damien Miller7b22d652000-06-18 14:07:04 +10004114 xauth_path=$withval
Damien Millera22ba012000-03-02 23:09:20 +11004115 fi
4116 ],
4117 [
Tim Ricee22be3b2002-07-17 19:20:07 -07004118 TestPath="$PATH"
4119 TestPath="${TestPath}${PATH_SEPARATOR}/usr/X/bin"
4120 TestPath="${TestPath}${PATH_SEPARATOR}/usr/bin/X11"
4121 TestPath="${TestPath}${PATH_SEPARATOR}/usr/X11R6/bin"
4122 TestPath="${TestPath}${PATH_SEPARATOR}/usr/openwin/bin"
Tim Rice648f8762011-01-26 12:38:57 -08004123 AC_PATH_PROG([xauth_path], [xauth], , [$TestPath])
Damien Milleredb82922000-06-20 13:25:52 +10004124 if (test ! -z "$xauth_path" && test -x "/usr/openwin/bin/xauth") ; then
Damien Millera22ba012000-03-02 23:09:20 +11004125 xauth_path="/usr/openwin/bin/xauth"
4126 fi
4127 ]
4128)
4129
Damien Miller7d901272003-01-13 16:55:22 +11004130STRIP_OPT=-s
Tim Rice648f8762011-01-26 12:38:57 -08004131AC_ARG_ENABLE([strip],
Damien Miller7d901272003-01-13 16:55:22 +11004132 [ --disable-strip Disable calling strip(1) on install],
4133 [
4134 if test "x$enableval" = "xno" ; then
4135 STRIP_OPT=
4136 fi
4137 ]
4138)
Tim Rice648f8762011-01-26 12:38:57 -08004139AC_SUBST([STRIP_OPT])
Damien Miller7d901272003-01-13 16:55:22 +11004140
Damien Millera19cf472000-11-29 13:28:50 +11004141if test -z "$xauth_path" ; then
4142 XAUTH_PATH="undefined"
Tim Rice648f8762011-01-26 12:38:57 -08004143 AC_SUBST([XAUTH_PATH])
Damien Millera19cf472000-11-29 13:28:50 +11004144else
Tim Rice648f8762011-01-26 12:38:57 -08004145 AC_DEFINE_UNQUOTED([XAUTH_PATH], ["$xauth_path"],
Tim Rice7df8d392005-09-19 09:33:39 -07004146 [Define if xauth is found in your path])
Damien Millera19cf472000-11-29 13:28:50 +11004147 XAUTH_PATH=$xauth_path
Tim Rice648f8762011-01-26 12:38:57 -08004148 AC_SUBST([XAUTH_PATH])
Damien Millera22ba012000-03-02 23:09:20 +11004149fi
Damien Millera22ba012000-03-02 23:09:20 +11004150
Tim Rice90f42b02011-06-02 18:17:49 -07004151dnl # --with-maildir=/path/to/mail gets top priority.
4152dnl # if maildir is set in the platform case statement above we use that.
4153dnl # Otherwise we run a program to get the dir from system headers.
4154dnl # We first look for _PATH_MAILDIR then MAILDIR then _PATH_MAIL
4155dnl # If we find _PATH_MAILDIR we do nothing because that is what
4156dnl # session.c expects anyway. Otherwise we set to the value found
4157dnl # stripping any trailing slash. If for some strage reason our program
4158dnl # does not find what it needs, we default to /var/spool/mail.
4159# Check for mail directory
4160AC_ARG_WITH([maildir],
4161 [ --with-maildir=/path/to/mail Specify your system mail directory],
4162 [
4163 if test "X$withval" != X && test "x$withval" != xno && \
4164 test "x${withval}" != xyes; then
4165 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$withval"],
4166 [Set this to your mail directory if you do not have _PATH_MAILDIR])
4167 fi
4168 ],[
4169 if test "X$maildir" != "X"; then
4170 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$maildir"])
4171 else
4172 AC_MSG_CHECKING([Discovering system mail directory])
4173 AC_RUN_IFELSE(
4174 [AC_LANG_PROGRAM([[
4175#include <stdio.h>
4176#include <string.h>
4177#ifdef HAVE_PATHS_H
4178#include <paths.h>
4179#endif
4180#ifdef HAVE_MAILLOCK_H
4181#include <maillock.h>
4182#endif
4183#define DATA "conftest.maildir"
4184 ]], [[
4185 FILE *fd;
4186 int rc;
4187
4188 fd = fopen(DATA,"w");
4189 if(fd == NULL)
4190 exit(1);
4191
4192#if defined (_PATH_MAILDIR)
4193 if ((rc = fprintf(fd ,"_PATH_MAILDIR:%s\n", _PATH_MAILDIR)) <0)
4194 exit(1);
4195#elif defined (MAILDIR)
4196 if ((rc = fprintf(fd ,"MAILDIR:%s\n", MAILDIR)) <0)
4197 exit(1);
4198#elif defined (_PATH_MAIL)
4199 if ((rc = fprintf(fd ,"_PATH_MAIL:%s\n", _PATH_MAIL)) <0)
4200 exit(1);
4201#else
4202 exit (2);
4203#endif
4204
4205 exit(0);
4206 ]])],
4207 [
4208 maildir_what=`awk -F: '{print $1}' conftest.maildir`
4209 maildir=`awk -F: '{print $2}' conftest.maildir \
4210 | sed 's|/$||'`
4211 AC_MSG_RESULT([Using: $maildir from $maildir_what])
4212 if test "x$maildir_what" != "x_PATH_MAILDIR"; then
4213 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$maildir"])
4214 fi
4215 ],
4216 [
4217 if test "X$ac_status" = "X2";then
4218# our test program didn't find it. Default to /var/spool/mail
4219 AC_MSG_RESULT([Using: default value of /var/spool/mail])
4220 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["/var/spool/mail"])
4221 else
4222 AC_MSG_RESULT([*** not found ***])
4223 fi
4224 ],
4225 [
4226 AC_MSG_WARN([cross compiling: use --with-maildir=/path/to/mail])
4227 ]
4228 )
4229 fi
4230 ]
4231) # maildir
Damien Millera22ba012000-03-02 23:09:20 +11004232
Darren Tucker623d92f2004-09-12 22:36:15 +10004233if test ! -z "$cross_compiling" && test "x$cross_compiling" = "xyes"; then
Darren Tuckera0c2b392004-09-11 23:26:37 +10004234 AC_MSG_WARN([cross compiling: Disabling /dev/ptmx test])
4235 disable_ptmx_check=yes
4236fi
Damien Millera22ba012000-03-02 23:09:20 +11004237if test -z "$no_dev_ptmx" ; then
Kevin Steves0ea1d9d2002-04-25 18:17:04 +00004238 if test "x$disable_ptmx_check" != "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004239 AC_CHECK_FILE(["/dev/ptmx"],
Kevin Steves0ea1d9d2002-04-25 18:17:04 +00004240 [
Tim Rice648f8762011-01-26 12:38:57 -08004241 AC_DEFINE_UNQUOTED([HAVE_DEV_PTMX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004242 [Define if you have /dev/ptmx])
Kevin Steves0ea1d9d2002-04-25 18:17:04 +00004243 have_dev_ptmx=1
4244 ]
4245 )
4246 fi
Damien Millera22ba012000-03-02 23:09:20 +11004247fi
Darren Tuckera0c2b392004-09-11 23:26:37 +10004248
Darren Tucker623d92f2004-09-12 22:36:15 +10004249if test ! -z "$cross_compiling" && test "x$cross_compiling" != "xyes"; then
Tim Rice648f8762011-01-26 12:38:57 -08004250 AC_CHECK_FILE(["/dev/ptc"],
Darren Tuckera0c2b392004-09-11 23:26:37 +10004251 [
Tim Rice648f8762011-01-26 12:38:57 -08004252 AC_DEFINE_UNQUOTED([HAVE_DEV_PTS_AND_PTC], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004253 [Define if you have /dev/ptc])
Darren Tuckera0c2b392004-09-11 23:26:37 +10004254 have_dev_ptc=1
4255 ]
4256 )
4257else
4258 AC_MSG_WARN([cross compiling: Disabling /dev/ptc test])
4259fi
Damien Miller204ad072000-03-02 23:56:12 +11004260
Damien Millera22ba012000-03-02 23:09:20 +11004261# Options from here on. Some of these are preset by platform above
Tim Rice648f8762011-01-26 12:38:57 -08004262AC_ARG_WITH([mantype],
Damien Miller897741e2001-04-16 10:41:46 +10004263 [ --with-mantype=man|cat|doc Set man page type],
Damien Miller670a4b82000-01-22 13:53:11 +11004264 [
Damien Miller897741e2001-04-16 10:41:46 +10004265 case "$withval" in
4266 man|cat|doc)
4267 MANTYPE=$withval
4268 ;;
4269 *)
Tim Rice648f8762011-01-26 12:38:57 -08004270 AC_MSG_ERROR([invalid man type: $withval])
Damien Miller897741e2001-04-16 10:41:46 +10004271 ;;
4272 esac
Damien Miller670a4b82000-01-22 13:53:11 +11004273 ]
4274)
Ben Lindstrombc709922001-04-18 18:04:21 +00004275if test -z "$MANTYPE"; then
Tim Ricee22be3b2002-07-17 19:20:07 -07004276 TestPath="/usr/bin${PATH_SEPARATOR}/usr/ucb"
Tim Rice648f8762011-01-26 12:38:57 -08004277 AC_PATH_PROGS([NROFF], [nroff awf], [/bin/false], [$TestPath])
Ben Lindstrombc709922001-04-18 18:04:21 +00004278 if ${NROFF} -mdoc ${srcdir}/ssh.1 >/dev/null 2>&1; then
4279 MANTYPE=doc
4280 elif ${NROFF} -man ${srcdir}/ssh.1 >/dev/null 2>&1; then
4281 MANTYPE=man
4282 else
4283 MANTYPE=cat
4284 fi
4285fi
Tim Rice648f8762011-01-26 12:38:57 -08004286AC_SUBST([MANTYPE])
Ben Lindstrombc709922001-04-18 18:04:21 +00004287if test "$MANTYPE" = "doc"; then
4288 mansubdir=man;
4289else
4290 mansubdir=$MANTYPE;
4291fi
Tim Rice648f8762011-01-26 12:38:57 -08004292AC_SUBST([mansubdir])
Damien Miller8bdeee21999-12-30 15:50:54 +11004293
Damien Millera22ba012000-03-02 23:09:20 +11004294# Check whether to enable MD5 passwords
Damien Millera8e06ce2003-11-21 23:48:55 +11004295MD5_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08004296AC_ARG_WITH([md5-passwords],
Damien Millerdd1c7ba1999-11-19 15:53:20 +11004297 [ --with-md5-passwords Enable use of MD5 passwords],
Damien Miller8bdeee21999-12-30 15:50:54 +11004298 [
Damien Millerb85dcad2000-03-11 11:37:00 +11004299 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004300 AC_DEFINE([HAVE_MD5_PASSWORDS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004301 [Define if you want to allow MD5 passwords])
Damien Millera8e06ce2003-11-21 23:48:55 +11004302 MD5_MSG="yes"
Damien Miller8bdeee21999-12-30 15:50:54 +11004303 fi
4304 ]
Damien Millerdd1c7ba1999-11-19 15:53:20 +11004305)
4306
Damien Millera22ba012000-03-02 23:09:20 +11004307# Whether to disable shadow password support
Tim Rice648f8762011-01-26 12:38:57 -08004308AC_ARG_WITH([shadow],
Damien Miller76112de1999-12-21 11:18:08 +11004309 [ --without-shadow Disable shadow password support],
4310 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004311 if test "x$withval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004312 AC_DEFINE([DISABLE_SHADOW])
Damien Miller1f335fb2000-06-26 11:31:33 +10004313 disable_shadow=yes
Damien Miller76112de1999-12-21 11:18:08 +11004314 fi
4315 ]
4316)
4317
Damien Miller1f335fb2000-06-26 11:31:33 +10004318if test -z "$disable_shadow" ; then
4319 AC_MSG_CHECKING([if the systems has expire shadow information])
Tim Rice648f8762011-01-26 12:38:57 -08004320 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller1f335fb2000-06-26 11:31:33 +10004321#include <sys/types.h>
4322#include <shadow.h>
Tim Rice648f8762011-01-26 12:38:57 -08004323struct spwd sp;
4324 ]], [[ sp.sp_expire = sp.sp_lstchg = sp.sp_inact = 0; ]])],
4325 [ sp_expire_available=yes ], [
4326 ])
Damien Miller1f335fb2000-06-26 11:31:33 +10004327
4328 if test "x$sp_expire_available" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004329 AC_MSG_RESULT([yes])
4330 AC_DEFINE([HAS_SHADOW_EXPIRE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004331 [Define if you want to use shadow password expire field])
Damien Miller1f335fb2000-06-26 11:31:33 +10004332 else
Tim Rice648f8762011-01-26 12:38:57 -08004333 AC_MSG_RESULT([no])
Damien Miller1f335fb2000-06-26 11:31:33 +10004334 fi
4335fi
4336
Damien Millera22ba012000-03-02 23:09:20 +11004337# Use ip address instead of hostname in $DISPLAY
Damien Miller9a947342000-08-30 10:03:33 +11004338if test ! -z "$IPADDR_IN_DISPLAY" ; then
4339 DISPLAY_HACK_MSG="yes"
Tim Rice648f8762011-01-26 12:38:57 -08004340 AC_DEFINE([IPADDR_IN_DISPLAY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004341 [Define if you need to use IP address
4342 instead of hostname in $DISPLAY])
Damien Miller9a947342000-08-30 10:03:33 +11004343else
Damien Millera8e06ce2003-11-21 23:48:55 +11004344 DISPLAY_HACK_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08004345 AC_ARG_WITH([ipaddr-display],
Damien Miller9a947342000-08-30 10:03:33 +11004346 [ --with-ipaddr-display Use ip address instead of hostname in \$DISPLAY],
4347 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004348 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004349 AC_DEFINE([IPADDR_IN_DISPLAY])
Damien Millera8e06ce2003-11-21 23:48:55 +11004350 DISPLAY_HACK_MSG="yes"
Damien Miller9a947342000-08-30 10:03:33 +11004351 fi
4352 ]
4353 )
4354fi
Damien Miller76112de1999-12-21 11:18:08 +11004355
Darren Tuckere1a790d2003-09-16 11:52:19 +10004356# check for /etc/default/login and use it if present.
Tim Rice648f8762011-01-26 12:38:57 -08004357AC_ARG_ENABLE([etc-default-login],
Darren Tucker1b6f2292005-02-11 16:11:49 +11004358 [ --disable-etc-default-login Disable using PATH from /etc/default/login [no]],
Darren Tucker2f9573d2005-02-10 22:28:54 +11004359 [ if test "x$enableval" = "xno"; then
4360 AC_MSG_NOTICE([/etc/default/login handling disabled])
4361 etc_default_login=no
4362 else
4363 etc_default_login=yes
4364 fi ],
Darren Tucker314d89e2005-10-17 23:29:23 +10004365 [ if test ! -z "$cross_compiling" && test "x$cross_compiling" = "xyes";
4366 then
4367 AC_MSG_WARN([cross compiling: not checking /etc/default/login])
4368 etc_default_login=no
4369 else
4370 etc_default_login=yes
4371 fi ]
Darren Tucker2f9573d2005-02-10 22:28:54 +11004372)
Darren Tuckere1a790d2003-09-16 11:52:19 +10004373
Darren Tucker2f9573d2005-02-10 22:28:54 +11004374if test "x$etc_default_login" != "xno"; then
Tim Rice648f8762011-01-26 12:38:57 -08004375 AC_CHECK_FILE(["/etc/default/login"],
Darren Tucker2f9573d2005-02-10 22:28:54 +11004376 [ external_path_file=/etc/default/login ])
Darren Tucker314d89e2005-10-17 23:29:23 +10004377 if test "x$external_path_file" = "x/etc/default/login"; then
Tim Rice648f8762011-01-26 12:38:57 -08004378 AC_DEFINE([HAVE_ETC_DEFAULT_LOGIN], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004379 [Define if your system has /etc/default/login])
Darren Tuckera0c2b392004-09-11 23:26:37 +10004380 fi
Darren Tucker2f9573d2005-02-10 22:28:54 +11004381fi
Darren Tuckere1a790d2003-09-16 11:52:19 +10004382
Tim Rice43a1c132002-04-17 21:19:14 -07004383dnl BSD systems use /etc/login.conf so --with-default-path= has no effect
Tim Rice8bb561b2005-03-17 16:23:19 -08004384if test $ac_cv_func_login_getcapbool = "yes" && \
4385 test $ac_cv_header_login_cap_h = "yes" ; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10004386 external_path_file=/etc/login.conf
Tim Rice43a1c132002-04-17 21:19:14 -07004387fi
Darren Tuckere1a790d2003-09-16 11:52:19 +10004388
Damien Millera22ba012000-03-02 23:09:20 +11004389# Whether to mess with the default path
Damien Millera8e06ce2003-11-21 23:48:55 +11004390SERVER_PATH_MSG="(default)"
Tim Rice648f8762011-01-26 12:38:57 -08004391AC_ARG_WITH([default-path],
Damien Millerf71d2a52002-05-13 15:14:08 +10004392 [ --with-default-path= Specify default \$PATH environment for server],
Damien Miller5a3e6831999-12-27 09:48:56 +11004393 [
Darren Tuckere1a790d2003-09-16 11:52:19 +10004394 if test "x$external_path_file" = "x/etc/login.conf" ; then
Tim Rice43a1c132002-04-17 21:19:14 -07004395 AC_MSG_WARN([
4396--with-default-path=PATH has no effect on this system.
4397Edit /etc/login.conf instead.])
Tim Riceeae17cc2005-03-17 16:52:20 -08004398 elif test "x$withval" != "xno" ; then
Tim Riceb925b4b2003-09-15 22:40:49 -07004399 if test ! -z "$external_path_file" ; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10004400 AC_MSG_WARN([
4401--with-default-path=PATH will only be used if PATH is not defined in
4402$external_path_file .])
4403 fi
Tim Rice59ea0a02001-03-10 13:50:45 -08004404 user_path="$withval"
Damien Millera8e06ce2003-11-21 23:48:55 +11004405 SERVER_PATH_MSG="$withval"
Damien Miller5a3e6831999-12-27 09:48:56 +11004406 fi
Tim Rice59ea0a02001-03-10 13:50:45 -08004407 ],
Darren Tuckere1a790d2003-09-16 11:52:19 +10004408 [ if test "x$external_path_file" = "x/etc/login.conf" ; then
4409 AC_MSG_WARN([Make sure the path to scp is in /etc/login.conf])
Tim Rice43a1c132002-04-17 21:19:14 -07004410 else
Tim Riceb925b4b2003-09-15 22:40:49 -07004411 if test ! -z "$external_path_file" ; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10004412 AC_MSG_WARN([
4413If PATH is defined in $external_path_file, ensure the path to scp is included,
4414otherwise scp will not work.])
4415 fi
Darren Tucker314d89e2005-10-17 23:29:23 +10004416 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08004417 [AC_LANG_PROGRAM([[
Tim Rice59ea0a02001-03-10 13:50:45 -08004418/* find out what STDPATH is */
4419#include <stdio.h>
Tim Rice59ea0a02001-03-10 13:50:45 -08004420#ifdef HAVE_PATHS_H
4421# include <paths.h>
4422#endif
4423#ifndef _PATH_STDPATH
Tim Rice1c9e6882002-11-22 13:29:01 -08004424# ifdef _PATH_USERPATH /* Irix */
4425# define _PATH_STDPATH _PATH_USERPATH
4426# else
4427# define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
4428# endif
Tim Rice59ea0a02001-03-10 13:50:45 -08004429#endif
4430#include <sys/types.h>
4431#include <sys/stat.h>
4432#include <fcntl.h>
4433#define DATA "conftest.stdpath"
Tim Rice648f8762011-01-26 12:38:57 -08004434 ]], [[
Tim Rice59ea0a02001-03-10 13:50:45 -08004435 FILE *fd;
4436 int rc;
Tim Riceeae17cc2005-03-17 16:52:20 -08004437
Tim Rice59ea0a02001-03-10 13:50:45 -08004438 fd = fopen(DATA,"w");
4439 if(fd == NULL)
4440 exit(1);
Tim Riceeae17cc2005-03-17 16:52:20 -08004441
Tim Rice59ea0a02001-03-10 13:50:45 -08004442 if ((rc = fprintf(fd,"%s", _PATH_STDPATH)) < 0)
4443 exit(1);
4444
4445 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10004446 ]])],
4447 [ user_path=`cat conftest.stdpath` ],
Tim Rice59ea0a02001-03-10 13:50:45 -08004448 [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ],
4449 [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ]
4450 )
4451# make sure $bindir is in USER_PATH so scp will work
Damien Miller77eab7b2012-07-06 11:49:28 +10004452 t_bindir="${bindir}"
4453 while echo "${t_bindir}" | egrep '\$\{|NONE/' >/dev/null 2>&1; do
4454 t_bindir=`eval echo ${t_bindir}`
4455 case $t_bindir in
4456 NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$prefix~"` ;;
4457 esac
4458 case $t_bindir in
4459 NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$ac_default_prefix~"` ;;
4460 esac
4461 done
Tim Rice59ea0a02001-03-10 13:50:45 -08004462 echo $user_path | grep ":$t_bindir" > /dev/null 2>&1
4463 if test $? -ne 0 ; then
4464 echo $user_path | grep "^$t_bindir" > /dev/null 2>&1
4465 if test $? -ne 0 ; then
4466 user_path=$user_path:$t_bindir
Tim Rice648f8762011-01-26 12:38:57 -08004467 AC_MSG_RESULT([Adding $t_bindir to USER_PATH so scp will work])
Tim Rice59ea0a02001-03-10 13:50:45 -08004468 fi
4469 fi
Tim Rice43a1c132002-04-17 21:19:14 -07004470 fi ]
Damien Miller5a3e6831999-12-27 09:48:56 +11004471)
Darren Tuckere1a790d2003-09-16 11:52:19 +10004472if test "x$external_path_file" != "x/etc/login.conf" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004473 AC_DEFINE_UNQUOTED([USER_PATH], ["$user_path"], [Specify default $PATH])
4474 AC_SUBST([user_path])
Tim Rice43a1c132002-04-17 21:19:14 -07004475fi
Damien Miller5a3e6831999-12-27 09:48:56 +11004476
Damien Millera18bbd32002-05-13 10:48:57 +10004477# Set superuser path separately to user path
Tim Rice648f8762011-01-26 12:38:57 -08004478AC_ARG_WITH([superuser-path],
Damien Millera18bbd32002-05-13 10:48:57 +10004479 [ --with-superuser-path= Specify different path for super-user],
4480 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004481 if test -n "$withval" && test "x$withval" != "xno" && \
4482 test "x${withval}" != "xyes"; then
Tim Rice648f8762011-01-26 12:38:57 -08004483 AC_DEFINE_UNQUOTED([SUPERUSER_PATH], ["$withval"],
Tim Rice7df8d392005-09-19 09:33:39 -07004484 [Define if you want a different $PATH
4485 for the superuser])
Damien Millera18bbd32002-05-13 10:48:57 +10004486 superuser_path=$withval
4487 fi
4488 ]
4489)
4490
4491
Damien Miller61e50f12000-05-08 20:49:37 +10004492AC_MSG_CHECKING([if we need to convert IPv4 in IPv6-mapped addresses])
Damien Millera8e06ce2003-11-21 23:48:55 +11004493IPV4_IN6_HACK_MSG="no"
Damien Miller7bcb0892000-03-11 20:45:40 +11004494AC_ARG_WITH(4in6,
4495 [ --with-4in6 Check for and convert IPv4 in IPv6 mapped addresses],
4496 [
4497 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004498 AC_MSG_RESULT([yes])
4499 AC_DEFINE([IPV4_IN_IPV6], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004500 [Detect IPv4 in IPv6 mapped addresses
4501 and treat as IPv4])
Damien Millera8e06ce2003-11-21 23:48:55 +11004502 IPV4_IN6_HACK_MSG="yes"
Damien Miller7bcb0892000-03-11 20:45:40 +11004503 else
Tim Rice648f8762011-01-26 12:38:57 -08004504 AC_MSG_RESULT([no])
Damien Miller7bcb0892000-03-11 20:45:40 +11004505 fi
Tim Rice648f8762011-01-26 12:38:57 -08004506 ], [
Damien Miller7bcb0892000-03-11 20:45:40 +11004507 if test "x$inet6_default_4in6" = "xyes"; then
4508 AC_MSG_RESULT([yes (default)])
Tim Rice648f8762011-01-26 12:38:57 -08004509 AC_DEFINE([IPV4_IN_IPV6])
Damien Millera8e06ce2003-11-21 23:48:55 +11004510 IPV4_IN6_HACK_MSG="yes"
Damien Miller7bcb0892000-03-11 20:45:40 +11004511 else
4512 AC_MSG_RESULT([no (default)])
4513 fi
4514 ]
4515)
4516
Damien Miller60396b02001-02-18 17:01:00 +11004517# Whether to enable BSD auth support
Damien Miller6c21c512002-01-22 21:57:53 +11004518BSD_AUTH_MSG=no
Tim Rice648f8762011-01-26 12:38:57 -08004519AC_ARG_WITH([bsd-auth],
Damien Miller60396b02001-02-18 17:01:00 +11004520 [ --with-bsd-auth Enable BSD auth support],
4521 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004522 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004523 AC_DEFINE([BSD_AUTH], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004524 [Define if you have BSD auth support])
Damien Miller6c21c512002-01-22 21:57:53 +11004525 BSD_AUTH_MSG=yes
Damien Miller60396b02001-02-18 17:01:00 +11004526 fi
4527 ]
4528)
4529
Damien Millera22ba012000-03-02 23:09:20 +11004530# Where to place sshd.pid
Damien Millerb13c73e2000-01-17 22:02:17 +11004531piddir=/var/run
Damien Miller78315eb2000-09-29 23:01:36 +11004532# make sure the directory exists
Tim Riceeae17cc2005-03-17 16:52:20 -08004533if test ! -d $piddir ; then
Damien Miller78315eb2000-09-29 23:01:36 +11004534 piddir=`eval echo ${sysconfdir}`
4535 case $piddir in
Damien Millera8e06ce2003-11-21 23:48:55 +11004536 NONE/*) piddir=`echo $piddir | sed "s~NONE~$ac_default_prefix~"` ;;
Damien Miller78315eb2000-09-29 23:01:36 +11004537 esac
4538fi
4539
Tim Rice648f8762011-01-26 12:38:57 -08004540AC_ARG_WITH([pid-dir],
Tim Rice88f2ab52002-03-17 12:17:34 -08004541 [ --with-pid-dir=PATH Specify location of ssh.pid file],
4542 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004543 if test -n "$withval" && test "x$withval" != "xno" && \
4544 test "x${withval}" != "xyes"; then
Tim Rice88f2ab52002-03-17 12:17:34 -08004545 piddir=$withval
Tim Riceeae17cc2005-03-17 16:52:20 -08004546 if test ! -d $piddir ; then
Tim Rice88f2ab52002-03-17 12:17:34 -08004547 AC_MSG_WARN([** no $piddir directory on this system **])
4548 fi
4549 fi
4550 ]
4551)
4552
Tim Rice648f8762011-01-26 12:38:57 -08004553AC_DEFINE_UNQUOTED([_PATH_SSH_PIDDIR], ["$piddir"],
4554 [Specify location of ssh.pid])
4555AC_SUBST([piddir])
Damien Miller5eed6a22000-01-16 12:05:18 +11004556
andre2ff7b5d2000-06-03 14:57:40 +00004557dnl allow user to disable some login recording features
Tim Rice648f8762011-01-26 12:38:57 -08004558AC_ARG_ENABLE([lastlog],
andre43ca7e22000-06-19 08:23:46 +00004559 [ --disable-lastlog disable use of lastlog even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004560 [
4561 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004562 AC_DEFINE([DISABLE_LASTLOG])
Darren Tuckera3020db2003-06-28 12:54:33 +10004563 fi
4564 ]
andre2ff7b5d2000-06-03 14:57:40 +00004565)
Tim Rice648f8762011-01-26 12:38:57 -08004566AC_ARG_ENABLE([utmp],
andre43ca7e22000-06-19 08:23:46 +00004567 [ --disable-utmp disable use of utmp even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004568 [
4569 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004570 AC_DEFINE([DISABLE_UTMP])
Darren Tuckera3020db2003-06-28 12:54:33 +10004571 fi
4572 ]
andre2ff7b5d2000-06-03 14:57:40 +00004573)
Tim Rice648f8762011-01-26 12:38:57 -08004574AC_ARG_ENABLE([utmpx],
andre43ca7e22000-06-19 08:23:46 +00004575 [ --disable-utmpx disable use of utmpx even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004576 [
4577 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004578 AC_DEFINE([DISABLE_UTMPX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004579 [Define if you don't want to use utmpx])
Darren Tuckera3020db2003-06-28 12:54:33 +10004580 fi
4581 ]
andre2ff7b5d2000-06-03 14:57:40 +00004582)
Tim Rice648f8762011-01-26 12:38:57 -08004583AC_ARG_ENABLE([wtmp],
andre43ca7e22000-06-19 08:23:46 +00004584 [ --disable-wtmp disable use of wtmp even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004585 [
4586 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004587 AC_DEFINE([DISABLE_WTMP])
Darren Tuckera3020db2003-06-28 12:54:33 +10004588 fi
4589 ]
andre2ff7b5d2000-06-03 14:57:40 +00004590)
Tim Rice648f8762011-01-26 12:38:57 -08004591AC_ARG_ENABLE([wtmpx],
andre43ca7e22000-06-19 08:23:46 +00004592 [ --disable-wtmpx disable use of wtmpx even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004593 [
4594 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004595 AC_DEFINE([DISABLE_WTMPX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004596 [Define if you don't want to use wtmpx])
Darren Tuckera3020db2003-06-28 12:54:33 +10004597 fi
4598 ]
andre2ff7b5d2000-06-03 14:57:40 +00004599)
Tim Rice648f8762011-01-26 12:38:57 -08004600AC_ARG_ENABLE([libutil],
andre43ca7e22000-06-19 08:23:46 +00004601 [ --disable-libutil disable use of libutil (login() etc.) [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004602 [
4603 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004604 AC_DEFINE([DISABLE_LOGIN])
Darren Tuckera3020db2003-06-28 12:54:33 +10004605 fi
4606 ]
andre2ff7b5d2000-06-03 14:57:40 +00004607)
Tim Rice648f8762011-01-26 12:38:57 -08004608AC_ARG_ENABLE([pututline],
andre43ca7e22000-06-19 08:23:46 +00004609 [ --disable-pututline disable use of pututline() etc. ([uw]tmp) [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004610 [
4611 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004612 AC_DEFINE([DISABLE_PUTUTLINE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004613 [Define if you don't want to use pututline()
4614 etc. to write [uw]tmp])
Darren Tuckera3020db2003-06-28 12:54:33 +10004615 fi
4616 ]
andre2ff7b5d2000-06-03 14:57:40 +00004617)
Tim Rice648f8762011-01-26 12:38:57 -08004618AC_ARG_ENABLE([pututxline],
andre43ca7e22000-06-19 08:23:46 +00004619 [ --disable-pututxline disable use of pututxline() etc. ([uw]tmpx) [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004620 [
4621 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004622 AC_DEFINE([DISABLE_PUTUTXLINE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004623 [Define if you don't want to use pututxline()
4624 etc. to write [uw]tmpx])
Darren Tuckera3020db2003-06-28 12:54:33 +10004625 fi
4626 ]
andre2ff7b5d2000-06-03 14:57:40 +00004627)
Tim Rice648f8762011-01-26 12:38:57 -08004628AC_ARG_WITH([lastlog],
andre43ca7e22000-06-19 08:23:46 +00004629 [ --with-lastlog=FILE|DIR specify lastlog location [common locations]],
Damien Miller709528a2001-01-31 09:57:55 +11004630 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004631 if test "x$withval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004632 AC_DEFINE([DISABLE_LASTLOG])
Tim Rice35cc69d2005-03-17 16:44:25 -08004633 elif test -n "$withval" && test "x${withval}" != "xyes"; then
Damien Miller709528a2001-01-31 09:57:55 +11004634 conf_lastlog_location=$withval
4635 fi
4636 ]
4637)
andre2ff7b5d2000-06-03 14:57:40 +00004638
4639dnl lastlog, [uw]tmpx? detection
4640dnl NOTE: set the paths in the platform section to avoid the
4641dnl need for command-line parameters
4642dnl lastlog and [uw]tmp are subject to a file search if all else fails
4643
4644dnl lastlog detection
4645dnl NOTE: the code itself will detect if lastlog is a directory
4646AC_MSG_CHECKING([if your system defines LASTLOG_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08004647AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00004648#include <sys/types.h>
4649#include <utmp.h>
4650#ifdef HAVE_LASTLOG_H
4651# include <lastlog.h>
4652#endif
Damien Miller2994e082000-06-04 15:51:47 +10004653#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00004654# include <paths.h>
4655#endif
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00004656#ifdef HAVE_LOGIN_H
4657# include <login.h>
4658#endif
Tim Rice648f8762011-01-26 12:38:57 -08004659 ]], [[ char *lastlog = LASTLOG_FILE; ]])],
4660 [ AC_MSG_RESULT([yes]) ],
4661 [
4662 AC_MSG_RESULT([no])
Damien Miller2994e082000-06-04 15:51:47 +10004663 AC_MSG_CHECKING([if your system defines _PATH_LASTLOG])
Tim Rice648f8762011-01-26 12:38:57 -08004664 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller2994e082000-06-04 15:51:47 +10004665#include <sys/types.h>
4666#include <utmp.h>
4667#ifdef HAVE_LASTLOG_H
4668# include <lastlog.h>
4669#endif
4670#ifdef HAVE_PATHS_H
4671# include <paths.h>
4672#endif
Tim Rice648f8762011-01-26 12:38:57 -08004673 ]], [[ char *lastlog = _PATH_LASTLOG; ]])],
4674 [ AC_MSG_RESULT([yes]) ],
Damien Miller2994e082000-06-04 15:51:47 +10004675 [
Tim Rice648f8762011-01-26 12:38:57 -08004676 AC_MSG_RESULT([no])
Damien Miller2994e082000-06-04 15:51:47 +10004677 system_lastlog_path=no
4678 ])
Tim Rice648f8762011-01-26 12:38:57 -08004679])
Damien Miller2994e082000-06-04 15:51:47 +10004680
andre2ff7b5d2000-06-03 14:57:40 +00004681if test -z "$conf_lastlog_location"; then
4682 if test x"$system_lastlog_path" = x"no" ; then
4683 for f in /var/log/lastlog /usr/adm/lastlog /var/adm/lastlog /etc/security/lastlog ; do
Damien Milleredb82922000-06-20 13:25:52 +10004684 if (test -d "$f" || test -f "$f") ; then
andre2ff7b5d2000-06-03 14:57:40 +00004685 conf_lastlog_location=$f
4686 fi
4687 done
4688 if test -z "$conf_lastlog_location"; then
andre45cad512000-06-12 23:27:31 +00004689 AC_MSG_WARN([** Cannot find lastlog **])
4690 dnl Don't define DISABLE_LASTLOG - that means we don't try wtmp/wtmpx
andre2ff7b5d2000-06-03 14:57:40 +00004691 fi
4692 fi
4693fi
4694
4695if test -n "$conf_lastlog_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08004696 AC_DEFINE_UNQUOTED([CONF_LASTLOG_FILE], ["$conf_lastlog_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07004697 [Define if you want to specify the path to your lastlog file])
Tim Riceeae17cc2005-03-17 16:52:20 -08004698fi
andre2ff7b5d2000-06-03 14:57:40 +00004699
4700dnl utmp detection
4701AC_MSG_CHECKING([if your system defines UTMP_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08004702AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00004703#include <sys/types.h>
4704#include <utmp.h>
Damien Miller2994e082000-06-04 15:51:47 +10004705#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00004706# include <paths.h>
4707#endif
Tim Rice648f8762011-01-26 12:38:57 -08004708 ]], [[ char *utmp = UTMP_FILE; ]])],
4709 [ AC_MSG_RESULT([yes]) ],
4710 [ AC_MSG_RESULT([no])
4711 system_utmp_path=no
4712])
andre2ff7b5d2000-06-03 14:57:40 +00004713if test -z "$conf_utmp_location"; then
4714 if test x"$system_utmp_path" = x"no" ; then
4715 for f in /etc/utmp /usr/adm/utmp /var/run/utmp; do
4716 if test -f $f ; then
4717 conf_utmp_location=$f
4718 fi
4719 done
4720 if test -z "$conf_utmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08004721 AC_DEFINE([DISABLE_UTMP])
andre2ff7b5d2000-06-03 14:57:40 +00004722 fi
4723 fi
4724fi
4725if test -n "$conf_utmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08004726 AC_DEFINE_UNQUOTED([CONF_UTMP_FILE], ["$conf_utmp_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07004727 [Define if you want to specify the path to your utmp file])
Tim Riceeae17cc2005-03-17 16:52:20 -08004728fi
andre2ff7b5d2000-06-03 14:57:40 +00004729
4730dnl wtmp detection
4731AC_MSG_CHECKING([if your system defines WTMP_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08004732AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00004733#include <sys/types.h>
4734#include <utmp.h>
Damien Miller2994e082000-06-04 15:51:47 +10004735#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00004736# include <paths.h>
4737#endif
Tim Rice648f8762011-01-26 12:38:57 -08004738 ]], [[ char *wtmp = WTMP_FILE; ]])],
4739 [ AC_MSG_RESULT([yes]) ],
4740 [ AC_MSG_RESULT([no])
4741 system_wtmp_path=no
4742])
andre2ff7b5d2000-06-03 14:57:40 +00004743if test -z "$conf_wtmp_location"; then
4744 if test x"$system_wtmp_path" = x"no" ; then
4745 for f in /usr/adm/wtmp /var/log/wtmp; do
4746 if test -f $f ; then
4747 conf_wtmp_location=$f
4748 fi
4749 done
4750 if test -z "$conf_wtmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08004751 AC_DEFINE([DISABLE_WTMP])
andre2ff7b5d2000-06-03 14:57:40 +00004752 fi
4753 fi
4754fi
4755if test -n "$conf_wtmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08004756 AC_DEFINE_UNQUOTED([CONF_WTMP_FILE], ["$conf_wtmp_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07004757 [Define if you want to specify the path to your wtmp file])
Tim Riceeae17cc2005-03-17 16:52:20 -08004758fi
andre2ff7b5d2000-06-03 14:57:40 +00004759
andre2ff7b5d2000-06-03 14:57:40 +00004760dnl wtmpx detection
4761AC_MSG_CHECKING([if your system defines WTMPX_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08004762AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00004763#include <sys/types.h>
4764#include <utmp.h>
4765#ifdef HAVE_UTMPX_H
4766#include <utmpx.h>
4767#endif
Damien Miller2994e082000-06-04 15:51:47 +10004768#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00004769# include <paths.h>
4770#endif
Tim Rice648f8762011-01-26 12:38:57 -08004771 ]], [[ char *wtmpx = WTMPX_FILE; ]])],
4772 [ AC_MSG_RESULT([yes]) ],
4773 [ AC_MSG_RESULT([no])
4774 system_wtmpx_path=no
4775])
andre2ff7b5d2000-06-03 14:57:40 +00004776if test -z "$conf_wtmpx_location"; then
4777 if test x"$system_wtmpx_path" = x"no" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004778 AC_DEFINE([DISABLE_WTMPX])
andre2ff7b5d2000-06-03 14:57:40 +00004779 fi
4780else
Tim Rice648f8762011-01-26 12:38:57 -08004781 AC_DEFINE_UNQUOTED([CONF_WTMPX_FILE], ["$conf_wtmpx_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07004782 [Define if you want to specify the path to your wtmpx file])
Tim Riceeae17cc2005-03-17 16:52:20 -08004783fi
andre2ff7b5d2000-06-03 14:57:40 +00004784
Damien Miller4018c192000-04-30 09:30:44 +10004785
Damien Miller29ea30d2000-03-17 10:54:15 +11004786if test ! -z "$blibpath" ; then
Damien Millereab4bae2003-04-29 23:22:40 +10004787 LDFLAGS="$LDFLAGS $blibflags$blibpath"
4788 AC_MSG_WARN([Please check and edit blibpath in LDFLAGS in Makefile])
Damien Miller29ea30d2000-03-17 10:54:15 +11004789fi
4790
Damien Millera2438bb2013-03-15 10:23:07 +11004791AC_CHECK_MEMBER([struct lastlog.ll_line], [], [
Tim Riceaa86c392013-03-16 20:55:46 -07004792 if test x$SKIP_DISABLE_LASTLOG_DEFINE != "xyes" ; then
Damien Millera2438bb2013-03-15 10:23:07 +11004793 AC_DEFINE([DISABLE_LASTLOG])
Tim Riceaa86c392013-03-16 20:55:46 -07004794 fi
Damien Millera2438bb2013-03-15 10:23:07 +11004795 ], [
4796#ifdef HAVE_SYS_TYPES_H
4797#include <sys/types.h>
4798#endif
4799#ifdef HAVE_UTMP_H
4800#include <utmp.h>
4801#endif
4802#ifdef HAVE_UTMPX_H
4803#include <utmpx.h>
4804#endif
4805#ifdef HAVE_LASTLOG_H
4806#include <lastlog.h>
4807#endif
4808 ])
4809
4810AC_CHECK_MEMBER([struct utmp.ut_line], [], [
4811 AC_DEFINE([DISABLE_UTMP])
4812 AC_DEFINE([DISABLE_WTMP])
4813 ], [
4814#ifdef HAVE_SYS_TYPES_H
4815#include <sys/types.h>
4816#endif
4817#ifdef HAVE_UTMP_H
4818#include <utmp.h>
4819#endif
4820#ifdef HAVE_UTMPX_H
4821#include <utmpx.h>
4822#endif
4823#ifdef HAVE_LASTLOG_H
4824#include <lastlog.h>
4825#endif
4826 ])
4827
Darren Tucker7da23cb2005-08-03 00:20:15 +10004828dnl Adding -Werror to CFLAGS early prevents configure tests from running.
4829dnl Add now.
4830CFLAGS="$CFLAGS $werror_flags"
4831
Darren Tucker627337d2010-04-10 22:58:01 +10004832if test "x$ac_cv_func_getaddrinfo" != "xyes" ; then
4833 TEST_SSH_IPV6=no
4834else
4835 TEST_SSH_IPV6=yes
4836fi
Tim Rice648f8762011-01-26 12:38:57 -08004837AC_CHECK_DECL([BROKEN_GETADDRINFO], [TEST_SSH_IPV6=no])
4838AC_SUBST([TEST_SSH_IPV6], [$TEST_SSH_IPV6])
Darren Tucker882abfd2013-11-09 00:17:41 +11004839AC_SUBST([TEST_MALLOC_OPTIONS], [$TEST_MALLOC_OPTIONS])
Darren Tucker6d8bd572013-06-11 11:26:10 +10004840AC_SUBST([UNSUPPORTED_ALGORITHMS], [$unsupported_algorithms])
Darren Tucker5d376902008-06-11 04:15:05 +10004841
Damien Millerbac2d8a2000-09-05 16:13:06 +11004842AC_EXEEXT
Damien Miller223897a2006-09-12 21:54:10 +10004843AC_CONFIG_FILES([Makefile buildpkg.sh opensshd.init openssh.xml \
4844 openbsd-compat/Makefile openbsd-compat/regress/Makefile \
Damien Millerf22019b2011-05-05 13:48:37 +10004845 survey.sh])
Tim Rice13aae5e2001-10-21 17:53:58 -07004846AC_OUTPUT
Damien Miller0437b332000-05-02 09:56:41 +10004847
Damien Miller7b22d652000-06-18 14:07:04 +10004848# Print summary of options
4849
Damien Miller7b22d652000-06-18 14:07:04 +10004850# Someone please show me a better way :)
4851A=`eval echo ${prefix}` ; A=`eval echo ${A}`
4852B=`eval echo ${bindir}` ; B=`eval echo ${B}`
4853C=`eval echo ${sbindir}` ; C=`eval echo ${C}`
4854D=`eval echo ${sysconfdir}` ; D=`eval echo ${D}`
Kevin Stevese0f49142000-10-14 17:51:48 +00004855E=`eval echo ${libexecdir}/ssh-askpass` ; E=`eval echo ${E}`
Ben Lindstrombc709922001-04-18 18:04:21 +00004856F=`eval echo ${mandir}/${mansubdir}X` ; F=`eval echo ${F}`
Damien Miller7b22d652000-06-18 14:07:04 +10004857G=`eval echo ${piddir}` ; G=`eval echo ${G}`
Damien Millerf58c6722002-05-13 13:15:42 +10004858H=`eval echo ${PRIVSEP_PATH}` ; H=`eval echo ${H}`
4859I=`eval echo ${user_path}` ; I=`eval echo ${I}`
4860J=`eval echo ${superuser_path}` ; J=`eval echo ${J}`
Damien Miller7b22d652000-06-18 14:07:04 +10004861
4862echo ""
Kevin Steves393d2f72001-04-08 22:50:43 +00004863echo "OpenSSH has been configured with the following options:"
Damien Millerf58c6722002-05-13 13:15:42 +10004864echo " User binaries: $B"
4865echo " System binaries: $C"
4866echo " Configuration files: $D"
4867echo " Askpass program: $E"
4868echo " Manual pages: $F"
4869echo " PID file: $G"
4870echo " Privilege separation chroot path: $H"
Darren Tuckere1a790d2003-09-16 11:52:19 +10004871if test "x$external_path_file" = "x/etc/login.conf" ; then
4872echo " At runtime, sshd will use the path defined in $external_path_file"
4873echo " Make sure the path to scp is present, otherwise scp will not work"
Tim Rice43a1c132002-04-17 21:19:14 -07004874else
Damien Millerf58c6722002-05-13 13:15:42 +10004875echo " sshd default user PATH: $I"
Tim Riceb925b4b2003-09-15 22:40:49 -07004876 if test ! -z "$external_path_file"; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10004877echo " (If PATH is set in $external_path_file it will be used instead. If"
4878echo " used, ensure the path to scp is present, otherwise scp will not work.)"
4879 fi
Tim Rice43a1c132002-04-17 21:19:14 -07004880fi
Damien Millera18bbd32002-05-13 10:48:57 +10004881if test ! -z "$superuser_path" ; then
Damien Millerf58c6722002-05-13 13:15:42 +10004882echo " sshd superuser user PATH: $J"
Damien Millera18bbd32002-05-13 10:48:57 +10004883fi
Damien Millerf58c6722002-05-13 13:15:42 +10004884echo " Manpage format: $MANTYPE"
Damien Miller7abe09b2003-05-15 10:53:49 +10004885echo " PAM support: $PAM_MSG"
Damien Miller1b06dc32006-08-31 03:24:41 +10004886echo " OSF SIA support: $SIA_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10004887echo " KerberosV support: $KRB5_MSG"
Damien Miller73b42d22006-04-22 21:26:08 +10004888echo " SELinux support: $SELINUX_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10004889echo " Smartcard support: $SCARD_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10004890echo " S/KEY support: $SKEY_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10004891echo " MD5 password support: $MD5_MSG"
Darren Tucker16bcc1c2004-11-07 20:14:34 +11004892echo " libedit support: $LIBEDIT_MSG"
Damien Miller1b06dc32006-08-31 03:24:41 +10004893echo " Solaris process contract support: $SPC_MSG"
Darren Tucker97528352010-11-05 12:03:05 +11004894echo " Solaris project support: $SP_MSG"
Damien Miller903e1152002-05-13 14:41:31 +10004895echo " IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10004896echo " Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG"
4897echo " BSD Auth support: $BSD_AUTH_MSG"
4898echo " Random number source: $RAND_MSG"
Damien Miller69ff1df2011-06-23 08:30:03 +10004899echo " Privsep sandbox style: $SANDBOX_STYLE"
Damien Miller60396b02001-02-18 17:01:00 +11004900
Damien Miller7b22d652000-06-18 14:07:04 +10004901echo ""
4902
Ben Lindstrom28bfc0d2000-12-18 19:58:57 +00004903echo " Host: ${host}"
4904echo " Compiler: ${CC}"
4905echo " Compiler flags: ${CFLAGS}"
4906echo "Preprocessor flags: ${CPPFLAGS}"
4907echo " Linker flags: ${LDFLAGS}"
Darren Tucker20e9f972007-03-25 18:26:01 +10004908echo " Libraries: ${LIBS}"
4909if test ! -z "${SSHDLIBS}"; then
4910echo " +for sshd: ${SSHDLIBS}"
4911fi
Damien Miller71adf122011-01-25 12:16:15 +11004912if test ! -z "${SSHLIBS}"; then
4913echo " +for ssh: ${SSHLIBS}"
4914fi
Damien Miller7b22d652000-06-18 14:07:04 +10004915
4916echo ""
4917
Tim Rice6f1f7582004-05-30 21:38:51 -07004918if test "x$MAKE_PACKAGE_SUPPORTED" = "xyes" ; then
Darren Tuckercf59d312004-08-29 21:18:09 +10004919 echo "SVR4 style packages are supported with \"make package\""
4920 echo ""
Tim Rice6f1f7582004-05-30 21:38:51 -07004921fi
4922
Damien Miller82cf0ce2000-12-20 13:34:48 +11004923if test "x$PAM_MSG" = "xyes" ; then
Damien Miller6c21c512002-01-22 21:57:53 +11004924 echo "PAM is enabled. You may need to install a PAM control file "
4925 echo "for sshd, otherwise password authentication may fail. "
Damien Millera8e06ce2003-11-21 23:48:55 +11004926 echo "Example PAM control files can be found in the contrib/ "
Damien Miller6c21c512002-01-22 21:57:53 +11004927 echo "subdirectory"
Damien Miller6f9c3372000-10-25 10:06:04 +11004928 echo ""
4929fi
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00004930
Damien Millerb4097182004-05-23 14:09:40 +10004931if test ! -z "$NO_PEERCHECK" ; then
Darren Tucker164aa302007-03-21 21:39:57 +11004932 echo "WARNING: the operating system that you are using does not"
4933 echo "appear to support getpeereid(), getpeerucred() or the"
4934 echo "SO_PEERCRED getsockopt() option. These facilities are used to"
4935 echo "enforce security checks to prevent unauthorised connections to"
4936 echo "ssh-agent. Their absence increases the risk that a malicious"
4937 echo "user can connect to your agent."
Damien Millerb4097182004-05-23 14:09:40 +10004938 echo ""
4939fi
4940
Darren Tuckerd9f88912005-02-20 21:01:48 +11004941if test "$AUDIT_MODULE" = "bsm" ; then
4942 echo "WARNING: BSM audit support is currently considered EXPERIMENTAL."
4943 echo "See the Solaris section in README.platform for details."
4944fi