Loading README.md +12 −3 Original line number Diff line number Diff line Norns Data Scheduler ==================== Dependencies: Build dependencies: - A c++11-conforming compiler - libboost-system >= 1.53 - libboost-filesystem >= 1.53 - libboost-program-options >= 1.53 - libboost-thread >= 1.53 - libprotobuf + protobuf compiler - libprotobuf-c + protobuf-c compiler - Intel TBB yum install tbb-devel - Installation in CentOS 7 git clone git@git.ph.ed.ac.uk:nextgenio/norns.git && cd norns ./bootstrap mkdir <build-dir> cd <build-dir> ./configure --prefix=<install-dir> --sysconfdir=<config-dir> make Loading src/api/local-endpoint.hpp +3 −2 Original line number Diff line number Diff line Loading @@ -43,7 +43,8 @@ namespace api { template <typename Message> class local_endpoint { using DispatcherType = typename session<Message>::Dispatcher; using SessionType = session<ba::local::stream_protocol::socket, Message>; using DispatcherType = typename SessionType::Dispatcher; public: local_endpoint(const bfs::path& sockfile, ba::io_service& ios, Loading @@ -61,7 +62,7 @@ public: m_acceptor.async_accept(m_socket, [this](const boost::system::error_code& ec) { if(!ec) { std::make_shared<session<Message>>( std::make_shared<SessionType>( std::move(m_socket), m_dispatcher )->start(); } Loading src/api/remote-endpoint.hpp +3 −2 Original line number Diff line number Diff line Loading @@ -42,7 +42,8 @@ namespace api { template <typename Message> class remote_endpoint { using DispatcherType = typename session<Message>::Dispatcher; using SessionType = session<ba::ip::tcp::socket, Message>; using DispatcherType = typename SessionType::Dispatcher; public: remote_endpoint(short port, ba::io_service& ios, Loading @@ -61,7 +62,7 @@ public: m_acceptor.async_accept(m_socket, [this](const boost::system::error_code& ec) { if(!ec) { std::make_shared<session<Message>>( std::make_shared<SessionType>( std::move(m_socket), m_dispatcher )->start(); Loading src/api/session.hpp +10 −7 Original line number Diff line number Diff line Loading @@ -46,8 +46,8 @@ template <typename Message> class remote_endpoint; /* helper class for managing communication sessions with a client */ template <typename Message> class session : public std::enable_shared_from_this<session<Message>> { template <typename Socket, typename Message> class session : public std::enable_shared_from_this<session<Socket, Message>> { friend class local_endpoint<Message>; friend class remote_endpoint<Message>; Loading @@ -63,7 +63,7 @@ class session : public std::enable_shared_from_this<session<Message>> { using Output = std::unique_ptr<typename Message::response_type>; public: session(ba::generic::stream_protocol::socket&& socket, session(Socket&& socket, std::shared_ptr<Dispatcher> dispatcher) : m_socket(std::move(socket)), m_dispatcher(dispatcher) {} Loading @@ -79,7 +79,8 @@ public: private: void do_read_request() { auto self(std::enable_shared_from_this<session<Message>>::shared_from_this()); auto self(std::enable_shared_from_this< session<Socket, Message>>::shared_from_this()); std::size_t header_length = m_message.expected_length(Message::header); Loading @@ -99,7 +100,8 @@ private: void do_read_request_body() { auto self(std::enable_shared_from_this<session<Message>>::shared_from_this()); auto self(std::enable_shared_from_this< session<Socket, Message>>::shared_from_this()); std::size_t body_length = m_message.expected_length(Message::body); Loading Loading @@ -148,7 +150,8 @@ private: //Message::print_hex(m_message.buffer(Message::header)); //Message::print_hex(m_message.buffer(Message::body)); auto self(std::enable_shared_from_this<session<Message>>::shared_from_this()); auto self(std::enable_shared_from_this< session<Socket, Message>>::shared_from_this()); ba::async_write(m_socket, buffers, [this, self](boost::system::error_code ec, std::size_t /*length*/){ Loading @@ -161,7 +164,7 @@ private: }); } ba::generic::stream_protocol::socket m_socket; Socket m_socket; Message m_message; std::shared_ptr<Dispatcher> m_dispatcher; }; Loading src/auth/process-credentials.cpp +23 −3 Original line number Diff line number Diff line Loading @@ -31,15 +31,16 @@ namespace norns { namespace auth { #if 0 boost::optional<credentials> credentials::fetch(const ba::generic::stream_protocol::socket& socket) { credentials::fetch(const ba::ip::tcp::socket& socket) { using generic_socket = ba::generic::stream_protocol::socket; using SocketType = ba::ip::tcp::socket; struct ucred ucred; socklen_t len = sizeof(ucred); int sockfd = const_cast<generic_socket&>(socket).native_handle(); int sockfd = const_cast<SocketType&>(socket).native_handle(); if(getsockopt(sockfd, SOL_SOCKET, SO_PEERCRED, &ucred, &len) != -1) { return credentials(ucred.pid, ucred.uid, ucred.gid); Loading @@ -49,6 +50,25 @@ credentials::fetch(const ba::generic::stream_protocol::socket& socket) { } boost::optional<credentials> credentials::fetch(const ba::local::stream_protocol::socket& socket) { using SocketType = ba::local::stream_protocol::socket; struct ucred ucred; socklen_t len = sizeof(ucred); int sockfd = const_cast<SocketType&>(socket).native_handle(); if(getsockopt(sockfd, SOL_SOCKET, SO_PEERCRED, &ucred, &len) != -1) { return credentials(ucred.pid, ucred.uid, ucred.gid); } return boost::none; } #endif credentials::credentials(pid_t pid, uid_t uid, gid_t gid) : m_pid(pid), m_uid(uid), Loading Loading
README.md +12 −3 Original line number Diff line number Diff line Norns Data Scheduler ==================== Dependencies: Build dependencies: - A c++11-conforming compiler - libboost-system >= 1.53 - libboost-filesystem >= 1.53 - libboost-program-options >= 1.53 - libboost-thread >= 1.53 - libprotobuf + protobuf compiler - libprotobuf-c + protobuf-c compiler - Intel TBB yum install tbb-devel - Installation in CentOS 7 git clone git@git.ph.ed.ac.uk:nextgenio/norns.git && cd norns ./bootstrap mkdir <build-dir> cd <build-dir> ./configure --prefix=<install-dir> --sysconfdir=<config-dir> make Loading
src/api/local-endpoint.hpp +3 −2 Original line number Diff line number Diff line Loading @@ -43,7 +43,8 @@ namespace api { template <typename Message> class local_endpoint { using DispatcherType = typename session<Message>::Dispatcher; using SessionType = session<ba::local::stream_protocol::socket, Message>; using DispatcherType = typename SessionType::Dispatcher; public: local_endpoint(const bfs::path& sockfile, ba::io_service& ios, Loading @@ -61,7 +62,7 @@ public: m_acceptor.async_accept(m_socket, [this](const boost::system::error_code& ec) { if(!ec) { std::make_shared<session<Message>>( std::make_shared<SessionType>( std::move(m_socket), m_dispatcher )->start(); } Loading
src/api/remote-endpoint.hpp +3 −2 Original line number Diff line number Diff line Loading @@ -42,7 +42,8 @@ namespace api { template <typename Message> class remote_endpoint { using DispatcherType = typename session<Message>::Dispatcher; using SessionType = session<ba::ip::tcp::socket, Message>; using DispatcherType = typename SessionType::Dispatcher; public: remote_endpoint(short port, ba::io_service& ios, Loading @@ -61,7 +62,7 @@ public: m_acceptor.async_accept(m_socket, [this](const boost::system::error_code& ec) { if(!ec) { std::make_shared<session<Message>>( std::make_shared<SessionType>( std::move(m_socket), m_dispatcher )->start(); Loading
src/api/session.hpp +10 −7 Original line number Diff line number Diff line Loading @@ -46,8 +46,8 @@ template <typename Message> class remote_endpoint; /* helper class for managing communication sessions with a client */ template <typename Message> class session : public std::enable_shared_from_this<session<Message>> { template <typename Socket, typename Message> class session : public std::enable_shared_from_this<session<Socket, Message>> { friend class local_endpoint<Message>; friend class remote_endpoint<Message>; Loading @@ -63,7 +63,7 @@ class session : public std::enable_shared_from_this<session<Message>> { using Output = std::unique_ptr<typename Message::response_type>; public: session(ba::generic::stream_protocol::socket&& socket, session(Socket&& socket, std::shared_ptr<Dispatcher> dispatcher) : m_socket(std::move(socket)), m_dispatcher(dispatcher) {} Loading @@ -79,7 +79,8 @@ public: private: void do_read_request() { auto self(std::enable_shared_from_this<session<Message>>::shared_from_this()); auto self(std::enable_shared_from_this< session<Socket, Message>>::shared_from_this()); std::size_t header_length = m_message.expected_length(Message::header); Loading @@ -99,7 +100,8 @@ private: void do_read_request_body() { auto self(std::enable_shared_from_this<session<Message>>::shared_from_this()); auto self(std::enable_shared_from_this< session<Socket, Message>>::shared_from_this()); std::size_t body_length = m_message.expected_length(Message::body); Loading Loading @@ -148,7 +150,8 @@ private: //Message::print_hex(m_message.buffer(Message::header)); //Message::print_hex(m_message.buffer(Message::body)); auto self(std::enable_shared_from_this<session<Message>>::shared_from_this()); auto self(std::enable_shared_from_this< session<Socket, Message>>::shared_from_this()); ba::async_write(m_socket, buffers, [this, self](boost::system::error_code ec, std::size_t /*length*/){ Loading @@ -161,7 +164,7 @@ private: }); } ba::generic::stream_protocol::socket m_socket; Socket m_socket; Message m_message; std::shared_ptr<Dispatcher> m_dispatcher; }; Loading
src/auth/process-credentials.cpp +23 −3 Original line number Diff line number Diff line Loading @@ -31,15 +31,16 @@ namespace norns { namespace auth { #if 0 boost::optional<credentials> credentials::fetch(const ba::generic::stream_protocol::socket& socket) { credentials::fetch(const ba::ip::tcp::socket& socket) { using generic_socket = ba::generic::stream_protocol::socket; using SocketType = ba::ip::tcp::socket; struct ucred ucred; socklen_t len = sizeof(ucred); int sockfd = const_cast<generic_socket&>(socket).native_handle(); int sockfd = const_cast<SocketType&>(socket).native_handle(); if(getsockopt(sockfd, SOL_SOCKET, SO_PEERCRED, &ucred, &len) != -1) { return credentials(ucred.pid, ucred.uid, ucred.gid); Loading @@ -49,6 +50,25 @@ credentials::fetch(const ba::generic::stream_protocol::socket& socket) { } boost::optional<credentials> credentials::fetch(const ba::local::stream_protocol::socket& socket) { using SocketType = ba::local::stream_protocol::socket; struct ucred ucred; socklen_t len = sizeof(ucred); int sockfd = const_cast<SocketType&>(socket).native_handle(); if(getsockopt(sockfd, SOL_SOCKET, SO_PEERCRED, &ucred, &len) != -1) { return credentials(ucred.pid, ucred.uid, ucred.gid); } return boost::none; } #endif credentials::credentials(pid_t pid, uid_t uid, gid_t gid) : m_pid(pid), m_uid(uid), Loading