blob: 2ef9db6d0cb06ee12ee38016b4943dce702aa37c [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 Tuckere50e8c92015-02-21 15:10:33 +11002200if test "x$ac_cv_func_getaddrinfo" = "xyes"; then
2201 AC_CHECK_DECLS(AI_NUMERICSERV, , ,
2202 [#include <sys/types.h>
2203 #include <sys/socket.h>
2204 #include <netdb.h>])
2205fi
2206
Darren Tuckera56f1912004-11-02 20:30:54 +11002207if test "x$check_for_conflicting_getspnam" = "x1"; then
Tim Rice648f8762011-01-26 12:38:57 -08002208 AC_MSG_CHECKING([for conflicting getspnam in shadow.h])
2209 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <shadow.h> ]],
2210 [[ exit(0); ]])],
Darren Tuckera56f1912004-11-02 20:30:54 +11002211 [
Tim Rice648f8762011-01-26 12:38:57 -08002212 AC_MSG_RESULT([no])
Darren Tuckera56f1912004-11-02 20:30:54 +11002213 ],
2214 [
Tim Rice648f8762011-01-26 12:38:57 -08002215 AC_MSG_RESULT([yes])
2216 AC_DEFINE([GETSPNAM_CONFLICTING_DEFS], [1],
Darren Tuckera56f1912004-11-02 20:30:54 +11002217 [Conflicting defs for getspnam])
2218 ]
2219 )
2220fi
2221
Damien Miller606f8802000-09-16 15:39:56 +11002222AC_FUNC_GETPGRP
2223
Tim Riceaef73712002-05-11 13:17:42 -07002224# Search for OpenSSL
2225saved_CPPFLAGS="$CPPFLAGS"
2226saved_LDFLAGS="$LDFLAGS"
Tim Rice648f8762011-01-26 12:38:57 -08002227AC_ARG_WITH([ssl-dir],
Damien Millera22ba012000-03-02 23:09:20 +11002228 [ --with-ssl-dir=PATH Specify path to OpenSSL installation ],
2229 [
Damien Miller72ef7c12015-01-15 02:21:31 +11002230 if test "x$openssl" = "xno" ; then
2231 AC_MSG_ERROR([cannot use --with-ssl-dir when OpenSSL disabled])
2232 fi
Ben Lindstrom23e13712000-10-29 22:49:19 +00002233 if test "x$withval" != "xno" ; then
Darren Tuckerc7e38d52005-02-09 22:12:30 +11002234 case "$withval" in
2235 # Relative paths
2236 ./*|../*) withval="`pwd`/$withval"
2237 esac
Tim Riceaef73712002-05-11 13:17:42 -07002238 if test -d "$withval/lib"; then
2239 if test -n "${need_dash_r}"; then
2240 LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
2241 else
2242 LDFLAGS="-L${withval}/lib ${LDFLAGS}"
2243 fi
Darren Tucker9f8703b2010-04-23 11:12:06 +10002244 elif test -d "$withval/lib64"; then
2245 if test -n "${need_dash_r}"; then
2246 LDFLAGS="-L${withval}/lib64 -R${withval}/lib64 ${LDFLAGS}"
2247 else
2248 LDFLAGS="-L${withval}/lib64 ${LDFLAGS}"
2249 fi
Tim Riceaef73712002-05-11 13:17:42 -07002250 else
2251 if test -n "${need_dash_r}"; then
2252 LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
2253 else
2254 LDFLAGS="-L${withval} ${LDFLAGS}"
2255 fi
2256 fi
2257 if test -d "$withval/include"; then
2258 CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
2259 else
2260 CPPFLAGS="-I${withval} ${CPPFLAGS}"
2261 fi
Damien Millera22ba012000-03-02 23:09:20 +11002262 fi
2263 ]
2264)
Damien Millerb9c56672014-05-15 14:43:37 +10002265
Tim Rice648f8762011-01-26 12:38:57 -08002266AC_ARG_WITH([openssl-header-check],
Damien Miller9975e482007-03-05 11:51:27 +11002267 [ --without-openssl-header-check Disable OpenSSL version consistency check],
Damien Millerec932372002-01-22 22:16:03 +11002268 [
Damien Miller72ef7c12015-01-15 02:21:31 +11002269 if test "x$withval" = "xno" ; then
2270 openssl_check_nonfatal=1
Damien Miller9975e482007-03-05 11:51:27 +11002271 fi
Damien Millerec932372002-01-22 22:16:03 +11002272 ]
2273)
2274
Damien Miller72ef7c12015-01-15 02:21:31 +11002275openssl_engine=no
Tim Rice648f8762011-01-26 12:38:57 -08002276AC_ARG_WITH([ssl-engine],
Darren Tuckerfabdb6c2006-02-20 20:17:35 +11002277 [ --with-ssl-engine Enable OpenSSL (hardware) ENGINE support ],
Damien Miller72ef7c12015-01-15 02:21:31 +11002278 [
2279 if test "x$openssl" = "xno" ; then
2280 AC_MSG_ERROR([cannot use --with-ssl-engine when OpenSSL disabled])
2281 fi
2282 if test "x$withval" != "xno" ; then
2283 openssl_engine=yes
2284 fi
2285 ]
2286)
2287
2288if test "x$openssl" = "xyes" ; then
2289 LIBS="-lcrypto $LIBS"
2290 AC_TRY_LINK_FUNC([RAND_add], [AC_DEFINE([HAVE_OPENSSL], [1],
2291 [Define if your ssl headers are included
2292 with #include <openssl/header.h>])],
2293 [
2294 dnl Check default openssl install dir
2295 if test -n "${need_dash_r}"; then
2296 LDFLAGS="-L/usr/local/ssl/lib -R/usr/local/ssl/lib ${saved_LDFLAGS}"
2297 else
2298 LDFLAGS="-L/usr/local/ssl/lib ${saved_LDFLAGS}"
2299 fi
2300 CPPFLAGS="-I/usr/local/ssl/include ${saved_CPPFLAGS}"
2301 AC_CHECK_HEADER([openssl/opensslv.h], ,
2302 [AC_MSG_ERROR([*** OpenSSL headers missing - please install first or check config.log ***])])
2303 AC_TRY_LINK_FUNC([RAND_add], [AC_DEFINE([HAVE_OPENSSL])],
2304 [
2305 AC_MSG_ERROR([*** Can't find recent OpenSSL libcrypto (see config.log for details) ***])
2306 ]
2307 )
2308 ]
2309 )
2310
2311 # Determine OpenSSL header version
2312 AC_MSG_CHECKING([OpenSSL header version])
2313 AC_RUN_IFELSE(
2314 [AC_LANG_PROGRAM([[
2315 #include <stdio.h>
2316 #include <string.h>
2317 #include <openssl/opensslv.h>
2318 #define DATA "conftest.sslincver"
2319 ]], [[
2320 FILE *fd;
2321 int rc;
2322
2323 fd = fopen(DATA,"w");
2324 if(fd == NULL)
2325 exit(1);
2326
2327 if ((rc = fprintf(fd ,"%08x (%s)\n", OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_TEXT)) <0)
2328 exit(1);
2329
2330 exit(0);
2331 ]])],
2332 [
2333 ssl_header_ver=`cat conftest.sslincver`
2334 AC_MSG_RESULT([$ssl_header_ver])
2335 ],
2336 [
2337 AC_MSG_RESULT([not found])
2338 AC_MSG_ERROR([OpenSSL version header not found.])
2339 ],
2340 [
2341 AC_MSG_WARN([cross compiling: not checking])
2342 ]
2343 )
2344
2345 # Determine OpenSSL library version
2346 AC_MSG_CHECKING([OpenSSL library version])
2347 AC_RUN_IFELSE(
2348 [AC_LANG_PROGRAM([[
2349 #include <stdio.h>
2350 #include <string.h>
2351 #include <openssl/opensslv.h>
2352 #include <openssl/crypto.h>
2353 #define DATA "conftest.ssllibver"
2354 ]], [[
2355 FILE *fd;
2356 int rc;
2357
2358 fd = fopen(DATA,"w");
2359 if(fd == NULL)
2360 exit(1);
2361
2362 if ((rc = fprintf(fd ,"%08x (%s)\n", SSLeay(),
2363 SSLeay_version(SSLEAY_VERSION))) <0)
2364 exit(1);
2365
2366 exit(0);
2367 ]])],
2368 [
2369 ssl_library_ver=`cat conftest.ssllibver`
2370 # Check version is supported.
2371 case "$ssl_library_ver" in
2372 0090[[0-7]]*|009080[[0-5]]*)
2373 AC_MSG_ERROR([OpenSSL >= 0.9.8f required (have "$ssl_library_ver")])
2374 ;;
2375 *) ;;
2376 esac
2377 AC_MSG_RESULT([$ssl_library_ver])
2378 ],
2379 [
2380 AC_MSG_RESULT([not found])
2381 AC_MSG_ERROR([OpenSSL library not found.])
2382 ],
2383 [
2384 AC_MSG_WARN([cross compiling: not checking])
2385 ]
2386 )
2387
2388 # Sanity check OpenSSL headers
2389 AC_MSG_CHECKING([whether OpenSSL's headers match the library])
2390 AC_RUN_IFELSE(
2391 [AC_LANG_PROGRAM([[
2392 #include <string.h>
2393 #include <openssl/opensslv.h>
2394 ]], [[
2395 exit(SSLeay() == OPENSSL_VERSION_NUMBER ? 0 : 1);
2396 ]])],
2397 [
2398 AC_MSG_RESULT([yes])
2399 ],
2400 [
2401 AC_MSG_RESULT([no])
2402 if test "x$openssl_check_nonfatal" = "x"; then
2403 AC_MSG_ERROR([Your OpenSSL headers do not match your
2404 library. Check config.log for details.
2405 If you are sure your installation is consistent, you can disable the check
2406 by running "./configure --without-openssl-header-check".
2407 Also see contrib/findssl.sh for help identifying header/library mismatches.
2408 ])
2409 else
2410 AC_MSG_WARN([Your OpenSSL headers do not match your
2411 library. Check config.log for details.
2412 Also see contrib/findssl.sh for help identifying header/library mismatches.])
2413 fi
2414 ],
2415 [
2416 AC_MSG_WARN([cross compiling: not checking])
2417 ]
2418 )
2419
2420 AC_MSG_CHECKING([if programs using OpenSSL functions will link])
2421 AC_LINK_IFELSE(
2422 [AC_LANG_PROGRAM([[ #include <openssl/evp.h> ]],
2423 [[ SSLeay_add_all_algorithms(); ]])],
2424 [
2425 AC_MSG_RESULT([yes])
2426 ],
2427 [
2428 AC_MSG_RESULT([no])
2429 saved_LIBS="$LIBS"
2430 LIBS="$LIBS -ldl"
2431 AC_MSG_CHECKING([if programs using OpenSSL need -ldl])
2432 AC_LINK_IFELSE(
2433 [AC_LANG_PROGRAM([[ #include <openssl/evp.h> ]],
2434 [[ SSLeay_add_all_algorithms(); ]])],
2435 [
2436 AC_MSG_RESULT([yes])
2437 ],
2438 [
2439 AC_MSG_RESULT([no])
2440 LIBS="$saved_LIBS"
2441 ]
2442 )
2443 ]
2444 )
2445
2446 AC_CHECK_FUNCS([ \
2447 BN_is_prime_ex \
2448 DSA_generate_parameters_ex \
2449 EVP_DigestInit_ex \
2450 EVP_DigestFinal_ex \
2451 EVP_MD_CTX_init \
2452 EVP_MD_CTX_cleanup \
2453 EVP_MD_CTX_copy_ex \
2454 HMAC_CTX_init \
2455 RSA_generate_key_ex \
2456 RSA_get_default_method \
2457 ])
2458
2459 if test "x$openssl_engine" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08002460 AC_MSG_CHECKING([for OpenSSL ENGINE support])
2461 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller72ef7c12015-01-15 02:21:31 +11002462 #include <openssl/engine.h>
Tim Rice648f8762011-01-26 12:38:57 -08002463 ]], [[
Damien Miller72ef7c12015-01-15 02:21:31 +11002464 ENGINE_load_builtin_engines();
2465 ENGINE_register_all_complete();
Tim Rice648f8762011-01-26 12:38:57 -08002466 ]])],
2467 [ AC_MSG_RESULT([yes])
2468 AC_DEFINE([USE_OPENSSL_ENGINE], [1],
Darren Tuckerfabdb6c2006-02-20 20:17:35 +11002469 [Enable OpenSSL engine support])
Tim Rice648f8762011-01-26 12:38:57 -08002470 ], [ AC_MSG_ERROR([OpenSSL ENGINE support not found])
2471 ])
Damien Miller72ef7c12015-01-15 02:21:31 +11002472 fi
Darren Tuckerfabdb6c2006-02-20 20:17:35 +11002473
Damien Miller72ef7c12015-01-15 02:21:31 +11002474 # Check for OpenSSL without EVP_aes_{192,256}_cbc
2475 AC_MSG_CHECKING([whether OpenSSL has crippled AES support])
2476 AC_LINK_IFELSE(
Darren Tucker37bcef52013-11-09 18:39:25 +11002477 [AC_LANG_PROGRAM([[
Damien Miller72ef7c12015-01-15 02:21:31 +11002478 #include <string.h>
2479 #include <openssl/evp.h>
2480 ]], [[
2481 exit(EVP_aes_192_cbc() == NULL || EVP_aes_256_cbc() == NULL);
2482 ]])],
2483 [
2484 AC_MSG_RESULT([no])
2485 ],
2486 [
2487 AC_MSG_RESULT([yes])
2488 AC_DEFINE([OPENSSL_LOBOTOMISED_AES], [1],
2489 [libcrypto is missing AES 192 and 256 bit functions])
2490 ]
2491 )
2492
2493 # Check for OpenSSL with EVP_aes_*ctr
2494 AC_MSG_CHECKING([whether OpenSSL has AES CTR via EVP])
2495 AC_LINK_IFELSE(
2496 [AC_LANG_PROGRAM([[
2497 #include <string.h>
2498 #include <openssl/evp.h>
2499 ]], [[
2500 exit(EVP_aes_128_ctr() == NULL ||
2501 EVP_aes_192_cbc() == NULL ||
2502 EVP_aes_256_cbc() == NULL);
2503 ]])],
2504 [
2505 AC_MSG_RESULT([yes])
2506 AC_DEFINE([OPENSSL_HAVE_EVPCTR], [1],
2507 [libcrypto has EVP AES CTR])
2508 ],
2509 [
2510 AC_MSG_RESULT([no])
2511 ]
2512 )
2513
2514 # Check for OpenSSL with EVP_aes_*gcm
2515 AC_MSG_CHECKING([whether OpenSSL has AES GCM via EVP])
2516 AC_LINK_IFELSE(
2517 [AC_LANG_PROGRAM([[
2518 #include <string.h>
2519 #include <openssl/evp.h>
2520 ]], [[
2521 exit(EVP_aes_128_gcm() == NULL ||
2522 EVP_aes_256_gcm() == NULL ||
2523 EVP_CTRL_GCM_SET_IV_FIXED == 0 ||
2524 EVP_CTRL_GCM_IV_GEN == 0 ||
2525 EVP_CTRL_GCM_SET_TAG == 0 ||
2526 EVP_CTRL_GCM_GET_TAG == 0 ||
2527 EVP_CIPHER_CTX_ctrl(NULL, 0, 0, NULL) == 0);
2528 ]])],
2529 [
2530 AC_MSG_RESULT([yes])
2531 AC_DEFINE([OPENSSL_HAVE_EVPGCM], [1],
2532 [libcrypto has EVP AES GCM])
2533 ],
2534 [
2535 AC_MSG_RESULT([no])
2536 unsupported_algorithms="$unsupported_cipers \
2537 aes128-gcm@openssh.com aes256-gcm@openssh.com"
2538 ]
2539 )
2540
2541 AC_SEARCH_LIBS([EVP_CIPHER_CTX_ctrl], [crypto],
2542 [AC_DEFINE([HAVE_EVP_CIPHER_CTX_CTRL], [1],
2543 [Define if libcrypto has EVP_CIPHER_CTX_ctrl])])
2544
2545 AC_MSG_CHECKING([if EVP_DigestUpdate returns an int])
2546 AC_LINK_IFELSE(
2547 [AC_LANG_PROGRAM([[
2548 #include <string.h>
2549 #include <openssl/evp.h>
2550 ]], [[
2551 if(EVP_DigestUpdate(NULL, NULL,0))
2552 exit(0);
2553 ]])],
2554 [
2555 AC_MSG_RESULT([yes])
2556 ],
2557 [
2558 AC_MSG_RESULT([no])
2559 AC_DEFINE([OPENSSL_EVP_DIGESTUPDATE_VOID], [1],
2560 [Define if EVP_DigestUpdate returns void])
2561 ]
2562 )
2563
2564 # Some systems want crypt() from libcrypt, *not* the version in OpenSSL,
2565 # because the system crypt() is more featureful.
2566 if test "x$check_for_libcrypt_before" = "x1"; then
2567 AC_CHECK_LIB([crypt], [crypt])
2568 fi
2569
2570 # Some Linux systems (Slackware) need crypt() from libcrypt, *not* the
2571 # version in OpenSSL.
2572 if test "x$check_for_libcrypt_later" = "x1"; then
2573 AC_CHECK_LIB([crypt], [crypt], [LIBS="$LIBS -lcrypt"])
2574 fi
2575
2576 # Search for SHA256 support in libc and/or OpenSSL
2577 AC_CHECK_FUNCS([SHA256_Update EVP_sha256], ,
2578 [unsupported_algorithms="$unsupported_algorithms \
2579 hmac-sha2-256 hmac-sha2-512 \
2580 diffie-hellman-group-exchange-sha256 \
2581 hmac-sha2-256-etm@openssh.com hmac-sha2-512-etm@openssh.com"
2582 ]
2583 )
2584 # Search for RIPE-MD support in OpenSSL
2585 AC_CHECK_FUNCS([EVP_ripemd160], ,
2586 [unsupported_algorithms="$unsupported_algorithms \
2587 hmac-ripemd160
2588 hmac-ripemd160@openssh.com
2589 hmac-ripemd160-etm@openssh.com"
2590 ]
2591 )
2592
2593 # Check complete ECC support in OpenSSL
2594 AC_MSG_CHECKING([whether OpenSSL has NID_X9_62_prime256v1])
2595 AC_LINK_IFELSE(
2596 [AC_LANG_PROGRAM([[
2597 #include <openssl/ec.h>
2598 #include <openssl/ecdh.h>
2599 #include <openssl/ecdsa.h>
2600 #include <openssl/evp.h>
2601 #include <openssl/objects.h>
2602 #include <openssl/opensslv.h>
2603 #if OPENSSL_VERSION_NUMBER < 0x0090807f /* 0.9.8g */
2604 # error "OpenSSL < 0.9.8g has unreliable ECC code"
2605 #endif
2606 ]], [[
2607 EC_KEY *e = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
2608 const EVP_MD *m = EVP_sha256(); /* We need this too */
Darren Tucker37bcef52013-11-09 18:39:25 +11002609 ]])],
2610 [ AC_MSG_RESULT([yes])
Damien Miller72ef7c12015-01-15 02:21:31 +11002611 enable_nistp256=1 ],
2612 [ AC_MSG_RESULT([no]) ]
2613 )
Darren Tucker37bcef52013-11-09 18:39:25 +11002614
Damien Miller72ef7c12015-01-15 02:21:31 +11002615 AC_MSG_CHECKING([whether OpenSSL has NID_secp384r1])
2616 AC_LINK_IFELSE(
2617 [AC_LANG_PROGRAM([[
2618 #include <openssl/ec.h>
2619 #include <openssl/ecdh.h>
2620 #include <openssl/ecdsa.h>
2621 #include <openssl/evp.h>
2622 #include <openssl/objects.h>
2623 #include <openssl/opensslv.h>
2624 #if OPENSSL_VERSION_NUMBER < 0x0090807f /* 0.9.8g */
2625 # error "OpenSSL < 0.9.8g has unreliable ECC code"
2626 #endif
2627 ]], [[
2628 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp384r1);
2629 const EVP_MD *m = EVP_sha384(); /* We need this too */
2630 ]])],
2631 [ AC_MSG_RESULT([yes])
2632 enable_nistp384=1 ],
2633 [ AC_MSG_RESULT([no]) ]
2634 )
Darren Tucker37bcef52013-11-09 18:39:25 +11002635
Damien Miller72ef7c12015-01-15 02:21:31 +11002636 AC_MSG_CHECKING([whether OpenSSL has NID_secp521r1])
2637 AC_LINK_IFELSE(
2638 [AC_LANG_PROGRAM([[
2639 #include <openssl/ec.h>
2640 #include <openssl/ecdh.h>
2641 #include <openssl/ecdsa.h>
2642 #include <openssl/evp.h>
2643 #include <openssl/objects.h>
2644 #include <openssl/opensslv.h>
2645 #if OPENSSL_VERSION_NUMBER < 0x0090807f /* 0.9.8g */
2646 # error "OpenSSL < 0.9.8g has unreliable ECC code"
2647 #endif
2648 ]], [[
2649 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1);
2650 const EVP_MD *m = EVP_sha512(); /* We need this too */
2651 ]])],
2652 [ AC_MSG_RESULT([yes])
2653 AC_MSG_CHECKING([if OpenSSL's NID_secp521r1 is functional])
2654 AC_RUN_IFELSE(
2655 [AC_LANG_PROGRAM([[
2656 #include <openssl/ec.h>
2657 #include <openssl/ecdh.h>
2658 #include <openssl/ecdsa.h>
2659 #include <openssl/evp.h>
2660 #include <openssl/objects.h>
2661 #include <openssl/opensslv.h>
2662 ]],[[
2663 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1);
2664 const EVP_MD *m = EVP_sha512(); /* We need this too */
2665 exit(e == NULL || m == NULL);
2666 ]])],
2667 [ AC_MSG_RESULT([yes])
2668 enable_nistp521=1 ],
2669 [ AC_MSG_RESULT([no]) ],
2670 [ AC_MSG_WARN([cross-compiling: assuming yes])
2671 enable_nistp521=1 ]
2672 )],
2673 AC_MSG_RESULT([no])
2674 )
Darren Tucker37bcef52013-11-09 18:39:25 +11002675
Damien Miller72ef7c12015-01-15 02:21:31 +11002676 COMMENT_OUT_ECC="#no ecc#"
2677 TEST_SSH_ECC=no
2678
2679 if test x$enable_nistp256 = x1 || test x$enable_nistp384 = x1 || \
2680 test x$enable_nistp521 = x1; then
2681 AC_DEFINE(OPENSSL_HAS_ECC, [1], [OpenSSL has ECC])
2682 fi
2683 if test x$enable_nistp256 = x1; then
2684 AC_DEFINE([OPENSSL_HAS_NISTP256], [1],
2685 [libcrypto has NID_X9_62_prime256v1])
2686 TEST_SSH_ECC=yes
2687 COMMENT_OUT_ECC=""
2688 else
2689 unsupported_algorithms="$unsupported_algorithms ecdsa-sha2-nistp256 \
2690 ecdh-sha2-nistp256 ecdsa-sha2-nistp256-cert-v01@openssh.com"
2691 fi
2692 if test x$enable_nistp384 = x1; then
2693 AC_DEFINE([OPENSSL_HAS_NISTP384], [1], [libcrypto has NID_secp384r1])
2694 TEST_SSH_ECC=yes
2695 COMMENT_OUT_ECC=""
2696 else
2697 unsupported_algorithms="$unsupported_algorithms ecdsa-sha2-nistp384 \
2698 ecdh-sha2-nistp384 ecdsa-sha2-nistp384-cert-v01@openssh.com"
2699 fi
2700 if test x$enable_nistp521 = x1; then
2701 AC_DEFINE([OPENSSL_HAS_NISTP521], [1], [libcrypto has NID_secp521r1])
2702 TEST_SSH_ECC=yes
2703 COMMENT_OUT_ECC=""
2704 else
2705 unsupported_algorithms="$unsupported_algorithms ecdh-sha2-nistp521 \
2706 ecdsa-sha2-nistp521 ecdsa-sha2-nistp521-cert-v01@openssh.com"
2707 fi
2708
2709 AC_SUBST([TEST_SSH_ECC])
2710 AC_SUBST([COMMENT_OUT_ECC])
2711else
2712 AC_CHECK_LIB([crypt], [crypt], [LIBS="$LIBS -lcrypt"])
2713 AC_CHECK_FUNCS([crypt DES_crypt])
2714fi
Damien Miller6af914a2010-09-10 11:39:26 +10002715
Damien Miller00f9cd22014-07-15 10:41:38 +10002716AC_CHECK_FUNCS([ \
2717 arc4random \
2718 arc4random_buf \
2719 arc4random_stir \
2720 arc4random_uniform \
2721])
2722
Tim Rice99203ec2007-03-26 09:35:28 -07002723saved_LIBS="$LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08002724AC_CHECK_LIB([iaf], [ia_openinfo], [
Tim Rice99203ec2007-03-26 09:35:28 -07002725 LIBS="$LIBS -liaf"
Tim Rice648f8762011-01-26 12:38:57 -08002726 AC_CHECK_FUNCS([set_id], [SSHDLIBS="$SSHDLIBS -liaf"
2727 AC_DEFINE([HAVE_LIBIAF], [1],
Tim Rice0eeaf122007-09-10 16:24:17 -07002728 [Define if system has libiaf that supports set_id])
2729 ])
Tim Rice99203ec2007-03-26 09:35:28 -07002730])
2731LIBS="$saved_LIBS"
Damien Miller6c21c512002-01-22 21:57:53 +11002732
2733### Configure cryptographic random number support
2734
2735# Check wheter OpenSSL seeds itself
Damien Miller72ef7c12015-01-15 02:21:31 +11002736if test "x$openssl" = "xyes" ; then
2737 AC_MSG_CHECKING([whether OpenSSL's PRNG is internally seeded])
2738 AC_RUN_IFELSE(
2739 [AC_LANG_PROGRAM([[
2740 #include <string.h>
2741 #include <openssl/rand.h>
2742 ]], [[
2743 exit(RAND_status() == 1 ? 0 : 1);
2744 ]])],
2745 [
2746 OPENSSL_SEEDS_ITSELF=yes
2747 AC_MSG_RESULT([yes])
2748 ],
2749 [
2750 AC_MSG_RESULT([no])
2751 ],
2752 [
2753 AC_MSG_WARN([cross compiling: assuming yes])
2754 # This is safe, since we will fatal() at runtime if
2755 # OpenSSL is not seeded correctly.
2756 OPENSSL_SEEDS_ITSELF=yes
2757 ]
2758 )
2759fi
Damien Miller6c21c512002-01-22 21:57:53 +11002760
Damien Millerf22019b2011-05-05 13:48:37 +10002761# PRNGD TCP socket
2762AC_ARG_WITH([prngd-port],
2763 [ --with-prngd-port=PORT read entropy from PRNGD/EGD TCP localhost:PORT],
2764 [
2765 case "$withval" in
2766 no)
2767 withval=""
2768 ;;
2769 [[0-9]]*)
2770 ;;
2771 *)
2772 AC_MSG_ERROR([You must specify a numeric port number for --with-prngd-port])
2773 ;;
2774 esac
2775 if test ! -z "$withval" ; then
2776 PRNGD_PORT="$withval"
2777 AC_DEFINE_UNQUOTED([PRNGD_PORT], [$PRNGD_PORT],
2778 [Port number of PRNGD/EGD random number socket])
2779 fi
2780 ]
2781)
2782
2783# PRNGD Unix domain socket
2784AC_ARG_WITH([prngd-socket],
2785 [ --with-prngd-socket=FILE read entropy from PRNGD/EGD socket FILE (default=/var/run/egd-pool)],
2786 [
2787 case "$withval" in
2788 yes)
2789 withval="/var/run/egd-pool"
2790 ;;
2791 no)
2792 withval=""
2793 ;;
2794 /*)
2795 ;;
2796 *)
2797 AC_MSG_ERROR([You must specify an absolute path to the entropy socket])
2798 ;;
2799 esac
2800
2801 if test ! -z "$withval" ; then
2802 if test ! -z "$PRNGD_PORT" ; then
2803 AC_MSG_ERROR([You may not specify both a PRNGD/EGD port and socket])
2804 fi
2805 if test ! -r "$withval" ; then
2806 AC_MSG_WARN([Entropy socket is not readable])
2807 fi
2808 PRNGD_SOCKET="$withval"
2809 AC_DEFINE_UNQUOTED([PRNGD_SOCKET], ["$PRNGD_SOCKET"],
2810 [Location of PRNGD/EGD random number socket])
2811 fi
2812 ],
2813 [
2814 # Check for existing socket only if we don't have a random device already
2815 if test "x$OPENSSL_SEEDS_ITSELF" != "xyes" ; then
2816 AC_MSG_CHECKING([for PRNGD/EGD socket])
2817 # Insert other locations here
2818 for sock in /var/run/egd-pool /dev/egd-pool /etc/entropy; do
2819 if test -r $sock && $TEST_MINUS_S_SH -c "test -S $sock -o -p $sock" ; then
2820 PRNGD_SOCKET="$sock"
2821 AC_DEFINE_UNQUOTED([PRNGD_SOCKET], ["$PRNGD_SOCKET"])
2822 break;
2823 fi
2824 done
2825 if test ! -z "$PRNGD_SOCKET" ; then
2826 AC_MSG_RESULT([$PRNGD_SOCKET])
2827 else
2828 AC_MSG_RESULT([not found])
2829 fi
2830 fi
2831 ]
2832)
2833
2834# Which randomness source do we use?
2835if test ! -z "$PRNGD_PORT" ; then
2836 RAND_MSG="PRNGd port $PRNGD_PORT"
2837elif test ! -z "$PRNGD_SOCKET" ; then
2838 RAND_MSG="PRNGd socket $PRNGD_SOCKET"
2839elif test ! -z "$OPENSSL_SEEDS_ITSELF" ; then
2840 AC_DEFINE([OPENSSL_PRNG_ONLY], [1],
Damien Miller72ef7c12015-01-15 02:21:31 +11002841 [Define if you want the OpenSSL internally seeded PRNG only])
Damien Millerf22019b2011-05-05 13:48:37 +10002842 RAND_MSG="OpenSSL internal ONLY"
Damien Miller72ef7c12015-01-15 02:21:31 +11002843elif test "x$openssl" = "xno" ; then
2844 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 +10002845else
2846 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])
2847fi
2848
Darren Tucker3e6bde42006-08-20 20:03:50 +10002849# Check for PAM libs
2850PAM_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08002851AC_ARG_WITH([pam],
Darren Tucker3e6bde42006-08-20 20:03:50 +10002852 [ --with-pam Enable PAM support ],
2853 [
2854 if test "x$withval" != "xno" ; then
2855 if test "x$ac_cv_header_security_pam_appl_h" != "xyes" && \
2856 test "x$ac_cv_header_pam_pam_appl_h" != "xyes" ; then
2857 AC_MSG_ERROR([PAM headers not found])
2858 fi
2859
2860 saved_LIBS="$LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08002861 AC_CHECK_LIB([dl], [dlopen], , )
2862 AC_CHECK_LIB([pam], [pam_set_item], , [AC_MSG_ERROR([*** libpam missing])])
2863 AC_CHECK_FUNCS([pam_getenvlist])
2864 AC_CHECK_FUNCS([pam_putenv])
Darren Tucker3e6bde42006-08-20 20:03:50 +10002865 LIBS="$saved_LIBS"
2866
2867 PAM_MSG="yes"
2868
Darren Tucker20e9f972007-03-25 18:26:01 +10002869 SSHDLIBS="$SSHDLIBS -lpam"
Tim Rice648f8762011-01-26 12:38:57 -08002870 AC_DEFINE([USE_PAM], [1],
Darren Tucker3e6bde42006-08-20 20:03:50 +10002871 [Define if you want to enable PAM support])
Darren Tucker639bbe82006-08-20 20:17:53 +10002872
Darren Tucker3e6bde42006-08-20 20:03:50 +10002873 if test $ac_cv_lib_dl_dlopen = yes; then
Darren Tucker639bbe82006-08-20 20:17:53 +10002874 case "$LIBS" in
2875 *-ldl*)
2876 # libdl already in LIBS
2877 ;;
2878 *)
Darren Tucker20e9f972007-03-25 18:26:01 +10002879 SSHDLIBS="$SSHDLIBS -ldl"
Darren Tucker639bbe82006-08-20 20:17:53 +10002880 ;;
2881 esac
Darren Tucker3e6bde42006-08-20 20:03:50 +10002882 fi
Darren Tucker3e6bde42006-08-20 20:03:50 +10002883 fi
2884 ]
2885)
2886
2887# Check for older PAM
2888if test "x$PAM_MSG" = "xyes" ; then
2889 # Check PAM strerror arguments (old PAM)
2890 AC_MSG_CHECKING([whether pam_strerror takes only one argument])
Tim Rice648f8762011-01-26 12:38:57 -08002891 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker3e6bde42006-08-20 20:03:50 +10002892#include <stdlib.h>
2893#if defined(HAVE_SECURITY_PAM_APPL_H)
2894#include <security/pam_appl.h>
2895#elif defined (HAVE_PAM_PAM_APPL_H)
2896#include <pam/pam_appl.h>
2897#endif
Tim Rice648f8762011-01-26 12:38:57 -08002898 ]], [[
2899(void)pam_strerror((pam_handle_t *)NULL, -1);
2900 ]])], [AC_MSG_RESULT([no])], [
2901 AC_DEFINE([HAVE_OLD_PAM], [1],
Darren Tucker3e6bde42006-08-20 20:03:50 +10002902 [Define if you have an old version of PAM
2903 which takes only one argument to pam_strerror])
Tim Rice648f8762011-01-26 12:38:57 -08002904 AC_MSG_RESULT([yes])
Darren Tucker3e6bde42006-08-20 20:03:50 +10002905 PAM_MSG="yes (old library)"
Damien Miller72ef7c12015-01-15 02:21:31 +11002906
Tim Rice648f8762011-01-26 12:38:57 -08002907 ])
Darren Tucker3e6bde42006-08-20 20:03:50 +10002908fi
Damien Miller6c21c512002-01-22 21:57:53 +11002909
Damien Miller6482d902014-05-27 14:34:42 +10002910case "$host" in
2911*-*-cygwin*)
2912 SSH_PRIVSEP_USER=CYGWIN_SSH_PRIVSEP_USER
2913 ;;
2914*)
2915 SSH_PRIVSEP_USER=sshd
2916 ;;
2917esac
Tim Rice648f8762011-01-26 12:38:57 -08002918AC_ARG_WITH([privsep-user],
Kevin Stevesc81e1292002-05-13 03:51:40 +00002919 [ --with-privsep-user=user Specify non-privileged user for privilege separation],
Kevin Steves7ff91122002-04-07 19:22:54 +00002920 [
Tim Rice35cc69d2005-03-17 16:44:25 -08002921 if test -n "$withval" && test "x$withval" != "xno" && \
2922 test "x${withval}" != "xyes"; then
Damien Millerd3f6ad22002-06-25 10:24:47 +10002923 SSH_PRIVSEP_USER=$withval
Kevin Steves7ff91122002-04-07 19:22:54 +00002924 fi
Tim Riceeae17cc2005-03-17 16:52:20 -08002925 ]
Kevin Steves7ff91122002-04-07 19:22:54 +00002926)
Damien Miller6482d902014-05-27 14:34:42 +10002927if test "x$SSH_PRIVSEP_USER" = "xCYGWIN_SSH_PRIVSEP_USER" ; then
2928 AC_DEFINE_UNQUOTED([SSH_PRIVSEP_USER], [CYGWIN_SSH_PRIVSEP_USER],
2929 [Cygwin function to fetch non-privileged user for privilege separation])
2930else
2931 AC_DEFINE_UNQUOTED([SSH_PRIVSEP_USER], ["$SSH_PRIVSEP_USER"],
2932 [non-privileged user for privilege separation])
2933fi
Tim Rice648f8762011-01-26 12:38:57 -08002934AC_SUBST([SSH_PRIVSEP_USER])
Kevin Steves7ff91122002-04-07 19:22:54 +00002935
Damien Miller91f40d82013-02-22 11:37:00 +11002936if test "x$have_linux_no_new_privs" = "x1" ; then
2937AC_CHECK_DECL([SECCOMP_MODE_FILTER], [have_seccomp_filter=1], , [
2938 #include <sys/types.h>
2939 #include <linux/seccomp.h>
2940])
2941fi
2942if test "x$have_seccomp_filter" = "x1" ; then
2943AC_MSG_CHECKING([kernel for seccomp_filter support])
2944AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2945 #include <errno.h>
2946 #include <elf.h>
2947 #include <linux/audit.h>
2948 #include <linux/seccomp.h>
2949 #include <stdlib.h>
2950 #include <sys/prctl.h>
2951 ]],
2952 [[ int i = $seccomp_audit_arch;
2953 errno = 0;
2954 prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, NULL, 0, 0);
2955 exit(errno == EFAULT ? 0 : 1); ]])],
2956 [ AC_MSG_RESULT([yes]) ], [
2957 AC_MSG_RESULT([no])
2958 # Disable seccomp filter as a target
2959 have_seccomp_filter=0
2960 ]
2961)
2962fi
2963
Damien Miller69ff1df2011-06-23 08:30:03 +10002964# Decide which sandbox style to use
2965sandbox_arg=""
2966AC_ARG_WITH([sandbox],
Damien Miller868ea1e2014-01-17 16:47:04 +11002967 [ --with-sandbox=style Specify privilege separation sandbox (no, darwin, rlimit, systrace, seccomp_filter, capsicum)],
Damien Miller69ff1df2011-06-23 08:30:03 +10002968 [
2969 if test "x$withval" = "xyes" ; then
2970 sandbox_arg=""
2971 else
2972 sandbox_arg="$withval"
2973 fi
2974 ]
2975)
Darren Tucker60395f92012-07-03 14:31:18 +10002976
2977# Some platforms (seems to be the ones that have a kernel poll(2)-type
2978# function with which they implement select(2)) use an extra file descriptor
2979# when calling select(2), which means we can't use the rlimit sandbox.
2980AC_MSG_CHECKING([if select works with descriptor rlimit])
2981AC_RUN_IFELSE(
2982 [AC_LANG_PROGRAM([[
2983#include <sys/types.h>
2984#ifdef HAVE_SYS_TIME_H
2985# include <sys/time.h>
2986#endif
2987#include <sys/resource.h>
2988#ifdef HAVE_SYS_SELECT_H
2989# include <sys/select.h>
2990#endif
2991#include <errno.h>
2992#include <fcntl.h>
2993#include <stdlib.h>
2994 ]],[[
2995 struct rlimit rl_zero;
2996 int fd, r;
2997 fd_set fds;
Damien Millere4f43472013-03-08 12:14:22 +11002998 struct timeval tv;
Darren Tucker60395f92012-07-03 14:31:18 +10002999
3000 fd = open("/dev/null", O_RDONLY);
3001 FD_ZERO(&fds);
3002 FD_SET(fd, &fds);
3003 rl_zero.rlim_cur = rl_zero.rlim_max = 0;
3004 setrlimit(RLIMIT_FSIZE, &rl_zero);
3005 setrlimit(RLIMIT_NOFILE, &rl_zero);
Damien Millere4f43472013-03-08 12:14:22 +11003006 tv.tv_sec = 1;
3007 tv.tv_usec = 0;
3008 r = select(fd+1, &fds, NULL, NULL, &tv);
Darren Tucker60395f92012-07-03 14:31:18 +10003009 exit (r == -1 ? 1 : 0);
3010 ]])],
3011 [AC_MSG_RESULT([yes])
3012 select_works_with_rlimit=yes],
3013 [AC_MSG_RESULT([no])
3014 select_works_with_rlimit=no],
3015 [AC_MSG_WARN([cross compiling: assuming yes])]
3016)
3017
Darren Tuckerff008de2013-03-06 17:48:48 +11003018AC_MSG_CHECKING([if setrlimit(RLIMIT_NOFILE,{0,0}) works])
3019AC_RUN_IFELSE(
3020 [AC_LANG_PROGRAM([[
3021#include <sys/types.h>
3022#ifdef HAVE_SYS_TIME_H
3023# include <sys/time.h>
3024#endif
3025#include <sys/resource.h>
3026#include <errno.h>
3027#include <stdlib.h>
3028 ]],[[
3029 struct rlimit rl_zero;
3030 int fd, r;
3031 fd_set fds;
3032
3033 rl_zero.rlim_cur = rl_zero.rlim_max = 0;
3034 r = setrlimit(RLIMIT_NOFILE, &rl_zero);
3035 exit (r == -1 ? 1 : 0);
3036 ]])],
3037 [AC_MSG_RESULT([yes])
3038 rlimit_nofile_zero_works=yes],
3039 [AC_MSG_RESULT([no])
3040 rlimit_nofile_zero_works=no],
3041 [AC_MSG_WARN([cross compiling: assuming yes])]
3042)
3043
Darren Tuckerd545a4b2012-07-03 22:48:31 +10003044AC_MSG_CHECKING([if setrlimit RLIMIT_FSIZE works])
3045AC_RUN_IFELSE(
3046 [AC_LANG_PROGRAM([[
3047#include <sys/types.h>
3048#include <sys/resource.h>
3049#include <stdlib.h>
3050 ]],[[
3051 struct rlimit rl_zero;
3052
3053 rl_zero.rlim_cur = rl_zero.rlim_max = 0;
3054 exit(setrlimit(RLIMIT_FSIZE, &rl_zero) != 0);
3055 ]])],
3056 [AC_MSG_RESULT([yes])],
3057 [AC_MSG_RESULT([no])
3058 AC_DEFINE(SANDBOX_SKIP_RLIMIT_FSIZE, 1,
3059 [setrlimit RLIMIT_FSIZE works])],
3060 [AC_MSG_WARN([cross compiling: assuming yes])]
3061)
3062
Damien Miller69ff1df2011-06-23 08:30:03 +10003063if test "x$sandbox_arg" = "xsystrace" || \
3064 ( test -z "$sandbox_arg" && test "x$have_systr_policy_kill" = "x1" ) ; then
Damien Miller1a91c0f2011-08-17 11:59:25 +10003065 test "x$have_systr_policy_kill" != "x1" && \
3066 AC_MSG_ERROR([systrace sandbox requires systrace headers and SYSTR_POLICY_KILL support])
Damien Miller69ff1df2011-06-23 08:30:03 +10003067 SANDBOX_STYLE="systrace"
3068 AC_DEFINE([SANDBOX_SYSTRACE], [1], [Sandbox using systrace(4)])
Damien Millercd5e52e2011-06-27 07:18:18 +10003069elif test "x$sandbox_arg" = "xdarwin" || \
3070 ( test -z "$sandbox_arg" && test "x$ac_cv_func_sandbox_init" = "xyes" && \
3071 test "x$ac_cv_header_sandbox_h" = "xyes") ; then
Damien Miller1a91c0f2011-08-17 11:59:25 +10003072 test "x$ac_cv_func_sandbox_init" != "xyes" -o \
3073 "x$ac_cv_header_sandbox_h" != "xyes" && \
3074 AC_MSG_ERROR([Darwin seatbelt sandbox requires sandbox.h and sandbox_init function])
Damien Millercd5e52e2011-06-27 07:18:18 +10003075 SANDBOX_STYLE="darwin"
3076 AC_DEFINE([SANDBOX_DARWIN], [1], [Sandbox using Darwin sandbox_init(3)])
Damien Millere0956e32012-04-04 11:27:54 +10003077elif test "x$sandbox_arg" = "xseccomp_filter" || \
3078 ( test -z "$sandbox_arg" && \
Darren Tuckerd0494fd2012-05-19 14:25:39 +10003079 test "x$have_seccomp_filter" = "x1" && \
Damien Miller91f40d82013-02-22 11:37:00 +11003080 test "x$ac_cv_header_elf_h" = "xyes" && \
Damien Millere0956e32012-04-04 11:27:54 +10003081 test "x$ac_cv_header_linux_audit_h" = "xyes" && \
Damien Miller91f40d82013-02-22 11:37:00 +11003082 test "x$ac_cv_header_linux_filter_h" = "xyes" && \
3083 test "x$seccomp_audit_arch" != "x" && \
Damien Millere0956e32012-04-04 11:27:54 +10003084 test "x$have_linux_no_new_privs" = "x1" && \
3085 test "x$ac_cv_func_prctl" = "xyes" ) ; then
Damien Miller91f40d82013-02-22 11:37:00 +11003086 test "x$seccomp_audit_arch" = "x" && \
Damien Millere0956e32012-04-04 11:27:54 +10003087 AC_MSG_ERROR([seccomp_filter sandbox not supported on $host])
3088 test "x$have_linux_no_new_privs" != "x1" && \
3089 AC_MSG_ERROR([seccomp_filter sandbox requires PR_SET_NO_NEW_PRIVS])
3090 test "x$have_seccomp_filter" != "x1" && \
3091 AC_MSG_ERROR([seccomp_filter sandbox requires seccomp headers])
3092 test "x$ac_cv_func_prctl" != "xyes" && \
3093 AC_MSG_ERROR([seccomp_filter sandbox requires prctl function])
3094 SANDBOX_STYLE="seccomp_filter"
3095 AC_DEFINE([SANDBOX_SECCOMP_FILTER], [1], [Sandbox using seccomp filter])
Damien Millerf62ecef2014-01-25 12:34:38 +11003096elif test "x$sandbox_arg" = "xcapsicum" || \
3097 ( test -z "$sandbox_arg" && \
Damien Miller603b8f42014-01-25 13:16:59 +11003098 test "x$ac_cv_header_sys_capability_h" = "xyes" && \
3099 test "x$ac_cv_func_cap_rights_limit" = "xyes") ; then
3100 test "x$ac_cv_header_sys_capability_h" != "xyes" && \
Damien Millerc96d8532014-01-25 13:12:28 +11003101 AC_MSG_ERROR([capsicum sandbox requires sys/capability.h header])
Damien Miller603b8f42014-01-25 13:16:59 +11003102 test "x$ac_cv_func_cap_rights_limit" != "xyes" && \
Damien Millerc96d8532014-01-25 13:12:28 +11003103 AC_MSG_ERROR([capsicum sandbox requires cap_rights_limit function])
Damien Millerf62ecef2014-01-25 12:34:38 +11003104 SANDBOX_STYLE="capsicum"
3105 AC_DEFINE([SANDBOX_CAPSICUM], [1], [Sandbox using capsicum])
Damien Miller69ff1df2011-06-23 08:30:03 +10003106elif test "x$sandbox_arg" = "xrlimit" || \
Darren Tucker60395f92012-07-03 14:31:18 +10003107 ( test -z "$sandbox_arg" && test "x$ac_cv_func_setrlimit" = "xyes" && \
Darren Tuckerff008de2013-03-06 17:48:48 +11003108 test "x$select_works_with_rlimit" = "xyes" && \
3109 test "x$rlimit_nofile_zero_works" = "xyes" ) ; then
Damien Miller1a91c0f2011-08-17 11:59:25 +10003110 test "x$ac_cv_func_setrlimit" != "xyes" && \
3111 AC_MSG_ERROR([rlimit sandbox requires setrlimit function])
Darren Tucker60395f92012-07-03 14:31:18 +10003112 test "x$select_works_with_rlimit" != "xyes" && \
3113 AC_MSG_ERROR([rlimit sandbox requires select to work with rlimit])
Damien Miller69ff1df2011-06-23 08:30:03 +10003114 SANDBOX_STYLE="rlimit"
3115 AC_DEFINE([SANDBOX_RLIMIT], [1], [Sandbox using setrlimit(2)])
3116elif test -z "$sandbox_arg" || test "x$sandbox_arg" = "xno" || \
3117 test "x$sandbox_arg" = "xnone" || test "x$sandbox_arg" = "xnull" ; then
3118 SANDBOX_STYLE="none"
3119 AC_DEFINE([SANDBOX_NULL], [1], [no privsep sandboxing])
3120else
Tim Ricea6e60612011-08-17 21:48:22 -07003121 AC_MSG_ERROR([unsupported --with-sandbox])
Damien Miller69ff1df2011-06-23 08:30:03 +10003122fi
3123
Ben Lindstromb5628642000-10-18 00:02:25 +00003124# Cheap hack to ensure NEWS-OS libraries are arranged right.
3125if test ! -z "$SONY" ; then
3126 LIBS="$LIBS -liberty";
3127fi
3128
Damien Miller57f39152005-11-24 19:58:19 +11003129# Check for long long datatypes
3130AC_CHECK_TYPES([long long, unsigned long long, long double])
3131
3132# Check datatype sizes
Tim Rice648f8762011-01-26 12:38:57 -08003133AC_CHECK_SIZEOF([short int], [2])
3134AC_CHECK_SIZEOF([int], [4])
3135AC_CHECK_SIZEOF([long int], [4])
3136AC_CHECK_SIZEOF([long long int], [8])
Damien Millerc6398ef1999-11-20 12:18:40 +11003137
Damien Millerfa2bb692002-04-23 23:22:25 +10003138# Sanity check long long for some platforms (AIX)
3139if test "x$ac_cv_sizeof_long_long_int" = "x4" ; then
3140 ac_cv_sizeof_long_long_int=0
3141fi
3142
Darren Tucker537f1ed2005-10-25 18:38:33 +10003143# compute LLONG_MIN and LLONG_MAX if we don't know them.
3144if test -z "$have_llong_max"; then
3145 AC_MSG_CHECKING([for max value of long long])
3146 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08003147 [AC_LANG_PROGRAM([[
Darren Tucker537f1ed2005-10-25 18:38:33 +10003148#include <stdio.h>
3149/* Why is this so damn hard? */
3150#ifdef __GNUC__
3151# undef __GNUC__
3152#endif
3153#define __USE_ISOC99
3154#include <limits.h>
3155#define DATA "conftest.llminmax"
Darren Tuckerd1450db2006-03-13 19:06:51 +11003156#define my_abs(a) ((a) < 0 ? ((a) * -1) : (a))
3157
3158/*
3159 * printf in libc on some platforms (eg old Tru64) does not understand %lld so
3160 * we do this the hard way.
3161 */
3162static int
3163fprint_ll(FILE *f, long long n)
3164{
3165 unsigned int i;
3166 int l[sizeof(long long) * 8];
3167
3168 if (n < 0)
3169 if (fprintf(f, "-") < 0)
3170 return -1;
3171 for (i = 0; n != 0; i++) {
3172 l[i] = my_abs(n % 10);
3173 n /= 10;
3174 }
3175 do {
3176 if (fprintf(f, "%d", l[--i]) < 0)
3177 return -1;
3178 } while (i != 0);
3179 if (fprintf(f, " ") < 0)
3180 return -1;
3181 return 0;
3182}
Tim Rice648f8762011-01-26 12:38:57 -08003183 ]], [[
Darren Tucker537f1ed2005-10-25 18:38:33 +10003184 FILE *f;
3185 long long i, llmin, llmax = 0;
3186
3187 if((f = fopen(DATA,"w")) == NULL)
3188 exit(1);
3189
3190#if defined(LLONG_MIN) && defined(LLONG_MAX)
3191 fprintf(stderr, "Using system header for LLONG_MIN and LLONG_MAX\n");
3192 llmin = LLONG_MIN;
3193 llmax = LLONG_MAX;
3194#else
3195 fprintf(stderr, "Calculating LLONG_MIN and LLONG_MAX\n");
3196 /* This will work on one's complement and two's complement */
3197 for (i = 1; i > llmax; i <<= 1, i++)
3198 llmax = i;
3199 llmin = llmax + 1LL; /* wrap */
3200#endif
3201
3202 /* Sanity check */
3203 if (llmin + 1 < llmin || llmin - 1 < llmin || llmax + 1 > llmax
Darren Tuckerd1450db2006-03-13 19:06:51 +11003204 || llmax - 1 > llmax || llmin == llmax || llmin == 0
3205 || llmax == 0 || llmax < LONG_MAX || llmin > LONG_MIN) {
Darren Tucker537f1ed2005-10-25 18:38:33 +10003206 fprintf(f, "unknown unknown\n");
3207 exit(2);
3208 }
3209
Darren Tuckerd1450db2006-03-13 19:06:51 +11003210 if (fprint_ll(f, llmin) < 0)
Darren Tucker537f1ed2005-10-25 18:38:33 +10003211 exit(3);
Darren Tuckerd1450db2006-03-13 19:06:51 +11003212 if (fprint_ll(f, llmax) < 0)
3213 exit(4);
3214 if (fclose(f) < 0)
3215 exit(5);
Darren Tucker537f1ed2005-10-25 18:38:33 +10003216 exit(0);
Darren Tucker537f1ed2005-10-25 18:38:33 +10003217 ]])],
3218 [
3219 llong_min=`$AWK '{print $1}' conftest.llminmax`
3220 llong_max=`$AWK '{print $2}' conftest.llminmax`
3221
Tim Rice648f8762011-01-26 12:38:57 -08003222 AC_MSG_RESULT([$llong_max])
3223 AC_DEFINE_UNQUOTED([LLONG_MAX], [${llong_max}LL],
Darren Tucker537f1ed2005-10-25 18:38:33 +10003224 [max value of long long calculated by configure])
3225 AC_MSG_CHECKING([for min value of long long])
Tim Rice648f8762011-01-26 12:38:57 -08003226 AC_MSG_RESULT([$llong_min])
3227 AC_DEFINE_UNQUOTED([LLONG_MIN], [${llong_min}LL],
Darren Tucker537f1ed2005-10-25 18:38:33 +10003228 [min value of long long calculated by configure])
3229 ],
3230 [
Tim Rice648f8762011-01-26 12:38:57 -08003231 AC_MSG_RESULT([not found])
Darren Tucker537f1ed2005-10-25 18:38:33 +10003232 ],
3233 [
3234 AC_MSG_WARN([cross compiling: not checking])
3235 ]
3236 )
3237fi
3238
3239
Damien Millera22ba012000-03-02 23:09:20 +11003240# More checks for data types
Damien Millercaf6dd62000-08-29 11:33:50 +11003241AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [
Tim Rice648f8762011-01-26 12:38:57 -08003242 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3243 [[ u_int a; a = 1;]])],
3244 [ ac_cv_have_u_int="yes" ], [ ac_cv_have_u_int="no"
3245 ])
Damien Millercaf6dd62000-08-29 11:33:50 +11003246])
3247if test "x$ac_cv_have_u_int" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003248 AC_DEFINE([HAVE_U_INT], [1], [define if you have u_int data type])
Damien Millercaf6dd62000-08-29 11:33:50 +11003249 have_u_int=1
3250fi
3251
Damien Miller61e50f12000-05-08 20:49:37 +10003252AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003253 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3254 [[ int8_t a; int16_t b; int32_t c; a = b = c = 1;]])],
3255 [ ac_cv_have_intxx_t="yes" ], [ ac_cv_have_intxx_t="no"
3256 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003257])
3258if test "x$ac_cv_have_intxx_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003259 AC_DEFINE([HAVE_INTXX_T], [1], [define if you have intxx_t data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003260 have_intxx_t=1
3261fi
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003262
3263if (test -z "$have_intxx_t" && \
Damien Millera8e06ce2003-11-21 23:48:55 +11003264 test "x$ac_cv_header_stdint_h" = "xyes")
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003265then
3266 AC_MSG_CHECKING([for intXX_t types in stdint.h])
Tim Rice648f8762011-01-26 12:38:57 -08003267 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdint.h> ]],
3268 [[ int8_t a; int16_t b; int32_t c; a = b = c = 1;]])],
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003269 [
Tim Rice648f8762011-01-26 12:38:57 -08003270 AC_DEFINE([HAVE_INTXX_T])
3271 AC_MSG_RESULT([yes])
3272 ], [ AC_MSG_RESULT([no])
3273 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003274fi
3275
Damien Miller578783e2000-09-23 14:12:24 +11003276AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003277 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Tim Rice907881e2002-07-18 11:44:50 -07003278#include <sys/types.h>
3279#ifdef HAVE_STDINT_H
3280# include <stdint.h>
3281#endif
3282#include <sys/socket.h>
3283#ifdef HAVE_SYS_BITYPES_H
3284# include <sys/bitypes.h>
3285#endif
Tim Rice648f8762011-01-26 12:38:57 -08003286 ]], [[
3287int64_t a; a = 1;
3288 ]])],
3289 [ ac_cv_have_int64_t="yes" ], [ ac_cv_have_int64_t="no"
3290 ])
Damien Miller578783e2000-09-23 14:12:24 +11003291])
3292if test "x$ac_cv_have_int64_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003293 AC_DEFINE([HAVE_INT64_T], [1], [define if you have int64_t data type])
Tim Rice4cec93f2002-02-26 08:40:48 -08003294fi
3295
Damien Miller61e50f12000-05-08 20:49:37 +10003296AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003297 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3298 [[ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;]])],
3299 [ ac_cv_have_u_intxx_t="yes" ], [ ac_cv_have_u_intxx_t="no"
3300 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003301])
3302if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003303 AC_DEFINE([HAVE_U_INTXX_T], [1], [define if you have u_intxx_t data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003304 have_u_intxx_t=1
3305fi
Damien Millerc6398ef1999-11-20 12:18:40 +11003306
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003307if test -z "$have_u_intxx_t" ; then
3308 AC_MSG_CHECKING([for u_intXX_t types in sys/socket.h])
Tim Rice648f8762011-01-26 12:38:57 -08003309 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/socket.h> ]],
3310 [[ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;]])],
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003311 [
Tim Rice648f8762011-01-26 12:38:57 -08003312 AC_DEFINE([HAVE_U_INTXX_T])
3313 AC_MSG_RESULT([yes])
3314 ], [ AC_MSG_RESULT([no])
3315 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003316fi
3317
Damien Miller578783e2000-09-23 14:12:24 +11003318AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003319 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3320 [[ u_int64_t a; a = 1;]])],
3321 [ ac_cv_have_u_int64_t="yes" ], [ ac_cv_have_u_int64_t="no"
3322 ])
Damien Miller578783e2000-09-23 14:12:24 +11003323])
3324if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003325 AC_DEFINE([HAVE_U_INT64_T], [1], [define if you have u_int64_t data type])
Damien Miller578783e2000-09-23 14:12:24 +11003326 have_u_int64_t=1
3327fi
3328
Damien Millerc2868192014-01-30 10:21:19 +11003329if (test -z "$have_u_int64_t" && \
3330 test "x$ac_cv_header_sys_bitypes_h" = "xyes")
3331then
Tim Rice4cec93f2002-02-26 08:40:48 -08003332 AC_MSG_CHECKING([for u_int64_t type in sys/bitypes.h])
Tim Rice648f8762011-01-26 12:38:57 -08003333 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/bitypes.h> ]],
3334 [[ u_int64_t a; a = 1]])],
Tim Rice4cec93f2002-02-26 08:40:48 -08003335 [
Tim Rice648f8762011-01-26 12:38:57 -08003336 AC_DEFINE([HAVE_U_INT64_T])
3337 AC_MSG_RESULT([yes])
3338 ], [ AC_MSG_RESULT([no])
3339 ])
Tim Rice4cec93f2002-02-26 08:40:48 -08003340fi
3341
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003342if test -z "$have_u_intxx_t" ; then
3343 AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003344 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003345#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08003346 ]], [[
3347 uint8_t a;
3348 uint16_t b;
3349 uint32_t c;
3350 a = b = c = 1;
3351 ]])],
3352 [ ac_cv_have_uintxx_t="yes" ], [ ac_cv_have_uintxx_t="no"
3353 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003354 ])
3355 if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003356 AC_DEFINE([HAVE_UINTXX_T], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003357 [define if you have uintxx_t data type])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003358 fi
3359fi
3360
Damien Millerc2868192014-01-30 10:21:19 +11003361if (test -z "$have_uintxx_t" && \
3362 test "x$ac_cv_header_stdint_h" = "xyes")
3363then
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003364 AC_MSG_CHECKING([for uintXX_t types in stdint.h])
Tim Rice648f8762011-01-26 12:38:57 -08003365 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdint.h> ]],
3366 [[ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;]])],
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003367 [
Tim Rice648f8762011-01-26 12:38:57 -08003368 AC_DEFINE([HAVE_UINTXX_T])
3369 AC_MSG_RESULT([yes])
3370 ], [ AC_MSG_RESULT([no])
3371 ])
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00003372fi
3373
Damien Millerc2868192014-01-30 10:21:19 +11003374if (test -z "$have_uintxx_t" && \
3375 test "x$ac_cv_header_inttypes_h" = "xyes")
3376then
Darren Tucker6d725682014-01-17 19:17:34 +11003377 AC_MSG_CHECKING([for uintXX_t types in inttypes.h])
3378 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <inttypes.h> ]],
3379 [[ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;]])],
3380 [
3381 AC_DEFINE([HAVE_UINTXX_T])
3382 AC_MSG_RESULT([yes])
3383 ], [ AC_MSG_RESULT([no])
3384 ])
3385fi
3386
Damien Milleredb82922000-06-20 13:25:52 +10003387if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
Damien Millera8e06ce2003-11-21 23:48:55 +11003388 test "x$ac_cv_header_sys_bitypes_h" = "xyes")
Damien Millerb29ea912000-01-15 14:12:03 +11003389then
3390 AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
Tim Rice648f8762011-01-26 12:38:57 -08003391 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller61e50f12000-05-08 20:49:37 +10003392#include <sys/bitypes.h>
Tim Rice648f8762011-01-26 12:38:57 -08003393 ]], [[
Damien Miller70494d12000-04-03 15:57:06 +10003394 int8_t a; int16_t b; int32_t c;
3395 u_int8_t e; u_int16_t f; u_int32_t g;
3396 a = b = c = e = f = g = 1;
Tim Rice648f8762011-01-26 12:38:57 -08003397 ]])],
Damien Millerb29ea912000-01-15 14:12:03 +11003398 [
Tim Rice648f8762011-01-26 12:38:57 -08003399 AC_DEFINE([HAVE_U_INTXX_T])
3400 AC_DEFINE([HAVE_INTXX_T])
3401 AC_MSG_RESULT([yes])
3402 ], [AC_MSG_RESULT([no])
3403 ])
Damien Millerb29ea912000-01-15 14:12:03 +11003404fi
3405
Damien Miller58be7382001-09-15 21:31:54 +10003406
3407AC_CACHE_CHECK([for u_char], ac_cv_have_u_char, [
Tim Rice648f8762011-01-26 12:38:57 -08003408 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3409 [[ u_char foo; foo = 125; ]])],
3410 [ ac_cv_have_u_char="yes" ], [ ac_cv_have_u_char="no"
3411 ])
Damien Miller58be7382001-09-15 21:31:54 +10003412])
3413if test "x$ac_cv_have_u_char" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003414 AC_DEFINE([HAVE_U_CHAR], [1], [define if you have u_char data type])
Damien Miller58be7382001-09-15 21:31:54 +10003415fi
3416
Darren Tucker007e3b32013-11-03 18:43:55 +11003417AC_CHECK_TYPES([intmax_t, uintmax_t], , , [
3418#include <sys/types.h>
3419#include <stdint.h>
3420])
3421
Tim Rice13aae5e2001-10-21 17:53:58 -07003422TYPE_SOCKLEN_T
Damien Miller74d0d4a1999-12-29 02:24:35 +11003423
Tim Rice648f8762011-01-26 12:38:57 -08003424AC_CHECK_TYPES([sig_atomic_t], , , [#include <signal.h>])
3425AC_CHECK_TYPES([fsblkcnt_t, fsfilcnt_t], , , [
Darren Tucker598eaa62008-06-09 03:32:29 +10003426#include <sys/types.h>
3427#ifdef HAVE_SYS_BITYPES_H
3428#include <sys/bitypes.h>
3429#endif
3430#ifdef HAVE_SYS_STATFS_H
3431#include <sys/statfs.h>
3432#endif
3433#ifdef HAVE_SYS_STATVFS_H
3434#include <sys/statvfs.h>
3435#endif
3436])
Tim Rice4cec93f2002-02-26 08:40:48 -08003437
Tim Rice648f8762011-01-26 12:38:57 -08003438AC_CHECK_TYPES([in_addr_t, in_port_t], , ,
Damien Miller848b9932005-02-24 12:12:34 +11003439[#include <sys/types.h>
3440#include <netinet/in.h>])
Darren Tuckerd9f88912005-02-20 21:01:48 +11003441
Damien Miller61e50f12000-05-08 20:49:37 +10003442AC_CACHE_CHECK([for size_t], ac_cv_have_size_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003443 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3444 [[ size_t foo; foo = 1235; ]])],
3445 [ ac_cv_have_size_t="yes" ], [ ac_cv_have_size_t="no"
3446 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003447])
3448if test "x$ac_cv_have_size_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003449 AC_DEFINE([HAVE_SIZE_T], [1], [define if you have size_t data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003450fi
Damien Miller95058511999-12-29 10:36:45 +11003451
Damien Miller615f9392000-05-17 22:53:33 +10003452AC_CACHE_CHECK([for ssize_t], ac_cv_have_ssize_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003453 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3454 [[ ssize_t foo; foo = 1235; ]])],
3455 [ ac_cv_have_ssize_t="yes" ], [ ac_cv_have_ssize_t="no"
3456 ])
Damien Miller615f9392000-05-17 22:53:33 +10003457])
3458if test "x$ac_cv_have_ssize_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003459 AC_DEFINE([HAVE_SSIZE_T], [1], [define if you have ssize_t data type])
Damien Miller615f9392000-05-17 22:53:33 +10003460fi
3461
Ben Lindstrom0d5af602001-01-09 00:50:29 +00003462AC_CACHE_CHECK([for clock_t], ac_cv_have_clock_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003463 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <time.h> ]],
3464 [[ clock_t foo; foo = 1235; ]])],
3465 [ ac_cv_have_clock_t="yes" ], [ ac_cv_have_clock_t="no"
3466 ])
Ben Lindstrom0d5af602001-01-09 00:50:29 +00003467])
3468if test "x$ac_cv_have_clock_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003469 AC_DEFINE([HAVE_CLOCK_T], [1], [define if you have clock_t data type])
Ben Lindstrom0d5af602001-01-09 00:50:29 +00003470fi
3471
Damien Millerb54b40e2000-06-23 08:23:34 +10003472AC_CACHE_CHECK([for sa_family_t], ac_cv_have_sa_family_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003473 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Millerb54b40e2000-06-23 08:23:34 +10003474#include <sys/types.h>
3475#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08003476 ]], [[ sa_family_t foo; foo = 1235; ]])],
3477 [ ac_cv_have_sa_family_t="yes" ],
3478 [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller78315eb2000-09-29 23:01:36 +11003479#include <sys/types.h>
3480#include <sys/socket.h>
3481#include <netinet/in.h>
Tim Rice648f8762011-01-26 12:38:57 -08003482 ]], [[ sa_family_t foo; foo = 1235; ]])],
Damien Miller78315eb2000-09-29 23:01:36 +11003483 [ ac_cv_have_sa_family_t="yes" ],
Damien Millerb54b40e2000-06-23 08:23:34 +10003484 [ ac_cv_have_sa_family_t="no" ]
3485 )
Tim Rice648f8762011-01-26 12:38:57 -08003486 ])
Damien Millerb54b40e2000-06-23 08:23:34 +10003487])
3488if test "x$ac_cv_have_sa_family_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003489 AC_DEFINE([HAVE_SA_FAMILY_T], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003490 [define if you have sa_family_t data type])
Damien Millerb54b40e2000-06-23 08:23:34 +10003491fi
3492
Damien Miller0f91b4e2000-06-18 15:43:25 +10003493AC_CACHE_CHECK([for pid_t], ac_cv_have_pid_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003494 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3495 [[ pid_t foo; foo = 1235; ]])],
3496 [ ac_cv_have_pid_t="yes" ], [ ac_cv_have_pid_t="no"
3497 ])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003498])
3499if test "x$ac_cv_have_pid_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003500 AC_DEFINE([HAVE_PID_T], [1], [define if you have pid_t data type])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003501fi
3502
3503AC_CACHE_CHECK([for mode_t], ac_cv_have_mode_t, [
Tim Rice648f8762011-01-26 12:38:57 -08003504 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
3505 [[ mode_t foo; foo = 1235; ]])],
3506 [ ac_cv_have_mode_t="yes" ], [ ac_cv_have_mode_t="no"
3507 ])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003508])
3509if test "x$ac_cv_have_mode_t" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003510 AC_DEFINE([HAVE_MODE_T], [1], [define if you have mode_t data type])
Damien Miller0f91b4e2000-06-18 15:43:25 +10003511fi
3512
Damien Miller61e50f12000-05-08 20:49:37 +10003513
3514AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_have_struct_sockaddr_storage, [
Tim Rice648f8762011-01-26 12:38:57 -08003515 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10003516#include <sys/types.h>
3517#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08003518 ]], [[ struct sockaddr_storage s; ]])],
3519 [ ac_cv_have_struct_sockaddr_storage="yes" ],
3520 [ ac_cv_have_struct_sockaddr_storage="no"
3521 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003522])
3523if test "x$ac_cv_have_struct_sockaddr_storage" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003524 AC_DEFINE([HAVE_STRUCT_SOCKADDR_STORAGE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003525 [define if you have struct sockaddr_storage data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003526fi
Damien Miller34132e52000-01-14 15:45:46 +11003527
Damien Miller61e50f12000-05-08 20:49:37 +10003528AC_CACHE_CHECK([for struct sockaddr_in6], ac_cv_have_struct_sockaddr_in6, [
Tim Rice648f8762011-01-26 12:38:57 -08003529 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller7b22d652000-06-18 14:07:04 +10003530#include <sys/types.h>
Damien Miller61e50f12000-05-08 20:49:37 +10003531#include <netinet/in.h>
Tim Rice648f8762011-01-26 12:38:57 -08003532 ]], [[ struct sockaddr_in6 s; s.sin6_family = 0; ]])],
3533 [ ac_cv_have_struct_sockaddr_in6="yes" ],
3534 [ ac_cv_have_struct_sockaddr_in6="no"
3535 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003536])
3537if test "x$ac_cv_have_struct_sockaddr_in6" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003538 AC_DEFINE([HAVE_STRUCT_SOCKADDR_IN6], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003539 [define if you have struct sockaddr_in6 data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003540fi
Damien Miller34132e52000-01-14 15:45:46 +11003541
Damien Miller61e50f12000-05-08 20:49:37 +10003542AC_CACHE_CHECK([for struct in6_addr], ac_cv_have_struct_in6_addr, [
Tim Rice648f8762011-01-26 12:38:57 -08003543 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller7b22d652000-06-18 14:07:04 +10003544#include <sys/types.h>
Damien Miller61e50f12000-05-08 20:49:37 +10003545#include <netinet/in.h>
Tim Rice648f8762011-01-26 12:38:57 -08003546 ]], [[ struct in6_addr s; s.s6_addr[0] = 0; ]])],
3547 [ ac_cv_have_struct_in6_addr="yes" ],
3548 [ ac_cv_have_struct_in6_addr="no"
3549 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003550])
3551if test "x$ac_cv_have_struct_in6_addr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003552 AC_DEFINE([HAVE_STRUCT_IN6_ADDR], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003553 [define if you have struct in6_addr data type])
Tim Rice0f4d2c02008-11-18 21:26:41 -08003554
3555dnl Now check for sin6_scope_id
Tim Rice648f8762011-01-26 12:38:57 -08003556 AC_CHECK_MEMBERS([struct sockaddr_in6.sin6_scope_id], , ,
Tim Rice0f4d2c02008-11-18 21:26:41 -08003557 [
3558#ifdef HAVE_SYS_TYPES_H
3559#include <sys/types.h>
3560#endif
3561#include <netinet/in.h>
3562 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003563fi
Damien Miller34132e52000-01-14 15:45:46 +11003564
Damien Miller61e50f12000-05-08 20:49:37 +10003565AC_CACHE_CHECK([for struct addrinfo], ac_cv_have_struct_addrinfo, [
Tim Rice648f8762011-01-26 12:38:57 -08003566 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10003567#include <sys/types.h>
3568#include <sys/socket.h>
3569#include <netdb.h>
Tim Rice648f8762011-01-26 12:38:57 -08003570 ]], [[ struct addrinfo s; s.ai_flags = AI_PASSIVE; ]])],
3571 [ ac_cv_have_struct_addrinfo="yes" ],
3572 [ ac_cv_have_struct_addrinfo="no"
3573 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003574])
3575if test "x$ac_cv_have_struct_addrinfo" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003576 AC_DEFINE([HAVE_STRUCT_ADDRINFO], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003577 [define if you have struct addrinfo data type])
Damien Miller61e50f12000-05-08 20:49:37 +10003578fi
3579
Ben Lindstrom42202bc2001-01-15 02:34:37 +00003580AC_CACHE_CHECK([for struct timeval], ac_cv_have_struct_timeval, [
Tim Rice648f8762011-01-26 12:38:57 -08003581 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/time.h> ]],
3582 [[ struct timeval tv; tv.tv_sec = 1;]])],
3583 [ ac_cv_have_struct_timeval="yes" ],
3584 [ ac_cv_have_struct_timeval="no"
3585 ])
Ben Lindstrom42202bc2001-01-15 02:34:37 +00003586])
3587if test "x$ac_cv_have_struct_timeval" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003588 AC_DEFINE([HAVE_STRUCT_TIMEVAL], [1], [define if you have struct timeval])
Ben Lindstrom42202bc2001-01-15 02:34:37 +00003589 have_struct_timeval=1
3590fi
3591
Tim Rice648f8762011-01-26 12:38:57 -08003592AC_CHECK_TYPES([struct timespec])
Tim Rice4e4dc562003-03-18 10:21:40 -08003593
Ben Lindstrom5bd6eb72003-03-21 00:34:34 +00003594# We need int64_t or else certian parts of the compile will fail.
Tim Rice8bb561b2005-03-17 16:23:19 -08003595if test "x$ac_cv_have_int64_t" = "xno" && \
3596 test "x$ac_cv_sizeof_long_int" != "x8" && \
3597 test "x$ac_cv_sizeof_long_long_int" = "x0" ; then
Ben Lindstrom5bd6eb72003-03-21 00:34:34 +00003598 echo "OpenSSH requires int64_t support. Contact your vendor or install"
3599 echo "an alternative compiler (I.E., GCC) before continuing."
3600 echo ""
3601 exit 1;
Tim Ricebee3f222001-03-11 17:32:12 -08003602else
3603dnl test snprintf (broken on SCO w/gcc)
Darren Tuckera0c2b392004-09-11 23:26:37 +10003604 AC_RUN_IFELSE(
Darren Tucker623d92f2004-09-12 22:36:15 +10003605 [AC_LANG_SOURCE([[
Tim Ricebee3f222001-03-11 17:32:12 -08003606#include <stdio.h>
3607#include <string.h>
3608#ifdef HAVE_SNPRINTF
3609main()
3610{
3611 char buf[50];
3612 char expected_out[50];
3613 int mazsize = 50 ;
3614#if (SIZEOF_LONG_INT == 8)
3615 long int num = 0x7fffffffffffffff;
3616#else
Kevin Steves6482ec82001-07-15 02:09:28 +00003617 long long num = 0x7fffffffffffffffll;
Tim Ricebee3f222001-03-11 17:32:12 -08003618#endif
3619 strcpy(expected_out, "9223372036854775807");
3620 snprintf(buf, mazsize, "%lld", num);
3621 if(strcmp(buf, expected_out) != 0)
Damien Millera8e06ce2003-11-21 23:48:55 +11003622 exit(1);
Tim Ricebee3f222001-03-11 17:32:12 -08003623 exit(0);
3624}
3625#else
3626main() { exit(0); }
3627#endif
Tim Rice648f8762011-01-26 12:38:57 -08003628 ]])], [ true ], [ AC_DEFINE([BROKEN_SNPRINTF]) ],
Darren Tuckera0c2b392004-09-11 23:26:37 +10003629 AC_MSG_WARN([cross compiling: Assuming working snprintf()])
Tim Ricebee3f222001-03-11 17:32:12 -08003630 )
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00003631fi
3632
Damien Miller78315eb2000-09-29 23:01:36 +11003633dnl Checks for structure members
Tim Rice648f8762011-01-26 12:38:57 -08003634OSSH_CHECK_HEADER_FOR_FIELD([ut_host], [utmp.h], [HAVE_HOST_IN_UTMP])
3635OSSH_CHECK_HEADER_FOR_FIELD([ut_host], [utmpx.h], [HAVE_HOST_IN_UTMPX])
3636OSSH_CHECK_HEADER_FOR_FIELD([syslen], [utmpx.h], [HAVE_SYSLEN_IN_UTMPX])
3637OSSH_CHECK_HEADER_FOR_FIELD([ut_pid], [utmp.h], [HAVE_PID_IN_UTMP])
3638OSSH_CHECK_HEADER_FOR_FIELD([ut_type], [utmp.h], [HAVE_TYPE_IN_UTMP])
3639OSSH_CHECK_HEADER_FOR_FIELD([ut_type], [utmpx.h], [HAVE_TYPE_IN_UTMPX])
3640OSSH_CHECK_HEADER_FOR_FIELD([ut_tv], [utmp.h], [HAVE_TV_IN_UTMP])
3641OSSH_CHECK_HEADER_FOR_FIELD([ut_id], [utmp.h], [HAVE_ID_IN_UTMP])
3642OSSH_CHECK_HEADER_FOR_FIELD([ut_id], [utmpx.h], [HAVE_ID_IN_UTMPX])
3643OSSH_CHECK_HEADER_FOR_FIELD([ut_addr], [utmp.h], [HAVE_ADDR_IN_UTMP])
3644OSSH_CHECK_HEADER_FOR_FIELD([ut_addr], [utmpx.h], [HAVE_ADDR_IN_UTMPX])
3645OSSH_CHECK_HEADER_FOR_FIELD([ut_addr_v6], [utmp.h], [HAVE_ADDR_V6_IN_UTMP])
3646OSSH_CHECK_HEADER_FOR_FIELD([ut_addr_v6], [utmpx.h], [HAVE_ADDR_V6_IN_UTMPX])
3647OSSH_CHECK_HEADER_FOR_FIELD([ut_exit], [utmp.h], [HAVE_EXIT_IN_UTMP])
3648OSSH_CHECK_HEADER_FOR_FIELD([ut_time], [utmp.h], [HAVE_TIME_IN_UTMP])
3649OSSH_CHECK_HEADER_FOR_FIELD([ut_time], [utmpx.h], [HAVE_TIME_IN_UTMPX])
3650OSSH_CHECK_HEADER_FOR_FIELD([ut_tv], [utmpx.h], [HAVE_TV_IN_UTMPX])
Tim Rice13aae5e2001-10-21 17:53:58 -07003651
3652AC_CHECK_MEMBERS([struct stat.st_blksize])
Damien Miller6332da22013-04-23 14:25:52 +10003653AC_CHECK_MEMBERS([struct passwd.pw_gecos, struct passwd.pw_class,
3654struct passwd.pw_change, struct passwd.pw_expire],
3655[], [], [[
3656#include <sys/types.h>
3657#include <pwd.h>
3658]])
3659
Tim Rice648f8762011-01-26 12:38:57 -08003660AC_CHECK_MEMBER([struct __res_state.retrans], [], [AC_DEFINE([__res_state], [state],
Darren Tucker58e298d2005-11-25 13:14:58 +11003661 [Define if we don't have struct __res_state in resolv.h])],
Damien Miller6332da22013-04-23 14:25:52 +10003662[[
Darren Tucker58e298d2005-11-25 13:14:58 +11003663#include <stdio.h>
3664#if HAVE_SYS_TYPES_H
3665# include <sys/types.h>
3666#endif
3667#include <netinet/in.h>
3668#include <arpa/nameser.h>
3669#include <resolv.h>
Damien Miller6332da22013-04-23 14:25:52 +10003670]])
andre2ff7b5d2000-06-03 14:57:40 +00003671
Damien Miller61e50f12000-05-08 20:49:37 +10003672AC_CACHE_CHECK([for ss_family field in struct sockaddr_storage],
3673 ac_cv_have_ss_family_in_struct_ss, [
Tim Rice648f8762011-01-26 12:38:57 -08003674 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10003675#include <sys/types.h>
3676#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08003677 ]], [[ struct sockaddr_storage s; s.ss_family = 1; ]])],
3678 [ ac_cv_have_ss_family_in_struct_ss="yes" ],
3679 [ ac_cv_have_ss_family_in_struct_ss="no" ])
Damien Miller61e50f12000-05-08 20:49:37 +10003680])
3681if test "x$ac_cv_have_ss_family_in_struct_ss" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003682 AC_DEFINE([HAVE_SS_FAMILY_IN_SS], [1], [Fields in struct sockaddr_storage])
Damien Miller61e50f12000-05-08 20:49:37 +10003683fi
3684
Damien Miller61e50f12000-05-08 20:49:37 +10003685AC_CACHE_CHECK([for __ss_family field in struct sockaddr_storage],
3686 ac_cv_have___ss_family_in_struct_ss, [
Tim Rice648f8762011-01-26 12:38:57 -08003687 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller81171112000-04-23 11:14:01 +10003688#include <sys/types.h>
3689#include <sys/socket.h>
Tim Rice648f8762011-01-26 12:38:57 -08003690 ]], [[ struct sockaddr_storage s; s.__ss_family = 1; ]])],
3691 [ ac_cv_have___ss_family_in_struct_ss="yes" ],
3692 [ ac_cv_have___ss_family_in_struct_ss="no"
3693 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003694])
3695if test "x$ac_cv_have___ss_family_in_struct_ss" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003696 AC_DEFINE([HAVE___SS_FAMILY_IN_SS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003697 [Fields in struct sockaddr_storage])
Damien Miller61e50f12000-05-08 20:49:37 +10003698fi
Damien Millerbf1c9b21999-12-09 10:16:54 +11003699
Tim Rice28bbb0c2002-05-27 17:37:32 -07003700dnl make sure we're using the real structure members and not defines
Kevin Steves939c9db2002-03-22 17:23:25 +00003701AC_CACHE_CHECK([for msg_accrights field in struct msghdr],
3702 ac_cv_have_accrights_in_msghdr, [
Tim Rice648f8762011-01-26 12:38:57 -08003703 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Tim Riceae49fe62002-04-12 10:26:21 -07003704#include <sys/types.h>
Kevin Steves939c9db2002-03-22 17:23:25 +00003705#include <sys/socket.h>
3706#include <sys/uio.h>
Tim Rice648f8762011-01-26 12:38:57 -08003707 ]], [[
Tim Rice28bbb0c2002-05-27 17:37:32 -07003708#ifdef msg_accrights
Darren Tuckera0c2b392004-09-11 23:26:37 +10003709#error "msg_accrights is a macro"
Tim Rice28bbb0c2002-05-27 17:37:32 -07003710exit(1);
3711#endif
3712struct msghdr m;
3713m.msg_accrights = 0;
3714exit(0);
Tim Rice648f8762011-01-26 12:38:57 -08003715 ]])],
Kevin Steves939c9db2002-03-22 17:23:25 +00003716 [ ac_cv_have_accrights_in_msghdr="yes" ],
3717 [ ac_cv_have_accrights_in_msghdr="no" ]
3718 )
3719])
3720if test "x$ac_cv_have_accrights_in_msghdr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003721 AC_DEFINE([HAVE_ACCRIGHTS_IN_MSGHDR], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003722 [Define if your system uses access rights style
3723 file descriptor passing])
Kevin Steves939c9db2002-03-22 17:23:25 +00003724fi
3725
Tim Rice648f8762011-01-26 12:38:57 -08003726AC_MSG_CHECKING([if struct statvfs.f_fsid is integral type])
3727AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckere1a3ddf2012-05-04 11:05:45 +10003728#include <sys/param.h>
Darren Tucker32780622009-06-16 16:11:02 +10003729#include <sys/stat.h>
3730#ifdef HAVE_SYS_TIME_H
3731# include <sys/time.h>
3732#endif
3733#ifdef HAVE_SYS_MOUNT_H
3734#include <sys/mount.h>
3735#endif
3736#ifdef HAVE_SYS_STATVFS_H
3737#include <sys/statvfs.h>
3738#endif
Tim Rice648f8762011-01-26 12:38:57 -08003739 ]], [[ struct statvfs s; s.f_fsid = 0; ]])],
3740 [ AC_MSG_RESULT([yes]) ],
3741 [ AC_MSG_RESULT([no])
Darren Tucker32780622009-06-16 16:11:02 +10003742
Tim Rice648f8762011-01-26 12:38:57 -08003743 AC_MSG_CHECKING([if fsid_t has member val])
3744 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker32780622009-06-16 16:11:02 +10003745#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08003746#include <sys/statvfs.h>
3747 ]], [[ fsid_t t; t.val[0] = 0; ]])],
3748 [ AC_MSG_RESULT([yes])
3749 AC_DEFINE([FSID_HAS_VAL], [1], [fsid_t has member val]) ],
3750 [ AC_MSG_RESULT([no]) ])
Darren Tucker32780622009-06-16 16:11:02 +10003751
Tim Rice648f8762011-01-26 12:38:57 -08003752 AC_MSG_CHECKING([if f_fsid has member __val])
3753 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Darren Tucker32780622009-06-16 16:11:02 +10003754#include <sys/types.h>
Tim Rice648f8762011-01-26 12:38:57 -08003755#include <sys/statvfs.h>
3756 ]], [[ fsid_t t; t.__val[0] = 0; ]])],
3757 [ AC_MSG_RESULT([yes])
3758 AC_DEFINE([FSID_HAS___VAL], [1], [fsid_t has member __val]) ],
3759 [ AC_MSG_RESULT([no]) ])
Darren Tucker32780622009-06-16 16:11:02 +10003760])
Darren Tucker77001382008-06-09 06:17:53 +10003761
Kevin Stevesa44e0352002-04-07 16:18:03 +00003762AC_CACHE_CHECK([for msg_control field in struct msghdr],
3763 ac_cv_have_control_in_msghdr, [
Tim Rice648f8762011-01-26 12:38:57 -08003764 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Tim Riceae49fe62002-04-12 10:26:21 -07003765#include <sys/types.h>
Kevin Stevesa44e0352002-04-07 16:18:03 +00003766#include <sys/socket.h>
3767#include <sys/uio.h>
Tim Rice648f8762011-01-26 12:38:57 -08003768 ]], [[
Tim Rice28bbb0c2002-05-27 17:37:32 -07003769#ifdef msg_control
Darren Tuckera0c2b392004-09-11 23:26:37 +10003770#error "msg_control is a macro"
Tim Rice28bbb0c2002-05-27 17:37:32 -07003771exit(1);
3772#endif
3773struct msghdr m;
3774m.msg_control = 0;
3775exit(0);
Tim Rice648f8762011-01-26 12:38:57 -08003776 ]])],
Kevin Stevesa44e0352002-04-07 16:18:03 +00003777 [ ac_cv_have_control_in_msghdr="yes" ],
3778 [ ac_cv_have_control_in_msghdr="no" ]
3779 )
3780])
3781if test "x$ac_cv_have_control_in_msghdr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003782 AC_DEFINE([HAVE_CONTROL_IN_MSGHDR], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003783 [Define if your system uses ancillary data style
3784 file descriptor passing])
Kevin Stevesa44e0352002-04-07 16:18:03 +00003785fi
3786
Damien Miller61e50f12000-05-08 20:49:37 +10003787AC_CACHE_CHECK([if libc defines __progname], ac_cv_libc_defines___progname, [
Tim Rice648f8762011-01-26 12:38:57 -08003788 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
3789 [[ extern char *__progname; printf("%s", __progname); ]])],
3790 [ ac_cv_libc_defines___progname="yes" ],
3791 [ ac_cv_libc_defines___progname="no"
3792 ])
Damien Miller61e50f12000-05-08 20:49:37 +10003793])
3794if test "x$ac_cv_libc_defines___progname" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003795 AC_DEFINE([HAVE___PROGNAME], [1], [Define if libc defines __progname])
Damien Miller61e50f12000-05-08 20:49:37 +10003796fi
3797
Kevin Steves4846f4a2002-03-22 18:19:53 +00003798AC_CACHE_CHECK([whether $CC implements __FUNCTION__], ac_cv_cc_implements___FUNCTION__, [
Tim Rice648f8762011-01-26 12:38:57 -08003799 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]],
3800 [[ printf("%s", __FUNCTION__); ]])],
3801 [ ac_cv_cc_implements___FUNCTION__="yes" ],
3802 [ ac_cv_cc_implements___FUNCTION__="no"
3803 ])
Kevin Steves4846f4a2002-03-22 18:19:53 +00003804])
3805if test "x$ac_cv_cc_implements___FUNCTION__" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003806 AC_DEFINE([HAVE___FUNCTION__], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003807 [Define if compiler implements __FUNCTION__])
Kevin Steves4846f4a2002-03-22 18:19:53 +00003808fi
3809
3810AC_CACHE_CHECK([whether $CC implements __func__], ac_cv_cc_implements___func__, [
Tim Rice648f8762011-01-26 12:38:57 -08003811 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]],
3812 [[ printf("%s", __func__); ]])],
3813 [ ac_cv_cc_implements___func__="yes" ],
3814 [ ac_cv_cc_implements___func__="no"
3815 ])
Kevin Steves4846f4a2002-03-22 18:19:53 +00003816])
3817if test "x$ac_cv_cc_implements___func__" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003818 AC_DEFINE([HAVE___func__], [1], [Define if compiler implements __func__])
Kevin Steves4846f4a2002-03-22 18:19:53 +00003819fi
3820
Damien Miller57f39152005-11-24 19:58:19 +11003821AC_CACHE_CHECK([whether va_copy exists], ac_cv_have_va_copy, [
Tim Rice648f8762011-01-26 12:38:57 -08003822 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
3823#include <stdarg.h>
3824va_list x,y;
3825 ]], [[ va_copy(x,y); ]])],
3826 [ ac_cv_have_va_copy="yes" ],
3827 [ ac_cv_have_va_copy="no"
3828 ])
Damien Miller57f39152005-11-24 19:58:19 +11003829])
3830if test "x$ac_cv_have_va_copy" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003831 AC_DEFINE([HAVE_VA_COPY], [1], [Define if va_copy exists])
Damien Miller57f39152005-11-24 19:58:19 +11003832fi
3833
3834AC_CACHE_CHECK([whether __va_copy exists], ac_cv_have___va_copy, [
Tim Rice648f8762011-01-26 12:38:57 -08003835 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
3836#include <stdarg.h>
3837va_list x,y;
3838 ]], [[ __va_copy(x,y); ]])],
3839 [ ac_cv_have___va_copy="yes" ], [ ac_cv_have___va_copy="no"
3840 ])
Damien Miller57f39152005-11-24 19:58:19 +11003841])
3842if test "x$ac_cv_have___va_copy" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003843 AC_DEFINE([HAVE___VA_COPY], [1], [Define if __va_copy exists])
Damien Miller57f39152005-11-24 19:58:19 +11003844fi
3845
Damien Miller4f8e6692001-07-14 13:22:53 +10003846AC_CACHE_CHECK([whether getopt has optreset support],
3847 ac_cv_have_getopt_optreset, [
Tim Rice648f8762011-01-26 12:38:57 -08003848 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <getopt.h> ]],
3849 [[ extern int optreset; optreset = 0; ]])],
3850 [ ac_cv_have_getopt_optreset="yes" ],
3851 [ ac_cv_have_getopt_optreset="no"
3852 ])
Damien Miller4f8e6692001-07-14 13:22:53 +10003853])
3854if test "x$ac_cv_have_getopt_optreset" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003855 AC_DEFINE([HAVE_GETOPT_OPTRESET], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003856 [Define if your getopt(3) defines and uses optreset])
Damien Miller4f8e6692001-07-14 13:22:53 +10003857fi
Damien Millera22ba012000-03-02 23:09:20 +11003858
Damien Millerecbb26d2000-07-15 14:59:14 +10003859AC_CACHE_CHECK([if libc defines sys_errlist], ac_cv_libc_defines_sys_errlist, [
Tim Rice648f8762011-01-26 12:38:57 -08003860 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
3861[[ extern const char *const sys_errlist[]; printf("%s", sys_errlist[0]);]])],
3862 [ ac_cv_libc_defines_sys_errlist="yes" ],
3863 [ ac_cv_libc_defines_sys_errlist="no"
3864 ])
Damien Millerecbb26d2000-07-15 14:59:14 +10003865])
3866if test "x$ac_cv_libc_defines_sys_errlist" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003867 AC_DEFINE([HAVE_SYS_ERRLIST], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003868 [Define if your system defines sys_errlist[]])
Damien Millerecbb26d2000-07-15 14:59:14 +10003869fi
3870
3871
Damien Miller11fa2cc2000-08-16 10:35:58 +10003872AC_CACHE_CHECK([if libc defines sys_nerr], ac_cv_libc_defines_sys_nerr, [
Tim Rice648f8762011-01-26 12:38:57 -08003873 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
3874[[ extern int sys_nerr; printf("%i", sys_nerr);]])],
3875 [ ac_cv_libc_defines_sys_nerr="yes" ],
3876 [ ac_cv_libc_defines_sys_nerr="no"
3877 ])
Damien Miller11fa2cc2000-08-16 10:35:58 +10003878])
3879if test "x$ac_cv_libc_defines_sys_nerr" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08003880 AC_DEFINE([HAVE_SYS_NERR], [1], [Define if your system defines sys_nerr])
Damien Miller11fa2cc2000-08-16 10:35:58 +10003881fi
3882
Darren Tucker5f88d342003-10-15 16:57:57 +10003883# Check libraries needed by DNS fingerprint support
Tim Rice648f8762011-01-26 12:38:57 -08003884AC_SEARCH_LIBS([getrrsetbyname], [resolv],
3885 [AC_DEFINE([HAVE_GETRRSETBYNAME], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003886 [Define if getrrsetbyname() exists])],
Damien Miller7abe09b2003-05-15 10:53:49 +10003887 [
Darren Tucker5f88d342003-10-15 16:57:57 +10003888 # Needed by our getrrsetbyname()
Tim Rice648f8762011-01-26 12:38:57 -08003889 AC_SEARCH_LIBS([res_query], [resolv])
3890 AC_SEARCH_LIBS([dn_expand], [resolv])
3891 AC_MSG_CHECKING([if res_query will link])
3892 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckere02b49a2009-09-11 14:56:08 +10003893#include <sys/types.h>
3894#include <netinet/in.h>
3895#include <arpa/nameser.h>
3896#include <netdb.h>
3897#include <resolv.h>
Tim Rice648f8762011-01-26 12:38:57 -08003898 ]], [[
Darren Tuckere02b49a2009-09-11 14:56:08 +10003899 res_query (0, 0, 0, 0, 0);
Tim Rice648f8762011-01-26 12:38:57 -08003900 ]])],
3901 AC_MSG_RESULT([yes]),
3902 [AC_MSG_RESULT([no])
Darren Tucker8e968a52004-05-13 11:56:16 +10003903 saved_LIBS="$LIBS"
3904 LIBS="$LIBS -lresolv"
Tim Rice648f8762011-01-26 12:38:57 -08003905 AC_MSG_CHECKING([for res_query in -lresolv])
3906 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckere02b49a2009-09-11 14:56:08 +10003907#include <sys/types.h>
3908#include <netinet/in.h>
3909#include <arpa/nameser.h>
3910#include <netdb.h>
Darren Tucker8e968a52004-05-13 11:56:16 +10003911#include <resolv.h>
Tim Rice648f8762011-01-26 12:38:57 -08003912 ]], [[
Darren Tucker8e968a52004-05-13 11:56:16 +10003913 res_query (0, 0, 0, 0, 0);
Tim Rice648f8762011-01-26 12:38:57 -08003914 ]])],
3915 [AC_MSG_RESULT([yes])],
Darren Tucker8e968a52004-05-13 11:56:16 +10003916 [LIBS="$saved_LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08003917 AC_MSG_RESULT([no])])
Darren Tucker8e968a52004-05-13 11:56:16 +10003918 ])
Tim Rice648f8762011-01-26 12:38:57 -08003919 AC_CHECK_FUNCS([_getshort _getlong])
Darren Tuckerd886e1c2005-06-01 18:57:45 +10003920 AC_CHECK_DECLS([_getshort, _getlong], , ,
Tim Ricefcc7ff12005-06-02 20:28:29 -07003921 [#include <sys/types.h>
3922 #include <arpa/nameser.h>])
Tim Rice648f8762011-01-26 12:38:57 -08003923 AC_CHECK_MEMBER([HEADER.ad],
3924 [AC_DEFINE([HAVE_HEADER_AD], [1],
3925 [Define if HEADER.ad exists in arpa/nameser.h])], ,
Darren Tucker5f88d342003-10-15 16:57:57 +10003926 [#include <arpa/nameser.h>])
3927 ])
Damien Miller7abe09b2003-05-15 10:53:49 +10003928
Tim Rice648f8762011-01-26 12:38:57 -08003929AC_MSG_CHECKING([if struct __res_state _res is an extern])
3930AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Darren Tuckercc40d5e2007-04-29 13:58:06 +10003931#include <stdio.h>
3932#if HAVE_SYS_TYPES_H
3933# include <sys/types.h>
3934#endif
3935#include <netinet/in.h>
3936#include <arpa/nameser.h>
3937#include <resolv.h>
3938extern struct __res_state _res;
Tim Rice648f8762011-01-26 12:38:57 -08003939 ]], [[ ]])],
3940 [AC_MSG_RESULT([yes])
3941 AC_DEFINE([HAVE__RES_EXTERN], [1],
Darren Tuckercc40d5e2007-04-29 13:58:06 +10003942 [Define if you have struct __res_state _res as an extern])
3943 ],
Tim Rice648f8762011-01-26 12:38:57 -08003944 [ AC_MSG_RESULT([no]) ]
Darren Tuckercc40d5e2007-04-29 13:58:06 +10003945)
3946
Damien Miller73b42d22006-04-22 21:26:08 +10003947# Check whether user wants SELinux support
3948SELINUX_MSG="no"
3949LIBSELINUX=""
Tim Rice648f8762011-01-26 12:38:57 -08003950AC_ARG_WITH([selinux],
Damien Miller5b1c8b32008-03-27 12:33:07 +11003951 [ --with-selinux Enable SELinux support],
Damien Miller73b42d22006-04-22 21:26:08 +10003952 [ if test "x$withval" != "xno" ; then
Darren Tucker20e9f972007-03-25 18:26:01 +10003953 save_LIBS="$LIBS"
Tim Rice648f8762011-01-26 12:38:57 -08003954 AC_DEFINE([WITH_SELINUX], [1],
3955 [Define if you want SELinux support.])
Damien Miller73b42d22006-04-22 21:26:08 +10003956 SELINUX_MSG="yes"
3957 AC_CHECK_HEADER([selinux/selinux.h], ,
Tim Rice648f8762011-01-26 12:38:57 -08003958 AC_MSG_ERROR([SELinux support requires selinux.h header]))
3959 AC_CHECK_LIB([selinux], [setexeccon],
Damien Miller1d2bfc42010-02-10 10:19:29 +11003960 [ LIBSELINUX="-lselinux"
3961 LIBS="$LIBS -lselinux"
3962 ],
Tim Rice648f8762011-01-26 12:38:57 -08003963 AC_MSG_ERROR([SELinux support requires libselinux library]))
Damien Miller71adf122011-01-25 12:16:15 +11003964 SSHLIBS="$SSHLIBS $LIBSELINUX"
Darren Tucker20e9f972007-03-25 18:26:01 +10003965 SSHDLIBS="$SSHDLIBS $LIBSELINUX"
Tim Rice648f8762011-01-26 12:38:57 -08003966 AC_CHECK_FUNCS([getseuserbyname get_default_context_with_level])
Darren Tuckeradc947d2006-10-07 09:07:20 +10003967 LIBS="$save_LIBS"
Damien Miller73b42d22006-04-22 21:26:08 +10003968 fi ]
3969)
Tim Rice648f8762011-01-26 12:38:57 -08003970AC_SUBST([SSHLIBS])
3971AC_SUBST([SSHDLIBS])
Damien Miller73b42d22006-04-22 21:26:08 +10003972
Damien Millerfd4c9ee2002-04-13 11:04:40 +10003973# Check whether user wants Kerberos 5 support
Damien Millera8e06ce2003-11-21 23:48:55 +11003974KRB5_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08003975AC_ARG_WITH([kerberos5],
Damien Millera8e06ce2003-11-21 23:48:55 +11003976 [ --with-kerberos5=PATH Enable Kerberos 5 support],
Darren Tucker1d3ca582004-01-22 12:05:34 +11003977 [ if test "x$withval" != "xno" ; then
3978 if test "x$withval" = "xyes" ; then
3979 KRB5ROOT="/usr/local"
3980 else
3981 KRB5ROOT=${withval}
3982 fi
3983
Tim Rice648f8762011-01-26 12:38:57 -08003984 AC_DEFINE([KRB5], [1], [Define if you want Kerberos 5 support])
Darren Tucker1d3ca582004-01-22 12:05:34 +11003985 KRB5_MSG="yes"
3986
Tim Rice648f8762011-01-26 12:38:57 -08003987 AC_PATH_PROG([KRB5CONF], [krb5-config],
Darren Tuckerdad48e72009-09-01 18:26:00 +10003988 [$KRB5ROOT/bin/krb5-config],
3989 [$KRB5ROOT/bin:$PATH])
3990 if test -x $KRB5CONF ; then
Darren Tucker964de182013-02-22 10:39:59 +11003991 K5CFLAGS="`$KRB5CONF --cflags`"
3992 K5LIBS="`$KRB5CONF --libs`"
3993 CPPFLAGS="$CPPFLAGS $K5CFLAGS"
Darren Tucker1d3ca582004-01-22 12:05:34 +11003994
Tim Rice648f8762011-01-26 12:38:57 -08003995 AC_MSG_CHECKING([for gssapi support])
Darren Tucker1d3ca582004-01-22 12:05:34 +11003996 if $KRB5CONF | grep gssapi >/dev/null ; then
Tim Rice648f8762011-01-26 12:38:57 -08003997 AC_MSG_RESULT([yes])
3998 AC_DEFINE([GSSAPI], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07003999 [Define this if you want GSSAPI
4000 support in the version 2 protocol])
Darren Tucker964de182013-02-22 10:39:59 +11004001 GSSCFLAGS="`$KRB5CONF --cflags gssapi`"
4002 GSSLIBS="`$KRB5CONF --libs gssapi`"
4003 CPPFLAGS="$CPPFLAGS $GSSCFLAGS"
Damien Millera8e06ce2003-11-21 23:48:55 +11004004 else
Tim Rice648f8762011-01-26 12:38:57 -08004005 AC_MSG_RESULT([no])
Damien Millera8e06ce2003-11-21 23:48:55 +11004006 fi
Tim Rice648f8762011-01-26 12:38:57 -08004007 AC_MSG_CHECKING([whether we are using Heimdal])
4008 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <krb5.h>
4009 ]], [[ char *tmp = heimdal_version; ]])],
4010 [ AC_MSG_RESULT([yes])
4011 AC_DEFINE([HEIMDAL], [1],
4012 [Define this if you are using the Heimdal
4013 version of Kerberos V5]) ],
4014 [AC_MSG_RESULT([no])
4015 ])
Darren Tucker1d3ca582004-01-22 12:05:34 +11004016 else
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004017 CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include"
Damien Millera8e06ce2003-11-21 23:48:55 +11004018 LDFLAGS="$LDFLAGS -L${KRB5ROOT}/lib"
Tim Rice648f8762011-01-26 12:38:57 -08004019 AC_MSG_CHECKING([whether we are using Heimdal])
4020 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <krb5.h>
4021 ]], [[ char *tmp = heimdal_version; ]])],
4022 [ AC_MSG_RESULT([yes])
4023 AC_DEFINE([HEIMDAL])
Damien Miller41bccf72011-01-02 21:53:07 +11004024 K5LIBS="-lkrb5"
Damien Miller5561e0b2004-04-20 20:28:55 +10004025 K5LIBS="$K5LIBS -lcom_err -lasn1"
Tim Rice648f8762011-01-26 12:38:57 -08004026 AC_CHECK_LIB([roken], [net_write],
Damien Miller5561e0b2004-04-20 20:28:55 +10004027 [K5LIBS="$K5LIBS -lroken"])
Tim Rice648f8762011-01-26 12:38:57 -08004028 AC_CHECK_LIB([des], [des_cbc_encrypt],
Damien Miller41bccf72011-01-02 21:53:07 +11004029 [K5LIBS="$K5LIBS -ldes"])
Tim Rice648f8762011-01-26 12:38:57 -08004030 ], [ AC_MSG_RESULT([no])
Damien Millera8e06ce2003-11-21 23:48:55 +11004031 K5LIBS="-lkrb5 -lk5crypto -lcom_err"
Tim Rice648f8762011-01-26 12:38:57 -08004032
4033 ])
4034 AC_SEARCH_LIBS([dn_expand], [resolv])
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004035
Tim Rice648f8762011-01-26 12:38:57 -08004036 AC_CHECK_LIB([gssapi_krb5], [gss_init_sec_context],
4037 [ AC_DEFINE([GSSAPI])
Darren Tucker964de182013-02-22 10:39:59 +11004038 GSSLIBS="-lgssapi_krb5" ],
Tim Rice648f8762011-01-26 12:38:57 -08004039 [ AC_CHECK_LIB([gssapi], [gss_init_sec_context],
4040 [ AC_DEFINE([GSSAPI])
Darren Tucker964de182013-02-22 10:39:59 +11004041 GSSLIBS="-lgssapi" ],
Darren Tuckera2b5a4c2013-02-22 10:43:15 +11004042 [ AC_CHECK_LIB([gss], [gss_init_sec_context],
4043 [ AC_DEFINE([GSSAPI])
4044 GSSLIBS="-lgss" ],
4045 AC_MSG_WARN([Cannot find any suitable gss-api library - build may fail]))
4046 ])
Darren Tucker964de182013-02-22 10:39:59 +11004047 ])
Tim Riceeae17cc2005-03-17 16:52:20 -08004048
Tim Rice648f8762011-01-26 12:38:57 -08004049 AC_CHECK_HEADER([gssapi.h], ,
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004050 [ unset ac_cv_header_gssapi_h
Damien Millera8e06ce2003-11-21 23:48:55 +11004051 CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
Tim Rice648f8762011-01-26 12:38:57 -08004052 AC_CHECK_HEADERS([gssapi.h], ,
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004053 AC_MSG_WARN([Cannot find any suitable gss-api header - build may fail])
Damien Millera8e06ce2003-11-21 23:48:55 +11004054 )
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004055 ]
4056 )
4057
4058 oldCPP="$CPPFLAGS"
4059 CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
Tim Rice648f8762011-01-26 12:38:57 -08004060 AC_CHECK_HEADER([gssapi_krb5.h], ,
Darren Tucker49aaf4a2003-08-26 11:58:16 +10004061 [ CPPFLAGS="$oldCPP" ])
4062
Damien Millera8e06ce2003-11-21 23:48:55 +11004063 fi
Darren Tucker1d3ca582004-01-22 12:05:34 +11004064 if test ! -z "$need_dash_r" ; then
4065 LDFLAGS="$LDFLAGS -R${KRB5ROOT}/lib"
4066 fi
4067 if test ! -z "$blibpath" ; then
4068 blibpath="$blibpath:${KRB5ROOT}/lib"
4069 fi
Tim Ricefd9e9e32005-09-12 17:36:10 -07004070
Tim Rice648f8762011-01-26 12:38:57 -08004071 AC_CHECK_HEADERS([gssapi.h gssapi/gssapi.h])
4072 AC_CHECK_HEADERS([gssapi_krb5.h gssapi/gssapi_krb5.h])
4073 AC_CHECK_HEADERS([gssapi_generic.h gssapi/gssapi_generic.h])
Tim Ricefd9e9e32005-09-12 17:36:10 -07004074
Tim Rice648f8762011-01-26 12:38:57 -08004075 AC_SEARCH_LIBS([k_hasafs], [kafs], [AC_DEFINE([USE_AFS], [1],
4076 [Define this if you want to use libkafs' AFS support])])
Darren Tucker03978c62013-02-25 11:24:44 +11004077
4078 AC_CHECK_DECLS([GSS_C_NT_HOSTBASED_SERVICE], [], [], [[
4079#ifdef HAVE_GSSAPI_H
4080# include <gssapi.h>
4081#elif defined(HAVE_GSSAPI_GSSAPI_H)
4082# include <gssapi/gssapi.h>
4083#endif
4084
4085#ifdef HAVE_GSSAPI_GENERIC_H
4086# include <gssapi_generic.h>
4087#elif defined(HAVE_GSSAPI_GSSAPI_GENERIC_H)
4088# include <gssapi/gssapi_generic.h>
4089#endif
4090 ]])
Darren Tuckerf3ab2c52013-08-04 21:48:41 +10004091 saved_LIBS="$LIBS"
4092 LIBS="$LIBS $K5LIBS"
4093 AC_CHECK_FUNCS([krb5_cc_new_unique krb5_get_error_message krb5_free_error_message])
4094 LIBS="$saved_LIBS"
4095
Darren Tucker0d27ed12004-02-24 10:37:33 +11004096 fi
Darren Tucker0d27ed12004-02-24 10:37:33 +11004097 ]
Damien Millerfd4c9ee2002-04-13 11:04:40 +10004098)
Darren Tucker964de182013-02-22 10:39:59 +11004099AC_SUBST([GSSLIBS])
4100AC_SUBST([K5LIBS])
Damien Millerc79bc0d2001-03-28 13:03:42 +10004101
Damien Millera22ba012000-03-02 23:09:20 +11004102# Looking for programs, paths and files
Damien Millera22ba012000-03-02 23:09:20 +11004103
Damien Millerf58c6722002-05-13 13:15:42 +10004104PRIVSEP_PATH=/var/empty
Tim Rice648f8762011-01-26 12:38:57 -08004105AC_ARG_WITH([privsep-path],
Tim Ricecbb90662002-07-08 19:17:10 -07004106 [ --with-privsep-path=xxx Path for privilege separation chroot (default=/var/empty)],
Damien Millerf58c6722002-05-13 13:15:42 +10004107 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004108 if test -n "$withval" && test "x$withval" != "xno" && \
4109 test "x${withval}" != "xyes"; then
Damien Millerf58c6722002-05-13 13:15:42 +10004110 PRIVSEP_PATH=$withval
4111 fi
4112 ]
4113)
Tim Rice648f8762011-01-26 12:38:57 -08004114AC_SUBST([PRIVSEP_PATH])
Damien Millerf58c6722002-05-13 13:15:42 +10004115
Tim Rice648f8762011-01-26 12:38:57 -08004116AC_ARG_WITH([xauth],
Damien Millera22ba012000-03-02 23:09:20 +11004117 [ --with-xauth=PATH Specify path to xauth program ],
4118 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004119 if test -n "$withval" && test "x$withval" != "xno" && \
4120 test "x${withval}" != "xyes"; then
Damien Miller7b22d652000-06-18 14:07:04 +10004121 xauth_path=$withval
Damien Millera22ba012000-03-02 23:09:20 +11004122 fi
4123 ],
4124 [
Tim Ricee22be3b2002-07-17 19:20:07 -07004125 TestPath="$PATH"
4126 TestPath="${TestPath}${PATH_SEPARATOR}/usr/X/bin"
4127 TestPath="${TestPath}${PATH_SEPARATOR}/usr/bin/X11"
4128 TestPath="${TestPath}${PATH_SEPARATOR}/usr/X11R6/bin"
4129 TestPath="${TestPath}${PATH_SEPARATOR}/usr/openwin/bin"
Tim Rice648f8762011-01-26 12:38:57 -08004130 AC_PATH_PROG([xauth_path], [xauth], , [$TestPath])
Damien Milleredb82922000-06-20 13:25:52 +10004131 if (test ! -z "$xauth_path" && test -x "/usr/openwin/bin/xauth") ; then
Damien Millera22ba012000-03-02 23:09:20 +11004132 xauth_path="/usr/openwin/bin/xauth"
4133 fi
4134 ]
4135)
4136
Damien Miller7d901272003-01-13 16:55:22 +11004137STRIP_OPT=-s
Tim Rice648f8762011-01-26 12:38:57 -08004138AC_ARG_ENABLE([strip],
Damien Miller7d901272003-01-13 16:55:22 +11004139 [ --disable-strip Disable calling strip(1) on install],
4140 [
4141 if test "x$enableval" = "xno" ; then
4142 STRIP_OPT=
4143 fi
4144 ]
4145)
Tim Rice648f8762011-01-26 12:38:57 -08004146AC_SUBST([STRIP_OPT])
Damien Miller7d901272003-01-13 16:55:22 +11004147
Damien Millera19cf472000-11-29 13:28:50 +11004148if test -z "$xauth_path" ; then
4149 XAUTH_PATH="undefined"
Tim Rice648f8762011-01-26 12:38:57 -08004150 AC_SUBST([XAUTH_PATH])
Damien Millera19cf472000-11-29 13:28:50 +11004151else
Tim Rice648f8762011-01-26 12:38:57 -08004152 AC_DEFINE_UNQUOTED([XAUTH_PATH], ["$xauth_path"],
Tim Rice7df8d392005-09-19 09:33:39 -07004153 [Define if xauth is found in your path])
Damien Millera19cf472000-11-29 13:28:50 +11004154 XAUTH_PATH=$xauth_path
Tim Rice648f8762011-01-26 12:38:57 -08004155 AC_SUBST([XAUTH_PATH])
Damien Millera22ba012000-03-02 23:09:20 +11004156fi
Damien Millera22ba012000-03-02 23:09:20 +11004157
Tim Rice90f42b02011-06-02 18:17:49 -07004158dnl # --with-maildir=/path/to/mail gets top priority.
4159dnl # if maildir is set in the platform case statement above we use that.
4160dnl # Otherwise we run a program to get the dir from system headers.
4161dnl # We first look for _PATH_MAILDIR then MAILDIR then _PATH_MAIL
4162dnl # If we find _PATH_MAILDIR we do nothing because that is what
4163dnl # session.c expects anyway. Otherwise we set to the value found
4164dnl # stripping any trailing slash. If for some strage reason our program
4165dnl # does not find what it needs, we default to /var/spool/mail.
4166# Check for mail directory
4167AC_ARG_WITH([maildir],
4168 [ --with-maildir=/path/to/mail Specify your system mail directory],
4169 [
4170 if test "X$withval" != X && test "x$withval" != xno && \
4171 test "x${withval}" != xyes; then
4172 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$withval"],
4173 [Set this to your mail directory if you do not have _PATH_MAILDIR])
4174 fi
4175 ],[
4176 if test "X$maildir" != "X"; then
4177 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$maildir"])
4178 else
4179 AC_MSG_CHECKING([Discovering system mail directory])
4180 AC_RUN_IFELSE(
4181 [AC_LANG_PROGRAM([[
4182#include <stdio.h>
4183#include <string.h>
4184#ifdef HAVE_PATHS_H
4185#include <paths.h>
4186#endif
4187#ifdef HAVE_MAILLOCK_H
4188#include <maillock.h>
4189#endif
4190#define DATA "conftest.maildir"
4191 ]], [[
4192 FILE *fd;
4193 int rc;
4194
4195 fd = fopen(DATA,"w");
4196 if(fd == NULL)
4197 exit(1);
4198
4199#if defined (_PATH_MAILDIR)
4200 if ((rc = fprintf(fd ,"_PATH_MAILDIR:%s\n", _PATH_MAILDIR)) <0)
4201 exit(1);
4202#elif defined (MAILDIR)
4203 if ((rc = fprintf(fd ,"MAILDIR:%s\n", MAILDIR)) <0)
4204 exit(1);
4205#elif defined (_PATH_MAIL)
4206 if ((rc = fprintf(fd ,"_PATH_MAIL:%s\n", _PATH_MAIL)) <0)
4207 exit(1);
4208#else
4209 exit (2);
4210#endif
4211
4212 exit(0);
4213 ]])],
4214 [
4215 maildir_what=`awk -F: '{print $1}' conftest.maildir`
4216 maildir=`awk -F: '{print $2}' conftest.maildir \
4217 | sed 's|/$||'`
4218 AC_MSG_RESULT([Using: $maildir from $maildir_what])
4219 if test "x$maildir_what" != "x_PATH_MAILDIR"; then
4220 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$maildir"])
4221 fi
4222 ],
4223 [
4224 if test "X$ac_status" = "X2";then
4225# our test program didn't find it. Default to /var/spool/mail
4226 AC_MSG_RESULT([Using: default value of /var/spool/mail])
4227 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["/var/spool/mail"])
4228 else
4229 AC_MSG_RESULT([*** not found ***])
4230 fi
4231 ],
4232 [
4233 AC_MSG_WARN([cross compiling: use --with-maildir=/path/to/mail])
4234 ]
4235 )
4236 fi
4237 ]
4238) # maildir
Damien Millera22ba012000-03-02 23:09:20 +11004239
Darren Tucker623d92f2004-09-12 22:36:15 +10004240if test ! -z "$cross_compiling" && test "x$cross_compiling" = "xyes"; then
Darren Tuckera0c2b392004-09-11 23:26:37 +10004241 AC_MSG_WARN([cross compiling: Disabling /dev/ptmx test])
4242 disable_ptmx_check=yes
4243fi
Damien Millera22ba012000-03-02 23:09:20 +11004244if test -z "$no_dev_ptmx" ; then
Kevin Steves0ea1d9d2002-04-25 18:17:04 +00004245 if test "x$disable_ptmx_check" != "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004246 AC_CHECK_FILE(["/dev/ptmx"],
Kevin Steves0ea1d9d2002-04-25 18:17:04 +00004247 [
Tim Rice648f8762011-01-26 12:38:57 -08004248 AC_DEFINE_UNQUOTED([HAVE_DEV_PTMX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004249 [Define if you have /dev/ptmx])
Kevin Steves0ea1d9d2002-04-25 18:17:04 +00004250 have_dev_ptmx=1
4251 ]
4252 )
4253 fi
Damien Millera22ba012000-03-02 23:09:20 +11004254fi
Darren Tuckera0c2b392004-09-11 23:26:37 +10004255
Darren Tucker623d92f2004-09-12 22:36:15 +10004256if test ! -z "$cross_compiling" && test "x$cross_compiling" != "xyes"; then
Tim Rice648f8762011-01-26 12:38:57 -08004257 AC_CHECK_FILE(["/dev/ptc"],
Darren Tuckera0c2b392004-09-11 23:26:37 +10004258 [
Tim Rice648f8762011-01-26 12:38:57 -08004259 AC_DEFINE_UNQUOTED([HAVE_DEV_PTS_AND_PTC], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004260 [Define if you have /dev/ptc])
Darren Tuckera0c2b392004-09-11 23:26:37 +10004261 have_dev_ptc=1
4262 ]
4263 )
4264else
4265 AC_MSG_WARN([cross compiling: Disabling /dev/ptc test])
4266fi
Damien Miller204ad072000-03-02 23:56:12 +11004267
Damien Millera22ba012000-03-02 23:09:20 +11004268# Options from here on. Some of these are preset by platform above
Tim Rice648f8762011-01-26 12:38:57 -08004269AC_ARG_WITH([mantype],
Damien Miller897741e2001-04-16 10:41:46 +10004270 [ --with-mantype=man|cat|doc Set man page type],
Damien Miller670a4b82000-01-22 13:53:11 +11004271 [
Damien Miller897741e2001-04-16 10:41:46 +10004272 case "$withval" in
4273 man|cat|doc)
4274 MANTYPE=$withval
4275 ;;
4276 *)
Tim Rice648f8762011-01-26 12:38:57 -08004277 AC_MSG_ERROR([invalid man type: $withval])
Damien Miller897741e2001-04-16 10:41:46 +10004278 ;;
4279 esac
Damien Miller670a4b82000-01-22 13:53:11 +11004280 ]
4281)
Ben Lindstrombc709922001-04-18 18:04:21 +00004282if test -z "$MANTYPE"; then
Tim Ricee22be3b2002-07-17 19:20:07 -07004283 TestPath="/usr/bin${PATH_SEPARATOR}/usr/ucb"
Tim Rice648f8762011-01-26 12:38:57 -08004284 AC_PATH_PROGS([NROFF], [nroff awf], [/bin/false], [$TestPath])
Ben Lindstrombc709922001-04-18 18:04:21 +00004285 if ${NROFF} -mdoc ${srcdir}/ssh.1 >/dev/null 2>&1; then
4286 MANTYPE=doc
4287 elif ${NROFF} -man ${srcdir}/ssh.1 >/dev/null 2>&1; then
4288 MANTYPE=man
4289 else
4290 MANTYPE=cat
4291 fi
4292fi
Tim Rice648f8762011-01-26 12:38:57 -08004293AC_SUBST([MANTYPE])
Ben Lindstrombc709922001-04-18 18:04:21 +00004294if test "$MANTYPE" = "doc"; then
4295 mansubdir=man;
4296else
4297 mansubdir=$MANTYPE;
4298fi
Tim Rice648f8762011-01-26 12:38:57 -08004299AC_SUBST([mansubdir])
Damien Miller8bdeee21999-12-30 15:50:54 +11004300
Damien Millera22ba012000-03-02 23:09:20 +11004301# Check whether to enable MD5 passwords
Damien Millera8e06ce2003-11-21 23:48:55 +11004302MD5_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08004303AC_ARG_WITH([md5-passwords],
Damien Millerdd1c7ba1999-11-19 15:53:20 +11004304 [ --with-md5-passwords Enable use of MD5 passwords],
Damien Miller8bdeee21999-12-30 15:50:54 +11004305 [
Damien Millerb85dcad2000-03-11 11:37:00 +11004306 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004307 AC_DEFINE([HAVE_MD5_PASSWORDS], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004308 [Define if you want to allow MD5 passwords])
Damien Millera8e06ce2003-11-21 23:48:55 +11004309 MD5_MSG="yes"
Damien Miller8bdeee21999-12-30 15:50:54 +11004310 fi
4311 ]
Damien Millerdd1c7ba1999-11-19 15:53:20 +11004312)
4313
Damien Millera22ba012000-03-02 23:09:20 +11004314# Whether to disable shadow password support
Tim Rice648f8762011-01-26 12:38:57 -08004315AC_ARG_WITH([shadow],
Damien Miller76112de1999-12-21 11:18:08 +11004316 [ --without-shadow Disable shadow password support],
4317 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004318 if test "x$withval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004319 AC_DEFINE([DISABLE_SHADOW])
Damien Miller1f335fb2000-06-26 11:31:33 +10004320 disable_shadow=yes
Damien Miller76112de1999-12-21 11:18:08 +11004321 fi
4322 ]
4323)
4324
Damien Miller1f335fb2000-06-26 11:31:33 +10004325if test -z "$disable_shadow" ; then
4326 AC_MSG_CHECKING([if the systems has expire shadow information])
Tim Rice648f8762011-01-26 12:38:57 -08004327 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller1f335fb2000-06-26 11:31:33 +10004328#include <sys/types.h>
4329#include <shadow.h>
Tim Rice648f8762011-01-26 12:38:57 -08004330struct spwd sp;
4331 ]], [[ sp.sp_expire = sp.sp_lstchg = sp.sp_inact = 0; ]])],
4332 [ sp_expire_available=yes ], [
4333 ])
Damien Miller1f335fb2000-06-26 11:31:33 +10004334
4335 if test "x$sp_expire_available" = "xyes" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004336 AC_MSG_RESULT([yes])
4337 AC_DEFINE([HAS_SHADOW_EXPIRE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004338 [Define if you want to use shadow password expire field])
Damien Miller1f335fb2000-06-26 11:31:33 +10004339 else
Tim Rice648f8762011-01-26 12:38:57 -08004340 AC_MSG_RESULT([no])
Damien Miller1f335fb2000-06-26 11:31:33 +10004341 fi
4342fi
4343
Damien Millera22ba012000-03-02 23:09:20 +11004344# Use ip address instead of hostname in $DISPLAY
Damien Miller9a947342000-08-30 10:03:33 +11004345if test ! -z "$IPADDR_IN_DISPLAY" ; then
4346 DISPLAY_HACK_MSG="yes"
Tim Rice648f8762011-01-26 12:38:57 -08004347 AC_DEFINE([IPADDR_IN_DISPLAY], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004348 [Define if you need to use IP address
4349 instead of hostname in $DISPLAY])
Damien Miller9a947342000-08-30 10:03:33 +11004350else
Damien Millera8e06ce2003-11-21 23:48:55 +11004351 DISPLAY_HACK_MSG="no"
Tim Rice648f8762011-01-26 12:38:57 -08004352 AC_ARG_WITH([ipaddr-display],
Damien Miller9a947342000-08-30 10:03:33 +11004353 [ --with-ipaddr-display Use ip address instead of hostname in \$DISPLAY],
4354 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004355 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004356 AC_DEFINE([IPADDR_IN_DISPLAY])
Damien Millera8e06ce2003-11-21 23:48:55 +11004357 DISPLAY_HACK_MSG="yes"
Damien Miller9a947342000-08-30 10:03:33 +11004358 fi
4359 ]
4360 )
4361fi
Damien Miller76112de1999-12-21 11:18:08 +11004362
Darren Tuckere1a790d2003-09-16 11:52:19 +10004363# check for /etc/default/login and use it if present.
Tim Rice648f8762011-01-26 12:38:57 -08004364AC_ARG_ENABLE([etc-default-login],
Darren Tucker1b6f2292005-02-11 16:11:49 +11004365 [ --disable-etc-default-login Disable using PATH from /etc/default/login [no]],
Darren Tucker2f9573d2005-02-10 22:28:54 +11004366 [ if test "x$enableval" = "xno"; then
4367 AC_MSG_NOTICE([/etc/default/login handling disabled])
4368 etc_default_login=no
4369 else
4370 etc_default_login=yes
4371 fi ],
Darren Tucker314d89e2005-10-17 23:29:23 +10004372 [ if test ! -z "$cross_compiling" && test "x$cross_compiling" = "xyes";
4373 then
4374 AC_MSG_WARN([cross compiling: not checking /etc/default/login])
4375 etc_default_login=no
4376 else
4377 etc_default_login=yes
4378 fi ]
Darren Tucker2f9573d2005-02-10 22:28:54 +11004379)
Darren Tuckere1a790d2003-09-16 11:52:19 +10004380
Darren Tucker2f9573d2005-02-10 22:28:54 +11004381if test "x$etc_default_login" != "xno"; then
Tim Rice648f8762011-01-26 12:38:57 -08004382 AC_CHECK_FILE(["/etc/default/login"],
Darren Tucker2f9573d2005-02-10 22:28:54 +11004383 [ external_path_file=/etc/default/login ])
Darren Tucker314d89e2005-10-17 23:29:23 +10004384 if test "x$external_path_file" = "x/etc/default/login"; then
Tim Rice648f8762011-01-26 12:38:57 -08004385 AC_DEFINE([HAVE_ETC_DEFAULT_LOGIN], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004386 [Define if your system has /etc/default/login])
Darren Tuckera0c2b392004-09-11 23:26:37 +10004387 fi
Darren Tucker2f9573d2005-02-10 22:28:54 +11004388fi
Darren Tuckere1a790d2003-09-16 11:52:19 +10004389
Tim Rice43a1c132002-04-17 21:19:14 -07004390dnl BSD systems use /etc/login.conf so --with-default-path= has no effect
Tim Rice8bb561b2005-03-17 16:23:19 -08004391if test $ac_cv_func_login_getcapbool = "yes" && \
4392 test $ac_cv_header_login_cap_h = "yes" ; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10004393 external_path_file=/etc/login.conf
Tim Rice43a1c132002-04-17 21:19:14 -07004394fi
Darren Tuckere1a790d2003-09-16 11:52:19 +10004395
Damien Millera22ba012000-03-02 23:09:20 +11004396# Whether to mess with the default path
Damien Millera8e06ce2003-11-21 23:48:55 +11004397SERVER_PATH_MSG="(default)"
Tim Rice648f8762011-01-26 12:38:57 -08004398AC_ARG_WITH([default-path],
Damien Millerf71d2a52002-05-13 15:14:08 +10004399 [ --with-default-path= Specify default \$PATH environment for server],
Damien Miller5a3e6831999-12-27 09:48:56 +11004400 [
Darren Tuckere1a790d2003-09-16 11:52:19 +10004401 if test "x$external_path_file" = "x/etc/login.conf" ; then
Tim Rice43a1c132002-04-17 21:19:14 -07004402 AC_MSG_WARN([
4403--with-default-path=PATH has no effect on this system.
4404Edit /etc/login.conf instead.])
Tim Riceeae17cc2005-03-17 16:52:20 -08004405 elif test "x$withval" != "xno" ; then
Tim Riceb925b4b2003-09-15 22:40:49 -07004406 if test ! -z "$external_path_file" ; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10004407 AC_MSG_WARN([
4408--with-default-path=PATH will only be used if PATH is not defined in
4409$external_path_file .])
4410 fi
Tim Rice59ea0a02001-03-10 13:50:45 -08004411 user_path="$withval"
Damien Millera8e06ce2003-11-21 23:48:55 +11004412 SERVER_PATH_MSG="$withval"
Damien Miller5a3e6831999-12-27 09:48:56 +11004413 fi
Tim Rice59ea0a02001-03-10 13:50:45 -08004414 ],
Darren Tuckere1a790d2003-09-16 11:52:19 +10004415 [ if test "x$external_path_file" = "x/etc/login.conf" ; then
4416 AC_MSG_WARN([Make sure the path to scp is in /etc/login.conf])
Tim Rice43a1c132002-04-17 21:19:14 -07004417 else
Tim Riceb925b4b2003-09-15 22:40:49 -07004418 if test ! -z "$external_path_file" ; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10004419 AC_MSG_WARN([
4420If PATH is defined in $external_path_file, ensure the path to scp is included,
4421otherwise scp will not work.])
4422 fi
Darren Tucker314d89e2005-10-17 23:29:23 +10004423 AC_RUN_IFELSE(
Tim Rice648f8762011-01-26 12:38:57 -08004424 [AC_LANG_PROGRAM([[
Tim Rice59ea0a02001-03-10 13:50:45 -08004425/* find out what STDPATH is */
4426#include <stdio.h>
Tim Rice59ea0a02001-03-10 13:50:45 -08004427#ifdef HAVE_PATHS_H
4428# include <paths.h>
4429#endif
4430#ifndef _PATH_STDPATH
Tim Rice1c9e6882002-11-22 13:29:01 -08004431# ifdef _PATH_USERPATH /* Irix */
4432# define _PATH_STDPATH _PATH_USERPATH
4433# else
4434# define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
4435# endif
Tim Rice59ea0a02001-03-10 13:50:45 -08004436#endif
4437#include <sys/types.h>
4438#include <sys/stat.h>
4439#include <fcntl.h>
4440#define DATA "conftest.stdpath"
Tim Rice648f8762011-01-26 12:38:57 -08004441 ]], [[
Tim Rice59ea0a02001-03-10 13:50:45 -08004442 FILE *fd;
4443 int rc;
Tim Riceeae17cc2005-03-17 16:52:20 -08004444
Tim Rice59ea0a02001-03-10 13:50:45 -08004445 fd = fopen(DATA,"w");
4446 if(fd == NULL)
4447 exit(1);
Tim Riceeae17cc2005-03-17 16:52:20 -08004448
Tim Rice59ea0a02001-03-10 13:50:45 -08004449 if ((rc = fprintf(fd,"%s", _PATH_STDPATH)) < 0)
4450 exit(1);
4451
4452 exit(0);
Darren Tucker314d89e2005-10-17 23:29:23 +10004453 ]])],
4454 [ user_path=`cat conftest.stdpath` ],
Tim Rice59ea0a02001-03-10 13:50:45 -08004455 [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ],
4456 [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ]
4457 )
4458# make sure $bindir is in USER_PATH so scp will work
Damien Miller77eab7b2012-07-06 11:49:28 +10004459 t_bindir="${bindir}"
4460 while echo "${t_bindir}" | egrep '\$\{|NONE/' >/dev/null 2>&1; do
4461 t_bindir=`eval echo ${t_bindir}`
4462 case $t_bindir in
4463 NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$prefix~"` ;;
4464 esac
4465 case $t_bindir in
4466 NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$ac_default_prefix~"` ;;
4467 esac
4468 done
Tim Rice59ea0a02001-03-10 13:50:45 -08004469 echo $user_path | grep ":$t_bindir" > /dev/null 2>&1
4470 if test $? -ne 0 ; then
4471 echo $user_path | grep "^$t_bindir" > /dev/null 2>&1
4472 if test $? -ne 0 ; then
4473 user_path=$user_path:$t_bindir
Tim Rice648f8762011-01-26 12:38:57 -08004474 AC_MSG_RESULT([Adding $t_bindir to USER_PATH so scp will work])
Tim Rice59ea0a02001-03-10 13:50:45 -08004475 fi
4476 fi
Tim Rice43a1c132002-04-17 21:19:14 -07004477 fi ]
Damien Miller5a3e6831999-12-27 09:48:56 +11004478)
Darren Tuckere1a790d2003-09-16 11:52:19 +10004479if test "x$external_path_file" != "x/etc/login.conf" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004480 AC_DEFINE_UNQUOTED([USER_PATH], ["$user_path"], [Specify default $PATH])
4481 AC_SUBST([user_path])
Tim Rice43a1c132002-04-17 21:19:14 -07004482fi
Damien Miller5a3e6831999-12-27 09:48:56 +11004483
Damien Millera18bbd32002-05-13 10:48:57 +10004484# Set superuser path separately to user path
Tim Rice648f8762011-01-26 12:38:57 -08004485AC_ARG_WITH([superuser-path],
Damien Millera18bbd32002-05-13 10:48:57 +10004486 [ --with-superuser-path= Specify different path for super-user],
4487 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004488 if test -n "$withval" && test "x$withval" != "xno" && \
4489 test "x${withval}" != "xyes"; then
Tim Rice648f8762011-01-26 12:38:57 -08004490 AC_DEFINE_UNQUOTED([SUPERUSER_PATH], ["$withval"],
Tim Rice7df8d392005-09-19 09:33:39 -07004491 [Define if you want a different $PATH
4492 for the superuser])
Damien Millera18bbd32002-05-13 10:48:57 +10004493 superuser_path=$withval
4494 fi
4495 ]
4496)
4497
4498
Damien Miller61e50f12000-05-08 20:49:37 +10004499AC_MSG_CHECKING([if we need to convert IPv4 in IPv6-mapped addresses])
Damien Millera8e06ce2003-11-21 23:48:55 +11004500IPV4_IN6_HACK_MSG="no"
Damien Miller7bcb0892000-03-11 20:45:40 +11004501AC_ARG_WITH(4in6,
4502 [ --with-4in6 Check for and convert IPv4 in IPv6 mapped addresses],
4503 [
4504 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004505 AC_MSG_RESULT([yes])
4506 AC_DEFINE([IPV4_IN_IPV6], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004507 [Detect IPv4 in IPv6 mapped addresses
4508 and treat as IPv4])
Damien Millera8e06ce2003-11-21 23:48:55 +11004509 IPV4_IN6_HACK_MSG="yes"
Damien Miller7bcb0892000-03-11 20:45:40 +11004510 else
Tim Rice648f8762011-01-26 12:38:57 -08004511 AC_MSG_RESULT([no])
Damien Miller7bcb0892000-03-11 20:45:40 +11004512 fi
Tim Rice648f8762011-01-26 12:38:57 -08004513 ], [
Damien Miller7bcb0892000-03-11 20:45:40 +11004514 if test "x$inet6_default_4in6" = "xyes"; then
4515 AC_MSG_RESULT([yes (default)])
Tim Rice648f8762011-01-26 12:38:57 -08004516 AC_DEFINE([IPV4_IN_IPV6])
Damien Millera8e06ce2003-11-21 23:48:55 +11004517 IPV4_IN6_HACK_MSG="yes"
Damien Miller7bcb0892000-03-11 20:45:40 +11004518 else
4519 AC_MSG_RESULT([no (default)])
4520 fi
4521 ]
4522)
4523
Damien Miller60396b02001-02-18 17:01:00 +11004524# Whether to enable BSD auth support
Damien Miller6c21c512002-01-22 21:57:53 +11004525BSD_AUTH_MSG=no
Tim Rice648f8762011-01-26 12:38:57 -08004526AC_ARG_WITH([bsd-auth],
Damien Miller60396b02001-02-18 17:01:00 +11004527 [ --with-bsd-auth Enable BSD auth support],
4528 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004529 if test "x$withval" != "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004530 AC_DEFINE([BSD_AUTH], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004531 [Define if you have BSD auth support])
Damien Miller6c21c512002-01-22 21:57:53 +11004532 BSD_AUTH_MSG=yes
Damien Miller60396b02001-02-18 17:01:00 +11004533 fi
4534 ]
4535)
4536
Damien Millera22ba012000-03-02 23:09:20 +11004537# Where to place sshd.pid
Damien Millerb13c73e2000-01-17 22:02:17 +11004538piddir=/var/run
Damien Miller78315eb2000-09-29 23:01:36 +11004539# make sure the directory exists
Tim Riceeae17cc2005-03-17 16:52:20 -08004540if test ! -d $piddir ; then
Damien Miller78315eb2000-09-29 23:01:36 +11004541 piddir=`eval echo ${sysconfdir}`
4542 case $piddir in
Damien Millera8e06ce2003-11-21 23:48:55 +11004543 NONE/*) piddir=`echo $piddir | sed "s~NONE~$ac_default_prefix~"` ;;
Damien Miller78315eb2000-09-29 23:01:36 +11004544 esac
4545fi
4546
Tim Rice648f8762011-01-26 12:38:57 -08004547AC_ARG_WITH([pid-dir],
Tim Rice88f2ab52002-03-17 12:17:34 -08004548 [ --with-pid-dir=PATH Specify location of ssh.pid file],
4549 [
Tim Rice35cc69d2005-03-17 16:44:25 -08004550 if test -n "$withval" && test "x$withval" != "xno" && \
4551 test "x${withval}" != "xyes"; then
Tim Rice88f2ab52002-03-17 12:17:34 -08004552 piddir=$withval
Tim Riceeae17cc2005-03-17 16:52:20 -08004553 if test ! -d $piddir ; then
Tim Rice88f2ab52002-03-17 12:17:34 -08004554 AC_MSG_WARN([** no $piddir directory on this system **])
4555 fi
4556 fi
4557 ]
4558)
4559
Tim Rice648f8762011-01-26 12:38:57 -08004560AC_DEFINE_UNQUOTED([_PATH_SSH_PIDDIR], ["$piddir"],
4561 [Specify location of ssh.pid])
4562AC_SUBST([piddir])
Damien Miller5eed6a22000-01-16 12:05:18 +11004563
andre2ff7b5d2000-06-03 14:57:40 +00004564dnl allow user to disable some login recording features
Tim Rice648f8762011-01-26 12:38:57 -08004565AC_ARG_ENABLE([lastlog],
andre43ca7e22000-06-19 08:23:46 +00004566 [ --disable-lastlog disable use of lastlog even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004567 [
4568 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004569 AC_DEFINE([DISABLE_LASTLOG])
Darren Tuckera3020db2003-06-28 12:54:33 +10004570 fi
4571 ]
andre2ff7b5d2000-06-03 14:57:40 +00004572)
Tim Rice648f8762011-01-26 12:38:57 -08004573AC_ARG_ENABLE([utmp],
andre43ca7e22000-06-19 08:23:46 +00004574 [ --disable-utmp disable use of utmp even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004575 [
4576 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004577 AC_DEFINE([DISABLE_UTMP])
Darren Tuckera3020db2003-06-28 12:54:33 +10004578 fi
4579 ]
andre2ff7b5d2000-06-03 14:57:40 +00004580)
Tim Rice648f8762011-01-26 12:38:57 -08004581AC_ARG_ENABLE([utmpx],
andre43ca7e22000-06-19 08:23:46 +00004582 [ --disable-utmpx disable use of utmpx even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004583 [
4584 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004585 AC_DEFINE([DISABLE_UTMPX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004586 [Define if you don't want to use utmpx])
Darren Tuckera3020db2003-06-28 12:54:33 +10004587 fi
4588 ]
andre2ff7b5d2000-06-03 14:57:40 +00004589)
Tim Rice648f8762011-01-26 12:38:57 -08004590AC_ARG_ENABLE([wtmp],
andre43ca7e22000-06-19 08:23:46 +00004591 [ --disable-wtmp disable use of wtmp even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004592 [
4593 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004594 AC_DEFINE([DISABLE_WTMP])
Darren Tuckera3020db2003-06-28 12:54:33 +10004595 fi
4596 ]
andre2ff7b5d2000-06-03 14:57:40 +00004597)
Tim Rice648f8762011-01-26 12:38:57 -08004598AC_ARG_ENABLE([wtmpx],
andre43ca7e22000-06-19 08:23:46 +00004599 [ --disable-wtmpx disable use of wtmpx even if detected [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004600 [
4601 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004602 AC_DEFINE([DISABLE_WTMPX], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004603 [Define if you don't want to use wtmpx])
Darren Tuckera3020db2003-06-28 12:54:33 +10004604 fi
4605 ]
andre2ff7b5d2000-06-03 14:57:40 +00004606)
Tim Rice648f8762011-01-26 12:38:57 -08004607AC_ARG_ENABLE([libutil],
andre43ca7e22000-06-19 08:23:46 +00004608 [ --disable-libutil disable use of libutil (login() etc.) [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004609 [
4610 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004611 AC_DEFINE([DISABLE_LOGIN])
Darren Tuckera3020db2003-06-28 12:54:33 +10004612 fi
4613 ]
andre2ff7b5d2000-06-03 14:57:40 +00004614)
Tim Rice648f8762011-01-26 12:38:57 -08004615AC_ARG_ENABLE([pututline],
andre43ca7e22000-06-19 08:23:46 +00004616 [ --disable-pututline disable use of pututline() etc. ([uw]tmp) [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004617 [
4618 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004619 AC_DEFINE([DISABLE_PUTUTLINE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004620 [Define if you don't want to use pututline()
4621 etc. to write [uw]tmp])
Darren Tuckera3020db2003-06-28 12:54:33 +10004622 fi
4623 ]
andre2ff7b5d2000-06-03 14:57:40 +00004624)
Tim Rice648f8762011-01-26 12:38:57 -08004625AC_ARG_ENABLE([pututxline],
andre43ca7e22000-06-19 08:23:46 +00004626 [ --disable-pututxline disable use of pututxline() etc. ([uw]tmpx) [no]],
Darren Tuckera3020db2003-06-28 12:54:33 +10004627 [
4628 if test "x$enableval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004629 AC_DEFINE([DISABLE_PUTUTXLINE], [1],
Tim Rice7df8d392005-09-19 09:33:39 -07004630 [Define if you don't want to use pututxline()
4631 etc. to write [uw]tmpx])
Darren Tuckera3020db2003-06-28 12:54:33 +10004632 fi
4633 ]
andre2ff7b5d2000-06-03 14:57:40 +00004634)
Tim Rice648f8762011-01-26 12:38:57 -08004635AC_ARG_WITH([lastlog],
andre43ca7e22000-06-19 08:23:46 +00004636 [ --with-lastlog=FILE|DIR specify lastlog location [common locations]],
Damien Miller709528a2001-01-31 09:57:55 +11004637 [
Tim Riceeae17cc2005-03-17 16:52:20 -08004638 if test "x$withval" = "xno" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004639 AC_DEFINE([DISABLE_LASTLOG])
Tim Rice35cc69d2005-03-17 16:44:25 -08004640 elif test -n "$withval" && test "x${withval}" != "xyes"; then
Damien Miller709528a2001-01-31 09:57:55 +11004641 conf_lastlog_location=$withval
4642 fi
4643 ]
4644)
andre2ff7b5d2000-06-03 14:57:40 +00004645
4646dnl lastlog, [uw]tmpx? detection
4647dnl NOTE: set the paths in the platform section to avoid the
4648dnl need for command-line parameters
4649dnl lastlog and [uw]tmp are subject to a file search if all else fails
4650
4651dnl lastlog detection
4652dnl NOTE: the code itself will detect if lastlog is a directory
4653AC_MSG_CHECKING([if your system defines LASTLOG_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08004654AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00004655#include <sys/types.h>
4656#include <utmp.h>
4657#ifdef HAVE_LASTLOG_H
4658# include <lastlog.h>
4659#endif
Damien Miller2994e082000-06-04 15:51:47 +10004660#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00004661# include <paths.h>
4662#endif
Ben Lindstrom19d7b8d2001-08-16 00:09:49 +00004663#ifdef HAVE_LOGIN_H
4664# include <login.h>
4665#endif
Tim Rice648f8762011-01-26 12:38:57 -08004666 ]], [[ char *lastlog = LASTLOG_FILE; ]])],
4667 [ AC_MSG_RESULT([yes]) ],
4668 [
4669 AC_MSG_RESULT([no])
Damien Miller2994e082000-06-04 15:51:47 +10004670 AC_MSG_CHECKING([if your system defines _PATH_LASTLOG])
Tim Rice648f8762011-01-26 12:38:57 -08004671 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Damien Miller2994e082000-06-04 15:51:47 +10004672#include <sys/types.h>
4673#include <utmp.h>
4674#ifdef HAVE_LASTLOG_H
4675# include <lastlog.h>
4676#endif
4677#ifdef HAVE_PATHS_H
4678# include <paths.h>
4679#endif
Tim Rice648f8762011-01-26 12:38:57 -08004680 ]], [[ char *lastlog = _PATH_LASTLOG; ]])],
4681 [ AC_MSG_RESULT([yes]) ],
Damien Miller2994e082000-06-04 15:51:47 +10004682 [
Tim Rice648f8762011-01-26 12:38:57 -08004683 AC_MSG_RESULT([no])
Damien Miller2994e082000-06-04 15:51:47 +10004684 system_lastlog_path=no
4685 ])
Tim Rice648f8762011-01-26 12:38:57 -08004686])
Damien Miller2994e082000-06-04 15:51:47 +10004687
andre2ff7b5d2000-06-03 14:57:40 +00004688if test -z "$conf_lastlog_location"; then
4689 if test x"$system_lastlog_path" = x"no" ; then
4690 for f in /var/log/lastlog /usr/adm/lastlog /var/adm/lastlog /etc/security/lastlog ; do
Damien Milleredb82922000-06-20 13:25:52 +10004691 if (test -d "$f" || test -f "$f") ; then
andre2ff7b5d2000-06-03 14:57:40 +00004692 conf_lastlog_location=$f
4693 fi
4694 done
4695 if test -z "$conf_lastlog_location"; then
andre45cad512000-06-12 23:27:31 +00004696 AC_MSG_WARN([** Cannot find lastlog **])
4697 dnl Don't define DISABLE_LASTLOG - that means we don't try wtmp/wtmpx
andre2ff7b5d2000-06-03 14:57:40 +00004698 fi
4699 fi
4700fi
4701
4702if test -n "$conf_lastlog_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08004703 AC_DEFINE_UNQUOTED([CONF_LASTLOG_FILE], ["$conf_lastlog_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07004704 [Define if you want to specify the path to your lastlog file])
Tim Riceeae17cc2005-03-17 16:52:20 -08004705fi
andre2ff7b5d2000-06-03 14:57:40 +00004706
4707dnl utmp detection
4708AC_MSG_CHECKING([if your system defines UTMP_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08004709AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00004710#include <sys/types.h>
4711#include <utmp.h>
Damien Miller2994e082000-06-04 15:51:47 +10004712#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00004713# include <paths.h>
4714#endif
Tim Rice648f8762011-01-26 12:38:57 -08004715 ]], [[ char *utmp = UTMP_FILE; ]])],
4716 [ AC_MSG_RESULT([yes]) ],
4717 [ AC_MSG_RESULT([no])
4718 system_utmp_path=no
4719])
andre2ff7b5d2000-06-03 14:57:40 +00004720if test -z "$conf_utmp_location"; then
4721 if test x"$system_utmp_path" = x"no" ; then
4722 for f in /etc/utmp /usr/adm/utmp /var/run/utmp; do
4723 if test -f $f ; then
4724 conf_utmp_location=$f
4725 fi
4726 done
4727 if test -z "$conf_utmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08004728 AC_DEFINE([DISABLE_UTMP])
andre2ff7b5d2000-06-03 14:57:40 +00004729 fi
4730 fi
4731fi
4732if test -n "$conf_utmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08004733 AC_DEFINE_UNQUOTED([CONF_UTMP_FILE], ["$conf_utmp_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07004734 [Define if you want to specify the path to your utmp file])
Tim Riceeae17cc2005-03-17 16:52:20 -08004735fi
andre2ff7b5d2000-06-03 14:57:40 +00004736
4737dnl wtmp detection
4738AC_MSG_CHECKING([if your system defines WTMP_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08004739AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00004740#include <sys/types.h>
4741#include <utmp.h>
Damien Miller2994e082000-06-04 15:51:47 +10004742#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00004743# include <paths.h>
4744#endif
Tim Rice648f8762011-01-26 12:38:57 -08004745 ]], [[ char *wtmp = WTMP_FILE; ]])],
4746 [ AC_MSG_RESULT([yes]) ],
4747 [ AC_MSG_RESULT([no])
4748 system_wtmp_path=no
4749])
andre2ff7b5d2000-06-03 14:57:40 +00004750if test -z "$conf_wtmp_location"; then
4751 if test x"$system_wtmp_path" = x"no" ; then
4752 for f in /usr/adm/wtmp /var/log/wtmp; do
4753 if test -f $f ; then
4754 conf_wtmp_location=$f
4755 fi
4756 done
4757 if test -z "$conf_wtmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08004758 AC_DEFINE([DISABLE_WTMP])
andre2ff7b5d2000-06-03 14:57:40 +00004759 fi
4760 fi
4761fi
4762if test -n "$conf_wtmp_location"; then
Tim Rice648f8762011-01-26 12:38:57 -08004763 AC_DEFINE_UNQUOTED([CONF_WTMP_FILE], ["$conf_wtmp_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07004764 [Define if you want to specify the path to your wtmp file])
Tim Riceeae17cc2005-03-17 16:52:20 -08004765fi
andre2ff7b5d2000-06-03 14:57:40 +00004766
andre2ff7b5d2000-06-03 14:57:40 +00004767dnl wtmpx detection
4768AC_MSG_CHECKING([if your system defines WTMPX_FILE])
Tim Rice648f8762011-01-26 12:38:57 -08004769AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
andre2ff7b5d2000-06-03 14:57:40 +00004770#include <sys/types.h>
4771#include <utmp.h>
4772#ifdef HAVE_UTMPX_H
4773#include <utmpx.h>
4774#endif
Damien Miller2994e082000-06-04 15:51:47 +10004775#ifdef HAVE_PATHS_H
andre2ff7b5d2000-06-03 14:57:40 +00004776# include <paths.h>
4777#endif
Tim Rice648f8762011-01-26 12:38:57 -08004778 ]], [[ char *wtmpx = WTMPX_FILE; ]])],
4779 [ AC_MSG_RESULT([yes]) ],
4780 [ AC_MSG_RESULT([no])
4781 system_wtmpx_path=no
4782])
andre2ff7b5d2000-06-03 14:57:40 +00004783if test -z "$conf_wtmpx_location"; then
4784 if test x"$system_wtmpx_path" = x"no" ; then
Tim Rice648f8762011-01-26 12:38:57 -08004785 AC_DEFINE([DISABLE_WTMPX])
andre2ff7b5d2000-06-03 14:57:40 +00004786 fi
4787else
Tim Rice648f8762011-01-26 12:38:57 -08004788 AC_DEFINE_UNQUOTED([CONF_WTMPX_FILE], ["$conf_wtmpx_location"],
Tim Rice7df8d392005-09-19 09:33:39 -07004789 [Define if you want to specify the path to your wtmpx file])
Tim Riceeae17cc2005-03-17 16:52:20 -08004790fi
andre2ff7b5d2000-06-03 14:57:40 +00004791
Damien Miller4018c192000-04-30 09:30:44 +10004792
Damien Miller29ea30d2000-03-17 10:54:15 +11004793if test ! -z "$blibpath" ; then
Damien Millereab4bae2003-04-29 23:22:40 +10004794 LDFLAGS="$LDFLAGS $blibflags$blibpath"
4795 AC_MSG_WARN([Please check and edit blibpath in LDFLAGS in Makefile])
Damien Miller29ea30d2000-03-17 10:54:15 +11004796fi
4797
Damien Millera2438bb2013-03-15 10:23:07 +11004798AC_CHECK_MEMBER([struct lastlog.ll_line], [], [
Tim Riceaa86c392013-03-16 20:55:46 -07004799 if test x$SKIP_DISABLE_LASTLOG_DEFINE != "xyes" ; then
Damien Millera2438bb2013-03-15 10:23:07 +11004800 AC_DEFINE([DISABLE_LASTLOG])
Tim Riceaa86c392013-03-16 20:55:46 -07004801 fi
Damien Millera2438bb2013-03-15 10:23:07 +11004802 ], [
4803#ifdef HAVE_SYS_TYPES_H
4804#include <sys/types.h>
4805#endif
4806#ifdef HAVE_UTMP_H
4807#include <utmp.h>
4808#endif
4809#ifdef HAVE_UTMPX_H
4810#include <utmpx.h>
4811#endif
4812#ifdef HAVE_LASTLOG_H
4813#include <lastlog.h>
4814#endif
4815 ])
4816
4817AC_CHECK_MEMBER([struct utmp.ut_line], [], [
4818 AC_DEFINE([DISABLE_UTMP])
4819 AC_DEFINE([DISABLE_WTMP])
4820 ], [
4821#ifdef HAVE_SYS_TYPES_H
4822#include <sys/types.h>
4823#endif
4824#ifdef HAVE_UTMP_H
4825#include <utmp.h>
4826#endif
4827#ifdef HAVE_UTMPX_H
4828#include <utmpx.h>
4829#endif
4830#ifdef HAVE_LASTLOG_H
4831#include <lastlog.h>
4832#endif
4833 ])
4834
Darren Tucker7da23cb2005-08-03 00:20:15 +10004835dnl Adding -Werror to CFLAGS early prevents configure tests from running.
4836dnl Add now.
4837CFLAGS="$CFLAGS $werror_flags"
4838
Darren Tucker627337d2010-04-10 22:58:01 +10004839if test "x$ac_cv_func_getaddrinfo" != "xyes" ; then
4840 TEST_SSH_IPV6=no
4841else
4842 TEST_SSH_IPV6=yes
4843fi
Tim Rice648f8762011-01-26 12:38:57 -08004844AC_CHECK_DECL([BROKEN_GETADDRINFO], [TEST_SSH_IPV6=no])
4845AC_SUBST([TEST_SSH_IPV6], [$TEST_SSH_IPV6])
Darren Tucker882abfd2013-11-09 00:17:41 +11004846AC_SUBST([TEST_MALLOC_OPTIONS], [$TEST_MALLOC_OPTIONS])
Darren Tucker6d8bd572013-06-11 11:26:10 +10004847AC_SUBST([UNSUPPORTED_ALGORITHMS], [$unsupported_algorithms])
Darren Tucker5d376902008-06-11 04:15:05 +10004848
Damien Millerbac2d8a2000-09-05 16:13:06 +11004849AC_EXEEXT
Damien Miller223897a2006-09-12 21:54:10 +10004850AC_CONFIG_FILES([Makefile buildpkg.sh opensshd.init openssh.xml \
4851 openbsd-compat/Makefile openbsd-compat/regress/Makefile \
Damien Millerf22019b2011-05-05 13:48:37 +10004852 survey.sh])
Tim Rice13aae5e2001-10-21 17:53:58 -07004853AC_OUTPUT
Damien Miller0437b332000-05-02 09:56:41 +10004854
Damien Miller7b22d652000-06-18 14:07:04 +10004855# Print summary of options
4856
Damien Miller7b22d652000-06-18 14:07:04 +10004857# Someone please show me a better way :)
4858A=`eval echo ${prefix}` ; A=`eval echo ${A}`
4859B=`eval echo ${bindir}` ; B=`eval echo ${B}`
4860C=`eval echo ${sbindir}` ; C=`eval echo ${C}`
4861D=`eval echo ${sysconfdir}` ; D=`eval echo ${D}`
Kevin Stevese0f49142000-10-14 17:51:48 +00004862E=`eval echo ${libexecdir}/ssh-askpass` ; E=`eval echo ${E}`
Ben Lindstrombc709922001-04-18 18:04:21 +00004863F=`eval echo ${mandir}/${mansubdir}X` ; F=`eval echo ${F}`
Damien Miller7b22d652000-06-18 14:07:04 +10004864G=`eval echo ${piddir}` ; G=`eval echo ${G}`
Damien Millerf58c6722002-05-13 13:15:42 +10004865H=`eval echo ${PRIVSEP_PATH}` ; H=`eval echo ${H}`
4866I=`eval echo ${user_path}` ; I=`eval echo ${I}`
4867J=`eval echo ${superuser_path}` ; J=`eval echo ${J}`
Damien Miller7b22d652000-06-18 14:07:04 +10004868
4869echo ""
Kevin Steves393d2f72001-04-08 22:50:43 +00004870echo "OpenSSH has been configured with the following options:"
Damien Millerf58c6722002-05-13 13:15:42 +10004871echo " User binaries: $B"
4872echo " System binaries: $C"
4873echo " Configuration files: $D"
4874echo " Askpass program: $E"
4875echo " Manual pages: $F"
4876echo " PID file: $G"
4877echo " Privilege separation chroot path: $H"
Darren Tuckere1a790d2003-09-16 11:52:19 +10004878if test "x$external_path_file" = "x/etc/login.conf" ; then
4879echo " At runtime, sshd will use the path defined in $external_path_file"
4880echo " Make sure the path to scp is present, otherwise scp will not work"
Tim Rice43a1c132002-04-17 21:19:14 -07004881else
Damien Millerf58c6722002-05-13 13:15:42 +10004882echo " sshd default user PATH: $I"
Tim Riceb925b4b2003-09-15 22:40:49 -07004883 if test ! -z "$external_path_file"; then
Darren Tuckere1a790d2003-09-16 11:52:19 +10004884echo " (If PATH is set in $external_path_file it will be used instead. If"
4885echo " used, ensure the path to scp is present, otherwise scp will not work.)"
4886 fi
Tim Rice43a1c132002-04-17 21:19:14 -07004887fi
Damien Millera18bbd32002-05-13 10:48:57 +10004888if test ! -z "$superuser_path" ; then
Damien Millerf58c6722002-05-13 13:15:42 +10004889echo " sshd superuser user PATH: $J"
Damien Millera18bbd32002-05-13 10:48:57 +10004890fi
Damien Millerf58c6722002-05-13 13:15:42 +10004891echo " Manpage format: $MANTYPE"
Damien Miller7abe09b2003-05-15 10:53:49 +10004892echo " PAM support: $PAM_MSG"
Damien Miller1b06dc32006-08-31 03:24:41 +10004893echo " OSF SIA support: $SIA_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10004894echo " KerberosV support: $KRB5_MSG"
Damien Miller73b42d22006-04-22 21:26:08 +10004895echo " SELinux support: $SELINUX_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10004896echo " Smartcard support: $SCARD_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10004897echo " S/KEY support: $SKEY_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10004898echo " MD5 password support: $MD5_MSG"
Darren Tucker16bcc1c2004-11-07 20:14:34 +11004899echo " libedit support: $LIBEDIT_MSG"
Damien Miller1b06dc32006-08-31 03:24:41 +10004900echo " Solaris process contract support: $SPC_MSG"
Darren Tucker97528352010-11-05 12:03:05 +11004901echo " Solaris project support: $SP_MSG"
Damien Miller903e1152002-05-13 14:41:31 +10004902echo " IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG"
Damien Millerf58c6722002-05-13 13:15:42 +10004903echo " Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG"
4904echo " BSD Auth support: $BSD_AUTH_MSG"
4905echo " Random number source: $RAND_MSG"
Damien Miller69ff1df2011-06-23 08:30:03 +10004906echo " Privsep sandbox style: $SANDBOX_STYLE"
Damien Miller60396b02001-02-18 17:01:00 +11004907
Damien Miller7b22d652000-06-18 14:07:04 +10004908echo ""
4909
Ben Lindstrom28bfc0d2000-12-18 19:58:57 +00004910echo " Host: ${host}"
4911echo " Compiler: ${CC}"
4912echo " Compiler flags: ${CFLAGS}"
4913echo "Preprocessor flags: ${CPPFLAGS}"
4914echo " Linker flags: ${LDFLAGS}"
Darren Tucker20e9f972007-03-25 18:26:01 +10004915echo " Libraries: ${LIBS}"
4916if test ! -z "${SSHDLIBS}"; then
4917echo " +for sshd: ${SSHDLIBS}"
4918fi
Damien Miller71adf122011-01-25 12:16:15 +11004919if test ! -z "${SSHLIBS}"; then
4920echo " +for ssh: ${SSHLIBS}"
4921fi
Damien Miller7b22d652000-06-18 14:07:04 +10004922
4923echo ""
4924
Tim Rice6f1f7582004-05-30 21:38:51 -07004925if test "x$MAKE_PACKAGE_SUPPORTED" = "xyes" ; then
Darren Tuckercf59d312004-08-29 21:18:09 +10004926 echo "SVR4 style packages are supported with \"make package\""
4927 echo ""
Tim Rice6f1f7582004-05-30 21:38:51 -07004928fi
4929
Damien Miller82cf0ce2000-12-20 13:34:48 +11004930if test "x$PAM_MSG" = "xyes" ; then
Damien Miller6c21c512002-01-22 21:57:53 +11004931 echo "PAM is enabled. You may need to install a PAM control file "
4932 echo "for sshd, otherwise password authentication may fail. "
Damien Millera8e06ce2003-11-21 23:48:55 +11004933 echo "Example PAM control files can be found in the contrib/ "
Damien Miller6c21c512002-01-22 21:57:53 +11004934 echo "subdirectory"
Damien Miller6f9c3372000-10-25 10:06:04 +11004935 echo ""
4936fi
Ben Lindstrom3ad650a2001-01-03 06:02:51 +00004937
Damien Millerb4097182004-05-23 14:09:40 +10004938if test ! -z "$NO_PEERCHECK" ; then
Darren Tucker164aa302007-03-21 21:39:57 +11004939 echo "WARNING: the operating system that you are using does not"
4940 echo "appear to support getpeereid(), getpeerucred() or the"
4941 echo "SO_PEERCRED getsockopt() option. These facilities are used to"
4942 echo "enforce security checks to prevent unauthorised connections to"
4943 echo "ssh-agent. Their absence increases the risk that a malicious"
4944 echo "user can connect to your agent."
Damien Millerb4097182004-05-23 14:09:40 +10004945 echo ""
4946fi
4947
Darren Tuckerd9f88912005-02-20 21:01:48 +11004948if test "$AUDIT_MODULE" = "bsm" ; then
4949 echo "WARNING: BSM audit support is currently considered EXPERIMENTAL."
4950 echo "See the Solaris section in README.platform for details."
4951fi