提交 ced343a5 编写于 作者: H handyohos

bugfix: setcon according to actual process name

setcon according to actual process name
Signed-off-by: Nhandyohos <zhangxiaotian@huawei.com>
Change-Id: I6435824ec0b97c954532993c65f9b4ca840de873

#I64HB9
上级 24e8d21a
......@@ -19,6 +19,7 @@
#include "init_hook.h"
#include "init_module_engine.h"
#include "plugin_adapter.h"
#include "securec.h"
#include <policycoreutils.h>
#include <selinux/selinux.h>
......@@ -30,8 +31,13 @@ enum {
CMD_RESTORE_INDEX = 3,
};
extern char *__progname;
static int LoadSelinuxPolicy(int id, const char *name, int argc, const char **argv)
{
int ret;
char process_context[MAX_SECON_LEN];
UNUSED(id);
UNUSED(name);
UNUSED(argc);
......@@ -44,7 +50,12 @@ static int LoadSelinuxPolicy(int id, const char *name, int argc, const char **ar
PLUGIN_LOGI("main, load_policy success.");
}
setcon("u:r:init:s0");
ret = snprintf_s(process_context, sizeof(process_context), sizeof(process_context) - 1, "u:r:%s:s0", __progname);
if (ret == -1) {
setcon("u:r:init:s0");
} else {
setcon(process_context);
}
(void)RestoreconRecurse("/dev");
return 0;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册