1# 2# Copyright (c) 1999-2004 Damien Miller 3# 4# Permission to use, copy, modify, and distribute this software for any 5# purpose with or without fee is hereby granted, provided that the above 6# copyright notice and this permission notice appear in all copies. 7# 8# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 16AC_INIT([OpenSSH], [Portable], [openssh-unix-dev@mindrot.org]) 17AC_CONFIG_MACRO_DIR([m4]) 18AC_CONFIG_SRCDIR([ssh.c]) 19 20# Check for stale configure as early as possible. 21for i in $srcdir/configure.ac $srcdir/m4/*.m4; do 22 if test "$i" -nt "$srcdir/configure"; then 23 AC_MSG_ERROR([$i newer than configure, run autoreconf]) 24 fi 25done 26 27AC_LANG([C]) 28 29AC_CONFIG_HEADERS([config.h]) 30AC_PROG_CC([cc gcc clang]) 31 32# XXX relax this after reimplementing logit() etc. 33AC_MSG_CHECKING([if $CC supports C99-style variadic macros]) 34AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 35int f(int a, int b, int c) { return a + b + c; } 36#define F(a, ...) f(a, __VA_ARGS__) 37]], [[return F(1, 2, -3);]])], 38 [ AC_MSG_RESULT([yes]) ], 39 [ AC_MSG_ERROR([*** OpenSSH requires support for C99-style variadic macros]) ] 40) 41 42AC_CANONICAL_HOST 43AC_C_BIGENDIAN 44 45# Checks for programs. 46AC_PROG_AWK 47AC_PROG_CPP 48AC_PROG_RANLIB 49AC_PROG_INSTALL 50AC_PROG_EGREP 51AC_PROG_MKDIR_P 52AC_CHECK_TOOLS([AR], [ar]) 53AC_PATH_PROG([CAT], [cat]) 54AC_PATH_PROG([KILL], [kill]) 55AC_PATH_PROG([SED], [sed]) 56AC_PATH_PROG([TEST_MINUS_S_SH], [bash]) 57AC_PATH_PROG([TEST_MINUS_S_SH], [ksh]) 58AC_PATH_PROG([TEST_MINUS_S_SH], [sh]) 59AC_PATH_PROG([SH], [bash]) 60AC_PATH_PROG([SH], [ksh]) 61AC_PATH_PROG([SH], [sh]) 62AC_PATH_PROG([GROFF], [groff]) 63AC_PATH_PROGS([NROFF], [nroff awf]) 64AC_PATH_PROG([MANDOC], [mandoc]) 65AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no]) 66AC_SUBST([TEST_SHELL], [sh]) 67 68dnl select manpage formatter to be used to build "cat" format pages. 69if test "x$MANDOC" != "x" ; then 70 MANFMT="$MANDOC" 71elif test "x$NROFF" != "x" ; then 72 MANFMT="$NROFF -mandoc" 73elif test "x$GROFF" != "x" ; then 74 MANFMT="$GROFF -mandoc -Tascii" 75else 76 AC_MSG_WARN([no manpage formatter found]) 77 MANFMT="false" 78fi 79AC_SUBST([MANFMT]) 80 81dnl for buildpkg.sh 82AC_PATH_PROG([PATH_GROUPADD_PROG], [groupadd], [groupadd], 83 [/usr/sbin${PATH_SEPARATOR}/etc]) 84AC_PATH_PROG([PATH_USERADD_PROG], [useradd], [useradd], 85 [/usr/sbin${PATH_SEPARATOR}/etc]) 86AC_CHECK_PROG([MAKE_PACKAGE_SUPPORTED], [pkgmk], [yes], [no]) 87if test -x /sbin/sh; then 88 AC_SUBST([STARTUP_SCRIPT_SHELL], [/sbin/sh]) 89else 90 AC_SUBST([STARTUP_SCRIPT_SHELL], [/bin/sh]) 91fi 92 93# System features 94AC_SYS_LARGEFILE 95 96if test -z "$AR" ; then 97 AC_MSG_ERROR([*** 'ar' missing, please install or fix your \$PATH ***]) 98fi 99 100AC_PATH_PROG([PATH_PASSWD_PROG], [passwd]) 101if test ! -z "$PATH_PASSWD_PROG" ; then 102 AC_DEFINE_UNQUOTED([_PATH_PASSWD_PROG], ["$PATH_PASSWD_PROG"], 103 [Full path of your "passwd" program]) 104fi 105 106dnl Since autoconf doesn't support it very well, we no longer allow users to 107dnl override LD, however keeping the hook here for now in case there's a use 108dnl use case we overlooked and someone needs to re-enable it. Unless a good 109dnl reason is found we'll be removing this in future. 110LD="$CC" 111AC_SUBST([LD]) 112 113AC_C_INLINE 114 115AC_CHECK_DECL([LLONG_MAX], [have_llong_max=1], , [#include <limits.h>]) 116AC_CHECK_DECL([LONG_LONG_MAX], [have_long_long_max=1], , [#include <limits.h>]) 117AC_CHECK_DECL([RLIMIT_NPROC], 118 [AC_DEFINE([HAVE_RLIMIT_NPROC], [], [sys/resource.h has RLIMIT_NPROC])], , [ 119 #include <sys/types.h> 120 #include <sys/resource.h> 121]) 122AC_CHECK_DECL([PR_SET_NO_NEW_PRIVS], [have_linux_no_new_privs=1], , [ 123 #include <sys/types.h> 124 #include <linux/prctl.h> 125]) 126 127openssl=yes 128openssl_bin=openssl 129AC_ARG_WITH([openssl], 130 [ --without-openssl Disable use of OpenSSL; use only limited internal crypto **EXPERIMENTAL** ], 131 [ if test "x$withval" = "xno" ; then 132 openssl=no 133 openssl_bin="" 134 fi 135 ] 136) 137AC_MSG_CHECKING([whether OpenSSL will be used for cryptography]) 138if test "x$openssl" = "xyes" ; then 139 AC_MSG_RESULT([yes]) 140 AC_DEFINE_UNQUOTED([WITH_OPENSSL], [1], [use libcrypto for cryptography]) 141else 142 AC_MSG_RESULT([no]) 143fi 144 145use_stack_protector=1 146use_toolchain_hardening=1 147use_retpoline=1 148AC_ARG_WITH([stackprotect], 149 [ --without-stackprotect Don't use compiler's stack protection], [ 150 if test "x$withval" = "xno"; then 151 use_stack_protector=0 152 fi ]) 153AC_ARG_WITH([hardening], 154 [ --without-hardening Don't use toolchain hardening flags], [ 155 if test "x$withval" = "xno"; then 156 use_toolchain_hardening=0 157 fi ]) 158AC_ARG_WITH([retpoline], 159 [ --without-retpoline Enable retpoline spectre mitigation], [ 160 if test "x$withval" = "xno"; then 161 use_retpoline=0 162 fi ]) 163 164# We use -Werror for the tests only so that we catch warnings like "this is 165# on by default" for things like -fPIE. 166AC_MSG_CHECKING([if $CC supports -Werror]) 167saved_CFLAGS="$CFLAGS" 168CFLAGS="$CFLAGS -Werror" 169AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int main(void) { return 0; }]])], 170 [ AC_MSG_RESULT([yes]) 171 WERROR="-Werror"], 172 [ AC_MSG_RESULT([no]) 173 WERROR="" ] 174) 175CFLAGS="$saved_CFLAGS" 176 177if test "$GCC" = "yes" || test "$GCC" = "egcs"; then 178 AC_MSG_CHECKING([gcc version]) 179 GCC_VER=`$CC -v 2>&1 | $AWK '/gcc version /{print $3}'` 180 case "$GCC_VER" in 181 1.*) no_attrib_nonnull=1 ;; 182 2.8* | 2.9*) 183 no_attrib_nonnull=1 184 ;; 185 2.*) no_attrib_nonnull=1 ;; 186 *) ;; 187 esac 188 AC_MSG_RESULT([$GCC_VER]) 189 190 AC_MSG_CHECKING([clang version]) 191 ver="`$CC -v 2>&1`" 192 if echo "$ver" | grep "Apple" >/dev/null; then 193 CLANG_VER=apple-`echo "$ver" | grep 'clang version' | \ 194 $SED 's/.*clang version //g' | $AWK '{print $1}'` 195 else 196 CLANG_VER=`echo "$ver" | grep 'clang version' | \ 197 $SED 's/.*clang version //g' | $AWK '{print $1}'` 198 fi 199 AC_MSG_RESULT([$CLANG_VER]) 200 201 OSSH_CHECK_CFLAG_COMPILE([-pipe]) 202 OSSH_CHECK_CFLAG_COMPILE([-Wunknown-warning-option]) 203 OSSH_CHECK_CFLAG_COMPILE([-Wno-error=format-truncation]) 204 OSSH_CHECK_CFLAG_COMPILE([-Qunused-arguments]) 205 OSSH_CHECK_CFLAG_COMPILE([-Wall]) 206 OSSH_CHECK_CFLAG_COMPILE([-Wextra]) 207 OSSH_CHECK_CFLAG_COMPILE([-Wpointer-arith]) 208 OSSH_CHECK_CFLAG_COMPILE([-Wuninitialized]) 209 OSSH_CHECK_CFLAG_COMPILE([-Wsign-compare]) 210 OSSH_CHECK_CFLAG_COMPILE([-Wformat-security]) 211 OSSH_CHECK_CFLAG_COMPILE([-Wsizeof-pointer-memaccess]) 212 OSSH_CHECK_CFLAG_COMPILE([-Wpointer-sign], [-Wno-pointer-sign]) 213 OSSH_CHECK_CFLAG_COMPILE([-Wunused-parameter], [-Wno-unused-parameter]) 214 OSSH_CHECK_CFLAG_COMPILE([-Wunused-result], [-Wno-unused-result]) 215 OSSH_CHECK_CFLAG_COMPILE([-Wimplicit-fallthrough]) 216 OSSH_CHECK_CFLAG_COMPILE([-Wmisleading-indentation]) 217 OSSH_CHECK_CFLAG_COMPILE([-Wbitwise-instead-of-logical]) 218 OSSH_CHECK_CFLAG_COMPILE([-fno-strict-aliasing]) 219 if test "x$use_toolchain_hardening" = "x1"; then 220 OSSH_CHECK_CFLAG_COMPILE([-D_FORTIFY_SOURCE=2]) 221 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,relro]) 222 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,now]) 223 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,noexecstack]) 224 # NB. -ftrapv expects certain support functions to be present in 225 # the compiler library (libgcc or similar) to detect integer operations 226 # that can overflow. We must check that the result of enabling it 227 # actually links. The test program compiled/linked includes a number 228 # of integer operations that should exercise this. 229 OSSH_CHECK_CFLAG_LINK([-ftrapv]) 230 # clang 15 seems to have a bug in -fzero-call-used-regs=all. See 231 # https://bugzilla.mindrot.org/show_bug.cgi?id=3475 and 232 # https://github.com/llvm/llvm-project/issues/59242 233 # clang 17 has a different bug that causes an ICE when using this 234 # flag at all (https://bugzilla.mindrot.org/show_bug.cgi?id=3629) 235 case "$CLANG_VER" in 236 apple-15*) OSSH_CHECK_CFLAG_LINK([-fzero-call-used-regs=used]) ;; 237 17*) ;; 238 *) OSSH_CHECK_CFLAG_LINK([-fzero-call-used-regs=used]) ;; 239 esac 240 OSSH_CHECK_CFLAG_COMPILE([-ftrivial-auto-var-init=zero]) 241 fi 242 if test "x$use_retpoline" = "x1"; then 243 OSSH_CHECK_CFLAG_COMPILE([-mretpoline]) # clang 244 OSSH_CHECK_LDFLAG_LINK([-Wl,-z,retpolineplt]) 245 fi 246 247 AC_MSG_CHECKING([if $CC accepts -fno-builtin-memset]) 248 saved_CFLAGS="$CFLAGS" 249 CFLAGS="$CFLAGS -fno-builtin-memset" 250 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <string.h> ]], 251 [[ char b[10]; memset(b, 0, sizeof(b)); ]])], 252 [ AC_MSG_RESULT([yes]) ], 253 [ AC_MSG_RESULT([no]) 254 CFLAGS="$saved_CFLAGS" ] 255 ) 256 257 # -fstack-protector-all doesn't always work for some GCC versions 258 # and/or platforms, so we test if we can. If it's not supported 259 # on a given platform gcc will emit a warning so we use -Werror. 260 if test "x$use_stack_protector" = "x1"; then 261 for t in -fstack-protector-strong -fstack-protector-all \ 262 -fstack-protector; do 263 AC_MSG_CHECKING([if $CC supports $t]) 264 saved_CFLAGS="$CFLAGS" 265 saved_LDFLAGS="$LDFLAGS" 266 CFLAGS="$CFLAGS $t -Werror" 267 LDFLAGS="$LDFLAGS $t -Werror" 268 AC_LINK_IFELSE( 269 [AC_LANG_PROGRAM([[ 270 #include <stdio.h> 271 int func (int t) {char b[100]; snprintf(b,sizeof b,"%d",t); return t;} 272 ]], 273 [[ 274 char x[256]; 275 snprintf(x, sizeof(x), "XXX%d", func(1)); 276 ]])], 277 [ AC_MSG_RESULT([yes]) 278 CFLAGS="$saved_CFLAGS $t" 279 LDFLAGS="$saved_LDFLAGS $t" 280 AC_MSG_CHECKING([if $t works]) 281 AC_RUN_IFELSE( 282 [AC_LANG_PROGRAM([[ 283 #include <stdio.h> 284 int func (int t) {char b[100]; snprintf(b,sizeof b,"%d",t); return t;} 285 ]], 286 [[ 287 char x[256]; 288 snprintf(x, sizeof(x), "XXX%d", func(1)); 289 ]])], 290 [ AC_MSG_RESULT([yes]) 291 break ], 292 [ AC_MSG_RESULT([no]) ], 293 [ AC_MSG_WARN([cross compiling: cannot test]) 294 break ] 295 ) 296 ], 297 [ AC_MSG_RESULT([no]) ] 298 ) 299 CFLAGS="$saved_CFLAGS" 300 LDFLAGS="$saved_LDFLAGS" 301 done 302 fi 303 304 if test -z "$have_llong_max"; then 305 # retry LLONG_MAX with -std=gnu99, needed on some Linuxes 306 unset ac_cv_have_decl_LLONG_MAX 307 saved_CFLAGS="$CFLAGS" 308 CFLAGS="$CFLAGS -std=gnu99" 309 AC_CHECK_DECL([LLONG_MAX], 310 [have_llong_max=1], 311 [CFLAGS="$saved_CFLAGS"], 312 [#include <limits.h>] 313 ) 314 fi 315fi 316 317AC_MSG_CHECKING([if compiler allows __attribute__ on return types]) 318AC_COMPILE_IFELSE( 319 [AC_LANG_PROGRAM([[ 320#include <stdlib.h> 321__attribute__((__unused__)) static void foo(void){return;}]], 322 [[ exit(0); ]])], 323 [ AC_MSG_RESULT([yes]) ], 324 [ AC_MSG_RESULT([no]) 325 AC_DEFINE(NO_ATTRIBUTE_ON_RETURN_TYPE, 1, 326 [compiler does not accept __attribute__ on return types]) ] 327) 328 329AC_MSG_CHECKING([if compiler allows __attribute__ prototype args]) 330AC_COMPILE_IFELSE( 331 [AC_LANG_PROGRAM([[ 332#include <stdlib.h> 333typedef void foo(const char *, ...) __attribute__((format(printf, 1, 2)));]], 334 [[ exit(0); ]])], 335 [ AC_MSG_RESULT([yes]) ], 336 [ AC_MSG_RESULT([no]) 337 AC_DEFINE(NO_ATTRIBUTE_ON_PROTOTYPE_ARGS, 1, 338 [compiler does not accept __attribute__ on prototype args]) ] 339) 340 341AC_MSG_CHECKING([if compiler supports variable length arrays]) 342AC_COMPILE_IFELSE( 343 [AC_LANG_PROGRAM([[#include <stdlib.h>]], 344 [[ int i; for (i=0; i<3; i++){int a[i]; a[i-1]=0;} exit(0); ]])], 345 [ AC_MSG_RESULT([yes]) 346 AC_DEFINE(VARIABLE_LENGTH_ARRAYS, [1], 347 [compiler supports variable length arrays]) ], 348 [ AC_MSG_RESULT([no]) ] 349) 350 351AC_MSG_CHECKING([if compiler accepts variable declarations after code]) 352AC_COMPILE_IFELSE( 353 [AC_LANG_PROGRAM([[#include <stdlib.h>]], 354 [[ int a; a = 1; int b = 1; exit(a-b); ]])], 355 [ AC_MSG_RESULT([yes]) 356 AC_DEFINE(VARIABLE_DECLARATION_AFTER_CODE, [1], 357 [compiler variable declarations after code]) ], 358 [ AC_MSG_RESULT([no]) ] 359) 360 361saved_CFLAGS="$CFLAGS" 362CFLAGS="$CFLAGS -Werror" 363AC_MSG_CHECKING([if compiler supports __nonstring__ attribute on char arrays]) 364AC_COMPILE_IFELSE( 365 [AC_LANG_PROGRAM([[#include <stdlib.h>]], 366 [[ char __attribute__ ((__nonstring__)) h[5] = "hello"; return h[0]!='h'; ]])], 367 [ AC_MSG_RESULT([yes]) 368 AC_DEFINE(HAVE_ATTRIBUTE__NONSTRING__, [1], 369 [compiler supports nonstring attribute]) ], 370 [ AC_MSG_RESULT([no]) ] 371) 372CFLAGS="$saved_CFLAGS" 373 374if test "x$no_attrib_nonnull" != "x1" ; then 375 AC_DEFINE([HAVE_ATTRIBUTE__NONNULL__], [1], [Have attribute nonnull]) 376fi 377 378AC_ARG_WITH([rpath], 379 [ --without-rpath Disable auto-added -R linker paths], 380 [ 381 if test "x$withval" = "xno" ; then 382 rpath_opt="" 383 elif test "x$withval" = "xyes" ; then 384 rpath_opt="-R" 385 else 386 rpath_opt="$withval" 387 fi 388 ] 389) 390 391# Allow user to specify flags 392AC_ARG_WITH([cflags], 393 [ --with-cflags Specify additional flags to pass to compiler], 394 [ 395 if test -n "$withval" && test "x$withval" != "xno" && \ 396 test "x${withval}" != "xyes"; then 397 CFLAGS="$CFLAGS $withval" 398 fi 399 ] 400) 401 402AC_ARG_WITH([cflags-after], 403 [ --with-cflags-after Specify additional flags to pass to compiler after configure], 404 [ 405 if test -n "$withval" && test "x$withval" != "xno" && \ 406 test "x${withval}" != "xyes"; then 407 CFLAGS_AFTER="$withval" 408 fi 409 ] 410) 411AC_ARG_WITH([cppflags], 412 [ --with-cppflags Specify additional flags to pass to preprocessor] , 413 [ 414 if test -n "$withval" && test "x$withval" != "xno" && \ 415 test "x${withval}" != "xyes"; then 416 CPPFLAGS="$CPPFLAGS $withval" 417 fi 418 ] 419) 420AC_ARG_WITH([ldflags], 421 [ --with-ldflags Specify additional flags to pass to linker], 422 [ 423 if test -n "$withval" && test "x$withval" != "xno" && \ 424 test "x${withval}" != "xyes"; then 425 LDFLAGS="$LDFLAGS $withval" 426 fi 427 ] 428) 429AC_ARG_WITH([ldflags-after], 430 [ --with-ldflags-after Specify additional flags to pass to linker after configure], 431 [ 432 if test -n "$withval" && test "x$withval" != "xno" && \ 433 test "x${withval}" != "xyes"; then 434 LDFLAGS_AFTER="$withval" 435 fi 436 ] 437) 438AC_ARG_WITH([libs], 439 [ --with-libs Specify additional libraries to link with], 440 [ 441 if test -n "$withval" && test "x$withval" != "xno" && \ 442 test "x${withval}" != "xyes"; then 443 LIBS="$LIBS $withval" 444 fi 445 ] 446) 447AC_ARG_WITH([Werror], 448 [ --with-Werror Build main code with -Werror], 449 [ 450 if test -n "$withval" && test "x$withval" != "xno"; then 451 werror_flags="-Werror" 452 if test "x${withval}" != "xyes"; then 453 werror_flags="$withval" 454 fi 455 fi 456 ] 457) 458 459dnl On some old platforms, sys/stat.h requires sys/types.h, but autoconf-2.71's 460dnl AC_CHECK_INCLUDES_DEFAULT checks for them in the opposite order. If we 461dnl haven't detected it, recheck. 462if test "x$ac_cv_header_sys_stat_h" != "xyes"; then 463 unset ac_cv_header_sys_stat_h 464 AC_CHECK_HEADERS([sys/stat.h]) 465fi 466 467AC_CHECK_HEADERS([ \ 468 blf.h \ 469 bstring.h \ 470 crypt.h \ 471 crypto/sha2.h \ 472 dirent.h \ 473 elf.h \ 474 err.h \ 475 features.h \ 476 fcntl.h \ 477 floatingpoint.h \ 478 fnmatch.h \ 479 getopt.h \ 480 ia.h \ 481 iaf.h \ 482 inttypes.h \ 483 langinfo.h \ 484 limits.h \ 485 locale.h \ 486 login.h \ 487 maillock.h \ 488 ndir.h \ 489 net/if_tun.h \ 490 netdb.h \ 491 pam/pam_appl.h \ 492 pty.h \ 493 readpassphrase.h \ 494 rpc/types.h \ 495 security/pam_appl.h \ 496 sha2.h \ 497 shadow.h \ 498 stddef.h \ 499 string.h \ 500 strings.h \ 501 sys/bitypes.h \ 502 sys/byteorder.h \ 503 sys/bsdtty.h \ 504 sys/cdefs.h \ 505 sys/dir.h \ 506 sys/file.h \ 507 sys/mman.h \ 508 sys/label.h \ 509 sys/ndir.h \ 510 sys/param.h \ 511 sys/poll.h \ 512 sys/prctl.h \ 513 sys/procctl.h \ 514 sys/pstat.h \ 515 sys/ptrace.h \ 516 sys/random.h \ 517 sys/select.h \ 518 sys/stream.h \ 519 sys/stropts.h \ 520 sys/strtio.h \ 521 sys/statvfs.h \ 522 sys/sysmacros.h \ 523 sys/timers.h \ 524 sys/vfs.h \ 525 tmpdir.h \ 526 ttyent.h \ 527 ucred.h \ 528 unistd.h \ 529 usersec.h \ 530 utime.h \ 531 utmp.h \ 532 utmpx.h \ 533 vis.h \ 534 wchar.h \ 535]) 536 537# Create replacement header files for common headers that are missing on this 538# platform. Usually these are just empty, but in some cases they'll include 539# the equivalent file. This avoids having to wrap those includes in 540# '#ifdef HAVE_FOO_H'. If we create any such headers, add the path to includes. 541COMPATINCLUDESDIR="openbsd-compat/include" 542COMPATINCLUDES="" 543AC_CHECK_HEADERS([ \ 544 endian.h \ 545 ifaddrs.h \ 546 libgen.h \ 547 paths.h \ 548 netgroup.h \ 549 nlist.h \ 550 poll.h \ 551 stdint.h \ 552 sys/mman.h \ 553 sys/stat.h \ 554 sys/statvfs.h \ 555 sys/time.h \ 556 sys/un.h \ 557 time.h \ 558 util.h \ 559 ], [ 560 # Remove any old shims. 561 rm -f "$COMPATINCLUDESDIR/$ac_header" 562 ], [ 563 COMPATINCLUDES="$COMPATINCLUDESDIR" 564 header="$COMPATINCLUDES/$ac_header" 565 dir=`dirname "$header"` 566 mkdir -p "$dir" 567 case "$ac_header" in 568 poll.h) echo '#ifdef HAVE_SYS_POLL_H' 569 echo '#include <sys/poll.h>' 570 echo '#endif' ;; 571 *) ;; 572 esac >"$header" 573]) 574 575dnl Now create replacement headers for those that we always want to shim. 576for include in sys/queue.h sys/tree.h; do 577 COMPATINCLUDES="$COMPATINCLUDESDIR" 578 header="$COMPATINCLUDES/$include" 579 dir=`dirname "$header"` 580 mkdir -p "$dir" 581 case "$include" in 582 sys/queue.h) 583 echo '#include "openbsd-compat/sys-queue.h"' 584 ;; 585 sys/tree.h) 586 echo '#include "openbsd-compat/sys-tree.h"' 587 ;; 588 esac >"$header" 589done 590 591AC_CHECK_DECLS([le32toh, le64toh, htole64, htobe32], [], [], [ 592#ifdef HAVE_SYS_TYPES_H 593# include <sys/types.h> 594#endif 595#ifdef HAVE_STDINT_H 596# include <stdint.h> 597#endif 598#ifdef HAVE_ENDIAN_H 599# include <endian.h> 600#endif 601]) 602 603# On some platforms (eg SunOS4) sys/audit.h requires sys/[time|types|label.h] 604# to be included first. 605AC_CHECK_HEADERS([sys/audit.h], [], [], [ 606#ifdef HAVE_SYS_TIME_H 607# include <sys/time.h> 608#endif 609#ifdef HAVE_SYS_TYPES_H 610# include <sys/types.h> 611#endif 612#ifdef HAVE_SYS_LABEL_H 613# include <sys/label.h> 614#endif 615]) 616 617# sys/capsicum.h requires sys/types.h 618AC_CHECK_HEADERS([sys/capsicum.h capsicum_helpers.h], [], [], [ 619#ifdef HAVE_SYS_TYPES_H 620# include <sys/types.h> 621#endif 622]) 623 624AC_MSG_CHECKING([for caph_cache_tzdata]) 625AC_LINK_IFELSE( 626 [AC_LANG_PROGRAM([[ #include <capsicum_helpers.h> ]], 627 [[caph_cache_tzdata();]])], 628 [ 629 AC_MSG_RESULT([yes]) 630 AC_DEFINE([HAVE_CAPH_CACHE_TZDATA], [1], 631 [Define if you have caph_cache_tzdata]) 632 ], 633 [ AC_MSG_RESULT([no]) ] 634) 635 636# net/route.h requires sys/socket.h and sys/types.h. 637# sys/sysctl.h also requires sys/param.h 638AC_CHECK_HEADERS([net/route.h sys/sysctl.h], [], [], [ 639#ifdef HAVE_SYS_TYPES_H 640# include <sys/types.h> 641#endif 642#include <sys/param.h> 643#include <sys/socket.h> 644]) 645 646# lastlog.h requires sys/time.h to be included first on Solaris 647AC_CHECK_HEADERS([lastlog.h], [], [], [ 648#ifdef HAVE_SYS_TIME_H 649# include <sys/time.h> 650#endif 651]) 652 653# sys/ptms.h requires sys/stream.h to be included first on Solaris 654AC_CHECK_HEADERS([sys/ptms.h], [], [], [ 655#ifdef HAVE_SYS_STREAM_H 656# include <sys/stream.h> 657#endif 658]) 659 660# login_cap.h requires sys/types.h on NetBSD 661AC_CHECK_HEADERS([login_cap.h], [], [], [ 662#include <sys/types.h> 663]) 664 665# older BSDs need sys/param.h before sys/mount.h 666AC_CHECK_HEADERS([sys/mount.h], [], [], [ 667#include <sys/param.h> 668]) 669 670# Android requires sys/socket.h to be included before sys/un.h 671AC_CHECK_HEADERS([sys/un.h], [], [], [ 672#include <sys/types.h> 673#include <sys/socket.h> 674]) 675 676# Messages for features tested for in target-specific section 677SIA_MSG="no" 678SPC_MSG="no" 679SP_MSG="no" 680SPP_MSG="no" 681 682# Support for Solaris/Illumos privileges (this test is used by both 683# the --with-solaris-privs option and --with-sandbox=solaris). 684SOLARIS_PRIVS="no" 685 686# Default shared library extension 687SHLIBEXT=".so" 688 689# See OpenBSD section in $host case below. 690need_pledge_inet="" 691 692# Check for some target-specific stuff 693case "$host" in 694*-*-aix*) 695 # Some versions of VAC won't allow macro redefinitions at 696 # -qlanglevel=ansi, and autoconf 2.60 sometimes insists on using that 697 # particularly with older versions of vac or xlc. 698 # It also throws errors about null macro arguments, but these are 699 # not fatal. 700 AC_MSG_CHECKING([if compiler allows macro redefinitions]) 701 AC_COMPILE_IFELSE( 702 [AC_LANG_PROGRAM([[ 703#include <stdlib.h> 704#define testmacro foo 705#define testmacro bar]], 706 [[ exit(0); ]])], 707 [ AC_MSG_RESULT([yes]) ], 708 [ AC_MSG_RESULT([no]) 709 CC="`echo $CC | sed 's/-qlanglvl\=ansi//g'`" 710 CFLAGS="`echo $CFLAGS | sed 's/-qlanglvl\=ansi//g'`" 711 CPPFLAGS="`echo $CPPFLAGS | sed 's/-qlanglvl\=ansi//g'`" 712 ] 713 ) 714 715 AC_MSG_CHECKING([how to specify blibpath for linker ($LD)]) 716 if (test -z "$blibpath"); then 717 blibpath="/usr/lib:/lib" 718 fi 719 saved_LDFLAGS="$LDFLAGS" 720 if test "$GCC" = "yes"; then 721 flags="-Wl,-blibpath: -Wl,-rpath, -blibpath:" 722 else 723 flags="-blibpath: -Wl,-blibpath: -Wl,-rpath," 724 fi 725 for tryflags in $flags ;do 726 if (test -z "$blibflags"); then 727 LDFLAGS="$saved_LDFLAGS $tryflags$blibpath" 728 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], 729 [blibflags=$tryflags], []) 730 fi 731 done 732 if (test -z "$blibflags"); then 733 AC_MSG_RESULT([not found]) 734 AC_MSG_ERROR([*** must be able to specify blibpath on AIX - check config.log]) 735 else 736 AC_MSG_RESULT([$blibflags]) 737 fi 738 LDFLAGS="$saved_LDFLAGS" 739 dnl Check for authenticate. Might be in libs.a on older AIXes 740 AC_CHECK_FUNC([authenticate], [AC_DEFINE([WITH_AIXAUTHENTICATE], [1], 741 [Define if you want to enable AIX4's authenticate function])], 742 [AC_CHECK_LIB([s], [authenticate], 743 [ AC_DEFINE([WITH_AIXAUTHENTICATE]) 744 LIBS="$LIBS -ls" 745 ]) 746 ]) 747 dnl Check for various auth function declarations in headers. 748 AC_CHECK_DECLS([authenticate, loginrestrictions, loginsuccess, 749 passwdexpired, setauthdb], , , [#include <usersec.h>]) 750 dnl Check if loginfailed is declared and takes 4 arguments (AIX >= 5.2) 751 AC_CHECK_DECLS([loginfailed], 752 [AC_MSG_CHECKING([if loginfailed takes 4 arguments]) 753 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <usersec.h> ]], 754 [[ (void)loginfailed("user","host","tty",0); ]])], 755 [AC_MSG_RESULT([yes]) 756 AC_DEFINE([AIX_LOGINFAILED_4ARG], [1], 757 [Define if your AIX loginfailed() function 758 takes 4 arguments (AIX >= 5.2)])], [AC_MSG_RESULT([no]) 759 ])], 760 [], 761 [#include <usersec.h>] 762 ) 763 AC_CHECK_FUNCS([getgrset setauthdb]) 764 AC_CHECK_DECL([F_CLOSEM], 765 AC_DEFINE([HAVE_FCNTL_CLOSEM], [1], [Use F_CLOSEM fcntl for closefrom]), 766 [], 767 [ #include <limits.h> 768 #include <fcntl.h> ] 769 ) 770 check_for_aix_broken_getaddrinfo=1 771 AC_DEFINE([SETEUID_BREAKS_SETUID], [1], 772 [Define if your platform breaks doing a seteuid before a setuid]) 773 AC_DEFINE([BROKEN_SETREUID], [1], [Define if your setreuid() is broken]) 774 AC_DEFINE([BROKEN_SETREGID], [1], [Define if your setregid() is broken]) 775 dnl AIX handles lastlog as part of its login message 776 AC_DEFINE([DISABLE_LASTLOG], [1], [Define if you don't want to use lastlog]) 777 AC_DEFINE([LOGIN_NEEDS_UTMPX], [1], 778 [Some systems need a utmpx entry for /bin/login to work]) 779 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV], 780 [Define to a Set Process Title type if your system is 781 supported by bsd-setproctitle.c]) 782 AC_DEFINE([PTY_ZEROREAD], [1], [read(1) can return 0 for a non-closed fd]) 783 AC_DEFINE([PLATFORM_SYS_DIR_UID], 2, [System dirs owned by bin (uid 2)]) 784 AC_DEFINE([BROKEN_STRNDUP], 1, [strndup broken, see APAR IY61211]) 785 AC_DEFINE([BROKEN_STRNLEN], 1, [strnlen broken, see APAR IY62551]) 786 ;; 787*-*-android*) 788 AC_DEFINE([DISABLE_UTMP], [1], [Define if you don't want to use utmp]) 789 AC_DEFINE([DISABLE_WTMP], [1], [Define if you don't want to use wtmp]) 790 ;; 791*-*-cygwin*) 792 LIBS="$LIBS /usr/lib/textreadmode.o" 793 AC_DEFINE([HAVE_CYGWIN], [1], [Define if you are on Cygwin]) 794 AC_DEFINE([USE_PIPES], [1], [Use PIPES instead of a socketpair()]) 795 AC_DEFINE([NO_UID_RESTORATION_TEST], [1], 796 [Define to disable UID restoration test]) 797 AC_DEFINE([DISABLE_SHADOW], [1], 798 [Define if you want to disable shadow passwords]) 799 AC_DEFINE([NO_X11_UNIX_SOCKETS], [1], 800 [Define if X11 doesn't support AF_UNIX sockets on that system]) 801 AC_DEFINE([DISABLE_FD_PASSING], [1], 802 [Define if your platform needs to skip post auth 803 file descriptor passing]) 804 AC_DEFINE([SSH_IOBUFSZ], [65535], [Windows is sensitive to read buffer size]) 805 AC_DEFINE([FILESYSTEM_NO_BACKSLASH], [1], [File names may not contain backslash characters]) 806 # Cygwin defines optargs, optargs as declspec(dllimport) for historical 807 # reasons which cause compile warnings, so we disable those warnings. 808 OSSH_CHECK_CFLAG_COMPILE([-Wno-attributes]) 809 SHLIBEXT=".dll" 810 ;; 811*-*-dgux*) 812 AC_DEFINE([IP_TOS_IS_BROKEN], [1], 813 [Define if your system choked on IP TOS setting]) 814 AC_DEFINE([SETEUID_BREAKS_SETUID]) 815 AC_DEFINE([BROKEN_SETREUID]) 816 AC_DEFINE([BROKEN_SETREGID]) 817 ;; 818*-*-darwin*) 819 use_pie=auto 820 AC_MSG_CHECKING([if we have working getaddrinfo]) 821 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 822#include <mach-o/dyld.h> 823#include <stdlib.h> 824int main(void) { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16)) 825 exit(0); 826 else 827 exit(1); 828} 829 ]])], 830 [AC_MSG_RESULT([working])], 831 [AC_MSG_RESULT([buggy]) 832 AC_DEFINE([BROKEN_GETADDRINFO], [1], 833 [getaddrinfo is broken (if present)]) 834 ], 835 [AC_MSG_RESULT([assume it is working])]) 836 AC_DEFINE([SETEUID_BREAKS_SETUID]) 837 AC_DEFINE([BROKEN_SETREUID]) 838 AC_DEFINE([BROKEN_SETREGID]) 839 broken_glob=yes # OS X glob does not do what we expect 840 AC_DEFINE_UNQUOTED([BIND_8_COMPAT], [1], 841 [Define if your resolver libs need this for getrrsetbyname]) 842 AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way]) 843 AC_DEFINE([SSH_TUN_COMPAT_AF], [1], 844 [Use tunnel device compatibility to OpenBSD]) 845 AC_DEFINE([SSH_TUN_PREPEND_AF], [1], 846 [Prepend the address family to IP tunnel traffic]) 847 m4_pattern_allow([AU_IPv]) 848 AC_CHECK_DECL([AU_IPv4], [], 849 AC_DEFINE([AU_IPv4], [0], [System only supports IPv4 audit records]) 850 [#include <bsm/audit.h>] 851 AC_DEFINE([LASTLOG_WRITE_PUTUTXLINE], [1], 852 [Define if pututxline updates lastlog too]) 853 ) 854 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV], 855 [Define to a Set Process Title type if your system is 856 supported by bsd-setproctitle.c]) 857 AC_CHECK_FUNCS([sandbox_init]) 858 AC_CHECK_HEADERS([sandbox.h]) 859 AC_CHECK_LIB([sandbox], [sandbox_apply], [ 860 SSHDLIBS="$SSHDLIBS -lsandbox" 861 ]) 862 # proc_pidinfo()-based closefrom() replacement. 863 AC_CHECK_HEADERS([libproc.h]) 864 AC_CHECK_FUNCS([proc_pidinfo]) 865 # poll(2) is broken for character-special devices (at least). 866 # cf. Apple bug 3710161 (not public, but searchable) 867 AC_DEFINE([BROKEN_POLL], [1], 868 [System poll(2) implementation is broken]) 869 SHLIBEXT=".dylib" 870 ;; 871*-*-dragonfly*) 872 SSHDLIBS="$SSHDLIBS" 873 TEST_MALLOC_OPTIONS="AFGJPRX" 874 ;; 875*-*-haiku*) 876 LIBS="$LIBS -lbsd " 877 CFLAGS="$CFLAGS -D_BSD_SOURCE" 878 AC_CHECK_LIB([network], [socket]) 879 AC_DEFINE([HAVE_U_INT64_T]) 880 AC_DEFINE([DISABLE_UTMPX], [1], [no utmpx]) 881 MANTYPE=man 882 ;; 883*-*-hpux*) 884 # first we define all of the options common to all HP-UX releases 885 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1" 886 IPADDR_IN_DISPLAY=yes 887 AC_DEFINE([USE_PIPES]) 888 AC_DEFINE([LOGIN_NEEDS_UTMPX]) 889 AC_DEFINE([LOCKED_PASSWD_STRING], ["*"], 890 [String used in /etc/passwd to denote locked account]) 891 AC_DEFINE([SPT_TYPE], [SPT_PSTAT]) 892 AC_DEFINE([PLATFORM_SYS_DIR_UID], 2, [System dirs owned by bin (uid 2)]) 893 maildir="/var/mail" 894 LIBS="$LIBS -lsec" 895 AC_CHECK_LIB([xnet], [t_error], , 896 [AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***])]) 897 898 # next, we define all of the options specific to major releases 899 case "$host" in 900 *-*-hpux10*) 901 if test -z "$GCC"; then 902 CFLAGS="$CFLAGS -Ae" 903 fi 904 AC_DEFINE([BROKEN_GETLINE], [1], [getline is not what we expect]) 905 ;; 906 *-*-hpux11*) 907 AC_DEFINE([PAM_SUN_CODEBASE], [1], 908 [Define if you are using Solaris-derived PAM which 909 passes pam_messages to the conversation function 910 with an extra level of indirection]) 911 AC_DEFINE([DISABLE_UTMP], [1], 912 [Define if you don't want to use utmp]) 913 AC_DEFINE([USE_BTMP], [1], [Use btmp to log bad logins]) 914 check_for_hpux_broken_getaddrinfo=1 915 check_for_conflicting_getspnam=1 916 ;; 917 esac 918 919 # lastly, we define options specific to minor releases 920 case "$host" in 921 *-*-hpux10.26) 922 AC_DEFINE([HAVE_SECUREWARE], [1], 923 [Define if you have SecureWare-based 924 protected password database]) 925 disable_ptmx_check=yes 926 LIBS="$LIBS -lsecpw" 927 ;; 928 esac 929 ;; 930*-*-irix5*) 931 PATH="$PATH:/usr/etc" 932 AC_DEFINE([BROKEN_INET_NTOA], [1], 933 [Define if you system's inet_ntoa is busted 934 (e.g. Irix gcc issue)]) 935 AC_DEFINE([SETEUID_BREAKS_SETUID]) 936 AC_DEFINE([BROKEN_SETREUID]) 937 AC_DEFINE([BROKEN_SETREGID]) 938 AC_DEFINE([WITH_ABBREV_NO_TTY], [1], 939 [Define if you shouldn't strip 'tty' from your 940 ttyname in [uw]tmp]) 941 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"]) 942 ;; 943*-*-irix6*) 944 PATH="$PATH:/usr/etc" 945 AC_DEFINE([WITH_IRIX_ARRAY], [1], 946 [Define if you have/want arrays 947 (cluster-wide session management, not C arrays)]) 948 AC_DEFINE([WITH_IRIX_PROJECT], [1], 949 [Define if you want IRIX project management]) 950 AC_DEFINE([WITH_IRIX_AUDIT], [1], 951 [Define if you want IRIX audit trails]) 952 AC_CHECK_FUNC([jlimit_startjob], [AC_DEFINE([WITH_IRIX_JOBS], [1], 953 [Define if you want IRIX kernel jobs])]) 954 AC_DEFINE([BROKEN_INET_NTOA]) 955 AC_DEFINE([SETEUID_BREAKS_SETUID]) 956 AC_DEFINE([BROKEN_SETREUID]) 957 AC_DEFINE([BROKEN_SETREGID]) 958 AC_DEFINE([BROKEN_UPDWTMPX], [1], [updwtmpx is broken (if present)]) 959 AC_DEFINE([WITH_ABBREV_NO_TTY]) 960 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"]) 961 ;; 962*-*-k*bsd*-gnu | *-*-kopensolaris*-gnu) 963 AC_DEFINE([PAM_TTY_KLUDGE]) 964 AC_DEFINE([LOCKED_PASSWD_PREFIX], ["!"]) 965 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV]) 966 AC_DEFINE([_PATH_BTMP], ["/var/log/btmp"], [log for bad login attempts]) 967 AC_DEFINE([USE_BTMP], [1], [Use btmp to log bad logins]) 968 ;; 969*-*-linux*) 970 no_dev_ptmx=1 971 use_pie=auto 972 check_for_openpty_ctty_bug=1 973 dnl Target SUSv3/POSIX.1-2001 plus BSD specifics. 974 dnl _DEFAULT_SOURCE is the new name for _BSD_SOURCE 975 dnl _GNU_SOURCE is needed for setres*id prototypes. 976 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_GNU_SOURCE" 977 AC_DEFINE([BROKEN_CLOSEFROM], [1], [broken in chroots on older kernels]) 978 AC_DEFINE([PAM_TTY_KLUDGE], [1], 979 [Work around problematic Linux PAM modules handling of PAM_TTY]) 980 AC_DEFINE([LOCKED_PASSWD_PREFIX], ["!"], 981 [String used in /etc/passwd to denote locked account]) 982 AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV]) 983 AC_DEFINE([LINK_OPNOTSUPP_ERRNO], [EPERM], 984 [Define to whatever link() returns for "not supported" 985 if it doesn't return EOPNOTSUPP.]) 986 AC_DEFINE([_PATH_BTMP], ["/var/log/btmp"], [log for bad login attempts]) 987 AC_DEFINE([USE_BTMP]) 988 AC_DEFINE([LINUX_OOM_ADJUST], [1], [Adjust Linux out-of-memory killer]) 989 AC_ARG_WITH([linux-memlock-onfault], 990 [ --with-linux-memlock-onfault Enables memory locking on Linux], 991 [ 992 if test "x$withval" != "xno" ; then 993 AC_MSG_CHECKING([for MCL_ONFAULT]) 994 AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 995 [[ #include <sys/mman.h> ]], 996 [[ mlockall(MCL_FUTURE | MCL_ONFAULT); ]], 997 )], 998 [ 999 AC_MSG_RESULT([supported]) 1000 AC_DEFINE([LINUX_MEMLOCK_ONFAULT], [1], 1001 [Lock all memory to protect sshd against Linux kcompactd] )], 1002 [ 1003 AC_MSG_RESULT([not supported]) 1004 AC_MSG_ERROR([MCL_ONFAULT is not available on your system]) 1005 ]) 1006 fi 1007 ], 1008 ) 1009 1010 AC_DEFINE([SYSTEMD_NOTIFY], [1], [Have sshd notify systemd on start/reload]) 1011 inet6_default_4in6=yes 1012 case `uname -r` in 1013 1.*|2.0.*) 1014 AC_DEFINE([BROKEN_CMSG_TYPE], [1], 1015 [Define if cmsg_type is not passed correctly]) 1016 ;; 1017 esac 1018 # tun(4) forwarding compat code 1019 AC_CHECK_HEADERS([linux/if_tun.h]) 1020 if test "x$ac_cv_header_linux_if_tun_h" = "xyes" ; then 1021 AC_DEFINE([SSH_TUN_LINUX], [1], 1022 [Open tunnel devices the Linux tun/tap way]) 1023 AC_DEFINE([SSH_TUN_COMPAT_AF], [1], 1024 [Use tunnel device compatibility to OpenBSD]) 1025 AC_DEFINE([SSH_TUN_PREPEND_AF], [1], 1026 [Prepend the address family to IP tunnel traffic]) 1027 fi 1028 AC_CHECK_HEADER([linux/if.h], 1029 AC_DEFINE([SYS_RDOMAIN_LINUX], [1], 1030 [Support routing domains using Linux VRF]), [], [ 1031#ifdef HAVE_SYS_TYPES_H 1032# include <sys/types.h> 1033#endif 1034 ]) 1035 AC_CHECK_HEADERS([linux/seccomp.h linux/filter.h linux/audit.h], [], 1036 [], [#include <linux/types.h>]) 1037 # Obtain MIPS ABI 1038 case "$host" in 1039 mips*) 1040 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1041#if _MIPS_SIM != _ABIO32 1042#error 1043#endif 1044 ]])],[mips_abi="o32"],[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1045#if _MIPS_SIM != _ABIN32 1046#error 1047#endif 1048 ]])],[mips_abi="n32"],[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 1049#if _MIPS_SIM != _ABI64 1050#error 1051#endif 1052 ]])],[mips_abi="n64"],[AC_MSG_ERROR([unknown MIPS ABI]) 1053 ]) 1054 ]) 1055 ]) 1056 ;; 1057 esac 1058 AC_MSG_CHECKING([for seccomp architecture]) 1059 seccomp_audit_arch= 1060 case "$host" in 1061 x86_64-*) 1062 seccomp_audit_arch=AUDIT_ARCH_X86_64 1063 ;; 1064 i*86-*) 1065 seccomp_audit_arch=AUDIT_ARCH_I386 1066 ;; 1067 arm*-*) 1068 seccomp_audit_arch=AUDIT_ARCH_ARM 1069 ;; 1070 aarch64*-*) 1071 seccomp_audit_arch=AUDIT_ARCH_AARCH64 1072 ;; 1073 s390x-*) 1074 seccomp_audit_arch=AUDIT_ARCH_S390X 1075 ;; 1076 s390-*) 1077 seccomp_audit_arch=AUDIT_ARCH_S390 1078 ;; 1079 powerpc-*) 1080 seccomp_audit_arch=AUDIT_ARCH_PPC 1081 ;; 1082 powerpc64-*) 1083 seccomp_audit_arch=AUDIT_ARCH_PPC64 1084 ;; 1085 powerpc64le-*) 1086 seccomp_audit_arch=AUDIT_ARCH_PPC64LE 1087 ;; 1088 mips-*) 1089 seccomp_audit_arch=AUDIT_ARCH_MIPS 1090 ;; 1091 mipsel-*) 1092 seccomp_audit_arch=AUDIT_ARCH_MIPSEL 1093 ;; 1094 mips64-*) 1095 case "$mips_abi" in 1096 "n32") 1097 seccomp_audit_arch=AUDIT_ARCH_MIPS64N32 1098 ;; 1099 "n64") 1100 seccomp_audit_arch=AUDIT_ARCH_MIPS64 1101 ;; 1102 esac 1103 ;; 1104 mips64el-*) 1105 case "$mips_abi" in 1106 "n32") 1107 seccomp_audit_arch=AUDIT_ARCH_MIPSEL64N32 1108 ;; 1109 "n64") 1110 seccomp_audit_arch=AUDIT_ARCH_MIPSEL64 1111 ;; 1112 esac 1113 ;; 1114 riscv64-*) 1115 seccomp_audit_arch=AUDIT_ARCH_RISCV64 1116 ;; 1117 esac 1118 if test "x$seccomp_audit_arch" != "x" ; then 1119 AC_MSG_RESULT(["$seccomp_audit_arch"]) 1120 AC_DEFINE_UNQUOTED([SECCOMP_AUDIT_ARCH], [$seccomp_audit_arch], 1121 [Specify the system call convention in use]) 1122 else 1123 AC_MSG_RESULT([architecture not supported]) 1124 fi 1125 ;; 1126*-*-minix) 1127 AC_DEFINE([SETEUID_BREAKS_SETUID]) 1128 # poll(2) seems to choke on /dev/null; "Bad file descriptor" 1129 AC_DEFINE([BROKEN_POLL], [1], 1130 [System poll(2) implementation is broken]) 1131 ;; 1132mips-sony-bsd|mips-sony-newsos4) 1133 AC_DEFINE([NEED_SETPGRP], [1], [Need setpgrp to acquire controlling tty]) 1134 SONY=1 1135 ;; 1136*-*-netbsd*) 1137 if test "x$withval" != "xno" ; then 1138 rpath_opt="-R" 1139 fi 1140 CPPFLAGS="$CPPFLAGS -D_OPENBSD_SOURCE" 1141 AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way]) 1142 AC_CHECK_HEADER([net/if_tap.h], , 1143 AC_DEFINE([SSH_TUN_NO_L2], [1], [No layer 2 tunnel support])) 1144 AC_DEFINE([SSH_TUN_PREPEND_AF], [1], 1145 [Prepend the address family to IP tunnel traffic]) 1146 TEST_MALLOC_OPTIONS="AJRX" 1147 AC_DEFINE([BROKEN_READ_COMPARISON], [1], 1148 [NetBSD read function is sometimes redirected, breaking atomicio comparisons against it]) 1149 ;; 1150*-*-freebsd*) 1151 SKIP_DISABLE_LASTLOG_DEFINE=yes 1152 AC_DEFINE([LOCKED_PASSWD_PREFIX], ["*LOCKED*"], [Account locked with pw(1)]) 1153 AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way]) 1154 AC_DEFINE([SSH_TUN_COMPAT_AF], [1], 1155 [Use tunnel device compatibility to OpenBSD]) 1156 AC_CHECK_HEADER([net/if_tap.h], , 1157 AC_DEFINE([SSH_TUN_NO_L2], [1], [No layer 2 tunnel support])) 1158 broken_glob=yes # FreeBSD glob does not do what we need 1159 TEST_MALLOC_OPTIONS="AJRX" 1160 # Preauth crypto occasionally uses file descriptors for crypto offload 1161 # and will crash if they cannot be opened. 1162 AC_DEFINE([SANDBOX_SKIP_RLIMIT_NOFILE], [1], 1163 [define if setrlimit RLIMIT_NOFILE breaks things]) 1164 case "$host" in 1165 *-*-freebsd9.*|*-*-freebsd10.*) 1166 # Capsicum on 9 and 10 do not allow ppoll() so don't auto-enable. 1167 disable_capsicum=yes 1168 esac 1169 ;; 1170*-*-bsdi*) 1171 AC_DEFINE([SETEUID_BREAKS_SETUID]) 1172 AC_DEFINE([BROKEN_SETREUID]) 1173 AC_DEFINE([BROKEN_SETREGID]) 1174 ;; 1175*-next-*) 1176 conf_lastlog_location="/usr/adm/lastlog" 1177 conf_utmp_location=/etc/utmp 1178 conf_wtmp_location=/usr/adm/wtmp 1179 maildir=/usr/spool/mail 1180 AC_DEFINE([HAVE_NEXT], [1], [Define if you are on NeXT]) 1181 AC_DEFINE([USE_PIPES]) 1182 AC_DEFINE([BROKEN_SAVED_UIDS], [1], [Needed for NeXT]) 1183 ;; 1184*-*-openbsd*) 1185 use_pie=auto 1186 AC_DEFINE([HAVE_ATTRIBUTE__SENTINEL__], [1], [OpenBSD's gcc has sentinel]) 1187 AC_DEFINE([HAVE_ATTRIBUTE__BOUNDED__], [1], [OpenBSD's gcc has bounded]) 1188 AC_DEFINE([SSH_TUN_OPENBSD], [1], [Open tunnel devices the OpenBSD way]) 1189 AC_DEFINE([SYSLOG_R_SAFE_IN_SIGHAND], [1], 1190 [syslog_r function is safe to use in in a signal handler]) 1191 TEST_MALLOC_OPTIONS="SJRU" 1192 AC_MSG_CHECKING([whether pledge(2) allows IP_TOS]) 1193 AC_RUN_IFELSE( 1194 [AC_LANG_PROGRAM([[ 1195#include <sys/socket.h> 1196#include <netinet/in.h> 1197#include <unistd.h> 1198#include <stdlib.h> 1199#include <err.h> 1200 ]], [[ 1201int s, one = 1; 1202if ((s = socket(AF_INET, SOCK_STREAM, 0)) == -1) 1203 err(1, "socket"); 1204if (pledge("stdio", NULL) == -1) 1205 err(1, "pledge"); 1206if (setsockopt(s, IPPROTO_IP, IP_TOS, &one, sizeof(one)) == -1) 1207 err(1, "setsockopt"); 1208 ]])], 1209 [ AC_MSG_RESULT([yes]) ], [ 1210 AC_MSG_RESULT([no]) 1211 need_pledge_inet=1 1212 ], 1213 [ AC_MSG_WARN([cross compiling: cannot test]) ]) 1214 ;; 1215*-*-solaris*) 1216 if test "x$withval" != "xno" ; then 1217 rpath_opt="-R" 1218 fi 1219 AC_DEFINE([PAM_SUN_CODEBASE]) 1220 AC_DEFINE([LOGIN_NEEDS_UTMPX]) 1221 AC_DEFINE([PAM_TTY_KLUDGE]) 1222 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"]) 1223 # Pushing STREAMS modules will cause sshd to acquire a controlling tty. 1224 AC_DEFINE([SSHD_ACQUIRES_CTTY], [1], 1225 [Define if sshd somehow reacquires a controlling TTY 1226 after setsid()]) 1227 AC_DEFINE([PASSWD_NEEDS_USERNAME], [1], [must supply username to passwd 1228 in case the name is longer than 8 chars]) 1229 AC_DEFINE([BROKEN_TCGETATTR_ICANON], [1], [tcgetattr with ICANON may hang]) 1230 external_path_file=/etc/default/login 1231 # hardwire lastlog location (can't detect it on some versions) 1232 conf_lastlog_location="/var/adm/lastlog" 1233 AC_MSG_CHECKING([for obsolete utmp and wtmp in solaris2.x]) 1234 sol2ver=`echo "$host"| sed -e 's/.*[[0-9]]\.//'` 1235 if test "$sol2ver" -ge 8; then 1236 AC_MSG_RESULT([yes]) 1237 AC_DEFINE([DISABLE_UTMP]) 1238 AC_DEFINE([DISABLE_WTMP], [1], 1239 [Define if you don't want to use wtmp]) 1240 else 1241 AC_MSG_RESULT([no]) 1242 fi 1243 AC_CHECK_FUNCS([setpflags]) 1244 AC_CHECK_FUNCS([setppriv]) 1245 AC_CHECK_FUNCS([priv_basicset]) 1246 AC_CHECK_HEADERS([priv.h]) 1247 AC_ARG_WITH([solaris-contracts], 1248 [ --with-solaris-contracts Enable Solaris process contracts (experimental)], 1249 [ 1250 AC_CHECK_LIB([contract], [ct_tmpl_activate], 1251 [ AC_DEFINE([USE_SOLARIS_PROCESS_CONTRACTS], [1], 1252 [Define if you have Solaris process contracts]) 1253 LIBS="$LIBS -lcontract" 1254 SPC_MSG="yes" ], ) 1255 ], 1256 ) 1257 AC_ARG_WITH([solaris-projects], 1258 [ --with-solaris-projects Enable Solaris projects (experimental)], 1259 [ 1260 AC_CHECK_LIB([project], [setproject], 1261 [ AC_DEFINE([USE_SOLARIS_PROJECTS], [1], 1262 [Define if you have Solaris projects]) 1263 LIBS="$LIBS -lproject" 1264 SP_MSG="yes" ], ) 1265 ], 1266 ) 1267 AC_ARG_WITH([solaris-privs], 1268 [ --with-solaris-privs Enable Solaris/Illumos privileges (experimental)], 1269 [ 1270 AC_MSG_CHECKING([for Solaris/Illumos privilege support]) 1271 if test "x$ac_cv_func_setppriv" = "xyes" -a \ 1272 "x$ac_cv_header_priv_h" = "xyes" ; then 1273 SOLARIS_PRIVS=yes 1274 AC_MSG_RESULT([found]) 1275 AC_DEFINE([NO_UID_RESTORATION_TEST], [1], 1276 [Define to disable UID restoration test]) 1277 AC_DEFINE([USE_SOLARIS_PRIVS], [1], 1278 [Define if you have Solaris privileges]) 1279 SPP_MSG="yes" 1280 else 1281 AC_MSG_RESULT([not found]) 1282 AC_MSG_ERROR([*** must have support for Solaris privileges to use --with-solaris-privs]) 1283 fi 1284 ], 1285 ) 1286 TEST_SHELL=$SHELL # let configure find us a capable shell 1287 ;; 1288*-*-sunos4*) 1289 CPPFLAGS="$CPPFLAGS -DSUNOS4" 1290 AC_CHECK_FUNCS([getpwanam]) 1291 AC_DEFINE([PAM_SUN_CODEBASE]) 1292 conf_utmp_location=/etc/utmp 1293 conf_wtmp_location=/var/adm/wtmp 1294 conf_lastlog_location=/var/adm/lastlog 1295 AC_DEFINE([USE_PIPES]) 1296 AC_DEFINE([DISABLE_UTMPX], [1], [no utmpx]) 1297 ;; 1298*-ncr-sysv*) 1299 LIBS="$LIBS -lc89" 1300 AC_DEFINE([USE_PIPES]) 1301 AC_DEFINE([SSHD_ACQUIRES_CTTY]) 1302 AC_DEFINE([SETEUID_BREAKS_SETUID]) 1303 AC_DEFINE([BROKEN_SETREUID]) 1304 AC_DEFINE([BROKEN_SETREGID]) 1305 ;; 1306*-sni-sysv*) 1307 # /usr/ucblib MUST NOT be searched on ReliantUNIX 1308 AC_CHECK_LIB([dl], [dlsym], ,) 1309 # -lresolv needs to be at the end of LIBS or DNS lookups break 1310 AC_CHECK_LIB([resolv], [res_query], [ LIBS="$LIBS -lresolv" ]) 1311 IPADDR_IN_DISPLAY=yes 1312 AC_DEFINE([USE_PIPES]) 1313 AC_DEFINE([IP_TOS_IS_BROKEN]) 1314 AC_DEFINE([SETEUID_BREAKS_SETUID]) 1315 AC_DEFINE([BROKEN_SETREUID]) 1316 AC_DEFINE([BROKEN_SETREGID]) 1317 AC_DEFINE([SSHD_ACQUIRES_CTTY]) 1318 external_path_file=/etc/default/login 1319 # /usr/ucblib/libucb.a no longer needed on ReliantUNIX 1320 # Attention: always take care to bind libsocket and libnsl before libc, 1321 # otherwise you will find lots of "SIOCGPGRP errno 22" on syslog 1322 ;; 1323# UnixWare 1.x, UnixWare 2.x, and others based on code from Univel. 1324*-*-sysv4.2*) 1325 AC_DEFINE([USE_PIPES]) 1326 AC_DEFINE([SETEUID_BREAKS_SETUID]) 1327 AC_DEFINE([BROKEN_SETREUID]) 1328 AC_DEFINE([BROKEN_SETREGID]) 1329 AC_DEFINE([PASSWD_NEEDS_USERNAME], [1], [must supply username to passwd]) 1330 AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"]) 1331 TEST_SHELL=$SHELL # let configure find us a capable shell 1332 ;; 1333# UnixWare 7.x, OpenUNIX 8 1334*-*-sysv5*) 1335 CPPFLAGS="$CPPFLAGS -Dvsnprintf=_xvsnprintf -Dsnprintf=_xsnprintf" 1336 AC_DEFINE([UNIXWARE_LONG_PASSWORDS], [1], [Support passwords > 8 chars]) 1337 AC_DEFINE([USE_PIPES]) 1338 AC_DEFINE([SETEUID_BREAKS_SETUID]) 1339 AC_DEFINE([BROKEN_GETADDRINFO]) 1340 AC_DEFINE([BROKEN_SETREUID]) 1341 AC_DEFINE([BROKEN_SETREGID]) 1342 AC_DEFINE([PASSWD_NEEDS_USERNAME]) 1343 AC_DEFINE([BROKEN_TCGETATTR_ICANON]) 1344 TEST_SHELL=$SHELL # let configure find us a capable shell 1345 case "$host" in 1346 *-*-sysv5SCO_SV*) # SCO OpenServer 6.x 1347 maildir=/var/spool/mail 1348 AC_DEFINE([BROKEN_UPDWTMPX]) 1349 AC_CHECK_LIB([prot], [getluid], [ LIBS="$LIBS -lprot" 1350 AC_CHECK_FUNCS([getluid setluid], , , [-lprot]) 1351 ], , ) 1352 ;; 1353 *) AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"]) 1354 ;; 1355 esac 1356 ;; 1357*-*-sysv*) 1358 ;; 1359# SCO UNIX and OEM versions of SCO UNIX 1360*-*-sco3.2v4*) 1361 AC_MSG_ERROR("This Platform is no longer supported.") 1362 ;; 1363# SCO OpenServer 5.x 1364*-*-sco3.2v5*) 1365 if test -z "$GCC"; then 1366 CFLAGS="$CFLAGS -belf" 1367 fi 1368 LIBS="$LIBS -lprot -lx -ltinfo -lm" 1369 no_dev_ptmx=1 1370 AC_DEFINE([USE_PIPES]) 1371 AC_DEFINE([HAVE_SECUREWARE]) 1372 AC_DEFINE([DISABLE_SHADOW]) 1373 AC_DEFINE([DISABLE_FD_PASSING]) 1374 AC_DEFINE([SETEUID_BREAKS_SETUID]) 1375 AC_DEFINE([BROKEN_GETADDRINFO]) 1376 AC_DEFINE([BROKEN_SETREUID]) 1377 AC_DEFINE([BROKEN_SETREGID]) 1378 AC_DEFINE([WITH_ABBREV_NO_TTY]) 1379 AC_DEFINE([BROKEN_UPDWTMPX]) 1380 AC_DEFINE([PASSWD_NEEDS_USERNAME]) 1381 AC_CHECK_FUNCS([getluid setluid]) 1382 MANTYPE=man 1383 TEST_SHELL=$SHELL # let configure find us a capable shell 1384 SKIP_DISABLE_LASTLOG_DEFINE=yes 1385 ;; 1386*-dec-osf*) 1387 AC_MSG_CHECKING([for Digital Unix SIA]) 1388 no_osfsia="" 1389 AC_ARG_WITH([osfsia], 1390 [ --with-osfsia Enable Digital Unix SIA], 1391 [ 1392 if test "x$withval" = "xno" ; then 1393 AC_MSG_RESULT([disabled]) 1394 no_osfsia=1 1395 fi 1396 ], 1397 ) 1398 if test -z "$no_osfsia" ; then 1399 if test -f /etc/sia/matrix.conf; then 1400 AC_MSG_RESULT([yes]) 1401 AC_DEFINE([HAVE_OSF_SIA], [1], 1402 [Define if you have Digital Unix Security 1403 Integration Architecture]) 1404 AC_DEFINE([DISABLE_LOGIN], [1], 1405 [Define if you don't want to use your 1406 system's login() call]) 1407 AC_DEFINE([DISABLE_FD_PASSING]) 1408 LIBS="$LIBS -lsecurity -ldb -lm -laud" 1409 SIA_MSG="yes" 1410 else 1411 AC_MSG_RESULT([no]) 1412 AC_DEFINE([LOCKED_PASSWD_SUBSTR], ["Nologin"], 1413 [String used in /etc/passwd to denote locked account]) 1414 fi 1415 fi 1416 AC_DEFINE([BROKEN_GETADDRINFO]) 1417 AC_DEFINE([SETEUID_BREAKS_SETUID]) 1418 AC_DEFINE([BROKEN_SETREUID]) 1419 AC_DEFINE([BROKEN_SETREGID]) 1420 AC_DEFINE([BROKEN_READV_COMPARISON], [1], [Can't do comparisons on readv]) 1421 ;; 1422 1423*-*-nto-qnx*) 1424 AC_DEFINE([USE_PIPES]) 1425 AC_DEFINE([NO_X11_UNIX_SOCKETS]) 1426 AC_DEFINE([DISABLE_LASTLOG]) 1427 AC_DEFINE([SSHD_ACQUIRES_CTTY]) 1428 AC_DEFINE([BROKEN_SHADOW_EXPIRE], [1], [QNX shadow support is broken]) 1429 enable_etc_default_login=no # has incompatible /etc/default/login 1430 case "$host" in 1431 *-*-nto-qnx6*) 1432 AC_DEFINE([DISABLE_FD_PASSING]) 1433 ;; 1434 esac 1435 ;; 1436 1437*-*-ultrix*) 1438 AC_DEFINE([BROKEN_GETGROUPS], [1], [getgroups(0,NULL) will return -1]) 1439 AC_DEFINE([NEED_SETPGRP], [1], [Need setpgrp to for controlling tty]) 1440 AC_DEFINE([HAVE_SYS_SYSLOG_H], [1], [Force use of sys/syslog.h on Ultrix]) 1441 AC_DEFINE([DISABLE_UTMPX], [1], [Disable utmpx]) 1442 # DISABLE_FD_PASSING so that we call setpgrp as root, otherwise we 1443 # don't get a controlling tty. 1444 AC_DEFINE([DISABLE_FD_PASSING], [1], [Need to call setpgrp as root]) 1445 # On Ultrix some headers are not protected against multiple includes, 1446 # so we create wrappers and put it where the compiler will find it. 1447 AC_MSG_WARN([creating compat wrappers for headers]) 1448 mkdir -p netinet 1449 for header in netinet/ip.h netdb.h resolv.h; do 1450 name=`echo $header | tr 'a-z/.' 'A-Z__'` 1451 cat >$header <<EOD 1452#ifndef _SSH_COMPAT_${name} 1453#define _SSH_COMPAT_${name} 1454#include "/usr/include/${header}" 1455#endif 1456EOD 1457 done 1458 ;; 1459 1460*-*-lynxos) 1461 CFLAGS="$CFLAGS -D__NO_INCLUDE_WARN__" 1462 AC_DEFINE([BROKEN_SETVBUF], [1], 1463 [LynxOS has broken setvbuf() implementation]) 1464 ;; 1465*-*-gnu*) 1466 dnl GNU Hurd. Needs to be after the linux and the other *-gnu entries. 1467 dnl Target SUSv3/POSIX.1-2001 plus BSD specifics. 1468 dnl _DEFAULT_SOURCE is the new name for _BSD_SOURCE 1469 dnl _GNU_SOURCE is needed for setres*id prototypes. 1470 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_GNU_SOURCE" 1471 ;; 1472esac 1473 1474AC_MSG_CHECKING([compiler and flags for sanity]) 1475AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #include <stdlib.h> ]], [[ exit(0); ]])], 1476 [ AC_MSG_RESULT([yes]) ], 1477 [ 1478 AC_MSG_RESULT([no]) 1479 AC_MSG_ERROR([*** compiler cannot create working executables, check config.log ***]) 1480 ], 1481 [ AC_MSG_WARN([cross compiling: not checking compiler sanity]) ] 1482) 1483 1484dnl Finish up special pledge(2) handling from above. 1485if test -z "$need_pledge_inet" ; then 1486 AC_DEFINE_UNQUOTED([PLEDGE_EXTRA_INET], []) 1487else 1488 AC_DEFINE_UNQUOTED([PLEDGE_EXTRA_INET], ["inet "], 1489 [need inet in pledge for setsockopt IP_TOS]) 1490fi 1491 1492dnl Checks for header files. 1493# Checks for libraries. 1494AC_CHECK_FUNC([setsockopt], , [AC_CHECK_LIB([socket], [setsockopt])]) 1495 1496dnl IRIX and Solaris 2.5.1 have dirname() in libgen 1497AC_CHECK_FUNCS([dirname], [AC_CHECK_HEADERS([libgen.h])] , [ 1498 AC_CHECK_LIB([gen], [dirname], [ 1499 AC_CACHE_CHECK([for broken dirname], 1500 ac_cv_have_broken_dirname, [ 1501 save_LIBS="$LIBS" 1502 LIBS="$LIBS -lgen" 1503 AC_RUN_IFELSE( 1504 [AC_LANG_SOURCE([[ 1505#include <libgen.h> 1506#include <string.h> 1507#include <stdlib.h> 1508 1509int main(int argc, char **argv) { 1510 char *s, buf[32]; 1511 1512 strncpy(buf,"/etc", 32); 1513 s = dirname(buf); 1514 if (!s || strncmp(s, "/", 32) != 0) { 1515 exit(1); 1516 } else { 1517 exit(0); 1518 } 1519} 1520 ]])], 1521 [ ac_cv_have_broken_dirname="no" ], 1522 [ ac_cv_have_broken_dirname="yes" ], 1523 [ ac_cv_have_broken_dirname="no" ], 1524 ) 1525 LIBS="$save_LIBS" 1526 ]) 1527 if test "x$ac_cv_have_broken_dirname" = "xno" ; then 1528 LIBS="$LIBS -lgen" 1529 AC_DEFINE([HAVE_DIRNAME]) 1530 AC_CHECK_HEADERS([libgen.h]) 1531 fi 1532 ]) 1533]) 1534 1535AC_CHECK_FUNC([getspnam], , 1536 [AC_CHECK_LIB([gen], [getspnam], [LIBS="$LIBS -lgen"])]) 1537AC_SEARCH_LIBS([basename], [gen], [AC_DEFINE([HAVE_BASENAME], [1], 1538 [Define if you have the basename function.])]) 1539 1540dnl sqrt() only used in unit tests. 1541AC_CHECK_FUNC([sqrt], , 1542 [AC_CHECK_LIB([m], [sqrt], [TESTLIBS="$TESTLIBS -lm"])]) 1543AC_SUBST([TESTLIBS]) 1544 1545dnl zlib defaults to enabled 1546zlib=yes 1547AC_ARG_WITH([zlib], 1548 [ --with-zlib=PATH Use zlib in PATH], 1549 [ if test "x$withval" = "xno" ; then 1550 zlib=no 1551 elif test "x$withval" != "xyes"; then 1552 if test -d "$withval/lib"; then 1553 if test -n "${rpath_opt}"; then 1554 LDFLAGS="-L${withval}/lib ${rpath_opt}${withval}/lib ${LDFLAGS}" 1555 else 1556 LDFLAGS="-L${withval}/lib ${LDFLAGS}" 1557 fi 1558 else 1559 if test -n "${rpath_opt}"; then 1560 LDFLAGS="-L${withval} ${rpath_opt}${withval} ${LDFLAGS}" 1561 else 1562 LDFLAGS="-L${withval} ${LDFLAGS}" 1563 fi 1564 fi 1565 if test -d "$withval/include"; then 1566 CPPFLAGS="-I${withval}/include ${CPPFLAGS}" 1567 else 1568 CPPFLAGS="-I${withval} ${CPPFLAGS}" 1569 fi 1570 fi ] 1571) 1572 1573# These libraries are needed for anything that links in the channel code. 1574CHANNELLIBS="" 1575AC_MSG_CHECKING([for zlib]) 1576if test "x${zlib}" = "xno"; then 1577 AC_MSG_RESULT([no]) 1578else 1579 saved_LIBS="$LIBS" 1580 CHANNELLIBS="$CHANNELLIBS -lz" 1581 AC_MSG_RESULT([yes]) 1582 AC_DEFINE([WITH_ZLIB], [1], [Enable zlib]) 1583 AC_CHECK_HEADER([zlib.h], ,[AC_MSG_ERROR([*** zlib.h missing - please install first or check config.log ***])]) 1584 AC_CHECK_LIB([z], [deflate], [], 1585 [ 1586 saved_CPPFLAGS="$CPPFLAGS" 1587 saved_LDFLAGS="$LDFLAGS" 1588 dnl Check default zlib install dir 1589 if test -n "${rpath_opt}"; then 1590 LDFLAGS="-L/usr/local/lib ${rpath_opt}/usr/local/lib ${saved_LDFLAGS}" 1591 else 1592 LDFLAGS="-L/usr/local/lib ${saved_LDFLAGS}" 1593 fi 1594 CPPFLAGS="-I/usr/local/include ${saved_CPPFLAGS}" 1595 AC_TRY_LINK_FUNC([deflate], [AC_DEFINE([HAVE_LIBZ])], 1596 [ 1597 AC_MSG_ERROR([*** zlib missing - please install first or check config.log ***]) 1598 ] 1599 ) 1600 ] 1601 ) 1602 1603 AC_ARG_WITH([zlib-version-check], 1604 [ --without-zlib-version-check Disable zlib version check], 1605 [ if test "x$withval" = "xno" ; then 1606 zlib_check_nonfatal=1 1607 fi 1608 ] 1609 ) 1610 1611 AC_MSG_CHECKING([for possibly buggy zlib]) 1612 AC_RUN_IFELSE([AC_LANG_PROGRAM([[ 1613#include <stdio.h> 1614#include <stdlib.h> 1615#include <zlib.h> 1616 ]], 1617 [[ 1618 int a=0, b=0, c=0, d=0, n, v; 1619 n = sscanf(ZLIB_VERSION, "%d.%d.%d.%d", &a, &b, &c, &d); 1620 if (n < 1) 1621 exit(1); 1622 v = a*1000000 + b*10000 + c*100 + d; 1623 fprintf(stderr, "found zlib version %s (%d)\n", ZLIB_VERSION, v); 1624 1625 /* 1.1.4 is OK */ 1626 if (a == 1 && b == 1 && c >= 4) 1627 exit(0); 1628 1629 /* 1.2.3 and up are OK */ 1630 if (v >= 1020300) 1631 exit(0); 1632 1633 exit(2); 1634 ]])], 1635 AC_MSG_RESULT([no]), 1636 [ AC_MSG_RESULT([yes]) 1637 if test -z "$zlib_check_nonfatal" ; then 1638 AC_MSG_ERROR([*** zlib too old - check config.log *** 1639Your reported zlib version has known security problems. It's possible your 1640vendor has fixed these problems without changing the version number. If you 1641are sure this is the case, you can disable the check by running 1642"./configure --without-zlib-version-check". 1643If you are in doubt, upgrade zlib to version 1.2.3 or greater. 1644See http://www.gzip.org/zlib/ for details.]) 1645 else 1646 AC_MSG_WARN([zlib version may have security problems]) 1647 fi 1648 ], 1649 [ AC_MSG_WARN([cross compiling: not checking zlib version]) ] 1650 ) 1651 LIBS="$saved_LIBS" 1652fi 1653 1654dnl UnixWare 2.x 1655AC_CHECK_FUNC([strcasecmp], 1656 [], [ AC_CHECK_LIB([resolv], [strcasecmp], [LIBS="$LIBS -lresolv"]) ] 1657) 1658AC_CHECK_FUNCS([utimes], 1659 [], [ AC_CHECK_LIB([c89], [utimes], [AC_DEFINE([HAVE_UTIMES]) 1660 LIBS="$LIBS -lc89"]) ] 1661) 1662 1663dnl Checks for libutil functions 1664AC_CHECK_HEADERS([bsd/libutil.h libutil.h]) 1665AC_SEARCH_LIBS([fmt_scaled], [util bsd]) 1666AC_SEARCH_LIBS([scan_scaled], [util bsd]) 1667AC_SEARCH_LIBS([login], [util bsd]) 1668AC_SEARCH_LIBS([logout], [util bsd]) 1669AC_SEARCH_LIBS([logwtmp], [util bsd]) 1670AC_SEARCH_LIBS([openpty], [util bsd]) 1671AC_SEARCH_LIBS([updwtmp], [util bsd]) 1672AC_CHECK_FUNCS([fmt_scaled scan_scaled login logout openpty updwtmp logwtmp]) 1673 1674# On some platforms, inet_ntop and gethostbyname may be found in libresolv 1675# or libnsl. 1676AC_SEARCH_LIBS([inet_ntop], [resolv nsl]) 1677AC_SEARCH_LIBS([gethostbyname], [resolv nsl]) 1678 1679# Some Linux distribtions ship the BSD libc hashing functions in 1680# separate libraries. 1681AC_SEARCH_LIBS([SHA256Update], [md bsd]) 1682 1683# "Particular Function Checks" 1684# see https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Particular-Functions.html 1685AC_FUNC_STRFTIME 1686AC_FUNC_MALLOC 1687AC_FUNC_REALLOC 1688# autoconf doesn't have AC_FUNC_CALLOC so fake it if malloc returns NULL; 1689AC_MSG_CHECKING([if calloc(0, N) returns non-null]) 1690AC_RUN_IFELSE( 1691 [AC_LANG_PROGRAM( 1692 [[ #include <stdlib.h> ]], 1693 [[ void *p = calloc(0, 1); exit(p == NULL); ]] 1694 )], 1695 [ func_calloc_0_nonnull=yes ], 1696 [ func_calloc_0_nonnull=no ], 1697 [ AC_MSG_WARN([cross compiling: assuming same as malloc]) 1698 func_calloc_0_nonnull="$ac_cv_func_malloc_0_nonnull"] 1699) 1700AC_MSG_RESULT([$func_calloc_0_nonnull]) 1701 1702if test "x$func_calloc_0_nonnull" = "xyes"; then 1703 AC_DEFINE(HAVE_CALLOC, 1, [calloc(0, x) returns non-null]) 1704else 1705 AC_DEFINE(HAVE_CALLOC, 0, [calloc(0, x) returns NULL]) 1706 AC_DEFINE(calloc, rpl_calloc, 1707 [Define to rpl_calloc if the replacement function should be used.]) 1708fi 1709 1710dnl Figure out if we have a system glob, and if so if we can use it. 1711AC_CHECK_FUNCS([glob], 1712 [ AC_CHECK_HEADERS([glob.h], 1713 [use_system_glob=yes], 1714 [use_system_glob=no]) 1715 ], 1716 use_system_glob=no 1717) 1718 1719# Check for ALTDIRFUNC glob() extension 1720AC_MSG_CHECKING([for GLOB_ALTDIRFUNC support]) 1721AC_EGREP_CPP([FOUNDIT], 1722 [ 1723 #include <glob.h> 1724 #ifdef GLOB_ALTDIRFUNC 1725 FOUNDIT 1726 #endif 1727 ], 1728 [ 1729 AC_DEFINE([GLOB_HAS_ALTDIRFUNC], [1], 1730 [Define if your system glob() function has 1731 the GLOB_ALTDIRFUNC extension]) 1732 AC_MSG_RESULT([yes]) 1733 ], 1734 [ 1735 AC_MSG_RESULT([no]) 1736 use_system_glob=no 1737 ] 1738) 1739 1740# Check for g.gl_matchc glob() extension 1741AC_MSG_CHECKING([for gl_matchc field in glob_t]) 1742AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <glob.h> ]], 1743 [[ glob_t g; g.gl_matchc = 1; ]])], 1744 [ 1745 AC_DEFINE([GLOB_HAS_GL_MATCHC], [1], 1746 [Define if your system glob() function has 1747 gl_matchc options in glob_t]) 1748 AC_MSG_RESULT([yes]) 1749 ], [ 1750 AC_MSG_RESULT([no]) 1751 use_system_glob=no 1752 ] 1753) 1754 1755# Check for g.gl_statv glob() extension 1756AC_MSG_CHECKING([for gl_statv and GLOB_KEEPSTAT extensions for glob]) 1757AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <glob.h> ]], [[ 1758#ifndef GLOB_KEEPSTAT 1759#error "glob does not support GLOB_KEEPSTAT extension" 1760#endif 1761glob_t g; 1762g.gl_statv = NULL; 1763]])], 1764 [ 1765 AC_DEFINE([GLOB_HAS_GL_STATV], [1], 1766 [Define if your system glob() function has 1767 gl_statv options in glob_t]) 1768 AC_MSG_RESULT([yes]) 1769 ], [ 1770 AC_MSG_RESULT([no]) 1771 use_system_glob=no 1772 ] 1773) 1774 1775AC_CHECK_DECLS([GLOB_NOMATCH], , [use_system_glob=no], [#include <glob.h>]) 1776 1777if test "x$broken_glob" = "xyes"; then 1778 AC_DEFINE([BROKEN_GLOB], [1], [Do not use system glob]) 1779 use_system_glob=no 1780fi 1781 1782dnl If we don't have a system glob, or we do but we're not using it, then 1783dnl create a glob.h shim so we don't have to sprinkle ifdefs everywhere. 1784AC_MSG_CHECKING([if we can use the system glob]) 1785if test "x$use_system_glob" = "xyes" ; then 1786 AC_MSG_RESULT([yes]) 1787 # Remove any old shims. 1788 rm -f "$COMPATINCLUDESDIR/glob.h" 1789else 1790 AC_MSG_RESULT([no]) 1791 COMPATINCLUDES="$COMPATINCLUDESDIR" 1792 mkdir -p "$COMPATINCLUDES" 1793 echo '#include "openbsd-compat/glob.h"' >$COMPATINCLUDES/glob.h 1794fi 1795 1796AC_CHECK_DECL([VIS_ALL], , 1797 AC_DEFINE(BROKEN_STRNVIS, 1, [missing VIS_ALL]), [#include <vis.h>]) 1798 1799AC_MSG_CHECKING([whether struct dirent allocates space for d_name]) 1800AC_RUN_IFELSE( 1801 [AC_LANG_PROGRAM([[ 1802#include <sys/types.h> 1803#include <dirent.h> 1804#include <stdlib.h> 1805 ]], 1806 [[ 1807 struct dirent d; 1808 exit(sizeof(d.d_name)<=sizeof(char)); 1809 ]])], 1810 [AC_MSG_RESULT([yes])], 1811 [ 1812 AC_MSG_RESULT([no]) 1813 AC_DEFINE([BROKEN_ONE_BYTE_DIRENT_D_NAME], [1], 1814 [Define if your struct dirent expects you to 1815 allocate extra space for d_name]) 1816 ], 1817 [ 1818 AC_MSG_WARN([cross compiling: assuming BROKEN_ONE_BYTE_DIRENT_D_NAME]) 1819 AC_DEFINE([BROKEN_ONE_BYTE_DIRENT_D_NAME]) 1820 ] 1821) 1822 1823AC_CHECK_MEMBERS([struct dirent.d_type], [], [], [[ 1824#ifdef HAVE_DIRENT_H 1825#include <dirent.h> 1826#endif 1827]]) 1828 1829AC_MSG_CHECKING([for /proc/pid/fd directory]) 1830if test -d "/proc/$$/fd" ; then 1831 AC_DEFINE([HAVE_PROC_PID], [1], [Define if you have /proc/$pid/fd]) 1832 AC_MSG_RESULT([yes]) 1833else 1834 AC_MSG_RESULT([no]) 1835fi 1836 1837# Check whether user wants TCP wrappers support 1838TCPW_MSG="no" 1839AC_ARG_WITH([tcp-wrappers], 1840 [ --with-tcp-wrappers[[=PATH]] Enable tcpwrappers support (optionally in PATH)], 1841 [ 1842 if test "x$withval" != "xno" ; then 1843 saved_LIBS="$LIBS" 1844 saved_LDFLAGS="$LDFLAGS" 1845 saved_CPPFLAGS="$CPPFLAGS" 1846 if test -n "${withval}" && \ 1847 test "x${withval}" != "xyes"; then 1848 if test -d "${withval}/lib"; then 1849 if test -n "${need_dash_r}"; then 1850 LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}" 1851 else 1852 LDFLAGS="-L${withval}/lib ${LDFLAGS}" 1853 fi 1854 else 1855 if test -n "${need_dash_r}"; then 1856 LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}" 1857 else 1858 LDFLAGS="-L${withval} ${LDFLAGS}" 1859 fi 1860 fi 1861 if test -d "${withval}/include"; then 1862 CPPFLAGS="-I${withval}/include ${CPPFLAGS}" 1863 else 1864 CPPFLAGS="-I${withval} ${CPPFLAGS}" 1865 fi 1866 fi 1867 LIBS="-lwrap $LIBS" 1868 AC_MSG_CHECKING([for libwrap]) 1869 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 1870#include <sys/types.h> 1871#include <sys/socket.h> 1872#include <netinet/in.h> 1873#include <tcpd.h> 1874int deny_severity = 0, allow_severity = 0; 1875 ]], [[ 1876 hosts_access(0); 1877 ]])], [ 1878 AC_MSG_RESULT([yes]) 1879 AC_DEFINE([LIBWRAP], [1], 1880 [Define if you want 1881 TCP Wrappers support]) 1882 SSHDLIBS="$SSHDLIBS -lwrap" 1883 TCPW_MSG="yes" 1884 ], [ 1885 AC_MSG_ERROR([*** libwrap missing]) 1886 ]) 1887 LIBS="$saved_LIBS" 1888 fi 1889 ] 1890) 1891 1892# Check whether user wants to use ldns 1893LDNS_MSG="no" 1894AC_ARG_WITH(ldns, 1895 [ --with-ldns[[=PATH]] Use ldns for DNSSEC support (optionally in PATH)], 1896 [ 1897 ldns="" 1898 if test "x$withval" = "xyes" ; then 1899 AC_PATH_TOOL([LDNSCONFIG], [ldns-config], [no]) 1900 if test "x$LDNSCONFIG" = "xno"; then 1901 LIBS="-lldns $LIBS" 1902 ldns=yes 1903 else 1904 LIBS="$LIBS `$LDNSCONFIG --libs`" 1905 CPPFLAGS="$CPPFLAGS `$LDNSCONFIG --cflags`" 1906 ldns=yes 1907 fi 1908 elif test "x$withval" != "xno" ; then 1909 CPPFLAGS="$CPPFLAGS -I${withval}/include" 1910 LDFLAGS="$LDFLAGS -L${withval}/lib" 1911 LIBS="-lldns $LIBS" 1912 ldns=yes 1913 fi 1914 1915 # Verify that it works. 1916 if test "x$ldns" = "xyes" ; then 1917 AC_DEFINE(HAVE_LDNS, 1, [Define if you want ldns support]) 1918 LDNS_MSG="yes" 1919 AC_MSG_CHECKING([for ldns support]) 1920 AC_LINK_IFELSE( 1921 [AC_LANG_SOURCE([[ 1922#include <stdio.h> 1923#include <stdlib.h> 1924#ifdef HAVE_STDINT_H 1925# include <stdint.h> 1926#endif 1927#include <ldns/ldns.h> 1928int main(void) { ldns_status status = ldns_verify_trusted(NULL, NULL, NULL, NULL); status=LDNS_STATUS_OK; exit(0); } 1929 ]]) 1930 ], 1931 [AC_MSG_RESULT(yes)], 1932 [ 1933 AC_MSG_RESULT(no) 1934 AC_MSG_ERROR([** Incomplete or missing ldns libraries.]) 1935 ]) 1936 fi 1937]) 1938 1939# Check whether user wants libedit support 1940LIBEDIT_MSG="no" 1941AC_ARG_WITH([libedit], 1942 [ --with-libedit[[=PATH]] Enable libedit support for sftp], 1943 [ if test "x$withval" != "xno" ; then 1944 if test "x$withval" = "xyes" ; then 1945 if test "x$PKGCONFIG" != "xno"; then 1946 AC_MSG_CHECKING([if $PKGCONFIG knows about libedit]) 1947 if "$PKGCONFIG" libedit; then 1948 AC_MSG_RESULT([yes]) 1949 use_pkgconfig_for_libedit=yes 1950 else 1951 AC_MSG_RESULT([no]) 1952 fi 1953 fi 1954 else 1955 CPPFLAGS="$CPPFLAGS -I${withval}/include" 1956 if test -n "${rpath_opt}"; then 1957 LDFLAGS="-L${withval}/lib ${rpath_opt}${withval}/lib ${LDFLAGS}" 1958 else 1959 LDFLAGS="-L${withval}/lib ${LDFLAGS}" 1960 fi 1961 fi 1962 if test "x$use_pkgconfig_for_libedit" = "xyes"; then 1963 LIBEDIT=`$PKGCONFIG --libs libedit` 1964 CPPFLAGS="$CPPFLAGS `$PKGCONFIG --cflags libedit`" 1965 else 1966 LIBEDIT="-ledit -lcurses" 1967 fi 1968 OTHERLIBS=`echo $LIBEDIT | sed 's/-ledit//'` 1969 AC_CHECK_LIB([edit], [el_init], 1970 [ AC_DEFINE([USE_LIBEDIT], [1], [Use libedit for sftp]) 1971 LIBEDIT_MSG="yes" 1972 AC_SUBST([LIBEDIT]) 1973 ], 1974 [ AC_MSG_ERROR([libedit not found]) ], 1975 [ $OTHERLIBS ] 1976 ) 1977 AC_MSG_CHECKING([if libedit version is compatible]) 1978 AC_COMPILE_IFELSE( 1979 [AC_LANG_PROGRAM([[ 1980#include <histedit.h> 1981#include <stdlib.h> 1982 ]], 1983 [[ 1984 int i = H_SETSIZE; 1985 el_init("", NULL, NULL, NULL); 1986 exit(0); 1987 ]])], 1988 [ AC_MSG_RESULT([yes]) ], 1989 [ AC_MSG_RESULT([no]) 1990 AC_MSG_ERROR([libedit version is not compatible]) ] 1991 ) 1992 fi ] 1993) 1994 1995# Check whether user wants wtmpdb support 1996WTMPDB_MSG="no" 1997AC_ARG_WITH([wtmpdb], 1998 [ --with-wtmpdb[[=PATH]] Enable wtmpdb support for sshd], 1999 [ if test "x$withval" != "xno" ; then 2000 if test "x$withval" = "xyes" ; then 2001 if test "x$PKGCONFIG" != "xno"; then 2002 AC_MSG_CHECKING([if $PKGCONFIG knows about wtmpdb]) 2003 if "$PKGCONFIG" libwtmpdb; then 2004 AC_MSG_RESULT([yes]) 2005 use_pkgconfig_for_libwtmpdb=yes 2006 else 2007 AC_MSG_RESULT([no]) 2008 fi 2009 fi 2010 else 2011 CPPFLAGS="$CPPFLAGS -I${withval}/include" 2012 if test -n "${rpath_opt}"; then 2013 LDFLAGS="-L${withval}/lib ${rpath_opt}${withval}/lib ${LDFLAGS}" 2014 else 2015 LDFLAGS="-L${withval}/lib ${LDFLAGS}" 2016 fi 2017 fi 2018 if test "x$use_pkgconfig_for_libwtmpdb" = "xyes"; then 2019 LIBWTMPDB=`$PKGCONFIG --libs libwtmpdb` 2020 CPPFLAGS="$CPPFLAGS `$PKGCONFIG --cflags libwtmpdb`" 2021 else 2022 LIBWTMPDB="-lwtmpdb" 2023 fi 2024 OTHERLIBS=`echo $LIBWTMPDB | sed 's/-lwtmpdb//'` 2025 AC_CHECK_LIB([wtmpdb], [wtmpdb_login], 2026 [ AC_DEFINE([USE_WTMPDB], [1], [Use libwtmpdb for sshd]) 2027 WTMPDB_MSG="yes" 2028 AC_SUBST([LIBWTMPDB]) 2029 ], 2030 [ AC_MSG_ERROR([libwtmpdb not found]) ], 2031 [ $OTHERLIBS ] 2032 ) 2033 fi ] 2034) 2035 2036 2037AUDIT_MODULE=none 2038AC_ARG_WITH([audit], 2039 [ --with-audit=module Enable audit support (modules=debug,bsm,linux)], 2040 [ 2041 AC_MSG_CHECKING([for supported audit module]) 2042 case "$withval" in 2043 bsm) 2044 AC_MSG_RESULT([bsm]) 2045 AUDIT_MODULE=bsm 2046 dnl Checks for headers, libs and functions 2047 AC_CHECK_HEADERS([bsm/audit.h], [], 2048 [AC_MSG_ERROR([BSM enabled and bsm/audit.h not found])], 2049 [ 2050#ifdef HAVE_TIME_H 2051# include <time.h> 2052#endif 2053 ] 2054) 2055 AC_CHECK_LIB([bsm], [getaudit], [], 2056 [AC_MSG_ERROR([BSM enabled and required library not found])]) 2057 AC_CHECK_FUNCS([getaudit], [], 2058 [AC_MSG_ERROR([BSM enabled and required function not found])]) 2059 # These are optional 2060 AC_CHECK_FUNCS([getaudit_addr aug_get_machine]) 2061 AC_DEFINE([USE_BSM_AUDIT], [1], [Use BSM audit module]) 2062 if test "$sol2ver" -ge 11; then 2063 SSHDLIBS="$SSHDLIBS -lscf" 2064 AC_DEFINE([BROKEN_BSM_API], [1], 2065 [The system has incomplete BSM API]) 2066 fi 2067 ;; 2068 linux) 2069 AC_MSG_RESULT([linux]) 2070 AUDIT_MODULE=linux 2071 dnl Checks for headers, libs and functions 2072 AC_CHECK_HEADERS([libaudit.h]) 2073 SSHDLIBS="$SSHDLIBS -laudit" 2074 AC_DEFINE([USE_LINUX_AUDIT], [1], [Use Linux audit module]) 2075 ;; 2076 debug) 2077 AUDIT_MODULE=debug 2078 AC_MSG_RESULT([debug]) 2079 AC_DEFINE([SSH_AUDIT_EVENTS], [1], [Use audit debugging module]) 2080 ;; 2081 no) 2082 AC_MSG_RESULT([no]) 2083 ;; 2084 *) 2085 AC_MSG_ERROR([Unknown audit module $withval]) 2086 ;; 2087 esac ] 2088) 2089 2090AC_ARG_WITH([pie], 2091 [ --with-pie Build Position Independent Executables if possible], [ 2092 if test "x$withval" = "xno"; then 2093 use_pie=no 2094 fi 2095 if test "x$withval" = "xyes"; then 2096 use_pie=yes 2097 fi 2098 ] 2099) 2100if test "x$use_pie" = "x"; then 2101 use_pie=no 2102fi 2103if test "x$use_toolchain_hardening" != "x1" && test "x$use_pie" = "xauto"; then 2104 # Turn off automatic PIE when toolchain hardening is off. 2105 use_pie=no 2106fi 2107if test "x$use_pie" = "xauto"; then 2108 # Automatic PIE requires gcc >= 4.x 2109 AC_MSG_CHECKING([for gcc >= 4.x]) 2110 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ 2111#if !defined(__GNUC__) || __GNUC__ < 4 2112#error gcc is too old 2113#endif 2114]])], 2115 [ AC_MSG_RESULT([yes]) ], 2116 [ AC_MSG_RESULT([no]) 2117 use_pie=no ] 2118) 2119fi 2120if test "x$use_pie" != "xno"; then 2121 SAVED_CFLAGS="$CFLAGS" 2122 SAVED_LDFLAGS="$LDFLAGS" 2123 OSSH_CHECK_CFLAG_COMPILE([-fPIE]) 2124 OSSH_CHECK_LDFLAG_LINK([-pie]) 2125 # We use both -fPIE and -pie or neither. 2126 AC_MSG_CHECKING([whether both -fPIE and -pie are supported]) 2127 if echo "x $CFLAGS" | grep ' -fPIE' >/dev/null 2>&1 && \ 2128 echo "x $LDFLAGS" | grep ' -pie' >/dev/null 2>&1 ; then 2129 AC_MSG_RESULT([yes]) 2130 else 2131 AC_MSG_RESULT([no]) 2132 CFLAGS="$SAVED_CFLAGS" 2133 LDFLAGS="$SAVED_LDFLAGS" 2134 fi 2135fi 2136 2137AC_MSG_CHECKING([whether -fPIC is accepted]) 2138SAVED_CFLAGS="$CFLAGS" 2139CFLAGS="$CFLAGS -fPIC" 2140AC_COMPILE_IFELSE( 2141 [AC_LANG_PROGRAM( [[ #include <stdlib.h> ]], [[ exit(0); ]] )], 2142 [AC_MSG_RESULT([yes]) 2143 PICFLAG="-fPIC"; ], 2144 [AC_MSG_RESULT([no]) 2145 PICFLAG=""; ]) 2146CFLAGS="$SAVED_CFLAGS" 2147AC_SUBST([PICFLAG]) 2148 2149dnl Checks for library functions. Please keep in alphabetical order 2150AC_CHECK_FUNCS([ \ 2151 auth_hostok \ 2152 auth_timeok \ 2153 Blowfish_initstate \ 2154 Blowfish_expandstate \ 2155 Blowfish_expand0state \ 2156 Blowfish_stream2word \ 2157 SHA256Update \ 2158 SHA384Update \ 2159 SHA512Update \ 2160 asprintf \ 2161 b64_ntop \ 2162 __b64_ntop \ 2163 b64_pton \ 2164 __b64_pton \ 2165 bcopy \ 2166 bcrypt_pbkdf \ 2167 bindresvport_sa \ 2168 blf_enc \ 2169 bzero \ 2170 cap_rights_limit \ 2171 clock \ 2172 closefrom \ 2173 close_range \ 2174 dirfd \ 2175 endgrent \ 2176 err \ 2177 errx \ 2178 explicit_bzero \ 2179 explicit_memset \ 2180 fchmod \ 2181 fchmodat \ 2182 fchown \ 2183 fchownat \ 2184 flock \ 2185 fnmatch \ 2186 freeaddrinfo \ 2187 freezero \ 2188 fstatat \ 2189 fstatfs \ 2190 fstatvfs \ 2191 futimes \ 2192 getaddrinfo \ 2193 getcwd \ 2194 getentropy \ 2195 getgrouplist \ 2196 getline \ 2197 getnameinfo \ 2198 getopt \ 2199 getpeereid \ 2200 getpeerucred \ 2201 getpgid \ 2202 _getpty \ 2203 getrlimit \ 2204 getrandom \ 2205 getsid \ 2206 getttyent \ 2207 group_from_gid \ 2208 inet_aton \ 2209 inet_ntoa \ 2210 inet_ntop \ 2211 innetgr \ 2212 killpg \ 2213 llabs \ 2214 localtime_r \ 2215 login_getcapbool \ 2216 login_getpwclass \ 2217 memmem \ 2218 memmove \ 2219 memset_s \ 2220 mkdtemp \ 2221 mmap \ 2222 ngetaddrinfo \ 2223 nlist \ 2224 nsleep \ 2225 ogetaddrinfo \ 2226 openlog_r \ 2227 pledge \ 2228 poll \ 2229 ppoll \ 2230 prctl \ 2231 procctl \ 2232 pselect \ 2233 pstat \ 2234 raise \ 2235 readpassphrase \ 2236 reallocarray \ 2237 realpath \ 2238 recvmsg \ 2239 recallocarray \ 2240 rresvport_af \ 2241 sendmsg \ 2242 setdtablesize \ 2243 setegid \ 2244 setenv \ 2245 seteuid \ 2246 setgroupent \ 2247 setgroups \ 2248 setlinebuf \ 2249 setlogin \ 2250 setpassent\ 2251 setpcred \ 2252 setproctitle \ 2253 setregid \ 2254 setreuid \ 2255 setrlimit \ 2256 setsid \ 2257 setvbuf \ 2258 sigaction \ 2259 sigvec \ 2260 snprintf \ 2261 socketpair \ 2262 statfs \ 2263 statvfs \ 2264 strcasestr \ 2265 strdup \ 2266 strerror \ 2267 strlcat \ 2268 strlcpy \ 2269 strmode \ 2270 strndup \ 2271 strnlen \ 2272 strnvis \ 2273 strptime \ 2274 strsignal \ 2275 strtonum \ 2276 strtoll \ 2277 strtoul \ 2278 strtoull \ 2279 sysconf \ 2280 tcgetpgrp \ 2281 timegm \ 2282 timingsafe_bcmp \ 2283 truncate \ 2284 unlinkat \ 2285 unsetenv \ 2286 unveil \ 2287 updwtmpx \ 2288 utimensat \ 2289 user_from_uid \ 2290 usleep \ 2291 vasprintf \ 2292 vsnprintf \ 2293 waitpid \ 2294 warn \ 2295]) 2296 2297AC_MSG_CHECKING([whether compiler supports __builtin_popcount]) 2298AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 2299 #include <stdlib.h> 2300 ]], 2301 [[ int x = 123, y; 2302 y = __builtin_popcount(123); 2303 exit(y == 6 ? 0 : -1); ]])], 2304 [ AC_MSG_RESULT([yes]) ], [ 2305 AC_MSG_RESULT([no]) 2306 AC_DEFINE([MISSING_BUILTIN_POPCOUNT], [1], [Define if your compiler lacks __builtin_popcount]) 2307 ] 2308) 2309 2310AC_CHECK_DECLS([bzero, memmem]) 2311 2312dnl Wide character support. 2313AC_CHECK_FUNCS([mblen mbtowc nl_langinfo wcwidth]) 2314 2315TEST_SSH_UTF8=${TEST_SSH_UTF8:=yes} 2316AC_MSG_CHECKING([for utf8 locale support]) 2317AC_RUN_IFELSE( 2318 [AC_LANG_PROGRAM([[ 2319#include <locale.h> 2320#include <stdlib.h> 2321 ]], [[ 2322 char *loc = setlocale(LC_CTYPE, "en_US.UTF-8"); 2323 if (loc != NULL) 2324 exit(0); 2325 exit(1); 2326 ]])], 2327 AC_MSG_RESULT(yes), 2328 [AC_MSG_RESULT(no) 2329 TEST_SSH_UTF8=no], 2330 AC_MSG_WARN([cross compiling: assuming yes]) 2331) 2332 2333AC_LINK_IFELSE( 2334 [AC_LANG_PROGRAM( 2335 [[ #include <ctype.h> ]], 2336 [[ return (isblank('a')); ]])], 2337 [AC_DEFINE([HAVE_ISBLANK], [1], [Define if you have isblank(3C).]) 2338]) 2339 2340disable_pkcs11= 2341AC_ARG_ENABLE([pkcs11], 2342 [ --disable-pkcs11 disable PKCS#11 support code [no]], 2343 [ 2344 if test "x$enableval" = "xno" ; then 2345 disable_pkcs11=1 2346 fi 2347 ] 2348) 2349 2350disable_sk= 2351AC_ARG_ENABLE([security-key], 2352 [ --disable-security-key disable U2F/FIDO support code [no]], 2353 [ 2354 if test "x$enableval" = "xno" ; then 2355 disable_sk=1 2356 fi 2357 ] 2358) 2359enable_sk_internal= 2360AC_ARG_WITH([security-key-builtin], 2361 [ --with-security-key-builtin include builtin U2F/FIDO support], 2362 [ enable_sk_internal=$withval ] 2363) 2364 2365enable_sk_standalone= 2366AC_ARG_WITH([security-key-standalone], 2367 [ --with-security-key-standalone build standalone sk-libfido2 SecurityKeyProvider], 2368 [ enable_sk_standalone=$withval ] 2369) 2370 2371AC_SEARCH_LIBS([dlopen], [dl]) 2372AC_CHECK_FUNCS([dlopen]) 2373AC_CHECK_DECL([RTLD_NOW], [], [], [#include <dlfcn.h>]) 2374 2375# IRIX has a const char return value for gai_strerror() 2376AC_CHECK_FUNCS([gai_strerror], [ 2377 AC_DEFINE([HAVE_GAI_STRERROR]) 2378 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 2379#include <sys/types.h> 2380#include <sys/socket.h> 2381#include <netdb.h> 2382 2383const char *gai_strerror(int); 2384 ]], [[ 2385 char *str; 2386 str = gai_strerror(0); 2387 ]])], [ 2388 AC_DEFINE([HAVE_CONST_GAI_STRERROR_PROTO], [1], 2389 [Define if gai_strerror() returns const char *])], [])]) 2390 2391AC_SEARCH_LIBS([nanosleep], [rt posix4], [AC_DEFINE([HAVE_NANOSLEEP], [1], 2392 [Some systems put nanosleep outside of libc])]) 2393 2394AC_SEARCH_LIBS([clock_gettime], [rt], 2395 [AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Have clock_gettime])]) 2396 2397dnl check if we need -D_REENTRANT for localtime_r declaration. 2398AC_CHECK_DECL([localtime_r], [], 2399 [ saved_CPPFLAGS="$CPPFLAGS" 2400 CPPFLAGS="$CPPFLAGS -D_REENTRANT" 2401 unset ac_cv_have_decl_localtime_r 2402 AC_CHECK_DECL([localtime_r], [], 2403 [ CPPFLAGS="$saved_CPPFLAGS" ], 2404 [ #include <time.h> ] 2405 ) 2406 ], 2407 [ #include <time.h> ] 2408) 2409 2410dnl Make sure prototypes are defined for these before using them. 2411AC_CHECK_DECL([strsep], 2412 [AC_CHECK_FUNCS([strsep])], 2413 [], 2414 [ 2415#ifdef HAVE_STRING_H 2416# include <string.h> 2417#endif 2418 ]) 2419 2420dnl tcsendbreak might be a macro 2421AC_CHECK_DECL([tcsendbreak], 2422 [AC_DEFINE([HAVE_TCSENDBREAK])], 2423 [AC_CHECK_FUNCS([tcsendbreak])], 2424 [#include <termios.h>] 2425) 2426 2427AC_CHECK_DECLS([h_errno], , ,[#include <netdb.h>]) 2428 2429AC_CHECK_DECLS([SHUT_RD, getpeereid], , , 2430 [ 2431#include <sys/types.h> 2432#include <sys/socket.h> 2433#include <unistd.h> 2434 ]) 2435 2436AC_CHECK_DECLS([O_NONBLOCK], , , 2437 [ 2438#include <sys/types.h> 2439#ifdef HAVE_SYS_STAT_H 2440# include <sys/stat.h> 2441#endif 2442#ifdef HAVE_FCNTL_H 2443# include <fcntl.h> 2444#endif 2445 ]) 2446 2447AC_CHECK_DECLS([ftruncate, getentropy], , , 2448 [ 2449#include <sys/types.h> 2450#include <unistd.h> 2451 ]) 2452 2453AC_CHECK_DECLS([readv, writev], , , [ 2454#include <sys/types.h> 2455#include <sys/uio.h> 2456#include <unistd.h> 2457 ]) 2458 2459AC_CHECK_DECLS([MAXSYMLINKS], , , [ 2460#include <sys/param.h> 2461 ]) 2462 2463AC_CHECK_DECLS([offsetof], , , [ 2464#include <stddef.h> 2465 ]) 2466 2467AC_CHECK_DECLS([INFINITY], , 2468 AC_CHECK_DECLS(__builtin_inff), 2469 [#include <math.h>] 2470) 2471 2472# extra bits for select(2) 2473AC_CHECK_DECLS([howmany, NFDBITS], [], [], [[ 2474#include <sys/param.h> 2475#include <sys/types.h> 2476#ifdef HAVE_SYS_SYSMACROS_H 2477#include <sys/sysmacros.h> 2478#endif 2479#ifdef HAVE_SYS_SELECT_H 2480#include <sys/select.h> 2481#endif 2482#ifdef HAVE_SYS_TIME_H 2483#include <sys/time.h> 2484#endif 2485#ifdef HAVE_UNISTD_H 2486#include <unistd.h> 2487#endif 2488 ]]) 2489AC_CHECK_TYPES([fd_mask], [], [], [[ 2490#include <sys/param.h> 2491#include <sys/types.h> 2492#ifdef HAVE_SYS_SELECT_H 2493#include <sys/select.h> 2494#endif 2495#ifdef HAVE_SYS_TIME_H 2496#include <sys/time.h> 2497#endif 2498#ifdef HAVE_UNISTD_H 2499#include <unistd.h> 2500#endif 2501 ]]) 2502 2503AC_CHECK_FUNCS([setresuid], [ 2504 dnl Some platorms have setresuid that isn't implemented, test for this 2505 AC_MSG_CHECKING([if setresuid seems to work]) 2506 AC_RUN_IFELSE( 2507 [AC_LANG_PROGRAM([[ 2508#include <errno.h> 2509#include <stdlib.h> 2510#include <unistd.h> 2511 ]], [[ 2512 errno=0; 2513 setresuid(0,0,0); 2514 if (errno==ENOSYS) 2515 exit(1); 2516 else 2517 exit(0); 2518 ]])], 2519 [AC_MSG_RESULT([yes])], 2520 [AC_DEFINE([BROKEN_SETRESUID], [1], 2521 [Define if your setresuid() is broken]) 2522 AC_MSG_RESULT([not implemented])], 2523 [AC_MSG_WARN([cross compiling: not checking setresuid])] 2524 ) 2525]) 2526 2527AC_CHECK_FUNCS([setresgid], [ 2528 dnl Some platorms have setresgid that isn't implemented, test for this 2529 AC_MSG_CHECKING([if setresgid seems to work]) 2530 AC_RUN_IFELSE( 2531 [AC_LANG_PROGRAM([[ 2532#include <errno.h> 2533#include <stdlib.h> 2534#include <unistd.h> 2535 ]], [[ 2536 errno=0; 2537 setresgid(0,0,0); 2538 if (errno==ENOSYS) 2539 exit(1); 2540 else 2541 exit(0); 2542 ]])], 2543 [AC_MSG_RESULT([yes])], 2544 [AC_DEFINE([BROKEN_SETRESGID], [1], 2545 [Define if your setresgid() is broken]) 2546 AC_MSG_RESULT([not implemented])], 2547 [AC_MSG_WARN([cross compiling: not checking setresuid])] 2548 ) 2549]) 2550 2551AC_MSG_CHECKING([for working fflush(NULL)]) 2552AC_RUN_IFELSE( 2553 [AC_LANG_PROGRAM([[ 2554#include <stdio.h> 2555#include <stdlib.h> 2556 ]], 2557 [[fflush(NULL); exit(0);]])], 2558 AC_MSG_RESULT([yes]), 2559 [AC_MSG_RESULT([no]) 2560 AC_DEFINE([FFLUSH_NULL_BUG], [1], 2561 [define if fflush(NULL) does not work])], 2562 AC_MSG_WARN([cross compiling: assuming working]) 2563) 2564 2565dnl Checks for time functions 2566AC_CHECK_FUNCS([gettimeofday time]) 2567dnl Checks for utmp functions 2568AC_CHECK_FUNCS([endutent getutent getutid getutline pututline setutent]) 2569AC_CHECK_FUNCS([utmpname]) 2570dnl Checks for utmpx functions 2571AC_CHECK_FUNCS([endutxent getutxent getutxid getutxline getutxuser pututxline]) 2572AC_CHECK_FUNCS([setutxdb setutxent utmpxname]) 2573dnl Checks for lastlog functions 2574AC_CHECK_FUNCS([getlastlogxbyname]) 2575 2576AC_CHECK_FUNC([daemon], 2577 [AC_DEFINE([HAVE_DAEMON], [1], [Define if your libraries define daemon()])], 2578 [AC_CHECK_LIB([bsd], [daemon], 2579 [LIBS="$LIBS -lbsd"; AC_DEFINE([HAVE_DAEMON])])] 2580) 2581 2582AC_CHECK_FUNC([getpagesize], 2583 [AC_DEFINE([HAVE_GETPAGESIZE], [1], 2584 [Define if your libraries define getpagesize()])], 2585 [AC_CHECK_LIB([ucb], [getpagesize], 2586 [LIBS="$LIBS -lucb"; AC_DEFINE([HAVE_GETPAGESIZE])])] 2587) 2588 2589# Check for broken snprintf 2590if test "x$ac_cv_func_snprintf" = "xyes" ; then 2591 AC_MSG_CHECKING([whether snprintf correctly terminates long strings]) 2592 AC_RUN_IFELSE( 2593 [AC_LANG_PROGRAM([[ 2594#include <stdio.h> 2595#include <stdlib.h> 2596 ]], 2597 [[ 2598 char b[5]; 2599 snprintf(b,5,"123456789"); 2600 exit(b[4]!='\0'); 2601 ]])], 2602 [AC_MSG_RESULT([yes])], 2603 [ 2604 AC_MSG_RESULT([no]) 2605 AC_DEFINE([BROKEN_SNPRINTF], [1], 2606 [Define if your snprintf is busted]) 2607 AC_MSG_WARN([****** Your snprintf() function is broken, complain to your vendor]) 2608 ], 2609 [ AC_MSG_WARN([cross compiling: Assuming working snprintf()]) ] 2610 ) 2611fi 2612 2613if test "x$ac_cv_func_snprintf" = "xyes" ; then 2614 AC_MSG_CHECKING([whether snprintf understands %zu]) 2615 AC_RUN_IFELSE( 2616 [AC_LANG_PROGRAM([[ 2617#include <sys/types.h> 2618#include <stdio.h> 2619#include <stdlib.h> 2620#include <string.h> 2621 ]], 2622 [[ 2623 size_t a = 1, b = 2; 2624 char z[128]; 2625 snprintf(z, sizeof z, "%zu%zu", a, b); 2626 exit(strcmp(z, "12")); 2627 ]])], 2628 [AC_MSG_RESULT([yes])], 2629 [ 2630 AC_MSG_RESULT([no]) 2631 AC_DEFINE([BROKEN_SNPRINTF], [1], 2632 [snprintf does not understand %zu]) 2633 ], 2634 [ AC_MSG_WARN([cross compiling: Assuming working snprintf()]) ] 2635 ) 2636fi 2637 2638# We depend on vsnprintf returning the right thing on overflow: the 2639# number of characters it tried to create (as per SUSv3) 2640if test "x$ac_cv_func_vsnprintf" = "xyes" ; then 2641 AC_MSG_CHECKING([whether vsnprintf returns correct values on overflow]) 2642 AC_RUN_IFELSE( 2643 [AC_LANG_PROGRAM([[ 2644#include <sys/types.h> 2645#include <stdio.h> 2646#include <stdarg.h> 2647 2648int x_snprintf(char *str, size_t count, const char *fmt, ...) 2649{ 2650 size_t ret; 2651 va_list ap; 2652 2653 va_start(ap, fmt); 2654 ret = vsnprintf(str, count, fmt, ap); 2655 va_end(ap); 2656 return ret; 2657} 2658 ]], [[ 2659char x[1]; 2660if (x_snprintf(x, 1, "%s %d", "hello", 12345) != 11) 2661 return 1; 2662if (x_snprintf(NULL, 0, "%s %d", "hello", 12345) != 11) 2663 return 1; 2664return 0; 2665 ]])], 2666 [AC_MSG_RESULT([yes])], 2667 [ 2668 AC_MSG_RESULT([no]) 2669 AC_DEFINE([BROKEN_SNPRINTF], [1], 2670 [Define if your snprintf is busted]) 2671 AC_MSG_WARN([****** Your vsnprintf() function is broken, complain to your vendor]) 2672 ], 2673 [ AC_MSG_WARN([cross compiling: Assuming working vsnprintf()]) ] 2674 ) 2675fi 2676 2677# On systems where [v]snprintf is broken, but is declared in stdio, 2678# check that the fmt argument is const char * or just char *. 2679# This is only useful for when BROKEN_SNPRINTF 2680AC_MSG_CHECKING([whether snprintf can declare const char *fmt]) 2681AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 2682#ifdef _FORTIFY_SOURCE 2683#undef _FORTIFY_SOURCE 2684#endif 2685#include <stdio.h> 2686int snprintf(char *a, size_t b, const char *c, ...) { return 0; } 2687 ]], [[ 2688 snprintf(0, 0, 0); 2689 ]])], 2690 [AC_MSG_RESULT([yes]) 2691 AC_DEFINE([SNPRINTF_CONST], [const], 2692 [Define as const if snprintf() can declare const char *fmt])], 2693 [AC_MSG_RESULT([no]) 2694 AC_DEFINE([SNPRINTF_CONST], [/* not const */])]) 2695 2696# Check for missing getpeereid (or equiv) support 2697NO_PEERCHECK="" 2698if test "x$ac_cv_func_getpeereid" != "xyes" -a "x$ac_cv_func_getpeerucred" != "xyes"; then 2699 AC_MSG_CHECKING([whether system supports SO_PEERCRED getsockopt]) 2700 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 2701#include <sys/types.h> 2702#include <sys/socket.h>]], [[int i = SO_PEERCRED;]])], 2703 [ AC_MSG_RESULT([yes]) 2704 AC_DEFINE([HAVE_SO_PEERCRED], [1], [Have PEERCRED socket option]) 2705 ], [AC_MSG_RESULT([no]) 2706 NO_PEERCHECK=1 2707 ]) 2708fi 2709 2710dnl make sure that openpty does not reacquire controlling terminal 2711if test ! -z "$check_for_openpty_ctty_bug"; then 2712 AC_MSG_CHECKING([if openpty correctly handles controlling tty]) 2713 AC_RUN_IFELSE( 2714 [AC_LANG_PROGRAM([[ 2715#include <stdio.h> 2716#include <stdlib.h> 2717#include <unistd.h> 2718#ifdef HAVE_PTY_H 2719# include <pty.h> 2720#endif 2721#include <sys/fcntl.h> 2722#include <sys/types.h> 2723#include <sys/wait.h> 2724 ]], [[ 2725 pid_t pid; 2726 int fd, ptyfd, ttyfd, status; 2727 2728 pid = fork(); 2729 if (pid < 0) { /* failed */ 2730 exit(1); 2731 } else if (pid > 0) { /* parent */ 2732 waitpid(pid, &status, 0); 2733 if (WIFEXITED(status)) 2734 exit(WEXITSTATUS(status)); 2735 else 2736 exit(2); 2737 } else { /* child */ 2738 close(0); close(1); close(2); 2739 setsid(); 2740 openpty(&ptyfd, &ttyfd, NULL, NULL, NULL); 2741 fd = open("/dev/tty", O_RDWR | O_NOCTTY); 2742 if (fd >= 0) 2743 exit(3); /* Acquired ctty: broken */ 2744 else 2745 exit(0); /* Did not acquire ctty: OK */ 2746 } 2747 ]])], 2748 [ 2749 AC_MSG_RESULT([yes]) 2750 ], 2751 [ 2752 AC_MSG_RESULT([no]) 2753 AC_DEFINE([SSHD_ACQUIRES_CTTY]) 2754 ], 2755 [ 2756 AC_MSG_RESULT([cross-compiling, assuming yes]) 2757 ] 2758 ) 2759fi 2760 2761if test "x$ac_cv_func_getaddrinfo" = "xyes" && \ 2762 test "x$check_for_hpux_broken_getaddrinfo" = "x1"; then 2763 AC_MSG_CHECKING([if getaddrinfo seems to work]) 2764 AC_RUN_IFELSE( 2765 [AC_LANG_PROGRAM([[ 2766#include <stdio.h> 2767#include <stdlib.h> 2768#include <sys/socket.h> 2769#include <netdb.h> 2770#include <errno.h> 2771#include <netinet/in.h> 2772 2773#define TEST_PORT "2222" 2774 ]], [[ 2775 int err, sock; 2776 struct addrinfo *gai_ai, *ai, hints; 2777 char ntop[NI_MAXHOST], strport[NI_MAXSERV], *name = NULL; 2778 2779 memset(&hints, 0, sizeof(hints)); 2780 hints.ai_family = PF_UNSPEC; 2781 hints.ai_socktype = SOCK_STREAM; 2782 hints.ai_flags = AI_PASSIVE; 2783 2784 err = getaddrinfo(name, TEST_PORT, &hints, &gai_ai); 2785 if (err != 0) { 2786 fprintf(stderr, "getaddrinfo failed (%s)", gai_strerror(err)); 2787 exit(1); 2788 } 2789 2790 for (ai = gai_ai; ai != NULL; ai = ai->ai_next) { 2791 if (ai->ai_family != AF_INET6) 2792 continue; 2793 2794 err = getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop, 2795 sizeof(ntop), strport, sizeof(strport), 2796 NI_NUMERICHOST|NI_NUMERICSERV); 2797 2798 if (err != 0) { 2799 if (err == EAI_SYSTEM) 2800 perror("getnameinfo EAI_SYSTEM"); 2801 else 2802 fprintf(stderr, "getnameinfo failed: %s\n", 2803 gai_strerror(err)); 2804 exit(2); 2805 } 2806 2807 sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); 2808 if (sock < 0) 2809 perror("socket"); 2810 if (bind(sock, ai->ai_addr, ai->ai_addrlen) < 0) { 2811 if (errno == EBADF) 2812 exit(3); 2813 } 2814 } 2815 exit(0); 2816 ]])], 2817 [ 2818 AC_MSG_RESULT([yes]) 2819 ], 2820 [ 2821 AC_MSG_RESULT([no]) 2822 AC_DEFINE([BROKEN_GETADDRINFO]) 2823 ], 2824 [ 2825 AC_MSG_RESULT([cross-compiling, assuming yes]) 2826 ] 2827 ) 2828fi 2829 2830if test "x$ac_cv_func_getaddrinfo" = "xyes" && \ 2831 test "x$check_for_aix_broken_getaddrinfo" = "x1"; then 2832 AC_MSG_CHECKING([if getaddrinfo seems to work]) 2833 AC_RUN_IFELSE( 2834 [AC_LANG_PROGRAM([[ 2835#include <stdio.h> 2836#include <stdlib.h> 2837#include <sys/socket.h> 2838#include <netdb.h> 2839#include <errno.h> 2840#include <netinet/in.h> 2841 2842#define TEST_PORT "2222" 2843 ]], [[ 2844 int err, sock; 2845 struct addrinfo *gai_ai, *ai, hints; 2846 char ntop[NI_MAXHOST], strport[NI_MAXSERV], *name = NULL; 2847 2848 memset(&hints, 0, sizeof(hints)); 2849 hints.ai_family = PF_UNSPEC; 2850 hints.ai_socktype = SOCK_STREAM; 2851 hints.ai_flags = AI_PASSIVE; 2852 2853 err = getaddrinfo(name, TEST_PORT, &hints, &gai_ai); 2854 if (err != 0) { 2855 fprintf(stderr, "getaddrinfo failed (%s)", gai_strerror(err)); 2856 exit(1); 2857 } 2858 2859 for (ai = gai_ai; ai != NULL; ai = ai->ai_next) { 2860 if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6) 2861 continue; 2862 2863 err = getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop, 2864 sizeof(ntop), strport, sizeof(strport), 2865 NI_NUMERICHOST|NI_NUMERICSERV); 2866 2867 if (ai->ai_family == AF_INET && err != 0) { 2868 perror("getnameinfo"); 2869 exit(2); 2870 } 2871 } 2872 exit(0); 2873 ]])], 2874 [ 2875 AC_MSG_RESULT([yes]) 2876 AC_DEFINE([AIX_GETNAMEINFO_HACK], [1], 2877 [Define if you have a getaddrinfo that fails 2878 for the all-zeros IPv6 address]) 2879 ], 2880 [ 2881 AC_MSG_RESULT([no]) 2882 AC_DEFINE([BROKEN_GETADDRINFO]) 2883 ], 2884 [ 2885 AC_MSG_RESULT([cross-compiling, assuming no]) 2886 ] 2887 ) 2888fi 2889 2890if test "x$ac_cv_func_getaddrinfo" = "xyes"; then 2891 AC_CHECK_DECLS(AI_NUMERICSERV, , , 2892 [#include <sys/types.h> 2893 #include <sys/socket.h> 2894 #include <netdb.h>]) 2895fi 2896 2897if test "x$check_for_conflicting_getspnam" = "x1"; then 2898 AC_MSG_CHECKING([for conflicting getspnam in shadow.h]) 2899 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 2900#include <shadow.h> 2901#include <stdlib.h> 2902 ]], 2903 [[ exit(0); ]])], 2904 [ 2905 AC_MSG_RESULT([no]) 2906 ], 2907 [ 2908 AC_MSG_RESULT([yes]) 2909 AC_DEFINE([GETSPNAM_CONFLICTING_DEFS], [1], 2910 [Conflicting defs for getspnam]) 2911 ] 2912 ) 2913fi 2914 2915dnl NetBSD added an strnvis and unfortunately made it incompatible with the 2916dnl existing one in OpenBSD and Linux's libbsd (the former having existed 2917dnl for over ten years). Despite this incompatibility being reported during 2918dnl development (see http://gnats.netbsd.org/44977) they still shipped it. 2919dnl Even more unfortunately FreeBSD and later MacOS picked up this incompatible 2920dnl implementation. Try to detect this mess, and assume the only safe option 2921dnl if we're cross compiling. 2922dnl 2923dnl OpenBSD, 2001: strnvis(char *dst, const char *src, size_t dlen, int flag); 2924dnl NetBSD: 2012, strnvis(char *dst, size_t dlen, const char *src, int flag); 2925if test "x$ac_cv_func_strnvis" = "xyes"; then 2926 AC_MSG_CHECKING([for working strnvis]) 2927 AC_RUN_IFELSE( 2928 [AC_LANG_PROGRAM([[ 2929#include <signal.h> 2930#include <stdlib.h> 2931#include <string.h> 2932#include <unistd.h> 2933#include <vis.h> 2934static void sighandler(int sig) { _exit(1); } 2935 ]], [[ 2936 char dst[16]; 2937 2938 signal(SIGSEGV, sighandler); 2939 if (strnvis(dst, "src", 4, 0) && strcmp(dst, "src") == 0) 2940 exit(0); 2941 exit(1) 2942 ]])], 2943 [AC_MSG_RESULT([yes])], 2944 [AC_MSG_RESULT([no]) 2945 AC_DEFINE([BROKEN_STRNVIS], [1], [strnvis detected broken])], 2946 [AC_MSG_WARN([cross compiling: assuming broken]) 2947 AC_DEFINE([BROKEN_STRNVIS], [1], [strnvis assumed broken])] 2948 ) 2949fi 2950 2951AC_MSG_CHECKING([if SA_RESTARTed signals interrupt select()]) 2952AC_RUN_IFELSE( 2953 [AC_LANG_PROGRAM([[ 2954#ifdef HAVE_SYS_SELECT 2955# include <sys/select.h> 2956#endif 2957#include <sys/types.h> 2958#include <sys/time.h> 2959#include <stdlib.h> 2960#include <signal.h> 2961#include <unistd.h> 2962static void sighandler(int sig) { } 2963 ]], [[ 2964 int r; 2965 pid_t pid; 2966 struct sigaction sa; 2967 2968 sa.sa_handler = sighandler; 2969 sa.sa_flags = SA_RESTART; 2970 (void)sigaction(SIGTERM, &sa, NULL); 2971 if ((pid = fork()) == 0) { /* child */ 2972 pid = getppid(); 2973 sleep(1); 2974 kill(pid, SIGTERM); 2975 sleep(1); 2976 if (getppid() == pid) /* if parent did not exit, shoot it */ 2977 kill(pid, SIGKILL); 2978 exit(0); 2979 } else { /* parent */ 2980 r = select(0, NULL, NULL, NULL, NULL); 2981 } 2982 exit(r == -1 ? 0 : 1); 2983 ]])], 2984 [AC_MSG_RESULT([yes])], 2985 [AC_MSG_RESULT([no]) 2986 AC_DEFINE([NO_SA_RESTART], [1], 2987 [SA_RESTARTed signals do no interrupt select])], 2988 [AC_MSG_WARN([cross compiling: assuming yes])] 2989) 2990 2991AC_CHECK_FUNCS([getpgrp],[ 2992 AC_MSG_CHECKING([if getpgrp accepts zero args]) 2993 AC_COMPILE_IFELSE( 2994 [AC_LANG_PROGRAM([[$ac_includes_default]], [[ getpgrp(); ]])], 2995 [ AC_MSG_RESULT([yes]) 2996 AC_DEFINE([GETPGRP_VOID], [1], [getpgrp takes zero args])], 2997 [ AC_MSG_RESULT([no]) 2998 AC_DEFINE([GETPGRP_VOID], [0], [getpgrp takes one arg])] 2999 ) 3000]) 3001 3002# Search for OpenSSL 3003saved_CPPFLAGS="$CPPFLAGS" 3004saved_LDFLAGS="$LDFLAGS" 3005openssl_bin_PATH="$PATH" 3006AC_ARG_WITH([ssl-dir], 3007 [ --with-ssl-dir=PATH Specify path to OpenSSL installation ], 3008 [ 3009 if test "x$openssl" = "xno" ; then 3010 AC_MSG_ERROR([cannot use --with-ssl-dir when OpenSSL disabled]) 3011 fi 3012 if test "x$withval" != "xno" ; then 3013 case "$withval" in 3014 # Relative paths 3015 ./*|../*) withval="`pwd`/$withval" 3016 esac 3017 if test -d "$withval/lib"; then 3018 libcrypto_path="${withval}/lib" 3019 elif test -d "$withval/lib64"; then 3020 libcrypto_path="$withval/lib64" 3021 else 3022 # Built but not installed 3023 libcrypto_path="${withval}" 3024 fi 3025 if test -n "${rpath_opt}"; then 3026 LDFLAGS="-L${libcrypto_path} ${rpath_opt}${libcrypto_path} ${LDFLAGS}" 3027 else 3028 LDFLAGS="-L${libcrypto_path} ${LDFLAGS}" 3029 fi 3030 if test -d "$withval/include"; then 3031 CPPFLAGS="-I${withval}/include ${CPPFLAGS}" 3032 else 3033 CPPFLAGS="-I${withval} ${CPPFLAGS}" 3034 fi 3035 dnl Ensure specified openssl binary works, eg it can 3036 dnl find its runtime libraries, before trying to use. 3037 if test -x "${withval}/bin/openssl" && \ 3038 "${withval}/bin/openssl" version >/dev/null 2>&1; then 3039 openssl_bin_PATH="${withval}/bin${PATH_SEPARATOR}${PATH}" 3040 elif test -x "${withval}/apps/openssl" && \ 3041 "${withval}/apps/openssl" version >/dev/null 2>&1; then 3042 openssl_bin_PATH="${withval}/apps${PATH_SEPARATOR}${PATH}" 3043 fi 3044 fi 3045 ] 3046) 3047AC_PATH_PROGS([openssl_bin], openssl, [], [$openssl_bin_PATH]) 3048AC_SUBST(OPENSSL_BIN, [${openssl_bin}]) 3049 3050AC_ARG_WITH([openssl-header-check], 3051 [ --without-openssl-header-check Disable OpenSSL version consistency check], 3052 [ 3053 if test "x$withval" = "xno" ; then 3054 openssl_check_nonfatal=1 3055 fi 3056 ] 3057) 3058 3059openssl_engine=no 3060AC_ARG_WITH([ssl-engine], 3061 [ --with-ssl-engine Enable OpenSSL (hardware) ENGINE support ], 3062 [ 3063 if test "x$withval" != "xno" ; then 3064 if test "x$openssl" = "xno" ; then 3065 AC_MSG_ERROR([cannot use --with-ssl-engine when OpenSSL disabled]) 3066 fi 3067 openssl_engine=yes 3068 fi 3069 ] 3070) 3071 3072nocrypto_saved_LIBS="$LIBS" 3073if test "x$openssl" = "xyes" ; then 3074 LIBS="-lcrypto $LIBS" 3075 CHANNELLIBS="-lcrypto $CHANNELLIBS" 3076 AC_TRY_LINK_FUNC([RAND_add], , [ 3077 # As of early 2026, BoringSSL libcrypto needs -lstdc++ for 3078 # destructors so try that before giving up. 3079 LIBS="$LIBS -lstdc++" 3080 CHANNELLIBS="$CHANNELLIBS -lstdc++" 3081 AC_TRY_LINK_FUNC([RAND_add], , [ 3082 AC_MSG_ERROR([*** working libcrypto not found, check config.log]) 3083 ]) 3084 ]) 3085 AC_CHECK_HEADER([openssl/opensslv.h], , 3086 [AC_MSG_ERROR([*** OpenSSL headers missing - please install first or check config.log ***])]) 3087 3088 # Determine OpenSSL header version 3089 AC_MSG_CHECKING([OpenSSL header version]) 3090 AC_RUN_IFELSE( 3091 [AC_LANG_PROGRAM([[ 3092 #include <stdlib.h> 3093 #include <stdio.h> 3094 #include <string.h> 3095 #include <openssl/opensslv.h> 3096 #define DATA "conftest.sslincver" 3097 ]], [[ 3098 FILE *fd; 3099 int rc; 3100 3101 fd = fopen(DATA,"w"); 3102 if(fd == NULL) 3103 exit(1); 3104 3105 if ((rc = fprintf(fd, "%08lx (%s)\n", 3106 (unsigned long)OPENSSL_VERSION_NUMBER, 3107 OPENSSL_VERSION_TEXT)) < 0) 3108 exit(1); 3109 3110 exit(0); 3111 ]])], 3112 [ 3113 ssl_header_ver=`cat conftest.sslincver` 3114 AC_MSG_RESULT([$ssl_header_ver]) 3115 ], 3116 [ 3117 AC_MSG_RESULT([failed]) 3118 AC_MSG_ERROR([OpenSSL version test program failed.]) 3119 ], 3120 [ 3121 AC_MSG_WARN([cross compiling: not checking]) 3122 ] 3123 ) 3124 3125 # Determining OpenSSL library version is version dependent. 3126 AC_CHECK_FUNCS([OpenSSL_version OpenSSL_version_num]) 3127 3128 # Determine OpenSSL library version 3129 AC_MSG_CHECKING([OpenSSL library version]) 3130 AC_RUN_IFELSE( 3131 [AC_LANG_PROGRAM([[ 3132 #include <stdio.h> 3133 #include <stdlib.h> 3134 #include <string.h> 3135 #include <openssl/opensslv.h> 3136 #include <openssl/crypto.h> 3137 #define DATA "conftest.ssllibver" 3138 ]], [[ 3139 FILE *f; 3140 /* We need these legacy bits to warn for old libcrypto */ 3141 #ifndef OPENSSL_VERSION 3142 # define OPENSSL_VERSION SSLEAY_VERSION 3143 #endif 3144 #ifndef HAVE_OPENSSL_VERSION 3145 # define OpenSSL_version SSLeay_version 3146 #endif 3147 #ifndef HAVE_OPENSSL_VERSION_NUM 3148 # define OpenSSL_version_num SSLeay 3149 #endif 3150 if ((f = fopen(DATA, "w")) == NULL) 3151 exit(1); 3152 if (fprintf(f, "%08lx (%s)", 3153 (unsigned long)OpenSSL_version_num(), 3154 OpenSSL_version(OPENSSL_VERSION)) < 0) 3155 exit(1); 3156#ifdef LIBRESSL_VERSION_NUMBER 3157 if (fprintf(f, " libressl-%08lx", LIBRESSL_VERSION_NUMBER) < 0) 3158 exit(1); 3159#endif 3160 if (fputc('\n', f) == EOF || fclose(f) == EOF) 3161 exit(1); 3162 exit(0); 3163 ]])], 3164 [ 3165 sslver=`cat conftest.ssllibver` 3166 ssl_showver=`echo "$sslver" | sed 's/ libressl-.*//'` 3167 # Check version is supported. 3168 case "$sslver" in 3169 100*|10100*) # 1.0.x, 1.1.0x 3170 AC_MSG_ERROR([OpenSSL >= 1.1.1 required (have "$ssl_showver")]) 3171 ;; 3172 101*) ;; # 1.1.x 3173 200*) # LibreSSL 3174 lver=`echo "$sslver" | sed 's/.*libressl-//'` 3175 case "$lver" in 3176 2*|300*) # 2.x, 3.0.0 3177 AC_MSG_ERROR([LibreSSL >= 3.1.0 required (have "$ssl_showver")]) 3178 ;; 3179 *) ;; # Assume all other versions are good. 3180 esac 3181 ;; 3182 30*|40*) 3183 # OpenSSL 3 & 4; we use the 1.1x API 3184 # https://openssl.org/policies/general/versioning-policy.html 3185 CPPFLAGS="$CPPFLAGS -DOPENSSL_API_COMPAT=0x10100000L" 3186 ;; 3187 *) 3188 AC_MSG_ERROR([Unknown/unsupported OpenSSL version ("$ssl_showver")]) 3189 ;; 3190 esac 3191 AC_MSG_RESULT([$ssl_showver]) 3192 ], 3193 [ 3194 AC_MSG_RESULT([not found]) 3195 AC_MSG_ERROR([OpenSSL library not found.]) 3196 ], 3197 [ 3198 AC_MSG_WARN([cross compiling: not checking]) 3199 ] 3200 ) 3201 3202 case "$host" in 3203 x86_64-*) 3204 case "$sslver" in 3205 3000004*) 3206 AC_MSG_ERROR([OpenSSL 3.0.4 has a potential RCE in its RSA implementation (CVE-2022-2274)]) 3207 ;; 3208 esac 3209 esac 3210 3211 # Sanity check OpenSSL headers 3212 AC_MSG_CHECKING([whether OpenSSL's headers match the library]) 3213 AC_RUN_IFELSE( 3214 [AC_LANG_PROGRAM([[ 3215 #include <stdlib.h> 3216 #include <string.h> 3217 #include <openssl/opensslv.h> 3218 #include <openssl/crypto.h> 3219 ]], [[ 3220 exit(OpenSSL_version_num() == OPENSSL_VERSION_NUMBER ? 0 : 1); 3221 ]])], 3222 [ 3223 AC_MSG_RESULT([yes]) 3224 ], 3225 [ 3226 AC_MSG_RESULT([no]) 3227 if test "x$openssl_check_nonfatal" = "x"; then 3228 AC_MSG_ERROR([Your OpenSSL headers do not match your 3229 library. Check config.log for details. 3230 If you are sure your installation is consistent, you can disable the check 3231 by running "./configure --without-openssl-header-check". 3232 Also see contrib/findssl.sh for help identifying header/library mismatches. 3233 ]) 3234 else 3235 AC_MSG_WARN([Your OpenSSL headers do not match your 3236 library. Check config.log for details. 3237 Also see contrib/findssl.sh for help identifying header/library mismatches.]) 3238 fi 3239 ], 3240 [ 3241 AC_MSG_WARN([cross compiling: not checking]) 3242 ] 3243 ) 3244 3245 AC_MSG_CHECKING([if programs using OpenSSL functions will link]) 3246 AC_LINK_IFELSE( 3247 [AC_LANG_PROGRAM([[ #include <openssl/err.h> ]], 3248 [[ OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL); ]])], 3249 [ 3250 AC_MSG_RESULT([yes]) 3251 ], 3252 [ 3253 AC_MSG_RESULT([no]) 3254 LIBS="$LIBS -ldl" 3255 AC_MSG_CHECKING([if programs using OpenSSL need -ldl]) 3256 AC_LINK_IFELSE( 3257 [AC_LANG_PROGRAM([[ #include <openssl/err.h> ]], 3258 [[ OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL); ]])], 3259 [ 3260 AC_MSG_RESULT([yes]) 3261 CHANNELLIBS="$CHANNELLIBS -ldl" 3262 ], 3263 [ 3264 AC_MSG_RESULT([no]) 3265 ] 3266 ) 3267 ] 3268 ) 3269 3270 AC_CHECK_FUNCS([ \ 3271 BN_is_prime_ex \ 3272 DES_crypt \ 3273 EVP_DigestSign \ 3274 EVP_DigestVerify \ 3275 EVP_DigestFinal_ex \ 3276 EVP_DigestInit_ex \ 3277 EVP_MD_CTX_cleanup \ 3278 EVP_MD_CTX_copy_ex \ 3279 EVP_MD_CTX_init \ 3280 HMAC_CTX_init \ 3281 RSA_generate_key_ex \ 3282 RSA_get_default_method \ 3283 ]) 3284 3285 # LibreSSL/OpenSSL API differences 3286 AC_CHECK_FUNCS([ \ 3287 EC_POINT_get_affine_coordinates \ 3288 EC_POINT_get_affine_coordinates_GFp \ 3289 EC_POINT_set_affine_coordinates \ 3290 EC_POINT_set_affine_coordinates_GFp \ 3291 EVP_CIPHER_CTX_iv \ 3292 EVP_CIPHER_CTX_iv_noconst \ 3293 EVP_CIPHER_CTX_get_iv \ 3294 EVP_CIPHER_CTX_get_updated_iv \ 3295 EVP_CIPHER_CTX_set_iv \ 3296 ]) 3297 3298 if test "x$openssl_engine" = "xyes" ; then 3299 AC_CHECK_HEADERS([openssl/opensslconf.h openssl/configuration.h]) 3300 AC_MSG_CHECKING([for OpenSSL ENGINE support]) 3301 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 3302 #ifdef HAVE_OPENSSL_OPENSSLCONF_H 3303 # include <openssl/opensslconf.h> 3304 #endif 3305 #ifdef HAVE_OPENSSL_CONFIGURATION_H 3306 # include <openssl/configuration.h> 3307 #endif 3308 #include <openssl/engine.h> 3309 ]], [[ 3310 #ifndef OPENSSL_NO_ENGINE 3311 ENGINE_load_builtin_engines(); 3312 ENGINE_register_all_complete(); 3313 #else 3314 #error "OPENSSL_NO_ENGINE" 3315 #endif 3316 ]])], 3317 [ AC_MSG_RESULT([yes]) 3318 AC_DEFINE([USE_OPENSSL_ENGINE], [1], 3319 [Enable OpenSSL engine support]) 3320 ], [ AC_MSG_ERROR([OpenSSL ENGINE support not found]) 3321 ]) 3322 fi 3323 3324 AC_MSG_CHECKING([if EVP_DigestUpdate returns an int]) 3325 AC_LINK_IFELSE( 3326 [AC_LANG_PROGRAM([[ 3327 #include <stdlib.h> 3328 #include <string.h> 3329 #include <openssl/evp.h> 3330 ]], [[ 3331 if(EVP_DigestUpdate(NULL, NULL,0)) 3332 exit(0); 3333 ]])], 3334 [ 3335 AC_MSG_RESULT([yes]) 3336 ], 3337 [ 3338 AC_MSG_RESULT([no]) 3339 AC_DEFINE([OPENSSL_EVP_DIGESTUPDATE_VOID], [1], 3340 [Define if EVP_DigestUpdate returns void]) 3341 ] 3342 ) 3343 3344 # Check for various EVP support in OpenSSL 3345 AC_CHECK_FUNCS([EVP_sha256 EVP_sha384 EVP_sha512 EVP_chacha20]) 3346 3347 # Check complete ECC support in OpenSSL 3348 AC_MSG_CHECKING([whether OpenSSL has NID_X9_62_prime256v1]) 3349 AC_LINK_IFELSE( 3350 [AC_LANG_PROGRAM([[ 3351 #include <openssl/ec.h> 3352 #include <openssl/ecdh.h> 3353 #include <openssl/ecdsa.h> 3354 #include <openssl/evp.h> 3355 #include <openssl/objects.h> 3356 #include <openssl/opensslv.h> 3357 ]], [[ 3358 EC_KEY *e = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1); 3359 const EVP_MD *m = EVP_sha256(); /* We need this too */ 3360 ]])], 3361 [ AC_MSG_RESULT([yes]) 3362 enable_nistp256=1 ], 3363 [ AC_MSG_RESULT([no]) ] 3364 ) 3365 3366 AC_MSG_CHECKING([whether OpenSSL has NID_secp384r1]) 3367 AC_LINK_IFELSE( 3368 [AC_LANG_PROGRAM([[ 3369 #include <openssl/ec.h> 3370 #include <openssl/ecdh.h> 3371 #include <openssl/ecdsa.h> 3372 #include <openssl/evp.h> 3373 #include <openssl/objects.h> 3374 #include <openssl/opensslv.h> 3375 ]], [[ 3376 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp384r1); 3377 const EVP_MD *m = EVP_sha384(); /* We need this too */ 3378 ]])], 3379 [ AC_MSG_RESULT([yes]) 3380 enable_nistp384=1 ], 3381 [ AC_MSG_RESULT([no]) ] 3382 ) 3383 3384 AC_MSG_CHECKING([whether OpenSSL has NID_secp521r1]) 3385 AC_LINK_IFELSE( 3386 [AC_LANG_PROGRAM([[ 3387 #include <openssl/ec.h> 3388 #include <openssl/ecdh.h> 3389 #include <openssl/ecdsa.h> 3390 #include <openssl/evp.h> 3391 #include <openssl/objects.h> 3392 #include <openssl/opensslv.h> 3393 ]], [[ 3394 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1); 3395 const EVP_MD *m = EVP_sha512(); /* We need this too */ 3396 ]])], 3397 [ AC_MSG_RESULT([yes]) 3398 AC_MSG_CHECKING([if OpenSSL's NID_secp521r1 is functional]) 3399 AC_RUN_IFELSE( 3400 [AC_LANG_PROGRAM([[ 3401 #include <stdlib.h> 3402 #include <openssl/ec.h> 3403 #include <openssl/ecdh.h> 3404 #include <openssl/ecdsa.h> 3405 #include <openssl/evp.h> 3406 #include <openssl/objects.h> 3407 #include <openssl/opensslv.h> 3408 ]],[[ 3409 EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1); 3410 const EVP_MD *m = EVP_sha512(); /* We need this too */ 3411 exit(e == NULL || m == NULL); 3412 ]])], 3413 [ AC_MSG_RESULT([yes]) 3414 enable_nistp521=1 ], 3415 [ AC_MSG_RESULT([no]) ], 3416 [ AC_MSG_WARN([cross-compiling: assuming yes]) 3417 enable_nistp521=1 ] 3418 )], 3419 AC_MSG_RESULT([no]) 3420 ) 3421 3422 if test x$enable_nistp256 = x1 || test x$enable_nistp384 = x1 || \ 3423 test x$enable_nistp521 = x1; then 3424 AC_DEFINE(OPENSSL_HAS_ECC, [1], [OpenSSL has ECC]) 3425 AC_CHECK_FUNCS([EC_KEY_METHOD_new]) 3426 openssl_ecc=yes 3427 else 3428 openssl_ecc=no 3429 fi 3430 if test x$enable_nistp256 = x1; then 3431 AC_DEFINE([OPENSSL_HAS_NISTP256], [1], 3432 [libcrypto has NID_X9_62_prime256v1]) 3433 else 3434 unsupported_algorithms="$unsupported_algorithms \ 3435 ecdsa-sha2-nistp256 \ 3436 ecdh-sha2-nistp256 \ 3437 ecdsa-sha2-nistp256-cert-v01@openssh.com" 3438 fi 3439 if test x$enable_nistp384 = x1; then 3440 AC_DEFINE([OPENSSL_HAS_NISTP384], [1], [libcrypto has NID_secp384r1]) 3441 else 3442 unsupported_algorithms="$unsupported_algorithms \ 3443 ecdsa-sha2-nistp384 \ 3444 ecdh-sha2-nistp384 \ 3445 ecdsa-sha2-nistp384-cert-v01@openssh.com" 3446 fi 3447 if test x$enable_nistp521 = x1; then 3448 AC_DEFINE([OPENSSL_HAS_NISTP521], [1], [libcrypto has NID_secp521r1]) 3449 else 3450 unsupported_algorithms="$unsupported_algorithms \ 3451 ecdh-sha2-nistp521 \ 3452 ecdsa-sha2-nistp521 \ 3453 ecdsa-sha2-nistp521-cert-v01@openssh.com" 3454 fi 3455 3456 # Check libcrypto ED25519 support 3457 AC_CHECK_FUNCS([EVP_PKEY_get_raw_public_key]) 3458 AC_CHECK_FUNCS([EVP_PKEY_get_raw_private_key]) 3459 AC_MSG_CHECKING([whether OpenSSL has ED25519 support]) 3460 AC_LINK_IFELSE( 3461 [AC_LANG_PROGRAM([[ 3462 #include <string.h> 3463 #include <openssl/evp.h> 3464 #include <openssl/opensslconf.h> 3465 #ifdef OPENSSL_NO_EC 3466 # error "OpenSSL has no EC support." 3467 #endif 3468 ]], [[ 3469 unsigned char buf[64]; 3470 memset(buf, 0, sizeof(buf)); 3471 exit(EVP_PKEY_new_raw_private_key(EVP_PKEY_ED25519, NULL, 3472 buf, sizeof(buf)) == NULL); 3473 ]])], 3474 [ 3475 AC_MSG_RESULT([yes]) 3476 AC_DEFINE([OPENSSL_HAS_ED25519], [1], 3477 [libcrypto has ed25519 support]) 3478 ], 3479 [ 3480 AC_MSG_RESULT([no]) 3481 ] 3482 ) 3483fi 3484 3485# PKCS11/U2F depend on OpenSSL and dlopen(). 3486enable_pkcs11=yes 3487enable_sk=yes 3488 3489AC_CHECK_DECL([OPENSSL_IS_AWSLC], 3490 [enable_pkcs11="disabled; PKCS#11 not supported with AWS-LC"], 3491 [], 3492 [#include <openssl/base.h>] 3493) 3494if test "x$ac_cv_func_dlopen" != "xyes" ; then 3495 enable_pkcs11="disabled; missing dlopen(3)" 3496 enable_sk="disabled; missing dlopen(3)" 3497fi 3498if test "x$ac_cv_have_decl_RTLD_NOW" != "xyes" ; then 3499 enable_pkcs11="disabled; missing RTLD_NOW" 3500 enable_sk="disabled; missing RTLD_NOW" 3501fi 3502if test ! -z "$disable_pkcs11" ; then 3503 enable_pkcs11="disabled by user" 3504fi 3505if test ! -z "$disable_sk" ; then 3506 enable_sk="disabled by user" 3507fi 3508 3509AC_MSG_CHECKING([whether to enable PKCS11]) 3510if test "x$enable_pkcs11" = "xyes" ; then 3511 AC_DEFINE([ENABLE_PKCS11], [], [Enable for PKCS#11 support]) 3512fi 3513AC_MSG_RESULT([$enable_pkcs11]) 3514 3515AC_MSG_CHECKING([whether to enable U2F]) 3516if test "x$enable_sk" = "xyes" ; then 3517 AC_DEFINE([ENABLE_SK], [], [Enable for U2F/FIDO support]) 3518 AC_SUBST(SK_DUMMY_LIBRARY, [regress/misc/sk-dummy/sk-dummy.so]) 3519else 3520 # Do not try to build sk-dummy library. 3521 AC_SUBST(SK_DUMMY_LIBRARY, [""]) 3522fi 3523AC_MSG_RESULT([$enable_sk]) 3524 3525# Now check for built-in security key support. 3526if test "x$enable_sk" = "xyes" -a "x$enable_sk_internal" != "xno" ; then 3527 use_pkgconfig_for_libfido2= 3528 if test "x$PKGCONFIG" != "xno"; then 3529 AC_MSG_CHECKING([if $PKGCONFIG knows about libfido2]) 3530 if "$PKGCONFIG" libfido2; then 3531 AC_MSG_RESULT([yes]) 3532 use_pkgconfig_for_libfido2=yes 3533 else 3534 AC_MSG_RESULT([no]) 3535 fi 3536 fi 3537 if test "x$use_pkgconfig_for_libfido2" = "xyes"; then 3538 LIBFIDO2=`$PKGCONFIG --libs libfido2` 3539 CPPFLAGS="$CPPFLAGS `$PKGCONFIG --cflags libfido2`" 3540 else 3541 LIBFIDO2="-lprivatefido2 -lprivatecbor" 3542 fi 3543 OTHERLIBS=`echo $LIBFIDO2 | sed 's/-lfido2//'` 3544 fido2_error= 3545 AC_CHECK_LIB([privatefido2], [fido_init], 3546 [ ], 3547 [ fido2_error="missing/unusable libfido2" ], 3548 [ $OTHERLIBS ] 3549 ) 3550 AC_CHECK_HEADER([fido.h], [], 3551 [ fido2_error="missing fido.h from libfido2" ]) 3552 AC_CHECK_HEADER([fido/credman.h], [], 3553 [ fido2_error="missing fido/credman.h from libfido2" ], 3554 [ #include <fido.h> ] 3555 ) 3556 AC_MSG_CHECKING([for usable libfido2 installation]) 3557 if test ! -z "$fido2_error" ; then 3558 AC_MSG_RESULT([$fido2_error]) 3559 if test "x$enable_sk_internal" = "xyes" ; then 3560 AC_MSG_ERROR([No usable libfido2 library/headers found]) 3561 fi 3562 LIBFIDO2="" 3563 else 3564 AC_MSG_RESULT([yes]) 3565 AC_SUBST([LIBFIDO2]) 3566 AC_DEFINE([ENABLE_SK_INTERNAL], [], 3567 [Enable for built-in U2F/FIDO support]) 3568 enable_sk="built-in" 3569 saved_LIBS="$LIBS" 3570 LIBS="$LIBFIDO2 $LIBS" 3571 AC_CHECK_FUNCS([ \ 3572 fido_assert_set_clientdata \ 3573 fido_cred_prot \ 3574 fido_cred_set_prot \ 3575 fido_cred_set_clientdata \ 3576 fido_dev_get_touch_begin \ 3577 fido_dev_get_touch_status \ 3578 fido_dev_supports_cred_prot \ 3579 fido_dev_is_winhello \ 3580 ]) 3581 LIBS="$saved_LIBS" 3582 fi 3583fi 3584 3585# Check for standalone SecurityKeyProvider 3586AC_MSG_CHECKING([whether to build standalone sk-libfido2]) 3587if test "x$enable_sk_standalone" = "xyes" ; then 3588 AC_MSG_RESULT([yes]) 3589 AC_SUBST([SK_STANDALONE], [sk-libfido2$SHLIBEXT]) 3590else 3591 AC_MSG_RESULT([no]) 3592 AC_SUBST([SK_STANDALONE], [""]) 3593fi 3594 3595AC_CHECK_FUNCS([ \ 3596 arc4random \ 3597 arc4random_buf \ 3598 arc4random_stir \ 3599 arc4random_uniform \ 3600]) 3601### Configure cryptographic random number support 3602 3603# Check whether OpenSSL seeds itself 3604if test "x$openssl" = "xyes" ; then 3605 AC_MSG_CHECKING([whether OpenSSL's PRNG is internally seeded]) 3606 AC_RUN_IFELSE( 3607 [AC_LANG_PROGRAM([[ 3608 #include <stdlib.h> 3609 #include <string.h> 3610 #include <openssl/rand.h> 3611 ]], [[ 3612 exit(RAND_status() == 1 ? 0 : 1); 3613 ]])], 3614 [ 3615 OPENSSL_SEEDS_ITSELF=yes 3616 AC_MSG_RESULT([yes]) 3617 ], 3618 [ 3619 AC_MSG_RESULT([no]) 3620 ], 3621 [ 3622 AC_MSG_WARN([cross compiling: assuming yes]) 3623 # This is safe, since we will fatal() at runtime if 3624 # OpenSSL is not seeded correctly. 3625 OPENSSL_SEEDS_ITSELF=yes 3626 ] 3627 ) 3628fi 3629 3630# PRNGD TCP socket 3631AC_ARG_WITH([prngd-port], 3632 [ --with-prngd-port=PORT read entropy from PRNGD/EGD TCP localhost:PORT], 3633 [ 3634 case "$withval" in 3635 no) 3636 withval="" 3637 ;; 3638 [[0-9]]*) 3639 ;; 3640 *) 3641 AC_MSG_ERROR([You must specify a numeric port number for --with-prngd-port]) 3642 ;; 3643 esac 3644 if test ! -z "$withval" ; then 3645 PRNGD_PORT="$withval" 3646 AC_DEFINE_UNQUOTED([PRNGD_PORT], [$PRNGD_PORT], 3647 [Port number of PRNGD/EGD random number socket]) 3648 fi 3649 ] 3650) 3651 3652# PRNGD Unix domain socket 3653AC_ARG_WITH([prngd-socket], 3654 [ --with-prngd-socket=FILE read entropy from PRNGD/EGD socket FILE (default=/var/run/egd-pool)], 3655 [ 3656 case "$withval" in 3657 yes) 3658 withval="/var/run/egd-pool" 3659 ;; 3660 no) 3661 withval="" 3662 ;; 3663 /*) 3664 ;; 3665 *) 3666 AC_MSG_ERROR([You must specify an absolute path to the entropy socket]) 3667 ;; 3668 esac 3669 3670 if test ! -z "$withval" ; then 3671 if test ! -z "$PRNGD_PORT" ; then 3672 AC_MSG_ERROR([You may not specify both a PRNGD/EGD port and socket]) 3673 fi 3674 if test ! -r "$withval" ; then 3675 AC_MSG_WARN([Entropy socket is not readable]) 3676 fi 3677 PRNGD_SOCKET="$withval" 3678 AC_DEFINE_UNQUOTED([PRNGD_SOCKET], ["$PRNGD_SOCKET"], 3679 [Location of PRNGD/EGD random number socket]) 3680 fi 3681 ], 3682 [ 3683 # Check for existing socket only if we don't have a random device already 3684 if test "x$OPENSSL_SEEDS_ITSELF" != "xyes" ; then 3685 AC_MSG_CHECKING([for PRNGD/EGD socket]) 3686 # Insert other locations here 3687 for sock in /var/run/egd-pool /dev/egd-pool /etc/entropy; do 3688 if test -r $sock && $TEST_MINUS_S_SH -c "test -S $sock -o -p $sock" ; then 3689 PRNGD_SOCKET="$sock" 3690 AC_DEFINE_UNQUOTED([PRNGD_SOCKET], ["$PRNGD_SOCKET"]) 3691 break; 3692 fi 3693 done 3694 if test ! -z "$PRNGD_SOCKET" ; then 3695 AC_MSG_RESULT([$PRNGD_SOCKET]) 3696 else 3697 AC_MSG_RESULT([not found]) 3698 fi 3699 fi 3700 ] 3701) 3702 3703# Which randomness source do we use? 3704if test ! -z "$PRNGD_PORT" ; then 3705 RAND_MSG="PRNGd port $PRNGD_PORT" 3706elif test ! -z "$PRNGD_SOCKET" ; then 3707 RAND_MSG="PRNGd socket $PRNGD_SOCKET" 3708elif test ! -z "$OPENSSL_SEEDS_ITSELF" ; then 3709 AC_DEFINE([OPENSSL_PRNG_ONLY], [1], 3710 [Define if you want the OpenSSL internally seeded PRNG only]) 3711 RAND_MSG="OpenSSL internal ONLY" 3712elif test "x$openssl" = "xno" ; then 3713 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]) 3714else 3715 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]) 3716fi 3717LIBS="$nocrypto_saved_LIBS" 3718 3719saved_LIBS="$LIBS" 3720AC_CHECK_LIB([iaf], [ia_openinfo], [ 3721 LIBS="$LIBS -liaf" 3722 AC_CHECK_FUNCS([set_id], [SSHDLIBS="$SSHDLIBS -liaf" 3723 AC_DEFINE([HAVE_LIBIAF], [1], 3724 [Define if system has libiaf that supports set_id]) 3725 ]) 3726]) 3727LIBS="$saved_LIBS" 3728 3729# Check for crypt() in libcrypt. If we have it, we only need it for sshd. 3730saved_LIBS="$LIBS" 3731AC_CHECK_LIB([crypt], [crypt], [ 3732 LIBS="-lcrypt $LIBS" 3733 SSHDLIBS="-lcrypt $SSHDLIBS" 3734]) 3735AC_CHECK_FUNCS([crypt]) 3736LIBS="$saved_LIBS" 3737 3738# Check for PAM libs 3739PAM_MSG="no" 3740AC_ARG_WITH([pam], 3741 [ --with-pam Enable PAM support ], 3742 [ 3743 if test "x$withval" != "xno" ; then 3744 if test "x$ac_cv_header_security_pam_appl_h" != "xyes" && \ 3745 test "x$ac_cv_header_pam_pam_appl_h" != "xyes" ; then 3746 AC_MSG_ERROR([PAM headers not found]) 3747 fi 3748 3749 saved_LIBS="$LIBS" 3750 AC_CHECK_LIB([dl], [dlopen], , ) 3751 AC_CHECK_LIB([pam], [pam_set_item], , [AC_MSG_ERROR([*** libpam missing])]) 3752 AC_CHECK_FUNCS([pam_getenvlist]) 3753 AC_CHECK_FUNCS([pam_putenv]) 3754 LIBS="$saved_LIBS" 3755 3756 PAM_MSG="yes" 3757 3758 SSHDLIBS="$SSHDLIBS -lpam" 3759 AC_DEFINE([USE_PAM], [1], 3760 [Define if you want to enable PAM support]) 3761 3762 if test $ac_cv_lib_dl_dlopen = yes; then 3763 case "$LIBS" in 3764 *-ldl*) 3765 # libdl already in LIBS 3766 ;; 3767 *) 3768 SSHDLIBS="$SSHDLIBS -ldl" 3769 ;; 3770 esac 3771 fi 3772 fi 3773 ] 3774) 3775 3776AC_ARG_WITH([pam-service], 3777 [ --with-pam-service=name Specify PAM service name ], 3778 [ 3779 if test "x$withval" != "xno" && \ 3780 test "x$withval" != "xyes" ; then 3781 AC_DEFINE_UNQUOTED([SSHD_PAM_SERVICE], 3782 ["$withval"], [sshd PAM service name]) 3783 fi 3784 ] 3785) 3786 3787# Check for older PAM 3788if test "x$PAM_MSG" = "xyes" ; then 3789 # Check PAM strerror arguments (old PAM) 3790 AC_MSG_CHECKING([whether pam_strerror takes only one argument]) 3791 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 3792#include <stdlib.h> 3793#if defined(HAVE_SECURITY_PAM_APPL_H) 3794#include <security/pam_appl.h> 3795#elif defined (HAVE_PAM_PAM_APPL_H) 3796#include <pam/pam_appl.h> 3797#endif 3798 ]], [[ 3799(void)pam_strerror((pam_handle_t *)NULL, -1); 3800 ]])], [AC_MSG_RESULT([no])], [ 3801 AC_DEFINE([HAVE_OLD_PAM], [1], 3802 [Define if you have an old version of PAM 3803 which takes only one argument to pam_strerror]) 3804 AC_MSG_RESULT([yes]) 3805 PAM_MSG="yes (old library)" 3806 3807 ]) 3808fi 3809 3810case "$host" in 3811*-*-cygwin*) 3812 SSH_PRIVSEP_USER=CYGWIN_SSH_PRIVSEP_USER 3813 ;; 3814*) 3815 SSH_PRIVSEP_USER=sshd 3816 ;; 3817esac 3818AC_ARG_WITH([privsep-user], 3819 [ --with-privsep-user=user Specify non-privileged user for privilege separation], 3820 [ 3821 if test -n "$withval" && test "x$withval" != "xno" && \ 3822 test "x${withval}" != "xyes"; then 3823 SSH_PRIVSEP_USER=$withval 3824 fi 3825 ] 3826) 3827if test "x$SSH_PRIVSEP_USER" = "xCYGWIN_SSH_PRIVSEP_USER" ; then 3828 AC_DEFINE_UNQUOTED([SSH_PRIVSEP_USER], [CYGWIN_SSH_PRIVSEP_USER], 3829 [Cygwin function to fetch non-privileged user for privilege separation]) 3830else 3831 AC_DEFINE_UNQUOTED([SSH_PRIVSEP_USER], ["$SSH_PRIVSEP_USER"], 3832 [non-privileged user for privilege separation]) 3833fi 3834AC_SUBST([SSH_PRIVSEP_USER]) 3835 3836if test "x$have_linux_no_new_privs" = "x1" ; then 3837AC_CHECK_DECL([SECCOMP_MODE_FILTER], [have_seccomp_filter=1], , [ 3838 #include <sys/types.h> 3839 #include <linux/seccomp.h> 3840]) 3841fi 3842if test "x$have_seccomp_filter" = "x1" ; then 3843AC_MSG_CHECKING([kernel for seccomp_filter support]) 3844AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 3845 #include <errno.h> 3846 #include <elf.h> 3847 #include <linux/audit.h> 3848 #include <linux/seccomp.h> 3849 #include <stdlib.h> 3850 #include <sys/prctl.h> 3851 ]], 3852 [[ int i = $seccomp_audit_arch; 3853 errno = 0; 3854 prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, NULL, 0, 0); 3855 exit(errno == EFAULT ? 0 : 1); ]])], 3856 [ AC_MSG_RESULT([yes]) ], [ 3857 AC_MSG_RESULT([no]) 3858 # Disable seccomp filter as a target 3859 have_seccomp_filter=0 3860 ] 3861) 3862fi 3863 3864AC_CHECK_MEMBERS([struct pollfd.fd], [], [], [[ 3865#include <sys/types.h> 3866#ifdef HAVE_POLL_H 3867#include <poll.h> 3868#endif 3869#ifdef HAVE_SYS_POLL_H 3870#include <sys/poll.h> 3871#endif 3872]]) 3873 3874AC_CHECK_TYPES([nfds_t], , , [ 3875#include <sys/types.h> 3876#ifdef HAVE_POLL_H 3877#include <poll.h> 3878#endif 3879#ifdef HAVE_SYS_POLL_H 3880#include <sys/poll.h> 3881#endif 3882]) 3883 3884if test "x$ac_cv_type_nfds_t" != "xyes"; then 3885 AC_MSG_CHECKING([if poll nfds_t is unsigned long]) 3886 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 3887#include <sys/types.h> 3888#ifdef HAVE_POLL_H 3889#include <poll.h> 3890#endif 3891#ifdef HAVE_SYS_POLL_H 3892#include <sys/poll.h> 3893#endif 3894 int poll(struct pollfd *, unsigned long, int timeout); 3895 ]], [[return poll(0, 0, 0);]])], 3896 [AC_MSG_RESULT([yes]) 3897 AC_DEFINE(POLL_NFDS_T_ULONG, 1, [Define if poll 2nd arg is ulong])], 3898 [AC_MSG_RESULT([no])] 3899 ) 3900fi 3901 3902# Decide which sandbox style to use 3903sandbox_arg="" 3904AC_ARG_WITH([sandbox], 3905 [ --with-sandbox=style Specify privilege separation sandbox (no, capsicum, darwin, rlimit, seccomp_filter)], 3906 [ 3907 if test "x$withval" = "xyes" ; then 3908 sandbox_arg="" 3909 else 3910 sandbox_arg="$withval" 3911 fi 3912 ] 3913) 3914 3915if test "x$sandbox_arg" != "xno"; then 3916# POSIX specifies that poll() "shall fail with EINVAL if the nfds argument 3917# is greater than OPEN_MAX". On some platforms that includes implementions 3918# of select in userspace on top of poll() so check both work with rlimit 3919# NOFILES so check that both work before enabling the rlimit sandbox. 3920 AC_MSG_CHECKING([if select and/or poll works with descriptor rlimit]) 3921 AC_RUN_IFELSE( 3922 [AC_LANG_PROGRAM([[ 3923#include <sys/types.h> 3924#ifdef HAVE_SYS_TIME_H 3925# include <sys/time.h> 3926#endif 3927#include <sys/resource.h> 3928#ifdef HAVE_SYS_SELECT_H 3929# include <sys/select.h> 3930#endif 3931#ifdef HAVE_POLL_H 3932# include <poll.h> 3933#elif HAVE_SYS_POLL_H 3934# include <sys/poll.h> 3935#endif 3936#include <errno.h> 3937#include <fcntl.h> 3938#include <stdlib.h> 3939 ]],[[ 3940 struct rlimit rl_zero; 3941 int fd, r; 3942 fd_set fds; 3943 struct timeval tv; 3944#ifdef HAVE_POLL 3945 struct pollfd pfd; 3946#endif 3947 3948 fd = open("/dev/null", O_RDONLY); 3949 FD_ZERO(&fds); 3950 FD_SET(fd, &fds); 3951 rl_zero.rlim_cur = rl_zero.rlim_max = 0; 3952 setrlimit(RLIMIT_FSIZE, &rl_zero); 3953 setrlimit(RLIMIT_NOFILE, &rl_zero); 3954 tv.tv_sec = 1; 3955 tv.tv_usec = 0; 3956 r = select(fd+1, &fds, NULL, NULL, &tv); 3957 if (r == -1) 3958 exit(1); 3959#ifdef HAVE_POLL 3960 pfd.fd = fd; 3961 pfd.events = POLLIN; 3962 r = poll(&pfd, 1, 1); 3963 if (r == -1) 3964 exit(2); 3965#endif 3966 exit(0); 3967 ]])], 3968 [AC_MSG_RESULT([yes]) 3969 select_works_with_rlimit=yes], 3970 [AC_MSG_RESULT([no]) 3971 select_works_with_rlimit=no], 3972 [AC_MSG_WARN([cross compiling: assuming no]) 3973 select_works_with_rlimit=no] 3974 ) 3975 3976 AC_MSG_CHECKING([if setrlimit(RLIMIT_NOFILE,{0,0}) works]) 3977 AC_RUN_IFELSE( 3978 [AC_LANG_PROGRAM([[ 3979#include <sys/types.h> 3980#ifdef HAVE_SYS_TIME_H 3981# include <sys/time.h> 3982#endif 3983#include <sys/resource.h> 3984#include <errno.h> 3985#include <stdlib.h> 3986 ]],[[ 3987 struct rlimit rl_zero; 3988 int r; 3989 3990 rl_zero.rlim_cur = rl_zero.rlim_max = 0; 3991 r = setrlimit(RLIMIT_NOFILE, &rl_zero); 3992 exit (r == -1 ? 1 : 0); 3993 ]])], 3994 [AC_MSG_RESULT([yes]) 3995 rlimit_nofile_zero_works=yes], 3996 [AC_MSG_RESULT([no]) 3997 rlimit_nofile_zero_works=no], 3998 [AC_MSG_WARN([cross compiling: assuming yes]) 3999 rlimit_nofile_zero_works=yes] 4000 ) 4001 4002 AC_MSG_CHECKING([if setrlimit RLIMIT_FSIZE works]) 4003 AC_RUN_IFELSE( 4004 [AC_LANG_PROGRAM([[ 4005#include <sys/types.h> 4006#include <sys/resource.h> 4007#include <stdlib.h> 4008 ]],[[ 4009 struct rlimit rl_zero; 4010 4011 rl_zero.rlim_cur = rl_zero.rlim_max = 0; 4012 exit(setrlimit(RLIMIT_FSIZE, &rl_zero) != 0); 4013 ]])], 4014 [AC_MSG_RESULT([yes])], 4015 [AC_MSG_RESULT([no]) 4016 AC_DEFINE(SANDBOX_SKIP_RLIMIT_FSIZE, 1, 4017 [setrlimit RLIMIT_FSIZE works])], 4018 [AC_MSG_WARN([cross compiling: assuming yes])] 4019 ) 4020fi 4021 4022if test "x$sandbox_arg" = "xdarwin" || \ 4023 ( test -z "$sandbox_arg" && test "x$ac_cv_func_sandbox_init" = "xyes" && \ 4024 test "x$ac_cv_header_sandbox_h" = "xyes") ; then 4025 test "x$ac_cv_func_sandbox_init" != "xyes" -o \ 4026 "x$ac_cv_header_sandbox_h" != "xyes" && \ 4027 AC_MSG_ERROR([Darwin seatbelt sandbox requires sandbox.h and sandbox_init function]) 4028 SANDBOX_STYLE="darwin" 4029 AC_DEFINE([SANDBOX_DARWIN], [1], [Sandbox using Darwin sandbox_init(3)]) 4030elif test "x$sandbox_arg" = "xseccomp_filter" || \ 4031 ( test -z "$sandbox_arg" && \ 4032 test "x$have_seccomp_filter" = "x1" && \ 4033 test "x$ac_cv_header_elf_h" = "xyes" && \ 4034 test "x$ac_cv_header_linux_audit_h" = "xyes" && \ 4035 test "x$ac_cv_header_linux_filter_h" = "xyes" && \ 4036 test "x$seccomp_audit_arch" != "x" && \ 4037 test "x$have_linux_no_new_privs" = "x1" && \ 4038 test "x$ac_cv_func_prctl" = "xyes" ) ; then 4039 test "x$seccomp_audit_arch" = "x" && \ 4040 AC_MSG_ERROR([seccomp_filter sandbox not supported on $host]) 4041 test "x$have_linux_no_new_privs" != "x1" && \ 4042 AC_MSG_ERROR([seccomp_filter sandbox requires PR_SET_NO_NEW_PRIVS]) 4043 test "x$have_seccomp_filter" != "x1" && \ 4044 AC_MSG_ERROR([seccomp_filter sandbox requires seccomp headers]) 4045 test "x$ac_cv_func_prctl" != "xyes" && \ 4046 AC_MSG_ERROR([seccomp_filter sandbox requires prctl function]) 4047 SANDBOX_STYLE="seccomp_filter" 4048 AC_DEFINE([SANDBOX_SECCOMP_FILTER], [1], [Sandbox using seccomp filter]) 4049elif test "x$sandbox_arg" = "xcapsicum" || \ 4050 ( test -z "$sandbox_arg" && \ 4051 test "x$disable_capsicum" != "xyes" && \ 4052 test "x$ac_cv_header_sys_capsicum_h" = "xyes" && \ 4053 test "x$ac_cv_func_cap_rights_limit" = "xyes") ; then 4054 test "x$ac_cv_header_sys_capsicum_h" != "xyes" && \ 4055 AC_MSG_ERROR([capsicum sandbox requires sys/capsicum.h header]) 4056 test "x$ac_cv_func_cap_rights_limit" != "xyes" && \ 4057 AC_MSG_ERROR([capsicum sandbox requires cap_rights_limit function]) 4058 SANDBOX_STYLE="capsicum" 4059 AC_DEFINE([SANDBOX_CAPSICUM], [1], [Sandbox using capsicum]) 4060elif test "x$sandbox_arg" = "xrlimit" || \ 4061 ( test -z "$sandbox_arg" && test "x$ac_cv_func_setrlimit" = "xyes" && \ 4062 test "x$select_works_with_rlimit" = "xyes" && \ 4063 test "x$rlimit_nofile_zero_works" = "xyes" ) ; then 4064 test "x$ac_cv_func_setrlimit" != "xyes" && \ 4065 AC_MSG_ERROR([rlimit sandbox requires setrlimit function]) 4066 test "x$select_works_with_rlimit" != "xyes" && \ 4067 AC_MSG_ERROR([rlimit sandbox requires select to work with rlimit]) 4068 SANDBOX_STYLE="rlimit" 4069 AC_DEFINE([SANDBOX_RLIMIT], [1], [Sandbox using setrlimit(2)]) 4070elif test "x$sandbox_arg" = "xsolaris" || \ 4071 ( test -z "$sandbox_arg" && test "x$SOLARIS_PRIVS" = "xyes" ) ; then 4072 SANDBOX_STYLE="solaris" 4073 AC_DEFINE([SANDBOX_SOLARIS], [1], [Sandbox using Solaris/Illumos privileges]) 4074elif test -z "$sandbox_arg" || test "x$sandbox_arg" = "xno" || \ 4075 test "x$sandbox_arg" = "xnone" || test "x$sandbox_arg" = "xnull" ; then 4076 SANDBOX_STYLE="none" 4077 AC_DEFINE([SANDBOX_NULL], [1], [no privsep sandboxing]) 4078else 4079 AC_MSG_ERROR([unsupported --with-sandbox]) 4080fi 4081 4082# Cheap hack to ensure NEWS-OS libraries are arranged right. 4083if test ! -z "$SONY" ; then 4084 LIBS="$LIBS -liberty"; 4085fi 4086 4087# Check for long long datatypes 4088AC_CHECK_TYPES([long long, unsigned long long, long double]) 4089 4090# Check datatype sizes 4091AC_CHECK_SIZEOF([short int]) 4092AC_CHECK_SIZEOF([int]) 4093AC_CHECK_SIZEOF([long int]) 4094AC_CHECK_SIZEOF([long long int]) 4095AC_CHECK_SIZEOF([time_t], [], [[ 4096 #include <sys/types.h> 4097 #ifdef HAVE_SYS_TIME_H 4098 # include <sys/time.h> 4099 #endif 4100 #ifdef HAVE_TIME_H 4101 # include <time.h> 4102 #endif 4103 ]] 4104) 4105 4106# Sanity check long long for some platforms (AIX) 4107if test "x$ac_cv_sizeof_long_long_int" = "x4" ; then 4108 ac_cv_sizeof_long_long_int=0 4109fi 4110 4111# compute LLONG_MIN and LLONG_MAX if we don't know them. 4112if test -z "$have_llong_max" && test -z "$have_long_long_max"; then 4113 AC_MSG_CHECKING([for max value of long long]) 4114 AC_RUN_IFELSE( 4115 [AC_LANG_PROGRAM([[ 4116#include <stdio.h> 4117#include <stdlib.h> 4118/* Why is this so damn hard? */ 4119#ifdef __GNUC__ 4120# undef __GNUC__ 4121#endif 4122#define __USE_ISOC99 4123#include <limits.h> 4124#define DATA "conftest.llminmax" 4125#define my_abs(a) ((a) < 0 ? ((a) * -1) : (a)) 4126 4127/* 4128 * printf in libc on some platforms (eg old Tru64) does not understand %lld so 4129 * we do this the hard way. 4130 */ 4131static int 4132fprint_ll(FILE *f, long long n) 4133{ 4134 unsigned int i; 4135 int l[sizeof(long long) * 8]; 4136 4137 if (n < 0) 4138 if (fprintf(f, "-") < 0) 4139 return -1; 4140 for (i = 0; n != 0; i++) { 4141 l[i] = my_abs(n % 10); 4142 n /= 10; 4143 } 4144 do { 4145 if (fprintf(f, "%d", l[--i]) < 0) 4146 return -1; 4147 } while (i != 0); 4148 if (fprintf(f, " ") < 0) 4149 return -1; 4150 return 0; 4151} 4152 ]], [[ 4153 FILE *f; 4154 long long i, llmin, llmax = 0; 4155 4156 if((f = fopen(DATA,"w")) == NULL) 4157 exit(1); 4158 4159#if defined(LLONG_MIN) && defined(LLONG_MAX) 4160 fprintf(stderr, "Using system header for LLONG_MIN and LLONG_MAX\n"); 4161 llmin = LLONG_MIN; 4162 llmax = LLONG_MAX; 4163#else 4164 fprintf(stderr, "Calculating LLONG_MIN and LLONG_MAX\n"); 4165 /* This will work on one's complement and two's complement */ 4166 for (i = 1; i > llmax; i <<= 1, i++) 4167 llmax = i; 4168 llmin = llmax + 1LL; /* wrap */ 4169#endif 4170 4171 /* Sanity check */ 4172 if (llmin + 1 < llmin || llmin - 1 < llmin || llmax + 1 > llmax 4173 || llmax - 1 > llmax || llmin == llmax || llmin == 0 4174 || llmax == 0 || llmax < LONG_MAX || llmin > LONG_MIN) { 4175 fprintf(f, "unknown unknown\n"); 4176 exit(2); 4177 } 4178 4179 if (fprint_ll(f, llmin) < 0) 4180 exit(3); 4181 if (fprint_ll(f, llmax) < 0) 4182 exit(4); 4183 if (fclose(f) < 0) 4184 exit(5); 4185 exit(0); 4186 ]])], 4187 [ 4188 llong_min=`$AWK '{print $1}' conftest.llminmax` 4189 llong_max=`$AWK '{print $2}' conftest.llminmax` 4190 4191 AC_MSG_RESULT([$llong_max]) 4192 AC_DEFINE_UNQUOTED([LLONG_MAX], [${llong_max}LL], 4193 [max value of long long calculated by configure]) 4194 AC_MSG_CHECKING([for min value of long long]) 4195 AC_MSG_RESULT([$llong_min]) 4196 AC_DEFINE_UNQUOTED([LLONG_MIN], [${llong_min}LL], 4197 [min value of long long calculated by configure]) 4198 ], 4199 [ 4200 AC_MSG_RESULT([not found]) 4201 ], 4202 [ 4203 AC_MSG_WARN([cross compiling: not checking]) 4204 ] 4205 ) 4206fi 4207 4208AC_CHECK_DECLS([UINT32_MAX], , , [[ 4209#ifdef HAVE_SYS_LIMITS_H 4210# include <sys/limits.h> 4211#endif 4212#ifdef HAVE_LIMITS_H 4213# include <limits.h> 4214#endif 4215#ifdef HAVE_STDINT_H 4216# include <stdint.h> 4217#endif 4218]]) 4219 4220# More checks for data types 4221AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [ 4222 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]], 4223 [[ u_int a; a = 1;]])], 4224 [ ac_cv_have_u_int="yes" ], [ ac_cv_have_u_int="no" 4225 ]) 4226]) 4227if test "x$ac_cv_have_u_int" = "xyes" ; then 4228 AC_DEFINE([HAVE_U_INT], [1], [define if you have u_int data type]) 4229 have_u_int=1 4230fi 4231 4232AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [ 4233 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]], 4234 [[ int8_t a; int16_t b; int32_t c; a = b = c = 1;]])], 4235 [ ac_cv_have_intxx_t="yes" ], [ ac_cv_have_intxx_t="no" 4236 ]) 4237]) 4238if test "x$ac_cv_have_intxx_t" = "xyes" ; then 4239 AC_DEFINE([HAVE_INTXX_T], [1], [define if you have intxx_t data type]) 4240 have_intxx_t=1 4241fi 4242 4243if (test -z "$have_intxx_t" && \ 4244 test "x$ac_cv_header_stdint_h" = "xyes") 4245then 4246 AC_MSG_CHECKING([for intXX_t types in stdint.h]) 4247 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdint.h> ]], 4248 [[ int8_t a; int16_t b; int32_t c; a = b = c = 1;]])], 4249 [ 4250 AC_DEFINE([HAVE_INTXX_T]) 4251 AC_MSG_RESULT([yes]) 4252 ], [ AC_MSG_RESULT([no]) 4253 ]) 4254fi 4255 4256AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [ 4257 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 4258#include <sys/types.h> 4259#ifdef HAVE_STDINT_H 4260# include <stdint.h> 4261#endif 4262#include <sys/socket.h> 4263#ifdef HAVE_SYS_BITYPES_H 4264# include <sys/bitypes.h> 4265#endif 4266 ]], [[ 4267int64_t a; a = 1; 4268 ]])], 4269 [ ac_cv_have_int64_t="yes" ], [ ac_cv_have_int64_t="no" 4270 ]) 4271]) 4272if test "x$ac_cv_have_int64_t" = "xyes" ; then 4273 AC_DEFINE([HAVE_INT64_T], [1], [define if you have int64_t data type]) 4274fi 4275 4276AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [ 4277 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]], 4278 [[ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;]])], 4279 [ ac_cv_have_u_intxx_t="yes" ], [ ac_cv_have_u_intxx_t="no" 4280 ]) 4281]) 4282if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then 4283 AC_DEFINE([HAVE_U_INTXX_T], [1], [define if you have u_intxx_t data type]) 4284 have_u_intxx_t=1 4285fi 4286 4287if test -z "$have_u_intxx_t" ; then 4288 AC_MSG_CHECKING([for u_intXX_t types in sys/socket.h]) 4289 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/socket.h> ]], 4290 [[ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;]])], 4291 [ 4292 AC_DEFINE([HAVE_U_INTXX_T]) 4293 AC_MSG_RESULT([yes]) 4294 ], [ AC_MSG_RESULT([no]) 4295 ]) 4296fi 4297 4298AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [ 4299 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]], 4300 [[ u_int64_t a; a = 1;]])], 4301 [ ac_cv_have_u_int64_t="yes" ], [ ac_cv_have_u_int64_t="no" 4302 ]) 4303]) 4304if test "x$ac_cv_have_u_int64_t" = "xyes" ; then 4305 AC_DEFINE([HAVE_U_INT64_T], [1], [define if you have u_int64_t data type]) 4306 have_u_int64_t=1 4307fi 4308 4309if (test -z "$have_u_int64_t" && \ 4310 test "x$ac_cv_header_sys_bitypes_h" = "xyes") 4311then 4312 AC_MSG_CHECKING([for u_int64_t type in sys/bitypes.h]) 4313 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/bitypes.h> ]], 4314 [[ u_int64_t a; a = 1]])], 4315 [ 4316 AC_DEFINE([HAVE_U_INT64_T]) 4317 AC_MSG_RESULT([yes]) 4318 ], [ AC_MSG_RESULT([no]) 4319 ]) 4320fi 4321 4322if test -z "$have_u_intxx_t" ; then 4323 AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [ 4324 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 4325#include <sys/types.h> 4326 ]], [[ 4327 uint8_t a; 4328 uint16_t b; 4329 uint32_t c; 4330 a = b = c = 1; 4331 ]])], 4332 [ ac_cv_have_uintxx_t="yes" ], [ ac_cv_have_uintxx_t="no" 4333 ]) 4334 ]) 4335 if test "x$ac_cv_have_uintxx_t" = "xyes" ; then 4336 AC_DEFINE([HAVE_UINTXX_T], [1], 4337 [define if you have uintxx_t data type]) 4338 fi 4339fi 4340 4341if (test -z "$have_uintxx_t" && \ 4342 test "x$ac_cv_header_stdint_h" = "xyes") 4343then 4344 AC_MSG_CHECKING([for uintXX_t types in stdint.h]) 4345 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdint.h> ]], 4346 [[ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;]])], 4347 [ 4348 AC_DEFINE([HAVE_UINTXX_T]) 4349 AC_MSG_RESULT([yes]) 4350 ], [ AC_MSG_RESULT([no]) 4351 ]) 4352fi 4353 4354if (test -z "$have_uintxx_t" && \ 4355 test "x$ac_cv_header_inttypes_h" = "xyes") 4356then 4357 AC_MSG_CHECKING([for uintXX_t types in inttypes.h]) 4358 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <inttypes.h> ]], 4359 [[ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;]])], 4360 [ 4361 AC_DEFINE([HAVE_UINTXX_T]) 4362 AC_MSG_RESULT([yes]) 4363 ], [ AC_MSG_RESULT([no]) 4364 ]) 4365fi 4366 4367if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \ 4368 test "x$ac_cv_header_sys_bitypes_h" = "xyes") 4369then 4370 AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h]) 4371 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 4372#include <sys/bitypes.h> 4373 ]], [[ 4374 int8_t a; int16_t b; int32_t c; 4375 u_int8_t e; u_int16_t f; u_int32_t g; 4376 a = b = c = e = f = g = 1; 4377 ]])], 4378 [ 4379 AC_DEFINE([HAVE_U_INTXX_T]) 4380 AC_DEFINE([HAVE_INTXX_T]) 4381 AC_MSG_RESULT([yes]) 4382 ], [AC_MSG_RESULT([no]) 4383 ]) 4384fi 4385 4386 4387AC_CACHE_CHECK([for u_char], ac_cv_have_u_char, [ 4388 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]], 4389 [[ u_char foo; foo = 125; ]])], 4390 [ ac_cv_have_u_char="yes" ], [ ac_cv_have_u_char="no" 4391 ]) 4392]) 4393if test "x$ac_cv_have_u_char" = "xyes" ; then 4394 AC_DEFINE([HAVE_U_CHAR], [1], [define if you have u_char data type]) 4395fi 4396 4397AC_CHECK_TYPES([intmax_t, uintmax_t], , , [ 4398#include <sys/types.h> 4399#ifdef HAVE_STDINT_H 4400# include <stdint.h> 4401#endif 4402]) 4403 4404TYPE_SOCKLEN_T 4405 4406AC_CHECK_TYPES([sig_atomic_t, sighandler_t], , , [#include <signal.h>]) 4407AC_CHECK_TYPES([fsblkcnt_t, fsfilcnt_t], , , [ 4408#include <sys/types.h> 4409#ifdef HAVE_SYS_BITYPES_H 4410#include <sys/bitypes.h> 4411#endif 4412#ifdef HAVE_SYS_STATFS_H 4413#include <sys/statfs.h> 4414#endif 4415#ifdef HAVE_SYS_STATVFS_H 4416#include <sys/statvfs.h> 4417#endif 4418]) 4419 4420AC_CHECK_MEMBERS([struct statfs.f_files, struct statfs.f_flags], [], [], [[ 4421#include <sys/param.h> 4422#include <sys/types.h> 4423#ifdef HAVE_SYS_BITYPES_H 4424#include <sys/bitypes.h> 4425#endif 4426#ifdef HAVE_SYS_STATFS_H 4427#include <sys/statfs.h> 4428#endif 4429#ifdef HAVE_SYS_STATVFS_H 4430#include <sys/statvfs.h> 4431#endif 4432#ifdef HAVE_SYS_VFS_H 4433#include <sys/vfs.h> 4434#endif 4435#ifdef HAVE_SYS_MOUNT_H 4436#include <sys/mount.h> 4437#endif 4438]]) 4439 4440 4441AC_CHECK_TYPES([in_addr_t, in_port_t], , , 4442[#include <sys/types.h> 4443#include <netinet/in.h>]) 4444 4445AC_CACHE_CHECK([for size_t], ac_cv_have_size_t, [ 4446 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]], 4447 [[ size_t foo; foo = 1235; ]])], 4448 [ ac_cv_have_size_t="yes" ], [ ac_cv_have_size_t="no" 4449 ]) 4450]) 4451if test "x$ac_cv_have_size_t" = "xyes" ; then 4452 AC_DEFINE([HAVE_SIZE_T], [1], [define if you have size_t data type]) 4453fi 4454 4455AC_CACHE_CHECK([for ssize_t], ac_cv_have_ssize_t, [ 4456 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]], 4457 [[ ssize_t foo; foo = 1235; ]])], 4458 [ ac_cv_have_ssize_t="yes" ], [ ac_cv_have_ssize_t="no" 4459 ]) 4460]) 4461if test "x$ac_cv_have_ssize_t" = "xyes" ; then 4462 AC_DEFINE([HAVE_SSIZE_T], [1], [define if you have ssize_t data type]) 4463fi 4464 4465AC_CACHE_CHECK([for clock_t], ac_cv_have_clock_t, [ 4466 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <time.h> ]], 4467 [[ clock_t foo; foo = 1235; ]])], 4468 [ ac_cv_have_clock_t="yes" ], [ ac_cv_have_clock_t="no" 4469 ]) 4470]) 4471if test "x$ac_cv_have_clock_t" = "xyes" ; then 4472 AC_DEFINE([HAVE_CLOCK_T], [1], [define if you have clock_t data type]) 4473fi 4474 4475AC_CACHE_CHECK([for sa_family_t], ac_cv_have_sa_family_t, [ 4476 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 4477#include <sys/types.h> 4478#include <sys/socket.h> 4479 ]], [[ sa_family_t foo; foo = 1235; ]])], 4480 [ ac_cv_have_sa_family_t="yes" ], 4481 [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 4482#include <sys/types.h> 4483#include <sys/socket.h> 4484#include <netinet/in.h> 4485 ]], [[ sa_family_t foo; foo = 1235; ]])], 4486 [ ac_cv_have_sa_family_t="yes" ], 4487 [ ac_cv_have_sa_family_t="no" ] 4488 ) 4489 ]) 4490]) 4491if test "x$ac_cv_have_sa_family_t" = "xyes" ; then 4492 AC_DEFINE([HAVE_SA_FAMILY_T], [1], 4493 [define if you have sa_family_t data type]) 4494fi 4495 4496AC_CACHE_CHECK([for pid_t], ac_cv_have_pid_t, [ 4497 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]], 4498 [[ pid_t foo; foo = 1235; ]])], 4499 [ ac_cv_have_pid_t="yes" ], [ ac_cv_have_pid_t="no" 4500 ]) 4501]) 4502if test "x$ac_cv_have_pid_t" = "xyes" ; then 4503 AC_DEFINE([HAVE_PID_T], [1], [define if you have pid_t data type]) 4504fi 4505 4506AC_CACHE_CHECK([for mode_t], ac_cv_have_mode_t, [ 4507 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]], 4508 [[ mode_t foo; foo = 1235; ]])], 4509 [ ac_cv_have_mode_t="yes" ], [ ac_cv_have_mode_t="no" 4510 ]) 4511]) 4512if test "x$ac_cv_have_mode_t" = "xyes" ; then 4513 AC_DEFINE([HAVE_MODE_T], [1], [define if you have mode_t data type]) 4514fi 4515 4516 4517AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_have_struct_sockaddr_storage, [ 4518 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 4519#include <sys/types.h> 4520#include <sys/socket.h> 4521 ]], [[ struct sockaddr_storage s; ]])], 4522 [ ac_cv_have_struct_sockaddr_storage="yes" ], 4523 [ ac_cv_have_struct_sockaddr_storage="no" 4524 ]) 4525]) 4526if test "x$ac_cv_have_struct_sockaddr_storage" = "xyes" ; then 4527 AC_DEFINE([HAVE_STRUCT_SOCKADDR_STORAGE], [1], 4528 [define if you have struct sockaddr_storage data type]) 4529fi 4530 4531AC_CACHE_CHECK([for struct sockaddr_in6], ac_cv_have_struct_sockaddr_in6, [ 4532 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 4533#include <sys/types.h> 4534#include <netinet/in.h> 4535 ]], [[ struct sockaddr_in6 s; s.sin6_family = 0; ]])], 4536 [ ac_cv_have_struct_sockaddr_in6="yes" ], 4537 [ ac_cv_have_struct_sockaddr_in6="no" 4538 ]) 4539]) 4540if test "x$ac_cv_have_struct_sockaddr_in6" = "xyes" ; then 4541 AC_DEFINE([HAVE_STRUCT_SOCKADDR_IN6], [1], 4542 [define if you have struct sockaddr_in6 data type]) 4543fi 4544 4545AC_CACHE_CHECK([for struct in6_addr], ac_cv_have_struct_in6_addr, [ 4546 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 4547#include <sys/types.h> 4548#include <netinet/in.h> 4549 ]], [[ struct in6_addr s; s.s6_addr[0] = 0; ]])], 4550 [ ac_cv_have_struct_in6_addr="yes" ], 4551 [ ac_cv_have_struct_in6_addr="no" 4552 ]) 4553]) 4554if test "x$ac_cv_have_struct_in6_addr" = "xyes" ; then 4555 AC_DEFINE([HAVE_STRUCT_IN6_ADDR], [1], 4556 [define if you have struct in6_addr data type]) 4557 4558dnl Now check for sin6_scope_id 4559 AC_CHECK_MEMBERS([struct sockaddr_in6.sin6_scope_id], , , 4560 [ 4561#ifdef HAVE_SYS_TYPES_H 4562#include <sys/types.h> 4563#endif 4564#include <netinet/in.h> 4565 ]) 4566fi 4567 4568AC_CACHE_CHECK([for struct addrinfo], ac_cv_have_struct_addrinfo, [ 4569 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 4570#include <sys/types.h> 4571#include <sys/socket.h> 4572#include <netdb.h> 4573 ]], [[ struct addrinfo s; s.ai_flags = AI_PASSIVE; ]])], 4574 [ ac_cv_have_struct_addrinfo="yes" ], 4575 [ ac_cv_have_struct_addrinfo="no" 4576 ]) 4577]) 4578if test "x$ac_cv_have_struct_addrinfo" = "xyes" ; then 4579 AC_DEFINE([HAVE_STRUCT_ADDRINFO], [1], 4580 [define if you have struct addrinfo data type]) 4581fi 4582 4583AC_CACHE_CHECK([for struct timeval], ac_cv_have_struct_timeval, [ 4584 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/time.h> ]], 4585 [[ struct timeval tv; tv.tv_sec = 1;]])], 4586 [ ac_cv_have_struct_timeval="yes" ], 4587 [ ac_cv_have_struct_timeval="no" 4588 ]) 4589]) 4590if test "x$ac_cv_have_struct_timeval" = "xyes" ; then 4591 AC_DEFINE([HAVE_STRUCT_TIMEVAL], [1], [define if you have struct timeval]) 4592 have_struct_timeval=1 4593fi 4594 4595AC_CACHE_CHECK([for struct timespec], ac_cv_have_struct_timespec, [ 4596 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 4597 #ifdef HAVE_SYS_TIME_H 4598 # include <sys/time.h> 4599 #endif 4600 #ifdef HAVE_TIME_H 4601 # include <time.h> 4602 #endif 4603 ]], 4604 [[ struct timespec ts; ts.tv_sec = 1;]])], 4605 [ ac_cv_have_struct_timespec="yes" ], 4606 [ ac_cv_have_struct_timespec="no" 4607 ]) 4608]) 4609if test "x$ac_cv_have_struct_timespec" = "xyes" ; then 4610 AC_DEFINE([HAVE_STRUCT_TIMESPEC], [1], [define if you have struct timespec]) 4611 have_struct_timespec=1 4612fi 4613 4614# We need int64_t or else certain parts of the compile will fail. 4615if test "x$ac_cv_have_int64_t" = "xno" && \ 4616 test "x$ac_cv_sizeof_long_int" != "x8" && \ 4617 test "x$ac_cv_sizeof_long_long_int" = "x0" ; then 4618 echo "OpenSSH requires int64_t support. Contact your vendor or install" 4619 echo "an alternative compiler (I.E., GCC) before continuing." 4620 echo "" 4621 exit 1; 4622else 4623dnl test snprintf (broken on SCO w/gcc) 4624 AC_RUN_IFELSE( 4625 [AC_LANG_SOURCE([[ 4626#include <stdio.h> 4627#include <stdlib.h> 4628#include <string.h> 4629#ifdef HAVE_SNPRINTF 4630int main(void) 4631{ 4632 char buf[50]; 4633 char expected_out[50]; 4634 int mazsize = 50 ; 4635#if (SIZEOF_LONG_INT == 8) 4636 long int num = 0x7fffffffffffffff; 4637#else 4638 long long num = 0x7fffffffffffffffll; 4639#endif 4640 strcpy(expected_out, "9223372036854775807"); 4641#if (SIZEOF_LONG_INT == 8) 4642 snprintf(buf, mazsize, "%ld", num); 4643#else 4644 snprintf(buf, mazsize, "%lld", num); 4645#endif 4646 if(strcmp(buf, expected_out) != 0) 4647 exit(1); 4648 exit(0); 4649} 4650#else 4651int main(void) { exit(0); } 4652#endif 4653 ]])], [ true ], [ AC_DEFINE([BROKEN_SNPRINTF]) ], 4654 AC_MSG_WARN([cross compiling: Assuming working snprintf()]) 4655 ) 4656fi 4657 4658dnl Checks for structure members 4659OSSH_CHECK_HEADER_FOR_FIELD([ut_host], [utmp.h], [HAVE_HOST_IN_UTMP]) 4660OSSH_CHECK_HEADER_FOR_FIELD([ut_host], [utmpx.h], [HAVE_HOST_IN_UTMPX]) 4661OSSH_CHECK_HEADER_FOR_FIELD([syslen], [utmpx.h], [HAVE_SYSLEN_IN_UTMPX]) 4662OSSH_CHECK_HEADER_FOR_FIELD([ut_pid], [utmp.h], [HAVE_PID_IN_UTMP]) 4663OSSH_CHECK_HEADER_FOR_FIELD([ut_type], [utmp.h], [HAVE_TYPE_IN_UTMP]) 4664OSSH_CHECK_HEADER_FOR_FIELD([ut_type], [utmpx.h], [HAVE_TYPE_IN_UTMPX]) 4665OSSH_CHECK_HEADER_FOR_FIELD([ut_tv], [utmp.h], [HAVE_TV_IN_UTMP]) 4666OSSH_CHECK_HEADER_FOR_FIELD([ut_id], [utmp.h], [HAVE_ID_IN_UTMP]) 4667OSSH_CHECK_HEADER_FOR_FIELD([ut_id], [utmpx.h], [HAVE_ID_IN_UTMPX]) 4668OSSH_CHECK_HEADER_FOR_FIELD([ut_addr], [utmp.h], [HAVE_ADDR_IN_UTMP]) 4669OSSH_CHECK_HEADER_FOR_FIELD([ut_addr], [utmpx.h], [HAVE_ADDR_IN_UTMPX]) 4670OSSH_CHECK_HEADER_FOR_FIELD([ut_addr_v6], [utmp.h], [HAVE_ADDR_V6_IN_UTMP]) 4671OSSH_CHECK_HEADER_FOR_FIELD([ut_addr_v6], [utmpx.h], [HAVE_ADDR_V6_IN_UTMPX]) 4672OSSH_CHECK_HEADER_FOR_FIELD([ut_exit], [utmp.h], [HAVE_EXIT_IN_UTMP]) 4673OSSH_CHECK_HEADER_FOR_FIELD([ut_time], [utmp.h], [HAVE_TIME_IN_UTMP]) 4674OSSH_CHECK_HEADER_FOR_FIELD([ut_time], [utmpx.h], [HAVE_TIME_IN_UTMPX]) 4675OSSH_CHECK_HEADER_FOR_FIELD([ut_tv], [utmpx.h], [HAVE_TV_IN_UTMPX]) 4676OSSH_CHECK_HEADER_FOR_FIELD([ut_ss], [utmpx.h], [HAVE_SS_IN_UTMPX]) 4677 4678AC_CHECK_MEMBERS([struct stat.st_blksize]) 4679AC_CHECK_MEMBERS([struct stat.st_mtim]) 4680AC_CHECK_MEMBERS([struct stat.st_mtime]) 4681AC_CHECK_MEMBERS([struct passwd.pw_gecos, struct passwd.pw_class, 4682struct passwd.pw_change, struct passwd.pw_expire], 4683[], [], [[ 4684#include <sys/types.h> 4685#include <pwd.h> 4686]]) 4687 4688AC_CHECK_MEMBER([struct __res_state.retrans], [], [AC_DEFINE([__res_state], [state], 4689 [Define if we don't have struct __res_state in resolv.h])], 4690[[ 4691#include <stdio.h> 4692#if HAVE_SYS_TYPES_H 4693# include <sys/types.h> 4694#endif 4695#include <netinet/in.h> 4696#include <arpa/nameser.h> 4697#include <resolv.h> 4698]]) 4699 4700AC_CHECK_MEMBER([struct sockaddr_in.sin_len], 4701 [AC_DEFINE([SOCK_HAS_LEN], [1], [sockaddr_in has sin_len])], 4702 [], 4703 [AC_LANG_SOURCE([[ 4704#include <sys/types.h> 4705#include <sys/socket.h> 4706#include <netinet/in.h> 4707 ]])] 4708) 4709 4710AC_CACHE_CHECK([for ss_family field in struct sockaddr_storage], 4711 ac_cv_have_ss_family_in_struct_ss, [ 4712 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 4713#include <sys/types.h> 4714#include <sys/socket.h> 4715 ]], [[ struct sockaddr_storage s; s.ss_family = 1; ]])], 4716 [ ac_cv_have_ss_family_in_struct_ss="yes" ], 4717 [ ac_cv_have_ss_family_in_struct_ss="no" ]) 4718]) 4719if test "x$ac_cv_have_ss_family_in_struct_ss" = "xyes" ; then 4720 AC_DEFINE([HAVE_SS_FAMILY_IN_SS], [1], [Fields in struct sockaddr_storage]) 4721fi 4722 4723AC_CACHE_CHECK([for __ss_family field in struct sockaddr_storage], 4724 ac_cv_have___ss_family_in_struct_ss, [ 4725 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 4726#include <sys/types.h> 4727#include <sys/socket.h> 4728 ]], [[ struct sockaddr_storage s; s.__ss_family = 1; ]])], 4729 [ ac_cv_have___ss_family_in_struct_ss="yes" ], 4730 [ ac_cv_have___ss_family_in_struct_ss="no" 4731 ]) 4732]) 4733if test "x$ac_cv_have___ss_family_in_struct_ss" = "xyes" ; then 4734 AC_DEFINE([HAVE___SS_FAMILY_IN_SS], [1], 4735 [Fields in struct sockaddr_storage]) 4736fi 4737 4738dnl make sure we're using the real structure members and not defines 4739AC_CACHE_CHECK([for msg_accrights field in struct msghdr], 4740 ac_cv_have_accrights_in_msghdr, [ 4741 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 4742#include <sys/types.h> 4743#include <sys/socket.h> 4744#include <sys/uio.h> 4745#include <stdlib.h> 4746 ]], [[ 4747#ifdef msg_accrights 4748#error "msg_accrights is a macro" 4749exit(1); 4750#endif 4751struct msghdr m; 4752m.msg_accrights = 0; 4753exit(0); 4754 ]])], 4755 [ ac_cv_have_accrights_in_msghdr="yes" ], 4756 [ ac_cv_have_accrights_in_msghdr="no" ] 4757 ) 4758]) 4759if test "x$ac_cv_have_accrights_in_msghdr" = "xyes" ; then 4760 AC_DEFINE([HAVE_ACCRIGHTS_IN_MSGHDR], [1], 4761 [Define if your system uses access rights style 4762 file descriptor passing]) 4763fi 4764 4765AC_MSG_CHECKING([if struct statvfs.f_fsid is integral type]) 4766AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 4767#include <sys/param.h> 4768#include <sys/stat.h> 4769#ifdef HAVE_SYS_TIME_H 4770# include <sys/time.h> 4771#endif 4772#ifdef HAVE_SYS_MOUNT_H 4773#include <sys/mount.h> 4774#endif 4775#ifdef HAVE_SYS_STATVFS_H 4776#include <sys/statvfs.h> 4777#endif 4778 ]], [[ struct statvfs s; s.f_fsid = 0; ]])], 4779 [ AC_MSG_RESULT([yes]) ], 4780 [ AC_MSG_RESULT([no]) 4781 4782 AC_MSG_CHECKING([if fsid_t has member val]) 4783 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 4784#include <sys/types.h> 4785#include <sys/statvfs.h> 4786 ]], [[ fsid_t t; t.val[0] = 0; ]])], 4787 [ AC_MSG_RESULT([yes]) 4788 AC_DEFINE([FSID_HAS_VAL], [1], [fsid_t has member val]) ], 4789 [ AC_MSG_RESULT([no]) ]) 4790 4791 AC_MSG_CHECKING([if f_fsid has member __val]) 4792 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 4793#include <sys/types.h> 4794#include <sys/statvfs.h> 4795 ]], [[ fsid_t t; t.__val[0] = 0; ]])], 4796 [ AC_MSG_RESULT([yes]) 4797 AC_DEFINE([FSID_HAS___VAL], [1], [fsid_t has member __val]) ], 4798 [ AC_MSG_RESULT([no]) ]) 4799]) 4800 4801AC_CACHE_CHECK([for msg_control field in struct msghdr], 4802 ac_cv_have_control_in_msghdr, [ 4803 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 4804#include <sys/types.h> 4805#include <sys/socket.h> 4806#include <sys/uio.h> 4807#include <stdlib.h> 4808 ]], [[ 4809#ifdef msg_control 4810#error "msg_control is a macro" 4811exit(1); 4812#endif 4813struct msghdr m; 4814m.msg_control = 0; 4815exit(0); 4816 ]])], 4817 [ ac_cv_have_control_in_msghdr="yes" ], 4818 [ ac_cv_have_control_in_msghdr="no" ] 4819 ) 4820]) 4821if test "x$ac_cv_have_control_in_msghdr" = "xyes" ; then 4822 AC_DEFINE([HAVE_CONTROL_IN_MSGHDR], [1], 4823 [Define if your system uses ancillary data style 4824 file descriptor passing]) 4825fi 4826 4827AC_CACHE_CHECK([if libc defines __progname], ac_cv_libc_defines___progname, [ 4828 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]], 4829 [[ extern char *__progname; printf("%s", __progname); ]])], 4830 [ ac_cv_libc_defines___progname="yes" ], 4831 [ ac_cv_libc_defines___progname="no" 4832 ]) 4833]) 4834if test "x$ac_cv_libc_defines___progname" = "xyes" ; then 4835 AC_DEFINE([HAVE___PROGNAME], [1], [Define if libc defines __progname]) 4836fi 4837 4838AC_CACHE_CHECK([whether $CC implements __FUNCTION__], ac_cv_cc_implements___FUNCTION__, [ 4839 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]], 4840 [[ printf("%s", __FUNCTION__); ]])], 4841 [ ac_cv_cc_implements___FUNCTION__="yes" ], 4842 [ ac_cv_cc_implements___FUNCTION__="no" 4843 ]) 4844]) 4845if test "x$ac_cv_cc_implements___FUNCTION__" = "xyes" ; then 4846 AC_DEFINE([HAVE___FUNCTION__], [1], 4847 [Define if compiler implements __FUNCTION__]) 4848fi 4849 4850AC_CACHE_CHECK([whether $CC implements __func__], ac_cv_cc_implements___func__, [ 4851 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]], 4852 [[ printf("%s", __func__); ]])], 4853 [ ac_cv_cc_implements___func__="yes" ], 4854 [ ac_cv_cc_implements___func__="no" 4855 ]) 4856]) 4857if test "x$ac_cv_cc_implements___func__" = "xyes" ; then 4858 AC_DEFINE([HAVE___func__], [1], [Define if compiler implements __func__]) 4859fi 4860 4861AC_CACHE_CHECK([whether va_copy exists], ac_cv_have_va_copy, [ 4862 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 4863#include <stdarg.h> 4864va_list x,y; 4865 ]], [[ va_copy(x,y); ]])], 4866 [ ac_cv_have_va_copy="yes" ], 4867 [ ac_cv_have_va_copy="no" 4868 ]) 4869]) 4870if test "x$ac_cv_have_va_copy" = "xyes" ; then 4871 AC_DEFINE([HAVE_VA_COPY], [1], [Define if va_copy exists]) 4872fi 4873 4874AC_CACHE_CHECK([whether __va_copy exists], ac_cv_have___va_copy, [ 4875 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 4876#include <stdarg.h> 4877va_list x,y; 4878 ]], [[ __va_copy(x,y); ]])], 4879 [ ac_cv_have___va_copy="yes" ], [ ac_cv_have___va_copy="no" 4880 ]) 4881]) 4882if test "x$ac_cv_have___va_copy" = "xyes" ; then 4883 AC_DEFINE([HAVE___VA_COPY], [1], [Define if __va_copy exists]) 4884fi 4885 4886AC_CACHE_CHECK([whether getopt has optreset support], 4887 ac_cv_have_getopt_optreset, [ 4888 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <getopt.h> ]], 4889 [[ extern int optreset; optreset = 0; ]])], 4890 [ ac_cv_have_getopt_optreset="yes" ], 4891 [ ac_cv_have_getopt_optreset="no" 4892 ]) 4893]) 4894if test "x$ac_cv_have_getopt_optreset" = "xyes" ; then 4895 AC_DEFINE([HAVE_GETOPT_OPTRESET], [1], 4896 [Define if your getopt(3) defines and uses optreset]) 4897fi 4898 4899AC_CACHE_CHECK([if libc defines sys_errlist], ac_cv_libc_defines_sys_errlist, [ 4900 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]], 4901[[ extern const char *const sys_errlist[]; printf("%s", sys_errlist[0]);]])], 4902 [ ac_cv_libc_defines_sys_errlist="yes" ], 4903 [ ac_cv_libc_defines_sys_errlist="no" 4904 ]) 4905]) 4906if test "x$ac_cv_libc_defines_sys_errlist" = "xyes" ; then 4907 AC_DEFINE([HAVE_SYS_ERRLIST], [1], 4908 [Define if your system defines sys_errlist[]]) 4909fi 4910 4911 4912AC_CACHE_CHECK([if libc defines sys_nerr], ac_cv_libc_defines_sys_nerr, [ 4913 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]], 4914[[ extern int sys_nerr; printf("%i", sys_nerr);]])], 4915 [ ac_cv_libc_defines_sys_nerr="yes" ], 4916 [ ac_cv_libc_defines_sys_nerr="no" 4917 ]) 4918]) 4919if test "x$ac_cv_libc_defines_sys_nerr" = "xyes" ; then 4920 AC_DEFINE([HAVE_SYS_NERR], [1], [Define if your system defines sys_nerr]) 4921fi 4922 4923# Check libraries needed by DNS fingerprint support 4924AC_SEARCH_LIBS([getrrsetbyname], [resolv], 4925 [AC_DEFINE([HAVE_GETRRSETBYNAME], [1], 4926 [Define if getrrsetbyname() exists])], 4927 [ 4928 # Needed by our getrrsetbyname() 4929 AC_SEARCH_LIBS([res_query], [resolv]) 4930 AC_SEARCH_LIBS([dn_expand], [resolv]) 4931 AC_MSG_CHECKING([if res_query will link]) 4932 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 4933#include <sys/types.h> 4934#include <netinet/in.h> 4935#include <arpa/nameser.h> 4936#include <netdb.h> 4937#include <resolv.h> 4938 ]], [[ 4939 res_query (0, 0, 0, 0, 0); 4940 ]])], 4941 AC_MSG_RESULT([yes]), 4942 [AC_MSG_RESULT([no]) 4943 saved_LIBS="$LIBS" 4944 LIBS="$LIBS -lresolv" 4945 AC_MSG_CHECKING([for res_query in -lresolv]) 4946 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 4947#include <sys/types.h> 4948#include <netinet/in.h> 4949#include <arpa/nameser.h> 4950#include <netdb.h> 4951#include <resolv.h> 4952 ]], [[ 4953 res_query (0, 0, 0, 0, 0); 4954 ]])], 4955 [AC_MSG_RESULT([yes])], 4956 [LIBS="$saved_LIBS" 4957 AC_MSG_RESULT([no])]) 4958 ]) 4959 AC_CHECK_FUNCS([_getshort _getlong]) 4960 AC_CHECK_DECLS([_getshort, _getlong], , , 4961 [#include <sys/types.h> 4962 #include <arpa/nameser.h>]) 4963 AC_CHECK_MEMBER([HEADER.ad], 4964 [AC_DEFINE([HAVE_HEADER_AD], [1], 4965 [Define if HEADER.ad exists in arpa/nameser.h])], , 4966 [#include <arpa/nameser.h>]) 4967 ]) 4968 4969AC_MSG_CHECKING([if struct __res_state _res is an extern]) 4970AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 4971#include <stdio.h> 4972#if HAVE_SYS_TYPES_H 4973# include <sys/types.h> 4974#endif 4975#include <netinet/in.h> 4976#include <arpa/nameser.h> 4977#include <resolv.h> 4978extern struct __res_state _res; 4979 ]], [[ 4980struct __res_state *volatile p = &_res; /* force resolution of _res */ 4981return 0; 4982 ]],)], 4983 [AC_MSG_RESULT([yes]) 4984 AC_DEFINE([HAVE__RES_EXTERN], [1], 4985 [Define if you have struct __res_state _res as an extern]) 4986 ], 4987 [ AC_MSG_RESULT([no]) ] 4988) 4989 4990# Check whether user wants SELinux support 4991SELINUX_MSG="no" 4992LIBSELINUX="" 4993AC_ARG_WITH([selinux], 4994 [ --with-selinux Enable SELinux support], 4995 [ if test "x$withval" != "xno" ; then 4996 save_LIBS="$LIBS" 4997 AC_DEFINE([WITH_SELINUX], [1], 4998 [Define if you want SELinux support.]) 4999 SELINUX_MSG="yes" 5000 AC_CHECK_HEADER([selinux/selinux.h], , 5001 AC_MSG_ERROR([SELinux support requires selinux.h header])) 5002 AC_CHECK_LIB([selinux], [setexeccon], 5003 [ LIBSELINUX="-lselinux" 5004 LIBS="$LIBS -lselinux" 5005 ], 5006 AC_MSG_ERROR([SELinux support requires libselinux library])) 5007 AC_CHECK_FUNCS([getseuserbyname get_default_context_with_level]) 5008 LIBS="$save_LIBS $LIBSELINUX" 5009 fi ] 5010) 5011AC_SUBST([SSHDLIBS]) 5012 5013# Check whether user wants Kerberos 5 support 5014KRB5_MSG="no" 5015AC_ARG_WITH([kerberos5], 5016 [ --with-kerberos5=PATH Enable Kerberos 5 support], 5017 [ if test "x$withval" != "xno" ; then 5018 if test "x$withval" = "xyes" ; then 5019 KRB5ROOT="/usr/local" 5020 else 5021 KRB5ROOT=${withval} 5022 fi 5023 5024 AC_DEFINE([KRB5], [1], [Define if you want Kerberos 5 support]) 5025 KRB5_MSG="yes" 5026 5027 use_pkgconfig_for_krb5= 5028 if test "x$PKGCONFIG" != "xno"; then 5029 AC_MSG_CHECKING([if $PKGCONFIG knows about kerberos5]) 5030 if "$PKGCONFIG" krb5; then 5031 AC_MSG_RESULT([yes]) 5032 use_pkgconfig_for_krb5=yes 5033 else 5034 AC_MSG_RESULT([no]) 5035 fi 5036 fi 5037 if test "x$use_pkgconfig_for_krb5" = "xyes"; then 5038 K5CFLAGS=`$PKGCONFIG --cflags krb5` 5039 K5LIBS=`$PKGCONFIG --libs krb5` 5040 CPPFLAGS="$CPPFLAGS $K5CFLAGS" 5041 5042 AC_MSG_CHECKING([for gssapi support]) 5043 if "$PKGCONFIG" krb5-gssapi; then 5044 AC_MSG_RESULT([yes]) 5045 AC_DEFINE([GSSAPI], [1], 5046 [Define this if you want GSSAPI 5047 support in the version 2 protocol]) 5048 GSSCFLAGS="`$PKGCONFIG --cflags krb5-gssapi`" 5049 GSSLIBS="`$PKGCONFIG --libs krb5-gssapi`" 5050 CPPFLAGS="$CPPFLAGS $GSSCFLAGS" 5051 else 5052 AC_MSG_RESULT([no]) 5053 fi 5054 AC_MSG_CHECKING([whether we are using Heimdal]) 5055 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <krb5.h> 5056 ]], [[ char *tmp = heimdal_version; ]])], 5057 [ AC_MSG_RESULT([yes]) 5058 AC_DEFINE([HEIMDAL], [1], 5059 [Define this if you are using the Heimdal 5060 version of Kerberos V5]) ], 5061 [AC_MSG_RESULT([no]) 5062 ]) 5063 else 5064 AC_PATH_TOOL([KRB5CONF], [krb5-config], 5065 [$KRB5ROOT/bin/krb5-config], 5066 [$KRB5ROOT/bin:$PATH]) 5067 if test -x $KRB5CONF ; then 5068 K5CFLAGS="`$KRB5CONF --cflags`" 5069 K5LIBS="`$KRB5CONF --libs`" 5070 CPPFLAGS="$CPPFLAGS $K5CFLAGS" 5071 5072 AC_MSG_CHECKING([for gssapi support]) 5073 if $KRB5CONF | grep gssapi >/dev/null ; then 5074 AC_MSG_RESULT([yes]) 5075 AC_DEFINE([GSSAPI], [1], 5076 [Define this if you want GSSAPI 5077 support in the version 2 protocol]) 5078 GSSCFLAGS="`$KRB5CONF --cflags gssapi`" 5079 GSSLIBS="`$KRB5CONF --libs gssapi`" 5080 CPPFLAGS="$CPPFLAGS $GSSCFLAGS" 5081 else 5082 AC_MSG_RESULT([no]) 5083 fi 5084 AC_MSG_CHECKING([whether we are using Heimdal]) 5085 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <krb5.h> 5086 ]], [[ char *tmp = heimdal_version; ]])], 5087 [ AC_MSG_RESULT([yes]) 5088 AC_DEFINE([HEIMDAL], [1], 5089 [Define this if you are using the Heimdal 5090 version of Kerberos V5]) ], 5091 [AC_MSG_RESULT([no]) 5092 ]) 5093 else 5094 CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include" 5095 LDFLAGS="$LDFLAGS -L${KRB5ROOT}/lib" 5096 AC_MSG_CHECKING([whether we are using Heimdal]) 5097 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <krb5.h> 5098 ]], [[ char *tmp = heimdal_version; ]])], 5099 [ AC_MSG_RESULT([yes]) 5100 AC_DEFINE([HEIMDAL]) 5101 K5LIBS="-lkrb5" 5102 K5LIBS="$K5LIBS -lcom_err -lasn1" 5103 AC_CHECK_LIB([roken], [net_write], 5104 [K5LIBS="$K5LIBS -lroken"]) 5105 AC_CHECK_LIB([des], [des_cbc_encrypt], 5106 [K5LIBS="$K5LIBS -ldes"]) 5107 ], [ AC_MSG_RESULT([no]) 5108 K5LIBS="-lkrb5 -lk5crypto -lcom_err" 5109 ]) 5110 AC_SEARCH_LIBS([dn_expand], [resolv]) 5111 5112 AC_CHECK_LIB([gssapi_krb5], [gss_init_sec_context], 5113 [ AC_DEFINE([GSSAPI]) 5114 GSSLIBS="-lgssapi_krb5" ], 5115 [ AC_CHECK_LIB([gssapi], [gss_init_sec_context], 5116 [ AC_DEFINE([GSSAPI]) 5117 GSSLIBS="-lgssapi" ], 5118 [ AC_CHECK_LIB([gss], [gss_init_sec_context], 5119 [ AC_DEFINE([GSSAPI]) 5120 GSSLIBS="-lgss" ], 5121 AC_MSG_WARN([Cannot find any suitable gss-api library - build may fail])) 5122 ]) 5123 ]) 5124 5125 AC_CHECK_HEADER([gssapi.h], , 5126 [ unset ac_cv_header_gssapi_h 5127 CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi" 5128 AC_CHECK_HEADERS([gssapi.h], , 5129 AC_MSG_WARN([Cannot find any suitable gss-api header - build may fail]) 5130 ) 5131 ] 5132 ) 5133 5134 oldCPP="$CPPFLAGS" 5135 CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi" 5136 AC_CHECK_HEADER([gssapi_krb5.h], , 5137 [ CPPFLAGS="$oldCPP" ]) 5138 5139 fi 5140 fi 5141 if test -n "${rpath_opt}" ; then 5142 LDFLAGS="$LDFLAGS ${rpath_opt}${KRB5ROOT}/lib" 5143 fi 5144 if test ! -z "$blibpath" ; then 5145 blibpath="$blibpath:${KRB5ROOT}/lib" 5146 fi 5147 5148 AC_CHECK_HEADERS([gssapi.h gssapi/gssapi.h]) 5149 AC_CHECK_HEADERS([gssapi_krb5.h gssapi/gssapi_krb5.h]) 5150 AC_CHECK_HEADERS([gssapi_generic.h gssapi/gssapi_generic.h]) 5151 5152 AC_SEARCH_LIBS([k_hasafs], [kafs], [AC_DEFINE([USE_AFS], [1], 5153 [Define this if you want to use libkafs' AFS support])]) 5154 5155 AC_CHECK_DECLS([GSS_C_NT_HOSTBASED_SERVICE], [], [], [[ 5156#ifdef HAVE_GSSAPI_H 5157# include <gssapi.h> 5158#elif defined(HAVE_GSSAPI_GSSAPI_H) 5159# include <gssapi/gssapi.h> 5160#endif 5161 5162#ifdef HAVE_GSSAPI_GENERIC_H 5163# include <gssapi_generic.h> 5164#elif defined(HAVE_GSSAPI_GSSAPI_GENERIC_H) 5165# include <gssapi/gssapi_generic.h> 5166#endif 5167 ]]) 5168 saved_LIBS="$LIBS" 5169 LIBS="$LIBS $K5LIBS" 5170 AC_CHECK_FUNCS([krb5_cc_new_unique krb5_get_error_message krb5_free_error_message]) 5171 LIBS="$saved_LIBS" 5172 5173 fi 5174 ] 5175) 5176AC_SUBST([GSSLIBS]) 5177AC_SUBST([K5LIBS]) 5178AC_SUBST([CHANNELLIBS]) 5179 5180# Looking for programs, paths and files 5181 5182PRIVSEP_PATH=/var/empty 5183AC_ARG_WITH([privsep-path], 5184 [ --with-privsep-path=xxx Path for privilege separation chroot (default=/var/empty)], 5185 [ 5186 if test -n "$withval" && test "x$withval" != "xno" && \ 5187 test "x${withval}" != "xyes"; then 5188 PRIVSEP_PATH=$withval 5189 fi 5190 ] 5191) 5192AC_SUBST([PRIVSEP_PATH]) 5193 5194AC_ARG_WITH([xauth], 5195 [ --with-xauth=PATH Specify path to xauth program ], 5196 [ 5197 if test -n "$withval" && test "x$withval" != "xno" && \ 5198 test "x${withval}" != "xyes"; then 5199 xauth_path=$withval 5200 fi 5201 ], 5202 [ 5203 TestPath="$PATH" 5204 TestPath="${TestPath}${PATH_SEPARATOR}/usr/X/bin" 5205 TestPath="${TestPath}${PATH_SEPARATOR}/usr/bin/X11" 5206 TestPath="${TestPath}${PATH_SEPARATOR}/usr/X11R6/bin" 5207 TestPath="${TestPath}${PATH_SEPARATOR}/usr/openwin/bin" 5208 AC_PATH_PROG([xauth_path], [xauth], , [$TestPath]) 5209 if (test ! -z "$xauth_path" && test -x "/usr/openwin/bin/xauth") ; then 5210 xauth_path="/usr/openwin/bin/xauth" 5211 fi 5212 ] 5213) 5214 5215STRIP_OPT=-s 5216AC_ARG_ENABLE([strip], 5217 [ --disable-strip Disable calling strip(1) on install], 5218 [ 5219 if test "x$enableval" = "xno" ; then 5220 STRIP_OPT= 5221 fi 5222 ] 5223) 5224AC_SUBST([STRIP_OPT]) 5225 5226if test -z "$xauth_path" ; then 5227 XAUTH_PATH="undefined" 5228 AC_SUBST([XAUTH_PATH]) 5229else 5230 AC_DEFINE_UNQUOTED([XAUTH_PATH], ["$xauth_path"], 5231 [Define if xauth is found in your path]) 5232 XAUTH_PATH=$xauth_path 5233 AC_SUBST([XAUTH_PATH]) 5234fi 5235 5236dnl # --with-maildir=/path/to/mail gets top priority. 5237dnl # if maildir is set in the platform case statement above we use that. 5238dnl # Otherwise we run a program to get the dir from system headers. 5239dnl # We first look for _PATH_MAILDIR then MAILDIR then _PATH_MAIL 5240dnl # If we find _PATH_MAILDIR we do nothing because that is what 5241dnl # session.c expects anyway. Otherwise we set to the value found 5242dnl # stripping any trailing slash. If for some strage reason our program 5243dnl # does not find what it needs, we default to /var/spool/mail. 5244# Check for mail directory 5245AC_ARG_WITH([maildir], 5246 [ --with-maildir=/path/to/mail Specify your system mail directory], 5247 [ 5248 if test "X$withval" != X && test "x$withval" != xno && \ 5249 test "x${withval}" != xyes; then 5250 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$withval"], 5251 [Set this to your mail directory if you do not have _PATH_MAILDIR]) 5252 fi 5253 ],[ 5254 if test "X$maildir" != "X"; then 5255 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$maildir"]) 5256 else 5257 AC_MSG_CHECKING([Discovering system mail directory]) 5258 AC_RUN_IFELSE( 5259 [AC_LANG_PROGRAM([[ 5260#include <stdio.h> 5261#include <stdlib.h> 5262#include <string.h> 5263#ifdef HAVE_PATHS_H 5264#include <paths.h> 5265#endif 5266#ifdef HAVE_MAILLOCK_H 5267#include <maillock.h> 5268#endif 5269#define DATA "conftest.maildir" 5270 ]], [[ 5271 FILE *fd; 5272 int rc; 5273 5274 fd = fopen(DATA,"w"); 5275 if(fd == NULL) 5276 exit(1); 5277 5278#if defined (_PATH_MAILDIR) 5279 if ((rc = fprintf(fd ,"_PATH_MAILDIR:%s\n", _PATH_MAILDIR)) <0) 5280 exit(1); 5281#elif defined (MAILDIR) 5282 if ((rc = fprintf(fd ,"MAILDIR:%s\n", MAILDIR)) <0) 5283 exit(1); 5284#elif defined (_PATH_MAIL) 5285 if ((rc = fprintf(fd ,"_PATH_MAIL:%s\n", _PATH_MAIL)) <0) 5286 exit(1); 5287#else 5288 exit (2); 5289#endif 5290 5291 exit(0); 5292 ]])], 5293 [ 5294 maildir_what=`awk -F: '{print $1}' conftest.maildir` 5295 maildir=`awk -F: '{print $2}' conftest.maildir \ 5296 | sed 's|/$||'` 5297 AC_MSG_RESULT([Using: $maildir from $maildir_what]) 5298 if test "x$maildir_what" != "x_PATH_MAILDIR"; then 5299 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$maildir"]) 5300 fi 5301 ], 5302 [ 5303 if test "X$ac_status" = "X2";then 5304# our test program didn't find it. Default to /var/spool/mail 5305 AC_MSG_RESULT([Using: default value of /var/spool/mail]) 5306 AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["/var/spool/mail"]) 5307 else 5308 AC_MSG_RESULT([*** not found ***]) 5309 fi 5310 ], 5311 [ 5312 AC_MSG_WARN([cross compiling: use --with-maildir=/path/to/mail]) 5313 ] 5314 ) 5315 fi 5316 ] 5317) # maildir 5318 5319if test ! -z "$cross_compiling" && test "x$cross_compiling" = "xyes"; then 5320 AC_MSG_WARN([cross compiling: Disabling /dev/ptmx test]) 5321 disable_ptmx_check=yes 5322fi 5323if test -z "$no_dev_ptmx" ; then 5324 if test "x$disable_ptmx_check" != "xyes" ; then 5325 AC_CHECK_FILE(["/dev/ptmx"], 5326 [ 5327 AC_DEFINE_UNQUOTED([HAVE_DEV_PTMX], [1], 5328 [Define if you have /dev/ptmx]) 5329 have_dev_ptmx=1 5330 ] 5331 ) 5332 fi 5333fi 5334 5335if test ! -z "$cross_compiling" && test "x$cross_compiling" != "xyes"; then 5336 AC_CHECK_FILE(["/dev/ptc"], 5337 [ 5338 AC_DEFINE_UNQUOTED([HAVE_DEV_PTS_AND_PTC], [1], 5339 [Define if you have /dev/ptc]) 5340 have_dev_ptc=1 5341 ] 5342 ) 5343else 5344 AC_MSG_WARN([cross compiling: Disabling /dev/ptc test]) 5345fi 5346 5347# Options from here on. Some of these are preset by platform above 5348AC_ARG_WITH([mantype], 5349 [ --with-mantype=man|cat|doc Set man page type], 5350 [ 5351 case "$withval" in 5352 man|cat|doc) 5353 MANTYPE=$withval 5354 ;; 5355 *) 5356 AC_MSG_ERROR([invalid man type: $withval]) 5357 ;; 5358 esac 5359 ] 5360) 5361if test -z "$MANTYPE"; then 5362 if ${MANDOC} ${srcdir}/ssh.1 >/dev/null 2>&1; then 5363 MANTYPE=doc 5364 elif ${NROFF} -mdoc ${srcdir}/ssh.1 >/dev/null 2>&1; then 5365 MANTYPE=doc 5366 elif ${NROFF} -man ${srcdir}/ssh.1 >/dev/null 2>&1; then 5367 MANTYPE=man 5368 else 5369 MANTYPE=cat 5370 fi 5371fi 5372AC_SUBST([MANTYPE]) 5373if test "$MANTYPE" = "doc"; then 5374 mansubdir=man; 5375else 5376 mansubdir=$MANTYPE; 5377fi 5378AC_SUBST([mansubdir]) 5379 5380# Whether to disable shadow password support 5381AC_ARG_WITH([shadow], 5382 [ --without-shadow Disable shadow password support], 5383 [ 5384 if test "x$withval" = "xno" ; then 5385 AC_DEFINE([DISABLE_SHADOW]) 5386 disable_shadow=yes 5387 fi 5388 ] 5389) 5390 5391if test -z "$disable_shadow" ; then 5392 AC_MSG_CHECKING([if the systems has expire shadow information]) 5393 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 5394#include <sys/types.h> 5395#include <shadow.h> 5396struct spwd sp; 5397 ]], [[ sp.sp_expire = sp.sp_lstchg = sp.sp_inact = 0; ]])], 5398 [ sp_expire_available=yes ], [ 5399 ]) 5400 5401 if test "x$sp_expire_available" = "xyes" ; then 5402 AC_MSG_RESULT([yes]) 5403 AC_DEFINE([HAS_SHADOW_EXPIRE], [1], 5404 [Define if you want to use shadow password expire field]) 5405 else 5406 AC_MSG_RESULT([no]) 5407 fi 5408fi 5409 5410# Use ip address instead of hostname in $DISPLAY 5411if test ! -z "$IPADDR_IN_DISPLAY" ; then 5412 DISPLAY_HACK_MSG="yes" 5413 AC_DEFINE([IPADDR_IN_DISPLAY], [1], 5414 [Define if you need to use IP address 5415 instead of hostname in $DISPLAY]) 5416else 5417 DISPLAY_HACK_MSG="no" 5418 AC_ARG_WITH([ipaddr-display], 5419 [ --with-ipaddr-display Use ip address instead of hostname in $DISPLAY], 5420 [ 5421 if test "x$withval" != "xno" ; then 5422 AC_DEFINE([IPADDR_IN_DISPLAY]) 5423 DISPLAY_HACK_MSG="yes" 5424 fi 5425 ] 5426 ) 5427fi 5428 5429# check for /etc/default/login and use it if present. 5430AC_ARG_ENABLE([etc-default-login], 5431 [ --disable-etc-default-login Disable using PATH from /etc/default/login [no]], 5432 [ if test "x$enableval" = "xno"; then 5433 AC_MSG_NOTICE([/etc/default/login handling disabled]) 5434 etc_default_login=no 5435 else 5436 etc_default_login=yes 5437 fi ], 5438 [ if test ! -z "$cross_compiling" && test "x$cross_compiling" = "xyes"; 5439 then 5440 AC_MSG_WARN([cross compiling: not checking /etc/default/login]) 5441 etc_default_login=no 5442 else 5443 etc_default_login=yes 5444 fi ] 5445) 5446 5447if test "x$etc_default_login" != "xno"; then 5448 AC_CHECK_FILE(["/etc/default/login"], 5449 [ external_path_file=/etc/default/login ]) 5450 if test "x$external_path_file" = "x/etc/default/login"; then 5451 AC_DEFINE([HAVE_ETC_DEFAULT_LOGIN], [1], 5452 [Define if your system has /etc/default/login]) 5453 fi 5454fi 5455 5456dnl BSD systems use /etc/login.conf so --with-default-path= has no effect 5457if test $ac_cv_func_login_getcapbool = "yes" && \ 5458 test $ac_cv_header_login_cap_h = "yes" ; then 5459 external_path_file=/etc/login.conf 5460fi 5461 5462# Whether to mess with the default path 5463SERVER_PATH_MSG="(default)" 5464AC_ARG_WITH([default-path], 5465 [ --with-default-path= Specify default $PATH environment for server], 5466 [ 5467 if test "x$external_path_file" = "x/etc/login.conf" ; then 5468 AC_MSG_WARN([ 5469--with-default-path=PATH has no effect on this system. 5470Edit /etc/login.conf instead.]) 5471 elif test "x$withval" != "xno" ; then 5472 if test ! -z "$external_path_file" ; then 5473 AC_MSG_WARN([ 5474--with-default-path=PATH will only be used if PATH is not defined in 5475$external_path_file .]) 5476 fi 5477 user_path="$withval" 5478 SERVER_PATH_MSG="$withval" 5479 fi 5480 ], 5481 [ if test "x$external_path_file" = "x/etc/login.conf" ; then 5482 AC_MSG_WARN([Make sure the path to scp is in /etc/login.conf]) 5483 else 5484 if test ! -z "$external_path_file" ; then 5485 AC_MSG_WARN([ 5486If PATH is defined in $external_path_file, ensure the path to scp is included, 5487otherwise scp will not work.]) 5488 fi 5489 AC_RUN_IFELSE( 5490 [AC_LANG_PROGRAM([[ 5491/* find out what STDPATH is */ 5492#include <stdio.h> 5493#include <stdlib.h> 5494#ifdef HAVE_PATHS_H 5495# include <paths.h> 5496#endif 5497#ifndef _PATH_STDPATH 5498# ifdef _PATH_USERPATH /* Irix */ 5499# define _PATH_STDPATH _PATH_USERPATH 5500# else 5501# define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin" 5502# endif 5503#endif 5504#include <sys/types.h> 5505#include <sys/stat.h> 5506#include <fcntl.h> 5507#define DATA "conftest.stdpath" 5508 ]], [[ 5509 FILE *fd; 5510 int rc; 5511 5512 fd = fopen(DATA,"w"); 5513 if(fd == NULL) 5514 exit(1); 5515 5516 if ((rc = fprintf(fd,"%s", _PATH_STDPATH)) < 0) 5517 exit(1); 5518 5519 exit(0); 5520 ]])], 5521 [ user_path=`cat conftest.stdpath` ], 5522 [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ], 5523 [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ] 5524 ) 5525# make sure $bindir is in USER_PATH so scp will work 5526 t_bindir="${bindir}" 5527 while echo "${t_bindir}" | egrep '\$\{|NONE/' >/dev/null 2>&1; do 5528 t_bindir=`eval echo ${t_bindir}` 5529 case $t_bindir in 5530 NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$prefix~"` ;; 5531 esac 5532 case $t_bindir in 5533 NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$ac_default_prefix~"` ;; 5534 esac 5535 done 5536 echo $user_path | grep ":$t_bindir" > /dev/null 2>&1 5537 if test $? -ne 0 ; then 5538 echo $user_path | grep "^$t_bindir" > /dev/null 2>&1 5539 if test $? -ne 0 ; then 5540 user_path=$user_path:$t_bindir 5541 AC_MSG_RESULT([Adding $t_bindir to USER_PATH so scp will work]) 5542 fi 5543 fi 5544 fi ] 5545) 5546if test "x$external_path_file" != "x/etc/login.conf" ; then 5547 AC_DEFINE_UNQUOTED([USER_PATH], ["$user_path"], [Specify default $PATH]) 5548 AC_SUBST([user_path]) 5549fi 5550 5551# Set superuser path separately to user path 5552AC_ARG_WITH([superuser-path], 5553 [ --with-superuser-path= Specify different path for super-user], 5554 [ 5555 if test -n "$withval" && test "x$withval" != "xno" && \ 5556 test "x${withval}" != "xyes"; then 5557 AC_DEFINE_UNQUOTED([SUPERUSER_PATH], ["$withval"], 5558 [Define if you want a different $PATH 5559 for the superuser]) 5560 superuser_path=$withval 5561 fi 5562 ] 5563) 5564 5565 5566AC_MSG_CHECKING([if we need to convert IPv4 in IPv6-mapped addresses]) 5567IPV4_IN6_HACK_MSG="no" 5568AC_ARG_WITH(4in6, 5569 [ --with-4in6 Check for and convert IPv4 in IPv6 mapped addresses], 5570 [ 5571 if test "x$withval" != "xno" ; then 5572 AC_MSG_RESULT([yes]) 5573 AC_DEFINE([IPV4_IN_IPV6], [1], 5574 [Detect IPv4 in IPv6 mapped addresses 5575 and treat as IPv4]) 5576 IPV4_IN6_HACK_MSG="yes" 5577 else 5578 AC_MSG_RESULT([no]) 5579 fi 5580 ], [ 5581 if test "x$inet6_default_4in6" = "xyes"; then 5582 AC_MSG_RESULT([yes (default)]) 5583 AC_DEFINE([IPV4_IN_IPV6]) 5584 IPV4_IN6_HACK_MSG="yes" 5585 else 5586 AC_MSG_RESULT([no (default)]) 5587 fi 5588 ] 5589) 5590 5591# Whether to enable BSD auth support 5592BSD_AUTH_MSG=no 5593AC_ARG_WITH([bsd-auth], 5594 [ --with-bsd-auth Enable BSD auth support], 5595 [ 5596 if test "x$withval" != "xno" ; then 5597 AC_DEFINE([BSD_AUTH], [1], 5598 [Define if you have BSD auth support]) 5599 BSD_AUTH_MSG=yes 5600 fi 5601 ] 5602) 5603 5604# Where to place sshd.pid 5605piddir=/var/run 5606# make sure the directory exists 5607if test ! -d $piddir ; then 5608 piddir=`eval echo ${sysconfdir}` 5609 case $piddir in 5610 NONE/*) piddir=`echo $piddir | sed "s~NONE~$ac_default_prefix~"` ;; 5611 esac 5612fi 5613 5614AC_ARG_WITH([pid-dir], 5615 [ --with-pid-dir=PATH Specify location of sshd.pid file], 5616 [ 5617 if test -n "$withval" && test "x$withval" != "xno" && \ 5618 test "x${withval}" != "xyes"; then 5619 piddir=$withval 5620 if test ! -d $piddir ; then 5621 AC_MSG_WARN([** no $piddir directory on this system **]) 5622 fi 5623 fi 5624 ] 5625) 5626 5627AC_DEFINE_UNQUOTED([_PATH_SSH_PIDDIR], ["$piddir"], 5628 [Specify location of ssh.pid]) 5629AC_SUBST([piddir]) 5630 5631 5632AC_ARG_ENABLE([fd-passing], 5633 [ --disable-fd-passing disable file descriptor passsing [no]], 5634 [ 5635 if test "x$enableval" = "xno" ; then 5636 AC_DEFINE([DISABLE_FD_PASSING]) 5637 fi 5638 ] 5639) 5640 5641dnl allow user to disable some login recording features 5642AC_ARG_ENABLE([lastlog], 5643 [ --disable-lastlog disable use of lastlog even if detected [no]], 5644 [ 5645 if test "x$enableval" = "xno" ; then 5646 AC_DEFINE([DISABLE_LASTLOG]) 5647 fi 5648 ] 5649) 5650AC_ARG_ENABLE([utmp], 5651 [ --disable-utmp disable use of utmp even if detected [no]], 5652 [ 5653 if test "x$enableval" = "xno" ; then 5654 AC_DEFINE([DISABLE_UTMP]) 5655 fi 5656 ] 5657) 5658AC_ARG_ENABLE([utmpx], 5659 [ --disable-utmpx disable use of utmpx even if detected [no]], 5660 [ 5661 if test "x$enableval" = "xno" ; then 5662 AC_DEFINE([DISABLE_UTMPX], [1], 5663 [Define if you don't want to use utmpx]) 5664 fi 5665 ] 5666) 5667AC_ARG_ENABLE([wtmp], 5668 [ --disable-wtmp disable use of wtmp even if detected [no]], 5669 [ 5670 if test "x$enableval" = "xno" ; then 5671 AC_DEFINE([DISABLE_WTMP]) 5672 fi 5673 ] 5674) 5675AC_ARG_ENABLE([wtmpx], 5676 [ --disable-wtmpx disable use of wtmpx even if detected [no]], 5677 [ 5678 if test "x$enableval" = "xno" ; then 5679 AC_DEFINE([DISABLE_WTMPX], [1], 5680 [Define if you don't want to use wtmpx]) 5681 fi 5682 ] 5683) 5684AC_ARG_ENABLE([libutil], 5685 [ --disable-libutil disable use of libutil (login() etc.) [no]], 5686 [ 5687 if test "x$enableval" = "xno" ; then 5688 AC_DEFINE([DISABLE_LOGIN]) 5689 fi 5690 ] 5691) 5692AC_ARG_ENABLE([pututline], 5693 [ --disable-pututline disable use of pututline() etc. ([uw]tmp) [no]], 5694 [ 5695 if test "x$enableval" = "xno" ; then 5696 AC_DEFINE([DISABLE_PUTUTLINE], [1], 5697 [Define if you don't want to use pututline() 5698 etc. to write [uw]tmp]) 5699 fi 5700 ] 5701) 5702AC_ARG_ENABLE([pututxline], 5703 [ --disable-pututxline disable use of pututxline() etc. ([uw]tmpx) [no]], 5704 [ 5705 if test "x$enableval" = "xno" ; then 5706 AC_DEFINE([DISABLE_PUTUTXLINE], [1], 5707 [Define if you don't want to use pututxline() 5708 etc. to write [uw]tmpx]) 5709 fi 5710 ] 5711) 5712AC_ARG_WITH([lastlog], 5713 [ --with-lastlog=FILE|DIR specify lastlog location [common locations]], 5714 [ 5715 if test "x$withval" = "xno" ; then 5716 AC_DEFINE([DISABLE_LASTLOG]) 5717 elif test -n "$withval" && test "x${withval}" != "xyes"; then 5718 conf_lastlog_location=$withval 5719 fi 5720 ] 5721) 5722 5723dnl lastlog, [uw]tmpx? detection 5724dnl NOTE: set the paths in the platform section to avoid the 5725dnl need for command-line parameters 5726dnl lastlog and [uw]tmp are subject to a file search if all else fails 5727 5728dnl lastlog detection 5729dnl NOTE: the code itself will detect if lastlog is a directory 5730AC_MSG_CHECKING([if your system defines LASTLOG_FILE]) 5731AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 5732#include <sys/types.h> 5733#include <utmp.h> 5734#ifdef HAVE_LASTLOG_H 5735# include <lastlog.h> 5736#endif 5737#ifdef HAVE_PATHS_H 5738# include <paths.h> 5739#endif 5740#ifdef HAVE_LOGIN_H 5741# include <login.h> 5742#endif 5743 ]], [[ char *lastlog = LASTLOG_FILE; ]])], 5744 [ AC_MSG_RESULT([yes]) ], 5745 [ 5746 AC_MSG_RESULT([no]) 5747 AC_MSG_CHECKING([if your system defines _PATH_LASTLOG]) 5748 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 5749#include <sys/types.h> 5750#include <utmp.h> 5751#ifdef HAVE_LASTLOG_H 5752# include <lastlog.h> 5753#endif 5754#ifdef HAVE_PATHS_H 5755# include <paths.h> 5756#endif 5757 ]], [[ char *lastlog = _PATH_LASTLOG; ]])], 5758 [ AC_MSG_RESULT([yes]) ], 5759 [ 5760 AC_MSG_RESULT([no]) 5761 system_lastlog_path=no 5762 ]) 5763]) 5764 5765if test -z "$conf_lastlog_location"; then 5766 if test x"$system_lastlog_path" = x"no" ; then 5767 for f in /var/log/lastlog /usr/adm/lastlog /var/adm/lastlog /etc/security/lastlog ; do 5768 if (test -d "$f" || test -f "$f") ; then 5769 conf_lastlog_location=$f 5770 fi 5771 done 5772 if test -z "$conf_lastlog_location"; then 5773 AC_MSG_WARN([** Cannot find lastlog **]) 5774 dnl Don't define DISABLE_LASTLOG - that means we don't try wtmp/wtmpx 5775 fi 5776 fi 5777fi 5778 5779if test -n "$conf_lastlog_location"; then 5780 AC_DEFINE_UNQUOTED([CONF_LASTLOG_FILE], ["$conf_lastlog_location"], 5781 [Define if you want to specify the path to your lastlog file]) 5782fi 5783 5784dnl utmp detection 5785AC_MSG_CHECKING([if your system defines UTMP_FILE]) 5786AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 5787#include <sys/types.h> 5788#include <utmp.h> 5789#ifdef HAVE_PATHS_H 5790# include <paths.h> 5791#endif 5792 ]], [[ char *utmp = UTMP_FILE; ]])], 5793 [ AC_MSG_RESULT([yes]) ], 5794 [ AC_MSG_RESULT([no]) 5795 system_utmp_path=no 5796]) 5797if test -z "$conf_utmp_location"; then 5798 if test x"$system_utmp_path" = x"no" ; then 5799 for f in /etc/utmp /usr/adm/utmp /var/run/utmp; do 5800 if test -f $f ; then 5801 conf_utmp_location=$f 5802 fi 5803 done 5804 if test -z "$conf_utmp_location"; then 5805 AC_DEFINE([DISABLE_UTMP]) 5806 fi 5807 fi 5808fi 5809if test -n "$conf_utmp_location"; then 5810 AC_DEFINE_UNQUOTED([CONF_UTMP_FILE], ["$conf_utmp_location"], 5811 [Define if you want to specify the path to your utmp file]) 5812fi 5813 5814dnl wtmp detection 5815AC_MSG_CHECKING([if your system defines WTMP_FILE]) 5816AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 5817#include <sys/types.h> 5818#include <utmp.h> 5819#ifdef HAVE_PATHS_H 5820# include <paths.h> 5821#endif 5822 ]], [[ char *wtmp = WTMP_FILE; ]])], 5823 [ AC_MSG_RESULT([yes]) ], 5824 [ AC_MSG_RESULT([no]) 5825 system_wtmp_path=no 5826]) 5827if test -z "$conf_wtmp_location"; then 5828 if test x"$system_wtmp_path" = x"no" ; then 5829 for f in /usr/adm/wtmp /var/log/wtmp; do 5830 if test -f $f ; then 5831 conf_wtmp_location=$f 5832 fi 5833 done 5834 if test -z "$conf_wtmp_location"; then 5835 AC_DEFINE([DISABLE_WTMP]) 5836 fi 5837 fi 5838fi 5839if test -n "$conf_wtmp_location"; then 5840 AC_DEFINE_UNQUOTED([CONF_WTMP_FILE], ["$conf_wtmp_location"], 5841 [Define if you want to specify the path to your wtmp file]) 5842fi 5843 5844dnl wtmpx detection 5845AC_MSG_CHECKING([if your system defines WTMPX_FILE]) 5846AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 5847#include <sys/types.h> 5848#include <utmp.h> 5849#ifdef HAVE_UTMPX_H 5850#include <utmpx.h> 5851#endif 5852#ifdef HAVE_PATHS_H 5853# include <paths.h> 5854#endif 5855 ]], [[ char *wtmpx = WTMPX_FILE; ]])], 5856 [ AC_MSG_RESULT([yes]) ], 5857 [ AC_MSG_RESULT([no]) 5858 system_wtmpx_path=no 5859]) 5860if test -z "$conf_wtmpx_location"; then 5861 if test x"$system_wtmpx_path" = x"no" ; then 5862 AC_DEFINE([DISABLE_WTMPX]) 5863 fi 5864else 5865 AC_DEFINE_UNQUOTED([CONF_WTMPX_FILE], ["$conf_wtmpx_location"], 5866 [Define if you want to specify the path to your wtmpx file]) 5867fi 5868 5869 5870if test ! -z "$blibpath" ; then 5871 LDFLAGS="$LDFLAGS $blibflags$blibpath" 5872 AC_MSG_WARN([Please check and edit blibpath in LDFLAGS in Makefile]) 5873fi 5874 5875AC_CHECK_MEMBER([struct lastlog.ll_line], [], [ 5876 if test x$SKIP_DISABLE_LASTLOG_DEFINE != "xyes" ; then 5877 AC_DEFINE([DISABLE_LASTLOG]) 5878 fi 5879 ], [ 5880#ifdef HAVE_SYS_TYPES_H 5881#include <sys/types.h> 5882#endif 5883#ifdef HAVE_UTMP_H 5884#include <utmp.h> 5885#endif 5886#ifdef HAVE_UTMPX_H 5887#include <utmpx.h> 5888#endif 5889#ifdef HAVE_LASTLOG_H 5890#include <lastlog.h> 5891#endif 5892 ]) 5893 5894AC_CHECK_MEMBER([struct utmp.ut_line], [], [ 5895 AC_DEFINE([DISABLE_UTMP]) 5896 AC_DEFINE([DISABLE_WTMP]) 5897 ], [ 5898#ifdef HAVE_SYS_TYPES_H 5899#include <sys/types.h> 5900#endif 5901#ifdef HAVE_UTMP_H 5902#include <utmp.h> 5903#endif 5904#ifdef HAVE_UTMPX_H 5905#include <utmpx.h> 5906#endif 5907#ifdef HAVE_LASTLOG_H 5908#include <lastlog.h> 5909#endif 5910 ]) 5911 5912dnl Adding -Werror to CFLAGS early prevents configure tests from running. 5913dnl Add now. 5914CFLAGS="$CFLAGS $werror_flags" 5915 5916if test "x$ac_cv_func_getaddrinfo" != "xyes" ; then 5917 TEST_SSH_IPV6=no 5918else 5919 TEST_SSH_IPV6=yes 5920fi 5921AC_CHECK_DECL([BROKEN_GETADDRINFO], [TEST_SSH_IPV6=no]) 5922AC_SUBST([TEST_SSH_IPV6], [$TEST_SSH_IPV6]) 5923AC_SUBST([TEST_SSH_UTF8], [$TEST_SSH_UTF8]) 5924AC_SUBST([TEST_MALLOC_OPTIONS], [$TEST_MALLOC_OPTIONS]) 5925AC_SUBST([UNSUPPORTED_ALGORITHMS], [$unsupported_algorithms]) 5926AC_SUBST([DEPEND], [$(cat $srcdir/.depend)]) 5927 5928# Binaries for interop tests. 5929AC_PATH_PROG([PLINK], [plink]) 5930AC_PATH_PROG([PUTTYGEN], [puttygen]) 5931AC_PATH_PROG([CONCH], [conch]) 5932AC_PATH_PROG([DROPBEAR], [dropbear]) 5933AC_PATH_PROG([DBCLIENT], [dbclient]) 5934AC_PATH_PROG([DROPBEARKEY], [dropbearkey]) 5935AC_PATH_PROG([DROPBEARCONVERT], [dropbearconvert]) 5936AC_PATH_PROG([TMUX], [tmux]) 5937 5938CFLAGS="${CFLAGS} ${CFLAGS_AFTER}" 5939LDFLAGS="${LDFLAGS} ${LDFLAGS_AFTER}" 5940 5941# Make a copy of CFLAGS/LDFLAGS without PIE options. 5942LDFLAGS_NOPIE=`echo "$LDFLAGS" | sed 's/^-pie //;s/ -pie//g'` 5943CFLAGS_NOPIE=`echo "$CFLAGS" | sed 's/^-fPIE //;s/ -fPIE//g'` 5944AC_SUBST([LDFLAGS_NOPIE]) 5945AC_SUBST([CFLAGS_NOPIE]) 5946AC_SUBST([COMPATINCLUDES]) 5947 5948AC_EXEEXT 5949AC_CONFIG_FILES([Makefile buildpkg.sh opensshd.init openssh.xml \ 5950 openbsd-compat/Makefile openbsd-compat/regress/Makefile \ 5951 survey.sh]) 5952AC_OUTPUT 5953 5954# Print summary of options 5955 5956# Someone please show me a better way :) 5957A=`eval echo ${prefix}` ; A=`eval echo ${A}` 5958B=`eval echo ${bindir}` ; B=`eval echo ${B}` 5959C=`eval echo ${sbindir}` ; C=`eval echo ${C}` 5960D=`eval echo ${sysconfdir}` ; D=`eval echo ${D}` 5961E=`eval echo ${libexecdir}/ssh-askpass` ; E=`eval echo ${E}` 5962F=`eval echo ${mandir}/${mansubdir}X` ; F=`eval echo ${F}` 5963G=`eval echo ${piddir}` ; G=`eval echo ${G}` 5964H=`eval echo ${PRIVSEP_PATH}` ; H=`eval echo ${H}` 5965I=`eval echo ${user_path}` ; I=`eval echo ${I}` 5966J=`eval echo ${superuser_path}` ; J=`eval echo ${J}` 5967 5968echo "" 5969echo "OpenSSH has been configured with the following options:" 5970echo " User binaries: $B" 5971echo " System binaries: $C" 5972echo " Configuration files: $D" 5973echo " Askpass program: $E" 5974echo " Manual pages: $F" 5975echo " PID file: $G" 5976echo " Privilege separation chroot path: $H" 5977if test "x$external_path_file" = "x/etc/login.conf" ; then 5978echo " At runtime, sshd will use the path defined in $external_path_file" 5979echo " Make sure the path to scp is present, otherwise scp will not work" 5980else 5981echo " sshd default user PATH: $I" 5982 if test ! -z "$external_path_file"; then 5983echo " (If PATH is set in $external_path_file it will be used instead. If" 5984echo " used, ensure the path to scp is present, otherwise scp will not work.)" 5985 fi 5986fi 5987if test ! -z "$superuser_path" ; then 5988echo " sshd superuser user PATH: $J" 5989fi 5990echo " Manpage format: $MANTYPE" 5991echo " PAM support: $PAM_MSG" 5992echo " OSF SIA support: $SIA_MSG" 5993echo " KerberosV support: $KRB5_MSG" 5994echo " SELinux support: $SELINUX_MSG" 5995echo " TCP Wrappers support: $TCPW_MSG" 5996echo " libedit support: $LIBEDIT_MSG" 5997echo " libldns support: $LDNS_MSG" 5998echo " Solaris process contract support: $SPC_MSG" 5999echo " Solaris project support: $SP_MSG" 6000echo " Solaris privilege support: $SPP_MSG" 6001echo " IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG" 6002echo " Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG" 6003echo " BSD Auth support: $BSD_AUTH_MSG" 6004echo " Random number source: $RAND_MSG" 6005echo " Privsep sandbox style: $SANDBOX_STYLE" 6006echo " PKCS#11 support: $enable_pkcs11" 6007echo " U2F/FIDO support: $enable_sk" 6008 6009echo "" 6010 6011echo " Host: ${host}" 6012echo " Compiler: ${CC}" 6013echo " Compiler flags: ${CFLAGS}" 6014echo "Preprocessor flags: ${CPPFLAGS}" 6015echo " Linker flags: ${LDFLAGS}" 6016echo " Libraries: ${LIBS}" 6017if test ! -z "${CHANNELLIBS}"; then 6018echo " +for channels: ${CHANNELLIBS}" 6019fi 6020if test ! -z "${LIBFIDO2}"; then 6021echo " +for FIDO2: ${LIBFIDO2}" 6022fi 6023if test ! -z "${SSHDLIBS}"; then 6024echo " +for sshd: ${SSHDLIBS}" 6025fi 6026 6027echo "" 6028 6029if test "x$MAKE_PACKAGE_SUPPORTED" = "xyes" ; then 6030 echo "SVR4 style packages are supported with \"make package\"" 6031 echo "" 6032fi 6033 6034if test "x$PAM_MSG" = "xyes" ; then 6035 echo "PAM is enabled. You may need to install a PAM control file " 6036 echo "for sshd, otherwise password authentication may fail. " 6037 echo "Example PAM control files can be found in the contrib/ " 6038 echo "subdirectory" 6039 echo "" 6040fi 6041 6042if test ! -z "$NO_PEERCHECK" ; then 6043 echo "WARNING: the operating system that you are using does not" 6044 echo "appear to support getpeereid(), getpeerucred() or the" 6045 echo "SO_PEERCRED getsockopt() option. These facilities are used to" 6046 echo "enforce security checks to prevent unauthorised connections to" 6047 echo "ssh-agent. Their absence increases the risk that a malicious" 6048 echo "user can connect to your agent." 6049 echo "" 6050fi 6051 6052if test "$AUDIT_MODULE" = "bsm" ; then 6053 echo "WARNING: BSM audit support is currently considered EXPERIMENTAL." 6054 echo "See the Solaris section in README.platform for details." 6055fi 6056