cp -a db* %{buildroot}/%{tests_dir}
ln -s ../cynara.socket %{buildroot}/usr/lib/systemd/system/sockets.target.wants/cynara.socket
ln -s ../cynara-admin.socket %{buildroot}/usr/lib/systemd/system/sockets.target.wants/cynara-admin.socket
+ln -s ../cynara-agent.socket %{buildroot}/usr/lib/systemd/system/sockets.target.wants/cynara-agent.socket
%pre
id -g %{group_name} > /dev/null 2>&1
%attr(-,root,root) /usr/lib/systemd/system/cynara.socket
%attr(-,root,root) /usr/lib/systemd/system/sockets.target.wants/cynara-admin.socket
%attr(-,root,root) /usr/lib/systemd/system/cynara-admin.socket
+%attr(-,root,root) /usr/lib/systemd/system/sockets.target.wants/cynara-agent.socket
+%attr(-,root,root) /usr/lib/systemd/system/cynara-agent.socket
%dir %attr(700,cynara,cynara) %{state_path}
%files -n libcynara-client
${COMMON_PATH}/log/log.cpp
${COMMON_PATH}/plugin/PluginManager.cpp
${COMMON_PATH}/protocol/ProtocolAdmin.cpp
+ ${COMMON_PATH}/protocol/ProtocolAgent.cpp
${COMMON_PATH}/protocol/ProtocolClient.cpp
${COMMON_PATH}/protocol/ProtocolFrame.cpp
${COMMON_PATH}/protocol/ProtocolFrameHeader.cpp
#include "types/PolicyTypeExtension.h"
-
#endif /* COMMON_H */
namespace SocketPath {
const std::string client(clientPath + "cynara.socket");
const std::string admin(clientPath + "cynara-admin.socket");
+const std::string agent(clientPath + "cynara-agent.socket");
} // namespace SocketPath
namespace StoragePath {
namespace SocketPath {
extern const std::string client;
extern const std::string admin;
+extern const std::string agent;
} // namespace SocketPath
namespace StoragePath {
--- /dev/null
+/*
+ * Copyright (c) 2014 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 src/common/protocol/ProtocolAgent.cpp
+ * @author Adam Malinowski <a.malinowsk2@partner.samsung.com>
+ * @version 1.0
+ * @brief This file implements protocol class for communication with agent
+ */
+
+#include <inttypes.h>
+#include <memory>
+
+#include <exceptions/InvalidProtocolException.h>
+#include <log/log.h>
+#include <protocol/ProtocolFrameSerializer.h>
+#include <protocol/ProtocolOpCode.h>
+#include <protocol/ProtocolSerialization.h>
+
+#include "ProtocolAgent.h"
+
+namespace Cynara {
+
+ProtocolAgent::ProtocolAgent() {
+}
+
+ProtocolAgent::~ProtocolAgent() {
+}
+
+ProtocolPtr ProtocolAgent::clone(void) {
+ return std::make_shared<ProtocolAgent>();
+}
+
+RequestPtr ProtocolAgent::extractRequestFromBuffer(BinaryQueuePtr bufferQueue) {
+ ProtocolFrameSerializer::deserializeHeader(m_frameHeader, bufferQueue);
+
+ if (m_frameHeader.isFrameComplete()) {
+ ProtocolOpCode opCode;
+
+ m_frameHeader.resetState();
+ ProtocolDeserialization::deserialize(m_frameHeader, opCode);
+ LOGD("Deserialized opCode [%" PRIu8 "]", opCode);
+ switch (opCode) {
+ default:
+ throw InvalidProtocolException(InvalidProtocolException::WrongOpCode);
+ break;
+ }
+ }
+
+ return nullptr;
+}
+
+ResponsePtr ProtocolAgent::extractResponseFromBuffer(BinaryQueuePtr bufferQueue) {
+ ProtocolFrameSerializer::deserializeHeader(m_frameHeader, bufferQueue);
+
+ if (m_frameHeader.isFrameComplete()) {
+ ProtocolOpCode opCode;
+
+ m_frameHeader.resetState();
+ ProtocolDeserialization::deserialize(m_frameHeader, opCode);
+ LOGD("Deserialized opCode [%" PRIu8 "]", opCode);
+ switch (opCode) {
+ default:
+ throw InvalidProtocolException(InvalidProtocolException::WrongOpCode);
+ break;
+ }
+ }
+
+ return nullptr;
+}
+
+} // namespace Cynara
--- /dev/null
+/*
+ * Copyright (c) 2014 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 src/common/protocol/ProtocolAgent.h
+ * @author Adam Malinowski <a.malinowsk2@partner.samsung.com>
+ * @version 1.0
+ * @brief This file defines protocol class for communication with agent
+ */
+
+#ifndef SRC_COMMON_PROTOCOL_PROTOCOLAGENT_H_
+#define SRC_COMMON_PROTOCOL_PROTOCOLAGENT_H_
+
+#include <protocol/ProtocolFrameHeader.h>
+#include <request/pointers.h>
+#include <response/pointers.h>
+
+#include "Protocol.h"
+
+namespace Cynara {
+
+class ProtocolAgent : public Protocol {
+public:
+ ProtocolAgent();
+ virtual ~ProtocolAgent();
+
+ virtual ProtocolPtr clone(void);
+
+ virtual RequestPtr extractRequestFromBuffer(BinaryQueuePtr bufferQueue);
+ virtual ResponsePtr extractResponseFromBuffer(BinaryQueuePtr bufferQueue);
+};
+
+} // namespace Cynara
+
+#endif /* SRC_COMMON_PROTOCOL_PROTOCOLAGENT_H_ */
#include <logic/Logic.h>
#include <main/Cynara.h>
#include <protocol/ProtocolAdmin.h>
+#include <protocol/ProtocolAgent.h>
#include <protocol/ProtocolClient.h>
#include <protocol/ProtocolSignal.h>
#include <request/pointers.h>
LOGI("SocketManger init start");
const mode_t clientSocketUMask(0);
const mode_t adminSocketUMask(0077);
+ const mode_t agentSocketUMask(0);
createDomainSocket(std::make_shared<ProtocolClient>(), PathConfig::SocketPath::client,
clientSocketUMask, true);
createDomainSocket(std::make_shared<ProtocolAdmin>(), PathConfig::SocketPath::admin,
adminSocketUMask, false);
+ createDomainSocket(std::make_shared<ProtocolAgent>(), PathConfig::SocketPath::agent,
+ agentSocketUMask, false);
createSignalSocket(std::make_shared<ProtocolSignal>());
LOGI("SocketManger init done");
}
${CMAKE_SOURCE_DIR}/systemd/cynara.target
${CMAKE_SOURCE_DIR}/systemd/cynara.socket
${CMAKE_SOURCE_DIR}/systemd/cynara-admin.socket
+ ${CMAKE_SOURCE_DIR}/systemd/cynara-agent.socket
DESTINATION
lib/systemd/system
)
--- /dev/null
+[Socket]
+ListenStream=/run/cynara/cynara-agent.socket
+SocketMode=0060
+SmackLabelIPIn=*
+SmackLabelIPOut=@
+
+Service=cynara.service
+
+[Unit]
+Wants=cynara.target
+Before=cynara.target
+
+[Install]
+WantedBy=sockets.target
Sockets=cynara.socket
Sockets=cynara-admin.socket
+Sockets=cynara-agent.socket
UMask=0000
User=cynara