aboutgitcodebugslistschat
path: root/conf.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2021-10-10 01:13:37 +0200
committerStefano Brivio <sbrivio@redhat.com>2021-10-10 01:24:19 +0200
commitdcd3605d14aba011fa6c2f4596cb7494f64d2b93 (patch)
treefd127596e7262ff49b443dd76ab17773378cb09a /conf.c
parent580581fd966015538b527fcd52449055b795cbf4 (diff)
downloadpasst-dcd3605d14aba011fa6c2f4596cb7494f64d2b93.tar
passt-dcd3605d14aba011fa6c2f4596cb7494f64d2b93.tar.gz
passt-dcd3605d14aba011fa6c2f4596cb7494f64d2b93.tar.bz2
passt-dcd3605d14aba011fa6c2f4596cb7494f64d2b93.tar.lz
passt-dcd3605d14aba011fa6c2f4596cb7494f64d2b93.tar.xz
passt-dcd3605d14aba011fa6c2f4596cb7494f64d2b93.tar.zst
passt-dcd3605d14aba011fa6c2f4596cb7494f64d2b93.zip
conf: Don't get IPv{4,6} DNS addresses if IPv{4,6} is disabled
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'conf.c')
-rw-r--r--conf.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/conf.c b/conf.c
index 94ecf44..e020417 100644
--- a/conf.c
+++ b/conf.c
@@ -574,8 +574,8 @@ static void get_dns(struct ctx *c)
char buf[BUFSIZ], *p, *end;
FILE *r;
- dns4_set = !!*dns4;
- dns6_set = !IN6_IS_ADDR_UNSPECIFIED(dns6);
+ dns4_set = !c->v4 || !!*dns4;
+ dns6_set = !c->v6 || !IN6_IS_ADDR_UNSPECIFIED(dns6);
dnss_set = !!*s->n || c->no_dns_search;
dns_set = dns4_set || dns6_set || c->no_dns;
@@ -596,13 +596,15 @@ static void get_dns(struct ctx *c)
if (end)
*end = 0;
- if (dns4 - &c->dns4[0] < ARRAY_SIZE(c->dns4) - 1 &&
+ if (!dns4_set &&
+ dns4 - &c->dns4[0] < ARRAY_SIZE(c->dns4) - 1 &&
inet_pton(AF_INET, p + 1, dns4)) {
dns4++;
*dns4 = 0;
}
- if (dns6 - &c->dns6[0] < ARRAY_SIZE(c->dns6) - 1 &&
+ if (!dns6_set &&
+ dns6 - &c->dns6[0] < ARRAY_SIZE(c->dns6) - 1 &&
inet_pton(AF_INET6, p + 1, dns6)) {
dns6++;
memset(dns6, 0, sizeof(*dns6));