diff options
author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2002-06-17 06:27:32 +0000 |
---|---|---|
committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2002-06-17 06:27:32 +0000 |
commit | 043dbb70cbc557bbc5f70a74453e506546148963 (patch) | |
tree | 9dcdd9364879c4ac3384d4e53b2054653964a69b | |
parent | 565fba506fd51acbedc8d06c07b93abae22444a7 (diff) | |
download | zabbix-043dbb70cbc557bbc5f70a74453e506546148963.tar.gz zabbix-043dbb70cbc557bbc5f70a74453e506546148963.tar.xz zabbix-043dbb70cbc557bbc5f70a74453e506546148963.zip |
- php/include/*inc renamed to php/include/*inc.php (Alexei)
- check of source IP address for trapped values (Alexei)
- added include/security.h and include/security.c (Alexei)
- added items.trapper_hosts (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@411 97f52cf1-0a1b-0410-bd0e-c28be96e8082
52 files changed, 152 insertions, 77 deletions
@@ -1,9 +1,6 @@ Not ready yet: -[ CORE. Investigate why new alarm added for unreachable host ] - [ HB. Verify parameters before using them in SQL ] -[ HB. Check IP addresses for trapped parameters ] [ CORE. Support for Service Tree ] [ CORE. If Zabbix is restarted change triggers status to UNKNOWN ] [ CORE. Change trigger status in case if host/item status is changed ] @@ -13,7 +10,6 @@ Not ready yet: [ PHP. Show triggers by userid ] [ PHP. Split include/common.inc ] -[ PHP. Rename *.inc to *.inc.php ] [ CORE. Make one suckerd to send emails ] @@ -28,7 +24,10 @@ snmpget -On localhost public enterprises.ucdavis.memory.memTotalSwap.0] Changes for 1.0beta4: - - new column item.trapper_hosts (Alexei) + - php/include/*inc renamed to php/include/*inc.php (Alexei) + - check of source IP address for trapped values (Alexei) + - added include/security.h and include/security.c (Alexei) + - added items.trapper_hosts (Alexei) - housekeeping period for items to be set in days (Alexei) - authorisation without user name/password (Alexei) - default user "guest" (Alexei) diff --git a/create/mysql/schema.sql b/create/mysql/schema.sql index 76392f3e..e68a5f3f 100644 --- a/create/mysql/schema.sql +++ b/create/mysql/schema.sql @@ -265,6 +265,7 @@ CREATE TABLE items ( prevvalue varchar(255) DEFAULT NULL, status int(4) DEFAULT '0' NOT NULL, value_type int(4) DEFAULT '0' NOT NULL, + trapper_hosts varchar(255) DEFAULT '' NOT NULL, PRIMARY KEY (itemid), UNIQUE shortname (hostid,key_), KEY (hostid), diff --git a/create/postgresql/schema.sql b/create/postgresql/schema.sql index 93a5a4a8..b7125683 100644 --- a/create/postgresql/schema.sql +++ b/create/postgresql/schema.sql @@ -38,6 +38,7 @@ CREATE TABLE items ( lastclock int4 DEFAULT NULL, prevvalue varchar(255) DEFAULT NULL, status int4 DEFAULT '0' NOT NULL, + trapper_hosts varchar(255) DEFAULT '' NOT NULL, PRIMARY KEY (itemid), FOREIGN KEY (hostid) REFERENCES hosts ); diff --git a/frontends/php/about.php b/frontends/php/about.php index c715b7b1..dea2b5e1 100644 --- a/frontends/php/about.php +++ b/frontends/php/about.php @@ -1,5 +1,5 @@ <? - include "include/config.inc"; + include "include/config.inc.php"; $page["title"] = "Abbout Zabbix"; $page["file"] = "about.php"; show_header($page["title"],0,0); diff --git a/frontends/php/actions.php b/frontends/php/actions.php index d092f4bb..5138dd69 100644 --- a/frontends/php/actions.php +++ b/frontends/php/actions.php @@ -2,7 +2,7 @@ $page["title"]="Actions"; $page["file"]="actions.php"; - include "include/config.inc"; + include "include/config.inc.php"; show_header($page["title"],0,0); ?> diff --git a/frontends/php/alarms.php b/frontends/php/alarms.php index 6160ef14..2c26c8a3 100644 --- a/frontends/php/alarms.php +++ b/frontends/php/alarms.php @@ -2,7 +2,7 @@ $page["title"] = "Alarms"; $page["file"] = "alarms.php"; - include "include/config.inc"; + include "include/config.inc.php"; show_header($page["title"],0,0); ?> diff --git a/frontends/php/alerts.php b/frontends/php/alerts.php index f9082f18..be7fb057 100644 --- a/frontends/php/alerts.php +++ b/frontends/php/alerts.php @@ -1,5 +1,5 @@ <? - include "include/config.inc"; + include "include/config.inc.php"; $page["title"] = "Alert history"; $page["file"] = "alerts.php"; show_header($page["title"],30,0); diff --git a/frontends/php/chart.php b/frontends/php/chart.php index 346f3bad..3d59dfd7 100644 --- a/frontends/php/chart.php +++ b/frontends/php/chart.php @@ -1,5 +1,5 @@ <? - include "include/config.inc"; + include "include/config.inc.php"; # PARAMETERS: diff --git a/frontends/php/chart2.php b/frontends/php/chart2.php index 0dacb7bc..48a1301b 100644 --- a/frontends/php/chart2.php +++ b/frontends/php/chart2.php @@ -1,5 +1,5 @@ <? - include "include/config.inc"; + include "include/config.inc.php"; # PARAMETERS: diff --git a/frontends/php/chart_diff.php b/frontends/php/chart_diff.php index 8074afda..a70ea3bd 100644 --- a/frontends/php/chart_diff.php +++ b/frontends/php/chart_diff.php @@ -1,5 +1,5 @@ <? - include "include/config.inc"; + include "include/config.inc.php"; # PARAMETERS: diff --git a/frontends/php/charts.php b/frontends/php/charts.php index ba69bd14..db88d2d4 100644 --- a/frontends/php/charts.php +++ b/frontends/php/charts.php @@ -1,5 +1,5 @@ <? - include "include/config.inc"; + include "include/config.inc.php"; $page["title"] = "User defined graphs"; $page["file"] = "charts.php"; diff --git a/frontends/php/config.php b/frontends/php/config.php index 4b55bcdc..c92afd9a 100644 --- a/frontends/php/config.php +++ b/frontends/php/config.php @@ -2,7 +2,7 @@ $page["title"] = "Configuration of Zabbix"; $page["file"] = "config.php"; - include "include/config.inc"; + include "include/config.inc.php"; show_header($page["title"],0,0); ?> diff --git a/frontends/php/graph.php b/frontends/php/graph.php index bc6e1fa0..e7bc0ce3 100644 --- a/frontends/php/graph.php +++ b/frontends/php/graph.php @@ -1,5 +1,5 @@ <? - include "include/config.inc"; + include "include/config.inc.php"; $page["title"] = "Configuration of graph"; $page["file"] = "graph.php"; show_header($page["title"],0,0); diff --git a/frontends/php/graphs.php b/frontends/php/graphs.php index 7edefd74..2807c1b5 100644 --- a/frontends/php/graphs.php +++ b/frontends/php/graphs.php @@ -1,5 +1,5 @@ <? - include "include/config.inc"; + include "include/config.inc.php"; $page["title"] = "Graphs"; $page["file"] = "graphs.php"; show_header($page["title"],0,0); diff --git a/frontends/php/history.php b/frontends/php/history.php index f29b7a47..fbc27926 100644 --- a/frontends/php/history.php +++ b/frontends/php/history.php @@ -1,7 +1,7 @@ <? $page["file"]="history.php"; - include "include/config.inc"; + include "include/config.inc.php"; $now=time(); diff --git a/frontends/php/hosts.php b/frontends/php/hosts.php index bcc1c12a..c2373e3c 100644 --- a/frontends/php/hosts.php +++ b/frontends/php/hosts.php @@ -1,12 +1,12 @@ <? - include "include/config.inc"; + include "include/config.inc.php"; $page["title"] = "Hosts"; $page["file"] = "hosts.php"; show_header($page["title"],0,0); ?> <? - if(!check_right("Host","W",0)) + if(!check_right("Host","R",0)) { show_table_header("<font color=\"AA0000\">No permissions !</font >"); diff --git a/frontends/php/include/.htaccess b/frontends/php/include/.htaccess index 89b8ddb2..53c662c2 100644 --- a/frontends/php/include/.htaccess +++ b/frontends/php/include/.htaccess @@ -1,7 +1,7 @@ Order Deny,Allow Deny from All -<files config.inc> +<files *.php> Order Deny,Allow Deny from All </files> diff --git a/frontends/php/include/config.inc b/frontends/php/include/config.inc.php index 438cfea8..bb48475d 100644 --- a/frontends/php/include/config.inc +++ b/frontends/php/include/config.inc.php @@ -1,5 +1,5 @@ <? - include "include/db.inc"; + include "include/db.inc.php"; $USER_DETAILS =""; $ERROR_MSG =""; @@ -1219,7 +1219,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; # Update Item definition - function update_item($itemid,$description,$key,$hostid,$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type) + function update_item($itemid,$description,$key,$hostid,$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts) { global $ERROR_MSG; @@ -1234,7 +1234,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; return 0; } - $sql="update items set description='$description',key_='$key',hostid=$hostid,delay=$delay,history=$history,lastdelete=0,nextcheck=0,status=$status,type=$type,snmp_community='$snmp_community',snmp_oid='$snmp_oid',value_type=$value_type where itemid=$itemid"; + $sql="update items set description='$description',key_='$key',hostid=$hostid,delay=$delay,history=$history,lastdelete=0,nextcheck=0,status=$status,type=$type,snmp_community='$snmp_community',snmp_oid='$snmp_oid',value_type=$value_type,trapper_hosts='$trapper_hosts' where itemid=$itemid"; return DBexecute($sql); } @@ -1505,7 +1505,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; # Add Item definition - function add_item($description,$key,$hostid,$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type) + function add_item($description,$key,$hostid,$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts) { global $ERROR_MSG; @@ -1521,7 +1521,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; return 0; } - $sql="insert into items (description,key_,hostid,delay,history,lastdelete,nextcheck,status,type,snmp_community,snmp_oid,value_type) values ('$description','$key',$hostid,$delay,$history,0,0,$status,$type,'$snmp_community','$snmp_oid',$value_type)"; + $sql="insert into items (description,key_,hostid,delay,history,lastdelete,nextcheck,status,type,snmp_community,snmp_oid,value_type,trapper_hosts) values ('$description','$key',$hostid,$delay,$history,0,0,$status,$type,'$snmp_community','$snmp_oid',$value_type,'$trapper_hosts')"; $result=DBexecute($sql); return DBinsert_id($result,"items","itemid"); } @@ -1770,7 +1770,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; $delay=DBget_field($result,$i,3); $value_type=DBget_field($result,$i,4); - $itemid=add_item($description,$key,$hostid,$delay,30*24*3600,0,0,"","",$value_type); + $itemid=add_item($description,$key,$hostid,$delay,30*24*3600,0,0,"","",$value_type,''); $result2=DBselect("select triggertemplateid,description,expression from triggers_template where itemtemplateid=$itemtemplateid"); for($j=0;$j<DBnum_rows($result2);$j++) @@ -1901,7 +1901,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; while($row=DBfetch($result)) { $item=get_item_by_itemid($row["itemid"]); - $itemid=add_item($item["description"],$item["key_"],$hostid,$item["delay"],$item["history"],$item["status"],$item["type"],$item["snmp_community"],$item["snmp_oid"],$item["value_type"]); + $itemid=add_item($item["description"],$item["key_"],$hostid,$item["delay"],$item["history"],$item["status"],$item["type"],$item["snmp_community"],$item["snmp_oid"],$item["value_type"],""); $sql="select distinct t.triggerid from triggers t,functions f where f.itemid=".$row["itemid"]." and f.triggerid=t.triggerid"; $result2=DBselect($sql); diff --git a/frontends/php/include/db.inc b/frontends/php/include/db.inc.php index 2de3acce..2de3acce 100644 --- a/frontends/php/include/db.inc +++ b/frontends/php/include/db.inc.php diff --git a/frontends/php/index.php b/frontends/php/index.php index fd62c39c..96cf5bcc 100644 --- a/frontends/php/index.php +++ b/frontends/php/index.php @@ -2,7 +2,7 @@ $page["title"]="Zabbix main page"; $page["file"]="index.php"; - include "include/config.inc"; + include "include/config.inc.php"; if(isset($reconnect)) { diff --git a/frontends/php/items.php b/frontends/php/items.php index f380e2cd..c2116ac7 100644 --- a/frontends/php/items.php +++ b/frontends/php/items.php @@ -2,7 +2,7 @@ $page["title"] = "Configuration of items"; $page["file"] = "items.php"; - include "include/config.inc"; + include "include/config.inc.php"; show_header($page["title"],0,0); ?> @@ -21,7 +21,7 @@ { if($register=="update") { - $result=update_item($itemid,$description,$key,$hostid,$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type); + $result=update_item($itemid,$description,$key,$hostid,$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts); show_messages($result,"Item updated","Cannot update item"); unset($itemid); } @@ -33,7 +33,7 @@ } if($register=="add") { - $result=add_item($description,$key,$hostid,$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type); + $result=add_item($description,$key,$hostid,$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts); show_messages($result,"Item added","Cannot add item"); unset($itemid); } @@ -184,7 +184,7 @@ if(DBget_field($result,0,0)>0) { echo "<a name=\"form\"></a>"; - @insert_item_form($itemid); + insert_item_form($itemid); } ?> diff --git a/frontends/php/latest.php b/frontends/php/latest.php index ef39b34f..0f501109 100644 --- a/frontends/php/latest.php +++ b/frontends/php/latest.php @@ -1,5 +1,5 @@ <? - include "include/config.inc"; + include "include/config.inc.php"; $page["title"] = "Latest values"; $page["file"] = "latest.php"; show_header($page["title"],0,0); diff --git a/frontends/php/latestalarms.php b/frontends/php/latestalarms.php index e31e1bb1..8487bfb9 100644 --- a/frontends/php/latestalarms.php +++ b/frontends/php/latestalarms.php @@ -2,7 +2,7 @@ $page["title"] = "Latest alarms"; $page["file"] = "latestalarms.php"; - include "include/config.inc"; + include "include/config.inc.php"; show_header($page["title"],30,0); ?> diff --git a/frontends/php/map.php b/frontends/php/map.php index edb41eeb..879c49ab 100644 --- a/frontends/php/map.php +++ b/frontends/php/map.php @@ -1,5 +1,5 @@ <? - include "include/config.inc"; + include "include/config.inc.php"; # PARAMETERS: diff --git a/frontends/php/maps.php b/frontends/php/maps.php index 01148f59..7654505f 100644 --- a/frontends/php/maps.php +++ b/frontends/php/maps.php @@ -1,5 +1,5 @@ <? - include "include/config.inc"; + include "include/config.inc.php"; $page["title"] = "Network maps"; $page["file"] = "maps.php"; diff --git a/frontends/php/media.php b/frontends/php/media.php index 63bdbc4d..73572f6b 100644 --- a/frontends/php/media.php +++ b/frontends/php/media.php @@ -2,7 +2,7 @@ $page["title"] = "Media"; $page["file"] = "media.php"; - include "include/config.inc"; + include "include/config.inc.php"; show_header($page["title"],0,0); ?> diff --git a/frontends/php/queue.php b/frontends/php/queue.php index 21e6c8c5..bd3db8a1 100644 --- a/frontends/php/queue.php +++ b/frontends/php/queue.php @@ -2,7 +2,7 @@ $page["title"] = "Information about monitoring server"; $page["file"] = "queue.php"; - include "include/config.inc"; + include "include/config.inc.php"; show_header($page["title"],10,0); ?> diff --git a/frontends/php/report1.php b/frontends/php/report1.php index 91524b1b..87d50789 100644 --- a/frontends/php/report1.php +++ b/frontends/php/report1.php @@ -1,5 +1,5 @@ <? - include "include/config.inc"; + include "include/config.inc.php"; $page["title"] = "Status of Zabbix"; $page["file"] = "report1.php"; show_header($page["title"],0,0); diff --git a/frontends/php/report2.php b/frontends/php/report2.php index 2a298568..19c9a974 100644 --- a/frontends/php/report2.php +++ b/frontends/php/report2.php @@ -1,5 +1,5 @@ <? - include "include/config.inc"; + include "include/config.inc.php"; $page["title"] = "Availability report"; $page["file"] = "report2.php"; show_header($page["title"],0,0); diff --git a/frontends/php/services.php b/frontends/php/services.php index ad302d51..067c7b2d 100644 --- a/frontends/php/services.php +++ b/frontends/php/services.php @@ -2,7 +2,7 @@ $page["title"] = "High-level representation of monitored data"; $page["file"] = "services.php"; - include "include/config.inc"; + include "include/config.inc.php"; show_header($page["title"],0,0); ?> diff --git a/frontends/php/srv_status.php b/frontends/php/srv_status.php index 139577d5..006f7d62 100644 --- a/frontends/php/srv_status.php +++ b/frontends/php/srv_status.php @@ -2,7 +2,7 @@ $page["title"] = "High-level representation of monitored data"; $page["file"] = "srv_status.php"; - include "include/config.inc"; + include "include/config.inc.php"; show_header($page["title"],0,0); ?> diff --git a/frontends/php/sysmap.php b/frontends/php/sysmap.php index 40078b37..191bde33 100644 --- a/frontends/php/sysmap.php +++ b/frontends/php/sysmap.php @@ -1,5 +1,5 @@ <? - include "include/config.inc"; + include "include/config.inc.php"; $page["title"] = "Configuration of network map"; $page["file"] = "sysmap.php"; show_header($page["title"],0,0); diff --git a/frontends/php/sysmaps.php b/frontends/php/sysmaps.php index a0133059..23a28fea 100644 --- a/frontends/php/sysmaps.php +++ b/frontends/php/sysmaps.php @@ -1,5 +1,5 @@ <? - include "include/config.inc"; + include "include/config.inc.php"; $page["title"] = "Network maps"; $page["file"] = "sysmaps.php"; show_header($page["title"],0,0); diff --git a/frontends/php/tr_comments.php b/frontends/php/tr_comments.php index c8e95c55..f0b73359 100644 --- a/frontends/php/tr_comments.php +++ b/frontends/php/tr_comments.php @@ -2,7 +2,7 @@ $page["title"] = "Trigger comments"; $page["file"] = "tr_comments.php"; - include "include/config.inc"; + include "include/config.inc.php"; show_header($page["title"],0,0); ?> diff --git a/frontends/php/tr_status.php b/frontends/php/tr_status.php index fdf81e34..cfd2d8db 100644 --- a/frontends/php/tr_status.php +++ b/frontends/php/tr_status.php @@ -2,7 +2,7 @@ $page["title"] = "Status of triggers"; $page["file"] = "tr_status.php"; - include "include/config.inc"; + include "include/config.inc.php"; ?> <? $tr_hash=calc_trigger_hash(); diff --git a/frontends/php/trend.php b/frontends/php/trend.php index e66e03d9..53c2c773 100644 --- a/frontends/php/trend.php +++ b/frontends/php/trend.php @@ -1,5 +1,5 @@ <? - include "include/config.inc"; + include "include/config.inc.php"; # PARAMETERS: diff --git a/frontends/php/trends.php b/frontends/php/trends.php index ba327373..3c7c363a 100644 --- a/frontends/php/trends.php +++ b/frontends/php/trends.php @@ -1,5 +1,5 @@ <? - include "include/config.inc"; + include "include/config.inc.php"; $page["title"] = "Latest values"; $page["file"] = "latest.php"; show_header($page["title"],0,0); diff --git a/frontends/php/triggers.php b/frontends/php/triggers.php index 98f4ab11..40b02140 100644 --- a/frontends/php/triggers.php +++ b/frontends/php/triggers.php @@ -2,7 +2,7 @@ $page["title"] = "Configuration of triggers"; $page["file"] = "triggers.php"; - include "include/config.inc"; + include "include/config.inc.php"; show_header($page["title"],0,0); ?> diff --git a/frontends/php/users.php b/frontends/php/users.php index 2682d914..86b5819e 100644 --- a/frontends/php/users.php +++ b/frontends/php/users.php @@ -2,7 +2,7 @@ $page["title"] = "Users"; $page["file"] = "users.php"; - include "include/config.inc"; + include "include/config.inc.php"; show_header($page["title"],0,0); ?> diff --git a/include/db.h b/include/db.h index 440f9eb7..571519f4 100644 --- a/include/db.h +++ b/include/db.h @@ -43,6 +43,7 @@ DB_ITEM char *shortname; char *snmp_community; char *snmp_oid; + char *trapper_hosts; int port; int delay; int history; diff --git a/include/functions.c b/include/functions.c index fdf09d1b..731efa4c 100644 --- a/include/functions.c +++ b/include/functions.c @@ -18,6 +18,7 @@ #include "common.h" #include "db.h" #include "log.h" +#include "security.h" #include "functions.h" #include "expression.h" @@ -761,7 +762,7 @@ int get_lastvalue(char *value,char *host,char *key,char *function,char *paramete /* For zabbix_trapper(d) */ /* int process_data(char *server,char *key, double value)*/ -int process_data(char *server,char *key,char *value) +int process_data(int sockfd,char *server,char *key,char *value) { char sql[MAX_STRING_LEN+1]; @@ -769,7 +770,9 @@ int process_data(char *server,char *key,char *value) DB_ITEM item; char *s; - sprintf(sql,"select i.itemid,i.key_,h.host,h.port,i.delay,i.description,i.nextcheck,i.type,i.snmp_community,i.snmp_oid,h.useip,h.ip,i.history,i.lastvalue,i.prevvalue,i.value_type from items i,hosts h where h.status in (0,2) and h.hostid=i.hostid and h.host='%s' and i.key_='%s' and i.status=%d", server, key, ITEM_TYPE_TRAPPER); + zabbix_log( LOG_LEVEL_DEBUG, "In process_data()"); + + sprintf(sql,"select i.itemid,i.key_,h.host,h.port,i.delay,i.description,i.nextcheck,i.type,i.snmp_community,i.snmp_oid,h.useip,h.ip,i.history,i.lastvalue,i.prevvalue,i.value_type,i.trapper_hosts from items i,hosts h where h.status in (0,2) and h.hostid=i.hostid and h.host='%s' and i.key_='%s' and i.status=%d", server, key, ITEM_TYPE_TRAPPER); result = DBselect(sql); if(DBis_empty(result) == SUCCEED) @@ -777,6 +780,13 @@ int process_data(char *server,char *key,char *value) DBfree_result(result); return FAIL; } + + item.trapper_hosts=DBget_field(result,0,16); + if(check_security(sockfd,item.trapper_hosts,1) == FAIL) + { + DBfree_result(result); + return FAIL; + } item.itemid=atoi(DBget_field(result,0,0)); item.key=DBget_field(result,0,1); diff --git a/include/functions.h b/include/functions.h index 860af003..8009776d 100644 --- a/include/functions.h +++ b/include/functions.h @@ -5,7 +5,7 @@ void update_triggers (int suckers, int flag,int sucker_num,int lastclock); int get_lastvalue(char *value,char *host,char *key,char *function,char *parameter); -int process_data(char *server,char *key, char *value); +int process_data(int sockfd,char *server,char *key, char *value); void process_new_value(DB_ITEM *item,char *value); #endif diff --git a/include/security.c b/include/security.c new file mode 100644 index 00000000..4ec67479 --- /dev/null +++ b/include/security.c @@ -0,0 +1,58 @@ +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> + +#include <string.h> + +#include <errno.h> + +#include "common.h" +#include "log.h" + +int check_security(int sockfd, char *ip_list, int allow_if_empty) +{ + char *sname; + struct sockaddr_in name; + int i; + char *s; + + char tmp[MAX_STRING_LEN+1]; + + zabbix_log( LOG_LEVEL_DEBUG, "In check_security()"); + + if( (1 == allow_if_empty) && (strlen(ip_list)==0) ) + { + return SUCCEED; + } + + i=sizeof(name); + + if(getpeername(sockfd, (struct sockaddr *)&name, (size_t *)&i) == 0) + { + i=sizeof(struct sockaddr_in); + + sname=inet_ntoa(name.sin_addr); + + zabbix_log( LOG_LEVEL_DEBUG, "Connection from [%s]. Allowed servers [%s] ",sname, ip_list); + + strncpy(tmp,ip_list,MAX_STRING_LEN); + s=(char *)strtok(tmp,","); + while(s!=NULL) + { + if(strcmp(sname, s)==0) + { + return SUCCEED; + } + s=(char *)strtok(NULL,","); + } + } + else + { + zabbix_log( LOG_LEVEL_WARNING, "Error getpeername [%s]",strerror(errno)); + zabbix_log( LOG_LEVEL_WARNING, "Connection rejected"); + return FAIL; + } + zabbix_log( LOG_LEVEL_WARNING, "Connection from [%s] rejected. Allowed server is [%s] ",sname, ip_list); + return FAIL; +} diff --git a/include/security.h b/include/security.h new file mode 100644 index 00000000..1a53cfa1 --- /dev/null +++ b/include/security.h @@ -0,0 +1,6 @@ +#ifndef ZABBIX_SECURITY_H +#define ZABBIX_SECURITY_H + +int check_security(int sockfd, char *ip_list, int allow_if_empty); + +#endif diff --git a/src/zabbix_agent/Makefile.in b/src/zabbix_agent/Makefile.in index f87a00c9..6dead4ba 100644 --- a/src/zabbix_agent/Makefile.in +++ b/src/zabbix_agent/Makefile.in @@ -2,8 +2,8 @@ all: - @CC@ -o ../../bin/zabbix_agent @CFLAGS@ -I../../include zabbix_agent.c sysinfo.c ../../include/cfg.c @LIBS@ - @CC@ -o ../../bin/zabbix_agentd @CFLAGS@ -I../../include zabbix_agentd.c sysinfo.c ../../include/log.c ../../include/cfg.c @LIBS@ + @CC@ -o ../../bin/zabbix_agent @CFLAGS@ -I../../include zabbix_agent.c sysinfo.c ../../include/log.c ../../include/cfg.c ../../include/security.c @LIBS@ + @CC@ -o ../../bin/zabbix_agentd @CFLAGS@ -I../../include zabbix_agentd.c sysinfo.c ../../include/log.c ../../include/cfg.c ../../include/security.c @LIBS@ clean: rm -fv *.o diff --git a/src/zabbix_agent/zabbix_agent.c b/src/zabbix_agent/zabbix_agent.c index 74c78264..ae5c6058 100644 --- a/src/zabbix_agent/zabbix_agent.c +++ b/src/zabbix_agent/zabbix_agent.c @@ -21,6 +21,7 @@ #include "common.h" #include "cfg.h" +#include "log.h" #include "sysinfo.h" #include "zabbix_agent.h" @@ -69,7 +70,7 @@ void init_config(void) parse_cfg_file("/etc/zabbix/zabbix_agent.conf",cfg); } - +/* int check_security(void) { char *sname; @@ -98,12 +99,11 @@ int check_security(void) } else { -/* syslog( LOG_WARNING, "Error getpeername [%m]");*/ -/* syslog( LOG_WARNING, "Connection rejected");*/ return FAIL; } return FAIL; } +*/ int main() { @@ -123,9 +123,12 @@ int main() init_config(); +/* Do not create debug files */ + zabbix_open_log(LOG_TYPE_SYSLOG,LOG_LEVEL_EMPTY,NULL); + alarm(CONFIG_TIMEOUT); - if(check_security() == FAIL) + if(check_security(0,CONFIG_HOSTS_ALLOWED,0) == FAIL) { exit(FAIL); } diff --git a/src/zabbix_agent/zabbix_agentd.c b/src/zabbix_agent/zabbix_agentd.c index 55715ca6..85e700b1 100644 --- a/src/zabbix_agent/zabbix_agentd.c +++ b/src/zabbix_agent/zabbix_agentd.c @@ -31,6 +31,7 @@ #include "common.h" #include "sysinfo.h" +#include "security.h" #include "zabbix_agent.h" #include "log.h" @@ -235,7 +236,7 @@ void init_config(void) CONFIG_PID_FILE=strdup("/tmp/zabbix_agentd.pid"); } } - +/* int check_security(int sockfd) { char *sname; @@ -275,6 +276,7 @@ int check_security(int sockfd) zabbix_log( LOG_LEVEL_WARNING, "Connection from [%s] rejected. Allowed server is [%s] ",sname, CONFIG_HOSTS_ALLOWED); return FAIL; } +*/ void process_child(int sockfd) { @@ -384,7 +386,7 @@ void child_main(int i,int listenfd, int addrlen) #ifdef HAVE_FUNCTION_SETPROCTITLE setproctitle("processing request"); #endif - if( check_security(connfd) == SUCCEED) + if( check_security(connfd, CONFIG_HOSTS_ALLOWED, 0) == SUCCEED) { process_child(connfd); } diff --git a/src/zabbix_sucker/Makefile.in b/src/zabbix_sucker/Makefile.in index a327336e..85715e21 100644 --- a/src/zabbix_sucker/Makefile.in +++ b/src/zabbix_sucker/Makefile.in @@ -5,7 +5,7 @@ LIBS = @LIBS@ @MYSQL_LFLAGS@ @PGSQL_LFLAGS@ all: - @CC@ -o ../../bin/zabbix_suckerd @CFLAGS@ -I../../include $(INCLUDE) zabbix_sucker.c ../../include/db.c ../../include/functions.c ../../include/expression.c ../../include/cfg.c ../../include/log.c -Wall $(LIBS) + @CC@ -o ../../bin/zabbix_suckerd @CFLAGS@ -I../../include $(INCLUDE) zabbix_sucker.c ../../include/db.c ../../include/functions.c ../../include/expression.c ../../include/cfg.c ../../include/log.c ../../include/security.c -Wall $(LIBS) clean: rm -fv *.o diff --git a/src/zabbix_trapper/Makefile.in b/src/zabbix_trapper/Makefile.in index c100817a..848419f8 100644 --- a/src/zabbix_trapper/Makefile.in +++ b/src/zabbix_trapper/Makefile.in @@ -5,8 +5,8 @@ LIBS = @LIBS@ @MYSQL_LFLAGS@ @PGSQL_LFLAGS@ all: - @CC@ -o ../../bin/zabbix_trapper @CFLAGS@ $(INCLUDE) -I../../include zabbix_trapper.c ../../include/db.c ../../include/functions.c ../../include/expression.c ../../include/log.c ../../include/cfg.c -Wall $(LIBS) - @CC@ -o ../../bin/zabbix_trapperd @CFLAGS@ $(INCLUDE) -I../../include zabbix_trapperd.c ../../include/db.c ../../include/functions.c ../../include/expression.c ../../include/log.c ../../include/cfg.c -Wall $(LIBS) + @CC@ -o ../../bin/zabbix_trapper @CFLAGS@ $(INCLUDE) -I../../include zabbix_trapper.c ../../include/db.c ../../include/functions.c ../../include/expression.c ../../include/log.c ../../include/cfg.c ../../include/security.c -Wall $(LIBS) + @CC@ -o ../../bin/zabbix_trapperd @CFLAGS@ $(INCLUDE) -I../../include zabbix_trapperd.c ../../include/db.c ../../include/functions.c ../../include/expression.c ../../include/log.c ../../include/cfg.c ../../include/security.c -Wall $(LIBS) clean: rm -fv *.o diff --git a/src/zabbix_trapper/zabbix_trapper.c b/src/zabbix_trapper/zabbix_trapper.c index 7bd834dd..9698311e 100644 --- a/src/zabbix_trapper/zabbix_trapper.c +++ b/src/zabbix_trapper/zabbix_trapper.c @@ -101,7 +101,7 @@ int main() } init_config(); - + fgets(s,MAX_STRING_LEN,stdin); for( p=s+strlen(s)-1; p>s && ( *p=='\r' || *p =='\n' || *p == ' ' ); --p ); p[1]=0; @@ -126,10 +126,8 @@ int main() /* ??? value=atof(value_string);*/ - DBconnect(CONFIG_DBNAME, CONFIG_DBUSER, CONFIG_DBPASSWORD, CONFIG_DBSOCKET); - - ret=process_data(server,key,value_string); + ret=process_data(0,server,key,value_string); alarm(0); @@ -137,10 +135,6 @@ int main() { printf("OK\n"); } - else - { - printf("OK\n"); - } return ret; } diff --git a/src/zabbix_trapper/zabbix_trapperd.c b/src/zabbix_trapper/zabbix_trapperd.c index fe599f57..e820f205 100644 --- a/src/zabbix_trapper/zabbix_trapperd.c +++ b/src/zabbix_trapper/zabbix_trapperd.c @@ -157,15 +157,13 @@ void init_config(void) } } -int process(char *s) +int process(int sockfd,char *s) { char *p; char *server,*key,*value_string; int ret=SUCCEED; - return SUCCEED; - for( p=s+strlen(s)-1; p>s && ( *p=='\r' || *p =='\n' || *p == ' ' ); --p ); p[1]=0; @@ -187,7 +185,7 @@ int process(char *s) return FAIL; } - ret=process_data(server,key,value_string); + ret=process_data(sockfd,server,key,value_string); return ret; } @@ -289,7 +287,7 @@ void process_child(int sockfd) line[nread-1]=0; zabbix_log( LOG_LEVEL_DEBUG, "Got line:%s", line); - if( SUCCEED == process(line) ) + if( SUCCEED == process(sockfd,line) ) { sprintf(result,"OK\n"); } diff --git a/upgrades/dbpatches/1.0beta3_to_1.0beta4/mysql/patch.sql b/upgrades/dbpatches/1.0beta3_to_1.0beta4/mysql/patch.sql index e0cba5cb..00991240 100644 --- a/upgrades/dbpatches/1.0beta3_to_1.0beta4/mysql/patch.sql +++ b/upgrades/dbpatches/1.0beta3_to_1.0beta4/mysql/patch.sql @@ -6,6 +6,8 @@ update config set alarm_history=alarm_history/(24*3600); alter table triggers add status int(4) DEFAULT '0' NOT NULL; alter table triggers add value int(4) DEFAULT '0' NOT NULL; +alter table items add trapper_hosts varchar(255) DEFAULT '' NOT NULL; + update triggers set status=0 where istrue in (0,1,3); update triggers set status=1 where istrue in (2); update triggers set status=2 where istrue in (4); |