From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Gunnar Beutner <gbeutner@serenityos.org>
Date: Sat, 30 Apr 2022 10:58:10 +0000
Subject: [PATCH] ifdef out missing functionality
Co-Authored-By: Luke <luke.wilde@live.co.uk>
Co-Authored-By: Oskar Skog <oskar@oskog97.com>
Co-Authored-By: Patrick Meyer <git@the-space.agency>
Co-Authored-By: Tim Schumacher <timschumi@gmx.de>
---
atomicio.c | 2 +-
defines.h | 5 +++++
dns.c | 4 ++++
dns.h | 4 ++++
hostfile.c | 2 ++
includes.h | 2 ++
loginrec.c | 8 ++++----
misc.c | 2 ++
openbsd-compat/getrrsetbyname-ldns.c | 4 ++++
openbsd-compat/getrrsetbyname.c | 4 ++++
openbsd-compat/getrrsetbyname.h | 4 ++++
openbsd-compat/mktemp.c | 2 +-
readconf.c | 5 ++++-
regress/netcat.c | 2 ++
sandbox-pledge.c | 2 ++
servconf.c | 2 ++
ssh-add.c | 4 ++++
ssh-agent.c | 2 ++
ssh-keygen.c | 13 +++++++++++++
ssh-keyscan.c | 2 ++
ssh-pkcs11-client.c | 8 +++++++-
ssh-sk-client.c | 4 ++++
sshbuf-misc.c | 2 ++
sshconnect.c | 10 ++++++++--
sshkey.c | 4 ++++
25 files changed, 93 insertions(+), 10 deletions(-)
diff --git a/atomicio.c b/atomicio.c
index 765073357f67342f8b5f21ac869629c0c9260c7a..7a195f5abe8df53a17ed0a20671d027c5978f991 100644
--- a/atomicio.c
+++ b/atomicio.c
@@ -119,7 +119,7 @@ atomiciov6(ssize_t (*f) (int, const struct iovec *, int), int fd,
memcpy(iov, _iov, (size_t)iovcnt * sizeof(*_iov));
pfd.fd = fd;
-#ifndef BROKEN_READV_COMPARISON
+#if !defined(BROKEN_READV_COMPARISON) && !defined(__minerva__)
pfd.events = f == readv ? POLLIN : POLLOUT;
#else
pfd.events = POLLIN|POLLOUT;
diff --git a/defines.h b/defines.h
index 279e509aae22e4e2824a15c9be4dac7f89a5be5c..5fb970a186ac375da4c737b7edff187320ce735b 100644
--- a/defines.h
+++ b/defines.h
@@ -55,8 +55,13 @@ enum
/*
* Definitions for IP type of service (ip_tos)
*/
+#ifndef __minerva__
#include <netinet/in_systm.h>
+#endif
#include <netinet/ip.h>
+#ifdef __minerva__
+#include <arpa/inet.h>
+#endif
#ifndef IPTOS_LOWDELAY
# define IPTOS_LOWDELAY 0x10
# define IPTOS_THROUGHPUT 0x08
diff --git a/dns.c b/dns.c
index f2310bec2b08865ef14dd2f334ec5f96ecc8d71b..f39db585ae3122dab44eba0ddb4c1fa8ac1278d8 100644
--- a/dns.c
+++ b/dns.c
@@ -25,6 +25,8 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef __minerva__
+
#include "includes.h"
#include <sys/types.h>
@@ -338,3 +340,5 @@ export_dns_rr(const char *hostname, struct sshkey *key, FILE *f, int generic)
return success;
}
+
+#endif
diff --git a/dns.h b/dns.h
index c9b61c4f28f89659a34ba1b6ee903e9e2d91fb7d..2b9f153c84f1b7adb273d1352fede728f23912d6 100644
--- a/dns.h
+++ b/dns.h
@@ -25,6 +25,8 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef __minerva__
+
#ifndef DNS_H
#define DNS_H
@@ -57,3 +59,5 @@ int verify_host_key_dns(const char *, struct sockaddr *,
int export_dns_rr(const char *, struct sshkey *, FILE *, int);
#endif /* DNS_H */
+
+#endif
diff --git a/hostfile.c b/hostfile.c
index bd49e3ac7c48b12f09316a028e471019b7ea3b4c..34030f1da19db07207afa0a5efcadba6effcff00 100644
--- a/hostfile.c
+++ b/hostfile.c
@@ -44,7 +44,9 @@
#include <netinet/in.h>
#include <errno.h>
+#ifndef __minerva__
#include <resolv.h>
+#endif
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/includes.h b/includes.h
index 6d17ef6da9338cfd0de8c044f2a1483991c166e4..eef913a348d04323e42e3ec4a3ddb585db4df4a0 100644
--- a/includes.h
+++ b/includes.h
@@ -109,7 +109,9 @@
#endif
#include <netinet/in.h>
+#ifndef __minerva__
#include <netinet/in_systm.h> /* For typedefs */
+#endif
#ifdef HAVE_RPC_TYPES_H
# include <rpc/types.h> /* For INADDR_LOOPBACK */
#endif
diff --git a/loginrec.c b/loginrec.c
index 4f21499586afc5d87f2d28f639cb725e366cd25e..574e3a1af5aaaebf9a8befc55fc028db47d095b4 100644
--- a/loginrec.c
+++ b/loginrec.c
@@ -461,7 +461,7 @@ login_write(struct logininfo *li)
#ifdef USE_WTMP
wtmp_write_entry(li);
#endif
-#ifdef USE_UTMPX
+#ifndef __minerva__
utmpx_write_entry(li);
#endif
#ifdef USE_WTMPX
@@ -494,7 +494,7 @@ login_utmp_only(struct logininfo *li)
# ifdef USE_WTMP
wtmp_write_entry(li);
# endif
-# ifdef USE_UTMPX
+# ifndef __minerva__
utmpx_write_entry(li);
# endif
# ifdef USE_WTMPX
@@ -725,7 +725,7 @@ construct_utmp(struct logininfo *li,
** variations.
**/
-#if defined(USE_UTMPX) || defined (USE_WTMPX)
+#if !defined(__minerva__)
/* build the utmpx structure */
void
set_utmpx_time(struct logininfo *li, struct utmpx *utx)
@@ -987,7 +987,7 @@ utmp_write_entry(struct logininfo *li)
**/
/* not much point if we don't want utmpx entries */
-#ifdef USE_UTMPX
+#ifndef __minerva__
/* if we have the wherewithall, use pututxline etc. */
# if !defined(DISABLE_PUTUTXLINE) && defined(HAVE_SETUTXENT) && \
diff --git a/misc.c b/misc.c
index 85d22369505dc81ad0a55af304ef751cccfa960a..bc0609405500ae905523b5ec55478a7c4c87d3eb 100644
--- a/misc.c
+++ b/misc.c
@@ -44,7 +44,9 @@
#include <unistd.h>
#include <netinet/in.h>
+#ifndef __minerva__
#include <netinet/in_systm.h>
+#endif
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
diff --git a/openbsd-compat/getrrsetbyname-ldns.c b/openbsd-compat/getrrsetbyname-ldns.c
index 4647b623b8621a97b6790504e20b3fca7b3f84b7..d684f6fbac27cca4db6a87bb0aea0ece8e33d7e9 100644
--- a/openbsd-compat/getrrsetbyname-ldns.c
+++ b/openbsd-compat/getrrsetbyname-ldns.c
@@ -43,6 +43,8 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifndef __minerva__
+
#include "includes.h"
#if !defined (HAVE_GETRRSETBYNAME) && defined (HAVE_LDNS)
@@ -282,3 +284,5 @@ freerrset(struct rrsetinfo *rrset)
#endif /* !defined (HAVE_GETRRSETBYNAME) && defined (HAVE_LDNS) */
+
+#endif
diff --git a/openbsd-compat/getrrsetbyname.c b/openbsd-compat/getrrsetbyname.c
index cc1f8ae519ebe8747acd2189fa6cf081f4c3f84b..57999ed45ca016559ad9aa4e547c4c58e0dc02eb 100644
--- a/openbsd-compat/getrrsetbyname.c
+++ b/openbsd-compat/getrrsetbyname.c
@@ -45,6 +45,8 @@
/* OPENBSD ORIGINAL: lib/libc/net/getrrsetbyname.c */
+#ifndef __minerva__
+
#include "includes.h"
#if !defined (HAVE_GETRRSETBYNAME) && !defined (HAVE_LDNS)
@@ -607,3 +609,5 @@ count_dns_rr(struct dns_rr *p, u_int16_t class, u_int16_t type)
}
#endif /* !defined (HAVE_GETRRSETBYNAME) && !defined (HAVE_LDNS) */
+
+#endif
diff --git a/openbsd-compat/getrrsetbyname.h b/openbsd-compat/getrrsetbyname.h
index 1283f55062e0cc5ebdb323cb68c4b02d125d2be5..0b33705e3a460a845999b2855f21d3cc0e4a497e 100644
--- a/openbsd-compat/getrrsetbyname.h
+++ b/openbsd-compat/getrrsetbyname.h
@@ -45,6 +45,8 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifndef __minerva__
+
#ifndef _GETRRSETBYNAME_H
#define _GETRRSETBYNAME_H
@@ -108,3 +110,5 @@ void freerrset(struct rrsetinfo *);
#endif /* !defined(HAVE_GETRRSETBYNAME) */
#endif /* _GETRRSETBYNAME_H */
+
+#endif
diff --git a/openbsd-compat/mktemp.c b/openbsd-compat/mktemp.c
index ac922c1ecbe5c579233cf1ba44c98bfd59e31def..1ebb975d1823008d888b45b74fd7edeccf35f71a 100644
--- a/openbsd-compat/mktemp.c
+++ b/openbsd-compat/mktemp.c
@@ -34,7 +34,7 @@
#include <ctype.h>
#include <unistd.h>
-#if !defined(HAVE_MKDTEMP)
+#if !defined(HAVE_MKDTEMP) || !defined(__minerva__)
#define MKTEMP_NAME 0
#define MKTEMP_FILE 1
diff --git a/readconf.c b/readconf.c
index f26fabaa6af465f927c021eeb651815afad0d37d..56122d8fb2792514e483bd9ecce27a4eb12df2ed 100644
--- a/readconf.c
+++ b/readconf.c
@@ -21,7 +21,9 @@
#include <sys/un.h>
#include <netinet/in.h>
+#ifndef __minerva__
#include <netinet/in_systm.h>
+#endif
#include <netinet/ip.h>
#include <arpa/inet.h>
@@ -1134,11 +1136,12 @@ parse_time:
case oCheckHostIP:
intptr = &options->check_host_ip;
goto parse_flag;
-
+#ifndef __minerva__
case oVerifyHostKeyDNS:
intptr = &options->verify_host_key_dns;
multistate_ptr = multistate_yesnoask;
goto parse_multistate;
+ #endif
case oStrictHostKeyChecking:
intptr = &options->strict_host_key_checking;
diff --git a/regress/netcat.c b/regress/netcat.c
index 20ec3f5954faad76dba6615bdba18bbf8d3dc9f3..55e087e02aa51d4b95f6c79f5e23a092adf05e60 100644
--- a/regress/netcat.c
+++ b/regress/netcat.c
@@ -1384,7 +1384,9 @@ usage(int ret)
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#ifndef __minerva__
#include <resolv.h>
+#endif
#define SOCKS_PORT "1080"
#define HTTP_PROXY_PORT "3128"
diff --git a/sandbox-pledge.c b/sandbox-pledge.c
index 302f1cfedd3dab43e7f53870b37515f0ad6970b7..693a443770c3dfac2ef88d1fd24f6dfe10860d8d 100644
--- a/sandbox-pledge.c
+++ b/sandbox-pledge.c
@@ -21,7 +21,9 @@
#include <sys/types.h>
#include <sys/ioctl.h>
+#ifndef __minerva__
#include <sys/syscall.h>
+#endif
#include <sys/socket.h>
#include <sys/wait.h>
diff --git a/servconf.c b/servconf.c
index 9d9681f15acfb130ee0f3e0c77bcf1edb34952d0..c4185091e53954add94b47f7a9342b0fd1e11703 100644
--- a/servconf.c
+++ b/servconf.c
@@ -21,7 +21,9 @@
#endif
#include <netinet/in.h>
+#ifndef __minerva__
#include <netinet/in_systm.h>
+#endif
#include <netinet/ip.h>
#ifdef HAVE_NET_ROUTE_H
#include <net/route.h>
diff --git a/ssh-add.c b/ssh-add.c
index 7555477482766e4464ab92bcbf19a879fe28d4f1..ea8e27c8a18f12098fef77ba310d1e356aafbd96 100644
--- a/ssh-add.c
+++ b/ssh-add.c
@@ -577,6 +577,7 @@ lock_agent(int agent_fd, int lock)
return (ret);
}
+#ifndef __minerva__
static int
load_resident_keys(int agent_fd, const char *skprovider, int qflag,
struct dest_constraint **dest_constraints, size_t ndest_constraints)
@@ -628,6 +629,7 @@ load_resident_keys(int agent_fd, const char *skprovider, int qflag,
return SSH_ERR_KEY_NOT_FOUND;
return ok == 1 ? 0 : ok;
}
+#endif
static int
do_file(int agent_fd, int deleting, int key_only, char *file, int qflag,
@@ -964,6 +966,7 @@ main(int argc, char **argv)
ret = 1;
goto done;
}
+ #ifndef __minerva__
if (do_download) {
if (skprovider == NULL)
fatal("Cannot download keys without provider");
@@ -972,6 +975,7 @@ main(int argc, char **argv)
ret = 1;
goto done;
}
+ #endif
if (argc == 0) {
char buf[PATH_MAX];
struct passwd *pw;
diff --git a/ssh-agent.c b/ssh-agent.c
index 03ae2b022eedf1334e55f229dec1f4743eababe1..c1b6350dfe9a1c6eedfc5cbaacd7b47b6957e334 100644
--- a/ssh-agent.c
+++ b/ssh-agent.c
@@ -2146,10 +2146,12 @@ main(int ac, char **av)
* a few spare for libc / stack protectors / sanitisers, etc.
*/
#define SSH_AGENT_MIN_FDS (3+1+1+1+4)
+#ifndef __minerva__
if (rlim.rlim_cur < SSH_AGENT_MIN_FDS)
fatal("%s: file descriptor rlimit %lld too low (minimum %u)",
__progname, (long long)rlim.rlim_cur, SSH_AGENT_MIN_FDS);
maxfds = rlim.rlim_cur - SSH_AGENT_MIN_FDS;
+#endif
parent_pid = getpid();
diff --git a/ssh-keygen.c b/ssh-keygen.c
index d62fab3e818a7016af904cbf8843022d25f3fa0d..64c87a20af0aafd060da515c677b590f8f4215ed 100644
--- a/ssh-keygen.c
+++ b/ssh-keygen.c
@@ -1471,6 +1471,7 @@ do_change_passphrase(struct passwd *pw)
exit(0);
}
+#ifndef __minerva__
/*
* Print the SSHFP RR.
*/
@@ -1497,6 +1498,7 @@ do_print_resource_record(struct passwd *pw, char *fname, char *hname,
free(comment);
return 1;
}
+#endif
/*
* Change the comment of a private key file.
@@ -3075,6 +3077,7 @@ sk_suffix(const char *application, const uint8_t *user, size_t userlen)
return ret;
}
+#ifndef __minerva__
static int
do_download_sk(const char *skprovider, const char *device)
{
@@ -3185,6 +3188,7 @@ save_attestation(struct sshbuf *attest, const char *path)
printf("Your FIDO attestation certificate has been saved in "
"%s\n", path);
}
+#endif
static void
usage(void)
@@ -3627,6 +3631,7 @@ main(int argc, char **argv)
}
if (pkcs11provider != NULL)
do_download(pw);
+#ifndef __minerva__
if (download_sk) {
for (i = 0; i < nopts; i++) {
if (strncasecmp(opts[i], "device=", 7) == 0) {
@@ -3638,6 +3643,7 @@ main(int argc, char **argv)
}
return do_download_sk(sk_provider, sk_device);
}
+#endif
if (print_fingerprint || print_bubblebabble)
do_fingerprint(pw);
if (change_passphrase)
@@ -3655,6 +3661,8 @@ main(int argc, char **argv)
#endif /* WITH_OPENSSL */
if (print_public)
do_print_public(pw);
+
+#ifndef __minerva__
if (rr_hostname != NULL) {
unsigned int n = 0;
@@ -3686,6 +3694,7 @@ main(int argc, char **argv)
exit(0);
}
}
+#endif
if (do_gen_candidates || do_screen_candidates) {
if (argc <= 0)
@@ -3717,6 +3726,7 @@ main(int argc, char **argv)
printf("Generating public/private %s key pair.\n",
key_type_name);
switch (type) {
+#ifndef __minerva__
case KEY_ECDSA_SK:
case KEY_ED25519_SK:
for (i = 0; i < nopts; i++) {
@@ -3795,6 +3805,7 @@ main(int argc, char **argv)
passphrase = NULL;
}
break;
+#endif
default:
if ((r = sshkey_generate(type, bits, &private)) != 0)
fatal("sshkey_generate failed");
@@ -3858,8 +3869,10 @@ main(int argc, char **argv)
free(fp);
}
+#ifndef __minerva__
if (sk_attestation_path != NULL)
save_attestation(attest, sk_attestation_path);
+#endif
sshbuf_free(attest);
sshkey_free(public);
diff --git a/ssh-keyscan.c b/ssh-keyscan.c
index d29a03b4e68a82772010786f5b93dd50cbc86cb9..e6aac3db105adbe88c854e91da7be9e3fb66049e 100644
--- a/ssh-keyscan.c
+++ b/ssh-keyscan.c
@@ -313,7 +313,9 @@ keyprint_one(const char *host, struct sshkey *key)
found_one = 1;
if (print_sshfp) {
+#ifndef __minerva__
export_dns_rr(host, key, stdout, 0);
+#endif
return;
}
diff --git a/ssh-pkcs11-client.c b/ssh-pkcs11-client.c
index cfd833d74054f45098c2aa1f8dcbc057ca042cee..de8fb904de7de30153dbf3d751bc529a65158f5e 100644
--- a/ssh-pkcs11-client.c
+++ b/ssh-pkcs11-client.c
@@ -241,6 +241,7 @@ wrap_key(struct sshkey *k)
fatal_f("unknown key type");
}
+#ifndef __minerva__
static int
pkcs11_start_helper_methods(void)
{
@@ -310,6 +311,7 @@ pkcs11_start_helper(void)
fd = pair[0];
return (0);
}
+#endif
int
pkcs11_add_provider(char *name, char *pin, struct sshkey ***keysp,
@@ -323,7 +325,11 @@ pkcs11_add_provider(char *name, char *pin, struct sshkey ***keysp,
u_int nkeys, i;
struct sshbuf *msg;
- if (fd < 0 && pkcs11_start_helper() < 0)
+ if (fd < 0
+#ifndef __minerva__
+ && pkcs11_start_helper() < 0
+#endif
+ )
return (-1);
if ((msg = sshbuf_new()) == NULL)
diff --git a/ssh-sk-client.c b/ssh-sk-client.c
index 321fe53a2d9195b04ede36d32e71e7529b5af209..984aa6a01757ea9875b043e247a4c370a4f0e3b1 100644
--- a/ssh-sk-client.c
+++ b/ssh-sk-client.c
@@ -15,6 +15,8 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifndef __minerva__
+
#include "includes.h"
#include <sys/types.h>
@@ -478,3 +480,5 @@ sshsk_load_resident(const char *provider_path, const char *device,
errno = oerrno;
return r;
}
+
+#endif
diff --git a/sshbuf-misc.c b/sshbuf-misc.c
index 9c5c42bba70ac1042c080da1744ddeb2274a6dfb..1759ed2a1d1413a916ac2bcf347dbc544ee6156b 100644
--- a/sshbuf-misc.c
+++ b/sshbuf-misc.c
@@ -28,7 +28,9 @@
#include <stdio.h>
#include <limits.h>
#include <string.h>
+#ifndef __minerva__
#include <resolv.h>
+#endif
#include <ctype.h>
#include <unistd.h>
diff --git a/sshconnect.c b/sshconnect.c
index ebecc83747bbb6704c9b1bcf8e72f7b9c2b7a24b..81df6126821bfd021fba6e6f584c1a77c754e4c5 100644
--- a/sshconnect.c
+++ b/sshconnect.c
@@ -106,6 +106,7 @@ expand_proxy_command(const char *proxy_command, const char *user,
return ret;
}
+#ifndef __minerva__
/*
* Connect to the given ssh server using a proxy command that passes a
* a connected fd back to us.
@@ -188,6 +189,7 @@ ssh_proxy_fdpass_connect(struct ssh *ssh, const char *host,
return 0;
}
+#endif
/*
* Connect to the given ssh server using a proxy command.
@@ -555,10 +557,13 @@ ssh_connect(struct ssh *ssh, const char *host, const char *host_arg,
if ((ssh_packet_set_connection(ssh, in, out)) == NULL)
return -1; /* ssh_packet_set_connection logs error */
return 0;
- } else if (options.proxy_use_fdpass) {
+ }
+ #ifndef __minerva__
+ else if (options.proxy_use_fdpass) {
return ssh_proxy_fdpass_connect(ssh, host, host_arg, port,
options.proxy_command);
}
+ #endif
return ssh_proxy_connect(ssh, host, host_arg, port,
options.proxy_command);
}
@@ -1483,7 +1488,7 @@ verify_host_key(char *host, struct sockaddr *hostaddr, struct sshkey *host_key,
goto out;
}
}
-
+#ifndef __minerva__
if (options.verify_host_key_dns) {
/*
* XXX certs are not yet supported for DNS, so downgrade
@@ -1512,6 +1517,7 @@ verify_host_key(char *host, struct sockaddr *hostaddr, struct sshkey *host_key,
}
}
}
+#endif
r = check_host_key(host, cinfo, hostaddr, options.port, host_key,
RDRW, 0, options.user_hostfiles, options.num_user_hostfiles,
options.system_hostfiles, options.num_system_hostfiles,
diff --git a/sshkey.c b/sshkey.c
index f1e92003b7e40df63743b79924f9a18b5f8d6c66..564ff40d080c22e09750f5129d479707c02b6f4a 100644
--- a/sshkey.c
+++ b/sshkey.c
@@ -42,7 +42,9 @@
#include <limits.h>
#include <stdio.h>
#include <string.h>
+#ifndef __minerva__
#include <resolv.h>
+#endif
#include <time.h>
#ifdef HAVE_UTIL_H
#include <util.h>
@@ -2790,6 +2792,7 @@ sshkey_sign(struct sshkey *key,
case KEY_ED25519_CERT:
r = ssh_ed25519_sign(key, sigp, lenp, data, datalen, compat);
break;
+#ifndef __minerva__
case KEY_ED25519_SK:
case KEY_ED25519_SK_CERT:
case KEY_ECDSA_SK_CERT:
@@ -2797,6 +2800,7 @@ sshkey_sign(struct sshkey *key,
r = sshsk_sign(sk_provider, key, sigp, lenp, data,
datalen, compat, sk_pin);
break;
+#endif
#ifdef WITH_XMSS
case KEY_XMSS:
case KEY_XMSS_CERT: