From 74f05e3264128773a46f98576c1f12a0b5cc1cb7 Mon Sep 17 00:00:00 2001 From: caixiangrong Date: Wed, 26 Aug 2026 14:34:43 +0800 Subject: [PATCH] fix(wireless): drop default MAC binding on connect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Remove code that wrote the device permanent/real hardware address into the Wireless setting when creating or activating a connection (WirelessDeviceManagerRealize::connectNetwork, NetWirelessConnect::activateConnection) 2. Keep user-selected device binding in WirelessSection 3. A pinned MAC defeats random-MAC mode and blocks auto-connect after reboot, leaving wifi disconnected Log: Wireless auto-reconnects after reboot with random MAC enabled Influence: 1. Connect to WiFi, reboot, verify it reconnects automatically 2. Bind a wireless connection to a specific NIC in control center, verify profile keeps that mac-address 3. Choose "Not Bind", verify mac-address cleared from profile fix(wireless): 默认不再将连接绑定到网卡MAC地址 1. 移除创建/激活连接时将设备永久/真实硬件地址写入无线配置的代码 (WirelessDeviceManagerRealize::connectNetwork、 NetWirelessConnect::activateConnection) 2. 保留控制中心 WirelessSection 中用户手动选择的网卡绑定 3. 固定 MAC 会破坏随机 MAC 功能,且导致重启后无线无法自动回连 Log: 开启随机 MAC 后,重启系统可自动重连无线网络 Influence: 1. 连接 WiFi 后重启系统,验证能自动重连 2. 控制中心绑定指定网卡后,验证配置保留该 mac-address 3. 选择"不绑定",验证配置中 mac-address 已清空 PMS: BUG-374945 --- net-view/operation/private/netwirelessconnect.cpp | 9 --------- src/impl/networkmanager/devicemanagerrealize.cpp | 3 --- 2 files changed, 12 deletions(-) diff --git a/net-view/operation/private/netwirelessconnect.cpp b/net-view/operation/private/netwirelessconnect.cpp index de9a903fa..bec72238b 100644 --- a/net-view/operation/private/netwirelessconnect.cpp +++ b/net-view/operation/private/netwirelessconnect.cpp @@ -400,15 +400,6 @@ void NetWirelessConnect::activateConnection() conn = findConnectionByUuid(m_connectionSettings->uuid()); } - // 默认设置Mac地址 - NetworkManager::WirelessSetting::Ptr wirelessSetting = m_connectionSettings->setting(NetworkManager::Setting::Wireless).dynamicCast(); - if (wirelessSetting) { - QString macAddress = m_device->realHwAdr(); - macAddress.remove(":"); - wirelessSetting->setMacAddress(QByteArray::fromHex(macAddress.toUtf8())); - wirelessSetting->setInitialized(true); - } - // 工银瑞信的项目默认关闭自动连接的功能 if (ConfigSetting::instance()->enableAccountNetwork()) m_connectionSettings->setAutoconnect(false); diff --git a/src/impl/networkmanager/devicemanagerrealize.cpp b/src/impl/networkmanager/devicemanagerrealize.cpp index 3ad7b6b3e..e8eca4712 100644 --- a/src/impl/networkmanager/devicemanagerrealize.cpp +++ b/src/impl/networkmanager/devicemanagerrealize.cpp @@ -818,9 +818,6 @@ void WirelessDeviceManagerRealize::connectNetwork(const AccessPoints *accessPoin NetworkManager::WirelessSetting::Ptr wirelessSetting = settings->setting(NetworkManager::Setting::Wireless).dynamicCast(); wirelessSetting->setSsid(accessPoint->ssid().toUtf8()); - QString macAddress = m_device->permanentHardwareAddress(); - macAddress.remove(":"); - wirelessSetting->setMacAddress(QByteArray::fromHex(macAddress.toUtf8())); wirelessSetting->setInitialized(true); QVariantMap options; options.insert("persist", "memory");