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);
}