Added: write 'Auth failed' to syslog

This commit is contained in:
djmaze 2020-07-07 13:33:38 +02:00
parent 693e0f4c10
commit aa805f9ff9
2 changed files with 10 additions and 8 deletions

View file

@ -24,15 +24,9 @@ class Syslog extends \MailSo\Log\Driver
{ {
parent::__construct(); parent::__construct();
$this->iLogLevel = \defined('LOG_INFO') ? LOG_INFO : 6;
if (\function_exists('openlog') && \function_exists('closelog') && \defined('LOG_ODELAY') && \defined('LOG_USER')) if (\function_exists('openlog') && \function_exists('closelog') && \defined('LOG_ODELAY') && \defined('LOG_USER'))
{ {
\openlog('rainloop', LOG_ODELAY, LOG_USER); $this->iLogLevel = \defined('LOG_INFO') ? LOG_INFO : 6;
\register_shutdown_function(function () {
\closelog();
});
} }
else else
{ {
@ -52,7 +46,10 @@ class Syslog extends \MailSo\Log\Driver
$mDesc = \implode($this->sNewLine, $mDesc); $mDesc = \implode($this->sNewLine, $mDesc);
} }
return \syslog($this->iLogLevel, $mDesc); \openlog('rainloop', LOG_ODELAY, LOG_USER);
$result = \syslog($this->iLogLevel, $mDesc);
\closelog();
return $result;
} }
protected function clearImplementation() : bool protected function clearImplementation() : bool

View file

@ -984,6 +984,11 @@ class Actions
{ {
$this->LoggerAuth()->Write($this->compileLogParams($sLine, $oAccount, false, $aAdditionalParams)); $this->LoggerAuth()->Write($this->compileLogParams($sLine, $oAccount, false, $aAdditionalParams));
} }
if ($this->Config()->Get('logs', 'auth_logging', false) && \openlog('rainloop', 0, \LOG_AUTHPRIV))
{
\syslog(\LOG_ERR, $this->compileLogParams('Auth failed: ip={request:ip} user={imap:login}', $oAccount, false, $aAdditionalParams));
\closelog();
}
} }
private function getAdminToken() : string private function getAdminToken() : string