Commit 06da3532 authored by Lubomir Rintel's avatar Lubomir Rintel 🥕 Committed by Thomas Haller

core: separate active and applied connection

Clone the connection upon activation. This makes it safe for the user
to modify the original connection while it is activated.

This involves several changes:

- NMActiveConnection gets @settings_connection and @applied_connection.
  To support add-and-activate, we constructing a NMActiveConnection with
  no connection set. Previously, we would set the "connection" field to
  a temporary NMConnection. Now NMManager piggybacks this temporary
  connection as object-data (TAG_ACTIVE_CONNETION_ADD_AND_ACTIVATE).

- get rid of the functions nm_active_connection_get_connection_type()
  and nm_active_connection_get_connection_uuid(). From their names
  it is unclear whether this returns the settings or applied connection.
  The (few) callers should figure that out themselves.

- rename nm_active_connection_get_id() to
  nm_active_connection_get_settings_connection_id(). This function
  is only used internally for logging.

- dispatcher calls now get two connections as well. The
  applied-connection is used for the connection data, while
  the settings-connection is used for the connection path.

- needs special handling for properties that apply immediately
  when changed (nm_device_reapply_settings_immediately()).
Co-Authored-By: Thomas Haller's avatarThomas Haller <thaller@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=724041
parent c9b3617c
......@@ -321,7 +321,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_reason)
g_assert (out_reason);
s_adsl = nm_connection_get_setting_adsl (nm_device_get_connection (device));
s_adsl = nm_connection_get_setting_adsl (nm_device_get_applied_connection (device));
g_assert (s_adsl);
protocol = nm_setting_adsl_get_protocol (s_adsl);
......@@ -411,7 +411,7 @@ act_stage3_ip4_config_start (NMDevice *device,
req = nm_device_get_act_request (device);
g_assert (req);
connection = nm_act_request_get_connection (req);
connection = nm_act_request_get_applied_connection (req);
g_assert (req);
s_adsl = nm_connection_get_setting_adsl (connection);
......
......@@ -821,7 +821,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device);
NMConnection *connection;
connection = nm_device_get_connection (device);
connection = nm_device_get_applied_connection (device);
g_assert (connection);
priv->bt_type = get_connection_bt_type (connection);
if (priv->bt_type == NM_BT_CAPABILITY_NONE) {
......
......@@ -264,7 +264,7 @@ apply_bonding_config (NMDevice *device)
* arp_interval doesn't require miimon to be 0
*/
connection = nm_device_get_connection (device);
connection = nm_device_get_applied_connection (device);
g_assert (connection);
s_bond = nm_connection_get_setting_bond (connection);
g_assert (s_bond);
......@@ -377,7 +377,7 @@ ip4_config_pre_commit (NMDevice *self, NMIP4Config *config)
NMSettingWired *s_wired;
guint32 mtu;
connection = nm_device_get_connection (self);
connection = nm_device_get_applied_connection (self);
g_assert (connection);
s_wired = nm_connection_get_setting_wired (connection);
......
......@@ -317,7 +317,7 @@ static NMActStageReturn
act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
{
NMActStageReturn ret;
NMConnection *connection = nm_device_get_connection (device);
NMConnection *connection = nm_device_get_applied_connection (device);
g_assert (connection);
......
......@@ -271,7 +271,7 @@ clear_secrets_tries (NMDevice *device)
req = nm_device_get_act_request (device);
if (req) {
connection = nm_act_request_get_connection (req);
connection = nm_act_request_get_applied_connection (req);
/* Clear wired secrets tries on success, failure, or when deactivating */
g_object_set_data (G_OBJECT (connection), WIRED_SECRETS_TRIES, NULL);
}
......@@ -415,7 +415,7 @@ device_get_setting (NMDevice *device, GType setting_type)
if (req) {
NMConnection *connection;
connection = nm_act_request_get_connection (req);
connection = nm_act_request_get_applied_connection (req);
if (connection)
setting = nm_connection_get_setting (connection, setting_type);
}
......@@ -481,7 +481,7 @@ supplicant_interface_release (NMDeviceEthernet *self)
static void
wired_secrets_cb (NMActRequest *req,
NMActRequestGetSecretsCallId call_id,
NMConnection *connection,
NMSettingsConnection *connection,
GError *error,
gpointer user_data)
{
......@@ -492,7 +492,7 @@ wired_secrets_cb (NMActRequest *req,
return;
g_return_if_fail (nm_device_get_state (dev) == NM_DEVICE_STATE_NEED_AUTH);
g_return_if_fail (nm_act_request_get_connection (req) == connection);
g_return_if_fail (nm_act_request_get_settings_connection (req) == connection);
if (error) {
_LOGW (LOGD_ETHER, "%s", error->message);
......@@ -510,7 +510,7 @@ link_timeout_cb (gpointer user_data)
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
NMDevice *dev = NM_DEVICE (self);
NMActRequest *req;
NMConnection *connection;
NMConnection *applied_connection;
const char *setting_name;
priv->supplicant_timeout_id = 0;
......@@ -531,9 +531,10 @@ link_timeout_cb (gpointer user_data)
if (nm_device_get_state (dev) != NM_DEVICE_STATE_CONFIG)
goto time_out;
connection = nm_act_request_get_connection (req);
nm_connection_clear_secrets (connection);
setting_name = nm_connection_need_secrets (connection, NULL);
nm_active_connection_clear_secrets (NM_ACTIVE_CONNECTION (req));
applied_connection = nm_act_request_get_applied_connection (req);
setting_name = nm_connection_need_secrets (applied_connection, NULL);
if (!setting_name)
goto time_out;
......@@ -566,7 +567,7 @@ build_supplicant_config (NMDeviceEthernet *self)
NMSetting8021x *security;
NMConnection *connection;
connection = nm_device_get_connection (NM_DEVICE (self));
connection = nm_device_get_applied_connection (NM_DEVICE (self));
g_assert (connection);
con_uuid = nm_connection_get_uuid (connection);
......@@ -703,19 +704,19 @@ handle_auth_or_fail (NMDeviceEthernet *self,
{
const char *setting_name;
guint32 tries;
NMConnection *connection;
NMConnection *applied_connection;
connection = nm_act_request_get_connection (req);
g_assert (connection);
applied_connection = nm_act_request_get_applied_connection (req);
tries = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), WIRED_SECRETS_TRIES));
tries = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (applied_connection), WIRED_SECRETS_TRIES));
if (tries > 3)
return NM_ACT_STAGE_RETURN_FAILURE;
nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_NONE);
nm_connection_clear_secrets (connection);
setting_name = nm_connection_need_secrets (connection, NULL);
nm_active_connection_clear_secrets (NM_ACTIVE_CONNECTION (req));
setting_name = nm_connection_need_secrets (applied_connection, NULL);
if (setting_name) {
NMSecretAgentGetSecretsFlags flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION;
......@@ -723,7 +724,7 @@ handle_auth_or_fail (NMDeviceEthernet *self,
flags |= NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW;
nm_act_request_get_secrets (req, setting_name, flags, NULL, wired_secrets_cb, self);
g_object_set_data (G_OBJECT (connection), WIRED_SECRETS_TRIES, GUINT_TO_POINTER (++tries));
g_object_set_data (G_OBJECT (applied_connection), WIRED_SECRETS_TRIES, GUINT_TO_POINTER (++tries));
} else
_LOGI (LOGD_DEVICE, "Cleared secrets, but setting didn't need any secrets.");
......@@ -753,7 +754,7 @@ supplicant_connection_timeout_cb (gpointer user_data)
req = nm_device_get_act_request (device);
g_assert (req);
connection = nm_act_request_get_connection (req);
connection = nm_act_request_get_applied_connection (req);
g_assert (connection);
/* Ask for new secrets only if we've never activated this connection
......@@ -875,7 +876,7 @@ nm_8021x_stage2_config (NMDeviceEthernet *self, NMDeviceStateReason *reason)
const char *setting_name;
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
connection = nm_device_get_connection (NM_DEVICE (self));
connection = nm_device_get_applied_connection (NM_DEVICE (self));
g_assert (connection);
security = nm_connection_get_setting_802_1x (connection);
if (!security) {
......@@ -961,7 +962,7 @@ pppoe_stage3_ip4_config_start (NMDeviceEthernet *self, NMDeviceStateReason *reas
req = nm_device_get_act_request (NM_DEVICE (self));
g_assert (req);
connection = nm_act_request_get_connection (req);
connection = nm_act_request_get_applied_connection (req);
g_assert (req);
s_pppoe = nm_connection_get_setting_pppoe (connection);
......@@ -1275,7 +1276,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
}
/* PPPoE setup */
if (nm_connection_is_type (nm_device_get_connection (device),
if (nm_connection_is_type (nm_device_get_applied_connection (device),
NM_SETTING_PPPOE_SETTING_NAME)) {
NMSettingPpp *s_ppp;
......@@ -1330,7 +1331,7 @@ ip4_config_pre_commit (NMDevice *device, NMIP4Config *config)
if (NM_DEVICE_ETHERNET_GET_PRIVATE (device)->ppp_manager)
return;
connection = nm_device_get_connection (device);
connection = nm_device_get_applied_connection (device);
g_assert (connection);
s_wired = nm_connection_get_setting_wired (connection);
g_assert (s_wired);
......
......@@ -85,7 +85,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
req = nm_device_get_act_request (dev);
g_return_val_if_fail (req != NULL, NM_ACT_STAGE_RETURN_FAILURE);
connection = nm_act_request_get_connection (req);
connection = nm_act_request_get_applied_connection (req);
g_assert (connection);
s_infiniband = nm_connection_get_setting_infiniband (connection);
g_assert (s_infiniband);
......@@ -123,7 +123,7 @@ ip4_config_pre_commit (NMDevice *self, NMIP4Config *config)
NMSettingInfiniband *s_infiniband;
guint32 mtu;
connection = nm_device_get_connection (self);
connection = nm_device_get_applied_connection (self);
g_assert (connection);
s_infiniband = nm_connection_get_setting_infiniband (connection);
g_assert (s_infiniband);
......
......@@ -310,7 +310,7 @@ match_parent (NMDeviceVlan *self, const char *parent)
if (!parent_req)
return FALSE;
parent_connection = nm_active_connection_get_connection (NM_ACTIVE_CONNECTION (parent_req));
parent_connection = nm_active_connection_get_applied_connection (NM_ACTIVE_CONNECTION (parent_req));
if (!parent_connection)
return FALSE;
......@@ -495,7 +495,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
req = nm_device_get_act_request (dev);
g_return_val_if_fail (req != NULL, NM_ACT_STAGE_RETURN_FAILURE);
connection = nm_act_request_get_connection (req);
connection = nm_act_request_get_applied_connection (req);
g_return_val_if_fail (connection != NULL, NM_ACT_STAGE_RETURN_FAILURE);
s_wired = nm_connection_get_setting_wired (connection);
......@@ -534,7 +534,7 @@ ip4_config_pre_commit (NMDevice *device, NMIP4Config *config)
NMSettingWired *s_wired;
guint32 mtu;
connection = nm_device_get_connection (device);
connection = nm_device_get_applied_connection (device);
g_assert (connection);
s_wired = nm_connection_get_setting_wired (connection);
......
This diff is collapsed.
......@@ -357,8 +357,11 @@ GSList * nm_device_master_get_slaves (NMDevice *dev);
/* Slave */
NMDevice * nm_device_get_master (NMDevice *dev);
NMActRequest * nm_device_get_act_request (NMDevice *dev);
NMConnection * nm_device_get_connection (NMDevice *dev);
NMActRequest * nm_device_get_act_request (NMDevice *dev);
NMSettingsConnection * nm_device_get_settings_connection (NMDevice *dev);
NMConnection * nm_device_get_applied_connection (NMDevice *dev);
gboolean nm_device_has_unmodified_applied_connection (NMDevice *self,
NMSettingCompareFlags compare_flags);
void nm_device_removed (NMDevice *dev);
......@@ -470,7 +473,7 @@ gboolean nm_device_get_nm_plugin_missing (NMDevice *self);
void nm_device_set_nm_plugin_missing (NMDevice *self,
gboolean missing);
void nm_device_steal_connection (NMDevice *device, NMConnection *connection);
void nm_device_steal_connection (NMDevice *device, NMSettingsConnection *connection);
void nm_device_queue_activation (NMDevice *device, NMActRequest *req);
......@@ -498,6 +501,10 @@ const NMPlatformIP4Route *nm_device_get_ip4_default_route (NMDevice *self, gbool
const NMPlatformIP6Route *nm_device_get_ip6_default_route (NMDevice *self, gboolean *out_is_assumed);
void nm_device_spawn_iface_helper (NMDevice *self);
void nm_device_reapply_settings_immediately (NMDevice *self);
void nm_device_update_firewall_zone (NMDevice *self);
void nm_device_update_metered (NMDevice *self);
G_END_DECLS
......
......@@ -383,7 +383,7 @@ teamd_dbus_vanished (GDBusConnection *dbus_connection,
/* Attempt to respawn teamd */
if (state >= NM_DEVICE_STATE_PREPARE && state <= NM_DEVICE_STATE_ACTIVATED) {
NMConnection *connection = nm_device_get_connection (device);
NMConnection *connection = nm_device_get_applied_connection (device);
g_assert (connection);
if (!teamd_start (device, nm_connection_get_setting_team (connection)))
......@@ -526,7 +526,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
return ret;
connection = nm_device_get_connection (device);
connection = nm_device_get_applied_connection (device);
g_assert (connection);
s_team = nm_connection_get_setting_team (connection);
g_assert (s_team);
......@@ -567,7 +567,7 @@ ip4_config_pre_commit (NMDevice *self, NMIP4Config *config)
NMSettingWired *s_wired;
guint32 mtu;
connection = nm_device_get_connection (self);
connection = nm_device_get_applied_connection (self);
g_assert (connection);
s_wired = nm_connection_get_setting_wired (connection);
......
......@@ -208,7 +208,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
GBytes *ssid;
const char *anycast_addr;
connection = nm_device_get_connection (device);
connection = nm_device_get_applied_connection (device);
g_assert (connection);
s_mesh = nm_connection_get_setting_olpc_mesh (connection);
......
This diff is collapsed.
......@@ -330,7 +330,7 @@ device_state_changed (NMDevice *device,
{
NMDeviceModem *self = NM_DEVICE_MODEM (device);
NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE (device);
NMConnection *connection = nm_device_get_connection (device);
NMConnection *connection = nm_device_get_applied_connection (device);
g_assert (priv->modem);
......
......@@ -30,6 +30,7 @@
#include "nm-device-private.h"
#include "nm-modem-enum-types.h"
#include "nm-route-manager.h"
#include "gsystem-local-alloc.h"
G_DEFINE_TYPE (NMModem, nm_modem, G_TYPE_OBJECT)
......@@ -490,7 +491,7 @@ ppp_stage3_ip_config_start (NMModem *self,
return NM_ACT_STAGE_RETURN_POSTPONE;
if (NM_MODEM_GET_CLASS (self)->get_user_pass) {
NMConnection *connection = nm_act_request_get_connection (req);
NMConnection *connection = nm_act_request_get_applied_connection (req);
g_assert (connection);
if (!NM_MODEM_GET_CLASS (self)->get_user_pass (self, connection, &ppp_name, NULL))
......@@ -560,7 +561,7 @@ nm_modem_stage3_ip4_config_start (NMModem *self,
req = nm_device_get_act_request (device);
g_assert (req);
connection = nm_act_request_get_connection (req);
connection = nm_act_request_get_applied_connection (req);
g_assert (connection);
method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP4_CONFIG);
......@@ -677,7 +678,7 @@ nm_modem_stage3_ip6_config_start (NMModem *self,
g_return_val_if_fail (NM_IS_ACT_REQUEST (req), NM_ACT_STAGE_RETURN_FAILURE);
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
connection = nm_act_request_get_connection (req);
connection = nm_act_request_get_applied_connection (req);
g_assert (connection);
method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP6_CONFIG);
......@@ -728,7 +729,7 @@ cancel_get_secrets (NMModem *self)
static void
modem_secrets_cb (NMActRequest *req,
NMActRequestGetSecretsCallId call_id,
NMConnection *connection,
NMSettingsConnection *connection,
GError *error,
gpointer user_data)
{
......@@ -797,7 +798,7 @@ nm_modem_act_stage1_prepare (NMModem *self,
g_object_unref (priv->act_request);
priv->act_request = g_object_ref (req);
connection = nm_act_request_get_connection (req);
connection = nm_act_request_get_applied_connection (req);
g_assert (connection);
setting_name = nm_connection_need_secrets (connection, &hints);
......
......@@ -65,25 +65,52 @@ enum {
/*******************************************************************/
NMSettingsConnection *
nm_act_request_get_settings_connection (NMActRequest *req)
{
g_return_val_if_fail (NM_IS_ACT_REQUEST (req), NULL);
return nm_active_connection_get_settings_connection (NM_ACTIVE_CONNECTION (req));
}
NMConnection *
nm_act_request_get_connection (NMActRequest *req)
nm_act_request_get_applied_connection (NMActRequest *req)
{
g_return_val_if_fail (NM_IS_ACT_REQUEST (req), NULL);
return nm_active_connection_get_connection (NM_ACTIVE_CONNECTION (req));
return nm_active_connection_get_applied_connection (NM_ACTIVE_CONNECTION (req));
}
/*******************************************************************/
struct _NMActRequestGetSecretsCallId {
NMActRequest *self;
NMSettingsConnectionCallId call_id_s;
NMActRequestSecretsFunc callback;
gpointer callback_data;
NMSettingsConnectionCallId call_id;
};
typedef struct _NMActRequestGetSecretsCallId GetSecretsInfo;
static GetSecretsInfo *
_get_secrets_info_new (NMActRequest *self, NMActRequestSecretsFunc callback, gpointer callback_data)
{
GetSecretsInfo *info;
info = g_slice_new0 (GetSecretsInfo);
info->self = self;
info->callback = callback;
info->callback_data = callback_data;
return info;
}
static void
_get_secrets_info_free (GetSecretsInfo *info)
{
g_slice_free (GetSecretsInfo, info);
}
static void
get_secrets_cb (NMSettingsConnection *connection,
NMSettingsConnectionCallId call_id_s,
......@@ -93,16 +120,24 @@ get_secrets_cb (NMSettingsConnection *connection,
gpointer user_data)
{
GetSecretsInfo *info = user_data;
NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (info->self);
NMActRequestPrivate *priv;
g_return_if_fail (info && info->call_id == call_id_s);
g_return_if_fail (NM_IS_ACT_REQUEST (info->self));
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
return;
priv = NM_ACT_REQUEST_GET_PRIVATE (info->self);
g_return_if_fail (info->call_id_s == call_id_s);
g_return_if_fail (g_slist_find (priv->secrets_calls, info));
priv->secrets_calls = g_slist_remove (priv->secrets_calls, info);
if (info->callback)
info->callback (info->self, info, NM_CONNECTION (connection), error, info->callback_data);
g_free (info);
info->callback (info->self, info, connection, error, info->callback_data);
_get_secrets_info_free (info);
}
/**
......@@ -135,57 +170,92 @@ nm_act_request_get_secrets (NMActRequest *self,
NMActRequestPrivate *priv;
GetSecretsInfo *info;
NMSettingsConnectionCallId call_id_s;
NMConnection *connection;
NMSettingsConnection *settings_connection;
NMConnection *applied_connection;
const char *hints[2] = { hint, NULL };
g_return_val_if_fail (self, 0);
g_return_val_if_fail (NM_IS_ACT_REQUEST (self), 0);
priv = NM_ACT_REQUEST_GET_PRIVATE (self);
info = g_malloc0 (sizeof (GetSecretsInfo));
info->self = self;
info->callback = callback;
info->callback_data = callback_data;
settings_connection = nm_act_request_get_settings_connection (self);
applied_connection = nm_act_request_get_applied_connection (self);
info = _get_secrets_info_new (self, callback, callback_data);
priv->secrets_calls = g_slist_append (priv->secrets_calls, info);
if (nm_active_connection_get_user_requested (NM_ACTIVE_CONNECTION (self)))
flags |= NM_SECRET_AGENT_GET_SECRETS_FLAG_USER_REQUESTED;
connection = nm_active_connection_get_connection (NM_ACTIVE_CONNECTION (self));
call_id_s = nm_settings_connection_get_secrets (NM_SETTINGS_CONNECTION (connection),
call_id_s = nm_settings_connection_get_secrets (settings_connection,
applied_connection,
nm_active_connection_get_subject (NM_ACTIVE_CONNECTION (self)),
setting_name,
flags,
hints,
get_secrets_cb,
info,
NULL);
if (call_id_s) {
info->call_id_s = call_id_s;
priv->secrets_calls = g_slist_append (priv->secrets_calls, info);
} else
g_free (info);
info);
info->call_id = call_id_s;
g_return_val_if_fail (call_id_s, NULL);
return info;
}
static void
_do_cancel_secrets (NMActRequest *self, GetSecretsInfo *info, gboolean is_disposing)
{
NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (self);
nm_assert (info && info->self == self);
nm_assert (g_slist_find (priv->secrets_calls, info));
priv->secrets_calls = g_slist_remove (priv->secrets_calls, info);
nm_settings_connection_cancel_secrets (nm_act_request_get_settings_connection (self), info->call_id);
if (info->callback) {
gs_free_error GError *error = NULL;
if (is_disposing) {
/* Use a different error code. G_IO_ERROR_CANCELLED is only used synchronously
* when the user calls nm_act_request_cancel_secrets(). Disposing the instance
* with pending requests also cancels the requests, but with a different error
* code. */
g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Disposing NMActRequest instance");
} else {
g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_CANCELLED,
"Request cancelled");
}
info->callback (self, info, NULL, error, info->callback_data);
}
_get_secrets_info_free (info);
}
void
nm_act_request_cancel_secrets (NMActRequest *self, NMActRequestGetSecretsCallId call_id)
{
NMActRequestPrivate *priv;
NMConnection *connection;
g_return_if_fail (self);
g_return_if_fail (NM_IS_ACT_REQUEST (self));
g_return_if_fail (call_id);
priv = NM_ACT_REQUEST_GET_PRIVATE (self);
if (g_slist_find (priv->secrets_calls, call_id))
if (!g_slist_find (priv->secrets_calls, call_id))
g_return_if_reached ();
connection = nm_active_connection_get_connection (NM_ACTIVE_CONNECTION (self));
nm_settings_connection_cancel_secrets (NM_SETTINGS_CONNECTION (connection), call_id->call_id_s);
_do_cancel_secrets (self, call_id, FALSE);
}
void
nm_act_request_clear_secrets (NMActRequest *self)
{
g_return_if_fail (NM_IS_ACT_REQUEST (self));
nm_active_connection_clear_secrets ((NMActiveConnection *) self);
}
/********************************************************************/
......@@ -405,7 +475,7 @@ master_failed (NMActiveConnection *self)
/**
* nm_act_request_new:
*
* @connection: the connection to activate @device with
* @settings_connection: (allow-none): the connection to activate @device with
* @specific_object: the object path of the specific object (ie, WiFi access point,
* etc) that will be used to activate @connection and @device
* @subject: the #NMAuthSubject representing the requestor of the activation
......@@ -418,17 +488,17 @@ master_failed (NMActiveConnection *self)
* Returns: the new activation request on success, %NULL on error.
*/
NMActRequest *
nm_act_request_new (NMConnection *connection,
nm_act_request_new (NMSettingsConnection *settings_connection,
const char *specific_object,
NMAuthSubject *subject,
NMDevice *device)
{
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
g_return_val_if_fail (!settings_connection || NM_IS_SETTINGS_CONNECTION (settings_connection), NULL);
g_return_val_if_fail (!device || NM_IS_DEVICE (device), NULL);
g_return_val_if_fail (NM_IS_AUTH_SUBJECT (subject), NULL);
return (NMActRequest *) g_object_new (NM_TYPE_ACT_REQUEST,
NM_ACTIVE_CONNECTION_INT_CONNECTION, connection,
NM_ACTIVE_CONNECTION_INT_SETTINGS_CONNECTION, settings_connection,
NM_ACTIVE_CONNECTION_INT_DEVICE, device,
NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT, specific_object,
NM_ACTIVE_CONNECTION_INT_SUBJECT, subject,
......@@ -443,8 +513,12 @@ nm_act_request_init (NMActRequest *req)
static void
dispose (GObject *object)
{
NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (object);
NMConnection *connection;
NMActRequest *self = NM_ACT_REQUEST (object);
NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (self);
/* Kill any in-progress secrets requests */
while (priv->secrets_calls)
_do_cancel_secrets (self, priv->secrets_calls->data, TRUE);
/* Clear any share rules */
if (priv->share_rules) {
......@@ -452,16 +526,6 @@ dispose (GObject *object)
clear_share_rules (NM_ACT_REQUEST (object));
}
/* Kill any in-progress secrets requests */
connection = nm_active_connection_get_connection (NM_ACTIVE_CONNECTION (object));
while (priv->secrets_calls) {
GetSecretsInfo *info = priv->secrets_calls->data;
nm_settings_connection_cancel_secrets (NM_SETTINGS_CONNECTION (connection), info->call_id_s);
g_return_if_fail (!priv->secrets_calls || info != priv->secrets_calls->data);
}
G_OBJECT_CLASS (nm_act_request_parent_class)->dispose (object);
}
......
......@@ -47,26 +47,28 @@ typedef struct {
GType nm_act_request_get_type (void);
NMActRequest *nm_act_request_new (NMConnection *connection,
NMActRequest *nm_act_request_new (NMSettingsConnection *settings_connection,
const char *specific_object,
NMAuthSubject *subject,
NMDevice *device);
NMConnection *nm_act_request_get_connection (NMActRequest *req);
NMSettingsConnection *nm_act_request_get_settings_connection (NMActRequest *req);
gboolean nm_act_request_get_shared (NMActRequest *req);
NMConnection *nm_act_request_get_applied_connection (NMActRequest *req);
void nm_act_request_set_shared (NMActRequest *req, gboolean shared);
gboolean nm_act_request_get_shared (NMActRequest *req);
void nm_act_request_add_share_rule (NMActRequest *req,
const char *table,
const char *rule);
void nm_act_request_set_shared (NMActRequest *req, gboolean shared);
void nm_act_request_add_share_rule (NMActRequest *req,
const char *table,
const char *rule);
/* Secrets handling */
typedef void (*NMActRequestSecretsFunc) (NMActRequest *req,
NMActRequestGetSecretsCallId call_id,
NMConnection *connection,
NMSettingsConnection *connection,
GError *error,
gpointer user_data);
......@@ -78,6 +80,7 @@ NMActRequestGetSecretsCallId nm_act_request_get_secrets (NMActRequest *req,
gpointer callback_data);
void nm_act_request_cancel_secrets (NMActRequest *req, NMActRequestGetSecretsCallId call_id);
void nm_act_request_clear_secrets (NMActRequest *self);
#endif /* __NETWORKMANAGER_ACTIVATION_REQUEST_H__ */
This diff is collapsed.
......@@ -49,7 +49,7 @@
#define NM_ACTIVE_CONNECTION_MASTER "master"
/* Internal non-exported properties */
#define NM_ACTIVE_CONNECTION_INT_CONNECTION "int-connection"
#define NM_ACTIVE_CONNECTION_INT_SETTINGS_CONNECTION "int-settings-connection"
#define NM_ACTIVE_CONNECTION_INT_DEVICE "int-device"
#define NM_ACTIVE_CONNECTION_INT_SUBJECT "int-subject"
#define NM_ACTIVE_CONNECTION_INT_MASTER "int-master"
......@@ -92,20 +92,23 @@ typedef void (*NMActiveConnectionAuthResultFunc) (NMActiveConnection *self,
gpointer user_data2);
void nm_active_connection_authorize (NMActiveConnection *self,
NMConnection *initial_connection,
NMActiveConnectionAuthResultFunc result_func,
gpointer user_data1,
gpointer user_data2);
NMConnection *nm_active_connection_get_connection (NMActiveConnection *self);
NMSettingsConnection *nm_active_connection_get_settings_connection (NMActiveConnection *self);
NMConnection *nm_active_connection_get_applied_connection (NMActiveConnection *self);
void nm_active_connection_set_connection (NMActiveConnection *self,
NMConnection *connection);
NMSettingsConnection *_nm_active_connection_get_settings_connection (NMActiveConnection *self);
const char * nm_active_connection_get_id (NMActiveConnection *self);
void nm_active_connection_set_settings_connection (NMActiveConnection *self,
NMSettingsConnection *connection);
const char * nm_active_connection_get_uuid (NMActiveConnection *self);
gboolean nm_active_connection_has_unmodified_applied_connection (NMActiveConnection *self,
NMSettingCompareFlags compare_flags);
const char * nm_active_connection_get_connection_type (NMActiveConnection *self);
const char * nm_active_connection_get_settings_connection_id (NMActiveConnection *self);
const char * nm_active_connection_get_specific_object (NMActiveConnection *self);
......@@ -147,4 +150,6 @@ void nm_active_connection_set_assumed (NMActiveConnection *self,