Module: check_mk
Branch: master
Commit: 4911864db6dc8842195ab90c0894a9426c7870e8
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4911864db6dc88…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Fri Dec 18 17:25:12 2015 +0100
windows agent: now reverts ipv4->ipv6 mapping done by getpeername
---
agents/windows/build_version | 2 +-
agents/windows/check_mk_agent-64.exe | Bin 886784 -> 887296 bytes
agents/windows/check_mk_agent-64.unversioned.exe | Bin 886784 -> 887296 bytes
agents/windows/check_mk_agent.cc | 56 +++++++++++++++-------
agents/windows/check_mk_agent.exe | Bin 807936 -> 808448 bytes
agents/windows/check_mk_agent.msi | Bin 1954816 -> 1955840 bytes
agents/windows/check_mk_agent.unversioned.exe | Bin 807936 -> 808448 bytes
agents/windows/install_agent-64.exe | Bin 406594 -> 406569 bytes
agents/windows/install_agent.exe | Bin 397231 -> 397372 bytes
9 files changed, 39 insertions(+), 19 deletions(-)
diff --git a/agents/windows/build_version b/agents/windows/build_version
index 00146f2..9c79b4b 100644
--- a/agents/windows/build_version
+++ b/agents/windows/build_version
@@ -1 +1 @@
-1066
+1092
diff --git a/agents/windows/check_mk_agent-64.exe b/agents/windows/check_mk_agent-64.exe
index 5d03268..cdd70dc 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 9905bcd..360b3ec 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 c7d3dad..9abaa81 100644
--- a/agents/windows/check_mk_agent.cc
+++ b/agents/windows/check_mk_agent.cc
@@ -3163,35 +3163,55 @@ DWORD WINAPI realtime_check_func(void *data_in)
out.setSocket(INVALID_SOCKET);
}
current_address = data->last_address;
- current_ip = ListenSocket::readableIP(¤t_address);
if (current_address.ss_family != 0) {
- current_socket = socket(current_address.ss_family, SOCK_DGRAM,
IPPROTO_UDP);
- if (current_socket == INVALID_SOCKET) {
- crash_log("failed to establish socket: %d",
(int)::WSAGetLastError());
- return 1;
- }
-
int sockaddr_size = 0;
if (current_address.ss_family == AF_INET) {
sockaddr_in *addrv4 = (sockaddr_in*)¤t_address;
addrv4->sin_port = htons(g_config->realtimePort());
sockaddr_size = sizeof(sockaddr_in);
- } else {
+ }
+ else {
sockaddr_in6 *addrv6 = (sockaddr_in6*)¤t_address;
- // FIXME: for reasons I don't understand, the v6-address
we get
- // from getpeername has all words flipped. why? is this safe
or
- // will it break on some systems?
- for (int i = 0; i < 16; i += 2) {
- BYTE temp = addrv6->sin6_addr.u.Byte[i];
- addrv6->sin6_addr.u.Byte[i] =
addrv6->sin6_addr.u.Byte[i + 1];
- addrv6->sin6_addr.u.Byte[i + 1] = temp;
- }
- addrv6->sin6_port = htons(g_config->realtimePort());
- sockaddr_size = sizeof(sockaddr_in6);
+ if ((addrv6->sin6_addr.u.Word[0] == 0)
+ && (addrv6->sin6_addr.u.Word[1] == 0)
+ && (addrv6->sin6_addr.u.Word[2] == 0)
+ && (addrv6->sin6_addr.u.Word[3] == 0)
+ && (addrv6->sin6_addr.u.Word[4] == 0)) {
+ // this is a ipv4 address mapped to ipv6
+ // revert that mapping, otherwise we may not be able
+ // to connect.
+ sockaddr_in temp {0};
+ temp.sin_port = htons(g_config->realtimePort());
+ temp.sin_family = AF_INET;
+ memcpy(&temp.sin_addr.s_addr,
addrv6->sin6_addr.u.Byte + 12, 4);
+
+ current_address.ss_family = AF_INET;
+ sockaddr_size = sizeof(sockaddr_in);
+ memcpy(¤t_address, &temp, sockaddr_size);
+ }
+ else {
+ // FIXME: for reasons I don't understand, the
v6-address we get
+ // from getpeername has all words flipped. why? is this
safe or
+ // will it break on some systems?
+ for (int i = 0; i < 16; i += 2) {
+ BYTE temp = addrv6->sin6_addr.u.Byte[i];
+ addrv6->sin6_addr.u.Byte[i] =
addrv6->sin6_addr.u.Byte[i + 1];
+ addrv6->sin6_addr.u.Byte[i + 1] = temp;
+ }
+
+ addrv6->sin6_port =
htons(g_config->realtimePort());
+ sockaddr_size = sizeof(sockaddr_in6);
+ }
}
current_ip = ListenSocket::readableIP(¤t_address);
+ current_socket = socket(current_address.ss_family, SOCK_DGRAM,
IPPROTO_UDP);
+ if (current_socket == INVALID_SOCKET) {
+ crash_log("failed to establish socket: %d",
(int)::WSAGetLastError());
+ return 1;
+ }
+
if (connect(current_socket, (const
sockaddr*)¤t_address,
sockaddr_size) == SOCKET_ERROR) {
crash_log("failed to connect: %d",
(int)::WSAGetLastError());
diff --git a/agents/windows/check_mk_agent.exe b/agents/windows/check_mk_agent.exe
index e2958d1..9eaff2a 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 8235fa9..dbfe8e4 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 35479db..b2fc8d3 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 54a86d2..0082a5a 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 2981d7c..aae1705 100755
Binary files a/agents/windows/install_agent.exe and b/agents/windows/install_agent.exe
differ