Commit afcd9360 authored by Côme Chilliet's avatar Côme Chilliet

🚑 fix(logging) Remove view action, replace debug by error in logging

issue #6046
parent 56f4f7ef
......@@ -35,16 +35,16 @@
*/
class logging
{
static $validActions = ['modify','create','remove','copy','snapshot','view','security','debug'];
static $validActions = ['modify','create','remove','copy','snapshot','security','error'];
/*!
* \brief logging method
*
* \param $action One of these values (modify|create|remove|snapshot|copy|view|security|debug)
* \param $action One of these values (modify|create|remove|copy|snapshot|security|error)
*
* \param $objecttype represents the current edited objecttype, like user/user
* \param $objecttype represents the current edited objecttype, like user/user, or the event, like logout
*
* \param $object represents the current edited object dn
* \param $object represents the current edited object dn, or the target of the operation
*
* \param $changes_array An array containing names of all touched attributes
*
......
......@@ -189,23 +189,17 @@ function gosaRaiseError ($errno, $errstr, $errfile, $errline)
return;
}
/* Send all errors to logging class, except "Ldap : No such object" messages*/
if (class_exists('logging') && !preg_match('/No such object/', $errstr)) {
logging::log('error', 'php', $errfile, [], 'Type:'.$errno.', Message:'.$errstr.', File:'.$errfile.', Line: '.$errline);
}
/* Error messages are hidden in FusionDirectory, so we only send them to the logging class and abort here */
if (isset($config->data) && $config->get_cfg_value('displayerrors') != 'TRUE') {
/* Write to syslog */
if (class_exists('logging') && !preg_match('/No such object/', $errstr)) {
logging::log('view', 'error', '', [], "PHP error: $errstr ($errfile, line $errline)");
}
set_error_handler('gosaRaiseError', E_WARNING | E_NOTICE | E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE | E_STRICT);
return;
}
/* Send all errors to logging class, except "Ldap : No such object" messages*/
if (class_exists('logging') && !preg_match('/No such object/', $errstr)) {
logging::log('debug', 'all', $errfile, [], 'Type:'.$errno.', Message:'.$errstr.', File:'.$errfile.', Line: '.$errline);
}
/* Create header as needed */
if ($error_collector == "") {
......
......@@ -593,8 +593,7 @@ class simplePlugin implements SimpleTab
$ldap->cd($config->current['BASE']);
$ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $dst_dn));
if (!$ldap->rename_dn($src_dn, $dst_dn)) {
logging::log('debug', 'Ldap Protocol v3 implementation error, ldap_rename failed.',
"FROM: $src_dn -- TO: $dst_dn", [], $ldap->get_error());
logging::log('error', 'ldap', "FROM: $src_dn -- TO: $dst_dn", [], 'Ldap Protocol v3 implementation error, ldap_rename failed: '.$ldap->get_error());
@DEBUG(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, "Rename failed FROM: $src_dn -- TO: $dst_dn",
'Ldap Protocol v3 implementation error. Error:'.$ldap->get_error());
return $ldap->get_error();
......@@ -602,9 +601,7 @@ class simplePlugin implements SimpleTab
/* Update userinfo if necessary */
if (preg_match('/'.preg_quote($src_dn, '/').'$/i', $ui->dn)) {
$ui_dn = preg_replace('/'.preg_quote($src_dn, '/').'$/i', $dst_dn, $ui->dn);
logging::log('view', 'acl/'.get_class($this), $this->dn, [], 'Updated userinfo dn from "'.$ui->dn.'" to "'.$ui_dn.'"');
$ui->dn = $ui_dn;
$ui->dn = preg_replace('/'.preg_quote($src_dn, '/').'$/i', $dst_dn, $ui->dn);
}
/* Check if departments were moved. If so, force the reload of $config departments cache */
......
......@@ -154,7 +154,6 @@ class groupManagement extends management
if ($o_queue->is_currently_installing($mac_address)) {
msg_dialog::display(_('Action canceled'), sprintf(_('System %s is currently installing'), $dn), ERROR_DIALOG);
unset($mac[$key]);
logging::log('security', 'systems/'.get_class($this), '', [], 'Skip adding "argonautAction::'.$event.'" for mac "'.$mac_address.'", there is already a job in progress.');
}
}
}
......
......@@ -509,7 +509,7 @@ class setupStepMigrate extends setupStep
$res = $ldap->add($testEntry);
$ldap->cat($dn);
if (!$ldap->count()) {
logging::log('view', 'setup/'.get_class($this), $dn, [], $ldap->get_error());
logging::log('error', 'setup/'.get_class($this), $dn, [], $ldap->get_error());
throw new CheckFailedException(
_('Failed'),
sprintf(_('The specified user "%s" does not have full access to your LDAP database.'), $config->current['ADMINDN'])
......@@ -520,7 +520,7 @@ class setupStepMigrate extends setupStep
$res = $ldap->rmDir($dn);
$ldap->cat($dn);
if ($ldap->count()) {
logging::log('view', 'setup/'.get_class($this), $dn, [], $ldap->get_error());
logging::log('error', 'setup/'.get_class($this), $dn, [], $ldap->get_error());
throw new CheckFailedException(
_('Failed'),
sprintf(_('The specified user "%s" does not have full access to your ldap database.'), $config->current['ADMINDN'])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment