!548 feat: support selinux feature switch

Merge pull request !548 from yuanbo/master
This commit is contained in:
openharmony_ci
2022-04-24 08:11:29 +00:00
committed by Gitee
2 changed files with 11 additions and 2 deletions
+5 -1
View File
@@ -67,7 +67,6 @@ ohos_executable("hdf_devmgr") {
external_deps = [
"hiviewdfx_hilog_native:libhilog",
"init:libbegetutil",
"selinux:libservice_checker",
"utils_base:utils",
]
@@ -77,6 +76,11 @@ ohos_executable("hdf_devmgr") {
"-Werror",
]
if (build_selinux) {
external_deps += [ "selinux:libservice_checker" ]
cflags += [ "-DWITH_SELINUX" ]
}
install_enable = true
install_images = [ chipset_base_dir ]
subsystem_name = "hdf"
+6 -1
View File
@@ -15,7 +15,9 @@
#include "devsvc_manager_stub.h"
#ifdef WITH_SELINUX
#include <hdf_service_checker.h>
#endif
#include "device_token_proxy.h"
#include "devmgr_service_stub.h"
@@ -32,22 +34,25 @@
static int32_t AddServicePermCheck(const char *servName)
{
#ifdef WITH_SELINUX
pid_t callingPid = HdfRemoteGetCallingPid();
if (HdfAddServiceCheck(callingPid, servName) != 0) {
HDF_LOGE("[selinux] %{public}d haven't \"add service\" permission to %{public}s", callingPid, servName);
return HDF_ERR_NOPERM;
}
#endif
return HDF_SUCCESS;
}
static int32_t GetServicePermCheck(const char *servName)
{
#ifdef WITH_SELINUX
pid_t callingPid = HdfRemoteGetCallingPid();
if (HdfGetServiceCheck(callingPid, servName) != 0) {
HDF_LOGE("[selinux] %{public}d haven't \"get service\" permission to %{public}s", callingPid, servName);
return HDF_ERR_NOPERM;
}
#endif
return HDF_SUCCESS;
}