first commit
This commit is contained in:
144
inc/system/requirement/abstractrequirement.class.php
Normal file
144
inc/system/requirement/abstractrequirement.class.php
Normal file
@ -0,0 +1,144 @@
|
||||
<?php
|
||||
/**
|
||||
* ---------------------------------------------------------------------
|
||||
* GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2015-2020 Teclib' and contributors.
|
||||
*
|
||||
* http://glpi-project.org
|
||||
*
|
||||
* based on GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2003-2014 by the INDEPNET Development Team.
|
||||
*
|
||||
* ---------------------------------------------------------------------
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This file is part of GLPI.
|
||||
*
|
||||
* GLPI is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GLPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GLPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace Glpi\System\Requirement;
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Sorry. You can't access this file directly");
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 9.5.0
|
||||
*/
|
||||
abstract class AbstractRequirement implements RequirementInterface {
|
||||
|
||||
/**
|
||||
* Flag that indicates if requirement check has already been done.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $has_been_checked = false;
|
||||
|
||||
/**
|
||||
* Flag that indicates if requirement is considered as optional.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $optional = false;
|
||||
|
||||
/**
|
||||
* Flag that indicates if requirement is considered as out of context.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $out_of_context = false;
|
||||
|
||||
/**
|
||||
* Requirement title.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $title;
|
||||
|
||||
/**
|
||||
* Flag that indicates if requirement is validated on system.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $validated;
|
||||
|
||||
/**
|
||||
* Requirement validation message.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $validation_messages = [];
|
||||
|
||||
/**
|
||||
* Check requirement.
|
||||
*
|
||||
* This method will be called once before access to any RequirementInterface method
|
||||
* and should be used to compute $validated and $validation_messages properties.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function check();
|
||||
|
||||
/**
|
||||
* Run requirement check once.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function doCheck() {
|
||||
if (!$this->has_been_checked) {
|
||||
$this->check();
|
||||
$this->has_been_checked = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function getTitle(): string {
|
||||
$this->doCheck();
|
||||
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function getValidationMessages(): array {
|
||||
$this->doCheck();
|
||||
|
||||
return $this->validation_messages;
|
||||
}
|
||||
|
||||
public function isMissing(): bool {
|
||||
$this->doCheck();
|
||||
|
||||
return true !== $this->validated;
|
||||
}
|
||||
|
||||
public function isOptional(): bool {
|
||||
$this->doCheck();
|
||||
|
||||
return $this->optional;
|
||||
}
|
||||
|
||||
public function isOutOfContext(): bool {
|
||||
$this->doCheck();
|
||||
|
||||
return $this->out_of_context;
|
||||
}
|
||||
|
||||
public function isValidated(): bool {
|
||||
$this->doCheck();
|
||||
|
||||
return true === $this->validated;
|
||||
}
|
||||
|
||||
}
|
||||
73
inc/system/requirement/dbengine.class.php
Normal file
73
inc/system/requirement/dbengine.class.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* ---------------------------------------------------------------------
|
||||
* GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2015-2020 Teclib' and contributors.
|
||||
*
|
||||
* http://glpi-project.org
|
||||
*
|
||||
* based on GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2003-2014 by the INDEPNET Development Team.
|
||||
*
|
||||
* ---------------------------------------------------------------------
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This file is part of GLPI.
|
||||
*
|
||||
* GLPI is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GLPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GLPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace Glpi\System\Requirement;
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Sorry. You can't access this file directly");
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 9.5.0
|
||||
*/
|
||||
class DbEngine extends AbstractRequirement {
|
||||
|
||||
/**
|
||||
* DB instance.
|
||||
*
|
||||
* @var \DBmysql
|
||||
*/
|
||||
private $db;
|
||||
|
||||
public function __construct(\DBmysql $db) {
|
||||
$this->title = __('Testing DB engine version');
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
protected function check() {
|
||||
$version = preg_replace('/^((\d+\.?)+).*$/', '$1', $this->db->getVersion());
|
||||
|
||||
if (version_compare($version, '5.6', '>=')) {
|
||||
$this->validated = true;
|
||||
$this->validation_messages[] = sprintf(
|
||||
__('Database version seems correct (%s) - Perfect!'),
|
||||
$version
|
||||
);
|
||||
} else {
|
||||
$this->validated = false;
|
||||
$this->validation_messages[] = sprintf(
|
||||
__('Your database engine version seems too old: %s.'),
|
||||
$version
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
69
inc/system/requirement/dbtimezones.class.php
Normal file
69
inc/system/requirement/dbtimezones.class.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* ---------------------------------------------------------------------
|
||||
* GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2015-2020 Teclib' and contributors.
|
||||
*
|
||||
* http://glpi-project.org
|
||||
*
|
||||
* based on GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2003-2014 by the INDEPNET Development Team.
|
||||
*
|
||||
* ---------------------------------------------------------------------
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This file is part of GLPI.
|
||||
*
|
||||
* GLPI is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GLPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GLPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace Glpi\System\Requirement;
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Sorry. You can't access this file directly");
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 9.5.0
|
||||
*/
|
||||
class DbTimezones extends AbstractRequirement {
|
||||
|
||||
/**
|
||||
* DB instance.
|
||||
*
|
||||
* @var \DBmysql
|
||||
*/
|
||||
private $db;
|
||||
|
||||
public function __construct(\DBmysql $db) {
|
||||
$this->title = __('Testing DB timezone data');
|
||||
$this->db = $db;
|
||||
$this->optional = true;
|
||||
}
|
||||
|
||||
protected function check() {
|
||||
$tz_warning = '';
|
||||
$tz_available = $this->db->areTimezonesAvailable($tz_warning);
|
||||
|
||||
if (!$tz_available) {
|
||||
$this->validated = false;
|
||||
$this->validation_messages[] = $tz_warning;
|
||||
} else {
|
||||
$this->validated = true;
|
||||
$this->validation_messages[] = __('Timezones seems loaded in database');
|
||||
}
|
||||
}
|
||||
}
|
||||
135
inc/system/requirement/directorywriteaccess.class.php
Normal file
135
inc/system/requirement/directorywriteaccess.class.php
Normal file
@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/**
|
||||
* ---------------------------------------------------------------------
|
||||
* GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2015-2020 Teclib' and contributors.
|
||||
*
|
||||
* http://glpi-project.org
|
||||
*
|
||||
* based on GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2003-2014 by the INDEPNET Development Team.
|
||||
*
|
||||
* ---------------------------------------------------------------------
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This file is part of GLPI.
|
||||
*
|
||||
* GLPI is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GLPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GLPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace Glpi\System\Requirement;
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Sorry. You can't access this file directly");
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 9.5.0
|
||||
*/
|
||||
class DirectoryWriteAccess extends AbstractRequirement {
|
||||
|
||||
/**
|
||||
* Directory path.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $path;
|
||||
|
||||
/**
|
||||
* @param string $path Directory path.
|
||||
* @param bool $optional Indicated if write access is optional.
|
||||
*/
|
||||
public function __construct(string $path, bool $optional = false) {
|
||||
$this->path = $path;
|
||||
$this->optional = $optional;
|
||||
|
||||
switch (realpath($this->path)) {
|
||||
case realpath(GLPI_CACHE_DIR):
|
||||
$this->title = __('Checking write permissions for cache files');
|
||||
break;
|
||||
case realpath(GLPI_CONFIG_DIR):
|
||||
$this->title = __('Checking write permissions for setting files');
|
||||
break;
|
||||
case realpath(GLPI_CRON_DIR):
|
||||
$this->title = __('Checking write permissions for automatic actions files');
|
||||
break;
|
||||
case realpath(GLPI_DOC_DIR):
|
||||
$this->title = __('Checking write permissions for document files');
|
||||
break;
|
||||
case realpath(GLPI_DUMP_DIR):
|
||||
$this->title = __('Checking write permissions for dump files');
|
||||
break;
|
||||
case realpath(GLPI_GRAPH_DIR):
|
||||
$this->title = __('Checking write permissions for graphic files');
|
||||
break;
|
||||
case realpath(GLPI_LOCK_DIR):
|
||||
$this->title = __('Checking write permissions for lock files');
|
||||
break;
|
||||
case realpath(GLPI_MARKETPLACE_DIR):
|
||||
$this->title = __('Checking write permissions for marketplace plugins directory');
|
||||
break;
|
||||
case realpath(GLPI_PLUGIN_DOC_DIR):
|
||||
$this->title = __('Checking write permissions for plugins document files');
|
||||
break;
|
||||
case realpath(GLPI_PICTURE_DIR):
|
||||
$this->title = __('Checking write permissions for pictures files');
|
||||
break;
|
||||
case realpath(GLPI_RSS_DIR):
|
||||
$this->title = __('Checking write permissions for rss files');
|
||||
break;
|
||||
case realpath(GLPI_SESSION_DIR):
|
||||
$this->title = __('Checking write permissions for session files');
|
||||
break;
|
||||
case realpath(GLPI_TMP_DIR):
|
||||
$this->title = __('Checking write permissions for temporary files');
|
||||
break;
|
||||
case realpath(GLPI_UPLOAD_DIR):
|
||||
$this->title = __('Checking write permissions for upload files');
|
||||
break;
|
||||
default:
|
||||
$this->title = sprintf(__('Checking write permissions for directory %s'), $this->path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected function check() {
|
||||
|
||||
$result = \Toolbox::testWriteAccessToDirectory($this->path);
|
||||
|
||||
$this->validated = $result === 0;
|
||||
|
||||
if (0 === $result) {
|
||||
$this->validated = true;
|
||||
$this->validation_messages[] = sprintf(__('Write access to %s has been validated.'), $this->path);
|
||||
} else {
|
||||
switch ($result) {
|
||||
case 1:
|
||||
$this->validation_messages[] = sprintf(__("The file was created in %s but can't be deleted."), $this->path);
|
||||
break;
|
||||
case 2:
|
||||
$this->validation_messages[] = sprintf(__('The file could not be created in %s.'), $this->path);
|
||||
break;
|
||||
case 3:
|
||||
$this->validation_messages[] = sprintf(__('The directory was created in %s but could not be removed.'), $this->path);
|
||||
break;
|
||||
case 4:
|
||||
$this->validation_messages[] = sprintf(__('The directory could not be created in %s.'), $this->path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
80
inc/system/requirement/extension.class.php
Normal file
80
inc/system/requirement/extension.class.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* ---------------------------------------------------------------------
|
||||
* GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2015-2020 Teclib' and contributors.
|
||||
*
|
||||
* http://glpi-project.org
|
||||
*
|
||||
* based on GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2003-2014 by the INDEPNET Development Team.
|
||||
*
|
||||
* ---------------------------------------------------------------------
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This file is part of GLPI.
|
||||
*
|
||||
* GLPI is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GLPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GLPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace Glpi\System\Requirement;
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Sorry. You can't access this file directly");
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 9.5.0
|
||||
*/
|
||||
class Extension extends AbstractRequirement {
|
||||
|
||||
/**
|
||||
* Required extension name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* @param string $name Required extension name.
|
||||
* @param bool $optional Indicated if extension is optional.
|
||||
*/
|
||||
public function __construct(string $name, bool $optional = false) {
|
||||
$this->title = sprintf(__('%s extension test'), $name);
|
||||
$this->name = $name;
|
||||
$this->optional = $optional;
|
||||
}
|
||||
|
||||
protected function check() {
|
||||
$this->validated = extension_loaded($this->name);
|
||||
$this->buildValidationMessage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the validation message based on self properties.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function buildValidationMessage() {
|
||||
if ($this->validated) {
|
||||
$this->validation_messages[] = sprintf(__('%s extension is installed'), $this->name);
|
||||
} else if ($this->optional) {
|
||||
$this->validation_messages[] = sprintf(__('%s extension is not present'), $this->name);
|
||||
} else {
|
||||
$this->validation_messages[] = sprintf(__('%s extension is missing'), $this->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
66
inc/system/requirement/extensionclass.class.php
Normal file
66
inc/system/requirement/extensionclass.class.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* ---------------------------------------------------------------------
|
||||
* GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2015-2020 Teclib' and contributors.
|
||||
*
|
||||
* http://glpi-project.org
|
||||
*
|
||||
* based on GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2003-2014 by the INDEPNET Development Team.
|
||||
*
|
||||
* ---------------------------------------------------------------------
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This file is part of GLPI.
|
||||
*
|
||||
* GLPI is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GLPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GLPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace Glpi\System\Requirement;
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Sorry. You can't access this file directly");
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 9.5.0
|
||||
*/
|
||||
class ExtensionClass extends Extension {
|
||||
|
||||
/**
|
||||
* Required class or interface name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $class_name;
|
||||
|
||||
/**
|
||||
* @param string $name Extension name.
|
||||
* @param string $class_name Required class or interface name.
|
||||
* @param bool $optional Indicated if extension is optional.
|
||||
*/
|
||||
public function __construct(string $name, string $class_name, bool $optional = false) {
|
||||
parent::__construct($name, $optional);
|
||||
$this->class_name = $class_name;
|
||||
}
|
||||
|
||||
protected function check() {
|
||||
$this->validated = class_exists($this->class_name) || interface_exists($this->class_name);
|
||||
$this->buildValidationMessage();
|
||||
}
|
||||
|
||||
}
|
||||
66
inc/system/requirement/extensionfunction.class.php
Normal file
66
inc/system/requirement/extensionfunction.class.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* ---------------------------------------------------------------------
|
||||
* GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2015-2020 Teclib' and contributors.
|
||||
*
|
||||
* http://glpi-project.org
|
||||
*
|
||||
* based on GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2003-2014 by the INDEPNET Development Team.
|
||||
*
|
||||
* ---------------------------------------------------------------------
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This file is part of GLPI.
|
||||
*
|
||||
* GLPI is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GLPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GLPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace Glpi\System\Requirement;
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Sorry. You can't access this file directly");
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 9.5.0
|
||||
*/
|
||||
class ExtensionFunction extends Extension {
|
||||
|
||||
/**
|
||||
* Required function name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $function_name;
|
||||
|
||||
/**
|
||||
* @param string $name Extension name.
|
||||
* @param string $function_name Required function name.
|
||||
* @param bool $optional Indicated if extension is optional.
|
||||
*/
|
||||
public function __construct(string $name, string $function_name, bool $optional = false) {
|
||||
parent::__construct($name, $optional);
|
||||
$this->function_name = $function_name;
|
||||
}
|
||||
|
||||
protected function check() {
|
||||
$this->validated = function_exists($this->function_name);
|
||||
$this->buildValidationMessage();
|
||||
}
|
||||
|
||||
}
|
||||
73
inc/system/requirement/logswriteaccess.class.php
Normal file
73
inc/system/requirement/logswriteaccess.class.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* ---------------------------------------------------------------------
|
||||
* GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2015-2020 Teclib' and contributors.
|
||||
*
|
||||
* http://glpi-project.org
|
||||
*
|
||||
* based on GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2003-2014 by the INDEPNET Development Team.
|
||||
*
|
||||
* ---------------------------------------------------------------------
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This file is part of GLPI.
|
||||
*
|
||||
* GLPI is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GLPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GLPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace Glpi\System\Requirement;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Sorry. You can't access this file directly");
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 9.5.0
|
||||
*/
|
||||
class LogsWriteAccess extends AbstractRequirement {
|
||||
|
||||
/**
|
||||
* Logger.
|
||||
*
|
||||
* @var LoggerInterface
|
||||
*/
|
||||
private $logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param LoggerInterface $logger
|
||||
*/
|
||||
public function __construct(LoggerInterface $logger) {
|
||||
$this->logger = $logger;
|
||||
$this->title = __('Checking write permissions for log files');
|
||||
}
|
||||
|
||||
protected function check() {
|
||||
// Only write test for GLPI_LOG as SElinux prevent removing log file.
|
||||
try {
|
||||
$this->logger->warning('Test logger');
|
||||
$this->validated = true;
|
||||
$this->validation_messages[] = __('The log file has been created successfully.');
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
$this->validated = false;
|
||||
$this->validation_messages[] = sprintf(__('The log file could not be created in %s.'), GLPI_LOG_DIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
80
inc/system/requirement/memorylimit.class.php
Normal file
80
inc/system/requirement/memorylimit.class.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* ---------------------------------------------------------------------
|
||||
* GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2015-2020 Teclib' and contributors.
|
||||
*
|
||||
* http://glpi-project.org
|
||||
*
|
||||
* based on GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2003-2014 by the INDEPNET Development Team.
|
||||
*
|
||||
* ---------------------------------------------------------------------
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This file is part of GLPI.
|
||||
*
|
||||
* GLPI is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GLPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GLPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace Glpi\System\Requirement;
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Sorry. You can't access this file directly");
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 9.5.0
|
||||
*/
|
||||
class MemoryLimit extends AbstractRequirement {
|
||||
|
||||
/**
|
||||
* Minimal allocated memory size.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $min;
|
||||
|
||||
/**
|
||||
* @param int $min Minimal allocated memory.
|
||||
*/
|
||||
public function __construct(int $min) {
|
||||
$this->title = __('Allocated memory test');
|
||||
$this->min = $min;
|
||||
}
|
||||
|
||||
protected function check() {
|
||||
$limit = \Toolbox::getMemoryLimit();
|
||||
|
||||
/*
|
||||
* $limit can be:
|
||||
* -1 : unlimited
|
||||
* >0 : allocated bytes
|
||||
*/
|
||||
if ($limit == -1 || $limit >= $this->min) {
|
||||
$this->validated = true;
|
||||
$this->validation_messages[] = $limit > 0
|
||||
? sprintf(__('Allocated memory > %s - Perfect!'), \Toolbox::getSize($this->min))
|
||||
: __('Unlimited memory - Perfect!');
|
||||
} else {
|
||||
$this->validated = false;
|
||||
$this->validation_messages[] = sprintf( __('%1$s: %2$s'), __('Allocated memory'), \Toolbox::getSize($limit));
|
||||
$this->validation_messages[] = sprintf(__('A minimum of %s is commonly required for GLPI.'), \Toolbox::getSize($this->min));
|
||||
$this->validation_messages[] = __('Try increasing the memory_limit parameter in the php.ini file.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
66
inc/system/requirement/mysqlimysqlnd.class.php
Normal file
66
inc/system/requirement/mysqlimysqlnd.class.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* ---------------------------------------------------------------------
|
||||
* GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2015-2020 Teclib' and contributors.
|
||||
*
|
||||
* http://glpi-project.org
|
||||
*
|
||||
* based on GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2003-2014 by the INDEPNET Development Team.
|
||||
*
|
||||
* ---------------------------------------------------------------------
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This file is part of GLPI.
|
||||
*
|
||||
* GLPI is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GLPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GLPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace Glpi\System\Requirement;
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Sorry. You can't access this file directly");
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 9.5.1
|
||||
*/
|
||||
class MysqliMysqlnd extends Extension {
|
||||
|
||||
/**
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct('mysqli');
|
||||
}
|
||||
|
||||
protected function check() {
|
||||
$extension_loaded = extension_loaded('mysqli');
|
||||
$driver_is_mysqlnd = defined('MYSQLI_OPT_INT_AND_FLOAT_NATIVE');
|
||||
|
||||
// We check for "mysqli_fetch_all" function to be sure that the used driver is "mysqlnd".
|
||||
// Indeed, it is mandatory to be able to use MYSQLI_OPT_INT_AND_FLOAT_NATIVE option.
|
||||
$this->validated = $extension_loaded && $driver_is_mysqlnd;
|
||||
|
||||
if ($extension_loaded && $driver_is_mysqlnd) {
|
||||
$this->validation_messages[] = sprintf(__('%s extension is installed'), $this->name);
|
||||
} else if ($extension_loaded && !$driver_is_mysqlnd) {
|
||||
$this->validation_messages[] = sprintf(__('%s extension is installed but is not using mysqlnd driver'), $this->name);
|
||||
} else {
|
||||
$this->validation_messages[] = sprintf(__('%s extension is missing'), $this->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
67
inc/system/requirement/phpversion.class.php
Normal file
67
inc/system/requirement/phpversion.class.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* ---------------------------------------------------------------------
|
||||
* GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2015-2020 Teclib' and contributors.
|
||||
*
|
||||
* http://glpi-project.org
|
||||
*
|
||||
* based on GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2003-2014 by the INDEPNET Development Team.
|
||||
*
|
||||
* ---------------------------------------------------------------------
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This file is part of GLPI.
|
||||
*
|
||||
* GLPI is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GLPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GLPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace Glpi\System\Requirement;
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Sorry. You can't access this file directly");
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 9.5.0
|
||||
*/
|
||||
class PhpVersion extends AbstractRequirement {
|
||||
|
||||
/**
|
||||
* Minimal required PHP version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $min_version;
|
||||
|
||||
/**
|
||||
* @param string $min_version Minimal required PHP version
|
||||
*/
|
||||
public function __construct(string $min_version) {
|
||||
$this->title = __('Testing PHP Parser');
|
||||
$this->min_version = $min_version;
|
||||
}
|
||||
|
||||
protected function check() {
|
||||
$this->validated = version_compare(PHP_VERSION, $this->min_version, '>=');
|
||||
|
||||
$this->validation_messages[] = $this->validated
|
||||
? sprintf(__('PHP version is at least %s - Perfect!'), $this->min_version)
|
||||
: sprintf(__('You must install at least PHP %s.'), $this->min_version);
|
||||
}
|
||||
|
||||
}
|
||||
128
inc/system/requirement/protectedwebaccess.class.php
Normal file
128
inc/system/requirement/protectedwebaccess.class.php
Normal file
@ -0,0 +1,128 @@
|
||||
<?php
|
||||
/**
|
||||
* ---------------------------------------------------------------------
|
||||
* GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2015-2020 Teclib' and contributors.
|
||||
*
|
||||
* http://glpi-project.org
|
||||
*
|
||||
* based on GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2003-2014 by the INDEPNET Development Team.
|
||||
*
|
||||
* ---------------------------------------------------------------------
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This file is part of GLPI.
|
||||
*
|
||||
* GLPI is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GLPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GLPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace Glpi\System\Requirement;
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Sorry. You can't access this file directly");
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 9.5.0
|
||||
*
|
||||
* @TODO Check access to each directory, not only to log file.
|
||||
*/
|
||||
class ProtectedWebAccess extends AbstractRequirement {
|
||||
|
||||
/**
|
||||
* Paths of directories to check.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private $directories;
|
||||
|
||||
/**
|
||||
* @param array $directories Paths of directories to check.
|
||||
*/
|
||||
public function __construct(array $directories) {
|
||||
$this->title = __('Web access to files directory is protected');
|
||||
$this->optional = true;
|
||||
|
||||
$this->directories = $directories;
|
||||
}
|
||||
|
||||
protected function check() {
|
||||
global $CFG_GLPI;
|
||||
|
||||
if (isCommandLine()) {
|
||||
$this->out_of_context = true;
|
||||
$this->validated = false;
|
||||
$this->validation_messages[] = __('Checking that web access to files directory is protected cannot be done on CLI context.');
|
||||
return;
|
||||
}
|
||||
|
||||
$check_access = false;
|
||||
foreach ($this->directories as $dir) {
|
||||
if (\Toolbox::startsWith($dir, GLPI_ROOT)) {
|
||||
// Only check access if one of the data directories is under GLPI document root.
|
||||
$check_access = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['skipCheckWriteAccessToDirs']) || !$check_access) {
|
||||
$this->out_of_context = true;
|
||||
return;
|
||||
}
|
||||
|
||||
$oldhand = set_error_handler(function($errno, $errmsg, $filename, $linenum, $vars){return true;});
|
||||
$oldlevel = error_reporting(0);
|
||||
|
||||
//create a context to set timeout
|
||||
$context = stream_context_create([
|
||||
'http' => [
|
||||
'timeout' => 2.0
|
||||
]
|
||||
]);
|
||||
|
||||
$protocol = 'http';
|
||||
if (isset($_SERVER['HTTPS'])) {
|
||||
$protocol = 'https';
|
||||
}
|
||||
$uri = $protocol . '://' . $_SERVER['SERVER_NAME'] . $CFG_GLPI['root_doc'];
|
||||
|
||||
if ($fic = fopen($uri.'/index.php?skipCheckWriteAccessToDirs=1', 'r', false, $context)) {
|
||||
fclose($fic);
|
||||
if ($fic = fopen($uri.'/files/_log/php-errors.log', 'r', false, $context)) {
|
||||
fclose($fic);
|
||||
|
||||
$this->validated = false;
|
||||
$this->validation_messages[] = __('Web access to the files directory should not be allowed');
|
||||
$this->validation_messages[] = __('Check the .htaccess file and the web server configuration.');
|
||||
} else {
|
||||
$this->validated = true;
|
||||
$this->validation_messages[] = __('Web access to files directory is protected');
|
||||
}
|
||||
} else {
|
||||
$this->validated = false;
|
||||
$this->validation_messages[] = __('Web access to the files directory should not be allowed but this cannot be checked automatically on this instance.');
|
||||
$this->validation_messages[] = sprintf(
|
||||
__('Make sure access to %s (%s) is forbidden; otherwise review .htaccess file and web server configuration.'),
|
||||
__('error log file'),
|
||||
$CFG_GLPI['root_doc'] . '/files/_log/php-errors.log'
|
||||
);
|
||||
}
|
||||
|
||||
error_reporting($oldlevel);
|
||||
set_error_handler($oldhand);
|
||||
}
|
||||
}
|
||||
87
inc/system/requirement/requirementinterface.class.php
Normal file
87
inc/system/requirement/requirementinterface.class.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/**
|
||||
* ---------------------------------------------------------------------
|
||||
* GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2015-2020 Teclib' and contributors.
|
||||
*
|
||||
* http://glpi-project.org
|
||||
*
|
||||
* based on GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2003-2014 by the INDEPNET Development Team.
|
||||
*
|
||||
* ---------------------------------------------------------------------
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This file is part of GLPI.
|
||||
*
|
||||
* GLPI is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GLPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GLPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace Glpi\System\Requirement;
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Sorry. You can't access this file directly");
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 9.5.0
|
||||
*/
|
||||
interface RequirementInterface {
|
||||
|
||||
/**
|
||||
* Get the title of the requirement.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle(): string;
|
||||
|
||||
/**
|
||||
* Get the validation messages of the requirement.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getValidationMessages(): array;
|
||||
|
||||
/**
|
||||
* Indicates if requirement is missing on system.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isMissing(): bool;
|
||||
|
||||
/**
|
||||
* Indicates if requirement is considered as optional.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isOptional(): bool;
|
||||
|
||||
/**
|
||||
* Indicates if requirement is considered as out of context
|
||||
* (i.e. system is not compatible).
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isOutOfContext(): bool;
|
||||
|
||||
/**
|
||||
* Indicates if requirement is validated on system.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidated(): bool;
|
||||
|
||||
}
|
||||
138
inc/system/requirement/selinux.class.php
Normal file
138
inc/system/requirement/selinux.class.php
Normal file
@ -0,0 +1,138 @@
|
||||
<?php
|
||||
/**
|
||||
* ---------------------------------------------------------------------
|
||||
* GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2015-2020 Teclib' and contributors.
|
||||
*
|
||||
* http://glpi-project.org
|
||||
*
|
||||
* based on GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2003-2014 by the INDEPNET Development Team.
|
||||
*
|
||||
* ---------------------------------------------------------------------
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This file is part of GLPI.
|
||||
*
|
||||
* GLPI is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GLPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GLPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace Glpi\System\Requirement;
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Sorry. You can't access this file directly");
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 9.5.0
|
||||
*/
|
||||
class SeLinux extends AbstractRequirement {
|
||||
|
||||
public function __construct() {
|
||||
$this->title = __('Check SELinux configuration');
|
||||
$this->optional = true;
|
||||
}
|
||||
|
||||
protected function check() {
|
||||
$is_slash_separator = DIRECTORY_SEPARATOR == '/';
|
||||
$are_bin_existing = file_exists('/usr/sbin/getenforce') && file_exists('/usr/sbin/getsebool');
|
||||
$are_functions_existing = function_exists('selinux_is_enabled')
|
||||
&& function_exists('selinux_getenforce')
|
||||
&& function_exists('selinux_get_boolean_active');
|
||||
|
||||
if (!$is_slash_separator || (!$are_bin_existing && !$are_functions_existing)) {
|
||||
// This is not a SELinux system
|
||||
$this->out_of_context = true;
|
||||
$this->validated = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (function_exists('selinux_is_enabled') && function_exists('selinux_getenforce')) {
|
||||
// Use https://pecl.php.net/package/selinux
|
||||
if (!selinux_is_enabled()) {
|
||||
$mode = 'disabled';
|
||||
} else {
|
||||
$mode = selinux_getenforce();
|
||||
// Make it human readable, with same output as the command
|
||||
if ($mode == 1) {
|
||||
$mode = 'enforcing';
|
||||
} else if ($mode == 0) {
|
||||
$mode = 'permissive';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$mode = strtolower(exec('/usr/sbin/getenforce'));
|
||||
}
|
||||
if (!in_array($mode, ['enforcing', 'permissive', 'disabled'])) {
|
||||
$mode = 'unknown';
|
||||
}
|
||||
|
||||
//TRANS: %s is mode name (Permissive, Enforcing, Disabled or Unknown)
|
||||
$this->title = sprintf(__('SELinux mode is %s'), ucfirst($mode));
|
||||
|
||||
if ('enforcing' !== $mode) {
|
||||
$this->validated = false;
|
||||
$this->validation_messages[] = __('For security reasons, SELinux mode should be Enforcing.');
|
||||
return;
|
||||
}
|
||||
|
||||
// No need to check file context as DirectoryWriteAccess requirements will show issues
|
||||
|
||||
$bools = [
|
||||
'httpd_can_network_connect',
|
||||
'httpd_can_network_connect_db',
|
||||
'httpd_can_sendmail',
|
||||
];
|
||||
|
||||
$has_missing_boolean = false;
|
||||
|
||||
foreach ($bools as $bool) {
|
||||
if (function_exists('selinux_get_boolean_active')) {
|
||||
$state = selinux_get_boolean_active($bool);
|
||||
if ($state == 1) {
|
||||
$state = 'on';
|
||||
} else if ($state == 0) {
|
||||
$state = 'off';
|
||||
}
|
||||
} else {
|
||||
// command result is something like "httpd_can_network_connect --> on"
|
||||
$state = preg_replace(
|
||||
'/^.*(on|off)$/',
|
||||
'$1',
|
||||
strtolower(exec('/usr/sbin/getsebool ' . $bool))
|
||||
);
|
||||
}
|
||||
if (!in_array($state, ['on', 'off'])) {
|
||||
$state = 'unknown';
|
||||
}
|
||||
|
||||
if ('on' !== $state) {
|
||||
$has_missing_boolean = true;
|
||||
$this->validation_messages[] = sprintf(
|
||||
__('SELinux boolean %s is %s, some features may require this to be on.'),
|
||||
$bool,
|
||||
$state
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->validated = !$has_missing_boolean;
|
||||
|
||||
if (!$has_missing_boolean) {
|
||||
$this->validation_messages[] = __('SELinux configuration is OK.');
|
||||
}
|
||||
}
|
||||
}
|
||||
80
inc/system/requirement/sessionsconfiguration.class.php
Normal file
80
inc/system/requirement/sessionsconfiguration.class.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* ---------------------------------------------------------------------
|
||||
* GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2015-2020 Teclib' and contributors.
|
||||
*
|
||||
* http://glpi-project.org
|
||||
*
|
||||
* based on GLPI - Gestionnaire Libre de Parc Informatique
|
||||
* Copyright (C) 2003-2014 by the INDEPNET Development Team.
|
||||
*
|
||||
* ---------------------------------------------------------------------
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This file is part of GLPI.
|
||||
*
|
||||
* GLPI is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GLPI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GLPI. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace Glpi\System\Requirement;
|
||||
|
||||
if (!defined('GLPI_ROOT')) {
|
||||
die("Sorry. You can't access this file directly");
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 9.5.0
|
||||
*/
|
||||
class SessionsConfiguration extends AbstractRequirement {
|
||||
|
||||
public function __construct() {
|
||||
$this->title = __('Sessions test');
|
||||
}
|
||||
|
||||
protected function check() {
|
||||
// Check session extension
|
||||
if (!extension_loaded('session')) {
|
||||
$this->validated = false;
|
||||
$this->validation_messages[] = __('Your parser PHP is not installed with sessions support!');
|
||||
return;
|
||||
}
|
||||
|
||||
// Check configuration values
|
||||
$is_autostart_on = ini_get('session.auto_start') == 1;
|
||||
$is_usetranssid_on = ini_get('session.use_trans_sid') == 1
|
||||
|| isset($_POST[session_name()]) || isset($_GET[session_name()]);
|
||||
|
||||
if ($is_autostart_on || $is_usetranssid_on) {
|
||||
if ($is_autostart_on && $is_usetranssid_on) {
|
||||
$this->validation_messages[] = __('"session.auto_start" and "session.use_trans_sid" must be set to off.');
|
||||
} else if ($is_autostart_on) {
|
||||
$this->validation_messages[] = __('"session.auto_start" must be set to off.');
|
||||
} else {
|
||||
$this->validation_messages[] = __('"session.use_trans_sid" must be set to off.');
|
||||
}
|
||||
|
||||
$this->validated = false;
|
||||
$this->validation_messages[] = __('See .htaccess file in the GLPI root for more informations.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->validated = true;
|
||||
$this->validation_messages[] = __s('Sessions support is available - Perfect!');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user