Module: check_mk
Branch: master
Commit: 858e1984a64cfb0ef6c0dbdc04a41cd8d04f8a49
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=858e1984a64cfb…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Aug 18 20:08:31 2011 +0200
windows agent: Cleaned up plugin command quotings
---
agents/windows/check_mk_agent.cc | 25 +++++++++----------------
agents/windows/check_mk_agent.exe | Bin 97280 -> 97280 bytes
2 files changed, 9 insertions(+), 16 deletions(-)
diff --git a/agents/windows/check_mk_agent.cc b/agents/windows/check_mk_agent.cc
index a40aef7..5803397 100755
--- a/agents/windows/check_mk_agent.cc
+++ b/agents/windows/check_mk_agent.cc
@@ -1068,33 +1068,26 @@ void section_eventlog(SOCKET &out)
char *add_interpreter(char *path, char *newpath)
{
- if (!strcmp(path + strlen(path) - 5, ".vbs\"")) {
+ if (!strcmp(path + strlen(path) - 4, ".vbs")) {
// If this is a vbscript don't rely on the default handler for this
// file extensions. This might be notepad or some other editor by
// default on a lot of systems. So better add cscript as interpreter.
- snprintf(newpath, 256, "cscript.exe //Nologo %s", path);
+ snprintf(newpath, 256, "cscript.exe //Nologo \"%s\"", path);
return newpath;
}
- else if (!strcmp(path + strlen(path) - 5, ".ps1\"")) {
+ else if (!strcmp(path + strlen(path) - 4, ".ps1")) {
// Same for the powershell scripts. Add the powershell interpreter.
// To make this work properly two things are needed:
// 1.) The powershell interpreter needs to be in PATH
// 2.) The execution policy needs to allow the script execution
// -> Get-ExecutionPolicy / Set-ExecutionPolicy
- // Another ugly thing: The commandline syntax of the interpreter.
- // we need to replace the quotes round the path
- // and put the path into single quotes oO.
-
- // Strip the quotes round the string
- char tmppath[256];
- strcpy(tmppath, ++path);
- tmppath[strlen(tmppath) - 1] = '\0';
-
- snprintf(newpath, 256, "powershell.exe -NoLogo -ExecutionPolicy RemoteSigned
\"& \'%s\'\"", tmppath);
+ snprintf(newpath, 256, "powershell.exe -NoLogo -ExecutionPolicy RemoteSigned
\"& \'%s\'\"", path);
+ return newpath;
+ }
+ else {
+ snprintf(newpath, 256, "\"%s\"", path);
return newpath;
}
- else
- return path;
}
void run_plugin(SOCKET &out, char *path)
@@ -1121,7 +1114,7 @@ void run_external_programs(SOCKET &out, char *dirname)
while (0 != (de = readdir(dir))) {
char *name = de->d_name;
if (name[0] != '.') {
- snprintf(path, sizeof(path), "\"%s\\%s\"", dirname,
name);
+ snprintf(path, sizeof(path), "%s\\%s", dirname, name);
run_plugin(out, path);
}
}
diff --git a/agents/windows/check_mk_agent.exe b/agents/windows/check_mk_agent.exe
index 16e6aaf..dca5b54 100755
Binary files a/agents/windows/check_mk_agent.exe and b/agents/windows/check_mk_agent.exe
differ