Rename policyd to vist-policy
authorSangwan Kwon <sangwan.kwon@samsung.com>
Wed, 30 Oct 2019 06:53:03 +0000 (15:53 +0900)
committer권상완/Security 2Lab(SR)/Engineer/삼성전자 <sangwan.kwon@samsung.com>
Fri, 8 Nov 2019 05:39:18 +0000 (14:39 +0900)
Signed-off-by: Sangwan Kwon <sangwan.kwon@samsung.com>
36 files changed:
CMake/Macro.cmake
packaging/vist.spec
plugins/bluetooth/bluetooth.cpp
plugins/wifi/wifi.cpp
src/CMakeLists.txt
src/osquery/CMakeLists.txt
src/osquery/tables/tizen/policy.cpp
src/osquery/tables/tizen/policy_admin.cpp
src/osquery/tables/tizen/tests/policy_tests.cpp
src/policyd/CMakeLists.txt [deleted file]
src/policyd/sdk/CMakeLists.txt [deleted file]
src/vist/CMakeLists.txt
src/vist/client/tests/client-tests.cpp [moved from src/vist/client/tests/client_tests.cpp with 100% similarity]
src/vist/client/tests/virtual-table-tests.cpp [moved from src/vist/client/tests/virtual_table_tests.cpp with 100% similarity]
src/vist/common/CMakeLists.txt [deleted file]
src/vist/common/ipc/tests/ipc_tests.cpp
src/vist/notification/tests/notification-tests.cpp [moved from src/vist/notification/tests/notification_tests.cpp with 100% similarity]
src/vist/policy/CMakeLists.txt [moved from src/policyd/core/CMakeLists.txt with 55% similarity]
src/vist/policy/api.h [moved from src/policyd/api.h with 90% similarity]
src/vist/policy/core/api.cpp [moved from src/policyd/core/api.cpp with 92% similarity]
src/vist/policy/core/db-schema.h [moved from src/policyd/core/db-schema.h with 92% similarity]
src/vist/policy/core/policy-loader.cpp [moved from src/policyd/core/policy-loader.cpp with 95% similarity]
src/vist/policy/core/policy-loader.h [moved from src/policyd/core/policy-loader.h with 91% similarity]
src/vist/policy/core/policy-manager.cpp [moved from src/policyd/core/policy-manager.cpp with 98% similarity]
src/vist/policy/core/policy-manager.h [moved from src/policyd/core/policy-manager.h with 92% similarity]
src/vist/policy/core/policy-storage.cpp [moved from src/policyd/core/policy-storage.cpp with 98% similarity]
src/vist/policy/core/policy-storage.h [moved from src/policyd/core/policy-storage.h with 95% similarity]
src/vist/policy/core/tests/core-tests.cpp [moved from src/policyd/core/tests/core-tests.cpp with 94% similarity]
src/vist/policy/core/tests/storage-tests.cpp [moved from src/policyd/core/tests/storage-tests.cpp with 99% similarity]
src/vist/policy/sdk/domain-policy.h [moved from src/policyd/sdk/domain-policy.h with 95% similarity]
src/vist/policy/sdk/global-policy.h [moved from src/policyd/sdk/global-policy.h with 95% similarity]
src/vist/policy/sdk/policy-model.h [moved from src/policyd/sdk/policy-model.h with 94% similarity]
src/vist/policy/sdk/policy-provider.h [moved from src/policyd/sdk/policy-provider.h with 95% similarity]
src/vist/policy/sdk/policy-value.h [moved from src/policyd/sdk/policy-value.h with 94% similarity]
src/vist/policy/sdk/tests/sdk-tests.cpp [moved from src/policyd/sdk/tests/sdk-tests.cpp with 98% similarity]
src/vist/service/tests/core-tests.cpp [moved from src/vist/service/tests/core_tests.cpp with 94% similarity]

index 580b6f1..4c0d54b 100644 (file)
@@ -29,35 +29,24 @@ MACRO(ADD_OSQUERY_LINK)
        SET(${TARGET_OSQUERY_LIB}_DEPS ${${TARGET_OSQUERY_LIB}_DEPS} PARENT_SCOPE)
 ENDMACRO(ADD_OSQUERY_LINK)
 
-## VIST  #####################
+## ViST  #####################
 MACRO(ADD_VIST_LIBRARY TARGET)
        ADD_LIBRARY(${TARGET} OBJECT ${ARGN})
        LIST(APPEND ${TARGET_VIST_LIB}_SRCS $<TARGET_OBJECTS:${TARGET}>)
        SET(${TARGET_VIST_LIB}_SRCS ${${TARGET_VIST_LIB}_SRCS} PARENT_SCOPE)
 ENDMACRO(ADD_VIST_LIBRARY)
 
+MACRO(ADD_VIST_POLICY_LIBRARY TARGET)
+       ADD_LIBRARY(${TARGET} OBJECT ${ARGN})
+       LIST(APPEND ${TARGET_VIST_POLICY_LIB}_SRCS $<TARGET_OBJECTS:${TARGET}>)
+       SET(${TARGET_VIST_POLICY_LIB}_SRCS ${${TARGET_VIST_POLICY_LIB}_SRCS} PARENT_SCOPE)
+ENDMACRO(ADD_VIST_LIBRARY)
+
 MACRO(ADD_VIST_TEST)
        LIST(APPEND ${TARGET_VIST_LIB}_TESTS ${ARGN})
        SET(${TARGET_VIST_LIB}_TESTS ${${TARGET_VIST_LIB}_TESTS} PARENT_SCOPE)
 ENDMACRO(ADD_VIST_TEST)
 
-MACRO(ADD_VIST_LINK)
-       LIST(APPEND ${TARGET_VIST_LIB}_DEPS ${ARGN})
-       SET(${TARGET_VIST_LIB}_DEPS ${${TARGET_VIST_LIB}_DEPS} PARENT_SCOPE)
-ENDMACRO(ADD_VIST_LINK)
-
-## policyd #####################
-MACRO(ADD_POLICYD_LIBRARY TARGET)
-       ADD_LIBRARY(${TARGET} OBJECT ${ARGN})
-       LIST(APPEND ${TARGET_POLICYD_LIB}_SRCS $<TARGET_OBJECTS:${TARGET}>)
-       SET(${TARGET_POLICYD_LIB}_SRCS ${${TARGET_POLICYD_LIB}_SRCS} PARENT_SCOPE)
-ENDMACRO(ADD_POLICYD_LIBRARY)
-
-MACRO(ADD_POLICYD_TEST)
-       LIST(APPEND ${TARGET_POLICYD_LIB}_TESTS ${ARGN})
-       SET(${TARGET_POLICYD_LIB}_TESTS ${${TARGET_POLICYD_LIB}_TESTS} PARENT_SCOPE)
-ENDMACRO(ADD_POLICYD_TEST)
-
 ## common #############################
 MACRO(TARGET_LINK_WHOLE TARGET LIBRARY)
        TARGET_LINK_LIBRARIES(${TARGET} "-Wl,-whole-archive")
index f88f53c..5e797dd 100644 (file)
@@ -110,7 +110,6 @@ Provides internal testcases for ViST implementation.
 %files test
 %{_bindir}/osquery-test
 %{_bindir}/vist-test
-%{_bindir}/policyd-test
 
 ## ViST Plugins - ###########################################################
 %package plugins
index eb41e97..aca5c24 100644 (file)
@@ -18,8 +18,8 @@
 #include <bluetooth-api.h>
 #include <bluetooth_internal.h>
 
-#include <policyd/sdk/global-policy.h>
-#include <policyd/sdk/policy-provider.h>
+#include <vist/policy/sdk/global-policy.h>
+#include <vist/policy/sdk/policy-provider.h>
 
 #include <memory>
 
@@ -37,7 +37,7 @@
        ((int)(enable) ? BLUETOOTH_DPM_BT_ALLOWED :              \
                                         BLUETOOTH_DPM_BT_RESTRICTED)
 
-using namespace policyd;
+using namespace vist::policy;
 
 class ModeChange : public GlobalPolicy {
 public:
index e490ac9..3714fa8 100644 (file)
@@ -17,8 +17,8 @@
 #include <arpa/inet.h>
 #include <wifi-manager.h>
 
-#include <policyd/sdk/global-policy.h>
-#include <policyd/sdk/policy-provider.h>
+#include <vist/policy/sdk/global-policy.h>
+#include <vist/policy/sdk/policy-provider.h>
 
 #include <klay/dbus/connection.h>
 
@@ -31,7 +31,7 @@
        "/net/netconfig/network",       \
        "net.netconfig.network"
 
-using namespace policyd;
+using namespace vist::policy;
 
 class ModeChange : public GlobalPolicy {
 public:
index d0646df..08d05f8 100644 (file)
 #  limitations under the License
 
 SET(TARGET_OSQUERY_LIB osquery)
-SET(TARGET_POLICYD_LIB policyd)
+SET(TARGET_VIST_POLICY_LIB vist-policy)
 SET(TARGET_VIST_LIB vist)
 
 ADD_SUBDIRECTORY(osquery)
 
 IF(DEFINED GBS_BUILD)
        ADD_SUBDIRECTORY(vist)
-       ADD_SUBDIRECTORY(policyd)
 ENDIF(DEFINED GBS_BUILD)
index 660bf29..7b48c17 100644 (file)
@@ -69,7 +69,7 @@ ADD_LIBRARY(${TARGET_OSQUERY_LIB}
 TARGET_LINK_LIBRARIES(${TARGET_OSQUERY_LIB} ${${TARGET_OSQUERY_LIB}_DEPS})
 
 IF(DEFINED GBS_BUILD)
-TARGET_LINK_LIBRARIES(${TARGET_OSQUERY_LIB} ${TARGET_POLICYD_LIB})
+TARGET_LINK_LIBRARIES(${TARGET_OSQUERY_LIB} ${TARGET_VIST_POLICY_LIB})
 ENDIF(DEFINED GBS_BUILD)
 
 SET_TARGET_PROPERTIES(${TARGET_OSQUERY_LIB} PROPERTIES OUTPUT_NAME ${TARGET_OSQUERY_LIB})
index a35b62b..5301071 100644 (file)
 #include <stdexcept>
 
 #include <osquery/sql.h>
-#include <osquery/logger.h>
 #include <osquery/tables.h>
 
-#include <policyd/api.h>
+#include <vist/policy/api.h>
+#include <vist/common/audit/logger.h>
 
 namespace osquery {
 namespace tables {
 
 QueryData genPolicy(QueryContext& context) try {
+       INFO(VIST, "Select query about policy table.");
+
        QueryData results;
        if (context.constraints["name"].exists(EQUALS)) { /// where clause
                auto names = context.constraints["name"].getAll(EQUALS);
                for (const auto& name : names) {
-                       auto ret = policyd::API::Get(name);
+                       auto ret = vist::policy::API::Get(name);
 
                        Row r;
                        r["name"] = TEXT(name);
@@ -41,7 +43,7 @@ QueryData genPolicy(QueryContext& context) try {
                        results.emplace_back(std::move(r));
                }
        } else { /// select *;
-               auto policies = policyd::API::GetAll();
+               auto policies = vist::policy::API::GetAll();
                for (auto& policy : policies) {
                        Row r;
                        r["name"] = TEXT(policy.first);
@@ -53,11 +55,13 @@ QueryData genPolicy(QueryContext& context) try {
 
        return results;
 } catch (...) {
+       ERROR(VIST, "Failed to select query on policy.");
        Row r;
        return { r };
 }
 
 QueryData updatePolicy(QueryContext& context, const PluginRequest& request) try {
+       INFO(VIST, "Update query about policy table.");
        if (request.count("json_value_array") == 0)
                throw std::runtime_error("Wrong request format. Not found json value.");
 
@@ -73,7 +77,7 @@ QueryData updatePolicy(QueryContext& context, const PluginRequest& request) try
        std::string name = document[0].GetString();
        int value = std::stoi(document[1].GetString());
 
-       policyd::API::Admin::Set(name, policyd::PolicyValue(value));
+       vist::policy::API::Admin::Set(name, vist::policy::PolicyValue(value));
 
        Row r;
        r["status"] = "success";
index 035e86f..e3e47da 100644 (file)
@@ -21,7 +21,7 @@
 #include <osquery/sql.h>
 #include <osquery/tables.h>
 
-#include <policyd/api.h>
+#include <vist/policy/api.h>
 #include <vist/common/audit/logger.h>
 
 namespace {
@@ -70,10 +70,10 @@ namespace osquery {
 namespace tables {
 
 QueryData genPolicyAdmin(QueryContext& context) try {
-       INFO(VIST, "Select query about policy-admin.");
+       INFO(VIST, "Select query about policy-admin table.");
 
        QueryData results;
-       auto admins = policyd::API::Admin::GetAll();
+       auto admins = vist::policy::API::Admin::GetAll();
 
        for (auto& admin : admins) {
                Row r;
@@ -92,13 +92,13 @@ QueryData genPolicyAdmin(QueryContext& context) try {
 }
 
 QueryData insertPolicyAdmin(QueryContext& context, const PluginRequest& request) try {
-       INFO(VIST, "Insert query about policy-admin.");
+       INFO(VIST, "Insert query about policy-admin table.");
        if (request.count("json_value_array") == 0)
                throw std::runtime_error("Wrong request format. Not found json value.");
 
        auto admin = parseAdmin(request.at("json_value_array"));
        DEBUG(VIST, "Admin info [name]: " << admin.first << ", [uid]: " << admin.second);
-       policyd::API::Admin::Enroll(admin.first, admin.second);
+       vist::policy::API::Admin::Enroll(admin.first, admin.second);
 
        Row r;
        r["status"] = "success";
@@ -110,13 +110,13 @@ QueryData insertPolicyAdmin(QueryContext& context, const PluginRequest& request)
 }
 
 QueryData deletePolicyAdmin(QueryContext& context, const PluginRequest& request) try {
-       INFO(VIST, "Delete query about policy-admin.");
+       INFO(VIST, "Delete query about policy-admin table.");
        if (request.count("json_value_array") == 0)
                throw std::runtime_error("Wrong request format. Not found json value.");
 
        auto admin = parseAdmin(request.at("json_value_array"), false);
        DEBUG(VIST, "Admin info [name]: " << admin.first << ", [uid]: " << admin.second);
-       policyd::API::Admin::Disenroll(admin.first, admin.second);
+       vist::policy::API::Admin::Disenroll(admin.first, admin.second);
 
        Row r;
        r["status"] = "success";
index 4a3a9eb..f31d527 100644 (file)
 
 #include <gtest/gtest.h>
 
-#include <policyd/api.h>
+#include <vist/policy/api.h>
+
+using namespace vist;
 
 class PolicyTests : public testing::Test {};
 
 TEST_F(PolicyTests, get_all) {
-       auto policies = policyd::API::GetAll();
+       auto policies = policy::API::GetAll();
 
        EXPECT_TRUE(policies.size() > 0);
 }
 
 TEST_F(PolicyTests, get_admin_all) {
-       auto admins = policyd::API::Admin::GetAll();
+       auto admins = policy::API::Admin::GetAll();
        EXPECT_EQ(admins.size(), 0);
 
-       policyd::API::Admin::Enroll("testAdmin", 0);
-       admins = policyd::API::Admin::GetAll();
+       policy::API::Admin::Enroll("testAdmin", 0);
+       admins = policy::API::Admin::GetAll();
        EXPECT_EQ(admins.size(), 1);
 
-       policyd::API::Admin::Enroll("testAdmin", 1);
-       admins = policyd::API::Admin::GetAll();
+       policy::API::Admin::Enroll("testAdmin", 1);
+       admins = policy::API::Admin::GetAll();
        EXPECT_EQ(admins.size(), 2);
 
-       policyd::API::Admin::Disenroll("testAdmin", 0);
-       admins = policyd::API::Admin::GetAll();
+       policy::API::Admin::Disenroll("testAdmin", 0);
+       admins = policy::API::Admin::GetAll();
        EXPECT_EQ(admins.size(), 1);
 
-       policyd::API::Admin::Disenroll("testAdmin", 1);
-       admins = policyd::API::Admin::GetAll();
+       policy::API::Admin::Disenroll("testAdmin", 1);
+       admins = policy::API::Admin::GetAll();
        EXPECT_EQ(admins.size(), 0);
 }
diff --git a/src/policyd/CMakeLists.txt b/src/policyd/CMakeLists.txt
deleted file mode 100644 (file)
index e148a03..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright (c) 2019 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.
-#
-
-SET(TARGET_POLICYD_TEST policyd-test)
-
-SET(${TARGET_POLICYD_LIB}_SRCS "")
-SET(${TARGET_POLICYD_LIB}_TESTS "")
-
-SET(DEPENDENCY klay)
-
-PKG_CHECK_MODULES(POLICYD_DEPS REQUIRED ${DEPENDENCY})
-
-INCLUDE_DIRECTORIES(SYSTEM . ${POLICYD_DEPS_INCLUDE_DIRS})
-
-ADD_DEFINITIONS(-DDB_PATH="${DB_INSTALL_DIR}/.vist.db"
-                               -DPLUGIN_INSTALL_DIR="${PLUGIN_INSTALL_DIR}"
-                               -DSCRIPT_INSTALL_DIR="${SCRIPT_INSTALL_DIR}")
-
-ADD_SUBDIRECTORY(core)
-ADD_SUBDIRECTORY(sdk)
-
-ADD_LIBRARY(${TARGET_POLICYD_LIB} STATIC ${${TARGET_POLICYD_LIB}_SRCS})
-
-TARGET_LINK_LIBRARIES(${TARGET_POLICYD_LIB} ${POLICYD_DEPS_LIBRARIES} pthread dl)
-
-SET_TARGET_PROPERTIES(${TARGET_POLICYD_LIB} PROPERTIES COMPILE_FLAGS "-fPIE")
-SET_TARGET_PROPERTIES(${TARGET_POLICYD_LIB} PROPERTIES LINK_FLAGS "-pie")
-
-ADD_EXECUTABLE(${TARGET_POLICYD_TEST} ../vist/main/tests.cpp
-                                                                         ${${TARGET_POLICYD_LIB}_TESTS})
-
-TARGET_LINK_LIBRARIES(${TARGET_POLICYD_TEST} ${TARGET_POLICYD_LIB}
-                                                                                        gtest
-                                                                                        pthread)
-ADD_TEST(${TARGET_POLICYD_TEST} ${TARGET_POLICYD_TEST})
-INSTALL(TARGETS ${TARGET_POLICYD_TEST}
-               DESTINATION ${CMAKE_INSTALL_BINDIR}
-               PERMISSIONS OWNER_READ
-                                       OWNER_WRITE
-                                       OWNER_EXECUTE
-                                       GROUP_READ
-                                       GROUP_EXECUTE
-                                       WORLD_READ
-                                       WORLD_EXECUTE)
diff --git a/src/policyd/sdk/CMakeLists.txt b/src/policyd/sdk/CMakeLists.txt
deleted file mode 100644 (file)
index fb08801..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright (c) 2019 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.
-#
-
-FILE(GLOB SDK_TESTS "tests/*.cpp")
-ADD_POLICYD_TEST(${SDK_TESTS})
index 52b8725..73f9be1 100644 (file)
@@ -16,23 +16,34 @@ SET(TARGET_VIST_DAEMON vistd)
 SET(TARGET_VIST_TEST vist-test)
 
 SET(${TARGET_VIST_LIB}_SRCS "")
-SET(${TARGET_VIST_LIB}_DEPS "")
 SET(${TARGET_VIST_LIB}_TESTS "")
 
-INCLUDE_DIRECTORIES(. common)
+SET(DEPENDENCY klay)
+
+PKG_CHECK_MODULES(VIST_DEPS REQUIRED ${DEPENDENCY})
+
+INCLUDE_DIRECTORIES(SYSTEM . common ${VIST_DEPS_INCLUDE_DIRS})
+
+ADD_DEFINITIONS(-DDB_PATH="${DB_INSTALL_DIR}/.vist.db"
+                               -DPLUGIN_INSTALL_DIR="${PLUGIN_INSTALL_DIR}"
+                               -DSCRIPT_INSTALL_DIR="${SCRIPT_INSTALL_DIR}")
 
 ADD_SUBDIRECTORY(client)
 ADD_SUBDIRECTORY(common)
 ADD_SUBDIRECTORY(notification)
+ADD_SUBDIRECTORY(policy)
 ADD_SUBDIRECTORY(service)
 
 ADD_LIBRARY(${TARGET_VIST_LIB} STATIC ${${TARGET_VIST_LIB}_SRCS})
-TARGET_LINK_LIBRARIES(${TARGET_VIST_LIB} ${${TARGET_VIST_LIB}_DEPS}
+TARGET_LINK_LIBRARIES(${TARGET_VIST_LIB} ${VSIT_DEPS_LIBRARIES}
+                                                                                ${TARGET_VIST_POLICY_LIB}
                                                                                 ${TARGET_OSQUERY_LIB})
 
 ADD_EXECUTABLE(${TARGET_VIST_DAEMON} main/main.cpp)
 TARGET_LINK_LIBRARIES(${TARGET_VIST_DAEMON} ${TARGET_VIST_LIB})
 TARGET_LINK_WHOLE(${TARGET_VIST_DAEMON} ${TARGET_OSQUERY_LIB})
+SET_TARGET_PROPERTIES(${TARGET_VIST_DAEMON} PROPERTIES COMPILE_FLAGS "-fPIE")
+SET_TARGET_PROPERTIES(${TARGET_VIST_DAEMON} PROPERTIES LINK_FLAGS "-pie")
 INSTALL(TARGETS ${TARGET_VIST_DAEMON}
                DESTINATION ${CMAKE_INSTALL_BINDIR}
                PERMISSIONS OWNER_READ
@@ -46,7 +57,7 @@ INSTALL(TARGETS ${TARGET_VIST_DAEMON}
 ADD_EXECUTABLE(${TARGET_VIST_TEST} main/tests.cpp
                                                                   ${${TARGET_VIST_LIB}_TESTS})
 TARGET_LINK_LIBRARIES(${TARGET_VIST_TEST} ${TARGET_VIST_LIB}
-                                                                                  gtest)
+                                                                                 gtest)
 TARGET_LINK_WHOLE(${TARGET_VIST_TEST} ${TARGET_OSQUERY_LIB})
 ADD_TEST(${TARGET_VIST_TEST} ${TARGET_VIST_TEST})
 INSTALL(TARGETS ${TARGET_VIST_TEST}
diff --git a/src/vist/common/CMakeLists.txt b/src/vist/common/CMakeLists.txt
deleted file mode 100644 (file)
index 66c3149..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#  Copyright (c) 2019 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
-
-FILE(GLOB COMMON_TESTS "ipc/tests/*.cpp")
-ADD_VIST_TEST(${COMMON_TESTS})
index e9f656e..94c082a 100644 (file)
@@ -58,7 +58,6 @@ public:
                } else if (pid == 0) {
                        TestServer server;
                        server.init();
-                       
                }
 
                std::this_thread::sleep_for(std::chrono::seconds(1));
similarity index 55%
rename from src/policyd/core/CMakeLists.txt
rename to src/vist/policy/CMakeLists.txt
index 4f73300..4be4c4b 100644 (file)
 # limitations under the License.
 #
 
-ADD_POLICYD_LIBRARY(policyd_core api.cpp
-                                                                policy-manager.cpp
-                                                                policy-loader.cpp
-                                                                policy-storage.cpp)
+SET(${TARGET_VIST_POLICY_LIB}_SRCS "")
 
-FILE(GLOB SDK_TESTS "tests/*.cpp")
-ADD_POLICYD_TEST(${SDK_TESTS})
+ADD_VIST_POLICY_LIBRARY(vist_policy_core core/api.cpp
+                                                                                core/policy-manager.cpp
+                                                                                core/policy-loader.cpp
+                                                                                core/policy-storage.cpp)
+
+FILE(GLOB POLICY_CORE_TESTS "core/tests/*.cpp")
+ADD_VIST_TEST(${POLICY_CORE_TESTS})
+
+FILE(GLOB POLICY_SDK_TESTS "sdk/tests/*.cpp")
+ADD_VIST_TEST(${POLICY_SDK_TESTS})
+
+ADD_LIBRARY(${TARGET_VIST_POLICY_LIB} STATIC ${${TARGET_VIST_POLICY_LIB}_SRCS})
+TARGET_LINK_LIBRARIES(${TARGET_VIST_POLICY_LIB} pthread dl)
similarity index 90%
rename from src/policyd/api.h
rename to src/vist/policy/api.h
index 6fdb5bc..33b54f3 100644 (file)
 
 #pragma once
 
-#include <policyd/sdk/policy-value.h>
+#include <vist/policy/sdk/policy-value.h>
 
 #include <string>
 #include <map>
 #include <unordered_map>
 
-namespace policyd {
+namespace vist {
+namespace policy {
 
 struct API {
        static PolicyValue Get(const std::string& policy);
@@ -38,4 +39,5 @@ struct API {
        };
 };
 
-} // namespace policyd
+} // namespace policy
+} // namespace vist
similarity index 92%
rename from src/policyd/core/api.cpp
rename to src/vist/policy/core/api.cpp
index 66d0bfd..7a5a8e0 100644 (file)
  *  limitations under the License
  */
 
-#include <policyd/api.h>
+#include <vist/policy/api.h>
 
 #include "policy-manager.h"
 
-namespace policyd {
+namespace vist {
+namespace policy {
 
 PolicyValue API::Get(const std::string& policy)
 {
@@ -51,4 +52,5 @@ std::multimap<std::string, int> API::Admin::GetAll()
        return PolicyManager::Instance().getAdmins();
 }
 
-} // namespace policyd
+} // namespace policy
+} // namespace vist
similarity index 92%
rename from src/policyd/core/db-schema.h
rename to src/vist/policy/core/db-schema.h
index 98f7a3b..c2facea 100644 (file)
@@ -17,7 +17,8 @@
 
 #include <string>
 
-namespace policyd {
+namespace vist {
+namespace policy {
 namespace schema {
 
 struct Admin {
@@ -43,4 +44,5 @@ struct PolicyDefinition {
 };
 
 } // namespace schema
-} // namespace policyd
+} // namespace policy
+} // namespace vist
similarity index 95%
rename from src/policyd/core/policy-loader.cpp
rename to src/vist/policy/core/policy-loader.cpp
index 042e915..b9350fb 100644 (file)
@@ -16,7 +16,8 @@
 
 #include "policy-loader.h"
 
-namespace policyd {
+namespace vist {
+namespace policy {
 
 PolicyProvider* PolicyLoader::load(const std::string& path)
 {
@@ -43,4 +44,5 @@ PluginLoader::PluginLoader(const std::string& path, int flag)
                throw std::invalid_argument("Failed to open: " + path);
 }
 
-} // namespace policyd
+} // namespace policy
+} // namespace vist
similarity index 91%
rename from src/policyd/core/policy-loader.h
rename to src/vist/policy/core/policy-loader.h
index 14c32a2..73dab2d 100644 (file)
@@ -16,7 +16,7 @@
 
 #pragma once
 
-#include <policyd/sdk/policy-provider.h>
+#include <vist/policy/sdk/policy-provider.h>
 
 #include <stdexcept>
 #include <string>
@@ -24,7 +24,8 @@
 
 #include <dlfcn.h>
 
-namespace policyd {
+namespace vist {
+namespace policy {
 
 struct PolicyLoader final {
        static PolicyProvider* load(const std::string& path);
@@ -50,4 +51,5 @@ void PluginLoader::load(const std::string& name, T& symbol)
                throw std::runtime_error("Failed to load: " + name);
 }
 
-} // namespace policyd
+} // namespace policy
+} // namespace vist
similarity index 98%
rename from src/policyd/core/policy-manager.cpp
rename to src/vist/policy/core/policy-manager.cpp
index 2d59145..0def919 100644 (file)
@@ -21,7 +21,8 @@
 
 #include <klay/filesystem.h>
 
-namespace policyd {
+namespace vist {
+namespace policy {
 
 PolicyManager::PolicyManager() : storage(DB_PATH)
 {
@@ -153,4 +154,5 @@ std::multimap<std::string, int> PolicyManager::getAdmins()
        return storage.getAdmins();
 }
 
-} // namespace policyd
+} // namespace policy
+} // namespace vist
similarity index 92%
rename from src/policyd/core/policy-manager.h
rename to src/vist/policy/core/policy-manager.h
index 9ab2b06..feff66e 100644 (file)
@@ -16,8 +16,8 @@
 
 #pragma once
 
-#include <policyd/sdk/policy-provider.h>
-#include <policyd/sdk/policy-value.h>
+#include <vist/policy/sdk/policy-provider.h>
+#include <vist/policy/sdk/policy-value.h>
 
 #include "policy-storage.h"
 
@@ -30,7 +30,8 @@
 
 #include <gtest/gtest_prod.h>
 
-namespace policyd {
+namespace vist {
+namespace policy {
 
 class PolicyManager final {
 public:
@@ -71,4 +72,5 @@ private:
        FRIEND_TEST(PolicyCoreTests, policy_loader);
 };
 
-} // namespace policyd
+} // namespace policy
+} // namespace vist
similarity index 98%
rename from src/policyd/core/policy-storage.cpp
rename to src/vist/policy/core/policy-storage.cpp
index afd2463..e7a6cb5 100644 (file)
@@ -26,7 +26,7 @@
 #include <fstream>
 
 using namespace query_builder;
-using namespace policyd::schema;
+using namespace vist::policy::schema;
 
 namespace {
 
@@ -54,7 +54,8 @@ const std::string SCRIPT_CREATE_SCHEMA  = "create_schema";
 
 } // anonymous namespace
 
-namespace policyd {
+namespace vist {
+namespace policy {
 
 PolicyStorage::PolicyStorage(const std::string& path) :
        database(std::make_shared<database::Connection>(path,
@@ -327,4 +328,5 @@ int PolicyStorage::getUid(int adminId) const noexcept
        return -1;
 }
 
-} // namespace policyd
+} // namespace policy
+} // namespace vist
similarity index 95%
rename from src/policyd/core/policy-storage.h
rename to src/vist/policy/core/policy-storage.h
index d2e39e7..49a4283 100644 (file)
@@ -16,7 +16,7 @@
 
 #pragma once
 
-#include <policyd/sdk/policy-value.h>
+#include <vist/policy/sdk/policy-value.h>
 
 #include "db-schema.h"
 
@@ -27,7 +27,8 @@
 
 #include <klay/db/connection.h>
 
-namespace policyd {
+namespace vist {
+namespace policy {
 
 using namespace schema;
 
@@ -78,4 +79,5 @@ private:
        std::unordered_multimap<int, ManagedPolicy> managedPolicies;
 };
 
-} // namespace policyd
+} // namespace policy
+} // namespace vist
similarity index 94%
rename from src/policyd/core/tests/core-tests.cpp
rename to src/vist/policy/core/tests/core-tests.cpp
index 83e5cb6..46afc70 100644 (file)
@@ -18,7 +18,8 @@
 
 #include "../policy-manager.h"
 
-namespace policyd {
+namespace vist {
+namespace policy {
 
 class PolicyCoreTests : public testing::Test {};
 
@@ -48,4 +49,5 @@ TEST_F(PolicyCoreTests, policy_set_get) {
        manager.disenroll("testAdmin1", 0);
 }
 
-} // namespace policyd
+} // namespace policy
+} // namespace vist
similarity index 99%
rename from src/policyd/core/tests/storage-tests.cpp
rename to src/vist/policy/core/tests/storage-tests.cpp
index d533c67..5249395 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "../policy-storage.h"
 
-using namespace policyd;
+using namespace vist::policy;
 
 class PolicyStorageTests : public testing::Test {
 public:
similarity index 95%
rename from src/policyd/sdk/domain-policy.h
rename to src/vist/policy/sdk/domain-policy.h
index f27e105..6992f8c 100644 (file)
@@ -24,7 +24,8 @@
 
 #include <sys/types.h>
 
-namespace policyd {
+namespace vist {
+namespace policy {
 
 class DomainPolicy : public PolicyModel {
 public:
@@ -59,4 +60,5 @@ private:
        std::unordered_map<uid_t, PolicyValue> current;
 };
 
-} // namespace policyd
+} // namespace policy
+} // namespace vist
similarity index 95%
rename from src/policyd/sdk/global-policy.h
rename to src/vist/policy/sdk/global-policy.h
index 0217554..88d94c9 100644 (file)
@@ -21,7 +21,8 @@
 #include <stdexcept>
 #include <string>
 
-namespace policyd {
+namespace vist {
+namespace policy {
 
 class GlobalPolicy : public PolicyModel {
 public:
@@ -58,4 +59,5 @@ private:
        bool ready = false;
 };
 
-} // namespace policyd
+} // namespace policy
+} // namespace vist
similarity index 94%
rename from src/policyd/sdk/policy-model.h
rename to src/vist/policy/sdk/policy-model.h
index 95b5dfe..09df30a 100644 (file)
@@ -20,7 +20,8 @@
 
 #include <string>
 
-namespace policyd {
+namespace vist {
+namespace policy {
 
 class PolicyModel {
 public:
@@ -42,4 +43,5 @@ protected:
        PolicyValue initial;
 };
 
-} // namespace policyd
+} // namespace policy
+} // namespace vist
similarity index 95%
rename from src/policyd/sdk/policy-provider.h
rename to src/vist/policy/sdk/policy-provider.h
index 27bb0ae..75a996a 100644 (file)
@@ -23,7 +23,8 @@
 #include <memory>
 #include <unordered_map>
 
-namespace policyd {
+namespace vist {
+namespace policy {
 
 class PolicyProvider {
 public:
@@ -57,4 +58,5 @@ private:
        friend class PolicyManager;
 };
 
-} // namespace policyd
+} // namespace policy
+} // namespace vist
similarity index 94%
rename from src/policyd/sdk/policy-value.h
rename to src/vist/policy/sdk/policy-value.h
index 31dd582..e1b2464 100644 (file)
@@ -16,7 +16,8 @@
 
 #pragma once
 
-namespace policyd {
+namespace vist {
+namespace policy {
 
 // TODO: Support various value type
 struct PolicyValue final {
@@ -43,4 +44,5 @@ struct PolicyValue final {
        int value = -1;
 };
 
-} // namespace policyd
+} // namespace policy
+} // namespace vist
similarity index 98%
rename from src/policyd/sdk/tests/sdk-tests.cpp
rename to src/vist/policy/sdk/tests/sdk-tests.cpp
index afc476f..b6fb906 100644 (file)
@@ -28,7 +28,7 @@ namespace {
        uid_t d_uid = 0;
 } // anonymous namespace
 
-using namespace policyd;
+using namespace vist::policy;
 
 class PolicySDKTests : public testing::Test {};
 
similarity index 94%
rename from src/vist/service/tests/core_tests.cpp
rename to src/vist/service/tests/core-tests.cpp
index 1d3e381..62edf79 100644 (file)
@@ -22,7 +22,7 @@
 #include <chrono>
 #include <thread>
 
-#include <policyd/core/policy-manager.h>
+#include <vist/policy/core/policy-manager.h>
 
 using namespace vist;
 
@@ -41,7 +41,7 @@ TEST_F(CoreTests, query_select) {
 }
 
 TEST_F(CoreTests, query_update) {
-       auto& manager = policyd::PolicyManager::Instance();
+       auto& manager = policy::PolicyManager::Instance();
        manager.enroll("admin", 0);
 
        std::string statement = "SELECT * FROM policy WHERE name = 'bluetooth'";