mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-22 21:34:28 +02:00
parent
b764993091
commit
9c5878cbbe
@ -206,10 +206,8 @@ class Manager
|
|||||||
{
|
{
|
||||||
if (!$this->hasInstalled($name)) {
|
if (!$this->hasInstalled($name)) {
|
||||||
throw new ConfigurationError(
|
throw new ConfigurationError(
|
||||||
sprintf(
|
'Cannot enable module "%s". Module is not installed.',
|
||||||
'Cannot enable module "%s". Module is not installed.',
|
$name
|
||||||
$name
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,14 +266,18 @@ class Manager
|
|||||||
}
|
}
|
||||||
$link = $this->enableDir . '/' . $name;
|
$link = $this->enableDir . '/' . $name;
|
||||||
if (!file_exists($link)) {
|
if (!file_exists($link)) {
|
||||||
throw new ConfigurationError('Could not disable module. The module ' . $name . ' was not found.');
|
throw new ConfigurationError(
|
||||||
|
'Could not disable module. The module %s was not found.',
|
||||||
|
$name
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (!is_link($link)) {
|
if (!is_link($link)) {
|
||||||
throw new ConfigurationError(
|
throw new ConfigurationError(
|
||||||
'Could not disable module. The module "' . $name . '" is not a symlink. '
|
'Could not disable module. The module "%s" is not a symlink. '
|
||||||
. 'It looks like you have installed this module manually and moved it to your module folder. '
|
. 'It looks like you have installed this module manually and moved it to your module folder. '
|
||||||
. 'In order to dynamically enable and disable modules, you have to create a symlink to '
|
. 'In order to dynamically enable and disable modules, you have to create a symlink to '
|
||||||
. 'the enabled_modules folder.'
|
. 'the enabled_modules folder.',
|
||||||
|
$name
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,9 @@ class AuthChain implements Iterator
|
|||||||
} catch (ConfigurationError $e) {
|
} catch (ConfigurationError $e) {
|
||||||
Logger::error(
|
Logger::error(
|
||||||
new ConfigurationError(
|
new ConfigurationError(
|
||||||
'Cannot create authentication backend "' . $name . '". An exception was thrown:', 0, $e
|
'Cannot create authentication backend "%s". An exception was thrown:',
|
||||||
|
$name,
|
||||||
|
$e
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->next();
|
$this->next();
|
||||||
|
@ -54,16 +54,18 @@ abstract class UserBackend implements Countable
|
|||||||
// Use a custom backend class, this is only useful for testing
|
// Use a custom backend class, this is only useful for testing
|
||||||
if (!class_exists($backendConfig->class)) {
|
if (!class_exists($backendConfig->class)) {
|
||||||
throw new ConfigurationError(
|
throw new ConfigurationError(
|
||||||
'Authentication configuration for backend "' . $name . '" defines an invalid backend'
|
'Authentication configuration for backend "%s" defines an invalid backend class.'
|
||||||
. ' class. Backend class "' . $backendConfig->class. '" not found'
|
. ' Backend class "%s" not found',
|
||||||
|
$name,
|
||||||
|
$backendConfig->class
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return new $backendConfig->class($backendConfig);
|
return new $backendConfig->class($backendConfig);
|
||||||
}
|
}
|
||||||
if (($backendType = $backendConfig->backend) === null) {
|
if (($backendType = $backendConfig->backend) === null) {
|
||||||
throw new ConfigurationError(
|
throw new ConfigurationError(
|
||||||
'Authentication configuration for backend "' . $name
|
'Authentication configuration for backend "%s" is missing the backend directive',
|
||||||
. '" is missing the backend directive'
|
$name
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$backendType = strtolower($backendType);
|
$backendType = strtolower($backendType);
|
||||||
@ -74,8 +76,8 @@ abstract class UserBackend implements Countable
|
|||||||
}
|
}
|
||||||
if ($backendConfig->resource === null) {
|
if ($backendConfig->resource === null) {
|
||||||
throw new ConfigurationError(
|
throw new ConfigurationError(
|
||||||
'Authentication configuration for backend "' . $name
|
'Authentication configuration for backend "%s" is missing the resource directive',
|
||||||
. '" is missing the resource directive'
|
$name
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -100,22 +102,24 @@ abstract class UserBackend implements Countable
|
|||||||
case 'ldap':
|
case 'ldap':
|
||||||
if (($userClass = $backendConfig->user_class) === null) {
|
if (($userClass = $backendConfig->user_class) === null) {
|
||||||
throw new ConfigurationError(
|
throw new ConfigurationError(
|
||||||
'Authentication configuration for backend "' . $name
|
'Authentication configuration for backend "%s" is missing the user_class directive',
|
||||||
. '" is missing the user_class directive'
|
$name
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (($userNameAttribute = $backendConfig->user_name_attribute) === null) {
|
if (($userNameAttribute = $backendConfig->user_name_attribute) === null) {
|
||||||
throw new ConfigurationError(
|
throw new ConfigurationError(
|
||||||
'Authentication configuration for backend "' . $name
|
'Authentication configuration for backend "%s" is missing the user_name_attribute directive',
|
||||||
. '" is missing the user_name_attribute directive'
|
$name
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$backend = new LdapUserBackend($resource, $userClass, $userNameAttribute);
|
$backend = new LdapUserBackend($resource, $userClass, $userNameAttribute);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ConfigurationError(
|
throw new ConfigurationError(
|
||||||
'Authentication configuration for backend "' . $name. '" defines an invalid backend'
|
'Authentication configuration for backend "%s" defines an invalid backend type.'
|
||||||
. ' type. Backend type "' . $backendType . '" is not supported'
|
. ' Backend type "%s" is not supported',
|
||||||
|
$name,
|
||||||
|
$backendType
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$backend->setName($name);
|
$backend->setName($name);
|
||||||
|
@ -142,7 +142,10 @@ class DbConnection implements Selectable
|
|||||||
}
|
}
|
||||||
break;*/
|
break;*/
|
||||||
default:
|
default:
|
||||||
throw new ConfigurationError(sprintf('Backend "%s" is not supported', $this->dbType));
|
throw new ConfigurationError(
|
||||||
|
'Backend "%s" is not supported',
|
||||||
|
$this->dbType
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$this->dbAdapter = Zend_Db::factory($adapter, $adapterParamaters);
|
$this->dbAdapter = Zend_Db::factory($adapter, $adapterParamaters);
|
||||||
$this->dbAdapter->setFetchMode(Zend_Db::FETCH_OBJ);
|
$this->dbAdapter->setFetchMode(Zend_Db::FETCH_OBJ);
|
||||||
|
@ -39,7 +39,8 @@ class ResourceFactory implements ConfigAwareFactory
|
|||||||
self::assertResourcesExist();
|
self::assertResourcesExist();
|
||||||
if (($resourceConfig = self::$resources->get($resourceName)) === null) {
|
if (($resourceConfig = self::$resources->get($resourceName)) === null) {
|
||||||
throw new ConfigurationError(
|
throw new ConfigurationError(
|
||||||
'Cannot load resource config "' . $resourceName . '". Resource does not exist'
|
'Cannot load resource config "%s". Resource does not exist',
|
||||||
|
$resourceName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return $resourceConfig;
|
return $resourceConfig;
|
||||||
@ -113,7 +114,10 @@ class ResourceFactory implements ConfigAwareFactory
|
|||||||
$resource = new FileReader($config);
|
$resource = new FileReader($config);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ConfigurationError('Unsupported resource type "' . $config->type . '"');
|
throw new ConfigurationError(
|
||||||
|
'Unsupported resource type "%s"',
|
||||||
|
$config->type
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return $resource;
|
return $resource;
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,6 @@ namespace Icinga\Exception;
|
|||||||
* Class ConfigurationError
|
* Class ConfigurationError
|
||||||
* @package Icinga\Exception
|
* @package Icinga\Exception
|
||||||
*/
|
*/
|
||||||
class ConfigurationError extends \RuntimeException
|
class ConfigurationError extends IcingaException
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,10 @@ class Logger
|
|||||||
{
|
{
|
||||||
$class = 'Icinga\\Logger\\Writer\\' . ucfirst(strtolower($config->type)) . 'Writer';
|
$class = 'Icinga\\Logger\\Writer\\' . ucfirst(strtolower($config->type)) . 'Writer';
|
||||||
if (!class_exists($class)) {
|
if (!class_exists($class)) {
|
||||||
throw new ConfigurationError('Cannot find log writer of type "' . $config->type . '"');
|
throw new ConfigurationError(
|
||||||
|
'Cannot find log writer of type "%s"',
|
||||||
|
$config->type
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new $class($config);
|
return new $class($config);
|
||||||
|
@ -33,13 +33,20 @@ class FileWriter extends LogWriter
|
|||||||
$this->path = $config->target;
|
$this->path = $config->target;
|
||||||
|
|
||||||
if (substr($this->path, 0, 6) !== 'php://' && false === file_exists(dirname($this->path))) {
|
if (substr($this->path, 0, 6) !== 'php://' && false === file_exists(dirname($this->path))) {
|
||||||
throw new ConfigurationError('Log path "' . dirname($this->path) . '" does not exist');
|
throw new ConfigurationError(
|
||||||
|
'Log path "%s" does not exist',
|
||||||
|
dirname($this->path)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->write(''); // Avoid to handle such errors on every write access
|
$this->write(''); // Avoid to handle such errors on every write access
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw new ConfigurationError('Cannot write to log file "' . $this->path . '" (' . $e->getMessage() . ')');
|
throw new ConfigurationError(
|
||||||
|
'Cannot write to log file "%s" (%s)',
|
||||||
|
$this->path,
|
||||||
|
$e->getMessage()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,8 @@ class SyslogWriter extends LogWriter
|
|||||||
{
|
{
|
||||||
if (!array_key_exists($config->facility, $this->facilities)) {
|
if (!array_key_exists($config->facility, $this->facilities)) {
|
||||||
throw new ConfigurationError(
|
throw new ConfigurationError(
|
||||||
'Cannot create syslog writer with unknown facility "' . $config->facility . '"'
|
'Cannot create syslog writer with unknown facility "%s"',
|
||||||
|
$config->facility
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,11 +49,9 @@ class LocalPipe implements Transport
|
|||||||
$file->fflush();
|
$file->fflush();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw new ConfigurationError(
|
throw new ConfigurationError(
|
||||||
sprintf(
|
'Could not open icinga command pipe at "%s" (%s)',
|
||||||
'Could not open icinga command pipe at "%s" (%s)',
|
$this->path,
|
||||||
$this->path,
|
$e->getMessage()
|
||||||
$e->getMessage()
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +246,8 @@ class Reader implements IReader, Selectable
|
|||||||
{
|
{
|
||||||
if (!is_readable($this->config->object_file)) {
|
if (!is_readable($this->config->object_file)) {
|
||||||
throw new ConfigurationError(
|
throw new ConfigurationError(
|
||||||
'Can\'t read object-file "' . $this->config->object_file . '", check your configuration'
|
'Can\'t read object-file "%s", check your configuration',
|
||||||
|
$this->config->object_file
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!$this->parser) {
|
if (!$this->parser) {
|
||||||
@ -265,7 +266,8 @@ class Reader implements IReader, Selectable
|
|||||||
{
|
{
|
||||||
if (!is_readable($this->config->status_file)) {
|
if (!is_readable($this->config->status_file)) {
|
||||||
throw new ConfigurationError(
|
throw new ConfigurationError(
|
||||||
"Can't read status-file {$this->config->status_file}, check your configuration"
|
'Can\'t read status-file %s, check your configuration',
|
||||||
|
$this->config->status_file
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!$this->parser) {
|
if (!$this->parser) {
|
||||||
|
@ -127,7 +127,8 @@ abstract class PreferencesStore
|
|||||||
$storeClass = 'Icinga\\User\\Preferences\\Store\\' . $type . 'Store';
|
$storeClass = 'Icinga\\User\\Preferences\\Store\\' . $type . 'Store';
|
||||||
if (!class_exists($storeClass)) {
|
if (!class_exists($storeClass)) {
|
||||||
throw new ConfigurationError(
|
throw new ConfigurationError(
|
||||||
'Preferences configuration defines an invalid storage type. Storage type ' . $type . ' not found'
|
'Preferences configuration defines an invalid storage type. Storage type %s not found',
|
||||||
|
$type
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ class Pane extends AbstractWidget
|
|||||||
} elseif (is_string($component) && $url !== null) {
|
} elseif (is_string($component) && $url !== null) {
|
||||||
$this->components[$component] = new Component($component, $url, $this);
|
$this->components[$component] = new Component($component, $url, $this);
|
||||||
} else {
|
} else {
|
||||||
throw new ConfigurationError('Invalid component added: ' . $component);
|
throw new ConfigurationError('Invalid component added: %s', $component);
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ class Monitoring_CommandController extends Controller
|
|||||||
if ($targetConfig->get($instance)) {
|
if ($targetConfig->get($instance)) {
|
||||||
$this->target = new CommandPipe($targetConfig->get($instance));
|
$this->target = new CommandPipe($targetConfig->get($instance));
|
||||||
} else {
|
} else {
|
||||||
throw new ConfigurationError('Instance is not configured: '. $instance);
|
throw new ConfigurationError('Instance is not configured: %s', $instance);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($targetConfig && $targetInfo = $targetConfig->current()) {
|
if ($targetConfig && $targetInfo = $targetConfig->current()) {
|
||||||
|
@ -87,12 +87,13 @@ class Backend implements Selectable, Queryable, ConnectionInterface
|
|||||||
$backendConfig = $defaultBackend;
|
$backendConfig = $defaultBackend;
|
||||||
} else {
|
} else {
|
||||||
if (!array_key_exists($backendName, $allBackends)) {
|
if (!array_key_exists($backendName, $allBackends)) {
|
||||||
throw new ConfigurationError('No configuration for backend ' . $backendName);
|
throw new ConfigurationError('No configuration for backend %s', $backendName);
|
||||||
}
|
}
|
||||||
$backendConfig = $allBackends[$backendName];
|
$backendConfig = $allBackends[$backendName];
|
||||||
if ((bool) $backendConfig->get('disabled', false)) {
|
if ((bool) $backendConfig->get('disabled', false)) {
|
||||||
throw new ConfigurationError(
|
throw new ConfigurationError(
|
||||||
'Configuration for backend ' . $backendName . ' available but backend is disabled'
|
'Configuration for backend %s available but backend is disabled',
|
||||||
|
$backendName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user