Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
dc6c151d
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看板
未验证
提交
dc6c151d
编写于
6月 16, 2022
作者:
O
openharmony_ci
提交者:
Gitee
6月 16, 2022
浏览文件
操作
浏览文件
下载
差异文件
!787 优化service内存占用
Merge pull request !787 from Mupceet/initselinux
上级
3370247e
20644f65
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
19 addition
and
3 deletion
+19
-3
services/init/include/init_service.h
services/init/include/init_service.h
+1
-1
services/init/init_common_service.c
services/init/init_common_service.c
+1
-1
services/init/init_service_manager.c
services/init/init_service_manager.c
+17
-1
未找到文件。
services/init/include/init_service.h
浏览文件 @
dc6c151d
...
...
@@ -126,7 +126,7 @@ typedef struct {
typedef
struct
Service_
{
char
*
name
;
#ifdef WITH_SELINUX
char
secon
[
MAX_SECON_LEN
]
;
char
*
secon
;
#endif // WITH_SELINUX
int
pid
;
int
crashCnt
;
...
...
services/init/init_common_service.c
浏览文件 @
dc6c151d
...
...
@@ -171,7 +171,7 @@ static int WritePid(const Service *service)
void
SetSecon
(
Service
*
service
)
{
#ifdef WITH_SELINUX
if
(
*
(
service
->
secon
)
)
{
if
(
service
->
secon
!=
NULL
)
{
if
(
setexeccon
(
service
->
secon
)
<
0
)
{
INIT_LOGE
(
"failed to set service %s's secon (%s)."
,
service
->
name
,
service
->
secon
);
_exit
(
PROCESS_EXIT_CODE
);
...
...
services/init/init_service_manager.c
浏览文件 @
dc6c151d
...
...
@@ -93,6 +93,11 @@ void DumpOneService(const Service *service)
int
size
=
0
;
const
InitArgInfo
*
statusMap
=
GetServieStatusMap
(
&
size
);
printf
(
"
\t
service name: [%s]
\n
"
,
service
->
name
);
#ifdef WITH_SELINUX
if
(
service
->
secon
!=
NULL
)
{
printf
(
"
\t
service secon: [%s]
\n
"
,
service
->
secon
);
}
#endif
printf
(
"
\t
service pid: [%d]
\n
"
,
service
->
pid
);
printf
(
"
\t
service crashCnt: [%d]
\n
"
,
service
->
crashCnt
);
printf
(
"
\t
service attribute: [%d]
\n
"
,
service
->
attribute
);
...
...
@@ -204,6 +209,12 @@ void ReleaseService(Service *service)
if
(
service
==
NULL
)
{
return
;
}
#ifdef WITH_SELINUX
if
(
service
->
secon
!=
NULL
)
{
free
(
service
->
secon
);
service
->
secon
=
NULL
;
}
#endif
FreeServiceArg
(
&
service
->
pathArgs
);
FreeServiceArg
(
&
service
->
writePidArgs
);
FreeServiceArg
(
&
service
->
capsArgs
);
...
...
@@ -788,7 +799,12 @@ int ParseOneService(const cJSON *curItem, Service *service)
INIT_CHECK_RETURN_VALUE
(
curItem
!=
NULL
&&
service
!=
NULL
,
SERVICE_FAILURE
);
int
ret
=
0
;
#ifdef WITH_SELINUX
(
void
)
GetStringItem
(
curItem
,
SECON_STR_IN_CFG
,
service
->
secon
,
MAX_SECON_LEN
);
size_t
strLen
=
0
;
char
*
fieldStr
=
GetStringValue
(
curItem
,
SECON_STR_IN_CFG
,
&
strLen
);
if
(
fieldStr
!=
NULL
)
{
service
->
secon
=
strdup
(
fieldStr
);
INIT_ERROR_CHECK
(
service
->
secon
!=
NULL
,
return
-
1
,
"Failed to get secon for service %s"
,
service
->
name
);
}
#endif // WITH_SELINUX
ret
=
GetServiceArgs
(
curItem
,
"path"
,
MAX_PATH_ARGS_CNT
,
&
service
->
pathArgs
);
INIT_ERROR_CHECK
(
ret
==
0
,
return
SERVICE_FAILURE
,
"Failed to get path for service %s"
,
service
->
name
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录