From fe10bc7682c1da645fab90583a2e9d9cddf53dd6 Mon Sep 17 00:00:00 2001 From: nnarayanamurthy Date: Wed, 21 Jan 2026 17:42:13 +0530 Subject: [PATCH] QNX Porting support for unbound branch-1.24.1 (#1388) * qnx Porting support for version release-1.24.1 * updating __QNXNTO__ with __QNX__ --- compat/arc4random.c | 7 +++++++ compat/getentropy_linux.c | 20 ++++++++++++++++++++ services/outside_network.h | 4 ++++ testcode/replay.h | 4 ++++ testcode/unitldns.c | 4 ++++ testcode/unitmsgparse.c | 4 ++++ testcode/unitverify.c | 5 ++++- testcode/unitzonemd.c | 4 ++++ util/data/msgreply.h | 4 ++++ util/timehist.h | 4 ++++ 10 files changed, 59 insertions(+), 1 deletion(-) diff --git a/compat/arc4random.c b/compat/arc4random.c index 486ab89c6..50d87beac 100644 --- a/compat/arc4random.c +++ b/compat/arc4random.c @@ -38,6 +38,9 @@ #ifndef UB_ON_WINDOWS #include #endif +#ifdef __QNX__ +#include "util/log.h" +#endif /* __QNX__ */ #define KEYSTREAM_ONLY #include "chacha_private.h" @@ -187,7 +190,11 @@ _rs_stir(void) if(errno != ENOSYS || fallback_getentropy_urandom(rnd, sizeof rnd) == -1) { #ifdef SIGKILL +#ifndef __QNX__ raise(SIGKILL); +#else /* !__QNX__ */ + fatal_exit("failed to getentropy"); +#endif /* __QNX__ */ #else exit(9); /* windows */ #endif diff --git a/compat/getentropy_linux.c b/compat/getentropy_linux.c index 82cdb78b8..1a91c99ed 100644 --- a/compat/getentropy_linux.c +++ b/compat/getentropy_linux.c @@ -29,7 +29,9 @@ #include #include #include +#ifndef __QNX__ #include +#endif /* !__QNX__ */ #ifdef SYS__sysctl #include #endif @@ -42,7 +44,9 @@ #include #include #include +#ifndef __QNX__ #include +#endif /* __QNX__ */ #include #include #include @@ -60,12 +64,14 @@ #define SHA512_Final(r, c) sha512_digest(c, SHA512_DIGEST_SIZE, r) #endif +#ifndef __QNX__ #include #include #ifdef HAVE_GETAUXVAL #include #endif #include +#endif /* !__QNX__ */ #ifndef MAP_ANON #define MAP_ANON MAP_ANONYMOUS #endif @@ -94,8 +100,10 @@ static int getentropy_urandom(void *buf, size_t len); #ifdef SYS__sysctl static int getentropy_sysctl(void *buf, size_t len); #endif +#ifndef __QNX__ static int getentropy_fallback(void *buf, size_t len); static int getentropy_phdr(struct dl_phdr_info *info, size_t size, void *data); +#endif /* !__QNX__ */ int getentropy(void *buf, size_t len) @@ -178,6 +186,7 @@ getentropy(void *buf, size_t len) * sysctl ABI, or consider providing a new failsafe API which * works in a chroot or when file descriptors are exhausted. */ +#ifndef __QNX__ #undef FAIL_INSTEAD_OF_TRYING_FALLBACK #ifdef FAIL_INSTEAD_OF_TRYING_FALLBACK raise(SIGKILL); @@ -185,6 +194,9 @@ getentropy(void *buf, size_t len) ret = getentropy_fallback(buf, len); if (ret != -1) return (ret); +#else /* !__QNX__ */ + fatal_exit("failed to read from /dev/urandom"); +#endif /* __QNX__ */ errno = EIO; return (ret); @@ -214,7 +226,11 @@ getentropy_urandom(void *buf, size_t len) { struct stat st; size_t i; +#ifndef __QNX__ int fd, cnt, flags; +#else /* !__QNX__ */ + int fd, flags; +#endif /* __QNX__ */ int save_errno = errno; start: @@ -241,10 +257,12 @@ start: close(fd); goto nodevrandom; } +#ifndef __QNX__ if (ioctl(fd, RNDGETENTCNT, &cnt) == -1) { close(fd); goto nodevrandom; } +#endif /* !__QNX__ */ for (i = 0; i < len; ) { size_t wanted = len - i; ssize_t ret = read(fd, (char *)buf + i, wanted); @@ -265,6 +283,7 @@ nodevrandom: return (-1); } +#ifndef __QNX__ #ifdef SYS__sysctl static int getentropy_sysctl(void *buf, size_t len) @@ -537,3 +556,4 @@ getentropy_fallback(void *buf, size_t len) errno = save_errno; return (0); /* satisfied */ } +#endif /* !__QNX__ */ diff --git a/services/outside_network.h b/services/outside_network.h index 0a77e3388..7404d462f 100644 --- a/services/outside_network.h +++ b/services/outside_network.h @@ -48,6 +48,10 @@ #include "util/regional.h" #include "util/netevent.h" #include "dnstap/dnstap_config.h" +#ifdef __QNX__ +/* For struct timeval */ +#include +#endif /* __QNX__ */ struct pending; struct pending_timeout; struct ub_randstate; diff --git a/testcode/replay.h b/testcode/replay.h index 809e8ee39..42a56a1c4 100644 --- a/testcode/replay.h +++ b/testcode/replay.h @@ -142,6 +142,10 @@ #include "util/netevent.h" #include "testcode/testpkts.h" #include "util/rbtree.h" +#ifdef __QNX__ +/* For struct timeval */ +#include +#endif /* __QNX__ */ struct replay_answer; struct replay_moment; struct replay_range; diff --git a/testcode/unitldns.c b/testcode/unitldns.c index f8409fec7..07d001a79 100644 --- a/testcode/unitldns.c +++ b/testcode/unitldns.c @@ -207,7 +207,11 @@ rr_test_file(const char* input, const char* check) #define xstr(s) str(s) #define str(s) #s +#ifndef __QNX__ #define SRCDIRSTR xstr(SRCDIR) +#else /* !__QNX__ */ +#define SRCDIRSTR "." +#endif /* __QNX__ */ /** read rrs to and from string, to and from wireformat */ static void diff --git a/testcode/unitmsgparse.c b/testcode/unitmsgparse.c index a87314019..d65b7dd02 100644 --- a/testcode/unitmsgparse.c +++ b/testcode/unitmsgparse.c @@ -498,7 +498,11 @@ testfromdrillfile(sldns_buffer* pkt, struct alloc_cache* alloc, #define xstr(s) str(s) #define str(s) #s +#ifndef __QNX__ #define SRCDIRSTR xstr(SRCDIR) +#else /* !__QNX__ */ +#define SRCDIRSTR "." +#endif /* __QNX__ */ void msgparse_test(void) { diff --git a/testcode/unitverify.c b/testcode/unitverify.c index a101c528f..fcf2e2ffe 100644 --- a/testcode/unitverify.c +++ b/testcode/unitverify.c @@ -513,8 +513,11 @@ nsec3_hash_test(const char* fname) #define xstr(s) str(s) #define str(s) #s +#ifndef __QNX__ #define SRCDIRSTR xstr(SRCDIR) - +#else /* !__QNX__ */ +#define SRCDIRSTR "." +#endif /* __QNX__ */ #if defined(HAVE_SSL) && defined(USE_SHA1) /* Detect if openssl is configured to disable RSASHA1 signatures, * with the rh-allow-sha1-signatures disabled. */ diff --git a/testcode/unitzonemd.c b/testcode/unitzonemd.c index 0420b0361..c98dcf395 100644 --- a/testcode/unitzonemd.c +++ b/testcode/unitzonemd.c @@ -50,7 +50,11 @@ #define xstr(s) str(s) #define str(s) #s +#ifndef __QNX__ #define SRCDIRSTR xstr(SRCDIR) +#else /* !__QNX__ */ +#define SRCDIRSTR "." +#endif /* __QNX__ */ /** Add zone from file for testing */ struct auth_zone* authtest_addzone(struct auth_zones* az, const char* name, diff --git a/util/data/msgreply.h b/util/data/msgreply.h index 87eebb2b9..e7c688e97 100644 --- a/util/data/msgreply.h +++ b/util/data/msgreply.h @@ -44,6 +44,10 @@ #include "util/storage/lruhash.h" #include "util/data/packed_rrset.h" #include "sldns/rrdef.h" +#ifdef __QNX__ +/* For struct timeval */ +#include +#endif /* __QNX__ */ struct sldns_buffer; struct comm_reply; struct alloc_cache; diff --git a/util/timehist.h b/util/timehist.h index 5f88a38a9..12855f94b 100644 --- a/util/timehist.h +++ b/util/timehist.h @@ -42,6 +42,10 @@ #ifndef UTIL_TIMEHIST_H #define UTIL_TIMEHIST_H +#ifdef __QNX__ +/* For struct timeval */ +#include +#endif /* __QNX__ */ /** Number of buckets in a histogram */ #define NUM_BUCKETS_HIST 40 -- 2.47.3