Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
e0d5b080
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
1 年多 前同步成功
通知
3
Star
37
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Startup Init Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e0d5b080
编写于
8月 12, 2022
作者:
M
Mupceet
提交者:
an_xinwei
8月 16, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
build for musl
Signed-off-by:
N
Mupceet
<
laiguizhong@huawei.com
>
上级
65312a7d
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
38 addition
and
28 deletion
+38
-28
interfaces/innerkits/include/beget_ext.h
interfaces/innerkits/include/beget_ext.h
+1
-1
services/log/init_log.c
services/log/init_log.c
+1
-2
services/log/init_log.h
services/log/init_log.h
+1
-2
services/param/adapter/param_selinux.c
services/param/adapter/param_selinux.c
+8
-10
services/param/base/BUILD.gn
services/param/base/BUILD.gn
+23
-6
services/param/include/param_security.h
services/param/include/param_security.h
+2
-2
services/param/linux/param_service.c
services/param/linux/param_service.c
+1
-4
test/unittest/param/param_stub.cpp
test/unittest/param/param_stub.cpp
+1
-1
未找到文件。
interfaces/innerkits/include/beget_ext.h
浏览文件 @
e0d5b080
...
...
@@ -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
,
...);
...
...
services/log/init_log.c
浏览文件 @
e0d5b080
...
...
@@ -116,8 +116,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
;
...
...
services/log/init_log.h
浏览文件 @
e0d5b080
...
...
@@ -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, ...)
...
...
services/param/adapter/param_selinux.c
浏览文件 @
e0d5b080
...
...
@@ -154,7 +154,7 @@ static int SelinuxGetAllLabel(int readOnly)
node
=
node
->
next
;
continue
;
}
// set selinx label
// set selin
u
x 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
);
...
...
services/param/base/BUILD.gn
浏览文件 @
e0d5b080
...
...
@@ -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",
...
...
services/param/include/param_security.h
浏览文件 @
e0d5b080
...
...
@@ -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
);
...
...
services/param/linux/param_service.c
浏览文件 @
e0d5b080
...
...
@@ -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
...
...
test/unittest/param/param_stub.cpp
浏览文件 @
e0d5b080
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录