From: "plaisthos (Code Review)" Date: Mon, 16 Sep 2024 13:04:08 +0000 References: Reply-To: arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <16273cddc913033cb2871584840dd12ce04675f7-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="l4+By+ulJAg="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Automatically enable ifconfig-exec/route-exec behaviour for afunix tu... List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld Cc: openvpn-devel --l4+By+ulJAg= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld. Hello flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/750?usp=3Demail to review the following change. Change subject: Automatically enable ifconfig-exec/route-exec behaviour for= afunix tun/tap ...................................................................... Automatically enable ifconfig-exec/route-exec behaviour for afunix tun/tap Change-Id: I0a2957699757665d70514ba7cafe833443018ad6 Signed-off-by: Arne Schwabe --- M src/openvpn/init.c 1 file changed, 27 insertions(+), 4 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/50/750/1 diff --git a/src/openvpn/init.c b/src/openvpn/init.c index 8d37a7f..ae5a1f4 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -1679,6 +1679,17 @@ #endif /* ifdef ENABLE_MANAGEMENT */ } +/** + * Determine if external route commands should be executed based on + * configured options and backend driver + */ +static bool +route_noexec_enabled(const struct options *o, const struct tuntap *tt) +{ + return o->route_noexec + || (tt && tt->backend_driver =3D=3D DRIVER_AFUNIX); +} + /* * Possibly add routes and/or call route-up script * based on options. @@ -1693,7 +1704,7 @@ openvpn_net_ctx_t *ctx) { bool ret =3D true; - if (!options->route_noexec && ( route_list || route_ipv6_list ) ) + if (!route_noexec_enabled(options, tt) && ( route_list || route_ipv6_l= ist ) ) { ret =3D add_routes(route_list, route_ipv6_list, tt, ROUTE_OPTION_F= LAGS(options), es, ctx); @@ -1858,6 +1869,18 @@ #endif } +/** + * Determines if ifconfig execution should be disabled because of a + * @param c + * @return + */ +static bool +ifconfig_noexec_enabled(const struct context *c) +{ + return c->options.ifconfig_noexec + || (c->c1.tuntap && c->c1.tuntap->backend_driver =3D=3D DRIVER_= AFUNIX); +} + static void open_tun_backend(struct context *c) { @@ -1937,7 +1960,7 @@ } /* do ifconfig */ - if (!c->options.ifconfig_noexec + if (!ifconfig_noexec_enabled(c) && ifconfig_order(c->c1.tuntap) =3D=3D IFCONFIG_BEFORE_TUN_OPE= N) { /* guess actual tun/tap unit number that will be returned @@ -1978,7 +2001,7 @@ } /* do ifconfig */ - if (!c->options.ifconfig_noexec + if (!ifconfig_noexec_enabled(c) && ifconfig_order(c->c1.tuntap) =3D=3D IFCONFIG_AFTER_TUN_OPEN) { do_ifconfig(c->c1.tuntap, c->c1.tuntap->actual_name, @@ -2061,7 +2084,7 @@ if (c->c1.tuntap) { - if (!c->options.ifconfig_noexec) + if (!ifconfig_noexec_enabled(c)) { undo_ifconfig(c->c1.tuntap, &c->net_ctx); } -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/750?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: I0a2957699757665d70514ba7cafe833443018ad6 Gerrit-Change-Number: 750 Gerrit-PatchSet: 1 Gerrit-Owner: plaisthos Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-Attention: flichtenheld Gerrit-MessageType: newchange --l4+By+ulJAg= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld.

plaisthos would like flichtenheld to review this change.

Vi= ew Change

Automatically enable ifconfig-exec/route-exec behaviour for a=
funix tun/tap

Change-Id: I0a2957699757665d70514ba7cafe833443018ad6Signed-off-by: Arne Schwabe <arne@...1227...>
---
M src/openv= pn/init.c
1 file changed, 27 insertions(+), 4 deletions(-)

=
git=
 pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/50/750/1
= diff --git a/src/openvpn/init.c b/src/openvpn/init.c
index = 8d37a7f..ae5a1f4 100644
--- a/src/openvpn/init.c
= +++ b/src/openvpn/init.c
@@ -1679,6 +1679,17 @@
#endif /* ifdef ENABLE_MANAGEMENT */
}<= br>
+/**
+ * Determine if external = route commands should be executed based on
+ * configured options and backend driver
<= span style=3D"color: hsl(120, 100%, 40%);">+ */

+static bool
+route_noexec_enabled(const struct options *o, const str= uct tuntap *tt)
+{
+ return o->route= _noexec
+ |= | (tt && tt->backend_driver =3D=3D DRIVER_AFUNIX);
+}

+
/*
* Possibly a= dd routes and/or call route-up script
* based on options.=
@@ -1693,7 +1704,7 @@
openvpn_ne= t_ctx_t *ctx)
{
bool ret =3D true;
- if (!options->rou= te_noexec && ( route_list || route_ipv6_list ) )
+ if (!route_noexec_enabled(options,= tt) && ( route_list || route_ipv6_list ) )
{<= /span>
ret =3D add_routes(route_list, route_ipv6_list, tt= , ROUTE_OPTION_FLAGS(options),
es= , ctx);
@@ -1858,6 +1869,18 @@
#endif
}

+/**
+ * = Determines if ifconfig execution should be disabled because of a
= + * @param c
+ * @return
+ */
+static bool
+ifconfig_noexec_enabled(const struct context *c)
+{
+ return c->options.ifconfig_noexec
+ || (c->c1.tuntap &&a= mp; c->c1.tuntap->backend_driver =3D=3D DRIVER_AFUNIX);
+}

+
static void
open= _tun_backend(struct context *c)
{
@@ -1937= ,7 +1960,7 @@
}

= /* do ifconfig */
- if (!c->options.ifconfig_noexec
+ if (!ifconfig_noexec_enabled(c)<= br> && ifconfig_order(c->c1.tuntap) =3D=3D IFC= ONFIG_BEFORE_TUN_OPEN)
{
= /* guess actual tun/tap unit number that will be returned
@@ -1978,7 +2001,7 @@

}

/* do ifconfig */
- if (!c->options.ifconfig_noexec
+ if (!ifconfig_noexec_enabled= (c)
&& ifconfig_order(c->c1.tuntap)= =3D=3D IFCONFIG_AFTER_TUN_OPEN)
{
do_ifconfig(c->c1.tuntap, c->c1.tuntap->actual_name,=

@@ -2061,7 +2084,7 @@

= if (c->c1.tuntap)
{
- if (!c->options.ifconfig_noexec)=
+ if (!ifconfig_noex= ec_enabled(c))
{
undo= _ifconfig(c->c1.tuntap, &c->net_ctx);
}<= /span>

To view, visit change 750. To unsubscribe, o= r for help writing mail filters, visit settings.

=
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I0a2957699757665d70514ba7caf= e833443018ad6
Gerrit-Change-Number: 750
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newchange
--l4+By+ulJAg=--