act-request: return empty properties when not activated

We start to track changes to the device's properties only after the
active connection gets activated. It's wrong to return properties
while we don't track their changes as this causes stale objects
references on D-Bus. Let's return DHCP and IP configurations from the
device only when the connection is activated.

(cherry picked from commit 4215c2640a)
This commit is contained in:
Beniamino Galvani 2017-01-19 09:56:15 +01:00 committed by Thomas Haller
parent b916d9dfe0
commit 99110ce529

View file

@ -495,31 +495,39 @@ static void
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
NMActiveConnection *active;
NMDevice *device;
char *name;
device = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (object));
if (!device) {
switch (prop_id) {
case PROP_IP4_CONFIG:
name = NM_DEVICE_IP4_CONFIG;
break;
case PROP_DHCP4_CONFIG:
name = NM_DEVICE_DHCP4_CONFIG;
break;
case PROP_IP6_CONFIG:
name = NM_DEVICE_IP6_CONFIG;
break;
case PROP_DHCP6_CONFIG:
name = NM_DEVICE_DHCP6_CONFIG;
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
return;
}
active = NM_ACTIVE_CONNECTION (object);
device = nm_active_connection_get_device (active);
if ( !device
|| !NM_IN_SET (nm_active_connection_get_state (active),
NM_ACTIVE_CONNECTION_STATE_ACTIVATED,
NM_ACTIVE_CONNECTION_STATE_DEACTIVATING)) {
g_value_set_string (value, "/");
return;
}
switch (prop_id) {
case PROP_IP4_CONFIG:
g_object_get_property (G_OBJECT (device), NM_DEVICE_IP4_CONFIG, value);
break;
case PROP_DHCP4_CONFIG:
g_object_get_property (G_OBJECT (device), NM_DEVICE_DHCP4_CONFIG, value);
break;
case PROP_IP6_CONFIG:
g_object_get_property (G_OBJECT (device), NM_DEVICE_IP6_CONFIG, value);
break;
case PROP_DHCP6_CONFIG:
g_object_get_property (G_OBJECT (device), NM_DEVICE_DHCP6_CONFIG, value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
g_object_get_property (G_OBJECT (device), name, value);
}
static void