Commit Graph

808 Commits

Author SHA1 Message Date
Darren Tucker 26b2675b0c Remove configure test & compat code for ripemd160.
RIPEMD160 support was removed upstream in 2017, however we still had
a configure test and compat code for it, so clean those up now.
2020-01-14 12:05:00 +11:00
Damien Miller 633778d567 only link ssh-sk-helper against libfido2 2019-12-14 08:40:58 +11:00
Darren Tucker afffd31036 Check if memmem is declared in system headers.
If the system (or one of the dependencies) implements memmem but does
not define the header, we would not declare it either resulting in
compiler warnings.  Check for declaration explicitly.  bz#3102.
2019-12-11 13:22:06 +11:00
Damien Miller 443848155f compile sk-dummy.so with no-PIE version of LDFLAGS
This lets it pick up the -L path to libcrypto for example.
2019-11-29 15:10:21 +11:00
Damien Miller b218055e59 (yet) another x-platform fix for sk-dummy.so
Check for -fPIC support from compiler

Compile libopenbsd-compat -fPIC

Don't mix -fPIE and -fPIC when compiling
2019-11-29 12:32:23 +11:00
Darren Tucker 6cf1c40096 Enable -Wimplicit-fallthrough if supported
Suggested by djm.
2019-11-18 14:14:18 +11:00
Darren Tucker 39b87104cd Add wrappers for other ultrix headers.
Wrappers protect against multiple inclusions for headers that don't do
it themselves.
2019-11-15 18:56:54 +11:00
Darren Tucker 9c6d0a3a1e Remove ultrix realpath hack. 2019-11-15 17:13:19 +11:00
Damien Miller 5c0bc273cb configure flag to built-in security key support
Require --with-security-key-builtin before enabling the built-in
security key support (and consequent dependency on libfido2).
2019-11-15 16:08:00 +11:00
Damien Miller 63a5b24f2d don't fatal if libfido2 not found
spotted by dtucker@
2019-11-15 11:21:49 +11:00
djm@openbsd.org 6bff9521ab upstream: directly support U2F/FIDO2 security keys in OpenSSH by
linking against the (previously external) USB HID middleware. The dlopen()
capability still exists for alternate middlewares, e.g. for Bluetooth, NFC
and test/debugging.

OpenBSD-Commit-ID: 14446cf170ac0351f0d4792ba0bca53024930069
2019-11-15 09:57:30 +11:00
Darren Tucker 382c18c20c statfs might be defined in sys/mount.h.
eg on old NetBSDs.
2019-11-03 00:09:21 +11:00
Darren Tucker f5cc5816aa Only enable U2F if OpenSSL supports ECC.
This requires moving the U2F bits to below the OpenSSL parts so we have
the required information.  ok djm@
2019-11-02 16:39:38 +11:00
Darren Tucker 9cac151c2d Add flags needed to build and work on Ultrix. 2019-11-01 18:27:37 +11:00
Darren Tucker 0e3c5bc509 Hook up fnmatch for platforms that don't have it. 2019-11-01 18:27:37 +11:00
Darren Tucker 79d46de9fb Use sftp_realpath if no native realpath. 2019-11-01 18:27:37 +11:00
Darren Tucker bb4f003ed8 Configure flags for haiku from haikuports.
Should build with the default flags with ./configure
2019-11-01 15:06:16 +11:00
Damien Miller 764d51e044 autoconf pieces for U2F support
Mostly following existing logic for PKCS#11 - turning off support
when either libcrypto or dlopen(3) are unavailable.
2019-11-01 13:35:34 +11:00
Darren Tucker 1bcd1169c5 Add implementation of localtime_r. 2019-10-29 20:48:46 +11:00
Darren Tucker d561b0b2fa Make sure we have struct statfs before using. 2019-10-28 16:27:53 +11:00
Darren Tucker 2912596aec Define UINT32_MAX if needed. 2019-10-28 16:27:53 +11:00
Darren Tucker 9239a18f96 Add a function call stackprotector tests.
Including a function call in the test programs for the gcc stack
protector flag tests exercises more of the compiler and makes it more
likely it'll detect problems.
2019-10-24 14:39:49 +11:00
Damien Miller e0e7e3d0e2 tweak warning flags
Enable -Wextra if compiler supports it

Set -Wno-error=format-truncation if available to prevent expected
string truncations in openbsd-compat from breaking -Werror builds
2019-08-30 14:26:19 +10:00
Damien Miller 28744182cf proc_pidinfo()-based closefrom() for OS X
Refactor closefrom() to use a single brute-force close() loop fallback.

Based on patch from likan_999.student@sina.com in bz#3049. ok dtucker@
2019-08-30 13:23:04 +10:00
Darren Tucker 11cba2a452 Re-apply portability changes to current sha2.{c,h}.
Rather than attempt to apply 14 years' worth of changes to OpenBSD's sha2
I imported the current versions directly then re-applied the portability
changes.  This also allowed re-syncing digest-libc.c against upstream.
2019-07-23 22:06:24 +10:00
Darren Tucker 45478898f9 Hook memmem compat code into build.
This fixes builds on platforms that don't have it (at least old DragonFly,
probably others).
2019-07-16 09:21:20 +10:00
Damien Miller 8729498a5d fix typo that prevented detection of Linux VRF
Reported by hexiaowen AT huawei.com
2019-07-10 09:43:19 +10:00
Damien Miller 4efe1adf05 remove realpath() compat replacement
We shipped a BSD implementation of realpath() because sftp-server
depended on its behaviour.

OpenBSD is now moving to a more strictly POSIX-compliant realpath(2),
so sftp-server now unconditionally requires its own BSD-style realpath
implementation. As such, there is no need to carry another independant
implementation in openbsd-compat.

ok dtucker@
2019-07-08 13:38:39 +10:00
Darren Tucker 6fd4aa2aaf Fix typo in man page formatter selector. 2019-05-15 16:19:14 +10:00
Darren Tucker 285546b73e Use "doc" man page format if mandoc present.
Previously configure would not select the "doc" man page format if
mandoc was present but nroff was not.  This checks for mandoc first
and removes a now-superflous AC_PATH_PROG.  Based on a patch from
vehk at vehk.de and feedback from schwarze at usta.de.
2019-05-10 15:04:42 +10:00
Darren Tucker 34e87fb5d9 Remove unused variables from RLIMIT_NOFILE test. 2019-04-30 12:27:57 +10:00
Darren Tucker c882d74652 Allow building against OpenSSL dev (3.x) version. 2019-01-22 20:38:40 +11:00
Darren Tucker 2f0bad2bf8 Make --with-rpath take a flag instead of yes/no.
Linkers need various flags for -rpath and similar, so make --with-rpath
take an optional flag argument which is passed to the linker.  ok djm@
2019-01-21 21:28:27 +11:00
Damien Miller e2cb445d78 conditionalise ECDSA PKCS#11 support
Require EC_KEY_METHOD support in libcrypto, evidenced by presence
of EC_KEY_METHOD_new() function.
2019-01-21 11:32:28 +11:00
Darren Tucker c90a7928c4 Check for cc before gcc.
If cc is something other than gcc and is the system compiler prefer using
that, unless otherwise told via $CC.  ok djm@
2019-01-21 09:22:36 +11:00
Darren Tucker a6258e5dc3 Add minimal fchownat and fchmodat implementations.
Fixes builds on at least OS X Lion, NetBSD 6 and Solaris 10.
2019-01-18 11:09:01 +11:00
Darren Tucker 091093d258 Add a minimal implementation of utimensat().
Some systems (eg older OS X) do not have utimensat, so provide minimal
implementation in compat layer.  Fixes build on at least El Capitan.
2019-01-18 10:16:11 +11:00
Darren Tucker 98f878d227 Improve OpenSSL_add_all_algorithms check.
OpenSSL_add_all_algorithms() may be a macro so check for that too.
2018-11-25 14:05:08 +11:00
Damien Miller 28c7b2cd05 fix configure test for OpenSSL version
square brackets in case statements may be eaten by autoconf.

Report and fix from Filipp Gunbin; tweaked by naddy@
2018-11-23 10:45:20 +11:00
Damien Miller 42c5ec4b97 refactor libcrypto initialisation
Don't call OpenSSL_add_all_algorithms() unless OpenSSL actually
supports it.

Move all libcrypto initialisation to a single function, and call that
from seed_rng() that is called early in each tool's main().

Prompted by patch from Rosen Penev
2018-11-23 10:42:05 +11:00
Darren Tucker d0d1dfa55b Test for OPENSSL_init_crypto before using.
Check for the presence of OPENSSL_init_crypto and all the flags we want
before trying to use it (bz#2931).
2018-11-16 14:11:44 +11:00
Darren Tucker 8d8340e2c2 Remove fallback check for /usr/local/ssl.
If configure could not find a working OpenSSL installation it would
fall back to checking in /usr/local/ssl.  This made sense back when
systems did not ship with OpenSSL, but most do and OpenSSL 1.1 doesn't
use that as a default any more.  The fallback behaviour also meant
that if you pointed --with-ssl-dir at a specific directory and it
didn't work, it would silently use either the system libs or the ones
in /usr/local/ssl.  If you want to use /usr/local/ssl you'll need to
pass configure --with-ssl-dir=/usr/local/ssl.  ok djm@
2018-11-16 13:32:13 +11:00
Dag-Erling Smørgrav d0153c77bf AC_CHECK_SIZEOF() no longer needs a second argument. 2018-11-10 19:45:14 +11:00
Darren Tucker 1801cd11d9 Simplify OpenSSL 1.1 function checks.
Replace AC_SEARCH_LIBS checks for OpenSSL 1.1 functions with a single
AC_CHECK_FUNCS.  ok djm@
2018-11-08 15:03:11 +11:00
Darren Tucker bc32f118d4 Fix pasto for HAVE_EVP_CIPHER_CTX_SET_IV.
Prevents unnecessary redefinition.  Patch from mforney at mforney.org.
2018-11-05 17:31:24 +11:00
Darren Tucker 262d81a259 Check for the existence of openssl version funcs.
Check for the existence of openssl version functions and use the ones
detected instead of trying to guess based on the int32 version
identifier.  Fixes builds with LibreSSL.
2018-10-27 16:45:59 +11:00
Damien Miller 406a24b25d fix builds on OpenSSL <= 1.0.x
I thought OpenSSL 1.0.x offered the new-style OpenSSL_version_num() API
to obtain version number, but they don't.
2018-10-26 13:43:28 +11:00
Damien Miller 859754bdeb remove remaining references to SSLeay
Prompted by Rosen Penev
2018-10-23 17:10:41 +11:00
Damien Miller aede1c3424 Require OpenSSL 1.1.x series 1.1.0g or greater
Previous versions have a bug with EVP_CipherInit() when passed a
NULL EVP_CIPHER, per https://github.com/openssl/openssl/pull/4613

ok dtucker@
2018-10-17 11:01:20 +11:00
Darren Tucker 1673274aee Remove gcc spectre mitigation flags.
Current impementions of the gcc spectre mitigation flags cause
miscompilations when combined with other flags and do not provide much
protection.  Found by fweimer at redhat.com, ok djm@
2018-10-16 14:45:57 +11:00
Darren Tucker e526127cbd Check if snprintf understands %zu.
If the platforms snprintf and friends don't understand %zu, use the
compat replacement.  Prevents segfaults on those platforms.
2018-10-12 16:43:35 +11:00
Damien Miller 48f54b9d12 adapt -portable to OpenSSL 1.1x API
Polyfill missing API with replacement functions extracted from LibreSSL
2018-09-13 12:13:50 +10:00
Corinna Vinschen 477b49a34b configure: work around GCC shortcoming on Cygwin
Cygwin's latest 7.x GCC allows to specify -mfunction-return=thunk
as well as -mindirect-branch=thunk on the command line, albeit
producing invalid code, leading to an error at link stage.

The check in configure.ac only checks if the option is present,
but not if it produces valid code.

This patch fixes it by special-casing Cygwin.  Another solution
may be to change these to linker checks.

Signed-off-by: Corinna Vinschen <vinschen@redhat.com>
2018-08-13 13:01:25 -07:00
Damien Miller 87f08be054 Remove support for S/Key
Most people will 1) be using modern multi-factor authentication methods
like TOTP/OATH etc and 2) be getting support for multi-factor
authentication via PAM or BSD Auth.
2018-07-31 12:59:30 +10:00
Darren Tucker 6301e6c787 Add implementation of getline.
Add getline for the benefit of platforms that don't have it.  Sourced
from NetBSD (OpenBSD's implementation is a little too chummy with the
internals of FILE).
2018-07-02 21:36:31 +10:00
Darren Tucker f2c06ab8dd Remove ability to override $LD.
Since autoconf always uses $CC to link C programs, allowing users to
override LD caused mismatches between what LD_LINK_IFELSE thought worked
and what ld thought worked.  If you do need to do this kind of thing you
need to set a compiler flag such as gcc's -fuse-ld in LDFLAGS.
2018-06-08 17:43:36 +10:00
Darren Tucker d97874cbd9 Using "==" in shell tests is not portable.
Patch from rsbecker at nexbridge.com.
2018-04-13 13:45:51 +10:00
Damien Miller afa6e79b76 prefer to use getrandom() for PRNG seeding
Only applies when built --without-openssl. Thanks Jann Horn for
reminder.
2018-04-13 13:32:23 +10:00
Damien Miller 10479cc2a4 Many typo fixes from Karsten Weiss
Spotted using https://github.com/lucasdemarchi/codespell
2018-04-10 10:19:02 +10:00
Darren Tucker 2c71ca1dd1 Disable native strndup and strnlen on AIX.
On at least some revisions of AIX, strndup returns unterminated strings
under some conditions, apparently because strnlen returns incorrect
values in those cases.  Disable both on AIX and use the replacements
from openbsd-compat.  Fixes problem with ECDSA keys there, ok djm.
2018-03-30 18:23:07 +11:00
Tim Rice 4afeaf3dcb Use libiaf on all sysv5 systems 2018-03-25 10:00:21 -07:00
Darren Tucker fbd733ab7a Add AC_LANG_PROGRAM to AC_COMPILE_IFELSE.
The recently added MIPS ABI tests need AC_LANG_PROGRAM to prevent
warnings from autoconf.  Pointed out by klausz at haus-gisela.de.
2018-03-12 19:17:26 +11:00
Vicente Olivert Riera 45011511a0 configure.ac: properly set seccomp_audit_arch for MIPS64
Currently seccomp_audit_arch is set to AUDIT_ARCH_MIPS64 or
AUDIT_ARCH_MIPSEL64 (depending on the endinness) when openssh is built
for MIPS64. However, that's only valid for n64 ABI. The right macros for
n32 ABI defined in seccomp.h are AUDIT_ARCH_MIPS64N32 and
AUDIT_ARCH_MIPSEL64N32, for big and little endian respectively.

Because of that an sshd built for MIPS64 n32 rejects connection attempts
and the output of strace reveals that the problem is related to seccomp
audit:

[pid   194] prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, {len=57,
filter=0x555d5da0}) = 0
[pid   194] write(7, "\0\0\0]\0\0\0\5\0\0\0Ulist_hostkey_types: "..., 97) = ?
[pid   193] <... poll resumed> )        = 2 ([{fd=5, revents=POLLIN|POLLHUP},
{fd=6, revents=POLLHUP}])
[pid   194] +++ killed by SIGSYS +++

This patch fixes that problem by setting the right value to
seccomp_audit_arch taking into account the MIPS64 ABI.

Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
2018-03-08 13:03:06 +11:00
Vicente Olivert Riera 580086704c configure.ac: detect MIPS ABI
Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
2018-03-08 13:02:48 +11:00
Darren Tucker c0a0c3fc4a Disable UTMPX on SunOS4. 2018-03-05 20:03:07 +11:00
Darren Tucker 58fd4c5c01 Check for and work around buggy fflush(NULL).
Some really old platforms (eg SunOS4) segfault on fflush(NULL) so check
for and work around.  With klausz at haus-gisela.de.
2018-03-05 19:28:08 +11:00
Darren Tucker 33561e68e0 Add strndup for platforms that need it.
Some platforms don't have strndup, which includes Solaris 10, NetBSD 3
and FreeBSD 6.
2018-03-03 14:58:34 +11:00
Darren Tucker 146c3bd28c Check dlopen has RTLD_NOW before enabling pkcs11. 2018-02-27 15:28:31 +11:00
Darren Tucker 1323f120d0 Check for attributes on prototype args.
Some compilers (gcc 2.9.53, 3.0 and probably others, see gcc bug #3481)
do not accept __attribute__ on function pointer prototype args.  Check for
this and hide them if they're not accepted.
2018-02-27 08:51:56 +11:00
Darren Tucker cd3ab57f9b Hook up flock() compat code.
Also a couple of minor changes: fail if we can't lock instead of
silently succeeding, and apply a couple of minor style fixes.
2018-02-26 14:37:06 +11:00
Damien Miller f885474137 XMSS-related files get includes.h 2018-02-26 12:18:14 +11:00
Darren Tucker c7b5a47e3b Invert sense of getpgrp test.
AC_FUNC_GETPGRP tests if getpgrp(0) works, which it does if it's not
declared.  Instead, test if the zero-arg version we want to use works.
2018-02-26 00:14:42 +11:00
Darren Tucker b39593a6de Add no-op getsid implmentation. 2018-02-26 00:09:04 +11:00
Darren Tucker 11057564eb bsd-statvfs: include sys/vfs.h, check for f_flags. 2018-02-26 00:09:04 +11:00
Darren Tucker e9dede06e5 Handle calloc(0,x) where different from malloc.
Configure assumes that if malloc(0) returns null then calloc(0,n)
also does.  On some old platforms (SunOS4) malloc behaves as expected
(as determined by AC_FUNC_MALLOC) but calloc doesn't.  Test for this
at configure time and activate the replacement function if found, plus
handle this case in rpl_calloc.
2018-02-26 00:09:04 +11:00
Darren Tucker 2eb4041493 Add prototype for readv if needed. 2018-02-26 00:09:04 +11:00
Darren Tucker 6c8c9a615b Check for raise and supply if needed. 2018-02-26 00:09:04 +11:00
Darren Tucker a9004425a0 Check for bzero and supply if needed.
Since explicit_bzero uses it via an indirect it needs to be a function
not just a macro.
2018-02-26 00:09:04 +11:00
Darren Tucker b59162da99 Check for ifaddrs.h for BindInterface.
BindInterface required getifaddr and friends so disable if not available
(eg Solaris 10).  We should be able to add support for some systems with
a bit more work but this gets the building again.
2018-02-23 15:20:42 +11:00
Darren Tucker ce066f688d Add headers for sys/audit.h.
On some older platforms (at least sunos4, probably others) sys/audit.h
requires some other headers.  Patch from klausz at haus-gisela.de.
2018-02-22 21:00:06 +11:00
Darren Tucker f833842858 Remove now-unused check for getrusage.
getrusage was used in ssh-rand-helper but that's now long gone.
Patch from klauszh at haus-gisela.de.
2018-02-18 15:53:15 +11:00
Darren Tucker 265d88d4e6 Remove remaining now-obsolete cvs $Ids. 2018-02-15 20:06:19 +11:00
Darren Tucker ddc0f38148 Remove UNICOS support.
The code required to support it is quite invasive to the mainline
code that is synced with upstream and is an ongoing maintenance burden.
Both the hardware and software are literal museum pieces these days and
we could not find anyone still running OpenSSH on one.
2018-02-15 20:04:02 +11:00
Darren Tucker 174bed6869 Retpoline linker flag only needed for linking. 2018-02-13 18:12:47 +11:00
Darren Tucker 075e258c2c Default PidFile is sshd.pid not ssh.pid. 2018-02-13 17:36:43 +11:00
Darren Tucker 24d2a33bd3 Include headers for linux/if.h.
Prevents configure-time "present but cannot be compiled" warning.
2018-02-11 21:17:33 +11:00
Darren Tucker bc02181c24 Fix test for -z,retpolineplt linker flag. 2018-02-11 21:17:21 +11:00
Darren Tucker 3377df00ea Add checks for Spectre v2 mitigation (retpoline)
This adds checks for gcc and clang flags for mitigations for Spectre
variant 2, ie "retpoline".  It'll automatically enabled if the compiler
supports it as part of toolchain hardening flag.  ok djm@
2018-02-11 09:32:37 +11:00
Darren Tucker 3c000d57d4 Remove obsolete "Smartcard support" message
The configure checks that populated $SCARD_MSG were removed in commits
7ea845e4 and d8f60022 when the smartcard support was replaced with
PKCS#11.
2018-02-07 09:26:45 +11:00
Darren Tucker 79c0e1d299 Add autogenerated dependency info to Makefile.
Adds a .depend file containing dependency information generated by
makedepend, which is appended to the generated Makefile by configure.

You can regen the file with "make -f Makefile.in depend" if necessary,
but we'll be looking at some way to automatically keep this up to date.

"no objection" djm@
2017-12-11 14:38:33 +11:00
Darren Tucker f001de8fbf Fix pasto in ldns handling.
When ldns-config is not found, configure would check the wrong variable.
ok djm@
2017-12-11 13:42:51 +11:00
Darren Tucker bb82e61a40 Remove now-used check for perl. 2017-12-09 08:06:00 +11:00
Darren Tucker 6c8a246437 Replace mkinstalldirs with mkdir -p.
Check for MIKDIR_P and use it instead of mkinstalldirs.  Should fix "mkdir:
cannot create directory:... File exists" during "make install".
Patch from eb at emlix.com.
2017-12-01 17:13:34 +11:00
Darren Tucker 81c9ccdbf6 Check for linux/if.h when enabling rdomain.
musl libc doesn't seem to have linux/if.h, so check for its presence
before enabling rdomain support on Linux.
2017-11-03 14:52:51 +11:00
Darren Tucker fa1b834cce Add headers for sys/sysctl.h and net/route.h
On at least older OpenBSDs, sys/sysctl.h and net/route.h require
sys/types and, in the case of sys/sysctl.h, sys/param.h for MAXLOGNAME.
2017-11-03 14:09:45 +11:00
Damien Miller 6bd5b569fd autoconf glue to enable Linux VRF 2017-10-25 14:15:42 +11:00
Damien Miller 3235473bc8 check for net/route.h and sys/sysctl.h 2017-10-25 13:11:37 +11:00
Damien Miller bba69c246f don't fatal ./configure for LibreSSL 2017-09-28 16:06:21 -07:00
Damien Miller 04dc070e8b abort in configure when only openssl-1.1.x found
We don't support openssl-1.1.x yet (see multiple threads on the
openssh-unix-dev@ mailing list for the reason), but previously
./configure would accept it and the compilation would subsequently
fail. This makes ./configure display an explicit error message and
abort.

ok dtucker@
2017-09-28 14:54:34 -07:00
Darren Tucker 74c1c3660a Check for and handle calloc(p, 0) = NULL.
On some platforms (AIX, maybe others) allocating zero bytes of memory
via the various *alloc functions returns NULL, which is permitted
by the standards.  Autoconf has some macros for detecting this (with
the exception of calloc for some reason) so use these and if necessary
activate shims for them.  ok djm@
2017-09-27 07:44:41 +10:00