diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/acl/acl.php | 10 | ||||
-rw-r--r-- | plugins/acl/config.inc.php.dist | 3 | ||||
-rw-r--r-- | plugins/enigma/lib/enigma_driver_phpssl.php | 2 | ||||
-rw-r--r-- | plugins/new_user_identity/config.inc.php.dist | 10 | ||||
-rw-r--r-- | plugins/new_user_identity/new_user_identity.php | 31 | ||||
-rw-r--r-- | plugins/password/README | 20 | ||||
-rw-r--r-- | plugins/password/config.inc.php.dist | 5 | ||||
-rw-r--r-- | plugins/password/drivers/ldap.php | 25 | ||||
-rw-r--r-- | plugins/password/drivers/plesk.php | 2 | ||||
-rw-r--r-- | plugins/password/helpers/dovecot_hmacmd5.php | 191 | ||||
-rw-r--r-- | plugins/vcard_attachments/vcard_attachments.php | 2 | ||||
-rw-r--r-- | plugins/zipdownload/zipdownload.php | 20 |
12 files changed, 271 insertions, 50 deletions
diff --git a/plugins/acl/acl.php b/plugins/acl/acl.php index 33bd91e22..349f7e518 100644 --- a/plugins/acl/acl.php +++ b/plugins/acl/acl.php @@ -114,14 +114,16 @@ class acl extends rcube_plugin } if ($this->rc->config->get('acl_groups')) { - $prefix = $this->rc->config->get('acl_group_prefix'); - $result = $this->ldap->list_groups($search, $mode); + $prefix = $this->rc->config->get('acl_group_prefix'); + $group_field = $this->rc->config->get('acl_group_field', 'name'); + $result = $this->ldap->list_groups($search, $mode); foreach ($result as $record) { - $group = $record['name']; + $group = $record['name']; + $group_id = is_array($record[$group_field]) ? $record[$group_field][0] : $record[$group_field]; if ($group) { - $users[] = array('name' => ($prefix ? $prefix : '') . $group, 'display' => $group); + $users[] = array('name' => ($prefix ? $prefix : '') . $group_id, 'display' => $group); $keys[] = $group; } } diff --git a/plugins/acl/config.inc.php.dist b/plugins/acl/config.inc.php.dist index de1f8b5d2..ed7000267 100644 --- a/plugins/acl/config.inc.php.dist +++ b/plugins/acl/config.inc.php.dist @@ -23,6 +23,9 @@ $config['acl_groups'] = false; // Prefix added to the group name to build IMAP ACL identifier $config['acl_group_prefix'] = 'group:'; +// The LDAP attribute (or field name) which will be used as ACL group identifier +$config['acl_group_field'] = 'name'; + // Include the following 'special' access control subjects in the ACL dialog; // Defaults to array('anyone', 'anonymous') (not when set to an empty array) // Example: array('anyone') to exclude 'anonymous'. diff --git a/plugins/enigma/lib/enigma_driver_phpssl.php b/plugins/enigma/lib/enigma_driver_phpssl.php index 50af44762..fcd15db73 100644 --- a/plugins/enigma/lib/enigma_driver_phpssl.php +++ b/plugins/enigma/lib/enigma_driver_phpssl.php @@ -95,7 +95,7 @@ class enigma_driver_phpssl extends enigma_driver $fh = fopen($msg_file, "w"); if ($struct->mime_id) { - $message->get_part_content($struct->mime_id, $fh, true, 0, false); + $message->get_part_body($struct->mime_id, false, 0, $fh); } else { $this->rc->storage->get_raw_body($message->uid, $fh); diff --git a/plugins/new_user_identity/config.inc.php.dist b/plugins/new_user_identity/config.inc.php.dist new file mode 100644 index 000000000..b2fd76408 --- /dev/null +++ b/plugins/new_user_identity/config.inc.php.dist @@ -0,0 +1,10 @@ +<?php + +// The id of the address book to use to automatically set a new +// user's full name in their new identity. (This should be an +// string, which refers to the $config['ldap_public'] array.) +$config['new_user_identity_addressbook'] = 'People'; + +// When automatically setting a new users's full name in their +// new identity, match the user's login name against this field. +$config['new_user_identity_match'] = 'uid'; diff --git a/plugins/new_user_identity/new_user_identity.php b/plugins/new_user_identity/new_user_identity.php index 3943134b2..d1d1d9f24 100644 --- a/plugins/new_user_identity/new_user_identity.php +++ b/plugins/new_user_identity/new_user_identity.php @@ -9,17 +9,6 @@ * @version @package_version@ * @author Kris Steinhoff * @license GNU GPLv3+ - * - * Example configuration: - * - * // The id of the address book to use to automatically set a new - * // user's full name in their new identity. (This should be an - * // string, which refers to the $config['ldap_public'] array.) - * $config['new_user_identity_addressbook'] = 'People'; - * - * // When automatically setting a new users's full name in their - * // new identity, match the user's login name against this field. - * $config['new_user_identity_match'] = 'uid'; */ class new_user_identity extends rcube_plugin { @@ -36,16 +25,33 @@ class new_user_identity extends rcube_plugin { if ($this->init_ldap($args['host'])) { $results = $this->ldap->search('*', $args['user'], true); + if (count($results->records) == 1) { $user_name = is_array($results->records[0]['name']) ? $results->records[0]['name'][0] : $results->records[0]['name']; $user_email = is_array($results->records[0]['email']) ? $results->records[0]['email'][0] : $results->records[0]['email']; - $args['user_name'] = $user_name; + $args['user_name'] = $user_name; + $args['email_list'] = array(); + if (!$args['user_email'] && strpos($user_email, '@')) { $args['user_email'] = rcube_utils::idn_to_ascii($user_email); } + + foreach (array_keys($results[0]) as $key) { + if (!preg_match('/^email($|:)/', $key)) { + continue; + } + + foreach ((array) $results->records[0][$key] as $alias) { + if (strpos($alias, '@')) { + $args['email_list'][] = rcube_utils::idn_to_ascii($alias); + } + } + } + } } + return $args; } @@ -56,6 +62,7 @@ class new_user_identity extends rcube_plugin } $rcmail = rcmail::get_instance(); + $this->load_config(); $addressbook = $rcmail->config->get('new_user_identity_addressbook'); $ldap_config = (array)$rcmail->config->get('ldap_public'); diff --git a/plugins/password/README b/plugins/password/README index 936aa53cc..8c3a2afbd 100644 --- a/plugins/password/README +++ b/plugins/password/README @@ -317,31 +317,25 @@ 2.20. Plesk (Plesk RPC-API) --------------------------- - + Driver for changing Passwords via Plesk RPC-API. This Driver also works with Parallels Plesk Automation (PPA). - + You need to allow the IP of the Roundcube-Server for RPC-Calls in the Panel. - - + Set $config['password_plesk_host'] to the Hostname / IP where Plesk runs - Set your Admin or RPC User: $config['password_plesk_user'] - Set the Password of the User: $config['password_plesk_pass'] - Set $config['password_plesk_rpc_port'] for the RPC-Port. Usually its 8443 - - Set the RPC-Path in $config['password_plesk_rpc_path']. Normally this is: enterprise/control/agent.php; + Set the RPC-Path in $config['password_plesk_rpc_path']. Normally this is: enterprise/control/agent.php. - 3. Driver API ------------- - Driver file (<driver_name>.php) must define 'password_save' function with - two arguments. First - current password, second - new password. Function - should return PASSWORD_SUCCESS on success or any of PASSWORD_CONNECT_ERROR, + Driver file (<driver_name>.php) must define rcube_<driver_name>_password class + with public save() method that has two arguments. First - current password, second - new password. + This method should return PASSWORD_SUCCESS on success or any of PASSWORD_CONNECT_ERROR, PASSWORD_CRYPT_ERROR, PASSWORD_ERROR when driver was unable to change password. Extended result (as a hash-array with 'message' and 'code' items) can be returned too. See existing drivers in drivers/ directory for examples. diff --git a/plugins/password/config.inc.php.dist b/plugins/password/config.inc.php.dist index 6610b4dae..94c4368fe 100644 --- a/plugins/password/config.inc.php.dist +++ b/plugins/password/config.inc.php.dist @@ -204,10 +204,11 @@ $config['password_ldap_search_filter'] = '(uid=%login)'; // LDAP password hash type // Standard LDAP encryption type which must be one of: crypt, -// ext_des, md5crypt, blowfish, md5, sha, smd5, ssha, ad or clear. +// ext_des, md5crypt, blowfish, md5, sha, smd5, ssha, ad, cram-md5 (dovecot style) or clear. // Please note that most encodage types require external libraries // to be included in your PHP installation, see function hashPassword in drivers/ldap.php for more info. -// Default: 'crypt' +// Multiple password Values can be generated by concatenating encodings with a +. E.g. 'cram-md5+crypt' +// Default: 'crypt'. $config['password_ldap_encodage'] = 'crypt'; // LDAP password attribute diff --git a/plugins/password/drivers/ldap.php b/plugins/password/drivers/ldap.php index 340dd29f8..ac2ea3bd3 100644 --- a/plugins/password/drivers/ldap.php +++ b/plugins/password/drivers/ldap.php @@ -38,7 +38,8 @@ class rcube_ldap_password // Building user DN if ($userDN = $rcmail->config->get('password_ldap_userDN_mask')) { $userDN = self::substitute_vars($userDN); - } else { + } + else { $userDN = $this->search_userdn($rcmail); } @@ -78,13 +79,25 @@ class rcube_ldap_password return PASSWORD_CONNECT_ERROR; } - $crypted_pass = self::hash_password($passwd, $rcmail->config->get('password_ldap_encodage')); $force = $rcmail->config->get('password_ldap_force_replace'); $pwattr = $rcmail->config->get('password_ldap_pwattr'); $lchattr = $rcmail->config->get('password_ldap_lchattr'); $smbpwattr = $rcmail->config->get('password_ldap_samba_pwattr'); $smblchattr = $rcmail->config->get('password_ldap_samba_lchattr'); $samba = $rcmail->config->get('password_ldap_samba'); + $encodage = $rcmail->config->get('password_ldap_encodage'); + + // Support multiple userPassword values where desired. + // multiple encodings can be specified separated by '+' (e.g. "cram-md5+ssha") + $encodages = explode('+', $encodage); + $crypted_pass = array(); + + foreach ($encodages as $enc) { + $cpw = self::hash_password($passwd, $enc); + if (!empty($cpw)) { + $crypted_pass[] = $cpw; + } + } // Support password_ldap_samba option for backward compat. if ($samba && !$smbpwattr) { @@ -93,7 +106,7 @@ class rcube_ldap_password } // Crypt new password - if (!$crypted_pass) { + if (empty($crypted_pass)) { return PASSWORD_CRYPT_ERROR; } @@ -297,6 +310,7 @@ class rcube_ldap_password } break; + case 'smd5': mt_srand((double) microtime() * 1000000); $salt = substr(pack('h*', md5(mt_rand())), 0, 8); @@ -332,6 +346,11 @@ class rcube_ldap_password $crypted_password = rcube_charset::convert('"' . $password_clear . '"', RCUBE_CHARSET, 'UTF-16LE'); break; + case 'cram-md5': + require_once __DIR__ . '/../helpers/dovecot_hmacmd5.php'; + return dovecot_hmacmd5($password_clear); + break; + case 'clear': default: $crypted_password = $password_clear; diff --git a/plugins/password/drivers/plesk.php b/plugins/password/drivers/plesk.php index d0a511fbe..db9ad9efd 100644 --- a/plugins/password/drivers/plesk.php +++ b/plugins/password/drivers/plesk.php @@ -49,7 +49,7 @@ class rcube_plesk_password * @param string $newpass New password * @returns int PASSWORD_SUCCESS|PASSWORD_ERROR */ - function save($currpass, $newpass)\ + function save($currpass, $newpass) { // get config $rcmail = rcmail::get_instance(); diff --git a/plugins/password/helpers/dovecot_hmacmd5.php b/plugins/password/helpers/dovecot_hmacmd5.php new file mode 100644 index 000000000..644b5377e --- /dev/null +++ b/plugins/password/helpers/dovecot_hmacmd5.php @@ -0,0 +1,191 @@ +<?php + +/** + * + * dovecot_hmacmd5.php V1.01 + * + * Generates HMAC-MD5 'contexts' for Dovecot's password files. + * + * (C) 2008 Hajo Noerenberg + * + * http://www.noerenberg.de/hajo/pub/dovecot_hmacmd5.php.txt + * + * Most of the code has been shamelessly stolen from various sources: + * + * (C) Paul Johnston 1999 - 2000 / http://pajhome.org.uk/crypt/md5/ + * (C) William K. Cole 2008 / http://www.scconsult.com/bill/crampass.pl + * (C) Borfast 2002 / http://www.zend.com/code/codex.php?ozid=962&single=1 + * (C) Thomas Weber / http://pajhome.org.uk/crypt/md5/contrib/md5.java.txt + * + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3.0 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/gpl-3.0.txt>. + * + */ + +/* Convert a 32-bit number to a hex string with ls-byte first + */ + +function rhex($n) { + $hex_chr = "0123456789abcdef"; $r = ''; + for($j = 0; $j <= 3; $j++) + $r .= $hex_chr[($n >> ($j * 8 + 4)) & 0x0F] . $hex_chr[($n >> ($j * 8)) & 0x0F]; + return $r; +} + +/* zeroFill() is needed because PHP doesn't have a zero-fill + * right shift operator like JavaScript's >>> + */ + +function zeroFill($a, $b) { + $z = hexdec(80000000); + if ($z & $a) { + $a >>= 1; + $a &= (~$z); + $a |= 0x40000000; + $a >>= ($b-1); + } else { + $a >>= $b; + } + return $a; +} + +/* Bitwise rotate a 32-bit number to the left + */ + +function bit_rol($num, $cnt) { + return ($num << $cnt) | (zeroFill($num, (32 - $cnt))); +} + +/* Add integers, wrapping at 2^32 + */ + +function safe_add($x, $y) { + return (($x&0x7FFFFFFF) + ($y&0x7FFFFFFF)) ^ ($x&0x80000000) ^ ($y&0x80000000); +} + +/* These functions implement the four basic operations the algorithm uses. + */ + +function md5_cmn($q, $a, $b, $x, $s, $t) { + return safe_add(bit_rol(safe_add(safe_add($a, $q), safe_add($x, $t)), $s), $b); +} +function md5_ff($a, $b, $c, $d, $x, $s, $t) { + return md5_cmn(($b & $c) | ((~$b) & $d), $a, $b, $x, $s, $t); +} +function md5_gg($a, $b, $c, $d, $x, $s, $t) { + return md5_cmn(($b & $d) | ($c & (~$d)), $a, $b, $x, $s, $t); +} +function md5_hh($a, $b, $c, $d, $x, $s, $t) { + return md5_cmn($b ^ $c ^ $d, $a, $b, $x, $s, $t); +} +function md5_ii($a, $b, $c, $d, $x, $s, $t) { + return md5_cmn($c ^ ($b | (~$d)), $a, $b, $x, $s, $t); +} + +/* Calculate the first round of the MD5 algorithm + */ + +function md5_oneround($s, $io) { + + $s = str_pad($s, 64, chr(0x00)); + + $x = array_fill(0, 16, 0); + + for($i = 0; $i < 64; $i++) + $x[$i >> 2] |= (($io ? 0x36 : 0x5c) ^ ord($s[$i])) << (($i % 4) * 8); + + $a = $olda = 1732584193; + $b = $oldb = -271733879; + $c = $oldc = -1732584194; + $d = $oldd = 271733878; + + $a = md5_ff($a, $b, $c, $d, $x[ 0], 7 , -680876936); + $d = md5_ff($d, $a, $b, $c, $x[ 1], 12, -389564586); + $c = md5_ff($c, $d, $a, $b, $x[ 2], 17, 606105819); + $b = md5_ff($b, $c, $d, $a, $x[ 3], 22, -1044525330); + $a = md5_ff($a, $b, $c, $d, $x[ 4], 7 , -176418897); + $d = md5_ff($d, $a, $b, $c, $x[ 5], 12, 1200080426); + $c = md5_ff($c, $d, $a, $b, $x[ 6], 17, -1473231341); + $b = md5_ff($b, $c, $d, $a, $x[ 7], 22, -45705983); + $a = md5_ff($a, $b, $c, $d, $x[ 8], 7 , 1770035416); + $d = md5_ff($d, $a, $b, $c, $x[ 9], 12, -1958414417); + $c = md5_ff($c, $d, $a, $b, $x[10], 17, -42063); + $b = md5_ff($b, $c, $d, $a, $x[11], 22, -1990404162); + $a = md5_ff($a, $b, $c, $d, $x[12], 7 , 1804603682); + $d = md5_ff($d, $a, $b, $c, $x[13], 12, -40341101); + $c = md5_ff($c, $d, $a, $b, $x[14], 17, -1502002290); + $b = md5_ff($b, $c, $d, $a, $x[15], 22, 1236535329); + + $a = md5_gg($a, $b, $c, $d, $x[ 1], 5 , -165796510); + $d = md5_gg($d, $a, $b, $c, $x[ 6], 9 , -1069501632); + $c = md5_gg($c, $d, $a, $b, $x[11], 14, 643717713); + $b = md5_gg($b, $c, $d, $a, $x[ 0], 20, -373897302); + $a = md5_gg($a, $b, $c, $d, $x[ 5], 5 , -701558691); + $d = md5_gg($d, $a, $b, $c, $x[10], 9 , 38016083); + $c = md5_gg($c, $d, $a, $b, $x[15], 14, -660478335); + $b = md5_gg($b, $c, $d, $a, $x[ 4], 20, -405537848); + $a = md5_gg($a, $b, $c, $d, $x[ 9], 5 , 568446438); + $d = md5_gg($d, $a, $b, $c, $x[14], 9 , -1019803690); + $c = md5_gg($c, $d, $a, $b, $x[ 3], 14, -187363961); + $b = md5_gg($b, $c, $d, $a, $x[ 8], 20, 1163531501); + $a = md5_gg($a, $b, $c, $d, $x[13], 5 , -1444681467); + $d = md5_gg($d, $a, $b, $c, $x[ 2], 9 , -51403784); + $c = md5_gg($c, $d, $a, $b, $x[ 7], 14, 1735328473); + $b = md5_gg($b, $c, $d, $a, $x[12], 20, -1926607734); + + $a = md5_hh($a, $b, $c, $d, $x[ 5], 4 , -378558); + $d = md5_hh($d, $a, $b, $c, $x[ 8], 11, -2022574463); + $c = md5_hh($c, $d, $a, $b, $x[11], 16, 1839030562); + $b = md5_hh($b, $c, $d, $a, $x[14], 23, -35309556); + $a = md5_hh($a, $b, $c, $d, $x[ 1], 4 , -1530992060); + $d = md5_hh($d, $a, $b, $c, $x[ 4], 11, 1272893353); + $c = md5_hh($c, $d, $a, $b, $x[ 7], 16, -155497632); + $b = md5_hh($b, $c, $d, $a, $x[10], 23, -1094730640); + $a = md5_hh($a, $b, $c, $d, $x[13], 4 , 681279174); + $d = md5_hh($d, $a, $b, $c, $x[ 0], 11, -358537222); + $c = md5_hh($c, $d, $a, $b, $x[ 3], 16, -722521979); + $b = md5_hh($b, $c, $d, $a, $x[ 6], 23, 76029189); + $a = md5_hh($a, $b, $c, $d, $x[ 9], 4 , -640364487); + $d = md5_hh($d, $a, $b, $c, $x[12], 11, -421815835); + $c = md5_hh($c, $d, $a, $b, $x[15], 16, 530742520); + $b = md5_hh($b, $c, $d, $a, $x[ 2], 23, -995338651); + + $a = md5_ii($a, $b, $c, $d, $x[ 0], 6 , -198630844); + $d = md5_ii($d, $a, $b, $c, $x[ 7], 10, 1126891415); + $c = md5_ii($c, $d, $a, $b, $x[14], 15, -1416354905); + $b = md5_ii($b, $c, $d, $a, $x[ 5], 21, -57434055); + $a = md5_ii($a, $b, $c, $d, $x[12], 6 , 1700485571); + $d = md5_ii($d, $a, $b, $c, $x[ 3], 10, -1894986606); + $c = md5_ii($c, $d, $a, $b, $x[10], 15, -1051523); + $b = md5_ii($b, $c, $d, $a, $x[ 1], 21, -2054922799); + $a = md5_ii($a, $b, $c, $d, $x[ 8], 6 , 1873313359); + $d = md5_ii($d, $a, $b, $c, $x[15], 10, -30611744); + $c = md5_ii($c, $d, $a, $b, $x[ 6], 15, -1560198380); + $b = md5_ii($b, $c, $d, $a, $x[13], 21, 1309151649); + $a = md5_ii($a, $b, $c, $d, $x[ 4], 6 , -145523070); + $d = md5_ii($d, $a, $b, $c, $x[11], 10, -1120210379); + $c = md5_ii($c, $d, $a, $b, $x[ 2], 15, 718787259); + $b = md5_ii($b, $c, $d, $a, $x[ 9], 21, -343485551); + + $a = safe_add($a, $olda); + $b = safe_add($b, $oldb); + $c = safe_add($c, $oldc); + $d = safe_add($d, $oldd); + + return rhex($a) . rhex($b) . rhex($c) . rhex($d); +} + +function dovecot_hmacmd5 ($s) { + if (strlen($s) > 64) $s=pack("H*", md5($s)); + return "{CRAM-MD5}" . md5_oneround($s, 0) . md5_oneround($s, 1); +} diff --git a/plugins/vcard_attachments/vcard_attachments.php b/plugins/vcard_attachments/vcard_attachments.php index cf7e22d3a..74718be6f 100644 --- a/plugins/vcard_attachments/vcard_attachments.php +++ b/plugins/vcard_attachments/vcard_attachments.php @@ -65,7 +65,7 @@ class vcard_attachments extends rcube_plugin $attach_script = false; foreach ($this->vcard_parts as $part) { - $vcards = rcube_vcard::import($this->message->get_part_content($part, null, true)); + $vcards = rcube_vcard::import($this->message->get_part_body($part, true)); // successfully parsed vcards? if (empty($vcards)) { diff --git a/plugins/zipdownload/zipdownload.php b/plugins/zipdownload/zipdownload.php index edb8188cc..2e103ceb0 100644 --- a/plugins/zipdownload/zipdownload.php +++ b/plugins/zipdownload/zipdownload.php @@ -144,20 +144,14 @@ class zipdownload extends rcube_plugin } } - $disp_name = $this->_convert_filename($filename); + $disp_name = $this->_convert_filename($filename); + $tmpfn = tempnam($temp_dir, 'zipattach'); + $tmpfp = fopen($tmpfn, 'w'); + $tempfiles[] = $tmpfn; - if ($part->body) { - $orig_message_raw = $part->body; - $zip->addFromString($disp_name, $orig_message_raw); - } - else { - $tmpfn = tempnam($temp_dir, 'zipattach'); - $tmpfp = fopen($tmpfn, 'w'); - $imap->get_message_part($message->uid, $part->mime_id, $part, null, $tmpfp, true); - $tempfiles[] = $tmpfn; - fclose($tmpfp); - $zip->addFile($tmpfn, $disp_name); - } + $message->get_part_body($part->mime_id, false, 0, $tmpfp); + $zip->addFile($tmpfn, $disp_name); + fclose($tmpfp); } $zip->close(); |