From a698f68ebf44c4761204789f740b67c08dab012e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Fri, 9 Nov 2012 00:16:24 +0100 Subject: [PATCH 01/42] Minor glitches, better documentation, Req. php - Remove further references to /usr/local in configuration files - Improve documentation, finishing the TODOs - Explicitly require php again, as it turned out necessary --- zabbix-fedora.README | 69 +++++++++++++++++++++++--------------------- zabbix20.spec | 23 ++++++++++++--- 2 files changed, 55 insertions(+), 37 deletions(-) diff --git a/zabbix-fedora.README b/zabbix-fedora.README index 703a9e2..9dba2c9 100644 --- a/zabbix-fedora.README +++ b/zabbix-fedora.README @@ -1,21 +1,22 @@ +#TODO: SELinux =Custom in Fedora= -_Web configuration_ +==Web configuration== Web configuration resides in /etc/zabbix/web. -_Log files_ +==Log files== Log files are located in /var/log/zabbix. -_Where's my Flash watch?_ +==Where's my Flash watch?== It's not included in Fedora! Fedora's policy does not allow to include blobs. -_No htaccess files_ +==No htaccess files== Fedora ships an Apache configuration file instead. This solutions performs better and is easier to maintain. @@ -23,10 +24,10 @@ better and is easier to maintain. =Additional changes from 1.8 to 2.0 in Fedora= -_Zabbix 2.0 packages conflict Zabbix 1.8_ +==Zabbix 2.0 packages conflict Zabbix 1.8== This measure was taken because this major version introduces various database -schema changes. A silent update would render Zabbix inoperational and possibly +schema changes. A silent update would render Zabbix nonoperational and possibly break the database. Besides that, Zabbix 2.0 server only works with other 2.0 servers and proxies. Distributed setups must therefore be updated at the same time. @@ -34,7 +35,7 @@ time. http://www.zabbix.com/documentation/2.0/manual/appendix/compatibility -_Two users_ +==Two users== There's a certain security risk involved, running agent and proxy/server as the same user. This package therefore introduces an additional zabbixsrv user, used @@ -42,74 +43,76 @@ for proxy and server. Please check the permissions of your scripts and group memberships, if necessary. -_Using the Alternatives system instead of conflicting sub-packages_ +==Using the Alternatives system instead of conflicting sub-packages== You can now install Zabbix proxies or servers compiled for different database -backends on the same system. While this is not intended to happily switch back +back-ends on the same system. While this is not intended to happily switch back and forth, it allows you to: - Stop the daemon -- "Run alternatives --config zabbix-server" or "alternatives --config - zabbix-proxy" +- "Run alternatives --config zabbix-server" or + "alternatives --config zabbix-proxy" - Make your choice - If you're using systemd, run systemctl reload - Adjust the configuration file - Start the daemon -#TODO: Why does it need "restart" in cases? +- In some cases you have to use "restart" instead of "start". + The reason is not yet clear to me. -Alternatives considers the first installed implementation of server or proxy as -default respectively. +"Alternatives" considers the first installed implementation of server or proxy as +default, respectively. -Don't forget to reconfigure the frontend when you switch the server to a +Don't forget to reconfigure the front-end when you switch the server to a different DB implementation! -_Configuration changes_ +==Configuration changes== -Zabbix 2.0 places configuration files directly in /etc and a couple of -sub-directories. Symlinks preserve compatibility. maintenance.inc.php also moved -to /etc/zabbix/web. #TODO: Didn't install *.conf.d directories +Zabbix 2.0 places configuration files directly in /etc. Symlinks preserve +compatibility. maintenance.inc.php moved from /usr/share/zabbix/conf to +/etc/zabbix/web. -_Alert and media scripts_ +==Alert and media scripts== The Alert and media script directories have moved to /var/lib/zabbixsrv. -Symlinks preserver compatibility. +Symlinks preserve compatibility. /var/lib/zabbix is now intended for scripts run by the agent. Please move your server or proxy scripts to /var/lib/zabbixsrv. Be sure to check permissions and ownership. -_No Java bridge_ +==No Java bridge== The Zabbix Java bridge can not be included now, due to legal issue with one of -the modules (json). +the modules (json). See https://support.zabbix.com/browse/ZBX-4800 and feel free +to vote on it. -_No Sqlite frontend or server implementation_ +==No SQLite front-end or server implementation== Sadly it doesn't work with how Fedora's/EPEL's PHP is compiled. -------------------------------------------------------------------------------- -_Guide for updating to 2.0_ +=Guide for updating to 2.0 from 1.8= -http://www.zabbix.com/documentation/2.0/manual/installation/upgrade_notes +http://www.zabbix.com/documentation/2.0/manual/installation/upgrade==notes -Picking the relevant steps from +The below should be the relevant steps, picked from http://www.zabbix.com/documentation/2.0/manual/installation/upgrade -- Stop the Zabbix server/proxy -TODO: Did it already stop when uninstalling 1.8? - Back up the Zabbix database (really!) -- Make sure the database user has sufficing permissions. +- Remove custom database changes, if any +- Make sure the database user has sufficing permissions + (ALTER TABLE, DROP INDEX, DROP TABLE, ...) - Run the fitting database update script/s - The scripts can run very long, depending on the content of your database and - your hardware; A case running 90 hours was reported. 2.0.3 should improve the - situation a lot. + your hardware; +- Check the output of the script for errors - Review all rpmnew and rpmsave files; merge where necessary - Review permissions, ownerships and group memberships for zabbixsrv -Volker Fröhlich volker27@gmx.at Sep 15 2012 +Volker Fröhlich volker27@gmx.at Nov 8 2012 diff --git a/zabbix20.spec b/zabbix20.spec index 5032c2a..a3bfaed 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -36,7 +36,7 @@ Name: zabbix20 Version: 2.0.3 -Release: 3%{?dist} +Release: 4%{?dist} Summary: Open-source monitoring solution for your IT infrastructure Group: Applications/Internet @@ -241,6 +241,9 @@ The Zabbix proxy compiled to use SQLite Summary: Zabbix Web Frontend Group: Applications/Internet BuildArch: noarch +# Don't remove "php". Everything else only depends on php-common +# and you'll end up with no module for Apache +Requires: php Requires: php-gd Requires: php-bcmath Requires: php-mbstring @@ -321,13 +324,18 @@ touch -r frontends/php/css.css frontends/php/include/config.inc.php \ frontends/php/include \ frontends/php/include/classes -# fix config file options +# Adapt configuration file options sed -i \ -e 's|# PidFile=.*|PidFile=%{_localstatedir}/run/%{srcname}/zabbix_agentd.pid|g' \ -e 's|^LogFile=.*|LogFile=%{_localstatedir}/log/%{srcname}/zabbix_agentd.log|g' \ -e 's|# LogFileSize=.*|LogFileSize=0|g' \ + -e 's|/usr/local||g' \ conf/zabbix_agentd.conf +sed -i \ + -e 's|/usr/local||g' \ + conf/zabbix_agent.conf + sed -i \ -e 's|# PidFile=.*|PidFile=%{_localstatedir}/run/%{srcname}/zabbix_server.pid|g' \ -e 's|^LogFile=.*|LogFile=%{_localstatedir}/log/%{srcname}/zabbix_server.log|g' \ @@ -336,6 +344,7 @@ sed -i \ -e 's|^DBUser=root|DBUser=zabbix|g' \ -e 's|# DBSocket=/tmp/mysql.sock|DBSocket=%{_sharedstatedir}/mysql/mysql.sock|g' \ -e 's|# ExternalScripts=\${datadir}/zabbix/externalscripts|ExternalScripts=%{_sharedstatedir}/zabbixsrv/externalscripts|' \ + -e 's|/usr/local||g' \ conf/zabbix_server.conf sed -i \ @@ -345,6 +354,7 @@ sed -i \ -e 's|^DBUser=root|DBUser=zabbix|g' \ -e 's|# DBSocket=/tmp/mysql.sock|DBSocket=%{_sharedstatedir}/mysql/mysql.sock|g' \ -e 's|# ExternalScripts=\${datadir}/zabbix/externalscripts|ExternalScripts=%{_sharedstatedir}/zabbixsrv/externalscripts|' \ + -e 's|/usr/local||g' \ conf/zabbix_proxy.conf #TODO: Ticket @@ -428,14 +438,14 @@ install -m 0755 -p src/zabbix_proxy/zabbix_proxy_* $RPM_BUILD_ROOT%{_sbindir}/ find frontends/php -name '*.orig' -exec rm {} \; cp -a frontends/php $RPM_BUILD_ROOT%{_datadir}/%{srcname} -# prepare ghosted config file +# Prepare ghosted config file #TODO: Simplify that? Like /etc/zabbix_web/zabbix.conf.php? touch $RPM_BUILD_ROOT%{_sysconfdir}/%{srcname}/web/zabbix.conf.php # This file is used to switch the frontend to maintenance mode mv $RPM_BUILD_ROOT%{_datadir}/%{srcname}/conf/maintenance.inc.php $RPM_BUILD_ROOT%{_sysconfdir}/%{srcname}/web/maintenance.inc.php -# drop Apache config file in place +# Drop Apache config file in place install -m 0644 -p %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/httpd/conf.d/%{srcname}.conf # install log rotation @@ -839,6 +849,11 @@ fi %files web-pgsql %changelog +* Thu Nov 8 2012 Volker Fröhlich - 2.0.3-4 +- Require php explicitly again +- Remove traces of /usr/local in configuration files +- Improve Fedora README file + * Sun Oct 14 2012 Volker Fröhlich - 2.0.3-3 - Correct capitalization in unit files, init scripts and package description - Improve sysconfig sourcing in init scripts From 3ab0dd56c4426bd493be16317f00bbc6714efc30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Tue, 13 Nov 2012 22:38:10 +0100 Subject: [PATCH 02/42] Update httpd configuration for Apache 2.4 - Solving BZ#871498 --- zabbix-web.conf | 58 ++++++++++++++++++++++++------------------------- zabbix20.spec | 5 ++++- 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/zabbix-web.conf b/zabbix-web.conf index f784ed8..4e4e237 100644 --- a/zabbix-web.conf +++ b/zabbix-web.conf @@ -7,42 +7,42 @@ Alias /zabbix /usr/share/zabbix Options FollowSymLinks AllowOverride None - Order allow,deny - Allow from all + + + # Apache 2.4 + Require all granted + + + + # Apache 2.2 + Order allow,deny + Allow from all + + - - Order deny,allow - Deny from all - - Order deny,allow - Deny from all - - + + + # Apache 2.4 + Require all denied + - - Order deny,allow - Deny from all - - Order deny,allow - Deny from all - - + + # Apache 2.2 + Order deny,allow + Deny from all + - - Order deny,allow - Deny from all - Order deny,allow - Deny from all - - + + # Apache 2.4 + Require all denied + - - Order deny,allow - Deny from all - + Order deny,allow Deny from all + + diff --git a/zabbix20.spec b/zabbix20.spec index a3bfaed..6838988 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -36,7 +36,7 @@ Name: zabbix20 Version: 2.0.3 -Release: 4%{?dist} +Release: 5%{?dist} Summary: Open-source monitoring solution for your IT infrastructure Group: Applications/Internet @@ -849,6 +849,9 @@ fi %files web-pgsql %changelog +* Tue Nov 13 2012 Volker Fröhlich - 2.0.3-5 +- Adapt httpd configuration file for Apache 2.4 (BZ#871498) + * Thu Nov 8 2012 Volker Fröhlich - 2.0.3-4 - Require php explicitly again - Remove traces of /usr/local in configuration files From e1ddb3874c189feb0780604d30e9e42aac5e65c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Mon, 26 Nov 2012 10:28:37 +0100 Subject: [PATCH 03/42] APPLY FPING PATCH ONLY FOR FEDORA - Fping 3 is not in EPEL --- zabbix20.spec | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/zabbix20.spec b/zabbix20.spec index 6838988..9d9bc8a 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -36,7 +36,7 @@ Name: zabbix20 Version: 2.0.3 -Release: 5%{?dist} +Release: 6%{?dist} Summary: Open-source monitoring solution for your IT infrastructure Group: Applications/Internet @@ -284,7 +284,9 @@ Zabbix web frontend for PostgreSQL %setup0 -q -n %{srcname}-%{version} %patch0 -p1 %patch1 -p1 +%if 0%{?fedora} %patch3 -p1 +%endif # remove flash applet # https://support.zabbix.com/browse/ZBX-4794 @@ -849,6 +851,9 @@ fi %files web-pgsql %changelog +* Mon Nov 26 2012 Volker Fröhlich - 2.0.3-6 +- Apply fping 3 patch only for Fedora + * Tue Nov 13 2012 Volker Fröhlich - 2.0.3-5 - Adapt httpd configuration file for Apache 2.4 (BZ#871498) From f4d7e885aa04151ac0055af6f15427b86bb5172b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Sat, 8 Dec 2012 14:28:37 +0100 Subject: [PATCH 04/42] New release 2.0.4 plus SNMP patch Use upstream patch to solve the issue described in ZBX-3379: SNMP polling breaks if daemon is bound to an interface --- .gitignore | 2 ++ sources | 2 +- zabbix-2.0.3-snmp-source-address.patch | 22 ++++++++++++++++++++++ zabbix20.spec | 14 ++++++++++++-- 4 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 zabbix-2.0.3-snmp-source-address.patch diff --git a/.gitignore b/.gitignore index e9cbecf..723db9c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ /zabbix-2.0.3-free.tar.gz +/zabbix-2.0.4.tar.gz +/zabbix-2.0.4-free.tar.gz diff --git a/sources b/sources index ad543c4..93e4086 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -10c50c7ff5f605139590e1e03c40026d zabbix-2.0.3-free.tar.gz +9762c41929f2fe775ce8238890314a60 zabbix-2.0.4-free.tar.gz diff --git a/zabbix-2.0.3-snmp-source-address.patch b/zabbix-2.0.3-snmp-source-address.patch new file mode 100644 index 0000000..31a3bd0 --- /dev/null +++ b/zabbix-2.0.3-snmp-source-address.patch @@ -0,0 +1,22 @@ +Index: src/zabbix_server/poller/checks_snmp.c +=================================================================== +--- src/zabbix_server/poller/checks_snmp.c (revision 31973) ++++ src/zabbix_server/poller/checks_snmp.c (revision 31978) +@@ -364,7 +364,16 @@ + + #ifdef HAVE_SNMP_SESSION_LOCALNAME + if (NULL != CONFIG_SOURCE_IP) +- session.localname = CONFIG_SOURCE_IP; ++ { ++ /* In some cases specifying just local host (without local port) is not enough. We do */ ++ /* not care about the port number though so we let the OS select one by specifying 0. */ ++ /* See marc.info/?l=net-snmp-bugs&m=115624676507760 for details. */ ++ ++ static char localname[64]; ++ ++ zbx_snprintf(localname, sizeof(localname), "%s:0", CONFIG_SOURCE_IP); ++ session.localname = localname; ++ } + #endif + + SOCK_STARTUP; diff --git a/zabbix20.spec b/zabbix20.spec index 9d9bc8a..730e8cd 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -35,8 +35,8 @@ %global srcname zabbix Name: zabbix20 -Version: 2.0.3 -Release: 6%{?dist} +Version: 2.0.4 +Release: 1%{?dist} Summary: Open-source monitoring solution for your IT infrastructure Group: Applications/Internet @@ -71,6 +71,9 @@ Patch1: %{srcname}-2.0.3-fonts-config.patch Patch2: %{srcname}-2.0.1-no-flash.patch # adapt for fping3 - https://support.zabbix.com/browse/ZBX-4894 Patch3: %{srcname}-1.8.12-fping3.patch +# Setting source IP address rendered SNMP polling broken +# https://support.zabbix.com/browse/ZBX-3379 +Patch4: %{srcname}-2.0.3-snmp-source-address.patch BuildRequires: mysql-devel BuildRequires: postgresql-devel @@ -287,6 +290,7 @@ Zabbix web frontend for PostgreSQL %if 0%{?fedora} %patch3 -p1 %endif +%patch4 -p0 # remove flash applet # https://support.zabbix.com/browse/ZBX-4794 @@ -851,6 +855,12 @@ fi %files web-pgsql %changelog +* Sat Dec 8 2012 Volker Fröhlich - 2.0.4-1 +- New upstream release + +* Fri Dec 7 2012 Volker Fröhlich - 2.0.3-7 +- Add SNMP source IP address patch + * Mon Nov 26 2012 Volker Fröhlich - 2.0.3-6 - Apply fping 3 patch only for Fedora From a9e361ae98c98b764b3001b9e102e0354f73c3e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Mon, 14 Jan 2013 22:20:27 +0100 Subject: [PATCH 05/42] SNMP trap patch ZBX-6101, agent pre-un script - Patch for ZBX-6101, where SNMP traps were not processed in maintenances with data collection - The pre-un scriptlet of the agent was empty for EL - Updated logrotate file with "su" statements for Fedora - Don't own /var/lib/run directories in Fedora --- zabbix-2.0.4-snmptrap.patch | 23 ++++++++++++++++ zabbix-fedora.README | 8 +++--- zabbix-logrotate.in | 1 + zabbix20.spec | 54 +++++++++++++++++++++++++++---------- 4 files changed, 68 insertions(+), 18 deletions(-) create mode 100644 zabbix-2.0.4-snmptrap.patch diff --git a/zabbix-2.0.4-snmptrap.patch b/zabbix-2.0.4-snmptrap.patch new file mode 100644 index 0000000..117dc8e --- /dev/null +++ b/zabbix-2.0.4-snmptrap.patch @@ -0,0 +1,23 @@ +Index: src/libs/zbxdbcache/dbconfig.c +=================================================================== +--- src/libs/zbxdbcache/dbconfig.c (revision 32723) ++++ src/libs/zbxdbcache/dbconfig.c (revision 32724) +@@ -3872,10 +3872,14 @@ + + LOCK_CACHE; + +- if (NULL == (dc_interface = zbx_hashset_search(&config->interfaces, &interfaceid)) || +- NULL == (dc_host = zbx_hashset_search(&config->hosts, &dc_interface->hostid)) || +- HOST_MAINTENANCE_STATUS_OFF != dc_host->maintenance_status || +- MAINTENANCE_TYPE_NORMAL != dc_host->maintenance_type) ++ if (NULL == (dc_interface = zbx_hashset_search(&config->interfaces, &interfaceid))) ++ goto unlock; ++ ++ if (NULL == (dc_host = zbx_hashset_search(&config->hosts, &dc_interface->hostid))) ++ goto unlock; ++ ++ if (HOST_MAINTENANCE_STATUS_ON == dc_host->maintenance_status && ++ MAINTENANCE_TYPE_NODATA == dc_host->maintenance_type) + { + goto unlock; + } diff --git a/zabbix-fedora.README b/zabbix-fedora.README index 9dba2c9..671c140 100644 --- a/zabbix-fedora.README +++ b/zabbix-fedora.README @@ -27,7 +27,7 @@ better and is easier to maintain. ==Zabbix 2.0 packages conflict Zabbix 1.8== This measure was taken because this major version introduces various database -schema changes. A silent update would render Zabbix nonoperational and possibly +schema changes. A silent update would render Zabbix non-operational and possibly break the database. Besides that, Zabbix 2.0 server only works with other 2.0 servers and proxies. Distributed setups must therefore be updated at the same time. @@ -73,10 +73,10 @@ compatibility. maintenance.inc.php moved from /usr/share/zabbix/conf to /etc/zabbix/web. -==Alert and media scripts== +==Media scripts and external scripts== -The Alert and media script directories have moved to /var/lib/zabbixsrv. -Symlinks preserve compatibility. +The directories for external scripts and media scripts have moved to +/var/lib/zabbixsrv. Symlinks preserve compatibility. /var/lib/zabbix is now intended for scripts run by the agent. Please move your server or proxy scripts to /var/lib/zabbixsrv. Be sure to check permissions and diff --git a/zabbix-logrotate.in b/zabbix-logrotate.in index 027da64..c2f9045 100644 --- a/zabbix-logrotate.in +++ b/zabbix-logrotate.in @@ -4,4 +4,5 @@ notifempty compress create 0664 zabbix zabbix + su zabbix zabbix } diff --git a/zabbix20.spec b/zabbix20.spec index 730e8cd..89869b3 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -36,7 +36,7 @@ Name: zabbix20 Version: 2.0.4 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Open-source monitoring solution for your IT infrastructure Group: Applications/Internet @@ -75,6 +75,9 @@ Patch3: %{srcname}-1.8.12-fping3.patch # https://support.zabbix.com/browse/ZBX-3379 Patch4: %{srcname}-2.0.3-snmp-source-address.patch +#https://support.zabbix.com/browse/ZBX-6101 +Patch5: %{srcname}-2.0.4-snmptrap.patch + BuildRequires: mysql-devel BuildRequires: postgresql-devel BuildRequires: sqlite-devel @@ -290,23 +293,29 @@ Zabbix web frontend for PostgreSQL %if 0%{?fedora} %patch3 -p1 %endif -%patch4 -p0 -# remove flash applet +# Logrotate's su option is currently only available in Fedora +%if 0%{?rhel} +sed -i '/su zabbix zabbix/d' %{SOURCE5} +%endif +%patch4 -p0 +%patch5 -p0 + +# Remove flash applet # https://support.zabbix.com/browse/ZBX-4794 %patch2 -p1 rm -f frontend/php/images/flash/zbxclock.swf -# remove bundled java libs +# Remove bundled java libs rm -rf src/zabbix_java/lib/*.jar -# remove prebuilt Windows binaries +# Remove prebuilt Windows binaries rm -rf bin -# remove included fonts +# Remove included fonts rm -rf frontends/php/fonts -# remove executable permissions +# Remove executable permissions chmod a-x upgrades/dbpatches/*/mysql/upgrade # All libraries are expected in /usr/lib or /usr/local/lib @@ -314,7 +323,7 @@ chmod a-x upgrades/dbpatches/*/mysql/upgrade sed -i.orig -e 's|_LIBDIR=/usr/lib|_LIBDIR=%{_libdir}|g' \ configure -# kill off .htaccess files, options set in SOURCE1 +# Kill off .htaccess files, options set in SOURCE1 rm -f frontends/php/include/.htaccess rm -f frontends/php/api/.htaccess rm -f frontends/php/conf/.htaccess @@ -454,12 +463,12 @@ mv $RPM_BUILD_ROOT%{_datadir}/%{srcname}/conf/maintenance.inc.php $RPM_BUILD_ROO # Drop Apache config file in place install -m 0644 -p %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/httpd/conf.d/%{srcname}.conf -# install log rotation -cat %{SOURCE5} | sed -e 's|COMPONENT|agentd|g' > \ +# Install log rotation +sed -e 's|COMPONENT|agentd|g' %{SOURCE5} > \ $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/zabbix-agent -cat %{SOURCE5} | sed -e 's|COMPONENT|server|g' > \ +sed -e 's|COMPONENT|server|g' %{SOURCE5} > \ $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/zabbix-server -cat %{SOURCE5} | sed -e 's|COMPONENT|proxy|g' > \ +sed -e 's|COMPONENT|proxy|g' %{SOURCE5} > \ $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/zabbix-proxy %if 0%{?fedora} @@ -653,6 +662,7 @@ getent passwd zabbixsrv > /dev/null || \ : %preun proxy +#TODO: Use the same style consistently if [ "$1" = 0 ] then %if 0%{?fedora} @@ -666,12 +676,16 @@ fi : %preun agent -%if 0%{?fedora} if [ $1 -eq 0 ] ; then +%if 0%{?fedora} /bin/systemctl --no-reload disable zabbix-agent.service > /dev/null 2>&1 || : /bin/systemctl stop zabbix-agent.service > /dev/null 2>&1 || : -fi +%else + /sbin/service zabbix-agent stop >/dev/null 2>&1 + /sbin/chkconfig --del zabbix-agent %endif +fi +: %postun server %if 0%{?fedora} @@ -755,7 +769,9 @@ fi %files server %doc misc/snmptrap/zabbix_trap_receiver.pl %attr(0775,root,zabbix) %dir %{_localstatedir}/log/zabbix +%if 0%{?rhel} %attr(0775,root,zabbix) %dir %{_localstatedir}/run/zabbix +%endif %attr(0400,zabbixsrv,zabbix) %config(noreplace) %{_sysconfdir}/zabbix_server.conf %config(noreplace) %{_sysconfdir}/%{srcname}/zabbix_server.conf %config(noreplace) %{_sysconfdir}/%{srcname}/externalscripts @@ -787,7 +803,9 @@ fi %files agent %doc conf/zabbix_agentd/*.conf %attr(0775,root,zabbix) %dir %{_localstatedir}/log/zabbix +%if 0%{?rhel} %attr(0775,root,zabbix) %dir %{_localstatedir}/run/zabbix +%endif %config(noreplace) %{_sysconfdir}/zabbix_agent.conf %config(noreplace) %{_sysconfdir}/%{srcname}/zabbix_agent.conf %config(noreplace) %{_sysconfdir}/zabbix_agentd.conf @@ -806,7 +824,9 @@ fi %files proxy %doc misc/snmptrap/zabbix_trap_receiver.pl %attr(0775,root,zabbix) %dir %{_localstatedir}/log/zabbix +%if 0%{?rhel} %attr(0775,root,zabbix) %dir %{_localstatedir}/run/zabbix +%endif %attr(0600,zabbixsrv,zabbix) %config(noreplace) %{_sysconfdir}/zabbix_proxy.conf %config(noreplace) %{_sysconfdir}/%{srcname}/zabbix_proxy.conf %attr(0755,zabbixsrv,zabbix) %dir %{_sysconfdir}/%{srcname}/externalscripts @@ -855,6 +875,12 @@ fi %files web-pgsql %changelog +* Mon Jan 14 2013 Volker Fröhlich - 2.0.4-2 +- Apply patch for ZBX-6101 +- Add su line to logrotate config file +- Do not own /var/run/zabbix on Fedora, systemd manages it +- Add forgotten chkconfig and service commands on agent preun script + * Sat Dec 8 2012 Volker Fröhlich - 2.0.4-1 - New upstream release From 1dad1297e8bd41ca9f34d46064ac9b9769594c8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Thu, 17 Jan 2013 22:28:12 +0100 Subject: [PATCH 06/42] Patch LDAP security issue CVE-2013-1364 --- zabbix-2.0.4-ldap.patch | 66 +++++++++++++++++++++++++++++++++++++++++ zabbix20.spec | 10 ++++++- 2 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 zabbix-2.0.4-ldap.patch diff --git a/zabbix-2.0.4-ldap.patch b/zabbix-2.0.4-ldap.patch new file mode 100644 index 0000000..65d92a8 --- /dev/null +++ b/zabbix-2.0.4-ldap.patch @@ -0,0 +1,66 @@ +Index: frontends/php/authentication.php +=================================================================== +--- frontends/php/authentication.php (revision 32376) ++++ frontends/php/authentication.php (revision 32393) +@@ -101,12 +101,11 @@ + $config['authentication_type'] = $_REQUEST['config']; + + // check login/password +- $login = API::User()->ldapLogin(array( +- 'user' => get_request('user', $USER_DETAILS['alias']), +- 'password' => get_request('user_password', ''), +- 'cnf' => $ldap_cnf +- )); ++ $ldap = new CLdap($ldap_cnf); ++ $ldap->connect(); ++ $login = $ldap->checkPass(get_request('user', $USER_DETAILS['alias']), get_request('user_password', '')); + if (!$login) { ++ error(_('Login name or password is incorrect')); + throw new Exception(); + } + +@@ -129,12 +128,13 @@ + } + elseif (isset($_REQUEST['test'])) { + // check login/password +- $result = API::User()->ldapLogin(array( +- 'user' => get_request('user', $USER_DETAILS['alias']), +- 'password' => get_request('user_password', ''), +- 'cnf' => $ldap_cnf +- )); ++ $ldap = new CLdap($ldap_cnf); ++ $ldap->connect(); ++ $result = $ldap->checkPass(get_request('user', $USER_DETAILS['alias']), get_request('user_password', '')); + ++ if (!$result) ++ error(_('Login name or password is incorrect'));{ ++ } + show_messages($result, _('LDAP login successful'), _('LDAP login was not successful')); + } + } +Index: frontends/php/api/classes/CUser.php +=================================================================== +--- frontends/php/api/classes/CUser.php (revision 32376) ++++ frontends/php/api/classes/CUser.php (revision 32393) +@@ -822,15 +822,12 @@ + // ****************************************************************************** + // LOGIN Methods + // ****************************************************************************** +- public function ldapLogin($user) { +- $cnf = isset($user['cnf']) ? $user['cnf'] : null; +- +- if (is_null($cnf)) { +- $config = select_config(); +- foreach ($config as $id => $value) { +- if (zbx_strpos($id, 'ldap_') !== false) { +- $cnf[str_replace('ldap_', '', $id)] = $config[$id]; +- } ++ protected function ldapLogin($user) { ++ $config = select_config(); ++ $cnf = array(); ++ foreach ($config as $id => $value) { ++ if (zbx_strpos($id, 'ldap_') !== false) { ++ $cnf[str_replace('ldap_', '', $id)] = $config[$id]; + } + } + diff --git a/zabbix20.spec b/zabbix20.spec index 89869b3..3fa01c4 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -36,7 +36,7 @@ Name: zabbix20 Version: 2.0.4 -Release: 2%{?dist} +Release: 3%{?dist} Summary: Open-source monitoring solution for your IT infrastructure Group: Applications/Internet @@ -78,6 +78,10 @@ Patch4: %{srcname}-2.0.3-snmp-source-address.patch #https://support.zabbix.com/browse/ZBX-6101 Patch5: %{srcname}-2.0.4-snmptrap.patch +#https://support.zabbix.com/browse/ZBX-6097 +#CVE-2013-1364 +Patch6: %{srcname}-2.0.4-ldap.patch + BuildRequires: mysql-devel BuildRequires: postgresql-devel BuildRequires: sqlite-devel @@ -300,6 +304,7 @@ sed -i '/su zabbix zabbix/d' %{SOURCE5} %endif %patch4 -p0 %patch5 -p0 +%patch6 -p0 # Remove flash applet # https://support.zabbix.com/browse/ZBX-4794 @@ -875,6 +880,9 @@ fi %files web-pgsql %changelog +* Thu Jan 17 2013 Volker Fröhlich - 2.0.4-3 +- Patch for CVE-2013-1364 + * Mon Jan 14 2013 Volker Fröhlich - 2.0.4-2 - Apply patch for ZBX-6101 - Add su line to logrotate config file From 6afe7903ccc738fae7e9aa04d5f2843cbe565daa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Tue, 22 Jan 2013 11:31:05 +0100 Subject: [PATCH 07/42] Solve conflict between proxy, server and base package - Remove zabbix_get plus manpage from the proxy files section - Solve conflict for externalscripts symlink between proxy and server package --- zabbix20.spec | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/zabbix20.spec b/zabbix20.spec index 3fa01c4..b0bed59 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -834,7 +834,7 @@ fi %endif %attr(0600,zabbixsrv,zabbix) %config(noreplace) %{_sysconfdir}/zabbix_proxy.conf %config(noreplace) %{_sysconfdir}/%{srcname}/zabbix_proxy.conf -%attr(0755,zabbixsrv,zabbix) %dir %{_sysconfdir}/%{srcname}/externalscripts +%config(noreplace) %{_sysconfdir}/%{srcname}/externalscripts %config(noreplace) %{_sysconfdir}/logrotate.d/zabbix-proxy %ghost %{_sbindir}/zabbix_proxy %attr(0755,zabbixsrv,zabbix) %{_sharedstatedir}/%{srcname}srv @@ -843,8 +843,6 @@ fi %else %{_initrddir}/zabbix-proxy %endif -%{_bindir}/zabbix_get -%{_mandir}/man1/zabbix_get.1* %{_mandir}/man8/zabbix_proxy.8* %files proxy-mysql @@ -880,6 +878,11 @@ fi %files web-pgsql %changelog +* Tue Jan 22 2013 Volker Fröhlich - 2.0.4-4 +- Remove zabbix_get plus manpage from the proxy files section +- Solve conflict for externalscripts symlink between proxy and + server package + * Thu Jan 17 2013 Volker Fröhlich - 2.0.4-3 - Patch for CVE-2013-1364 From 662d4681c51f8a3eba4e007a68e9631e6feab09b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Tue, 22 Jan 2013 11:32:33 +0100 Subject: [PATCH 08/42] Bump release number --- zabbix20.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zabbix20.spec b/zabbix20.spec index b0bed59..c06cb83 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -36,7 +36,7 @@ Name: zabbix20 Version: 2.0.4 -Release: 3%{?dist} +Release: 4%{?dist} Summary: Open-source monitoring solution for your IT infrastructure Group: Applications/Internet From 110cd4715df4a3b43cc0ddd9d08479dac7614d50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Sat, 9 Feb 2013 17:41:04 +0100 Subject: [PATCH 09/42] Re-add patch for traceroute path in SQL dumps --- zabbix20.spec | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/zabbix20.spec b/zabbix20.spec index c06cb83..14c0286 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -333,12 +333,11 @@ rm -f frontends/php/include/.htaccess rm -f frontends/php/api/.htaccess rm -f frontends/php/conf/.htaccess -# Remove dispensable COPYING -# https://support.zabbix.com/browse/ZBX-5568 -# Solved for releases after 2.0.3 -rm -rf frontends/php/conf/COPYING +# Fix path to traceroute utility +# Probably obsolete after EL 6 +find database -name 'data.sql' -exec sed -i 's|/usr/bin/traceroute|/bin/traceroute|' {} \; -# set timestamp on modified config file and directories +# Set timestamp on modified config file and directories touch -r frontends/php/css.css frontends/php/include/config.inc.php \ frontends/php/include/defines.inc.php \ frontends/php/include \ @@ -878,6 +877,10 @@ fi %files web-pgsql %changelog +* Sat Feb 9 2013 Volker Fröhlich - 2.0.4-5 +- Dispensable version of COPYING is no more +- Correct path to traceroute in DB dumps again + * Tue Jan 22 2013 Volker Fröhlich - 2.0.4-4 - Remove zabbix_get plus manpage from the proxy files section - Solve conflict for externalscripts symlink between proxy and From 7999746b52713ec45a28479b1d8a4c6126fa34c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Sat, 9 Feb 2013 17:54:51 +0100 Subject: [PATCH 10/42] Correct release number --- zabbix20.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zabbix20.spec b/zabbix20.spec index 14c0286..524a740 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -36,7 +36,7 @@ Name: zabbix20 Version: 2.0.4 -Release: 4%{?dist} +Release: 5%{?dist} Summary: Open-source monitoring solution for your IT infrastructure Group: Applications/Internet From 2934dfdd0e53198985cc894ca5ee4da2654f89ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Mon, 11 Feb 2013 11:37:05 +0100 Subject: [PATCH 11/42] Correct comments on configuration in init scripts The init scripts claimed the configuration was still in /etc/zabbix, which is not the case anymore. --- zabbix-agent.init | 2 +- zabbix-proxy.init | 2 +- zabbix-server.init | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/zabbix-agent.init b/zabbix-agent.init index 02f351d..7e3019d 100644 --- a/zabbix-agent.init +++ b/zabbix-agent.init @@ -3,7 +3,7 @@ # chkconfig: - 86 14 # description: Zabbix agent daemon # processname: zabbix_agentd -# config: /etc/zabbix/zabbix_agentd.conf +# config: /etc/zabbix_agentd.conf # ### BEGIN INIT INFO diff --git a/zabbix-proxy.init b/zabbix-proxy.init index e44be3d..079f2ea 100644 --- a/zabbix-proxy.init +++ b/zabbix-proxy.init @@ -2,7 +2,7 @@ # # chkconfig: - 85 15 # description: Zabbix proxy daemon -# config: /etc/zabbix/zabbix_proxy.conf +# config: /etc/zabbix_proxy.conf # ### BEGIN INIT INFO diff --git a/zabbix-server.init b/zabbix-server.init index 1863a3b..60990ae 100644 --- a/zabbix-server.init +++ b/zabbix-server.init @@ -2,7 +2,7 @@ # # chkconfig: - 85 15 # description: Zabbix server daemon -# config: /etc/zabbix/zabbix_server.conf +# config: /etc/zabbix_server.conf # ### BEGIN INIT INFO From 61acbc797fdc4cb8af5c0237950bd442f50d9b65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Tue, 12 Feb 2013 13:12:59 +0100 Subject: [PATCH 12/42] New upstream release 2.0.5 - Also correct configuration comments in init scripts --- .gitignore | 2 + sources | 2 +- zabbix-2.0.3-snmp-source-address.patch | 22 --------- zabbix-2.0.4-ldap.patch | 66 -------------------------- zabbix-2.0.4-snmptrap.patch | 23 --------- zabbix20.spec | 22 +++------ 6 files changed, 10 insertions(+), 127 deletions(-) delete mode 100644 zabbix-2.0.3-snmp-source-address.patch delete mode 100644 zabbix-2.0.4-ldap.patch delete mode 100644 zabbix-2.0.4-snmptrap.patch diff --git a/.gitignore b/.gitignore index 723db9c..672730a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /zabbix-2.0.3-free.tar.gz /zabbix-2.0.4.tar.gz /zabbix-2.0.4-free.tar.gz +/zabbix-2.0.5.tar.gz +/zabbix-2.0.5-free.tar.gz diff --git a/sources b/sources index 93e4086..280ddc1 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -9762c41929f2fe775ce8238890314a60 zabbix-2.0.4-free.tar.gz +beb0d36bd18abe3ddd4a7c6c0f2b9093 zabbix-2.0.5-free.tar.gz diff --git a/zabbix-2.0.3-snmp-source-address.patch b/zabbix-2.0.3-snmp-source-address.patch deleted file mode 100644 index 31a3bd0..0000000 --- a/zabbix-2.0.3-snmp-source-address.patch +++ /dev/null @@ -1,22 +0,0 @@ -Index: src/zabbix_server/poller/checks_snmp.c -=================================================================== ---- src/zabbix_server/poller/checks_snmp.c (revision 31973) -+++ src/zabbix_server/poller/checks_snmp.c (revision 31978) -@@ -364,7 +364,16 @@ - - #ifdef HAVE_SNMP_SESSION_LOCALNAME - if (NULL != CONFIG_SOURCE_IP) -- session.localname = CONFIG_SOURCE_IP; -+ { -+ /* In some cases specifying just local host (without local port) is not enough. We do */ -+ /* not care about the port number though so we let the OS select one by specifying 0. */ -+ /* See marc.info/?l=net-snmp-bugs&m=115624676507760 for details. */ -+ -+ static char localname[64]; -+ -+ zbx_snprintf(localname, sizeof(localname), "%s:0", CONFIG_SOURCE_IP); -+ session.localname = localname; -+ } - #endif - - SOCK_STARTUP; diff --git a/zabbix-2.0.4-ldap.patch b/zabbix-2.0.4-ldap.patch deleted file mode 100644 index 65d92a8..0000000 --- a/zabbix-2.0.4-ldap.patch +++ /dev/null @@ -1,66 +0,0 @@ -Index: frontends/php/authentication.php -=================================================================== ---- frontends/php/authentication.php (revision 32376) -+++ frontends/php/authentication.php (revision 32393) -@@ -101,12 +101,11 @@ - $config['authentication_type'] = $_REQUEST['config']; - - // check login/password -- $login = API::User()->ldapLogin(array( -- 'user' => get_request('user', $USER_DETAILS['alias']), -- 'password' => get_request('user_password', ''), -- 'cnf' => $ldap_cnf -- )); -+ $ldap = new CLdap($ldap_cnf); -+ $ldap->connect(); -+ $login = $ldap->checkPass(get_request('user', $USER_DETAILS['alias']), get_request('user_password', '')); - if (!$login) { -+ error(_('Login name or password is incorrect')); - throw new Exception(); - } - -@@ -129,12 +128,13 @@ - } - elseif (isset($_REQUEST['test'])) { - // check login/password -- $result = API::User()->ldapLogin(array( -- 'user' => get_request('user', $USER_DETAILS['alias']), -- 'password' => get_request('user_password', ''), -- 'cnf' => $ldap_cnf -- )); -+ $ldap = new CLdap($ldap_cnf); -+ $ldap->connect(); -+ $result = $ldap->checkPass(get_request('user', $USER_DETAILS['alias']), get_request('user_password', '')); - -+ if (!$result) -+ error(_('Login name or password is incorrect'));{ -+ } - show_messages($result, _('LDAP login successful'), _('LDAP login was not successful')); - } - } -Index: frontends/php/api/classes/CUser.php -=================================================================== ---- frontends/php/api/classes/CUser.php (revision 32376) -+++ frontends/php/api/classes/CUser.php (revision 32393) -@@ -822,15 +822,12 @@ - // ****************************************************************************** - // LOGIN Methods - // ****************************************************************************** -- public function ldapLogin($user) { -- $cnf = isset($user['cnf']) ? $user['cnf'] : null; -- -- if (is_null($cnf)) { -- $config = select_config(); -- foreach ($config as $id => $value) { -- if (zbx_strpos($id, 'ldap_') !== false) { -- $cnf[str_replace('ldap_', '', $id)] = $config[$id]; -- } -+ protected function ldapLogin($user) { -+ $config = select_config(); -+ $cnf = array(); -+ foreach ($config as $id => $value) { -+ if (zbx_strpos($id, 'ldap_') !== false) { -+ $cnf[str_replace('ldap_', '', $id)] = $config[$id]; - } - } - diff --git a/zabbix-2.0.4-snmptrap.patch b/zabbix-2.0.4-snmptrap.patch deleted file mode 100644 index 117dc8e..0000000 --- a/zabbix-2.0.4-snmptrap.patch +++ /dev/null @@ -1,23 +0,0 @@ -Index: src/libs/zbxdbcache/dbconfig.c -=================================================================== ---- src/libs/zbxdbcache/dbconfig.c (revision 32723) -+++ src/libs/zbxdbcache/dbconfig.c (revision 32724) -@@ -3872,10 +3872,14 @@ - - LOCK_CACHE; - -- if (NULL == (dc_interface = zbx_hashset_search(&config->interfaces, &interfaceid)) || -- NULL == (dc_host = zbx_hashset_search(&config->hosts, &dc_interface->hostid)) || -- HOST_MAINTENANCE_STATUS_OFF != dc_host->maintenance_status || -- MAINTENANCE_TYPE_NORMAL != dc_host->maintenance_type) -+ if (NULL == (dc_interface = zbx_hashset_search(&config->interfaces, &interfaceid))) -+ goto unlock; -+ -+ if (NULL == (dc_host = zbx_hashset_search(&config->hosts, &dc_interface->hostid))) -+ goto unlock; -+ -+ if (HOST_MAINTENANCE_STATUS_ON == dc_host->maintenance_status && -+ MAINTENANCE_TYPE_NODATA == dc_host->maintenance_type) - { - goto unlock; - } diff --git a/zabbix20.spec b/zabbix20.spec index 524a740..2ba6f7b 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -35,8 +35,8 @@ %global srcname zabbix Name: zabbix20 -Version: 2.0.4 -Release: 5%{?dist} +Version: 2.0.5 +Release: 1%{?dist} Summary: Open-source monitoring solution for your IT infrastructure Group: Applications/Internet @@ -71,16 +71,6 @@ Patch1: %{srcname}-2.0.3-fonts-config.patch Patch2: %{srcname}-2.0.1-no-flash.patch # adapt for fping3 - https://support.zabbix.com/browse/ZBX-4894 Patch3: %{srcname}-1.8.12-fping3.patch -# Setting source IP address rendered SNMP polling broken -# https://support.zabbix.com/browse/ZBX-3379 -Patch4: %{srcname}-2.0.3-snmp-source-address.patch - -#https://support.zabbix.com/browse/ZBX-6101 -Patch5: %{srcname}-2.0.4-snmptrap.patch - -#https://support.zabbix.com/browse/ZBX-6097 -#CVE-2013-1364 -Patch6: %{srcname}-2.0.4-ldap.patch BuildRequires: mysql-devel BuildRequires: postgresql-devel @@ -302,9 +292,6 @@ Zabbix web frontend for PostgreSQL %if 0%{?rhel} sed -i '/su zabbix zabbix/d' %{SOURCE5} %endif -%patch4 -p0 -%patch5 -p0 -%patch6 -p0 # Remove flash applet # https://support.zabbix.com/browse/ZBX-4794 @@ -877,6 +864,11 @@ fi %files web-pgsql %changelog +* Tue Feb 12 2013 Volker Fröhlich - 2.0.5-1 +- New upstream release +- Drop now-included patches +- Init file comments point to the actual configuration files now + * Sat Feb 9 2013 Volker Fröhlich - 2.0.4-5 - Dispensable version of COPYING is no more - Correct path to traceroute in DB dumps again From 3a52765f17656b4515d92f0bd1b5a30704c099c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Thu, 7 Mar 2013 11:48:21 +0100 Subject: [PATCH 13/42] Include patch for ZBX-6290 --- zabbix-2.0.5-zbx6290.patch | 21 +++++++++++++++++++++ zabbix20.spec | 11 ++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 zabbix-2.0.5-zbx6290.patch diff --git a/zabbix-2.0.5-zbx6290.patch b/zabbix-2.0.5-zbx6290.patch new file mode 100644 index 0000000..a75e4f1 --- /dev/null +++ b/zabbix-2.0.5-zbx6290.patch @@ -0,0 +1,21 @@ +Index: frontends/php/include/maps.inc.php +=================================================================== +--- frontends/php/include/maps.inc.php (revision 33831) ++++ frontends/php/include/maps.inc.php (revision 33834) +@@ -1019,14 +1019,14 @@ + } + } + +- // get hosts data ++ // get host inventories + if ($sysmap['iconmapid']) { + $hostInventories = API::Host()->get(array( + 'hostids' => $hostsToGetInventories, + 'output' => API_OUTPUT_SHORTEN, + 'nopermissions' => true, + 'preservekeys' => true, +- 'selectInventory' => array('hostid') ++ 'selectInventory' => API_OUTPUT_EXTEND + )); + } + diff --git a/zabbix20.spec b/zabbix20.spec index 2ba6f7b..122a32e 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -36,7 +36,7 @@ Name: zabbix20 Version: 2.0.5 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Open-source monitoring solution for your IT infrastructure Group: Applications/Internet @@ -72,6 +72,11 @@ Patch2: %{srcname}-2.0.1-no-flash.patch # adapt for fping3 - https://support.zabbix.com/browse/ZBX-4894 Patch3: %{srcname}-1.8.12-fping3.patch +# https://support.zabbix.com/browse/ZBX-6290 +# Icon mapping broken on maps +# Solved in releases after 2.0.5 +Patch4: %{srcname}-2.0.5-zbx6290.patch + BuildRequires: mysql-devel BuildRequires: postgresql-devel BuildRequires: sqlite-devel @@ -287,6 +292,7 @@ Zabbix web frontend for PostgreSQL %if 0%{?fedora} %patch3 -p1 %endif +%patch4 -p0 # Logrotate's su option is currently only available in Fedora %if 0%{?rhel} @@ -864,6 +870,9 @@ fi %files web-pgsql %changelog +* Tue Feb 12 2013 Volker Fröhlich - 2.0.5-2 +- Include patch for ZBX-6290 + * Tue Feb 12 2013 Volker Fröhlich - 2.0.5-1 - New upstream release - Drop now-included patches From 24f44f5b1594fa33794324edeaceeb342205980f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Tue, 19 Mar 2013 13:12:17 +0100 Subject: [PATCH 14/42] Add patch for ZBX-6318 --- zabbix-2.0.5-zbx6318.patch | 13 +++++++++++++ zabbix20.spec | 10 +++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 zabbix-2.0.5-zbx6318.patch diff --git a/zabbix-2.0.5-zbx6318.patch b/zabbix-2.0.5-zbx6318.patch new file mode 100644 index 0000000..fc04ea4 --- /dev/null +++ b/zabbix-2.0.5-zbx6318.patch @@ -0,0 +1,13 @@ +Index: frontends/php/include/db.inc.php +=================================================================== +--- frontends/php/include/db.inc.php (revision 34427) ++++ frontends/php/include/db.inc.php (working copy) +@@ -1087,7 +1087,7 @@ + while (false !== ($valueR = next($values))) { + $valueL = bcadd($valueL, 1, 0); + +- if ($valueR != $valueL) { ++ if (bccomp($valueR, $valueL) != 0) { + if ($len >= $MIN_NUM_BETWEEN) { + $betweens[] = array(bcsub($valueL, $len, 0), bcsub($valueL, 1, 0)); + } diff --git a/zabbix20.spec b/zabbix20.spec index 122a32e..b6904e6 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -36,7 +36,7 @@ Name: zabbix20 Version: 2.0.5 -Release: 2%{?dist} +Release: 3%{?dist} Summary: Open-source monitoring solution for your IT infrastructure Group: Applications/Internet @@ -77,6 +77,10 @@ Patch3: %{srcname}-1.8.12-fping3.patch # Solved in releases after 2.0.5 Patch4: %{srcname}-2.0.5-zbx6290.patch +# Specific node-ids leave the frontend broken +# Solved in releases after 2.0.5 +Patch5: %{srcname}-2.0.5-zbx6318.patch + BuildRequires: mysql-devel BuildRequires: postgresql-devel BuildRequires: sqlite-devel @@ -293,6 +297,7 @@ Zabbix web frontend for PostgreSQL %patch3 -p1 %endif %patch4 -p0 +%patch5 -p0 # Logrotate's su option is currently only available in Fedora %if 0%{?rhel} @@ -870,6 +875,9 @@ fi %files web-pgsql %changelog +* Tue Mar 19 2013 Volker Fröhlich - 2.0.5-3 +- Include patch for ZBX-6318 + * Tue Feb 12 2013 Volker Fröhlich - 2.0.5-2 - Include patch for ZBX-6290 From c4be78932fcac298cf80468550594e5d39b82e42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Mon, 22 Apr 2013 15:29:54 +0200 Subject: [PATCH 15/42] New upstream release 2.0.6 --- .gitignore | 1 + sources | 2 +- zabbix20.spec | 19 ++++++------------- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 672730a..de1b02d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /zabbix-2.0.4-free.tar.gz /zabbix-2.0.5.tar.gz /zabbix-2.0.5-free.tar.gz +/zabbix-2.0.6-free.tar.gz diff --git a/sources b/sources index 280ddc1..bf98dab 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -beb0d36bd18abe3ddd4a7c6c0f2b9093 zabbix-2.0.5-free.tar.gz +d480122e6cfb0983d9946148d82a0b8b zabbix-2.0.6-free.tar.gz diff --git a/zabbix20.spec b/zabbix20.spec index b6904e6..5153ca6 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -35,8 +35,8 @@ %global srcname zabbix Name: zabbix20 -Version: 2.0.5 -Release: 3%{?dist} +Version: 2.0.6 +Release: 1%{?dist} Summary: Open-source monitoring solution for your IT infrastructure Group: Applications/Internet @@ -72,15 +72,6 @@ Patch2: %{srcname}-2.0.1-no-flash.patch # adapt for fping3 - https://support.zabbix.com/browse/ZBX-4894 Patch3: %{srcname}-1.8.12-fping3.patch -# https://support.zabbix.com/browse/ZBX-6290 -# Icon mapping broken on maps -# Solved in releases after 2.0.5 -Patch4: %{srcname}-2.0.5-zbx6290.patch - -# Specific node-ids leave the frontend broken -# Solved in releases after 2.0.5 -Patch5: %{srcname}-2.0.5-zbx6318.patch - BuildRequires: mysql-devel BuildRequires: postgresql-devel BuildRequires: sqlite-devel @@ -296,8 +287,6 @@ Zabbix web frontend for PostgreSQL %if 0%{?fedora} %patch3 -p1 %endif -%patch4 -p0 -%patch5 -p0 # Logrotate's su option is currently only available in Fedora %if 0%{?rhel} @@ -875,6 +864,10 @@ fi %files web-pgsql %changelog +* Mon Apr 22 2013 Volker Fröhlich - 2.0.6-1 +- New upstream release +- Drop ZBX-6290 and ZBX-6318 patches + * Tue Mar 19 2013 Volker Fröhlich - 2.0.5-3 - Include patch for ZBX-6318 From 790a6502301945fed6e26e2c7353b03697bc3019 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Mon, 22 Apr 2013 15:35:44 +0200 Subject: [PATCH 16/42] Remove obsolete patch files --- zabbix-2.0.5-zbx6290.patch | 21 --------------------- zabbix-2.0.5-zbx6318.patch | 13 ------------- 2 files changed, 34 deletions(-) delete mode 100644 zabbix-2.0.5-zbx6290.patch delete mode 100644 zabbix-2.0.5-zbx6318.patch diff --git a/zabbix-2.0.5-zbx6290.patch b/zabbix-2.0.5-zbx6290.patch deleted file mode 100644 index a75e4f1..0000000 --- a/zabbix-2.0.5-zbx6290.patch +++ /dev/null @@ -1,21 +0,0 @@ -Index: frontends/php/include/maps.inc.php -=================================================================== ---- frontends/php/include/maps.inc.php (revision 33831) -+++ frontends/php/include/maps.inc.php (revision 33834) -@@ -1019,14 +1019,14 @@ - } - } - -- // get hosts data -+ // get host inventories - if ($sysmap['iconmapid']) { - $hostInventories = API::Host()->get(array( - 'hostids' => $hostsToGetInventories, - 'output' => API_OUTPUT_SHORTEN, - 'nopermissions' => true, - 'preservekeys' => true, -- 'selectInventory' => array('hostid') -+ 'selectInventory' => API_OUTPUT_EXTEND - )); - } - diff --git a/zabbix-2.0.5-zbx6318.patch b/zabbix-2.0.5-zbx6318.patch deleted file mode 100644 index fc04ea4..0000000 --- a/zabbix-2.0.5-zbx6318.patch +++ /dev/null @@ -1,13 +0,0 @@ -Index: frontends/php/include/db.inc.php -=================================================================== ---- frontends/php/include/db.inc.php (revision 34427) -+++ frontends/php/include/db.inc.php (working copy) -@@ -1087,7 +1087,7 @@ - while (false !== ($valueR = next($values))) { - $valueL = bcadd($valueL, 1, 0); - -- if ($valueR != $valueL) { -+ if (bccomp($valueR, $valueL) != 0) { - if ($len >= $MIN_NUM_BETWEEN) { - $betweens[] = array(bcsub($valueL, $len, 0), bcsub($valueL, 1, 0)); - } From ba458dd0d7841972f825d8c482b825d71c80086d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Mon, 6 May 2013 23:38:50 +0200 Subject: [PATCH 17/42] Solve /var/run permissions, add patch ZBX-6526 - Add patch for ZBX-6526 - Solve permission problem with /var/run/zabbix in Fedora (BZ#904041) --- zabbix-2.0.6-ZBX-6526.patch | 41 +++++++++++++++++++++++++++++++++++++ zabbix-tmpfiles.conf | 2 +- zabbix20.spec | 9 +++++++- 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 zabbix-2.0.6-ZBX-6526.patch diff --git a/zabbix-2.0.6-ZBX-6526.patch b/zabbix-2.0.6-ZBX-6526.patch new file mode 100644 index 0000000..56a1def --- /dev/null +++ b/zabbix-2.0.6-ZBX-6526.patch @@ -0,0 +1,41 @@ +Index: src/zabbix_proxy/servercomms.c +=================================================================== +--- src/zabbix_proxy/servercomms.c (revision 35199) ++++ src/zabbix_proxy/servercomms.c (revision 35235) +@@ -165,7 +165,7 @@ + if (FAIL == send_data_to_server(sock, j->buffer)) + goto exit; + +- if (FAIL == zbx_recv_response(sock, NULL, 0, 0)) ++ if (SUCCEED != zbx_recv_response(sock, NULL, 0, 0)) + goto exit; + + ret = SUCCEED; +Index: src/zabbix_server/server.c +=================================================================== +--- src/zabbix_server/server.c (revision 35199) ++++ src/zabbix_server/server.c (revision 35235) +@@ -588,6 +588,9 @@ + /* need to set trigger status to UNKNOWN since last run */ + DBupdate_triggers_status_after_restart(); + ++ /* make initial configuration sync before worker processes are forked */ ++ DCsync_configuration(); ++ + DBclose(); + + if (ZBX_MUTEX_ERROR == zbx_mutex_create_force(&node_sync_access, ZBX_MUTEX_NODE_SYNC)) +Index: src/zabbix_server/dbconfig/dbconfig.c +=================================================================== +--- src/zabbix_server/dbconfig/dbconfig.c (revision 35199) ++++ src/zabbix_server/dbconfig/dbconfig.c (revision 35235) +@@ -51,6 +51,9 @@ + + zabbix_log(LOG_LEVEL_DEBUG, "In main_dbconfig_loop()"); + ++ /* the initial configuration sync is done by server before worker processes are forked */ ++ zbx_sleep_loop(CONFIG_CONFSYNCER_FREQUENCY); ++ + zbx_setproctitle("%s [connecting to the database]", get_process_type_string(process_type)); + + DBconnect(ZBX_DB_CONNECT_NORMAL); diff --git a/zabbix-tmpfiles.conf b/zabbix-tmpfiles.conf index 0e4755a..3099a5d 100644 --- a/zabbix-tmpfiles.conf +++ b/zabbix-tmpfiles.conf @@ -1 +1 @@ -D /var/run/zabbix 0755 zabbix zabbix - +D /var/run/zabbix 0775 zabbix zabbix - diff --git a/zabbix20.spec b/zabbix20.spec index 5153ca6..9251da9 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -36,7 +36,7 @@ Name: zabbix20 Version: 2.0.6 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Open-source monitoring solution for your IT infrastructure Group: Applications/Internet @@ -72,6 +72,9 @@ Patch2: %{srcname}-2.0.1-no-flash.patch # adapt for fping3 - https://support.zabbix.com/browse/ZBX-4894 Patch3: %{srcname}-1.8.12-fping3.patch +# https://support.zabbix.com/browse/ZBX-6526 +Patch4: %{srcname}-2.0.6-ZBX-6526.patch + BuildRequires: mysql-devel BuildRequires: postgresql-devel BuildRequires: sqlite-devel @@ -864,6 +867,10 @@ fi %files web-pgsql %changelog +* Mon Apr 22 2013 Volker Fröhlich - 2.0.6-2 +- Add patch for ZBX-6526 +- Solve permission problem with /var/run/zabbix in Fedora (BZ#904041) + * Mon Apr 22 2013 Volker Fröhlich - 2.0.6-1 - New upstream release - Drop ZBX-6290 and ZBX-6318 patches From 7fd36e028927fac5bd4c0d219932cf3667d17a5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Tue, 7 May 2013 16:41:40 +0200 Subject: [PATCH 18/42] Actually apply patch; solve cause for zabbix sub-directories in zabbixsrv's home - Remove origin of directories BZ#867159, comment 14 and 16 --- zabbix20.spec | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/zabbix20.spec b/zabbix20.spec index 9251da9..86c95d5 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -290,6 +290,7 @@ Zabbix web frontend for PostgreSQL %if 0%{?fedora} %patch3 -p1 %endif +%patch4 -p0 # Logrotate's su option is currently only available in Fedora %if 0%{?rhel} @@ -313,6 +314,12 @@ rm -rf frontends/php/fonts # Remove executable permissions chmod a-x upgrades/dbpatches/*/mysql/upgrade +# Override statically named directory for alertscripts and externalscripts +# https://support.zabbix.com/browse/ZBX-6159 +sed -i 's|$(DESTDIR)@datadir@/zabbix|$(DESTDIR)/var/lib/zabbixsrv|' \ + src/zabbix_server/Makefile.in \ + src/zabbix_proxy/Makefile.in + # All libraries are expected in /usr/lib or /usr/local/lib # https://support.zabbix.com/browse/ZBXNEXT-1296 sed -i.orig -e 's|_LIBDIR=/usr/lib|_LIBDIR=%{_libdir}|g' \ @@ -392,7 +399,6 @@ common_flags=" --with-jabber --with-unixodbc --with-ssh2 - --datadir=%{_sharedstatedir}/zabbixsrv " # Frontend doesn't work for Sqlite, thus don't build server @@ -431,12 +437,9 @@ mkdir -p $RPM_BUILD_ROOT%{_initrddir} # Frontend mkdir -p $RPM_BUILD_ROOT%{_datadir} -# Home directories -#TODO: Duplicate directory exists for unknown reason +# Home directory for the agent; +# The other home directory is created during installation mkdir -p $RPM_BUILD_ROOT%{_sharedstatedir}/zabbix -mkdir -p $RPM_BUILD_ROOT%{_sharedstatedir}/zabbixsrv -mkdir -p $RPM_BUILD_ROOT%{_sharedstatedir}/zabbixsrv/externalscripts -mkdir -p $RPM_BUILD_ROOT%{_sharedstatedir}/zabbixsrv/alertscripts # Install binaries make DESTDIR=$RPM_BUILD_ROOT install @@ -867,9 +870,10 @@ fi %files web-pgsql %changelog -* Mon Apr 22 2013 Volker Fröhlich - 2.0.6-2 +* Tue May 07 2013 Volker Fröhlich - 2.0.6-2 - Add patch for ZBX-6526 - Solve permission problem with /var/run/zabbix in Fedora (BZ#904041) +- Remove origin of directories BZ#867159, comment 14 and 16 * Mon Apr 22 2013 Volker Fröhlich - 2.0.6-1 - New upstream release From 081d6a943b8f0bc72358ee7fb93512893e0c312c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Tue, 30 Jul 2013 17:18:24 +0200 Subject: [PATCH 19/42] Patch for CVE-2012-6086 Possible security issue due to misuse of the libcurl API https://support.zabbix.com/browse/ZBX-5924 --- zabbix-2.0.6-ZBX-5924.patch | 13 +++++++++++++ zabbix20.spec | 10 +++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 zabbix-2.0.6-ZBX-5924.patch diff --git a/zabbix-2.0.6-ZBX-5924.patch b/zabbix-2.0.6-ZBX-5924.patch new file mode 100644 index 0000000..560fe8b --- /dev/null +++ b/zabbix-2.0.6-ZBX-5924.patch @@ -0,0 +1,13 @@ +Index: src/libs/zbxmedia/eztexting.c +=================================================================== +--- src/libs/zbxmedia/eztexting.c (revision 37391) ++++ src/libs/zbxmedia/eztexting.c (revision 37395) +@@ -205,7 +205,7 @@ + CURLE_OK != (err = curl_easy_setopt(easy_handle, opt = CURLOPT_WRITEFUNCTION, WRITEFUNCTION2)) || + CURLE_OK != (err = curl_easy_setopt(easy_handle, opt = CURLOPT_HEADERFUNCTION, HEADERFUNCTION2)) || + CURLE_OK != (err = curl_easy_setopt(easy_handle, opt = CURLOPT_SSL_VERIFYPEER, 1L)) || +- CURLE_OK != (err = curl_easy_setopt(easy_handle, opt = CURLOPT_SSL_VERIFYHOST, 1L)) || ++ CURLE_OK != (err = curl_easy_setopt(easy_handle, opt = CURLOPT_SSL_VERIFYHOST, 2L)) || + CURLE_OK != (err = curl_easy_setopt(easy_handle, opt = CURLOPT_POSTFIELDS, postfields)) || + CURLE_OK != (err = curl_easy_setopt(easy_handle, opt = CURLOPT_POST, 1L)) || + CURLE_OK != (err = curl_easy_setopt(easy_handle, opt = CURLOPT_URL, EZ_TEXTING_API_URL)) || diff --git a/zabbix20.spec b/zabbix20.spec index 86c95d5..217b9c9 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -36,7 +36,7 @@ Name: zabbix20 Version: 2.0.6 -Release: 2%{?dist} +Release: 3%{?dist} Summary: Open-source monitoring solution for your IT infrastructure Group: Applications/Internet @@ -75,6 +75,10 @@ Patch3: %{srcname}-1.8.12-fping3.patch # https://support.zabbix.com/browse/ZBX-6526 Patch4: %{srcname}-2.0.6-ZBX-6526.patch +# Insecure use of libcurl API, CVE-2012-6086 +# https://support.zabbix.com/browse/ZBX-5924 +Patch5: %{srcname}-2.0.6-ZBX-5924.patch + BuildRequires: mysql-devel BuildRequires: postgresql-devel BuildRequires: sqlite-devel @@ -291,6 +295,7 @@ Zabbix web frontend for PostgreSQL %patch3 -p1 %endif %patch4 -p0 +%patch5 -p0 # Logrotate's su option is currently only available in Fedora %if 0%{?rhel} @@ -870,6 +875,9 @@ fi %files web-pgsql %changelog +* Tue Jul 30 2013 Volker Fröhlich - 2.0.6-3 +- Backport fix for CVE-2012-6086 + * Tue May 07 2013 Volker Fröhlich - 2.0.6-2 - Add patch for ZBX-6526 - Solve permission problem with /var/run/zabbix in Fedora (BZ#904041) From c0be11fd7c9688e341415d5410467c6fd55fce92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Fri, 23 Aug 2013 22:55:07 -0700 Subject: [PATCH 20/42] New upstream version 2.0.8 - Create and configure a spooling directory for fping files outside of /tmp - Update README to reflect that and add a SELinux section - Drop PrivateTmp from systemd unit files - Drop patch for ZBX-6526 (solved upstream) - Drop patch for CVE-2012-6086 (solved upstream) - Correct path for the flash applet when removing - Truncate changelog --- .gitignore | 3 + sources | 2 +- zabbix-2.0.6-ZBX-6526.patch | 41 -------- zabbix-agent.service | 1 - zabbix-fedora.README | 42 +++++++- zabbix-proxy-mysql.service | 1 - zabbix-proxy-pgsql.service | 1 - zabbix-proxy-sqlite3.service | 1 - zabbix-server-mysql.service | 1 - zabbix-server-pgsql.service | 1 - zabbix20.spec | 189 ++++++----------------------------- 11 files changed, 70 insertions(+), 213 deletions(-) delete mode 100644 zabbix-2.0.6-ZBX-6526.patch diff --git a/.gitignore b/.gitignore index de1b02d..e4488ae 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ /zabbix-2.0.5.tar.gz /zabbix-2.0.5-free.tar.gz /zabbix-2.0.6-free.tar.gz +/zabbix-2.0.7-free.tar.gz +/zabbix-2.0.8.tar.gz +/zabbix-2.0.8-free.tar.gz diff --git a/sources b/sources index bf98dab..ab672de 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -d480122e6cfb0983d9946148d82a0b8b zabbix-2.0.6-free.tar.gz +213cfb023a9c3afb807746003027a9c2 zabbix-2.0.8-free.tar.gz diff --git a/zabbix-2.0.6-ZBX-6526.patch b/zabbix-2.0.6-ZBX-6526.patch deleted file mode 100644 index 56a1def..0000000 --- a/zabbix-2.0.6-ZBX-6526.patch +++ /dev/null @@ -1,41 +0,0 @@ -Index: src/zabbix_proxy/servercomms.c -=================================================================== ---- src/zabbix_proxy/servercomms.c (revision 35199) -+++ src/zabbix_proxy/servercomms.c (revision 35235) -@@ -165,7 +165,7 @@ - if (FAIL == send_data_to_server(sock, j->buffer)) - goto exit; - -- if (FAIL == zbx_recv_response(sock, NULL, 0, 0)) -+ if (SUCCEED != zbx_recv_response(sock, NULL, 0, 0)) - goto exit; - - ret = SUCCEED; -Index: src/zabbix_server/server.c -=================================================================== ---- src/zabbix_server/server.c (revision 35199) -+++ src/zabbix_server/server.c (revision 35235) -@@ -588,6 +588,9 @@ - /* need to set trigger status to UNKNOWN since last run */ - DBupdate_triggers_status_after_restart(); - -+ /* make initial configuration sync before worker processes are forked */ -+ DCsync_configuration(); -+ - DBclose(); - - if (ZBX_MUTEX_ERROR == zbx_mutex_create_force(&node_sync_access, ZBX_MUTEX_NODE_SYNC)) -Index: src/zabbix_server/dbconfig/dbconfig.c -=================================================================== ---- src/zabbix_server/dbconfig/dbconfig.c (revision 35199) -+++ src/zabbix_server/dbconfig/dbconfig.c (revision 35235) -@@ -51,6 +51,9 @@ - - zabbix_log(LOG_LEVEL_DEBUG, "In main_dbconfig_loop()"); - -+ /* the initial configuration sync is done by server before worker processes are forked */ -+ zbx_sleep_loop(CONFIG_CONFSYNCER_FREQUENCY); -+ - zbx_setproctitle("%s [connecting to the database]", get_process_type_string(process_type)); - - DBconnect(ZBX_DB_CONNECT_NORMAL); diff --git a/zabbix-agent.service b/zabbix-agent.service index cca7cc9..27bfad7 100644 --- a/zabbix-agent.service +++ b/zabbix-agent.service @@ -7,7 +7,6 @@ Type=oneshot ExecStart=/usr/sbin/zabbix_agentd RemainAfterExit=yes User=zabbix -PrivateTmp=yes [Install] WantedBy=multi-user.target diff --git a/zabbix-fedora.README b/zabbix-fedora.README index 671c140..4bbf487 100644 --- a/zabbix-fedora.README +++ b/zabbix-fedora.README @@ -1,9 +1,16 @@ -#TODO: SELinux -=Custom in Fedora= +=Custom in Fedora/EPEL= + +==Pinger files== + +Since /tmp is not a good place to spool files, the pinger files shall now reside +in /var/lib/zabbixsrv/tmp. This directory is automatically created and proxy and +server configuration files are changed accordingly from 2.0.8 on. ==Web configuration== -Web configuration resides in /etc/zabbix/web. +Web configuration resides in /etc/zabbix/web. No need to copy or edit +anything -- just do the configuration by accessing the frontend as soon as your +httpd configuration allows. ==Log files== @@ -14,6 +21,7 @@ Log files are located in /var/log/zabbix. ==Where's my Flash watch?== It's not included in Fedora! Fedora's policy does not allow to include blobs. +https://support.zabbix.com/browse/ZBX-4794 ==No htaccess files== @@ -94,6 +102,32 @@ to vote on it. Sadly it doesn't work with how Fedora's/EPEL's PHP is compiled. +-------------------------------------------------------------------------------- + +=SELinux= + +The settings necessary for you vary, depending on how you set up your system/s. +Most of the time, the only adjustments necessary should be on the machine that +holds the frontend: + +#Allow to connect the frontend to a database by other means than sockets +setsebool -P httpd_can_network_connect_db 1 + +#Allow the frontend to create a connection to the server listening port +#That's the check the frontend uses to see whether the server is running. +#This option effectively supersedes the previous +setsebool -P httpd_can_network_connect 1 + +Using sebools is a somewhat coarse method of allowing things. +A more fine-grained approach for the latter would be to grab an actual +avc denial from the audit log, pipe it through audit2allow, put it in a +module package and load that: + +echo "avc: denied { name_connect } for pid=20619 comm="httpd" dest=10051 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:zabbix_port_t:s0 tclass=tcp_socket" | audit2allow -M zabbix_conn_httpd; sudo semodule -i zabbix_conn_httpd.pp + +If you're using ping from the frontend: + +echo "avc: denied { setpgid } for pid=31880 comm="zabbix_server_p" scontext=system_u:system_r:zabbix_t:s0 tcontext=system_u:system_r:zabbix_t:s0 tclass=process" | audit2allow -M zabbix_ping_frontend; sudo semodule -i zabbix_ping_frontend.pp -------------------------------------------------------------------------------- @@ -115,4 +149,4 @@ http://www.zabbix.com/documentation/2.0/manual/installation/upgrade - Review all rpmnew and rpmsave files; merge where necessary - Review permissions, ownerships and group memberships for zabbixsrv -Volker Fröhlich volker27@gmx.at Nov 8 2012 +Volker Fröhlich volker27@gmx.at Aug 14 2013 diff --git a/zabbix-proxy-mysql.service b/zabbix-proxy-mysql.service index 515bb8e..6464a5a 100644 --- a/zabbix-proxy-mysql.service +++ b/zabbix-proxy-mysql.service @@ -7,7 +7,6 @@ Type=oneshot ExecStart=/usr/sbin/zabbix_proxy RemainAfterExit=yes User=zabbixsrv -PrivateTmp=yes [Install] WantedBy=multi-user.target diff --git a/zabbix-proxy-pgsql.service b/zabbix-proxy-pgsql.service index d1fc5fc..5d52fd9 100644 --- a/zabbix-proxy-pgsql.service +++ b/zabbix-proxy-pgsql.service @@ -7,7 +7,6 @@ Type=oneshot ExecStart=/usr/sbin/zabbix_proxy RemainAfterExit=yes User=zabbixsrv -PrivateTmp=yes [Install] WantedBy=multi-user.target diff --git a/zabbix-proxy-sqlite3.service b/zabbix-proxy-sqlite3.service index 2058613..a102fc0 100644 --- a/zabbix-proxy-sqlite3.service +++ b/zabbix-proxy-sqlite3.service @@ -7,7 +7,6 @@ Type=oneshot ExecStart=/usr/sbin/zabbix_proxy RemainAfterExit=yes User=zabbixsrv -PrivateTmp=yes [Install] WantedBy=multi-user.target diff --git a/zabbix-server-mysql.service b/zabbix-server-mysql.service index 7c1962c..9c0217b 100644 --- a/zabbix-server-mysql.service +++ b/zabbix-server-mysql.service @@ -7,7 +7,6 @@ Type=oneshot ExecStart=/usr/sbin/zabbix_server RemainAfterExit=yes User=zabbixsrv -PrivateTmp=yes [Install] WantedBy=multi-user.target diff --git a/zabbix-server-pgsql.service b/zabbix-server-pgsql.service index 8d6a83f..a196b4c 100644 --- a/zabbix-server-pgsql.service +++ b/zabbix-server-pgsql.service @@ -7,7 +7,6 @@ Type=oneshot ExecStart=/usr/sbin/zabbix_server RemainAfterExit=yes User=zabbixsrv -PrivateTmp=yes [Install] WantedBy=multi-user.target diff --git a/zabbix20.spec b/zabbix20.spec index 217b9c9..bde0a80 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -2,41 +2,26 @@ # * F18 systemd macros, when EL6 reaches EOL # * Do something about mutex errors sometimes occurring when init scripts' # restart is invoked; something like "sleep 2" between stop and start? -# * Use "Include" in zabbix_{agentd,proxy,server}.conf, point to corresponding -# /etc/zabbix/zabbix_*.conf.d/ dir; needs patching in order to not load +# "Include" statement in config files needs patching in order to not load # various backup files (*.rpm{orig,new,save}, *~ etc) in that dir. -# https://support.zabbix.com/browse/ZBXNEXT-497 -- Scheduled for 2.2 +# https://support.zabbix.com/browse/ZBXNEXT-497 # * zabbixsrv could be member of the groups zabbixsrv and zabbix # * Consider using systemd's ReadWriteDirectories -# * Consider mod_proxy patch from Debian -# https://support.zabbix.com/browse/ZBX-4986 #TODO: systemctl reload seems to be necessary after switching with Alternatives #TODO: If the DB path for a Sqlite proxy is configured wrong, it requires systemctl restart. Start doesn't work. -# Some info on SELinux that should go to our README +# Allow pinger lists in /var/lib/zabbixsrv/tmp +#echo "avc: denied { read } for pid=3427 comm="fping6" path="/var/lib/zabbixsrv/tmp/zabbix_server_pgsql_3002.pinger" dev=dm-1 ino=20 scontext=system_u:system_r:ping_t:s0 tcontext=system_u:object_r:initrc_tmp_t:s0 tclass=file" | audit2allow -M myzab; sudo semodule -i myzab2.pp -# Allow to connect the frontend to a database -# setsebool -P httpd_can_network_connect_db 1 - -# Allow the frontend to check whether Zabbix server is reachable -#echo "avc: denied { name_connect } for pid=20619 comm="httpd" dest=10051 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:zabbix_port_t:s0 tclass=tcp_socket" | audit2allow -M myhttpd; sudo semodule -i myhttpd.pp - -#TODO: Consider filing a bug for selinux-policy -# Allow ping from the frontend -#echo "avc: denied { setpgid } for pid=31880 comm="zabbix_server_p" scontext=system_u:system_r:zabbix_t:s0 tcontext=system_u:system_r:zabbix_t:s0 tclass=process" | audit2allow -M myzab; sudo semodule -i myzab.pp - -# Allow host list for pings in /tmp -#echo "avc: denied { read } for pid=3427 comm="fping6" path="/tmp/zabbix_server_pgsql_3002.pinger" dev=dm-1 ino=20 scontext=system_u:system_r:ping_t:s0 tcontext=system_u:object_r:initrc_tmp_t:s0 tclass=file" | audit2allow -M myzab; sudo semodule -i myzab2.pp - -#type=AVC msg=audit(1346965425.718:65127): avc: denied { getattr } for pid=3427 comm="fping6" path="/tmp/zabbix_server_pgsql_3002.pinger" dev=dm-1 ino=20 scontext=system_u:system_r:ping_t:s0 tcontext=system_u:object_r:initrc_tmp_t:s0 tclass=file +#type=AVC msg=audit(1346965425.718:65127): avc: denied { getattr } for pid=3427 comm="fping6" path="/var/lib/zabbixsrv/tmp/zabbix_server_pgsql_3002.pinger" dev=dm-1 ino=20 scontext=system_u:system_r:ping_t:s0 tcontext=system_u:object_r:initrc_tmp_t:s0 tclass=file %global srcname zabbix Name: zabbix20 -Version: 2.0.6 -Release: 3%{?dist} +Version: 2.0.8 +Release: 1%{?dist} Summary: Open-source monitoring solution for your IT infrastructure Group: Applications/Internet @@ -52,7 +37,7 @@ Source4: %{srcname}-proxy.init Source5: %{srcname}-logrotate.in Source9: %{srcname}-tmpfiles.conf # systemd units -- Alternatives switches between them (they state their dependencies) -#TODO: Submit upstream +# https://support.zabbix.com/browse/ZBXNEXT-1593 Source10: %{srcname}-agent.service Source11: %{srcname}-proxy-mysql.service Source12: %{srcname}-proxy-pgsql.service @@ -72,13 +57,6 @@ Patch2: %{srcname}-2.0.1-no-flash.patch # adapt for fping3 - https://support.zabbix.com/browse/ZBX-4894 Patch3: %{srcname}-1.8.12-fping3.patch -# https://support.zabbix.com/browse/ZBX-6526 -Patch4: %{srcname}-2.0.6-ZBX-6526.patch - -# Insecure use of libcurl API, CVE-2012-6086 -# https://support.zabbix.com/browse/ZBX-5924 -Patch5: %{srcname}-2.0.6-ZBX-5924.patch - BuildRequires: mysql-devel BuildRequires: postgresql-devel BuildRequires: sqlite-devel @@ -294,8 +272,6 @@ Zabbix web frontend for PostgreSQL %if 0%{?fedora} %patch3 -p1 %endif -%patch4 -p0 -%patch5 -p0 # Logrotate's su option is currently only available in Fedora %if 0%{?rhel} @@ -305,7 +281,7 @@ sed -i '/su zabbix zabbix/d' %{SOURCE5} # Remove flash applet # https://support.zabbix.com/browse/ZBX-4794 %patch2 -p1 -rm -f frontend/php/images/flash/zbxclock.swf +rm -f frontends/php/images/flash/zbxclock.swf # Remove bundled java libs rm -rf src/zabbix_java/lib/*.jar @@ -357,6 +333,7 @@ sed -i \ -e 's|/usr/local||g' \ conf/zabbix_agent.conf +#TODO: It'd be better to leave the defaults in a commment and just override them, as they are still hard-coded! sed -i \ -e 's|# PidFile=.*|PidFile=%{_localstatedir}/run/%{srcname}/zabbix_server.pid|g' \ -e 's|^LogFile=.*|LogFile=%{_localstatedir}/log/%{srcname}/zabbix_server.log|g' \ @@ -365,6 +342,7 @@ sed -i \ -e 's|^DBUser=root|DBUser=zabbix|g' \ -e 's|# DBSocket=/tmp/mysql.sock|DBSocket=%{_sharedstatedir}/mysql/mysql.sock|g' \ -e 's|# ExternalScripts=\${datadir}/zabbix/externalscripts|ExternalScripts=%{_sharedstatedir}/zabbixsrv/externalscripts|' \ + -e 's|# TmpDir=\/tmp|TmpDir=%{_sharedstatedir}/zabbixsrv/tmp|' \ -e 's|/usr/local||g' \ conf/zabbix_server.conf @@ -375,6 +353,7 @@ sed -i \ -e 's|^DBUser=root|DBUser=zabbix|g' \ -e 's|# DBSocket=/tmp/mysql.sock|DBSocket=%{_sharedstatedir}/mysql/mysql.sock|g' \ -e 's|# ExternalScripts=\${datadir}/zabbix/externalscripts|ExternalScripts=%{_sharedstatedir}/zabbixsrv/externalscripts|' \ + -e 's|# TmpDir=\/tmp|TmpDir=%{_sharedstatedir}/zabbixsrv/tmp|' \ -e 's|/usr/local||g' \ conf/zabbix_proxy.conf @@ -481,15 +460,6 @@ install -m 0644 -p %{SOURCE12} $RPM_BUILD_ROOT%{_unitdir}/zabbix-proxy-pgsql.ser install -m 0644 -p %{SOURCE13} $RPM_BUILD_ROOT%{_unitdir}/zabbix-proxy-sqlite3.service install -m 0644 -p %{SOURCE14} $RPM_BUILD_ROOT%{_unitdir}/zabbix-server-mysql.service install -m 0644 -p %{SOURCE15} $RPM_BUILD_ROOT%{_unitdir}/zabbix-server-pgsql.service -# PrivateTmp available from F17 on -%if 0%{?fedora} < 17 -sed -i '/^PrivateTmp/d' $RPM_BUILD_ROOT%{_unitdir}/zabbix-agent.service -sed -i '/^PrivateTmp/d' $RPM_BUILD_ROOT%{_unitdir}/zabbix-proxy-mysql.service -sed -i '/^PrivateTmp/d' $RPM_BUILD_ROOT%{_unitdir}/zabbix-proxy-pgsql.service -sed -i '/^PrivateTmp/d' $RPM_BUILD_ROOT%{_unitdir}/zabbix-proxy-sqlite3.service -sed -i '/^PrivateTmp/d' $RPM_BUILD_ROOT%{_unitdir}/zabbix-server-mysql.service -sed -i '/^PrivateTmp/d' $RPM_BUILD_ROOT%{_unitdir}/zabbix-server-pgsql.service -%endif %else # init scripts install -m 0755 -p %{SOURCE3} $RPM_BUILD_ROOT%{_initrddir}/zabbix-agent @@ -510,6 +480,9 @@ ln -sf %{_sharedstatedir}/zabbixsrv/externalscripts $RPM_BUILD_ROOT%{_sysconfdir ln -sf %{_sharedstatedir}/zabbixsrv/alertscripts $RPM_BUILD_ROOT%{_sysconfdir}/%{srcname}/alertscripts #TODO: What does that do to existing directories? +# Directory for fping spooling files +mkdir $RPM_BUILD_ROOT%{_sharedstatedir}/zabbixsrv/tmp + # Install sql files for db in postgresql mysql; do datadir=$RPM_BUILD_ROOT%{_datadir}/%{srcname}-$db @@ -780,7 +753,7 @@ fi %config(noreplace) %{_sysconfdir}/%{srcname}/alertscripts %config(noreplace) %{_sysconfdir}/logrotate.d/zabbix-server %ghost %{_sbindir}/zabbix_server -%attr(0755,zabbixsrv,zabbix) %{_sharedstatedir}/%{srcname}srv +%attr(0755,zabbixsrv,zabbix) %{_sharedstatedir}/zabbixsrv %if 0%{?fedora} %ghost %{_unitdir}/zabbix-server.service %else @@ -813,7 +786,7 @@ fi %config(noreplace) %{_sysconfdir}/zabbix_agentd.conf %config(noreplace) %{_sysconfdir}/%{srcname}/zabbix_agentd.conf %config(noreplace) %{_sysconfdir}/logrotate.d/zabbix-agent -%attr(0755,zabbix,zabbix) %dir %{_sharedstatedir}/%{srcname} +%attr(0755,zabbix,zabbix) %dir %{_sharedstatedir}/zabbix %if 0%{?fedora} %{_unitdir}/zabbix-agent.service %else @@ -834,7 +807,7 @@ fi %config(noreplace) %{_sysconfdir}/%{srcname}/externalscripts %config(noreplace) %{_sysconfdir}/logrotate.d/zabbix-proxy %ghost %{_sbindir}/zabbix_proxy -%attr(0755,zabbixsrv,zabbix) %{_sharedstatedir}/%{srcname}srv +%attr(0755,zabbixsrv,zabbix) %{_sharedstatedir}/zabbixsrv %if 0%{?fedora} %ghost %{_unitdir}/zabbix-proxy.service %else @@ -875,6 +848,16 @@ fi %files web-pgsql %changelog +* Fri Aug 23 2013 Volker Fröhlich - 2.0.8-1 +- New upstream release +- Create and configure a spooling directory for fping files outside of /tmp +- Update README to reflect that and add a SELinux section +- Drop PrivateTmp from systemd unit files +- Drop patch for ZBX-6526 (solved upstream) +- Drop patch for CVE-2012-6086 (solved upstream) +- Correct path for the flash applet when removing +- Truncate changelog + * Tue Jul 30 2013 Volker Fröhlich - 2.0.6-3 - Backport fix for CVE-2012-6086 @@ -1199,119 +1182,3 @@ fi * Thu Sep 30 2008 Jeffrey C. Ollie - 1.6-1 - Update to final 1.6 - -* Mon Aug 11 2008 Jason L Tibbitts III - 1.4.6-2 -- Fix license tag. - -* Fri Jul 25 2008 Jeffrey C. Ollie - 1.4.6-1 -- Update to 1.4.6 - -* Mon Jul 07 2008 Dan Horak - 1.4.5-4 -- add LSB headers into init scripts -- disable internal log rotation - -* Fri May 02 2008 Jarod Wilson - 1.4.5-3 -- Seems the zabbix folks replaced the original 1.4.5 tarball with - an updated tarball or something -- it actually does contain a - tiny bit of additional code... So update to newer 1.4.5. - -* Tue Apr 08 2008 Jarod Wilson - 1.4.5-2 -- Fix building w/postgresql (#441456) - -* Tue Mar 25 2008 Jeffrey C. Ollie - 1.4.5-1 -- Update to 1.4.5 - -* Thu Feb 14 2008 Jarod Wilson - 1.4.4-2 -- Bump and rebuild with gcc 4.3 - -* Mon Dec 17 2007 Jarod Wilson - 1.4.4-1 -- New upstream release -- Fixes two crasher bugs in 1.4.3 release - -* Wed Dec 12 2007 Jarod Wilson - 1.4.3-1 -- New upstream release - -* Thu Dec 06 2007 Release Engineering - 1.4.2-5 -- Rebuild for deps - -* Sat Dec 01 2007 Dan Horak 1.4.2-4 -- add security fix (#407181) - -* Thu Sep 20 2007 Dan Horak 1.4.2-3 -- Add a patch to clean a warning during compile -- Add a patch to fix cpu load computations - -* Tue Aug 21 2007 Jarod Wilson 1.4.2-2 -- Account for binaries moving from %%_bindir to %%_sbindir - -* Tue Aug 21 2007 Jarod Wilson 1.4.2-1 -- New upstream release - -* Mon Jul 02 2007 Jarod Wilson 1.4.1-1 -- New upstream release - -* Fri Jun 29 2007 Jarod Wilson 1.4-3 -- Install correct sql init files (#244991) -- Add Requires: php-bcmath to zabbix-web (#245767) - -* Wed May 30 2007 Jarod Wilson 1.4-2 -- Add placeholder zabbix.conf.php - -* Tue May 29 2007 Jarod Wilson 1.4-1 -- New upstream release - -* Fri Mar 30 2007 Jarod Wilson 1.1.7-1 -- New upstream release - -* Wed Feb 07 2007 Jarod Wilson 1.1.6-1 -- New upstream release - -* Thu Feb 01 2007 Jarod Wilson 1.1.5-1 -- New upstream release - -* Tue Jan 02 2007 Jarod Wilson 1.1.4-5 -- Add explicit R:php to zabbix-web (#220676) - -* Wed Dec 13 2006 Jarod Wilson 1.1.4-4 -- Fix snmp polling buffer overflow (#218065) - -* Wed Nov 29 2006 Jarod Wilson 1.1.4-3 -- Rebuild for updated libnetsnmp - -* Thu Nov 16 2006 Jarod Wilson 1.1.4-2 -- Fix up pt_br -- Add Req-pre on useradd - -* Wed Nov 15 2006 Jarod Wilson 1.1.4-1 -- Update to 1.1.4 - -* Tue Nov 14 2006 Jarod Wilson 1.1.3-3 -- Add BR: gnutls-devel, R: net-snmp-libs - -* Tue Nov 14 2006 Jarod Wilson 1.1.3-2 -- Fix php-pgsql Requires - -* Tue Nov 14 2006 Jarod Wilson 1.1.3-1 -- Update to 1.1.3 - -* Mon Oct 02 2006 Jarod Wilson 1.1.2-1 -- Update to 1.1.2 -- Enable alternate building with postgresql support - -* Thu Aug 17 2006 Jarod Wilson 1.1.1-2 -- Yank out Requires: mysql-server -- Add Requires: for php-gd and fping - -* Tue Aug 15 2006 Jarod Wilson 1.1.1-1 -- Update to 1.1.1 -- More macroification -- Fix up zabbix-web Requires: -- Prep for enabling postgres support - -* Thu Jul 27 2006 Jarod Wilson 1.1-2 -- Add Requires: on chkconfig and service -- Remove openssl-devel from BR, mysql-devel pulls it in -- Alter scriptlets to match Fedora conventions - -* Tue Jul 11 2006 Jarod Wilson 1.1-1 -- Initial build for Fedora Extras From 8d8672155a2c3c2024499f2e801af4b4adeb53b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Fri, 13 Sep 2013 10:34:09 +0200 Subject: [PATCH 21/42] Require php-ldap and ZBX-6992 (Service SQL) --- zabbix-2.0.8-ZBX-6992.patch | 15 +++++++++++++++ zabbix20.spec | 11 ++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 zabbix-2.0.8-ZBX-6992.patch diff --git a/zabbix-2.0.8-ZBX-6992.patch b/zabbix-2.0.8-ZBX-6992.patch new file mode 100644 index 0000000..6c3a0cc --- /dev/null +++ b/zabbix-2.0.8-ZBX-6992.patch @@ -0,0 +1,15 @@ +Index: frontends/php/api/classes/CService.php +=================================================================== +--- frontends/php/api/classes/CService.php (.../2.0) (revision 38431) ++++ frontends/php/api/classes/CService.php (.../dev/ZBX-6992) (revision 38466) +@@ -1004,8 +1004,8 @@ + // since multiple alarms can have the same timestamp, we only need to save the last one + $query = DBSelect( + 'SELECT sa.serviceid,sa.value'. +- ' FROM (SELECT MAX(sa3.servicealarmid) servicealarmid'. +- ' FROM (SELECT sa2.serviceid,MAX(sa2.clock) clock'. ++ ' FROM (SELECT MAX(sa3.servicealarmid) AS servicealarmid'. ++ ' FROM (SELECT sa2.serviceid,MAX(sa2.clock) AS clock'. + ' FROM service_alarms sa2'. + ' WHERE sa2.clock<'.zbx_dbstr($beforeTime). + ' AND '.dbConditionInt('sa2.serviceid', $serviceIds). diff --git a/zabbix20.spec b/zabbix20.spec index bde0a80..e1e8c08 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -21,7 +21,7 @@ Name: zabbix20 Version: 2.0.8 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Open-source monitoring solution for your IT infrastructure Group: Applications/Internet @@ -56,6 +56,9 @@ Patch1: %{srcname}-2.0.3-fonts-config.patch Patch2: %{srcname}-2.0.1-no-flash.patch # adapt for fping3 - https://support.zabbix.com/browse/ZBX-4894 Patch3: %{srcname}-1.8.12-fping3.patch +# Services page broken due to missing AS in SQL +# https://support.zabbix.com/browse/ZBX-4894 +Patch4: %{srcname}-2.0.8-ZBX-6992.patch BuildRequires: mysql-devel BuildRequires: postgresql-devel @@ -231,6 +234,7 @@ BuildArch: noarch Requires: php Requires: php-gd Requires: php-bcmath +Requires: php-ldap Requires: php-mbstring Requires: php-xml Requires: php-gettext @@ -272,6 +276,7 @@ Zabbix web frontend for PostgreSQL %if 0%{?fedora} %patch3 -p1 %endif +%patch4 -p0 # Logrotate's su option is currently only available in Fedora %if 0%{?rhel} @@ -848,6 +853,10 @@ fi %files web-pgsql %changelog +* Fri Sep 13 2013 Volker Fröhlich - 2.0.8-2 +- Add php-ldap as a requirement for the frontend +- Add patch for ZBX-6992 + * Fri Aug 23 2013 Volker Fröhlich - 2.0.8-1 - New upstream release - Create and configure a spooling directory for fping files outside of /tmp From 79d978de86aaf8153604b503d4d794a31ca73aa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Mon, 23 Sep 2013 17:48:21 +0200 Subject: [PATCH 22/42] SQL speed-up patch for graphs (ZBX-6804) --- zabbix-2.0.8-ZBX-6804.patch | 121 ++++++++++++++++++++++++++++++++++++ zabbix20.spec | 5 ++ 2 files changed, 126 insertions(+) create mode 100644 zabbix-2.0.8-ZBX-6804.patch diff --git a/zabbix-2.0.8-ZBX-6804.patch b/zabbix-2.0.8-ZBX-6804.patch new file mode 100644 index 0000000..f3547b4 --- /dev/null +++ b/zabbix-2.0.8-ZBX-6804.patch @@ -0,0 +1,121 @@ +Index: frontends/php/include/graphs.inc.php +=================================================================== +--- frontends/php/include/graphs.inc.php (revision 38431) ++++ frontends/php/include/graphs.inc.php (revision 38500) +@@ -199,18 +199,19 @@ + /** + * Return the time of the 1st appearance of item in trends. + * +- * @param array|int $itemids ++ * @param array $itemIds + * + * @return int (unixtime) + */ +-function get_min_itemclock_by_itemid($itemids) { +- zbx_value2array($itemids); ++function get_min_itemclock_by_itemid($itemIds) { ++ zbx_value2array($itemIds); ++ + $min = null; + $result = time() - SEC_PER_YEAR; + +- $items_by_type = array( ++ $itemTypes = array( + ITEM_VALUE_TYPE_FLOAT => array(), +- ITEM_VALUE_TYPE_STR => array(), ++ ITEM_VALUE_TYPE_STR => array(), + ITEM_VALUE_TYPE_LOG => array(), + ITEM_VALUE_TYPE_UINT64 => array(), + ITEM_VALUE_TYPE_TEXT => array() +@@ -219,64 +220,68 @@ + $dbItems = DBselect( + 'SELECT i.itemid,i.value_type'. + ' FROM items i'. +- ' WHERE '.dbConditionInt('i.itemid', $itemids) ++ ' WHERE '.dbConditionInt('i.itemid', $itemIds) + ); + + while ($item = DBfetch($dbItems)) { +- $items_by_type[$item['value_type']][$item['itemid']] = $item['itemid']; ++ $itemTypes[$item['value_type']][$item['itemid']] = $item['itemid']; + } + + // data for ITEM_VALUE_TYPE_FLOAT and ITEM_VALUE_TYPE_UINT64 can be stored in trends tables or history table + // get max trends and history values for such type items to find out in what tables to look for data +- $sql_from = 'history'; +- $sql_from_num = ''; ++ $sqlFrom = 'history'; ++ $sqlFromNum = ''; + +- if (!empty($items_by_type[ITEM_VALUE_TYPE_FLOAT]) || !empty($items_by_type[ITEM_VALUE_TYPE_UINT64])) { +- $itemids_numeric = zbx_array_merge($items_by_type[ITEM_VALUE_TYPE_FLOAT], $items_by_type[ITEM_VALUE_TYPE_UINT64]); ++ if (!empty($itemTypes[ITEM_VALUE_TYPE_FLOAT]) || !empty($itemTypes[ITEM_VALUE_TYPE_UINT64])) { ++ $itemIdsNumeric = zbx_array_merge($itemTypes[ITEM_VALUE_TYPE_FLOAT], $itemTypes[ITEM_VALUE_TYPE_UINT64]); + + $sql = 'SELECT MAX(i.history) AS history,MAX(i.trends) AS trends'. + ' FROM items i'. +- ' WHERE '.dbConditionInt('i.itemid', $itemids_numeric); +- if ($table_for_numeric = DBfetch(DBselect($sql))) { +- $sql_from_num = ($table_for_numeric['history'] > $table_for_numeric['trends']) ? 'history' : 'trends'; +- $result = time() - (SEC_PER_DAY * max($table_for_numeric['history'], $table_for_numeric['trends'])); ++ ' WHERE '.dbConditionInt('i.itemid', $itemIdsNumeric); ++ if ($tableForNumeric = DBfetch(DBselect($sql))) { ++ $sqlFromNum = ($tableForNumeric['history'] > $tableForNumeric['trends']) ? 'history' : 'trends'; ++ $result = time() - (SEC_PER_DAY * max($tableForNumeric['history'], $tableForNumeric['trends'])); + } + } + +- foreach ($items_by_type as $type => $items) { ++ foreach ($itemTypes as $type => $items) { + if (empty($items)) { + continue; + } + +- switch($type) { ++ switch ($type) { + case ITEM_VALUE_TYPE_FLOAT: +- $sql_from = $sql_from_num; ++ $sqlFrom = $sqlFromNum; + break; + case ITEM_VALUE_TYPE_STR: +- $sql_from = 'history_str'; ++ $sqlFrom = 'history_str'; + break; + case ITEM_VALUE_TYPE_LOG: +- $sql_from = 'history_log'; ++ $sqlFrom = 'history_log'; + break; + case ITEM_VALUE_TYPE_UINT64: +- $sql_from = $sql_from_num.'_uint'; ++ $sqlFrom = $sqlFromNum.'_uint'; + break; + case ITEM_VALUE_TYPE_TEXT: +- $sql_from = 'history_text'; ++ $sqlFrom = 'history_text'; + break; + default: +- $sql_from = 'history'; ++ $sqlFrom = 'history'; + } + ++ foreach ($itemIds as $itemId) { ++ $sqlUnions[] = 'SELECT MIN(ht.clock) AS c FROM '.$sqlFrom.' ht WHERE ht.itemid='.$itemId; ++ } ++ + $dbMin = DBfetch(DBselect( +- 'SELECT MIN(ht.clock) AS min_clock'. +- ' FROM '.$sql_from.' ht'. +- ' WHERE '.dbConditionInt('ht.itemid', $itemids) ++ 'SELECT MIN(ht.c) AS min_clock'. ++ ' FROM ('.implode(' UNION ALL ', $sqlUnions).') ht' + )); +- $min = empty($min) ? $dbMin['min_clock'] : min($min, $dbMin['min_clock']); ++ ++ $min = $min ? min($min, $dbMin['min_clock']) : $dbMin['min_clock']; + } + +- return empty($min) ? $result : $min; ++ return $min ? $min: $result; + } + + function get_graph_by_graphid($graphid) { diff --git a/zabbix20.spec b/zabbix20.spec index e1e8c08..32352c6 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -60,6 +60,10 @@ Patch3: %{srcname}-1.8.12-fping3.patch # https://support.zabbix.com/browse/ZBX-4894 Patch4: %{srcname}-2.0.8-ZBX-6992.patch +# SQL speedup for graphs, fixed in 2.0.9 +# https://support.zabbix.com/browse/ZBX-6840 +Patch5: %{srcname}-2.0.8-ZBX-6804.patch + BuildRequires: mysql-devel BuildRequires: postgresql-devel BuildRequires: sqlite-devel @@ -277,6 +281,7 @@ Zabbix web frontend for PostgreSQL %patch3 -p1 %endif %patch4 -p0 +%patch5 -p0 # Logrotate's su option is currently only available in Fedora %if 0%{?rhel} From 02468f2fc909d3465424f389aee712b275a679cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Wed, 2 Oct 2013 10:36:50 +0200 Subject: [PATCH 23/42] Add patch for CVE-2013-5743 (SQL injection vulnerability, ZBX-7091) -Also add patch for ZBX-6922 (Failing host XML import) --- zabbix-2.0.8-ZBX-6922.patch | 21 + zabbix-2.0.8-ZBX-7091.patch | 2021 +++++++++++++++++++++++++++++++++++ zabbix20.spec | 18 +- 3 files changed, 2058 insertions(+), 2 deletions(-) create mode 100644 zabbix-2.0.8-ZBX-6922.patch create mode 100644 zabbix-2.0.8-ZBX-7091.patch diff --git a/zabbix-2.0.8-ZBX-6922.patch b/zabbix-2.0.8-ZBX-6922.patch new file mode 100644 index 0000000..97ba0cc --- /dev/null +++ b/zabbix-2.0.8-ZBX-6922.patch @@ -0,0 +1,21 @@ +Index: frontends/php/include/db.inc.php +=================================================================== +--- frontends/php/include/db.inc.php (revision 38161) ++++ frontends/php/include/db.inc.php (revision 38173) +@@ -1080,14 +1080,14 @@ + return '1=0'; + } + +- $values = array_unique($values); ++ $values = array_keys(array_flip($values)); + + if ($sort) { + natsort($values); ++ ++ $values = array_values($values); + } + +- zbx_cleanHashes($values); +- + $betweens = array(); + $data = array(); diff --git a/zabbix-2.0.8-ZBX-7091.patch b/zabbix-2.0.8-ZBX-7091.patch new file mode 100644 index 0000000..ca5d2c1 --- /dev/null +++ b/zabbix-2.0.8-ZBX-7091.patch @@ -0,0 +1,2021 @@ +Index: frontends/php/api/classes/CGraphItem.php +=================================================================== +--- frontends/php/api/classes/CGraphItem.php (revision 38884) ++++ frontends/php/api/classes/CGraphItem.php (working copy) +@@ -119,7 +119,7 @@ + + // type + if (!is_null($options['type'] )) { +- $sqlParts['where'][] = 'gi.type='.$options['type']; ++ $sqlParts['where'][] = 'gi.type='.zbx_dbstr($options['type']); + } + + // output +@@ -254,8 +254,8 @@ + $dbRes = DBselect( + 'SELECT gi.gitemid'. + ' FROM graphs_items gi'. +- ' WHERE gi.itemid='.$gitemData['itemid']. +- ' AND gi.graphid='.$gitemData['graphid'] ++ ' WHERE gi.itemid='.zbx_dbstr($gitemData['itemid']). ++ ' AND gi.graphid='.zbx_dbstr($gitemData['graphid']) + ); + while ($gitem = DBfetch($dbRes)) { + $gitemids[$gitem['gitemid']] = $gitem['gitemid']; +Index: frontends/php/api/classes/CEvent.php +=================================================================== +--- frontends/php/api/classes/CEvent.php (revision 38884) ++++ frontends/php/api/classes/CEvent.php (working copy) +@@ -232,12 +232,12 @@ + + // object + if (!is_null($options['object'])) { +- $sqlParts['where']['o'] = 'e.object='.$options['object']; ++ $sqlParts['where']['o'] = 'e.object='.zbx_dbstr($options['object']); + } + + // source + if (!is_null($options['source'])) { +- $sqlParts['where'][] = 'e.source='.$options['source']; ++ $sqlParts['where'][] = 'e.source='.zbx_dbstr($options['source']); + } + + // acknowledged +@@ -255,22 +255,22 @@ + + // time_from + if (!is_null($options['time_from'])) { +- $sqlParts['where'][] = 'e.clock>='.$options['time_from']; ++ $sqlParts['where'][] = 'e.clock>='.zbx_dbstr($options['time_from']); + } + + // time_till + if (!is_null($options['time_till'])) { +- $sqlParts['where'][] = 'e.clock<='.$options['time_till']; ++ $sqlParts['where'][] = 'e.clock<='.zbx_dbstr($options['time_till']); + } + + // eventid_from + if (!is_null($options['eventid_from'])) { +- $sqlParts['where'][] = 'e.eventid>='.$options['eventid_from']; ++ $sqlParts['where'][] = 'e.eventid>='.zbx_dbstr($options['eventid_from']); + } + + // eventid_till + if (!is_null($options['eventid_till'])) { +- $sqlParts['where'][] = 'e.eventid<='.$options['eventid_till']; ++ $sqlParts['where'][] = 'e.eventid<='.zbx_dbstr($options['eventid_till']); + } + + // value +Index: frontends/php/api/classes/CGraphPrototype.php +=================================================================== +--- frontends/php/api/classes/CGraphPrototype.php (revision 38884) ++++ frontends/php/api/classes/CGraphPrototype.php (working copy) +@@ -227,7 +227,7 @@ + + // type + if (!is_null($options['type'] )) { +- $sqlParts['where'][] = 'g.type='.$options['type']; ++ $sqlParts['where'][] = 'g.type='.zbx_dbstr($options['type']); + } + + // templated +Index: frontends/php/api/classes/CItemGeneral.php +=================================================================== +--- frontends/php/api/classes/CItemGeneral.php (revision 38884) ++++ frontends/php/api/classes/CItemGeneral.php (working copy) +@@ -707,7 +707,7 @@ + + $sqlWhere = array(); + foreach ($itemKeysByHostId as $hostId => $keys) { +- $sqlWhere[] = '(i.hostid='.$hostId.' AND '.dbConditionString('i.key_', $keys).')'; ++ $sqlWhere[] = '(i.hostid='.zbx_dbstr($hostId).' AND '.dbConditionString('i.key_', $keys).')'; + } + + if ($sqlWhere) { +Index: frontends/php/api/classes/CHistory.php +=================================================================== +--- frontends/php/api/classes/CHistory.php (revision 38884) ++++ frontends/php/api/classes/CHistory.php (working copy) +@@ -169,13 +169,13 @@ + // time_from + if (!is_null($options['time_from'])) { + $sqlParts['select']['clock'] = 'h.clock'; +- $sqlParts['where']['clock_from'] = 'h.clock>='.$options['time_from']; ++ $sqlParts['where']['clock_from'] = 'h.clock>='.zbx_dbstr($options['time_from']); + } + + // time_till + if (!is_null($options['time_till'])) { + $sqlParts['select']['clock'] = 'h.clock'; +- $sqlParts['where']['clock_till'] = 'h.clock<='.$options['time_till']; ++ $sqlParts['where']['clock_till'] = 'h.clock<='.zbx_dbstr($options['time_till']); + } + + // filter +Index: frontends/php/api/classes/CTrigger.php +=================================================================== +--- frontends/php/api/classes/CTrigger.php (revision 38884) ++++ frontends/php/api/classes/CTrigger.php (working copy) +@@ -321,12 +321,12 @@ + + // lastChangeSince + if (!is_null($options['lastChangeSince'])) { +- $sqlParts['where']['lastchangesince'] = 't.lastchange>'.$options['lastChangeSince']; ++ $sqlParts['where']['lastchangesince'] = 't.lastchange>'.zbx_dbstr($options['lastChangeSince']); + } + + // lastChangeTill + if (!is_null($options['lastChangeTill'])) { +- $sqlParts['where']['lastchangetill'] = 't.lastchange<'.$options['lastChangeTill']; ++ $sqlParts['where']['lastchangetill'] = 't.lastchange<'.zbx_dbstr($options['lastChangeTill']); + } + + // withUnacknowledgedEvents +@@ -466,7 +466,7 @@ + + // min_severity + if (!is_null($options['min_severity'])) { +- $sqlParts['where'][] = 't.priority>='.$options['min_severity']; ++ $sqlParts['where'][] = 't.priority>='.zbx_dbstr($options['min_severity']); + } + + // output +Index: frontends/php/api/classes/CScript.php +=================================================================== +--- frontends/php/api/classes/CScript.php (revision 38884) ++++ frontends/php/api/classes/CScript.php (working copy) +@@ -114,7 +114,7 @@ + $sqlParts['from']['hosts_groups'] = 'hosts_groups hg'; + $sqlParts['where'][] = 'hg.groupid=r.id'; + $sqlParts['where'][] = 'r.groupid=ug.usrgrpid'; +- $sqlParts['where'][] = 'ug.userid='.$userid; ++ $sqlParts['where'][] = 'ug.userid='.zbx_dbstr($userid); + $sqlParts['where'][] = '(hg.groupid=s.groupid OR s.groupid IS NULL)'; + $sqlParts['where'][] = '(ug.usrgrpid=s.usrgrpid OR s.usrgrpid IS NULL)'; + } +@@ -265,7 +265,7 @@ + 'SELECT s.scriptid'. + ' FROM scripts s'. + ' WHERE '.DBin_node('s.scriptid'). +- ' AND s.name='.$script['name'] ++ ' AND s.name='.zbx_dbstr($script['name']) + ); + while ($script = DBfetch($dbScripts)) { + $scriptids[$script['scriptid']] = $script['scriptid']; +Index: frontends/php/api/classes/CTemplate.php +=================================================================== +--- frontends/php/api/classes/CTemplate.php (revision 38884) ++++ frontends/php/api/classes/CTemplate.php (working copy) +@@ -1021,7 +1021,7 @@ + + foreach ($template['groups'] as $group) { + $hostgroupid = get_dbid('hosts_groups', 'hostgroupid'); +- $result = DBexecute("INSERT INTO hosts_groups (hostgroupid, hostid, groupid) VALUES ($hostgroupid, $templateid, {$group['groupid']})"); ++ $result = DBexecute('INSERT INTO hosts_groups (hostgroupid,hostid,groupid) VALUES ('.zbx_dbstr($hostgroupid).','.zbx_dbstr($templateid).','.zbx_dbstr($group['groupid']).')'); + if (!$result) { + self::exception(ZBX_API_ERROR_PARAMETERS, 'DBerror'); + } +Index: frontends/php/api/classes/CHostGeneral.php +=================================================================== +--- frontends/php/api/classes/CHostGeneral.php (revision 38884) ++++ frontends/php/api/classes/CHostGeneral.php (working copy) +@@ -261,7 +261,7 @@ + continue; + } + +- $values = array(get_dbid('hosts_templates', 'hosttemplateid'), $targetid, $templateid); ++ $values = array(get_dbid('hosts_templates', 'hosttemplateid'), zbx_dbstr($targetid), zbx_dbstr($templateid)); + $sql = 'INSERT INTO hosts_templates VALUES ('.implode(', ', $values).')'; + $result = DBexecute($sql); + +Index: frontends/php/api/classes/CUser.php +=================================================================== +--- frontends/php/api/classes/CUser.php (revision 38884) ++++ frontends/php/api/classes/CUser.php (working copy) +@@ -507,7 +507,8 @@ + $usrgrps = zbx_objectValues($user['usrgrps'], 'usrgrpid'); + foreach ($usrgrps as $groupid) { + $usersGroupdId = get_dbid('users_groups', 'id'); +- $sql = 'INSERT INTO users_groups (id,usrgrpid,userid) VALUES ('.$usersGroupdId.','.$groupid.','.$userid.')'; ++ $sql = 'INSERT INTO users_groups (id,usrgrpid,userid) VALUES ('.zbx_dbstr($usersGroupdId).','.zbx_dbstr($groupid).','.zbx_dbstr($userid).')'; ++ + if (!DBexecute($sql)) { + self::exception(ZBX_API_ERROR_PARAMETERS, 'DBerror'); + } +@@ -516,8 +517,8 @@ + foreach ($user['user_medias'] as $mediaData) { + $mediaid = get_dbid('media', 'mediaid'); + $sql = 'INSERT INTO media (mediaid,userid,mediatypeid,sendto,active,severity,period)'. +- ' VALUES ('.$mediaid.','.$userid.','.$mediaData['mediatypeid'].','. +- zbx_dbstr($mediaData['sendto']).','.$mediaData['active'].','.$mediaData['severity'].','. ++ ' VALUES ('.zbx_dbstr($mediaid).','.zbx_dbstr($userid).','.zbx_dbstr($mediaData['mediatypeid']).','. ++ zbx_dbstr($mediaData['sendto']).','.zbx_dbstr($mediaData['active']).','.zbx_dbstr($mediaData['severity']).','. + zbx_dbstr($mediaData['period']).')'; + if (!DBexecute($sql)) { + self::exception(ZBX_API_ERROR_PARAMETERS, 'DBerror'); +@@ -577,10 +578,10 @@ + $newUsrgrpids = zbx_objectValues($user['usrgrps'], 'usrgrpid'); + + // deleting all relations with groups, but not touching those, where user still must be after update +- DBexecute('DELETE FROM users_groups WHERE userid='.$user['userid'].' AND '.dbConditionInt('usrgrpid', $newUsrgrpids, true)); ++ DBexecute('DELETE FROM users_groups WHERE userid='.zbx_dbstr($user['userid']).' AND '.dbConditionInt('usrgrpid', $newUsrgrpids, true)); + + // getting the list of groups user is currently in +- $dbGroupsUserIn = DBSelect('SELECT usrgrpid FROM users_groups WHERE userid='.$user['userid']); ++ $dbGroupsUserIn = DBSelect('SELECT usrgrpid FROM users_groups WHERE userid='.zbx_dbstr($user['userid'])); + $groupsUserIn = array(); + while ($grp = DBfetch($dbGroupsUserIn)) { + $groupsUserIn[$grp['usrgrpid']] = $grp['usrgrpid']; +@@ -598,7 +599,7 @@ + } + + $usersGroupdId = get_dbid('users_groups', 'id'); +- $sql = 'INSERT INTO users_groups (id,usrgrpid,userid) VALUES ('.$usersGroupdId.','.$groupid.','.$user['userid'].')'; ++ $sql = 'INSERT INTO users_groups (id,usrgrpid,userid) VALUES ('.zbx_dbstr($usersGroupdId).','.zbx_dbstr($groupid).','.zbx_dbstr($user['userid']).')'; + + if (!DBexecute($sql)) { + self::exception(ZBX_API_ERROR_PARAMETERS, 'DBerror'); +@@ -696,8 +697,8 @@ + $mediaid = get_dbid('media', 'mediaid'); + + $sql = 'INSERT INTO media (mediaid,userid,mediatypeid,sendto,active,severity,period)'. +- ' VALUES ('.$mediaid.','.$user['userid'].','.$media['mediatypeid'].','. +- zbx_dbstr($media['sendto']).','.$media['active'].','.$media['severity'].','. ++ ' VALUES ('.zbx_dbstr($mediaid).','.zbx_dbstr($user['userid']).','.zbx_dbstr($media['mediatypeid']).','. ++ zbx_dbstr($media['sendto']).','.zbx_dbstr($media['active']).','.zbx_dbstr($media['severity']).','. + zbx_dbstr($media['period']).')'; + if (!DBexecute($sql)) { + self::exception(ZBX_API_ERROR_PARAMETERS, 'DBerror'); +@@ -796,12 +797,12 @@ + + $result = DBexecute( + 'UPDATE media'. +- ' SET mediatypeid='.$media['mediatypeid'].','. ++ ' SET mediatypeid='.zbx_dbstr($media['mediatypeid']).','. + ' sendto='.zbx_dbstr($media['sendto']).','. +- ' active='.$media['active'].','. +- ' severity='.$media['severity'].','. ++ ' active='.zbx_dbstr($media['active']).','. ++ ' severity='.zbx_dbstr($media['severity']).','. + ' period='.zbx_dbstr($media['period']). +- ' WHERE mediaid='.$media['mediaid'] ++ ' WHERE mediaid='.zbx_dbstr($media['mediaid']) + ); + if (!$result) { + self::exception(ZBX_API_ERROR_PARAMETERS, _('Cannot update user media.')); +@@ -927,7 +928,7 @@ + $dbAccess = DBfetch(DBselect( + 'SELECT MAX(g.gui_access) AS gui_access'. + ' FROM usrgrp g,users_groups ug'. +- ' WHERE ug.userid='.$userInfo['userid']. ++ ' WHERE ug.userid='.zbx_dbstr($userInfo['userid']). + ' AND g.usrgrpid=ug.usrgrpid' + )); + if (!zbx_empty($dbAccess['gui_access'])) { +@@ -968,7 +969,7 @@ + + DBexecute( + 'UPDATE users'. +- ' SET attempt_failed='.$userInfo['attempt_failed'].','. ++ ' SET attempt_failed='.zbx_dbstr($userInfo['attempt_failed']).','. + ' attempt_clock='.time().','. + ' attempt_ip='.zbx_dbstr($ip). + ' WHERE userid='.$userInfo['userid'] +@@ -980,7 +981,7 @@ + + // start session + $sessionid = md5(time().$password.$name.rand(0, 10000000)); +- DBexecute('INSERT INTO sessions (sessionid,userid,lastaccess,status) VALUES ('.zbx_dbstr($sessionid).','.$userInfo['userid'].','.time().','.ZBX_SESSION_ACTIVE.')'); ++ DBexecute('INSERT INTO sessions (sessionid,userid,lastaccess,status) VALUES ('.zbx_dbstr($sessionid).','.zbx_dbstr($userInfo['userid']).','.time().','.ZBX_SESSION_ACTIVE.')'); + + add_audit(AUDIT_ACTION_LOGIN, AUDIT_RESOURCE_USER, _s('Correct login "%s".', $name)); + +@@ -990,7 +991,7 @@ + $userData['userid'] = $userInfo['userid']; + + if ($userInfo['attempt_failed']) { +- DBexecute('UPDATE users SET attempt_failed=0 WHERE userid='.$userInfo['userid']); ++ DBexecute('UPDATE users SET attempt_failed=0 WHERE userid='.zbx_dbstr($userInfo['userid'])); + } + + CWebUser::$data = self::$userData = $userData; +@@ -1035,16 +1036,16 @@ + } + + if ($userInfo['autologout'] > 0) { +- DBexecute('DELETE FROM sessions WHERE userid='.$userInfo['userid'].' AND lastaccess<'.(time() - $userInfo['autologout'])); ++ DBexecute('DELETE FROM sessions WHERE userid='.zbx_dbstr($userInfo['userid']).' AND lastaccess<'.(time() - $userInfo['autologout'])); + } + +- DBexecute('UPDATE sessions SET lastaccess='.time().' WHERE userid='.$userInfo['userid'].' AND sessionid='.zbx_dbstr($sessionid)); ++ DBexecute('UPDATE sessions SET lastaccess='.time().' WHERE userid='.zbx_dbstr($userInfo['userid']).' AND sessionid='.zbx_dbstr($sessionid)); + } + + $dbAccess = DBfetch(DBselect( + 'SELECT MAX(g.gui_access) AS gui_access'. + ' FROM usrgrp g,users_groups ug'. +- ' WHERE ug.userid='.$userInfo['userid']. ++ ' WHERE ug.userid='.zbx_dbstr($userInfo['userid']). + ' AND g.usrgrpid=ug.usrgrpid' + )); + if (!zbx_empty($dbAccess['gui_access'])) { +@@ -1070,13 +1071,13 @@ + 'SELECT u.userid,u.alias,u.name,u.surname,u.url,u.autologin,u.autologout,u.lang,u.refresh,u.type,'. + ' u.theme,u.attempt_failed,u.attempt_ip,u.attempt_clock,u.rows_per_page'. + ' FROM users u'. +- ' WHERE u.userid='.$userid ++ ' WHERE u.userid='.zbx_dbstr($userid) + )); + + $userData['debug_mode'] = (bool) DBfetch(DBselect( + 'SELECT ug.userid'. + ' FROM usrgrp g,users_groups ug'. +- ' WHERE ug.userid='.$userid. ++ ' WHERE ug.userid='.zbx_dbstr($userid). + ' AND g.usrgrpid=ug.usrgrpid'. + ' AND g.debug_mode='.GROUP_DEBUG_MODE_ENABLED + )); +Index: frontends/php/api/classes/CImage.php +=================================================================== +--- frontends/php/api/classes/CImage.php (revision 38884) ++++ frontends/php/api/classes/CImage.php (working copy) +@@ -314,9 +314,9 @@ + + $imageid = get_dbid('images', 'imageid'); + $values = array( +- 'imageid' => $imageid, ++ 'imageid' => zbx_dbstr($imageid), + 'name' => zbx_dbstr($image['name']), +- 'imagetype' => $image['imagetype'], ++ 'imagetype' => zbx_dbstr($image['imagetype']) + ); + + switch ($DB['TYPE']) { +@@ -423,7 +423,7 @@ + + $values = array(); + if (isset($image['name'])) $values['name'] = zbx_dbstr($image['name']); +- if (isset($image['imagetype'])) $values['imagetype'] = $image['imagetype']; ++ if (isset($image['imagetype'])) $values['imagetype'] = zbx_dbstr($image['imagetype']); + + if (isset($image['image'])) { + // decode BASE64 +@@ -443,7 +443,7 @@ + $values['image'] = zbx_dbstr($image['image']); + break; + case ZBX_DB_ORACLE: +- $sql = 'SELECT image FROM images WHERE imageid = '.$image['imageid'].' FOR UPDATE'; ++ $sql = 'SELECT image FROM images WHERE imageid = '.zbx_dbstr($image['imageid']).' FOR UPDATE'; + + if (!$stmt = oci_parse($DB['DB'], $sql)) { + $e = oci_error($DB['DB']); +@@ -464,7 +464,7 @@ + $row['IMAGE']->free(); + break; + case ZBX_DB_DB2: +- $stmt = db2_prepare($DB['DB'], 'UPDATE images SET image=? WHERE imageid='.$image['imageid']); ++ $stmt = db2_prepare($DB['DB'], 'UPDATE images SET image=? WHERE imageid='.zbx_dbstr($image['imageid'])); + + if (!$stmt) { + self::exception(ZBX_API_ERROR_PARAMETERS, db2_conn_errormsg($DB['DB'])); +@@ -486,7 +486,7 @@ + foreach ($values as $field => $value) { + $sqlUpd[] = $field.'='.$value; + } +- $sql = 'UPDATE images SET '.implode(', ', $sqlUpd).' WHERE imageid='.$image['imageid']; ++ $sql = 'UPDATE images SET '.implode(', ', $sqlUpd).' WHERE imageid='.zbx_dbstr($image['imageid']); + $result = DBexecute($sql); + + if (!$result) { +Index: frontends/php/api/classes/CMapElement.php +=================================================================== +--- frontends/php/api/classes/CMapElement.php (revision 38884) ++++ frontends/php/api/classes/CMapElement.php (working copy) +@@ -586,7 +586,7 @@ + + $sql = 'SELECT elementid, elementtype '. + ' FROM sysmaps_elements '. +- ' WHERE sysmapid='.$elementid . ++ ' WHERE sysmapid='.zbx_dbstr($elementid) . + ' AND elementtype='.SYSMAP_ELEMENT_TYPE_MAP; + $dbElements = DBselect($sql); + +Index: frontends/php/api/classes/CTriggerPrototype.php +=================================================================== +--- frontends/php/api/classes/CTriggerPrototype.php (revision 38884) ++++ frontends/php/api/classes/CTriggerPrototype.php (working copy) +@@ -423,7 +423,7 @@ + + // min_severity + if (!is_null($options['min_severity'])) { +- $sqlParts['where'][] = 't.priority>='.$options['min_severity']; ++ $sqlParts['where'][] = 't.priority>='.zbx_dbstr($options['min_severity']); + } + + // output +Index: frontends/php/api/classes/CUserGroup.php +=================================================================== +--- frontends/php/api/classes/CUserGroup.php (revision 38884) ++++ frontends/php/api/classes/CUserGroup.php (working copy) +@@ -144,7 +144,7 @@ + + // status + if (!is_null($options['status'])) { +- $sqlParts['where'][] = 'g.users_status='.$options['status']; ++ $sqlParts['where'][] = 'g.users_status='.zbx_dbstr($options['status']); + } + + // with_gui_access +Index: frontends/php/api/classes/CGraph.php +=================================================================== +--- frontends/php/api/classes/CGraph.php (revision 38884) ++++ frontends/php/api/classes/CGraph.php (working copy) +@@ -209,7 +209,7 @@ + + // type + if (!is_null($options['type'])) { +- $sqlParts['where'][] = 'g.type='.$options['type']; ++ $sqlParts['where'][] = 'g.type='.zbx_dbstr($options['type']); + } + + // templated +Index: frontends/php/api/classes/CApplication.php +=================================================================== +--- frontends/php/api/classes/CApplication.php (revision 38884) ++++ frontends/php/api/classes/CApplication.php (working copy) +@@ -719,7 +719,7 @@ + DB::insert('items_applications', $appsInsert); + + foreach ($itemids as $inum => $itemid) { +- $dbChilds = DBselect('SELECT i.itemid,i.hostid FROM items i WHERE i.templateid='.$itemid); ++ $dbChilds = DBselect('SELECT i.itemid,i.hostid FROM items i WHERE i.templateid='.zbx_dbstr($itemid)); + while ($child = DBfetch($dbChilds)) { + $dbApps = DBselect( + 'SELECT a1.applicationid'. +Index: frontends/php/api/classes/CAlert.php +=================================================================== +--- frontends/php/api/classes/CAlert.php (revision 38884) ++++ frontends/php/api/classes/CAlert.php (working copy) +@@ -237,12 +237,12 @@ + + // time_from + if (!is_null($options['time_from'])) { +- $sqlParts['where'][] = 'a.clock>'.$options['time_from']; ++ $sqlParts['where'][] = 'a.clock>'.zbx_dbstr($options['time_from']); + } + + // time_till + if (!is_null($options['time_till'])) { +- $sqlParts['where'][] = 'a.clock<'.$options['time_till']; ++ $sqlParts['where'][] = 'a.clock<'.zbx_dbstr($options['time_till']); + } + + // output +Index: frontends/php/api/classes/CWebCheck.php +=================================================================== +--- frontends/php/api/classes/CWebCheck.php (revision 38884) ++++ frontends/php/api/classes/CWebCheck.php (working copy) +@@ -347,7 +347,7 @@ + $dbCheckItems = DBselect( + 'SELECT i.itemid,hi.type'. + ' FROM items i,httptestitem hi'. +- ' WHERE hi.httptestid='.$httpTest['httptestid']. ++ ' WHERE hi.httptestid='.zbx_dbstr($httpTest['httptestid']). + ' AND hi.itemid=i.itemid' + ); + while ($checkitem = DBfetch($dbCheckItems)) { +@@ -696,7 +696,7 @@ + + $sql = 'SELECT h.httpstepid,h.name'. + ' FROM httpstep h'. +- ' WHERE h.httptestid='.$httpTest['httptestid']. ++ ' WHERE h.httptestid='.zbx_dbstr($httpTest['httptestid']). + ' AND '.dbConditionString('h.name', $webstepsNames); + if ($httpstepData = DBfetch(DBselect($sql))) { + self::exception(ZBX_API_ERROR_PARAMETERS, _s('Step "%s" already exists.', $httpstepData['name'])); +@@ -820,7 +820,7 @@ + $dbStepItems = DBselect( + 'SELECT i.itemid,hi.type'. + ' FROM items i,httpstepitem hi'. +- ' WHERE hi.httpstepid='.$webstep['webstepid']. ++ ' WHERE hi.httpstepid='.zbx_dbstr($webstep['webstepid']). + ' AND hi.itemid=i.itemid' + ); + while ($stepitem = DBfetch($dbStepItems)) { +Index: frontends/php/api/classes/CTemplateScreen.php +=================================================================== +--- frontends/php/api/classes/CTemplateScreen.php (revision 38884) ++++ frontends/php/api/classes/CTemplateScreen.php (working copy) +@@ -618,7 +618,7 @@ + 'SELECT src.itemid as srcid,dest.itemid as destid'. + ' FROM items dest,items src'. + ' WHERE dest.key_=src.key_'. +- ' AND dest.hostid='.$templateId. ++ ' AND dest.hostid='.zbx_dbstr($templateId). + ' AND '.dbConditionInt('src.itemid', $resourceItemIds) + ); + while ($dbItem = DBfetch($dbItems)) { +@@ -633,7 +633,7 @@ + ' WHERE dest.name=src.name'. + ' AND destgi.graphid=dest.graphid'. + ' AND destgi.itemid=desti.itemid'. +- ' AND desti.hostid='.$templateId. ++ ' AND desti.hostid='.zbx_dbstr($templateId). + ' AND '.dbConditionInt('src.graphid', $resourceGraphIds) + ); + while ($dbItem = DBfetch($dbItems)) { +Index: frontends/php/include/items.inc.php +=================================================================== +--- frontends/php/include/items.inc.php (revision 38884) ++++ frontends/php/include/items.inc.php (working copy) +@@ -224,7 +224,7 @@ + while ($item = DBfetch($db_items)) { + $old_status = $item['status']; + if ($status != $old_status) { +- $result &= DBexecute('UPDATE items SET status='.$status. ++ $result &= DBexecute('UPDATE items SET status='.zbx_dbstr($status). + ($status != ITEM_STATUS_NOTSUPPORTED ? ",error=''" : ''). + ' WHERE itemid='.$item['itemid']); + if ($result) { +@@ -420,7 +420,7 @@ + } + + function get_item_by_itemid($itemid) { +- $db_items = DBfetch(DBselect('SELECT i.* FROM items i WHERE i.itemid='.$itemid)); ++ $db_items = DBfetch(DBselect('SELECT i.* FROM items i WHERE i.itemid='.zbx_dbstr($itemid))); + if ($db_items) { + return $db_items; + } +@@ -436,7 +436,7 @@ + 'i.formula,i.trends,i.logtimefmt,i.valuemapid,i.delay_flex,i.params,i.ipmi_sensor,i.templateid,'. + 'i.authtype,i.username,i.password,i.publickey,i.privatekey,i.flags,i.filter,i.description,i.inventory_link'. + ' FROM items i'. +- ' WHERE i.itemid='.$itemid)); ++ ' WHERE i.itemid='.zbx_dbstr($itemid))); + if ($row) { + return $row; + } +@@ -469,7 +469,7 @@ + $db_items = DBselect( + 'SELECT src.*'. + ' FROM items src,items dest'. +- ' WHERE dest.itemid='.$itemid. ++ ' WHERE dest.itemid='.zbx_dbstr($itemid). + ' AND src.key_=dest.key_'. + ' AND '.dbConditionInt('src.hostid', $dest_hostids) + ); +@@ -838,7 +838,7 @@ + 'SELECT a1.applicationid'. + ' FROM applications a1,applications a2'. + ' WHERE a1.name=a2.name'. +- ' AND a1.hostid='.$hostid. ++ ' AND a1.hostid='.zbx_dbstr($hostid). + ' AND '.dbConditionInt('a2.applicationid', $applications) + ); + while ($app = DBfetch($db_apps)) { +@@ -986,9 +986,9 @@ + if ($last == 0) { + $sql = 'SELECT value'. + ' FROM '.$table. +- ' WHERE itemid='.$db_item['itemid']. +- ' AND clock='.$clock. +- ' AND ns='.$ns; ++ ' WHERE itemid='.zbx_dbstr($db_item['itemid']). ++ ' AND clock='.zbx_dbstr($clock). ++ ' AND ns='.zbx_dbstr($ns); + if (null != ($row = DBfetch(DBselect($sql, 1)))) { + $value = $row['value']; + } +@@ -1000,17 +1000,17 @@ + + $sql = 'SELECT DISTINCT clock'. + ' FROM '.$table. +- ' WHERE itemid='.$db_item['itemid']. +- ' AND clock='.$clock. +- ' AND ns<'.$ns; ++ ' WHERE itemid='.zbx_dbstr($db_item['itemid']). ++ ' AND clock='.zbx_dbstr($clock). ++ ' AND ns<'.zbx_dbstr($ns); + if (null != ($row = DBfetch(DBselect($sql)))) { + $max_clock = $row['clock']; + } + if ($max_clock == 0) { + $sql = 'SELECT MAX(clock) AS clock'. + ' FROM '.$table. +- ' WHERE itemid='.$db_item['itemid']. +- ' AND clock<'.$clock; ++ ' WHERE itemid='.zbx_dbstr($db_item['itemid']). ++ ' AND clock<'.zbx_dbstr($clock); + if (null != ($row = DBfetch(DBselect($sql)))) { + $max_clock = $row['clock']; + } +@@ -1022,15 +1022,15 @@ + if ($clock == $max_clock) { + $sql = 'SELECT value'. + ' FROM '.$table. +- ' WHERE itemid='.$db_item['itemid']. +- ' AND clock='.$clock. +- ' AND ns<'.$ns; ++ ' WHERE itemid='.zbx_dbstr($db_item['itemid']). ++ ' AND clock='.zbx_dbstr($clock). ++ ' AND ns<'.zbx_dbstr($ns); + } + else { + $sql = 'SELECT value'. + ' FROM '.$table. +- ' WHERE itemid='.$db_item['itemid']. +- ' AND clock='.$max_clock. ++ ' WHERE itemid='.zbx_dbstr($db_item['itemid']). ++ ' AND clock='.zbx_dbstr($max_clock). + ' ORDER BY itemid,clock desc,ns desc'; + } + +@@ -1039,9 +1039,9 @@ + } + } + else { +- $row = DBfetch(DBselect('SELECT MAX(clock) AS clock FROM '.$table.' WHERE itemid='.$db_item['itemid'])); ++ $row = DBfetch(DBselect('SELECT MAX(clock) AS clock FROM '.$table.' WHERE itemid='.zbx_dbstr($db_item['itemid']))); + if (!empty($row['clock'])) { +- $row = DBfetch(DBselect('SELECT value FROM '.$table.' WHERE itemid='.$db_item['itemid'].' AND clock='.$row['clock'].' ORDER BY ns DESC', 1)); ++ $row = DBfetch(DBselect('SELECT value FROM '.$table.' WHERE itemid='.zbx_dbstr($db_item['itemid']).' AND clock='.zbx_dbstr($row['clock']).' ORDER BY ns DESC', 1)); + if (!empty($row['value'])) { + $value = $row['value']; + } +Index: frontends/php/include/services.inc.php +=================================================================== +--- frontends/php/include/services.inc.php (revision 38884) ++++ frontends/php/include/services.inc.php (working copy) +@@ -42,7 +42,7 @@ + $result = DBselect( + 'SELECT s.status'. + ' FROM services s,services_links l'. +- ' WHERE l.serviceupid='.$serviceid. ++ ' WHERE l.serviceupid='.zbx_dbstr($serviceid). + ' AND s.serviceid=l.servicedownid'. + ' ORDER BY s.status'.$sort_order + ); +@@ -77,7 +77,7 @@ + $result = DBselect( + 'SELECT sl.servicedownid'. + ' FROM services_links sl'. +- ' WHERE sl.serviceupid='.$serviceid. ++ ' WHERE sl.serviceupid='.zbx_dbstr($serviceid). + ($soft ? '' : ' AND sl.soft=0') + ); + while ($row = DBfetch($result)) { +@@ -354,7 +354,7 @@ + 'SELECT l.serviceupid,s.algorithm'. + ' FROM services_links l,services s'. + ' WHERE s.serviceid=l.serviceupid'. +- ' AND l.servicedownid='.$serviceid ++ ' AND l.servicedownid='.zbx_dbstr($serviceid) + ); + while ($row = DBfetch($result)) { + $serviceupid = $row['serviceupid']; +@@ -363,7 +363,7 @@ + if ($algorithm == SERVICE_ALGORITHM_MAX || $algorithm == SERVICE_ALGORITHM_MIN) { + $status = get_service_status($serviceupid, $algorithm); + add_service_alarm($serviceupid, $status, time()); +- DBexecute('UPDATE services SET status='.$status.' WHERE serviceid='.$serviceupid); ++ DBexecute('UPDATE services SET status='.zbx_dbstr($status).' WHERE serviceid='.zbx_dbstr($serviceupid)); + } + elseif ($algorithm != SERVICE_ALGORITHM_NONE) { + error(_('Unknown calculation algorithm of service status').SPACE.'['.$algorithm.']'); +@@ -371,7 +371,7 @@ + } + } + +- $result = DBselect('SELECT sl.serviceupid FROM services_links sl WHERE sl.servicedownid='.$serviceid); ++ $result = DBselect('SELECT sl.serviceupid FROM services_links sl WHERE sl.servicedownid='.zbx_dbstr($serviceid)); + while ($row = DBfetch($result)) { + $serviceupid = $row['serviceupid']; + update_services_rec($serviceupid); // ATTENTION: recursion!!! +@@ -386,9 +386,9 @@ + * @param $status + */ + function update_services($triggerid, $status) { +- DBexecute('UPDATE services SET status='.$status.' WHERE triggerid='.$triggerid); ++ DBexecute('UPDATE services SET status='.zbx_dbstr($status).' WHERE triggerid='.zbx_dbstr($triggerid)); + +- $result = DBselect('SELECT s.serviceid FROM services s WHERE s.triggerid='.$triggerid); ++ $result = DBselect('SELECT s.serviceid FROM services s WHERE s.triggerid='.zbx_dbstr($triggerid)); + while ($row = DBfetch($result)) { + add_service_alarm($row['serviceid'], $status, time()); + update_services_rec($row['serviceid']); +@@ -415,7 +415,7 @@ + ); + while ($row = DBfetch($result)) { + $status = get_service_status($row['serviceid'], $row['algorithm'], $row['triggerid']); +- DBexecute('UPDATE services SET status='.$status.' WHERE serviceid='.$row['serviceid']); ++ DBexecute('UPDATE services SET status='.zbx_dbstr($status).' WHERE serviceid='.$row['serviceid']); + add_service_alarm($row['serviceid'], $status, time()); + } + +@@ -441,7 +441,7 @@ + $result = DBselect( + 'SELECT sa.servicealarmid,sa.value'. + ' FROM service_alarms sa'. +- ' WHERE sa.serviceid='.$serviceid. ++ ' WHERE sa.serviceid='.zbx_dbstr($serviceid). + ' ORDER BY sa.servicealarmid DESC', 1 + ); + $row = DBfetch($result); +@@ -457,7 +457,7 @@ + if (latest_service_alarm($serviceid, $status)) { + return true; + } +- return DBexecute('INSERT INTO service_alarms (servicealarmid,serviceid,clock,value) VALUES ('.get_dbid('service_alarms', 'servicealarmid').','.$serviceid.','.$clock.','.$status.')'); ++ return DBexecute('INSERT INTO service_alarms (servicealarmid,serviceid,clock,value) VALUES ('.get_dbid('service_alarms', 'servicealarmid').','.zbx_dbstr($serviceid).','.zbx_dbstr($clock).','.zbx_dbstr($status).')'); + } + + /** +Index: frontends/php/include/profiles.inc.php +=================================================================== +--- frontends/php/include/profiles.inc.php (revision 38884) ++++ frontends/php/include/profiles.inc.php (working copy) +@@ -148,9 +148,9 @@ + 'profileid' => get_dbid('profiles', 'profileid'), + 'userid' => self::$userDetails['userid'], + 'idx' => zbx_dbstr($idx), +- $value_type => ($value_type == 'value_str') ? zbx_dbstr($value) : $value, +- 'type' => $type, +- 'idx2' => $idx2 ++ $value_type => zbx_dbstr($value), ++ 'type' => zbx_dbstr($type), ++ 'idx2' => zbx_dbstr($idx2) + ); + return DBexecute('INSERT INTO profiles ('.implode(', ', array_keys($values)).') VALUES ('.implode(', ', $values).')'); + } +@@ -163,16 +163,15 @@ + } + + if ($idx2 > 0) { +- $sql_cond .= ' AND idx2='.$idx2.' AND '.DBin_node('idx2', false); ++ $sql_cond .= ' AND idx2='.zbx_dbstr($idx2).' AND '.DBin_node('idx2', false); + } + + $value_type = self::getFieldByType($type); +- $value = ($value_type == 'value_str') ? zbx_dbstr($value) : $value; + + return DBexecute( + 'UPDATE profiles SET '. +- $value_type.'='.$value.','. +- ' type='.$type. ++ $value_type.'='.zbx_dbstr($value).','. ++ ' type='.zbx_dbstr($type). + ' WHERE userid='.self::$userDetails['userid']. + ' AND idx='.zbx_dbstr($idx). + $sql_cond +@@ -242,7 +241,7 @@ + } + } + if (isset($configs['alert_usrgrpid'])) { +- if ($configs['alert_usrgrpid'] != 0 && !DBfetch(DBselect('SELECT u.usrgrpid FROM usrgrp u WHERE u.usrgrpid='.$configs['alert_usrgrpid']))) { ++ if ($configs['alert_usrgrpid'] != 0 && !DBfetch(DBselect('SELECT u.usrgrpid FROM usrgrp u WHERE u.usrgrpid='.zbx_dbstr($configs['alert_usrgrpid'])))) { + error(_('Incorrect user group.')); + return false; + } +@@ -393,7 +392,7 @@ + $history5 = DBfetch(DBSelect( + 'SELECT uh.title5,uh.url5'. + ' FROM user_history uh'. +- ' WHERE uh.userid='.$userid ++ ' WHERE uh.userid='.zbx_dbstr($userid) + )); + + if ($history5 && ($history5['title5'] == $title)) { +@@ -401,7 +400,7 @@ + // title same, url isnt, change only url + $sql = 'UPDATE user_history'. + ' SET url5='.zbx_dbstr($url). +- ' WHERE userid='.$userid; ++ ' WHERE userid='.zbx_dbstr($userid); + } + else { + // no need to change anything; +@@ -413,7 +412,7 @@ + if ($history5 === false) { + $userhistoryid = get_dbid('user_history', 'userhistoryid'); + $sql = 'INSERT INTO user_history (userhistoryid, userid, title5, url5)'. +- ' VALUES('.$userhistoryid.', '.$userid.', '.zbx_dbstr($title).', '.zbx_dbstr($url).')'; ++ ' VALUES('.$userhistoryid.', '.zbx_dbstr($userid).', '.zbx_dbstr($title).', '.zbx_dbstr($url).')'; + } + else { + $sql = 'UPDATE user_history'. +@@ -427,7 +426,7 @@ + ' url4=url5,'. + ' title5='.zbx_dbstr($title).','. + ' url5='.zbx_dbstr($url). +- ' WHERE userid='.$userid; ++ ' WHERE userid='.zbx_dbstr($userid); + } + } + return DBexecute($sql); +@@ -464,7 +463,7 @@ + 'profileid' => get_dbid('profiles', 'profileid'), + 'userid' => CWebUser::$data['userid'], + 'idx' => zbx_dbstr($favobj), +- 'value_id' => $favid, ++ 'value_id' => zbx_dbstr($favid), + 'type' => PROFILE_TYPE_ID + ); + if (!is_null($source)) { +@@ -478,7 +477,7 @@ + 'DELETE FROM profiles'. + ' WHERE userid='.CWebUser::$data['userid']. + ' AND idx='.zbx_dbstr($favobj). +- ($favid > 0 ? ' AND value_id='.$favid : ''). ++ ($favid > 0 ? ' AND value_id='.zbx_dbstr($favid) : ''). + (is_null($source) ? '' : ' AND source='.zbx_dbstr($source)) + ); + } +Index: frontends/php/include/graphs.inc.php +=================================================================== +--- frontends/php/include/graphs.inc.php (revision 38884) ++++ frontends/php/include/graphs.inc.php (working copy) +@@ -120,7 +120,7 @@ + $dbGraphs = DBselect( + 'SELECT MAX(g.graphtype) AS graphtype,MIN(gi.yaxisside) AS yaxissidel,MAX(gi.yaxisside) AS yaxissider,MAX(g.height) AS height'. + ' FROM graphs g,graphs_items gi'. +- ' WHERE g.graphid='.$graphid. ++ ' WHERE g.graphid='.zbx_dbstr($graphid). + ' AND gi.graphid=g.graphid' + ); + if ($graph = DBfetch($dbGraphs)) { +@@ -154,7 +154,7 @@ + ' FROM graphs g,graphs_items gi,items i'. + ' WHERE g.graphid=gi.graphid'. + ' AND gi.itemid=i.itemid'. +- ' AND i.hostid='.$hostid ++ ' AND i.hostid='.zbx_dbstr($hostid) + ); + } + +@@ -172,7 +172,7 @@ + ' FROM graphs_items gi,items i,hosts h'. + ' WHERE h.hostid=i.hostid'. + ' AND gi.itemid=i.itemid'. +- ' AND gi.graphid='.$graphid ++ ' AND gi.graphid='.zbx_dbstr($graphid) + ); + } + +@@ -187,7 +187,7 @@ + $dbItems = DBselect( + 'SELECT DISTINCT gi.itemid'. + ' FROM graphs_items gi'. +- ' WHERE gi.graphid='.$graphid ++ ' WHERE gi.graphid='.zbx_dbstr($graphid) + ); + while ($item = DBfetch($dbItems)) { + $itemids[$item['itemid']] = $item['itemid']; +@@ -280,7 +280,7 @@ + } + + function get_graph_by_graphid($graphid) { +- $dbGraphs = DBselect('SELECT g.* FROM graphs g WHERE g.graphid='.$graphid); ++ $dbGraphs = DBselect('SELECT g.* FROM graphs g WHERE g.graphid='.zbx_dbstr($graphid)); + $dbGraphs = DBfetch($dbGraphs); + if (!empty($dbGraphs)) { + return $dbGraphs; +@@ -307,8 +307,8 @@ + 'SELECT dest.itemid,src.key_'. + ' FROM items dest,items src'. + ' WHERE dest.key_=src.key_'. +- ' AND dest.hostid='.$dest_hostid. +- ' AND src.itemid='.$gitem['itemid'] ++ ' AND dest.hostid='.zbx_dbstr($dest_hostid). ++ ' AND src.itemid='.zbx_dbstr($gitem['itemid']) + )); + + if ($dbItem) { +Index: frontends/php/include/db.inc.php +=================================================================== +--- frontends/php/include/db.inc.php (revision 38884) ++++ frontends/php/include/db.inc.php (working copy) +@@ -150,7 +150,7 @@ + ); + db2_set_option($DB['DB'], $options, 1); + if (isset($DB['SCHEMA']) && ($DB['SCHEMA'] != '')) { +- DBexecute("SET CURRENT SCHEMA='".$DB['SCHEMA']."'"); ++ DBexecute('SET CURRENT SCHEMA='.zbx_dbstr($DB['SCHEMA'])); + } + } + break; +@@ -563,7 +563,7 @@ + + $result = false; + +- if (!isset($DB['DB']) || empty($DB['DB'])) { ++ if (!isset($DB['DB']) || empty($DB['DB']) || is_bool($cursor)) { + return $result; + } + +Index: frontends/php/include/views/configuration.screen.constructor.edit.php +=================================================================== +--- frontends/php/include/views/configuration.screen.constructor.edit.php (revision 38884) ++++ frontends/php/include/views/configuration.screen.constructor.edit.php (working copy) +@@ -419,7 +419,7 @@ + 'SELECT DISTINCT n.name AS node_name,s.screenid,s.name'. + ' FROM screens s'. + ' LEFT JOIN nodes n ON n.nodeid='.DBid2nodeid('s.screenid'). +- ' WHERE s.screenid='.$resourceid ++ ' WHERE s.screenid='.zbx_dbstr($resourceid) + ); + while ($row = DBfetch($db_screens)) { + $screen = API::Screen()->get(array( +Index: frontends/php/include/classes/class.chostsinfo.php +=================================================================== +--- frontends/php/include/classes/class.chostsinfo.php (revision 38884) ++++ frontends/php/include/classes/class.chostsinfo.php (working copy) +@@ -55,7 +55,7 @@ + $cond_from = ''; + if (remove_nodes_from_id($this->groupid) > 0) { + $cond_from = ', hosts_groups hg '; +- $cond_where = 'AND hg.hostid=h.hostid AND hg.groupid='.$this->groupid; ++ $cond_where = 'AND hg.hostid=h.hostid AND hg.groupid='.zbx_dbstr($this->groupid); + } + else { + $cond_where = ' AND '.DBin_node('h.hostid', $this->nodeid); +Index: frontends/php/include/classes/import/CImportReferencer.php +=================================================================== +--- frontends/php/include/classes/import/CImportReferencer.php (revision 38884) ++++ frontends/php/include/classes/import/CImportReferencer.php (working copy) +@@ -595,7 +595,7 @@ + foreach ($this->applications as $host => $applications) { + $hostId = $this->resolveHostOrTemplate($host); + if ($hostId) { +- $sqlWhere[] = '(hostid='.$hostId.' AND '.dbConditionString('name', $applications).')'; ++ $sqlWhere[] = '(hostid='.zbx_dbstr($hostId).' AND '.dbConditionString('name', $applications).')'; + } + } + +@@ -626,7 +626,7 @@ + foreach ($this->items as $host => $keys) { + $hostId = $this->resolveHostOrTemplate($host); + if ($hostId) { +- $sqlWhere[] = '(i.hostid='.$hostId.' AND '.dbConditionString('i.key_', $keys).')'; ++ $sqlWhere[] = '(i.hostid='.zbx_dbstr($hostId).' AND '.dbConditionString('i.key_', $keys).')'; + } + } + +@@ -778,7 +778,7 @@ + foreach ($this->macros as $host => $macros) { + $hostId = $this->resolveHostOrTemplate($host); + if ($hostId) { +- $sqlWhere[] = '(hm.hostid='.$hostId.' AND '.dbConditionString('hm.macro', $macros).')'; ++ $sqlWhere[] = '(hm.hostid='.zbx_dbstr($hostId).' AND '.dbConditionString('hm.macro', $macros).')'; + } + } + +Index: frontends/php/include/classes/class.cpie.php +=================================================================== +--- frontends/php/include/classes/class.cpie.php (revision 38884) ++++ frontends/php/include/classes/class.cpie.php (working copy) +@@ -170,9 +170,9 @@ + 'MAX(i.lastvalue) AS lst'. + ' FROM history h'. + ' LEFT JOIN items i ON h.itemid=i.itemid'. +- ' WHERE h.itemid='.$this->items[$i]['itemid']. +- ' AND h.clock>='.$from_time. +- ' AND h.clock<='.$to_time. ++ ' WHERE h.itemid='.zbx_dbstr($this->items[$i]['itemid']). ++ ' AND h.clock>='.zbx_dbstr($from_time). ++ ' AND h.clock<='.zbx_dbstr($to_time). + ' GROUP BY h.itemid' + , + 'SELECT hu.itemid,'. +@@ -181,9 +181,9 @@ + 'MAX(i.lastvalue) AS lst'. + ' FROM history_uint hu'. + ' LEFT JOIN items i ON hu.itemid=i.itemid'. +- ' WHERE hu.itemid='.$this->items[$i]['itemid']. +- ' AND hu.clock>='.$from_time. +- ' AND hu.clock<='.$to_time. ++ ' WHERE hu.itemid='.zbx_dbstr($this->items[$i]['itemid']). ++ ' AND hu.clock>='.zbx_dbstr($from_time). ++ ' AND hu.clock<='.zbx_dbstr($to_time). + ' GROUP BY hu.itemid' + ); + } +@@ -196,9 +196,9 @@ + 'MAX(i.lastvalue) AS lst'. + ' FROM trends t'. + ' LEFT JOIN items i ON t.itemid=i.itemid'. +- ' WHERE t.itemid='.$this->items[$i]['itemid']. +- ' AND t.clock>='.$from_time. +- ' AND t.clock<='.$to_time. ++ ' WHERE t.itemid='.zbx_dbstr($this->items[$i]['itemid']). ++ ' AND t.clock>='.zbx_dbstr($from_time). ++ ' AND t.clock<='.zbx_dbstr($to_time). + ' GROUP BY t.itemid' + , + 'SELECT t.itemid,'. +@@ -207,9 +207,9 @@ + 'MAX(i.lastvalue) AS lst'. + ' FROM trends_uint t'. + ' LEFT JOIN items i ON t.itemid=i.itemid'. +- ' WHERE t.itemid='.$this->items[$i]['itemid']. +- ' AND t.clock>='.$from_time. +- ' AND t.clock<='.$to_time. ++ ' WHERE t.itemid='.zbx_dbstr($this->items[$i]['itemid']). ++ ' AND t.clock>='.zbx_dbstr($from_time). ++ ' AND t.clock<='.zbx_dbstr($to_time). + ' GROUP BY t.itemid' + ); + } +Index: frontends/php/include/classes/screens/CScreenDataOverview.php +=================================================================== +--- frontends/php/include/classes/screens/CScreenDataOverview.php (revision 38884) ++++ frontends/php/include/classes/screens/CScreenDataOverview.php (working copy) +@@ -28,7 +28,7 @@ + */ + public function get() { + $hostids = array(); +- $dbHostGroups = DBselect('SELECT DISTINCT hg.hostid FROM hosts_groups hg WHERE hg.groupid='.$this->screenitem['resourceid']); ++ $dbHostGroups = DBselect('SELECT DISTINCT hg.hostid FROM hosts_groups hg WHERE hg.groupid='.zbx_dbstr($this->screenitem['resourceid'])); + while ($dbHostGroup = DBfetch($dbHostGroups)) { + $hostids[$dbHostGroup['hostid']] = $dbHostGroup['hostid']; + } +Index: frontends/php/include/classes/screens/CScreenTriggersOverview.php +=================================================================== +--- frontends/php/include/classes/screens/CScreenTriggersOverview.php (revision 38884) ++++ frontends/php/include/classes/screens/CScreenTriggersOverview.php (working copy) +@@ -28,7 +28,7 @@ + */ + public function get() { + $hostids = array(); +- $dbHostGroups = DBselect('SELECT DISTINCT hg.hostid FROM hosts_groups hg WHERE hg.groupid='.$this->screenitem['resourceid']); ++ $dbHostGroups = DBselect('SELECT DISTINCT hg.hostid FROM hosts_groups hg WHERE hg.groupid='.zbx_dbstr($this->screenitem['resourceid'])); + while ($dbHostGroup = DBfetch($dbHostGroups)) { + $hostids[$dbHostGroup['hostid']] = $dbHostGroup['hostid']; + } +Index: frontends/php/include/classes/class.cchart.php +=================================================================== +--- frontends/php/include/classes/class.cchart.php (revision 38884) ++++ frontends/php/include/classes/class.cchart.php (working copy) +@@ -225,18 +225,18 @@ + 'COUNT(*) AS count,AVG(value) AS avg,MIN(value) as min,'. + 'MAX(value) AS max,MAX(clock) AS clock'. + ' FROM history '. +- ' WHERE itemid='.$this->items[$i]['itemid']. +- ' AND clock>='.$from_time. +- ' AND clock<='.$to_time. ++ ' WHERE itemid='.zbx_dbstr($this->items[$i]['itemid']). ++ ' AND clock>='.zbx_dbstr($from_time). ++ ' AND clock<='.zbx_dbstr($to_time). + ' GROUP BY itemid,'.$calc_field + , + 'SELECT itemid,'.$calc_field.' AS i,'. + 'COUNT(*) AS count,AVG(value) AS avg,MIN(value) AS min,'. + 'MAX(value) AS max,MAX(clock) AS clock'. + ' FROM history_uint '. +- ' WHERE itemid='.$this->items[$i]['itemid']. +- ' AND clock>='.$from_time. +- ' AND clock<='.$to_time. ++ ' WHERE itemid='.zbx_dbstr($this->items[$i]['itemid']). ++ ' AND clock>='.zbx_dbstr($from_time). ++ ' AND clock<='.zbx_dbstr($to_time). + ' GROUP BY itemid,'.$calc_field + ); + } +@@ -248,17 +248,17 @@ + 'MAX(value_max) AS max,MAX(clock) AS clock'. + ' FROM trends'. + ' WHERE itemid='.$this->items[$i]['itemid']. +- ' AND clock>='.$from_time. +- ' AND clock<='.$to_time. ++ ' AND clock>='.zbx_dbstr($from_time). ++ ' AND clock<='.zbx_dbstr($to_time). + ' GROUP BY itemid,'.$calc_field + , + 'SELECT itemid,'.$calc_field.' AS i,'. + 'SUM(num) AS count,AVG(value_avg) AS avg,MIN(value_min) AS min,'. + 'MAX(value_max) AS max,MAX(clock) AS clock'. + ' FROM trends_uint '. +- ' WHERE itemid='.$this->items[$i]['itemid']. +- ' AND clock>='.$from_time. +- ' AND clock<='.$to_time. ++ ' WHERE itemid='.zbx_dbstr($this->items[$i]['itemid']). ++ ' AND clock>='.zbx_dbstr($from_time). ++ ' AND clock<='.zbx_dbstr($to_time). + ' GROUP BY itemid,'.$calc_field + ); + +@@ -438,7 +438,7 @@ + ' AND tr.status='.TRIGGER_STATUS_ENABLED. + ' AND i.itemid=f.itemid'. + ' AND h.hostid=i.hostid'. +- ' AND f.itemid='.$item['itemid']. ++ ' AND f.itemid='.zbx_dbstr($item['itemid']). + ' ORDER BY tr.priority' + ); + while (($trigger = DBfetch($db_triggers)) && $cnt < $max) { +Index: frontends/php/include/classes/helpers/trigger/CTriggerDescription.php +=================================================================== +--- frontends/php/include/classes/helpers/trigger/CTriggerDescription.php (revision 38884) ++++ frontends/php/include/classes/helpers/trigger/CTriggerDescription.php (working copy) +@@ -59,7 +59,7 @@ + $trigger = DBfetch(DBselect( + 'SELECT DISTINCT t.description,t.expression,t.triggerid'. + ' FROM triggers t'. +- ' WHERE t.triggerid='.$triggerId ++ ' WHERE t.triggerid='.zbx_dbstr($triggerId) + )); + $triggers = $this->expandDescriptions(array($trigger['triggerid'] => $trigger)); + $trigger = reset($triggers); +Index: frontends/php/include/maps.inc.php +=================================================================== +--- frontends/php/include/maps.inc.php (revision 38884) ++++ frontends/php/include/maps.inc.php (working copy) +@@ -252,7 +252,7 @@ + $res = DBselect('SELECT hi.ip,hi.dns,hi.useip,h.host,h.name,hi.type AS interfacetype'. + ' FROM interface hi,hosts h'. + ' WHERE hi.hostid=h.hostid'. +- ' AND hi.main=1 AND hi.hostid='.$selement['elementid']); ++ ' AND hi.main=1 AND hi.hostid='.zbx_dbstr($selement['elementid'])); + + // process interface priorities + $tmpPriority = 0; +@@ -272,7 +272,7 @@ + ' WHERE h.hostid=hi.hostid'. + ' AND hi.hostid=i.hostid'. + ' AND i.itemid=f.itemid'. +- ' AND hi.main=1 AND f.triggerid='.$selement['elementid']. ++ ' AND hi.main=1 AND f.triggerid='.zbx_dbstr($selement['elementid']). + ' ORDER BY f.functionid'); + + // process interface priorities, build $hostsByFunctionId array +@@ -473,7 +473,7 @@ + 'SELECT '.$function.'(value) AS value'. + ' FROM '.$history_table[$item['value_type']]. + ' WHERE clock>'.(time() - $parameter). +- ' AND itemid='.$item['itemid'] ++ ' AND itemid='.zbx_dbstr($item['itemid']) + ); + if (null === ($row = DBfetch($result))) { + $label = str_replace($expr, '('._('no data').')', $label); +@@ -502,7 +502,7 @@ + $db_mapselements = DBselect( + 'SELECT DISTINCT se.elementtype,se.elementid'. + ' FROM sysmaps_elements se'. +- ' WHERE se.sysmapid='.$db_element['elementid'] ++ ' WHERE se.sysmapid='.zbx_dbstr($db_element['elementid']) + ); + while ($db_mapelement = DBfetch($db_mapselements)) { + get_map_elements($db_mapelement, $elements); +Index: frontends/php/include/hosts.inc.php +=================================================================== +--- frontends/php/include/hosts.inc.php (revision 38884) ++++ frontends/php/include/hosts.inc.php (working copy) +@@ -483,7 +483,7 @@ + } + + function get_hostgroup_by_groupid($groupid) { +- $groups = DBfetch(DBselect('SELECT g.* FROM groups g WHERE g.groupid='.$groupid)); ++ $groups = DBfetch(DBselect('SELECT g.* FROM groups g WHERE g.groupid='.zbx_dbstr($groupid))); + if (!empty($groups)) { + return $groups; + } +@@ -522,7 +522,7 @@ + } + + function get_host_by_hostid($hostid, $no_error_message = 0) { +- $row = DBfetch(DBselect('SELECT h.* FROM hosts h WHERE h.hostid='.$hostid)); ++ $row = DBfetch(DBselect('SELECT h.* FROM hosts h WHERE h.hostid='.zbx_dbstr($hostid))); + if ($row) { + return $row; + } +@@ -1109,7 +1109,7 @@ + + if ($_REQUEST['groupid'] > 0) { + if ($_REQUEST['hostid'] > 0) { +- if (!DBfetch(DBselect('SELECT hg.groupid FROM hosts_groups hg WHERE hg.hostid='.$_REQUEST['hostid'].' AND hg.groupid='.$_REQUEST['groupid']))) { ++ if (!DBfetch(DBselect('SELECT hg.groupid FROM hosts_groups hg WHERE hg.hostid='.zbx_dbstr($_REQUEST['hostid']).' AND hg.groupid='.zbx_dbstr($_REQUEST['groupid'])))) { + $_REQUEST['hostid'] = 0; + } + } +@@ -1145,7 +1145,7 @@ + } + + function get_application_by_applicationid($applicationid, $no_error_message = 0) { +- $row = DBfetch(DBselect('SELECT a.* FROM applications a WHERE a.applicationid='.$applicationid)); ++ $row = DBfetch(DBselect('SELECT a.* FROM applications a WHERE a.applicationid='.zbx_dbstr($applicationid))); + if ($row) { + return $row; + } +@@ -1157,7 +1157,7 @@ + } + + function get_applications_by_templateid($applicationid) { +- return DBselect('SELECT a.* FROM applications a WHERE a.templateid='.$applicationid); ++ return DBselect('SELECT a.* FROM applications a WHERE a.templateid='.zbx_dbstr($applicationid)); + } + + function get_realhost_by_applicationid($applicationid) { +@@ -1169,7 +1169,7 @@ + } + + function get_host_by_applicationid($applicationid) { +- $row = DBfetch(DBselect('SELECT h.* FROM hosts h,applications a WHERE a.hostid=h.hostid AND a.applicationid='.$applicationid)); ++ $row = DBfetch(DBselect('SELECT h.* FROM hosts h,applications a WHERE a.hostid=h.hostid AND a.applicationid='.zbx_dbstr($applicationid))); + if ($row) { + return $row; + } +@@ -1327,7 +1327,7 @@ + } + + function isTemplate($hostid) { +- $dbHost = DBfetch(DBselect('SELECT h.status FROM hosts h WHERE h.hostid='.$hostid)); ++ $dbHost = DBfetch(DBselect('SELECT h.status FROM hosts h WHERE h.hostid='.zbx_dbstr($hostid))); + + return !empty($dbHost) && $dbHost['status'] == HOST_STATUS_TEMPLATE; + } +Index: frontends/php/include/users.inc.php +=================================================================== +--- frontends/php/include/users.inc.php (revision 38884) ++++ frontends/php/include/users.inc.php (working copy) +@@ -90,9 +90,9 @@ + function add_user_to_group($userid, $usrgrpid) { + $result = false; + if (granted2move_user($userid,$usrgrpid)) { +- DBexecute('DELETE FROM users_groups WHERE userid='.$userid.' AND usrgrpid='.$usrgrpid); ++ DBexecute('DELETE FROM users_groups WHERE userid='.zbx_dbstr($userid).' AND usrgrpid='.zbx_dbstr($usrgrpid)); + $users_groups_id = get_dbid('users_groups', 'id'); +- $result = DBexecute('INSERT INTO users_groups (id,usrgrpid,userid) VALUES ('.$users_groups_id.','.$usrgrpid.','.$userid.')'); ++ $result = DBexecute('INSERT INTO users_groups (id,usrgrpid,userid) VALUES ('.$users_groups_id.','.zbx_dbstr($usrgrpid).','.zbx_dbstr($userid).')'); + } + else{ + error(_('User cannot change status of himself.')); +@@ -103,7 +103,7 @@ + function remove_user_from_group($userid, $usrgrpid) { + $result = false; + if (granted2move_user($userid,$usrgrpid)) { +- $result = DBexecute('DELETE FROM users_groups WHERE userid='.$userid.' AND usrgrpid='.$usrgrpid); ++ $result = DBexecute('DELETE FROM users_groups WHERE userid='.zbx_dbstr($userid).' AND usrgrpid='.zbx_dbstr($usrgrpid)); + } + else { + error(_('User cannot change status of himself.')); +@@ -138,7 +138,7 @@ + } + + if ($grant) { +- $result = DBexecute('UPDATE usrgrp SET users_status='.$users_status.' WHERE '.dbConditionInt('usrgrpid', $usrgrpids)); ++ $result = DBexecute('UPDATE usrgrp SET users_status='.zbx_dbstr($users_status).' WHERE '.dbConditionInt('usrgrpid', $usrgrpids)); + } + else { + error(_('User cannot change status of himself.')); +@@ -154,7 +154,7 @@ + $grant = granted2update_group($usrgrpids); + } + if ($grant) { +- $result = DBexecute('UPDATE usrgrp SET gui_access='.$gui_access.' WHERE '.dbConditionInt('usrgrpid',$usrgrpids)); ++ $result = DBexecute('UPDATE usrgrp SET gui_access='.zbx_dbstr($gui_access).' WHERE '.dbConditionInt('usrgrpid',$usrgrpids)); + } + else { + error(_('User cannot change GUI access for himself.')); +@@ -164,6 +164,6 @@ + + function change_group_debug_mode($usrgrpids, $debug_mode){ + zbx_value2array($usrgrpids); +- return DBexecute('UPDATE usrgrp SET debug_mode='.$debug_mode.' WHERE '.dbConditionInt('usrgrpid', $usrgrpids)); ++ return DBexecute('UPDATE usrgrp SET debug_mode='.zbx_dbstr($debug_mode).' WHERE '.dbConditionInt('usrgrpid', $usrgrpids)); + } + ?> +Index: frontends/php/include/events.inc.php +=================================================================== +--- frontends/php/include/events.inc.php (revision 38884) ++++ frontends/php/include/events.inc.php (working copy) +@@ -33,7 +33,7 @@ + function get_tr_event_by_eventid($eventid) { + $sql = 'SELECT e.*,t.triggerid,t.description,t.expression,t.priority,t.status,t.type'. + ' FROM events e,triggers t'. +- ' WHERE e.eventid='.$eventid. ++ ' WHERE e.eventid='.zbx_dbstr($eventid). + ' AND e.object='.EVENT_OBJECT_TRIGGER. + ' AND t.triggerid=e.objectid'; + return DBfetch(DBselect($sql)); +@@ -100,9 +100,9 @@ + + $sql = 'SELECT e.*'. + ' FROM events e'. +- ' WHERE e.objectid='.$currentEvent['objectid']. +- ' AND e.eventid>'.$currentEvent['eventid']. +- ' AND e.object='.$currentEvent['object']. ++ ' WHERE e.objectid='.zbx_dbstr($currentEvent['objectid']). ++ ' AND e.eventid>'.zbx_dbstr($currentEvent['eventid']). ++ ' AND e.object='.zbx_dbstr($currentEvent['object']). + ($showUnknown ? '' : ' AND e.value_changed='.TRIGGER_VALUE_CHANGED_YES). + ' ORDER BY e.object,e.objectid,e.eventid'; + return DBfetch(DBselect($sql, 1)); +Index: frontends/php/include/images.inc.php +=================================================================== +--- frontends/php/include/images.inc.php (revision 38884) ++++ frontends/php/include/images.inc.php (working copy) +@@ -36,7 +36,7 @@ + static $images = array(); + + if (!isset($images[$imageid])) { +- $row = DBfetch(DBselect('SELECT i.* FROM images i WHERE i.imageid='.$imageid)); ++ $row = DBfetch(DBselect('SELECT i.* FROM images i WHERE i.imageid='.zbx_dbstr($imageid))); + $row['image'] = zbx_unescape_image($row['image']); + $images[$imageid] = $row; + } +Index: frontends/php/include/maintenances.inc.php +=================================================================== +--- frontends/php/include/maintenances.inc.php (revision 38884) ++++ frontends/php/include/maintenances.inc.php (working copy) +@@ -23,7 +23,7 @@ + $sql = 'SELECT m.*'. + ' FROM maintenances m'. + ' WHERE '.DBin_node('m.maintenanceid'). +- ' AND maintenanceid='.$maintenanceid; ++ ' AND maintenanceid='.zbx_dbstr($maintenanceid); + return DBfetch(DBselect($sql)); + } + +Index: frontends/php/include/discovery.inc.php +=================================================================== +--- frontends/php/include/discovery.inc.php (revision 38884) ++++ frontends/php/include/discovery.inc.php (working copy) +@@ -164,7 +164,7 @@ + } + + function get_discovery_rule_by_druleid($druleid) { +- return DBfetch(DBselect('SELECT d.* FROM drules d WHERE d.druleid='.$druleid)); ++ return DBfetch(DBselect('SELECT d.* FROM drules d WHERE d.druleid='.zbx_dbstr($druleid))); + } + + function delete_discovery_rule($druleid) { +@@ -174,7 +174,7 @@ + 'SELECT DISTINCT c.actionid'. + ' FROM conditions c'. + ' WHERE c.conditiontype='.CONDITION_TYPE_DRULE. +- ' AND c.value=\''.$druleid.'\'' ++ ' AND c.value='.zbx_dbstr($druleid) + ); + while ($action = DBfetch($dbActions)) { + $actionids[] = $action['actionid']; +@@ -183,8 +183,8 @@ + // disabling actions with deleted conditions + if (!empty($actionids)) { + DBexecute('UPDATE actions SET status='.ACTION_STATUS_DISABLED.' WHERE '.dbConditionInt('actionid', $actionids)); +- DBexecute('DELETE FROM conditions WHERE conditiontype='.CONDITION_TYPE_DRULE.' AND value=\''.$druleid.'\''); ++ DBexecute('DELETE FROM conditions WHERE conditiontype='.CONDITION_TYPE_DRULE.' AND value='.zbx_dbstr($druleid)); + } +- return DBexecute('DELETE FROM drules WHERE druleid='.$druleid); ++ return DBexecute('DELETE FROM drules WHERE druleid='.zbx_dbstr($druleid)); + } + ?> +Index: frontends/php/include/nodes.inc.php +=================================================================== +--- frontends/php/include/nodes.inc.php (revision 38884) ++++ frontends/php/include/nodes.inc.php (working copy) +@@ -281,23 +281,22 @@ + error(_('Master node already exists.')); + return false; + } +- $masterid = 'NULL'; + break; + default: + error(_('Incorrect node type.')); + return false; + } + +- if (DBfetch(DBselect('SELECT n.nodeid FROM nodes n WHERE n.nodeid='.$nodeid))) { ++ if (DBfetch(DBselect('SELECT n.nodeid FROM nodes n WHERE n.nodeid='.zbx_dbstr($nodeid)))) { + error(_('Node with same ID already exists.')); + return false; + } + + $result = DBexecute('INSERT INTO nodes (nodeid,name,ip,port,nodetype,masterid)'. +- ' VALUES ('.$nodeid.','.zbx_dbstr($name).','.zbx_dbstr($ip).','.$port.','.$nodetype.','.$masterid.')'); ++ ' VALUES ('.$nodeid.','.zbx_dbstr($name).','.zbx_dbstr($ip).','.zbx_dbstr($port).','.zbx_dbstr($nodetype).','.($masterid ? zbx_dbstr($masterid) : 'NULL').')'); + + if ($result && $nodetype == ZBX_NODE_MASTER) { +- DBexecute('UPDATE nodes SET masterid='.$nodeid.' WHERE nodeid='.$ZBX_LOCALNODEID); ++ DBexecute('UPDATE nodes SET masterid='.zbx_dbstr($nodeid).' WHERE nodeid='.$ZBX_LOCALNODEID); + $ZBX_CURMASTERID = $nodeid; // apply master node for this script + } + +@@ -309,12 +308,12 @@ + error(_('Incorrect characters used for Node name.')); + return false; + } +- return DBexecute('UPDATE nodes SET name='.zbx_dbstr($name).',ip='.zbx_dbstr($ip).',port='.$port.' WHERE nodeid='.$nodeid); ++ return DBexecute('UPDATE nodes SET name='.zbx_dbstr($name).',ip='.zbx_dbstr($ip).',port='.zbx_dbstr($port).' WHERE nodeid='.zbx_dbstr($nodeid)); + } + + function delete_node($nodeid) { + $result = false; +- $node = DBfetch(DBselect('SELECT n.nodeid,n.masterid FROM nodes n WHERE n.nodeid='.$nodeid)); ++ $node = DBfetch(DBselect('SELECT n.nodeid,n.masterid FROM nodes n WHERE n.nodeid='.zbx_dbstr($nodeid))); + $nodetype = detect_node_type($node['nodeid'], $node['masterid']); + + if ($nodetype == ZBX_NODE_LOCAL) { +@@ -322,8 +321,8 @@ + } + else { + $result = ( +- DBexecute('UPDATE nodes SET masterid=NULL WHERE masterid='.$nodeid) && +- DBexecute('DELETE FROM nodes WHERE nodeid='.$nodeid) ++ DBexecute('UPDATE nodes SET masterid=NULL WHERE masterid='.zbx_dbstr($nodeid)) && ++ DBexecute('DELETE FROM nodes WHERE nodeid='.zbx_dbstr($nodeid)) + ); + if ($nodetype != ZBX_NODE_MASTER) { + error(_('Please be aware that database still contains data related to the deleted node.')); +@@ -333,7 +332,7 @@ + } + + function get_node_by_nodeid($nodeid) { +- return DBfetch(DBselect('SELECT n.* FROM nodes n WHERE n.nodeid='.$nodeid)); ++ return DBfetch(DBselect('SELECT n.* FROM nodes n WHERE n.nodeid='.zbx_dbstr($nodeid))); + } + + function get_node_path($nodeid, $result = '') { +Index: frontends/php/include/valuemap.inc.php +=================================================================== +--- frontends/php/include/valuemap.inc.php (revision 38884) ++++ frontends/php/include/valuemap.inc.php (working copy) +@@ -59,7 +59,7 @@ + unset($valueMap['valuemapid']); + + // check existence +- if (!DBfetch(DBselect('SELECT v.valuemapid FROM valuemaps v WHERE v.valuemapid='.$valueMapId))) { ++ if (!DBfetch(DBselect('SELECT v.valuemapid FROM valuemaps v WHERE v.valuemapid='.zbx_dbstr($valueMapId)))) { + throw new Exception(_s('Value map with valuemapid "%1$s" does not exist.', $valueMapId)); + } + +@@ -228,7 +228,7 @@ + $dbMappings = DBselect( + 'SELECT m.mappingid,m.value,m.newvalue'. + ' FROM mappings m'. +- ' WHERE m.valuemapid='.$valueMapId ++ ' WHERE m.valuemapid='.zbx_dbstr($valueMapId) + ); + while ($mapping = DBfetch($dbMappings)) { + $mappings[$mapping['mappingid']] = $mapping; +@@ -260,7 +260,7 @@ + $dbMappings = DBselect( + 'SELECT m.newvalue'. + ' FROM mappings m'. +- ' WHERE m.valuemapid='.$valueMapId. ++ ' WHERE m.valuemapid='.zbx_dbstr($valueMapId). + ' AND m.value='.zbx_dbstr($value) + ); + if ($mapping = DBfetch($dbMappings)) { +Index: frontends/php/include/httptest.inc.php +=================================================================== +--- frontends/php/include/httptest.inc.php (revision 38884) ++++ frontends/php/include/httptest.inc.php (working copy) +@@ -72,10 +72,10 @@ + } + + function activate_httptest($httptestid) { +- $result = DBexecute('UPDATE httptest SET status='.HTTPTEST_STATUS_ACTIVE.' WHERE httptestid='.$httptestid); ++ $result = DBexecute('UPDATE httptest SET status='.HTTPTEST_STATUS_ACTIVE.' WHERE httptestid='.zbx_dbstr($httptestid)); + + $itemids = array(); +- $items_db = DBselect('SELECT hti.itemid FROM httptestitem hti WHERE hti.httptestid='.$httptestid); ++ $items_db = DBselect('SELECT hti.itemid FROM httptestitem hti WHERE hti.httptestid='.zbx_dbstr($httptestid)); + while ($itemid = Dbfetch($items_db)) { + $itemids[] = $itemid['itemid']; + } +@@ -84,7 +84,7 @@ + 'SELECT hsi.itemid'. + ' FROM httpstep hs,httpstepitem hsi'. + ' WHERE hs.httpstepid=hsi.httpstepid'. +- ' AND hs.httptestid='.$httptestid ++ ' AND hs.httptestid='.zbx_dbstr($httptestid) + ); + while ($itemid = Dbfetch($items_db)) { + $itemids[] = $itemid['itemid']; +@@ -96,10 +96,10 @@ + } + + function disable_httptest($httptestid) { +- $result = DBexecute('UPDATE httptest SET status='.HTTPTEST_STATUS_DISABLED.' WHERE httptestid='.$httptestid); ++ $result = DBexecute('UPDATE httptest SET status='.HTTPTEST_STATUS_DISABLED.' WHERE httptestid='.zbx_dbstr($httptestid)); + + $itemids = array(); +- $items_db = DBselect('SELECT hti.itemid FROM httptestitem hti WHERE hti.httptestid='.$httptestid); ++ $items_db = DBselect('SELECT hti.itemid FROM httptestitem hti WHERE hti.httptestid='.zbx_dbstr($httptestid)); + while ($itemid = Dbfetch($items_db)) { + $itemids[] = $itemid['itemid']; + } +@@ -108,7 +108,7 @@ + 'SELECT hsi.itemid'. + ' FROM httpstep hs,httpstepitem hsi'. + ' WHERE hs.httpstepid=hsi.httpstepid'. +- ' AND hs.httptestid='.$httptestid ++ ' AND hs.httptestid='.zbx_dbstr($httptestid) + ); + while ($itemid = Dbfetch($items_db)) { + $itemids[] = $itemid['itemid']; +@@ -125,7 +125,7 @@ + ' FROM items i,httpstepitem si,httpstep s'. + ' WHERE i.itemid=si.itemid'. + ' AND si.httpstepid=s.httpstepid'. +- ' AND s.httptestid='.$httptestid ++ ' AND s.httptestid='.zbx_dbstr($httptestid) + ); + while ($item_data = DBfetch($db_items)) { + if (!delete_history_by_itemid($item_data['itemid'])) { +@@ -137,11 +137,11 @@ + } + + function get_httptest_by_httptestid($httptestid) { +- return DBfetch(DBselect('SELECT ht.* FROM httptest ht WHERE ht.httptestid='.$httptestid)); ++ return DBfetch(DBselect('SELECT ht.* FROM httptest ht WHERE ht.httptestid='.zbx_dbstr($httptestid))); + } + + function get_httpstep_by_no($httptestid, $no) { +- return DBfetch(DBselect('SELECT hs.* FROM httpstep hs WHERE hs.httptestid='.$httptestid.' AND hs.no='.$no)); ++ return DBfetch(DBselect('SELECT hs.* FROM httpstep hs WHERE hs.httptestid='.zbx_dbstr($httptestid).' AND hs.no='.zbx_dbstr($no))); + } + + function get_httptests_by_hostid($hostids) { +Index: frontends/php/include/acknow.inc.php +=================================================================== +--- frontends/php/include/acknow.inc.php (revision 38884) ++++ frontends/php/include/acknow.inc.php (working copy) +@@ -23,7 +23,7 @@ + $dbEvents = DBfetch(DBselect( + 'SELECT e.*'. + ' FROM events e'. +- ' WHERE e.objectid='.$triggerid. ++ ' WHERE e.objectid='.zbx_dbstr($triggerid). + ' AND e.object='.EVENT_OBJECT_TRIGGER. + ' AND e.value<>'.TRIGGER_VALUE_UNKNOWN. + ' AND e.value_changed='.TRIGGER_VALUE_CHANGED_YES. +@@ -35,7 +35,7 @@ + } + + function get_acknowledges_by_eventid($eventid) { +- return DBselect('SELECT a.*,u.alias FROM acknowledges a LEFT JOIN users u ON u.userid=a.userid WHERE a.eventid='.$eventid); ++ return DBselect('SELECT a.*,u.alias FROM acknowledges a LEFT JOIN users u ON u.userid=a.userid WHERE a.eventid='.zbx_dbstr($eventid)); + } + + /** +Index: frontends/php/include/triggers.inc.php +=================================================================== +--- frontends/php/include/triggers.inc.php (revision 38884) ++++ frontends/php/include/triggers.inc.php (working copy) +@@ -107,7 +107,7 @@ + function get_service_status_of_trigger($triggerid) { + $sql = 'SELECT t.triggerid,t.priority'. + ' FROM triggers t'. +- ' WHERE t.triggerid='.$triggerid. ++ ' WHERE t.triggerid='.zbx_dbstr($triggerid). + ' AND t.status='.TRIGGER_STATUS_ENABLED. + ' AND t.value='.TRIGGER_VALUE_TRUE; + $rows = DBfetch(DBselect($sql, 1)); +@@ -259,7 +259,7 @@ + } + + function get_trigger_by_triggerid($triggerid) { +- $db_trigger = DBfetch(DBselect('SELECT t.* FROM triggers t WHERE t.triggerid='.$triggerid)); ++ $db_trigger = DBfetch(DBselect('SELECT t.* FROM triggers t WHERE t.triggerid='.zbx_dbstr($triggerid))); + if (!empty($db_trigger)) { + return $db_trigger; + } +@@ -284,7 +284,7 @@ + return DBselect( + 'SELECT DISTINCT t.*'. + ' FROM triggers t,functions f,items i'. +- ' WHERE i.hostid='.$hostid. ++ ' WHERE i.hostid='.zbx_dbstr($hostid). + ' AND f.itemid=i.itemid'. + ' AND f.triggerid=t.triggerid' + ); +@@ -679,7 +679,7 @@ + $state = ''; + $sql = 'SELECT h.host,i.itemid,i.key_,f.function,f.triggerid,f.parameter,i.itemid,i.status,i.type,i.flags'. + ' FROM items i,functions f,hosts h'. +- ' WHERE f.functionid='.$functionid. ++ ' WHERE f.functionid='.zbx_dbstr($functionid). + ' AND i.itemid=f.itemid'. + ' AND h.hostid=i.hostid'; + +@@ -1068,8 +1068,8 @@ + ' FROM triggers t,functions f,items i'. + ' WHERE t.triggerid=f.triggerid'. + ' AND f.itemid=i.itemid'. +- ' AND t.templateid='.$val. +- ' AND i.hostid='.$hostid; ++ ' AND t.templateid='.zbx_dbstr($val). ++ ' AND i.hostid='.zbx_dbstr($hostid); + if ($db_new_dep = DBfetch(DBselect($sql))) { + $deps[$id] = $db_new_dep['triggerid']; + } +@@ -1395,9 +1395,9 @@ + if ($period_start > 0 && $period_start <= time()) { + $sql = 'SELECT e.eventid,e.value'. + ' FROM events e'. +- ' WHERE e.objectid='.$triggerid. ++ ' WHERE e.objectid='.zbx_dbstr($triggerid). + ' AND e.object='.EVENT_OBJECT_TRIGGER. +- ' AND e.clock<'.$period_start. ++ ' AND e.clock<'.zbx_dbstr($period_start). + ' ORDER BY e.eventid DESC'; + if ($row = DBfetch(DBselect($sql, 1))) { + $start_value = $row['value']; +@@ -1407,13 +1407,13 @@ + + $sql = 'SELECT COUNT(e.eventid) AS cnt,MIN(e.clock) AS min_clock,MAX(e.clock) AS max_clock'. + ' FROM events e'. +- ' WHERE e.objectid='.$triggerid. ++ ' WHERE e.objectid='.zbx_dbstr($triggerid). + ' AND e.object='.EVENT_OBJECT_TRIGGER; + if ($period_start != 0) { +- $sql .= ' AND clock>='.$period_start; ++ $sql .= ' AND clock>='.zbx_dbstr($period_start); + } + if ($period_end != 0) { +- $sql .= ' AND clock<='.$period_end; ++ $sql .= ' AND clock<='.zbx_dbstr($period_end); + } + + $db_events = DBfetch(DBselect($sql)); +@@ -1455,7 +1455,7 @@ + $db_events = DBselect( + 'SELECT e.eventid,e.clock,e.value'. + ' FROM events e'. +- ' WHERE e.objectid='.$triggerid. ++ ' WHERE e.objectid='.zbx_dbstr($triggerid). + ' AND e.object='.EVENT_OBJECT_TRIGGER. + ' AND e.clock BETWEEN '.$min.' AND '.$max. + ' ORDER BY e.eventid' +Index: frontends/php/include/forms.inc.php +=================================================================== +--- frontends/php/include/forms.inc.php (revision 38884) ++++ frontends/php/include/forms.inc.php (working copy) +@@ -66,7 +66,7 @@ + $data['user_medias'] = array(); + $dbMedia = DBselect('SELECT m.mediaid,m.mediatypeid,m.period,m.sendto,m.severity,m.active'. + ' FROM media m'. +- ' WHERE m.userid='.$userid ++ ' WHERE m.userid='.zbx_dbstr($userid) + ); + while ($dbMedium = DBfetch($dbMedia)) { + $data['user_medias'][] = $dbMedium; +@@ -1104,7 +1104,7 @@ + $data['db_applications'] = DBfetchArray(DBselect( + 'SELECT DISTINCT a.applicationid,a.name'. + ' FROM applications a'. +- ' WHERE a.hostid='.$data['hostid'] ++ ' WHERE a.hostid='.zbx_dbstr($data['hostid']) + )); + order_result($data['db_applications'], 'name'); + +@@ -1117,7 +1117,7 @@ + // valuemapid + if ($data['limited']) { + if (!empty($data['valuemapid'])) { +- if ($map_data = DBfetch(DBselect('SELECT v.name FROM valuemaps v WHERE v.valuemapid='.$data['valuemapid']))) { ++ if ($map_data = DBfetch(DBselect('SELECT v.name FROM valuemaps v WHERE v.valuemapid='.zbx_dbstr($data['valuemapid'])))) { + $data['valuemaps'] = $map_data['name']; + } + } +@@ -1270,7 +1270,7 @@ + ' LEFT JOIN items i ON f.itemid=i.itemid'. + ' LEFT JOIN hosts h ON i.hostid=h.hostid'. + ' LEFT JOIN item_discovery id ON i.itemid=id.itemid'. +- ' WHERE t.triggerid='.$tmp_triggerid ++ ' WHERE t.triggerid='.zbx_dbstr($tmp_triggerid) + )); + if (bccomp($data['triggerid'], $tmp_triggerid) != 0) { + // parent trigger prototype link +@@ -1313,7 +1313,7 @@ + 'SELECT t.triggerid,t.description'. + ' FROM triggers t,trigger_depends d'. + ' WHERE t.triggerid=d.triggerid_up'. +- ' AND d.triggerid_down='.$data['triggerid'] ++ ' AND d.triggerid_down='.zbx_dbstr($data['triggerid']) + ); + while ($trigger = DBfetch($db_triggers)) { + if (uint_in_array($trigger['triggerid'], $data['dependencies'])) { +@@ -1720,7 +1720,7 @@ + $table_titles = zbx_toHash($table_titles, 'db_field'); + $sql_fields = implode(', ', array_keys($table_titles)); + +- $sql = 'SELECT '.$sql_fields.' FROM host_inventory WHERE hostid='.$_REQUEST['hostid']; ++ $sql = 'SELECT '.$sql_fields.' FROM host_inventory WHERE hostid='.zbx_dbstr($_REQUEST['hostid']); + $result = DBselect($sql); + + $row = DBfetch($result); +@@ -1740,7 +1740,7 @@ + $sql = 'SELECT re.* '. + ' FROM regexps re '. + ' WHERE '.DBin_node('re.regexpid'). +- ' AND re.regexpid='.$_REQUEST['regexpid']; ++ ' AND re.regexpid='.zbx_dbstr($_REQUEST['regexpid']); + $regexp = DBfetch(DBSelect($sql)); + + $rename = $regexp['name']; +@@ -1750,7 +1750,7 @@ + $sql = 'SELECT e.* '. + ' FROM expressions e '. + ' WHERE '.DBin_node('e.expressionid'). +- ' AND e.regexpid='.$regexp['regexpid']. ++ ' AND e.regexpid='.zbx_dbstr($regexp['regexpid']). + ' ORDER BY e.expression_type'; + + $db_exps = DBselect($sql); +@@ -1888,7 +1888,7 @@ + $sql = 'SELECT e.* '. + ' FROM expressions e '. + ' WHERE '.DBin_node('e.expressionid'). +- ' AND e.regexpid='.$_REQUEST['regexpid']. ++ ' AND e.regexpid='.zbx_dbstr($_REQUEST['regexpid']). + ' ORDER BY e.expression_type'; + + $db_exps = DBselect($sql); +Index: frontends/php/include/regexp.inc.php +=================================================================== +--- frontends/php/include/regexp.inc.php (revision 38884) ++++ frontends/php/include/regexp.inc.php (working copy) +@@ -24,7 +24,7 @@ + 'SELECT re.*'. + ' FROM regexps re'. + ' WHERE '.DBin_node('re.regexpid'). +- ' AND regexpid='.$regexpId ++ ' AND regexpid='.zbx_dbstr($regexpId) + )); + } + +@@ -35,7 +35,7 @@ + 'SELECT e.expressionid,e.expression,e.expression_type,e.exp_delimiter,e.case_sensitive'. + ' FROM expressions e'. + ' WHERE '.DBin_node('e.expressionid'). +- ' AND regexpid='.$regexpId ++ ' AND regexpid='.zbx_dbstr($regexpId) + ); + while ($expression = DBfetch($dbExpressions)) { + $expressions[$expression['expressionid']] = $expression; +Index: frontends/php/include/actions.inc.php +=================================================================== +--- frontends/php/include/actions.inc.php (revision 38884) ++++ frontends/php/include/actions.inc.php (working copy) +@@ -203,7 +203,7 @@ + 'SELECT dr.name,c.dcheckid,c.type,c.key_,c.ports'. + ' FROM drules dr,dchecks c'. + ' WHERE dr.druleid=c.druleid'. +- ' AND c.dcheckid='.$value ++ ' AND c.dcheckid='.zbx_dbstr($value) + )); + if ($row) { + $str_val = $row['name'].': '.discovery_check2str($row['type'], $row['key_'], $row['ports']); +@@ -409,7 +409,7 @@ + $sql = 'SELECT a.def_shortdata,a.def_longdata '. + ' FROM actions a,operations o '. + ' WHERE a.actionid=o.actionid '. +- ' AND o.operationid='.$data['operationid']; ++ ' AND o.operationid='.zbx_dbstr($data['operationid']); + if ($rows = DBfetch(DBselect($sql, 1))) { + $result[] = array(bold(_('Subject').': '), BR(), zbx_nl2br($rows['def_shortdata'])); + $result[] = array(bold(_('Message').': '), BR(), zbx_nl2br($rows['def_longdata'])); +@@ -873,8 +873,8 @@ + ' FROM events e,alerts a'. + ' LEFT JOIN users u ON u.userid=a.userid'. + ' LEFT JOIN media_type mt ON mt.mediatypeid=a.mediatypeid'. +- ' WHERE a.eventid='.$eventid. +- (is_null($status)?'':' AND a.status='.$status). ++ ' WHERE a.eventid='.zbx_dbstr($eventid). ++ (is_null($status)?'':' AND a.status='.zbx_dbstr($status)). + ' AND e.eventid=a.eventid'. + ' AND a.alerttype IN ('.ALERT_TYPE_MESSAGE.','.ALERT_TYPE_COMMAND.')'. + ' AND '.DBin_node('a.alertid'). +Index: frontends/php/include/screens.inc.php +=================================================================== +--- frontends/php/include/screens.inc.php (revision 38884) ++++ frontends/php/include/screens.inc.php (working copy) +@@ -57,7 +57,7 @@ + } + + function get_screen_by_screenid($screenid) { +- $dbScreen = DBfetch(DBselect('SELECT s.* FROM screens s WHERE s.screenid='.$screenid)); ++ $dbScreen = DBfetch(DBselect('SELECT s.* FROM screens s WHERE s.screenid='.zbx_dbstr($screenid))); + return !empty($dbScreen) ? $dbScreen : false; + } + +@@ -69,7 +69,7 @@ + $db_scr_items = DBselect( + 'SELECT si.resourceid'. + ' FROM screens_items si'. +- ' WHERE si.screenid='.$child_screenid. ++ ' WHERE si.screenid='.zbx_dbstr($child_screenid). + ' AND si.resourcetype='.SCREEN_RESOURCE_SCREEN + ); + while ($scr_item = DBfetch($db_scr_items)) { +@@ -84,7 +84,7 @@ + $db_slides = DBfetch(DBselect( + 'SELECT MIN(s.step) AS min_step,MAX(s.step) AS max_step'. + ' FROM slides s'. +- ' WHERE s.slideshowid='.$slideshowid ++ ' WHERE s.slideshowid='.zbx_dbstr($slideshowid) + )); + if (!$db_slides || is_null($db_slides['min_step'])) { + return false; +@@ -101,9 +101,9 @@ + return DBfetch(DBselect( + 'SELECT sl.*'. + ' FROM slides sl,slideshows ss'. +- ' WHERE ss.slideshowid='.$slideshowid. ++ ' WHERE ss.slideshowid='.zbx_dbstr($slideshowid). + ' AND sl.slideshowid=ss.slideshowid'. +- ' AND sl.step='.$curr_step ++ ' AND sl.step='.zbx_dbstr($curr_step) + )); + } + +@@ -112,7 +112,7 @@ + + $sql = 'SELECT s.slideshowid'. + ' FROM slideshows s'. +- ' WHERE s.slideshowid='.$slideshowid. ++ ' WHERE s.slideshowid='.zbx_dbstr($slideshowid). + ' AND '.DBin_node('s.slideshowid', get_current_nodeid(null, $perm) + ); + if (DBselect($sql)) { +@@ -122,7 +122,7 @@ + $db_screens = DBselect( + 'SELECT DISTINCT s.screenid'. + ' FROM slides s'. +- ' WHERE s.slideshowid='.$slideshowid ++ ' WHERE s.slideshowid='.zbx_dbstr($slideshowid) + ); + while ($slide_data = DBfetch($db_screens)) { + $screenids[$slide_data['screenid']] = $slide_data['screenid']; +@@ -147,7 +147,7 @@ + } + + function get_slideshow_by_slideshowid($slideshowid) { +- return DBfetch(DBselect('SELECT s.* FROM slideshows s WHERE s.slideshowid='.$slideshowid)); ++ return DBfetch(DBselect('SELECT s.* FROM slideshows s WHERE s.slideshowid='.zbx_dbstr($slideshowid))); + } + + function add_slideshow($name, $delay, $slides) { +@@ -182,7 +182,7 @@ + $slideshowid = get_dbid('slideshows', 'slideshowid'); + $result = DBexecute( + 'INSERT INTO slideshows (slideshowid,name,delay)'. +- ' VALUES ('.$slideshowid.','.zbx_dbstr($name).','.$delay.')' ++ ' VALUES ('.zbx_dbstr($slideshowid).','.zbx_dbstr($name).','.zbx_dbstr($delay).')' + ); + + // create slides +@@ -197,7 +197,7 @@ + + $result = DBexecute( + 'INSERT INTO slides (slideid,slideshowid,screenid,step,delay)'. +- ' VALUES ('.$slideid.','.$slideshowid.','.$slide['screenid'].','.($i++).','.$slide['delay'].')' ++ ' VALUES ('.zbx_dbstr($slideid).','.zbx_dbstr($slideshowid).','.zbx_dbstr($slide['screenid']).','.($i++).','.zbx_dbstr($slide['delay']).')' + ); + if (!$result) { + return false; +@@ -228,14 +228,14 @@ + } + + // validate slide name +- $sql = 'SELECT s.slideshowid FROM slideshows s WHERE s.name='.zbx_dbstr($name).' AND s.slideshowid<>'.$slideshowid; ++ $sql = 'SELECT s.slideshowid FROM slideshows s WHERE s.name='.zbx_dbstr($name).' AND s.slideshowid<>'.zbx_dbstr($slideshowid); + $db_slideshow = DBfetch(DBselect($sql, 1)); + if (!empty($db_slideshow)) { + error(_s('Slide show "%s" already exists.', $name)); + return false; + } + +- $db_slideshow = DBfetchArray(DBselect('SELECT * FROM slideshows WHERE slideshowid='.$slideshowid)); ++ $db_slideshow = DBfetchArray(DBselect('SELECT * FROM slideshows WHERE slideshowid='.zbx_dbstr($slideshowid))); + $db_slideshow = $db_slideshow[0]; + $changed = false; + $slideshow = array('name' => $name, 'delay' => $delay); +@@ -246,13 +246,13 @@ + } + } + if ($changed) { +- if (!$result = DBexecute('UPDATE slideshows SET name='.zbx_dbstr($name).',delay='.$delay.' WHERE slideshowid='.$slideshowid)) { ++ if (!$result = DBexecute('UPDATE slideshows SET name='.zbx_dbstr($name).',delay='.zbx_dbstr($delay).' WHERE slideshowid='.zbx_dbstr($slideshowid))) { + return false; + } + } + + // get slides +- $db_slides = DBfetchArrayAssoc(DBselect('SELECT s.* FROM slides s WHERE s.slideshowid='.$slideshowid), 'slideid'); ++ $db_slides = DBfetchArrayAssoc(DBselect('SELECT s.* FROM slides s WHERE s.slideshowid='.zbx_dbstr($slideshowid)), 'slideid'); + + $slidesToDel = zbx_objectValues($db_slides, 'slideid'); + $slidesToDel = zbx_toHash($slidesToDel); +@@ -262,7 +262,7 @@ + if (isset($db_slides[$slide['slideid']])) { + // update slide + if ($db_slides[$slide['slideid']]['delay'] != $slide['delay'] || $db_slides[$slide['slideid']]['step'] != $step) { +- $result = DBexecute('UPDATE slides SET step='.$step.', delay='.$slide['delay'].' WHERE slideid='.$slide['slideid']); ++ $result = DBexecute('UPDATE slides SET step='.zbx_dbstr($step).', delay='.zbx_dbstr($slide['delay']).' WHERE slideid='.zbx_dbstr($slide['slideid'])); + } + // do nothing with slide + else { +@@ -275,7 +275,7 @@ + $slideid = get_dbid('slides', 'slideid'); + $result = DBexecute( + 'INSERT INTO slides (slideid,slideshowid,screenid,step,delay)'. +- ' VALUES ('.$slideid.','.$slideshowid.','.$slide['screenid'].','.$step.','.$slide['delay'].')' ++ ' VALUES ('.zbx_dbstr($slideid).','.zbx_dbstr($slideshowid).','.zbx_dbstr($slide['screenid']).','.zbx_dbstr($step).','.zbx_dbstr($slide['delay']).')' + ); + } + $step ++; +@@ -293,9 +293,9 @@ + } + + function delete_slideshow($slideshowid) { +- $result = DBexecute('DELETE FROM slideshows where slideshowid='.$slideshowid); +- $result &= DBexecute('DELETE FROM slides where slideshowid='.$slideshowid); +- $result &= DBexecute('DELETE FROM profiles WHERE idx=\'web.favorite.screenids\' AND source=\'slideshowid\' AND value_id='.$slideshowid); ++ $result = DBexecute('DELETE FROM slideshows where slideshowid='.zbx_dbstr($slideshowid)); ++ $result &= DBexecute('DELETE FROM slides where slideshowid='.zbx_dbstr($slideshowid)); ++ $result &= DBexecute('DELETE FROM profiles WHERE idx=\'web.favorite.screenids\' AND source=\'slideshowid\' AND value_id='.zbx_dbstr($slideshowid)); + return $result; + } + +@@ -304,13 +304,13 @@ + if ($config == 0) { + $sql = 'SELECT si.screenitemid'. + ' FROM screens_items si'. +- ' WHERE si.screenid='.$elid. ++ ' WHERE si.screenid='.zbx_dbstr($elid). + ' AND si.dynamic='.SCREEN_DYNAMIC_ITEM; + } + else { + $sql = 'SELECT si.screenitemid'. + ' FROM slides s,screens_items si'. +- ' WHERE s.slideshowid='.$elid. ++ ' WHERE s.slideshowid='.zbx_dbstr($elid). + ' AND si.screenid=s.screenid'. + ' AND si.dynamic='.SCREEN_DYNAMIC_ITEM; + } +Index: frontends/php/include/perm.inc.php +=================================================================== +--- frontends/php/include/perm.inc.php (revision 38884) ++++ frontends/php/include/perm.inc.php (working copy) +@@ -46,7 +46,7 @@ + function check_perm2system($userid) { + $sql = 'SELECT g.usrgrpid'. + ' FROM usrgrp g,users_groups ug'. +- ' WHERE ug.userid='.$userid. ++ ' WHERE ug.userid='.zbx_dbstr($userid). + ' AND g.usrgrpid=ug.usrgrpid'. + ' AND g.users_status='.GROUP_STATUS_DISABLED; + if ($res = DBfetch(DBselect($sql, 1))) { +@@ -91,7 +91,7 @@ + + $sql = 'SELECT MAX(g.gui_access) AS gui_access'. + ' FROM usrgrp g,users_groups ug'. +- ' WHERE ug.userid='.$userid. ++ ' WHERE ug.userid='.zbx_dbstr($userid). + ' AND g.usrgrpid=ug.usrgrpid'; + $db_access = DBfetch(DBselect($sql)); + if (!zbx_empty($db_access['gui_access'])) { +@@ -206,7 +206,7 @@ + ' LEFT JOIN rights r ON r.id=hg.groupid'. + ' LEFT JOIN users_groups g ON r.groupid=g.usrgrpid'. + ' LEFT JOIN nodes n ON '.DBid2nodeid('hg.groupid').'=n.nodeid'. +- ' WHERE g.userid='.$userid. ++ ' WHERE g.userid='.zbx_dbstr($userid). + ' AND '.DBin_node('hg.groupid', $nodeid). + ' GROUP BY n.nodeid,n.name,hg.groupid,hg.name,g.userid'. + ' ORDER BY node_name,hg.name,permission'; +@@ -306,7 +306,7 @@ + foreach ($node_data as $nodeid => $node) { + switch ($perm_res) { + case PERM_RES_DATA_ARRAY: +- $db_node = DBfetch(DBselect('SELECT n.* FROM nodes n WHERE n.nodeid='.$nodeid.' ORDER BY n.name')); ++ $db_node = DBfetch(DBselect('SELECT n.* FROM nodes n WHERE n.nodeid='.zbx_dbstr($nodeid).' ORDER BY n.name')); + + if (!ZBX_DISTRIBUTED) { + if (!$node) { +@@ -552,7 +552,7 @@ + if (!isset($userGroups[$userId])) { + $userGroups[$userId] = array(); + +- $result = DBselect('SELECT usrgrpid FROM users_groups WHERE userid='.$userId); ++ $result = DBselect('SELECT usrgrpid FROM users_groups WHERE userid='.zbx_dbstr($userId)); + while ($row = DBfetch($result)) { + $userGroups[$userId][] = $row['usrgrpid']; + } +Index: frontends/php/include/blocks.inc.php +=================================================================== +--- frontends/php/include/blocks.inc.php (revision 38884) ++++ frontends/php/include/blocks.inc.php (working copy) +@@ -1043,7 +1043,7 @@ + ' AND hti.type='.HTTPSTEP_ITEM_TYPE_LASTSTEP. + ' AND ht.status='.HTTPTEST_STATUS_ACTIVE. + ' AND '.dbConditionInt('hg.hostid', $availableHostIds). +- ' AND hg.groupid='.$group['groupid'] ++ ' AND hg.groupid='.zbx_dbstr($group['groupid']) + ); + while ($row = DBfetch($result)) { + $showGroup = true; diff --git a/zabbix20.spec b/zabbix20.spec index 32352c6..280b2bb 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -16,7 +16,6 @@ #type=AVC msg=audit(1346965425.718:65127): avc: denied { getattr } for pid=3427 comm="fping6" path="/var/lib/zabbixsrv/tmp/zabbix_server_pgsql_3002.pinger" dev=dm-1 ino=20 scontext=system_u:system_r:ping_t:s0 tcontext=system_u:object_r:initrc_tmp_t:s0 tclass=file - %global srcname zabbix Name: zabbix20 @@ -57,13 +56,21 @@ Patch2: %{srcname}-2.0.1-no-flash.patch # adapt for fping3 - https://support.zabbix.com/browse/ZBX-4894 Patch3: %{srcname}-1.8.12-fping3.patch # Services page broken due to missing AS in SQL -# https://support.zabbix.com/browse/ZBX-4894 +# https://support.zabbix.com/browse/ZBX-6992 Patch4: %{srcname}-2.0.8-ZBX-6992.patch # SQL speedup for graphs, fixed in 2.0.9 # https://support.zabbix.com/browse/ZBX-6840 Patch5: %{srcname}-2.0.8-ZBX-6804.patch +# Failure on XML import of hosts, fixed in 2.0.9 +# https://support.zabbix.com/browse/ZBX-6922 +Patch6: %{srcname}-2.0.8-ZBX-6922.patch + +# Frontend and API vulnerability to SQL injections +# CVE-2013-5743 +Patch7: %{srcname}-2.0.8-ZBX-7091.patch + BuildRequires: mysql-devel BuildRequires: postgresql-devel BuildRequires: sqlite-devel @@ -282,6 +289,8 @@ Zabbix web frontend for PostgreSQL %endif %patch4 -p0 %patch5 -p0 +%patch6 -p0 +%patch7 -p0 # Logrotate's su option is currently only available in Fedora %if 0%{?rhel} @@ -858,6 +867,11 @@ fi %files web-pgsql %changelog +* Mon Sep 23 2013 Volker Fröhlich - 2.0.8-3 +- Add SQL speed-up patch (ZBX-6804) +- Add SQL injection vulnerability patch (ZBX-7091, CVE-2013-5743) +- Add patch for failing XML host import (ZBX-6922) + * Fri Sep 13 2013 Volker Fröhlich - 2.0.8-2 - Add php-ldap as a requirement for the frontend - Add patch for ZBX-6992 From 621dfbcb3e9aec3c8c86689b8d516059decaf70e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Wed, 2 Oct 2013 10:54:28 +0200 Subject: [PATCH 24/42] Correct release number --- zabbix20.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zabbix20.spec b/zabbix20.spec index 280b2bb..5d6a651 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -20,7 +20,7 @@ Name: zabbix20 Version: 2.0.8 -Release: 2%{?dist} +Release: 3%{?dist} Summary: Open-source monitoring solution for your IT infrastructure Group: Applications/Internet From afd214492dac0de3df425817a3031b5df9139411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Wed, 9 Oct 2013 21:41:15 +0200 Subject: [PATCH 25/42] New upstream release 2.0.9 - Drop all patches incorporated in this release --- .gitignore | 1 + sources | 2 +- zabbix-2.0.6-ZBX-5924.patch | 13 - zabbix-2.0.8-ZBX-6804.patch | 121 --- zabbix-2.0.8-ZBX-6922.patch | 21 - zabbix-2.0.8-ZBX-6992.patch | 15 - zabbix-2.0.8-ZBX-7091.patch | 2021 ----------------------------------- zabbix20.spec | 27 +- 8 files changed, 8 insertions(+), 2213 deletions(-) delete mode 100644 zabbix-2.0.6-ZBX-5924.patch delete mode 100644 zabbix-2.0.8-ZBX-6804.patch delete mode 100644 zabbix-2.0.8-ZBX-6922.patch delete mode 100644 zabbix-2.0.8-ZBX-6992.patch delete mode 100644 zabbix-2.0.8-ZBX-7091.patch diff --git a/.gitignore b/.gitignore index e4488ae..89acafc 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ /zabbix-2.0.7-free.tar.gz /zabbix-2.0.8.tar.gz /zabbix-2.0.8-free.tar.gz +/zabbix-2.0.9-free.tar.gz diff --git a/sources b/sources index ab672de..b1d6d3e 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -213cfb023a9c3afb807746003027a9c2 zabbix-2.0.8-free.tar.gz +1b895bc113adb98c605d36b1a9328a26 zabbix-2.0.9-free.tar.gz diff --git a/zabbix-2.0.6-ZBX-5924.patch b/zabbix-2.0.6-ZBX-5924.patch deleted file mode 100644 index 560fe8b..0000000 --- a/zabbix-2.0.6-ZBX-5924.patch +++ /dev/null @@ -1,13 +0,0 @@ -Index: src/libs/zbxmedia/eztexting.c -=================================================================== ---- src/libs/zbxmedia/eztexting.c (revision 37391) -+++ src/libs/zbxmedia/eztexting.c (revision 37395) -@@ -205,7 +205,7 @@ - CURLE_OK != (err = curl_easy_setopt(easy_handle, opt = CURLOPT_WRITEFUNCTION, WRITEFUNCTION2)) || - CURLE_OK != (err = curl_easy_setopt(easy_handle, opt = CURLOPT_HEADERFUNCTION, HEADERFUNCTION2)) || - CURLE_OK != (err = curl_easy_setopt(easy_handle, opt = CURLOPT_SSL_VERIFYPEER, 1L)) || -- CURLE_OK != (err = curl_easy_setopt(easy_handle, opt = CURLOPT_SSL_VERIFYHOST, 1L)) || -+ CURLE_OK != (err = curl_easy_setopt(easy_handle, opt = CURLOPT_SSL_VERIFYHOST, 2L)) || - CURLE_OK != (err = curl_easy_setopt(easy_handle, opt = CURLOPT_POSTFIELDS, postfields)) || - CURLE_OK != (err = curl_easy_setopt(easy_handle, opt = CURLOPT_POST, 1L)) || - CURLE_OK != (err = curl_easy_setopt(easy_handle, opt = CURLOPT_URL, EZ_TEXTING_API_URL)) || diff --git a/zabbix-2.0.8-ZBX-6804.patch b/zabbix-2.0.8-ZBX-6804.patch deleted file mode 100644 index f3547b4..0000000 --- a/zabbix-2.0.8-ZBX-6804.patch +++ /dev/null @@ -1,121 +0,0 @@ -Index: frontends/php/include/graphs.inc.php -=================================================================== ---- frontends/php/include/graphs.inc.php (revision 38431) -+++ frontends/php/include/graphs.inc.php (revision 38500) -@@ -199,18 +199,19 @@ - /** - * Return the time of the 1st appearance of item in trends. - * -- * @param array|int $itemids -+ * @param array $itemIds - * - * @return int (unixtime) - */ --function get_min_itemclock_by_itemid($itemids) { -- zbx_value2array($itemids); -+function get_min_itemclock_by_itemid($itemIds) { -+ zbx_value2array($itemIds); -+ - $min = null; - $result = time() - SEC_PER_YEAR; - -- $items_by_type = array( -+ $itemTypes = array( - ITEM_VALUE_TYPE_FLOAT => array(), -- ITEM_VALUE_TYPE_STR => array(), -+ ITEM_VALUE_TYPE_STR => array(), - ITEM_VALUE_TYPE_LOG => array(), - ITEM_VALUE_TYPE_UINT64 => array(), - ITEM_VALUE_TYPE_TEXT => array() -@@ -219,64 +220,68 @@ - $dbItems = DBselect( - 'SELECT i.itemid,i.value_type'. - ' FROM items i'. -- ' WHERE '.dbConditionInt('i.itemid', $itemids) -+ ' WHERE '.dbConditionInt('i.itemid', $itemIds) - ); - - while ($item = DBfetch($dbItems)) { -- $items_by_type[$item['value_type']][$item['itemid']] = $item['itemid']; -+ $itemTypes[$item['value_type']][$item['itemid']] = $item['itemid']; - } - - // data for ITEM_VALUE_TYPE_FLOAT and ITEM_VALUE_TYPE_UINT64 can be stored in trends tables or history table - // get max trends and history values for such type items to find out in what tables to look for data -- $sql_from = 'history'; -- $sql_from_num = ''; -+ $sqlFrom = 'history'; -+ $sqlFromNum = ''; - -- if (!empty($items_by_type[ITEM_VALUE_TYPE_FLOAT]) || !empty($items_by_type[ITEM_VALUE_TYPE_UINT64])) { -- $itemids_numeric = zbx_array_merge($items_by_type[ITEM_VALUE_TYPE_FLOAT], $items_by_type[ITEM_VALUE_TYPE_UINT64]); -+ if (!empty($itemTypes[ITEM_VALUE_TYPE_FLOAT]) || !empty($itemTypes[ITEM_VALUE_TYPE_UINT64])) { -+ $itemIdsNumeric = zbx_array_merge($itemTypes[ITEM_VALUE_TYPE_FLOAT], $itemTypes[ITEM_VALUE_TYPE_UINT64]); - - $sql = 'SELECT MAX(i.history) AS history,MAX(i.trends) AS trends'. - ' FROM items i'. -- ' WHERE '.dbConditionInt('i.itemid', $itemids_numeric); -- if ($table_for_numeric = DBfetch(DBselect($sql))) { -- $sql_from_num = ($table_for_numeric['history'] > $table_for_numeric['trends']) ? 'history' : 'trends'; -- $result = time() - (SEC_PER_DAY * max($table_for_numeric['history'], $table_for_numeric['trends'])); -+ ' WHERE '.dbConditionInt('i.itemid', $itemIdsNumeric); -+ if ($tableForNumeric = DBfetch(DBselect($sql))) { -+ $sqlFromNum = ($tableForNumeric['history'] > $tableForNumeric['trends']) ? 'history' : 'trends'; -+ $result = time() - (SEC_PER_DAY * max($tableForNumeric['history'], $tableForNumeric['trends'])); - } - } - -- foreach ($items_by_type as $type => $items) { -+ foreach ($itemTypes as $type => $items) { - if (empty($items)) { - continue; - } - -- switch($type) { -+ switch ($type) { - case ITEM_VALUE_TYPE_FLOAT: -- $sql_from = $sql_from_num; -+ $sqlFrom = $sqlFromNum; - break; - case ITEM_VALUE_TYPE_STR: -- $sql_from = 'history_str'; -+ $sqlFrom = 'history_str'; - break; - case ITEM_VALUE_TYPE_LOG: -- $sql_from = 'history_log'; -+ $sqlFrom = 'history_log'; - break; - case ITEM_VALUE_TYPE_UINT64: -- $sql_from = $sql_from_num.'_uint'; -+ $sqlFrom = $sqlFromNum.'_uint'; - break; - case ITEM_VALUE_TYPE_TEXT: -- $sql_from = 'history_text'; -+ $sqlFrom = 'history_text'; - break; - default: -- $sql_from = 'history'; -+ $sqlFrom = 'history'; - } - -+ foreach ($itemIds as $itemId) { -+ $sqlUnions[] = 'SELECT MIN(ht.clock) AS c FROM '.$sqlFrom.' ht WHERE ht.itemid='.$itemId; -+ } -+ - $dbMin = DBfetch(DBselect( -- 'SELECT MIN(ht.clock) AS min_clock'. -- ' FROM '.$sql_from.' ht'. -- ' WHERE '.dbConditionInt('ht.itemid', $itemids) -+ 'SELECT MIN(ht.c) AS min_clock'. -+ ' FROM ('.implode(' UNION ALL ', $sqlUnions).') ht' - )); -- $min = empty($min) ? $dbMin['min_clock'] : min($min, $dbMin['min_clock']); -+ -+ $min = $min ? min($min, $dbMin['min_clock']) : $dbMin['min_clock']; - } - -- return empty($min) ? $result : $min; -+ return $min ? $min: $result; - } - - function get_graph_by_graphid($graphid) { diff --git a/zabbix-2.0.8-ZBX-6922.patch b/zabbix-2.0.8-ZBX-6922.patch deleted file mode 100644 index 97ba0cc..0000000 --- a/zabbix-2.0.8-ZBX-6922.patch +++ /dev/null @@ -1,21 +0,0 @@ -Index: frontends/php/include/db.inc.php -=================================================================== ---- frontends/php/include/db.inc.php (revision 38161) -+++ frontends/php/include/db.inc.php (revision 38173) -@@ -1080,14 +1080,14 @@ - return '1=0'; - } - -- $values = array_unique($values); -+ $values = array_keys(array_flip($values)); - - if ($sort) { - natsort($values); -+ -+ $values = array_values($values); - } - -- zbx_cleanHashes($values); -- - $betweens = array(); - $data = array(); diff --git a/zabbix-2.0.8-ZBX-6992.patch b/zabbix-2.0.8-ZBX-6992.patch deleted file mode 100644 index 6c3a0cc..0000000 --- a/zabbix-2.0.8-ZBX-6992.patch +++ /dev/null @@ -1,15 +0,0 @@ -Index: frontends/php/api/classes/CService.php -=================================================================== ---- frontends/php/api/classes/CService.php (.../2.0) (revision 38431) -+++ frontends/php/api/classes/CService.php (.../dev/ZBX-6992) (revision 38466) -@@ -1004,8 +1004,8 @@ - // since multiple alarms can have the same timestamp, we only need to save the last one - $query = DBSelect( - 'SELECT sa.serviceid,sa.value'. -- ' FROM (SELECT MAX(sa3.servicealarmid) servicealarmid'. -- ' FROM (SELECT sa2.serviceid,MAX(sa2.clock) clock'. -+ ' FROM (SELECT MAX(sa3.servicealarmid) AS servicealarmid'. -+ ' FROM (SELECT sa2.serviceid,MAX(sa2.clock) AS clock'. - ' FROM service_alarms sa2'. - ' WHERE sa2.clock<'.zbx_dbstr($beforeTime). - ' AND '.dbConditionInt('sa2.serviceid', $serviceIds). diff --git a/zabbix-2.0.8-ZBX-7091.patch b/zabbix-2.0.8-ZBX-7091.patch deleted file mode 100644 index ca5d2c1..0000000 --- a/zabbix-2.0.8-ZBX-7091.patch +++ /dev/null @@ -1,2021 +0,0 @@ -Index: frontends/php/api/classes/CGraphItem.php -=================================================================== ---- frontends/php/api/classes/CGraphItem.php (revision 38884) -+++ frontends/php/api/classes/CGraphItem.php (working copy) -@@ -119,7 +119,7 @@ - - // type - if (!is_null($options['type'] )) { -- $sqlParts['where'][] = 'gi.type='.$options['type']; -+ $sqlParts['where'][] = 'gi.type='.zbx_dbstr($options['type']); - } - - // output -@@ -254,8 +254,8 @@ - $dbRes = DBselect( - 'SELECT gi.gitemid'. - ' FROM graphs_items gi'. -- ' WHERE gi.itemid='.$gitemData['itemid']. -- ' AND gi.graphid='.$gitemData['graphid'] -+ ' WHERE gi.itemid='.zbx_dbstr($gitemData['itemid']). -+ ' AND gi.graphid='.zbx_dbstr($gitemData['graphid']) - ); - while ($gitem = DBfetch($dbRes)) { - $gitemids[$gitem['gitemid']] = $gitem['gitemid']; -Index: frontends/php/api/classes/CEvent.php -=================================================================== ---- frontends/php/api/classes/CEvent.php (revision 38884) -+++ frontends/php/api/classes/CEvent.php (working copy) -@@ -232,12 +232,12 @@ - - // object - if (!is_null($options['object'])) { -- $sqlParts['where']['o'] = 'e.object='.$options['object']; -+ $sqlParts['where']['o'] = 'e.object='.zbx_dbstr($options['object']); - } - - // source - if (!is_null($options['source'])) { -- $sqlParts['where'][] = 'e.source='.$options['source']; -+ $sqlParts['where'][] = 'e.source='.zbx_dbstr($options['source']); - } - - // acknowledged -@@ -255,22 +255,22 @@ - - // time_from - if (!is_null($options['time_from'])) { -- $sqlParts['where'][] = 'e.clock>='.$options['time_from']; -+ $sqlParts['where'][] = 'e.clock>='.zbx_dbstr($options['time_from']); - } - - // time_till - if (!is_null($options['time_till'])) { -- $sqlParts['where'][] = 'e.clock<='.$options['time_till']; -+ $sqlParts['where'][] = 'e.clock<='.zbx_dbstr($options['time_till']); - } - - // eventid_from - if (!is_null($options['eventid_from'])) { -- $sqlParts['where'][] = 'e.eventid>='.$options['eventid_from']; -+ $sqlParts['where'][] = 'e.eventid>='.zbx_dbstr($options['eventid_from']); - } - - // eventid_till - if (!is_null($options['eventid_till'])) { -- $sqlParts['where'][] = 'e.eventid<='.$options['eventid_till']; -+ $sqlParts['where'][] = 'e.eventid<='.zbx_dbstr($options['eventid_till']); - } - - // value -Index: frontends/php/api/classes/CGraphPrototype.php -=================================================================== ---- frontends/php/api/classes/CGraphPrototype.php (revision 38884) -+++ frontends/php/api/classes/CGraphPrototype.php (working copy) -@@ -227,7 +227,7 @@ - - // type - if (!is_null($options['type'] )) { -- $sqlParts['where'][] = 'g.type='.$options['type']; -+ $sqlParts['where'][] = 'g.type='.zbx_dbstr($options['type']); - } - - // templated -Index: frontends/php/api/classes/CItemGeneral.php -=================================================================== ---- frontends/php/api/classes/CItemGeneral.php (revision 38884) -+++ frontends/php/api/classes/CItemGeneral.php (working copy) -@@ -707,7 +707,7 @@ - - $sqlWhere = array(); - foreach ($itemKeysByHostId as $hostId => $keys) { -- $sqlWhere[] = '(i.hostid='.$hostId.' AND '.dbConditionString('i.key_', $keys).')'; -+ $sqlWhere[] = '(i.hostid='.zbx_dbstr($hostId).' AND '.dbConditionString('i.key_', $keys).')'; - } - - if ($sqlWhere) { -Index: frontends/php/api/classes/CHistory.php -=================================================================== ---- frontends/php/api/classes/CHistory.php (revision 38884) -+++ frontends/php/api/classes/CHistory.php (working copy) -@@ -169,13 +169,13 @@ - // time_from - if (!is_null($options['time_from'])) { - $sqlParts['select']['clock'] = 'h.clock'; -- $sqlParts['where']['clock_from'] = 'h.clock>='.$options['time_from']; -+ $sqlParts['where']['clock_from'] = 'h.clock>='.zbx_dbstr($options['time_from']); - } - - // time_till - if (!is_null($options['time_till'])) { - $sqlParts['select']['clock'] = 'h.clock'; -- $sqlParts['where']['clock_till'] = 'h.clock<='.$options['time_till']; -+ $sqlParts['where']['clock_till'] = 'h.clock<='.zbx_dbstr($options['time_till']); - } - - // filter -Index: frontends/php/api/classes/CTrigger.php -=================================================================== ---- frontends/php/api/classes/CTrigger.php (revision 38884) -+++ frontends/php/api/classes/CTrigger.php (working copy) -@@ -321,12 +321,12 @@ - - // lastChangeSince - if (!is_null($options['lastChangeSince'])) { -- $sqlParts['where']['lastchangesince'] = 't.lastchange>'.$options['lastChangeSince']; -+ $sqlParts['where']['lastchangesince'] = 't.lastchange>'.zbx_dbstr($options['lastChangeSince']); - } - - // lastChangeTill - if (!is_null($options['lastChangeTill'])) { -- $sqlParts['where']['lastchangetill'] = 't.lastchange<'.$options['lastChangeTill']; -+ $sqlParts['where']['lastchangetill'] = 't.lastchange<'.zbx_dbstr($options['lastChangeTill']); - } - - // withUnacknowledgedEvents -@@ -466,7 +466,7 @@ - - // min_severity - if (!is_null($options['min_severity'])) { -- $sqlParts['where'][] = 't.priority>='.$options['min_severity']; -+ $sqlParts['where'][] = 't.priority>='.zbx_dbstr($options['min_severity']); - } - - // output -Index: frontends/php/api/classes/CScript.php -=================================================================== ---- frontends/php/api/classes/CScript.php (revision 38884) -+++ frontends/php/api/classes/CScript.php (working copy) -@@ -114,7 +114,7 @@ - $sqlParts['from']['hosts_groups'] = 'hosts_groups hg'; - $sqlParts['where'][] = 'hg.groupid=r.id'; - $sqlParts['where'][] = 'r.groupid=ug.usrgrpid'; -- $sqlParts['where'][] = 'ug.userid='.$userid; -+ $sqlParts['where'][] = 'ug.userid='.zbx_dbstr($userid); - $sqlParts['where'][] = '(hg.groupid=s.groupid OR s.groupid IS NULL)'; - $sqlParts['where'][] = '(ug.usrgrpid=s.usrgrpid OR s.usrgrpid IS NULL)'; - } -@@ -265,7 +265,7 @@ - 'SELECT s.scriptid'. - ' FROM scripts s'. - ' WHERE '.DBin_node('s.scriptid'). -- ' AND s.name='.$script['name'] -+ ' AND s.name='.zbx_dbstr($script['name']) - ); - while ($script = DBfetch($dbScripts)) { - $scriptids[$script['scriptid']] = $script['scriptid']; -Index: frontends/php/api/classes/CTemplate.php -=================================================================== ---- frontends/php/api/classes/CTemplate.php (revision 38884) -+++ frontends/php/api/classes/CTemplate.php (working copy) -@@ -1021,7 +1021,7 @@ - - foreach ($template['groups'] as $group) { - $hostgroupid = get_dbid('hosts_groups', 'hostgroupid'); -- $result = DBexecute("INSERT INTO hosts_groups (hostgroupid, hostid, groupid) VALUES ($hostgroupid, $templateid, {$group['groupid']})"); -+ $result = DBexecute('INSERT INTO hosts_groups (hostgroupid,hostid,groupid) VALUES ('.zbx_dbstr($hostgroupid).','.zbx_dbstr($templateid).','.zbx_dbstr($group['groupid']).')'); - if (!$result) { - self::exception(ZBX_API_ERROR_PARAMETERS, 'DBerror'); - } -Index: frontends/php/api/classes/CHostGeneral.php -=================================================================== ---- frontends/php/api/classes/CHostGeneral.php (revision 38884) -+++ frontends/php/api/classes/CHostGeneral.php (working copy) -@@ -261,7 +261,7 @@ - continue; - } - -- $values = array(get_dbid('hosts_templates', 'hosttemplateid'), $targetid, $templateid); -+ $values = array(get_dbid('hosts_templates', 'hosttemplateid'), zbx_dbstr($targetid), zbx_dbstr($templateid)); - $sql = 'INSERT INTO hosts_templates VALUES ('.implode(', ', $values).')'; - $result = DBexecute($sql); - -Index: frontends/php/api/classes/CUser.php -=================================================================== ---- frontends/php/api/classes/CUser.php (revision 38884) -+++ frontends/php/api/classes/CUser.php (working copy) -@@ -507,7 +507,8 @@ - $usrgrps = zbx_objectValues($user['usrgrps'], 'usrgrpid'); - foreach ($usrgrps as $groupid) { - $usersGroupdId = get_dbid('users_groups', 'id'); -- $sql = 'INSERT INTO users_groups (id,usrgrpid,userid) VALUES ('.$usersGroupdId.','.$groupid.','.$userid.')'; -+ $sql = 'INSERT INTO users_groups (id,usrgrpid,userid) VALUES ('.zbx_dbstr($usersGroupdId).','.zbx_dbstr($groupid).','.zbx_dbstr($userid).')'; -+ - if (!DBexecute($sql)) { - self::exception(ZBX_API_ERROR_PARAMETERS, 'DBerror'); - } -@@ -516,8 +517,8 @@ - foreach ($user['user_medias'] as $mediaData) { - $mediaid = get_dbid('media', 'mediaid'); - $sql = 'INSERT INTO media (mediaid,userid,mediatypeid,sendto,active,severity,period)'. -- ' VALUES ('.$mediaid.','.$userid.','.$mediaData['mediatypeid'].','. -- zbx_dbstr($mediaData['sendto']).','.$mediaData['active'].','.$mediaData['severity'].','. -+ ' VALUES ('.zbx_dbstr($mediaid).','.zbx_dbstr($userid).','.zbx_dbstr($mediaData['mediatypeid']).','. -+ zbx_dbstr($mediaData['sendto']).','.zbx_dbstr($mediaData['active']).','.zbx_dbstr($mediaData['severity']).','. - zbx_dbstr($mediaData['period']).')'; - if (!DBexecute($sql)) { - self::exception(ZBX_API_ERROR_PARAMETERS, 'DBerror'); -@@ -577,10 +578,10 @@ - $newUsrgrpids = zbx_objectValues($user['usrgrps'], 'usrgrpid'); - - // deleting all relations with groups, but not touching those, where user still must be after update -- DBexecute('DELETE FROM users_groups WHERE userid='.$user['userid'].' AND '.dbConditionInt('usrgrpid', $newUsrgrpids, true)); -+ DBexecute('DELETE FROM users_groups WHERE userid='.zbx_dbstr($user['userid']).' AND '.dbConditionInt('usrgrpid', $newUsrgrpids, true)); - - // getting the list of groups user is currently in -- $dbGroupsUserIn = DBSelect('SELECT usrgrpid FROM users_groups WHERE userid='.$user['userid']); -+ $dbGroupsUserIn = DBSelect('SELECT usrgrpid FROM users_groups WHERE userid='.zbx_dbstr($user['userid'])); - $groupsUserIn = array(); - while ($grp = DBfetch($dbGroupsUserIn)) { - $groupsUserIn[$grp['usrgrpid']] = $grp['usrgrpid']; -@@ -598,7 +599,7 @@ - } - - $usersGroupdId = get_dbid('users_groups', 'id'); -- $sql = 'INSERT INTO users_groups (id,usrgrpid,userid) VALUES ('.$usersGroupdId.','.$groupid.','.$user['userid'].')'; -+ $sql = 'INSERT INTO users_groups (id,usrgrpid,userid) VALUES ('.zbx_dbstr($usersGroupdId).','.zbx_dbstr($groupid).','.zbx_dbstr($user['userid']).')'; - - if (!DBexecute($sql)) { - self::exception(ZBX_API_ERROR_PARAMETERS, 'DBerror'); -@@ -696,8 +697,8 @@ - $mediaid = get_dbid('media', 'mediaid'); - - $sql = 'INSERT INTO media (mediaid,userid,mediatypeid,sendto,active,severity,period)'. -- ' VALUES ('.$mediaid.','.$user['userid'].','.$media['mediatypeid'].','. -- zbx_dbstr($media['sendto']).','.$media['active'].','.$media['severity'].','. -+ ' VALUES ('.zbx_dbstr($mediaid).','.zbx_dbstr($user['userid']).','.zbx_dbstr($media['mediatypeid']).','. -+ zbx_dbstr($media['sendto']).','.zbx_dbstr($media['active']).','.zbx_dbstr($media['severity']).','. - zbx_dbstr($media['period']).')'; - if (!DBexecute($sql)) { - self::exception(ZBX_API_ERROR_PARAMETERS, 'DBerror'); -@@ -796,12 +797,12 @@ - - $result = DBexecute( - 'UPDATE media'. -- ' SET mediatypeid='.$media['mediatypeid'].','. -+ ' SET mediatypeid='.zbx_dbstr($media['mediatypeid']).','. - ' sendto='.zbx_dbstr($media['sendto']).','. -- ' active='.$media['active'].','. -- ' severity='.$media['severity'].','. -+ ' active='.zbx_dbstr($media['active']).','. -+ ' severity='.zbx_dbstr($media['severity']).','. - ' period='.zbx_dbstr($media['period']). -- ' WHERE mediaid='.$media['mediaid'] -+ ' WHERE mediaid='.zbx_dbstr($media['mediaid']) - ); - if (!$result) { - self::exception(ZBX_API_ERROR_PARAMETERS, _('Cannot update user media.')); -@@ -927,7 +928,7 @@ - $dbAccess = DBfetch(DBselect( - 'SELECT MAX(g.gui_access) AS gui_access'. - ' FROM usrgrp g,users_groups ug'. -- ' WHERE ug.userid='.$userInfo['userid']. -+ ' WHERE ug.userid='.zbx_dbstr($userInfo['userid']). - ' AND g.usrgrpid=ug.usrgrpid' - )); - if (!zbx_empty($dbAccess['gui_access'])) { -@@ -968,7 +969,7 @@ - - DBexecute( - 'UPDATE users'. -- ' SET attempt_failed='.$userInfo['attempt_failed'].','. -+ ' SET attempt_failed='.zbx_dbstr($userInfo['attempt_failed']).','. - ' attempt_clock='.time().','. - ' attempt_ip='.zbx_dbstr($ip). - ' WHERE userid='.$userInfo['userid'] -@@ -980,7 +981,7 @@ - - // start session - $sessionid = md5(time().$password.$name.rand(0, 10000000)); -- DBexecute('INSERT INTO sessions (sessionid,userid,lastaccess,status) VALUES ('.zbx_dbstr($sessionid).','.$userInfo['userid'].','.time().','.ZBX_SESSION_ACTIVE.')'); -+ DBexecute('INSERT INTO sessions (sessionid,userid,lastaccess,status) VALUES ('.zbx_dbstr($sessionid).','.zbx_dbstr($userInfo['userid']).','.time().','.ZBX_SESSION_ACTIVE.')'); - - add_audit(AUDIT_ACTION_LOGIN, AUDIT_RESOURCE_USER, _s('Correct login "%s".', $name)); - -@@ -990,7 +991,7 @@ - $userData['userid'] = $userInfo['userid']; - - if ($userInfo['attempt_failed']) { -- DBexecute('UPDATE users SET attempt_failed=0 WHERE userid='.$userInfo['userid']); -+ DBexecute('UPDATE users SET attempt_failed=0 WHERE userid='.zbx_dbstr($userInfo['userid'])); - } - - CWebUser::$data = self::$userData = $userData; -@@ -1035,16 +1036,16 @@ - } - - if ($userInfo['autologout'] > 0) { -- DBexecute('DELETE FROM sessions WHERE userid='.$userInfo['userid'].' AND lastaccess<'.(time() - $userInfo['autologout'])); -+ DBexecute('DELETE FROM sessions WHERE userid='.zbx_dbstr($userInfo['userid']).' AND lastaccess<'.(time() - $userInfo['autologout'])); - } - -- DBexecute('UPDATE sessions SET lastaccess='.time().' WHERE userid='.$userInfo['userid'].' AND sessionid='.zbx_dbstr($sessionid)); -+ DBexecute('UPDATE sessions SET lastaccess='.time().' WHERE userid='.zbx_dbstr($userInfo['userid']).' AND sessionid='.zbx_dbstr($sessionid)); - } - - $dbAccess = DBfetch(DBselect( - 'SELECT MAX(g.gui_access) AS gui_access'. - ' FROM usrgrp g,users_groups ug'. -- ' WHERE ug.userid='.$userInfo['userid']. -+ ' WHERE ug.userid='.zbx_dbstr($userInfo['userid']). - ' AND g.usrgrpid=ug.usrgrpid' - )); - if (!zbx_empty($dbAccess['gui_access'])) { -@@ -1070,13 +1071,13 @@ - 'SELECT u.userid,u.alias,u.name,u.surname,u.url,u.autologin,u.autologout,u.lang,u.refresh,u.type,'. - ' u.theme,u.attempt_failed,u.attempt_ip,u.attempt_clock,u.rows_per_page'. - ' FROM users u'. -- ' WHERE u.userid='.$userid -+ ' WHERE u.userid='.zbx_dbstr($userid) - )); - - $userData['debug_mode'] = (bool) DBfetch(DBselect( - 'SELECT ug.userid'. - ' FROM usrgrp g,users_groups ug'. -- ' WHERE ug.userid='.$userid. -+ ' WHERE ug.userid='.zbx_dbstr($userid). - ' AND g.usrgrpid=ug.usrgrpid'. - ' AND g.debug_mode='.GROUP_DEBUG_MODE_ENABLED - )); -Index: frontends/php/api/classes/CImage.php -=================================================================== ---- frontends/php/api/classes/CImage.php (revision 38884) -+++ frontends/php/api/classes/CImage.php (working copy) -@@ -314,9 +314,9 @@ - - $imageid = get_dbid('images', 'imageid'); - $values = array( -- 'imageid' => $imageid, -+ 'imageid' => zbx_dbstr($imageid), - 'name' => zbx_dbstr($image['name']), -- 'imagetype' => $image['imagetype'], -+ 'imagetype' => zbx_dbstr($image['imagetype']) - ); - - switch ($DB['TYPE']) { -@@ -423,7 +423,7 @@ - - $values = array(); - if (isset($image['name'])) $values['name'] = zbx_dbstr($image['name']); -- if (isset($image['imagetype'])) $values['imagetype'] = $image['imagetype']; -+ if (isset($image['imagetype'])) $values['imagetype'] = zbx_dbstr($image['imagetype']); - - if (isset($image['image'])) { - // decode BASE64 -@@ -443,7 +443,7 @@ - $values['image'] = zbx_dbstr($image['image']); - break; - case ZBX_DB_ORACLE: -- $sql = 'SELECT image FROM images WHERE imageid = '.$image['imageid'].' FOR UPDATE'; -+ $sql = 'SELECT image FROM images WHERE imageid = '.zbx_dbstr($image['imageid']).' FOR UPDATE'; - - if (!$stmt = oci_parse($DB['DB'], $sql)) { - $e = oci_error($DB['DB']); -@@ -464,7 +464,7 @@ - $row['IMAGE']->free(); - break; - case ZBX_DB_DB2: -- $stmt = db2_prepare($DB['DB'], 'UPDATE images SET image=? WHERE imageid='.$image['imageid']); -+ $stmt = db2_prepare($DB['DB'], 'UPDATE images SET image=? WHERE imageid='.zbx_dbstr($image['imageid'])); - - if (!$stmt) { - self::exception(ZBX_API_ERROR_PARAMETERS, db2_conn_errormsg($DB['DB'])); -@@ -486,7 +486,7 @@ - foreach ($values as $field => $value) { - $sqlUpd[] = $field.'='.$value; - } -- $sql = 'UPDATE images SET '.implode(', ', $sqlUpd).' WHERE imageid='.$image['imageid']; -+ $sql = 'UPDATE images SET '.implode(', ', $sqlUpd).' WHERE imageid='.zbx_dbstr($image['imageid']); - $result = DBexecute($sql); - - if (!$result) { -Index: frontends/php/api/classes/CMapElement.php -=================================================================== ---- frontends/php/api/classes/CMapElement.php (revision 38884) -+++ frontends/php/api/classes/CMapElement.php (working copy) -@@ -586,7 +586,7 @@ - - $sql = 'SELECT elementid, elementtype '. - ' FROM sysmaps_elements '. -- ' WHERE sysmapid='.$elementid . -+ ' WHERE sysmapid='.zbx_dbstr($elementid) . - ' AND elementtype='.SYSMAP_ELEMENT_TYPE_MAP; - $dbElements = DBselect($sql); - -Index: frontends/php/api/classes/CTriggerPrototype.php -=================================================================== ---- frontends/php/api/classes/CTriggerPrototype.php (revision 38884) -+++ frontends/php/api/classes/CTriggerPrototype.php (working copy) -@@ -423,7 +423,7 @@ - - // min_severity - if (!is_null($options['min_severity'])) { -- $sqlParts['where'][] = 't.priority>='.$options['min_severity']; -+ $sqlParts['where'][] = 't.priority>='.zbx_dbstr($options['min_severity']); - } - - // output -Index: frontends/php/api/classes/CUserGroup.php -=================================================================== ---- frontends/php/api/classes/CUserGroup.php (revision 38884) -+++ frontends/php/api/classes/CUserGroup.php (working copy) -@@ -144,7 +144,7 @@ - - // status - if (!is_null($options['status'])) { -- $sqlParts['where'][] = 'g.users_status='.$options['status']; -+ $sqlParts['where'][] = 'g.users_status='.zbx_dbstr($options['status']); - } - - // with_gui_access -Index: frontends/php/api/classes/CGraph.php -=================================================================== ---- frontends/php/api/classes/CGraph.php (revision 38884) -+++ frontends/php/api/classes/CGraph.php (working copy) -@@ -209,7 +209,7 @@ - - // type - if (!is_null($options['type'])) { -- $sqlParts['where'][] = 'g.type='.$options['type']; -+ $sqlParts['where'][] = 'g.type='.zbx_dbstr($options['type']); - } - - // templated -Index: frontends/php/api/classes/CApplication.php -=================================================================== ---- frontends/php/api/classes/CApplication.php (revision 38884) -+++ frontends/php/api/classes/CApplication.php (working copy) -@@ -719,7 +719,7 @@ - DB::insert('items_applications', $appsInsert); - - foreach ($itemids as $inum => $itemid) { -- $dbChilds = DBselect('SELECT i.itemid,i.hostid FROM items i WHERE i.templateid='.$itemid); -+ $dbChilds = DBselect('SELECT i.itemid,i.hostid FROM items i WHERE i.templateid='.zbx_dbstr($itemid)); - while ($child = DBfetch($dbChilds)) { - $dbApps = DBselect( - 'SELECT a1.applicationid'. -Index: frontends/php/api/classes/CAlert.php -=================================================================== ---- frontends/php/api/classes/CAlert.php (revision 38884) -+++ frontends/php/api/classes/CAlert.php (working copy) -@@ -237,12 +237,12 @@ - - // time_from - if (!is_null($options['time_from'])) { -- $sqlParts['where'][] = 'a.clock>'.$options['time_from']; -+ $sqlParts['where'][] = 'a.clock>'.zbx_dbstr($options['time_from']); - } - - // time_till - if (!is_null($options['time_till'])) { -- $sqlParts['where'][] = 'a.clock<'.$options['time_till']; -+ $sqlParts['where'][] = 'a.clock<'.zbx_dbstr($options['time_till']); - } - - // output -Index: frontends/php/api/classes/CWebCheck.php -=================================================================== ---- frontends/php/api/classes/CWebCheck.php (revision 38884) -+++ frontends/php/api/classes/CWebCheck.php (working copy) -@@ -347,7 +347,7 @@ - $dbCheckItems = DBselect( - 'SELECT i.itemid,hi.type'. - ' FROM items i,httptestitem hi'. -- ' WHERE hi.httptestid='.$httpTest['httptestid']. -+ ' WHERE hi.httptestid='.zbx_dbstr($httpTest['httptestid']). - ' AND hi.itemid=i.itemid' - ); - while ($checkitem = DBfetch($dbCheckItems)) { -@@ -696,7 +696,7 @@ - - $sql = 'SELECT h.httpstepid,h.name'. - ' FROM httpstep h'. -- ' WHERE h.httptestid='.$httpTest['httptestid']. -+ ' WHERE h.httptestid='.zbx_dbstr($httpTest['httptestid']). - ' AND '.dbConditionString('h.name', $webstepsNames); - if ($httpstepData = DBfetch(DBselect($sql))) { - self::exception(ZBX_API_ERROR_PARAMETERS, _s('Step "%s" already exists.', $httpstepData['name'])); -@@ -820,7 +820,7 @@ - $dbStepItems = DBselect( - 'SELECT i.itemid,hi.type'. - ' FROM items i,httpstepitem hi'. -- ' WHERE hi.httpstepid='.$webstep['webstepid']. -+ ' WHERE hi.httpstepid='.zbx_dbstr($webstep['webstepid']). - ' AND hi.itemid=i.itemid' - ); - while ($stepitem = DBfetch($dbStepItems)) { -Index: frontends/php/api/classes/CTemplateScreen.php -=================================================================== ---- frontends/php/api/classes/CTemplateScreen.php (revision 38884) -+++ frontends/php/api/classes/CTemplateScreen.php (working copy) -@@ -618,7 +618,7 @@ - 'SELECT src.itemid as srcid,dest.itemid as destid'. - ' FROM items dest,items src'. - ' WHERE dest.key_=src.key_'. -- ' AND dest.hostid='.$templateId. -+ ' AND dest.hostid='.zbx_dbstr($templateId). - ' AND '.dbConditionInt('src.itemid', $resourceItemIds) - ); - while ($dbItem = DBfetch($dbItems)) { -@@ -633,7 +633,7 @@ - ' WHERE dest.name=src.name'. - ' AND destgi.graphid=dest.graphid'. - ' AND destgi.itemid=desti.itemid'. -- ' AND desti.hostid='.$templateId. -+ ' AND desti.hostid='.zbx_dbstr($templateId). - ' AND '.dbConditionInt('src.graphid', $resourceGraphIds) - ); - while ($dbItem = DBfetch($dbItems)) { -Index: frontends/php/include/items.inc.php -=================================================================== ---- frontends/php/include/items.inc.php (revision 38884) -+++ frontends/php/include/items.inc.php (working copy) -@@ -224,7 +224,7 @@ - while ($item = DBfetch($db_items)) { - $old_status = $item['status']; - if ($status != $old_status) { -- $result &= DBexecute('UPDATE items SET status='.$status. -+ $result &= DBexecute('UPDATE items SET status='.zbx_dbstr($status). - ($status != ITEM_STATUS_NOTSUPPORTED ? ",error=''" : ''). - ' WHERE itemid='.$item['itemid']); - if ($result) { -@@ -420,7 +420,7 @@ - } - - function get_item_by_itemid($itemid) { -- $db_items = DBfetch(DBselect('SELECT i.* FROM items i WHERE i.itemid='.$itemid)); -+ $db_items = DBfetch(DBselect('SELECT i.* FROM items i WHERE i.itemid='.zbx_dbstr($itemid))); - if ($db_items) { - return $db_items; - } -@@ -436,7 +436,7 @@ - 'i.formula,i.trends,i.logtimefmt,i.valuemapid,i.delay_flex,i.params,i.ipmi_sensor,i.templateid,'. - 'i.authtype,i.username,i.password,i.publickey,i.privatekey,i.flags,i.filter,i.description,i.inventory_link'. - ' FROM items i'. -- ' WHERE i.itemid='.$itemid)); -+ ' WHERE i.itemid='.zbx_dbstr($itemid))); - if ($row) { - return $row; - } -@@ -469,7 +469,7 @@ - $db_items = DBselect( - 'SELECT src.*'. - ' FROM items src,items dest'. -- ' WHERE dest.itemid='.$itemid. -+ ' WHERE dest.itemid='.zbx_dbstr($itemid). - ' AND src.key_=dest.key_'. - ' AND '.dbConditionInt('src.hostid', $dest_hostids) - ); -@@ -838,7 +838,7 @@ - 'SELECT a1.applicationid'. - ' FROM applications a1,applications a2'. - ' WHERE a1.name=a2.name'. -- ' AND a1.hostid='.$hostid. -+ ' AND a1.hostid='.zbx_dbstr($hostid). - ' AND '.dbConditionInt('a2.applicationid', $applications) - ); - while ($app = DBfetch($db_apps)) { -@@ -986,9 +986,9 @@ - if ($last == 0) { - $sql = 'SELECT value'. - ' FROM '.$table. -- ' WHERE itemid='.$db_item['itemid']. -- ' AND clock='.$clock. -- ' AND ns='.$ns; -+ ' WHERE itemid='.zbx_dbstr($db_item['itemid']). -+ ' AND clock='.zbx_dbstr($clock). -+ ' AND ns='.zbx_dbstr($ns); - if (null != ($row = DBfetch(DBselect($sql, 1)))) { - $value = $row['value']; - } -@@ -1000,17 +1000,17 @@ - - $sql = 'SELECT DISTINCT clock'. - ' FROM '.$table. -- ' WHERE itemid='.$db_item['itemid']. -- ' AND clock='.$clock. -- ' AND ns<'.$ns; -+ ' WHERE itemid='.zbx_dbstr($db_item['itemid']). -+ ' AND clock='.zbx_dbstr($clock). -+ ' AND ns<'.zbx_dbstr($ns); - if (null != ($row = DBfetch(DBselect($sql)))) { - $max_clock = $row['clock']; - } - if ($max_clock == 0) { - $sql = 'SELECT MAX(clock) AS clock'. - ' FROM '.$table. -- ' WHERE itemid='.$db_item['itemid']. -- ' AND clock<'.$clock; -+ ' WHERE itemid='.zbx_dbstr($db_item['itemid']). -+ ' AND clock<'.zbx_dbstr($clock); - if (null != ($row = DBfetch(DBselect($sql)))) { - $max_clock = $row['clock']; - } -@@ -1022,15 +1022,15 @@ - if ($clock == $max_clock) { - $sql = 'SELECT value'. - ' FROM '.$table. -- ' WHERE itemid='.$db_item['itemid']. -- ' AND clock='.$clock. -- ' AND ns<'.$ns; -+ ' WHERE itemid='.zbx_dbstr($db_item['itemid']). -+ ' AND clock='.zbx_dbstr($clock). -+ ' AND ns<'.zbx_dbstr($ns); - } - else { - $sql = 'SELECT value'. - ' FROM '.$table. -- ' WHERE itemid='.$db_item['itemid']. -- ' AND clock='.$max_clock. -+ ' WHERE itemid='.zbx_dbstr($db_item['itemid']). -+ ' AND clock='.zbx_dbstr($max_clock). - ' ORDER BY itemid,clock desc,ns desc'; - } - -@@ -1039,9 +1039,9 @@ - } - } - else { -- $row = DBfetch(DBselect('SELECT MAX(clock) AS clock FROM '.$table.' WHERE itemid='.$db_item['itemid'])); -+ $row = DBfetch(DBselect('SELECT MAX(clock) AS clock FROM '.$table.' WHERE itemid='.zbx_dbstr($db_item['itemid']))); - if (!empty($row['clock'])) { -- $row = DBfetch(DBselect('SELECT value FROM '.$table.' WHERE itemid='.$db_item['itemid'].' AND clock='.$row['clock'].' ORDER BY ns DESC', 1)); -+ $row = DBfetch(DBselect('SELECT value FROM '.$table.' WHERE itemid='.zbx_dbstr($db_item['itemid']).' AND clock='.zbx_dbstr($row['clock']).' ORDER BY ns DESC', 1)); - if (!empty($row['value'])) { - $value = $row['value']; - } -Index: frontends/php/include/services.inc.php -=================================================================== ---- frontends/php/include/services.inc.php (revision 38884) -+++ frontends/php/include/services.inc.php (working copy) -@@ -42,7 +42,7 @@ - $result = DBselect( - 'SELECT s.status'. - ' FROM services s,services_links l'. -- ' WHERE l.serviceupid='.$serviceid. -+ ' WHERE l.serviceupid='.zbx_dbstr($serviceid). - ' AND s.serviceid=l.servicedownid'. - ' ORDER BY s.status'.$sort_order - ); -@@ -77,7 +77,7 @@ - $result = DBselect( - 'SELECT sl.servicedownid'. - ' FROM services_links sl'. -- ' WHERE sl.serviceupid='.$serviceid. -+ ' WHERE sl.serviceupid='.zbx_dbstr($serviceid). - ($soft ? '' : ' AND sl.soft=0') - ); - while ($row = DBfetch($result)) { -@@ -354,7 +354,7 @@ - 'SELECT l.serviceupid,s.algorithm'. - ' FROM services_links l,services s'. - ' WHERE s.serviceid=l.serviceupid'. -- ' AND l.servicedownid='.$serviceid -+ ' AND l.servicedownid='.zbx_dbstr($serviceid) - ); - while ($row = DBfetch($result)) { - $serviceupid = $row['serviceupid']; -@@ -363,7 +363,7 @@ - if ($algorithm == SERVICE_ALGORITHM_MAX || $algorithm == SERVICE_ALGORITHM_MIN) { - $status = get_service_status($serviceupid, $algorithm); - add_service_alarm($serviceupid, $status, time()); -- DBexecute('UPDATE services SET status='.$status.' WHERE serviceid='.$serviceupid); -+ DBexecute('UPDATE services SET status='.zbx_dbstr($status).' WHERE serviceid='.zbx_dbstr($serviceupid)); - } - elseif ($algorithm != SERVICE_ALGORITHM_NONE) { - error(_('Unknown calculation algorithm of service status').SPACE.'['.$algorithm.']'); -@@ -371,7 +371,7 @@ - } - } - -- $result = DBselect('SELECT sl.serviceupid FROM services_links sl WHERE sl.servicedownid='.$serviceid); -+ $result = DBselect('SELECT sl.serviceupid FROM services_links sl WHERE sl.servicedownid='.zbx_dbstr($serviceid)); - while ($row = DBfetch($result)) { - $serviceupid = $row['serviceupid']; - update_services_rec($serviceupid); // ATTENTION: recursion!!! -@@ -386,9 +386,9 @@ - * @param $status - */ - function update_services($triggerid, $status) { -- DBexecute('UPDATE services SET status='.$status.' WHERE triggerid='.$triggerid); -+ DBexecute('UPDATE services SET status='.zbx_dbstr($status).' WHERE triggerid='.zbx_dbstr($triggerid)); - -- $result = DBselect('SELECT s.serviceid FROM services s WHERE s.triggerid='.$triggerid); -+ $result = DBselect('SELECT s.serviceid FROM services s WHERE s.triggerid='.zbx_dbstr($triggerid)); - while ($row = DBfetch($result)) { - add_service_alarm($row['serviceid'], $status, time()); - update_services_rec($row['serviceid']); -@@ -415,7 +415,7 @@ - ); - while ($row = DBfetch($result)) { - $status = get_service_status($row['serviceid'], $row['algorithm'], $row['triggerid']); -- DBexecute('UPDATE services SET status='.$status.' WHERE serviceid='.$row['serviceid']); -+ DBexecute('UPDATE services SET status='.zbx_dbstr($status).' WHERE serviceid='.$row['serviceid']); - add_service_alarm($row['serviceid'], $status, time()); - } - -@@ -441,7 +441,7 @@ - $result = DBselect( - 'SELECT sa.servicealarmid,sa.value'. - ' FROM service_alarms sa'. -- ' WHERE sa.serviceid='.$serviceid. -+ ' WHERE sa.serviceid='.zbx_dbstr($serviceid). - ' ORDER BY sa.servicealarmid DESC', 1 - ); - $row = DBfetch($result); -@@ -457,7 +457,7 @@ - if (latest_service_alarm($serviceid, $status)) { - return true; - } -- return DBexecute('INSERT INTO service_alarms (servicealarmid,serviceid,clock,value) VALUES ('.get_dbid('service_alarms', 'servicealarmid').','.$serviceid.','.$clock.','.$status.')'); -+ return DBexecute('INSERT INTO service_alarms (servicealarmid,serviceid,clock,value) VALUES ('.get_dbid('service_alarms', 'servicealarmid').','.zbx_dbstr($serviceid).','.zbx_dbstr($clock).','.zbx_dbstr($status).')'); - } - - /** -Index: frontends/php/include/profiles.inc.php -=================================================================== ---- frontends/php/include/profiles.inc.php (revision 38884) -+++ frontends/php/include/profiles.inc.php (working copy) -@@ -148,9 +148,9 @@ - 'profileid' => get_dbid('profiles', 'profileid'), - 'userid' => self::$userDetails['userid'], - 'idx' => zbx_dbstr($idx), -- $value_type => ($value_type == 'value_str') ? zbx_dbstr($value) : $value, -- 'type' => $type, -- 'idx2' => $idx2 -+ $value_type => zbx_dbstr($value), -+ 'type' => zbx_dbstr($type), -+ 'idx2' => zbx_dbstr($idx2) - ); - return DBexecute('INSERT INTO profiles ('.implode(', ', array_keys($values)).') VALUES ('.implode(', ', $values).')'); - } -@@ -163,16 +163,15 @@ - } - - if ($idx2 > 0) { -- $sql_cond .= ' AND idx2='.$idx2.' AND '.DBin_node('idx2', false); -+ $sql_cond .= ' AND idx2='.zbx_dbstr($idx2).' AND '.DBin_node('idx2', false); - } - - $value_type = self::getFieldByType($type); -- $value = ($value_type == 'value_str') ? zbx_dbstr($value) : $value; - - return DBexecute( - 'UPDATE profiles SET '. -- $value_type.'='.$value.','. -- ' type='.$type. -+ $value_type.'='.zbx_dbstr($value).','. -+ ' type='.zbx_dbstr($type). - ' WHERE userid='.self::$userDetails['userid']. - ' AND idx='.zbx_dbstr($idx). - $sql_cond -@@ -242,7 +241,7 @@ - } - } - if (isset($configs['alert_usrgrpid'])) { -- if ($configs['alert_usrgrpid'] != 0 && !DBfetch(DBselect('SELECT u.usrgrpid FROM usrgrp u WHERE u.usrgrpid='.$configs['alert_usrgrpid']))) { -+ if ($configs['alert_usrgrpid'] != 0 && !DBfetch(DBselect('SELECT u.usrgrpid FROM usrgrp u WHERE u.usrgrpid='.zbx_dbstr($configs['alert_usrgrpid'])))) { - error(_('Incorrect user group.')); - return false; - } -@@ -393,7 +392,7 @@ - $history5 = DBfetch(DBSelect( - 'SELECT uh.title5,uh.url5'. - ' FROM user_history uh'. -- ' WHERE uh.userid='.$userid -+ ' WHERE uh.userid='.zbx_dbstr($userid) - )); - - if ($history5 && ($history5['title5'] == $title)) { -@@ -401,7 +400,7 @@ - // title same, url isnt, change only url - $sql = 'UPDATE user_history'. - ' SET url5='.zbx_dbstr($url). -- ' WHERE userid='.$userid; -+ ' WHERE userid='.zbx_dbstr($userid); - } - else { - // no need to change anything; -@@ -413,7 +412,7 @@ - if ($history5 === false) { - $userhistoryid = get_dbid('user_history', 'userhistoryid'); - $sql = 'INSERT INTO user_history (userhistoryid, userid, title5, url5)'. -- ' VALUES('.$userhistoryid.', '.$userid.', '.zbx_dbstr($title).', '.zbx_dbstr($url).')'; -+ ' VALUES('.$userhistoryid.', '.zbx_dbstr($userid).', '.zbx_dbstr($title).', '.zbx_dbstr($url).')'; - } - else { - $sql = 'UPDATE user_history'. -@@ -427,7 +426,7 @@ - ' url4=url5,'. - ' title5='.zbx_dbstr($title).','. - ' url5='.zbx_dbstr($url). -- ' WHERE userid='.$userid; -+ ' WHERE userid='.zbx_dbstr($userid); - } - } - return DBexecute($sql); -@@ -464,7 +463,7 @@ - 'profileid' => get_dbid('profiles', 'profileid'), - 'userid' => CWebUser::$data['userid'], - 'idx' => zbx_dbstr($favobj), -- 'value_id' => $favid, -+ 'value_id' => zbx_dbstr($favid), - 'type' => PROFILE_TYPE_ID - ); - if (!is_null($source)) { -@@ -478,7 +477,7 @@ - 'DELETE FROM profiles'. - ' WHERE userid='.CWebUser::$data['userid']. - ' AND idx='.zbx_dbstr($favobj). -- ($favid > 0 ? ' AND value_id='.$favid : ''). -+ ($favid > 0 ? ' AND value_id='.zbx_dbstr($favid) : ''). - (is_null($source) ? '' : ' AND source='.zbx_dbstr($source)) - ); - } -Index: frontends/php/include/graphs.inc.php -=================================================================== ---- frontends/php/include/graphs.inc.php (revision 38884) -+++ frontends/php/include/graphs.inc.php (working copy) -@@ -120,7 +120,7 @@ - $dbGraphs = DBselect( - 'SELECT MAX(g.graphtype) AS graphtype,MIN(gi.yaxisside) AS yaxissidel,MAX(gi.yaxisside) AS yaxissider,MAX(g.height) AS height'. - ' FROM graphs g,graphs_items gi'. -- ' WHERE g.graphid='.$graphid. -+ ' WHERE g.graphid='.zbx_dbstr($graphid). - ' AND gi.graphid=g.graphid' - ); - if ($graph = DBfetch($dbGraphs)) { -@@ -154,7 +154,7 @@ - ' FROM graphs g,graphs_items gi,items i'. - ' WHERE g.graphid=gi.graphid'. - ' AND gi.itemid=i.itemid'. -- ' AND i.hostid='.$hostid -+ ' AND i.hostid='.zbx_dbstr($hostid) - ); - } - -@@ -172,7 +172,7 @@ - ' FROM graphs_items gi,items i,hosts h'. - ' WHERE h.hostid=i.hostid'. - ' AND gi.itemid=i.itemid'. -- ' AND gi.graphid='.$graphid -+ ' AND gi.graphid='.zbx_dbstr($graphid) - ); - } - -@@ -187,7 +187,7 @@ - $dbItems = DBselect( - 'SELECT DISTINCT gi.itemid'. - ' FROM graphs_items gi'. -- ' WHERE gi.graphid='.$graphid -+ ' WHERE gi.graphid='.zbx_dbstr($graphid) - ); - while ($item = DBfetch($dbItems)) { - $itemids[$item['itemid']] = $item['itemid']; -@@ -280,7 +280,7 @@ - } - - function get_graph_by_graphid($graphid) { -- $dbGraphs = DBselect('SELECT g.* FROM graphs g WHERE g.graphid='.$graphid); -+ $dbGraphs = DBselect('SELECT g.* FROM graphs g WHERE g.graphid='.zbx_dbstr($graphid)); - $dbGraphs = DBfetch($dbGraphs); - if (!empty($dbGraphs)) { - return $dbGraphs; -@@ -307,8 +307,8 @@ - 'SELECT dest.itemid,src.key_'. - ' FROM items dest,items src'. - ' WHERE dest.key_=src.key_'. -- ' AND dest.hostid='.$dest_hostid. -- ' AND src.itemid='.$gitem['itemid'] -+ ' AND dest.hostid='.zbx_dbstr($dest_hostid). -+ ' AND src.itemid='.zbx_dbstr($gitem['itemid']) - )); - - if ($dbItem) { -Index: frontends/php/include/db.inc.php -=================================================================== ---- frontends/php/include/db.inc.php (revision 38884) -+++ frontends/php/include/db.inc.php (working copy) -@@ -150,7 +150,7 @@ - ); - db2_set_option($DB['DB'], $options, 1); - if (isset($DB['SCHEMA']) && ($DB['SCHEMA'] != '')) { -- DBexecute("SET CURRENT SCHEMA='".$DB['SCHEMA']."'"); -+ DBexecute('SET CURRENT SCHEMA='.zbx_dbstr($DB['SCHEMA'])); - } - } - break; -@@ -563,7 +563,7 @@ - - $result = false; - -- if (!isset($DB['DB']) || empty($DB['DB'])) { -+ if (!isset($DB['DB']) || empty($DB['DB']) || is_bool($cursor)) { - return $result; - } - -Index: frontends/php/include/views/configuration.screen.constructor.edit.php -=================================================================== ---- frontends/php/include/views/configuration.screen.constructor.edit.php (revision 38884) -+++ frontends/php/include/views/configuration.screen.constructor.edit.php (working copy) -@@ -419,7 +419,7 @@ - 'SELECT DISTINCT n.name AS node_name,s.screenid,s.name'. - ' FROM screens s'. - ' LEFT JOIN nodes n ON n.nodeid='.DBid2nodeid('s.screenid'). -- ' WHERE s.screenid='.$resourceid -+ ' WHERE s.screenid='.zbx_dbstr($resourceid) - ); - while ($row = DBfetch($db_screens)) { - $screen = API::Screen()->get(array( -Index: frontends/php/include/classes/class.chostsinfo.php -=================================================================== ---- frontends/php/include/classes/class.chostsinfo.php (revision 38884) -+++ frontends/php/include/classes/class.chostsinfo.php (working copy) -@@ -55,7 +55,7 @@ - $cond_from = ''; - if (remove_nodes_from_id($this->groupid) > 0) { - $cond_from = ', hosts_groups hg '; -- $cond_where = 'AND hg.hostid=h.hostid AND hg.groupid='.$this->groupid; -+ $cond_where = 'AND hg.hostid=h.hostid AND hg.groupid='.zbx_dbstr($this->groupid); - } - else { - $cond_where = ' AND '.DBin_node('h.hostid', $this->nodeid); -Index: frontends/php/include/classes/import/CImportReferencer.php -=================================================================== ---- frontends/php/include/classes/import/CImportReferencer.php (revision 38884) -+++ frontends/php/include/classes/import/CImportReferencer.php (working copy) -@@ -595,7 +595,7 @@ - foreach ($this->applications as $host => $applications) { - $hostId = $this->resolveHostOrTemplate($host); - if ($hostId) { -- $sqlWhere[] = '(hostid='.$hostId.' AND '.dbConditionString('name', $applications).')'; -+ $sqlWhere[] = '(hostid='.zbx_dbstr($hostId).' AND '.dbConditionString('name', $applications).')'; - } - } - -@@ -626,7 +626,7 @@ - foreach ($this->items as $host => $keys) { - $hostId = $this->resolveHostOrTemplate($host); - if ($hostId) { -- $sqlWhere[] = '(i.hostid='.$hostId.' AND '.dbConditionString('i.key_', $keys).')'; -+ $sqlWhere[] = '(i.hostid='.zbx_dbstr($hostId).' AND '.dbConditionString('i.key_', $keys).')'; - } - } - -@@ -778,7 +778,7 @@ - foreach ($this->macros as $host => $macros) { - $hostId = $this->resolveHostOrTemplate($host); - if ($hostId) { -- $sqlWhere[] = '(hm.hostid='.$hostId.' AND '.dbConditionString('hm.macro', $macros).')'; -+ $sqlWhere[] = '(hm.hostid='.zbx_dbstr($hostId).' AND '.dbConditionString('hm.macro', $macros).')'; - } - } - -Index: frontends/php/include/classes/class.cpie.php -=================================================================== ---- frontends/php/include/classes/class.cpie.php (revision 38884) -+++ frontends/php/include/classes/class.cpie.php (working copy) -@@ -170,9 +170,9 @@ - 'MAX(i.lastvalue) AS lst'. - ' FROM history h'. - ' LEFT JOIN items i ON h.itemid=i.itemid'. -- ' WHERE h.itemid='.$this->items[$i]['itemid']. -- ' AND h.clock>='.$from_time. -- ' AND h.clock<='.$to_time. -+ ' WHERE h.itemid='.zbx_dbstr($this->items[$i]['itemid']). -+ ' AND h.clock>='.zbx_dbstr($from_time). -+ ' AND h.clock<='.zbx_dbstr($to_time). - ' GROUP BY h.itemid' - , - 'SELECT hu.itemid,'. -@@ -181,9 +181,9 @@ - 'MAX(i.lastvalue) AS lst'. - ' FROM history_uint hu'. - ' LEFT JOIN items i ON hu.itemid=i.itemid'. -- ' WHERE hu.itemid='.$this->items[$i]['itemid']. -- ' AND hu.clock>='.$from_time. -- ' AND hu.clock<='.$to_time. -+ ' WHERE hu.itemid='.zbx_dbstr($this->items[$i]['itemid']). -+ ' AND hu.clock>='.zbx_dbstr($from_time). -+ ' AND hu.clock<='.zbx_dbstr($to_time). - ' GROUP BY hu.itemid' - ); - } -@@ -196,9 +196,9 @@ - 'MAX(i.lastvalue) AS lst'. - ' FROM trends t'. - ' LEFT JOIN items i ON t.itemid=i.itemid'. -- ' WHERE t.itemid='.$this->items[$i]['itemid']. -- ' AND t.clock>='.$from_time. -- ' AND t.clock<='.$to_time. -+ ' WHERE t.itemid='.zbx_dbstr($this->items[$i]['itemid']). -+ ' AND t.clock>='.zbx_dbstr($from_time). -+ ' AND t.clock<='.zbx_dbstr($to_time). - ' GROUP BY t.itemid' - , - 'SELECT t.itemid,'. -@@ -207,9 +207,9 @@ - 'MAX(i.lastvalue) AS lst'. - ' FROM trends_uint t'. - ' LEFT JOIN items i ON t.itemid=i.itemid'. -- ' WHERE t.itemid='.$this->items[$i]['itemid']. -- ' AND t.clock>='.$from_time. -- ' AND t.clock<='.$to_time. -+ ' WHERE t.itemid='.zbx_dbstr($this->items[$i]['itemid']). -+ ' AND t.clock>='.zbx_dbstr($from_time). -+ ' AND t.clock<='.zbx_dbstr($to_time). - ' GROUP BY t.itemid' - ); - } -Index: frontends/php/include/classes/screens/CScreenDataOverview.php -=================================================================== ---- frontends/php/include/classes/screens/CScreenDataOverview.php (revision 38884) -+++ frontends/php/include/classes/screens/CScreenDataOverview.php (working copy) -@@ -28,7 +28,7 @@ - */ - public function get() { - $hostids = array(); -- $dbHostGroups = DBselect('SELECT DISTINCT hg.hostid FROM hosts_groups hg WHERE hg.groupid='.$this->screenitem['resourceid']); -+ $dbHostGroups = DBselect('SELECT DISTINCT hg.hostid FROM hosts_groups hg WHERE hg.groupid='.zbx_dbstr($this->screenitem['resourceid'])); - while ($dbHostGroup = DBfetch($dbHostGroups)) { - $hostids[$dbHostGroup['hostid']] = $dbHostGroup['hostid']; - } -Index: frontends/php/include/classes/screens/CScreenTriggersOverview.php -=================================================================== ---- frontends/php/include/classes/screens/CScreenTriggersOverview.php (revision 38884) -+++ frontends/php/include/classes/screens/CScreenTriggersOverview.php (working copy) -@@ -28,7 +28,7 @@ - */ - public function get() { - $hostids = array(); -- $dbHostGroups = DBselect('SELECT DISTINCT hg.hostid FROM hosts_groups hg WHERE hg.groupid='.$this->screenitem['resourceid']); -+ $dbHostGroups = DBselect('SELECT DISTINCT hg.hostid FROM hosts_groups hg WHERE hg.groupid='.zbx_dbstr($this->screenitem['resourceid'])); - while ($dbHostGroup = DBfetch($dbHostGroups)) { - $hostids[$dbHostGroup['hostid']] = $dbHostGroup['hostid']; - } -Index: frontends/php/include/classes/class.cchart.php -=================================================================== ---- frontends/php/include/classes/class.cchart.php (revision 38884) -+++ frontends/php/include/classes/class.cchart.php (working copy) -@@ -225,18 +225,18 @@ - 'COUNT(*) AS count,AVG(value) AS avg,MIN(value) as min,'. - 'MAX(value) AS max,MAX(clock) AS clock'. - ' FROM history '. -- ' WHERE itemid='.$this->items[$i]['itemid']. -- ' AND clock>='.$from_time. -- ' AND clock<='.$to_time. -+ ' WHERE itemid='.zbx_dbstr($this->items[$i]['itemid']). -+ ' AND clock>='.zbx_dbstr($from_time). -+ ' AND clock<='.zbx_dbstr($to_time). - ' GROUP BY itemid,'.$calc_field - , - 'SELECT itemid,'.$calc_field.' AS i,'. - 'COUNT(*) AS count,AVG(value) AS avg,MIN(value) AS min,'. - 'MAX(value) AS max,MAX(clock) AS clock'. - ' FROM history_uint '. -- ' WHERE itemid='.$this->items[$i]['itemid']. -- ' AND clock>='.$from_time. -- ' AND clock<='.$to_time. -+ ' WHERE itemid='.zbx_dbstr($this->items[$i]['itemid']). -+ ' AND clock>='.zbx_dbstr($from_time). -+ ' AND clock<='.zbx_dbstr($to_time). - ' GROUP BY itemid,'.$calc_field - ); - } -@@ -248,17 +248,17 @@ - 'MAX(value_max) AS max,MAX(clock) AS clock'. - ' FROM trends'. - ' WHERE itemid='.$this->items[$i]['itemid']. -- ' AND clock>='.$from_time. -- ' AND clock<='.$to_time. -+ ' AND clock>='.zbx_dbstr($from_time). -+ ' AND clock<='.zbx_dbstr($to_time). - ' GROUP BY itemid,'.$calc_field - , - 'SELECT itemid,'.$calc_field.' AS i,'. - 'SUM(num) AS count,AVG(value_avg) AS avg,MIN(value_min) AS min,'. - 'MAX(value_max) AS max,MAX(clock) AS clock'. - ' FROM trends_uint '. -- ' WHERE itemid='.$this->items[$i]['itemid']. -- ' AND clock>='.$from_time. -- ' AND clock<='.$to_time. -+ ' WHERE itemid='.zbx_dbstr($this->items[$i]['itemid']). -+ ' AND clock>='.zbx_dbstr($from_time). -+ ' AND clock<='.zbx_dbstr($to_time). - ' GROUP BY itemid,'.$calc_field - ); - -@@ -438,7 +438,7 @@ - ' AND tr.status='.TRIGGER_STATUS_ENABLED. - ' AND i.itemid=f.itemid'. - ' AND h.hostid=i.hostid'. -- ' AND f.itemid='.$item['itemid']. -+ ' AND f.itemid='.zbx_dbstr($item['itemid']). - ' ORDER BY tr.priority' - ); - while (($trigger = DBfetch($db_triggers)) && $cnt < $max) { -Index: frontends/php/include/classes/helpers/trigger/CTriggerDescription.php -=================================================================== ---- frontends/php/include/classes/helpers/trigger/CTriggerDescription.php (revision 38884) -+++ frontends/php/include/classes/helpers/trigger/CTriggerDescription.php (working copy) -@@ -59,7 +59,7 @@ - $trigger = DBfetch(DBselect( - 'SELECT DISTINCT t.description,t.expression,t.triggerid'. - ' FROM triggers t'. -- ' WHERE t.triggerid='.$triggerId -+ ' WHERE t.triggerid='.zbx_dbstr($triggerId) - )); - $triggers = $this->expandDescriptions(array($trigger['triggerid'] => $trigger)); - $trigger = reset($triggers); -Index: frontends/php/include/maps.inc.php -=================================================================== ---- frontends/php/include/maps.inc.php (revision 38884) -+++ frontends/php/include/maps.inc.php (working copy) -@@ -252,7 +252,7 @@ - $res = DBselect('SELECT hi.ip,hi.dns,hi.useip,h.host,h.name,hi.type AS interfacetype'. - ' FROM interface hi,hosts h'. - ' WHERE hi.hostid=h.hostid'. -- ' AND hi.main=1 AND hi.hostid='.$selement['elementid']); -+ ' AND hi.main=1 AND hi.hostid='.zbx_dbstr($selement['elementid'])); - - // process interface priorities - $tmpPriority = 0; -@@ -272,7 +272,7 @@ - ' WHERE h.hostid=hi.hostid'. - ' AND hi.hostid=i.hostid'. - ' AND i.itemid=f.itemid'. -- ' AND hi.main=1 AND f.triggerid='.$selement['elementid']. -+ ' AND hi.main=1 AND f.triggerid='.zbx_dbstr($selement['elementid']). - ' ORDER BY f.functionid'); - - // process interface priorities, build $hostsByFunctionId array -@@ -473,7 +473,7 @@ - 'SELECT '.$function.'(value) AS value'. - ' FROM '.$history_table[$item['value_type']]. - ' WHERE clock>'.(time() - $parameter). -- ' AND itemid='.$item['itemid'] -+ ' AND itemid='.zbx_dbstr($item['itemid']) - ); - if (null === ($row = DBfetch($result))) { - $label = str_replace($expr, '('._('no data').')', $label); -@@ -502,7 +502,7 @@ - $db_mapselements = DBselect( - 'SELECT DISTINCT se.elementtype,se.elementid'. - ' FROM sysmaps_elements se'. -- ' WHERE se.sysmapid='.$db_element['elementid'] -+ ' WHERE se.sysmapid='.zbx_dbstr($db_element['elementid']) - ); - while ($db_mapelement = DBfetch($db_mapselements)) { - get_map_elements($db_mapelement, $elements); -Index: frontends/php/include/hosts.inc.php -=================================================================== ---- frontends/php/include/hosts.inc.php (revision 38884) -+++ frontends/php/include/hosts.inc.php (working copy) -@@ -483,7 +483,7 @@ - } - - function get_hostgroup_by_groupid($groupid) { -- $groups = DBfetch(DBselect('SELECT g.* FROM groups g WHERE g.groupid='.$groupid)); -+ $groups = DBfetch(DBselect('SELECT g.* FROM groups g WHERE g.groupid='.zbx_dbstr($groupid))); - if (!empty($groups)) { - return $groups; - } -@@ -522,7 +522,7 @@ - } - - function get_host_by_hostid($hostid, $no_error_message = 0) { -- $row = DBfetch(DBselect('SELECT h.* FROM hosts h WHERE h.hostid='.$hostid)); -+ $row = DBfetch(DBselect('SELECT h.* FROM hosts h WHERE h.hostid='.zbx_dbstr($hostid))); - if ($row) { - return $row; - } -@@ -1109,7 +1109,7 @@ - - if ($_REQUEST['groupid'] > 0) { - if ($_REQUEST['hostid'] > 0) { -- if (!DBfetch(DBselect('SELECT hg.groupid FROM hosts_groups hg WHERE hg.hostid='.$_REQUEST['hostid'].' AND hg.groupid='.$_REQUEST['groupid']))) { -+ if (!DBfetch(DBselect('SELECT hg.groupid FROM hosts_groups hg WHERE hg.hostid='.zbx_dbstr($_REQUEST['hostid']).' AND hg.groupid='.zbx_dbstr($_REQUEST['groupid'])))) { - $_REQUEST['hostid'] = 0; - } - } -@@ -1145,7 +1145,7 @@ - } - - function get_application_by_applicationid($applicationid, $no_error_message = 0) { -- $row = DBfetch(DBselect('SELECT a.* FROM applications a WHERE a.applicationid='.$applicationid)); -+ $row = DBfetch(DBselect('SELECT a.* FROM applications a WHERE a.applicationid='.zbx_dbstr($applicationid))); - if ($row) { - return $row; - } -@@ -1157,7 +1157,7 @@ - } - - function get_applications_by_templateid($applicationid) { -- return DBselect('SELECT a.* FROM applications a WHERE a.templateid='.$applicationid); -+ return DBselect('SELECT a.* FROM applications a WHERE a.templateid='.zbx_dbstr($applicationid)); - } - - function get_realhost_by_applicationid($applicationid) { -@@ -1169,7 +1169,7 @@ - } - - function get_host_by_applicationid($applicationid) { -- $row = DBfetch(DBselect('SELECT h.* FROM hosts h,applications a WHERE a.hostid=h.hostid AND a.applicationid='.$applicationid)); -+ $row = DBfetch(DBselect('SELECT h.* FROM hosts h,applications a WHERE a.hostid=h.hostid AND a.applicationid='.zbx_dbstr($applicationid))); - if ($row) { - return $row; - } -@@ -1327,7 +1327,7 @@ - } - - function isTemplate($hostid) { -- $dbHost = DBfetch(DBselect('SELECT h.status FROM hosts h WHERE h.hostid='.$hostid)); -+ $dbHost = DBfetch(DBselect('SELECT h.status FROM hosts h WHERE h.hostid='.zbx_dbstr($hostid))); - - return !empty($dbHost) && $dbHost['status'] == HOST_STATUS_TEMPLATE; - } -Index: frontends/php/include/users.inc.php -=================================================================== ---- frontends/php/include/users.inc.php (revision 38884) -+++ frontends/php/include/users.inc.php (working copy) -@@ -90,9 +90,9 @@ - function add_user_to_group($userid, $usrgrpid) { - $result = false; - if (granted2move_user($userid,$usrgrpid)) { -- DBexecute('DELETE FROM users_groups WHERE userid='.$userid.' AND usrgrpid='.$usrgrpid); -+ DBexecute('DELETE FROM users_groups WHERE userid='.zbx_dbstr($userid).' AND usrgrpid='.zbx_dbstr($usrgrpid)); - $users_groups_id = get_dbid('users_groups', 'id'); -- $result = DBexecute('INSERT INTO users_groups (id,usrgrpid,userid) VALUES ('.$users_groups_id.','.$usrgrpid.','.$userid.')'); -+ $result = DBexecute('INSERT INTO users_groups (id,usrgrpid,userid) VALUES ('.$users_groups_id.','.zbx_dbstr($usrgrpid).','.zbx_dbstr($userid).')'); - } - else{ - error(_('User cannot change status of himself.')); -@@ -103,7 +103,7 @@ - function remove_user_from_group($userid, $usrgrpid) { - $result = false; - if (granted2move_user($userid,$usrgrpid)) { -- $result = DBexecute('DELETE FROM users_groups WHERE userid='.$userid.' AND usrgrpid='.$usrgrpid); -+ $result = DBexecute('DELETE FROM users_groups WHERE userid='.zbx_dbstr($userid).' AND usrgrpid='.zbx_dbstr($usrgrpid)); - } - else { - error(_('User cannot change status of himself.')); -@@ -138,7 +138,7 @@ - } - - if ($grant) { -- $result = DBexecute('UPDATE usrgrp SET users_status='.$users_status.' WHERE '.dbConditionInt('usrgrpid', $usrgrpids)); -+ $result = DBexecute('UPDATE usrgrp SET users_status='.zbx_dbstr($users_status).' WHERE '.dbConditionInt('usrgrpid', $usrgrpids)); - } - else { - error(_('User cannot change status of himself.')); -@@ -154,7 +154,7 @@ - $grant = granted2update_group($usrgrpids); - } - if ($grant) { -- $result = DBexecute('UPDATE usrgrp SET gui_access='.$gui_access.' WHERE '.dbConditionInt('usrgrpid',$usrgrpids)); -+ $result = DBexecute('UPDATE usrgrp SET gui_access='.zbx_dbstr($gui_access).' WHERE '.dbConditionInt('usrgrpid',$usrgrpids)); - } - else { - error(_('User cannot change GUI access for himself.')); -@@ -164,6 +164,6 @@ - - function change_group_debug_mode($usrgrpids, $debug_mode){ - zbx_value2array($usrgrpids); -- return DBexecute('UPDATE usrgrp SET debug_mode='.$debug_mode.' WHERE '.dbConditionInt('usrgrpid', $usrgrpids)); -+ return DBexecute('UPDATE usrgrp SET debug_mode='.zbx_dbstr($debug_mode).' WHERE '.dbConditionInt('usrgrpid', $usrgrpids)); - } - ?> -Index: frontends/php/include/events.inc.php -=================================================================== ---- frontends/php/include/events.inc.php (revision 38884) -+++ frontends/php/include/events.inc.php (working copy) -@@ -33,7 +33,7 @@ - function get_tr_event_by_eventid($eventid) { - $sql = 'SELECT e.*,t.triggerid,t.description,t.expression,t.priority,t.status,t.type'. - ' FROM events e,triggers t'. -- ' WHERE e.eventid='.$eventid. -+ ' WHERE e.eventid='.zbx_dbstr($eventid). - ' AND e.object='.EVENT_OBJECT_TRIGGER. - ' AND t.triggerid=e.objectid'; - return DBfetch(DBselect($sql)); -@@ -100,9 +100,9 @@ - - $sql = 'SELECT e.*'. - ' FROM events e'. -- ' WHERE e.objectid='.$currentEvent['objectid']. -- ' AND e.eventid>'.$currentEvent['eventid']. -- ' AND e.object='.$currentEvent['object']. -+ ' WHERE e.objectid='.zbx_dbstr($currentEvent['objectid']). -+ ' AND e.eventid>'.zbx_dbstr($currentEvent['eventid']). -+ ' AND e.object='.zbx_dbstr($currentEvent['object']). - ($showUnknown ? '' : ' AND e.value_changed='.TRIGGER_VALUE_CHANGED_YES). - ' ORDER BY e.object,e.objectid,e.eventid'; - return DBfetch(DBselect($sql, 1)); -Index: frontends/php/include/images.inc.php -=================================================================== ---- frontends/php/include/images.inc.php (revision 38884) -+++ frontends/php/include/images.inc.php (working copy) -@@ -36,7 +36,7 @@ - static $images = array(); - - if (!isset($images[$imageid])) { -- $row = DBfetch(DBselect('SELECT i.* FROM images i WHERE i.imageid='.$imageid)); -+ $row = DBfetch(DBselect('SELECT i.* FROM images i WHERE i.imageid='.zbx_dbstr($imageid))); - $row['image'] = zbx_unescape_image($row['image']); - $images[$imageid] = $row; - } -Index: frontends/php/include/maintenances.inc.php -=================================================================== ---- frontends/php/include/maintenances.inc.php (revision 38884) -+++ frontends/php/include/maintenances.inc.php (working copy) -@@ -23,7 +23,7 @@ - $sql = 'SELECT m.*'. - ' FROM maintenances m'. - ' WHERE '.DBin_node('m.maintenanceid'). -- ' AND maintenanceid='.$maintenanceid; -+ ' AND maintenanceid='.zbx_dbstr($maintenanceid); - return DBfetch(DBselect($sql)); - } - -Index: frontends/php/include/discovery.inc.php -=================================================================== ---- frontends/php/include/discovery.inc.php (revision 38884) -+++ frontends/php/include/discovery.inc.php (working copy) -@@ -164,7 +164,7 @@ - } - - function get_discovery_rule_by_druleid($druleid) { -- return DBfetch(DBselect('SELECT d.* FROM drules d WHERE d.druleid='.$druleid)); -+ return DBfetch(DBselect('SELECT d.* FROM drules d WHERE d.druleid='.zbx_dbstr($druleid))); - } - - function delete_discovery_rule($druleid) { -@@ -174,7 +174,7 @@ - 'SELECT DISTINCT c.actionid'. - ' FROM conditions c'. - ' WHERE c.conditiontype='.CONDITION_TYPE_DRULE. -- ' AND c.value=\''.$druleid.'\'' -+ ' AND c.value='.zbx_dbstr($druleid) - ); - while ($action = DBfetch($dbActions)) { - $actionids[] = $action['actionid']; -@@ -183,8 +183,8 @@ - // disabling actions with deleted conditions - if (!empty($actionids)) { - DBexecute('UPDATE actions SET status='.ACTION_STATUS_DISABLED.' WHERE '.dbConditionInt('actionid', $actionids)); -- DBexecute('DELETE FROM conditions WHERE conditiontype='.CONDITION_TYPE_DRULE.' AND value=\''.$druleid.'\''); -+ DBexecute('DELETE FROM conditions WHERE conditiontype='.CONDITION_TYPE_DRULE.' AND value='.zbx_dbstr($druleid)); - } -- return DBexecute('DELETE FROM drules WHERE druleid='.$druleid); -+ return DBexecute('DELETE FROM drules WHERE druleid='.zbx_dbstr($druleid)); - } - ?> -Index: frontends/php/include/nodes.inc.php -=================================================================== ---- frontends/php/include/nodes.inc.php (revision 38884) -+++ frontends/php/include/nodes.inc.php (working copy) -@@ -281,23 +281,22 @@ - error(_('Master node already exists.')); - return false; - } -- $masterid = 'NULL'; - break; - default: - error(_('Incorrect node type.')); - return false; - } - -- if (DBfetch(DBselect('SELECT n.nodeid FROM nodes n WHERE n.nodeid='.$nodeid))) { -+ if (DBfetch(DBselect('SELECT n.nodeid FROM nodes n WHERE n.nodeid='.zbx_dbstr($nodeid)))) { - error(_('Node with same ID already exists.')); - return false; - } - - $result = DBexecute('INSERT INTO nodes (nodeid,name,ip,port,nodetype,masterid)'. -- ' VALUES ('.$nodeid.','.zbx_dbstr($name).','.zbx_dbstr($ip).','.$port.','.$nodetype.','.$masterid.')'); -+ ' VALUES ('.$nodeid.','.zbx_dbstr($name).','.zbx_dbstr($ip).','.zbx_dbstr($port).','.zbx_dbstr($nodetype).','.($masterid ? zbx_dbstr($masterid) : 'NULL').')'); - - if ($result && $nodetype == ZBX_NODE_MASTER) { -- DBexecute('UPDATE nodes SET masterid='.$nodeid.' WHERE nodeid='.$ZBX_LOCALNODEID); -+ DBexecute('UPDATE nodes SET masterid='.zbx_dbstr($nodeid).' WHERE nodeid='.$ZBX_LOCALNODEID); - $ZBX_CURMASTERID = $nodeid; // apply master node for this script - } - -@@ -309,12 +308,12 @@ - error(_('Incorrect characters used for Node name.')); - return false; - } -- return DBexecute('UPDATE nodes SET name='.zbx_dbstr($name).',ip='.zbx_dbstr($ip).',port='.$port.' WHERE nodeid='.$nodeid); -+ return DBexecute('UPDATE nodes SET name='.zbx_dbstr($name).',ip='.zbx_dbstr($ip).',port='.zbx_dbstr($port).' WHERE nodeid='.zbx_dbstr($nodeid)); - } - - function delete_node($nodeid) { - $result = false; -- $node = DBfetch(DBselect('SELECT n.nodeid,n.masterid FROM nodes n WHERE n.nodeid='.$nodeid)); -+ $node = DBfetch(DBselect('SELECT n.nodeid,n.masterid FROM nodes n WHERE n.nodeid='.zbx_dbstr($nodeid))); - $nodetype = detect_node_type($node['nodeid'], $node['masterid']); - - if ($nodetype == ZBX_NODE_LOCAL) { -@@ -322,8 +321,8 @@ - } - else { - $result = ( -- DBexecute('UPDATE nodes SET masterid=NULL WHERE masterid='.$nodeid) && -- DBexecute('DELETE FROM nodes WHERE nodeid='.$nodeid) -+ DBexecute('UPDATE nodes SET masterid=NULL WHERE masterid='.zbx_dbstr($nodeid)) && -+ DBexecute('DELETE FROM nodes WHERE nodeid='.zbx_dbstr($nodeid)) - ); - if ($nodetype != ZBX_NODE_MASTER) { - error(_('Please be aware that database still contains data related to the deleted node.')); -@@ -333,7 +332,7 @@ - } - - function get_node_by_nodeid($nodeid) { -- return DBfetch(DBselect('SELECT n.* FROM nodes n WHERE n.nodeid='.$nodeid)); -+ return DBfetch(DBselect('SELECT n.* FROM nodes n WHERE n.nodeid='.zbx_dbstr($nodeid))); - } - - function get_node_path($nodeid, $result = '') { -Index: frontends/php/include/valuemap.inc.php -=================================================================== ---- frontends/php/include/valuemap.inc.php (revision 38884) -+++ frontends/php/include/valuemap.inc.php (working copy) -@@ -59,7 +59,7 @@ - unset($valueMap['valuemapid']); - - // check existence -- if (!DBfetch(DBselect('SELECT v.valuemapid FROM valuemaps v WHERE v.valuemapid='.$valueMapId))) { -+ if (!DBfetch(DBselect('SELECT v.valuemapid FROM valuemaps v WHERE v.valuemapid='.zbx_dbstr($valueMapId)))) { - throw new Exception(_s('Value map with valuemapid "%1$s" does not exist.', $valueMapId)); - } - -@@ -228,7 +228,7 @@ - $dbMappings = DBselect( - 'SELECT m.mappingid,m.value,m.newvalue'. - ' FROM mappings m'. -- ' WHERE m.valuemapid='.$valueMapId -+ ' WHERE m.valuemapid='.zbx_dbstr($valueMapId) - ); - while ($mapping = DBfetch($dbMappings)) { - $mappings[$mapping['mappingid']] = $mapping; -@@ -260,7 +260,7 @@ - $dbMappings = DBselect( - 'SELECT m.newvalue'. - ' FROM mappings m'. -- ' WHERE m.valuemapid='.$valueMapId. -+ ' WHERE m.valuemapid='.zbx_dbstr($valueMapId). - ' AND m.value='.zbx_dbstr($value) - ); - if ($mapping = DBfetch($dbMappings)) { -Index: frontends/php/include/httptest.inc.php -=================================================================== ---- frontends/php/include/httptest.inc.php (revision 38884) -+++ frontends/php/include/httptest.inc.php (working copy) -@@ -72,10 +72,10 @@ - } - - function activate_httptest($httptestid) { -- $result = DBexecute('UPDATE httptest SET status='.HTTPTEST_STATUS_ACTIVE.' WHERE httptestid='.$httptestid); -+ $result = DBexecute('UPDATE httptest SET status='.HTTPTEST_STATUS_ACTIVE.' WHERE httptestid='.zbx_dbstr($httptestid)); - - $itemids = array(); -- $items_db = DBselect('SELECT hti.itemid FROM httptestitem hti WHERE hti.httptestid='.$httptestid); -+ $items_db = DBselect('SELECT hti.itemid FROM httptestitem hti WHERE hti.httptestid='.zbx_dbstr($httptestid)); - while ($itemid = Dbfetch($items_db)) { - $itemids[] = $itemid['itemid']; - } -@@ -84,7 +84,7 @@ - 'SELECT hsi.itemid'. - ' FROM httpstep hs,httpstepitem hsi'. - ' WHERE hs.httpstepid=hsi.httpstepid'. -- ' AND hs.httptestid='.$httptestid -+ ' AND hs.httptestid='.zbx_dbstr($httptestid) - ); - while ($itemid = Dbfetch($items_db)) { - $itemids[] = $itemid['itemid']; -@@ -96,10 +96,10 @@ - } - - function disable_httptest($httptestid) { -- $result = DBexecute('UPDATE httptest SET status='.HTTPTEST_STATUS_DISABLED.' WHERE httptestid='.$httptestid); -+ $result = DBexecute('UPDATE httptest SET status='.HTTPTEST_STATUS_DISABLED.' WHERE httptestid='.zbx_dbstr($httptestid)); - - $itemids = array(); -- $items_db = DBselect('SELECT hti.itemid FROM httptestitem hti WHERE hti.httptestid='.$httptestid); -+ $items_db = DBselect('SELECT hti.itemid FROM httptestitem hti WHERE hti.httptestid='.zbx_dbstr($httptestid)); - while ($itemid = Dbfetch($items_db)) { - $itemids[] = $itemid['itemid']; - } -@@ -108,7 +108,7 @@ - 'SELECT hsi.itemid'. - ' FROM httpstep hs,httpstepitem hsi'. - ' WHERE hs.httpstepid=hsi.httpstepid'. -- ' AND hs.httptestid='.$httptestid -+ ' AND hs.httptestid='.zbx_dbstr($httptestid) - ); - while ($itemid = Dbfetch($items_db)) { - $itemids[] = $itemid['itemid']; -@@ -125,7 +125,7 @@ - ' FROM items i,httpstepitem si,httpstep s'. - ' WHERE i.itemid=si.itemid'. - ' AND si.httpstepid=s.httpstepid'. -- ' AND s.httptestid='.$httptestid -+ ' AND s.httptestid='.zbx_dbstr($httptestid) - ); - while ($item_data = DBfetch($db_items)) { - if (!delete_history_by_itemid($item_data['itemid'])) { -@@ -137,11 +137,11 @@ - } - - function get_httptest_by_httptestid($httptestid) { -- return DBfetch(DBselect('SELECT ht.* FROM httptest ht WHERE ht.httptestid='.$httptestid)); -+ return DBfetch(DBselect('SELECT ht.* FROM httptest ht WHERE ht.httptestid='.zbx_dbstr($httptestid))); - } - - function get_httpstep_by_no($httptestid, $no) { -- return DBfetch(DBselect('SELECT hs.* FROM httpstep hs WHERE hs.httptestid='.$httptestid.' AND hs.no='.$no)); -+ return DBfetch(DBselect('SELECT hs.* FROM httpstep hs WHERE hs.httptestid='.zbx_dbstr($httptestid).' AND hs.no='.zbx_dbstr($no))); - } - - function get_httptests_by_hostid($hostids) { -Index: frontends/php/include/acknow.inc.php -=================================================================== ---- frontends/php/include/acknow.inc.php (revision 38884) -+++ frontends/php/include/acknow.inc.php (working copy) -@@ -23,7 +23,7 @@ - $dbEvents = DBfetch(DBselect( - 'SELECT e.*'. - ' FROM events e'. -- ' WHERE e.objectid='.$triggerid. -+ ' WHERE e.objectid='.zbx_dbstr($triggerid). - ' AND e.object='.EVENT_OBJECT_TRIGGER. - ' AND e.value<>'.TRIGGER_VALUE_UNKNOWN. - ' AND e.value_changed='.TRIGGER_VALUE_CHANGED_YES. -@@ -35,7 +35,7 @@ - } - - function get_acknowledges_by_eventid($eventid) { -- return DBselect('SELECT a.*,u.alias FROM acknowledges a LEFT JOIN users u ON u.userid=a.userid WHERE a.eventid='.$eventid); -+ return DBselect('SELECT a.*,u.alias FROM acknowledges a LEFT JOIN users u ON u.userid=a.userid WHERE a.eventid='.zbx_dbstr($eventid)); - } - - /** -Index: frontends/php/include/triggers.inc.php -=================================================================== ---- frontends/php/include/triggers.inc.php (revision 38884) -+++ frontends/php/include/triggers.inc.php (working copy) -@@ -107,7 +107,7 @@ - function get_service_status_of_trigger($triggerid) { - $sql = 'SELECT t.triggerid,t.priority'. - ' FROM triggers t'. -- ' WHERE t.triggerid='.$triggerid. -+ ' WHERE t.triggerid='.zbx_dbstr($triggerid). - ' AND t.status='.TRIGGER_STATUS_ENABLED. - ' AND t.value='.TRIGGER_VALUE_TRUE; - $rows = DBfetch(DBselect($sql, 1)); -@@ -259,7 +259,7 @@ - } - - function get_trigger_by_triggerid($triggerid) { -- $db_trigger = DBfetch(DBselect('SELECT t.* FROM triggers t WHERE t.triggerid='.$triggerid)); -+ $db_trigger = DBfetch(DBselect('SELECT t.* FROM triggers t WHERE t.triggerid='.zbx_dbstr($triggerid))); - if (!empty($db_trigger)) { - return $db_trigger; - } -@@ -284,7 +284,7 @@ - return DBselect( - 'SELECT DISTINCT t.*'. - ' FROM triggers t,functions f,items i'. -- ' WHERE i.hostid='.$hostid. -+ ' WHERE i.hostid='.zbx_dbstr($hostid). - ' AND f.itemid=i.itemid'. - ' AND f.triggerid=t.triggerid' - ); -@@ -679,7 +679,7 @@ - $state = ''; - $sql = 'SELECT h.host,i.itemid,i.key_,f.function,f.triggerid,f.parameter,i.itemid,i.status,i.type,i.flags'. - ' FROM items i,functions f,hosts h'. -- ' WHERE f.functionid='.$functionid. -+ ' WHERE f.functionid='.zbx_dbstr($functionid). - ' AND i.itemid=f.itemid'. - ' AND h.hostid=i.hostid'; - -@@ -1068,8 +1068,8 @@ - ' FROM triggers t,functions f,items i'. - ' WHERE t.triggerid=f.triggerid'. - ' AND f.itemid=i.itemid'. -- ' AND t.templateid='.$val. -- ' AND i.hostid='.$hostid; -+ ' AND t.templateid='.zbx_dbstr($val). -+ ' AND i.hostid='.zbx_dbstr($hostid); - if ($db_new_dep = DBfetch(DBselect($sql))) { - $deps[$id] = $db_new_dep['triggerid']; - } -@@ -1395,9 +1395,9 @@ - if ($period_start > 0 && $period_start <= time()) { - $sql = 'SELECT e.eventid,e.value'. - ' FROM events e'. -- ' WHERE e.objectid='.$triggerid. -+ ' WHERE e.objectid='.zbx_dbstr($triggerid). - ' AND e.object='.EVENT_OBJECT_TRIGGER. -- ' AND e.clock<'.$period_start. -+ ' AND e.clock<'.zbx_dbstr($period_start). - ' ORDER BY e.eventid DESC'; - if ($row = DBfetch(DBselect($sql, 1))) { - $start_value = $row['value']; -@@ -1407,13 +1407,13 @@ - - $sql = 'SELECT COUNT(e.eventid) AS cnt,MIN(e.clock) AS min_clock,MAX(e.clock) AS max_clock'. - ' FROM events e'. -- ' WHERE e.objectid='.$triggerid. -+ ' WHERE e.objectid='.zbx_dbstr($triggerid). - ' AND e.object='.EVENT_OBJECT_TRIGGER; - if ($period_start != 0) { -- $sql .= ' AND clock>='.$period_start; -+ $sql .= ' AND clock>='.zbx_dbstr($period_start); - } - if ($period_end != 0) { -- $sql .= ' AND clock<='.$period_end; -+ $sql .= ' AND clock<='.zbx_dbstr($period_end); - } - - $db_events = DBfetch(DBselect($sql)); -@@ -1455,7 +1455,7 @@ - $db_events = DBselect( - 'SELECT e.eventid,e.clock,e.value'. - ' FROM events e'. -- ' WHERE e.objectid='.$triggerid. -+ ' WHERE e.objectid='.zbx_dbstr($triggerid). - ' AND e.object='.EVENT_OBJECT_TRIGGER. - ' AND e.clock BETWEEN '.$min.' AND '.$max. - ' ORDER BY e.eventid' -Index: frontends/php/include/forms.inc.php -=================================================================== ---- frontends/php/include/forms.inc.php (revision 38884) -+++ frontends/php/include/forms.inc.php (working copy) -@@ -66,7 +66,7 @@ - $data['user_medias'] = array(); - $dbMedia = DBselect('SELECT m.mediaid,m.mediatypeid,m.period,m.sendto,m.severity,m.active'. - ' FROM media m'. -- ' WHERE m.userid='.$userid -+ ' WHERE m.userid='.zbx_dbstr($userid) - ); - while ($dbMedium = DBfetch($dbMedia)) { - $data['user_medias'][] = $dbMedium; -@@ -1104,7 +1104,7 @@ - $data['db_applications'] = DBfetchArray(DBselect( - 'SELECT DISTINCT a.applicationid,a.name'. - ' FROM applications a'. -- ' WHERE a.hostid='.$data['hostid'] -+ ' WHERE a.hostid='.zbx_dbstr($data['hostid']) - )); - order_result($data['db_applications'], 'name'); - -@@ -1117,7 +1117,7 @@ - // valuemapid - if ($data['limited']) { - if (!empty($data['valuemapid'])) { -- if ($map_data = DBfetch(DBselect('SELECT v.name FROM valuemaps v WHERE v.valuemapid='.$data['valuemapid']))) { -+ if ($map_data = DBfetch(DBselect('SELECT v.name FROM valuemaps v WHERE v.valuemapid='.zbx_dbstr($data['valuemapid'])))) { - $data['valuemaps'] = $map_data['name']; - } - } -@@ -1270,7 +1270,7 @@ - ' LEFT JOIN items i ON f.itemid=i.itemid'. - ' LEFT JOIN hosts h ON i.hostid=h.hostid'. - ' LEFT JOIN item_discovery id ON i.itemid=id.itemid'. -- ' WHERE t.triggerid='.$tmp_triggerid -+ ' WHERE t.triggerid='.zbx_dbstr($tmp_triggerid) - )); - if (bccomp($data['triggerid'], $tmp_triggerid) != 0) { - // parent trigger prototype link -@@ -1313,7 +1313,7 @@ - 'SELECT t.triggerid,t.description'. - ' FROM triggers t,trigger_depends d'. - ' WHERE t.triggerid=d.triggerid_up'. -- ' AND d.triggerid_down='.$data['triggerid'] -+ ' AND d.triggerid_down='.zbx_dbstr($data['triggerid']) - ); - while ($trigger = DBfetch($db_triggers)) { - if (uint_in_array($trigger['triggerid'], $data['dependencies'])) { -@@ -1720,7 +1720,7 @@ - $table_titles = zbx_toHash($table_titles, 'db_field'); - $sql_fields = implode(', ', array_keys($table_titles)); - -- $sql = 'SELECT '.$sql_fields.' FROM host_inventory WHERE hostid='.$_REQUEST['hostid']; -+ $sql = 'SELECT '.$sql_fields.' FROM host_inventory WHERE hostid='.zbx_dbstr($_REQUEST['hostid']); - $result = DBselect($sql); - - $row = DBfetch($result); -@@ -1740,7 +1740,7 @@ - $sql = 'SELECT re.* '. - ' FROM regexps re '. - ' WHERE '.DBin_node('re.regexpid'). -- ' AND re.regexpid='.$_REQUEST['regexpid']; -+ ' AND re.regexpid='.zbx_dbstr($_REQUEST['regexpid']); - $regexp = DBfetch(DBSelect($sql)); - - $rename = $regexp['name']; -@@ -1750,7 +1750,7 @@ - $sql = 'SELECT e.* '. - ' FROM expressions e '. - ' WHERE '.DBin_node('e.expressionid'). -- ' AND e.regexpid='.$regexp['regexpid']. -+ ' AND e.regexpid='.zbx_dbstr($regexp['regexpid']). - ' ORDER BY e.expression_type'; - - $db_exps = DBselect($sql); -@@ -1888,7 +1888,7 @@ - $sql = 'SELECT e.* '. - ' FROM expressions e '. - ' WHERE '.DBin_node('e.expressionid'). -- ' AND e.regexpid='.$_REQUEST['regexpid']. -+ ' AND e.regexpid='.zbx_dbstr($_REQUEST['regexpid']). - ' ORDER BY e.expression_type'; - - $db_exps = DBselect($sql); -Index: frontends/php/include/regexp.inc.php -=================================================================== ---- frontends/php/include/regexp.inc.php (revision 38884) -+++ frontends/php/include/regexp.inc.php (working copy) -@@ -24,7 +24,7 @@ - 'SELECT re.*'. - ' FROM regexps re'. - ' WHERE '.DBin_node('re.regexpid'). -- ' AND regexpid='.$regexpId -+ ' AND regexpid='.zbx_dbstr($regexpId) - )); - } - -@@ -35,7 +35,7 @@ - 'SELECT e.expressionid,e.expression,e.expression_type,e.exp_delimiter,e.case_sensitive'. - ' FROM expressions e'. - ' WHERE '.DBin_node('e.expressionid'). -- ' AND regexpid='.$regexpId -+ ' AND regexpid='.zbx_dbstr($regexpId) - ); - while ($expression = DBfetch($dbExpressions)) { - $expressions[$expression['expressionid']] = $expression; -Index: frontends/php/include/actions.inc.php -=================================================================== ---- frontends/php/include/actions.inc.php (revision 38884) -+++ frontends/php/include/actions.inc.php (working copy) -@@ -203,7 +203,7 @@ - 'SELECT dr.name,c.dcheckid,c.type,c.key_,c.ports'. - ' FROM drules dr,dchecks c'. - ' WHERE dr.druleid=c.druleid'. -- ' AND c.dcheckid='.$value -+ ' AND c.dcheckid='.zbx_dbstr($value) - )); - if ($row) { - $str_val = $row['name'].': '.discovery_check2str($row['type'], $row['key_'], $row['ports']); -@@ -409,7 +409,7 @@ - $sql = 'SELECT a.def_shortdata,a.def_longdata '. - ' FROM actions a,operations o '. - ' WHERE a.actionid=o.actionid '. -- ' AND o.operationid='.$data['operationid']; -+ ' AND o.operationid='.zbx_dbstr($data['operationid']); - if ($rows = DBfetch(DBselect($sql, 1))) { - $result[] = array(bold(_('Subject').': '), BR(), zbx_nl2br($rows['def_shortdata'])); - $result[] = array(bold(_('Message').': '), BR(), zbx_nl2br($rows['def_longdata'])); -@@ -873,8 +873,8 @@ - ' FROM events e,alerts a'. - ' LEFT JOIN users u ON u.userid=a.userid'. - ' LEFT JOIN media_type mt ON mt.mediatypeid=a.mediatypeid'. -- ' WHERE a.eventid='.$eventid. -- (is_null($status)?'':' AND a.status='.$status). -+ ' WHERE a.eventid='.zbx_dbstr($eventid). -+ (is_null($status)?'':' AND a.status='.zbx_dbstr($status)). - ' AND e.eventid=a.eventid'. - ' AND a.alerttype IN ('.ALERT_TYPE_MESSAGE.','.ALERT_TYPE_COMMAND.')'. - ' AND '.DBin_node('a.alertid'). -Index: frontends/php/include/screens.inc.php -=================================================================== ---- frontends/php/include/screens.inc.php (revision 38884) -+++ frontends/php/include/screens.inc.php (working copy) -@@ -57,7 +57,7 @@ - } - - function get_screen_by_screenid($screenid) { -- $dbScreen = DBfetch(DBselect('SELECT s.* FROM screens s WHERE s.screenid='.$screenid)); -+ $dbScreen = DBfetch(DBselect('SELECT s.* FROM screens s WHERE s.screenid='.zbx_dbstr($screenid))); - return !empty($dbScreen) ? $dbScreen : false; - } - -@@ -69,7 +69,7 @@ - $db_scr_items = DBselect( - 'SELECT si.resourceid'. - ' FROM screens_items si'. -- ' WHERE si.screenid='.$child_screenid. -+ ' WHERE si.screenid='.zbx_dbstr($child_screenid). - ' AND si.resourcetype='.SCREEN_RESOURCE_SCREEN - ); - while ($scr_item = DBfetch($db_scr_items)) { -@@ -84,7 +84,7 @@ - $db_slides = DBfetch(DBselect( - 'SELECT MIN(s.step) AS min_step,MAX(s.step) AS max_step'. - ' FROM slides s'. -- ' WHERE s.slideshowid='.$slideshowid -+ ' WHERE s.slideshowid='.zbx_dbstr($slideshowid) - )); - if (!$db_slides || is_null($db_slides['min_step'])) { - return false; -@@ -101,9 +101,9 @@ - return DBfetch(DBselect( - 'SELECT sl.*'. - ' FROM slides sl,slideshows ss'. -- ' WHERE ss.slideshowid='.$slideshowid. -+ ' WHERE ss.slideshowid='.zbx_dbstr($slideshowid). - ' AND sl.slideshowid=ss.slideshowid'. -- ' AND sl.step='.$curr_step -+ ' AND sl.step='.zbx_dbstr($curr_step) - )); - } - -@@ -112,7 +112,7 @@ - - $sql = 'SELECT s.slideshowid'. - ' FROM slideshows s'. -- ' WHERE s.slideshowid='.$slideshowid. -+ ' WHERE s.slideshowid='.zbx_dbstr($slideshowid). - ' AND '.DBin_node('s.slideshowid', get_current_nodeid(null, $perm) - ); - if (DBselect($sql)) { -@@ -122,7 +122,7 @@ - $db_screens = DBselect( - 'SELECT DISTINCT s.screenid'. - ' FROM slides s'. -- ' WHERE s.slideshowid='.$slideshowid -+ ' WHERE s.slideshowid='.zbx_dbstr($slideshowid) - ); - while ($slide_data = DBfetch($db_screens)) { - $screenids[$slide_data['screenid']] = $slide_data['screenid']; -@@ -147,7 +147,7 @@ - } - - function get_slideshow_by_slideshowid($slideshowid) { -- return DBfetch(DBselect('SELECT s.* FROM slideshows s WHERE s.slideshowid='.$slideshowid)); -+ return DBfetch(DBselect('SELECT s.* FROM slideshows s WHERE s.slideshowid='.zbx_dbstr($slideshowid))); - } - - function add_slideshow($name, $delay, $slides) { -@@ -182,7 +182,7 @@ - $slideshowid = get_dbid('slideshows', 'slideshowid'); - $result = DBexecute( - 'INSERT INTO slideshows (slideshowid,name,delay)'. -- ' VALUES ('.$slideshowid.','.zbx_dbstr($name).','.$delay.')' -+ ' VALUES ('.zbx_dbstr($slideshowid).','.zbx_dbstr($name).','.zbx_dbstr($delay).')' - ); - - // create slides -@@ -197,7 +197,7 @@ - - $result = DBexecute( - 'INSERT INTO slides (slideid,slideshowid,screenid,step,delay)'. -- ' VALUES ('.$slideid.','.$slideshowid.','.$slide['screenid'].','.($i++).','.$slide['delay'].')' -+ ' VALUES ('.zbx_dbstr($slideid).','.zbx_dbstr($slideshowid).','.zbx_dbstr($slide['screenid']).','.($i++).','.zbx_dbstr($slide['delay']).')' - ); - if (!$result) { - return false; -@@ -228,14 +228,14 @@ - } - - // validate slide name -- $sql = 'SELECT s.slideshowid FROM slideshows s WHERE s.name='.zbx_dbstr($name).' AND s.slideshowid<>'.$slideshowid; -+ $sql = 'SELECT s.slideshowid FROM slideshows s WHERE s.name='.zbx_dbstr($name).' AND s.slideshowid<>'.zbx_dbstr($slideshowid); - $db_slideshow = DBfetch(DBselect($sql, 1)); - if (!empty($db_slideshow)) { - error(_s('Slide show "%s" already exists.', $name)); - return false; - } - -- $db_slideshow = DBfetchArray(DBselect('SELECT * FROM slideshows WHERE slideshowid='.$slideshowid)); -+ $db_slideshow = DBfetchArray(DBselect('SELECT * FROM slideshows WHERE slideshowid='.zbx_dbstr($slideshowid))); - $db_slideshow = $db_slideshow[0]; - $changed = false; - $slideshow = array('name' => $name, 'delay' => $delay); -@@ -246,13 +246,13 @@ - } - } - if ($changed) { -- if (!$result = DBexecute('UPDATE slideshows SET name='.zbx_dbstr($name).',delay='.$delay.' WHERE slideshowid='.$slideshowid)) { -+ if (!$result = DBexecute('UPDATE slideshows SET name='.zbx_dbstr($name).',delay='.zbx_dbstr($delay).' WHERE slideshowid='.zbx_dbstr($slideshowid))) { - return false; - } - } - - // get slides -- $db_slides = DBfetchArrayAssoc(DBselect('SELECT s.* FROM slides s WHERE s.slideshowid='.$slideshowid), 'slideid'); -+ $db_slides = DBfetchArrayAssoc(DBselect('SELECT s.* FROM slides s WHERE s.slideshowid='.zbx_dbstr($slideshowid)), 'slideid'); - - $slidesToDel = zbx_objectValues($db_slides, 'slideid'); - $slidesToDel = zbx_toHash($slidesToDel); -@@ -262,7 +262,7 @@ - if (isset($db_slides[$slide['slideid']])) { - // update slide - if ($db_slides[$slide['slideid']]['delay'] != $slide['delay'] || $db_slides[$slide['slideid']]['step'] != $step) { -- $result = DBexecute('UPDATE slides SET step='.$step.', delay='.$slide['delay'].' WHERE slideid='.$slide['slideid']); -+ $result = DBexecute('UPDATE slides SET step='.zbx_dbstr($step).', delay='.zbx_dbstr($slide['delay']).' WHERE slideid='.zbx_dbstr($slide['slideid'])); - } - // do nothing with slide - else { -@@ -275,7 +275,7 @@ - $slideid = get_dbid('slides', 'slideid'); - $result = DBexecute( - 'INSERT INTO slides (slideid,slideshowid,screenid,step,delay)'. -- ' VALUES ('.$slideid.','.$slideshowid.','.$slide['screenid'].','.$step.','.$slide['delay'].')' -+ ' VALUES ('.zbx_dbstr($slideid).','.zbx_dbstr($slideshowid).','.zbx_dbstr($slide['screenid']).','.zbx_dbstr($step).','.zbx_dbstr($slide['delay']).')' - ); - } - $step ++; -@@ -293,9 +293,9 @@ - } - - function delete_slideshow($slideshowid) { -- $result = DBexecute('DELETE FROM slideshows where slideshowid='.$slideshowid); -- $result &= DBexecute('DELETE FROM slides where slideshowid='.$slideshowid); -- $result &= DBexecute('DELETE FROM profiles WHERE idx=\'web.favorite.screenids\' AND source=\'slideshowid\' AND value_id='.$slideshowid); -+ $result = DBexecute('DELETE FROM slideshows where slideshowid='.zbx_dbstr($slideshowid)); -+ $result &= DBexecute('DELETE FROM slides where slideshowid='.zbx_dbstr($slideshowid)); -+ $result &= DBexecute('DELETE FROM profiles WHERE idx=\'web.favorite.screenids\' AND source=\'slideshowid\' AND value_id='.zbx_dbstr($slideshowid)); - return $result; - } - -@@ -304,13 +304,13 @@ - if ($config == 0) { - $sql = 'SELECT si.screenitemid'. - ' FROM screens_items si'. -- ' WHERE si.screenid='.$elid. -+ ' WHERE si.screenid='.zbx_dbstr($elid). - ' AND si.dynamic='.SCREEN_DYNAMIC_ITEM; - } - else { - $sql = 'SELECT si.screenitemid'. - ' FROM slides s,screens_items si'. -- ' WHERE s.slideshowid='.$elid. -+ ' WHERE s.slideshowid='.zbx_dbstr($elid). - ' AND si.screenid=s.screenid'. - ' AND si.dynamic='.SCREEN_DYNAMIC_ITEM; - } -Index: frontends/php/include/perm.inc.php -=================================================================== ---- frontends/php/include/perm.inc.php (revision 38884) -+++ frontends/php/include/perm.inc.php (working copy) -@@ -46,7 +46,7 @@ - function check_perm2system($userid) { - $sql = 'SELECT g.usrgrpid'. - ' FROM usrgrp g,users_groups ug'. -- ' WHERE ug.userid='.$userid. -+ ' WHERE ug.userid='.zbx_dbstr($userid). - ' AND g.usrgrpid=ug.usrgrpid'. - ' AND g.users_status='.GROUP_STATUS_DISABLED; - if ($res = DBfetch(DBselect($sql, 1))) { -@@ -91,7 +91,7 @@ - - $sql = 'SELECT MAX(g.gui_access) AS gui_access'. - ' FROM usrgrp g,users_groups ug'. -- ' WHERE ug.userid='.$userid. -+ ' WHERE ug.userid='.zbx_dbstr($userid). - ' AND g.usrgrpid=ug.usrgrpid'; - $db_access = DBfetch(DBselect($sql)); - if (!zbx_empty($db_access['gui_access'])) { -@@ -206,7 +206,7 @@ - ' LEFT JOIN rights r ON r.id=hg.groupid'. - ' LEFT JOIN users_groups g ON r.groupid=g.usrgrpid'. - ' LEFT JOIN nodes n ON '.DBid2nodeid('hg.groupid').'=n.nodeid'. -- ' WHERE g.userid='.$userid. -+ ' WHERE g.userid='.zbx_dbstr($userid). - ' AND '.DBin_node('hg.groupid', $nodeid). - ' GROUP BY n.nodeid,n.name,hg.groupid,hg.name,g.userid'. - ' ORDER BY node_name,hg.name,permission'; -@@ -306,7 +306,7 @@ - foreach ($node_data as $nodeid => $node) { - switch ($perm_res) { - case PERM_RES_DATA_ARRAY: -- $db_node = DBfetch(DBselect('SELECT n.* FROM nodes n WHERE n.nodeid='.$nodeid.' ORDER BY n.name')); -+ $db_node = DBfetch(DBselect('SELECT n.* FROM nodes n WHERE n.nodeid='.zbx_dbstr($nodeid).' ORDER BY n.name')); - - if (!ZBX_DISTRIBUTED) { - if (!$node) { -@@ -552,7 +552,7 @@ - if (!isset($userGroups[$userId])) { - $userGroups[$userId] = array(); - -- $result = DBselect('SELECT usrgrpid FROM users_groups WHERE userid='.$userId); -+ $result = DBselect('SELECT usrgrpid FROM users_groups WHERE userid='.zbx_dbstr($userId)); - while ($row = DBfetch($result)) { - $userGroups[$userId][] = $row['usrgrpid']; - } -Index: frontends/php/include/blocks.inc.php -=================================================================== ---- frontends/php/include/blocks.inc.php (revision 38884) -+++ frontends/php/include/blocks.inc.php (working copy) -@@ -1043,7 +1043,7 @@ - ' AND hti.type='.HTTPSTEP_ITEM_TYPE_LASTSTEP. - ' AND ht.status='.HTTPTEST_STATUS_ACTIVE. - ' AND '.dbConditionInt('hg.hostid', $availableHostIds). -- ' AND hg.groupid='.$group['groupid'] -+ ' AND hg.groupid='.zbx_dbstr($group['groupid']) - ); - while ($row = DBfetch($result)) { - $showGroup = true; diff --git a/zabbix20.spec b/zabbix20.spec index 5d6a651..b28e732 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -19,8 +19,8 @@ %global srcname zabbix Name: zabbix20 -Version: 2.0.8 -Release: 3%{?dist} +Version: 2.0.9 +Release: 1%{?dist} Summary: Open-source monitoring solution for your IT infrastructure Group: Applications/Internet @@ -55,21 +55,6 @@ Patch1: %{srcname}-2.0.3-fonts-config.patch Patch2: %{srcname}-2.0.1-no-flash.patch # adapt for fping3 - https://support.zabbix.com/browse/ZBX-4894 Patch3: %{srcname}-1.8.12-fping3.patch -# Services page broken due to missing AS in SQL -# https://support.zabbix.com/browse/ZBX-6992 -Patch4: %{srcname}-2.0.8-ZBX-6992.patch - -# SQL speedup for graphs, fixed in 2.0.9 -# https://support.zabbix.com/browse/ZBX-6840 -Patch5: %{srcname}-2.0.8-ZBX-6804.patch - -# Failure on XML import of hosts, fixed in 2.0.9 -# https://support.zabbix.com/browse/ZBX-6922 -Patch6: %{srcname}-2.0.8-ZBX-6922.patch - -# Frontend and API vulnerability to SQL injections -# CVE-2013-5743 -Patch7: %{srcname}-2.0.8-ZBX-7091.patch BuildRequires: mysql-devel BuildRequires: postgresql-devel @@ -287,10 +272,6 @@ Zabbix web frontend for PostgreSQL %if 0%{?fedora} %patch3 -p1 %endif -%patch4 -p0 -%patch5 -p0 -%patch6 -p0 -%patch7 -p0 # Logrotate's su option is currently only available in Fedora %if 0%{?rhel} @@ -867,6 +848,10 @@ fi %files web-pgsql %changelog +* Wed Oct 9 2013 Volker Fröhlich - 2.0.9-1 +- New upstream release +- Drop obsolete patches ZBX-6804, ZBX-7091, ZBX-6922, ZBX-6992 + * Mon Sep 23 2013 Volker Fröhlich - 2.0.8-3 - Add SQL speed-up patch (ZBX-6804) - Add SQL injection vulnerability patch (ZBX-7091, CVE-2013-5743) From 9170450ddeaeb36cbfd43ce735ea883bfce12eca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Tue, 3 Dec 2013 19:40:56 +0100 Subject: [PATCH 26/42] Possible remote command injection ZBX-7479 (CVE-2013-6824) --- zabbix-2.0.9-ZBX-7479.patch | 83 +++++++++++++++++++++++++++++++++++++ zabbix20.spec | 10 ++++- 2 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 zabbix-2.0.9-ZBX-7479.patch diff --git a/zabbix-2.0.9-ZBX-7479.patch b/zabbix-2.0.9-ZBX-7479.patch new file mode 100644 index 0000000..52cabd4 --- /dev/null +++ b/zabbix-2.0.9-ZBX-7479.patch @@ -0,0 +1,83 @@ +Index: src/libs/zbxsysinfo/sysinfo.c +=================================================================== +--- src/libs/zbxsysinfo/sysinfo.c (revision 40346) ++++ src/libs/zbxsysinfo/sysinfo.c (working copy) +@@ -267,13 +267,49 @@ + test_parameter(commands[i].key, PROCESS_TEST | PROCESS_USE_TEST_PARAM); + } + ++static int zbx_check_user_parameter(const char *param, char *error, int max_error_len) ++{ ++ const char suppressed_chars[] = "\\'\"`*?[]{}~$!&;()<>|#@\n", *c; ++ char *buf = NULL; ++ size_t buf_alloc = 128, buf_offset = 0; ++ ++ if (0 != CONFIG_UNSAFE_USER_PARAMETERS) ++ return SUCCEED; ++ ++ for (c = suppressed_chars; '\0' != *c; c++) ++ { ++ if (NULL == strchr(param, *c)) ++ continue; ++ ++ buf = zbx_malloc(buf, buf_alloc); ++ ++ for (c = suppressed_chars; '\0' != *c; c++) ++ { ++ if (c != suppressed_chars) ++ zbx_strcpy_alloc(&buf, &buf_alloc, &buf_offset, ", "); ++ ++ if (0 != isprint(*c)) ++ zbx_chrcpy_alloc(&buf, &buf_alloc, &buf_offset, *c); ++ else ++ zbx_snprintf_alloc(&buf, &buf_alloc, &buf_offset, "0x%02x", *c); ++ } ++ ++ zbx_snprintf(error, max_error_len, "special characters \"%s\" are not allowed in the parameters", buf); ++ ++ zbx_free(buf); ++ ++ return FAIL; ++ } ++ ++ return SUCCEED; ++} ++ + static int replace_param(const char *cmd, const char *param, char *out, int outlen, char *error, int max_error_len) + { + int ret = SUCCEED; + char buf[MAX_STRING_LEN]; + char command[MAX_STRING_LEN]; + char *pl, *pr; +- const char suppressed_chars[] = "\\'\"`*?[]{}~$!&;()<>|#@", *c; + + assert(out); + +@@ -305,25 +341,10 @@ + { + get_param(param, (int)(pr[1] - '0'), buf, sizeof(buf)); + +- if (0 == CONFIG_UNSAFE_USER_PARAMETERS) +- { +- for (c = suppressed_chars; '\0' != *c; c++) +- { +- if (NULL != strchr(buf, *c)) +- { +- zbx_snprintf(error, max_error_len, "Special characters '%s'" +- " are not allowed in the parameters", +- suppressed_chars); +- ret = FAIL; +- break; +- } +- } +- } ++ if (SUCCEED != (ret = zbx_check_user_parameter(buf, error, max_error_len))) ++ break; + } + +- if (FAIL == ret) +- break; +- + zbx_strlcat(out, buf, outlen); + outlen -= MIN((int)strlen(buf), (int)outlen); + diff --git a/zabbix20.spec b/zabbix20.spec index b28e732..b01a104 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -20,7 +20,7 @@ Name: zabbix20 Version: 2.0.9 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Open-source monitoring solution for your IT infrastructure Group: Applications/Internet @@ -55,6 +55,9 @@ Patch1: %{srcname}-2.0.3-fonts-config.patch Patch2: %{srcname}-2.0.1-no-flash.patch # adapt for fping3 - https://support.zabbix.com/browse/ZBX-4894 Patch3: %{srcname}-1.8.12-fping3.patch +# Fix vulnerability for remote command execution injection CVE-2013-6824 +# https://support.zabbix.com/browse/ZBX-7479 +Patch4: %{srcname}-2.0.9-ZBX-7479.patch BuildRequires: mysql-devel BuildRequires: postgresql-devel @@ -272,6 +275,7 @@ Zabbix web frontend for PostgreSQL %if 0%{?fedora} %patch3 -p1 %endif +%patch4 -p0 # Logrotate's su option is currently only available in Fedora %if 0%{?rhel} @@ -848,6 +852,10 @@ fi %files web-pgsql %changelog +* Tue Nov 3 2013 Volker Fröhlich - 2.0.9-2 +- Fix vulnerability for remote command execution injection + (ZBX-7479, CVE-2013-6824) + * Wed Oct 9 2013 Volker Fröhlich - 2.0.9-1 - New upstream release - Drop obsolete patches ZBX-6804, ZBX-7091, ZBX-6922, ZBX-6992 From 3e7c729db2fc5f92e565690b6ebd1f2b5f6191b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Fri, 13 Dec 2013 23:08:15 +0100 Subject: [PATCH 27/42] New release 2.0.10 and init file improvements (BZ#1018293) - Upstream release 2.0.10 - Drop obsolete patch ZBX-7479 (previous CVE) - Improve init scripts to not kill other instances (BZ#1018293) - General overhaul of init scripts and documentation in README - Harmonize scriptlet if-clause style --- .gitignore | 1 + sources | 2 +- zabbix-2.0.9-ZBX-7479.patch | 83 ------------------------------------- zabbix-agent.init | 33 +++++++++------ zabbix-fedora.README | 17 ++++++++ zabbix-proxy.init | 31 +++++++++----- zabbix-server.init | 32 +++++++++----- zabbix20.spec | 20 +++++---- 8 files changed, 92 insertions(+), 127 deletions(-) delete mode 100644 zabbix-2.0.9-ZBX-7479.patch diff --git a/.gitignore b/.gitignore index 89acafc..c5a83c9 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ /zabbix-2.0.8.tar.gz /zabbix-2.0.8-free.tar.gz /zabbix-2.0.9-free.tar.gz +/zabbix-2.0.10.tar.gz diff --git a/sources b/sources index b1d6d3e..178d2a8 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -1b895bc113adb98c605d36b1a9328a26 zabbix-2.0.9-free.tar.gz +49297c0ac61858fd75ab9ea18ca6cdbb zabbix-2.0.10.tar.gz diff --git a/zabbix-2.0.9-ZBX-7479.patch b/zabbix-2.0.9-ZBX-7479.patch deleted file mode 100644 index 52cabd4..0000000 --- a/zabbix-2.0.9-ZBX-7479.patch +++ /dev/null @@ -1,83 +0,0 @@ -Index: src/libs/zbxsysinfo/sysinfo.c -=================================================================== ---- src/libs/zbxsysinfo/sysinfo.c (revision 40346) -+++ src/libs/zbxsysinfo/sysinfo.c (working copy) -@@ -267,13 +267,49 @@ - test_parameter(commands[i].key, PROCESS_TEST | PROCESS_USE_TEST_PARAM); - } - -+static int zbx_check_user_parameter(const char *param, char *error, int max_error_len) -+{ -+ const char suppressed_chars[] = "\\'\"`*?[]{}~$!&;()<>|#@\n", *c; -+ char *buf = NULL; -+ size_t buf_alloc = 128, buf_offset = 0; -+ -+ if (0 != CONFIG_UNSAFE_USER_PARAMETERS) -+ return SUCCEED; -+ -+ for (c = suppressed_chars; '\0' != *c; c++) -+ { -+ if (NULL == strchr(param, *c)) -+ continue; -+ -+ buf = zbx_malloc(buf, buf_alloc); -+ -+ for (c = suppressed_chars; '\0' != *c; c++) -+ { -+ if (c != suppressed_chars) -+ zbx_strcpy_alloc(&buf, &buf_alloc, &buf_offset, ", "); -+ -+ if (0 != isprint(*c)) -+ zbx_chrcpy_alloc(&buf, &buf_alloc, &buf_offset, *c); -+ else -+ zbx_snprintf_alloc(&buf, &buf_alloc, &buf_offset, "0x%02x", *c); -+ } -+ -+ zbx_snprintf(error, max_error_len, "special characters \"%s\" are not allowed in the parameters", buf); -+ -+ zbx_free(buf); -+ -+ return FAIL; -+ } -+ -+ return SUCCEED; -+} -+ - static int replace_param(const char *cmd, const char *param, char *out, int outlen, char *error, int max_error_len) - { - int ret = SUCCEED; - char buf[MAX_STRING_LEN]; - char command[MAX_STRING_LEN]; - char *pl, *pr; -- const char suppressed_chars[] = "\\'\"`*?[]{}~$!&;()<>|#@", *c; - - assert(out); - -@@ -305,25 +341,10 @@ - { - get_param(param, (int)(pr[1] - '0'), buf, sizeof(buf)); - -- if (0 == CONFIG_UNSAFE_USER_PARAMETERS) -- { -- for (c = suppressed_chars; '\0' != *c; c++) -- { -- if (NULL != strchr(buf, *c)) -- { -- zbx_snprintf(error, max_error_len, "Special characters '%s'" -- " are not allowed in the parameters", -- suppressed_chars); -- ret = FAIL; -- break; -- } -- } -- } -+ if (SUCCEED != (ret = zbx_check_user_parameter(buf, error, max_error_len))) -+ break; - } - -- if (FAIL == ret) -- break; -- - zbx_strlcat(out, buf, outlen); - outlen -= MIN((int)strlen(buf), (int)outlen); - diff --git a/zabbix-agent.init b/zabbix-agent.init index 7e3019d..cb97acf 100644 --- a/zabbix-agent.init +++ b/zabbix-agent.init @@ -2,20 +2,18 @@ # # chkconfig: - 86 14 # description: Zabbix agent daemon -# processname: zabbix_agentd -# config: /etc/zabbix_agentd.conf # ### BEGIN INIT INFO # Provides: zabbix-agent # Required-Start: $local_fs $network # Required-Stop: $local_fs $network -# Should-Start: zabbix zabbix-proxy -# Should-Stop: zabbix zabbix-proxy +# Should-Start: zabbix-server zabbix-proxy +# Should-Stop: zabbix-server zabbix-proxy # Default-Start: # Default-Stop: 0 1 2 3 4 5 6 # Short-Description: Start and stop Zabbix agent -# Description: Zabbix agent +# Description: Zabbix agent daemon ### END INIT INFO # Source function library. @@ -23,14 +21,25 @@ exec=/usr/sbin/zabbix_agentd prog=${exec##*/} -syscf=zabbix-agent -lockfile=/var/lock/subsys/zabbix-agent -[ -e /etc/sysconfig/$syscf ] && . /etc/sysconfig/$syscf +syscf=${0##*/} +lockfile=/var/lock/subsys/$syscf + +[ -f /etc/sysconfig/$syscf ] && . /etc/sysconfig/$syscf + +config=${CFG_FILE:-/etc/zabbix_agentd.conf} +if [ ! -f $config ]; then + echo "Not starting Zabbix agent: Config file $config not found!" + echo "Check /etc/sysconfig/$syscf" + exit 3 +fi + +pidfile=$(grep -e "^PidFile=.*$" $config | cut -d= -f2) +param="-c $config" start() { echo -n $"Starting Zabbix agent: " - daemon --user zabbix $exec + daemon --user zabbix --pidfile "$pidfile" $exec $param rv=$? echo [ $rv -eq 0 ] && touch $lockfile @@ -40,7 +49,7 @@ start() stop() { echo -n $"Shutting down Zabbix agent: " - killproc $prog + killproc -p "$pidfile" $prog rv=$? echo [ $rv -eq 0 ] && rm -f $lockfile @@ -61,10 +70,10 @@ case "$1" in restart ;; status) - status $prog + status -p "$pidfile" -l $prog $exec ;; try-restart|condrestart) - if status $prog >/dev/null ; then + if status -p "$pidfile" -l $prog $exec >/dev/null ; then restart fi ;; diff --git a/zabbix-fedora.README b/zabbix-fedora.README index 4bbf487..9efb395 100644 --- a/zabbix-fedora.README +++ b/zabbix-fedora.README @@ -6,6 +6,7 @@ Since /tmp is not a good place to spool files, the pinger files shall now reside in /var/lib/zabbixsrv/tmp. This directory is automatically created and proxy and server configuration files are changed accordingly from 2.0.8 on. + ==Web configuration== Web configuration resides in /etc/zabbix/web. No need to copy or edit @@ -74,6 +75,22 @@ Don't forget to reconfigure the front-end when you switch the server to a different DB implementation! +==How to run multiple instances of a Zabbix daemon with init scripts== + +If you want to run multiple instances on the same host, do the following: + +- Copy the init scripts +- Create a file of the same name as the new init script in /etc/sysconfig +- Define CFG_FILE="" in this file +- Create the file defined as CFG_FILE and adjust settings; in particular: + - PidFile + - ListenPort and/or ListenIP, if you plan for simultaneous operation + - LogFile, if you don't use syslog +- Optionally run the following to register as a service and set it to start up: + chkconfig --add + chkconfig on + + ==Configuration changes== Zabbix 2.0 places configuration files directly in /etc. Symlinks preserve diff --git a/zabbix-proxy.init b/zabbix-proxy.init index 079f2ea..cc1fe9e 100644 --- a/zabbix-proxy.init +++ b/zabbix-proxy.init @@ -2,7 +2,6 @@ # # chkconfig: - 85 15 # description: Zabbix proxy daemon -# config: /etc/zabbix_proxy.conf # ### BEGIN INIT INFO @@ -12,23 +11,33 @@ # Default-Start: # Default-Stop: 0 1 2 3 4 5 6 # Short-Description: Start and stop Zabbix proxy -# Description: Zabbix proxy +# Description: Zabbix proxy daemon ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions -exec=zabbix_proxy +exec=/usr/sbin/zabbix_proxy prog=${exec##*/} -lockfile=/var/lock/subsys/zabbix-proxy -conf= -syscf=zabbix-proxy -[ -e /etc/sysconfig/$syscf ] && . /etc/sysconfig/$syscf +syscf=${0##*/} +lockfile=/var/lock/subsys/$syscf + +[ -f /etc/sysconfig/$syscf ] && . /etc/sysconfig/$syscf + +config=${CFG_FILE:-/etc/zabbix_proxy.conf} +if [ ! -f $config ]; then + echo "Not starting Zabbix proxy: Config file $config not found!" + echo "Check /etc/sysconfig/$syscf" + exit 3 +fi + +pidfile=$(grep -e "^PidFile=.*$" $config | cut -d= -f2) +param="-c $config" start() { echo -n $"Starting Zabbix proxy: " - daemon --user zabbixsrv $exec + daemon --usersrv zabbix --pidfile "$pidfile" $exec $param rv=$? echo [ $rv -eq 0 ] && touch $lockfile @@ -38,7 +47,7 @@ start() stop() { echo -n $"Shutting down Zabbix proxy: " - killproc $prog + killproc -p "$pidfile" $prog rv=$? echo [ $rv -eq 0 ] && rm -f $lockfile @@ -59,10 +68,10 @@ case "$1" in restart ;; status) - status $prog + status -p "$pidfile" -l $prog $exec ;; try-restart|condrestart) - if status $prog >/dev/null ; then + if status -p "$pidfile" -l $prog $exec >/dev/null ; then restart fi ;; diff --git a/zabbix-server.init b/zabbix-server.init index 60990ae..0dd2710 100644 --- a/zabbix-server.init +++ b/zabbix-server.init @@ -2,32 +2,42 @@ # # chkconfig: - 85 15 # description: Zabbix server daemon -# config: /etc/zabbix_server.conf # ### BEGIN INIT INFO -# Provides: zabbix +# Provides: zabbix-server # Required-Start: $local_fs $network # Required-Stop: $local_fs $network # Default-Start: # Default-Stop: 0 1 2 3 4 5 6 # Short-Description: Start and stop Zabbix server -# Description: Zabbix server +# Description: Zabbix server daemon ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions -exec=zabbix_server +exec=/usr/sbin/zabbix_server prog=${exec##*/} -lockfile=/var/lock/subsys/zabbix -syscf=zabbix-server -[ -e /etc/sysconfig/$syscf ] && . /etc/sysconfig/$syscf +syscf=${0##*/} +lockfile=/var/lock/subsys/$syscf + +[ -f /etc/sysconfig/$syscf ] && . /etc/sysconfig/$syscf + +config=${CFG_FILE:-/etc/zabbix_server.conf} +if [ ! -f $config ]; then + echo "Not starting Zabbix server: Config file $config not found!" + echo "Check /etc/sysconfig/$syscf" + exit 3 +fi + +pidfile=$(grep -e "^PidFile=.*$" $config | cut -d= -f2) +param="-c $config" start() { echo -n $"Starting Zabbix server: " - daemon --user zabbixsrv $exec + daemon --user zabbixsrv --pidfile "$pidfile" $exec $param rv=$? echo [ $rv -eq 0 ] && touch $lockfile @@ -37,7 +47,7 @@ start() stop() { echo -n $"Shutting down Zabbix server: " - killproc $prog + killproc -p "$pidfile" $prog rv=$? echo [ $rv -eq 0 ] && rm -f $lockfile @@ -58,10 +68,10 @@ case "$1" in restart ;; status) - status $prog + status -p "$pidfile" -l $prog $exec ;; try-restart|condrestart) - if status $prog >/dev/null ; then + if status -p "$pidfile" -l $prog $exec >/dev/null ; then restart fi ;; diff --git a/zabbix20.spec b/zabbix20.spec index b01a104..2c8d830 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -19,8 +19,8 @@ %global srcname zabbix Name: zabbix20 -Version: 2.0.9 -Release: 2%{?dist} +Version: 2.0.10 +Release: 1%{?dist} Summary: Open-source monitoring solution for your IT infrastructure Group: Applications/Internet @@ -55,9 +55,6 @@ Patch1: %{srcname}-2.0.3-fonts-config.patch Patch2: %{srcname}-2.0.1-no-flash.patch # adapt for fping3 - https://support.zabbix.com/browse/ZBX-4894 Patch3: %{srcname}-1.8.12-fping3.patch -# Fix vulnerability for remote command execution injection CVE-2013-6824 -# https://support.zabbix.com/browse/ZBX-7479 -Patch4: %{srcname}-2.0.9-ZBX-7479.patch BuildRequires: mysql-devel BuildRequires: postgresql-devel @@ -275,7 +272,6 @@ Zabbix web frontend for PostgreSQL %if 0%{?fedora} %patch3 -p1 %endif -%patch4 -p0 # Logrotate's su option is currently only available in Fedora %if 0%{?rhel} @@ -620,7 +616,7 @@ getent passwd zabbixsrv > /dev/null || \ : %preun server -if [ "$1" = 0 ] +if [ $1 -eq 0 ] then %if 0%{?fedora} /bin/systemctl --no-reload disable zabbix-server.service > /dev/null 2>&1 || : @@ -641,8 +637,7 @@ getent passwd zabbixsrv > /dev/null || \ : %preun proxy -#TODO: Use the same style consistently -if [ "$1" = 0 ] +if [ $1 -eq 0 ] then %if 0%{?fedora} /bin/systemctl --no-reload disable zabbix-proxy.service > /dev/null 2>&1 || : @@ -852,6 +847,13 @@ fi %files web-pgsql %changelog +* Fri Dec 13 2013 Volker Fröhlich - 2.0.10-1 +- New upstream release +- Drop obsolete patch ZBX-7479 +- Improve init scripts to not kill other instances (BZ#1018293) +- General overhaul of init scripts and documentation in README +- Harmonize scriptlet if-clause style + * Tue Nov 3 2013 Volker Fröhlich - 2.0.9-2 - Fix vulnerability for remote command execution injection (ZBX-7479, CVE-2013-6824) From 7fe5d55eb9825dd0c5a520093f813ee82aa5be1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Fri, 13 Dec 2013 23:56:37 +0100 Subject: [PATCH 28/42] Upload correct tarball and add a note on proxy/server to README --- .gitignore | 1 + sources | 2 +- zabbix-fedora.README | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c5a83c9..257cb79 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ /zabbix-2.0.8-free.tar.gz /zabbix-2.0.9-free.tar.gz /zabbix-2.0.10.tar.gz +/zabbix-2.0.10-free.tar.gz diff --git a/sources b/sources index 178d2a8..80abb4b 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -49297c0ac61858fd75ab9ea18ca6cdbb zabbix-2.0.10.tar.gz +5bca44bce58b511955ae8cce69497fbd zabbix-2.0.10-free.tar.gz diff --git a/zabbix-fedora.README b/zabbix-fedora.README index 9efb395..172c4d9 100644 --- a/zabbix-fedora.README +++ b/zabbix-fedora.README @@ -86,6 +86,7 @@ If you want to run multiple instances on the same host, do the following: - PidFile - ListenPort and/or ListenIP, if you plan for simultaneous operation - LogFile, if you don't use syslog + - DB settings for server and proxy daemons - Optionally run the following to register as a service and set it to start up: chkconfig --add chkconfig on From d4237cf051079988946d69a3b781d9a057a46b03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Sun, 15 Dec 2013 14:55:26 +0100 Subject: [PATCH 29/42] Fix typo in proxy init script and improve the README - The start function had a typo causing failure - Improved the section on running multiple instances in the README --- zabbix-fedora.README | 11 ++++++++--- zabbix-proxy.init | 2 +- zabbix20.spec | 6 +++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/zabbix-fedora.README b/zabbix-fedora.README index 172c4d9..97d55dc 100644 --- a/zabbix-fedora.README +++ b/zabbix-fedora.README @@ -83,13 +83,18 @@ If you want to run multiple instances on the same host, do the following: - Create a file of the same name as the new init script in /etc/sysconfig - Define CFG_FILE="" in this file - Create the file defined as CFG_FILE and adjust settings; in particular: + - DB settings if you set up multiple instances of server and proxy daemons; + IMPORTANT: Two daemons using the same database at the same time could act + destructive! - PidFile - - ListenPort and/or ListenIP, if you plan for simultaneous operation + - ListenPort and/or ListenIP, if you plan for simultaneous operation; + Don't forget to review your firewall settings! - LogFile, if you don't use syslog - - DB settings for server and proxy daemons -- Optionally run the following to register as a service and set it to start up: +- Optionally run the following to register the new instance as a service and + start it up automatically: chkconfig --add chkconfig on +- service start ==Configuration changes== diff --git a/zabbix-proxy.init b/zabbix-proxy.init index cc1fe9e..e3b2283 100644 --- a/zabbix-proxy.init +++ b/zabbix-proxy.init @@ -37,7 +37,7 @@ param="-c $config" start() { echo -n $"Starting Zabbix proxy: " - daemon --usersrv zabbix --pidfile "$pidfile" $exec $param + daemon --user zabbixsrv --pidfile "$pidfile" $exec $param rv=$? echo [ $rv -eq 0 ] && touch $lockfile diff --git a/zabbix20.spec b/zabbix20.spec index 2c8d830..2ad6365 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -20,7 +20,7 @@ Name: zabbix20 Version: 2.0.10 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Open-source monitoring solution for your IT infrastructure Group: Applications/Internet @@ -847,6 +847,10 @@ fi %files web-pgsql %changelog +* Sun Dec 15 2013 Volker Fröhlich - 2.0.10-2 +- The start function of the proxy init script had a typo causing failure +- Improved the section on running multiple instances in the README + * Fri Dec 13 2013 Volker Fröhlich - 2.0.10-1 - New upstream release - Drop obsolete patch ZBX-7479 From 1230a27d031e1163ef9e19d1b5bfcdb350c1d056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Mon, 3 Feb 2014 08:47:41 +0100 Subject: [PATCH 30/42] To be rebased --- zabbix-fedora.README | 17 ++++++++--------- zabbix20.spec | 42 +++++++++++++++--------------------------- 2 files changed, 23 insertions(+), 36 deletions(-) diff --git a/zabbix-fedora.README b/zabbix-fedora.README index 97d55dc..3a6f35e 100644 --- a/zabbix-fedora.README +++ b/zabbix-fedora.README @@ -9,10 +9,9 @@ server configuration files are changed accordingly from 2.0.8 on. ==Web configuration== -Web configuration resides in /etc/zabbix/web. No need to copy or edit -anything -- just do the configuration by accessing the frontend as soon as your -httpd configuration allows. - +Web configuration resides in /etc/zabbix/web. The configuration file can be +created manually or by walking through the frontend setup tool, as soon as your +httpd configuration allows. The directory also contains maintenance.inc.php! ==Log files== @@ -21,7 +20,7 @@ Log files are located in /var/log/zabbix. ==Where's my Flash watch?== -It's not included in Fedora! Fedora's policy does not allow to include blobs. +It's not included in Fedora! Fedora's policy does not allow to include blobs: https://support.zabbix.com/browse/ZBX-4794 @@ -154,13 +153,15 @@ echo "avc: denied { setpgid } for pid=31880 comm="zabbix_server_p" scontext=s -------------------------------------------------------------------------------- -=Guide for updating to 2.0 from 1.8= +=Guide for upgrading to 2.0 from 1.8= http://www.zabbix.com/documentation/2.0/manual/installation/upgrade==notes The below should be the relevant steps, picked from http://www.zabbix.com/documentation/2.0/manual/installation/upgrade +- Review all rpmnew and rpmsave files; merge where necessary +- Review permissions, ownerships and group memberships for zabbixsrv - Back up the Zabbix database (really!) - Remove custom database changes, if any - Make sure the database user has sufficing permissions @@ -169,7 +170,5 @@ http://www.zabbix.com/documentation/2.0/manual/installation/upgrade - The scripts can run very long, depending on the content of your database and your hardware; - Check the output of the script for errors -- Review all rpmnew and rpmsave files; merge where necessary -- Review permissions, ownerships and group memberships for zabbixsrv -Volker Fröhlich volker27@gmx.at Aug 14 2013 +Volker Fröhlich volker27@gmx.at Jan 3 2013 diff --git a/zabbix20.spec b/zabbix20.spec index 2ad6365..145e4bf 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -5,7 +5,6 @@ # "Include" statement in config files needs patching in order to not load # various backup files (*.rpm{orig,new,save}, *~ etc) in that dir. # https://support.zabbix.com/browse/ZBXNEXT-497 -# * zabbixsrv could be member of the groups zabbixsrv and zabbix # * Consider using systemd's ReadWriteDirectories #TODO: systemctl reload seems to be necessary after switching with Alternatives @@ -226,7 +225,7 @@ Summary: Zabbix Web Frontend Group: Applications/Internet BuildArch: noarch # Don't remove "php". Everything else only depends on php-common -# and you'll end up with no module for Apache +# and you'll end up with no module for Apache! Requires: php Requires: php-gd Requires: php-bcmath @@ -301,30 +300,19 @@ sed -i 's|$(DESTDIR)@datadir@/zabbix|$(DESTDIR)/var/lib/zabbixsrv|' \ src/zabbix_server/Makefile.in \ src/zabbix_proxy/Makefile.in -# All libraries are expected in /usr/lib or /usr/local/lib -# https://support.zabbix.com/browse/ZBXNEXT-1296 -sed -i.orig -e 's|_LIBDIR=/usr/lib|_LIBDIR=%{_libdir}|g' \ - configure - # Kill off .htaccess files, options set in SOURCE1 rm -f frontends/php/include/.htaccess rm -f frontends/php/api/.htaccess rm -f frontends/php/conf/.htaccess # Fix path to traceroute utility -# Probably obsolete after EL 6 +# Still valid for EL7! find database -name 'data.sql' -exec sed -i 's|/usr/bin/traceroute|/bin/traceroute|' {} \; -# Set timestamp on modified config file and directories -touch -r frontends/php/css.css frontends/php/include/config.inc.php \ - frontends/php/include/defines.inc.php \ - frontends/php/include \ - frontends/php/include/classes - # Adapt configuration file options sed -i \ - -e 's|# PidFile=.*|PidFile=%{_localstatedir}/run/%{srcname}/zabbix_agentd.pid|g' \ - -e 's|^LogFile=.*|LogFile=%{_localstatedir}/log/%{srcname}/zabbix_agentd.log|g' \ + -e 's|# PidFile=.*|PidFile=%{_localstatedir}/run/zabbix/zabbix_agentd.pid|g' \ + -e 's|^LogFile=.*|LogFile=%{_localstatedir}/log/zabbix/zabbix_agentd.log|g' \ -e 's|# LogFileSize=.*|LogFileSize=0|g' \ -e 's|/usr/local||g' \ conf/zabbix_agentd.conf @@ -335,8 +323,8 @@ sed -i \ #TODO: It'd be better to leave the defaults in a commment and just override them, as they are still hard-coded! sed -i \ - -e 's|# PidFile=.*|PidFile=%{_localstatedir}/run/%{srcname}/zabbix_server.pid|g' \ - -e 's|^LogFile=.*|LogFile=%{_localstatedir}/log/%{srcname}/zabbix_server.log|g' \ + -e 's|# PidFile=.*|PidFile=%{_localstatedir}/run/zabbix/zabbix_server.pid|g' \ + -e 's|^LogFile=.*|LogFile=%{_localstatedir}/log/zabbix/zabbix_server.log|g' \ -e 's|# LogFileSize=.*|LogFileSize=0|g' \ -e 's|# AlertScriptsPath=${datadir}/zabbix/|AlertScriptsPath=%{_sharedstatedir}/zabbixsrv/|g' \ -e 's|^DBUser=root|DBUser=zabbix|g' \ @@ -347,8 +335,8 @@ sed -i \ conf/zabbix_server.conf sed -i \ - -e 's|# PidFile=.*|PidFile=%{_localstatedir}/run/%{srcname}/zabbix_proxy.pid|g' \ - -e 's|^LogFile=.*|LogFile=%{_localstatedir}/log/%{srcname}/zabbix_proxy.log|g' \ + -e 's|# PidFile=.*|PidFile=%{_localstatedir}/run/zabbix/zabbix_proxy.pid|g' \ + -e 's|^LogFile=.*|LogFile=%{_localstatedir}/log/zabbix/zabbix_proxy.log|g' \ -e 's|# LogFileSize=.*|LogFileSize=0|g' \ -e 's|^DBUser=root|DBUser=zabbix|g' \ -e 's|# DBSocket=/tmp/mysql.sock|DBSocket=%{_sharedstatedir}/mysql/mysql.sock|g' \ @@ -385,7 +373,7 @@ common_flags=" --with-ssh2 " -# Frontend doesn't work for Sqlite, thus don't build server +# Frontend doesn't work for SQLite, thus don't build server %configure $common_flags --with-sqlite3 make %{?_smp_mflags} mv src/zabbix_proxy/zabbix_proxy src/zabbix_proxy/zabbix_proxy_sqlite3 @@ -411,8 +399,8 @@ mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/%{srcname} mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/%{srcname}/web mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/httpd/conf.d -mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/log/%{srcname} -mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/run/%{srcname} +mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/log/zabbix +mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/run/zabbix mkdir -p $RPM_BUILD_ROOT%{_unitdir} %if 0%{?rhel} mkdir -p $RPM_BUILD_ROOT%{_initrddir} @@ -461,7 +449,7 @@ install -m 0644 -p %{SOURCE13} $RPM_BUILD_ROOT%{_unitdir}/zabbix-proxy-sqlite3.s install -m 0644 -p %{SOURCE14} $RPM_BUILD_ROOT%{_unitdir}/zabbix-server-mysql.service install -m 0644 -p %{SOURCE15} $RPM_BUILD_ROOT%{_unitdir}/zabbix-server-pgsql.service %else -# init scripts +# Init scripts install -m 0755 -p %{SOURCE3} $RPM_BUILD_ROOT%{_initrddir}/zabbix-agent install -m 0755 -p %{SOURCE4} $RPM_BUILD_ROOT%{_initrddir}/zabbix-proxy install -m 0755 -p %{SOURCE2} $RPM_BUILD_ROOT%{_initrddir}/zabbix-server @@ -471,7 +459,8 @@ install -m 0755 -p %{SOURCE2} $RPM_BUILD_ROOT%{_initrddir}/zabbix-server touch $RPM_BUILD_ROOT%{_unitdir}/zabbix-server.service touch $RPM_BUILD_ROOT%{_unitdir}/zabbix-proxy.service -# install compatibility links for config files +# Install compatibility links for config files +#TODO: Switch to .wants files instead! ln -sf %{_sysconfdir}/zabbix_agent.conf $RPM_BUILD_ROOT%{_sysconfdir}/%{srcname}/zabbix_agent.conf ln -sf %{_sysconfdir}/zabbix_agentd.conf $RPM_BUILD_ROOT%{_sysconfdir}/%{srcname}/zabbix_agentd.conf ln -sf %{_sysconfdir}/zabbix_server.conf $RPM_BUILD_ROOT%{_sysconfdir}/%{srcname}/zabbix_server.conf @@ -727,7 +716,6 @@ fi %files -#TODO: Arrange get/sender plus agent config differently %doc AUTHORS ChangeLog COPYING NEWS README %{srcname}-fedora.README %dir %{_sysconfdir}/%{srcname} %config(noreplace) %{_sysconfdir}/zabbix_agentd.conf @@ -746,7 +734,7 @@ fi %if 0%{?rhel} %attr(0775,root,zabbix) %dir %{_localstatedir}/run/zabbix %endif -%attr(0400,zabbixsrv,zabbix) %config(noreplace) %{_sysconfdir}/zabbix_server.conf +%attr(0600,zabbixsrv,zabbix) %config(noreplace) %{_sysconfdir}/zabbix_server.conf %config(noreplace) %{_sysconfdir}/%{srcname}/zabbix_server.conf %config(noreplace) %{_sysconfdir}/%{srcname}/externalscripts %config(noreplace) %{_sysconfdir}/%{srcname}/alertscripts From 3f5b071cec195b76e5524718b5911d77c90166b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Wed, 12 Feb 2014 12:01:51 +0100 Subject: [PATCH 31/42] New upstream release 2.0.11 --- .gitignore | 1 + sources | 2 +- zabbix20.spec | 101 ++++---------------------------------------------- 3 files changed, 10 insertions(+), 94 deletions(-) diff --git a/.gitignore b/.gitignore index 257cb79..9474fa5 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ /zabbix-2.0.9-free.tar.gz /zabbix-2.0.10.tar.gz /zabbix-2.0.10-free.tar.gz +/zabbix-2.0.11-free.tar.gz diff --git a/sources b/sources index 80abb4b..9ab4c4c 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -5bca44bce58b511955ae8cce69497fbd zabbix-2.0.10-free.tar.gz +71dbe3737daf554daacb90933d611a07 zabbix-2.0.11-free.tar.gz diff --git a/zabbix20.spec b/zabbix20.spec index 145e4bf..2718d4c 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -18,8 +18,8 @@ %global srcname zabbix Name: zabbix20 -Version: 2.0.10 -Release: 2%{?dist} +Version: 2.0.11 +Release: 1%{?dist} Summary: Open-source monitoring solution for your IT infrastructure Group: Applications/Internet @@ -835,6 +835,10 @@ fi %files web-pgsql %changelog +* Wed Feb 12 2014 Volker Fröhlich - 2.0.11-1 +- New upstream release +- Truncate changelog + * Sun Dec 15 2013 Volker Fröhlich - 2.0.10-2 - The start function of the proxy init script had a typo causing failure - Improved the section on running multiple instances in the README @@ -846,7 +850,7 @@ fi - General overhaul of init scripts and documentation in README - Harmonize scriptlet if-clause style -* Tue Nov 3 2013 Volker Fröhlich - 2.0.9-2 +* Sun Nov 3 2013 Volker Fröhlich - 2.0.9-2 - Fix vulnerability for remote command execution injection (ZBX-7479, CVE-2013-6824) @@ -1091,7 +1095,7 @@ fi * Wed Feb 24 2010 Dan Horák - 1.8.1-6 - use system fonts -* Sun Feb 13 2010 Dan Horák - 1.8.1-5 +* Sat Feb 13 2010 Dan Horák - 1.8.1-5 - fixed linking with the new --no-add-needed default (#564932) * Mon Feb 1 2010 Dan Horák - 1.8.1-4 @@ -1108,92 +1112,3 @@ fi * Tue Jan 26 2010 Dan Horák - 1.8-1 - Update to 1.8 - -* Thu Dec 31 2009 Dan Horák - 1.6.8-1 -- Update to 1.6.8 -- Upstream changelog: http://www.zabbix.com/rn1.6.8.php -- fixes 2 issues from #551331 - -* Wed Nov 25 2009 Dan Horák - 1.6.6-2 -- rebuilt with net-snmp 5.5 - -* Sat Aug 29 2009 Dan Horák - 1.6.6-1 -- Update to 1.6.6 -- Upstream changelog: http://www.zabbix.com/rn1.6.6.php - -* Fri Aug 21 2009 Tomas Mraz - 1.6.5-3 -- rebuilt with new openssl - -* Mon Jul 27 2009 Fedora Release Engineering - 1.6.5-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild - -* Mon Jun 8 2009 Jeffrey C. Ollie - 1.6.5-1 -- Update to 1.6.5, see http://sourceforge.net/mailarchive/message.php?msg_name=4A37A2CA.8050503%40zabbix.com for the full release notes. -- -- It is recommended to create the following indexes in order to speed up -- performance of Zabbix front-end as well as server side (ignore it if the -- indexes already exist): -- -- CREATE UNIQUE INDEX history_log_2 on history_log (itemid,id); -- CREATE UNIQUE INDEX history_text_2 on history_text (itemid,id); -- CREATE INDEX graphs_items_1 on graphs_items (itemid); -- CREATE INDEX graphs_items_2 on graphs_items (graphid); -- CREATE INDEX services_1 on services (triggerid); - -* Mon Jun 8 2009 Ville Skyttä - 1.6.4-4 -- Start agent after and shut down before proxy and server by default. -- Include database schemas also in -proxy-* docs. -- Make buildable on EL-4 (without libcurl, OpenIPMI). -- Reformat description. - -* Fri Apr 17 2009 Ville Skyttä - 1.6.4-3 -- Tighten configuration file permissions. -- Ensure zero exit status from scriptlets. -- Improve init script LSB compliance. -- Restart running services on package upgrades. - -* Thu Apr 9 2009 Dan Horák - 1.6.4-2 -- make the -docs subpackage noarch - -* Thu Apr 9 2009 Dan Horák - 1.6.4-1 -- update to 1.6.4 -- remove the cpustat patch, it was integreated into upstream -- use noarch subpackage for the web interface -- database specific web subpackages conflicts with each other -- use common set of option for the configure macro -- enable IPMI support -- sqlite web subpackage must depend on local sqlite -- reorganize the docs and the sql scripts -- change how the web interface config file is created -- updated scriptlet for adding the zabbix user -- move the documentation in PDF to -docs subpackage -- most of the changes were submitted by Ville Skyttä in #494706 -- Resolves: #489673, #493234, #494706 - -* Mon Mar 9 2009 Jeffrey C. Ollie - 1.6.2-5 -- Update pre patch due to incomplete fix for security problems. - -* Wed Mar 4 2009 Jeffrey C. Ollie - 1.6.2-4 -- Update to a SVN snapshot of the upstream 1.6 branch to fix security - issue (BZ#488501) - -* Wed Feb 25 2009 Fedora Release Engineering - 1.6.2-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild - -* Fri Jan 23 2009 Jeffrey C. Ollie - 1.6.2-2 -- Rebuild for MySQL 5.1.X - -* Fri Jan 16 2009 Jeffrey C. Ollie - 1.6.2-1 -- Update to 1.6.2: http://www.zabbix.com/rn1.6.2.php - -* Thu Dec 4 2008 Jeffrey C. Ollie - 1.6.1-1 -- Fix BZ#474593 by adding a requires. - -* Wed Nov 5 2008 Jeffrey C. Ollie - 1.6.1-1 -- Update to 1.6.1 - -* Tue Sep 30 2008 Jeffrey C. Ollie - 1.6-1.1 -- Bump release because forgot to add some new files. - -* Thu Sep 30 2008 Jeffrey C. Ollie - 1.6-1 -- Update to final 1.6 From 5bdbfe2a32c01031ddbfe141141f6f1096fb9426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Tue, 3 Jun 2014 22:07:39 +0200 Subject: [PATCH 32/42] Handle logrotate directions properly --- zabbix-logrotate.in | 4 ++-- zabbix20.spec | 21 ++++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/zabbix-logrotate.in b/zabbix-logrotate.in index c2f9045..84f86ae 100644 --- a/zabbix-logrotate.in +++ b/zabbix-logrotate.in @@ -3,6 +3,6 @@ monthly notifempty compress - create 0664 zabbix zabbix - su zabbix zabbix + create 0664 USER zabbix + su USER zabbix } diff --git a/zabbix20.spec b/zabbix20.spec index 2718d4c..d411d6c 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -19,7 +19,7 @@ Name: zabbix20 Version: 2.0.11 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Open-source monitoring solution for your IT infrastructure Group: Applications/Internet @@ -272,11 +272,6 @@ Zabbix web frontend for PostgreSQL %patch3 -p1 %endif -# Logrotate's su option is currently only available in Fedora -%if 0%{?rhel} -sed -i '/su zabbix zabbix/d' %{SOURCE5} -%endif - # Remove flash applet # https://support.zabbix.com/browse/ZBX-4794 %patch2 -p1 @@ -433,13 +428,18 @@ mv $RPM_BUILD_ROOT%{_datadir}/%{srcname}/conf/maintenance.inc.php $RPM_BUILD_ROO install -m 0644 -p %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/httpd/conf.d/%{srcname}.conf # Install log rotation -sed -e 's|COMPONENT|agentd|g' %{SOURCE5} > \ +sed -e 's|COMPONENT|agentd|g; s|USER|zabbix|g' %{SOURCE5} > \ $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/zabbix-agent -sed -e 's|COMPONENT|server|g' %{SOURCE5} > \ +sed -e 's|COMPONENT|server|g; s|USER|zabbixsrv|g' %{SOURCE5} > \ $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/zabbix-server -sed -e 's|COMPONENT|proxy|g' %{SOURCE5} > \ +sed -e 's|COMPONENT|proxy|g; s|USER|zabbixsrv|g' %{SOURCE5} > \ $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/zabbix-proxy +# Logrotate's su option is only available in Fedora and EL 7 +%if 0%{?rhel} +sed -i '/su USER zabbix/d' $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/zabbix-* +%endif + %if 0%{?fedora} # Install different systemd units because of the requirements for DBMS daemons install -m 0644 -p %{SOURCE10} $RPM_BUILD_ROOT%{_unitdir}/zabbix-agent.service @@ -835,6 +835,9 @@ fi %files web-pgsql %changelog +* Tue Jun 3 2014 Volker Fröhlich - 2.0.11-2 +- Handle su directive in logrotate configuration properly (BZ1074318) + * Wed Feb 12 2014 Volker Fröhlich - 2.0.11-1 - New upstream release - Truncate changelog From 4e87216a71b2b4d1ccf8498dcfa3014f3e295b74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Tue, 3 Jun 2014 19:41:42 +0200 Subject: [PATCH 33/42] New upstream release 2.0.12 and patch for ZBX-8238 - ZBX-8238 (logrt may continue reading an old file repeatedly) --- .gitignore | 1 + sources | 2 +- zabbix-2.0.12-zbx8238.patch | 24 ++++++++++++++++++++++++ zabbix20.spec | 12 ++++++++++-- 4 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 zabbix-2.0.12-zbx8238.patch diff --git a/.gitignore b/.gitignore index 9474fa5..8befb92 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ /zabbix-2.0.10.tar.gz /zabbix-2.0.10-free.tar.gz /zabbix-2.0.11-free.tar.gz +/zabbix-2.0.12-free.tar.gz diff --git a/sources b/sources index 9ab4c4c..b9ea480 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -71dbe3737daf554daacb90933d611a07 zabbix-2.0.11-free.tar.gz +8d497bc9eca83d59ba5633645b86584e zabbix-2.0.12-free.tar.gz diff --git a/zabbix-2.0.12-zbx8238.patch b/zabbix-2.0.12-zbx8238.patch new file mode 100644 index 0000000..45eedfa --- /dev/null +++ b/zabbix-2.0.12-zbx8238.patch @@ -0,0 +1,24 @@ +diff -Nur zabbix-2.0.12/src/zabbix_agent/logfiles.c zabbix-2.0.12-logrt/src/zabbix_agent/logfiles.c +--- zabbix-2.0.12/src/zabbix_agent/logfiles.c 2014-05-13 10:37:44.000000000 +0200 ++++ zabbix-2.0.12-logrt/src/zabbix_agent/logfiles.c 2014-06-03 16:40:27.165576906 +0200 +@@ -654,6 +654,9 @@ + goto out; + } + ++ if (NULL != mtime) ++ *mtime = (int)buf.st_mtime; ++ + if ((zbx_uint64_t)buf.st_size == *lastlogsize) + { + /* The file size has not changed. Nothing to do. Here we do not deal with a case of changing */ +@@ -685,9 +688,6 @@ + *lastlogsize = l_size; + *skip_old_data = 0; + +- if (NULL != mtime) +- *mtime = (int)buf.st_mtime; +- + ret = zbx_read2(f, lastlogsize, mtime, big_rec, encoding, regexps, regexps_num, pattern, p_count, + s_count, process_value, server, port, hostname, key); + } +Binärdateien zabbix-2.0.12/src/zabbix_agent/.logfiles.c.swp und zabbix-2.0.12-logrt/src/zabbix_agent/.logfiles.c.swp sind verschieden. diff --git a/zabbix20.spec b/zabbix20.spec index d411d6c..e9effe1 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -18,8 +18,8 @@ %global srcname zabbix Name: zabbix20 -Version: 2.0.11 -Release: 2%{?dist} +Version: 2.0.12 +Release: 1%{?dist} Summary: Open-source monitoring solution for your IT infrastructure Group: Applications/Internet @@ -54,6 +54,8 @@ Patch1: %{srcname}-2.0.3-fonts-config.patch Patch2: %{srcname}-2.0.1-no-flash.patch # adapt for fping3 - https://support.zabbix.com/browse/ZBX-4894 Patch3: %{srcname}-1.8.12-fping3.patch +# logrt may continue reading an old file repeatedly. +Patch4: %{srcname}-2.0.12-zbx8238.patch BuildRequires: mysql-devel BuildRequires: postgresql-devel @@ -277,6 +279,8 @@ Zabbix web frontend for PostgreSQL %patch2 -p1 rm -f frontends/php/images/flash/zbxclock.swf +%patch4 -p1 + # Remove bundled java libs rm -rf src/zabbix_java/lib/*.jar @@ -835,6 +839,10 @@ fi %files web-pgsql %changelog +* Tue Jun 3 2014 Volker Fröhlich - 2.0.12-1 +- New upstream release +- Patch for ZBX-8238 (logrt may continue reading an old file repeatedly) + * Tue Jun 3 2014 Volker Fröhlich - 2.0.11-2 - Handle su directive in logrotate configuration properly (BZ1074318) From 6a1cac2ea7469ec8f17e8fcaebf3156daf858468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Fri, 20 Jun 2014 08:34:46 +0200 Subject: [PATCH 34/42] Add patch for zbx-8158 (CVE-2014-3005) --- zabbix-2.0.12-zbx8151.patch | 53 +++++++++++++++++++++++++++++++++++++ zabbix20.spec | 9 ++++++- 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 zabbix-2.0.12-zbx8151.patch diff --git a/zabbix-2.0.12-zbx8151.patch b/zabbix-2.0.12-zbx8151.patch new file mode 100644 index 0000000..1ce2bac --- /dev/null +++ b/zabbix-2.0.12-zbx8151.patch @@ -0,0 +1,53 @@ +Index: frontends/php/include/defines.inc.php +=================================================================== +--- frontends/php/include/defines.inc.php (Revision 46596) ++++ frontends/php/include/defines.inc.php (Revision 46655) +@@ -835,6 +835,14 @@ + + define('ZBX_DEFAULT_IMPORT_HOST_GROUP', 'Imported hosts'); + ++// XML import flags ++// See ZBX-8151. Old version of libxml suffered from setting DTDLOAD and NOENT flags by default, which allowed ++// performing XXE attacks. Calling libxml_disable_entity_loader(true) also had no affect if flags passed to libxml ++// calls were 0 - so for better security with legacy libxml we need to call libxml_disable_entity_loader(true) AND ++// pass the LIBXML_NONET flag. Please keep in mind that LIBXML_NOENT actually EXPANDS entities, opposite to it's name - ++// so this flag is not needed here. ++define('LIBXML_IMPORT_FLAGS', LIBXML_NONET); ++ + // API errors + define('ZBX_API_ERROR_INTERNAL', 111); + define('ZBX_API_ERROR_PARAMETERS', 100); +Index: frontends/php/include/classes/import/readers/CXmlImportReader.php +=================================================================== +--- frontends/php/include/classes/import/readers/CXmlImportReader.php (Revision 46596) ++++ frontends/php/include/classes/import/readers/CXmlImportReader.php (Revision 46655) +@@ -32,7 +32,8 @@ + */ + public function read($string) { + libxml_use_internal_errors(true); +- $result = simplexml_load_string($string); ++ libxml_disable_entity_loader(true); ++ $result = simplexml_load_string($string, null, LIBXML_IMPORT_FLAGS); + if (!$result) { + $errors = libxml_get_errors(); + libxml_clear_errors(); +Index: frontends/php/include/classes/import/CXmlImport18.php +=================================================================== +--- frontends/php/include/classes/import/CXmlImport18.php (Revision 46596) ++++ frontends/php/include/classes/import/CXmlImport18.php (Revision 46655) +@@ -390,12 +390,13 @@ + return $array; + } + +- public static function import($file) { ++ public static function import($source) { + + libxml_use_internal_errors(true); ++ libxml_disable_entity_loader(true); + + $xml = new DOMDocument(); +- if (!$xml->loadXML($file)) { ++ if (!$xml->loadXML($source, LIBXML_IMPORT_FLAGS)) { + $text = ''; + foreach (libxml_get_errors() as $error) { + switch ($error->level) { diff --git a/zabbix20.spec b/zabbix20.spec index e9effe1..0300238 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -19,7 +19,7 @@ Name: zabbix20 Version: 2.0.12 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Open-source monitoring solution for your IT infrastructure Group: Applications/Internet @@ -56,6 +56,9 @@ Patch2: %{srcname}-2.0.1-no-flash.patch Patch3: %{srcname}-1.8.12-fping3.patch # logrt may continue reading an old file repeatedly. Patch4: %{srcname}-2.0.12-zbx8238.patch +# Local file inclusion via XXE attack (CVE-2014-3005) +# https://support.zabbix.com/browse/ZBX-8151 +Patch5: %{srcname}-2.0.12-zbx8151.patch BuildRequires: mysql-devel BuildRequires: postgresql-devel @@ -280,6 +283,7 @@ Zabbix web frontend for PostgreSQL rm -f frontends/php/images/flash/zbxclock.swf %patch4 -p1 +%patch5 -p0 # Remove bundled java libs rm -rf src/zabbix_java/lib/*.jar @@ -839,6 +843,9 @@ fi %files web-pgsql %changelog +* Fri Jun 20 2014 Volker Fröhlich - 2.0.12-2 +- Patch for ZBX-8151 (Local file inclusion via XXE attack) -- CVE-2014-3005 + * Tue Jun 3 2014 Volker Fröhlich - 2.0.12-1 - New upstream release - Patch for ZBX-8238 (logrt may continue reading an old file repeatedly) From fe5ba0f154c2d37405461f5eea8304f1b55239c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Thu, 11 Sep 2014 17:48:42 +0200 Subject: [PATCH 35/42] New upstream release, /var/run ownership - Use the upstream tarball, now that non-free json was replaced with android-json - Clean between builds, otherwise zabbix_{proxy,server} are compiled again on install; make server and proxy package noarch now - Harmonize package descriptions and summaries - Sort out /var/run ownership issue when only installing the agent --- .gitignore | 1 + sources | 2 +- zabbix-2.0.12-zbx8151.patch | 53 ------------------------------------- zabbix-2.0.12-zbx8238.patch | 24 ----------------- zabbix20.spec | 42 +++++++++++++++++------------ 5 files changed, 27 insertions(+), 95 deletions(-) delete mode 100644 zabbix-2.0.12-zbx8151.patch delete mode 100644 zabbix-2.0.12-zbx8238.patch diff --git a/.gitignore b/.gitignore index 8befb92..61c2654 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ /zabbix-2.0.10-free.tar.gz /zabbix-2.0.11-free.tar.gz /zabbix-2.0.12-free.tar.gz +/zabbix-2.0.13.tar.gz diff --git a/sources b/sources index b9ea480..821c330 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -8d497bc9eca83d59ba5633645b86584e zabbix-2.0.12-free.tar.gz +538e973109c36aaa8c1f2bc7925fb1c4 zabbix-2.0.13.tar.gz diff --git a/zabbix-2.0.12-zbx8151.patch b/zabbix-2.0.12-zbx8151.patch deleted file mode 100644 index 1ce2bac..0000000 --- a/zabbix-2.0.12-zbx8151.patch +++ /dev/null @@ -1,53 +0,0 @@ -Index: frontends/php/include/defines.inc.php -=================================================================== ---- frontends/php/include/defines.inc.php (Revision 46596) -+++ frontends/php/include/defines.inc.php (Revision 46655) -@@ -835,6 +835,14 @@ - - define('ZBX_DEFAULT_IMPORT_HOST_GROUP', 'Imported hosts'); - -+// XML import flags -+// See ZBX-8151. Old version of libxml suffered from setting DTDLOAD and NOENT flags by default, which allowed -+// performing XXE attacks. Calling libxml_disable_entity_loader(true) also had no affect if flags passed to libxml -+// calls were 0 - so for better security with legacy libxml we need to call libxml_disable_entity_loader(true) AND -+// pass the LIBXML_NONET flag. Please keep in mind that LIBXML_NOENT actually EXPANDS entities, opposite to it's name - -+// so this flag is not needed here. -+define('LIBXML_IMPORT_FLAGS', LIBXML_NONET); -+ - // API errors - define('ZBX_API_ERROR_INTERNAL', 111); - define('ZBX_API_ERROR_PARAMETERS', 100); -Index: frontends/php/include/classes/import/readers/CXmlImportReader.php -=================================================================== ---- frontends/php/include/classes/import/readers/CXmlImportReader.php (Revision 46596) -+++ frontends/php/include/classes/import/readers/CXmlImportReader.php (Revision 46655) -@@ -32,7 +32,8 @@ - */ - public function read($string) { - libxml_use_internal_errors(true); -- $result = simplexml_load_string($string); -+ libxml_disable_entity_loader(true); -+ $result = simplexml_load_string($string, null, LIBXML_IMPORT_FLAGS); - if (!$result) { - $errors = libxml_get_errors(); - libxml_clear_errors(); -Index: frontends/php/include/classes/import/CXmlImport18.php -=================================================================== ---- frontends/php/include/classes/import/CXmlImport18.php (Revision 46596) -+++ frontends/php/include/classes/import/CXmlImport18.php (Revision 46655) -@@ -390,12 +390,13 @@ - return $array; - } - -- public static function import($file) { -+ public static function import($source) { - - libxml_use_internal_errors(true); -+ libxml_disable_entity_loader(true); - - $xml = new DOMDocument(); -- if (!$xml->loadXML($file)) { -+ if (!$xml->loadXML($source, LIBXML_IMPORT_FLAGS)) { - $text = ''; - foreach (libxml_get_errors() as $error) { - switch ($error->level) { diff --git a/zabbix-2.0.12-zbx8238.patch b/zabbix-2.0.12-zbx8238.patch deleted file mode 100644 index 45eedfa..0000000 --- a/zabbix-2.0.12-zbx8238.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff -Nur zabbix-2.0.12/src/zabbix_agent/logfiles.c zabbix-2.0.12-logrt/src/zabbix_agent/logfiles.c ---- zabbix-2.0.12/src/zabbix_agent/logfiles.c 2014-05-13 10:37:44.000000000 +0200 -+++ zabbix-2.0.12-logrt/src/zabbix_agent/logfiles.c 2014-06-03 16:40:27.165576906 +0200 -@@ -654,6 +654,9 @@ - goto out; - } - -+ if (NULL != mtime) -+ *mtime = (int)buf.st_mtime; -+ - if ((zbx_uint64_t)buf.st_size == *lastlogsize) - { - /* The file size has not changed. Nothing to do. Here we do not deal with a case of changing */ -@@ -685,9 +688,6 @@ - *lastlogsize = l_size; - *skip_old_data = 0; - -- if (NULL != mtime) -- *mtime = (int)buf.st_mtime; -- - ret = zbx_read2(f, lastlogsize, mtime, big_rec, encoding, regexps, regexps_num, pattern, p_count, - s_count, process_value, server, port, hostname, key); - } -Binärdateien zabbix-2.0.12/src/zabbix_agent/.logfiles.c.swp und zabbix-2.0.12-logrt/src/zabbix_agent/.logfiles.c.swp sind verschieden. diff --git a/zabbix20.spec b/zabbix20.spec index 0300238..202a72a 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -18,16 +18,14 @@ %global srcname zabbix Name: zabbix20 -Version: 2.0.12 -Release: 2%{?dist} +Version: 2.0.13 +Release: 1%{?dist} Summary: Open-source monitoring solution for your IT infrastructure Group: Applications/Internet License: GPLv2+ URL: http://www.zabbix.com -#Source0: http://downloads.sourceforge.net/%{srcname}/%{srcname}-%{version}.tar.gz -# upstream tarball minus src/zabbix_java/lib/org-json-2010-12-28.jar -Source0: %{srcname}-%{version}-free.tar.gz +Source0: http://downloads.sourceforge.net/%{srcname}/%{srcname}-%{version}.tar.gz Source1: %{srcname}-web.conf Source2: %{srcname}-server.init Source3: %{srcname}-agent.init @@ -54,11 +52,6 @@ Patch1: %{srcname}-2.0.3-fonts-config.patch Patch2: %{srcname}-2.0.1-no-flash.patch # adapt for fping3 - https://support.zabbix.com/browse/ZBX-4894 Patch3: %{srcname}-1.8.12-fping3.patch -# logrt may continue reading an old file repeatedly. -Patch4: %{srcname}-2.0.12-zbx8238.patch -# Local file inclusion via XXE attack (CVE-2014-3005) -# https://support.zabbix.com/browse/ZBX-8151 -Patch5: %{srcname}-2.0.12-zbx8151.patch BuildRequires: mysql-devel BuildRequires: postgresql-devel @@ -104,6 +97,7 @@ multitude of servers. %package server Summary: Zabbix server common files Group: Applications/Internet +BuildArch: noarch Requires: %{name} = %{version}-%{release} Requires: %{name}-server-implementation = %{version}-%{release} Requires: fping @@ -150,7 +144,7 @@ Provides: %{name}-server-implementation = %{version}-%{release} Zabbix server compiled to use PostgresSQL %package agent -Summary: Zabbix Agent +Summary: Zabbix agent Group: Applications/Internet Requires: %{name} = %{version}-%{release} Requires(pre): shadow-utils @@ -166,11 +160,12 @@ Requires(postun): /sbin/service %endif %description agent -The Zabbix client agent, to be installed on monitored systems. +Zabbix agent, to be installed on monitored systems %package proxy -Summary: Zabbix Proxy +Summary: Zabbix proxy common files Group: Applications/Internet +BuildArch: noarch Requires: %{name} = %{version}-%{release} Requires: %{name}-proxy-implementation = %{version}-%{release} Requires(pre): shadow-utils @@ -282,9 +277,6 @@ Zabbix web frontend for PostgreSQL %patch2 -p1 rm -f frontends/php/images/flash/zbxclock.swf -%patch4 -p1 -%patch5 -p0 - # Remove bundled java libs rm -rf src/zabbix_java/lib/*.jar @@ -382,11 +374,13 @@ make %{?_smp_mflags} mv src/zabbix_proxy/zabbix_proxy src/zabbix_proxy/zabbix_proxy_sqlite3 %configure $common_flags --with-mysql --enable-server +make clean make %{?_smp_mflags} mv src/zabbix_server/zabbix_server src/zabbix_server/zabbix_server_mysql mv src/zabbix_proxy/zabbix_proxy src/zabbix_proxy/zabbix_proxy_mysql %configure $common_flags --with-postgresql --enable-server +make clean make %{?_smp_mflags} mv src/zabbix_server/zabbix_server src/zabbix_server/zabbix_server_pgsql mv src/zabbix_proxy/zabbix_proxy src/zabbix_proxy/zabbix_proxy_pgsql @@ -606,7 +600,10 @@ if [ $1 -eq 1 ] ; then fi %pre server -getent group zabbix > /dev/null || groupadd -r zabbix +etent group zabbix > /dev/null || groupadd -r zabbix +getent passwd zabbix > /dev/null || \ + useradd -r -g zabbix -d %{_sharedstatedir}/zabbix -s /sbin/nologin \ + -c "Zabbix Monitoring System" zabbix getent passwd zabbixsrv > /dev/null || \ useradd -r -g zabbix -d %{_sharedstatedir}/zabbixsrv -s /sbin/nologin \ -c "Zabbix Monitoring System -- Proxy or server" zabbixsrv @@ -628,6 +625,9 @@ fi #TODO: Update path from 1.8.6 with wrongly set home dir? %pre proxy getent group zabbix > /dev/null || groupadd -r zabbix +getent passwd zabbix > /dev/null || \ + useradd -r -g zabbix -d %{_sharedstatedir}/zabbix -s /sbin/nologin \ + -c "Zabbix Monitoring System" zabbix getent passwd zabbixsrv > /dev/null || \ useradd -r -g zabbix -d %{_sharedstatedir}/zabbixsrv -s /sbin/nologin \ -c "Zabbix Monitoring System -- Proxy or server" zabbixsrv @@ -843,6 +843,14 @@ fi %files web-pgsql %changelog +* Thu Sep 11 2014 Volker Fröhlich - 2.0.13-1 +- New upstream release; Remove obsolete patches for ZBX-8151 and ZBX-8238 +- Use the upstream tarball, now that non-free json was replaced with android-json +- Clean between builds, otherwise zabbix_{proxy,server} are compiled + again on install; make server and proxy package noarch now +- Harmonize package descriptions and summaries +- Sort out /var/run ownership issue when only installing the agent + * Fri Jun 20 2014 Volker Fröhlich - 2.0.12-2 - Patch for ZBX-8151 (Local file inclusion via XXE attack) -- CVE-2014-3005 From 37c271864e4858382eee84205cdd8d0258fda6a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Thu, 25 Sep 2014 19:59:11 +0200 Subject: [PATCH 36/42] Correct typo in getent in scriplet --- zabbix20.spec | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/zabbix20.spec b/zabbix20.spec index 202a72a..89a673d 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -19,7 +19,7 @@ Name: zabbix20 Version: 2.0.13 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Open-source monitoring solution for your IT infrastructure Group: Applications/Internet @@ -600,7 +600,7 @@ if [ $1 -eq 1 ] ; then fi %pre server -etent group zabbix > /dev/null || groupadd -r zabbix +getent group zabbix > /dev/null || groupadd -r zabbix getent passwd zabbix > /dev/null || \ useradd -r -g zabbix -d %{_sharedstatedir}/zabbix -s /sbin/nologin \ -c "Zabbix Monitoring System" zabbix @@ -843,6 +843,9 @@ fi %files web-pgsql %changelog +* Thu Sep 25 2014 Volker Fröhlich - 2.0.13-2 +- Correct typo "etent" --> "getent" + * Thu Sep 11 2014 Volker Fröhlich - 2.0.13-1 - New upstream release; Remove obsolete patches for ZBX-8151 and ZBX-8238 - Use the upstream tarball, now that non-free json was replaced with android-json From aafbb6086762982e6c41e4beeb1ed44e309344c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Wed, 12 Aug 2015 00:40:34 +0200 Subject: [PATCH 37/42] New version 2.0.15 - Remove su instruction from logrotate config file (BZ 1202602, 1251728) --- .gitignore | 1 + sources | 2 +- zabbix-logrotate.in | 1 - zabbix20.spec | 9 +++++++-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 61c2654..f9bbf43 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ /zabbix-2.0.11-free.tar.gz /zabbix-2.0.12-free.tar.gz /zabbix-2.0.13.tar.gz +/zabbix-2.0.15.tar.gz diff --git a/sources b/sources index 821c330..204a38d 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -538e973109c36aaa8c1f2bc7925fb1c4 zabbix-2.0.13.tar.gz +b54893d89f2a4129124644c8a16bfae5 zabbix-2.0.15.tar.gz diff --git a/zabbix-logrotate.in b/zabbix-logrotate.in index 84f86ae..ce6a26b 100644 --- a/zabbix-logrotate.in +++ b/zabbix-logrotate.in @@ -4,5 +4,4 @@ notifempty compress create 0664 USER zabbix - su USER zabbix } diff --git a/zabbix20.spec b/zabbix20.spec index 89a673d..aee7086 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -18,8 +18,8 @@ %global srcname zabbix Name: zabbix20 -Version: 2.0.13 -Release: 2%{?dist} +Version: 2.0.15 +Release: 1%{?dist} Summary: Open-source monitoring solution for your IT infrastructure Group: Applications/Internet @@ -843,6 +843,11 @@ fi %files web-pgsql %changelog +* Tue Aug 11 2015 Volker Fröhlich - 2.0.15-1 +- New upstream release +- Remove su instruction from logrotate config file (BZ 1202602, 1251728) + + * Thu Sep 25 2014 Volker Fröhlich - 2.0.13-2 - Correct typo "etent" --> "getent" From dca20f68b7662a7ca4534464b45b8ed77a87bd8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Thu, 12 Nov 2015 23:11:17 +0100 Subject: [PATCH 38/42] New version 2.0.16 --- .gitignore | 1 + sources | 2 +- zabbix20.spec | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index f9bbf43..6650c7a 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ /zabbix-2.0.12-free.tar.gz /zabbix-2.0.13.tar.gz /zabbix-2.0.15.tar.gz +/zabbix-2.0.16.tar.gz diff --git a/sources b/sources index 204a38d..e7dca94 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -b54893d89f2a4129124644c8a16bfae5 zabbix-2.0.15.tar.gz +1fec38a1fa72b5548a5875ac04c2294d zabbix-2.0.16.tar.gz diff --git a/zabbix20.spec b/zabbix20.spec index aee7086..4d042b3 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -18,7 +18,7 @@ %global srcname zabbix Name: zabbix20 -Version: 2.0.15 +Version: 2.0.16 Release: 1%{?dist} Summary: Open-source monitoring solution for your IT infrastructure @@ -843,6 +843,9 @@ fi %files web-pgsql %changelog +* Thu Nov 12 2015 Volker Fröhlich - 2.0.16-1 +- New upstream release + * Tue Aug 11 2015 Volker Fröhlich - 2.0.15-1 - New upstream release - Remove su instruction from logrotate config file (BZ 1202602, 1251728) From f6c9a8f19e626facd9000c26c42aeef0c4559c5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Sun, 9 Oct 2016 11:20:21 +0200 Subject: [PATCH 39/42] New version 2.0.19 --- .gitignore | 1 + sources | 2 +- zabbix20.spec | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 6650c7a..8010f91 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ /zabbix-2.0.13.tar.gz /zabbix-2.0.15.tar.gz /zabbix-2.0.16.tar.gz +/zabbix-2.0.19.tar.gz diff --git a/sources b/sources index e7dca94..2975327 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -1fec38a1fa72b5548a5875ac04c2294d zabbix-2.0.16.tar.gz +e0f6cfa9c1749be48fc7587f549e6904 zabbix-2.0.19.tar.gz diff --git a/zabbix20.spec b/zabbix20.spec index 4d042b3..b235e50 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -18,7 +18,7 @@ %global srcname zabbix Name: zabbix20 -Version: 2.0.16 +Version: 2.0.19 Release: 1%{?dist} Summary: Open-source monitoring solution for your IT infrastructure @@ -843,6 +843,9 @@ fi %files web-pgsql %changelog +* Sun Oct 09 2016 Volker Fröhlich - 2.0.19-1 +- New upstream release + * Thu Nov 12 2015 Volker Fröhlich - 2.0.16-1 - New upstream release From 85fb92f6a6123b6d05a01e355c60165dfce97f2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Sun, 11 Dec 2016 13:16:14 +0100 Subject: [PATCH 40/42] New version 2.0.20 --- .gitignore | 1 + sources | 2 +- zabbix20.spec | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 8010f91..4a9b9c3 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ /zabbix-2.0.15.tar.gz /zabbix-2.0.16.tar.gz /zabbix-2.0.19.tar.gz +/zabbix-2.0.20.tar.gz diff --git a/sources b/sources index 2975327..bddb320 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -e0f6cfa9c1749be48fc7587f549e6904 zabbix-2.0.19.tar.gz +2e5040ff48f3517956ee78c344ff83eb zabbix-2.0.20.tar.gz diff --git a/zabbix20.spec b/zabbix20.spec index b235e50..6c8cbe6 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -18,7 +18,7 @@ %global srcname zabbix Name: zabbix20 -Version: 2.0.19 +Version: 2.0.20 Release: 1%{?dist} Summary: Open-source monitoring solution for your IT infrastructure @@ -843,6 +843,9 @@ fi %files web-pgsql %changelog +* Sun Dec 11 2016 Volker Fröhlich - 2.0.20-1 +- New upstream release + * Sun Oct 09 2016 Volker Fröhlich - 2.0.19-1 - New upstream release From c7ccc76572625955ea68f963dda43fd8a14c9d6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Fri, 23 Jun 2017 22:42:03 +0200 Subject: [PATCH 41/42] New and final version of the 2.0 series: 2.0.21 http://www.zabbix.com/life_cycle_and_release_policy --- .gitignore | 1 + sources | 2 +- zabbix20.spec | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 4a9b9c3..d23b0a7 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ /zabbix-2.0.16.tar.gz /zabbix-2.0.19.tar.gz /zabbix-2.0.20.tar.gz +/zabbix-2.0.21.tar.gz diff --git a/sources b/sources index bddb320..0371759 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -2e5040ff48f3517956ee78c344ff83eb zabbix-2.0.20.tar.gz +SHA512 (zabbix-2.0.21.tar.gz) = 566f9ea6e6a4ed51941a0858311ded43b2d68d68a6a2a2a61824413008e0806df1b9747365df29b652a530be8e1cd68405bb7c65e86197ebe778bd4608127754 diff --git a/zabbix20.spec b/zabbix20.spec index 6c8cbe6..e54f99b 100644 --- a/zabbix20.spec +++ b/zabbix20.spec @@ -18,7 +18,7 @@ %global srcname zabbix Name: zabbix20 -Version: 2.0.20 +Version: 2.0.21 Release: 1%{?dist} Summary: Open-source monitoring solution for your IT infrastructure @@ -843,6 +843,9 @@ fi %files web-pgsql %changelog +* Fri Jun 23 2017 Volker Fröhlich - 2.0.21-1 +- New upstream release + * Sun Dec 11 2016 Volker Fröhlich - 2.0.20-1 - New upstream release From 7864f135fa1b650b3e2f29a41b93e77041830b6d Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Wed, 31 Oct 2018 15:18:25 -0600 Subject: [PATCH 42/42] 2.0 is out of support and has broken deps, move to 2.2 --- .gitignore | 20 - dead.package | 1 + sources | 1 - zabbix-1.8.12-fping3.patch | 39 -- zabbix-2.0.1-no-flash.patch | 11 - zabbix-2.0.2-config.patch | 22 - zabbix-2.0.3-fonts-config.patch | 12 - zabbix-agent.init | 89 --- zabbix-agent.service | 12 - zabbix-fedora.README | 174 ----- zabbix-logrotate.in | 7 - zabbix-proxy-mysql.service | 12 - zabbix-proxy-pgsql.service | 12 - zabbix-proxy-sqlite3.service | 12 - zabbix-proxy.init | 87 --- zabbix-server-mysql.service | 12 - zabbix-server-pgsql.service | 12 - zabbix-server.init | 87 --- zabbix-tmpfiles.conf | 1 - zabbix-web.conf | 48 -- zabbix20.spec | 1160 ------------------------------- 21 files changed, 1 insertion(+), 1830 deletions(-) delete mode 100644 .gitignore create mode 100644 dead.package delete mode 100644 sources delete mode 100644 zabbix-1.8.12-fping3.patch delete mode 100644 zabbix-2.0.1-no-flash.patch delete mode 100644 zabbix-2.0.2-config.patch delete mode 100644 zabbix-2.0.3-fonts-config.patch delete mode 100644 zabbix-agent.init delete mode 100644 zabbix-agent.service delete mode 100644 zabbix-fedora.README delete mode 100644 zabbix-logrotate.in delete mode 100644 zabbix-proxy-mysql.service delete mode 100644 zabbix-proxy-pgsql.service delete mode 100644 zabbix-proxy-sqlite3.service delete mode 100644 zabbix-proxy.init delete mode 100644 zabbix-server-mysql.service delete mode 100644 zabbix-server-pgsql.service delete mode 100644 zabbix-server.init delete mode 100644 zabbix-tmpfiles.conf delete mode 100644 zabbix-web.conf delete mode 100644 zabbix20.spec diff --git a/.gitignore b/.gitignore deleted file mode 100644 index d23b0a7..0000000 --- a/.gitignore +++ /dev/null @@ -1,20 +0,0 @@ -/zabbix-2.0.3-free.tar.gz -/zabbix-2.0.4.tar.gz -/zabbix-2.0.4-free.tar.gz -/zabbix-2.0.5.tar.gz -/zabbix-2.0.5-free.tar.gz -/zabbix-2.0.6-free.tar.gz -/zabbix-2.0.7-free.tar.gz -/zabbix-2.0.8.tar.gz -/zabbix-2.0.8-free.tar.gz -/zabbix-2.0.9-free.tar.gz -/zabbix-2.0.10.tar.gz -/zabbix-2.0.10-free.tar.gz -/zabbix-2.0.11-free.tar.gz -/zabbix-2.0.12-free.tar.gz -/zabbix-2.0.13.tar.gz -/zabbix-2.0.15.tar.gz -/zabbix-2.0.16.tar.gz -/zabbix-2.0.19.tar.gz -/zabbix-2.0.20.tar.gz -/zabbix-2.0.21.tar.gz diff --git a/dead.package b/dead.package new file mode 100644 index 0000000..e4f7227 --- /dev/null +++ b/dead.package @@ -0,0 +1 @@ +2.0 is out of support and has broken deps, move to 2.2 diff --git a/sources b/sources deleted file mode 100644 index 0371759..0000000 --- a/sources +++ /dev/null @@ -1 +0,0 @@ -SHA512 (zabbix-2.0.21.tar.gz) = 566f9ea6e6a4ed51941a0858311ded43b2d68d68a6a2a2a61824413008e0806df1b9747365df29b652a530be8e1cd68405bb7c65e86197ebe778bd4608127754 diff --git a/zabbix-1.8.12-fping3.patch b/zabbix-1.8.12-fping3.patch deleted file mode 100644 index db8c456..0000000 --- a/zabbix-1.8.12-fping3.patch +++ /dev/null @@ -1,39 +0,0 @@ -diff -up zabbix-1.8.12/src/libs/zbxicmpping/icmpping.c.fping3 zabbix-1.8.12/src/libs/zbxicmpping/icmpping.c ---- zabbix-1.8.12/src/libs/zbxicmpping/icmpping.c.fping3 2012-04-24 16:31:36.000000000 +0200 -+++ zabbix-1.8.12/src/libs/zbxicmpping/icmpping.c 2012-04-24 16:32:31.000000000 +0200 -@@ -42,34 +42,7 @@ static const char *source_ip6_option = N - - static void get_source_ip_option(const char *fping, const char **option, unsigned char *checked) - { -- FILE *f; -- char *p, tmp[MAX_STRING_LEN]; -- -- zbx_snprintf(tmp, sizeof(tmp), "%s -h 2>&1", fping); -- -- if (NULL == (f = popen(tmp, "r"))) -- return; -- -- while (NULL != fgets(tmp, sizeof(tmp), f)) -- { -- for (p = tmp; isspace(*p); p++) -- ; -- -- if ('-' == p[0] && 'I' == p[1] && isspace(p[2])) -- { -- *option = "-I"; -- break; -- } -- -- if ('-' == p[0] && 'S' == p[1] && isspace(p[2])) -- { -- *option = "-S"; -- break; -- } -- } -- -- pclose(f); -- -+ *option = "-S"; - *checked = 1; - } - diff --git a/zabbix-2.0.1-no-flash.patch b/zabbix-2.0.1-no-flash.patch deleted file mode 100644 index 36a7824..0000000 --- a/zabbix-2.0.1-no-flash.patch +++ /dev/null @@ -1,11 +0,0 @@ -diff -up zabbix-2.0.1/frontends/php/include/screens.inc.php.orig zabbix-2.0.1/frontends/php/include/screens.inc.php ---- zabbix-2.0.1/frontends/php/include/screens.inc.php.orig 2012-06-27 23:03:03.000000000 +0200 -+++ zabbix-2.0.1/frontends/php/include/screens.inc.php 2012-07-12 16:29:02.000000000 +0200 -@@ -25,7 +25,6 @@ require_once dirname(__FILE__).'/js.inc. - - function screen_resources($resource = null) { - $resources = array( -- SCREEN_RESOURCE_CLOCK => _('Clock'), - SCREEN_RESOURCE_DATA_OVERVIEW => _('Data overview'), - SCREEN_RESOURCE_GRAPH => _('Graph'), - SCREEN_RESOURCE_ACTIONS => _('History of actions'), diff --git a/zabbix-2.0.2-config.patch b/zabbix-2.0.2-config.patch deleted file mode 100644 index c25238b..0000000 --- a/zabbix-2.0.2-config.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff -Nur zabbix-2.0.2/frontends/php/include/config.inc.php zabbix-2.0.2-conf/frontends/php/include/config.inc.php ---- zabbix-2.0.2/frontends/php/include/config.inc.php 2012-07-31 11:16:47.000000000 +0200 -+++ zabbix-2.0.2-conf/frontends/php/include/config.inc.php 2012-09-04 00:07:03.217816413 +0200 -@@ -31,7 +31,7 @@ - CProfiler::getInstance()->start(); - - require_once dirname(__FILE__).'/profiles.inc.php'; --require_once dirname(__FILE__).'/../conf/maintenance.inc.php'; -+require_once '/etc/zabbix/web/maintenance.inc.php'; - - // abc sorting - require_once dirname(__FILE__).'/acknow.inc.php'; -@@ -64,8 +64,7 @@ - $USER_RIGHTS = array(); - $ZBX_LOCALNODEID = 0; - $ZBX_LOCMASTERID = 0; --$ZBX_CONFIGURATION_FILE = './conf/zabbix.conf.php'; --$ZBX_CONFIGURATION_FILE = realpath(dirname($ZBX_CONFIGURATION_FILE)).DIRECTORY_SEPARATOR.basename($ZBX_CONFIGURATION_FILE); -+$ZBX_CONFIGURATION_FILE = '/etc/zabbix/web/zabbix.conf.php'; - - // include tactical overview modules - require_once dirname(__FILE__).'/locales.inc.php'; diff --git a/zabbix-2.0.3-fonts-config.patch b/zabbix-2.0.3-fonts-config.patch deleted file mode 100644 index 02dd5e5..0000000 --- a/zabbix-2.0.3-fonts-config.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -Nur zabbix-2.0.3/frontends/php/include/defines.inc.php zabbix-2.0.3-fonts/frontends/php/include/defines.inc.php ---- zabbix-2.0.3/frontends/php/include/defines.inc.php 2012-10-03 16:41:36.000000000 +0200 -+++ zabbix-2.0.3-fonts/frontends/php/include/defines.inc.php 2012-10-05 23:47:17.341790748 +0200 -@@ -34,7 +34,7 @@ - - define('ZBX_WIDGET_ROWS', 20); - --define('ZBX_FONTPATH', realpath('fonts')); // where to search for font (GD > 2.0.18) -+define('ZBX_FONTPATH', '/usr/share/fonts/dejavu'); // where to search for font (GD > 2.0.18) - define('ZBX_GRAPH_FONT_NAME', 'DejaVuSans'); // font file name - define('ZBX_GRAPH_LEGEND_HEIGHT', 120); // when graph height is less then this value, some legend will not show up - diff --git a/zabbix-agent.init b/zabbix-agent.init deleted file mode 100644 index cb97acf..0000000 --- a/zabbix-agent.init +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/sh -# -# chkconfig: - 86 14 -# description: Zabbix agent daemon -# - -### BEGIN INIT INFO -# Provides: zabbix-agent -# Required-Start: $local_fs $network -# Required-Stop: $local_fs $network -# Should-Start: zabbix-server zabbix-proxy -# Should-Stop: zabbix-server zabbix-proxy -# Default-Start: -# Default-Stop: 0 1 2 3 4 5 6 -# Short-Description: Start and stop Zabbix agent -# Description: Zabbix agent daemon -### END INIT INFO - -# Source function library. -. /etc/rc.d/init.d/functions - -exec=/usr/sbin/zabbix_agentd -prog=${exec##*/} -syscf=${0##*/} -lockfile=/var/lock/subsys/$syscf - -[ -f /etc/sysconfig/$syscf ] && . /etc/sysconfig/$syscf - -config=${CFG_FILE:-/etc/zabbix_agentd.conf} -if [ ! -f $config ]; then - echo "Not starting Zabbix agent: Config file $config not found!" - echo "Check /etc/sysconfig/$syscf" - exit 3 -fi - -pidfile=$(grep -e "^PidFile=.*$" $config | cut -d= -f2) -param="-c $config" - -start() -{ - echo -n $"Starting Zabbix agent: " - daemon --user zabbix --pidfile "$pidfile" $exec $param - rv=$? - echo - [ $rv -eq 0 ] && touch $lockfile - return $rv -} - -stop() -{ - echo -n $"Shutting down Zabbix agent: " - killproc -p "$pidfile" $prog - rv=$? - echo - [ $rv -eq 0 ] && rm -f $lockfile - return $rv -} - -restart() -{ - stop - start -} - -case "$1" in - start|stop|restart) - $1 - ;; - force-reload) - restart - ;; - status) - status -p "$pidfile" -l $prog $exec - ;; - try-restart|condrestart) - if status -p "$pidfile" -l $prog $exec >/dev/null ; then - restart - fi - ;; - reload) - action $"Service ${0##*/} does not support the reload action: " /bin/false - exit 3 - ;; - *) - echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}" - exit 2 - ;; -esac - diff --git a/zabbix-agent.service b/zabbix-agent.service deleted file mode 100644 index 27bfad7..0000000 --- a/zabbix-agent.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Zabbix Monitor Agent -After=syslog.target network.target - -[Service] -Type=oneshot -ExecStart=/usr/sbin/zabbix_agentd -RemainAfterExit=yes -User=zabbix - -[Install] -WantedBy=multi-user.target diff --git a/zabbix-fedora.README b/zabbix-fedora.README deleted file mode 100644 index 3a6f35e..0000000 --- a/zabbix-fedora.README +++ /dev/null @@ -1,174 +0,0 @@ -=Custom in Fedora/EPEL= - -==Pinger files== - -Since /tmp is not a good place to spool files, the pinger files shall now reside -in /var/lib/zabbixsrv/tmp. This directory is automatically created and proxy and -server configuration files are changed accordingly from 2.0.8 on. - - -==Web configuration== - -Web configuration resides in /etc/zabbix/web. The configuration file can be -created manually or by walking through the frontend setup tool, as soon as your -httpd configuration allows. The directory also contains maintenance.inc.php! - -==Log files== - -Log files are located in /var/log/zabbix. - - -==Where's my Flash watch?== - -It's not included in Fedora! Fedora's policy does not allow to include blobs: -https://support.zabbix.com/browse/ZBX-4794 - - -==No htaccess files== - -Fedora ships an Apache configuration file instead. This solutions performs -better and is easier to maintain. - - -=Additional changes from 1.8 to 2.0 in Fedora= - -==Zabbix 2.0 packages conflict Zabbix 1.8== - -This measure was taken because this major version introduces various database -schema changes. A silent update would render Zabbix non-operational and possibly -break the database. Besides that, Zabbix 2.0 server only works with other 2.0 -servers and proxies. Distributed setups must therefore be updated at the same -time. - -http://www.zabbix.com/documentation/2.0/manual/appendix/compatibility - - -==Two users== - -There's a certain security risk involved, running agent and proxy/server as the -same user. This package therefore introduces an additional zabbixsrv user, used -for proxy and server. Please check the permissions of your scripts and group -memberships, if necessary. - - -==Using the Alternatives system instead of conflicting sub-packages== - -You can now install Zabbix proxies or servers compiled for different database -back-ends on the same system. While this is not intended to happily switch back -and forth, it allows you to: - -- Stop the daemon -- "Run alternatives --config zabbix-server" or - "alternatives --config zabbix-proxy" -- Make your choice -- If you're using systemd, run systemctl reload -- Adjust the configuration file -- Start the daemon -- In some cases you have to use "restart" instead of "start". - The reason is not yet clear to me. - -"Alternatives" considers the first installed implementation of server or proxy as -default, respectively. - -Don't forget to reconfigure the front-end when you switch the server to a -different DB implementation! - - -==How to run multiple instances of a Zabbix daemon with init scripts== - -If you want to run multiple instances on the same host, do the following: - -- Copy the init scripts -- Create a file of the same name as the new init script in /etc/sysconfig -- Define CFG_FILE="" in this file -- Create the file defined as CFG_FILE and adjust settings; in particular: - - DB settings if you set up multiple instances of server and proxy daemons; - IMPORTANT: Two daemons using the same database at the same time could act - destructive! - - PidFile - - ListenPort and/or ListenIP, if you plan for simultaneous operation; - Don't forget to review your firewall settings! - - LogFile, if you don't use syslog -- Optionally run the following to register the new instance as a service and - start it up automatically: - chkconfig --add - chkconfig on -- service start - - -==Configuration changes== - -Zabbix 2.0 places configuration files directly in /etc. Symlinks preserve -compatibility. maintenance.inc.php moved from /usr/share/zabbix/conf to -/etc/zabbix/web. - - -==Media scripts and external scripts== - -The directories for external scripts and media scripts have moved to -/var/lib/zabbixsrv. Symlinks preserve compatibility. - -/var/lib/zabbix is now intended for scripts run by the agent. Please move your -server or proxy scripts to /var/lib/zabbixsrv. Be sure to check permissions and -ownership. - - -==No Java bridge== - -The Zabbix Java bridge can not be included now, due to legal issue with one of -the modules (json). See https://support.zabbix.com/browse/ZBX-4800 and feel free -to vote on it. - - -==No SQLite front-end or server implementation== - -Sadly it doesn't work with how Fedora's/EPEL's PHP is compiled. - --------------------------------------------------------------------------------- - -=SELinux= - -The settings necessary for you vary, depending on how you set up your system/s. -Most of the time, the only adjustments necessary should be on the machine that -holds the frontend: - -#Allow to connect the frontend to a database by other means than sockets -setsebool -P httpd_can_network_connect_db 1 - -#Allow the frontend to create a connection to the server listening port -#That's the check the frontend uses to see whether the server is running. -#This option effectively supersedes the previous -setsebool -P httpd_can_network_connect 1 - -Using sebools is a somewhat coarse method of allowing things. -A more fine-grained approach for the latter would be to grab an actual -avc denial from the audit log, pipe it through audit2allow, put it in a -module package and load that: - -echo "avc: denied { name_connect } for pid=20619 comm="httpd" dest=10051 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:zabbix_port_t:s0 tclass=tcp_socket" | audit2allow -M zabbix_conn_httpd; sudo semodule -i zabbix_conn_httpd.pp - -If you're using ping from the frontend: - -echo "avc: denied { setpgid } for pid=31880 comm="zabbix_server_p" scontext=system_u:system_r:zabbix_t:s0 tcontext=system_u:system_r:zabbix_t:s0 tclass=process" | audit2allow -M zabbix_ping_frontend; sudo semodule -i zabbix_ping_frontend.pp - --------------------------------------------------------------------------------- - -=Guide for upgrading to 2.0 from 1.8= - -http://www.zabbix.com/documentation/2.0/manual/installation/upgrade==notes - -The below should be the relevant steps, picked from -http://www.zabbix.com/documentation/2.0/manual/installation/upgrade - -- Review all rpmnew and rpmsave files; merge where necessary -- Review permissions, ownerships and group memberships for zabbixsrv -- Back up the Zabbix database (really!) -- Remove custom database changes, if any -- Make sure the database user has sufficing permissions - (ALTER TABLE, DROP INDEX, DROP TABLE, ...) -- Run the fitting database update script/s -- The scripts can run very long, depending on the content of your database and - your hardware; -- Check the output of the script for errors - -Volker Fröhlich volker27@gmx.at Jan 3 2013 diff --git a/zabbix-logrotate.in b/zabbix-logrotate.in deleted file mode 100644 index ce6a26b..0000000 --- a/zabbix-logrotate.in +++ /dev/null @@ -1,7 +0,0 @@ -/var/log/zabbix/zabbix_COMPONENT.log { - missingok - monthly - notifempty - compress - create 0664 USER zabbix -} diff --git a/zabbix-proxy-mysql.service b/zabbix-proxy-mysql.service deleted file mode 100644 index 6464a5a..0000000 --- a/zabbix-proxy-mysql.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Zabbix MySQL Proxy Agent -After=syslog.target network.target mysqld.service - -[Service] -Type=oneshot -ExecStart=/usr/sbin/zabbix_proxy -RemainAfterExit=yes -User=zabbixsrv - -[Install] -WantedBy=multi-user.target diff --git a/zabbix-proxy-pgsql.service b/zabbix-proxy-pgsql.service deleted file mode 100644 index 5d52fd9..0000000 --- a/zabbix-proxy-pgsql.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Zabbix PostgreSQL Proxy Agent -After=syslog.target network.target postgresql.service - -[Service] -Type=oneshot -ExecStart=/usr/sbin/zabbix_proxy -RemainAfterExit=yes -User=zabbixsrv - -[Install] -WantedBy=multi-user.target diff --git a/zabbix-proxy-sqlite3.service b/zabbix-proxy-sqlite3.service deleted file mode 100644 index a102fc0..0000000 --- a/zabbix-proxy-sqlite3.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Zabbix SQLite3 Proxy Agent -After=syslog.target network.target - -[Service] -Type=oneshot -ExecStart=/usr/sbin/zabbix_proxy -RemainAfterExit=yes -User=zabbixsrv - -[Install] -WantedBy=multi-user.target diff --git a/zabbix-proxy.init b/zabbix-proxy.init deleted file mode 100644 index e3b2283..0000000 --- a/zabbix-proxy.init +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/sh -# -# chkconfig: - 85 15 -# description: Zabbix proxy daemon -# - -### BEGIN INIT INFO -# Provides: zabbix-proxy -# Required-Start: $local_fs $network -# Required-Stop: $local_fs $network -# Default-Start: -# Default-Stop: 0 1 2 3 4 5 6 -# Short-Description: Start and stop Zabbix proxy -# Description: Zabbix proxy daemon -### END INIT INFO - -# Source function library. -. /etc/rc.d/init.d/functions - -exec=/usr/sbin/zabbix_proxy -prog=${exec##*/} -syscf=${0##*/} -lockfile=/var/lock/subsys/$syscf - -[ -f /etc/sysconfig/$syscf ] && . /etc/sysconfig/$syscf - -config=${CFG_FILE:-/etc/zabbix_proxy.conf} -if [ ! -f $config ]; then - echo "Not starting Zabbix proxy: Config file $config not found!" - echo "Check /etc/sysconfig/$syscf" - exit 3 -fi - -pidfile=$(grep -e "^PidFile=.*$" $config | cut -d= -f2) -param="-c $config" - -start() -{ - echo -n $"Starting Zabbix proxy: " - daemon --user zabbixsrv --pidfile "$pidfile" $exec $param - rv=$? - echo - [ $rv -eq 0 ] && touch $lockfile - return $rv -} - -stop() -{ - echo -n $"Shutting down Zabbix proxy: " - killproc -p "$pidfile" $prog - rv=$? - echo - [ $rv -eq 0 ] && rm -f $lockfile - return $rv -} - -restart() -{ - stop - start -} - -case "$1" in - start|stop|restart) - $1 - ;; - force-reload) - restart - ;; - status) - status -p "$pidfile" -l $prog $exec - ;; - try-restart|condrestart) - if status -p "$pidfile" -l $prog $exec >/dev/null ; then - restart - fi - ;; - reload) - action $"Service ${0##*/} does not support the reload action: " /bin/false - exit 3 - ;; - *) - echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}" - exit 2 - ;; -esac - diff --git a/zabbix-server-mysql.service b/zabbix-server-mysql.service deleted file mode 100644 index 9c0217b..0000000 --- a/zabbix-server-mysql.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Zabbix Server with MySQL DB -After=syslog.target network.target mysqld.service - -[Service] -Type=oneshot -ExecStart=/usr/sbin/zabbix_server -RemainAfterExit=yes -User=zabbixsrv - -[Install] -WantedBy=multi-user.target diff --git a/zabbix-server-pgsql.service b/zabbix-server-pgsql.service deleted file mode 100644 index a196b4c..0000000 --- a/zabbix-server-pgsql.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Zabbix Server with PostgreSQL DB -After=syslog.target network.target postgresql.service - -[Service] -Type=oneshot -ExecStart=/usr/sbin/zabbix_server -RemainAfterExit=yes -User=zabbixsrv - -[Install] -WantedBy=multi-user.target diff --git a/zabbix-server.init b/zabbix-server.init deleted file mode 100644 index 0dd2710..0000000 --- a/zabbix-server.init +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/sh -# -# chkconfig: - 85 15 -# description: Zabbix server daemon -# - -### BEGIN INIT INFO -# Provides: zabbix-server -# Required-Start: $local_fs $network -# Required-Stop: $local_fs $network -# Default-Start: -# Default-Stop: 0 1 2 3 4 5 6 -# Short-Description: Start and stop Zabbix server -# Description: Zabbix server daemon -### END INIT INFO - -# Source function library. -. /etc/rc.d/init.d/functions - -exec=/usr/sbin/zabbix_server -prog=${exec##*/} -syscf=${0##*/} -lockfile=/var/lock/subsys/$syscf - -[ -f /etc/sysconfig/$syscf ] && . /etc/sysconfig/$syscf - -config=${CFG_FILE:-/etc/zabbix_server.conf} -if [ ! -f $config ]; then - echo "Not starting Zabbix server: Config file $config not found!" - echo "Check /etc/sysconfig/$syscf" - exit 3 -fi - -pidfile=$(grep -e "^PidFile=.*$" $config | cut -d= -f2) -param="-c $config" - -start() -{ - echo -n $"Starting Zabbix server: " - daemon --user zabbixsrv --pidfile "$pidfile" $exec $param - rv=$? - echo - [ $rv -eq 0 ] && touch $lockfile - return $rv -} - -stop() -{ - echo -n $"Shutting down Zabbix server: " - killproc -p "$pidfile" $prog - rv=$? - echo - [ $rv -eq 0 ] && rm -f $lockfile - return $rv -} - -restart() -{ - stop - start -} - -case "$1" in - start|stop|restart) - $1 - ;; - force-reload) - restart - ;; - status) - status -p "$pidfile" -l $prog $exec - ;; - try-restart|condrestart) - if status -p "$pidfile" -l $prog $exec >/dev/null ; then - restart - fi - ;; - reload) - action $"Service ${0##*/} does not support the reload action: " /bin/false - exit 3 - ;; - *) - echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}" - exit 2 - ;; -esac - diff --git a/zabbix-tmpfiles.conf b/zabbix-tmpfiles.conf deleted file mode 100644 index 3099a5d..0000000 --- a/zabbix-tmpfiles.conf +++ /dev/null @@ -1 +0,0 @@ -D /var/run/zabbix 0775 zabbix zabbix - diff --git a/zabbix-web.conf b/zabbix-web.conf deleted file mode 100644 index 4e4e237..0000000 --- a/zabbix-web.conf +++ /dev/null @@ -1,48 +0,0 @@ -# -# Zabbix monitoring system php web frontend -# - -Alias /zabbix /usr/share/zabbix - - - Options FollowSymLinks - AllowOverride None - - - # Apache 2.4 - Require all granted - - - - # Apache 2.2 - Order allow,deny - Allow from all - - - - - - - # Apache 2.4 - Require all denied - - - - # Apache 2.2 - Order deny,allow - Deny from all - - - - - # Apache 2.4 - Require all denied - - - - Order deny,allow - Deny from all - - - - diff --git a/zabbix20.spec b/zabbix20.spec deleted file mode 100644 index e54f99b..0000000 --- a/zabbix20.spec +++ /dev/null @@ -1,1160 +0,0 @@ -# TODO, maybe sometime: -# * F18 systemd macros, when EL6 reaches EOL -# * Do something about mutex errors sometimes occurring when init scripts' -# restart is invoked; something like "sleep 2" between stop and start? -# "Include" statement in config files needs patching in order to not load -# various backup files (*.rpm{orig,new,save}, *~ etc) in that dir. -# https://support.zabbix.com/browse/ZBXNEXT-497 -# * Consider using systemd's ReadWriteDirectories - -#TODO: systemctl reload seems to be necessary after switching with Alternatives -#TODO: If the DB path for a Sqlite proxy is configured wrong, it requires systemctl restart. Start doesn't work. - -# Allow pinger lists in /var/lib/zabbixsrv/tmp -#echo "avc: denied { read } for pid=3427 comm="fping6" path="/var/lib/zabbixsrv/tmp/zabbix_server_pgsql_3002.pinger" dev=dm-1 ino=20 scontext=system_u:system_r:ping_t:s0 tcontext=system_u:object_r:initrc_tmp_t:s0 tclass=file" | audit2allow -M myzab; sudo semodule -i myzab2.pp - -#type=AVC msg=audit(1346965425.718:65127): avc: denied { getattr } for pid=3427 comm="fping6" path="/var/lib/zabbixsrv/tmp/zabbix_server_pgsql_3002.pinger" dev=dm-1 ino=20 scontext=system_u:system_r:ping_t:s0 tcontext=system_u:object_r:initrc_tmp_t:s0 tclass=file - -%global srcname zabbix - -Name: zabbix20 -Version: 2.0.21 -Release: 1%{?dist} -Summary: Open-source monitoring solution for your IT infrastructure - -Group: Applications/Internet -License: GPLv2+ -URL: http://www.zabbix.com -Source0: http://downloads.sourceforge.net/%{srcname}/%{srcname}-%{version}.tar.gz -Source1: %{srcname}-web.conf -Source2: %{srcname}-server.init -Source3: %{srcname}-agent.init -Source4: %{srcname}-proxy.init -Source5: %{srcname}-logrotate.in -Source9: %{srcname}-tmpfiles.conf -# systemd units -- Alternatives switches between them (they state their dependencies) -# https://support.zabbix.com/browse/ZBXNEXT-1593 -Source10: %{srcname}-agent.service -Source11: %{srcname}-proxy-mysql.service -Source12: %{srcname}-proxy-pgsql.service -Source13: %{srcname}-proxy-sqlite3.service -Source14: %{srcname}-server-mysql.service -Source15: %{srcname}-server-pgsql.service - -Source16: %{srcname}-fedora.README - -# local rules for config files -Patch0: %{srcname}-2.0.2-config.patch -# local rules for config files - fonts -Patch1: %{srcname}-2.0.3-fonts-config.patch -# remove flash content (#737337) -# https://support.zabbix.com/browse/ZBX-4794 -Patch2: %{srcname}-2.0.1-no-flash.patch -# adapt for fping3 - https://support.zabbix.com/browse/ZBX-4894 -Patch3: %{srcname}-1.8.12-fping3.patch - -BuildRequires: mysql-devel -BuildRequires: postgresql-devel -BuildRequires: sqlite-devel -BuildRequires: net-snmp-devel -BuildRequires: openldap-devel -BuildRequires: gnutls-devel -BuildRequires: iksemel-devel -BuildRequires: unixODBC-devel -BuildRequires: curl-devel -BuildRequires: OpenIPMI-devel -BuildRequires: libssh2-devel -%if 0%{?fedora} -BuildRequires: systemd-units -%endif - -Requires: logrotate -# Could alternatively be conditional on Fedora/EL -%if %{srcname} != %{name} -Conflicts: %{srcname} -%else -Obsoletes: %{srcname}-docs < 1.8.15-2 -Obsoletes: %{srcname}-web-sqlite3 < 2.0.3-3 -Obsoletes: %{srcname}-server-sqlite3 < 2.0.3-3 -%endif - -%description -Zabbix is software that monitors numerous parameters of a network and the -health and integrity of servers. Zabbix uses a flexible notification mechanism -that allows users to configure e-mail based alerts for virtually any event. -This allows a fast reaction to server problems. Zabbix offers excellent -reporting and data visualization features based on the stored data. -This makes Zabbix ideal for capacity planning. - -Zabbix supports both polling and trapping. All Zabbix reports and statistics, -as well as configuration parameters are accessed through a web-based front end. -A web-based front end ensures that the status of your network and the health of -your servers can be assessed from any location. Properly configured, Zabbix can -play an important role in monitoring IT infrastructure. This is equally true -for small organizations with a few servers and for large companies with a -multitude of servers. - -%package server -Summary: Zabbix server common files -Group: Applications/Internet -BuildArch: noarch -Requires: %{name} = %{version}-%{release} -Requires: %{name}-server-implementation = %{version}-%{release} -Requires: fping -Requires: traceroute -Requires(pre): shadow-utils -%if 0%{?fedora} -Requires(post): systemd-units -Requires(preun): systemd-units -Requires(postun): systemd-units -%else -Requires(post): /sbin/chkconfig -Requires(preun): /sbin/chkconfig -Requires(preun): /sbin/service -Requires(postun): /sbin/service -%endif - -%description server -Zabbix server common files - -%package server-mysql -Summary: Zabbix server compiled to use MySQL -Group: Applications/Internet -Requires: %{name} = %{version}-%{release} -Requires: %{name}-server = %{version}-%{release} -Requires(post): %{_sbindir}/update-alternatives -Requires(preun): %{_sbindir}/alternatives -Requires(postun): %{_sbindir}/update-alternatives -Provides: %{name}-server-implementation = %{version}-%{release} - -%description server-mysql -Zabbix server compiled to use MySQL - -%package server-pgsql -Summary: Zabbix server compiled to use PostgresSQL -Group: Applications/Internet -Requires: %{name} = %{version}-%{release} -Requires: %{name}-server = %{version}-%{release} -Requires(post): %{_sbindir}/update-alternatives -Requires(preun): %{_sbindir}/alternatives -Requires(postun): %{_sbindir}/update-alternatives -Provides: %{name}-server-implementation = %{version}-%{release} - -%description server-pgsql -Zabbix server compiled to use PostgresSQL - -%package agent -Summary: Zabbix agent -Group: Applications/Internet -Requires: %{name} = %{version}-%{release} -Requires(pre): shadow-utils -%if 0%{?fedora} -Requires(post): systemd-units -Requires(preun): systemd-units -Requires(postun): systemd-units -%else -Requires(post): /sbin/chkconfig -Requires(preun): /sbin/chkconfig -Requires(preun): /sbin/service -Requires(postun): /sbin/service -%endif - -%description agent -Zabbix agent, to be installed on monitored systems - -%package proxy -Summary: Zabbix proxy common files -Group: Applications/Internet -BuildArch: noarch -Requires: %{name} = %{version}-%{release} -Requires: %{name}-proxy-implementation = %{version}-%{release} -Requires(pre): shadow-utils -%if 0%{?fedora} -Requires(post): systemd-units -Requires(preun): systemd-units -Requires(postun): systemd-units -%else -Requires(post): /sbin/chkconfig -Requires(preun): /sbin/chkconfig -Requires(preun): /sbin/service -Requires(postun): /sbin/service -%endif -Requires: fping - -%description proxy -The Zabbix proxy - -%package proxy-mysql -Summary: Zabbix proxy compiled to use MySQL -Group: Applications/Internet -Requires: %{name}-proxy = %{version}-%{release} -Provides: %{name}-proxy-implementation = %{version}-%{release} -Requires(post): %{_sbindir}/update-alternatives -Requires(preun): %{_sbindir}/alternatives -Requires(postun): %{_sbindir}/update-alternatives - -%description proxy-mysql -The Zabbix proxy compiled to use MySQL - -%package proxy-pgsql -Summary: Zabbix proxy compiled to use PostgreSQL -Group: Applications/Internet -Requires: %{name}-proxy = %{version}-%{release} -Provides: %{name}-proxy-implementation = %{version}-%{release} -Requires(post): %{_sbindir}/update-alternatives -Requires(preun): %{_sbindir}/alternatives -Requires(postun): %{_sbindir}/update-alternatives - -%description proxy-pgsql -The Zabbix proxy compiled to use PostgreSQL - -%package proxy-sqlite3 -Summary: Zabbix proxy compiled to use SQLite -Group: Applications/Internet -Requires: %{name}-proxy = %{version}-%{release} -Provides: %{name}-proxy-implementation = %{version}-%{release} -Requires(post): %{_sbindir}/update-alternatives -Requires(preun): %{_sbindir}/alternatives -Requires(postun): %{_sbindir}/update-alternatives - -%description proxy-sqlite3 -The Zabbix proxy compiled to use SQLite - -%package web -Summary: Zabbix Web Frontend -Group: Applications/Internet -BuildArch: noarch -# Don't remove "php". Everything else only depends on php-common -# and you'll end up with no module for Apache! -Requires: php -Requires: php-gd -Requires: php-bcmath -Requires: php-ldap -Requires: php-mbstring -Requires: php-xml -Requires: php-gettext -Requires: dejavu-sans-fonts -Requires: %{name} = %{version}-%{release} -Requires: %{name}-web-database = %{version}-%{release} - -%description web -The php frontend to display the Zabbix web interface. - -%package web-mysql -Summary: Zabbix web frontend for MySQL -Group: Applications/Internet -BuildArch: noarch -Requires: %{name}-web = %{version}-%{release} -Requires: php-mysql -Provides: %{name}-web-database = %{version}-%{release} -Obsoletes: %{name}-web <= 1.5.3-0.1 - -%description web-mysql -Zabbix web frontend for MySQL - -%package web-pgsql -Summary: Zabbix web frontend for PostgreSQL -Group: Applications/Internet -BuildArch: noarch -Requires: %{name}-web = %{version}-%{release} -Requires: php-pgsql -Provides: %{name}-web-database = %{version}-%{release} - -%description web-pgsql -Zabbix web frontend for PostgreSQL - - -%prep -%setup0 -q -n %{srcname}-%{version} -%patch0 -p1 -%patch1 -p1 -%if 0%{?fedora} -%patch3 -p1 -%endif - -# Remove flash applet -# https://support.zabbix.com/browse/ZBX-4794 -%patch2 -p1 -rm -f frontends/php/images/flash/zbxclock.swf - -# Remove bundled java libs -rm -rf src/zabbix_java/lib/*.jar - -# Remove prebuilt Windows binaries -rm -rf bin - -# Remove included fonts -rm -rf frontends/php/fonts - -# Remove executable permissions -chmod a-x upgrades/dbpatches/*/mysql/upgrade - -# Override statically named directory for alertscripts and externalscripts -# https://support.zabbix.com/browse/ZBX-6159 -sed -i 's|$(DESTDIR)@datadir@/zabbix|$(DESTDIR)/var/lib/zabbixsrv|' \ - src/zabbix_server/Makefile.in \ - src/zabbix_proxy/Makefile.in - -# Kill off .htaccess files, options set in SOURCE1 -rm -f frontends/php/include/.htaccess -rm -f frontends/php/api/.htaccess -rm -f frontends/php/conf/.htaccess - -# Fix path to traceroute utility -# Still valid for EL7! -find database -name 'data.sql' -exec sed -i 's|/usr/bin/traceroute|/bin/traceroute|' {} \; - -# Adapt configuration file options -sed -i \ - -e 's|# PidFile=.*|PidFile=%{_localstatedir}/run/zabbix/zabbix_agentd.pid|g' \ - -e 's|^LogFile=.*|LogFile=%{_localstatedir}/log/zabbix/zabbix_agentd.log|g' \ - -e 's|# LogFileSize=.*|LogFileSize=0|g' \ - -e 's|/usr/local||g' \ - conf/zabbix_agentd.conf - -sed -i \ - -e 's|/usr/local||g' \ - conf/zabbix_agent.conf - -#TODO: It'd be better to leave the defaults in a commment and just override them, as they are still hard-coded! -sed -i \ - -e 's|# PidFile=.*|PidFile=%{_localstatedir}/run/zabbix/zabbix_server.pid|g' \ - -e 's|^LogFile=.*|LogFile=%{_localstatedir}/log/zabbix/zabbix_server.log|g' \ - -e 's|# LogFileSize=.*|LogFileSize=0|g' \ - -e 's|# AlertScriptsPath=${datadir}/zabbix/|AlertScriptsPath=%{_sharedstatedir}/zabbixsrv/|g' \ - -e 's|^DBUser=root|DBUser=zabbix|g' \ - -e 's|# DBSocket=/tmp/mysql.sock|DBSocket=%{_sharedstatedir}/mysql/mysql.sock|g' \ - -e 's|# ExternalScripts=\${datadir}/zabbix/externalscripts|ExternalScripts=%{_sharedstatedir}/zabbixsrv/externalscripts|' \ - -e 's|# TmpDir=\/tmp|TmpDir=%{_sharedstatedir}/zabbixsrv/tmp|' \ - -e 's|/usr/local||g' \ - conf/zabbix_server.conf - -sed -i \ - -e 's|# PidFile=.*|PidFile=%{_localstatedir}/run/zabbix/zabbix_proxy.pid|g' \ - -e 's|^LogFile=.*|LogFile=%{_localstatedir}/log/zabbix/zabbix_proxy.log|g' \ - -e 's|# LogFileSize=.*|LogFileSize=0|g' \ - -e 's|^DBUser=root|DBUser=zabbix|g' \ - -e 's|# DBSocket=/tmp/mysql.sock|DBSocket=%{_sharedstatedir}/mysql/mysql.sock|g' \ - -e 's|# ExternalScripts=\${datadir}/zabbix/externalscripts|ExternalScripts=%{_sharedstatedir}/zabbixsrv/externalscripts|' \ - -e 's|# TmpDir=\/tmp|TmpDir=%{_sharedstatedir}/zabbixsrv/tmp|' \ - -e 's|/usr/local||g' \ - conf/zabbix_proxy.conf - -#TODO: Ticket -# Adapt man pages and SQL patches -sed -i 's|/usr/local||g;s| (if not modified during compile time).||' man/*.man -sed -i 's|/usr/local||g' \ - upgrades/dbpatches/2.0/mysql/patch.sql \ - upgrades/dbpatches/2.0/postgresql/patch.sql - -# Install README file -install -m0644 %{SOURCE16} . - - -%build - -common_flags=" - --enable-dependency-tracking - --enable-agent - --enable-proxy - --enable-ipv6 - --disable-java - --with-net-snmp - --with-ldap - --with-libcurl - --with-openipmi - --with-jabber - --with-unixodbc - --with-ssh2 -" - -# Frontend doesn't work for SQLite, thus don't build server -%configure $common_flags --with-sqlite3 -make %{?_smp_mflags} -mv src/zabbix_proxy/zabbix_proxy src/zabbix_proxy/zabbix_proxy_sqlite3 - -%configure $common_flags --with-mysql --enable-server -make clean -make %{?_smp_mflags} -mv src/zabbix_server/zabbix_server src/zabbix_server/zabbix_server_mysql -mv src/zabbix_proxy/zabbix_proxy src/zabbix_proxy/zabbix_proxy_mysql - -%configure $common_flags --with-postgresql --enable-server -make clean -make %{?_smp_mflags} -mv src/zabbix_server/zabbix_server src/zabbix_server/zabbix_server_pgsql -mv src/zabbix_proxy/zabbix_proxy src/zabbix_proxy/zabbix_proxy_pgsql - -# Ghosted alternatives -touch src/zabbix_server/zabbix_server -touch src/zabbix_proxy/zabbix_proxy - - -%install -# Configuration, runtime and start-up -mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/%{srcname} -mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/%{srcname}/web -mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d -mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/httpd/conf.d -mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/log/zabbix -mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/run/zabbix -mkdir -p $RPM_BUILD_ROOT%{_unitdir} -%if 0%{?rhel} -mkdir -p $RPM_BUILD_ROOT%{_initrddir} -%endif - -# Frontend -mkdir -p $RPM_BUILD_ROOT%{_datadir} - -# Home directory for the agent; -# The other home directory is created during installation -mkdir -p $RPM_BUILD_ROOT%{_sharedstatedir}/zabbix - -# Install binaries -make DESTDIR=$RPM_BUILD_ROOT install -install -m 0755 -p src/zabbix_server/zabbix_server_* $RPM_BUILD_ROOT%{_sbindir}/ -install -m 0755 -p src/zabbix_proxy/zabbix_proxy_* $RPM_BUILD_ROOT%{_sbindir}/ - -# Install the frontend after removing backup files from patching -find frontends/php -name '*.orig' -exec rm {} \; -cp -a frontends/php $RPM_BUILD_ROOT%{_datadir}/%{srcname} - -# Prepare ghosted config file -#TODO: Simplify that? Like /etc/zabbix_web/zabbix.conf.php? -touch $RPM_BUILD_ROOT%{_sysconfdir}/%{srcname}/web/zabbix.conf.php - -# This file is used to switch the frontend to maintenance mode -mv $RPM_BUILD_ROOT%{_datadir}/%{srcname}/conf/maintenance.inc.php $RPM_BUILD_ROOT%{_sysconfdir}/%{srcname}/web/maintenance.inc.php - -# Drop Apache config file in place -install -m 0644 -p %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/httpd/conf.d/%{srcname}.conf - -# Install log rotation -sed -e 's|COMPONENT|agentd|g; s|USER|zabbix|g' %{SOURCE5} > \ - $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/zabbix-agent -sed -e 's|COMPONENT|server|g; s|USER|zabbixsrv|g' %{SOURCE5} > \ - $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/zabbix-server -sed -e 's|COMPONENT|proxy|g; s|USER|zabbixsrv|g' %{SOURCE5} > \ - $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/zabbix-proxy - -# Logrotate's su option is only available in Fedora and EL 7 -%if 0%{?rhel} -sed -i '/su USER zabbix/d' $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/zabbix-* -%endif - -%if 0%{?fedora} -# Install different systemd units because of the requirements for DBMS daemons -install -m 0644 -p %{SOURCE10} $RPM_BUILD_ROOT%{_unitdir}/zabbix-agent.service -install -m 0644 -p %{SOURCE11} $RPM_BUILD_ROOT%{_unitdir}/zabbix-proxy-mysql.service -install -m 0644 -p %{SOURCE12} $RPM_BUILD_ROOT%{_unitdir}/zabbix-proxy-pgsql.service -install -m 0644 -p %{SOURCE13} $RPM_BUILD_ROOT%{_unitdir}/zabbix-proxy-sqlite3.service -install -m 0644 -p %{SOURCE14} $RPM_BUILD_ROOT%{_unitdir}/zabbix-server-mysql.service -install -m 0644 -p %{SOURCE15} $RPM_BUILD_ROOT%{_unitdir}/zabbix-server-pgsql.service -%else -# Init scripts -install -m 0755 -p %{SOURCE3} $RPM_BUILD_ROOT%{_initrddir}/zabbix-agent -install -m 0755 -p %{SOURCE4} $RPM_BUILD_ROOT%{_initrddir}/zabbix-proxy -install -m 0755 -p %{SOURCE2} $RPM_BUILD_ROOT%{_initrddir}/zabbix-server -%endif - -# Ghosted alternatives -touch $RPM_BUILD_ROOT%{_unitdir}/zabbix-server.service -touch $RPM_BUILD_ROOT%{_unitdir}/zabbix-proxy.service - -# Install compatibility links for config files -#TODO: Switch to .wants files instead! -ln -sf %{_sysconfdir}/zabbix_agent.conf $RPM_BUILD_ROOT%{_sysconfdir}/%{srcname}/zabbix_agent.conf -ln -sf %{_sysconfdir}/zabbix_agentd.conf $RPM_BUILD_ROOT%{_sysconfdir}/%{srcname}/zabbix_agentd.conf -ln -sf %{_sysconfdir}/zabbix_server.conf $RPM_BUILD_ROOT%{_sysconfdir}/%{srcname}/zabbix_server.conf -ln -sf %{_sysconfdir}/zabbix_proxy.conf $RPM_BUILD_ROOT%{_sysconfdir}/%{srcname}/zabbix_proxy.conf -ln -sf %{_sharedstatedir}/zabbixsrv/externalscripts $RPM_BUILD_ROOT%{_sysconfdir}/%{srcname}/externalscripts -ln -sf %{_sharedstatedir}/zabbixsrv/alertscripts $RPM_BUILD_ROOT%{_sysconfdir}/%{srcname}/alertscripts -#TODO: What does that do to existing directories? - -# Directory for fping spooling files -mkdir $RPM_BUILD_ROOT%{_sharedstatedir}/zabbixsrv/tmp - -# Install sql files -for db in postgresql mysql; do - datadir=$RPM_BUILD_ROOT%{_datadir}/%{srcname}-$db - install -dm 755 $datadir/upgrades/{1.6,1.8,2.0} - cp -p database/$db/* $datadir - cp -pR upgrades/dbpatches/1.6/$db/* $datadir/upgrades/1.6 - cp -pR upgrades/dbpatches/1.8/$db/* $datadir/upgrades/1.8 - cp -pR upgrades/dbpatches/2.0/$db/* $datadir/upgrades/2.0 -done - -install -dm 755 $RPM_BUILD_ROOT%{_datadir}/%{srcname}-sqlite3 -cp -p database/sqlite3/schema.sql $RPM_BUILD_ROOT%{_datadir}/%{srcname}-sqlite3 - -%if 0%{?fedora} -# systemd must create /var/run/%{srcname} -mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/tmpfiles.d -install -m 0644 %{SOURCE9} $RPM_BUILD_ROOT%{_sysconfdir}/tmpfiles.d/zabbix.conf -%endif - - -%post server -%if 0%{?fedora} -if [ $1 -eq 1 ] ; then - /bin/systemctl daemon-reload >/dev/null 2>&1 || : -fi -%else -/sbin/chkconfig --add zabbix-server -%endif - -if [ $1 -gt 1 ] -then - # Apply permissions also in *.rpmnew upgrades from old permissive ones - chmod 0600 %{_sysconfdir}/zabbix_server.conf - chown zabbixsrv:zabbix %{_sysconfdir}/zabbix_server.conf -fi -: - -%post server-mysql -%if 0%{?fedora} -%{_sbindir}/update-alternatives --install %{_sbindir}/%{srcname}_server \ - %{srcname}-server %{_sbindir}/%{srcname}_server_mysql 10 \ - --slave %{_unitdir}/zabbix-server.service %{srcname}-server-systemd \ - %{_unitdir}/zabbix-server-mysql.service -%else -%{_sbindir}/update-alternatives --install %{_sbindir}/%{srcname}_server \ - %{srcname}-server %{_sbindir}/%{srcname}_server_mysql 10 -%endif - -%post server-pgsql -%if 0%{?fedora} -%{_sbindir}/update-alternatives --install %{_sbindir}/%{srcname}_server \ - %{srcname}-server %{_sbindir}/%{srcname}_server_pgsql 10 \ - --slave %{_unitdir}/zabbix-server.service %{srcname}-server-systemd \ - %{_unitdir}/zabbix-server-pgsql.service -%else -%{_sbindir}/update-alternatives --install %{_sbindir}/%{srcname}_server \ - %{srcname}-server %{_sbindir}/%{srcname}_server_pgsql 10 -%endif - -%post proxy -%if 0%{?fedora} -if [ $1 -eq 1 ] ; then - /bin/systemctl daemon-reload >/dev/null 2>&1 || : -fi -%else -/sbin/chkconfig --add zabbix-proxy -%endif - -if [ $1 -gt 1 ] -then - # Apply permissions also in *.rpmnew upgrades from old permissive ones - chmod 0600 %{_sysconfdir}/zabbix_proxy.conf - chown zabbixsrv:zabbix %{_sysconfdir}/zabbix_proxy.conf -fi -: - -%post proxy-mysql -%if 0%{?fedora} -%{_sbindir}/update-alternatives --install %{_sbindir}/%{srcname}_proxy \ - %{srcname}-proxy %{_sbindir}/%{srcname}_proxy_mysql 10 \ - --slave %{_unitdir}/zabbix-proxy.service %{srcname}-proxy-systemd \ - %{_unitdir}/zabbix-proxy-mysql.service -%else -%{_sbindir}/update-alternatives --install %{_sbindir}/%{srcname}_proxy \ - %{srcname}-proxy %{_sbindir}/%{srcname}_proxy_mysql 10 -%endif - -%post proxy-pgsql -%if 0%{?fedora} -%{_sbindir}/update-alternatives --install %{_sbindir}/%{srcname}_proxy \ - %{srcname}-proxy %{_sbindir}/%{srcname}_proxy_pgsql 10 \ - --slave %{_unitdir}/zabbix-proxy.service %{srcname}-proxy-systemd \ - %{_unitdir}/zabbix-proxy-pgsql.service -%else -%{_sbindir}/update-alternatives --install %{_sbindir}/%{srcname}_proxy \ - %{srcname}-proxy %{_sbindir}/%{srcname}_proxy_pgsql 10 -%endif - -%post proxy-sqlite3 -%if 0%{?fedora} -%{_sbindir}/update-alternatives --install %{_sbindir}/%{srcname}_proxy \ - %{srcname}-proxy %{_sbindir}/%{srcname}_proxy_sqlite3 10 \ - --slave %{_unitdir}/zabbix-proxy.service %{srcname}-proxy-systemd \ - %{_unitdir}/zabbix-proxy-sqlite3.service -%else -%{_sbindir}/update-alternatives --install %{_sbindir}/%{srcname}_proxy \ - %{srcname}-proxy %{_sbindir}/%{srcname}_proxy_sqlite3 10 -%endif - -%pre agent -getent group zabbix > /dev/null || groupadd -r zabbix -getent passwd zabbix > /dev/null || \ - useradd -r -g zabbix -d %{_sharedstatedir}/zabbix -s /sbin/nologin \ - -c "Zabbix Monitoring System" zabbix -: - -%post agent -if [ $1 -eq 1 ] ; then -%if 0%{?fedora} - /bin/systemctl daemon-reload >/dev/null 2>&1 || : -%else - /sbin/chkconfig --add zabbix-agent || : -%endif -fi - -%pre server -getent group zabbix > /dev/null || groupadd -r zabbix -getent passwd zabbix > /dev/null || \ - useradd -r -g zabbix -d %{_sharedstatedir}/zabbix -s /sbin/nologin \ - -c "Zabbix Monitoring System" zabbix -getent passwd zabbixsrv > /dev/null || \ - useradd -r -g zabbix -d %{_sharedstatedir}/zabbixsrv -s /sbin/nologin \ - -c "Zabbix Monitoring System -- Proxy or server" zabbixsrv -: - -%preun server -if [ $1 -eq 0 ] -then -%if 0%{?fedora} - /bin/systemctl --no-reload disable zabbix-server.service > /dev/null 2>&1 || : - /bin/systemctl stop zabbix-server.service > /dev/null 2>&1 || : -%else - /sbin/service zabbix-server stop >/dev/null 2>&1 - /sbin/chkconfig --del zabbix-server -%endif -fi -: - -#TODO: Update path from 1.8.6 with wrongly set home dir? -%pre proxy -getent group zabbix > /dev/null || groupadd -r zabbix -getent passwd zabbix > /dev/null || \ - useradd -r -g zabbix -d %{_sharedstatedir}/zabbix -s /sbin/nologin \ - -c "Zabbix Monitoring System" zabbix -getent passwd zabbixsrv > /dev/null || \ - useradd -r -g zabbix -d %{_sharedstatedir}/zabbixsrv -s /sbin/nologin \ - -c "Zabbix Monitoring System -- Proxy or server" zabbixsrv -: - -%preun proxy -if [ $1 -eq 0 ] -then -%if 0%{?fedora} - /bin/systemctl --no-reload disable zabbix-proxy.service > /dev/null 2>&1 || : - /bin/systemctl stop zabbix-proxy.service > /dev/null 2>&1 || : -%else - /sbin/service zabbix-proxy stop >/dev/null 2>&1 - /sbin/chkconfig --del zabbix-proxy -%endif -fi -: - -%preun agent -if [ $1 -eq 0 ] ; then -%if 0%{?fedora} - /bin/systemctl --no-reload disable zabbix-agent.service > /dev/null 2>&1 || : - /bin/systemctl stop zabbix-agent.service > /dev/null 2>&1 || : -%else - /sbin/service zabbix-agent stop >/dev/null 2>&1 - /sbin/chkconfig --del zabbix-agent -%endif -fi -: - -%postun server -%if 0%{?fedora} - /bin/systemctl daemon-reload >/dev/null 2>&1 || : -%endif - -if [ $1 -ge 1 ] ; then -%if 0%{?fedora} - /bin/systemctl try-restart zabbix-server.service >/dev/null 2>&1 || : -%else - /sbin/service zabbix-server try-restart >/dev/null 2>&1 || : -%endif -fi - -%postun server-mysql -if [ $1 -eq 0 ] ; then - %{_sbindir}/update-alternatives --remove %{srcname}-server %{_sbindir}/%{srcname}_server_mysql -fi - -%postun server-pgsql -if [ $1 -eq 0 ] ; then - %{_sbindir}/update-alternatives --remove %{srcname}-server %{_sbindir}/%{srcname}_server_pgsql -fi - -%postun proxy -%if 0%{?fedora} - /bin/systemctl daemon-reload >/dev/null 2>&1 || : -%endif - -if [ $1 -ge 1 ] ; then -%if 0%{?fedora} - /bin/systemctl try-restart zabbix-proxy.service >/dev/null 2>&1 || : -%else - /sbin/service zabbix-proxy try-restart >/dev/null 2>&1 || : -%endif -fi - -%postun proxy-mysql -if [ $1 -eq 0 ] ; then - %{_sbindir}/update-alternatives --remove %{srcname}-proxy %{_sbindir}/%{srcname}_proxy_mysql -fi - -%postun proxy-pgsql -if [ $1 -eq 0 ] ; then - %{_sbindir}/update-alternatives --remove %{srcname}-proxy %{_sbindir}/%{srcname}_proxy_pgsql -fi - -%postun proxy-sqlite3 -if [ $1 -eq 0 ] ; then - %{_sbindir}/update-alternatives --remove %{srcname}-proxy %{_sbindir}/%{srcname}_proxy_sqlite3 -fi - -%postun agent -%if 0%{?fedora} - /bin/systemctl daemon-reload >/dev/null 2>&1 || : -%endif - -if [ $1 -ge 1 ] ; then -%if 0%{?fedora} - /bin/systemctl try-restart zabbix-agent.service >/dev/null 2>&1 || : -%else - /sbin/service zabbix-agent try-restart >/dev/null 2>&1 || : -%endif -fi - - -%files -%doc AUTHORS ChangeLog COPYING NEWS README %{srcname}-fedora.README -%dir %{_sysconfdir}/%{srcname} -%config(noreplace) %{_sysconfdir}/zabbix_agentd.conf -%config(noreplace) %{_sysconfdir}/%{srcname}/zabbix_agentd.conf -%if 0%{?fedora} -%config(noreplace) %{_sysconfdir}/tmpfiles.d/zabbix.conf -%endif -%{_bindir}/zabbix_get -%{_bindir}/zabbix_sender -%{_mandir}/man1/zabbix_get.1* -%{_mandir}/man1/zabbix_sender.1* - -%files server -%doc misc/snmptrap/zabbix_trap_receiver.pl -%attr(0775,root,zabbix) %dir %{_localstatedir}/log/zabbix -%if 0%{?rhel} -%attr(0775,root,zabbix) %dir %{_localstatedir}/run/zabbix -%endif -%attr(0600,zabbixsrv,zabbix) %config(noreplace) %{_sysconfdir}/zabbix_server.conf -%config(noreplace) %{_sysconfdir}/%{srcname}/zabbix_server.conf -%config(noreplace) %{_sysconfdir}/%{srcname}/externalscripts -%config(noreplace) %{_sysconfdir}/%{srcname}/alertscripts -%config(noreplace) %{_sysconfdir}/logrotate.d/zabbix-server -%ghost %{_sbindir}/zabbix_server -%attr(0755,zabbixsrv,zabbix) %{_sharedstatedir}/zabbixsrv -%if 0%{?fedora} -%ghost %{_unitdir}/zabbix-server.service -%else -%{_initrddir}/zabbix-server -%endif -%{_mandir}/man8/zabbix_server.8* - -%files server-mysql -%{_datadir}/%{srcname}-mysql -%{_sbindir}/zabbix_server_mysql -%if 0%{?fedora} -%{_unitdir}/zabbix-server-mysql.service -%endif - -%files server-pgsql -%{_datadir}/%{srcname}-postgresql -%{_sbindir}/zabbix_server_pgsql -%if 0%{?fedora} -%{_unitdir}/zabbix-server-pgsql.service -%endif - -%files agent -%doc conf/zabbix_agentd/*.conf -%attr(0775,root,zabbix) %dir %{_localstatedir}/log/zabbix -%if 0%{?rhel} -%attr(0775,root,zabbix) %dir %{_localstatedir}/run/zabbix -%endif -%config(noreplace) %{_sysconfdir}/zabbix_agent.conf -%config(noreplace) %{_sysconfdir}/%{srcname}/zabbix_agent.conf -%config(noreplace) %{_sysconfdir}/zabbix_agentd.conf -%config(noreplace) %{_sysconfdir}/%{srcname}/zabbix_agentd.conf -%config(noreplace) %{_sysconfdir}/logrotate.d/zabbix-agent -%attr(0755,zabbix,zabbix) %dir %{_sharedstatedir}/zabbix -%if 0%{?fedora} -%{_unitdir}/zabbix-agent.service -%else -%{_initrddir}/zabbix-agent -%endif -%{_sbindir}/zabbix_agent -%{_sbindir}/zabbix_agentd -%{_mandir}/man8/zabbix_agentd.8* - -%files proxy -%doc misc/snmptrap/zabbix_trap_receiver.pl -%attr(0775,root,zabbix) %dir %{_localstatedir}/log/zabbix -%if 0%{?rhel} -%attr(0775,root,zabbix) %dir %{_localstatedir}/run/zabbix -%endif -%attr(0600,zabbixsrv,zabbix) %config(noreplace) %{_sysconfdir}/zabbix_proxy.conf -%config(noreplace) %{_sysconfdir}/%{srcname}/zabbix_proxy.conf -%config(noreplace) %{_sysconfdir}/%{srcname}/externalscripts -%config(noreplace) %{_sysconfdir}/logrotate.d/zabbix-proxy -%ghost %{_sbindir}/zabbix_proxy -%attr(0755,zabbixsrv,zabbix) %{_sharedstatedir}/zabbixsrv -%if 0%{?fedora} -%ghost %{_unitdir}/zabbix-proxy.service -%else -%{_initrddir}/zabbix-proxy -%endif -%{_mandir}/man8/zabbix_proxy.8* - -%files proxy-mysql -%{_datadir}/%{srcname}-mysql -%{_sbindir}/zabbix_proxy_mysql -%if 0%{?fedora} -%{_unitdir}/zabbix-proxy-mysql.service -%endif - -%files proxy-pgsql -%{_datadir}/%{srcname}-postgresql -%{_sbindir}/zabbix_proxy_pgsql -%if 0%{?fedora} -%{_unitdir}/zabbix-proxy-pgsql.service -%endif - -%files proxy-sqlite3 -%{_datadir}/%{srcname}-sqlite3 -%{_sbindir}/zabbix_proxy_sqlite3 -%if 0%{?fedora} -%{_unitdir}/zabbix-proxy-sqlite3.service -%endif - -%files web -%dir %attr(0750,apache,apache) %{_sysconfdir}/%{srcname}/web -%ghost %attr(0644,apache,apache) %config(noreplace) %{_sysconfdir}/%{srcname}/web/zabbix.conf.php -%attr(0644,apache,apache) %config(noreplace) %{_sysconfdir}/%{srcname}/web/maintenance.inc.php -%config(noreplace) %{_sysconfdir}/httpd/conf.d/zabbix.conf -%{_datadir}/%{srcname} - -%files web-mysql - -%files web-pgsql - -%changelog -* Fri Jun 23 2017 Volker Fröhlich - 2.0.21-1 -- New upstream release - -* Sun Dec 11 2016 Volker Fröhlich - 2.0.20-1 -- New upstream release - -* Sun Oct 09 2016 Volker Fröhlich - 2.0.19-1 -- New upstream release - -* Thu Nov 12 2015 Volker Fröhlich - 2.0.16-1 -- New upstream release - -* Tue Aug 11 2015 Volker Fröhlich - 2.0.15-1 -- New upstream release -- Remove su instruction from logrotate config file (BZ 1202602, 1251728) - - -* Thu Sep 25 2014 Volker Fröhlich - 2.0.13-2 -- Correct typo "etent" --> "getent" - -* Thu Sep 11 2014 Volker Fröhlich - 2.0.13-1 -- New upstream release; Remove obsolete patches for ZBX-8151 and ZBX-8238 -- Use the upstream tarball, now that non-free json was replaced with android-json -- Clean between builds, otherwise zabbix_{proxy,server} are compiled - again on install; make server and proxy package noarch now -- Harmonize package descriptions and summaries -- Sort out /var/run ownership issue when only installing the agent - -* Fri Jun 20 2014 Volker Fröhlich - 2.0.12-2 -- Patch for ZBX-8151 (Local file inclusion via XXE attack) -- CVE-2014-3005 - -* Tue Jun 3 2014 Volker Fröhlich - 2.0.12-1 -- New upstream release -- Patch for ZBX-8238 (logrt may continue reading an old file repeatedly) - -* Tue Jun 3 2014 Volker Fröhlich - 2.0.11-2 -- Handle su directive in logrotate configuration properly (BZ1074318) - -* Wed Feb 12 2014 Volker Fröhlich - 2.0.11-1 -- New upstream release -- Truncate changelog - -* Sun Dec 15 2013 Volker Fröhlich - 2.0.10-2 -- The start function of the proxy init script had a typo causing failure -- Improved the section on running multiple instances in the README - -* Fri Dec 13 2013 Volker Fröhlich - 2.0.10-1 -- New upstream release -- Drop obsolete patch ZBX-7479 -- Improve init scripts to not kill other instances (BZ#1018293) -- General overhaul of init scripts and documentation in README -- Harmonize scriptlet if-clause style - -* Sun Nov 3 2013 Volker Fröhlich - 2.0.9-2 -- Fix vulnerability for remote command execution injection - (ZBX-7479, CVE-2013-6824) - -* Wed Oct 9 2013 Volker Fröhlich - 2.0.9-1 -- New upstream release -- Drop obsolete patches ZBX-6804, ZBX-7091, ZBX-6922, ZBX-6992 - -* Mon Sep 23 2013 Volker Fröhlich - 2.0.8-3 -- Add SQL speed-up patch (ZBX-6804) -- Add SQL injection vulnerability patch (ZBX-7091, CVE-2013-5743) -- Add patch for failing XML host import (ZBX-6922) - -* Fri Sep 13 2013 Volker Fröhlich - 2.0.8-2 -- Add php-ldap as a requirement for the frontend -- Add patch for ZBX-6992 - -* Fri Aug 23 2013 Volker Fröhlich - 2.0.8-1 -- New upstream release -- Create and configure a spooling directory for fping files outside of /tmp -- Update README to reflect that and add a SELinux section -- Drop PrivateTmp from systemd unit files -- Drop patch for ZBX-6526 (solved upstream) -- Drop patch for CVE-2012-6086 (solved upstream) -- Correct path for the flash applet when removing -- Truncate changelog - -* Tue Jul 30 2013 Volker Fröhlich - 2.0.6-3 -- Backport fix for CVE-2012-6086 - -* Tue May 07 2013 Volker Fröhlich - 2.0.6-2 -- Add patch for ZBX-6526 -- Solve permission problem with /var/run/zabbix in Fedora (BZ#904041) -- Remove origin of directories BZ#867159, comment 14 and 16 - -* Mon Apr 22 2013 Volker Fröhlich - 2.0.6-1 -- New upstream release -- Drop ZBX-6290 and ZBX-6318 patches - -* Tue Mar 19 2013 Volker Fröhlich - 2.0.5-3 -- Include patch for ZBX-6318 - -* Tue Feb 12 2013 Volker Fröhlich - 2.0.5-2 -- Include patch for ZBX-6290 - -* Tue Feb 12 2013 Volker Fröhlich - 2.0.5-1 -- New upstream release -- Drop now-included patches -- Init file comments point to the actual configuration files now - -* Sat Feb 9 2013 Volker Fröhlich - 2.0.4-5 -- Dispensable version of COPYING is no more -- Correct path to traceroute in DB dumps again - -* Tue Jan 22 2013 Volker Fröhlich - 2.0.4-4 -- Remove zabbix_get plus manpage from the proxy files section -- Solve conflict for externalscripts symlink between proxy and - server package - -* Thu Jan 17 2013 Volker Fröhlich - 2.0.4-3 -- Patch for CVE-2013-1364 - -* Mon Jan 14 2013 Volker Fröhlich - 2.0.4-2 -- Apply patch for ZBX-6101 -- Add su line to logrotate config file -- Do not own /var/run/zabbix on Fedora, systemd manages it -- Add forgotten chkconfig and service commands on agent preun script - -* Sat Dec 8 2012 Volker Fröhlich - 2.0.4-1 -- New upstream release - -* Fri Dec 7 2012 Volker Fröhlich - 2.0.3-7 -- Add SNMP source IP address patch - -* Mon Nov 26 2012 Volker Fröhlich - 2.0.3-6 -- Apply fping 3 patch only for Fedora - -* Tue Nov 13 2012 Volker Fröhlich - 2.0.3-5 -- Adapt httpd configuration file for Apache 2.4 (BZ#871498) - -* Thu Nov 8 2012 Volker Fröhlich - 2.0.3-4 -- Require php explicitly again -- Remove traces of /usr/local in configuration files -- Improve Fedora README file - -* Sun Oct 14 2012 Volker Fröhlich - 2.0.3-3 -- Correct capitalization in unit files, init scripts and package description -- Improve sysconfig sourcing in init scripts -- Correct post-script permissions and owner on rpmnew files -- Obsolete sqlite web and server sub-package - -* Sun Oct 14 2012 Volker Fröhlich - 2.0.3-2 -- Include agent configuration file in base package for zabbix_sender -- Stricter permissions for server config file -- Adapt DB patches to our file layout -- Remove conditional around Source9 -- doc-sub-package obsolete only for Fedora, where the package keeps - the name "zabbix" -- Add missing requirement for proxy scriplet -- Remove Requires php because the PHP modules serve this purpose -- Use systemd's PrivateTmp only for F17 and up -- Correct proxy and server pre-scriplet (usergroup) - -* Fri Oct 5 2012 Volker Fröhlich - 2.0.3-1 -- New upstream release -- Add Fedora specific README - -* Mon Aug 27 2012 Volker Fröhlich - 2.0.2-3 -- Eliminate Sqlite server and web sub-package - They never worked and are considered experimental by upstream -- Harmonize conditionals -- Put maintenance configuration in web configuration directory -- Adapt man pages to file layout -- Remove backup files from frontend -- Move maintenance configuration file to /etc/... -- Move ExternalScripts and AlertScripts to daemon home directory -- Don't ship SQL scripts as documentation - -* Sun Aug 26 2012 Volker Fröhlich - 2.0.2-2 -- Use separate daemon users, so the agent can not parse the - database password -- Use PrivateTmp in unit files - -* Wed Aug 15 2012 Volker Fröhlich - 2.0.2-1 -- New upstream release -- Unified specfile for sys-v-init scripts and systemd -- Switch to Alternatives system -- Source from systemconfig in init scripts - -* Sun Jul 22 2012 Fedora Release Engineering - 2.0.1-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild - -* Thu Jul 12 2012 Dan Horák - 2.0.1-1 -- update to 2.0.1 -- rebased patches -- upstream location (/etc) for config files is used with symlinks to the old /etc/zabbix -- dropped our own SNMP trap processor, upstream one running directly under net-snmp daemon is used instead -- moved zabbix_get and zabbix_sender tools to the main package - -* Thu Jun 28 2012 Dan Horák - 1.8.14-1 -- update to 1.8.14 - -* Sat May 12 2012 Dan Horák - 1.8.13-1 -- update to 1.8.13 - -* Tue Apr 24 2012 Dan Horák - 1.8.12-1 -- update to 1.8.12 - -* Wed Mar 21 2012 Dan Horák - 1.8.11-1 -- update to 1.8.11 - -* Sat Jan 14 2012 Fedora Release Engineering - 1.8.10-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild - -* Wed Dec 28 2011 Dan Horák - 1.8.10-1 -- update to 1.8.10 (fixes CVE-2011-4615) - -* Thu Nov 24 2011 Dan Horák - 1.8.9-1 -- update to 1.8.9 -- switch to systemd units (#720065) -- drop empty docs subpackage -- drop spec compatibility with sysv-based systems - -* Wed Oct 5 2011 Dan Horák - 1.8.8-1 -- Update for 1.8.8 -- Drop the ZBX-4099 patch, that's now obsolete -- Remove two further htaccess files and put the configuration in - the main configuration file -- thanks to Volker Fröhlich for the changes above -- move zabbix_get to the server and proxy subpackages (#734512) -- remove prebuilt Windows binaries (#737341) -- remove flash clock applet (#737337) - -* Fri Sep 9 2011 Dan Horák - 1.8.7-2 -- fix server crash (ZBX-4099) - -* Mon Sep 5 2011 Dan Horák - 1.8.7-1 -- updated to 1.8.7 - -* Tue Aug 9 2011 Dan Horák - 1.8.6-1 -- updated to 1.8.6 (#729164, #729165) -- updated user/group adding scriptlet - -* Fri Jul 8 2011 Dan Horák - 1.8.5-5 -- rebuilt with net-snmp 5.7 - -* Mon Jun 13 2011 Dan Horák - 1.8.5-4 -- generalize the spec so creating packages like zabbix18 will be much easier - -* Fri Jun 3 2011 Dan Horák - 1.8.5-3 -- fix path to the traceroute utility -- add tmpfiles.d support for /var/run/zabbix (#656726) - -* Mon May 23 2011 Dan Horák - 1.8.5-2 -- include /var/lib/zabbix and /etc/zabbix/externalscripts dirs in package (#704181) -- add snmp trap receiver script in package (#705331) - -* Wed Apr 20 2011 Dan Horák - 1.8.5-1 -- updated to 1.8.5 - -* Wed Mar 23 2011 Dan Horák - 1.8.4-4 -- rebuilt for mysql 5.5.10 (soname bump in libmysqlclient) - -* Tue Feb 08 2011 Fedora Release Engineering - 1.8.4-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild - -* Tue Jan 18 2011 Dan Horák - 1.8.4-2 -- enable libcurl detection (#670500) - -* Tue Jan 4 2011 Dan Horák - 1.8.4-1 -- updated to 1.8.4 -- fixes zabbix_agent fail to start on IPv4-only host (#664639) - -* Tue Nov 23 2010 Dan Horák - 1.8.3-5 -- zabbix emailer doesn't handle multiline responses (#656072) - -* Mon Nov 1 2010 Dan Horák - 1.8.3-4 -- rebuilt with net-snmp 5.6 - -* Wed Sep 29 2010 jkeating - 1.8.3-3 -- Rebuilt for gcc bug 634757 - -* Mon Sep 6 2010 Dan Horák - 1.8.3-2 -- fix font path in patch2 (#630500) - -* Tue Aug 17 2010 Dan Horák - 1.8.3-1 -- updated to 1.8.3 - -* Wed Aug 11 2010 Dan Horák - 1.8.2-3 -- added patch for XSS in triggers page (#620809, ZBX-2326) - -* Thu Apr 29 2010 Dan Horák - 1.8.2-2 -- DejaVu fonts doesn't exist on EL <= 5 - -* Tue Mar 30 2010 Dan Horák - 1.8.2-1 -- Update to 1.8.2 - -* Sat Mar 20 2010 Dan Horák - 1.8.1-7 -- web interface needs php-xml (#572413) -- updated defaults in config files (#573325) -- built with libssh2 support (#575279) - -* Wed Feb 24 2010 Dan Horák - 1.8.1-6 -- use system fonts - -* Sat Feb 13 2010 Dan Horák - 1.8.1-5 -- fixed linking with the new --no-add-needed default (#564932) - -* Mon Feb 1 2010 Dan Horák - 1.8.1-4 -- enable dependency tracking - -* Mon Feb 1 2010 Dan Horák - 1.8.1-3 -- updated the web-config patch - -* Mon Feb 1 2010 Dan Horák - 1.8.1-2 -- close fd on exec (#559221) - -* Fri Jan 29 2010 Dan Horák - 1.8.1-1 -- Update to 1.8.1 - -* Tue Jan 26 2010 Dan Horák - 1.8-1 -- Update to 1.8