[NetworkManager-openvpn/bg/ipv4-invalid: 8/8] helper: ignore IPv4 configuration without an address




commit 353a521bc08e2c762e7c63d10f8e3233e9442b08
Author: Beniamino Galvani <bgalvani redhat com>
Date:   Fri Feb 19 10:03:41 2021 +0100

    helper: ignore IPv4 configuration without an address
    
    This is the same as commit 56bb08f2956e ("helper: ignore IPv6
    configuration without an address") but for IPv4.
    
    NetworkManager always rejects configurations without an address, so
    ignore them. A configuration without address can be created, for
    example, if the server advertises IPv4 routes or domains without an
    address.
    
    https://gitlab.gnome.org/GNOME/NetworkManager-openvpn/-/merge_requests/35
    https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/62

 src/nm-openvpn-service-openvpn-helper.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/src/nm-openvpn-service-openvpn-helper.c b/src/nm-openvpn-service-openvpn-helper.c
index d85906b..6197f97 100644
--- a/src/nm-openvpn-service-openvpn-helper.c
+++ b/src/nm-openvpn-service-openvpn-helper.c
@@ -752,12 +752,15 @@ main (int argc, char *argv[])
 
        ip4config = g_variant_builder_end (&ip4builder);
 
-       if (g_variant_n_children (ip4config)) {
-               val = g_variant_new_boolean (TRUE);
-               g_variant_builder_add (&builder, "{sv}", NM_VPN_PLUGIN_CONFIG_HAS_IP4, val);
-       } else {
+       size = g_variant_n_children (ip4config);
+       if (size == 0 || !has_ip4_address) {
+               if (size > 0)
+                       _LOGW ("Ignoring IPv4 configuration without an address");
                g_variant_unref (ip4config);
                ip4config = NULL;
+       } else {
+               val = g_variant_new_boolean (TRUE);
+               g_variant_builder_add (&builder, "{sv}", NM_VPN_PLUGIN_CONFIG_HAS_IP4, val);
        }
 
        ip6config = g_variant_builder_end (&ip6builder);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]