|
@@ -4,6 +4,9 @@
|
|
|
#include <algorithm>
|
|
|
#include <cstdlib>
|
|
|
#include <thread>
|
|
|
+#include <unistd.h>
|
|
|
+#include <sys/types.h>
|
|
|
+#include <sys/wait.h>
|
|
|
|
|
|
#include "networkOrchestrator.hpp"
|
|
|
|
|
@@ -17,7 +20,7 @@
|
|
|
* START UP AND SHUT DOWN INSTANCES
|
|
|
*/
|
|
|
|
|
|
-int start_remote_actor(
|
|
|
+void start_remote_actor(
|
|
|
const std::string& target,
|
|
|
bool server,
|
|
|
const std::string& id,
|
|
@@ -25,16 +28,77 @@ int start_remote_actor(
|
|
|
size_t lambda,
|
|
|
bool maliciousServers)
|
|
|
{
|
|
|
- std::stringstream buffer;
|
|
|
- std::string command;
|
|
|
+ const char* sshFile = "ssh";
|
|
|
+ const char* serverFile = "bin/server";
|
|
|
+ const char* clientFile = "bin/client";
|
|
|
+ const char* calledFile = (target != "tick0" && !target.empty() ? sshFile : (server ? serverFile : clientFile));
|
|
|
|
|
|
- if (target != "tick0" && !target.empty())
|
|
|
- buffer << "ssh -n " << target << " \"~/prsona/prsona/scripts/startup.sh " << (server ? "server " : "client ") << id << " " << output << " " << lambda << (maliciousServers ? " T\" &" : " F\" &");
|
|
|
+ char *argv[6];
|
|
|
+
|
|
|
+ char fileBuffer[11];
|
|
|
+ strncpy(fileBuffer, calledFile, 11);
|
|
|
+ argv[0] = fileBuffer;
|
|
|
+
|
|
|
+ char flagBuffer[3];
|
|
|
+ strncpy(flagBuffer, "-n", 3);
|
|
|
+
|
|
|
+ char targetBuffer[64];
|
|
|
+ strncpy(targetBuffer, target.c_str(), 64);
|
|
|
+
|
|
|
+ std::string fullArgString;
|
|
|
+ char fullArgBuffer[256];
|
|
|
+
|
|
|
+ char idBuffer[64];
|
|
|
+ strncpy(idBuffer, id.c_str(), 64);
|
|
|
+
|
|
|
+ char outputBuffer[128];
|
|
|
+ strncpy(outputBuffer, output.c_str(), 128);
|
|
|
+
|
|
|
+ std::stringstream lambdaStream;
|
|
|
+ lambdaStream << lambda;
|
|
|
+ char lambdaBuffer[3];
|
|
|
+ strncpy(lambdaBuffer, lambdaStream.str().c_str(), 3);
|
|
|
+
|
|
|
+ char maliciousBuffer[2];
|
|
|
+ if (maliciousServers)
|
|
|
+ strncpy(maliciousBuffer, "T", 2);
|
|
|
else
|
|
|
- buffer << "bin/" << (server ? "server " : "client ") << id << " " << output << " " << lambda << (maliciousServers ? " T &" : " F &");
|
|
|
- command = buffer.str();
|
|
|
+ strncpy(maliciousBuffer, "F", 2);
|
|
|
|
|
|
- return system(command.c_str());
|
|
|
+ if (target != "tick0" && !target.empty())
|
|
|
+ {
|
|
|
+ fullArgString = "~/prsona/prsona/scripts/startup.sh ";
|
|
|
+ fullArgString += (server ? "server" : "client");
|
|
|
+ fullArgString += " ";
|
|
|
+ fullArgString += id;
|
|
|
+ fullArgString += " ";
|
|
|
+ fullArgString += output;
|
|
|
+ fullArgString += " ";
|
|
|
+ fullArgString += lambdaStream.str();
|
|
|
+ fullArgString += " ";
|
|
|
+ fullArgString += (maliciousServers ? "T" : "F");
|
|
|
+
|
|
|
+ strncpy(fullArgBuffer, fullArgString.c_str(), 256);
|
|
|
+
|
|
|
+ argv[1] = flagBuffer;
|
|
|
+ argv[2] = targetBuffer;
|
|
|
+ argv[3] = fullArgBuffer;
|
|
|
+ argv[4] = NULL;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ argv[1] = idBuffer;
|
|
|
+ argv[2] = outputBuffer;
|
|
|
+ argv[3] = lambdaBuffer;
|
|
|
+ argv[4] = maliciousBuffer;
|
|
|
+ argv[5] = NULL;
|
|
|
+ }
|
|
|
+
|
|
|
+ int pid = fork();
|
|
|
+ if (pid < 0)
|
|
|
+ exit(1);
|
|
|
+ if (pid == 0)
|
|
|
+ execv(calledFile, argv);
|
|
|
}
|
|
|
|
|
|
void shut_down_remote_actors(
|