Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/neutrinolabs/ulalaca-xrdp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGyuhwan Park <unstabler@unstabler.pl>2022-05-23 14:29:30 +0300
committerGyuhwan Park <unstabler@unstabler.pl>2022-05-23 14:29:30 +0300
commitb6ef5978972f342d072fee852bfc2c211f0171c6 (patch)
tree71c89c493f875654e9e656e972d89b52de05ed1a
parent3869c5880bef0b15e75e111002960af5af8864c9 (diff)
checkpoint(sessionbroker): add some dumb code
-rw-r--r--ulalaca.cpp48
-rw-r--r--ulalaca.hpp2
2 files changed, 47 insertions, 3 deletions
diff --git a/ulalaca.cpp b/ulalaca.cpp
index 9b14d42..c0ffa65 100644
--- a/ulalaca.cpp
+++ b/ulalaca.cpp
@@ -13,6 +13,7 @@
#include <sstream>
#include <string>
+#include "messages/broker.h"
#include "ulalaca.hpp"
#include "SocketStream.hpp"
@@ -122,11 +123,54 @@ int XrdpUlalaca::lib_mod_set_param(XrdpUlalaca *_this, const char *_name, const
}
int XrdpUlalaca::lib_mod_connect(XrdpUlalaca *_this) {
- _this->serverMessage("establishing connection to SessionProjector", 0);
+ std::string socketPath;
+
+ {
+ _this->serverMessage("", 0);
+ UnixSocket brokerSocket("/var/run/ulalaca_broker.sock");
+ brokerSocket.connect();
+
+ {
+ BrokerMessageHeader header {
+ 0,
+ REQUEST_SESSION,
+ 0,
+ sizeof(RequestSession)
+ };
+
+ RequestSession message {};
+
+ std::strncpy(&message.username[0], _this->_username.c_str(), sizeof(message.username));
+ std::strncpy(&message.password[0], _this->_password.c_str(), sizeof(message.password));
+
+ brokerSocket.write(&header, sizeof(header));
+ brokerSocket.write(&message, sizeof(message));
+ }
+ {
+ BrokerMessageHeader header {};
+ brokerSocket.read(&header, sizeof(header));
+
+ if (header.messageType == RESPONSE_REJECTION) {
+ brokerSocket.close();
+ _this->serverMessage("invalid credential", 0);
+ return 1;
+ }
+ if (header.messageType == RESPONSE_SESSION_READY) {
+ SessionReady message {};
+ brokerSocket.read(&message, sizeof(message));
+
+ socketPath = std::string(message.path);
+ }
+ }
+
+ brokerSocket.close();
+ }
try {
+ _this->serverMessage("establishing connection to SessionProjector", 0);
+
_this->_socket = std::make_unique<UnixSocket>(
- _this->getSessionSocketPath(_this->_username)
+ socketPath
);
_this->_socket->connect();
} catch (SystemCallException &e) {
diff --git a/ulalaca.hpp b/ulalaca.hpp
index 808cdb6..e68e3f6 100644
--- a/ulalaca.hpp
+++ b/ulalaca.hpp
@@ -22,7 +22,7 @@ extern "C" {
#include "UnixSocket.hpp"
-#include "UlalacaMessages.hpp"
+#include "messages/projector.h"
class ProjectionThread;