提交 e0d5b080 编写于 作者: M Mupceet 提交者: an_xinwei

build for musl

Signed-off-by: NMupceet <laiguizhong@huawei.com>
上级 65312a7d
...@@ -47,7 +47,7 @@ typedef enum InitLogLevel { ...@@ -47,7 +47,7 @@ typedef enum InitLogLevel {
INIT_FATAL INIT_FATAL
} InitLogLevel; } InitLogLevel;
typedef void (*InitCommLog)(InitLogLevel logLevel, uint32_t domain, const char *tag, const char *fmt, va_list vargs); typedef void (*InitCommLog)(int logLevel, uint32_t domain, const char *tag, const char *fmt, va_list vargs);
#define FILE_NAME (strrchr((__FILE__), '/') ? strrchr((__FILE__), '/') + 1 : (__FILE__)) #define FILE_NAME (strrchr((__FILE__), '/') ? strrchr((__FILE__), '/') + 1 : (__FILE__))
INIT_PUBLIC_API void StartupLog(InitLogLevel logLevel, uint32_t domain, const char *tag, const char *fmt, ...); INIT_PUBLIC_API void StartupLog(InitLogLevel logLevel, uint32_t domain, const char *tag, const char *fmt, ...);
......
...@@ -116,8 +116,7 @@ static void PrintLog(InitLogLevel logLevel, unsigned int domain, const char *tag ...@@ -116,8 +116,7 @@ static void PrintLog(InitLogLevel logLevel, unsigned int domain, const char *tag
#endif #endif
} }
INIT_LOCAL_API void InitLog(InitLogLevel logLevel, INIT_LOCAL_API void InitLog(int logLevel, unsigned int domain, const char *tag, const char *fmt, va_list vargs)
unsigned int domain, const char *tag, const char *fmt, va_list vargs)
{ {
if (g_logLevel > logLevel) { if (g_logLevel > logLevel) {
return; return;
......
...@@ -37,8 +37,7 @@ extern "C" { ...@@ -37,8 +37,7 @@ extern "C" {
#endif #endif
INIT_LOCAL_API void OpenLogDevice(void); INIT_LOCAL_API void OpenLogDevice(void);
INIT_LOCAL_API void InitLog(InitLogLevel logLevel, INIT_LOCAL_API void InitLog(int logLevel, unsigned int domain, const char *tag, const char *fmt, va_list vargs);
unsigned int domain, const char *tag, const char *fmt, va_list vargs);
#ifdef PARAM_BASE #ifdef PARAM_BASE
#define INIT_LOGV(fmt, ...) #define INIT_LOGV(fmt, ...)
......
...@@ -154,7 +154,7 @@ static int SelinuxGetAllLabel(int readOnly) ...@@ -154,7 +154,7 @@ static int SelinuxGetAllLabel(int readOnly)
node = node->next; node = node->next;
continue; continue;
} }
// set selinx label // set selinux label
SetSelinuxFileCon(node->info.paraName, node->info.paraContext); SetSelinuxFileCon(node->info.paraName, node->info.paraContext);
node = node->next; node = node->next;
} }
...@@ -200,15 +200,12 @@ static int SelinuxReadParamCheck(const char *name) ...@@ -200,15 +200,12 @@ static int SelinuxReadParamCheck(const char *name)
if (selinuxSpace->readParamCheck != NULL) { if (selinuxSpace->readParamCheck != NULL) {
ret = selinuxSpace->readParamCheck(name); ret = selinuxSpace->readParamCheck(name);
PARAM_LOGI("SelinuxReadParamCheck name %s ret %d", name, ret); PARAM_LOGI("SelinuxReadParamCheck name %s ret %d", name, ret);
return ret;
} }
const char *label = GetSelinuxContent(name); PARAM_LOGW("SelinuxReadParamCheck name %s label %s", name, GetSelinuxContent(name));
if (label == NULL) { // open file with readonly WorkSpace *space = GetWorkSpace(name);
ret = AddWorkSpace(WORKSPACE_NAME_DEF_SELINUX, 1, PARAM_WORKSPACE_MAX); if (space == NULL) {
} else { PARAM_LOGW("SelinuxReadParamCheck name %s label %s forbid", name, GetSelinuxContent(name));
ret = AddWorkSpace(label, 1, PARAM_WORKSPACE_MAX);
}
if (ret != 0) {
PARAM_LOGV("SelinuxReadParamCheck name %s label %s ", name, label);
return DAC_RESULT_FORBIDED; return DAC_RESULT_FORBIDED;
} }
return DAC_RESULT_PERMISSION; return DAC_RESULT_PERMISSION;
...@@ -225,7 +222,8 @@ static int SelinuxCheckParamPermission(const ParamSecurityLabel *srcLabel, const ...@@ -225,7 +222,8 @@ static int SelinuxCheckParamPermission(const ParamSecurityLabel *srcLabel, const
uc.gid = srcLabel->cred.gid; uc.gid = srcLabel->cred.gid;
if (mode == DAC_WRITE) { if (mode == DAC_WRITE) {
PARAM_CHECK(selinuxSpace->setParamCheck != NULL, return ret, "Invalid setParamCheck"); PARAM_CHECK(selinuxSpace->setParamCheck != NULL, return ret, "Invalid setParamCheck");
ret = selinuxSpace->setParamCheck(name, &uc); const char *context = GetSelinuxContent(name);
ret = selinuxSpace->setParamCheck(name, context, &uc);
} else { } else {
#ifndef STARTUP_INIT_TEST #ifndef STARTUP_INIT_TEST
ret = SelinuxReadParamCheck(name); ret = SelinuxReadParamCheck(name);
......
...@@ -71,7 +71,26 @@ if (defined(ohos_lite)) { ...@@ -71,7 +71,26 @@ if (defined(ohos_lite)) {
} }
} }
} else { } else {
ohos_source_set("parameterbase") { inherited_configs = [
"//build/config/compiler:afdo",
"//build/config/compiler:afdo_optimize_size",
"//build/config/compiler:compiler",
"//build/config/compiler:compiler_arm_fpu",
"//build/config/compiler:compiler_arm_thumb",
"//build/config/compiler:chromium_code",
"//build/config/compiler:default_include_dirs",
"//build/config/compiler:default_optimization",
"//build/config/compiler:default_stack_frames",
"//build/config/compiler:default_symbols",
"//build/config/compiler:export_dynamic",
"//build/config/compiler:no_exceptions",
"//build/config/compiler:no_rtti",
"//build/config/compiler:runtime_library",
"//build/config/compiler:thin_archive",
"//build/config/sanitizers:default_sanitizer_flags",
]
source_set("parameterbase") {
sources = comm_sources sources = comm_sources
sources += [ sources += [
"//base/startup/init/services/param/adapter/param_dac.c", "//base/startup/init/services/param/adapter/param_dac.c",
...@@ -79,6 +98,9 @@ if (defined(ohos_lite)) { ...@@ -79,6 +98,9 @@ if (defined(ohos_lite)) {
"//base/startup/init/services/param/linux/param_osadp.c", "//base/startup/init/services/param/linux/param_osadp.c",
] ]
cflags = [ "-fPIC" ] cflags = [ "-fPIC" ]
ldflags = [ "-nostdlib" ]
configs -= inherited_configs
configs += [ "//build/config/compiler:compiler" ]
include_dirs = base_include_dirs include_dirs = base_include_dirs
public_configs = [ ":exported_header_files" ] public_configs = [ ":exported_header_files" ]
defines = [ "_GNU_SOURCE" ] defines = [ "_GNU_SOURCE" ]
...@@ -106,7 +128,6 @@ if (defined(ohos_lite)) { ...@@ -106,7 +128,6 @@ if (defined(ohos_lite)) {
if (param_base_log) { if (param_base_log) {
defines += [ "PARAM_BASE_LOG" ] defines += [ "PARAM_BASE_LOG" ]
} }
part_name = "init"
} }
# extend for base # extend for base
...@@ -114,8 +135,6 @@ if (defined(ohos_lite)) { ...@@ -114,8 +135,6 @@ if (defined(ohos_lite)) {
sources = comm_sources sources = comm_sources
sources += [ sources += [
"//base/startup/init/services/log/init_commlog.c", "//base/startup/init/services/log/init_commlog.c",
"//base/startup/init/services/param/adapter/param_dac.c",
"//base/startup/init/services/param/base/param_base.c",
"//base/startup/init/services/param/linux/param_osadp.c", "//base/startup/init/services/param/linux/param_osadp.c",
] ]
cflags = [ "-fPIC" ] cflags = [ "-fPIC" ]
...@@ -130,8 +149,6 @@ if (defined(ohos_lite)) { ...@@ -130,8 +149,6 @@ if (defined(ohos_lite)) {
"//third_party/selinux/libselinux/include/", "//third_party/selinux/libselinux/include/",
"//base/security/selinux/interfaces/policycoreutils/include/", "//base/security/selinux/interfaces/policycoreutils/include/",
] ]
sources +=
[ "//base/startup/init/services/param/adapter/param_selinux.c" ]
defines += [ defines += [
"PARAM_SUPPORT_SELINUX", "PARAM_SUPPORT_SELINUX",
"PARAMWORKSPACE_NEED_MUTEX", "PARAMWORKSPACE_NEED_MUTEX",
......
...@@ -96,11 +96,11 @@ typedef struct { ...@@ -96,11 +96,11 @@ typedef struct {
} ParamSecurityOps; } ParamSecurityOps;
typedef int (*RegisterSecurityOpsPtr)(ParamSecurityOps *ops, int isInit); typedef int (*RegisterSecurityOpsPtr)(ParamSecurityOps *ops, int isInit);
typedef int (*SelinuxSetParamCheck)(const char *paraName, struct ucred *uc); typedef int (*SelinuxSetParamCheck)(const char *paraName, const char *destContext, struct ucred *uc);
typedef struct SelinuxSpace_ { typedef struct SelinuxSpace_ {
void *selinuxHandle; void *selinuxHandle;
void (*setSelinuxLogCallback)(void); void (*setSelinuxLogCallback)(void);
int (*setParamCheck)(const char *paraName, struct ucred *uc); int (*setParamCheck)(const char *paraName, const char *destContext, struct ucred *uc);
const char *(*getParamLabel)(const char *paraName); const char *(*getParamLabel)(const char *paraName);
int (*initParamSelinux)(void); int (*initParamSelinux)(void);
int (*readParamCheck)(const char *paraName); int (*readParamCheck)(const char *paraName);
......
...@@ -18,9 +18,7 @@ ...@@ -18,9 +18,7 @@
#include <string.h> #include <string.h>
#include <sys/socket.h> #include <sys/socket.h>
#ifdef PARAM_BASE_LOG
#include "init_log.h" #include "init_log.h"
#endif
#include "init_param.h" #include "init_param.h"
#include "init_utils.h" #include "init_utils.h"
#include "loop_event.h" #include "loop_event.h"
...@@ -380,9 +378,8 @@ void InitParamService(void) ...@@ -380,9 +378,8 @@ void InitParamService(void)
// param space // param space
PARAM_WORKSPACE_OPS ops = {0}; PARAM_WORKSPACE_OPS ops = {0};
ops.updaterMode = InUpdaterMode(); ops.updaterMode = InUpdaterMode();
#ifdef PARAM_BASE_LOG // init open log
ops.logFunc = InitLog; ops.logFunc = InitLog;
#endif
#ifdef PARAM_SUPPORT_SELINUX #ifdef PARAM_SUPPORT_SELINUX
ops.setfilecon = setfilecon; ops.setfilecon = setfilecon;
#endif #endif
......
...@@ -61,7 +61,7 @@ static const char *forbitWriteParamName[] = { ...@@ -61,7 +61,7 @@ static const char *forbitWriteParamName[] = {
"test.persmission.watch" "test.persmission.watch"
}; };
static int TestSetParamCheck(const char *paraName, struct ucred *uc) static int TestSetParamCheck(const char *paraName, const char *context, struct ucred *uc)
{ {
// forbid to read ohos.servicectrl. // forbid to read ohos.servicectrl.
for (size_t i = 0; i < ARRAY_LENGTH(forbitWriteParamName); i++) { for (size_t i = 0; i < ARRAY_LENGTH(forbitWriteParamName); i++) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册