git: 208c43d6f57b - main - Revert "libc/resolv: Drop Solaris 2 compatibility"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 29 Jun 2026 15:54:30 UTC
The branch main has been updated by des:
URL: https://cgit.FreeBSD.org/src/commit/?id=208c43d6f57b036cfd207a54de54c4dd7b8123da
commit 208c43d6f57b036cfd207a54de54c4dd7b8123da
Author: Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-06-29 15:54:01 +0000
Commit: Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-06-29 15:54:01 +0000
Revert "libc/resolv: Drop Solaris 2 compatibility"
This reverts commit b27e21f304f260d539288756c5bb85421a549d44.
---
lib/libc/nameser/ns_parse.c | 5 +++++
lib/libc/resolv/res_comp.c | 11 +++++++++++
lib/libc/resolv/res_init.c | 42 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 58 insertions(+)
diff --git a/lib/libc/nameser/ns_parse.c b/lib/libc/nameser/ns_parse.c
index fa21127a5c7e..40f19d33c2bc 100644
--- a/lib/libc/nameser/ns_parse.c
+++ b/lib/libc/nameser/ns_parse.c
@@ -38,7 +38,12 @@ static void setsection(ns_msg *msg, ns_sect sect);
/* Macros. */
+#if !defined(SOLARIS2) || defined(__COVERITY__)
#define RETERR(err) do { errno = (err); return (-1); } while (0)
+#else
+#define RETERR(err) \
+ do { errno = (err); if (errno == errno) return (-1); } while (0)
+#endif
#define PARSE_FMT_PRESO 0 /* Parse using presentation-format names */
#define PARSE_FMT_WIRE 1 /* Parse using network-format names */
diff --git a/lib/libc/resolv/res_comp.c b/lib/libc/resolv/res_comp.c
index d9edcc9a4930..55b71266b4ae 100644
--- a/lib/libc/resolv/res_comp.c
+++ b/lib/libc/resolv/res_comp.c
@@ -240,6 +240,17 @@ res_dnok(const char *dn) {
* Note that one _ comes from C and the others come from us.
*/
+#ifdef SOLARIS2
+#ifdef __putlong
+#undef __putlong
+#endif
+#ifdef __putshort
+#undef __putshort
+#endif
+#pragma weak putlong = __putlong
+#pragma weak putshort = __putshort
+#endif /* SOLARIS2 */
+
void __putlong(u_int32_t src, u_char *dst) { ns_put32(src, dst); }
void __putshort(u_int16_t src, u_char *dst) { ns_put16(src, dst); }
#ifndef __ultrix__
diff --git a/lib/libc/resolv/res_init.c b/lib/libc/resolv/res_init.c
index e9e982fe27bb..b21a3fa1670f 100644
--- a/lib/libc/resolv/res_init.c
+++ b/lib/libc/resolv/res_init.c
@@ -95,6 +95,10 @@
#include "res_private.h"
+#ifdef SOLARIS2
+#include <sys/systeminfo.h>
+#endif
+
static void res_setoptions(res_state, const char *, const char *);
#ifdef RESOLVSORT
@@ -215,6 +219,28 @@ __res_vinit(res_state statp, int preinit) {
#endif
res_setservers(statp, u, nitems(u));
+#ifdef SOLARIS2
+ /*
+ * The old libresolv derived the defaultdomain from NIS/NIS+.
+ * We want to keep this behaviour
+ */
+ {
+ char buf[sizeof(statp->defdname)], *cp;
+ int ret;
+
+ if ((ret = sysinfo(SI_SRPC_DOMAIN, buf, sizeof(buf))) > 0 &&
+ (unsigned int)ret <= sizeof(buf)) {
+ if (buf[0] == '+')
+ buf[0] = '.';
+ cp = strchr(buf, '.');
+ cp = (cp == NULL) ? buf : (cp + 1);
+ strncpy(statp->defdname, cp,
+ sizeof(statp->defdname) - 1);
+ statp->defdname[sizeof(statp->defdname) - 1] = '\0';
+ }
+ }
+#endif /* SOLARIS2 */
+
/* Allow user to override the local domain definition */
if ((cp = secure_getenv("LOCALDOMAIN")) != NULL) {
(void)strncpy(statp->defdname, cp, sizeof(statp->defdname) - 1);
@@ -554,6 +580,22 @@ res_setoptions(res_state statp, const char *options, const char *source)
if (statp->options & RES_DEBUG)
printf(";;\ttimeout=%d\n", statp->retrans);
#endif
+#ifdef SOLARIS2
+ } else if (!strncmp(cp, "retrans:", sizeof("retrans:") - 1)) {
+ /*
+ * For backward compatibility, 'retrans' is
+ * supported as an alias for 'timeout', though
+ * without an imposed maximum.
+ */
+ statp->retrans = atoi(cp + sizeof("retrans:") - 1);
+ } else if (!strncmp(cp, "retry:", sizeof("retry:") - 1)){
+ /*
+ * For backward compatibility, 'retry' is
+ * supported as an alias for 'attempts', though
+ * without an imposed maximum.
+ */
+ statp->retry = atoi(cp + sizeof("retry:") - 1);
+#endif /* SOLARIS2 */
} else if (!strncmp(cp, "attempts:", sizeof("attempts:") - 1)){
i = atoi(cp + sizeof("attempts:") - 1);
if (i <= RES_MAXRETRY)