summaryrefslogtreecommitdiff
path: root/program/lib/Roundcube/rcube.php
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2014-08-07 17:04:05 +0200
committerThomas Bruederli <thomas@roundcube.net>2014-08-07 17:04:05 +0200
commitf954922c03e30bfe06b60f35336f9274fa45ee4e (patch)
tree4a47d56752e20dbd5a750d0d3f0d16ed13a1f8f1 /program/lib/Roundcube/rcube.php
parent1db9a4931cd8f33a0c7305c4ed0e90e32c83db57 (diff)
- Implemented 'storage_connected' API hook after successful IMAP login (#1490025)
- Added config option 'imap_log_session' to enable Roundcube <-> IMAP session ID logging - Added config option 'log_session_id' to control the lengh of the session identifer in logs
Diffstat (limited to 'program/lib/Roundcube/rcube.php')
-rw-r--r--program/lib/Roundcube/rcube.php28
1 files changed, 23 insertions, 5 deletions
diff --git a/program/lib/Roundcube/rcube.php b/program/lib/Roundcube/rcube.php
index e3e26d8b9..eedc46c7a 100644
--- a/program/lib/Roundcube/rcube.php
+++ b/program/lib/Roundcube/rcube.php
@@ -389,8 +389,12 @@ class rcube
$this->storage->set_options($options);
$this->set_storage_prop();
- }
+ // subscribe to 'storage_connected' hook for session logging
+ if ($this->config->get('imap_log_session', false)) {
+ $this->plugins->register_hook('storage_connected', array($this, 'storage_log_session'));
+ }
+ }
/**
* Set storage parameters.
@@ -458,6 +462,16 @@ class rcube
/**
+ * Callback for IMAP connection events to log session identifiers
+ */
+ public function storage_log_session($args)
+ {
+ if (!empty($args['session']) && session_id()) {
+ $this->write_log('imap_session', $args['session']);
+ }
+ }
+
+ /**
* Create session object and start the session.
*/
public function session_init()
@@ -1138,8 +1152,12 @@ class rcube
$line = var_export($line, true);
}
- $date_format = self::$instance ? self::$instance->config->get('log_date_format') : null;
- $log_driver = self::$instance ? self::$instance->config->get('log_driver') : null;
+ $date_format = $log_driver = $session_key = null;
+ if (self::$instance) {
+ $date_format = self::$instance->config->get('log_date_format');
+ $log_driver = self::$instance->config->get('log_driver');
+ $session_key = intval(self::$instance->config->get('log_session_id', 8));
+ }
if (empty($date_format)) {
$date_format = 'd-M-Y H:i:s O';
@@ -1158,8 +1176,8 @@ class rcube
}
// add session ID to the log
- if ($sess = session_id()) {
- $line = '<' . substr($sess, 0, 8) . '> ' . $line;
+ if ($session_key > 0 && ($sess = session_id())) {
+ $line = '<' . substr($sess, 0, $session_key) . '> ' . $line;
}
if ($log_driver == 'syslog') {