diff --git a/libnm-util/nm-connection.c b/libnm-util/nm-connection.c index ab971c20ff..fec2950964 100644 --- a/libnm-util/nm-connection.c +++ b/libnm-util/nm-connection.c @@ -956,7 +956,8 @@ nm_connection_is_type (NMConnection *connection, const char *type) g_return_val_if_fail (type != NULL, FALSE); s_con = nm_connection_get_setting_connection (connection); - g_assert (s_con); + if (!s_con) + return FALSE; type2 = nm_setting_connection_get_connection_type (s_con); diff --git a/src/nm-manager.c b/src/nm-manager.c index 3a54bc4d29..9aa40e68a4 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -3299,15 +3299,16 @@ impl_manager_add_and_activate_connection (NMManager *self, NMDevice *device = NULL; gboolean vpn = FALSE; - if (!settings || !g_hash_table_size (settings)) { - error = g_error_new_literal (NM_MANAGER_ERROR, NM_MANAGER_ERROR_UNKNOWN_CONNECTION, - "Settings required to create a connection."); - goto error; - } - - /* Try to create a new connection with the given settings */ + /* Try to create a new connection with the given settings. + * We allow empty settings for AddAndActivateConnection(). In that case, + * the connection will be completed in nm_utils_complete_generic() or + * nm_device_complete_connection() below. Just make sure we don't expect + * specific data being in the connection till then (especially in + * validate_activation_request()). + */ connection = nm_connection_new (); - nm_connection_replace_settings (connection, settings, NULL); + if (settings && g_hash_table_size (settings)) + nm_connection_replace_settings (connection, settings, NULL); subject = validate_activation_request (self, context,