diff --git a/services/init/standard/init_cmds.c b/services/init/standard/init_cmds.c index 60a565d2b5ba7485e8842e9bf7c6b1143c5ad686..32894b551109ce7d5713b48f8a3a6ae0dd40a361 100755 --- a/services/init/standard/init_cmds.c +++ b/services/init/standard/init_cmds.c @@ -182,18 +182,29 @@ static void DoExec(const struct CmdArgs *ctx) INIT_ERROR_CHECK(ctx != NULL && ctx->argv[0] != NULL, _exit(0x7f), "DoExec: invalid arguments to exec \"%s\"", ctx->argv[0]); #ifdef SUPPORT_PROFILER_HIDEBUG - void* handle = dlopen("/system/lib/libhidebug.so", RTLD_LAZY); - if (handle == NULL) { - INIT_LOGE("Failed to dlopen libhidebug.so, %s\n", dlerror()); - return; - } - bool (* initParam)(); - initParam = (bool (*)())dlsym(handle, "InitEnvironmentParam"); - if (initParam == NULL) { - INIT_LOGE("Failed to dlsym InitEnvironmentParam, %s\n", dlerror()); - return; - } - (*initParam)(ctx->argv[0]); + do { + if (access("/system/lib/libhidebug.so", F_OK) != 0) { + INIT_LOGE("access failed, errno = %d\n", errno); + break; + } + void* handle = dlopen("/system/lib/libhidebug.so", RTLD_LAZY); + if (handle == NULL) { + INIT_LOGE("Failed to dlopen libhidebug.so, %s\n", dlerror()); + break; + } + bool (* initParam)(); + initParam = (bool (*)())dlsym(handle, "InitEnvironmentParam"); + if (initParam == NULL) { + INIT_LOGE("Failed to dlsym InitEnvironmentParam, %s\n", dlerror()); + dlclose(handle); + break; + } + bool ret = (*initParam)(ctx->argv[0]); + if (!ret) { + INIT_LOGE("init parameters failed.\n"); + } + dlclose(handle); + } while (0); #endif int ret = execv(ctx->argv[0], ctx->argv); if (ret == -1) { diff --git a/services/init/standard/init_service.c b/services/init/standard/init_service.c index cb0ca69697a6d613f8e916cdb63566eb4ffcf012..d627f4e46676f79448f7578617e493764275a7b1 100755 --- a/services/init/standard/init_service.c +++ b/services/init/standard/init_service.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "init_group_manager.h" #include "init.h" @@ -87,18 +88,29 @@ int ServiceExec(const Service *service) } INIT_CHECK_ONLY_ELOG(unsetenv("UV_THREADPOOL_SIZE") == 0, "set UV_THREADPOOL_SIZE error : %d.", errno); #ifdef SUPPORT_PROFILER_HIDEBUG - void* handle = dlopen("/system/lib/libhidebug.so", RTLD_LAZY); - if (handle == NULL) { - INIT_LOGE("Failed to dlopen libhidebug.so, %s\n", dlerror()); - return SERVICE_FAILURE; - } - bool (* initParam)(); - initParam = (bool (*)())dlsym(handle, "InitEnvironmentParam"); - if (initParam == NULL) { - INIT_LOGE("Failed to dlsym InitEnvironmentParam, %s\n", dlerror()); - return SERVICE_FAILURE; - } - (*initParam)(service->name); + do { + if (access("/system/lib/libhidebug.so", F_OK) != 0) { + INIT_LOGE("access failed, errno = %d\n", errno); + break; + } + void* handle = dlopen("/system/lib/libhidebug.so", RTLD_LAZY); + if (handle == NULL) { + INIT_LOGE("Failed to dlopen libhidebug.so, %s\n", dlerror()); + break; + } + bool (* initParam)(); + initParam = (bool (*)())dlsym(handle, "InitEnvironmentParam"); + if (initParam == NULL) { + INIT_LOGE("Failed to dlsym InitEnvironmentParam, %s\n", dlerror()); + dlclose(handle); + break; + } + bool ret = (*initParam)(service->name); + if (!ret) { + INIT_LOGE("init parameters failed.\n"); + } + dlclose(handle); + } while (0); #endif // L2 Can not be reset env if (service->extraArgs.argv != NULL && service->extraArgs.count > 0) { diff --git a/services/param/watcher/agent/watcher_manager_proxy.cpp b/services/param/watcher/agent/watcher_manager_proxy.cpp index 7e46b67310d99eba318e8390b8d069d29449f610..701dfcbb9f772aa8b98ab1569fac2419b0bab358 100755 --- a/services/param/watcher/agent/watcher_manager_proxy.cpp +++ b/services/param/watcher/agent/watcher_manager_proxy.cpp @@ -25,6 +25,7 @@ uint32_t WatcherManagerProxy::AddWatcher(const std::string &keyPrefix, const spt WATCHER_CHECK(remote != nullptr, return 0, "Can not get remote"); MessageParcel data; + data.WriteInterfaceToken(WatcherManagerProxy::GetDescriptor()); data.WriteString(keyPrefix); bool ret = data.WriteRemoteObject(watcher->AsObject()); WATCHER_CHECK(ret, return 0, "Can not get remote"); @@ -42,6 +43,7 @@ int32_t WatcherManagerProxy::DelWatcher(const std::string &keyPrefix, uint32_t w WATCHER_CHECK(remote != nullptr, return ERR_FLATTEN_OBJECT, "Can not get remote"); MessageParcel data; + data.WriteInterfaceToken(WatcherManagerProxy::GetDescriptor()); data.WriteString(keyPrefix); data.WriteUint32(watcherId); MessageParcel reply; diff --git a/services/param/watcher/agent/watcher_stub.cpp b/services/param/watcher/agent/watcher_stub.cpp index 3bc29a0251d719cae9c8db51457de2c4f790252a..c3cc3da2829054f8e046295ba6fcbab0e71ab1ca 100755 --- a/services/param/watcher/agent/watcher_stub.cpp +++ b/services/param/watcher/agent/watcher_stub.cpp @@ -22,6 +22,10 @@ namespace OHOS { namespace init_param { int32_t WatcherStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { + std::u16string myDescripter = IWatcher::GetDescriptor(); + std::u16string remoteDescripter = data.ReadInterfaceToken(); + WATCHER_CHECK(myDescripter == remoteDescripter, return -1, "Invalid remoteDescripter"); + switch (code) { case PARAM_CHANGE: { std::string name = data.ReadString(); diff --git a/services/param/watcher/proxy/watcher_manager_stub.cpp b/services/param/watcher/proxy/watcher_manager_stub.cpp index 6c1ecfe1e3074bac3f9f6c3c1a16e8751ca799cf..daf93a69f5840bdf5d816c97542c94e46f315d0e 100755 --- a/services/param/watcher/proxy/watcher_manager_stub.cpp +++ b/services/param/watcher/proxy/watcher_manager_stub.cpp @@ -21,6 +21,10 @@ namespace init_param { int32_t WatcherManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { + std::u16string myDescripter = IWatcherManager::GetDescriptor(); + std::u16string remoteDescripter = data.ReadInterfaceToken(); + WATCHER_CHECK(myDescripter == remoteDescripter, return -1, "Invalid remoteDescripter"); + switch (code) { case ADD_WATCHER: { std::string key = data.ReadString(); diff --git a/services/param/watcher/proxy/watcher_proxy.cpp b/services/param/watcher/proxy/watcher_proxy.cpp index e01d279a49b7bed5c544a41f0a0a024d1e7c9997..ae2fe81eb81beb926551c3b0b882e101eeb13e23 100755 --- a/services/param/watcher/proxy/watcher_proxy.cpp +++ b/services/param/watcher/proxy/watcher_proxy.cpp @@ -32,6 +32,7 @@ void WatcherProxy::OnParamerterChange(const std::string &name, const std::string auto remote = Remote(); WATCHER_CHECK(remote != nullptr, return, "Can not get remote"); + data.WriteInterfaceToken(WatcherProxy::GetDescriptor()); data.WriteString(name); data.WriteString(value); int ret = remote->SendRequest(PARAM_CHANGE, data, reply, option);