From: "cron2 (Code Review)" Date: Tue, 24 Sep 2024 13:27:19 +0000 In-Reply-To: References: Reply-To: gert@...1296..., 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="7mzX6ugzifo="; 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: plaisthos Cc: flichtenheld , openvpn-devel --7mzX6ugzifo= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/75= 0?usp=3Demail ) 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 Acked-by: Gert Doering Message-Id: <20240924131437.22294-1-gert@...1296...> URL: https://www.mail-archive.com/search?l=3Dmid&q=3D20240924131437.22294-1= -gert@...1296... Signed-off-by: Gert Doering --- M src/openvpn/init.c M src/openvpn/tun.c 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/openvpn/init.c b/src/openvpn/init.c index cd9203a..876edad 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -1679,6 +1679,18 @@ #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) + || (tt && tt->backend_driver =3D=3D DRIVER_NULL); +} + /* * Possibly add routes and/or call route-up script * based on options. @@ -1693,7 +1705,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 +1870,19 @@ #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) + || (c->c1.tuntap && c->c1.tuntap->backend_driver =3D=3D DRIVER_= NULL); +} + static void open_tun_backend(struct context *c) { @@ -1937,7 +1962,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 +2003,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 +2086,7 @@ if (c->c1.tuntap) { - if (!c->options.ifconfig_noexec) + if (!ifconfig_noexec_enabled(c)) { undo_ifconfig(c->c1.tuntap, &c->net_ctx); } diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 206ddc0..85fe01a 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -1744,7 +1744,7 @@ void undo_ifconfig(struct tuntap *tt, openvpn_net_ctx_t *ctx) { - if (tt->backend_driver !=3D DRIVER_NULL) + if (tt->backend_driver !=3D DRIVER_NULL && tt->backend_driver !=3D DRI= VER_AFUNIX) { if (tt->did_ifconfig_setup) { -- 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: 12 Gerrit-Owner: plaisthos Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-MessageType: merged --7mzX6ugzifo= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 submitted this change.

View Change

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

Change-Id: I0a2957699757665d70514ba7caf= e833443018ad6
Signed-off-by: Arne Schwabe <arne@...1227...>
Ack= ed-by: Gert Doering <gert@...1296...>
Message-Id: <202409241314= 37.22294-1-gert@...1296...>
URL: https://www.mail-archive.com/search?= l=3Dmid&q=3D20240924131437.22294-1-gert@...1296...
Signed-off-by: Ge= rt Doering <gert@...1296...>
---
M src/openvpn/init.c
M src/= openvpn/tun.c
2 files changed, 30 insertions(+), 5 deletions(-)

<= /pre>
diff --git a/src/openvpn/init.c b/src/openvpn/init.c
ind= ex cd9203a..876edad 100644
--- a/src/openvpn/init.c<= br>+++ b/src/openvpn/init.c
@@ -1679,6 +1679,18 @@
#endif /* ifdef ENABLE_MANAGEMENT */
}

+/**
+ * Determine if extern= al 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->ro= ute_noexec
+ = || (tt && tt->backend_driver =3D=3D DRIVER_AFUNIX)
<= span style=3D"color: hsl(120, 100%, 40%);">+ || (tt && tt= ->backend_driver =3D=3D DRIVER_NULL);

+}
- if (!options->route_noexec &&= ; ( route_list || route_ipv6_list ) )
+ if (!route_noexec_enabled(options, tt) && ( r= oute_list || route_ipv6_list ) )
{
= ret =3D add_routes(route_list, route_ipv6_list, tt, ROUTE_OPTION_FLAG= S(options),
es, ctx);
<= span>@@ -1858,6 +1870,19 @@

#endif
}

+/**
+ * Determines if ifcon= fig 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)
+ || (c->c1.tuntap && c->c1.tun= tap->backend_driver =3D=3D DRIVER_NULL);
+}
+
static void
open_tun_backend(struc= t context *c)
{
@@ -1937,7 +1962,7 @@
}

/* do ifc= onfig */
- if (!= c->options.ifconfig_noexec
+ if (!ifconfig_noexec_enabled(c)
= && ifconfig_order(c->c1.tuntap) =3D=3D IFCONFIG_BEFORE_TUN_O= PEN)
{
/* guess actua= l tun/tap unit number that will be returned
@@ -1978,7 +200= 3,7 @@
}

= /* do ifconfig */
- = if (!c->options.ifconfig_noexec
+ if (!ifconfig_noexec_enabled(c)
&& ifconfig_order(c->c1.tuntap) =3D=3D IFCONFIG_A= FTER_TUN_OPEN)

{
do_i= fconfig(c->c1.tuntap, c->c1.tuntap->actual_name,
@= @ -2061,7 +2086,7 @@

if (c->c1.tu= ntap)
{
- if (!c->options.ifconfig_noexec)
+ if (!ifconfig_noexec_enabled(c))

{
undo_ifconfig(c->c1= .tuntap, &c->net_ctx);
}
di= ff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
index 206d= dc0..85fe01a 100644
--- a/src/openvpn/tun.c
+++ b/src/openvpn/tun.c
@@ -1744,7 +1744,7 @@
void
undo_ifconfig(struct tuntap *tt, openvpn_net_ctx= _t *ctx)
{
- if (tt->backend_driver !=3D DRIVER_NULL)
+ if (tt->backend_driver !=3D DRIVER= _NULL && tt->backend_driver !=3D DRIVER_AFUNIX)
= {
if (tt->did_ifconfig_setup)
{

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

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I0a2957699757665d70514ba7caf= e833443018ad6
Gerrit-Change-Number: 750
Gerrit-PatchSet: 12
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: merged
--7mzX6ugzifo=--