[OpenVPN] [PATCH] Do not treat space as separator for multiple remote gateway entries (bug 712710)



Please pull from:

  git://iam.tj/network-manager-openvpn.git gnome712710

There is a bug in the parsing of multiple remote gateway specifications.

The tooltip says:

po/id.po:402:msgid "Remote host name or IP address. You can specify multiple
items for redundancy (use commas to separate the entries).
config: remote"

But the code separates on spaces as well as commas
(src/nm-openvpn-service.c::nm_openvpn_start_openvpn_binary()):

    tmp = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_REMOTE);
    if (tmp && strlen (tmp)) {
        char *tok;
        while ((tok = strsep((char**)&tmp, " ,")) != NULL) {
            if (strlen(tok)) {
                add_openvpn_arg (args, "--remote");
                add_openvpn_arg (args, tok);
            }
        }
    }

So the following entry in the Gateway text-box "a.b.c.d 1194 udp, e.f.g.h 443
tcp"

which is stored in /etc/NetworkManager/system-connections/server as:

 remote=a.b.c.d 1194 udp, e.f.g.h 443 tcp

results in trying to start the process using this:

/usr/sbin/openvpn --remote a.b.c.d --remote 1194 --remote udp --remote e.f.g.h
--remote 443 --remote tcp --comp-lzo --nobind --dev tun --proto udp --port 1194
...

which fails miserably.

the fix is to remove the space from the strsep() match string.

After applying the fix the resulting process command-line is:

/usr/sbin/openvpn --remote a.b.c.d 1194 udp --remote e.f.g.h 443 tcp --comp-lzo
--nobind --dev tun --proto udp --port 1194 ...

and the connection is successful.

----
Do not treat space as separator for multiple remote gateway entries (bug 712710)

Signed-off-by: TJ <gnome iam tj>

 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/nm-openvpn-service.c b/src/nm-openvpn-service.c
index 8589b57..3975643 100644
--- a/src/nm-openvpn-service.c
+++ b/src/nm-openvpn-service.c
@@ -906,7 +906,7 @@ nm_openvpn_start_openvpn_binary (NMOpenvpnPlugin *plugin,
        tmp = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_REMOTE);
        if (tmp && strlen (tmp)) {
                char *tok;
-               while ((tok = strsep((char**)&tmp, " ,")) != NULL) {
+               while ((tok = strsep((char**)&tmp, ",")) != NULL) {
                        if (strlen(tok)) {
                                add_openvpn_arg (args, "--remote");
                                add_openvpn_arg (args, tok);
-- 
1.8.1.2.433.g9808ce0.dirty



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