From 4522cf5090ef7a514466637f8cae7dbb4c2f67b3 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 21 Jul 2015 15:27:01 +0200 Subject: [PATCH 01/11] Add missing return to IdoQuery::getCustomvarColumnName() Some filter combinations still seem to not work properly. refs #9692 --- .../Monitoring/Backend/Ido/Query/IdoQuery.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php index c5e9e5333..3f3918a13 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php @@ -496,6 +496,7 @@ abstract class IdoQuery extends DbQuery in_array($filter->getColumn(), $this->columnsWithoutCollation) && strpos($filter->getColumn(), 'LOWER') !== 0 ) { + $filter->setColumn('LOWER(' . $filter->getColumn() . ')'); $filter->setColumn('LOWER(' . $filter->getColumn() . ')'); $expression = $filter->getExpression(); if (is_array($expression)) { @@ -855,7 +856,6 @@ abstract class IdoQuery extends DbQuery protected function customvarNameToTypeName($customvar) { $customvar = strtolower($customvar); - // TODO: Improve this: if (! preg_match('~^_(host|service)_([a-zA-Z0-9_]+)$~', $customvar, $m)) { throw new ProgrammingError( 'Got invalid custom var: "%s"', @@ -870,11 +870,19 @@ abstract class IdoQuery extends DbQuery return array_key_exists($name, $this->joinedVirtualTables); } + /** + * Get the query column of a custom variable or null in case the custom variable has not been joined + * + * @param string $customvar + * + * @return null|string + */ protected function getCustomvarColumnName($customvar) { if (isset($this->customVars[($customvar = strtolower($customvar))])) { - $this->customVars[strtolower($customvar)] . '.varvalue'; + return $this->customVars[$customvar] . '.varvalue'; } + return null; } public function aliasToColumnName($alias) From 3ed13366a80abab42934bffee961a8fddb059670 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 22 Jul 2015 09:05:18 +0200 Subject: [PATCH 02/11] Remove duplicate line in IdoQuery I introduced this w/ 4522cf5090ef7a514466637f8cae7dbb4c2f67b3. --- .../monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php index 3f3918a13..52485d9cb 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php @@ -496,7 +496,6 @@ abstract class IdoQuery extends DbQuery in_array($filter->getColumn(), $this->columnsWithoutCollation) && strpos($filter->getColumn(), 'LOWER') !== 0 ) { - $filter->setColumn('LOWER(' . $filter->getColumn() . ')'); $filter->setColumn('LOWER(' . $filter->getColumn() . ')'); $expression = $filter->getExpression(); if (is_array($expression)) { From 15cb24c6dc38090f2b3d84503bc795d10ce1821b Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 22 Jul 2015 12:00:59 +0200 Subject: [PATCH 03/11] Throw an exception in IdoQuery::getCustomvarColumnName() in case the custom variable has not been joined Queries extending IdoQuery and using the method getCustomvarColumnName() must be notified in case the custom variable has not been joined. refs #9692 --- library/Icinga/Exception/QueryException.php | 2 +- .../Monitoring/Backend/Ido/Query/IdoQuery.php | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/library/Icinga/Exception/QueryException.php b/library/Icinga/Exception/QueryException.php index bfe98855a..abfd7402d 100644 --- a/library/Icinga/Exception/QueryException.php +++ b/library/Icinga/Exception/QueryException.php @@ -4,7 +4,7 @@ namespace Icinga\Exception; /** - * Exception thrown if a query contains invalid parameters + * Exception thrown if a query encountered an error */ class QueryException extends IcingaException { diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php index 52485d9cb..b79229f8f 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php @@ -12,6 +12,7 @@ use Icinga\Data\Filter\FilterExpression; use Icinga\Exception\IcingaException; use Icinga\Exception\NotImplementedError; use Icinga\Exception\ProgrammingError; +use Icinga\Exception\QueryException; use Icinga\Web\Session; /** @@ -870,18 +871,19 @@ abstract class IdoQuery extends DbQuery } /** - * Get the query column of a custom variable or null in case the custom variable has not been joined + * Get the query column of a already joined custom variable * * @param string $customvar * - * @return null|string + * @return string + * @throws QueryException If the custom variable has not been joined */ protected function getCustomvarColumnName($customvar) { - if (isset($this->customVars[($customvar = strtolower($customvar))])) { - return $this->customVars[$customvar] . '.varvalue'; + if (! isset($this->customVars[($customvar = strtolower($customvar))])) { + throw new QueryException('Custom variable %s has not been joined', $customvar); } - return null; + return $this->customVars[$customvar] . '.varvalue'; } public function aliasToColumnName($alias) From a75b1a35c6f22dbecd55f6ee38fb09bd1aa9baa1 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 22 Jul 2015 13:47:52 +0200 Subject: [PATCH 04/11] monitoring: Don't fail when selecting custom variables while having a group by clause refs #9692 --- .../Monitoring/Backend/Ido/Query/IdoQuery.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php index b79229f8f..de89d23bb 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php @@ -891,9 +891,19 @@ abstract class IdoQuery extends DbQuery return $this->idxAliasColumn[$alias]; } + /** + * Get the alias of a column expression as defined in the {@link $columnMap} property. + * + * @param string $alias Potential custom alias + * + * @return string + */ public function customAliasToAlias($alias) { - return $this->idxCustomAliases[$alias]; + if (isset($this->idxCustomAliases[$alias])) { + return $this->idxCustomAliases[$alias]; + } + return $alias; } /** From 1d3a0f63eb8f9391b77eeea8a81069287b55f71e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 23 Jul 2015 12:25:30 +0200 Subject: [PATCH 05/11] BackendConfigForm: Fix that skipping the schema validation is not possible fixes #9719 --- .../application/forms/Config/BackendConfigForm.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/forms/Config/BackendConfigForm.php b/modules/monitoring/application/forms/Config/BackendConfigForm.php index 504ec9a59..ade94128d 100644 --- a/modules/monitoring/application/forms/Config/BackendConfigForm.php +++ b/modules/monitoring/application/forms/Config/BackendConfigForm.php @@ -309,10 +309,15 @@ class BackendConfigForm extends ConfigForm return false; } - $resourceConfig = ResourceFactory::getResourceConfig($this->getValue('resource')); - if (! self::isValidIdoSchema($this, $resourceConfig) || !self::isValidIdoInstance($this, $resourceConfig)) { - $this->addSkipValidationCheckbox(); - return false; + if (($el = $this->getElement('skip_validation')) === null || false === $el->isChecked()) { + $resourceConfig = ResourceFactory::getResourceConfig($this->getValue('resource')); + if (! self::isValidIdoSchema($this, $resourceConfig) || !self::isValidIdoInstance($this, $resourceConfig)) { + if ($el === null) { + $this->addSkipValidationCheckbox(); + } + + return false; + } } return true; From 3ffe657f716e6642e7413687834db1878e22d459 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 23 Jul 2015 12:37:23 +0200 Subject: [PATCH 06/11] Puppet: Use future parser --- Vagrantfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Vagrantfile b/Vagrantfile index 198016789..11b5e2b9c 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -47,5 +47,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| puppet.module_path = [ ".puppet/modules", ".puppet/profiles" ] puppet.manifests_path = ".puppet/manifests" puppet.manifest_file = "site.pp" + puppet.options = "--parser=future" end end From 67af7b51350b7d3e9ae6e7a0bbfcb9891577cbcc Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 23 Jul 2015 12:39:12 +0200 Subject: [PATCH 07/11] Puppet: Don't install icinga2-debuginfo --- .puppet/modules/icinga2/manifests/init.pp | 8 ++------ .puppet/profiles/icinga2_dev/manifests/init.pp | 6 +++++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.puppet/modules/icinga2/manifests/init.pp b/.puppet/modules/icinga2/manifests/init.pp index 26c7300a5..e5b77ad75 100644 --- a/.puppet/modules/icinga2/manifests/init.pp +++ b/.puppet/modules/icinga2/manifests/init.pp @@ -15,7 +15,7 @@ class icinga2 { include icinga_packages package { [ - 'icinga2', 'icinga2-doc', 'icinga2-debuginfo' + 'icinga2', 'icinga2-doc' ]: ensure => latest, require => Class['icinga_packages'], @@ -35,12 +35,8 @@ class icinga2 { links => follow, owner => 'icinga', group => 'icinga', - mode => 6750, + mode => '6750', } icinga2::feature { [ 'statusdata', 'command', 'compatlog' ]: } - - icinga2::feature { 'api': - ensure => absent, - } } diff --git a/.puppet/profiles/icinga2_dev/manifests/init.pp b/.puppet/profiles/icinga2_dev/manifests/init.pp index 7082fe935..322480594 100644 --- a/.puppet/profiles/icinga2_dev/manifests/init.pp +++ b/.puppet/profiles/icinga2_dev/manifests/init.pp @@ -19,11 +19,15 @@ class icinga2_dev { include monitoring_test_config icinga2::config { [ - 'conf.d/test-config', 'conf.d/commands', 'constants', + 'conf.d/test-config', 'conf.d/commands', 'constants' ]: source => 'puppet:///modules/icinga2_dev', } + icinga2::feature { 'api': + ensure => absent, + } + icinga2::feature { 'ido-pgsql': ensure => absent, require => Class['icinga2_pgsql'], From af6def7d7f5e57dd9974cb70507083e7fb948151 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 23 Jul 2015 12:39:36 +0200 Subject: [PATCH 08/11] Puppet: Use strings for file modes --- .puppet/modules/icingaweb2/manifests/config/general.pp | 2 +- .puppet/modules/icingaweb2/manifests/config/module.pp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.puppet/modules/icingaweb2/manifests/config/general.pp b/.puppet/modules/icingaweb2/manifests/config/general.pp index 8ccea172f..200a4f79e 100644 --- a/.puppet/modules/icingaweb2/manifests/config/general.pp +++ b/.puppet/modules/icingaweb2/manifests/config/general.pp @@ -10,7 +10,7 @@ define icingaweb2::config::general ( content => template("${source}/${name}.ini.erb"), owner => 'root', group => $web_group, - mode => 0660, + mode => '0660', replace => $replace, } } diff --git a/.puppet/modules/icingaweb2/manifests/config/module.pp b/.puppet/modules/icingaweb2/manifests/config/module.pp index 19db02250..90d98d083 100644 --- a/.puppet/modules/icingaweb2/manifests/config/module.pp +++ b/.puppet/modules/icingaweb2/manifests/config/module.pp @@ -20,7 +20,7 @@ define icingaweb2::config::module ( source => "${source}/modules/${module}/${name}.ini", owner => 'root', group => $web_group, - mode => 0660, + mode => '0660', replace => $replace, } } From b4861fe689d2086919359305c3618f27942c0156 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 23 Jul 2015 12:40:12 +0200 Subject: [PATCH 09/11] Puppet: Set date.timezone for PHP in a separate INI file --- .puppet/modules/php/manifests/init.pp | 17 ++------------- .puppet/modules/php/manifests/phpd.pp | 21 +++++++++++++++++++ .../modules/php/templates/timezone.ini.erb | 1 + 3 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 .puppet/modules/php/manifests/phpd.pp create mode 100644 .puppet/modules/php/templates/timezone.ini.erb diff --git a/.puppet/modules/php/manifests/init.pp b/.puppet/modules/php/manifests/init.pp index dd6df83b3..788ad5df1 100644 --- a/.puppet/modules/php/manifests/init.pp +++ b/.puppet/modules/php/manifests/init.pp @@ -20,24 +20,11 @@ class php { package { 'php': ensure => latest, - require => Package['apache'], - notify => Service['apache'] - } - # TODO(el): Always executed. Should be a resource - -> exec { 'php-timezone': - command => 'sed -re $\'s#^;?(date\\.timezone =).*$#\\1 "UTC"#\' -i /etc/php.ini', notify => Service['apache'], + require => Package['apache'], } - file { '/etc/php.d/error_reporting.ini': - content => template('php/error_reporting.ini.erb'), + php::phpd { ['error_reporting', 'timezone', 'xdebug_settings' ]: require => Package['php'], - notify => Service['apache'] - } - - file { '/etc/php.d/xdebug_settings.ini': - content => template('php/xdebug_settings.ini.erb'), - require => Package['php'], - notify => Service['apache'] } } diff --git a/.puppet/modules/php/manifests/phpd.pp b/.puppet/modules/php/manifests/phpd.pp new file mode 100644 index 000000000..4d59223cb --- /dev/null +++ b/.puppet/modules/php/manifests/phpd.pp @@ -0,0 +1,21 @@ +# define: php::phpd +# +# Provision php.d config +# +# Parameters: +# +# Actions: +# +# Requires: +# +# Sample Usage: +# +define php::phpd { + + include php + + file { "/etc/php.d/$name.ini": + content => template("php/$name.ini.erb"), + notify => Service['apache'], + } +} diff --git a/.puppet/modules/php/templates/timezone.ini.erb b/.puppet/modules/php/templates/timezone.ini.erb new file mode 100644 index 000000000..51e82763b --- /dev/null +++ b/.puppet/modules/php/templates/timezone.ini.erb @@ -0,0 +1 @@ +date.timezone = "UTC" From 593f90f330a2ab66ea1acd6896dd72ef9a5825fd Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 23 Jul 2015 12:40:51 +0200 Subject: [PATCH 10/11] Puppet: Fix that the LDAP server is empty when using CentOS 7 --- .puppet/modules/openldap/manifests/init.pp | 14 +++++++++++++- .../profiles/icingaweb2_dev/files/openldap/db.ldif | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.puppet/modules/openldap/manifests/init.pp b/.puppet/modules/openldap/manifests/init.pp index 069c4a157..11cc2b42a 100644 --- a/.puppet/modules/openldap/manifests/init.pp +++ b/.puppet/modules/openldap/manifests/init.pp @@ -20,6 +20,18 @@ class openldap { service { 'slapd': ensure => running, - require => Package['openldap-servers'] + require => Package['openldap-servers'], + } + + if versioncmp($::operatingsystemmajrelease, '7') >= 0 { + ['core', 'cosine', 'inetorgperson', 'nis', 'misc', 'openldap'].each |String $schema| { + exec { "slapd-schema-${schema}": + command => "ldapadd -Y EXTERNAL -H ldapi:// -f /etc/openldap/schema/${schema}.ldif", + group => 'root', + require => Package['openldap-servers'], + unless => "test -n \"$(find /etc/openldap/slapd.d/cn=config/cn=schema/ -name cn={*}${schema}.ldif -print -quit)\"", + user => 'root', + } + } } } diff --git a/.puppet/profiles/icingaweb2_dev/files/openldap/db.ldif b/.puppet/profiles/icingaweb2_dev/files/openldap/db.ldif index eab9b7bac..03263f9c3 100644 --- a/.puppet/profiles/icingaweb2_dev/files/openldap/db.ldif +++ b/.puppet/profiles/icingaweb2_dev/files/openldap/db.ldif @@ -6,7 +6,7 @@ olcRootPW: {SSHA}N/2WMqT8q7cElh7KUQz+p9TJbjmKv/u9 replace: olcRootDN olcRootDN: cn=admin,cn=config -dn: olcDatabase={2}bdb,cn=config +dn: olcDatabase={2}hdb,cn=config changetype: modify replace: olcRootPW olcRootPW: {SSHA}MxMpLBo2/TSymoIBf/Sb5iQac7Wwiur5 From 727a2d71411f781dd9cb1286accda249fb81db72 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Thu, 23 Jul 2015 13:48:49 +0200 Subject: [PATCH 11/11] Paginator: relax requirements to Paginatable * we need no full query interface here * introduced new interface "Paginatable" fixes #9483 --- library/Icinga/Data/Paginatable.php | 9 +++++++++ library/Icinga/Data/QueryInterface.php | 4 +--- library/Icinga/Web/Widget/Paginator.php | 8 ++++---- 3 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 library/Icinga/Data/Paginatable.php diff --git a/library/Icinga/Data/Paginatable.php b/library/Icinga/Data/Paginatable.php new file mode 100644 index 000000000..d9a6de397 --- /dev/null +++ b/library/Icinga/Data/Paginatable.php @@ -0,0 +1,9 @@ +query = $query; return $this;