fix: disable User/Group on hongmeng

This commit is contained in:
licunlong 2023-08-23 11:50:08 +08:00
parent 97e0449f9e
commit eeb26b0531
2 changed files with 62 additions and 1 deletions

View File

@ -0,0 +1,57 @@
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

View File

@ -17,7 +17,7 @@
Name: sysmaster
Version: 0.5.0
Release: 1
Release: 2
Summary: redesign and reimplement process1.
License: Mulan PSL v2
@ -29,6 +29,7 @@ Patch1: backport-fix-Fixed-parsing-single-quotes-error.patch
Patch2: backport-fix-devmaster-avoid-coredump-when-rules-directory-is.patch
Patch3: backport-fix-device-avoid-inserting-empty-tag.patch
Patch4: backport-fix-devmaster-append-trailing-white-line-in-99-defau.patch
Patch5: backport-fix-disable-User-Group-feature-for-hongmeng.patch
ExclusiveArch: x86_64 aarch64
@ -130,6 +131,9 @@ ln -s /usr/lib/sysmaster/system/sshd.service %{buildroot}/etc/sysmaster/system/m
%attr(0550,-,-) /usr/lib/devmaster/devmaster
%changelog
* Wed Aug 23 2023 licunlong<licunlong1@huawei.com> - 0.5.0-2
- disable User/Group on hongmeng
* Mon Aug 14 2023 shenyangyang<shenyangyang4@huawei.com> - 0.5.0-1
- bump version to 0.5.0 to supprot virtual machine