From: "d12fk (Code Review)" Date: Wed, 12 Mar 2025 04:06:32 +0000 In-Reply-To: References: Reply-To: heiko@...515..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <00f14410ef33a0baae913e7dee0515c9abbeef2e-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="D5c8Kfq36u4="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: dns: clean up --dhcp-options when --dns is active List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --D5c8Kfq36u4= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: d12fk, plaisthos. Hello flichtenheld, plaisthos, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/904?usp=3Demail to look at the new patch set (#3). The change is no longer submittable: checks~ChecksSubmitRule is unsatisfied= now. Change subject: dns: clean up --dhcp-options when --dns is active ...................................................................... dns: clean up --dhcp-options when --dns is active Since --dns setting overrule DNS related --dhcp-options, remove the latter when we got some via --dns. Change-Id: I635c4018fb43b5976a39b6a90cb2e9cb2570cd6a Signed-off-by: Heiko Hund --- M src/openvpn/options.c 1 file changed, 47 insertions(+), 0 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/04/904/3 diff --git a/src/openvpn/options.c b/src/openvpn/options.c index afb3999..1bcd7bf 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -4161,6 +4161,53 @@ if (success) { dns_options_postprocess_pull(&o->dns_options); + +#if defined(_WIN32) || defined(TARGET_ANDROID) + /* If there's --dns servers, remove dns related --dhcp-options */ + if (o->dns_options.servers) + { + o->tuntap_options.dns_len =3D 0; + o->tuntap_options.dns6_len =3D 0; + o->tuntap_options.domain =3D NULL; + o->tuntap_options.domain_search_list_len =3D 0; + } +#else /* if defined(_WIN32) || defined(TARGET_ANDROID) */ + /* Clean up env from overridden DNS config */ + struct gc_arena gc =3D gc_new(); + struct buffer name =3D alloc_buf_gc(OPTION_PARM_SIZE, &gc); + struct buffer value =3D alloc_buf_gc(OPTION_PARM_SIZE, &gc); + + const int fo_count =3D o->foreign_option_index; + o->foreign_option_index =3D 0; + + for (int i =3D 1; i <=3D fo_count; ++i) + { + buf_clear(&name); + buf_printf(&name, "foreign_option_%d", i); + const char *env_str =3D env_set_get(es, BSTR(&name)); + const char *item_val =3D strchr(env_str, '=3D') + 1; + buf_clear(&value); + buf_printf(&value, "%s", item_val); + + /* Remove foreign option item from env set */ + env_set_del(es, BSTR(&name)); + + item_val =3D BSTR(&value); + if (strncmp(item_val, "dhcp-option ", 12) !=3D 0 + || (strncmp(item_val + 12, "ADAPTER-DOMAIN-SUFFIX ", 22) != =3D 0 + && strncmp(item_val + 12, "DOMAIN-SEARCH ", 14) !=3D 0 + && strncmp(item_val + 12, "DOMAIN ", 7) !=3D 0 + && strncmp(item_val + 12, "DNS6 ", 5) !=3D 0 + && strncmp(item_val + 12, "DNS ", 4) !=3D 0)) + { + /* Re-set the item with potentially updated name */ + buf_clear(&name); + buf_printf(&name, "foreign_option_%d", ++o->foreign_option= _index); + setenv_str(es, BSTR(&name), BSTR(&value)); + } + } + gc_free(&gc); +#endif /* defined(_WIN32) || defined(TARGET_ANDROID) */ } return success; } -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/904?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I635c4018fb43b5976a39b6a90cb2e9cb2570cd6a Gerrit-Change-Number: 904 Gerrit-PatchSet: 3 Gerrit-Owner: d12fk Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: d12fk Gerrit-MessageType: newpatchset --D5c8Kfq36u4= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: d12fk, plaisthos.

d12fk uploaded patch set #3 to this change.

View Change

The change is no longer submittable: checks~ChecksSubmitRule is uns= atisfied now.

dns: clean up --dhcp-options when --dns is active

Sinc= e --dns setting overrule DNS related --dhcp-options,
remove the latter w= hen we got some via --dns.

Change-Id: I635c4018fb43b5976a39b6a90cb2e= 9cb2570cd6a
Signed-off-by: Heiko Hund <heiko@...2662...>
---M src/openvpn/options.c
1 file changed, 47 insertions(+), 0 deletions(-= )

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/04=
/904/3
diff --git a/src/openvpn/options.c b/src/openvpn/options.c
index afb3999..1bcd7bf 100644
--- a/src/open= vpn/options.c
+++ b/src/openvpn/options.c
@= @ -4161,6 +4161,53 @@
if (success)
= {
dns_options_postprocess_pull(&o->dns_op= tions);
+
<= span style=3D"color: hsl(120, 100%, 40%);">+#if defined(_WIN32) || defined(= TARGET_ANDROID)

+ = /* If there's --dns servers, remove dns related --dhcp-options */
+ if (o->dns= _options.servers)
+ = {
+ = o->tuntap_options.dns_len =3D 0;
+ o->tuntap_options.dns6_len =3D 0;
= + o->tuntap_optio= ns.domain =3D NULL;
+= o->tuntap_options.domain_search_list_len =3D 0;
+ }

+#else /* if defined(_WIN32) || defined(T= ARGET_ANDROID) */
+ = /* Clean up env from overridden DNS config */
+ struct gc_arena gc =3D gc_new();<= /span>
+ struct buffe= r name =3D alloc_buf_gc(OPTION_PARM_SIZE, &gc);
+ struct buffer value =3D alloc_buf= _gc(OPTION_PARM_SIZE, &gc);
+
+ = const int fo_count =3D o->foreign_option_index;
+ o->foreign_option_index =3D 0;=
+
+ for (int i =3D 1; i <=3D fo= _count; ++i)
+ = {
+ buf_c= lear(&name);
+ = buf_printf(&name, "foreign_option_%d", i);+ const char *env_s= tr =3D env_set_get(es, BSTR(&name));
+ const char *item_val =3D strchr(env_str, &= #39;=3D') + 1;
+ = buf_clear(&value);
+ buf_printf(&value, "%s", item_val);=
+
+ /* Remove foreign option i= tem from env set */
+= env_set_del(es, BSTR(&name));
+
+ item_val =3D BSTR(&value);
+ if (strncmp(item_val, "dhcp-= option ", 12) !=3D 0
+ || (strncmp(item_val + 12, "ADAPTER-DOMAIN-SUFFI= X ", 22) !=3D 0
= + && strncmp(item_val + 12, "DOMAIN-SEARCH = ", 14) !=3D 0
+ = && strncmp(item_val + 12, "DOMAIN ", 7= ) !=3D 0
+ = && strncmp(item_val + 12, "DNS6 ", 5) !=3D 0
+ &am= p;& strncmp(item_val + 12, "DNS ", 4) !=3D 0))
+ {

+ /* Re-set the item with = potentially updated name */
+ buf_clear(&name);
+ buf_printf(&name, "forei= gn_option_%d", ++o->foreign_option_index);
+ setenv_str(es, BSTR(&nam= e), BSTR(&value));
+ = }
+ gc_fr= ee(&gc);
+#endif = /* defined(_WIN32) || defined(TARGET_ANDROID) */
}
return success;
}

To view, visit change 904. To unsubscribe, or for help writing mai= l filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I635c4018fb43b5976a39b6a90cb= 2e9cb2570cd6a
Gerrit-Change-Number: 904
Gerrit-PatchSet: 3
Gerrit-Owner: d12fk <heiko@...515...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: d12fk <heiko@...515...>= ;
Gerrit-MessageType: newpatchset
--D5c8Kfq36u4=--