!2444 restore SELinux security contexts only if the folder is newly created

Merge pull request !2444 from Changbin Du/mkdir_selinux_opt
This commit is contained in:
openharmony_ci 2023-12-27 03:11:57 +00:00 committed by Gitee
commit 41e4711ca5
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -350,7 +350,13 @@ static void DoMkDir(const struct CmdArgs *ctx)
return;
}
PluginExecCmdByName("restoreContentRecurse", ctx->argv[0]);
/*
* Skip restoring default SELinux security contexts if the the folder already
* existed and its under /dev. These files will be proceed by loadSelinuxPolicy.
*/
if (errno != EEXIST || strncmp(ctx->argv[0], "/dev", strlen("/dev")) != 0) {
PluginExecCmdByName("restoreContentRecurse", ctx->argv[0]);
}
if (ctx->argc <= 1) {
return;