zbx-sadman / unifi_proxy

Fast client-server version of UniFi Miner
45 stars 21 forks source link

Stack Smashing detected on Zabbix Agent after trying to load module #16

Closed crypticg closed 6 years ago

crypticg commented 6 years ago

Running Ubuntu 14.04 Zabbix Agent 3.0.13 Latest unifi_proxy.

After compiling the latest unifi_proxy, when trying to load it with the zabbix_agent, the zabbix_agent crashes with stack smashing detected

zbx-sadman commented 6 years ago

Show to me link to file that you compile for Agent v3.0.13.

crypticg commented 6 years ago

I am using this one

https://github.com/zbx-sadman/unifi_proxy/blob/master/src/modules/zbx_unifi_Zabbix_3_0/unifi.c

with the Zabbix Agent 3.0.13 source.

zbx-sadman commented 6 years ago

Debian 7.11

A little problem with compilation ("._.. error: ‘MAX_ZBX_DNSNAMELEN’ undeclared here (not in a function)") exists, but after quick fix and making .so i see no any problem with module:

24527:20171116:203457.514 Starting Zabbix Agent [Zabbix server]. Zabbix 3.0.13 (revision 74336).
 24527:20171116:203457.514 **** Enabled features ****
 24527:20171116:203457.514 IPv6 support:           NO
 24527:20171116:203457.514 TLS support:            NO
 24527:20171116:203457.514 **************************
 24527:20171116:203457.514 using configuration file: /usr/local/etc/zabbix_agentd.conf
 24527:20171116:203457.514 In load_modules()
 24527:20171116:203457.514 loading module "/usr/local/sbin/zabbix/unifi.so"
 24527:20171116:203457.514 unifi.so: init module stage
 24527:20171116:203457.514 unifi.so: load & parse config stage. Config file is /usr/local/sbin/zabbix/unifi.conf
 24527:20171116:203457.514 unifi.so: UniFi Proxy host is 'localhost:8448'
 24527:20171116:203457.514 In register_module()
 24527:20171116:203457.514 End of register_module():SUCCEED
 24527:20171116:203457.514 loaded modules: unifi.so
 24527:20171116:203457.514 End of load_modules():SUCCEED
 24527:20171116:203457.515 In init_collector_data()
 24527:20171116:203457.515 In zbx_dshm_create() proj_id:112 size:0
crypticg commented 6 years ago

I had that issue too but was able to fix it. Upon compiling, I also get the following output but it still compiles it

unifi.c: In function ‘zbx_module_unifi_proxy’: unifi.c:106:13: warning: null argument where non-null required (argument 2) [-Wnonnull] strcat(send_buf, get_rparam(request, i));

zbx-sadman commented 6 years ago

I can't explain it at this time, because I have no errors:

root@keeper:/home/test/zabbix-3.0.13/src/modules/unifi# make
gcc -fPIC -shared -o unifi.so unifi.c -I ../../../include
In file included from unifi.c:3:0:
../../../include/comms.h:101:15: error: ‘MAX_ZBX_DNSNAME_LEN’ undeclared here (not in a function)
make: *** [unifi] Error 1
root@keeper:/home/test/zabbix-3.0.13/src/modules/unifi# make
gcc -fPIC -shared -o unifi.so unifi.c -I ../../../include
root@keeper:/home/test/zabbix-3.0.13/src/modules/unifi# ls -la unifi.so
-rwxr-xr-x 1 root root 11729 Nov 16 20:51 unifi.so
zbx-sadman commented 6 years ago

Refer to answer for issue #18

zbx-sadman commented 6 years ago

Try to use updated code of loadble module: https://github.com/zbx-sadman/unifi_proxy/tree/master/src/modules/zbx_unifi_Zabbix_3_0

# /usr/sbin/zabbix_agentd -V
zabbix_agentd (daemon) (Zabbix) 3.0.13
Revision 74336 7 November 2017, compilation time: Nov 23 2017 16:14:06

# /usr/sbin/zabbix_agentd -t unifi.proxy[discovery,wlan]
unifi.proxy[discovery,wlan]                   [s|{"data":[{"{#SITENAME}":"default",...{#SITEDESC}":"South"}]}]