...
 
Commits (4)
......@@ -151,6 +151,8 @@ class CopyPasteHandler
$entry['object']->resetCopyInfos();
}
logging::log('copy', $entry['method'], $entry['dn'], [], '');
$entry['object']->resetBase();
return $entry;
......@@ -209,6 +211,7 @@ class CopyPasteHandler
foreach ($this->clean_objects as $key => $entry) {
$this->current = $entry;
$errors = $this->current['object']->save();
logging::log('copy', 'paste', $this->current['object']->dn, [], reset($errors));
if (empty($errors)) {
$this->current_saved();
......@@ -228,6 +231,7 @@ class CopyPasteHandler
/* Save current object if edition is finished */
if (isset($_POST['edit_finish'])) {
$errors = $this->current['object']->save();
logging::log('copy', 'paste', $this->current['object']->dn, [], reset($errors));
if (empty($errors)) {
$this->current_saved();
......
......@@ -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
*
......
......@@ -262,6 +262,7 @@ class SnapshotHandler
if (!$ldap->success()) {
msg_dialog::display(_('LDAP error'), msgPool::ldaperror($ldap->get_error(), $new_base, '', get_class()), LDAP_ERROR);
}
logging::log('snapshot', 'create', $new_dn, array_keys($target), $ldap->get_error());
}
/*!
......@@ -278,6 +279,7 @@ class SnapshotHandler
if (!$ldap->success()) {
msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn), LDAP_ERROR);
}
logging::log('snapshot', 'delete', $dn, [], $ldap->get_error());
}
/*!
......@@ -397,6 +399,7 @@ class SnapshotHandler
/* Import the given data */
try {
$ldap->import_complete_ldif($data, FALSE, FALSE);
logging::log('snapshot', 'restore', $dn, [], $ldap->get_error());
if (!$ldap->success()) {
msg_dialog::display(_('LDAP error'), msgPool::ldaperror($ldap->get_error(), $dn, '', get_class()), LDAP_ERROR);
return FALSE;
......@@ -404,6 +407,7 @@ class SnapshotHandler
return $attrs['gosaSnapshotDN'][0];
} catch (LDIFImportException $e) {
msg_dialog::display(_('LDAP error'), $e->getMessage(), ERROR_DIALOG);
logging::log('snapshot', 'restore', $dn, [], $e->getMessage());
return FALSE;
}
}
......
......@@ -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'])
......