Skip to content

dbus: remove allow own for com.deepin.lastore.Smartmirror and org.deepin.dde.Lastore1.Smartmirror#289

Merged
zhaohuiw42 merged 1 commit into
linuxdeepin:masterfrom
zhaohuiw42:master
Jan 19, 2026
Merged

dbus: remove allow own for com.deepin.lastore.Smartmirror and org.deepin.dde.Lastore1.Smartmirror#289
zhaohuiw42 merged 1 commit into
linuxdeepin:masterfrom
zhaohuiw42:master

Conversation

@zhaohuiw42
Copy link
Copy Markdown
Contributor

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 19, 2026

CLA Assistant Lite bot:
提交邮箱中包含我们的合作伙伴,但您似乎并非合作伙伴的成员或对接人,请联系相关对接人将您添加至组织之中,或由其重新发起 Pull Request。
The commit email domain belongs to one of our partners, but it seems you are not yet a member of the current organization, please contact the contact person to add you to the organization or let them submit the Pull Request.

You can retrigger this bot by commenting recheck in this Pull Request

@deepin-ci-robot
Copy link
Copy Markdown

deepin pr auto review

这段代码 diff 是对两个 D-Bus 系统总线配置文件的修改,主要涉及权限控制策略。以下是对语法逻辑、代码质量、代码性能和代码安全的详细审查与改进意见:

1. 语法逻辑审查

  • 现状:语法是标准的 D-Bus XML 配置格式,修改后结构依然完整,没有 XML 语法错误。
  • 分析:代码移除了 <policy context="default"> 块中的 <allow own="..."/> 指令。
  • 逻辑含义<allow own="..."/> 用于允许特定的用户(如 root 或特定服务用户)在总线上注册(拥有)该服务名。将其从 default 策略中移除,意味着默认情况下(即未匹配到特定用户策略时),任何用户都禁止拥有(注册)这两个服务名
  • 结论:逻辑修改是清晰且有效的,目的是收紧默认权限。

2. 代码质量审查

  • 现状:配置文件结构清晰,注释(<!-- ... -->)准确地描述了意图:"Allow anyone to read information, but deny Changing System Actions"(允许任何人读取信息,但拒绝更改系统操作)。
  • 改进建议
    • 虽然注释提到了"deny Changing System Actions",但配置中依然保留了 <allow send_destination="..."/>。虽然这通常允许发送消息,但如果没有后续的 <deny> 规则针对具体的方法调用,且服务端本身没有做权限校验,这可能存在语义上的模糊。建议确认服务端是否对修改操作进行了严格的权限验证(如 Polkit 策略)。

3. 代码性能审查

  • 现状:D-Bus 守护进程在解析这些配置文件时,性能开销极小。移除一行规则对运行时性能几乎无影响。
  • 结论:无需性能优化。

4. 代码安全审查 —— 最重要部分

  • 改进效果正面
    • 防止服务劫持:在 default 策略中保留 <allow own="..."/> 是非常危险的。这意味着系统上的任何普通用户进程都可以尝试注册并抢占 com.deepin.lastore.Smartmirrororg.deepin.dde.Lastore1.Smartmirror 这两个系统级服务名称。
    • 移除该行后,只有在该配置文件的其他 <policy user="..."> 块中明确允许的特定用户(通常是 root 或系统服务账号)才能启动并注册该服务。这有效地防止了恶意软件冒充系统服务(Smartmirror 智能镜像服务),从而避免了中间人攻击或权限提升。
  • 潜在风险提示
    • 确保服务能启动:请务必确认在配置文件的其他位置(例如 <policy user="root"><policy at_console="true"> 等块中)存在针对运行该服务的特定用户的 <allow own="..."/> 规则。如果完全移除了所有 own 权限,该服务将无法在总线上注册名称,导致功能失效。
    • 发送权限:修改后的配置依然允许 default 用户向这两个服务发送消息(send_destination)。由于这些服务通常涉及系统更新或镜像管理,必须确保服务端代码本身对敏感方法(如修改镜像源、执行更新等)实施了严格的权限检查(如使用 Polkit)。仅靠 D-Bus 配置文件的 send_destination 无法区分"读取"和"修改"操作,除非配置了更细粒度的 send_membersend_interface 规则。

总结与建议

这是一个安全性增强的修改。

最终建议

  1. 确认配置完整性:检查配置文件中是否存在针对特定服务用户(如 lastoreroot)的 <allow own="..."/> 规则,确保服务能正常启动。

  2. 细化发送权限(可选但推荐)
    如果要严格实现注释中提到的"deny Changing System Actions",建议在 default 策略中不仅移除 own 权限,还应显式拒绝敏感方法的调用,或者只允许只读接口。
    例如:

    <policy context="default">
      <!-- 移除 own 权限 -->
      <!-- 允许发送消息,但仅限于特定只读接口 -->
      <allow send_destination="com.deepin.lastore.Smartmirror"
             send_interface="org.freedesktop.DBus.Introspectable"/>
      <allow send_destination="com.deepin.lastore.Smartmirror"
             send_interface="org.freedesktop.DBus.Properties"/>
      
      <!-- 显式拒绝修改操作的方法(假设有一个 Manager 接口) -->
      <deny send_destination="com.deepin.lastore.Smartmirror"
            send_interface="com.deepin.lastore.Smartmirror.Manager"
            send_member="UpdateMirror"/>
    </policy>

    (注:具体接口名需根据实际代码定义调整)

  3. 服务端校验:再次强调,D-Bus 策略只是第一道防线,核心的安全逻辑必须在服务端进程内部实现(例如验证调用者的 UID 或通过 Polkit 询问用户授权)。

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: electricface, zhaohuiw42

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

@zhaohuiw42 zhaohuiw42 merged commit 57e19f3 into linuxdeepin:master Jan 19, 2026
14 of 16 checks passed
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.

3 participants