diff options
Diffstat (limited to 'openbsd-compat')
-rw-r--r-- | openbsd-compat/Makefile.in | 5 | ||||
-rw-r--r-- | openbsd-compat/arc4random.c | 2 | ||||
-rw-r--r-- | openbsd-compat/arc4random_uniform.c | 4 | ||||
-rw-r--r-- | openbsd-compat/bsd-misc.c | 55 | ||||
-rw-r--r-- | openbsd-compat/bsd-misc.h | 14 | ||||
-rw-r--r-- | openbsd-compat/bsd-openpty.c | 8 | ||||
-rw-r--r-- | openbsd-compat/bsd-poll.h | 6 | ||||
-rw-r--r-- | openbsd-compat/daemon.c | 4 | ||||
-rw-r--r-- | openbsd-compat/glob.c | 2 | ||||
-rw-r--r-- | openbsd-compat/memmem.c | 2 | ||||
-rw-r--r-- | openbsd-compat/openssl-compat.c | 9 | ||||
-rw-r--r-- | openbsd-compat/openssl-compat.h | 19 | ||||
-rw-r--r-- | openbsd-compat/port-prngd.c | 4 | ||||
-rw-r--r-- | openbsd-compat/reallocarray.c | 2 | ||||
-rw-r--r-- | openbsd-compat/recallocarray.c | 2 | ||||
-rw-r--r-- | openbsd-compat/regress/utimensattest.c | 12 |
16 files changed, 103 insertions, 47 deletions
diff --git a/openbsd-compat/Makefile.in b/openbsd-compat/Makefile.in index 1d549954f9d6..53c87db6d01e 100644 --- a/openbsd-compat/Makefile.in +++ b/openbsd-compat/Makefile.in @@ -3,12 +3,14 @@ piddir=@piddir@ srcdir=@srcdir@ top_srcdir=@top_srcdir@ +BUILDDIR=@abs_top_builddir@ VPATH=@srcdir@ CC=@CC@ LD=@LD@ CFLAGS=@CFLAGS@ CFLAGS_NOPIE=@CFLAGS_NOPIE@ -CPPFLAGS=-I. -I.. -I$(srcdir) -I$(srcdir)/.. @CPPFLAGS@ @DEFS@ +COMPATINCLUDES="$(BUILDDIR)/@COMPATINCLUDES@" +CPPFLAGS=-I. -I.. -I$(srcdir) -I$(srcdir)/.. -I$(COMPATINCLUDES) @CPPFLAGS@ @DEFS@ PICFLAG=@PICFLAG@ LIBS=@LIBS@ AR=@AR@ @@ -120,3 +122,4 @@ clean: distclean: clean rm -f Makefile *~ + rm -rf include diff --git a/openbsd-compat/arc4random.c b/openbsd-compat/arc4random.c index ffd33734db56..376a893d2110 100644 --- a/openbsd-compat/arc4random.c +++ b/openbsd-compat/arc4random.c @@ -32,9 +32,7 @@ #include <fcntl.h> #include <limits.h> #include <signal.h> -#ifdef HAVE_STDINT_H #include <stdint.h> -#endif #include <stdlib.h> #include <string.h> #include <unistd.h> diff --git a/openbsd-compat/arc4random_uniform.c b/openbsd-compat/arc4random_uniform.c index 591f92d150fa..59d516884eb1 100644 --- a/openbsd-compat/arc4random_uniform.c +++ b/openbsd-compat/arc4random_uniform.c @@ -20,9 +20,7 @@ #include "includes.h" -#ifdef HAVE_STDINT_H -# include <stdint.h> -#endif +#include <stdint.h> #include <stdlib.h> #ifndef HAVE_ARC4RANDOM_UNIFORM diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c index 226a5915bd1d..983cd3fe6216 100644 --- a/openbsd-compat/bsd-misc.c +++ b/openbsd-compat/bsd-misc.c @@ -21,9 +21,7 @@ #ifdef HAVE_SYS_SELECT_H # include <sys/select.h> #endif -#ifdef HAVE_SYS_TIME_H -# include <sys/time.h> -#endif +#include <sys/time.h> #include <fcntl.h> #include <string.h> @@ -158,6 +156,15 @@ utimensat(int fd, const char *path, const struct timespec times[2], } #endif +#ifndef HAVE_DIRFD +int +dirfd(void *dir) +{ + errno = ENOSYS; + return -1; +} +#endif + #ifndef HAVE_FCHOWNAT /* * A limited implementation of fchownat() that only implements the @@ -220,6 +227,46 @@ fchmodat(int fd, const char *path, mode_t mode, int flag) } #endif +#ifndef HAVE_FSTATAT +/* + * A limited implementation of fstatat that just has what OpenSSH uses: + * cwd-relative and absolute paths, with or without following symlinks. + */ +int +fstatat(int dirfd, const char *path, struct stat *sb, int flag) +{ + if (dirfd != AT_FDCWD && path && path[0] != '/') { + errno = ENOSYS; + return -1; + } + if (flag == 0) + return stat(path, sb); + else if (flag == AT_SYMLINK_NOFOLLOW) + return lstat(path, sb); + errno = ENOSYS; + return -1; +} +#endif + +#ifndef HAVE_UNLINKAT +/* + * A limited implementation of unlinkat that just has what OpenSSH uses: + * cwd-relative and absolute paths. + */ +int +unlinkat(int dirfd, const char *path, int flag) +{ + if (dirfd != AT_FDCWD && path && path[0] != '/') { + errno = ENOSYS; + return -1; + } + if (flag == 0) + return unlink(path); + errno = ENOSYS; + return -1; +} +#endif + #ifndef HAVE_TRUNCATE int truncate(const char *path, off_t length) { @@ -356,7 +403,7 @@ getpgid(pid_t pid) #ifndef HAVE_PLEDGE int -pledge(const char *promises, const char *paths[]) +pledge(const char *promises, const char *execpromises) { return 0; } diff --git a/openbsd-compat/bsd-misc.h b/openbsd-compat/bsd-misc.h index 61ead1b7fad0..2ad89cd83b59 100644 --- a/openbsd-compat/bsd-misc.h +++ b/openbsd-compat/bsd-misc.h @@ -65,6 +65,10 @@ struct timeval { int utimes(const char *, struct timeval *); #endif /* HAVE_UTIMES */ +#ifndef HAVE_DIRFD +int dirfd(void *); +#endif + #ifndef AT_FDCWD # define AT_FDCWD (-2) #endif @@ -77,6 +81,14 @@ int fchmodat(int, const char *, mode_t, int); int fchownat(int, const char *, uid_t, gid_t, int); #endif +#ifdef HAVE_FSTATAT +int fstatat(int, const char *, struct stat *, int); +#endif + +#ifdef HAVE_UNLINKAT +int unlinkat(int, const char *, int); +#endif + #ifndef HAVE_TRUNCATE int truncate (const char *, off_t); #endif /* HAVE_TRUNCATE */ @@ -144,7 +156,7 @@ int pselect(int, fd_set *, fd_set *, fd_set *, const struct timespec *, #endif #ifndef HAVE_PLEDGE -int pledge(const char *promises, const char *paths[]); +int pledge(const char *promises, const char *execpromises); #endif /* bsd-err.h */ diff --git a/openbsd-compat/bsd-openpty.c b/openbsd-compat/bsd-openpty.c index f5507000a5cb..f08d6156d284 100644 --- a/openbsd-compat/bsd-openpty.c +++ b/openbsd-compat/bsd-openpty.c @@ -39,9 +39,7 @@ #include <stdlib.h> -#ifdef HAVE_SYS_STAT_H -# include <sys/stat.h> -#endif +#include <sys/stat.h> #ifdef HAVE_SYS_IOCTL_H # include <sys/ioctl.h> #endif @@ -50,9 +48,7 @@ # include <fcntl.h> #endif -#ifdef HAVE_UTIL_H -# include <util.h> -#endif /* HAVE_UTIL_H */ +#include <util.h> #ifdef HAVE_PTY_H # include <pty.h> diff --git a/openbsd-compat/bsd-poll.h b/openbsd-compat/bsd-poll.h index ae865a6e2622..67fd8c66f803 100644 --- a/openbsd-compat/bsd-poll.h +++ b/openbsd-compat/bsd-poll.h @@ -31,11 +31,7 @@ #define _COMPAT_POLL_H_ #include <sys/types.h> -#ifdef HAVE_POLL_H -# include <poll.h> -#elif HAVE_SYS_POLL_H -# include <sys/poll.h> -#endif +#include <poll.h> #ifndef HAVE_STRUCT_POLLFD_FD typedef struct pollfd { diff --git a/openbsd-compat/daemon.c b/openbsd-compat/daemon.c index 3efe14c68c41..256466959621 100644 --- a/openbsd-compat/daemon.c +++ b/openbsd-compat/daemon.c @@ -36,9 +36,7 @@ #include <sys/types.h> -#ifdef HAVE_SYS_STAT_H -# include <sys/stat.h> -#endif +#include <sys/stat.h> #ifdef HAVE_FCNTL_H # include <fcntl.h> diff --git a/openbsd-compat/glob.c b/openbsd-compat/glob.c index e89151789aa3..330b9c0aa73a 100644 --- a/openbsd-compat/glob.c +++ b/openbsd-compat/glob.c @@ -70,9 +70,7 @@ #include <limits.h> #include <pwd.h> #include <stdlib.h> -#ifdef HAVE_STDINT_H #include <stdint.h> -#endif #include <string.h> #include <unistd.h> diff --git a/openbsd-compat/memmem.c b/openbsd-compat/memmem.c index 2637401d7c6e..afc20c669b08 100644 --- a/openbsd-compat/memmem.c +++ b/openbsd-compat/memmem.c @@ -30,9 +30,7 @@ #ifndef HAVE_MEMMEM #include <string.h> -#ifdef HAVE_STDINT_H #include <stdint.h> -#endif static char * twobyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) diff --git a/openbsd-compat/openssl-compat.c b/openbsd-compat/openssl-compat.c index 14865077e469..48938920cda7 100644 --- a/openbsd-compat/openssl-compat.c +++ b/openbsd-compat/openssl-compat.c @@ -32,7 +32,8 @@ #include "openssl-compat.h" /* - * OpenSSL version numbers: MNNFFPPS: major minor fix patch status + * OpenSSL version numbers: MNNFFPPS: major minor fix patch status. + * See the OpenSSL_version_num(3ssl) man page. * Versions >=3 require only major versions to match. * For versions <3, we accept compatible fix versions (so we allow 1.0.1 * to work with 1.0.0). Going backwards is only allowed within a patch series. @@ -49,10 +50,10 @@ ssh_compatible_openssl(long headerver, long libver) return 1; /* - * For versions >= 3.0, only the major and status must match. + * For versions >= 3.0, only the major must match. */ - if (headerver >= 0x3000000f) { - mask = 0xf000000fL; /* major,status */ + if (headerver >= 0x30000000) { + mask = 0xf0000000L; /* major only */ return (headerver & mask) == (libver & mask); } diff --git a/openbsd-compat/openssl-compat.h b/openbsd-compat/openssl-compat.h index 6b8fff412951..d07928b17b6d 100644 --- a/openbsd-compat/openssl-compat.h +++ b/openbsd-compat/openssl-compat.h @@ -23,8 +23,8 @@ #include <openssl/opensslv.h> #include <openssl/crypto.h> #include <openssl/evp.h> +#include <openssl/bn.h> #include <openssl/rsa.h> -#include <openssl/dsa.h> #ifdef OPENSSL_HAS_ECC #include <openssl/ecdsa.h> #endif @@ -45,9 +45,6 @@ void ssh_libcrypto_init(void); #ifndef OPENSSL_RSA_MAX_MODULUS_BITS # define OPENSSL_RSA_MAX_MODULUS_BITS 16384 #endif -#ifndef OPENSSL_DSA_MAX_MODULUS_BITS -# define OPENSSL_DSA_MAX_MODULUS_BITS 10000 -#endif #ifdef LIBRESSL_VERSION_NUMBER # if LIBRESSL_VERSION_NUMBER < 0x3010000fL @@ -64,6 +61,20 @@ void ssh_libcrypto_init(void); # define BN_set_flags(a, b) #endif +/* LibreSSL <3.4 has the _GFp variants but not the equivalent modern ones. */ +#ifndef HAVE_EC_POINT_GET_AFFINE_COORDINATES +# ifdef HAVE_EC_POINT_GET_AFFINE_COORDINATES_GFP +# define EC_POINT_get_affine_coordinates(a, b, c, d, e) \ + (EC_POINT_get_affine_coordinates_GFp(a, b, c, d, e)) +# endif +#endif +#ifndef HAVE_EC_POINT_SET_AFFINE_COORDINATES +# ifdef HAVE_EC_POINT_SET_AFFINE_COORDINATES_GFP +# define EC_POINT_set_affine_coordinates(a, b, c, d, e) \ + (EC_POINT_set_affine_coordinates_GFp(a, b, c, d, e)) +# endif +#endif + #ifndef HAVE_EVP_CIPHER_CTX_GET_IV # ifdef HAVE_EVP_CIPHER_CTX_GET_UPDATED_IV # define EVP_CIPHER_CTX_get_iv EVP_CIPHER_CTX_get_updated_iv diff --git a/openbsd-compat/port-prngd.c b/openbsd-compat/port-prngd.c index 6afa8f913ae3..ac4f27082b74 100644 --- a/openbsd-compat/port-prngd.c +++ b/openbsd-compat/port-prngd.c @@ -26,9 +26,7 @@ #include <sys/types.h> #include <sys/socket.h> -#ifdef HAVE_SYS_UN_H -# include <sys/un.h> -#endif +#include <sys/un.h> #include <netinet/in.h> #include <arpa/inet.h> diff --git a/openbsd-compat/reallocarray.c b/openbsd-compat/reallocarray.c index 1a52acc623fe..cffe9b5efe7b 100644 --- a/openbsd-compat/reallocarray.c +++ b/openbsd-compat/reallocarray.c @@ -22,9 +22,7 @@ #include <sys/types.h> #include <errno.h> -#ifdef HAVE_STDINT_H #include <stdint.h> -#endif #include <stdlib.h> /* diff --git a/openbsd-compat/recallocarray.c b/openbsd-compat/recallocarray.c index 3e1156ce2d95..c281f75e94d1 100644 --- a/openbsd-compat/recallocarray.c +++ b/openbsd-compat/recallocarray.c @@ -22,9 +22,7 @@ #include <errno.h> #include <stdlib.h> -#ifdef HAVE_STDINT_H #include <stdint.h> -#endif #include <string.h> #include <unistd.h> diff --git a/openbsd-compat/regress/utimensattest.c b/openbsd-compat/regress/utimensattest.c index bbc66c48523e..b4405e464d03 100644 --- a/openbsd-compat/regress/utimensattest.c +++ b/openbsd-compat/regress/utimensattest.c @@ -77,11 +77,17 @@ main(void) fail("utimensat", 0, 0); if (stat(TMPFILE, &sb) == -1) - fail("stat", 0, 0 ); + fail("stat", 0, 0); +#if 0 + /* + * This test only works on filesystems mounted 'noatime', otherwise the + * stat() above resets atime. Skip by default. + */ if (sb.st_atime != 12345678) - fail("st_atime", 0, 0 ); + fail("st_atime", 0, 0); +#endif if (sb.st_mtime != 34567890) - fail("st_mtime", 0, 0 ); + fail("st_mtime", 0, 0); #if 0 /* * Results expected to be rounded to the nearest microsecond. |