-
Incident report
-
Resolution: Duplicate
-
Minor
-
None
-
2.0.5, 2.1.0
I've decided to create separate issue disregarding that we have already ZBX-3783 because I'll mention server side, maybe there also will be something to change/fix - all is up to you.
I'm creating this issue based on a real case happened.
My perl script resolved a host name to IP and mistakenly added one line break at the end of IP address. Then the script updates host's IP using zabbix API.
By API method "hostinterface.update" I was able to successfully put these params:
{ "interfaceid": "11", "ip": "10.20.0.71\n" }
As it look then (note here the line break):
mysql> select * from interface where hostid=10094;
+-------------+--------+------+------+-------+-------------+----------------+-------+
| interfaceid | hostid | main | type | useip | ip | dns | port |
+-------------+--------+------+------+-------+-------------+----------------+-------+
| 11 | 10094 | 1 | 1 | 0 | 10.20.0.71
| 2008serverNEW2 | 10050 |
+-------------+--------+------+------+-------+-------------+----------------+-------+
As it should look if there no line break:
mysql> select * from interface where hostid=10094;
+-------------+--------+------+------+-------+------------+----------------+-------+
| interfaceid | hostid | main | type | useip | ip | dns | port |
+-------------+--------+------+------+-------+------------+----------------+-------+
| 11 | 10094 | 1 | 1 | 0 | 10.20.0.71 | 2008serverNEW2 | 10050 |
+-------------+--------+------+------+-------+------------+----------------+-------+
This line break of course is not visible in frontend.
So it's bad that API allows to do that -> has to be fixed.
Server side:
IF server/proxy compiled with IPv6 support then it is able to process the IP address with a line break(s) at the end.
But without IPv6 support an agent goes to unavailable. Error message text in frontend is (the line break preserved here !):
"Get value from agent failed: gethostbyname() failed for '10.20.0.71
': [1] Unknown host"
Such problem becomes very unclear - what is bad actually.
Difference is that with IPv6 server/proxy uses "getaddrinfo()" system call, but without IPv6 - another system call - "gethostbyname()".
See comms.c lines 282 and 348
I don't know why it is so.
"# man gethostbyname" says that, quote:
" The gethostbyname*() and gethostbyaddr*() functions are obsolete. Applications should use getaddrinfo(3) and getnameinfo(3) instead.
...
This page is part of release 3.27 of the Linux man-pages project."
As we see the getaddrinfo() (used with IPv6) is more, say, "robust" in our case
So question to C devs - is this good/required to use namely gethostbyname() there in zabbix code ?
- duplicates
-
ZBX-3783 Proper API validation
- Reopened