sysmaster/backport-fix-disable-User-Group-feature-for-hongmeng.patch
2023-08-23 11:50:08 +08:00

58 lines
2.1 KiB
Diff

From 749a9ae4f901d2327bc519fd777b5a6c37ae5403 Mon Sep 17 00:00:00 2001
From: licunlong <licunlong1@huawei.com>
Date: Tue, 22 Aug 2023 14:49:56 +0800
Subject: [PATCH] fix: disable User/Group feature for hongmeng
---
core/coms/service/Cargo.toml | 4 +++-
core/coms/service/src/unit.rs | 2 ++
core/sysmaster/src/unit/execute/spawn.rs | 1 +
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/core/coms/service/Cargo.toml b/core/coms/service/Cargo.toml
index 99e7d2de..2dc55cd2 100755
--- a/core/coms/service/Cargo.toml
+++ b/core/coms/service/Cargo.toml
@@ -38,5 +38,7 @@ serde = { version = "1.0.130", default-features = false }
libtests = { path = "../../../libs/libtests" }
[features]
-default = ["noplugin"]
+default = ["linux", "noplugin"]
+hongmeng = []
+linux = []
noplugin = []
diff --git a/core/coms/service/src/unit.rs b/core/coms/service/src/unit.rs
index 3202a062..02b1ecb4 100755
--- a/core/coms/service/src/unit.rs
+++ b/core/coms/service/src/unit.rs
@@ -260,11 +260,13 @@ impl ServiceUnit {
self.exec_ctx
.set_state_directory(cfg_data.borrow().Service.StateDirectory.clone());
+ #[cfg(feature = "linux")]
if let Err(e) = self.exec_ctx.set_user(&cfg_data.borrow().Service.User) {
log::error!("Failed to set user: {}", e);
return Err(e);
}
+ #[cfg(feature = "linux")]
if let Err(e) = self.exec_ctx.set_group(&cfg_data.borrow().Service.Group) {
log::error!("Failed to set group: {}", e);
return Err(e);
diff --git a/core/sysmaster/src/unit/execute/spawn.rs b/core/sysmaster/src/unit/execute/spawn.rs
index 8f6da742..e27248b3 100755
--- a/core/sysmaster/src/unit/execute/spawn.rs
+++ b/core/sysmaster/src/unit/execute/spawn.rs
@@ -173,6 +173,7 @@ fn exec_child(unit: &Unit, cmdline: &ExecCommand, params: &ExecParameters, ctx:
let _ = setup_exec_directory(ctx.clone());
+ #[cfg(feature = "linux")]
if let Err(e) = apply_user_and_group(ctx.clone(), params) {
log::error!("Failed to apply user or group: {}", e);
return;
--
2.33.0