Re: [patch] fix openvpn port saving
- From: Dan Williams <dcbw redhat com>
- To: Robert Hughes <rhughes smgf org>
- Cc: networkmanager-list gnome org
- Subject: Re: [patch] fix openvpn port saving
- Date: Thu, 31 Jan 2008 13:14:18 -0500
On Wed, 2008-01-23 at 09:57 -0700, Robert Hughes wrote:
> Here is a patch to fix nm not saving the openvpn gateway port.
> I just switched the type from uint to int.
Committed to trunk, thanks!
> Alternatively you could patch the applet to know how to write uints to gconf.
GConf can't natively handle uints or double-precision floats though, so
we can't really do that.
Dan
> Rob
>
>
> Index: openvpn/src/nm-openvpn-service.c
> ===================================================================
> --- openvpn/src/nm-openvpn-service.c (revision 3261)
> +++ openvpn/src/nm-openvpn-service.c (working copy)
> @@ -91,7 +91,7 @@
> { NM_OPENVPN_KEY_TAP_DEV, G_TYPE_BOOLEAN },
> { NM_OPENVPN_KEY_KEY, G_TYPE_STRING },
> { NM_OPENVPN_KEY_LOCAL_IP, G_TYPE_STRING },
> - { NM_OPENVPN_KEY_PORT, G_TYPE_UINT },
> + { NM_OPENVPN_KEY_PORT, G_TYPE_INT },
> { NM_OPENVPN_KEY_PROTO_TCP, G_TYPE_BOOLEAN },
> { NM_OPENVPN_KEY_REMOTE, G_TYPE_STRING },
> { NM_OPENVPN_KEY_REMOTE_IP, G_TYPE_STRING },
> @@ -419,7 +419,7 @@
> tmp = g_hash_table_lookup (properties, NM_OPENVPN_KEY_PORT);
> if (tmp)
> /* The string here is leaked, big deal. */
> - g_ptr_array_add (openvpn_argv, g_strdup_printf ("%u", g_value_get_uint ((GValue *) tmp)));
> + g_ptr_array_add (openvpn_argv, g_strdup_printf ("%i", g_value_get_int ((GValue *) tmp)));
> else
> /* Default to IANA assigned port 1194 */
> g_ptr_array_add (openvpn_argv, (GValue *) "1194");
>
> Index: openvpn/properties/nm-openvpn.c
> ===================================================================
> --- openvpn/properties/nm-openvpn.c (revision 3261)
> +++ openvpn/properties/nm-openvpn.c (working copy)
> @@ -224,18 +224,6 @@
> return value;
> }
>
> -static GValue *
> -uint_to_gvalue (guint u)
> -{
> - GValue *value;
> -
> - value = g_slice_new0 (GValue);
> - g_value_init (value, G_TYPE_UINT);
> - g_value_set_uint (value, u);
> -
> - return value;
> -}
> -
> static void
> impl_fill_connection (NetworkManagerVpnUI *self, NMConnection *connection)
> {
> @@ -302,7 +290,7 @@
>
> g_hash_table_insert (properties, g_strdup(NM_OPENVPN_KEY_TAP_DEV), bool_to_gvalue (use_tap));
> g_hash_table_insert (properties, g_strdup(NM_OPENVPN_KEY_REMOTE), str_to_gvalue (remote));
> - g_hash_table_insert (properties, g_strdup(NM_OPENVPN_KEY_PORT), uint_to_gvalue ((guint) atoi (port)));
> + g_hash_table_insert (properties, g_strdup(NM_OPENVPN_KEY_PORT), int_to_gvalue (atoi (port)));
> g_hash_table_insert (properties, g_strdup(NM_OPENVPN_KEY_PROTO_TCP), bool_to_gvalue (use_tcp));
> g_hash_table_insert (properties, g_strdup(NM_OPENVPN_KEY_CA), str_to_gvalue (ca));
> g_hash_table_insert (properties, g_strdup(NM_OPENVPN_KEY_CERT), str_to_gvalue (cert));
> @@ -373,7 +361,7 @@
> if (!strcmp (name, NM_OPENVPN_KEY_REMOTE))
> gtk_entry_set_text (impl->w_remote, g_value_get_string (value));
> else if (!strcmp (name, NM_OPENVPN_KEY_PORT)) {
> - char *port = g_strdup_printf ("%u", g_value_get_uint (value));
> + char *port = g_strdup_printf ("%i", g_value_get_int (value));
> gtk_entry_set_text (impl->w_port, port);
> g_free (port);
> } else if (!strcmp (name, NM_OPENVPN_KEY_CA))
> @@ -1337,7 +1325,7 @@
> FILE *f;
> const char *connection_type = "";
> const char *remote = "";
> - guint port = 1194;
> + int port = 1194;
> gboolean tap_dev = FALSE;
> gboolean proto_tcp = FALSE;
> const char *ca = "";
> @@ -1369,7 +1357,7 @@
>
> val = (GValue *) g_hash_table_lookup (s_vpn_props->data, NM_OPENVPN_KEY_PORT);
> if (val)
> - port = g_value_get_uint (val);
> + port = g_value_get_int (val);
>
> val = (GValue *) g_hash_table_lookup (s_vpn_props->data, NM_OPENVPN_KEY_TAP_DEV);
> if (val)
> @@ -1468,7 +1456,7 @@
> "description=%s\n"
> "connection-type=%s\n"
> "remote=%s\n"
> - "port=%u\n"
> + "port=%i\n"
> "dev=%s\n"
> "proto=%s\n"
> "ca=%s\n"
>
>
> _______________________________________________
> NetworkManager-list mailing list
> NetworkManager-list gnome org
> http://mail.gnome.org/mailman/listinfo/networkmanager-list
[
Date Prev][Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]