Merge lp:~tj/ubuntu/trusty/network-manager-openvpn/lp1252832 into lp:ubuntu/trusty/network-manager-openvpn

Proposed by TJ on 2014-08-11
Status: Needs review
Proposed branch: lp:~tj/ubuntu/trusty/network-manager-openvpn/lp1252832
Merge into: lp:ubuntu/trusty/network-manager-openvpn
Diff against target: 176 lines (+100/-6)
6 files modified
.pc/applied-patches (+1/-0)
debian/changelog (+6/-0)
debian/patches/series (+1/-0)
properties/nm-openvpn-dialog.ui (+1/-1)
properties/nm-openvpn.c (+53/-1)
src/nm-openvpn-service.c (+38/-4)
To merge this branch: bzr merge lp:~tj/ubuntu/trusty/network-manager-openvpn/lp1252832
Reviewer Review Type Date Requested Status
Mathieu Trudel-Lapierre 2014-08-11 Resubmit on 2015-09-24
Bin Li (community) Approve on 2014-09-01
Review via email: mp+230248@code.launchpad.net

Description of the change

SRU to fix broken multiple gateway entry, taken from unreleased upstream commit (details in DEP-3 header of the patch)

To post a comment you must log in.
Bin Li (binli) wrote :

I found the upstream already accepted the change.

c55ba4e core/ui: allow specifying port and protocol for gateways (bgo #712710)

And the patch looks good, hope we could apply it into ubuntu.

review: Approve
Mathieu Trudel-Lapierre (cyphermox) wrote :

It seems to me like you forgot to bzr add the patch file when preparing this merge.

Also, this should also be landing in utopic before landing in trusty; would you please prepare a similar merge for that release?

Thanks!

review: Needs Fixing
Mathieu Trudel-Lapierre (cyphermox) wrote :

This is still missing a patch file rather than changing the files directly.

However, disregard my previous comment about landing in utopic -- it's no longer a supported release.

review: Resubmit

Unmerged revisions

20. By TJ on 2014-08-11

core/ui: allow specifying port and protocol for gateways (bgo #712710)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.pc/applied-patches'
2--- .pc/applied-patches 2014-03-06 16:43:05 +0000
3+++ .pc/applied-patches 2014-08-11 03:15:24 +0000
4@@ -3,3 +3,4 @@
5 gtk_table_to_gtk_grid.patch
6 enable_ipv6.patch
7 support-ipv6-dns
8+lp1252832_fix_multiple_gateways_entry.patch
9
10=== modified file 'debian/changelog'
11--- debian/changelog 2014-03-06 16:43:05 +0000
12+++ debian/changelog 2014-08-11 03:15:24 +0000
13@@ -1,3 +1,9 @@
14+network-manager-openvpn (0.9.8.2-1ubuntu5) trusty; urgency=medium
15+
16+ * Fix entry of multiple gateways (LP: #1252832).
17+
18+ -- TJ <ubuntu@iam.tj> Mon, 11 Aug 2014 04:04:43 +0100
19+
20 network-manager-openvpn (0.9.8.2-1ubuntu4) trusty; urgency=medium
21
22 * Fix IPv6 DNS support. Return IPv6 DNS servers are now passed to
23
24=== modified file 'debian/patches/series'
25--- debian/patches/series 2014-03-06 16:43:05 +0000
26+++ debian/patches/series 2014-08-11 03:15:24 +0000
27@@ -4,3 +4,4 @@
28 gtk_table_to_gtk_grid.patch
29 enable_ipv6.patch
30 support-ipv6-dns
31+lp1252832_fix_multiple_gateways_entry.patch
32
33=== modified file 'properties/nm-openvpn-dialog.ui'
34--- properties/nm-openvpn-dialog.ui 2013-05-06 18:03:37 +0000
35+++ properties/nm-openvpn-dialog.ui 2014-08-11 03:15:24 +0000
36@@ -1234,7 +1234,7 @@
37 <object class="GtkEntry" id="gateway_entry">
38 <property name="visible">True</property>
39 <property name="can_focus">True</property>
40- <property name="tooltip_text" translatable="yes">Remote host name or IP address. You can specify multiple items for redundancy (use commas to separate the entries).
41+ <property name="tooltip_text" translatable="yes">Remote gateway(s), with optional port and protocol (e.g. ovpn.corp.com:1234:tcp). You can specify multiple hosts for redundancy (use commas or spaces as delimiters).
42 config: remote</property>
43 </object>
44 </child>
45
46=== modified file 'properties/nm-openvpn.c'
47--- properties/nm-openvpn.c 2014-03-06 11:58:16 +0000
48+++ properties/nm-openvpn.c 2014-08-11 03:15:24 +0000
49@@ -127,6 +127,51 @@
50 return etype;
51 }
52
53+/* Example: abc.com:1234:udp, ovpnserver.company.com:443, vpn.example.com::tcp */
54+static gboolean
55+check_gateway_entry (const char *str)
56+{
57+ char **list, **iter;
58+ char *host, *port, *proto;
59+ long int port_int;
60+ gboolean success = FALSE;
61+
62+ if (!str || !*str)
63+ return FALSE;
64+
65+ list = g_strsplit_set (str, " \t,", -1);
66+ for (iter = list; iter && *iter; iter++) {
67+ if (!**iter)
68+ continue;
69+ host = g_strstrip (*iter);
70+ port = strchr (host, ':');
71+ proto = port ? strchr (port + 1, ':') : NULL;
72+ if (port)
73+ *port++ = '\0';
74+ if (proto)
75+ *proto++ = '\0';
76+
77+ /* check hostname */
78+ if (!host || !*host)
79+ goto out;
80+ /* check port */
81+ if (port && *port) {
82+ char *end;
83+ errno = 0;
84+ port_int = strtol (port, &end, 10);
85+ if (errno != 0 || *end != '\0' || port_int < 1 || port_int > 65535)
86+ goto out;
87+ }
88+ /* check proto */
89+ if (proto && strcmp (proto, "udp") && strcmp (proto, "tcp"))
90+ goto out;
91+ }
92+ success = TRUE;
93+out:
94+ g_strfreev (list);
95+ return success;
96+}
97+
98 static gboolean
99 check_validity (OpenvpnPluginUiWidget *self, GError **error)
100 {
101@@ -136,10 +181,17 @@
102 GtkTreeModel *model;
103 GtkTreeIter iter;
104 const char *contype = NULL;
105+ GdkRGBA rgba;
106+ gboolean gateway_valid;
107
108 widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "gateway_entry"));
109 str = gtk_entry_get_text (GTK_ENTRY (widget));
110- if (!str || !strlen (str)) {
111+ gateway_valid = check_gateway_entry (str);
112+ /* Change entry background colour while editing */
113+ if (!gateway_valid)
114+ gdk_rgba_parse (&rgba, "red3");
115+ gtk_widget_override_background_color (widget, GTK_STATE_NORMAL, !gateway_valid ? &rgba : NULL);
116+ if (!gateway_valid) {
117 g_set_error (error,
118 OPENVPN_PLUGIN_UI_ERROR,
119 OPENVPN_PLUGIN_UI_ERROR_INVALID_PROPERTY,
120
121=== modified file 'src/nm-openvpn-service.c'
122--- src/nm-openvpn-service.c 2013-05-06 18:03:37 +0000
123+++ src/nm-openvpn-service.c 2014-08-11 03:15:24 +0000
124@@ -777,14 +777,48 @@
125 add_openvpn_arg (args, openvpn_binary);
126
127 tmp = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_REMOTE);
128- if (tmp && strlen (tmp)) {
129- char *tok;
130- while ((tok = strsep((char**)&tmp, " ,")) != NULL) {
131- if (strlen(tok)) {
132+ if (tmp && *tmp) {
133+ char *tok, *port, *proto;
134+ char *tmp_dup = strdup (tmp);
135+ while ((tok = strsep (&tmp_dup, " \t,")) != NULL) {
136+ if (*tok) {
137+ port = strchr (tok, ':');
138+ proto = port ? strchr (port + 1, ':') : NULL;
139+ if (port)
140+ *port++ = '\0';
141+ if (proto)
142+ *proto++ = '\0';
143+
144 add_openvpn_arg (args, "--remote");
145 add_openvpn_arg (args, tok);
146+ if (port) {
147+ if (!add_openvpn_arg_int (args, port)) {
148+ g_set_error (error,
149+ NM_VPN_PLUGIN_ERROR,
150+ NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
151+ _("Invalid port number '%s'."), port);
152+ free_openvpn_args (args);
153+ g_free (tmp_dup);
154+ return FALSE;
155+ }
156+ } else
157+ add_openvpn_arg (args, "1194"); /* use default IANA port */
158+ if (proto) {
159+ if (!strcmp (proto, "udp") || !strcmp (proto, "tcp"))
160+ add_openvpn_arg (args, proto);
161+ else {
162+ g_set_error (error,
163+ NM_VPN_PLUGIN_ERROR,
164+ NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
165+ _("Invalid proto '%s'."), proto);
166+ free_openvpn_args (args);
167+ g_free (tmp_dup);
168+ return FALSE;
169+ }
170+ }
171 }
172 }
173+ g_free (tmp_dup);
174 }
175
176 /* Remote random */

Subscribers

People subscribed via source and target branches

to all changes: