fix: disable immutable remount for read-only dpkg/apt queries - #469
Conversation
There was a problem hiding this comment.
Sorry @qiuzhiqian, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
CLA Assistant Lite bot: |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR ensures read-only dpkg/apt queries do not trigger the immutable /usr remount logic by explicitly setting IMMUTABLE_DISABLE_REMOUNT=true on those subprocesses that don’t inherit the global env initialization. Sequence diagram for dpkg architecture query with IMMUTABLE_DISABLE_REMOUNTsequenceDiagram
participant GetArchInfo
participant dpkg
GetArchInfo->>dpkg: exec.Command("dpkg","--print-architecture")
GetArchInfo->>dpkg: cmd.Env append IMMUTABLE_DISABLE_REMOUNT=true
dpkg-->>GetArchInfo: Output()
Flow diagram for IMMUTABLE_DISABLE_REMOUNT propagation to dpkg/apt queriesflowchart TD
A[process_start] --> B[system_apt_init]
B --> C[os.Setenv IMMUTABLE_DISABLE_REMOUNT=true]
C --> D[dpkg_apt_queries_in_system_package]
A --> E[config_cache_init]
E --> F[exec.Command dpkg --print-architecture]
F --> G[cmd.Env append IMMUTABLE_DISABLE_REMOUNT=true]
A --> H[check_init]
H --> I[exec.Command dpkg --print-architecture]
I --> J[cmd.Env append IMMUTABLE_DISABLE_REMOUNT=true]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
3ea3d56 to
5180d9c
Compare
For read-only or verification commands such as 'dpkg --print-architecture', 'dpkg --print-foreign-architectures' and 'apt list --upgradable', no data is written to the system, so remounting the immutable /usr to rw is unnecessary. Set IMMUTABLE_DISABLE_REMOUNT=true on these subprocesses to skip the redundant remount flow. Note: most other dpkg/apt query call sites inherit this variable via the process-level os.Setenv in src/internal/system/system_apt.go init(). config/cache is the exception because it does not import the system package, so an explicit Env assignment there is required. PMS: TASK-393303
5180d9c to
a49e66f
Compare
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // src/lastore-tools/main.go
func main() {
// 默认禁用不可变系统的 remount,仅对需要写 /usr 的子进程显式置为 false
if err := os.Setenv("IMMUTABLE_DISABLE_REMOUNT", "true"); err != nil {
logger.Warningf("Failed to set IMMUTABLE_DISABLE_REMOUNT environment variable: %v", err)
}
// 清除语言相关环境变量
_ = utils.UnsetEnv("LC_ALL")
// ...
} |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: qiuzhiqian, zhaohuiw42 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
For read-only or verification commands such as 'dpkg --print-architecture', 'dpkg --print-foreign-architectures' and 'apt list --upgradable', no data is written to the system, so remounting the immutable /usr to rw is unnecessary. Set IMMUTABLE_DISABLE_REMOUNT=true on these subprocesses to skip the redundant remount flow.
Note: most other dpkg/apt query call sites inherit this variable via the process-level os.Setenv in src/internal/system/system_apt.go init(). config/cache is the exception because it does not import the system package, so an explicit Env assignment there is required.
Summary by Sourcery
Disable immutable /usr remounts for read-only dpkg and apt query commands by marking these subprocesses as remount-safe.
Enhancements: