mirror of
https://github.com/openharmony/drivers_adapter.git
synced 2026-07-19 18:23:38 -04:00
!548 feat: support selinux feature switch
Merge pull request !548 from yuanbo/master
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user