Skip to content

feat: add deepin-daemon service group support#78

Merged
fly602 merged 1 commit intolinuxdeepin:masterfrom
fly602:master
Dec 15, 2025
Merged

feat: add deepin-daemon service group support#78
fly602 merged 1 commit intolinuxdeepin:masterfrom
fly602:master

Conversation

@fly602
Copy link
Contributor

@fly602 fly602 commented Dec 12, 2025

Added support for deepin-daemon service group with specific user context

  1. Created systemd drop-in configuration for deepin-daemon group to run as deepin-daemon user
  2. Modified application initialization logic to detect deepin-daemon user and use QCoreApplication
  3. Updated service group list to include deepin-daemon group
  4. Added comments in service template explaining the deepin-daemon specific configuration

Log: Added deepin-daemon service group support with dedicated user context

Influence:

  1. Test deepin-daemon service group startup and operation
  2. Verify that services in deepin-daemon group run under deepin-daemon user
  3. Check systemd service status and user context configuration
  4. Test application behavior when running as deepin-daemon user vs regular user
  5. Verify service group serialization order including new deepin-daemon group

feat: 新增 deepin-daemon 服务组支持

添加对 deepin-daemon 服务组的支持,包含特定用户上下文配置

  1. 创建 systemd drop-in 配置,使 deepin-daemon 组以 deepin-daemon 用户身 份运行
  2. 修改应用初始化逻辑,检测 deepin-daemon 用户并使用 QCoreApplication
  3. 更新服务组列表以包含 deepin-daemon 组
  4. 在服务模板中添加注释说明 deepin-daemon 特定配置

Log: 新增 deepin-daemon 服务组支持,使用专用用户上下文

Influence:

  1. 测试 deepin-daemon 服务组的启动和运行
  2. 验证 deepin-daemon 组中的服务是否以 deepin-daemon 用户身份运行
  3. 检查 systemd 服务状态和用户上下文配置
  4. 测试应用在以 deepin-daemon 用户运行时与普通用户运行时的行为差异
  5. 验证服务组序列化顺序,包括新的 deepin-daemon 组

if (!useCoreApp) {
struct passwd *pw = getpwuid(euid);
if (pw != nullptr) {
QString username = QString::fromUtf8(pw->pw_name);
Copy link
Contributor

Choose a reason for hiding this comment

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

条件合并成一行

} else {
bool useCoreApp = (euid == 0);

// 检查是否是 deepin-admin 或 deepin-daemon 用户
Copy link
Contributor

Choose a reason for hiding this comment

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

deepin-admin 删掉

Added support for deepin-daemon service group with specific user context
1. Created systemd drop-in configuration for deepin-daemon group to run
as deepin-daemon user
2. Modified application initialization logic to detect deepin-daemon
user and use QCoreApplication
3. Updated service group list to include deepin-daemon group
4. Added comments in service template explaining the deepin-daemon
specific configuration

Log: Added deepin-daemon service group support with dedicated user
context

Influence:
1. Test deepin-daemon service group startup and operation
2. Verify that services in deepin-daemon group run under deepin-daemon
user
3. Check systemd service status and user context configuration
4. Test application behavior when running as deepin-daemon user vs
regular user
5. Verify service group serialization order including new deepin-daemon
group

feat: 新增 deepin-daemon 服务组支持

添加对 deepin-daemon 服务组的支持,包含特定用户上下文配置
1. 创建 systemd drop-in 配置,使 deepin-daemon 组以 deepin-daemon 用户身
份运行
2. 修改应用初始化逻辑,检测 deepin-daemon 用户并使用 QCoreApplication
3. 更新服务组列表以包含 deepin-daemon 组
4. 在服务模板中添加注释说明 deepin-daemon 特定配置

Log: 新增 deepin-daemon 服务组支持,使用专用用户上下文

Influence:
1. 测试 deepin-daemon 服务组的启动和运行
2. 验证 deepin-daemon 组中的服务是否以 deepin-daemon 用户身份运行
3. 检查 systemd 服务状态和用户上下文配置
4. 测试应用在以 deepin-daemon 用户运行时与普通用户运行时的行为差异
5. 验证服务组序列化顺序,包括新的 deepin-daemon 组
@deepin-ci-robot
Copy link

deepin pr auto review

我来对这个 git diff 进行详细的代码审查:

  1. 代码逻辑和功能变更:
  • 添加了对 deepin-daemon 用户组的特殊支持
  • 通过 systemd drop-in 配置来覆盖服务配置
  • 修改了服务管理器的用户判断逻辑
  • 扩展了服务组列表
  1. 代码质量改进建议:

a) 文件名拼写错误:

static const QStringList GroupSiral{ "core", "dde", "app", "deepin-daemon" };

"GroupSiral" 应该改为 "GroupSerial"。

b) 用户检查逻辑可以优化:

bool useCoreApp = (euid == 0);
if (!useCoreApp) {
    struct passwd *pw = getpwuid(euid);
    useCoreApp = (pw && QString::fromUtf8(pw->pw_name) == "deepin-daemon");
}

建议改为更清晰的写法:

bool useCoreApp = false;
if (euid == 0) {
    useCoreApp = true;
} else {
    struct passwd *pw = getpwuid(euid);
    useCoreApp = (pw && QString::fromUtf8(pw->pw_name) == "deepin-daemon");
}

c) 安全性考虑:

  • 需要检查 deepin-daemon 用户是否存在
  • 应该添加错误处理机制,当 getpwuid 返回 NULL 时要有适当处理
  1. 性能优化建议:
  • 可以缓存 deepin-daemon 用户的 UID,避免每次都调用 getpwuid
  • 考虑将用户检查逻辑封装成单独的函数
  1. 安全性建议:
  • 添加对 deepin-daemon 用户权限的验证
  • 确保配置文件的权限设置正确
  • 考虑添加对 override.conf 文件的权限检查
  1. 文档和注释改进:
  • 建议在 CMakeLists.txt 中添加更多说明注释
  • 在 main.cpp 中的用户检查逻辑部分添加更详细的注释
  • 为新增的 deepin-daemon 组添加说明文档
  1. 配置文件建议:
  • 建议在 override.conf.in 中添加更多配置说明
  • 考虑添加配置文件验证机制
  1. 错误处理:
  • 需要添加对配置文件不存在或损坏的处理
  • 添加对用户切换失败的处理
  1. 测试建议:
  • 需要添加对 deepin-daemon 用户的单元测试
  • 测试配置文件的加载和应用
  • 测试不同用户场景下的行为

这些修改将提高代码的可靠性、可维护性和安全性。建议在实施这些改进时,先在测试环境中验证所有更改。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: fly602, yixinshark

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

@fly602 fly602 merged commit 14224fc into linuxdeepin:master Dec 15, 2025
16 of 17 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