未验证 提交 955d01f7 编写于 作者: O openharmony_ci 提交者: Gitee

!1068 编译parameterbase到musl

Merge pull request !1068 from Mupceet/buildformusl
......@@ -47,7 +47,7 @@ typedef enum InitLogLevel {
INIT_FATAL
} 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__))
INIT_PUBLIC_API void StartupLog(InitLogLevel logLevel, uint32_t domain, const char *tag, const char *fmt, ...);
......
......@@ -118,8 +118,7 @@ static void PrintLog(InitLogLevel logLevel, unsigned int domain, const char *tag
#endif
}
INIT_LOCAL_API void InitLog(InitLogLevel logLevel,
unsigned int domain, const char *tag, const char *fmt, va_list vargs)
INIT_LOCAL_API void InitLog(int logLevel, unsigned int domain, const char *tag, const char *fmt, va_list vargs)
{
if (g_logLevel > logLevel) {
return;
......
......@@ -37,8 +37,7 @@ extern "C" {
#endif
INIT_LOCAL_API void OpenLogDevice(void);
INIT_LOCAL_API void InitLog(InitLogLevel logLevel,
unsigned int domain, const char *tag, const char *fmt, va_list vargs);
INIT_LOCAL_API void InitLog(int logLevel, unsigned int domain, const char *tag, const char *fmt, va_list vargs);
#ifdef PARAM_BASE
#define INIT_LOGV(fmt, ...)
......
......@@ -154,7 +154,7 @@ static int SelinuxGetAllLabel(int readOnly)
node = node->next;
continue;
}
// set selinx label
// set selinux label
SetSelinuxFileCon(node->info.paraName, node->info.paraContext);
node = node->next;
}
......@@ -200,15 +200,12 @@ static int SelinuxReadParamCheck(const char *name)
if (selinuxSpace->readParamCheck != NULL) {
ret = selinuxSpace->readParamCheck(name);
PARAM_LOGI("SelinuxReadParamCheck name %s ret %d", name, ret);
return ret;
}
const char *label = GetSelinuxContent(name);
if (label == NULL) { // open file with readonly
ret = AddWorkSpace(WORKSPACE_NAME_DEF_SELINUX, 1, PARAM_WORKSPACE_MAX);
} else {
ret = AddWorkSpace(label, 1, PARAM_WORKSPACE_MAX);
}
if (ret != 0) {
PARAM_LOGV("SelinuxReadParamCheck name %s label %s ", name, label);
PARAM_LOGW("SelinuxReadParamCheck name %s label %s", name, GetSelinuxContent(name));
WorkSpace *space = GetWorkSpace(name);
if (space == NULL) {
PARAM_LOGW("SelinuxReadParamCheck name %s label %s forbid", name, GetSelinuxContent(name));
return DAC_RESULT_FORBIDED;
}
return DAC_RESULT_PERMISSION;
......@@ -225,7 +222,8 @@ static int SelinuxCheckParamPermission(const ParamSecurityLabel *srcLabel, const
uc.gid = srcLabel->cred.gid;
if (mode == DAC_WRITE) {
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 {
#ifndef STARTUP_INIT_TEST
ret = SelinuxReadParamCheck(name);
......
......@@ -71,7 +71,26 @@ if (defined(ohos_lite)) {
}
}
} 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 += [
"//base/startup/init/services/param/adapter/param_dac.c",
......@@ -79,6 +98,9 @@ if (defined(ohos_lite)) {
"//base/startup/init/services/param/linux/param_osadp.c",
]
cflags = [ "-fPIC" ]
ldflags = [ "-nostdlib" ]
configs -= inherited_configs
configs += [ "//build/config/compiler:compiler" ]
include_dirs = base_include_dirs
public_configs = [ ":exported_header_files" ]
defines = [ "_GNU_SOURCE" ]
......@@ -106,7 +128,6 @@ if (defined(ohos_lite)) {
if (param_base_log) {
defines += [ "PARAM_BASE_LOG" ]
}
part_name = "init"
}
# extend for base
......@@ -114,8 +135,6 @@ if (defined(ohos_lite)) {
sources = comm_sources
sources += [
"//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",
]
cflags = [ "-fPIC" ]
......@@ -130,8 +149,6 @@ if (defined(ohos_lite)) {
"//third_party/selinux/libselinux/include/",
"//base/security/selinux/interfaces/policycoreutils/include/",
]
sources +=
[ "//base/startup/init/services/param/adapter/param_selinux.c" ]
defines += [
"PARAM_SUPPORT_SELINUX",
"PARAMWORKSPACE_NEED_MUTEX",
......
......@@ -96,11 +96,11 @@ typedef struct {
} ParamSecurityOps;
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_ {
void *selinuxHandle;
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);
int (*initParamSelinux)(void);
int (*readParamCheck)(const char *paraName);
......
......@@ -18,9 +18,7 @@
#include <string.h>
#include <sys/socket.h>
#ifdef PARAM_BASE_LOG
#include "init_log.h"
#endif
#include "init_param.h"
#include "init_utils.h"
#include "loop_event.h"
......@@ -380,9 +378,8 @@ void InitParamService(void)
// param space
PARAM_WORKSPACE_OPS ops = {0};
ops.updaterMode = InUpdaterMode();
#ifdef PARAM_BASE_LOG
// init open log
ops.logFunc = InitLog;
#endif
#ifdef PARAM_SUPPORT_SELINUX
ops.setfilecon = setfilecon;
#endif
......
......@@ -61,7 +61,7 @@ static const char *forbitWriteParamName[] = {
"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.
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.
先完成此消息的编辑!
想要评论请 注册