Skip to content

fix(wireless): drop default MAC binding on connect - #608

Open
caixr23 wants to merge 1 commit into
linuxdeepin:masterfrom
caixr23:master
Open

fix(wireless): drop default MAC binding on connect#608
caixr23 wants to merge 1 commit into
linuxdeepin:masterfrom
caixr23:master

Conversation

@caixr23

@caixr23 caixr23 commented Aug 26, 2026

Copy link
Copy Markdown
Contributor
  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

Summary by Sourcery

Allow wireless connections to use their configured MAC-binding choice instead of forcing a default device binding.

Bug Fixes:

  • Stop automatically binding wireless profiles to the device’s permanent hardware MAC so random-MAC connections can reconnect after reboot.

Enhancements:

  • Preserve MAC binding only when explicitly selected by the user in the wireless connection settings, while allowing unbound profiles to remain unbound.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: caixr23

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Removes automatic persistence of a wireless device’s permanent MAC address during connection creation and activation, preventing interference with randomized-MAC auto-reconnect while leaving explicit user-selected bindings under WirelessSection control.

Sequence diagram for wireless connection without default MAC binding

sequenceDiagram
    participant User
    participant WirelessDeviceManagerRealize
    participant NetWirelessConnect
    participant WirelessSection
    participant ConnectionProfile

    User->>WirelessDeviceManagerRealize: connectNetwork(accessPoint)
    WirelessDeviceManagerRealize->>ConnectionProfile: setSsid(ssid)
    WirelessDeviceManagerRealize->>ConnectionProfile: setInitialized(true)
    User->>NetWirelessConnect: activateConnection()
    NetWirelessConnect->>ConnectionProfile: setAutoconnect(false)
    User->>WirelessSection: Select NIC binding or Not Bind
    WirelessSection->>ConnectionProfile: setMacAddress(selectedMacOrEmpty)
    ConnectionProfile-->>User: Profile keeps explicit binding or cleared MAC
Loading

File-Level Changes

Change Details Files
Stop implicitly binding wireless profiles to the connected device’s permanent hardware MAC address.
  • Removed default MAC assignment during connection activation.
  • Removed permanent hardware MAC assignment when creating a connection from an access point.
  • Continued initializing the wireless setting without overriding its user-selected binding.
net-view/operation/private/netwirelessconnect.cpp
src/impl/networkmanager/devicemanagerrealize.cpp
Preserve explicit device-binding behavior managed by the control center.
  • Allow user-selected MAC bindings in WirelessSection to remain unchanged.
  • Allow the “Not Bind” choice to clear the profile MAC address instead of being replaced during connection.
net-view/operation/private/netwirelessconnect.cpp
src/impl/networkmanager/devicemanagerrealize.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 100 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 100 分,大于 70 分通过阈值。本次提交移除了无线连接时的默认 MAC 地址绑定逻辑,变更目的明确、实现简洁,未引入安全漏洞或其他质量问题。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 语法正确,逻辑清晰。两个文件的代码删除均不影响控制流完整性:1.netwirelessconnect.cpp 中 activateConnection() 移除的 MAC 绑定代码块为自包含逻辑,删除后从 findConnectionByUuid 到 setAutoconnect 的流程衔接正常;2.devicemanagerrealize.cpp 中 connectNetwork() 移除 MAC 设置行后,setSsid 和 setInitialized 调用仍保持正确顺序。


2. 代码质量 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 代码结构清晰,变更聚焦。本次 PR 仅移除了两处不必要的 MAC 地址绑定代码,变更范围明确。版权年份从 2022 更新为 2026 符合规范。无重复代码、无残留调试信息。


3. 代码性能 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 性能良好,资源使用合理。移除了 m_device->realHwAdr() 和 m_device->permanentHardwareAddress() 的调用以及 MAC 地址字符串处理操作,减少了不必要的设备查询和字符串操作。


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: 存在0个安全漏洞。本次变更移除了 MAC 地址绑定,反而有助于隐私保护,支持 MAC 随机化功能。无硬编码密钥、无注入风险、无敏感信息泄露。


💡 改进建议代码示例

// 本次变更无需修复代码示例
// 移除 MAC 绑定后的 activateConnection() 代码流程:
//   conn = findConnectionByUuid(m_connectionSettings->uuid());
//   // MAC 绑定代码已移除,直接进入后续逻辑
//   if (ConfigSetting::instance()->enableAccountNetwork())
//       m_connectionSettings->setAutoconnect(false);

// 移除 MAC 绑定后的 connectNetwork() 代码流程:
//   wirelessSetting->setSsid(accessPoint->ssid().toUtf8());
//   // MAC 绑定代码已移除,保留 setInitialized
//   wirelessSetting->setInitialized(true);

本报告由 AI 代码审查工具自动生成

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants