Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
40658ceb
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看板
提交
40658ceb
编写于
9月 13, 2022
作者:
C
cheng_jinsong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix sandbox codex
Signed-off-by:
N
cheng_jinsong
<
chengjinsong2@huawei.com
>
上级
f9ff0c09
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
53 addition
and
61 deletion
+53
-61
services/init/include/init.h
services/init/include/init.h
+0
-1
services/init/include/init_service.h
services/init/include/init_service.h
+2
-0
services/init/init_common_service.c
services/init/init_common_service.c
+3
-3
services/init/lite/init.c
services/init/lite/init.c
+0
-7
services/init/lite/init_service.c
services/init/lite/init_service.c
+12
-0
services/init/standard/init.c
services/init/standard/init.c
+0
-50
services/init/standard/init_service.c
services/init/standard/init_service.c
+36
-0
未找到文件。
services/init/include/init.h
浏览文件 @
40658ceb
...
...
@@ -43,7 +43,6 @@ void SystemExecuteRcs(void);
void
ReadConfig
(
void
);
void
SignalInit
(
void
);
void
SetServiceEnterSandbox
(
const
char
*
path
,
unsigned
int
attribute
);
#ifdef __cplusplus
#if __cplusplus
...
...
services/init/include/init_service.h
浏览文件 @
40658ceb
...
...
@@ -178,7 +178,9 @@ int SetAccessToken(const Service *service);
void
GetAccessToken
(
void
);
void
ServiceStopTimer
(
Service
*
service
);
void
ServiceStartTimer
(
Service
*
service
,
uint64_t
timeout
);
void
IsEnableSandbox
(
void
);
void
EnterServiceSandbox
(
Service
*
service
);
void
SetServiceEnterSandbox
(
const
char
*
execPath
,
unsigned
int
attribute
);
#ifdef __cplusplus
#if __cplusplus
}
...
...
services/init/init_common_service.c
浏览文件 @
40658ceb
...
...
@@ -291,7 +291,7 @@ static void ClearEnvironment(Service *service)
return
;
}
static
int
InitServicePropert
y
s
(
Service
*
service
)
static
int
InitServicePropert
ie
s
(
Service
*
service
)
{
INIT_ERROR_CHECK
(
service
!=
NULL
,
return
-
1
,
"Invalid parameter."
);
SetServiceEnterSandbox
(
service
->
pathArgs
.
argv
[
0
],
service
->
attribute
);
...
...
@@ -331,7 +331,7 @@ static int InitServicePropertys(Service *service)
void
EnterServiceSandbox
(
Service
*
service
)
{
INIT_ERROR_CHECK
(
InitServicePropert
y
s
(
service
)
==
0
,
return
,
"Failed init service property"
);
INIT_ERROR_CHECK
(
InitServicePropert
ie
s
(
service
)
==
0
,
return
,
"Failed init service property"
);
if
(
service
->
importance
!=
0
)
{
if
(
setpriority
(
PRIO_PROCESS
,
0
,
service
->
importance
)
!=
0
)
{
INIT_LOGE
(
"setpriority failed for %s, importance = %d, err=%d"
,
...
...
@@ -374,7 +374,7 @@ int ServiceStart(Service *service)
int
pid
=
fork
();
if
(
pid
==
0
)
{
// fail must exit sub process
INIT_ERROR_CHECK
(
InitServicePropert
y
s
(
service
)
==
0
,
INIT_ERROR_CHECK
(
InitServicePropert
ie
s
(
service
)
==
0
,
_exit
(
PROCESS_EXIT_CODE
),
"Failed init service property"
);
ServiceExec
(
service
);
_exit
(
PROCESS_EXIT_CODE
);
...
...
services/init/lite/init.c
浏览文件 @
40658ceb
...
...
@@ -96,10 +96,3 @@ void SystemRun(void)
}
#endif
}
void
SetServiceEnterSandbox
(
const
char
*
path
,
unsigned
int
attribute
)
{
UNUSED
(
path
);
UNUSED
(
attribute
);
return
;
}
services/init/lite/init_service.c
浏览文件 @
40658ceb
...
...
@@ -95,3 +95,15 @@ void GetAccessToken(void)
{
return
;
}
void
IsEnableSandbox
(
void
)
{
return
;
}
void
SetServiceEnterSandbox
(
const
char
*
path
,
unsigned
int
attribute
)
{
UNUSED
(
path
);
UNUSED
(
attribute
);
return
;
}
services/init/standard/init.c
浏览文件 @
40658ceb
...
...
@@ -43,12 +43,8 @@
#include "ueventd.h"
#include "ueventd_socket.h"
#include "fd_holder_internal.h"
#include "sandbox.h"
#include "sandbox_namespace.h"
#include "bootstage.h"
static
bool
g_enableSandbox
;
static
int
FdHolderSockInit
(
void
)
{
int
sock
=
-
1
;
...
...
@@ -263,24 +259,6 @@ static void BootStateChange(const char *content)
}
}
static
void
IsEnableSandbox
(
void
)
{
const
char
*
name
=
"const.sandbox"
;
char
value
[
MAX_BUFFER_LEN
]
=
{
0
};
unsigned
int
len
=
MAX_BUFFER_LEN
;
if
(
SystemReadParam
(
name
,
value
,
&
len
)
!=
0
)
{
INIT_LOGE
(
"Failed read param."
);
g_enableSandbox
=
false
;
}
if
(
strcmp
(
value
,
"enable"
)
==
0
)
{
INIT_LOGI
(
"Enable sandbox."
);
g_enableSandbox
=
true
;
}
else
{
INIT_LOGI
(
"Disable sandbox."
);
g_enableSandbox
=
false
;
}
}
static
void
InitLoadParamFiles
(
void
)
{
if
(
InUpdaterMode
()
!=
0
)
{
...
...
@@ -372,31 +350,3 @@ void SystemRun(void)
{
StartParamService
();
}
void
SetServiceEnterSandbox
(
const
char
*
execPath
,
unsigned
int
attribute
)
{
if
(
g_enableSandbox
==
false
)
{
return
;
}
if
((
attribute
&
SERVICE_ATTR_WITHOUT_SANDBOX
)
==
SERVICE_ATTR_WITHOUT_SANDBOX
)
{
return
;
}
INIT_ERROR_CHECK
(
execPath
!=
NULL
,
return
,
"Service path is null."
);
if
(
strncmp
(
execPath
,
"/system/bin/"
,
strlen
(
"/system/bin/"
))
==
0
)
{
if
(
strcmp
(
execPath
,
"/system/bin/appspawn"
)
==
0
)
{
INIT_LOGI
(
"Appspawn skip enter sandbox."
);
}
else
if
(
strcmp
(
execPath
,
"/system/bin/hilogd"
)
==
0
)
{
INIT_LOGI
(
"Hilogd skip enter sandbox."
);
}
else
{
INIT_INFO_CHECK
(
EnterSandbox
(
"system"
)
==
0
,
return
,
"Service %s skip enter sandbox system."
,
execPath
);
}
}
else
if
(
strncmp
(
execPath
,
"/vendor/bin/"
,
strlen
(
"/vendor/bin/"
))
==
0
)
{
// chipset sandbox will be implemented later.
INIT_INFO_CHECK
(
EnterSandbox
(
"chipset"
)
==
0
,
return
,
"Service %s skip enter sandbox system."
,
execPath
);
}
else
{
INIT_LOGI
(
"Service %s does not enter sandbox"
,
execPath
);
}
return
;
}
services/init/standard/init_service.c
浏览文件 @
40658ceb
...
...
@@ -29,11 +29,15 @@
#include "securec.h"
#include "token_setproc.h"
#include "nativetoken_kit.h"
#include "sandbox.h"
#include "sandbox_namespace.h"
#include "service_control.h"
#define MIN_IMPORTANT_LEVEL (-20)
#define MAX_IMPORTANT_LEVEL 19
static
bool
g_enableSandbox
=
false
;
void
NotifyServiceChange
(
Service
*
service
,
int
status
)
{
INIT_LOGI
(
"NotifyServiceChange %s %d to %d"
,
service
->
name
,
service
->
status
,
status
);
...
...
@@ -130,3 +134,35 @@ void GetAccessToken(void)
node
=
GetNextGroupNode
(
NODE_TYPE_SERVICES
,
node
);
}
}
void
IsEnableSandbox
(
void
)
{
char
value
[
MAX_BUFFER_LEN
]
=
{
0
};
unsigned
int
len
=
MAX_BUFFER_LEN
;
if
(
SystemReadParam
(
"const.sandbox"
,
value
,
&
len
)
==
0
)
{
if
(
strcmp
(
value
,
"enable"
)
==
0
)
{
g_enableSandbox
=
true
;
}
}
}
void
SetServiceEnterSandbox
(
const
char
*
execPath
,
unsigned
int
attribute
)
{
if
(
g_enableSandbox
==
false
)
{
return
;
}
if
((
attribute
&
SERVICE_ATTR_WITHOUT_SANDBOX
)
==
SERVICE_ATTR_WITHOUT_SANDBOX
)
{
return
;
}
INIT_ERROR_CHECK
(
execPath
!=
NULL
,
return
,
"Service path is null."
);
if
(
strncmp
(
execPath
,
"/system/bin/"
,
strlen
(
"/system/bin/"
))
==
0
)
{
INIT_INFO_CHECK
(
EnterSandbox
(
"system"
)
==
0
,
return
,
"Service %s skip enter system sandbox."
,
execPath
);
}
else
if
(
strncmp
(
execPath
,
"/vendor/bin/"
,
strlen
(
"/vendor/bin/"
))
==
0
)
{
INIT_INFO_CHECK
(
EnterSandbox
(
"chipset"
)
==
0
,
return
,
"Service %s skip enter chipset sandbox."
,
execPath
);
}
else
{
INIT_LOGI
(
"Service %s does not enter sandbox"
,
execPath
);
}
return
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录