[network-manager-openvpn: 2/3] all: minor fixes for max-routes option



commit ae6de6419da3cf7f69a49b4469861a6a660806d5
Author: Thomas Haller <thaller redhat com>
Date:   Mon Aug 15 10:40:32 2016 +0200

    all: minor fixes for max-routes option
    
    - whitespace/indention
    - openvpn checks for valid ranges as [0, 100000000]
    - sort entries in shared/utils.h alphabetically

 properties/import-export.c |    2 +-
 shared/utils.h             |    2 +-
 src/nm-openvpn-service.c   |   13 ++++++++-----
 3 files changed, 10 insertions(+), 7 deletions(-)
---
diff --git a/properties/import-export.c b/properties/import-export.c
index bbcbe0f..235f088 100644
--- a/properties/import-export.c
+++ b/properties/import-export.c
@@ -990,7 +990,7 @@ do_import (const char *path, const char *contents, gsize contents_len, GError **
                if (NM_IN_STRSET (params[0], NMV_OVPN_TAG_MAX_ROUTES)) {
                        if (!args_params_check_nargs_n (params, 1, &line_error))
                                goto handle_line_error;
-                       if (!args_params_parse_int64 (params, 1, 0, 604800, &v_int64, &line_error))
+                       if (!args_params_parse_int64 (params, 1, 0, 100000000, &v_int64, &line_error))
                                goto handle_line_error;
                        setting_vpn_add_data_item_int64 (s_vpn, NM_OPENVPN_KEY_MAX_ROUTES, v_int64);
                        continue;
diff --git a/shared/utils.h b/shared/utils.h
index 9ab2c48..71038b9 100644
--- a/shared/utils.h
+++ b/shared/utils.h
@@ -42,6 +42,7 @@
 #define NMV_OVPN_TAG_KEY_DIRECTION      "key-direction"
 #define NMV_OVPN_TAG_KEY                "key"
 #define NMV_OVPN_TAG_KEYSIZE            "keysize"
+#define NMV_OVPN_TAG_MAX_ROUTES         "max-routes"
 #define NMV_OVPN_TAG_MSSFIX             "mssfix"
 #define NMV_OVPN_TAG_NOBIND             "nobind"
 #define NMV_OVPN_TAG_NS_CERT_TYPE       "ns-cert-type"
@@ -71,7 +72,6 @@
 #define NMV_OVPN_TAG_TUN_MTU            "tun-mtu"
 #define NMV_OVPN_TAG_TUN_IPV6           "tun-ipv6"
 #define NMV_OVPN_TAG_USER               "user"
-#define NMV_OVPN_TAG_MAX_ROUTES         "max-routes"
 
 gboolean is_pkcs12 (const char *filepath);
 
diff --git a/src/nm-openvpn-service.c b/src/nm-openvpn-service.c
index 40db92a..6f24985 100644
--- a/src/nm-openvpn-service.c
+++ b/src/nm-openvpn-service.c
@@ -120,7 +120,7 @@ static ValidProperty valid_properties[] = {
        { NM_OPENVPN_KEY_PING,                 G_TYPE_INT, 0, G_MAXINT, FALSE },
        { NM_OPENVPN_KEY_PING_EXIT,            G_TYPE_INT, 0, G_MAXINT, FALSE },
        { NM_OPENVPN_KEY_PING_RESTART,         G_TYPE_INT, 0, G_MAXINT, FALSE },
-       { NM_OPENVPN_KEY_MAX_ROUTES,           G_TYPE_INT, 0, 65535, FALSE },
+       { NM_OPENVPN_KEY_MAX_ROUTES,           G_TYPE_INT, 0, 100000000, FALSE },
        { NM_OPENVPN_KEY_PROTO_TCP,            G_TYPE_BOOLEAN, 0, 0, FALSE },
        { NM_OPENVPN_KEY_PORT,                 G_TYPE_INT, 1, 65535, FALSE },
        { NM_OPENVPN_KEY_PROXY_TYPE,           G_TYPE_STRING, 0, 0, FALSE },
@@ -1332,13 +1332,16 @@ nm_openvpn_start_openvpn_binary (NMOpenvpnPlugin *plugin,
        /* max routes allowed from openvpn server */
        tmp = nm_setting_vpn_get_data_item(s_vpn, NM_OPENVPN_KEY_MAX_ROUTES);
        if (tmp) {
+               /* max-routes option is deprecated in 2.4 release
+                * https://github.com/OpenVPN/openvpn/commit/d0085293e709c8a722356cfa68ad74c962aef9a2
+                */
                add_openvpn_arg (args, "--max-routes");
                if (!add_openvpn_arg_int (args, tmp)) {
                        g_set_error (error,
-                                       NM_VPN_PLUGIN_ERROR,
-                                       NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
-                                       _("Invalid max-routes argument '%s'."),
-                                       tmp);
+                                    NM_VPN_PLUGIN_ERROR,
+                                    NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
+                                    _("Invalid max-routes argument '%s'."),
+                                    tmp);
                        free_openvpn_args (args);
                        return FALSE;
                }


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