device: block autoconnect of profile when deleting device

Currently, when we delete a device then autoconnect does not kick in
right away. But that is only, because we happen not to schedule a
"autoactivate" recheck.

What should be happen, is that rechecking whether to autoconnect is
always allowed, and that we have the necessary state to know that
autoconnect currently should not work.

Instead, block autoconnect of the involved profile. That makes sense,
because clearly we don't want to autoconnect right again after `nmcli
device delete $iface`.

(cherry picked from commit 14d429dd17)
(cherry picked from commit 53a3368bd600746c30798fb95113a8ccc5d48de3)
This commit is contained in:
Thomas Haller 2023-04-17 11:42:19 +02:00
parent d07827dfe1
commit f3a68c88a4
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -13414,7 +13414,8 @@ delete_cb(NMDevice *self,
GError *error,
gpointer user_data)
{
GError *local = NULL;
NMSettingsConnection *sett_conn;
GError *local = NULL;
if (error) {
g_dbus_method_invocation_return_gerror(context, error);
@ -13430,6 +13431,19 @@ delete_cb(NMDevice *self,
/* Authorized */
nm_audit_log_device_op(NM_AUDIT_OP_DEVICE_DELETE, self, TRUE, NULL, subject, NULL);
sett_conn = nm_device_get_settings_connection(self);
if (sett_conn) {
/* Block profile from autoconnecting. We block the profile, which may
* be ugly/wrong with multi-connect profiles. However, it's not
* obviously wrong, because profiles for software devices tend not to
* work with multi-connect anyway, because they describe a (unique)
* interface by name. */
nm_settings_connection_autoconnect_blocked_reason_set(
sett_conn,
NM_SETTINGS_AUTO_CONNECT_BLOCKED_REASON_USER_REQUEST,
TRUE);
}
if (!nm_device_unrealize(self, TRUE, &local)) {
g_dbus_method_invocation_take_error(context, local);
return;