提交 77ad0f3d 编写于 作者: L linruijie

1572 增加特性开关-startup_init_with_param_base;1599 setcon according to actual process name 挑单到monthly

Signed-off-by: Nlinruijie <linruijie@huawei.com>
上级 1443a8be
......@@ -29,4 +29,9 @@ declare_args() {
config_ohos_startup_init_lite_memory_size = 5120
# boot_kernel_extended_cmdline for extend cmdline
startup_init_with_param_base = false
if (!use_musl) {
startup_init_with_param_base = true
}
}
......@@ -86,7 +86,7 @@ if (defined(ohos_lite)) {
defines += [ "__LINUX__" ]
deps += [
"//base/startup/init/services/loopevent:loopevent",
"//base/startup/init/services/param/base:parameterbase",
"//base/startup/init/services/param/base:param_base",
"//base/startup/init/services/param/linux:param_client",
]
}
......@@ -197,11 +197,7 @@ if (defined(ohos_lite)) {
"//third_party/cJSON:cjson",
"//third_party/mbedtls:mbedtls_shared",
]
if (use_musl == false) {
deps += [ "//base/startup/init/services/param/base:parameterbase" ]
} else {
deps += [ "//base/startup/init/services/param/base:parameterbase_ext" ]
}
deps += [ "//base/startup/init/services/param/base:param_base" ]
external_deps = [
"c_utils:utils",
"hilog_native:libhilog_base",
......@@ -294,11 +290,7 @@ if (defined(ohos_lite)) {
"//third_party/bounds_checking_function:libsec_shared",
"//third_party/mbedtls:mbedtls_shared",
]
if (use_musl == false) {
deps += [ "//base/startup/init/services/param/base:parameterbase" ]
} else {
deps += [ "//base/startup/init/services/param/base:parameterbase_ext" ]
}
deps += [ "//base/startup/init/services/param/base:param_base" ]
external_deps = [
"c_utils:utils",
"hilog_native:libhilog_base",
......
......@@ -201,11 +201,7 @@ if (defined(ohos_lite)) {
"//base/startup/init/services/utils:libinit_utils",
"//third_party/bounds_checking_function:libsec_static",
]
if (use_musl == false) {
deps += [ "//base/startup/init/services/param/base:parameterbase" ]
} else {
deps += [ "//base/startup/init/services/param/base:parameterbase_ext" ]
}
deps += [ "//base/startup/init/services/param/base:param_base" ]
external_deps = [
"c_utils:utils",
"hilog_native:libhilog_base",
......
......@@ -49,6 +49,7 @@ executable("init") {
include_dirs = [
"//base/startup/init/interfaces/innerkits/include",
"//base/startup/init/interfaces/innerkits/fd_holder",
"//base/startup/init/services/include/param",
"//base/startup/init/services/init/include",
"//third_party/cJSON",
"//third_party/bounds_checking_function/include",
......@@ -61,7 +62,7 @@ executable("init") {
"//base/startup/init/services/log:init_log",
"//base/startup/init/services/loopevent:loopevent",
"//base/startup/init/services/modules/init_hook:inithook",
"//base/startup/init/services/param/base:parameterbase",
"//base/startup/init/services/param/base:param_base",
"//base/startup/init/services/utils:libinit_utils",
"//build/lite/config/component/cJSON:cjson_static",
"//third_party/bounds_checking_function:libsec_static",
......
......@@ -69,11 +69,7 @@ ohos_executable("init") {
"//base/startup/init/services/param/linux:param_init",
"//base/startup/init/services/utils:libinit_utils",
]
if (use_musl == false) {
deps += [ "//base/startup/init/services/param/base:parameterbase" ]
} else {
deps += [ "//base/startup/init/services/param/base:parameterbase_ext" ]
}
deps += [ "//base/startup/init/services/param/base:param_base" ]
deps += [
"//base/customization/config_policy/frameworks/config_policy:configpolicy_util_for_init_static",
......
......@@ -19,6 +19,7 @@
#include "init_hook.h"
#include "init_module_engine.h"
#include "plugin_adapter.h"
#include "securec.h"
#include <policycoreutils.h>
#include <selinux/selinux.h>
......@@ -30,8 +31,13 @@ enum {
CMD_RESTORE_INDEX = 3,
};
extern char *__progname;
static int LoadSelinuxPolicy(int id, const char *name, int argc, const char **argv)
{
int ret;
char process_context[MAX_SECON_LEN];
UNUSED(id);
UNUSED(name);
UNUSED(argc);
......@@ -44,7 +50,12 @@ static int LoadSelinuxPolicy(int id, const char *name, int argc, const char **ar
PLUGIN_LOGI("main, load_policy success.");
}
setcon("u:r:init:s0");
ret = snprintf_s(process_context, sizeof(process_context), sizeof(process_context) - 1, "u:r:%s:s0", __progname);
if (ret == -1) {
setcon("u:r:init:s0");
} else {
setcon(process_context);
}
(void)RestoreconRecurse("/dev");
return 0;
}
......
......@@ -19,7 +19,7 @@ group("parameter") {
if (defined(ohos_lite)) {
if (ohos_kernel_type == "linux") {
deps += [
"base:parameterbase",
"base:param_base",
"linux:param_client",
"linux:param_init",
]
......@@ -31,7 +31,7 @@ group("parameter") {
}
} else {
deps += [
"base:parameterbase",
"base:param_base",
"linux:param_client",
"linux:param_init",
]
......
......@@ -75,7 +75,7 @@ if (defined(ohos_lite)) {
}
}
} else {
if (use_musl) {
if (!startup_init_with_param_base) {
inherited_configs = [
"//build/config/compiler:afdo",
"//build/config/compiler:afdo_optimize_size",
......@@ -113,13 +113,13 @@ if (defined(ohos_lite)) {
deps = []
if (use_musl) {
defines += [ "__MUSL__" ]
}
if (!startup_init_with_param_base) {
ldflags = [ "-nostdlib" ]
configs -= inherited_configs
configs += [ "//build/config/compiler:compiler" ]
defines += [
"PARAM_BASE",
"__MUSL__",
]
defines += [ "PARAM_BASE" ]
} else {
include_dirs += [ "//third_party/bounds_checking_function/include" ]
sources += [ "//base/startup/init/services/log/init_commlog.c" ]
......@@ -174,3 +174,15 @@ if (defined(ohos_lite)) {
subsystem_name = "startup"
}
}
group("param_base") {
if (defined(ohos_lite)) {
deps = [ ":parameterbase" ]
} else {
if (startup_init_with_param_base) {
deps = [ ":parameterbase" ]
} else {
deps = [ ":parameterbase_ext" ]
}
}
}
......@@ -10,13 +10,14 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//base/startup/init/begetd.gni")
if (defined(ohos_lite)) {
if (ohos_kernel_type == "linux") {
service_ueventd_deps = [
"//base/startup/init/interfaces/innerkits/socket:libsocket",
"//base/startup/init/services/log:init_log",
"//base/startup/init/services/param/base:parameterbase",
"//base/startup/init/services/param/base:param_base",
"//base/startup/init/services/utils:libinit_utils",
"//third_party/bounds_checking_function:libsec_static",
]
......@@ -113,11 +114,7 @@ if (defined(ohos_lite)) {
deps = service_ueventd_deps
deps += [ "//base/startup/init/services/param/linux:param_client" ]
cflags = []
if (use_musl == false) {
deps += [ "//base/startup/init/services/param/base:parameterbase" ]
} else {
deps += [ "//base/startup/init/services/param/base:parameterbase_ext" ]
}
deps += [ "//base/startup/init/services/param/base:param_base" ]
if (build_selinux) {
external_deps = [ "selinux:librestorecon" ]
cflags += [ "-DWITH_SELINUX" ]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册