[network-manager-openvpn/bg/bgo774730: 1/3] support numeric argument to mssfix



commit ed812d0fa2a57cbc372076c7c6328f7df09a4d75
Author: Thomas Haller <thaller redhat com>
Date:   Mon Nov 7 17:18:55 2016 +0100

    support numeric argument to mssfix
    
    https://bugzilla.gnome.org/show_bug.cgi?id=739087

 properties/import-export.c |   13 ++++++++++---
 src/nm-openvpn-service.c   |   17 +++++++++++------
 2 files changed, 21 insertions(+), 9 deletions(-)
---
diff --git a/properties/import-export.c b/properties/import-export.c
index 00abc84..1993026 100644
--- a/properties/import-export.c
+++ b/properties/import-export.c
@@ -916,8 +916,12 @@ do_import (const char *path, const char *contents, gsize contents_len, GError **
                if (NM_IN_STRSET (params[0], NMV_OVPN_TAG_MSSFIX)) {
                        if (!args_params_check_nargs_minmax (params, 0, 1, &line_error))
                                goto handle_line_error;
-                       /* TODO: handle the mssfix argument. */
-                       setting_vpn_add_data_item (s_vpn, NM_OPENVPN_KEY_MSSFIX, "yes");
+                       if (params[1]) {
+                               if (!args_params_parse_int64 (params, 1, 1, G_MAXINT32, &v_int64, 
&line_error))
+                                       goto handle_line_error;
+                               setting_vpn_add_data_item_int64 (s_vpn, NM_OPENVPN_KEY_MSSFIX, v_int64);
+                       } else
+                               setting_vpn_add_data_item (s_vpn, NM_OPENVPN_KEY_MSSFIX, "yes");
                        continue;
                }
 
@@ -1872,8 +1876,11 @@ do_export_create (NMConnection *connection, const char *path, GError **error)
        if (nm_streq0 (nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_FLOAT), "yes"))
                args_write_line (f, NMV_OVPN_TAG_FLOAT);
 
-       if (nm_streq0 (nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_MSSFIX), "yes"))
+       value = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_MSSFIX);
+       if (nm_streq0 (value, "yes"))
                args_write_line (f, NMV_OVPN_TAG_MSSFIX);
+       else if (value)
+               args_write_line_setting_value_int (f, NMV_OVPN_TAG_MSSFIX, s_vpn, NM_OPENVPN_KEY_MSSFIX);
 
        args_write_line_setting_value_int (f, NMV_OVPN_TAG_TUN_MTU, s_vpn, NM_OPENVPN_KEY_TUNNEL_MTU);
 
diff --git a/src/nm-openvpn-service.c b/src/nm-openvpn-service.c
index be39b8c..d7bd29f 100644
--- a/src/nm-openvpn-service.c
+++ b/src/nm-openvpn-service.c
@@ -118,7 +118,7 @@ static ValidProperty valid_properties[] = {
        { NM_OPENVPN_KEY_FRAGMENT_SIZE,        G_TYPE_INT, 0, G_MAXINT, FALSE },
        { NM_OPENVPN_KEY_KEY,                  G_TYPE_STRING, 0, 0, FALSE },
        { NM_OPENVPN_KEY_LOCAL_IP,             G_TYPE_STRING, 0, 0, TRUE },
-       { NM_OPENVPN_KEY_MSSFIX,               G_TYPE_BOOLEAN, 0, 0, FALSE },
+       { NM_OPENVPN_KEY_MSSFIX,               G_TYPE_STRING, 0, 0, FALSE },
        { 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 },
@@ -1124,6 +1124,8 @@ nm_openvpn_start_openvpn_binary (NMOpenvpnPlugin *plugin,
        gs_free char *bus_name = NULL;
        NMSettingVpn *s_vpn;
        const char *connection_type;
+       gint64 v_int64;
+       char sbuf_64[65];
 
        s_vpn = nm_connection_get_setting_vpn (connection);
        if (!s_vpn) {
@@ -1519,10 +1521,8 @@ nm_openvpn_start_openvpn_binary (NMOpenvpnPlugin *plugin,
        }
 
        if (gl.log_level_ovpn >= 0) {
-               char buf[20];
-
                add_openvpn_arg (args, "--verb");
-               add_openvpn_arg (args, nm_sprintf_buf (buf, "%d", gl.log_level_ovpn));
+               add_openvpn_arg (args, nm_sprintf_buf (sbuf_64, "%d", gl.log_level_ovpn));
        }
 
        if (gl.log_syslog) {
@@ -1560,8 +1560,13 @@ nm_openvpn_start_openvpn_binary (NMOpenvpnPlugin *plugin,
 
        /* mssfix */
        tmp = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_MSSFIX);
-       if (tmp && !strcmp (tmp, "yes")) {
-               add_openvpn_arg (args, "--mssfix");
+       if (tmp) {
+               if (nm_streq (tmp, "yes"))
+                       add_openvpn_arg (args, "--mssfix");
+               else if ((v_int64 = _nm_utils_ascii_str_to_int64 (tmp, 10, 1, G_MAXINT32, 0))) {
+                       add_openvpn_arg (args, "--mssfix");
+                       add_openvpn_arg (args, nm_sprintf_buf (sbuf_64, "%d", (int) v_int64));
+               }
        }
 
        /* Punch script security in the face; this option was added to OpenVPN 2.1-rc9


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