vpn: convert NMVpnConnection <-> VPN service communication to GDBus (bgo #745307)
Of special note is the new D-Bus rule to allow root to talk to org.freedesktop.NetworkManager.VPN.Plugin, without which NetworkManager would not hear signals from the VPN plugins. Oddly, this worked fine with dbus-glib... https://bugzilla.gnome.org/show_bug.cgi?id=745307
This commit is contained in:
@@ -2588,121 +2588,6 @@ nm_utils_connection_dict_to_hash (GVariant *dict)
|
||||
return g_value_get_boxed (&val);
|
||||
}
|
||||
|
||||
GSList *
|
||||
nm_utils_ip4_routes_from_gvalue (const GValue *value)
|
||||
{
|
||||
GPtrArray *routes;
|
||||
int i;
|
||||
GSList *list = NULL;
|
||||
|
||||
routes = (GPtrArray *) g_value_get_boxed (value);
|
||||
for (i = 0; routes && (i < routes->len); i++) {
|
||||
GArray *array = (GArray *) g_ptr_array_index (routes, i);
|
||||
guint32 *array_val = (guint32 *) array->data;
|
||||
NMIPRoute *route;
|
||||
GError *error = NULL;
|
||||
|
||||
if (array->len < 4) {
|
||||
g_warning ("Ignoring invalid IP4 route");
|
||||
continue;
|
||||
}
|
||||
|
||||
route = nm_ip_route_new_binary (AF_INET,
|
||||
&array_val[0], array_val[1],
|
||||
&array_val[2], array_val[3],
|
||||
&error);
|
||||
if (route)
|
||||
list = g_slist_prepend (list, route);
|
||||
else {
|
||||
g_warning ("Ignoring invalid IP4 route: %s", error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
}
|
||||
|
||||
return g_slist_reverse (list);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_nm_utils_gvalue_array_validate (GValueArray *elements, guint n_expected, ...)
|
||||
{
|
||||
va_list args;
|
||||
GValue *tmp;
|
||||
int i;
|
||||
gboolean valid = FALSE;
|
||||
|
||||
if (n_expected != elements->n_values)
|
||||
return FALSE;
|
||||
|
||||
va_start (args, n_expected);
|
||||
for (i = 0; i < n_expected; i++) {
|
||||
tmp = g_value_array_get_nth (elements, i);
|
||||
if (G_VALUE_TYPE (tmp) != va_arg (args, GType))
|
||||
goto done;
|
||||
}
|
||||
valid = TRUE;
|
||||
|
||||
done:
|
||||
va_end (args);
|
||||
return valid;
|
||||
}
|
||||
|
||||
GSList *
|
||||
nm_utils_ip6_routes_from_gvalue (const GValue *value)
|
||||
{
|
||||
GPtrArray *routes;
|
||||
int i;
|
||||
GSList *list = NULL;
|
||||
|
||||
routes = (GPtrArray *) g_value_get_boxed (value);
|
||||
for (i = 0; routes && (i < routes->len); i++) {
|
||||
GValueArray *route_values = (GValueArray *) g_ptr_array_index (routes, i);
|
||||
GByteArray *dest, *next_hop;
|
||||
guint prefix, metric;
|
||||
NMIPRoute *route;
|
||||
GError *error = NULL;
|
||||
|
||||
if (!_nm_utils_gvalue_array_validate (route_values, 4,
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_TYPE_UINT,
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_TYPE_UINT)) {
|
||||
g_warning ("Ignoring invalid IP6 route");
|
||||
continue;
|
||||
}
|
||||
|
||||
dest = g_value_get_boxed (g_value_array_get_nth (route_values, 0));
|
||||
if (dest->len != 16) {
|
||||
g_warning ("%s: ignoring invalid IP6 dest address of length %d",
|
||||
__func__, dest->len);
|
||||
continue;
|
||||
}
|
||||
|
||||
prefix = g_value_get_uint (g_value_array_get_nth (route_values, 1));
|
||||
|
||||
next_hop = g_value_get_boxed (g_value_array_get_nth (route_values, 2));
|
||||
if (next_hop->len != 16) {
|
||||
g_warning ("%s: ignoring invalid IP6 next_hop address of length %d",
|
||||
__func__, next_hop->len);
|
||||
continue;
|
||||
}
|
||||
|
||||
metric = g_value_get_uint (g_value_array_get_nth (route_values, 3));
|
||||
|
||||
route = nm_ip_route_new_binary (AF_INET6,
|
||||
dest->data, prefix,
|
||||
next_hop->data, metric,
|
||||
&error);
|
||||
if (route)
|
||||
list = g_slist_prepend (list, route);
|
||||
else {
|
||||
g_warning ("Ignoring invalid IP6 route: %s", error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
}
|
||||
|
||||
return g_slist_reverse (list);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_utils_setpgid:
|
||||
* @unused: unused
|
||||
|
@@ -215,9 +215,6 @@ void nm_utils_ipv6_interface_identfier_get_from_addr (NMUtilsIPv6IfaceId *iid,
|
||||
GVariant *nm_utils_connection_hash_to_dict (GHashTable *hash);
|
||||
GHashTable *nm_utils_connection_dict_to_hash (GVariant *dict);
|
||||
|
||||
GSList *nm_utils_ip4_routes_from_gvalue (const GValue *value);
|
||||
GSList *nm_utils_ip6_routes_from_gvalue (const GValue *value);
|
||||
|
||||
void nm_utils_setpgid (gpointer unused);
|
||||
|
||||
#endif /* __NETWORKMANAGER_UTILS_H__ */
|
||||
|
@@ -25,6 +25,7 @@
|
||||
<allow send_destination="org.freedesktop.NetworkManager.vpnc"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.ssh"/>
|
||||
<allow send_destination="org.freedesktop.NetworkManager.iodine"/>
|
||||
<allow send_interface="org.freedesktop.NetworkManager.VPN.Plugin"/>
|
||||
</policy>
|
||||
<policy context="default">
|
||||
<deny own="org.freedesktop.NetworkManager"/>
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user