${PROJECT_SOURCE_DIR}/src/security-manager-tests/common/policy_configuration.cpp
${PROJECT_SOURCE_DIR}/src/security-manager-tests/common/sm_commons.cpp
${PROJECT_SOURCE_DIR}/src/security-manager-tests/common/template_parser.cpp
+ ${PROJECT_SOURCE_DIR}/src/security-manager-tests/common/scoped_app_launcher.cpp
${PROJECT_SOURCE_DIR}/src/cynara-tests/common/cynara_test_client.cpp
${PROJECT_SOURCE_DIR}/src/cynara-tests/common/cynara_test_admin.cpp
${PROJECT_SOURCE_DIR}/src/cynara-tests/plugins/plugins.cpp
--- /dev/null
+/*
+ * Copyright (c) 2020 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 <scoped_app_launcher.h>
+#include <sm_api.h>
+#include <sm_commons.h>
+#include <tests_common.h>
+
+using namespace SecurityManagerTest;
+
+ScopedAppLauncher::ScopedAppLauncher(const AppInstallHelper& app)
+{
+ SynchronizationPipe syncPipe;
+
+ m_pid = fork();
+ RUNNER_ASSERT_ERRNO_MSG(m_pid >= 0, "Fork failed");
+ if (m_pid != 0) {
+ m_syncPipe.claimParentEp();
+ m_syncPipe.wait();
+ } else {
+ m_syncPipe.claimChildEp();
+
+ RUNNER_ASSERT_ERRNO_MSG(setLauncherSecurityAttributes(app.getUID(), app.getGID()) == 0,
+ "launcher failed");
+ Api::prepareAppCandidate();
+ Api::prepareApp(app.getAppId().c_str());
+
+ m_syncPipe.post();
+ m_syncPipe.wait();
+ exit(0);
+ }
+}
+
+ScopedAppLauncher::~ScopedAppLauncher()
+{
+ m_syncPipe.post();
+ waitPid(m_pid);
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 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.
+ */
+#pragma once
+
+#include <app_install_helper.h>
+#include <synchronization_pipe.h>
+
+class ScopedAppLauncher final {
+public:
+ ScopedAppLauncher(const AppInstallHelper& app);
+ ~ScopedAppLauncher();
+
+ ScopedAppLauncher(const ScopedAppLauncher&) = delete;
+ ScopedAppLauncher& operator=(const ScopedAppLauncher&) = delete;
+
+private:
+ SynchronizationPipe m_syncPipe;
+ pid_t m_pid;
+};