X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Flaunch.cc;h=18166447d56efb25954c157d783c7db838260de8;hb=9d0ea4da9a97b93b156bac802f7ba386c70c857c;hp=fffa4370fa9adf00d64c911f16762b54360d7cd5;hpb=70747d724d024fae37397519b8005dc9a80e9c2d;p=platform%2Fcore%2Fappfw%2Faul-1.git diff --git a/src/launch.cc b/src/launch.cc index fffa437..1816644 100644 --- a/src/launch.cc +++ b/src/launch.cc @@ -29,7 +29,9 @@ #include #include +#include #include +#include #include #include "app_request.h" @@ -46,6 +48,10 @@ using namespace aul::internal; namespace { +constexpr const char kRunAulDaemonsPath[] = "/run/aul/daemons/"; +constexpr const char kLaunchpadProcessPoolSock[] = + ".launchpad-process-pool-sock"; +const int kPadCmdKillLoader = 19; constexpr const int TEP_ISMOUNT_MAX_RETRY_CNT = 20; class ResultInfo { @@ -861,3 +867,41 @@ extern "C" API int aul_kill_pid_async(pid_t pid, return AUL_R_OK; } + +extern "C" API int aul_kill_loader(const char* loader_name) { + return aul_kill_loader_for_uid(loader_name, getuid()); +} + +extern "C" API int aul_kill_loader_for_uid(const char* loader_name, + uid_t uid) { + if (loader_name == nullptr) { + _E("Invalid parameter"); + return AUL_R_EINVAL; + } + + if (uid < REGULAR_UID_MIN) { + uid = tzplatform_getuid(TZ_SYS_DEFAULT_USER); + _W("Use system default user ID(%u)", uid); + } + + std::string endpoint = kRunAulDaemonsPath + std::to_string(uid) + "/" + + std::string(kLaunchpadProcessPoolSock); + if (!std::filesystem::exists(endpoint)) { + _E("launchpad socket is not prepared"); + return AUL_R_ENOENT; + } + + int fd = aul_sock_create_launchpad_client(kLaunchpadProcessPoolSock, uid); + if (fd < 0) { + _E("Failed to create launchpad client socket. error(%d)", fd); + return aul_error_convert(fd); + } + + tizen_base::Bundle b = { {AUL_K_LOADER_NAME, loader_name} }; + int ret = aul_sock_send_bundle_with_fd(fd, kPadCmdKillLoader, b.GetHandle(), + AUL_SOCK_NOREPLY); + if (ret != AUL_R_OK) + return aul_error_convert(ret); + + return AUL_R_OK; +}