Module: check_mk
Branch: master
Commit: 065c19d5d63312afa3d245f4941c225591d4a4e7
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=065c19d5d63312…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Mon Nov 2 15:41:39 2015 +0100
windows agent: improve the chance to find the powershell interpreter
---
agents/windows/check_mk_agent-64.exe | Bin 830464 -> 831488 bytes
agents/windows/check_mk_agent-64.unversioned.exe | Bin 830464 -> 831488 bytes
agents/windows/check_mk_agent.cc | 11 ++++++++++-
agents/windows/check_mk_agent.exe | Bin 748544 -> 750592 bytes
agents/windows/check_mk_agent.msi | Bin 1837056 -> 1840128 bytes
agents/windows/check_mk_agent.unversioned.exe | Bin 748544 -> 750592 bytes
agents/windows/install_agent-64.exe | Bin 383220 -> 383962 bytes
agents/windows/install_agent.exe | Bin 374150 -> 375181 bytes
8 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/agents/windows/check_mk_agent-64.exe b/agents/windows/check_mk_agent-64.exe
index f83c9b5..84b4ab2 100755
Binary files a/agents/windows/check_mk_agent-64.exe and
b/agents/windows/check_mk_agent-64.exe differ
diff --git a/agents/windows/check_mk_agent-64.unversioned.exe
b/agents/windows/check_mk_agent-64.unversioned.exe
index 5449d1f..757f3d3 100755
Binary files a/agents/windows/check_mk_agent-64.unversioned.exe and
b/agents/windows/check_mk_agent-64.unversioned.exe differ
diff --git a/agents/windows/check_mk_agent.cc b/agents/windows/check_mk_agent.cc
index 6e57734..a30c8d9 100644
--- a/agents/windows/check_mk_agent.cc
+++ b/agents/windows/check_mk_agent.cc
@@ -2255,7 +2255,16 @@ char *add_interpreter(char *path, char *newpath)
// 1.) The powershell interpreter needs to be in PATH
// 2.) The execution policy needs to allow the script execution
// -> Get-ExecutionPolicy / Set-ExecutionPolicy
- snprintf(newpath, 256, "powershell.exe -NoLogo -ExecutionPolicy RemoteSigned
\"& \'%s\'\"", path);
+ //
+ // actually, microsoft always installs the powershell interpreter to the same
+ // directory (independent of the version) so even if it's not in the path,
+ // we have a good chance with this fallback.
+ char dummy;
+ ::SearchPathA(NULL, "powershell.exe", NULL, 1, &dummy, NULL);
+ const char *interpreter = ::GetLastError() != ERROR_FILE_NOT_FOUND
+ ? "powershell.exe"
+ :
"C:\\Windows\\System32\\WindowsPowershell\\v1.0\\powershell.exe";
+ snprintf(newpath, 256, "%s -NoLogo -ExecutionPolicy RemoteSigned
\"& \'%s\'\"", interpreter, path);
return newpath;
}
else if (!strcmp(path + strlen(path) - 3, ".pl")) {
diff --git a/agents/windows/check_mk_agent.exe b/agents/windows/check_mk_agent.exe
index 89c6e01..247a8db 100755
Binary files a/agents/windows/check_mk_agent.exe and b/agents/windows/check_mk_agent.exe
differ
diff --git a/agents/windows/check_mk_agent.msi b/agents/windows/check_mk_agent.msi
index 6dbd461..861e75f 100755
Binary files a/agents/windows/check_mk_agent.msi and b/agents/windows/check_mk_agent.msi
differ
diff --git a/agents/windows/check_mk_agent.unversioned.exe
b/agents/windows/check_mk_agent.unversioned.exe
index 899773f..dab3ac6 100755
Binary files a/agents/windows/check_mk_agent.unversioned.exe and
b/agents/windows/check_mk_agent.unversioned.exe differ
diff --git a/agents/windows/install_agent-64.exe b/agents/windows/install_agent-64.exe
index 872653f..75cc9d7 100755
Binary files a/agents/windows/install_agent-64.exe and
b/agents/windows/install_agent-64.exe differ
diff --git a/agents/windows/install_agent.exe b/agents/windows/install_agent.exe
index 5b14680..40fd66d 100755
Binary files a/agents/windows/install_agent.exe and b/agents/windows/install_agent.exe
differ