<manifest>
- <request>
- <domain name="_"/>
- </request>
+ <request>
+ <domain name="_"/>
+ </request>
</manifest>
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_" />
+ </request>
+ <assign>
+ <filesystem path="/usr/bin/vist-test" exec_label="System" />
+ </assign>
+</manifest>
<manifest>
- <request>
- <domain name="_"/>
- </request>
+ <request>
+ <domain name="_"/>
+ </request>
</manifest>
%license LICENSE-Apache-2.0
%license LICENSE-GPL-2.0
%license LICENSE-MIT
-%{_bindir}/vist-cli
-%{_bindir}/vistd
+%attr(-, %{user_name}, %{group_name}) %{_bindir}/vist-cli
+%attr(-, %{user_name}, %{group_name}) %{_bindir}/vistd
%{_libdir}/libvist-rmi.so
%{_unitdir}/vist.service
%{_unitdir}/vist.socket
Provides internal testcases for ViST implementation.
%files test
+%manifest packaging/%{name}-test.manifest
%{_bindir}/osquery-test
-%{_bindir}/vist-test
-%{vist_plugin_dir}/sample
+%attr(4755 %{user_name}, %{group_name}) %{_bindir}/vist-test
+%dir %attr(-, %{user_name}, %{group_name}) %{vist_plugin_dir}/sample
-## ViST Plugins - ###########################################################
+## ViST Plugins #############################################################
%package plugins
Summary: Virtaul Security Table (policy modules)
Group: Security/Other
TARGET_LINK_LIBRARIES(${TARGET_VIST_COMMON_LIB} ${VIST_COMMON_DEPS_LIBRARIES}
pthread glog gflags boost_system)
ELSE(DEFINED GBS_BUILD)
- TARGET_LINK_LIBRARIES(${TARGET_VIST_COMMON_LIB} pthread glog gflags boost_system)
+ TARGET_LINK_LIBRARIES(${TARGET_VIST_COMMON_LIB} pthread glog gflags boost_system systemd)
ENDIF(DEFINED GBS_BUILD)
ADD_LIBRARY(${TARGET_VIST_LIB} STATIC ${${TARGET_VIST_LIB}_SRCS})
#include <vist/exception.hpp>
#include <vist/rmi/message.hpp>
#include <vist/rmi/impl/server.hpp>
-
-#ifdef TIZEN
-#include <vist/rmi/impl/ondemand/server.hpp>
-#else
#include <vist/rmi/impl/general/server.hpp>
-#endif
+#include <vist/rmi/impl/ondemand/server.hpp>
#include <memory>
#include <string>
class Gateway::Impl {
public:
- explicit Impl(Gateway& gateway, const std::string& path)
+ explicit Impl(Gateway& gateway, const std::string& path, Gateway::ServiceType type)
{
auto dispatcher = [&gateway](auto& message) -> Message {
std::string function = message.signature;
return reply;
};
-#ifdef TIZEN
- this->server = std::make_unique<ondemand::Server>(path, dispatcher);
-#else
- this->server = std::make_unique<general::Server>(path, dispatcher);
-#endif
+ switch (type) {
+ case ServiceType::OnDemand:
+ this->server = std::make_unique<ondemand::Server>(path, dispatcher);
+ break;
+ case ServiceType::General: /// fall through
+ default:
+ this->server = std::make_unique<general::Server>(path, dispatcher);
+ break;
+ }
}
inline void start(int timeout, std::function<bool()> stopper)
std::unique_ptr<interface::Server> server;
};
-Gateway::Gateway(const std::string& path) : pImpl(std::make_unique<Impl>(*this, path))
+Gateway::Gateway(const std::string& path, ServiceType type) :
+ pImpl(std::make_unique<Impl>(*this, path, type))
{
}
class VIST_API Gateway final {
public:
- explicit Gateway(const std::string& path);
+ enum class ServiceType {
+ General,
+ OnDemand
+ };
+
+ explicit Gateway(const std::string& path, ServiceType type = ServiceType::General);
~Gateway();
Gateway(const Gateway&) = delete;
} // anonymous namespace
+#ifndef TIZEN
TEST(ServerClientTests, server)
{
std::string sockPath = "vist-test.sock";
if (serverThread.joinable())
serverThread.join();
}
+#endif
#include <vist/rmi/impl/ondemand/connection.hpp>
#include <vist/rmi/impl/ondemand/mainloop.hpp>
#include <vist/rmi/impl/ondemand/socket.hpp>
-
-#ifdef TIZEN
#include <vist/rmi/impl/ondemand/systemd-socket.hpp>
-#endif
#include <vist/exception.hpp>
#include <vist/logger.hpp>
public:
Server(const std::string& path, const interface::Task& task) :
interface::Server(path, task),
-#ifdef TIZEN
socket(SystemdSocket::Create(path))
-#else
- socket(path)
-#endif
{
this->accept(task);
}
+++ /dev/null
-/*
- * 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
- */
-
-#include <vist/rmi/message.hpp>
-#include <vist/rmi/impl/ondemand/server.hpp>
-#include <vist/rmi/impl/ondemand/client.hpp>
-
-#include <string>
-#include <thread>
-
-#include <gtest/gtest.h>
-
-using namespace vist::rmi;
-using namespace vist::rmi::impl::ondemand;
-
-namespace {
-
-/// Request variables
-std::string requestSignature = "request signature";
-int request1 = 100;
-bool request2 = true;
-std::string request3 = "request argument";
-
-/// Response variables
-std::string responseSignature = "response signature";
-int response1 = 300;
-bool response2 = false;
-std::string response3 = "response argument";
-
-} // anonymous namespace
-
-TEST(ServerClientTests, ondemand)
-{
- std::string sockPath = "./vist-test.sock";
-
- auto task = [&](Message& message) -> Message {
- EXPECT_EQ(message.signature, requestSignature);
-
- int recv1;
- bool recv2;
- std::string recv3;
- message.disclose(recv1, recv2, recv3);
- EXPECT_EQ(request1, recv1);
- EXPECT_EQ(request2, recv2);
- EXPECT_EQ(request3, recv3);
-
- Message reply(Message::Type::Reply, responseSignature);
- reply.enclose(response1, response2, response3);
- return reply;
- };
-
- Server server(sockPath, task);
- auto serverThread = std::thread([&]() {
- server.run();
- });
-
- { /// Client configuration
- auto clientClosure = [&]() {
- Client client(sockPath);
-
- Message message(Message::Type::MethodCall, requestSignature);
- message.enclose(request1, request2, request3);
-
- for (int i = 0; i < 3; i++) {
- auto reply = client.request(message);
- EXPECT_EQ(reply.signature, responseSignature);
-
- int recv1;
- bool recv2;
- std::string recv3;
- reply.disclose(recv1, recv2, recv3);
- EXPECT_EQ(response1, recv1);
- EXPECT_EQ(response2, recv2);
- EXPECT_EQ(response3, recv3);
- }
- };
-
- for (int i = 0; i < 3; i++)
- clientClosure();
- }
-
- server.stop();
-
- if (serverThread.joinable())
- serverThread.join();
-}
std::string sockPath = ("/tmp/test-gateway");
// gateway-side
- Gateway gateway(sockPath);
+ Gateway gateway(sockPath, Gateway::ServiceType::General);
Foo foo;
gateway.expose(foo, "Foo::setName", &Foo::setName);
{
INFO(VIST) << "Vistd daemon starts.";
- rmi::Gateway gateway(SOCK_ADDR);
+ rmi::Gateway::ServiceType type = rmi::Gateway::ServiceType::General;
+#ifdef TIZEN
+ type = rmi::Gateway::ServiceType::OnDemand;
+#endif
+
+ rmi::Gateway gateway(SOCK_ADDR, type);
EXPOSE(gateway, *this, &Vistd::query);
auto& pm = policy::PolicyManager::Instance();