Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
d4112e3b
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看板
未验证
提交
d4112e3b
编写于
6月 25, 2022
作者:
O
openharmony_ci
提交者:
Gitee
6月 25, 2022
浏览文件
操作
浏览文件
下载
差异文件
!854 system/chipset sandbox support ignore errors
Merge pull request !854 from handy/0625
上级
f4fc9cfc
6c8a356f
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
61 addition
and
22 deletion
+61
-22
interfaces/innerkits/sandbox/chipset-sandbox.json
interfaces/innerkits/sandbox/chipset-sandbox.json
+8
-4
interfaces/innerkits/sandbox/chipset-sandbox64.json
interfaces/innerkits/sandbox/chipset-sandbox64.json
+9
-5
interfaces/innerkits/sandbox/include/sandbox.h
interfaces/innerkits/sandbox/include/sandbox.h
+1
-0
interfaces/innerkits/sandbox/sandbox.c
interfaces/innerkits/sandbox/sandbox.c
+21
-4
interfaces/innerkits/sandbox/system-sandbox.json
interfaces/innerkits/sandbox/system-sandbox.json
+10
-5
interfaces/innerkits/sandbox/system-sandbox64.json
interfaces/innerkits/sandbox/system-sandbox64.json
+12
-4
未找到文件。
interfaces/innerkits/sandbox/chipset-sandbox.json
浏览文件 @
d4112e3b
...
...
@@ -19,15 +19,18 @@
},
{
"src-path"
:
"/system/app"
,
"sandbox-path"
:
"/system/app"
,
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
]
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
],
"ignore"
:
1
},
{
"src-path"
:
"/system/fonts"
,
"sandbox-path"
:
"/system/fonts"
,
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
]
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
],
"ignore"
:
1
},
{
"src-path"
:
"/system/usr"
,
"sandbox-path"
:
"/system/usr"
,
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
]
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
],
"ignore"
:
1
},
{
"src-path"
:
"/vendor"
,
"sandbox-path"
:
"/vendor"
,
...
...
@@ -47,7 +50,8 @@
},
{
"src-path"
:
"/sys/kernel/debug/tracing"
,
"sandbox-path"
:
"/sys/kernel/debug/tracing"
,
"sandbox-flags"
:
[
"bind"
,
"private"
]
"sandbox-flags"
:
[
"bind"
,
"private"
],
"ignore"
:
1
},
{
"src-path"
:
"/sys/kernel/debug"
,
"sandbox-path"
:
"/sys/kernel/debug"
,
...
...
interfaces/innerkits/sandbox/chipset-sandbox64.json
浏览文件 @
d4112e3b
...
...
@@ -23,15 +23,18 @@
},
{
"src-path"
:
"/system/app"
,
"sandbox-path"
:
"/system/app"
,
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
]
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
],
"ignore"
:
1
},
{
"src-path"
:
"/system/fonts"
,
"sandbox-path"
:
"/system/fonts"
,
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
]
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
],
"ignore"
:
1
},
{
"src-path"
:
"/system/usr"
,
"sandbox-path"
:
"/system/usr"
,
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
]
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
],
"ignore"
:
1
},
{
"src-path"
:
"/vendor"
,
"sandbox-path"
:
"/vendor"
,
...
...
@@ -51,12 +54,13 @@
},
{
"src-path"
:
"/sys/kernel/debug/tracing"
,
"sandbox-path"
:
"/sys/kernel/debug/tracing"
,
"sandbox-flags"
:
[
"bind"
,
"private"
]
"sandbox-flags"
:
[
"bind"
,
"private"
],
"ignore"
:
1
},
{
"src-path"
:
"/sys/kernel/debug"
,
"sandbox-path"
:
"/sys/kernel/debug"
,
"sandbox-flags"
:
[
"bind"
,
"private"
]
},
{
},
{
"src-path"
:
"/sys"
,
"sandbox-path"
:
"/sys"
,
"sandbox-flags"
:
[
"bind"
,
"private"
]
...
...
interfaces/innerkits/sandbox/include/sandbox.h
浏览文件 @
d4112e3b
...
...
@@ -26,6 +26,7 @@ typedef struct {
char
*
source
;
// source 目录,一般是全局的fs 目录
char
*
target
;
// 沙盒化后的目录
unsigned
long
flags
;
bool
ignoreErrors
;
}
mount_t
;
typedef
struct
MountList
{
...
...
interfaces/innerkits/sandbox/sandbox.c
浏览文件 @
d4112e3b
...
...
@@ -20,6 +20,7 @@
#include <unistd.h>
#include <sched.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <errno.h>
...
...
@@ -35,6 +36,7 @@
#define SANDBOX_SOURCE "src-path"
#define SANDBOX_TARGET "sandbox-path"
#define SANDBOX_FLAGS "sandbox-flags"
#define SANDBOX_IGNORE_ERRORS "ignore"
#define SANDBOX_SYMLINK_TAG "symbol-links"
#define SANDBOX_SYMLINK_TARGET "target-name"
#define SANDBOX_SYMLINK_NAME "link-name"
...
...
@@ -152,6 +154,10 @@ static int AddMountInfoToSandbox(sandbox_t *sandbox, cJSON *item, const char *ty
BEGET_ERROR_CHECK
(
tmpMount
->
info
!=
NULL
,
free
(
tmpMount
);
return
-
1
,
"Failed calloc err=%d"
,
errno
);
tmpMount
->
info
->
source
=
strdup
(
srcPath
);
tmpMount
->
info
->
target
=
strdup
(
dstPath
);
tmpMount
->
info
->
ignoreErrors
=
false
;
if
(
cJSON_GetNumberValue
(
cJSON_GetObjectItem
(
item
,
SANDBOX_IGNORE_ERRORS
)))
{
tmpMount
->
info
->
ignoreErrors
=
true
;
}
for
(
int
i
=
0
;
i
<
count
;
i
++
)
{
cJSON
*
item
=
cJSON_GetArrayItem
(
obj
,
i
);
tmpMount
->
info
->
flags
|=
GetSandboxMountFlags
(
item
);
...
...
@@ -298,10 +304,13 @@ static void InitSandbox(sandbox_t *sandbox, const char *sandboxConfig, const cha
static
int
CheckAndMakeDir
(
const
char
*
dir
,
mode_t
mode
)
{
if
(
access
(
dir
,
F_OK
)
==
0
)
{
struct
stat
sb
;
if
((
stat
(
dir
,
&
sb
)
==
0
)
&&
S_ISDIR
(
sb
.
st_mode
))
{
BEGET_LOGW
(
"Mount point
\'
%s
\'
already exist"
,
dir
);
return
0
;
}
else
{
BEGET_LOGI
(
"Ready to create dir [%s] now ..."
,
dir
);
if
(
errno
==
ENOENT
)
{
BEGET_ERROR_CHECK
(
MakeDirRecursive
(
dir
,
mode
)
==
0
,
return
-
1
,
"Failed MakeDirRecursive %s, err=%d"
,
dir
,
errno
);
...
...
@@ -323,7 +332,7 @@ static int BindMount(const char *source, const char *target, unsigned long flags
unsigned
long
tmpflags
=
flags
;
mode_t
mode
=
S_IRWXU
|
S_IRGRP
|
S_IXGRP
|
S_IROTH
|
S_IXOTH
;
if
(
tag
==
SANDBOX_TAG_MOUNT_PATH
)
{
BEGET_ERROR_CHECK
(
CheckAndMakeDir
(
target
,
mode
)
==
0
,
return
-
1
,
"Failed make %s dir."
,
target
);
CheckAndMakeDir
(
target
,
mode
);
}
else
if
(
tag
==
SANDBOX_TAG_MOUNT_FILE
)
{
BEGET_ERROR_CHECK
(
CheckAndCreatFile
(
target
,
mode
)
==
0
,
return
-
1
,
"Failed make %s file."
,
target
);
}
else
{
...
...
@@ -366,6 +375,7 @@ static int MountSandboxInfo(const mountlist_t *mounts, const char *rootPath, San
if
(
mounts
==
NULL
)
{
return
0
;
}
BEGET_LOGI
(
"MountSandboxInfo now ..."
);
BEGET_CHECK
(
mounts
->
info
!=
NULL
,
return
0
);
while
(
mounts
!=
NULL
)
{
mount_t
*
mount
=
mounts
->
info
;
...
...
@@ -373,9 +383,16 @@ static int MountSandboxInfo(const mountlist_t *mounts, const char *rootPath, San
char
target
[
PATH_MAX
]
=
{};
BEGET_ERROR_CHECK
(
!
(
snprintf_s
(
target
,
PATH_MAX
,
PATH_MAX
-
1
,
"%s%s"
,
rootPath
,
mount
->
target
)
<
0
),
return
-
1
,
"Failed snprintf_s err=%d"
,
errno
);
BEGET_LOGI
(
"Do BindMount from [%s] to [%s] now ..."
,
source
,
target
);
int
rc
=
BindMount
(
source
,
target
,
mount
->
flags
,
tag
);
BEGET_ERROR_CHECK
(
rc
==
0
,
return
-
1
,
"Failed bind mount %s to %s."
,
source
,
target
);
mounts
=
mounts
->
next
;
if
(
rc
!=
0
)
{
BEGET_LOGW
(
"Failed bind mount %s to %s."
,
source
,
target
);
}
if
(
mount
->
ignoreErrors
)
{
mounts
=
mounts
->
next
;
continue
;
}
return
-
1
;
}
return
0
;
}
...
...
interfaces/innerkits/sandbox/system-sandbox.json
浏览文件 @
d4112e3b
...
...
@@ -19,15 +19,18 @@
},
{
"src-path"
:
"/system/app"
,
"sandbox-path"
:
"/system/app"
,
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
]
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
],
"ignore"
:
1
},
{
"src-path"
:
"/system/fonts"
,
"sandbox-path"
:
"/system/fonts"
,
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
]
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
],
"ignore"
:
1
},
{
"src-path"
:
"/system/usr"
,
"sandbox-path"
:
"/system/usr"
,
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
]
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
],
"ignore"
:
1
},
{
"src-path"
:
"/vendor"
,
"sandbox-path"
:
"/vendor"
,
...
...
@@ -47,7 +50,8 @@
},
{
"src-path"
:
"/sys/kernel/debug/tracing"
,
"sandbox-path"
:
"/sys/kernel/debug/tracing"
,
"sandbox-flags"
:
[
"bind"
,
"private"
]
"sandbox-flags"
:
[
"bind"
,
"private"
],
"ignore"
:
1
},
{
"src-path"
:
"/sys/kernel/debug"
,
"sandbox-path"
:
"/sys/kernel/debug"
,
...
...
@@ -59,7 +63,8 @@
},
{
"src-path"
:
"/config"
,
"sandbox-path"
:
"/config"
,
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
]
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
],
"ignore"
:
1
},
{
"src-path"
:
"/mnt"
,
"sandbox-path"
:
"/mnt"
,
...
...
interfaces/innerkits/sandbox/system-sandbox64.json
浏览文件 @
d4112e3b
...
...
@@ -23,15 +23,18 @@
},
{
"src-path"
:
"/system/app"
,
"sandbox-path"
:
"/system/app"
,
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
]
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
],
"ignore"
:
1
},
{
"src-path"
:
"/system/fonts"
,
"sandbox-path"
:
"/system/fonts"
,
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
]
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
],
"ignore"
:
1
},
{
"src-path"
:
"/system/usr"
,
"sandbox-path"
:
"/system/usr"
,
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
]
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
],
"ignore"
:
1
},
{
"src-path"
:
"/vendor"
,
"sandbox-path"
:
"/vendor"
,
...
...
@@ -48,6 +51,11 @@
"src-path"
:
"/data"
,
"sandbox-path"
:
"/data"
,
"sandbox-flags"
:
[
"bind"
,
"rec"
,
"private"
]
},
{
"src-path"
:
"/sys/kernel/debug/tracing"
,
"sandbox-path"
:
"/sys/kernel/debug/tracing"
,
"sandbox-flags"
:
[
"bind"
,
"private"
],
"ignore"
:
1
},
{
"src-path"
:
"/sys/kernel/debug/tracing"
,
"sandbox-path"
:
"/sys/kernel/debug/tracing"
,
...
...
@@ -56,7 +64,7 @@
"src-path"
:
"/sys/kernel/debug"
,
"sandbox-path"
:
"/sys/kernel/debug"
,
"sandbox-flags"
:
[
"bind"
,
"private"
]
},
{
},
{
"src-path"
:
"/sys"
,
"sandbox-path"
:
"/sys"
,
"sandbox-flags"
:
[
"bind"
,
"private"
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录