Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
a2e15a94
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看板
未验证
提交
a2e15a94
编写于
2月 22, 2022
作者:
O
openharmony_ci
提交者:
Gitee
2月 22, 2022
浏览文件
操作
浏览文件
下载
差异文件
!336 动态文件标签适配
Merge pull request !336 from dapaodexiaoyu2/master
上级
814ebf05
2166750e
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
57 addition
and
7 deletion
+57
-7
services/init/init_common_cmds.c
services/init/init_common_cmds.c
+10
-0
services/init/standard/init.c
services/init/standard/init.c
+6
-3
services/init/standard/init_cmds.c
services/init/standard/init_cmds.c
+9
-4
ueventd/BUILD.gn
ueventd/BUILD.gn
+13
-0
ueventd/ueventd_device_handler.c
ueventd/ueventd_device_handler.c
+19
-0
未找到文件。
services/init/init_common_cmds.c
浏览文件 @
a2e15a94
...
...
@@ -36,6 +36,9 @@
#include "init_plugin_manager.h"
#include "init_service_manager.h"
#include "init_utils.h"
#ifdef WITH_SELINUX
#include "policycoreutils.h"
#endif
#include "securec.h"
static
char
*
g_fileCryptOptions
=
NULL
;
...
...
@@ -321,6 +324,13 @@ static void DoMkDir(const struct CmdArgs *ctx)
INIT_LOGE
(
"DoMkDir, failed for '%s', err %d."
,
ctx
->
argv
[
0
],
errno
);
return
;
}
#ifdef WITH_SELINUX
if
(
RestoreconRecurse
(
ctx
->
argv
[
0
]))
{
INIT_LOGE
(
"DoMkDir, Restorecon failed for '%s', err %d."
,
ctx
->
argv
[
0
],
errno
);
}
#endif
if
(
ctx
->
argc
<=
1
)
{
return
;
}
...
...
services/init/standard/init.c
浏览文件 @
a2e15a94
...
...
@@ -230,13 +230,14 @@ void SystemLoadSelinux(void)
{
#ifdef WITH_SELINUX
// load selinux policy and context
if
(
load_p
olicy
()
<
0
)
{
if
(
LoadP
olicy
()
<
0
)
{
INIT_LOGE
(
"main, load_policy failed."
);
}
else
{
INIT_LOGI
(
"main, load_policy success."
);
}
setcon
(
"u:r:init:s0"
);
(
void
)
RestoreconRecurse
(
"/dev"
);
#endif // WITH_SELINUX
}
...
...
@@ -273,6 +274,10 @@ void SystemConfig(void)
InitParamService
();
RegisterBootStateChange
(
BootStateChange
);
// load SELinux context and policy
// Do not move position!
SystemLoadSelinux
();
// parse parameters
LoadDefaultParams
(
"/system/etc/param/ohos_const"
,
LOAD_PARAM_NORMAL
);
LoadDefaultParams
(
"/vendor/etc/param"
,
LOAD_PARAM_NORMAL
);
...
...
@@ -291,8 +296,6 @@ void SystemConfig(void)
PostTrigger
(
EVENT_TRIGGER_BOOT
,
"pre-init"
,
strlen
(
"pre-init"
));
PostTrigger
(
EVENT_TRIGGER_BOOT
,
"init"
,
strlen
(
"init"
));
PostTrigger
(
EVENT_TRIGGER_BOOT
,
"post-init"
,
strlen
(
"post-init"
));
// load SELinux context and policy
SystemLoadSelinux
();
}
void
SystemRun
(
void
)
...
...
services/init/standard/init_cmds.c
浏览文件 @
a2e15a94
...
...
@@ -274,9 +274,14 @@ static void DoUmountFstabFile(const struct CmdArgs *ctx)
static
void
DoRestorecon
(
const
struct
CmdArgs
*
ctx
)
{
#ifdef WITH_SELINUX
INIT_LOGI
(
"start restorecon ......
\n
"
);
restorecon
();
INIT_LOGI
(
"finish restorecon ......
\n
"
);
if
(
ctx
->
argc
!=
1
)
{
INIT_LOGE
(
"DoRestorecon invalid arguments."
);
return
;
}
if
(
RestoreconRecurse
(
ctx
->
argv
[
0
]))
{
INIT_LOGE
(
"DoRestorecon failed for '%s', err %d."
,
ctx
->
argv
[
0
],
errno
);
}
#endif
return
;
}
...
...
@@ -498,7 +503,7 @@ static const struct CmdTable g_cmdTable[] = {
{
"ifup "
,
1
,
1
,
DoIfup
},
{
"mount_fstab "
,
1
,
1
,
DoMountFstabFile
},
{
"umount_fstab "
,
1
,
1
,
DoUmountFstabFile
},
{
"restorecon "
,
0
,
1
,
DoRestorecon
},
{
"restorecon "
,
1
,
1
,
DoRestorecon
},
{
"stopAllServices "
,
0
,
10
,
DoStopAllServices
},
{
"umount "
,
1
,
1
,
DoUmount
},
{
"sync "
,
0
,
1
,
DoSync
},
...
...
ueventd/BUILD.gn
浏览文件 @
a2e15a94
...
...
@@ -99,6 +99,12 @@ if (defined(ohos_lite)) {
include_dirs = service_ueventd_include
deps = service_ueventd_deps
defines = [ "__RAMDISK__" ]
cflags = []
if (build_selinux) {
external_deps = [ "selinux:librestorecon" ]
cflags += [ "-DWITH_SELINUX" ]
}
}
ohos_executable("ueventd") {
...
...
@@ -114,6 +120,13 @@ if (defined(ohos_lite)) {
]
deps = service_ueventd_deps
deps += [ "//base/startup/init_lite/services/param:param_client" ]
cflags = []
if (build_selinux) {
external_deps = [ "selinux:librestorecon" ]
cflags += [ "-DWITH_SELINUX" ]
}
install_images = [
"system",
"updater",
...
...
ueventd/ueventd_device_handler.c
浏览文件 @
a2e15a94
...
...
@@ -34,6 +34,9 @@
#include "securec.h"
#define INIT_LOG_TAG "ueventd"
#include "init_log.h"
#ifdef WITH_SELINUX
#include <policycoreutils.h>
#endif
static
void
CreateSymbolLinks
(
const
char
*
deviceNode
,
char
**
symLinks
)
{
...
...
@@ -79,6 +82,21 @@ static inline void AdjustDeviceNodePermissions(const char *deviceNode, uid_t uid
}
}
static
void
SetDeviceLable
(
const
char
*
dir
,
const
char
*
path
)
{
#ifdef WITH_SELINUX
int
rc
=
0
;
if
(
!
STRINGEQUAL
(
dir
,
"/dev"
))
{
rc
=
RestoreconRecurse
(
dir
);
}
rc
+=
Restorecon
(
path
);
if
(
rc
!=
0
)
{
INIT_LOGI
(
"restorecon device node[%s] failed. %d"
,
path
,
errno
);
}
#endif
}
static
int
CreateDeviceNode
(
const
struct
Uevent
*
uevent
,
const
char
*
deviceNode
,
char
**
symLinks
,
bool
isBlock
)
{
int
rc
=
-
1
;
...
...
@@ -126,6 +144,7 @@ static int CreateDeviceNode(const struct Uevent *uevent, const char *deviceNode,
if
(
symLinks
!=
NULL
)
{
CreateSymbolLinks
(
deviceNode
,
symLinks
);
}
SetDeviceLable
(
devicePath
,
deviceNode
);
// No matter what result the symbol links returns,
// as long as create device node done, just returns success.
rc
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录