未验证 提交 3fb0f722 编写于 作者: O openharmony_ci 提交者: Gitee

!227 add selinux adaption for rk3568

Merge pull request !227 from dapaodexiaoyu2/master
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "ueventd_socket.h" #include "ueventd_socket.h"
#ifdef WITH_SELINUX #ifdef WITH_SELINUX
#include <policycoreutils.h> #include <policycoreutils.h>
#include <selinux/selinux.h>
#endif // WITH_SELINUX #endif // WITH_SELINUX
void SystemInit(void) void SystemInit(void)
...@@ -164,16 +165,16 @@ void SystemLoadSelinux(void) ...@@ -164,16 +165,16 @@ void SystemLoadSelinux(void)
} else { } else {
INIT_LOGI("main, load_policy success."); INIT_LOGI("main, load_policy success.");
} }
if (restorecon() < 0) {
INIT_LOGE("main, restorecon failed."); setcon("u:r:init:s0");
} else {
INIT_LOGI("main, restorecon success.");
}
#endif // WITH_SELINUX #endif // WITH_SELINUX
} }
void SystemConfig(void) void SystemConfig(void)
{ {
// load SELinux context and policy
SystemLoadSelinux();
InitParamService(); InitParamService();
// parse parameters // parse parameters
LoadDefaultParams("/system/etc/param/ohos_const", LOAD_PARAM_NORMAL); LoadDefaultParams("/system/etc/param/ohos_const", LOAD_PARAM_NORMAL);
...@@ -193,9 +194,6 @@ void SystemConfig(void) ...@@ -193,9 +194,6 @@ void SystemConfig(void)
PostTrigger(EVENT_TRIGGER_BOOT, "pre-init", strlen("pre-init")); PostTrigger(EVENT_TRIGGER_BOOT, "pre-init", strlen("pre-init"));
PostTrigger(EVENT_TRIGGER_BOOT, "init", strlen("init")); PostTrigger(EVENT_TRIGGER_BOOT, "init", strlen("init"));
PostTrigger(EVENT_TRIGGER_BOOT, "post-init", strlen("post-init")); PostTrigger(EVENT_TRIGGER_BOOT, "post-init", strlen("post-init"));
// load SELinux context and policy
SystemLoadSelinux();
} }
void SystemRun(void) void SystemRun(void)
......
...@@ -38,6 +38,9 @@ ...@@ -38,6 +38,9 @@
#include "init_service_manager.h" #include "init_service_manager.h"
#include "init_utils.h" #include "init_utils.h"
#include "securec.h" #include "securec.h"
#ifdef WITH_SELINUX
#include <policycoreutils.h>
#endif
int GetParamValue(const char *symValue, unsigned int symLen, char *paramValue, unsigned int paramLen) int GetParamValue(const char *symValue, unsigned int symLen, char *paramValue, unsigned int paramLen)
{ {
...@@ -266,6 +269,16 @@ static void DoUmountFstabFile(const struct CmdArgs *ctx) ...@@ -266,6 +269,16 @@ 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");
#endif
return;
}
static const struct CmdTable g_cmdTable[] = { static const struct CmdTable g_cmdTable[] = {
{ "exec ", 1, 10, DoExec }, { "exec ", 1, 10, DoExec },
{ "mknode ", 1, 5, DoMakeNode }, { "mknode ", 1, 5, DoMakeNode },
...@@ -279,6 +292,7 @@ static const struct CmdTable g_cmdTable[] = { ...@@ -279,6 +292,7 @@ static const struct CmdTable g_cmdTable[] = {
{ "ifup ", 1, 1, DoIfup }, { "ifup ", 1, 1, DoIfup },
{ "mount_fstab ", 1, 1, DoMountFstabFile }, { "mount_fstab ", 1, 1, DoMountFstabFile },
{ "umount_fstab ", 1, 1, DoUmountFstabFile }, { "umount_fstab ", 1, 1, DoUmountFstabFile },
{ "restorecon ", 0, 0, DoRestorecon },
}; };
const struct CmdTable *GetCmdTable(int *number) const struct CmdTable *GetCmdTable(int *number)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册