-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathdovecot_impersonate.php
53 lines (44 loc) · 1.5 KB
/
dovecot_impersonate.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
/**
* This plugin lets you impersonate another user using a master login. Only works with dovecot.
*
* http://wiki.dovecot.org/Authentication/MasterUsers
*
* @author Cor Bosman ([email protected])
*/
class dovecot_impersonate extends rcube_plugin {
public function init()
{
$this->add_hook('storage_connect', array($this, 'impersonate'));
$this->add_hook('managesieve_connect', array($this, 'impersonate'));
$this->add_hook('authenticate', array($this, 'login'));
$this->add_hook('sieverules_connect', array($this, 'impersonate_sieve'));
}
function login($data) {
// find the seperator character
$rcmail = rcmail::get_instance();
$this->load_config();
$seperator = $rcmail->config->get('dovecot_impersonate_seperator', '*');
if(strpos($data['user'], $seperator)) {
$arr = explode($seperator, $data['user']);
if(count($arr) == 2) {
$data['user'] = $arr[0];
$_SESSION['plugin.dovecot_impersonate_master'] = $seperator . $arr[1];
}
}
return($data);
}
function impersonate($data) {
if(isset($_SESSION['plugin.dovecot_impersonate_master'])) {
$data['user'] = $data['user'] . $_SESSION['plugin.dovecot_impersonate_master'];
}
return($data);
}
function impersonate_sieve($data) {
if(isset($_SESSION['plugin.dovecot_impersonate_master'])) {
$data['username'] = $data['username'] . $_SESSION['plugin.dovecot_impersonate_master'];
}
return($data);
}
}
?>