Skip to content

feat: unify v20 and v25 DConfig support - #159

Draft
18202781743 wants to merge 7 commits into
linuxdeepin:masterfrom
18202781743:feat/v20-v25-unification
Draft

feat: unify v20 and v25 DConfig support#159
18202781743 wants to merge 7 commits into
linuxdeepin:masterfrom
18202781743:feat/v20-v25-unification

Conversation

@18202781743

@18202781743 18202781743 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • cherry-pick selected eagle Authorized, OEM, root-check, and Qt5 compatibility commits with original metadata
  • support C++17 builds with DTK5/Qt5 and DTK6/Qt6
  • select Qt5 or v25 runtime systemd, D-Bus activation/config, and policy resources by Qt major version
  • document the comparison, integration design, cache behavior, and validation results

Dependency

Validation

  • DTK5 Release full build against the staged dtkcore change: passed (-j6)
  • DTK6 Release full build against the staged dtkcore change: passed (-j6)
  • non-environment-dependent unit tests: 27/27 passed on both builds
  • install selection: Qt5 resources and policy verified; Qt6 v25 resources verified with no v20 policy

The five remaining removeUserData* tests require UID 1001-1004, which are absent in the current container. v20 runtime service and Debian package validation are intentionally out of scope.

Summary by Sourcery

Unify DConfig support across v20 and v25 by adding authorized access controls, Qt5/Qt6 runtime selection, and cross-version build compatibility.

New Features:

  • Add authorized read-only and read-write DConfig permissions with root and SID2 caller validation.
  • Support Qt5 and Qt6 builds with version-specific D-Bus, systemd, and PolicyKit resources.
  • Preserve OEM-exported JSON arrays and improve OEM dialog resizing and usability.

Bug Fixes:

  • Fix Qt5 compatibility for file timestamp handling and prevent unauthorized access to authorized configuration items.

Enhancements:

  • Adopt C++17 for the dconfig-center build and select canonical runtime resources according to the Qt major version.
  • Unify v20 and v25 integration while retaining compatible Qt5 runtime resources and existing Qt6 resources.

Deployment:

  • Install the appropriate Qt5 or Qt6 D-Bus activation, configuration, systemd, and PolicyKit resources based on the selected Qt version.

Documentation:

  • Document the v20/v25 integration approach, cache compatibility behavior, implementation decisions, and validation results.

Tests:

  • Validate DTK5 and DTK6 release builds, unit tests, cache and permission behavior, and version-specific installation contents.

wubw0508 and others added 7 commits September 2, 2026 16:39
…rite

添加管控类型

Log: 添加管控类型
Influence: 管控进程
Task: https://pms.uniontech.com/task-view-260335.html
Change-Id: I2b8725aecd36ca5e0dac0a80fa43b86796e26141
(cherry picked from commit 80b59ee4cb35ea083ec7f5158c0e31e30f4ff740)
(cherry picked from commit 7f00fdc3b408b89ff2993ac151c5c1bd6997d13a)
OEM对话框表头改为可调整大小,增加最小最大化按钮,结果改变窗口横向滚动条设为一直显示

Log: OEM对话框表头改为可调整大小,增加最小最大化按钮,结果改变窗口横向滚动条设为一直显示
Task: https://pms.uniontech.com/task-view-303031.html
Influence: dde-dconfig-editor的OEM对话框
Change-Id: I542861e38845f2ebc45ce175f011fb5a1946f577
(cherry picked from commit 721cb5a3aedc7ac57a13d79fe443ccd3afd420ef)
   导出数据做一步数组判断和转换

Log: oem导出的数组类型不对导致overrides失效
Influence: 导出配置
Change-Id: I101777e7e917acb44a358b3095ad11663f2c5e60
(cherry picked from commit a699f1c209b17369f0d492847850cd79f227bd81)
1. 修改 check_caller_sid2 函数,增加 uid 参数,并在函数入口处增加权限拦
截,仅允许 root 用户(uid为0)继续执行后续的安全上下文检查,非 root 用户
直接返回 EPERM 错误
2. 更新 checkDBusSender 函数中的 D-Bus 调用者信息获取逻辑,从仅获取 pid
改为同步获取调用者的 uid 和 pid
3. 增加 D-Bus 获取 uid 和 pid 返回值的有效性校验,防止因获取失败导致的潜
在异常或越权
4. 此改动修复了原先仅依赖进程 sid2 属性校验而忽略用户身份导致的权限控制
不严格问题,提升了 dconfig 守护进程的安全防护能力

Influence:
1. 测试非 root 用户通过 D-Bus 触发权限校验逻辑,验证是否被正确拦截并返回
权限错误
2. 测试 root 用户通过 D-Bus 调用相关接口,验证原有功能是否正常执行
3. 模拟 D-Bus 底层获取 uid 或 pid 失败的异常情况,验证接口是否安全降级返
回失败
4. 检查 dconfig-daemon 运行日志,确认非 root 用户调用时打印了预期的
uid != 0 告警信息
5. 验证普通应用正常的 dconfig 配置读取流程是否受到异常影响

Bug: https://pms.uniontech.com/bug-view-367861.html

Change-Id: I7d56594e1a255af87590697986af02f85962dc54
(cherry picked from commit 29198c6f15e6194842c737cdf3d41ec07a6be6ad)
1. 将所有 std::as_const 实例替换为 Qt 的 qAsConst 以提高与 Qt 容器的兼
容性
2. 通过移除 QTimeZone::UTC 参数将文件元数据时间戳处理从 UTC 改为本地时间
3. 在头文件中添加缺失的 QDateTime 包含以支持时间戳操作
4. 在实现文件中添加 DConfigFile 包含以确保功能完整性

这些更改提高了与 Qt 容器的兼容性,简化了时间戳处理,同时确保包含了所有必
需的头文件。qAsConst 更适合 Qt 容器,而本地时间戳足以满足文件变更检测的
需求。

Change-Id: I8d503fdc06876a9eb891eaa7384e6f0827968ac0
(cherry picked from commit e809ff37a2ec1b924905a722fa09e2ffe9d84cb1)
1. Bump C++ standard from C++14 to C++17 to resolve std::optional
compilation failures
2. Replace qAsConst with std::as_const to eliminate Qt6 deprecation
warnings
3. Add Qt5-specific systemd service, D-Bus config/activation, and
PolicyKit policy files
4. Update CMake installation logic to select runtime resources based
on QT_VERSION_MAJOR
5. Rename installed resource files to canonical names for consistent
packaging regardless of Qt version
6. Use timezone-agnostic QFileInfo::metadataChangeTime() for Qt5/Qt6
compatibility
7. Include documentation for v20/v25 code integration strategy

Log: Added Qt5-compatible runtime resources and unified build
configuration for dual Qt version support

Influence:
1. Verify Qt5 build compiles successfully without warnings
2. Verify Qt6 build compiles successfully without regressions
3. Verify Qt5 installation places service/config/policy files in correct
destinations
4. Verify Qt6 installation places service/config files in correct
destinations without PolicyKit policy
5. Verify installed D-Bus service activation and config allow correct
daemon access
6. Verify installed systemd service file has proper sandboxing options
and starts daemon successfully
7. Run unit tests on both Qt5 and Qt6 builds to confirm all pass

feat: 支持 Qt5/Qt6 双版本构建并分离运行时资源

1. 将 C++ 标准从 C++14 提升至 C++17,解决 std::optional 编译失败问题
2. 用 std::as_const 替换 qAsConst,消除 Qt6 弃用警告
3. 新增 Qt5 专用的 systemd 服务、D-Bus 配置/激活和 PolicyKit 策略文件
4. 更新 CMake 安装逻辑,根据 QT_VERSION_MAJOR 选择运行时资源
5. 将安装的资源文件重命名为规范名称,使不同 Qt 版本的打包保持一致
6. 使用不带时区参数的 QFileInfo::metadataChangeTime(),兼容 Qt5/Qt6
7. 添加 v20/v25 代码整合策略的文档说明

Log: 新增 Qt5 兼容运行时资源并统一双 Qt 版本构建配置

Influence:
1. 验证 Qt5 构建无警告地编译通过
2. 验证 Qt6 构建无回归地编译通过
3. 验证 Qt5 安装时将服务/配置/策略文件放在正确目录
4. 验证 Qt6 安装时将服务/配置文件放在正确目录且不安装 PolicyKit 策略
5. 验证安装后的 D-Bus 服务激活和配置允许守护进程被正确访问
6. 验证安装后的 systemd 服务文件具有正确的沙箱选项并能成功启动守护进程
7. 在 Qt5 和 Qt6 构建上运行单元测试,确认全部通过
1. Update the v2.0-v2.5 integration plan document
2. Change the 'no push/no PR' rule to push to personal GitHub fork and
create PRs upstream
3. Add request for code review by BLumia and mhduiy

Influence:
1. Verify the README/documentation accurately reflects the new
contribution workflow
2. Confirm the updated instructions are clear for developers reading
the plan

docs: 更新 v2.5 集成计划中的 PR 工作流

1. 更新 v2.0-v2.5 集成计划文档
2. 将"默认不推送、不创建 PR"的规则改为推送到个人 GitHub fork,并向上游创
建 PR
3. 新增请求 BLumia 和 mhduiy 进行代码审查的说明

Influence:
1. 验证文档准确反映了新的贡献工作流
2. 确认开发者在阅读计划时能清楚理解更新后的操作指引
@18202781743
18202781743 requested review from BLumia and mhduiy September 4, 2026 02:24
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743

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

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
  • 检测到敏感词export变动
详情
    {
    "export": {
        "dconfig-center/dde-dconfig-editor/oemdialog.cpp": {
            "b": [
                "    m_exportView->header()->setSectionResizeMode(QHeaderView::Interactive);",
                "    m_exportView->header()->resizeSection(0, 250);"
            ]
        }
    }
}

@sourcery-ai

sourcery-ai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR integrates selected v20/eagle functionality into the mainline while preserving Qt6/v25 behavior: it adds authorized SID2-validated configuration access, builds under C++17 for both Qt generations, chooses matching runtime resources at install time, improves OEM JSON export/UI behavior, and documents the cache/integration design and validation.

Sequence diagram for authorized D-Bus configuration access

sequenceDiagram
    participant Caller
    participant DBus as D-Bus
    participant Conn as DSGConfigConn
    participant Proc as Linux procfs

    Caller->>DBus: setValue(key, value)
    D-Bus->>Conn: dispatch setValue(key, value)
    Conn->>Conn: checkValid(key)
    Conn->>Conn: getPermissions(key)
    alt authorizedreadonly or authorizedreadwrite
        Conn->>DBus: serviceUid(service)
        Conn->>DBus: servicePid(service)
        Conn->>Proc: read /proc/pid/attr/sid2
        Proc-->>Conn: SID2 security label
        alt valid root and deepin SID2 label
            Conn->>Conn: hasPermissionByUid(key)
            Conn-->>DBus: apply configuration change
        else unauthorized caller
            Conn-->>DBus: sendErrorReply(QDBusError::Failed, errorMsg)
        end
    else readonly or readwrite
        Conn->>Conn: hasPermissionByUid(key)
    end
Loading

Flow diagram for Qt-version runtime resource installation

flowchart TD
    A[Configure project] --> B{QT_VERSION_MAJOR}
    B -->|5| C[Select services/qt5 resources]
    C --> D[Install D-Bus config and activation]
    C --> E[Install systemd service]
    C --> F[Install PolicyKit policy]
    B -->|6| G[Select v25 resources]
    G --> H[Install D-Bus config and activation]
    G --> I[Install systemd service]
    G --> J[Skip v20 PolicyKit policy]
Loading

Flow diagram for compatible DConfig cache loading

flowchart LR
    A[DConfigCache::load] --> B{cachePathPrefix set?}
    B -->|No| C[Load default cache]
    B -->|Yes| D[Load old default cache]
    D --> E[Load new prefixed cache]
    E --> F[Merge contents]
    F --> G[New cache values overwrite same keys]
    G --> H[DConfigCache::save writes prefixed cache]
Loading

File-Level Changes

Change Details Files
Unify Qt5/DTK5 and Qt6/DTK6 builds and runtime resource installation.
  • Raise the project standard to C++17.
  • Select systemd, D-Bus activation/configuration, and PolicyKit files from QT_VERSION_MAJOR while installing canonical filenames.
  • Add Qt5-specific service, activation, and policy resources while retaining the Qt6/v25 resources for Qt6 builds.
  • Update timestamp API usage and includes for Qt5/Qt6 compatibility.
dconfig-center/CMakeLists.txt
dconfig-center/dde-dconfig-daemon/CMakeLists.txt
dconfig-center/dde-dconfig-daemon/services/qt5/dde-dconfig-daemon.service
dconfig-center/dde-dconfig-daemon/services/qt5/org.desktopspec.ConfigManager.conf
dconfig-center/dde-dconfig-daemon/services/qt5/org.desktopspec.ConfigManager.policy
dconfig-center/dde-dconfig-daemon/services/qt5/org.desktopspec.ConfigManager.service
dconfig-center/dde-dconfig-daemon/dconfigserver.cpp
dconfig-center/dde-dconfig-daemon/dconfigserver.h
Add authorized configuration permissions backed by D-Bus sender and SID2 validation.
  • Expose authorized-read-only and authorized-read-write permission names.
  • Route mutating operations through key validation before permission checks or reset.
  • Resolve the D-Bus sender UID/PID and require root plus an accepted Deepin SID2 label for authorized keys.
  • Return D-Bus errors when authorized callers fail validation.
dconfig-center/dde-dconfig-daemon/dconfig_global.h
dconfig-center/dde-dconfig-daemon/dconfigconn.cpp
dconfig-center/dde-dconfig-daemon/dconfigconn.h
Improve OEM editor behavior and JSON export compatibility.
  • Allow the OEM dialog to be resized and configure interactive table headers and horizontal scrolling.
  • Convert string-valued JSON arrays into actual JSON arrays during export.
dconfig-center/dde-dconfig-editor/mainwindow.cpp
dconfig-center/dde-dconfig-editor/oemdialog.cpp
Document the v20/v25 integration strategy, cache compatibility model, and validation scope.
  • Record cherry-picked commits and the Qt-major-version resource split.
  • Document dtkcore's old/new cache overlay and save behavior, including its accepted deletion limitation.
  • Capture DTK5/DTK6 build, test, and install verification results and explicitly excluded validation.
dconfig-center/docs/v20-v25-integration-plan.md

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 found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="dconfig-center/dde-dconfig-daemon/dconfigconn.cpp" line_range="135" />
<code_context>
 void DSGConfigConn::setValue(const QString &key, const QDBusVariant &value)
 {
-    if (!contains(key))
+    if (!checkValid(key))
         return;

</code_context>
<issue_to_address>
**issue (bug_risk):** `reset()` validates an `AuthorizedReadOnly` item through `checkValid()`, but `checkValid()` only verifies the SID2/root authorization and `reset()` never calls `hasPermissionByUid()` or otherwise rejects read-only permissions. An authorized root caller can therefore reset a read-only configuration item.

**Triggers:** When a configuration item has the newly supported `AuthorizedReadOnly` permission and a root caller invokes `reset`.

**Suggested fix:** Reject `ReadOnly` and `AuthorizedReadOnly` permissions in `reset()`, or share the same write-permission check used by `setValue()`.
</issue_to_address>

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.

void DSGConfigConn::reset(const QString &key)
{
if (!contains(key))
if (!checkValid(key))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): reset() validates an AuthorizedReadOnly item through checkValid(), but checkValid() only verifies the SID2/root authorization and reset() never calls hasPermissionByUid() or otherwise rejects read-only permissions. An authorized root caller can therefore reset a read-only configuration item.

Triggers: When a configuration item has the newly supported AuthorizedReadOnly permission and a root caller invokes reset.

Suggested fix: Reject ReadOnly and AuthorizedReadOnly permissions in reset(), or share the same write-permission check used by setValue().

@18202781743
18202781743 marked this pull request as draft September 4, 2026 02:26
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.

5 participants