Skip to content

Conversation

@yixinshark
Copy link
Contributor

@yixinshark yixinshark commented Dec 19, 2025

When ExecCondition returns an exit code that is non-zero but not 255, the service is marked as "skipped" rather than "failed". The skipped state may be treated as success by some versions of systemd, thereby triggering OnSuccess!

Log: as title
Pms: BUG-343321

Summary by Sourcery

Bug Fixes:

  • Ensure services with specific ExecCondition exit codes are treated consistently to avoid incorrectly triggering OnSuccess and double-starting the dde-quick-login X11 service.

When ExecCondition returns an exit code that is non-zero but not 255,
the service is marked as "skipped" rather than "failed".
The skipped state may be treated as success by some versions of systemd,
thereby triggering OnSuccess!

Log: as title
Pms: BUG-343321
@sourcery-ai
Copy link

sourcery-ai bot commented Dec 19, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts the dde-quick-login@x11 systemd service definition so that its ExecCondition no longer leads to the unit being marked as "skipped" (and potentially autostarting twice) when it returns a non-zero, non-255 exit code, ensuring OnSuccess is not incorrectly triggered.

File-Level Changes

Change Details Files
Update dde-quick-login@x11 systemd service behavior so ExecCondition failures are treated as proper failures instead of skipped, preventing duplicate autostart execution via OnSuccess.
  • Modify the dde-quick-login@x11.service unit configuration so that non-zero, non-255 ExecCondition exit codes no longer result in the service entering a skipped state
  • Ensure that when the ExecCondition fails, the unit is marked as failed (or otherwise not successful), so OnSuccess is not triggered erroneously
  • Align behavior with systemd expectations to avoid treating skipped ExecCondition as success on some systemd versions
systemd/dde-session-pre.target.wants/dde-quick-login@x11.service

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

@deepin-ci-robot
Copy link

deepin pr auto review

我来对这个systemd服务文件的修改进行审查:

  1. 语法逻辑:
  • 修改后的代码在语法上是正确的,只是将退出状态码从2和3改为255
  • 两个ExecCondition条件判断的逻辑保持不变,仍然正确地检查快速登录模式和X11会话类型
  1. 代码质量:
  • 使用255作为错误退出码是一个常见的选择,因为它是系统保留的最高值之一
  • 但是这里有一个潜在的问题:使用相同的退出码(255)可能会让调试变得更困难,因为无法区分是哪个条件检查失败
  • 建议保持原有的不同退出码(2和3),这样更容易定位具体是哪个条件检查失败
  1. 代码性能:
  • 修改对性能没有影响,因为只是改变了退出状态码的值
  1. 代码安全:
  • 修改不会带来安全风险
  • 仍然正确地检查了必要的环境变量

改进建议:

  1. 建议保持原有的不同退出码设计,原因如下:

    • 不同的退出码有助于问题诊断和日志分析
    • 可以更容易地区分是快速登录模式检查失败还是X11会话类型检查失败
    • 符合系统设计中的错误分类原则
  2. 如果一定要统一使用255,建议添加注释说明原因,比如:

# Use 255 as unified error code for all condition checks
ExecCondition=/bin/sh -c '[ "$DDE_QUICKLOGIN" = "true" ] || exit 255'
ExecCondition=/bin/sh -c '[ "$XDG_SESSION_TYPE" = "%I" ] || exit 255'
  1. 可以考虑添加更多的错误处理和日志记录,例如:
ExecCondition=/bin/sh -c 'echo "Checking quick login mode: $DDE_QUICKLOGIN" >&2; [ "$DDE_QUICKLOGIN" = "true" ] || exit 255'

总的来说,这个修改在技术上是可行的,但从可维护性和调试的角度来看,保持原有的不同退出码会是更好的选择。

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - 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.

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mhduiy, 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

@yixinshark yixinshark merged commit a3c1f8a into linuxdeepin:master Dec 19, 2025
17 checks passed
@mhduiy
Copy link
Contributor

mhduiy commented Dec 19, 2025

用户级的 shell 环境变量展开理论上没有安全风险

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