diff --git a/uhdf2/manager/BUILD.gn b/uhdf2/manager/BUILD.gn index 01448cf..1b9d139 100644 --- a/uhdf2/manager/BUILD.gn +++ b/uhdf2/manager/BUILD.gn @@ -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" diff --git a/uhdf2/manager/src/devsvc_manager_stub.c b/uhdf2/manager/src/devsvc_manager_stub.c index 3acfd02..daf0d9b 100644 --- a/uhdf2/manager/src/devsvc_manager_stub.c +++ b/uhdf2/manager/src/devsvc_manager_stub.c @@ -15,7 +15,9 @@ #include "devsvc_manager_stub.h" +#ifdef WITH_SELINUX #include +#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; }