From: "d12fk (Code Review)" Date: Thu, 26 Jun 2025 09:10:37 +0000 In-Reply-To: References: Reply-To: heiko@...515..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="C+AoLjQywXE="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: run forced --dns-updown without --script-security List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --C+AoLjQywXE= 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/+/1065?usp=3Demail to look at the new patch set (#2). Change subject: run forced --dns-updown without --script-security ...................................................................... run forced --dns-updown without --script-security Due to a shortcut in the `--dns-updown force' implementation, running the default dns-updown script required `--script-security 2'. This makes the forced default script run without --script-security set. Change-Id: I55940b78e35f0e3d74aa6cba14378afed97a444e Signed-off-by: Heiko Hund --- M src/openvpn/dns.c M src/openvpn/dns.h M src/openvpn/options.c 3 files changed, 39 insertions(+), 12 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/65/1065/2 diff --git a/src/openvpn/dns.c b/src/openvpn/dns.c index 939ae09..ea3d91b 100644 --- a/src/openvpn/dns.c +++ b/src/openvpn/dns.c @@ -264,7 +264,7 @@ clone.servers =3D clone_dns_servers(o->servers, gc); clone.servers_prepull =3D clone_dns_servers(o->servers_prepull, gc); clone.updown =3D o->updown; - clone.user_set_updown =3D o->user_set_updown; + clone.updown_flags =3D o->updown_flags; return clone; } @@ -580,7 +580,7 @@ argv_printf(&argv, "%s", o->updown); argv_msg(M_INFO, &argv); int res; - if (o->user_set_updown) + if (dns_updown_user_set(o)) { res =3D openvpn_run_script(&argv, es, S_EXITCODE, "dns updown"); } @@ -692,7 +692,7 @@ run_up_down_command(bool up, struct options *o, const struct tuntap *tt, s= truct dns_updown_runner_info *updown_runner) { struct dns_options *dns =3D &o->dns_options; - if (!dns->updown || (o->up_script && !dns->user_set_updown)) + if (!dns->updown || (o->up_script && !dns_updown_user_set(dns) && !dns= _updown_forced(dns))) { return; } diff --git a/src/openvpn/dns.h b/src/openvpn/dns.h index 688daa7..d33f64e 100644 --- a/src/openvpn/dns.h +++ b/src/openvpn/dns.h @@ -42,13 +42,18 @@ DNS_TRANSPORT_TLS }; +enum dns_updown_flags { + DNS_UPDOWN_NO_FLAGS, + DNS_UPDOWN_USER_SET, + DNS_UPDOWN_FORCED +}; + struct dns_domain { struct dns_domain *next; const char *name; }; -struct dns_server_addr -{ +struct dns_server_addr { union { struct in_addr a4; struct in6_addr a6; @@ -103,7 +108,7 @@ struct dns_server *servers; struct gc_arena gc; const char *updown; - bool user_set_updown; + enum dns_updown_flags updown_flags; }; /** @@ -195,4 +200,26 @@ */ void show_dns_options(const struct dns_options *o); +/** + * Returns whether dns-updown is user defined + * + * @param o Pointer to the DNS options struct + */ +static inline bool +dns_updown_user_set(const struct dns_options *o) +{ + return o->updown_flags =3D=3D DNS_UPDOWN_USER_SET; +} + +/** + * Returns whether dns-updown is forced to run + * + * @param o Pointer to the DNS options struct + */ +static inline bool +dns_updown_forced(const struct dns_options *o) +{ + return o->updown_flags =3D=3D DNS_UPDOWN_FORCED; +} + #endif /* ifndef DNS_H */ diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 7e26069..af097f8 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -3593,7 +3593,7 @@ struct gc_arena gc =3D gc_new(); struct dns_options *dns =3D &o->dns_options; - if (dns->servers || dns->user_set_updown) + if (dns->servers || dns_updown_user_set(dns) || dns_updown_forced(dns)) { /* Clean up env from --dhcp-option DNS config */ struct buffer name =3D alloc_buf_gc(OPTION_PARM_SIZE, &gc); @@ -3667,7 +3667,7 @@ } } } - else if (o->up_script && !dns->user_set_updown) + else if (o->up_script && !dns_updown_user_set(dns) && !dns_updown_forc= ed(dns)) { /* Set foreign option env vars from --dns config */ const char *p[] =3D { "dhcp-option", NULL, NULL }; @@ -8182,15 +8182,15 @@ if (streq(p[1], "disable")) { dns->updown =3D NULL; - dns->user_set_updown =3D false; + dns->updown_flags =3D DNS_UPDOWN_NO_FLAGS; } else if (streq(p[1], "force")) { /* force dns-updown run, even if a --up script is defined */ - if (dns->user_set_updown =3D=3D false) + if (!dns_updown_user_set(dns)) { dns->updown =3D DEFAULT_DNS_UPDOWN; - dns->user_set_updown =3D true; + dns->updown_flags =3D DNS_UPDOWN_FORCED; } } else @@ -8201,7 +8201,7 @@ dns->updown =3D NULL; } set_user_script(options, &dns->updown, p[1], p[0], false); - dns->user_set_updown =3D true; + dns->updown_flags =3D DNS_UPDOWN_USER_SET; } } else if (streq(p[0], "dns") && p[1]) -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1065?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: I55940b78e35f0e3d74aa6cba14378afed97a444e Gerrit-Change-Number: 1065 Gerrit-PatchSet: 2 Gerrit-Owner: d12fk Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: d12fk Gerrit-MessageType: newpatchset --C+AoLjQywXE= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: d12fk, plaisthos.

d12fk uploaded patch set #2 to this change.

View Change

run forced --dns-updown without --script-security

Due to a shortc= ut in the `--dns-updown force' implementation, running the
default d= ns-updown script required `--script-security 2'. This makes the
forc= ed default script run without --script-security set.

Change-Id: I559= 40b78e35f0e3d74aa6cba14378afed97a444e
Signed-off-by: Heiko Hund <heik= o@...2662...>
---
M src/openvpn/dns.c
M src/openvpn/dns.h
M = src/openvpn/options.c
3 files changed, 39 insertions(+), 12 deletions(-)=

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/65/=
1065/2
diff --git a/src/openvpn/dns.c b/src/openvpn/dns.cindex 939ae09..ea3d91b 100644
--- a/src/openvpn/dns.= c
+++ b/src/openvpn/dns.c
@@ -264,7 +264,7 = @@
clone.servers =3D clone_dns_servers(o->servers, = gc);
clone.servers_prepull =3D clone_dns_servers(o->= ;servers_prepull, gc);
clone.updown =3D o->updown;<= /span>
- clone.user_set_upd= own =3D o->user_set_updown;
+ clone.updown_flags =3D o->updown_flags;
=
return clone;
}
@@ -= 580,7 +580,7 @@
argv_printf(&argv, "%s",= o->updown);
argv_msg(M_INFO, &argv); int res;
- = if (o->user_set_updown)
+ if (dns_updown_user_set(o))
{
= res =3D openvpn_run_script(&argv, es, S_EXITCODE, "= dns updown");
}
@@ -692,7 +692,7 = @@
run_up_down_command(bool up, struct options *o, const s= truct tuntap *tt, struct dns_updown_runner_info *updown_runner)
<= span> {

struct dns_options *dns =3D &o->dns_opt= ions;
- if (!dns->= ;updown || (o->up_script && !dns->user_set_updown))+ if (!dns->updown || (o= ->up_script && !dns_updown_user_set(dns) && !dns_updown_= forced(dns)))
{
return;
}
diff --git a/src/openvpn/dns.h b/src/open= vpn/dns.h
index 688daa7..d33f64e 100644
---= a/src/openvpn/dns.h
+++ b/src/openvpn/dns.h
@@ -42,13 +42,18 @@

DNS_TRANSPORT_TLS
};

+enum dns_updown_flags {
+ DNS_UPDOWN_NO_FLAGS,
+ DNS_UPDOWN_USER_SET,
+ DNS_UPDOWN_FORCED
+};
-struct d= ns_server_addr
-{
+struct dns_server_addr {<= /span>
union {
struct in_addr a4;
struct in6_addr a6;
@@ -103,7 +108,7= @@
struct dns_server *servers;
s= truct gc_arena gc;
const char *updown;
- bool user_set_updown;

<= span style=3D"color: hsl(120, 100%, 40%);">+ enum dns_updown_flags updow= n_flags;

};

/**<= br>@@ -195,4 +200,26 @@
*/
void sh= ow_dns_options(const struct dns_options *o);

+/**

+ * Returns whether dns-updown is user defined
+ *
+ * @param o Pointer to the = DNS options struct
+ = */
+static inline boo= l
+dns_updown_user_se= t(const struct dns_options *o)
+{
+ ret= urn o->updown_flags =3D=3D DNS_UPDOWN_USER_SET;
+}
+
+/**
+ * Returns whether dns= -updown is forced to run
+ *
+ * @param = o Pointer to the DNS options struct
+ */
+static inline bool
+dns_updown_forced(const struct dns_options *o)
+{
+ return o->updown_flags =3D=3D DNS_UPDOWN_FORCED;
+}
+
#endif /* ifndef DNS_= H */
diff --git a/src/openvpn/options.c b/src/openvpn/optio= ns.c
index 7e26069..af097f8 100644
--- a/sr= c/openvpn/options.c
+++ b/src/openvpn/options.c
<= span>@@ -3593,7 +3593,7 @@

struct gc_arena gc =3D gc_n= ew();
struct dns_options *dns =3D &o->dns_optio= ns;

-= if (dns->servers || dns->user_set_updown)
+ if (dns->servers || dns_updown_use= r_set(dns) || dns_updown_forced(dns))
{
/* Clean up env from --dhcp-option DNS config */

struct buffer name =3D alloc_buf_gc(OPTION_PARM_SIZE, &gc);
@@ -3667,7 +3667,7 @@
}<= br> }
}
- else if (o->up_script && !dns->user_= set_updown)
+ else= if (o->up_script && !dns_updown_user_set(dns) && !dns_u= pdown_forced(dns))
{
/* Set f= oreign option env vars from --dns config */
const = char *p[] =3D { "dhcp-option", NULL, NULL };
@@ -= 8182,15 +8182,15 @@
if (streq(p[1], "disable&= quot;))
{
dns->upd= own =3D NULL;
- = dns->user_set_updown =3D false;
+ dns->updown_flags =3D DNS_UPDOWN_NO_FLAGS= ;
}
else if (streq(p[1], = "force"))
{
= /* force dns-updown run, even if a --up script is defined */
- if (dns->user_set_up= down =3D=3D false)

+ = if (!dns_updown_user_set(dns))
{
dns->updown =3D DEFAULT_DNS_UPDOWN;
- dns->use= r_set_updown =3D true;
- dns->user= _set_updown =3D true;
+ dns->updown_flags =3D DNS_UPDOWN_USER_SET;
}

}
else if (streq(p[0]= , "dns") && p[1])

To = view, visit change 1065. To unsubscribe, or for help writing mail filters, visi= t settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I55940b78e35f0e3d74aa6cba143= 78afed97a444e
Gerrit-Change-Number: 1065
Gerrit-PatchSet: 2
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
--C+AoLjQywXE=--