devices: make sure the generated connections are normalized
Using these unormalized was wrong all along, but by chance didn't hit paths that needed normalized connections. This may change if we actually write in memory connections to /run with the keyfile plugin, because that one wants them normalized. This also saves some work, because normalization does boring things for us, such as adding default ipv4/ipv6/proxy settings everywhere.
This commit is contained in:
@@ -227,21 +227,12 @@ pan_connection_check_create (NMBluezDevice *self)
|
||||
NULL);
|
||||
nm_connection_add_setting (connection, setting);
|
||||
|
||||
/* Setting: IPv4 */
|
||||
setting = nm_setting_ip4_config_new ();
|
||||
g_object_set (G_OBJECT (setting),
|
||||
NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
|
||||
NM_SETTING_IP_CONFIG_MAY_FAIL, FALSE,
|
||||
NULL);
|
||||
nm_connection_add_setting (connection, setting);
|
||||
|
||||
/* Setting: IPv6 */
|
||||
setting = nm_setting_ip6_config_new ();
|
||||
g_object_set (G_OBJECT (setting),
|
||||
NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO,
|
||||
NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE,
|
||||
NULL);
|
||||
nm_connection_add_setting (connection, setting);
|
||||
if (!nm_connection_normalize (connection, NULL, NULL, &error)) {
|
||||
nm_log_err (LOGD_BT, "bluez[%s] couldn't generate a connection for NAP device: %s",
|
||||
priv->path, error->message);
|
||||
g_error_free (error);
|
||||
g_return_if_reached ();
|
||||
}
|
||||
|
||||
/* Adding a new connection raises a signal which eventually calls check_emit_usable (again)
|
||||
* which then already finds the suitable connection in priv->connections. This is confusing,
|
||||
|
@@ -4581,9 +4581,23 @@ nm_device_owns_iface (NMDevice *self, const char *iface)
|
||||
NMConnection *
|
||||
nm_device_new_default_connection (NMDevice *self)
|
||||
{
|
||||
if (NM_DEVICE_GET_CLASS (self)->new_default_connection)
|
||||
return NM_DEVICE_GET_CLASS (self)->new_default_connection (self);
|
||||
return NULL;
|
||||
NMConnection *connection;
|
||||
GError *error = NULL;
|
||||
|
||||
if (!NM_DEVICE_GET_CLASS (self)->new_default_connection)
|
||||
return NULL;
|
||||
|
||||
connection = NM_DEVICE_GET_CLASS (self)->new_default_connection (self);
|
||||
if (!connection)
|
||||
return NULL;
|
||||
|
||||
if (!nm_connection_normalize (connection, NULL, NULL, &error)) {
|
||||
_LOGD (LOGD_DEVICE, "device generated an invalid default connection: %s", error->message);
|
||||
g_error_free (error);
|
||||
g_return_val_if_reached (NULL);
|
||||
}
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -5454,7 +5468,7 @@ nm_device_generate_connection (NMDevice *self,
|
||||
|
||||
klass->update_connection (self, connection);
|
||||
|
||||
if (!nm_connection_verify (connection, &local)) {
|
||||
if (!nm_connection_normalize (connection, NULL, NULL, error)) {
|
||||
g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED,
|
||||
"generated connection does not verify: %s",
|
||||
local->message);
|
||||
|
Reference in New Issue
Block a user