git: 702c24ccc0c2 - main - libc/resolv: Export __res_conf_name

From: Dag-Erling Smørgrav <des_at_FreeBSD.org>
Date: Mon, 29 Jun 2026 15:52:19 UTC
The branch main has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=702c24ccc0c208e9bc697e775abe47ff723e3012

commit 702c24ccc0c208e9bc697e775abe47ff723e3012
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-06-28 09:37:40 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-06-29 13:49:20 +0000

    libc/resolv: Export __res_conf_name
    
    Add a new global variable, __res_conf_name, which is initialized to
    _PATH_RESCONF and used in its place by res_init().  This allows test
    programs (and applications) to select a different configuration file
    to read instead of /etc/resolv.conf.
    
    PR:             220610
---
 lib/libc/resolv/Symbol.map | 4 ++++
 lib/libc/resolv/res_init.c | 5 ++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/libc/resolv/Symbol.map b/lib/libc/resolv/Symbol.map
index 26daecbe2eff..c12d594a7e6b 100644
--- a/lib/libc/resolv/Symbol.map
+++ b/lib/libc/resolv/Symbol.map
@@ -105,3 +105,7 @@ FBSD_1.0 {
 FBSD_1.4 {
 	__res_nrandomid;
 };
+
+FBSD_1.9 {
+	__res_conf_name;
+};
diff --git a/lib/libc/resolv/res_init.c b/lib/libc/resolv/res_init.c
index 64522ef8f562..7466193e7476 100644
--- a/lib/libc/resolv/res_init.c
+++ b/lib/libc/resolv/res_init.c
@@ -116,6 +116,8 @@ static int res_setsortlist(res_state, int, const char *, const char *);
 	(strncmp((str), (word), (end) - (str)) == 0 &&			\
 	    (word)[(end) - (str)] == '\0')
 
+const char *__res_conf_name = _PATH_RESCONF;
+
 /*
  * Resolver state default settings.
  */
@@ -214,7 +216,8 @@ __res_vinit(res_state statp, int preinit)
 	res_setservers(statp, u, nitems(u));
 
 	/* read the configuration file */
-	res_readconf(statp, _PATH_RESCONF, maxns);
+	if (__res_conf_name != NULL)
+		res_readconf(statp, __res_conf_name, maxns);
 
 	/* Allow user to override the local domain definition */
 	if ((cp = secure_getenv("LOCALDOMAIN")) != NULL) {