--- smsdaemon/plugins/ShellExecPlugin.cpp 2008/06/11 08:25:34 44 +++ smsdaemon/plugins/ShellExecPlugin.cpp 2008/06/19 14:47:52 107 @@ -1,27 +1,52 @@ #include "ShellExecPlugin.h" -#include "GsmModem.h" +#include "IGsmModem.h" +#include "Sms.h" #include "util.h" -ShellExecPlugin::ShellExecPlugin(std::string pluginCommand, std::string exeCommand) +ShellExecPlugin::ShellExecPlugin(std::string pluginCommand, std::string exeCommand, bool allowParameters, bool returnOutput) : Plugin(pluginCommand, std::string("ShellExec: ")+exeCommand ), - _exeCommand(exeCommand) + _exeCommand(exeCommand), + _allowParameters(allowParameters), + _returnOutput(returnOutput) { } void ShellExecPlugin::Execute(IGsmModem& modem, SMS& sms) { - std::string parameters = GetSmsData(sms); - parameters = Util::str_replace(parameters,";"); + std::string command = _exeCommand; - std::string command = _exeCommand + " " + parameters; - int retval = ::system( command.c_str() ); + if (_allowParameters) + { + std::string parameters = GetSmsData(sms); + + parameters = Util::str_replace(parameters, "||"); + parameters = Util::str_replace(parameters, "&&"); + parameters = Util::str_replace(parameters, ";"); + parameters = Util::str_replace(parameters, "'"); + parameters = Util::str_replace(parameters, "\""); + + command += " "; + command += parameters; + } + std::string output; + std::string* out_p = 0; + + if (_returnOutput) + out_p = &output; + + int retval = Util::my_system( command.c_str(), out_p ); std::string message; if (retval == -1) message = "Error"; else - message = "OK"; + { + if (_returnOutput) + message = output; + else + message = "OK"; + } - modem.SendSms(sms.sender, message ); + modem.SendSms(sms.sender, message, false ); }