Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save BlueSkyDetector/910007 to your computer and use it in GitHub Desktop.
Save BlueSkyDetector/910007 to your computer and use it in GitHub Desktop.
fix net.tcp.dns to enable selecting name server for zabbix-1.8.4
diff -uNrp zabbix-1.8.4.orig/src/libs/zbxsysinfo/common/net.c zabbix-1.8.4/src/libs/zbxsysinfo/common/net.c
--- zabbix-1.8.4.orig/src/libs/zbxsysinfo/common/net.c 2011-01-04 22:57:50.000000000 +0900
+++ zabbix-1.8.4/src/libs/zbxsysinfo/common/net.c 2011-04-09 00:00:13.000000000 +0900
@@ -237,11 +237,6 @@ int NET_TCP_DNS(const char *cmd, const c
ip[0] = '\0';
}
- /* default parameter */
- if(ip[0] == '\0')
- {
- strscpy(ip, "127.0.0.1");
- }
if(get_param(param, 2, zone, MAX_STRING_LEN) != 0)
{
@@ -254,15 +249,18 @@ int NET_TCP_DNS(const char *cmd, const c
strscpy(zone, "localhost");
}
- res = inet_aton(ip, &in);
- if(res != 1)
- {
- SET_UI64_RESULT(result,0);
- return SYSINFO_RET_FAIL;
- }
-
if (!(_res.options & RES_INIT))
res_init();
+ /* default parameter */
+ if ('\0' != ip[0])
+ {
+ if (0 == inet_aton(ip, &in))
+ return SYSINFO_RET_FAIL;
+ _res.nsaddr_list[0].sin_addr = in;
+ _res.nsaddr_list[0].sin_family = AF_INET;
+ _res.nsaddr_list[0].sin_port = htons(NS_DEFAULTPORT);
+ _res.nscount = 1;
+ }
res = res_query(zone, C_IN, T_SOA, (unsigned char *)respbuf, sizeof(respbuf));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment