diff --git a/Common/GmshSocket.h b/Common/GmshSocket.h index 1614041a7ff228182511034964a04ad50265f095..e8d993b20f127b66f9677867ad8924f33fa03873 100644 --- a/Common/GmshSocket.h +++ b/Common/GmshSocket.h @@ -395,7 +395,7 @@ class GmshServer : public GmshSocket{ } } - if(exe && strlen(exe) && args && strlen(args)){ + if((exe && strlen(exe)) || (args && strlen(args))){ char s[1024]; sprintf(s, args, _sockname.c_str()); NonBlockingSystemCall(exe, s); // starts the solver diff --git a/Common/gmshLocalNetworkClient.cpp b/Common/gmshLocalNetworkClient.cpp index 0554e8d50b90690db55f60759bcbaf1064a21052..3eaa8a66de176d50235076daf3c9a3c897b513db 100644 --- a/Common/gmshLocalNetworkClient.cpp +++ b/Common/gmshLocalNetworkClient.cpp @@ -114,9 +114,15 @@ class onelabGmshServer : public GmshServer{ std::string exe = FixWindowsPath(_client->getExecutable()); std::string args; if(exe.size()){ - std::vector<std::string> cl = onelabUtils::getCommandLine(_client); - for(unsigned int i = 0; i < cl.size(); i++) - args.append(" " + cl[i]); + if(_client->treatExecutableAsFullCommandLine()){ + args = exe; + exe = ""; + } + else{ + std::vector<std::string> cl = onelabUtils::getCommandLine(_client); + for(unsigned int i = 0; i < cl.size(); i++) + args.append(" " + cl[i]); + } args.append(" " + _client->getSocketSwitch() + " \"" + _client->getName() + "\" %s"); } @@ -368,10 +374,10 @@ bool gmshLocalNetworkClient::receiveMessage(gmshLocalNetworkClient *master) { std::string::size_type first = 0; std::string clientName = onelab::parameter::getNextToken(message, first); - std::string exe = onelab::parameter::getNextToken(message, first); + std::string command = onelab::parameter::getNextToken(message, first); if (!onelab::server::instance()->isRegistered(clientName)){ gmshLocalNetworkClient* subClient = - new gmshLocalNetworkClient(clientName, exe); + new gmshLocalNetworkClient(clientName, command, "", true); onelabGmshServer *server = new onelabGmshServer(subClient); subClient->setPid(0); int sock = server->LaunchClient(); diff --git a/Common/gmshLocalNetworkClient.h b/Common/gmshLocalNetworkClient.h index 3dce8eda92b9040f7d331eb540d3bc6e1240a43e..ffb557037985a2efcc29cf74026207003c77706b 100644 --- a/Common/gmshLocalNetworkClient.h +++ b/Common/gmshLocalNetworkClient.h @@ -25,8 +25,10 @@ class gmshLocalNetworkClient : public onelab::localNetworkClient{ gmshLocalNetworkClient *_father; public: gmshLocalNetworkClient(const std::string &name, const std::string &executable, - const std::string &remoteLogin="") - : onelab::localNetworkClient(name, executable, remoteLogin), _father(0) + const std::string &remoteLogin="", + bool treatExecutableAsFullCommandLine=false) + : onelab::localNetworkClient(name, executable, remoteLogin, + treatExecutableAsFullCommandLine), _father(0) { addClient(this); } diff --git a/Common/onelab.h b/Common/onelab.h index 2e9dedd215b71d295429e52e9a6adba2151499d7..fafc38a39c52457f06a5e7c5d8233b9274f5f988 100644 --- a/Common/onelab.h +++ b/Common/onelab.h @@ -1409,6 +1409,10 @@ namespace onelab{ private: // executable of the client (including filesystem path, if necessary) std::string _executable; + // treat the executable name as a full command line (will prevent the + // escaping of the exe name, and will assume that the command line has been + // correcly escaped) + bool _treatExecutableAsFullCommandLine; // command to login to a remote host (if necessary) std::string _remoteLogin; // command line option to specify socket @@ -1419,14 +1423,21 @@ namespace onelab{ GmshServer *_gmshServer; public: localNetworkClient(const std::string &name, const std::string &executable, - const std::string &remoteLogin="") - : localClient(name), _executable(executable), _remoteLogin(remoteLogin), - _socketSwitch("-onelab"), _pid(-1), _gmshServer(0) {} + const std::string &remoteLogin="", + bool treatExecutableAsFullCommandLine=false) + : localClient(name), _executable(executable), + _treatExecutableAsFullCommandLine(treatExecutableAsFullCommandLine), + _remoteLogin(remoteLogin), _socketSwitch("-onelab"), _pid(-1), + _gmshServer(0) {} virtual ~localNetworkClient(){} virtual bool isNetworkClient(){ return true; } const std::string &getExecutable(){ return _executable; } void setExecutable(const std::string &s){ _executable = s; } const std::string &getRemoteLogin(){ return _remoteLogin; } + const bool treatExecutableAsFullCommandLine() + { + return _treatExecutableAsFullCommandLine; + } void setRemoteLogin(const std::string &s){ _remoteLogin = s; } const std::string &getSocketSwitch(){ return _socketSwitch; } void setSocketSwitch(const std::string &s){ _socketSwitch = s; }