fix(agent-sec-core): explicitly enable systemd user unit after install#1322
Closed
zhangtaibo wants to merge 1 commit into
Closed
fix(agent-sec-core): explicitly enable systemd user unit after install#1322zhangtaibo wants to merge 1 commit into
zhangtaibo wants to merge 1 commit into
Conversation
%systemd_user_post calls systemctl preset, which checks the preset policy. Since no preset rule matches agent-sec-core.service, the default action is disable, leaving the unit disabled after package installation. Add explicit 'systemctl --user enable agent-sec-core.service' after %systemd_user_post to ensure the security daemon is enabled on install. Fixes alibaba#1320
Collaborator
|
@RemindD PTAL |
RemindD
reviewed
Jul 9, 2026
RemindD
left a comment
Collaborator
There was a problem hiding this comment.
- RPM 脚本通常以 root 执行,不知道“哪个普通用户”要启用这个 user service。
- systemctl --user 依赖用户会话和 user bus,安装阶段通常不可用。
- 即使成功,也可能启用的是 root 的 user service,不是目标用户的。
- RPM 打包习惯上安装 unit 文件,并通过 %systemd_user_post 触发 daemon-
reload/preset 等发行版机制;是否启用由 preset、管理员策略或用户显式操作决
定。
Contributor
Author
|
[automated review] case 连续通过 6 次(在不含本 PR 的 main 上),原始 verdict=product_bug 但 main 已绿,PR 疑似 stale duplicate(修复已通过其他途径合入)。关闭 issue+PR。若 PR 仍需要,请重开并说明。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1320
The
%systemd_user_postmacro callssystemctl preset <unit>, which checks the system preset policy. Since no preset rule matchesagent-sec-core.service, the default action isdisable, leaving the unitdisabledafter package installation.This PR adds an explicit
systemctl --user enable agent-sec-core.service 2>/dev/null || trueafter%systemd_user_postin the%post -n agent-sec-clisection to ensure the security daemon is enabled on install.Root Cause
%systemd_user_postexpands to:This only copies the unit file to the user preset directory. It then calls
systemctl preset, which checks/usr/lib/systemd/user-preset/90-systemd.preset. Since no rule in that file matchesagent-sec-core.service, the default action isdisable.Fix
%post -n agent-sec-cli %systemd_user_post agent-sec-core.service +systemctl --user enable agent-sec-core.service 2>/dev/null || trueThe
2>/dev/null || trueensures the scriptlet does not fail if the user session is not available during RPM install.Verification
161859b9)source /root/.cargo/env && bash scripts/rpm-build.sh agent-sec-core→ exit 0, all 8 RPMs produced%postscript in built RPM containssystemctl --user enable agent-sec-core.service 2>/dev/null || trueafter the systemd-update-helper callThis PR was automatically generated by the nightly test pipeline (run
nightly-20260704-020034).