Visitar URL original
fix: authorize timedate setters via security-loader by fly602 · Pull Request #1300 · linuxdeepin/dde-daemon · GitHub
Skip to content

fix: authorize timedate setters via security-loader - #1300

Open
fly602 wants to merge 1 commit into
masterfrom
agent/agent/7cd29897cd31
Open

fly602 wants to merge 1 commit into
masterfrom
agent/agent/7cd29897cd31

Conversation

@fly602

@fly602 fly602 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

fix: authorize timedate setters via security-loader

  1. SetTime and SetNTP received the sender parameter but never used it, so any local user could change the system clock or toggle network time synchronization without authentication, bypassing the polkit check of systemd-timedated.
  2. Timedate1 now authorizes callers through the security-loader caller registry first (securityloader.TimedateScope) and falls back to Polkit only for unregistered callers, the same pattern airplane mode and the touchpad already use. The caller-supplied polkit.message detail is kept on the fallback path, so the authentication dialog still shows the translated message.
  3. New SetAllowCaller method, restricted by misc/conf/org.deepin.dde.Timedate1.conf to root and the deepin-daemon group. Timedate1 is also added to the handshake destination list of dde-session-daemon: the session module forwards SetDate/SetNTP to the system module, so that connection has to be registered as well, otherwise those two still prompt. 7 files, +75/-35. Reported as the timedate1 items of USRC CWE-306 and bughunter CWE-862.

Log: Changing the clock or the NTP switch from the control center no longer shows an authentication dialog; unregistered local callers are still denied.

Influence:

  1. Control center: toggle automatic time synchronization and change date/time, expect no authentication dialog and an applied change.
  2. Ordinary user calling SetTime with dbus-send: expect an authorization error and an unchanged timedatectl state.
  3. Ordinary user calling SetAllowCaller: expect AccessDenied from the D-Bus policy; the same call from a security-loader started control center succeeds.

fix: timedate 设置接口接入安全启动鉴权

  1. SetTime 与 SetNTP 接收了 sender 却从未使用,调用 systemd-timedated 前没有任何鉴权,任意本地用户可直接修改系统时间或开关网络对时,绕过 systemd-timedated 的 polkit 校验。
  2. Timedate1 现在先查 security-loader 调用者注册表(securityloader.TimedateScope),未注册的调用者才走 Polkit,与飞行模式、触摸板已有写法一致;Polkit 兜底路径保留调用方传入的 polkit.message,认证框仍显示已翻译的提示。
  3. 新增 SetAllowCaller 接口,misc/conf/org.deepin.dde.Timedate1.conf 限制只有 root 与 deepin-daemon 组可调用。同时把 Timedate1 加入 dde-session-daemon 的 handshake 目的列表:会话模块的 SetDate/SetNTP 由系统模块执行,不注册该连接这两个操作仍会弹认证框。7 个文件,+75/-35。对应报告 USRC CWE-306 与 bughunter CWE-862 中的 timedate1 项。

Log: 控制中心修改时间或切换网络对时不再弹出认证框;未注册的本地调用者仍被拒绝。

Influence:

  1. 控制中心切换自动同步时间、修改日期时间:不弹认证框且改动生效。
  2. 普通用户用 dbus-send 调用 SetTime:返回授权错误,timedatectl 状态不变。
  3. 普通用户调用 SetAllowCaller:D-Bus 策略返回 AccessDenied;由 security-loader 启动的控制中心调用成功。

Fixes: DDE-610
PMS: BUG-379743

Summary by Sourcery

Authorize timedate changes through security-loader with Polkit fallback for unregistered callers.

New Features:

  • Add timedate caller registration through security-loader and expose the SetAllowCaller D-Bus method.

Bug Fixes:

  • Authorize SetTime and SetNTP callers before allowing system clock changes or network time synchronization changes.
  • Preserve translated Polkit messages for callers that are not registered with security-loader.

Enhancements:

  • Register Timedate1 in the session daemon handshake so trusted session-module requests receive consistent authorization.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: fly602

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 Nov 11, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Data structures

Define the Timedate1 security-loader scope that the caller registry and authorization checks share.

  • securityloader/allowcaller.go L32

API

Expose SetAllowCaller on Timedate1 and include it in the exported method table so security-loader clients can register their unique name.

  • system/timedate1/exported_methods_auto.go L11-15
  • system/timedate1/manager_ifc.go L1, L12, L17-22

Uses of the API

Add Timedate1 to the session-daemon handshake destinations so the forwarded session-module calls can register as trusted callers.

  • bin/dde-session-daemon/main.go L181-185

Implementation

Route timedate setter authorization through the caller registry first and Polkit for unregistered callers, preserving the caller-provided Polkit message detail.

  • securityloader/polkit.go L22-27, L42-47 (+2 small edits)
  • system/timedate1/manager.go L304-318 (+5 small edits)
  • system/timedate1/manager_ifc.go L26-32, L95-99

Configuration

Permit SetAllowCaller only for root and the deepin-daemon group while denying it through the general interface policy.

  • misc/conf/org.deepin.dde.Timedate1.conf L11-20, L33-36

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 ✨

@fly602
fly602 force-pushed the agent/agent/7cd29897cd31 branch 2 times, most recently from c00fc15 to ba6b337 Compare November 11, 2026 08:09
@fly602 fly602 changed the title DDE-610: fix: add polkit authorization to timedate SetTime/SetNTP fix: add polkit authorization to timedate SetTime/SetNTP Nov 11, 2026
@fly602
fly602 force-pushed the agent/agent/7cd29897cd31 branch from ba6b337 to 9cc91ca Compare November 11, 2026 09:04
@fly602 fly602 changed the title fix: add polkit authorization to timedate SetTime/SetNTP fix: authorize timedate setters via security-loader Nov 11, 2026
1. Authorize Timedate1 setters through the security-loader caller registry
first and fall back to Polkit only for unregistered callers.
2. Expose SetAllowCaller, restrict it to root and the deepin-daemon group in
the D-Bus policy, and add Timedate1 to the session daemon handshake list.
3. Keep the caller-supplied polkit.message detail on the Polkit fallback path.
4. Expected: toggling auto time sync or changing the date/time from control
center shows no auth prompt; calling SetTime with dbus-send as an ordinary
user is still denied; calling SetAllowCaller as an ordinary user is denied by
the D-Bus policy.

fix: timedate 设置接口接入安全启动鉴权

1. Timedate1 设置类接口先查 security-loader 调用者注册表,未注册的调用者再走
Polkit 鉴权。
2. 新增 SetAllowCaller 接口,D-Bus 策略限制只有 root 和 deepin-daemon 组可调
用,并在会话守护进程 handshake 列表中加入 Timedate1。
3. Polkit 兜底路径保留调用方传入的 polkit.message 详情。

Log: 由 loader 启动的进程调用 timedate 设置接口不再弹出认证框;未注册的调用者仍需 Polkit 认证。
Influence: 控制中心切换自动同步时间、修改日期时间免认证;普通用户 dbus-send 调用 SetTime 仍被拒绝;普通用户调用 SetAllowCaller 被 D-Bus 策略拒绝。
PMS: BUG-379743
@fly602
fly602 force-pushed the agent/agent/7cd29897cd31 branch from 9cc91ca to 4fcb842 Compare November 11, 2026 09:41
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交通过 security-loader 基础设施为 timedate setter 方法(SetTime、SetNTP)添加了缺失的授权检查, 同时新增 SetAllowCaller 方法供安全加载器注册可信调用者以跳过 Polkit 认证。代码重构清晰,复用已有 securityloader 模块,移除了冗余的 doAuthorized 函数,改用 service.Conn() 替代每次新建 SystemBus 连接。DBus 策略配置正确限制 SetAllowCaller 仅 root 和 deepin-daemon 组可调用,默认策略拒绝访问。 四维度均无问题,无安全漏洞,OCR 审查亦未发现问题。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

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

建议: []


2. 代码质量 ✅

评价: 代码结构清晰,注释完整 ✅ 通过

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

建议: []


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

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

建议: []


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

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

建议: []


💡 改进建议代码示例

本次变更无需修复,代码已符合安全与质量标准。

本报告由 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