resolver: sysresolve, names resolved by the system routines

The command keeps the C library's resolution which a configuration
without nserver had before the system's name servers became the
default: no hosts file imported. nserver lines, if any, are still
there for dnspr to forward to. Of sysresolve and fakeresolve the last
given applies.

Tests: sysdns, with sysresolve dnspr has no hosts file names and a
name is resolved through the system routines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Vladimir DubrovinandClaude Opus 5.5 committed 2026-10-20 19:02:37 +03:00
1 parent d5e78a0900
commit 994526dbc4
6 files changed
+67 -8

No files matched your search

+12 -2
View File
@@ -741,6 +741,8 @@ static int h_flushusers(int argc, unsigned char **argv){
force (the process has one list) once it is committed */
static struct nserver cfgns[MAXNSERVERS];
static int cfgnsn = 0;
/* sysresolve: names resolved by the system routines */
static int cfgsysresolve = 0;
static int h_nserver(int argc, unsigned char **argv){
char *str;
@@ -764,13 +766,13 @@ static int h_nserver(int argc, unsigned char **argv){
/* The configuration's name servers, or the system's in their place */
void confdnscommit(struct extparam *c){
sysdnsapply(c, cfgns, cfgnsn);
sysdnsapply(c, cfgns, cfgnsn, cfgsysresolve);
}
/* Whether names would be resolved slowly: by the C library, or by name
servers, the system's taken by default, without a cache */
static int noresolver(void){
if(!conf->resolvfunc && !sysdnscount()) return 1;
if(cfgsysresolve || (!conf->resolvfunc && !sysdnscount())) return 1;
return (!conf->resolvfunc || conf->resolvfunc == myresolver) && !dns_table.poolsize;
}
@@ -790,6 +792,12 @@ static int h_authnserver(int argc, unsigned char **argv){
static int h_fakeresolve(int argc, unsigned char **argv){
conf->resolvfunc = fakeresolver;
cfgsysresolve = 0;
return 0;
}
static int h_sysresolve(int argc, unsigned char **argv){
cfgsysresolve = 1;
return 0;
}
@@ -2146,6 +2154,7 @@ struct commands commandhandlers[]={
{NULL, "flush", h_flush, 1, 1},
{NULL, "nserver", h_nserver, 2, 2},
{NULL, "fakeresolve", h_fakeresolve, 1, 1},
{NULL, "sysresolve", h_sysresolve, 1, 1},
{NULL, "nscache", h_nscache, 2, 2},
{NULL, "nscache6", h_nscache6, 2, 2},
{NULL, "nsrecord", h_nsrecord, 3, 3},
@@ -2534,6 +2543,7 @@ void confbegin(void){
char * args[] = {"auth", "iponly", NULL};
cfgnsn = 0;
cfgsysresolve = 0;
h_auth(2, (unsigned char **)args);
}
+1 -1
View File
@@ -435,7 +435,7 @@ int nscacheresolv(int af, unsigned char *name, unsigned char *value, uint32_t *t
void setnservers(const struct nserver *ns, int n);
void sysdnsinit(void);
int sysdnscount(void);
void sysdnsapply(struct extparam *c, const struct nserver *ns, int n);
void sysdnsapply(struct extparam *c, const struct nserver *ns, int n, int sysresolve);
void sysdnscheck(void);
void confdnscommit(struct extparam *c);
uint32_t udpresolve(int af, unsigned char * name, unsigned char * value, uint32_t *retttl, struct clientparam* param, int makeauth);
+9 -2
View File
@@ -585,9 +585,16 @@ int sysdnscount(void){
/* A configuration committed: the name servers of its nserver lines, else,
with nothing else to resolve names, the system's and its hosts file, read
again. Until then those in force stay. */
void sysdnsapply(struct extparam *c, const struct nserver *ns, int n){
again. Until then those in force stay. With sysresolve the system
routines resolve names, nserver lines left to dnspr. */
void sysdnsapply(struct extparam *c, const struct nserver *ns, int n, int sysresolve){
sysdns.active = 0;
if(sysresolve){
c->resolvfunc = NULL;
setnservers(ns, n);
hostsremove();
return;
}
if(n){
setnservers(ns, n);
hostsremove();