utd 动态添加selinux 文件标签

Signed-off-by: genglingxia <genglingxia3@huawei.com>
This commit is contained in:
genglingxia 2024-01-05 17:13:47 +08:00
parent a22c906250
commit 046278a99a
3 changed files with 18 additions and 2 deletions

View File

@ -35,7 +35,8 @@
"kv_store",
"napi",
"samgr",
"app_file_service"
"app_file_service",
"selinux_adapter"
],
"third_party": [
"bounds_checking_function",

View File

@ -18,6 +18,9 @@
#include "unistd.h"
#include "error_code.h"
#include "logger.h"
#ifdef WITH_SELINUX
#include <policycoreutils.h>
#endif
namespace OHOS {
namespace UDMF {
constexpr const char* UTD_CFG_FILE = "utd-adt.json";
@ -102,7 +105,14 @@ bool CustomUtdStore::CreateDirectory(const std::string &path) const
}
} while (index != std::string::npos);
return access(path.c_str(), F_OK) == 0;
if (access(path.c_str(), F_OK) == 0) {
#ifdef WITH_SELINUX
Restorecon(path.c_str());
#endif
return true;
}
return false;
}
} // namespace UDMF
} // namespace OHOS

View File

@ -94,4 +94,9 @@ ohos_shared_library("udmf_client") {
subsystem_name = "distributeddatamgr"
part_name = "udmf"
if (build_selinux) {
cflags = [ "-DWITH_SELINUX" ]
external_deps += [ "selinux_adapter:librestorecon" ]
}
}