--- smsdaemon/plugins/ShellExecPlugin.cpp 2008/06/10 20:25:15 38 +++ smsdaemon/plugins/ShellExecPlugin.cpp 2008/06/16 10:21:02 90 @@ -1,21 +1,34 @@ #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) : Plugin(pluginCommand, std::string("ShellExec: ")+exeCommand ), - _exeCommand(exeCommand) + _exeCommand(exeCommand), + _allowParameters(allowParameters) { } -void ShellExecPlugin::Execute(GsmModem& modem, SMS& sms) +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; + } + int retval = Util::my_system( command.c_str() ); std::string message; if (retval == -1) @@ -23,5 +36,5 @@ else message = "OK"; - modem.SendSms(sms.sender, message ); + modem.SendSms(sms.sender, message, false ); }