*/
int aul_kill_loader_for_uid(const char *loader_name, uid_t uid);
+/**
+ * @brief Sends the restart request to the running loader process.
+ * @since_tizen 8.0
+ * @details This function is to restart the loader process.
+ * If the process is running, it will be terminated and executed.
+ * @remarks This function is only available for system and user daemons.
+ * @param[in] loader_name The loader name
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #AUL_R_OK Successful
+ * @retval #AUL_R_EINVAL Invalid parameter
+ * @retval #AUL_R_ECOMM Communication error on send
+ * @retval #AUL_R_EILLACC Permission denied
+ */
+int aul_restart_loader(const char *loader_name);
+
+/**
+ * @brief Sends the restart request to the running loader process.
+ * @since_tizen 8.0
+ * @details This function is to restart the loader process.
+ * If the process is running, it will be terminated and executed.
+ * @remarks This function is only available for system and user daemons.
+ * @param[in] loader_name The loader name
+ * @param[in] uid The target uid
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #AUL_R_OK Successful
+ * @retval #AUL_R_EINVAL Invalid parameter
+ * @retval #AUL_R_ECOMM Communication error on send
+ * @retval #AUL_R_EILLACC Permission denied
+ */
+int aul_restart_loader_for_uid(const char *loader_name, uid_t uid);
+
#ifdef __cplusplus
}
#endif
constexpr const char kLaunchpadProcessPoolSock[] =
".launchpad-process-pool-sock";
const int kPadCmdKillLoader = 19;
+const int kPadCmdRestartLoader = 20;
constexpr const int TEP_ISMOUNT_MAX_RETRY_CNT = 20;
class ResultInfo {
return AUL_R_OK;
}
+
+extern "C" API int aul_restart_loader(const char* loader_name) {
+ return aul_restart_loader_for_uid(loader_name, getuid());
+}
+
+extern "C" API int aul_restart_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, kPadCmdRestartLoader,
+ b.GetHandle(), AUL_SOCK_NOREPLY);
+ if (ret != AUL_R_OK)
+ return aul_error_convert(ret);
+
+ return AUL_R_OK;
+}
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+
+#include "include/aul.h"
+
+#include "aul_test.hh"
+#include "log_private.hh"
+
+namespace aul_test {
+
+class AulRestartLoaderTest : public AulTest {
+ public:
+ AulRestartLoaderTest()
+ : AulTest("restart_loader", "aul_restart_loader",
+ "restart_loader <loader_name>") {
+ }
+
+ virtual ~AulRestartLoaderTest() {}
+
+ void SetUp() override {}
+
+ void TearDown() override {}
+
+ int Test(int argc, char** argv) override {
+ if (argc < 3) {
+ Usage();
+ return -1;
+ }
+
+ _D("[aul_restart_loader test] %s", argv[2]);
+ return aul_restart_loader(argv[2]);
+ }
+};
+
+AUL_TEST_REGISTER(AulRestartLoaderTest, restart_loader_test);
+
+} // namespace aul_test