diff options
| author | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2010-09-10 07:33:28 +0000 |
|---|---|---|
| committer | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2010-09-10 07:33:28 +0000 |
| commit | dafdf25a59ada82149c016ab6cc5f93bf1e53ece (patch) | |
| tree | 5ebd80fe0f6a8c7d796cad56b7f60de13633865e /plugins/password | |
| parent | cb82cda0095783990b4573b3170fd6868da4f68a (diff) | |
- Added XMail driver for password plugin
git-svn-id: https://svn.roundcube.net/trunk@3954 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'plugins/password')
| -rw-r--r-- | plugins/password/README | 37 | ||||
| -rw-r--r-- | plugins/password/config.inc.php.dist | 9 | ||||
| -rw-r--r-- | plugins/password/drivers/xmail.php | 101 | ||||
| -rw-r--r-- | plugins/password/package.xml | 24 |
4 files changed, 151 insertions, 20 deletions
diff --git a/plugins/password/README b/plugins/password/README index 5312cbf46..2e3a59509 100644 --- a/plugins/password/README +++ b/plugins/password/README @@ -26,18 +26,19 @@ 1. Configuration 2. Drivers - 2.1. Database (sql) - 2.2. Cyrus/SASL (sasl) - 2.3. Poppassd/Courierpassd (poppassd) - 2.4. LDAP (ldap) - 2.5. DirectAdmin Control Panel (directadmin) - 2.6. cPanel (cpanel) - 2.7. XIMSS/Communigate (ximms) - 2.8. Virtualmin (virtualmin) - 2.9. hMailServer (hmail) - 2.10. PAM (pam) - 2.11. Chpasswd (chpasswd) - 2.12. LDAP - no PEAR (ldap_simple) + 2.1. Database (sql) + 2.2. Cyrus/SASL (sasl) + 2.3. Poppassd/Courierpassd (poppassd) + 2.4. LDAP (ldap) + 2.5. DirectAdmin Control Panel (directadmin) + 2.6. cPanel (cpanel) + 2.7. XIMSS/Communigate (ximms) + 2.8. Virtualmin (virtualmin) + 2.9. hMailServer (hmail) + 2.10. PAM (pam) + 2.11. Chpasswd (chpasswd) + 2.12. LDAP - no PEAR (ldap_simple) + 2.13. XMail (xmail) 3. Driver API @@ -205,20 +206,20 @@ 2.9. hMailServer (hmail) ------------------------ - + Requires PHP COM (Windows only). 2.10. PAM (pam) --------------- - + This driver is for changing passwords of shell users authenticated with PAM. Requires PECL's PAM exitension to be installed (http://pecl.php.net/package/PAM). 2.11. Chpasswd (chpasswd) ------------------------- - + Driver that adds functionality to change the systems user password via the 'chpasswd' command. See config.inc.php file. @@ -238,6 +239,12 @@ why the 'force replace' is always used). + 2.13. XMail (xmail) + ----------------------------------- + + Driver for XMail (www.xmailserver.org). See config.inc.php file for configuration description. + + 3. Driver API ------------- diff --git a/plugins/password/config.inc.php.dist b/plugins/password/config.inc.php.dist index 9ac71aef7..cd819d1b3 100644 --- a/plugins/password/config.inc.php.dist +++ b/plugins/password/config.inc.php.dist @@ -242,4 +242,11 @@ $rcmail_config['password_ximss_port'] = 11024; // Command to use $rcmail_config['password_chpasswd_cmd'] = 'sudo /usr/sbin/chpasswd 2> /dev/null'; -?> + +// XMail Driver options +// --------------------- +$rcmail_config['xmail_host'] = 'localhost'; +$rcmail_config['xmail_user'] = 'YourXmailControlUser'; +$rcmail_config['xmail_pass'] = 'YourXmailControlPass'; +$rcmail_config['xmail_port'] = 6017; + diff --git a/plugins/password/drivers/xmail.php b/plugins/password/drivers/xmail.php new file mode 100644 index 000000000..8b827248c --- /dev/null +++ b/plugins/password/drivers/xmail.php @@ -0,0 +1,101 @@ +<?php +/** + * XMail Password Driver + * + * Driver for XMail password + * + * @version 1.0 + * @author Helio Cavichiolo Jr <helio@hcsistemas.com.br> + * + * Setup xmail_host, xmail_user, xmail_pass and xmail_port into + * config.inc.php of password plugin as follows: + * + * $rcmail_config['xmail_host'] = 'localhost'; + * $rcmail_config['xmail_user'] = 'YourXmailControlUser'; + * $rcmail_config['xmail_pass'] = 'YourXmailControlPass'; + * $rcmail_config['xmail_port'] = 6017; + * + */ + +function password_save($currpass, $newpass) +{ + $rcmail = rcmail::get_instance(); + list($user,$domain) = split('@',$_SESSION['username']); + + $xmail = new XMail; + + $xmail->hostname = $rcmail->config->get('xmail_host'); + $xmail->username = $rcmail->config->get('xmail_user'); + $xmail->password = $rcmail->config->get('xmail_pass'); + $xmail->port = $rcmail->config->get('xmail_port'); + + if (!$xmail->connect()) { + raise_error(array( + 'code' => 600, + 'type' => 'php', + 'file' => __FILE__, + 'message' => "Password plugin: Unable to connect to mail server" + ), true, false); + return PASSWORD_CONNECT_ERROR; + } else if (!$xmail->send("userpasswd\t".$domain."\t".$user."\t".$newpass."\n")) { + $xmail->close(); + raise_error(array( + 'code' => 600, + 'type' => 'php', + 'file' => __FILE__, + 'message' => "Password plugin: Unable to change password" + ), true, false); + return PASSWORD_ERROR; + } else { + $xmail->close(); + return PASSWORD_SUCCESS; + } +} + +class XMail { + var $socket; + var $hostname = 'localhost'; + var $username = 'xmail'; + var $password = ''; + var $port = 6017; + + function send($msg) + { + socket_write($this->socket,$msg); + if (substr($in = socket_read($this->socket, 512, PHP_BINARY_READ),0,1) != "+") { + return false; + } + return true; + } + + function connect() + { + $this->socket = socket_create(AF_INET, SOCK_STREAM, 0); + if ($this->socket < 0) + return false; + + $result = socket_connect($this->socket, $this->hostname, $this->port); + if ($result < 0) { + socket_close($this->socket); + return false; + } + + if (substr($in = socket_read($this->socket, 512, PHP_BINARY_READ),0,1) != "+") { + socket_close($this->socket); + return false; + } + + if (!$this->send("$this->username\t$this->password\n")) { + socket_close($this->socket); + return false; + } + return true; + } + + function close() + { + $this->send("quit\n"); + socket_close($this->socket); + } +} + diff --git a/plugins/password/package.xml b/plugins/password/package.xml index dfa57e88b..a106c8917 100644 --- a/plugins/password/package.xml +++ b/plugins/password/package.xml @@ -15,10 +15,10 @@ <email>alec@alec.pl</email> <active>yes</active> </lead> - <date>2010-08-01</date> - <time>09:00:00</time> + <date></date> + <time></time> <version> - <release>1.6</release> + <release>1.7</release> <api>1.5</api> </version> <stability> @@ -27,7 +27,7 @@ </stability> <license uri="http://www.gnu.org/licenses/gpl-2.0.html">GNU GPLv2</license> <notes> -- Added ldap_simple driver +- Added XMail driver </notes> <contents> <dir baseinstalldir="/" name="/"> @@ -133,5 +133,21 @@ use rcube_user::get_username instead (#1486707) </notes> </release> + <release> + <date>2010-08-01</date> + <time>09:00:00</time> + <version> + <release>1.6</release> + <api>1.5</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <license uri="http://www.gnu.org/licenses/gpl-2.0.html">GNU GPLv2</license> + <notes> +- Added ldap_simple driver + </notes> + </release> </changelog> </package> |
