From dafdf25a59ada82149c016ab6cc5f93bf1e53ece Mon Sep 17 00:00:00 2001 From: alec Date: Fri, 10 Sep 2010 07:33:28 +0000 Subject: - Added XMail driver for password plugin git-svn-id: https://svn.roundcube.net/trunk@3954 208e9e7b-5314-0410-a742-e7e81cd9613c --- plugins/password/README | 37 +++++++------ plugins/password/config.inc.php.dist | 9 +++- plugins/password/drivers/xmail.php | 101 +++++++++++++++++++++++++++++++++++ plugins/password/package.xml | 24 +++++++-- 4 files changed, 151 insertions(+), 20 deletions(-) create mode 100644 plugins/password/drivers/xmail.php (limited to 'plugins') 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 @@ + + * + * 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 @@ alec@alec.pl yes - 2010-08-01 - + + - 1.6 + 1.7 1.5 @@ -27,7 +27,7 @@ GNU GPLv2 -- Added ldap_simple driver +- Added XMail driver @@ -133,5 +133,21 @@ use rcube_user::get_username instead (#1486707) + + 2010-08-01 + + + 1.6 + 1.5 + + + stable + stable + + GNU GPLv2 + +- Added ldap_simple driver + + -- cgit v1.2.3