core: merge branch 'th/settings-delegate-connection'

https://github.com/NetworkManager/NetworkManager/pull/184
This commit is contained in:
Thomas Haller 2018-08-28 22:29:45 +02:00
commit d17d26887c
38 changed files with 898 additions and 754 deletions

View file

@ -805,9 +805,11 @@ nm_utils_match_connection (NMConnection *const*connections,
return NULL;
for (; *connections; connections++) {
NMConnection *candidate = NM_CONNECTION (*connections);
NMConnection *candidate = *connections;
GHashTable *diffs = NULL;
nm_assert (NM_IS_CONNECTION (candidate));
if (match_filter_func) {
if (!match_filter_func (candidate, match_filter_data))
continue;

View file

@ -94,7 +94,7 @@ typedef struct {
NMSettings *settings;
GSList *connections;
NMConnection *pan_connection;
NMSettingsConnection *pan_connection;
gboolean pan_connection_no_autocreate;
} NMBluezDevicePrivate;
@ -114,8 +114,9 @@ G_DEFINE_TYPE (NMBluezDevice, nm_bluez_device, G_TYPE_OBJECT)
/*****************************************************************************/
static void cp_connection_added (NMSettings *settings,
NMConnection *connection, NMBluezDevice *self);
static gboolean connection_compatible (NMBluezDevice *self, NMConnection *connection);
NMSettingsConnection *sett_conn,
NMBluezDevice *self);
static gboolean connection_compatible (NMBluezDevice *self, NMSettingsConnection *sett_conn);
/*****************************************************************************/
@ -181,10 +182,10 @@ nm_bluez_device_get_connected (NMBluezDevice *self)
static void
pan_connection_check_create (NMBluezDevice *self)
{
NMConnection *connection;
NMConnection *added;
gs_unref_object NMConnection *connection = NULL;
NMSettingsConnection *added;
NMSetting *setting;
char *id;
gs_free char *id = NULL;
char uuid[37];
GError *error = NULL;
NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self);
@ -246,15 +247,14 @@ pan_connection_check_create (NMBluezDevice *self)
* which then already finds the suitable connection in priv->connections. This is confusing,
* so block the signal. check_emit_usable will succeed after this function call returns. */
g_signal_handlers_block_by_func (priv->settings, cp_connection_added, self);
added = NM_CONNECTION (nm_settings_add_connection (priv->settings, connection, FALSE, &error));
added = nm_settings_add_connection (priv->settings, connection, FALSE, &error);
g_signal_handlers_unblock_by_func (priv->settings, cp_connection_added, self);
if (added) {
g_assert (!g_slist_find (priv->connections, added));
g_assert (connection_compatible (self, added));
g_assert (nm_connection_compare (added, connection, NM_SETTING_COMPARE_FLAG_EXACT));
nm_assert (!g_slist_find (priv->connections, added));
nm_assert (connection_compatible (self, added));
nm_settings_connection_set_flags (NM_SETTINGS_CONNECTION (added), NM_SETTINGS_CONNECTION_INT_FLAGS_NM_GENERATED, TRUE);
nm_settings_connection_set_flags (added, NM_SETTINGS_CONNECTION_INT_FLAGS_NM_GENERATED, TRUE);
priv->connections = g_slist_prepend (priv->connections, g_object_ref (added));
priv->pan_connection = added;
@ -263,11 +263,7 @@ pan_connection_check_create (NMBluezDevice *self)
nm_log_warn (LOGD_BT, "bluez[%s] couldn't add new Bluetooth connection for NAP device: '%s' (%s): %s",
priv->path, id, uuid, error->message);
g_clear_error (&error);
}
g_object_unref (connection);
g_free (id);
}
static gboolean
@ -321,9 +317,10 @@ check_emit_usable_schedule (NMBluezDevice *self)
/*****************************************************************************/
static gboolean
connection_compatible (NMBluezDevice *self, NMConnection *connection)
connection_compatible (NMBluezDevice *self, NMSettingsConnection *sett_conn)
{
NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self);
NMConnection *connection = nm_settings_connection_get_connection (sett_conn);
NMSettingBluetooth *s_bt;
const char *bt_type;
const char *bdaddr;
@ -361,22 +358,24 @@ connection_compatible (NMBluezDevice *self, NMConnection *connection)
}
static gboolean
_internal_track_connection (NMBluezDevice *self, NMConnection *connection, gboolean tracked)
_internal_track_connection (NMBluezDevice *self,
NMSettingsConnection *sett_conn,
gboolean tracked)
{
NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self);
gboolean was_tracked;
was_tracked = !!g_slist_find (priv->connections, connection);
was_tracked = !!g_slist_find (priv->connections, sett_conn);
if (was_tracked == !!tracked)
return FALSE;
if (tracked)
priv->connections = g_slist_prepend (priv->connections, g_object_ref (connection));
priv->connections = g_slist_prepend (priv->connections, g_object_ref (sett_conn));
else {
priv->connections = g_slist_remove (priv->connections, connection);
if (priv->pan_connection == connection)
priv->connections = g_slist_remove (priv->connections, sett_conn);
if (priv->pan_connection == sett_conn)
priv->pan_connection = NULL;
g_object_unref (connection);
g_object_unref (sett_conn);
}
return TRUE;
@ -384,32 +383,32 @@ _internal_track_connection (NMBluezDevice *self, NMConnection *connection, gbool
static void
cp_connection_added (NMSettings *settings,
NMConnection *connection,
NMSettingsConnection *sett_conn,
NMBluezDevice *self)
{
if (connection_compatible (self, connection)) {
if (_internal_track_connection (self, connection, TRUE))
if (connection_compatible (self, sett_conn)) {
if (_internal_track_connection (self, sett_conn, TRUE))
check_emit_usable (self);
}
}
static void
cp_connection_removed (NMSettings *settings,
NMConnection *connection,
NMSettingsConnection *sett_conn,
NMBluezDevice *self)
{
if (_internal_track_connection (self, connection, FALSE))
if (_internal_track_connection (self, sett_conn, FALSE))
check_emit_usable (self);
}
static void
cp_connection_updated (NMSettings *settings,
NMConnection *connection,
NMSettingsConnection *sett_conn,
gboolean by_user,
NMBluezDevice *self)
{
if (_internal_track_connection (self, connection,
connection_compatible (self, connection)))
if (_internal_track_connection (self, sett_conn,
connection_compatible (self, sett_conn)))
check_emit_usable_schedule (self);
}
@ -423,10 +422,8 @@ load_connections (NMBluezDevice *self)
connections = nm_settings_get_connections (priv->settings, NULL);
for (i = 0; connections[i]; i++) {
NMConnection *connection = (NMConnection *) connections[i];
if (connection_compatible (self, connection))
changed |= _internal_track_connection (self, connection, TRUE);
if (connection_compatible (self, connections[i]))
changed |= _internal_track_connection (self, connections[i], TRUE);
}
if (changed)
check_emit_usable (self);
@ -1178,14 +1175,14 @@ dispose (GObject *object)
{
NMBluezDevice *self = NM_BLUEZ_DEVICE (object);
NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self);
NMConnection *to_delete = NULL;
NMSettingsConnection *to_delete = NULL;
nm_clear_g_source (&priv->check_emit_usable_id);
if (priv->pan_connection) {
/* Check whether we want to remove the created connection. If so, we take a reference
* and delete it at the end of dispose(). */
if (NM_FLAGS_HAS (nm_settings_connection_get_flags (NM_SETTINGS_CONNECTION (priv->pan_connection)),
if (NM_FLAGS_HAS (nm_settings_connection_get_flags (priv->pan_connection),
NM_SETTINGS_CONNECTION_INT_FLAGS_NM_GENERATED))
to_delete = g_object_ref (priv->pan_connection);
@ -1219,8 +1216,8 @@ dispose (GObject *object)
if (to_delete) {
nm_log_dbg (LOGD_BT, "bluez[%s] removing Bluetooth connection for NAP device: '%s' (%s)", priv->path,
nm_connection_get_id (to_delete), nm_connection_get_uuid (to_delete));
nm_settings_connection_delete (NM_SETTINGS_CONNECTION (to_delete), NULL);
nm_settings_connection_get_id (to_delete), nm_settings_connection_get_uuid (to_delete));
nm_settings_connection_delete (to_delete, NULL);
g_object_unref (to_delete);
}

View file

@ -36,6 +36,7 @@
#include "nm-setting-serial.h"
#include "nm-setting-ppp.h"
#include "NetworkManagerUtils.h"
#include "settings/nm-settings-connection.h"
#include "nm-utils.h"
#include "nm-bt-error.h"
#include "platform/nm-platform.h"
@ -137,7 +138,7 @@ get_generic_capabilities (NMDevice *device)
static gboolean
can_auto_connect (NMDevice *device,
NMConnection *connection,
NMSettingsConnection *sett_conn,
char **specific_object)
{
NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE ((NMDeviceBt *) device);
@ -145,11 +146,11 @@ can_auto_connect (NMDevice *device,
nm_assert (!specific_object || !*specific_object);
if (!NM_DEVICE_CLASS (nm_device_bt_parent_class)->can_auto_connect (device, connection, NULL))
if (!NM_DEVICE_CLASS (nm_device_bt_parent_class)->can_auto_connect (device, sett_conn, NULL))
return FALSE;
/* Can't auto-activate a DUN connection without ModemManager */
bt_type = get_connection_bt_type (connection);
bt_type = get_connection_bt_type (nm_settings_connection_get_connection (sett_conn));
if (bt_type == NM_BT_CAPABILITY_DUN && priv->mm_running == FALSE)
return FALSE;

View file

@ -216,33 +216,17 @@ static void
update_connection (NMDevice *device, NMConnection *connection)
{
NMSetting6Lowpan *s_6lowpan = nm_connection_get_setting_6lowpan (connection);
NMDevice *parent_device;
const char *setting_parent, *new_parent;
if (!s_6lowpan) {
s_6lowpan = (NMSetting6Lowpan *) nm_setting_6lowpan_new ();
nm_connection_add_setting (connection, (NMSetting *) s_6lowpan);
}
/* Update parent in the connection; default to parent's interface name */
parent_device = nm_device_parent_get_device (device);
if (parent_device) {
new_parent = nm_device_get_iface (parent_device);
setting_parent = nm_setting_6lowpan_get_parent (s_6lowpan);
if (setting_parent && nm_utils_is_uuid (setting_parent)) {
NMConnection *parent_connection;
/* Don't change a parent specified by UUID if it's still valid */
parent_connection = (NMConnection *) nm_settings_get_connection_by_uuid (nm_device_get_settings (device), setting_parent);
if ( parent_connection
&& nm_device_check_connection_compatible (parent_device, parent_connection, NULL))
new_parent = NULL;
}
if (new_parent)
g_object_set (s_6lowpan, NM_SETTING_6LOWPAN_PARENT, new_parent, NULL);
} else
g_object_set (s_6lowpan, NM_SETTING_6LOWPAN_PARENT, NULL, NULL);
g_object_set (s_6lowpan,
NM_SETTING_6LOWPAN_PARENT,
nm_device_parent_find_for_connection (device,
nm_setting_6lowpan_get_parent (s_6lowpan)),
NULL);
}
static NMActStageReturn

View file

@ -18,33 +18,24 @@
#include "nm-default.h"
#include <string.h>
#include "nm-connection.h"
#include "nm-device-ethernet-utils.h"
#include "settings/nm-settings-connection.h"
char *
nm_device_ethernet_utils_get_default_wired_name (NMConnection *const *connections)
nm_device_ethernet_utils_get_default_wired_name (GHashTable *existing_ids)
{
char *temp;
guint j;
int i;
/* Find the next available unique connection name */
for (i = 1; i <= 10000; i++) {
for (i = 1; i <= G_MAXINT; i++) {
temp = g_strdup_printf (_("Wired connection %d"), i);
for (j = 0; connections[j]; j++) {
if (nm_streq0 (nm_connection_get_id (connections[j]), temp)) {
g_free (temp);
goto next;
}
}
return temp;
next:
;
if ( !existing_ids
|| !g_hash_table_contains (existing_ids, temp))
return temp;
g_free (temp);
}
return NULL;
}

View file

@ -19,6 +19,6 @@
#ifndef __NETWORKMANAGER_DEVICE_ETHERNET_UTILS_H__
#define __NETWORKMANAGER_DEVICE_ETHERNET_UTILS_H__
char *nm_device_ethernet_utils_get_default_wired_name (NMConnection *const *connections);
char *nm_device_ethernet_utils_get_default_wired_name (GHashTable *existing_ids);
#endif /* NETWORKMANAGER_DEVICE_ETHERNET_UTILS_H */

View file

@ -1443,12 +1443,14 @@ new_default_connection (NMDevice *self)
NMConnection *connection;
NMSettingsConnection *const*connections;
NMSetting *setting;
gs_unref_hashtable GHashTable *existing_ids = NULL;
struct udev_device *dev;
const char *perm_hw_addr;
const char *uprop = "0";
gs_free char *defname = NULL;
gs_free char *uuid = NULL;
gs_free char *machine_id = NULL;
guint i, n_connections;
if (nm_config_get_no_auto_default_for_device (nm_config_get (), self))
return NULL;
@ -1461,8 +1463,13 @@ new_default_connection (NMDevice *self)
setting = nm_setting_connection_new ();
nm_connection_add_setting (connection, setting);
connections = nm_settings_get_connections (nm_device_get_settings (self), NULL);
defname = nm_device_ethernet_utils_get_default_wired_name ((NMConnection *const*) connections);
connections = nm_settings_get_connections (nm_device_get_settings (self), &n_connections);
if (n_connections > 0) {
existing_ids = g_hash_table_new (nm_str_hash, g_str_equal);
for (i = 0; i < n_connections; i++)
g_hash_table_add (existing_ids, (char *) nm_settings_connection_get_id (connections[i]));
}
defname = nm_device_ethernet_utils_get_default_wired_name (existing_ids);
if (!defname)
return NULL;

View file

@ -435,8 +435,6 @@ update_connection (NMDevice *device, NMConnection *connection)
NMDeviceIPTunnel *self = NM_DEVICE_IP_TUNNEL (device);
NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE (self);
NMSettingIPTunnel *s_ip_tunnel = nm_connection_get_setting_ip_tunnel (connection);
NMDevice *parent = NULL;
const char *setting_parent, *new_parent;
if (!s_ip_tunnel) {
s_ip_tunnel = (NMSettingIPTunnel *) nm_setting_ip_tunnel_new ();
@ -446,25 +444,11 @@ update_connection (NMDevice *device, NMConnection *connection)
if (nm_setting_ip_tunnel_get_mode (s_ip_tunnel) != priv->mode)
g_object_set (G_OBJECT (s_ip_tunnel), NM_SETTING_IP_TUNNEL_MODE, priv->mode, NULL);
parent = nm_device_parent_get_device (device);
/* Update parent in the connection; default to parent's interface name */
if (parent) {
new_parent = nm_device_get_iface (parent);
setting_parent = nm_setting_ip_tunnel_get_parent (s_ip_tunnel);
if (setting_parent && nm_utils_is_uuid (setting_parent)) {
NMConnection *parent_connection;
/* Don't change a parent specified by UUID if it's still valid */
parent_connection = (NMConnection *) nm_settings_get_connection_by_uuid (nm_device_get_settings (device),
setting_parent);
if (parent_connection && nm_device_check_connection_compatible (parent, parent_connection, NULL))
new_parent = NULL;
}
if (new_parent)
g_object_set (s_ip_tunnel, NM_SETTING_IP_TUNNEL_PARENT, new_parent, NULL);
} else
g_object_set (s_ip_tunnel, NM_SETTING_IP_TUNNEL_PARENT, NULL, NULL);
g_object_set (s_ip_tunnel,
NM_SETTING_IP_TUNNEL_PARENT,
nm_device_parent_find_for_connection (device,
nm_setting_ip_tunnel_get_parent (s_ip_tunnel)),
NULL);
if (!address_equal_pp (priv->addr_family,
nm_setting_ip_tunnel_get_local (s_ip_tunnel),

View file

@ -391,8 +391,6 @@ update_connection (NMDevice *device, NMConnection *connection)
{
NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE ((NMDeviceMacvlan *) device);
NMSettingMacvlan *s_macvlan = nm_connection_get_setting_macvlan (connection);
NMDevice *parent_device;
const char *setting_parent, *new_parent;
int new_mode;
if (!s_macvlan) {
@ -410,24 +408,11 @@ update_connection (NMDevice *device, NMConnection *connection)
if (priv->props.tap != nm_setting_macvlan_get_tap (s_macvlan))
g_object_set (s_macvlan, NM_SETTING_MACVLAN_TAP, !!priv->props.tap, NULL);
/* Update parent in the connection; default to parent's interface name */
parent_device = nm_device_parent_get_device (device);
if (parent_device) {
new_parent = nm_device_get_iface (parent_device);
setting_parent = nm_setting_macvlan_get_parent (s_macvlan);
if (setting_parent && nm_utils_is_uuid (setting_parent)) {
NMConnection *parent_connection;
/* Don't change a parent specified by UUID if it's still valid */
parent_connection = (NMConnection *) nm_settings_get_connection_by_uuid (nm_device_get_settings (device), setting_parent);
if (parent_connection && nm_device_check_connection_compatible (parent_device, parent_connection, NULL))
new_parent = NULL;
}
if (new_parent)
g_object_set (s_macvlan, NM_SETTING_MACVLAN_PARENT, new_parent, NULL);
} else
g_object_set (s_macvlan, NM_SETTING_MACVLAN_PARENT, NULL, NULL);
g_object_set (s_macvlan,
NM_SETTING_MACVLAN_PARENT,
nm_device_parent_find_for_connection (device,
nm_setting_macvlan_get_parent (s_macvlan)),
NULL);
}
static NMActStageReturn

View file

@ -427,10 +427,8 @@ update_connection (NMDevice *device, NMConnection *connection)
NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (device);
NMSettingVlan *s_vlan = nm_connection_get_setting_vlan (connection);
int ifindex = nm_device_get_ifindex (device);
const char *setting_parent, *new_parent;
const NMPlatformLink *plink;
const NMPObject *polnk;
NMDevice *parent_device;
guint vlan_id;
guint vlan_flags;
@ -448,26 +446,11 @@ update_connection (NMDevice *device, NMConnection *connection)
if (vlan_id != nm_setting_vlan_get_id (s_vlan))
g_object_set (s_vlan, NM_SETTING_VLAN_ID, vlan_id, NULL);
/* Update parent in the connection; default to parent's interface name */
parent_device = nm_device_parent_get_device (device);
if ( parent_device
&& polnk
&& plink->parent > 0
&& nm_device_get_ifindex (parent_device) == plink->parent) {
new_parent = nm_device_get_iface (parent_device);
setting_parent = nm_setting_vlan_get_parent (s_vlan);
if (setting_parent && nm_utils_is_uuid (setting_parent)) {
NMConnection *parent_connection;
/* Don't change a parent specified by UUID if it's still valid */
parent_connection = (NMConnection *) nm_settings_get_connection_by_uuid (nm_device_get_settings (device), setting_parent);
if (parent_connection && nm_device_check_connection_compatible (parent_device, parent_connection, NULL))
new_parent = NULL;
}
if (new_parent)
g_object_set (s_vlan, NM_SETTING_VLAN_PARENT, new_parent, NULL);
} else
g_object_set (s_vlan, NM_SETTING_VLAN_PARENT, NULL, NULL);
g_object_set (s_vlan,
NM_SETTING_VLAN_PARENT,
nm_device_parent_find_for_connection (device,
nm_setting_vlan_get_parent (s_vlan)),
NULL);
if (polnk)
vlan_flags = polnk->lnk_vlan.flags;

View file

@ -386,9 +386,6 @@ update_connection (NMDevice *device, NMConnection *connection)
{
NMDeviceVxlanPrivate *priv = NM_DEVICE_VXLAN_GET_PRIVATE ((NMDeviceVxlan *) device);
NMSettingVxlan *s_vxlan = nm_connection_get_setting_vxlan (connection);
NMDevice *parent_device;
const char *setting_parent;
const char *new_parent = NULL;
if (!s_vxlan) {
s_vxlan = (NMSettingVxlan *) nm_setting_vxlan_new ();
@ -398,23 +395,11 @@ update_connection (NMDevice *device, NMConnection *connection)
if (priv->props.id != nm_setting_vxlan_get_id (s_vxlan))
g_object_set (G_OBJECT (s_vxlan), NM_SETTING_VXLAN_ID, priv->props.id, NULL);
parent_device = nm_device_parent_get_device (device);
/* Update parent in the connection; default to parent's interface name */
if (parent_device) {
new_parent = nm_device_get_iface (parent_device);
setting_parent = nm_setting_vxlan_get_parent (s_vxlan);
if (setting_parent && nm_utils_is_uuid (setting_parent)) {
NMConnection *parent_connection;
/* Don't change a parent specified by UUID if it's still valid */
parent_connection = (NMConnection *) nm_settings_get_connection_by_uuid (nm_device_get_settings (device),
setting_parent);
if (parent_connection && nm_device_check_connection_compatible (parent_device, parent_connection, NULL))
new_parent = NULL;
}
}
g_object_set (s_vxlan, NM_SETTING_VXLAN_PARENT, new_parent, NULL);
g_object_set (s_vxlan,
NM_SETTING_VXLAN_PARENT,
nm_device_parent_find_for_connection (device,
nm_setting_vxlan_get_parent (s_vxlan)),
NULL);
if (!address_matches (nm_setting_vxlan_get_remote (s_vxlan), priv->props.group, &priv->props.group6)) {
if (priv->props.group) {

View file

@ -1711,6 +1711,41 @@ nm_device_parent_notify_changed (NMDevice *self,
/*****************************************************************************/
const char *
nm_device_parent_find_for_connection (NMDevice *self,
const char *current_setting_parent)
{
const char *new_parent;
NMDevice *parent_device;
parent_device = nm_device_parent_get_device (self);
if (!parent_device)
return NULL;
new_parent = nm_device_get_iface (parent_device);
if (!new_parent)
return NULL;
if ( current_setting_parent
&& !nm_streq (current_setting_parent, new_parent)
&& nm_utils_is_uuid (current_setting_parent)) {
NMSettingsConnection *parent_connection;
/* Don't change a parent specified by UUID if it's still valid */
parent_connection = nm_settings_get_connection_by_uuid (nm_device_get_settings (self),
current_setting_parent);
if ( parent_connection
&& nm_device_check_connection_compatible (parent_device,
nm_settings_connection_get_connection (parent_connection),
NULL))
return current_setting_parent;
}
return new_parent;
}
/*****************************************************************************/
static void
_stats_update_counters (NMDevice *self,
guint64 tx_bytes,
@ -2310,6 +2345,22 @@ nm_device_get_settings_connection (NMDevice *self)
return priv->act_request.obj ? nm_act_request_get_settings_connection (priv->act_request.obj) : NULL;
}
NMConnection *
nm_device_get_settings_connection_get_connection (NMDevice *self)
{
NMSettingsConnection *sett_con;
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
if (!priv->act_request.obj)
return NULL;
sett_con = nm_act_request_get_settings_connection (priv->act_request.obj);
if (!sett_con)
return NULL;
return nm_settings_connection_get_connection (sett_con);
}
NMConnection *
nm_device_get_applied_connection (NMDevice *self)
{
@ -5158,7 +5209,7 @@ nm_device_autoconnect_allowed (NMDevice *self)
static gboolean
can_auto_connect (NMDevice *self,
NMConnection *connection,
NMSettingsConnection *sett_conn,
char **specific_object)
{
nm_assert (!specific_object || !*specific_object);
@ -5168,27 +5219,27 @@ can_auto_connect (NMDevice *self,
/**
* nm_device_can_auto_connect:
* @self: an #NMDevice
* @connection: a #NMConnection
* @sett_conn: a #NMSettingsConnection
* @specific_object: (out) (transfer full): on output, the path of an
* object associated with the returned connection, to be passed to
* nm_manager_activate_connection(), or %NULL.
*
* Checks if @connection can be auto-activated on @self right now.
* Checks if @sett_conn can be auto-activated on @self right now.
* This requires, at a minimum, that the connection be compatible with
* @self, and that it have the #NMSettingConnection:autoconnect property
* set, and that the device allow auto connections. Some devices impose
* additional requirements. (Eg, a Wi-Fi connection can only be activated
* if its SSID was seen in the last scan.)
*
* Returns: %TRUE, if the @connection can be auto-activated.
* Returns: %TRUE, if the @sett_conn can be auto-activated.
**/
gboolean
nm_device_can_auto_connect (NMDevice *self,
NMConnection *connection,
NMSettingsConnection *sett_conn,
char **specific_object)
{
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (sett_conn), FALSE);
g_return_val_if_fail (!specific_object || !*specific_object, FALSE);
/* the caller must ensure that nm_device_autoconnect_allowed() returns
@ -5200,10 +5251,14 @@ nm_device_can_auto_connect (NMDevice *self,
* over and over again. The caller is supposed to do that. */
nm_assert (nm_device_autoconnect_allowed (self));
if (!nm_device_check_connection_available (self, connection, NM_DEVICE_CHECK_CON_AVAILABLE_NONE, NULL, NULL))
if (!nm_device_check_connection_available (self,
nm_settings_connection_get_connection (sett_conn),
NM_DEVICE_CHECK_CON_AVAILABLE_NONE,
NULL,
NULL))
return FALSE;
if (!NM_DEVICE_GET_CLASS (self)->can_auto_connect (self, connection, specific_object))
if (!NM_DEVICE_GET_CLASS (self)->can_auto_connect (self, sett_conn, specific_object))
return FALSE;
return TRUE;
@ -11060,7 +11115,7 @@ reapply_cb (NMDevice *self,
nm_device_sys_iface_state_set (self, NM_DEVICE_SYS_IFACE_STATE_MANAGED);
if (!check_and_reapply_connection (self,
connection ?: (NMConnection *) nm_device_get_settings_connection (self),
connection ?: nm_device_get_settings_connection_get_connection (self),
version_id,
&audit_args,
&local)) {
@ -11848,7 +11903,8 @@ nm_device_set_ip_config (NMDevice *self,
NM_SETTINGS_CONNECTION_INT_FLAGS_NM_GENERATED)
&& nm_active_connection_get_activation_type (NM_ACTIVE_CONNECTION (priv->act_request.obj)) == NM_ACTIVATION_TYPE_EXTERNAL) {
g_object_freeze_notify (G_OBJECT (settings_connection));
nm_connection_add_setting (NM_CONNECTION (settings_connection),
/* FIXME(copy-on-write-connection): avoid modifying NMConnection instances and share them via copy-on-write. */
nm_connection_add_setting (nm_settings_connection_get_connection (settings_connection),
IS_IPv4
? nm_ip4_config_create_setting (priv->ip_config_4)
: nm_ip6_config_create_setting (priv->ip_config_6));
@ -13307,7 +13363,7 @@ nm_device_reapply_settings_immediately (NMDevice *self)
NM_SETTING_COMPARE_FLAG_IGNORE_REAPPLY_IMMEDIATELY))
return;
s_con_settings = nm_connection_get_setting_connection ((NMConnection *) settings_connection);
s_con_settings = nm_connection_get_setting_connection (nm_settings_connection_get_connection (settings_connection));
s_con_applied = nm_connection_get_setting_connection (applied_connection);
if (g_strcmp0 ((zone = nm_setting_connection_get_zone (s_con_settings)),
@ -13568,15 +13624,15 @@ available_connections_del_all (NMDevice *self)
}
static gboolean
available_connections_add (NMDevice *self, NMConnection *connection)
available_connections_add (NMDevice *self, NMSettingsConnection *sett_conn)
{
return g_hash_table_add (self->_priv->available_connections, g_object_ref (connection));
return g_hash_table_add (self->_priv->available_connections, g_object_ref (sett_conn));
}
static gboolean
available_connections_del (NMDevice *self, NMConnection *connection)
available_connections_del (NMDevice *self, NMSettingsConnection *sett_conn)
{
return g_hash_table_remove (self->_priv->available_connections, connection);
return g_hash_table_remove (self->_priv->available_connections, sett_conn);
}
static gboolean
@ -13622,7 +13678,7 @@ nm_device_recheck_available_connections (NMDevice *self)
NMSettingsConnection *const*connections;
gboolean changed = FALSE;
GHashTableIter h_iter;
NMConnection *connection;
NMSettingsConnection *sett_conn;
guint i;
gs_unref_hashtable GHashTable *prune_list = NULL;
@ -13633,30 +13689,30 @@ nm_device_recheck_available_connections (NMDevice *self)
if (g_hash_table_size (priv->available_connections) > 0) {
prune_list = g_hash_table_new (nm_direct_hash, NULL);
g_hash_table_iter_init (&h_iter, priv->available_connections);
while (g_hash_table_iter_next (&h_iter, (gpointer *) &connection, NULL))
g_hash_table_add (prune_list, connection);
while (g_hash_table_iter_next (&h_iter, (gpointer *) &sett_conn, NULL))
g_hash_table_add (prune_list, sett_conn);
}
connections = nm_settings_get_connections (priv->settings, NULL);
for (i = 0; connections[i]; i++) {
connection = (NMConnection *) connections[i];
sett_conn = connections[i];
if (nm_device_check_connection_available (self,
connection,
nm_settings_connection_get_connection (sett_conn),
NM_DEVICE_CHECK_CON_AVAILABLE_NONE,
NULL,
NULL)) {
if (available_connections_add (self, connection))
if (available_connections_add (self, sett_conn))
changed = TRUE;
if (prune_list)
g_hash_table_remove (prune_list, connection);
g_hash_table_remove (prune_list, sett_conn);
}
}
if (prune_list) {
g_hash_table_iter_init (&h_iter, prune_list);
while (g_hash_table_iter_next (&h_iter, (gpointer *) &connection, NULL)) {
if (available_connections_del (self, connection))
while (g_hash_table_iter_next (&h_iter, (gpointer *) &sett_conn, NULL)) {
if (available_connections_del (self, sett_conn))
changed = TRUE;
}
}
@ -13683,7 +13739,7 @@ nm_device_get_best_connection (NMDevice *self,
GError **error)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
NMSettingsConnection *connection = NULL;
NMSettingsConnection *sett_conn = NULL;
NMSettingsConnection *candidate;
guint64 best_timestamp = 0;
GHashTableIter iter;
@ -13697,44 +13753,44 @@ nm_device_get_best_connection (NMDevice *self,
*/
if ( specific_object /* << Optimization: we know that the connection is available without @specific_object. */
&& !nm_device_check_connection_available (self,
NM_CONNECTION (candidate),
nm_settings_connection_get_connection (candidate),
_NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST,
specific_object,
NULL))
continue;
nm_settings_connection_get_timestamp (candidate, &candidate_timestamp);
if (!connection || (candidate_timestamp > best_timestamp)) {
connection = candidate;
if (!sett_conn || (candidate_timestamp > best_timestamp)) {
sett_conn = candidate;
best_timestamp = candidate_timestamp;
}
}
if (!connection) {
if (!sett_conn) {
g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_CONNECTION,
"The device '%s' has no connections available for activation.",
nm_device_get_iface (self));
}
return connection;
return sett_conn;
}
static void
cp_connection_added_or_updated (NMDevice *self, NMConnection *connection)
cp_connection_added_or_updated (NMDevice *self, NMSettingsConnection *sett_conn)
{
gboolean changed;
g_return_if_fail (NM_IS_DEVICE (self));
g_return_if_fail (NM_IS_SETTINGS_CONNECTION (connection));
g_return_if_fail (NM_IS_SETTINGS_CONNECTION (sett_conn));
if (nm_device_check_connection_available (self,
connection,
nm_settings_connection_get_connection (sett_conn),
_NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST,
NULL,
NULL))
changed = available_connections_add (self, connection);
changed = available_connections_add (self, sett_conn);
else
changed = available_connections_del (self, connection);
changed = available_connections_del (self, sett_conn);
if (changed) {
_notify (self, PROP_AVAILABLE_CONNECTIONS);
@ -13743,25 +13799,25 @@ cp_connection_added_or_updated (NMDevice *self, NMConnection *connection)
}
static void
cp_connection_added (NMSettings *settings, NMConnection *connection, gpointer user_data)
cp_connection_added (NMSettings *settings, NMSettingsConnection *sett_conn, gpointer user_data)
{
cp_connection_added_or_updated (user_data, connection);
cp_connection_added_or_updated (user_data, sett_conn);
}
static void
cp_connection_updated (NMSettings *settings, NMConnection *connection, gboolean by_user, gpointer user_data)
cp_connection_updated (NMSettings *settings, NMSettingsConnection *sett_conn, gboolean by_user, gpointer user_data)
{
cp_connection_added_or_updated (user_data, connection);
cp_connection_added_or_updated (user_data, sett_conn);
}
static void
cp_connection_removed (NMSettings *settings, NMConnection *connection, gpointer user_data)
cp_connection_removed (NMSettings *settings, NMSettingsConnection *sett_conn, gpointer user_data)
{
NMDevice *self = user_data;
g_return_if_fail (NM_IS_DEVICE (self));
if (available_connections_del (self, connection)) {
if (available_connections_del (self, sett_conn)) {
_notify (self, PROP_AVAILABLE_CONNECTIONS);
available_connections_check_delete_unrealized (self);
}
@ -14401,7 +14457,7 @@ _set_state_full (NMDevice *self,
NMDeviceState old_state;
NMActRequest *req;
gboolean no_firmware = FALSE;
NMSettingsConnection *connection;
NMSettingsConnection *sett_conn;
g_return_if_fail (NM_IS_DEVICE (self));
@ -14660,10 +14716,10 @@ _set_state_full (NMDevice *self,
break;
}
connection = nm_device_get_settings_connection (self);
sett_conn = nm_device_get_settings_connection (self);
_LOGW (LOGD_DEVICE | LOGD_WIFI,
"Activation: failed for connection '%s'",
connection ? nm_settings_connection_get_id (connection) : "<unknown>");
sett_conn ? nm_settings_connection_get_id (sett_conn) : "<unknown>");
/* Notify any slaves of the unexpected failure */
nm_device_master_release_slaves (self);
@ -14673,8 +14729,8 @@ _set_state_full (NMDevice *self,
* failed (zero timestamp), connections that succeeded (non-zero timestamp),
* and those we haven't tried yet (no timestamp).
*/
if (connection && !nm_settings_connection_get_timestamp (connection, NULL))
nm_settings_connection_update_timestamp (connection, (guint64) 0, TRUE);
if (sett_conn && !nm_settings_connection_get_timestamp (sett_conn, NULL))
nm_settings_connection_update_timestamp (sett_conn, (guint64) 0, TRUE);
/* Schedule the transition to DISCONNECTED. The device can't transition
* immediately because we can't change states again from the state

View file

@ -297,7 +297,7 @@ typedef struct _NMDeviceClass {
gboolean (* get_autoconnect_allowed) (NMDevice *self);
gboolean (* can_auto_connect) (NMDevice *self,
NMConnection *connection,
NMSettingsConnection *sett_conn,
char **specific_object);
guint32 (*get_configured_mtu) (NMDevice *self, NMDeviceMtuSource *out_source);
@ -501,6 +501,9 @@ gboolean nm_device_parent_notify_changed (NMDevice *self,
NMDevice *change_candidate,
gboolean device_removed);
const char *nm_device_parent_find_for_connection (NMDevice *self,
const char *current_setting_parent);
/* Master */
gboolean nm_device_is_master (NMDevice *dev);
@ -509,6 +512,7 @@ NMDevice * nm_device_get_master (NMDevice *dev);
NMActRequest * nm_device_get_act_request (NMDevice *dev);
NMSettingsConnection *nm_device_get_settings_connection (NMDevice *dev);
NMConnection * nm_device_get_settings_connection_get_connection (NMDevice *self);
NMConnection * nm_device_get_applied_connection (NMDevice *dev);
gboolean nm_device_has_unmodified_applied_connection (NMDevice *self,
NMSettingCompareFlags compare_flags);
@ -532,7 +536,7 @@ gboolean nm_device_master_update_slave_connection (NMDevice *master,
GError **error);
gboolean nm_device_can_auto_connect (NMDevice *self,
NMConnection *connection,
NMSettingsConnection *sett_conn,
char **specific_object);
gboolean nm_device_complete_connection (NMDevice *device,

View file

@ -797,11 +797,12 @@ get_autoconnect_allowed (NMDevice *device)
static gboolean
can_auto_connect (NMDevice *device,
NMConnection *connection,
NMSettingsConnection *sett_conn,
char **specific_object)
{
NMDeviceIwd *self = NM_DEVICE_IWD (device);
NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE (self);
NMConnection *connection;
NMSettingWireless *s_wifi;
NMWifiAP *ap;
const char *mode;
@ -809,9 +810,11 @@ can_auto_connect (NMDevice *device,
nm_assert (!specific_object || !*specific_object);
if (!NM_DEVICE_CLASS (nm_device_iwd_parent_class)->can_auto_connect (device, connection, NULL))
if (!NM_DEVICE_CLASS (nm_device_iwd_parent_class)->can_auto_connect (device, sett_conn, NULL))
return FALSE;
connection = nm_settings_connection_get_connection (sett_conn);
s_wifi = nm_connection_get_setting_wireless (connection);
g_return_val_if_fail (s_wifi, FALSE);
@ -824,7 +827,7 @@ can_auto_connect (NMDevice *device,
* but haven't been successful, since these are often accidental choices
* from the menu and the user may not know the password.
*/
if (nm_settings_connection_get_timestamp (NM_SETTINGS_CONNECTION (connection), &timestamp)) {
if (nm_settings_connection_get_timestamp (sett_conn, &timestamp)) {
if (timestamp == 0)
return FALSE;
}

View file

@ -958,11 +958,12 @@ get_autoconnect_allowed (NMDevice *device)
static gboolean
can_auto_connect (NMDevice *device,
NMConnection *connection,
NMSettingsConnection *sett_conn,
char **specific_object)
{
NMDeviceWifi *self = NM_DEVICE_WIFI (device);
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
NMConnection *connection;
NMSettingWireless *s_wifi;
NMWifiAP *ap;
const char *method, *mode;
@ -970,26 +971,28 @@ can_auto_connect (NMDevice *device,
nm_assert (!specific_object || !*specific_object);
if (!NM_DEVICE_CLASS (nm_device_wifi_parent_class)->can_auto_connect (device, connection, NULL))
if (!NM_DEVICE_CLASS (nm_device_wifi_parent_class)->can_auto_connect (device, sett_conn, NULL))
return FALSE;
connection = nm_settings_connection_get_connection (sett_conn);
s_wifi = nm_connection_get_setting_wireless (connection);
g_return_val_if_fail (s_wifi, FALSE);
/* Always allow autoconnect for AP and non-autoconf Ad-Hoc */
method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP4_CONFIG);
mode = nm_setting_wireless_get_mode (s_wifi);
if (g_strcmp0 (mode, NM_SETTING_WIRELESS_MODE_AP) == 0)
if (nm_streq0 (mode, NM_SETTING_WIRELESS_MODE_AP))
return TRUE;
else if ( g_strcmp0 (mode, NM_SETTING_WIRELESS_MODE_ADHOC) == 0
&& g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) != 0)
else if ( nm_streq0 (mode, NM_SETTING_WIRELESS_MODE_ADHOC)
&& !nm_streq0 (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO))
return TRUE;
/* Don't autoconnect to networks that have been tried at least once
* but haven't been successful, since these are often accidental choices
* from the menu and the user may not know the password.
*/
if (nm_settings_connection_get_timestamp (NM_SETTINGS_CONNECTION (connection), &timestamp)) {
if (nm_settings_connection_get_timestamp (sett_conn, &timestamp)) {
if (timestamp == 0)
return FALSE;
}
@ -1264,14 +1267,15 @@ check_scanning_prohibited (NMDeviceWifi *self, gboolean periodic)
static gboolean
hidden_filter_func (NMSettings *settings,
NMSettingsConnection *connection,
NMSettingsConnection *set_con,
gpointer user_data)
{
NMConnection *connection = nm_settings_connection_get_connection (set_con);
NMSettingWireless *s_wifi;
if (!nm_connection_is_type (NM_CONNECTION (connection), NM_SETTING_WIRELESS_SETTING_NAME))
if (!nm_connection_is_type (connection, NM_SETTING_WIRELESS_SETTING_NAME))
return FALSE;
s_wifi = nm_connection_get_setting_wireless (NM_CONNECTION (connection));
s_wifi = nm_connection_get_setting_wireless (connection);
if (!s_wifi)
return FALSE;
if (nm_streq0 (nm_setting_wireless_get_mode (s_wifi), NM_SETTING_WIRELESS_MODE_AP))
@ -1316,7 +1320,7 @@ build_hidden_probe_list (NMDeviceWifi *self)
if (i >= max_scan_ssids - 1)
break;
s_wifi = (NMSettingWireless *) nm_connection_get_setting_wireless (NM_CONNECTION (connections[i]));
s_wifi = (NMSettingWireless *) nm_connection_get_setting_wireless (nm_settings_connection_get_connection (connections[i]));
ssid = nm_setting_wireless_get_ssid (s_wifi);
g_ptr_array_add (ssids, g_bytes_ref (ssid));
}
@ -1509,12 +1513,12 @@ try_fill_ssid_for_hidden_ap (NMDeviceWifi *self,
* and if a match is found, copy over the SSID */
connections = nm_settings_get_connections (nm_device_get_settings ((NMDevice *) self), NULL);
for (i = 0; connections[i]; i++) {
NMConnection *connection = (NMConnection *) connections[i];
NMSettingsConnection *sett_conn = connections[i];
NMSettingWireless *s_wifi;
s_wifi = nm_connection_get_setting_wireless (connection);
s_wifi = nm_connection_get_setting_wireless (nm_settings_connection_get_connection (sett_conn));
if (s_wifi) {
if (nm_settings_connection_has_seen_bssid (NM_SETTINGS_CONNECTION (connection), bssid)) {
if (nm_settings_connection_has_seen_bssid (sett_conn, bssid)) {
nm_wifi_ap_set_ssid (ap, nm_setting_wireless_get_ssid (s_wifi));
break;
}

View file

@ -1544,8 +1544,8 @@ nm_wifi_ap_lookup_for_device (NMDevice *device, const char *exported_path)
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
ap = (NMWifiAP *) nm_dbus_manager_lookup_object (nm_dbus_object_get_manager (NM_DBUS_OBJECT (device)),
exported_path);
ap = nm_dbus_manager_lookup_object (nm_dbus_object_get_manager (NM_DBUS_OBJECT (device)),
exported_path);
if ( !ap
|| !NM_IS_WIFI_AP (ap)
|| ap->wifi_device != device)

View file

@ -174,7 +174,7 @@ NM_UTILS_FLAGS2STR_DEFINE_STATIC (_state_flags_to_string, NMActivationStateFlags
/*****************************************************************************/
static void
_settings_connection_updated (NMSettingsConnection *connection,
_settings_connection_updated (NMSettingsConnection *sett_conn,
gboolean by_user,
gpointer user_data)
{
@ -196,24 +196,24 @@ _settings_connection_updated (NMSettingsConnection *connection,
}
static void
_set_settings_connection (NMActiveConnection *self, NMSettingsConnection *connection)
_set_settings_connection (NMActiveConnection *self, NMSettingsConnection *sett_conn)
{
NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
if (priv->settings_connection.obj == connection)
if (priv->settings_connection.obj == sett_conn)
return;
if (priv->settings_connection.obj) {
g_signal_handlers_disconnect_by_func (priv->settings_connection.obj, _settings_connection_updated, self);
g_signal_handlers_disconnect_by_func (priv->settings_connection.obj, _settings_connection_flags_changed, self);
}
if (connection) {
g_signal_connect (connection, NM_SETTINGS_CONNECTION_UPDATED_INTERNAL, (GCallback) _settings_connection_updated, self);
if (sett_conn) {
g_signal_connect (sett_conn, NM_SETTINGS_CONNECTION_UPDATED_INTERNAL, (GCallback) _settings_connection_updated, self);
if (nm_active_connection_get_activation_type (self) == NM_ACTIVATION_TYPE_EXTERNAL)
g_signal_connect (connection, NM_SETTINGS_CONNECTION_FLAGS_CHANGED, (GCallback) _settings_connection_flags_changed, self);
g_signal_connect (sett_conn, NM_SETTINGS_CONNECTION_FLAGS_CHANGED, (GCallback) _settings_connection_flags_changed, self);
}
nm_dbus_track_obj_path_set (&priv->settings_connection, connection, TRUE);
nm_dbus_track_obj_path_set (&priv->settings_connection, sett_conn, TRUE);
}
NMActiveConnectionState
@ -367,13 +367,13 @@ nm_active_connection_set_state_flags_full (NMActiveConnection *self,
const char *
nm_active_connection_get_settings_connection_id (NMActiveConnection *self)
{
NMSettingsConnection *con;
NMSettingsConnection *sett_conn;
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (self), NULL);
con = NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->settings_connection.obj;
return con
? nm_connection_get_id (NM_CONNECTION (con))
sett_conn = NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->settings_connection.obj;
return sett_conn
? nm_settings_connection_get_id (sett_conn)
: NULL;
}
@ -388,31 +388,31 @@ _nm_active_connection_get_settings_connection (NMActiveConnection *self)
NMSettingsConnection *
nm_active_connection_get_settings_connection (NMActiveConnection *self)
{
NMSettingsConnection *con;
NMSettingsConnection *sett_conn;
con = _nm_active_connection_get_settings_connection (self);
sett_conn = _nm_active_connection_get_settings_connection (self);
/* Only call this function on an active-connection that is already
* fully set-up (i.e. that has a settings-connection). Other uses
* indicate a bug. */
g_return_val_if_fail (con, NULL);
return con;
g_return_val_if_fail (sett_conn, NULL);
return sett_conn;
}
NMConnection *
nm_active_connection_get_applied_connection (NMActiveConnection *self)
{
NMConnection *con;
NMConnection *connection;
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (self), NULL);
con = NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->applied_connection;
connection = NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->applied_connection;
/* Only call this function on an active-connection that is already
* fully set-up (i.e. that has a settings-connection). Other uses
* indicate a bug. */
g_return_val_if_fail (con, NULL);
return con;
g_return_val_if_fail (connection, NULL);
return connection;
}
static void
@ -447,7 +447,7 @@ _set_applied_connection_take (NMActiveConnection *self,
void
nm_active_connection_set_settings_connection (NMActiveConnection *self,
NMSettingsConnection *connection)
NMSettingsConnection *sett_conn)
{
NMActiveConnectionPrivate *priv;
@ -455,7 +455,7 @@ nm_active_connection_set_settings_connection (NMActiveConnection *self,
priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
g_return_if_fail (NM_IS_SETTINGS_CONNECTION (connection));
g_return_if_fail (NM_IS_SETTINGS_CONNECTION (sett_conn));
g_return_if_fail (!priv->settings_connection.obj);
g_return_if_fail (!priv->applied_connection);
@ -468,10 +468,10 @@ nm_active_connection_set_settings_connection (NMActiveConnection *self,
* For example, we'd have to cancel all pending seret requests. */
g_return_if_fail (!nm_dbus_object_is_exported (NM_DBUS_OBJECT (self)));
_set_settings_connection (self, connection);
_set_settings_connection (self, sett_conn);
_set_applied_connection_take (self,
nm_simple_connection_new_clone (NM_CONNECTION (priv->settings_connection.obj)));
nm_simple_connection_new_clone (nm_settings_connection_get_connection (priv->settings_connection.obj)));
}
gboolean
@ -503,8 +503,10 @@ nm_active_connection_clear_secrets (NMActiveConnection *self)
if (nm_settings_connection_has_unmodified_applied_connection (priv->settings_connection.obj,
priv->applied_connection,
NM_SETTING_COMPARE_FLAG_NONE))
nm_connection_clear_secrets ((NMConnection *) priv->settings_connection.obj);
NM_SETTING_COMPARE_FLAG_NONE)) {
/* FIXME(copy-on-write-connection): avoid modifying NMConnection instances and share them via copy-on-write. */
nm_connection_clear_secrets (nm_settings_connection_get_connection (priv->settings_connection.obj));
}
nm_connection_clear_secrets (priv->applied_connection);
}
@ -921,7 +923,7 @@ _settings_connection_flags_changed (NMSettingsConnection *settings_connection,
_set_activation_type_managed (self);
if (!nm_device_reapply (nm_active_connection_get_device (self),
NM_CONNECTION (nm_active_connection_get_settings_connection (self)),
nm_settings_connection_get_connection ((nm_active_connection_get_settings_connection (self))),
&error)) {
_LOGW ("failed to reapply new device settings on previously externally managed device: %s",
error->message);
@ -1112,7 +1114,7 @@ nm_active_connection_authorize (NMActiveConnection *self,
{
NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
const char *wifi_permission = NULL;
NMConnection *con;
NMConnection *connection;
g_return_if_fail (result_func);
g_return_if_fail (!priv->auth.call_id_network_control);
@ -1122,11 +1124,11 @@ nm_active_connection_authorize (NMActiveConnection *self,
g_return_if_fail (NM_IS_CONNECTION (initial_connection));
g_return_if_fail (!priv->settings_connection.obj);
g_return_if_fail (!priv->applied_connection);
con = initial_connection;
connection = initial_connection;
} else {
g_return_if_fail (NM_IS_SETTINGS_CONNECTION (priv->settings_connection.obj));
g_return_if_fail (NM_IS_CONNECTION (priv->applied_connection));
con = priv->applied_connection;
connection = priv->applied_connection;
}
priv->auth.call_id_network_control = nm_auth_manager_check_authorization (nm_auth_manager_get (),
@ -1137,7 +1139,7 @@ nm_active_connection_authorize (NMActiveConnection *self,
self);
/* Shared wifi connections require special permissions too */
wifi_permission = nm_utils_get_shared_wifi_permission (con);
wifi_permission = nm_utils_get_shared_wifi_permission (connection);
if (wifi_permission) {
priv->auth.call_id_wifi_shared_permission = nm_auth_manager_check_authorization (nm_auth_manager_get (),
priv->subject,
@ -1227,13 +1229,13 @@ get_property (GObject *object, guint prop_id,
g_value_set_string (value, nm_dbus_track_obj_path_get (&priv->settings_connection));
break;
case PROP_ID:
g_value_set_string (value, nm_connection_get_id (NM_CONNECTION (priv->settings_connection.obj)));
g_value_set_string (value, nm_settings_connection_get_id (priv->settings_connection.obj));
break;
case PROP_UUID:
g_value_set_string (value, nm_connection_get_uuid (NM_CONNECTION (priv->settings_connection.obj)));
g_value_set_string (value, nm_settings_connection_get_uuid (priv->settings_connection.obj));
break;
case PROP_TYPE:
g_value_set_string (value, nm_connection_get_connection_type (NM_CONNECTION (priv->settings_connection.obj)));
g_value_set_string (value, nm_settings_connection_get_connection_type (priv->settings_connection.obj));
break;
case PROP_SPECIFIC_OBJECT:
@ -1304,16 +1306,16 @@ set_property (GObject *object, guint prop_id,
NMActiveConnection *self = (NMActiveConnection *) object;
NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
const char *tmp;
NMSettingsConnection *con;
NMSettingsConnection *sett_conn;
NMConnection *acon;
int i;
switch (prop_id) {
case PROP_INT_SETTINGS_CONNECTION:
/* construct-only */
con = g_value_get_object (value);
if (con)
_set_settings_connection (self, con);
sett_conn = g_value_get_object (value);
if (sett_conn)
_set_settings_connection (self, sett_conn);
break;
case PROP_INT_APPLIED_CONNECTION:
/* construct-only */
@ -1410,7 +1412,7 @@ constructed (GObject *object)
if ( !priv->applied_connection
&& priv->settings_connection.obj)
priv->applied_connection = nm_simple_connection_new_clone (NM_CONNECTION (priv->settings_connection.obj));
priv->applied_connection = nm_simple_connection_new_clone (nm_settings_connection_get_connection (priv->settings_connection.obj));
_LOGD ("constructed (%s, version-id %llu, type %s)",
G_OBJECT_TYPE_NAME (self),

View file

@ -265,8 +265,8 @@ nm_checkpoint_manager_lookup_by_path (NMCheckpointManager *self, const char *pat
g_return_val_if_fail (self, NULL);
checkpoint = (NMCheckpoint *) nm_dbus_manager_lookup_object (nm_dbus_object_get_manager (NM_DBUS_OBJECT (GET_MANAGER (self))),
path);
checkpoint = nm_dbus_manager_lookup_object (nm_dbus_object_get_manager (NM_DBUS_OBJECT (GET_MANAGER (self))),
path);
if ( !checkpoint
|| !NM_IS_CHECKPOINT (checkpoint)) {
g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_INVALID_ARGUMENTS,

View file

@ -159,7 +159,7 @@ find_settings_connection (NMCheckpoint *self,
{
NMCheckpointPrivate *priv = NM_CHECKPOINT_GET_PRIVATE (self);
NMActiveConnection *active;
NMSettingsConnection *connection;
NMSettingsConnection *sett_conn;
const char *uuid, *ac_uuid;
const CList *tmp_clist;
@ -167,14 +167,14 @@ find_settings_connection (NMCheckpoint *self,
*need_update = FALSE;
uuid = nm_connection_get_uuid (dev_checkpoint->settings_connection);
connection = nm_settings_get_connection_by_uuid (nm_settings_get (), uuid);
sett_conn = nm_settings_get_connection_by_uuid (nm_settings_get (), uuid);
if (!connection)
if (!sett_conn)
return NULL;
/* Now check if the connection changed, ... */
if (!nm_connection_compare (dev_checkpoint->settings_connection,
NM_CONNECTION (connection),
nm_settings_connection_get_connection (sett_conn),
NM_SETTING_COMPARE_FLAG_EXACT)) {
_LOGT ("rollback: settings connection %s changed", uuid);
*need_update = TRUE;
@ -193,7 +193,7 @@ find_settings_connection (NMCheckpoint *self,
if (!active) {
_LOGT ("rollback: connection %s is not active", uuid);
*need_activation = TRUE;
return connection;
return sett_conn;
}
/* ... or if the connection was reactivated/reapplied */
@ -202,7 +202,7 @@ find_settings_connection (NMCheckpoint *self,
*need_activation = TRUE;
}
return connection;
return sett_conn;
}
GVariant *
@ -337,8 +337,8 @@ activate:
dev_checkpoint->activation_reason,
&local_error)) {
_LOGW ("rollback: reactivation of connection %s/%s failed: %s",
nm_connection_get_id ((NMConnection *) connection),
nm_connection_get_uuid ((NMConnection *) connection),
nm_settings_connection_get_id (connection),
nm_settings_connection_get_uuid (connection),
local_error->message);
g_clear_error (&local_error);
result = NM_ROLLBACK_RESULT_ERR_FAILED;
@ -436,12 +436,9 @@ device_checkpoint_create (NMDevice *device)
applied_connection = nm_act_request_get_applied_connection (act_request);
dev_checkpoint->applied_connection = nm_simple_connection_new_clone (applied_connection);
dev_checkpoint->settings_connection =
nm_simple_connection_new_clone (NM_CONNECTION (settings_connection));
dev_checkpoint->ac_version_id =
nm_active_connection_version_id_get (NM_ACTIVE_CONNECTION (act_request));
dev_checkpoint->activation_reason =
nm_active_connection_get_activation_reason (NM_ACTIVE_CONNECTION (act_request));
dev_checkpoint->settings_connection = nm_simple_connection_new_clone (nm_settings_connection_get_connection (settings_connection));
dev_checkpoint->ac_version_id = nm_active_connection_version_id_get (NM_ACTIVE_CONNECTION (act_request));
dev_checkpoint->activation_reason = nm_active_connection_get_activation_reason (NM_ACTIVE_CONNECTION (act_request));
}
return dev_checkpoint;

View file

@ -1084,7 +1084,7 @@ _obj_unregister (NMDBusManager *self,
NULL);
}
NMDBusObject *
gpointer
nm_dbus_manager_lookup_object (NMDBusManager *self, const char *path)
{
NMDBusManagerPrivate *priv;

View file

@ -61,7 +61,7 @@ gboolean nm_dbus_manager_is_stopping (NMDBusManager *self);
GDBusConnection *nm_dbus_manager_get_connection (NMDBusManager *self);
NMDBusObject *nm_dbus_manager_lookup_object (NMDBusManager *self, const char *path);
gpointer nm_dbus_manager_lookup_object (NMDBusManager *self, const char *path);
void _nm_dbus_manager_obj_export (NMDBusObject *obj);
void _nm_dbus_manager_obj_unexport (NMDBusObject *obj);

File diff suppressed because it is too large Load diff

View file

@ -1242,23 +1242,26 @@ auto_activate_device (NMPolicy *self,
/* Find the first connection that should be auto-activated */
best_connection = NULL;
for (i = 0; i < len; i++) {
NMSettingsConnection *candidate = NM_SETTINGS_CONNECTION (connections[i]);
NMSettingsConnection *candidate = connections[i];
NMConnection *cand_conn;
NMSettingConnection *s_con;
const char *permission;
if (nm_settings_connection_autoconnect_is_blocked (candidate))
continue;
s_con = nm_connection_get_setting_connection (NM_CONNECTION (candidate));
cand_conn = nm_settings_connection_get_connection (candidate);
s_con = nm_connection_get_setting_connection (cand_conn);
if (!nm_setting_connection_get_autoconnect (s_con))
continue;
permission = nm_utils_get_shared_wifi_permission (NM_CONNECTION (candidate));
permission = nm_utils_get_shared_wifi_permission (cand_conn);
if ( permission
&& !nm_settings_connection_check_permission (candidate, permission))
continue;
if (nm_device_can_auto_connect (device, (NMConnection *) candidate, &specific_object)) {
if (nm_device_can_auto_connect (device, candidate, &specific_object)) {
best_connection = candidate;
break;
}
@ -1441,34 +1444,36 @@ reset_autoconnect_all (NMPolicy *self,
connections = nm_settings_get_connections (priv->settings, NULL);
for (i = 0; connections[i]; i++) {
NMSettingsConnection *connection = connections[i];
NMSettingsConnection *sett_conn = connections[i];
if ( device
&& !nm_device_check_connection_compatible (device, NM_CONNECTION (connection), NULL))
&& !nm_device_check_connection_compatible (device,
nm_settings_connection_get_connection (sett_conn),
NULL))
continue;
if (only_no_secrets) {
/* we only reset the no-secrets blocked flag. */
if (nm_settings_connection_autoconnect_blocked_reason_set (connection,
if (nm_settings_connection_autoconnect_blocked_reason_set (sett_conn,
NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_NO_SECRETS,
FALSE)) {
/* maybe the connection is still blocked afterwards for other reasons
* and in the larger picture nothing changed. But it's too complicated
* to find out exactly. Just assume, something changed to be sure. */
if (!nm_settings_connection_autoconnect_is_blocked (connection))
if (!nm_settings_connection_autoconnect_is_blocked (sett_conn))
changed = TRUE;
}
} else {
/* we reset the tries-count and any blocked-reason */
if (nm_settings_connection_autoconnect_retries_get (connection) == 0)
if (nm_settings_connection_autoconnect_retries_get (sett_conn) == 0)
changed = TRUE;
nm_settings_connection_autoconnect_retries_reset (connection);
nm_settings_connection_autoconnect_retries_reset (sett_conn);
if (nm_settings_connection_autoconnect_blocked_reason_set (connection,
if (nm_settings_connection_autoconnect_blocked_reason_set (sett_conn,
NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_ALL
& ~NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_USER_REQUEST,
FALSE)) {
if (!nm_settings_connection_autoconnect_is_blocked (connection))
if (!nm_settings_connection_autoconnect_is_blocked (sett_conn))
changed = TRUE;
}
}
@ -1589,7 +1594,9 @@ static void
activate_slave_connections (NMPolicy *self, NMDevice *device)
{
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self);
const char *master_device, *master_uuid_settings = NULL, *master_uuid_applied = NULL;
const char *master_device;
const char *master_uuid_settings = NULL;
const char *master_uuid_applied = NULL;
guint i;
NMActRequest *req;
gboolean internal_activation = FALSE;
@ -1601,16 +1608,18 @@ activate_slave_connections (NMPolicy *self, NMDevice *device)
req = nm_device_get_act_request (device);
if (req) {
NMConnection *con;
NMConnection *connection;
NMSettingsConnection *sett_conn;
NMAuthSubject *subject;
con = nm_active_connection_get_applied_connection (NM_ACTIVE_CONNECTION (req));
if (con)
master_uuid_applied = nm_connection_get_uuid (con);
con = NM_CONNECTION (nm_active_connection_get_settings_connection (NM_ACTIVE_CONNECTION (req)));
if (con) {
master_uuid_settings = nm_connection_get_uuid (con);
if (!g_strcmp0 (master_uuid_settings, master_uuid_applied))
connection = nm_active_connection_get_applied_connection (NM_ACTIVE_CONNECTION (req));
if (connection)
master_uuid_applied = nm_connection_get_uuid (connection);
sett_conn = nm_active_connection_get_settings_connection (NM_ACTIVE_CONNECTION (req));
if (sett_conn) {
master_uuid_settings = nm_settings_connection_get_uuid (sett_conn);
if (nm_streq0 (master_uuid_settings, master_uuid_applied))
master_uuid_settings = NULL;
}
@ -1621,11 +1630,11 @@ activate_slave_connections (NMPolicy *self, NMDevice *device)
changed = FALSE;
connections = nm_settings_get_connections (priv->settings, NULL);
for (i = 0; connections[i]; i++) {
NMSettingsConnection *connection = connections[i];
NMSettingsConnection *sett_conn = connections[i];
NMSettingConnection *s_slave_con;
const char *slave_master;
s_slave_con = nm_connection_get_setting_connection (NM_CONNECTION (connection));
s_slave_con = nm_connection_get_setting_connection (nm_settings_connection_get_connection (sett_conn));
slave_master = nm_setting_connection_get_master (s_slave_con);
if (!slave_master)
continue;
@ -1635,14 +1644,14 @@ activate_slave_connections (NMPolicy *self, NMDevice *device)
continue;
if (!internal_activation) {
if (nm_settings_connection_autoconnect_retries_get (connection) == 0)
if (nm_settings_connection_autoconnect_retries_get (sett_conn) == 0)
changed = TRUE;
nm_settings_connection_autoconnect_retries_reset (connection);
nm_settings_connection_autoconnect_retries_reset (sett_conn);
}
if (nm_settings_connection_autoconnect_blocked_reason_set (connection,
if (nm_settings_connection_autoconnect_blocked_reason_set (sett_conn,
NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_FAILED,
FALSE)) {
if (!nm_settings_connection_autoconnect_is_blocked (connection))
if (!nm_settings_connection_autoconnect_is_blocked (sett_conn))
changed = TRUE;
}
}
@ -1658,7 +1667,6 @@ activate_secondary_connections (NMPolicy *self,
{
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self);
NMSettingConnection *s_con;
NMSettingsConnection *settings_con;
NMActiveConnection *ac;
PendingSecondaryData *secondary_data;
GSList *secondary_ac_list = NULL;
@ -1667,22 +1675,25 @@ activate_secondary_connections (NMPolicy *self,
gboolean success = TRUE;
s_con = nm_connection_get_setting_connection (connection);
g_assert (s_con);
nm_assert (s_con);
for (i = 0; i < nm_setting_connection_get_num_secondaries (s_con); i++) {
NMSettingsConnection *sett_conn;
const char *sec_uuid = nm_setting_connection_get_secondary (s_con, i);
NMActRequest *req;
settings_con = nm_settings_get_connection_by_uuid (priv->settings, sec_uuid);
if (!settings_con) {
sett_conn = nm_settings_get_connection_by_uuid (priv->settings, sec_uuid);
if (!sett_conn) {
_LOGW (LOGD_DEVICE, "secondary connection '%s' auto-activation failed: The connection doesn't exist.",
sec_uuid);
success = FALSE;
break;
}
if (!nm_connection_is_type (NM_CONNECTION (settings_con), NM_SETTING_VPN_SETTING_NAME)) {
if (!nm_connection_is_type (nm_settings_connection_get_connection (sett_conn),
NM_SETTING_VPN_SETTING_NAME)) {
_LOGW (LOGD_DEVICE, "secondary connection '%s (%s)' auto-activation failed: The connection is not a VPN.",
nm_settings_connection_get_id (settings_con), sec_uuid);
nm_settings_connection_get_id (sett_conn), sec_uuid);
success = FALSE;
break;
}
@ -1691,10 +1702,10 @@ activate_secondary_connections (NMPolicy *self,
g_assert (req);
_LOGD (LOGD_DEVICE, "activating secondary connection '%s (%s)' for base connection '%s (%s)'",
nm_settings_connection_get_id (settings_con), sec_uuid,
nm_settings_connection_get_id (sett_conn), sec_uuid,
nm_connection_get_id (connection), nm_connection_get_uuid (connection));
ac = nm_manager_activate_connection (priv->manager,
settings_con,
sett_conn,
NULL,
nm_dbus_object_get_path (NM_DBUS_OBJECT (req)),
device,
@ -1706,7 +1717,7 @@ activate_secondary_connections (NMPolicy *self,
secondary_ac_list = g_slist_append (secondary_ac_list, g_object_ref (ac));
else {
_LOGW (LOGD_DEVICE, "secondary connection '%s (%s)' auto-activation failed: (%d) %s",
nm_settings_connection_get_id (settings_con), sec_uuid,
nm_settings_connection_get_id (sett_conn), sec_uuid,
error->code,
error->message);
g_clear_error (&error);
@ -1734,7 +1745,7 @@ device_state_changed (NMDevice *device,
NMPolicyPrivate *priv = user_data;
NMPolicy *self = _PRIV_TO_SELF (priv);
NMActiveConnection *ac;
NMSettingsConnection *connection = nm_device_get_settings_connection (device);
NMSettingsConnection *sett_conn = nm_device_get_settings_connection (device);
NMIP4Config *ip4_config;
NMIP6Config *ip6_config;
NMSettingConnection *s_con = NULL;
@ -1752,8 +1763,8 @@ device_state_changed (NMDevice *device,
/* Block autoconnect of the just-failed connection for situations
* where a retry attempt would just fail again.
*/
if (connection) {
nm_settings_connection_autoconnect_blocked_reason_set (connection,
if (sett_conn) {
nm_settings_connection_autoconnect_blocked_reason_set (sett_conn,
NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_FAILED,
TRUE);
}
@ -1767,7 +1778,7 @@ device_state_changed (NMDevice *device,
/* Mark the connection invalid if it failed during activation so that
* it doesn't get automatically chosen over and over and over again.
*/
if ( connection
if ( sett_conn
&& old_state >= NM_DEVICE_STATE_PREPARE
&& old_state <= NM_DEVICE_STATE_ACTIVATED) {
gboolean block_no_secrets = FALSE;
@ -1788,7 +1799,7 @@ device_state_changed (NMDevice *device,
* That can happen when nm_settings_connection_get_secrets() fails early without actually
* consulting any agents.
*/
con_v = nm_settings_connection_get_last_secret_agent_version_id (connection);
con_v = nm_settings_connection_get_last_secret_agent_version_id (sett_conn);
if ( con_v == 0
|| con_v == nm_agent_manager_get_agent_version_id (priv->agent_mgr))
block_no_secrets = TRUE;
@ -1796,33 +1807,35 @@ device_state_changed (NMDevice *device,
if (block_no_secrets) {
_LOGD (LOGD_DEVICE, "connection '%s' now blocked from autoconnect due to no secrets",
nm_settings_connection_get_id (connection));
nm_settings_connection_autoconnect_blocked_reason_set (connection, NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_NO_SECRETS, TRUE);
nm_settings_connection_get_id (sett_conn));
nm_settings_connection_autoconnect_blocked_reason_set (sett_conn, NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_NO_SECRETS, TRUE);
} else {
tries = nm_settings_connection_autoconnect_retries_get (connection);
tries = nm_settings_connection_autoconnect_retries_get (sett_conn);
if (tries > 0) {
_LOGD (LOGD_DEVICE, "connection '%s' failed to autoconnect; %d tries left",
nm_settings_connection_get_id (connection), tries - 1);
_connection_autoconnect_retries_set (self, connection, tries - 1);
nm_settings_connection_get_id (sett_conn), tries - 1);
_connection_autoconnect_retries_set (self, sett_conn, tries - 1);
} else if (tries != 0) {
_LOGD (LOGD_DEVICE, "connection '%s' failed to autoconnect; infinite tries left",
nm_settings_connection_get_id (connection));
nm_settings_connection_get_id (sett_conn));
}
}
nm_connection_clear_secrets (NM_CONNECTION (connection));
/* FIXME(copy-on-write-connection): avoid modifying NMConnection instances and share them via copy-on-write. */
nm_connection_clear_secrets (nm_settings_connection_get_connection (sett_conn));
}
break;
case NM_DEVICE_STATE_ACTIVATED:
if (connection) {
if (sett_conn) {
/* Reset auto retries back to default since connection was successful */
nm_settings_connection_autoconnect_retries_reset (connection);
nm_settings_connection_autoconnect_retries_reset (sett_conn);
/* And clear secrets so they will always be requested from the
* settings service when the next connection is made.
*/
nm_connection_clear_secrets (NM_CONNECTION (connection));
/* FIXME(copy-on-write-connection): avoid modifying NMConnection instances and share them via copy-on-write. */
nm_connection_clear_secrets (nm_settings_connection_get_connection (sett_conn));
}
/* Add device's new IPv4 and IPv6 configs to DNS */
@ -1846,7 +1859,7 @@ device_state_changed (NMDevice *device,
update_routing_and_dns (self, FALSE);
break;
case NM_DEVICE_STATE_DEACTIVATING:
if (connection) {
if (sett_conn) {
NMSettingsAutoconnectBlockedReason blocked_reason = NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_NONE;
switch (nm_device_state_reason_check (reason)) {
@ -1861,10 +1874,10 @@ device_state_changed (NMDevice *device,
}
if (blocked_reason != NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_NONE) {
_LOGD (LOGD_DEVICE, "blocking autoconnect of connection '%s': %s",
nm_settings_connection_get_id (connection),
nm_settings_connection_get_id (sett_conn),
NM_UTILS_LOOKUP_STR (nm_device_state_reason_to_str,
nm_device_state_reason_check (reason)));
nm_settings_connection_autoconnect_blocked_reason_set (connection, blocked_reason, TRUE);
nm_settings_connection_autoconnect_blocked_reason_set (sett_conn, blocked_reason, TRUE);
}
}
ip6_remove_device_prefix_delegations (self, device);
@ -1900,20 +1913,25 @@ device_state_changed (NMDevice *device,
break;
case NM_DEVICE_STATE_IP_CONFIG:
/* We must have secrets if we got here. */
if (connection)
nm_settings_connection_autoconnect_blocked_reason_set (connection, NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_ALL, FALSE);
if (sett_conn)
nm_settings_connection_autoconnect_blocked_reason_set (sett_conn, NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_ALL, FALSE);
break;
case NM_DEVICE_STATE_SECONDARIES:
if (connection)
s_con = nm_connection_get_setting_connection (NM_CONNECTION (connection));
if (s_con && nm_setting_connection_get_num_secondaries (s_con) > 0) {
if (sett_conn)
s_con = nm_connection_get_setting_connection (nm_settings_connection_get_connection (sett_conn));
if ( s_con
&& nm_setting_connection_get_num_secondaries (s_con) > 0) {
/* Make routes and DNS up-to-date before activating dependent connections */
update_routing_and_dns (self, FALSE);
/* Activate secondary (VPN) connections */
if (!activate_secondary_connections (self, NM_CONNECTION (connection), device))
nm_device_queue_state (device, NM_DEVICE_STATE_FAILED,
if (!activate_secondary_connections (self,
nm_settings_connection_get_connection (sett_conn),
device)) {
nm_device_queue_state (device,
NM_DEVICE_STATE_FAILED,
NM_DEVICE_STATE_REASON_SECONDARY_CONNECTION_FAILED);
}
} else
nm_device_queue_state (device, NM_DEVICE_STATE_ACTIVATED,
NM_DEVICE_STATE_REASON_NONE);

View file

@ -49,7 +49,26 @@
/*****************************************************************************/
static void nm_settings_connection_connection_interface_init (NMConnectionInterface *iface);
NMConnection **
nm_settings_connections_array_to_connections (NMSettingsConnection *const*connections,
gssize n_connections)
{
NMConnection **arr;
gssize i;
if (n_connections < 0)
n_connections = NM_PTRARRAY_LEN (connections);
if (n_connections == 0)
return NULL;
arr = g_new (NMConnection *, n_connections + 1);
for (i = 0; i < n_connections; i++)
arr[i] = nm_settings_connection_get_connection (connections[i]);
arr[i] = NULL;
return arr;
}
/*****************************************************************************/
NM_GOBJECT_PROPERTIES_DEFINE (NMSettingsConnection,
PROP_UNSAVED,
@ -87,6 +106,8 @@ typedef struct _NMSettingsConnectionPrivate {
CList call_ids_lst_head; /* in-progress secrets requests */
NMConnection *connection;
/* Caches secrets from on-disk connections; were they not cached any
* call to nm_connection_clear_secrets() wipes them out and we'd have
* to re-read them from disk which defeats the purpose of having the
@ -115,9 +136,7 @@ typedef struct _NMSettingsConnectionPrivate {
} NMSettingsConnectionPrivate;
G_DEFINE_TYPE_WITH_CODE (NMSettingsConnection, nm_settings_connection, NM_TYPE_DBUS_OBJECT,
G_IMPLEMENT_INTERFACE (NM_TYPE_CONNECTION, nm_settings_connection_connection_interface_init)
)
G_DEFINE_TYPE (NMSettingsConnection, nm_settings_connection, NM_TYPE_DBUS_OBJECT)
#define NM_SETTINGS_CONNECTION_GET_PRIVATE(self) _NM_GET_PRIVATE_PTR (self, NMSettingsConnection, NM_IS_SETTINGS_CONNECTION)
@ -152,6 +171,16 @@ static const NMDBusInterfaceInfoExtended interface_info_settings_connection;
/*****************************************************************************/
NMConnection *
nm_settings_connection_get_connection (NMSettingsConnection *self)
{
g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (self), NULL);
return NM_SETTINGS_CONNECTION_GET_PRIVATE (self)->connection;
}
/*****************************************************************************/
gboolean
nm_settings_connection_has_unmodified_applied_connection (NMSettingsConnection *self,
NMConnection *applied_connection,
@ -163,7 +192,8 @@ nm_settings_connection_has_unmodified_applied_connection (NMSettingsConnection *
/* for convenience, we *always* ignore certain settings. */
compare_flags |= NM_SETTING_COMPARE_FLAG_IGNORE_SECRETS | NM_SETTING_COMPARE_FLAG_IGNORE_TIMESTAMP;
return nm_connection_compare (NM_CONNECTION (self), applied_connection, compare_flags);
return nm_connection_compare (nm_settings_connection_get_connection (self),
applied_connection, compare_flags);
}
/*****************************************************************************/
@ -332,8 +362,7 @@ nm_settings_connection_recheck_visibility (NMSettingsConnection *self)
priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self);
s_con = nm_connection_get_setting_connection (NM_CONNECTION (self));
g_assert (s_con);
s_con = nm_connection_get_setting_connection (nm_settings_connection_get_connection (self));
/* Check every user in the ACL for a session */
num = nm_setting_connection_get_num_permissions (s_con);
@ -362,9 +391,9 @@ nm_settings_connection_recheck_visibility (NMSettingsConnection *self)
}
static void
session_changed_cb (NMSessionMonitor *self, gpointer user_data)
session_changed_cb (NMSessionMonitor *self, NMSettingsConnection *sett_conn)
{
nm_settings_connection_recheck_visibility (NM_SETTINGS_CONNECTION (user_data));
nm_settings_connection_recheck_visibility (sett_conn);
}
/*****************************************************************************/
@ -390,8 +419,7 @@ nm_settings_connection_check_permission (NMSettingsConnection *self,
NM_SETTINGS_CONNECTION_INT_FLAGS_VISIBLE))
return FALSE;
s_con = nm_connection_get_setting_connection (NM_CONNECTION (self));
g_assert (s_con);
s_con = nm_connection_get_setting_connection (nm_settings_connection_get_connection (self));
/* Check every user in the ACL for a session */
num = nm_setting_connection_get_num_permissions (s_con);
@ -447,7 +475,7 @@ update_system_secrets_cache (NMSettingsConnection *self)
if (priv->system_secrets)
g_object_unref (priv->system_secrets);
priv->system_secrets = nm_simple_connection_new_clone (NM_CONNECTION (self));
priv->system_secrets = nm_simple_connection_new_clone (nm_settings_connection_get_connection (self));
/* Clear out non-system-owned and not-saved secrets */
nm_connection_clear_secrets_with_flags (priv->system_secrets,
@ -463,7 +491,8 @@ update_agent_secrets_cache (NMSettingsConnection *self, NMConnection *new)
if (priv->agent_secrets)
g_object_unref (priv->agent_secrets);
priv->agent_secrets = nm_simple_connection_new_clone (new ?: NM_CONNECTION(self));
priv->agent_secrets = nm_simple_connection_new_clone ( new
?: nm_settings_connection_get_connection (self));
/* Clear out non-system-owned secrets */
nm_connection_clear_secrets_with_flags (priv->agent_secrets,
@ -472,7 +501,7 @@ update_agent_secrets_cache (NMSettingsConnection *self, NMConnection *new)
}
static void
secrets_cleared_cb (NMSettingsConnection *self)
secrets_cleared_cb (NMConnection *connection, NMSettingsConnection *self)
{
NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self);
@ -533,7 +562,7 @@ _emit_updated (NMSettingsConnection *self, gboolean by_user)
}
static void
connection_changed_cb (NMSettingsConnection *self, gpointer unused)
connection_changed_cb (NMConnection *connection, NMSettingsConnection *self)
{
set_persist_mode (self, NM_SETTINGS_CONNECTION_PERSIST_MODE_UNSAVED);
_emit_updated (self, FALSE);
@ -636,7 +665,7 @@ nm_settings_connection_update (NMSettingsConnection *self,
if (persist_mode == NM_SETTINGS_CONNECTION_PERSIST_MODE_DISK) {
if (!klass->commit_changes (self,
new_connection ?: NM_CONNECTION (self),
new_connection ?: nm_settings_connection_get_connection (self),
commit_reason,
&reread_connection,
&logmsg_change,
@ -655,30 +684,30 @@ nm_settings_connection_update (NMSettingsConnection *self,
/* Disconnect the changed signal to ensure we don't set Unsaved when
* it's not required.
*/
g_signal_handlers_block_by_func (self, G_CALLBACK (connection_changed_cb), NULL);
g_signal_handlers_block_by_func (priv->connection, G_CALLBACK (connection_changed_cb), self);
/* Do nothing if there's nothing to update */
if ( replace_connection
&& !nm_connection_compare (NM_CONNECTION (self),
&& !nm_connection_compare (nm_settings_connection_get_connection (self),
replace_connection,
NM_SETTING_COMPARE_FLAG_EXACT)) {
gs_unref_object NMConnection *simple = NULL;
if (log_diff_name) {
nm_utils_log_connection_diff (replace_connection, NM_CONNECTION (self), LOGL_DEBUG, LOGD_CORE, log_diff_name, "++ ",
nm_utils_log_connection_diff (replace_connection, nm_settings_connection_get_connection (self), LOGL_DEBUG, LOGD_CORE, log_diff_name, "++ ",
nm_dbus_object_get_path (NM_DBUS_OBJECT (self)));
}
/* Make a copy of agent-owned secrets because they won't be present in
* the connection returned by plugins, as plugins return only what was
* reread from the file. */
simple = nm_simple_connection_new_clone (NM_CONNECTION (self));
simple = nm_simple_connection_new_clone (nm_settings_connection_get_connection (self));
nm_connection_clear_secrets_with_flags (simple,
secrets_filter_cb,
GUINT_TO_POINTER (NM_SETTING_SECRET_FLAG_AGENT_OWNED));
con_agent_secrets = nm_connection_to_dbus (simple, NM_CONNECTION_SERIALIZE_ONLY_SECRETS);
nm_connection_replace_settings_from_connection (NM_CONNECTION (self), replace_connection);
nm_connection_replace_settings_from_connection (nm_settings_connection_get_connection (self), replace_connection);
replaced = TRUE;
}
@ -701,12 +730,12 @@ nm_settings_connection_update (NMSettingsConnection *self,
dict = nm_connection_to_dbus (priv->agent_secrets, NM_CONNECTION_SERIALIZE_ONLY_SECRETS);
if (dict) {
(void) nm_connection_update_secrets (NM_CONNECTION (self), NULL, dict, NULL);
(void) nm_connection_update_secrets (nm_settings_connection_get_connection (self), NULL, dict, NULL);
g_variant_unref (dict);
}
}
if (con_agent_secrets)
(void) nm_connection_update_secrets (NM_CONNECTION (self), NULL, con_agent_secrets, NULL);
(void) nm_connection_update_secrets (nm_settings_connection_get_connection (self), NULL, con_agent_secrets, NULL);
}
nm_settings_connection_recheck_visibility (self);
@ -724,7 +753,7 @@ nm_settings_connection_update (NMSettingsConnection *self,
NM_SETTINGS_CONNECTION_PERSIST_MODE_VOLATILE_DETACHED))
nm_settings_connection_set_filename (self, NULL);
g_signal_handlers_unblock_by_func (self, G_CALLBACK (connection_changed_cb), NULL);
g_signal_handlers_unblock_by_func (priv->connection, G_CALLBACK (connection_changed_cb), self);
_emit_updated (self, TRUE);
@ -800,7 +829,7 @@ nm_settings_connection_delete (NMSettingsConnection *self,
set_visible (self, FALSE);
/* Tell agents to remove secrets for this connection */
for_agents = nm_simple_connection_new_clone (NM_CONNECTION (self));
for_agents = nm_simple_connection_new_clone (nm_settings_connection_get_connection (self));
nm_connection_clear_secrets (for_agents);
nm_agent_manager_delete_secrets (priv->agent_mgr,
nm_dbus_object_get_path (NM_DBUS_OBJECT (self)),
@ -920,7 +949,7 @@ get_cmp_flags (NMSettingsConnection *self, /* only needed for logging */
gboolean *agent_had_system,
ForEachSecretFlags *cmp_flags)
{
gboolean is_self = (((NMConnection *) self) == connection);
gboolean is_self = (nm_settings_connection_get_connection (self) == connection);
g_return_if_fail (secrets);
@ -1001,7 +1030,7 @@ nm_settings_connection_new_secrets (NMSettingsConnection *self,
return FALSE;
}
if (!nm_connection_update_secrets (NM_CONNECTION (self), setting_name, secrets, error))
if (!nm_connection_update_secrets (nm_settings_connection_get_connection (self), setting_name, secrets, error))
return FALSE;
update_system_secrets_cache (self);
@ -1073,7 +1102,7 @@ get_secrets_done_cb (NMAgentManager *manager,
goto out;
}
if (!nm_connection_get_setting_by_name (NM_CONNECTION (self), setting_name)) {
if (!nm_connection_get_setting_by_name (nm_settings_connection_get_connection (self), setting_name)) {
g_set_error (&local, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_SETTING_NOT_FOUND,
"Connection didn't have requested setting '%s'.",
setting_name);
@ -1083,7 +1112,7 @@ get_secrets_done_cb (NMAgentManager *manager,
get_cmp_flags (self,
call_id,
NM_CONNECTION (self),
nm_settings_connection_get_connection (self),
agent_dbus_owner,
agent_has_modify,
setting_name,
@ -1100,8 +1129,8 @@ get_secrets_done_cb (NMAgentManager *manager,
dict = nm_connection_to_dbus (priv->system_secrets, NM_CONNECTION_SERIALIZE_ONLY_SECRETS);
/* Update the connection with our existing secrets from backing storage */
nm_connection_clear_secrets (NM_CONNECTION (self));
if (!dict || nm_connection_update_secrets (NM_CONNECTION (self), setting_name, dict, &local)) {
nm_connection_clear_secrets (nm_settings_connection_get_connection (self));
if (!dict || nm_connection_update_secrets (nm_settings_connection_get_connection (self), setting_name, dict, &local)) {
GVariant *filtered_secrets;
/* Update the connection with the agent's secrets; by this point if any
@ -1109,8 +1138,8 @@ get_secrets_done_cb (NMAgentManager *manager,
* will have been authenticated, so those secrets can replace the existing
* system secrets.
*/
filtered_secrets = for_each_secret (NM_CONNECTION (self), secrets, TRUE, validate_secret_flags, &cmp_flags);
if (nm_connection_update_secrets (NM_CONNECTION (self), setting_name, filtered_secrets, &local)) {
filtered_secrets = for_each_secret (nm_settings_connection_get_connection (self), secrets, TRUE, validate_secret_flags, &cmp_flags);
if (nm_connection_update_secrets (nm_settings_connection_get_connection (self), setting_name, filtered_secrets, &local)) {
/* Now that all secrets are updated, copy and cache new secrets,
* then save them to backing storage.
*/
@ -1250,7 +1279,7 @@ nm_settings_connection_get_secrets (NMSettingsConnection *self,
g_return_val_if_fail (NM_IS_SETTINGS_CONNECTION (self), NULL);
g_return_val_if_fail ( !applied_connection
|| ( NM_IS_CONNECTION (applied_connection)
&& (((NMConnection *) self) != applied_connection)), NULL);
&& (nm_settings_connection_get_connection (self) != applied_connection)), NULL);
call_id = g_slice_new0 (NMSettingsConnectionCallId);
call_id->self = self;
@ -1264,7 +1293,7 @@ nm_settings_connection_get_secrets (NMSettingsConnection *self,
c_list_link_tail (&priv->call_ids_lst_head, &call_id->call_ids_lst);
/* Make sure the request actually requests something we can return */
if (!nm_connection_get_setting_by_name (NM_CONNECTION (self), setting_name)) {
if (!nm_connection_get_setting_by_name (nm_settings_connection_get_connection (self), setting_name)) {
g_set_error (&local, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_SETTING_NOT_FOUND,
"Connection didn't have requested setting '%s'.",
setting_name);
@ -1295,7 +1324,7 @@ nm_settings_connection_get_secrets (NMSettingsConnection *self,
call_id_a = nm_agent_manager_get_secrets (priv->agent_mgr,
nm_dbus_object_get_path (NM_DBUS_OBJECT (self)),
NM_CONNECTION (self),
nm_settings_connection_get_connection (self),
subject,
existing_secrets,
setting_name,
@ -1465,7 +1494,7 @@ auth_start (NMSettingsConnection *self,
nm_assert (G_IS_DBUS_METHOD_INVOCATION (invocation));
nm_assert (NM_IS_AUTH_SUBJECT (subject));
if (!nm_auth_is_subject_in_acl_set_error (NM_CONNECTION (self),
if (!nm_auth_is_subject_in_acl_set_error (nm_settings_connection_get_connection (self),
subject,
NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_PERMISSION_DENIED,
@ -1539,15 +1568,14 @@ get_settings_auth_cb (NMSettingsConnection *self,
if (error)
g_dbus_method_invocation_return_gerror (context, error);
else {
gs_unref_object NMConnection *dupl_con = NULL;
GVariant *settings;
NMConnection *dupl_con;
NMSettingConnection *s_con;
NMSettingWireless *s_wifi;
guint64 timestamp = 0;
char **bssids;
gs_free char **bssids = NULL;
dupl_con = nm_simple_connection_new_clone (NM_CONNECTION (self));
g_assert (dupl_con);
dupl_con = nm_simple_connection_new_clone (nm_settings_connection_get_connection (self));
/* Timestamp is not updated in connection's 'timestamp' property,
* because it would force updating the connection and in turn
@ -1557,8 +1585,7 @@ get_settings_auth_cb (NMSettingsConnection *self,
*/
nm_settings_connection_get_timestamp (self, &timestamp);
if (timestamp) {
s_con = nm_connection_get_setting_connection (NM_CONNECTION (dupl_con));
g_assert (s_con);
s_con = nm_connection_get_setting_connection (dupl_con);
g_object_set (s_con, NM_SETTING_CONNECTION_TIMESTAMP, timestamp, NULL);
}
/* Seen BSSIDs are not updated in 802-11-wireless 'seen-bssids' property
@ -1566,20 +1593,17 @@ get_settings_auth_cb (NMSettingsConnection *self,
* return settings too.
*/
bssids = nm_settings_connection_get_seen_bssids (self);
s_wifi = nm_connection_get_setting_wireless (NM_CONNECTION (dupl_con));
s_wifi = nm_connection_get_setting_wireless (dupl_con);
if (bssids && bssids[0] && s_wifi)
g_object_set (s_wifi, NM_SETTING_WIRELESS_SEEN_BSSIDS, bssids, NULL);
g_free (bssids);
/* Secrets should *never* be returned by the GetSettings method, they
* get returned by the GetSecrets method which can be better
* protected against leakage of secrets to unprivileged callers.
*/
settings = nm_connection_to_dbus (NM_CONNECTION (dupl_con), NM_CONNECTION_SERIALIZE_NO_SECRETS);
g_assert (settings);
settings = nm_connection_to_dbus (dupl_con, NM_CONNECTION_SERIALIZE_NO_SECRETS);
g_dbus_method_invocation_return_value (context,
g_variant_new ("(@a{sa{sv}})", settings));
g_object_unref (dupl_con);
}
}
@ -1734,7 +1758,7 @@ update_auth_cb (NMSettingsConnection *self,
gs_unref_hashtable GHashTable *diff = NULL;
gboolean same;
same = nm_connection_diff (NM_CONNECTION (self), info->new_settings,
same = nm_connection_diff (nm_settings_connection_get_connection (self), info->new_settings,
NM_SETTING_COMPARE_FLAG_EXACT |
NM_SETTING_COMPARE_FLAG_DIFF_RESULT_NO_DEFAULT,
&diff);
@ -1745,7 +1769,7 @@ update_auth_cb (NMSettingsConnection *self,
commit_reason = NM_SETTINGS_CONNECTION_COMMIT_REASON_USER_ACTION;
if ( info->new_settings
&& !nm_streq0 (nm_connection_get_id (NM_CONNECTION (self)),
&& !nm_streq0 (nm_connection_get_id (nm_settings_connection_get_connection (self)),
nm_connection_get_id (info->new_settings)))
commit_reason |= NM_SETTINGS_CONNECTION_COMMIT_REASON_ID_CHANGED;
@ -1791,7 +1815,7 @@ update_auth_cb (NMSettingsConnection *self,
* as agent-owned secrets are the only ones we send back be saved.
* Only send secrets to agents of the same UID that called update too.
*/
for_agent = nm_simple_connection_new_clone (NM_CONNECTION (self));
for_agent = nm_simple_connection_new_clone (nm_settings_connection_get_connection (self));
nm_connection_clear_secrets_with_flags (for_agent,
secrets_filter_cb,
GUINT_TO_POINTER (NM_SETTING_SECRET_FLAG_AGENT_OWNED));
@ -1811,11 +1835,9 @@ get_update_modify_permission (NMConnection *old, NMConnection *new)
guint32 orig_num = 0, new_num = 0;
s_con = nm_connection_get_setting_connection (old);
g_assert (s_con);
orig_num = nm_setting_connection_get_num_permissions (s_con);
s_con = nm_connection_get_setting_connection (new);
g_assert (s_con);
new_num = nm_setting_connection_get_num_permissions (s_con);
/* If the caller is the only user in either connection's permissions, then
@ -1848,7 +1870,7 @@ settings_connection_update (NMSettingsConnection *self,
* the problem (ex a system settings plugin that can't write connections out)
* instead of over D-Bus.
*/
if (!check_writable (NM_CONNECTION (self), &error))
if (!check_writable (nm_settings_connection_get_connection (self), &error))
goto error;
/* Check if the settings are valid first */
@ -1879,7 +1901,7 @@ settings_connection_update (NMSettingsConnection *self,
* that's sending the update request. You can't make a connection
* invisible to yourself.
*/
if (!nm_auth_is_subject_in_acl_set_error (tmp ?: NM_CONNECTION(self),
if (!nm_auth_is_subject_in_acl_set_error (tmp ?: nm_settings_connection_get_connection (self),
subject,
NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_PERMISSION_DENIED,
@ -1894,8 +1916,8 @@ settings_connection_update (NMSettingsConnection *self,
info->flags = flags;
info->new_settings = tmp;
permission = get_update_modify_permission (NM_CONNECTION (self),
tmp ?: NM_CONNECTION(self));
permission = get_update_modify_permission (nm_settings_connection_get_connection (self),
tmp ?: nm_settings_connection_get_connection (self));
auth_start (self, context, subject, permission, update_auth_cb, info);
return;
@ -2066,8 +2088,7 @@ get_modify_permission_basic (NMSettingsConnection *self)
* we use the 'modify.own' permission instead of 'modify.system'. If the
* request affects more than just the caller, require 'modify.system'.
*/
s_con = nm_connection_get_setting_connection (NM_CONNECTION (self));
nm_assert (s_con);
s_con = nm_connection_get_setting_connection (nm_settings_connection_get_connection (self));
if (nm_setting_connection_get_num_permissions (s_con) == 1)
return NM_AUTH_PERMISSION_SETTINGS_MODIFY_OWN;
@ -2087,7 +2108,7 @@ impl_settings_connection_delete (NMDBusObject *obj,
gs_unref_object NMAuthSubject *subject = NULL;
GError *error = NULL;
if (!check_writable (NM_CONNECTION (self), &error))
if (!check_writable (nm_settings_connection_get_connection (self), &error))
goto err;
subject = _new_auth_subject (invocation, &error);
@ -2122,7 +2143,7 @@ dbus_get_agent_secrets_cb (NMSettingsConnection *self,
* secrets from backing storage and those returned from the agent
* by the time we get here.
*/
dict = nm_connection_to_dbus (NM_CONNECTION (self), NM_CONNECTION_SERIALIZE_ONLY_SECRETS);
dict = nm_connection_to_dbus (nm_settings_connection_get_connection (self), NM_CONNECTION_SERIALIZE_ONLY_SECRETS);
if (!dict)
dict = g_variant_new_array (G_VARIANT_TYPE ("{sa{sv}}"), NULL, 0);
g_dbus_method_invocation_return_value (context, g_variant_new ("(@a{sa{sv}})", dict));
@ -2204,7 +2225,7 @@ dbus_clear_secrets_auth_cb (NMSettingsConnection *self,
}
/* Clear secrets in connection and caches */
nm_connection_clear_secrets (NM_CONNECTION (self));
nm_connection_clear_secrets (nm_settings_connection_get_connection (self));
if (priv->system_secrets)
nm_connection_clear_secrets (priv->system_secrets);
if (priv->agent_secrets)
@ -2213,7 +2234,7 @@ dbus_clear_secrets_auth_cb (NMSettingsConnection *self,
/* Tell agents to remove secrets for this connection */
nm_agent_manager_delete_secrets (priv->agent_mgr,
nm_dbus_object_get_path (NM_DBUS_OBJECT (self)),
NM_CONNECTION (self));
nm_settings_connection_get_connection (self));
nm_settings_connection_update (self,
NULL,
@ -2388,15 +2409,8 @@ _cmp_timestamp (NMSettingsConnection *a, NMSettingsConnection *b)
static int
_cmp_last_resort (NMSettingsConnection *a, NMSettingsConnection *b)
{
int c;
nm_assert (NM_IS_SETTINGS_CONNECTION (a));
nm_assert (NM_IS_SETTINGS_CONNECTION (b));
c = g_strcmp0 (nm_connection_get_uuid (NM_CONNECTION (a)),
nm_connection_get_uuid (NM_CONNECTION (b)));
if (c)
return c;
NM_CMP_DIRECT_STRCMP0 (nm_settings_connection_get_uuid (a),
nm_settings_connection_get_uuid (b));
/* hm, same UUID. Use their pointer value to give them a stable
* order. */
@ -2411,19 +2425,11 @@ _cmp_last_resort (NMSettingsConnection *a, NMSettingsConnection *b)
int
nm_settings_connection_cmp_timestamp (NMSettingsConnection *a, NMSettingsConnection *b)
{
int c;
NM_CMP_SELF (a, b);
if (a == b)
return 0;
if (!a)
return 1;
if (!b)
return -1;
if ((c = _cmp_timestamp (a, b)))
return c;
if ((c = nm_utils_cmp_connection_by_autoconnect_priority (NM_CONNECTION (a), NM_CONNECTION (b))))
return c;
NM_CMP_RETURN (_cmp_timestamp (a, b));
NM_CMP_RETURN (nm_utils_cmp_connection_by_autoconnect_priority (nm_settings_connection_get_connection (a),
nm_settings_connection_get_connection (b)));
return _cmp_last_resort (a, b);
}
@ -2437,14 +2443,11 @@ nm_settings_connection_cmp_timestamp_p_with_data (gconstpointer pa, gconstpointe
int
nm_settings_connection_cmp_autoconnect_priority (NMSettingsConnection *a, NMSettingsConnection *b)
{
int c;
if (a == b)
return 0;
if ((c = nm_utils_cmp_connection_by_autoconnect_priority (NM_CONNECTION (a), NM_CONNECTION (b))))
return c;
if ((c = _cmp_timestamp (a, b)))
return c;
NM_CMP_RETURN (nm_utils_cmp_connection_by_autoconnect_priority (nm_settings_connection_get_connection (a),
nm_settings_connection_get_connection (b)));
NM_CMP_RETURN (_cmp_timestamp (a, b));
return _cmp_last_resort (a, b);
}
@ -2727,7 +2730,7 @@ nm_settings_connection_read_and_fill_seen_bssids (NMSettingsConnection *self)
* seen-bssids list from the deprecated seen-bssids property of the
* wifi setting.
*/
s_wifi = nm_connection_get_setting_wireless (NM_CONNECTION (self));
s_wifi = nm_connection_get_setting_wireless (nm_settings_connection_get_connection (self));
if (s_wifi) {
len = nm_setting_wireless_get_num_seen_bssids (s_wifi);
for (i = 0; i < len; i++) {
@ -2747,7 +2750,7 @@ _autoconnect_retries_initial (NMSettingsConnection *self)
NMSettingConnection *s_con;
int retries = -1;
s_con = nm_connection_get_setting_connection ((NMConnection *) self);
s_con = nm_connection_get_setting_connection (nm_settings_connection_get_connection (self));
if (s_con)
retries = nm_setting_connection_get_autoconnect_retries (s_con);
@ -2959,13 +2962,19 @@ nm_settings_connection_get_filename (NMSettingsConnection *self)
const char *
nm_settings_connection_get_id (NMSettingsConnection *self)
{
return nm_connection_get_id (NM_CONNECTION (self));
return nm_connection_get_id (nm_settings_connection_get_connection (self));
}
const char *
nm_settings_connection_get_uuid (NMSettingsConnection *self)
{
return nm_connection_get_uuid (NM_CONNECTION (self));
return nm_connection_get_uuid (nm_settings_connection_get_connection (self));
}
const char *
nm_settings_connection_get_connection_type (NMSettingsConnection *self)
{
return nm_connection_get_connection_type (nm_settings_connection_get_connection (self));
}
/*****************************************************************************/
@ -2995,8 +3004,10 @@ nm_settings_connection_init (NMSettingsConnection *self)
priv->autoconnect_retries = AUTOCONNECT_RETRIES_UNSET;
g_signal_connect (self, NM_CONNECTION_SECRETS_CLEARED, G_CALLBACK (secrets_cleared_cb), NULL);
g_signal_connect (self, NM_CONNECTION_CHANGED, G_CALLBACK (connection_changed_cb), NULL);
priv->connection = nm_simple_connection_new ();
g_signal_connect (priv->connection, NM_CONNECTION_SECRETS_CLEARED, G_CALLBACK (secrets_cleared_cb), self);
g_signal_connect (priv->connection, NM_CONNECTION_CHANGED, G_CALLBACK (connection_changed_cb), self);
}
static void
@ -3027,26 +3038,32 @@ dispose (GObject *object)
_get_secrets_cancel (self, call_id, TRUE);
}
/* Disconnect handlers.
* connection_changed_cb() has to be disconnected *before* nm_connection_clear_secrets(),
* because nm_connection_clear_secrets() emits NM_CONNECTION_CHANGED signal.
*/
g_signal_handlers_disconnect_by_func (self, G_CALLBACK (secrets_cleared_cb), NULL);
g_signal_handlers_disconnect_by_func (self, G_CALLBACK (connection_changed_cb), NULL);
set_visible (self, FALSE);
if (priv->connection) {
/* Disconnect handlers.
* connection_changed_cb() has to be disconnected *before* nm_connection_clear_secrets(),
* because nm_connection_clear_secrets() emits NM_CONNECTION_CHANGED signal.
*/
g_signal_handlers_disconnect_by_func (priv->connection, G_CALLBACK (secrets_cleared_cb), self);
g_signal_handlers_disconnect_by_func (priv->connection, G_CALLBACK (connection_changed_cb), self);
/* FIXME(copy-on-write-connection): avoid modifying NMConnection instances and share them via copy-on-write. */
nm_connection_clear_secrets (priv->connection);
}
nm_connection_clear_secrets (NM_CONNECTION (self));
g_clear_object (&priv->system_secrets);
g_clear_object (&priv->agent_secrets);
g_clear_pointer (&priv->seen_bssids, g_hash_table_destroy);
set_visible (self, FALSE);
nm_clear_g_signal_handler (priv->session_monitor, &priv->session_changed_id);
g_clear_object (&priv->session_monitor);
g_clear_object (&priv->agent_mgr);
g_clear_object (&priv->connection);
g_clear_pointer (&priv->filename, g_free);
G_OBJECT_CLASS (nm_settings_connection_parent_class)->dispose (object);
@ -3264,9 +3281,3 @@ nm_settings_connection_class_init (NMSettingsConnectionClass *klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
}
static void
nm_settings_connection_connection_interface_init (NMConnectionInterface *iface)
{
}

View file

@ -139,6 +139,8 @@ struct _NMSettingsConnectionClass {
GType nm_settings_connection_get_type (void);
NMConnection *nm_settings_connection_get_connection (NMSettingsConnection *self);
guint64 nm_settings_connection_get_last_secret_agent_version_id (NMSettingsConnection *self);
gboolean nm_settings_connection_has_unmodified_applied_connection (NMSettingsConnection *self,
@ -268,7 +270,13 @@ void nm_settings_connection_set_filename (NMSettingsConnection *self,
const char *filename);
const char *nm_settings_connection_get_filename (NMSettingsConnection *self);
const char *nm_settings_connection_get_id (NMSettingsConnection *connection);
const char *nm_settings_connection_get_uuid (NMSettingsConnection *connection);
const char *nm_settings_connection_get_id (NMSettingsConnection *connection);
const char *nm_settings_connection_get_uuid (NMSettingsConnection *connection);
const char *nm_settings_connection_get_connection_type (NMSettingsConnection *connection);
/*****************************************************************************/
NMConnection **nm_settings_connections_array_to_connections (NMSettingsConnection *const*connections,
gssize n_connections);
#endif /* __NETWORKMANAGER_SETTINGS_CONNECTION_H__ */

View file

@ -214,9 +214,9 @@ connection_ready_changed (NMSettingsConnection *conn,
static void
plugin_connection_added (NMSettingsPlugin *config,
NMSettingsConnection *connection,
gpointer user_data)
NMSettings *self)
{
claim_connection (NM_SETTINGS (user_data), connection);
claim_connection (self, connection);
}
static void
@ -237,7 +237,7 @@ load_connections (NMSettings *self)
// priority plugin.
for (elt = plugin_connections; elt; elt = g_slist_next (elt))
claim_connection (self, NM_SETTINGS_CONNECTION (elt->data));
claim_connection (self, elt->data);
g_slist_free (plugin_connections);
@ -306,15 +306,15 @@ impl_settings_get_connection_by_uuid (NMDBusObject *obj,
GVariant *parameters)
{
NMSettings *self = NM_SETTINGS (obj);
NMSettingsConnection *connection = NULL;
NMSettingsConnection *sett_conn;
gs_unref_object NMAuthSubject *subject = NULL;
GError *error = NULL;
const char *uuid;
g_variant_get (parameters, "(&s)", &uuid);
connection = nm_settings_get_connection_by_uuid (self, uuid);
if (!connection) {
sett_conn = nm_settings_get_connection_by_uuid (self, uuid);
if (!sett_conn) {
error = g_error_new_literal (NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_INVALID_CONNECTION,
"No connection with the UUID was found.");
@ -329,7 +329,7 @@ impl_settings_get_connection_by_uuid (NMDBusObject *obj,
goto error;
}
if (!nm_auth_is_subject_in_acl_set_error (NM_CONNECTION (connection),
if (!nm_auth_is_subject_in_acl_set_error (nm_settings_connection_get_connection (sett_conn),
subject,
NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_PERMISSION_DENIED,
@ -338,7 +338,7 @@ impl_settings_get_connection_by_uuid (NMDBusObject *obj,
g_dbus_method_invocation_return_value (invocation,
g_variant_new ("(o)",
nm_dbus_object_get_path (NM_DBUS_OBJECT (connection))));
nm_dbus_object_get_path (NM_DBUS_OBJECT (sett_conn))));
return;
error:
@ -362,6 +362,7 @@ _clear_connections_cached_list (NMSettingsPrivate *priv)
0xdeaddead,
sizeof (NMSettingsConnection *) * (priv->connections_len + 1));
#endif
nm_clear_g_free (&priv->connections_cached_list);
}
@ -480,8 +481,8 @@ nm_settings_get_connection_by_path (NMSettings *self, const char *path)
priv = NM_SETTINGS_GET_PRIVATE (self);
connection = (NMSettingsConnection *) nm_dbus_manager_lookup_object (nm_dbus_object_get_manager (NM_DBUS_OBJECT (self)),
path);
connection = nm_dbus_manager_lookup_object (nm_dbus_object_get_manager (NM_DBUS_OBJECT (self)),
path);
if ( !connection
|| !NM_IS_SETTINGS_CONNECTION (connection))
return NULL;
@ -931,29 +932,33 @@ openconnect_migrate_hack (NMConnection *connection)
}
static void
claim_connection (NMSettings *self, NMSettingsConnection *connection)
claim_connection (NMSettings *self, NMSettingsConnection *sett_conn)
{
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
NMSettingsPrivate *priv;
GError *error = NULL;
const char *path;
NMSettingsConnection *existing;
g_return_if_fail (NM_IS_SETTINGS_CONNECTION (connection));
g_return_if_fail (!nm_dbus_object_is_exported (NM_DBUS_OBJECT (connection)));
g_return_if_fail (NM_IS_SETTINGS (self));
g_return_if_fail (NM_IS_SETTINGS_CONNECTION (sett_conn));
g_return_if_fail (!nm_dbus_object_is_exported (NM_DBUS_OBJECT (sett_conn)));
priv = NM_SETTINGS_GET_PRIVATE (self);
/* prevent duplicates */
if (!c_list_is_empty (&connection->_connections_lst)) {
nm_assert (c_list_contains (&priv->connections_lst_head, &connection->_connections_lst));
if (!c_list_is_empty (&sett_conn->_connections_lst)) {
nm_assert (c_list_contains (&priv->connections_lst_head, &sett_conn->_connections_lst));
return;
}
if (!nm_connection_normalize (NM_CONNECTION (connection), NULL, NULL, &error)) {
/* FIXME(copy-on-write-connection): avoid modifying NMConnection instances and share them via copy-on-write. */
if (!nm_connection_normalize (nm_settings_connection_get_connection (sett_conn), NULL, NULL, &error)) {
_LOGW ("plugin provided invalid connection: %s", error->message);
g_error_free (error);
return;
}
existing = nm_settings_get_connection_by_uuid (self, nm_settings_connection_get_uuid (connection));
existing = nm_settings_get_connection_by_uuid (self, nm_settings_connection_get_uuid (sett_conn));
if (existing) {
/* Cannot add duplicate connections per UUID. Just return without action and
* log a warning.
@ -966,51 +971,56 @@ claim_connection (NMSettings *self, NMSettingsConnection *connection)
* error out. That should not happen unless the admin misconfigured the system
* to create conflicting connections. */
_LOGW ("plugin provided duplicate connection with UUID %s",
nm_settings_connection_get_uuid (connection));
nm_settings_connection_get_uuid (sett_conn));
return;
}
/* Read timestamp from look-aside file and put it into the connection's data */
nm_settings_connection_read_and_fill_timestamp (connection);
nm_settings_connection_read_and_fill_timestamp (sett_conn);
/* Read seen-bssids from look-aside file and put it into the connection's data */
nm_settings_connection_read_and_fill_seen_bssids (connection);
nm_settings_connection_read_and_fill_seen_bssids (sett_conn);
/* Ensure its initial visibility is up-to-date */
nm_settings_connection_recheck_visibility (connection);
nm_settings_connection_recheck_visibility (sett_conn);
/* Evil openconnect migration hack */
openconnect_migrate_hack (NM_CONNECTION (connection));
/* FIXME(copy-on-write-connection): avoid modifying NMConnection instances and share them via copy-on-write. */
openconnect_migrate_hack (nm_settings_connection_get_connection (sett_conn));
/* This one unexports the connection, it needs to run late to give the active
* connection a chance to deal with its reference to this settings connection. */
g_signal_connect_after (connection, NM_SETTINGS_CONNECTION_REMOVED,
g_signal_connect_after (sett_conn, NM_SETTINGS_CONNECTION_REMOVED,
G_CALLBACK (connection_removed), self);
g_signal_connect (connection, NM_SETTINGS_CONNECTION_UPDATED_INTERNAL,
g_signal_connect (sett_conn, NM_SETTINGS_CONNECTION_UPDATED_INTERNAL,
G_CALLBACK (connection_updated), self);
g_signal_connect (connection, NM_SETTINGS_CONNECTION_FLAGS_CHANGED,
g_signal_connect (sett_conn, NM_SETTINGS_CONNECTION_FLAGS_CHANGED,
G_CALLBACK (connection_flags_changed),
self);
if (!priv->startup_complete) {
g_signal_connect (connection, "notify::" NM_SETTINGS_CONNECTION_READY,
g_signal_connect (sett_conn, "notify::" NM_SETTINGS_CONNECTION_READY,
G_CALLBACK (connection_ready_changed),
self);
}
_clear_connections_cached_list (priv);
g_object_ref (connection);
g_object_ref (sett_conn);
/* FIXME(shutdown): The NMSettings instance can't be disposed
* while there is any exported connection. Ideally we should
* unexport all connections on NMSettings' disposal, but for now
* leak @self on termination when there are connections alive. */
g_object_ref (self);
priv->connections_len++;
c_list_link_tail (&priv->connections_lst_head, &connection->_connections_lst);
c_list_link_tail (&priv->connections_lst_head, &sett_conn->_connections_lst);
path = nm_dbus_object_export (NM_DBUS_OBJECT (connection));
path = nm_dbus_object_export (NM_DBUS_OBJECT (sett_conn));
nm_utils_log_connection_diff (NM_CONNECTION (connection), NULL, LOGL_DEBUG, LOGD_CORE, "new connection", "++ ",
nm_utils_log_connection_diff (nm_settings_connection_get_connection (sett_conn),
NULL,
LOGL_DEBUG,
LOGD_CORE,
"new connection", "++ ",
path);
/* Only emit the individual connection-added signal after connections
@ -1021,13 +1031,13 @@ claim_connection (NMSettings *self, NMSettingsConnection *connection)
&interface_info_settings,
&signal_info_new_connection,
"(o)",
nm_dbus_object_get_path (NM_DBUS_OBJECT (connection)));
nm_dbus_object_get_path (NM_DBUS_OBJECT (sett_conn)));
g_signal_emit (self, signals[CONNECTION_ADDED], 0, connection);
g_signal_emit (self, signals[CONNECTION_ADDED], 0, sett_conn);
_notify (self, PROP_CONNECTIONS);
}
nm_settings_connection_added (connection);
nm_settings_connection_added (sett_conn);
}
static gboolean
@ -1079,7 +1089,7 @@ nm_settings_add_connection (NMSettings *self,
/* Make sure a connection with this UUID doesn't already exist */
c_list_for_each_entry (candidate, &priv->connections_lst_head, _connections_lst) {
if (nm_streq0 (uuid, nm_connection_get_uuid (NM_CONNECTION (candidate)))) {
if (nm_streq0 (uuid, nm_settings_connection_get_uuid (candidate))) {
g_set_error_literal (error,
NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_UUID_EXISTS,
@ -1113,8 +1123,13 @@ nm_settings_add_connection (NMSettings *self,
added = nm_settings_plugin_add_connection (plugin, connection, save_to_disk, &add_error);
if (added) {
if (secrets)
nm_connection_update_secrets (NM_CONNECTION (added), NULL, secrets, NULL);
if (secrets) {
/* FIXME(copy-on-write-connection): avoid modifying NMConnection instances and share them via copy-on-write. */
nm_connection_update_secrets (nm_settings_connection_get_connection (added),
NULL,
secrets,
NULL);
}
claim_connection (self, added);
return added;
}
@ -1132,7 +1147,7 @@ nm_settings_add_connection (NMSettings *self,
static void
send_agent_owned_secrets (NMSettings *self,
NMSettingsConnection *connection,
NMSettingsConnection *sett_conn,
NMAuthSubject *subject)
{
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
@ -1142,12 +1157,12 @@ send_agent_owned_secrets (NMSettings *self,
* as agent-owned secrets are the only ones we send back to be saved.
* Only send secrets to agents of the same UID that called update too.
*/
for_agent = nm_simple_connection_new_clone (NM_CONNECTION (connection));
for_agent = nm_simple_connection_new_clone (nm_settings_connection_get_connection (sett_conn));
nm_connection_clear_secrets_with_flags (for_agent,
secrets_filter_cb,
GUINT_TO_POINTER (NM_SETTING_SECRET_FLAG_AGENT_OWNED));
nm_agent_manager_save_secrets (priv->agent_mgr,
nm_dbus_object_get_path (NM_DBUS_OBJECT (connection)),
nm_dbus_object_get_path (NM_DBUS_OBJECT (sett_conn)),
for_agent,
subject);
}
@ -1190,7 +1205,8 @@ pk_add_cb (NMAuthChain *chain,
} else {
/* Authorized */
connection = nm_auth_chain_get_data (chain, "connection");
g_assert (connection);
nm_assert (connection);
save_to_disk = GPOINTER_TO_UINT (nm_auth_chain_get_data (chain, "save-to-disk"));
added = nm_settings_add_connection (self, connection, save_to_disk, &error);
}
@ -1612,20 +1628,21 @@ have_connection_for_device (NMSettings *self, NMDevice *device)
NMSettingWired *s_wired;
const char *setting_hwaddr;
const char *perm_hw_addr;
NMSettingsConnection *connection;
NMSettingsConnection *sett_conn;
g_return_val_if_fail (NM_IS_SETTINGS (self), FALSE);
perm_hw_addr = nm_device_get_permanent_hw_address (device);
/* Find a wired connection locked to the given MAC address, if any */
c_list_for_each_entry (connection, &priv->connections_lst_head, _connections_lst) {
c_list_for_each_entry (sett_conn, &priv->connections_lst_head, _connections_lst) {
NMConnection *connection = nm_settings_connection_get_connection (sett_conn);
const char *ctype, *iface;
if (!nm_device_check_connection_compatible (device, NM_CONNECTION (connection), NULL))
if (!nm_device_check_connection_compatible (device, connection, NULL))
continue;
s_con = nm_connection_get_setting_connection (NM_CONNECTION (connection));
s_con = nm_connection_get_setting_connection (connection);
iface = nm_setting_connection_get_interface_name (s_con);
if (iface && strcmp (iface, nm_device_get_iface (device)) != 0)
@ -1636,14 +1653,15 @@ have_connection_for_device (NMSettings *self, NMDevice *device)
&& strcmp (ctype, NM_SETTING_PPPOE_SETTING_NAME))
continue;
s_wired = nm_connection_get_setting_wired (NM_CONNECTION (connection));
s_wired = nm_connection_get_setting_wired (connection);
if (!s_wired && !strcmp (ctype, NM_SETTING_PPPOE_SETTING_NAME)) {
if ( !s_wired
&& nm_streq (ctype, NM_SETTING_PPPOE_SETTING_NAME)) {
/* No wired setting; therefore the PPPoE connection applies to any device */
return TRUE;
}
g_assert (s_wired != NULL);
nm_assert (s_wired);
setting_hwaddr = nm_setting_wired_get_mac_address (s_wired);
if (setting_hwaddr) {
@ -1687,11 +1705,11 @@ default_wired_clear_tag (NMSettings *self,
NMSettingsConnection *connection,
gboolean add_to_no_auto_default)
{
g_return_if_fail (NM_IS_SETTINGS (self));
g_return_if_fail (NM_IS_DEVICE (device));
g_return_if_fail (NM_IS_CONNECTION (connection));
g_return_if_fail (device == g_object_get_qdata (G_OBJECT (connection), _default_wired_device_quark ()));
g_return_if_fail (connection == g_object_get_qdata (G_OBJECT (device), _default_wired_connection_quark ()));
nm_assert (NM_IS_SETTINGS (self));
nm_assert (NM_IS_DEVICE (device));
nm_assert (NM_IS_SETTINGS_CONNECTION (connection));
nm_assert (device == g_object_get_qdata (G_OBJECT (connection), _default_wired_device_quark ()));
nm_assert (connection == g_object_get_qdata (G_OBJECT (device), _default_wired_connection_quark ()));
g_object_set_qdata (G_OBJECT (connection), _default_wired_device_quark (), NULL);
g_object_set_qdata (G_OBJECT (device), _default_wired_connection_quark (), NULL);

View file

@ -85,7 +85,7 @@ void nm_settings_add_connection_dbus (NMSettings *self,
NMSettingsAddCallback callback,
gpointer user_data);
NMSettingsConnection *const* nm_settings_get_connections (NMSettings *settings, guint *out_len);
NMSettingsConnection *const*nm_settings_get_connections (NMSettings *settings, guint *out_len);
NMSettingsConnection **nm_settings_get_connections_clone (NMSettings *self,
guint *out_len,

View file

@ -84,9 +84,9 @@ read_connections (NMSIbftPlugin *self)
connection = nms_ibft_connection_new (iter->data, &error);
if (connection) {
nm_log_info (LOGD_SETTINGS, "ibft: read connection '%s'",
nm_connection_get_id (NM_CONNECTION (connection)));
nm_settings_connection_get_id (NM_SETTINGS_CONNECTION (connection)));
g_hash_table_insert (priv->connections,
g_strdup (nm_connection_get_uuid (NM_CONNECTION (connection))),
g_strdup (nm_settings_connection_get_uuid (NM_SETTINGS_CONNECTION (connection))),
connection);
} else {
nm_log_warn (LOGD_SETTINGS, "ibft: failed to read iscsiadm record: %s", error->message);

View file

@ -143,7 +143,7 @@ devtimeout_expired (gpointer user_data)
NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (self);
nm_log_info (LOGD_SETTINGS, "Device for connection '%s' did not appear before timeout",
nm_connection_get_id (NM_CONNECTION (self)));
nm_settings_connection_get_id (NM_SETTINGS_CONNECTION (self)));
g_signal_handler_disconnect (NM_PLATFORM_GET, priv->devtimeout_link_changed_handler);
priv->devtimeout_link_changed_handler = 0;
@ -163,7 +163,7 @@ nm_ifcfg_connection_check_devtimeout (NMIfcfgConnection *self)
guint devtimeout;
const NMPlatformLink *pllink;
s_con = nm_connection_get_setting_connection (NM_CONNECTION (self));
s_con = nm_connection_get_setting_connection (nm_settings_connection_get_connection (NM_SETTINGS_CONNECTION (self)));
if (!nm_setting_connection_get_autoconnect (s_con))
return;
@ -186,7 +186,7 @@ nm_ifcfg_connection_check_devtimeout (NMIfcfgConnection *self)
nm_settings_connection_set_ready (NM_SETTINGS_CONNECTION (self), FALSE);
nm_log_info (LOGD_SETTINGS, "Waiting %u seconds for %s to appear for connection '%s'",
devtimeout, ifname, nm_connection_get_id (NM_CONNECTION (self)));
devtimeout, ifname, nm_settings_connection_get_id (NM_SETTINGS_CONNECTION (self)));
priv->devtimeout_link_changed_handler =
g_signal_connect (NM_PLATFORM_GET, NM_PLATFORM_SIGNAL_LINK_CHANGED,

View file

@ -139,7 +139,7 @@ static void
connection_removed_cb (NMSettingsConnection *obj, gpointer user_data)
{
g_hash_table_remove (SETTINGS_PLUGIN_IFCFG_GET_PRIVATE ((SettingsPluginIfcfg *) user_data)->connections,
nm_connection_get_uuid (NM_CONNECTION (obj)));
nm_settings_connection_get_uuid (NM_SETTINGS_CONNECTION (obj)));
}
static void
@ -157,7 +157,7 @@ remove_connection (SettingsPluginIfcfg *self, NMIfcfgConnection *connection)
unrecognized = !!nm_ifcfg_connection_get_unrecognized_spec (connection);
g_object_ref (connection);
g_hash_table_remove (priv->connections, nm_connection_get_uuid (NM_CONNECTION (connection)));
g_hash_table_remove (priv->connections, nm_settings_connection_get_uuid (NM_SETTINGS_CONNECTION (connection)));
if (!unmanaged && !unrecognized)
nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection));
g_object_unref (connection);
@ -228,7 +228,7 @@ update_connection (SettingsPluginIfcfg *self,
return NULL;
}
uuid = nm_connection_get_uuid (NM_CONNECTION (connection_new));
uuid = nm_settings_connection_get_uuid (NM_SETTINGS_CONNECTION (connection_new));
connection_by_uuid = g_hash_table_lookup (priv->connections, uuid);
if ( connection
@ -285,12 +285,16 @@ update_connection (SettingsPluginIfcfg *self,
if ( !unmanaged_changed
&& !unrecognized_changed
&& nm_connection_compare (NM_CONNECTION (connection_by_uuid),
NM_CONNECTION (connection_new),
&& nm_connection_compare (nm_settings_connection_get_connection (NM_SETTINGS_CONNECTION (connection_by_uuid)),
nm_settings_connection_get_connection (NM_SETTINGS_CONNECTION (connection_new)),
NM_SETTING_COMPARE_FLAG_IGNORE_AGENT_OWNED_SECRETS |
NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS)) {
if (old_path && g_strcmp0 (old_path, full_path) != 0)
_LOGI ("rename \"%s\" to "NM_IFCFG_CONNECTION_LOG_FMT" without other changes", nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection_by_uuid)), NM_IFCFG_CONNECTION_LOG_ARG (connection_new));
if ( old_path
&& !nm_streq0 (old_path, full_path)) {
_LOGI ("rename \"%s\" to "NM_IFCFG_CONNECTION_LOG_FMT" without other changes",
nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection_by_uuid)),
NM_IFCFG_CONNECTION_LOG_ARG (connection_new));
}
} else {
/*******************************************************
@ -299,7 +303,7 @@ update_connection (SettingsPluginIfcfg *self,
if (source)
_LOGI ("update "NM_IFCFG_CONNECTION_LOG_FMT" from %s", NM_IFCFG_CONNECTION_LOG_ARG (connection_new), NM_IFCFG_CONNECTION_LOG_PATH (old_path));
else if (!g_strcmp0 (old_path, nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection_new))))
else if (nm_streq0 (old_path, nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection_new))))
_LOGI ("update "NM_IFCFG_CONNECTION_LOG_FMT, NM_IFCFG_CONNECTION_LOG_ARG (connection_new));
else if (old_path)
_LOGI ("rename \"%s\" to "NM_IFCFG_CONNECTION_LOG_FMT, old_path, NM_IFCFG_CONNECTION_LOG_ARG (connection_new));
@ -312,7 +316,7 @@ update_connection (SettingsPluginIfcfg *self,
NULL);
if (!nm_settings_connection_update (NM_SETTINGS_CONNECTION (connection_by_uuid),
NM_CONNECTION (connection_new),
nm_settings_connection_get_connection (NM_SETTINGS_CONNECTION (connection_new)),
NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP_SAVED,
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
"ifcfg-update",
@ -338,7 +342,7 @@ update_connection (SettingsPluginIfcfg *self,
* so add it back now.
*/
g_hash_table_insert (priv->connections,
g_strdup (nm_connection_get_uuid (NM_CONNECTION (connection_by_uuid))),
g_strdup (nm_settings_connection_get_uuid (NM_SETTINGS_CONNECTION (connection_by_uuid))),
connection_by_uuid /* we took reference above and pass it on */);
}
} else {
@ -731,7 +735,7 @@ impl_ifcfgrh_get_ifcfg_details (SettingsPluginIfcfg *plugin,
return;
}
s_con = nm_connection_get_setting_connection (NM_CONNECTION (connection));
s_con = nm_connection_get_setting_connection (nm_settings_connection_get_connection (NM_SETTINGS_CONNECTION (connection)));
if (!s_con) {
g_dbus_method_invocation_return_error (context,
NM_SETTINGS_ERROR,

View file

@ -28,9 +28,9 @@
#define NM_IFCFG_CONNECTION_LOG_PATH(path) ((path) ?: "in-memory")
#define NM_IFCFG_CONNECTION_LOG_FMT "%s (%s,\"%s\")"
#define NM_IFCFG_CONNECTION_LOG_ARG(con) NM_IFCFG_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_connection_get_uuid ((NMConnection *) (con)), nm_connection_get_id ((NMConnection *) (con))
#define NM_IFCFG_CONNECTION_LOG_ARG(con) NM_IFCFG_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_settings_connection_get_uuid ((NMSettingsConnection *) (con)), nm_settings_connection_get_id ((NMSettingsConnection *) (con))
#define NM_IFCFG_CONNECTION_LOG_FMTD "%s (%s,\"%s\",%p)"
#define NM_IFCFG_CONNECTION_LOG_ARGD(con) NM_IFCFG_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_connection_get_uuid ((NMConnection *) (con)), nm_connection_get_id ((NMConnection *) (con)), (con)
#define NM_IFCFG_CONNECTION_LOG_ARGD(con) NM_IFCFG_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_settings_connection_get_uuid ((NMSettingsConnection *) (con)), nm_settings_connection_get_id ((NMSettingsConnection *) (con)), (con)
char *utils_cert_path (const char *parent, const char *suffix, const char *extension);

View file

@ -64,26 +64,29 @@ nm_ifupdown_connection_init (NMIfupdownConnection *connection)
{
}
NMIfupdownConnection*
NMIfupdownConnection *
nm_ifupdown_connection_new (if_block *block)
{
GObject *object;
NMIfupdownConnection *connection;
GError *error = NULL;
g_return_val_if_fail (block != NULL, NULL);
object = g_object_new (NM_TYPE_IFUPDOWN_CONNECTION, NULL);
connection = g_object_new (NM_TYPE_IFUPDOWN_CONNECTION, NULL);
if (!ifupdown_update_connection_from_if_block (NM_CONNECTION (object), block, &error)) {
/* FIXME(copy-on-write-connection): avoid modifying NMConnection instances and share them via copy-on-write. */
if (!ifupdown_update_connection_from_if_block (nm_settings_connection_get_connection (NM_SETTINGS_CONNECTION (connection)),
block,
&error)) {
nm_log_warn (LOGD_SETTINGS, "%s.%d - invalid connection read from /etc/network/interfaces: %s",
__FILE__,
__LINE__,
error->message);
g_object_unref (object);
g_object_unref (connection);
return NULL;
}
return (NMIfupdownConnection *) object;
return connection;
}
static void

View file

@ -126,8 +126,8 @@ bind_device_to_connection (SettingsPluginIfupdown *self,
return;
}
s_wired = nm_connection_get_setting_wired (NM_CONNECTION (exported));
s_wifi = nm_connection_get_setting_wireless (NM_CONNECTION (exported));
s_wired = nm_connection_get_setting_wired (nm_settings_connection_get_connection (NM_SETTINGS_CONNECTION (exported)));
s_wifi = nm_connection_get_setting_wireless (nm_settings_connection_get_connection (NM_SETTINGS_CONNECTION (exported)));
if (s_wired) {
nm_log_info (LOGD_SETTINGS, "locking wired connection setting");
g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, address, NULL);
@ -415,7 +415,8 @@ init (NMSettingsPlugin *config)
NMSettingConnection *setting;
if (g_hash_table_lookup (auto_ifaces, block_name)) {
setting = nm_connection_get_setting_connection (NM_CONNECTION (connection));
/* FIXME(copy-on-write-connection): avoid modifying NMConnection instances and share them via copy-on-write. */
setting = nm_connection_get_setting_connection (nm_settings_connection_get_connection (NM_SETTINGS_CONNECTION (connection)));
g_object_set (setting, NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NULL);
nm_log_info (LOGD_SETTINGS, "autoconnect");
}

View file

@ -142,7 +142,7 @@ nms_keyfile_connection_new (NMConnection *source,
if (!tmp)
return NULL;
uuid = nm_connection_get_uuid (NM_CONNECTION (tmp));
uuid = nm_connection_get_uuid (tmp);
if (!uuid) {
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
"Connection in file %s had no UUID", full_path);
@ -154,9 +154,9 @@ nms_keyfile_connection_new (NMConnection *source,
update_unsaved = FALSE;
}
object = (GObject *) g_object_new (NMS_TYPE_KEYFILE_CONNECTION,
NM_SETTINGS_CONNECTION_FILENAME, full_path,
NULL);
object = g_object_new (NMS_TYPE_KEYFILE_CONNECTION,
NM_SETTINGS_CONNECTION_FILENAME, full_path,
NULL);
/* Update our settings with what was read from the file */
if (!nm_settings_connection_update (NM_SETTINGS_CONNECTION (object),

View file

@ -85,10 +85,10 @@ G_DEFINE_TYPE_EXTENDED (NMSKeyfilePlugin, nms_keyfile_plugin, G_TYPE_OBJECT, 0,
/*****************************************************************************/
static void
connection_removed_cb (NMSettingsConnection *obj, gpointer user_data)
connection_removed_cb (NMSettingsConnection *sett_conn, NMSKeyfilePlugin *self)
{
g_hash_table_remove (NMS_KEYFILE_PLUGIN_GET_PRIVATE ((NMSKeyfilePlugin *) user_data)->connections,
nm_connection_get_uuid (NM_CONNECTION (obj)));
g_hash_table_remove (NMS_KEYFILE_PLUGIN_GET_PRIVATE (self)->connections,
nm_settings_connection_get_uuid (sett_conn));
}
/* Monitoring */
@ -106,7 +106,7 @@ remove_connection (NMSKeyfilePlugin *self, NMSKeyfileConnection *connection)
g_object_ref (connection);
g_signal_handlers_disconnect_by_func (connection, connection_removed_cb, self);
removed = g_hash_table_remove (NMS_KEYFILE_PLUGIN_GET_PRIVATE (self)->connections,
nm_connection_get_uuid (NM_CONNECTION (connection)));
nm_settings_connection_get_uuid (NM_SETTINGS_CONNECTION (connection)));
nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection));
g_object_unref (connection);
@ -197,7 +197,7 @@ update_connection (NMSKeyfilePlugin *self,
return NULL;
}
uuid = nm_connection_get_uuid (NM_CONNECTION (connection_new));
uuid = nm_settings_connection_get_uuid (NM_SETTINGS_CONNECTION (connection_new));
connection_by_uuid = g_hash_table_lookup (priv->connections, uuid);
if ( connection

View file

@ -25,9 +25,9 @@
#define NMS_KEYFILE_CONNECTION_LOG_PATH(path) ((path) ?: "in-memory")
#define NMS_KEYFILE_CONNECTION_LOG_FMT "%s (%s,\"%s\")"
#define NMS_KEYFILE_CONNECTION_LOG_ARG(con) NMS_KEYFILE_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_connection_get_uuid ((NMConnection *) (con)), nm_connection_get_id ((NMConnection *) (con))
#define NMS_KEYFILE_CONNECTION_LOG_ARG(con) NMS_KEYFILE_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_settings_connection_get_uuid ((NMSettingsConnection *) (con)), nm_settings_connection_get_id ((NMSettingsConnection *) (con))
#define NMS_KEYFILE_CONNECTION_LOG_FMTD "%s (%s,\"%s\",%p)"
#define NMS_KEYFILE_CONNECTION_LOG_ARGD(con) NMS_KEYFILE_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_connection_get_uuid ((NMConnection *) (con)), nm_connection_get_id ((NMConnection *) (con)), (con)
#define NMS_KEYFILE_CONNECTION_LOG_ARGD(con) NMS_KEYFILE_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_settings_connection_get_uuid ((NMSettingsConnection *) (con)), nm_settings_connection_get_id ((NMSettingsConnection *) (con)), (con)
gboolean nms_keyfile_utils_should_ignore_file (const char *filename);

View file

@ -44,15 +44,14 @@ _new_connection (const char *id)
static char *
_get_default_wired_name (GSList *list)
{
gs_free NMConnection **v = NULL;
guint l, i;
gs_unref_hashtable GHashTable *existing_ids = NULL;
l = g_slist_length (list);
v = g_new0 (NMConnection *, l + 1);
for (i = 0; list; list = list->next, i++)
v[i] = NM_CONNECTION (list->data);
g_assert (i == l);
return nm_device_ethernet_utils_get_default_wired_name (v);
if (list) {
existing_ids = g_hash_table_new (nm_str_hash, g_str_equal);
for (; list; list = list->next)
g_hash_table_add (existing_ids, (char *) nm_connection_get_id (list->data));
}
return nm_device_ethernet_utils_get_default_wired_name (existing_ids);
}
/*****************************************************************************/

View file

@ -193,7 +193,7 @@ static void _set_vpn_state (NMVpnConnection *self,
#define __NMLOG_prefix_buf_len 128
static const char *
__LOG_create_prefix (char *buf, NMVpnConnection *self, NMConnection *con)
__LOG_create_prefix (char *buf, NMVpnConnection *self, NMSettingsConnection *con)
{
NMVpnConnectionPrivate *priv;
const char *id;
@ -202,7 +202,7 @@ __LOG_create_prefix (char *buf, NMVpnConnection *self, NMConnection *con)
return _NMLOG_PREFIX_NAME;
priv = NM_VPN_CONNECTION_GET_PRIVATE (self);
id = con ? nm_connection_get_id (con) : NULL;
id = con ? nm_settings_connection_get_id (con) : NULL;
g_snprintf (buf, __NMLOG_prefix_buf_len,
"%s["
@ -214,7 +214,7 @@ __LOG_create_prefix (char *buf, NMVpnConnection *self, NMConnection *con)
"]",
_NMLOG_PREFIX_NAME,
self,
con ? "," : "--", con ? (nm_connection_get_uuid (con) ?: "??") : "",
con ? "," : "--", con ? (nm_settings_connection_get_uuid (con) ?: "??") : "",
con ? "," : "", NM_PRINT_FMT_QUOTED (id, "\"", id, "\"", con ? "??" : ""),
priv->ip_ifindex,
NM_PRINT_FMT_QUOTED (priv->ip_iface, ":(", priv->ip_iface, ")", "")
@ -225,17 +225,17 @@ __LOG_create_prefix (char *buf, NMVpnConnection *self, NMConnection *con)
#define _NMLOG(level, ...) \
G_STMT_START { \
const NMLogLevel __level = (level); \
NMConnection *__con = (self) ? (NMConnection *) _get_settings_connection (self, TRUE) : NULL; \
const NMLogLevel _level = (level); \
NMSettingsConnection *_con = (self) ? _get_settings_connection (self, TRUE) : NULL; \
\
if (nm_logging_enabled (__level, _NMLOG_DOMAIN)) { \
if (nm_logging_enabled (_level, _NMLOG_DOMAIN)) { \
char __prefix[__NMLOG_prefix_buf_len]; \
\
_nm_log (__level, _NMLOG_DOMAIN, 0, \
_nm_log (_level, _NMLOG_DOMAIN, 0, \
(self) ? NM_VPN_CONNECTION_GET_PRIVATE (self)->ip_iface : NULL, \
(__con) ? nm_connection_get_uuid (__con) : NULL, \
(_con) ? nm_settings_connection_get_uuid (_con) : NULL, \
"%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
__LOG_create_prefix (__prefix, (self), __con) \
__LOG_create_prefix (__prefix, (self), _con) \
_NM_UTILS_MACRO_REST (__VA_ARGS__)); \
} \
} G_STMT_END