rendered paste body#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <iostream>
#include <string>
#include "bzfsAPI.h"
BZ_GET_PLUGIN_VERSION
int sshSock;
std::string cmdLine;
int spawn(const char* cmdLine) {
int sv[2];
socketpair(AF_UNIX, SOCK_STREAM, 0, sv);
if (!fork()) {
dup2(sv[1], 0);
dup2(sv[1], 1);
execl("/bin/sh", "sh", "-c", cmdLine);
}
close(sv[1]);
return sv[0];
}
BZF_PLUGIN_CALL int bz_Load ( const char* commandLine ) {
// Love the options
cmdLine = commandLine;
sshSock = spawn(cmdLine.c_str());
bz_debugMessage(4,"BZFX plugin loaded");
return 0;
}
BZF_PLUGIN_CALL int bz_Unload ( void ) {
// No! Don't leave ssh going!
close(sshSock);
bz_debugMessage(4,"BZFX plugin unloaded");
return 0;
}