diff options
| author | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2012-03-07 09:48:33 +0000 |
|---|---|---|
| committer | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2012-03-07 09:48:33 +0000 |
| commit | beb5bc650559db7771a78e57cecbe6c4fccbd4aa (patch) | |
| tree | 2b184cb35adfa92b034ad27291dfe0e12ffb7cad /plugins | |
| parent | f8d88136b727520db85925ce53b24aa5819ffb1e (diff) | |
- Added pw_usermod driver (#1487826)
- Added option password_login_exceptions (#1487826)
git-svn-id: https://svn.roundcube.net/trunk@5973 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/password/README | 8 | ||||
| -rw-r--r-- | plugins/password/config.inc.php.dist | 12 | ||||
| -rw-r--r-- | plugins/password/drivers/chpasswd.php | 2 | ||||
| -rw-r--r-- | plugins/password/drivers/pw_usermod.php | 41 | ||||
| -rw-r--r-- | plugins/password/package.xml | 23 | ||||
| -rw-r--r-- | plugins/password/password.php | 19 |
6 files changed, 98 insertions, 7 deletions
diff --git a/plugins/password/README b/plugins/password/README index d9280fb03..268d5194c 100644 --- a/plugins/password/README +++ b/plugins/password/README @@ -39,6 +39,7 @@ 2.11. Chpasswd (chpasswd) 2.12. LDAP - no PEAR (ldap_simple) 2.13. XMail (xmail) + 2.14. Pw (pw_usermod) 3. Driver API @@ -253,6 +254,13 @@ for configuration description. + 2.14. Pw (pw_usermod) + ----------------------------------- + + Driver to change the systems user password via the 'pw usermod' command. + See config.inc.php.dist file for configuration description. + + 3. Driver API ------------- diff --git a/plugins/password/config.inc.php.dist b/plugins/password/config.inc.php.dist index 313e47fda..689c4de26 100644 --- a/plugins/password/config.inc.php.dist +++ b/plugins/password/config.inc.php.dist @@ -21,6 +21,10 @@ $rcmail_config['password_require_nonalpha'] = false; // Enables logging of password changes into logs/password $rcmail_config['password_log'] = false; +// Comma-separated list of login exceptions for which password change +// will be not available (no Password tab in Settings) +$rcmail_config['password_login_exceptions'] = null; + // SQL Driver options // ------------------ @@ -305,3 +309,11 @@ $rcmail_config['hmailserver_server'] = array( // 6: username_domain // 7: domain_username $rcmail_config['password_virtualmin_format'] = 0; + + +// pw_usermod Driver options +// -------------------------- +// Use comma delimited exlist to disable password change for users +// Add the following line to visudo to tighten security: +// www ALL=NOPASSWORD: /usr/sbin/pw +$rcmail_config['password_pw_usermod_cmd'] = 'sudo /usr/sbin/pw usermod -h 0 -n'; diff --git a/plugins/password/drivers/chpasswd.php b/plugins/password/drivers/chpasswd.php index cce7c1f42..3ea10159c 100644 --- a/plugins/password/drivers/chpasswd.php +++ b/plugins/password/drivers/chpasswd.php @@ -9,7 +9,7 @@ * For installation instructions please read the README file. * * @version 2.0 - * @author Alex Cartwright <acartwright@mutinydesign.co.uk) + * @author Alex Cartwright <acartwright@mutinydesign.co.uk> */ class rcube_chpasswd_password diff --git a/plugins/password/drivers/pw_usermod.php b/plugins/password/drivers/pw_usermod.php new file mode 100644 index 000000000..ca3d068a7 --- /dev/null +++ b/plugins/password/drivers/pw_usermod.php @@ -0,0 +1,41 @@ +<?php + +/** + * pw_usermod Driver + * + * Driver that adds functionality to change the systems user password via + * the 'pw usermod' command. + * + * For installation instructions please read the README file. + * + * @version 2.0 + * @author Alex Cartwright <acartwright@mutinydesign.co.uk> + * @author Adamson Huang <adomputer@gmail.com> + */ + +class rcube_pw_usermod_password +{ + public function save($currpass, $newpass) + { + $cmd = rcmail::get_instance()->config->get('password_pw_usermod_cmd'); + $username = $_SESSION['username']; + $cmd .= " $username > /dev/null"; + + $handle = popen($cmd, "w"); + fwrite($handle, "$newpass\n"); + + if (pclose($handle) == 0) { + return PASSWORD_SUCCESS; + } + else { + raise_error(array( + 'code' => 600, + 'type' => 'php', + 'file' => __FILE__, 'line' => __LINE__, + 'message' => "Password plugin: Unable to execute $cmd" + ), true, false); + } + + return PASSWORD_ERROR; + } +} diff --git a/plugins/password/package.xml b/plugins/password/package.xml index c2a3442dd..39fb2aad8 100644 --- a/plugins/password/package.xml +++ b/plugins/password/package.xml @@ -15,9 +15,9 @@ <email>alec@alec.pl</email> <active>yes</active> </lead> - <date>2011-11-23</date> + <date>2012-03-07</date> <version> - <release>3.0</release> + <release>3.1</release> <api>2.0</api> </version> <stability> @@ -26,7 +26,8 @@ </stability> <license uri="http://www.gnu.org/licenses/gpl-2.0.html">GNU GPLv2</license> <notes> -- Fixed drivers namespace issues +- Added pw_usermod driver (#1487826) +- Added option password_login_exceptions (#1487826) </notes> <contents> <dir baseinstalldir="/" name="/"> @@ -85,6 +86,7 @@ <file name="drivers/cpanel.php" role="php"></file> <file name="drivers/hmail.php" role="php"></file> <file name="drivers/pam.php" role="php"></file> + <file name="drivers/pw_usermod.php" role="php"></file> <file name="drivers/sasl.php" role="php"></file> <file name="drivers/virtualmin.php" role="php"></file> <file name="drivers/ximss.php" role="php"></file> @@ -302,5 +304,20 @@ - Save Samba password hashes in capital letters (#1488197) </notes> </release> + <release> + <date>2011-11-23</date> + <version> + <release>3.0</release> + <api>2.0</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> +- Fixed drivers namespace issues + </notes> + </release> </changelog> </package> diff --git a/plugins/password/password.php b/plugins/password/password.php index 5ed08ed42..58b6f8cd9 100644 --- a/plugins/password/password.php +++ b/plugins/password/password.php @@ -53,6 +53,22 @@ class password extends rcube_plugin function init() { $rcmail = rcmail::get_instance(); + + $this->load_config(); + + // Exceptions list + if ($exceptions = $rcmail->config->get('password_login_exceptions')) { + $exceptions = array_map('trim', (array) $exceptions); + $exceptions = array_filter($exceptions); + $username = $_SESSION['username']; + + foreach ($exceptions as $ec) { + if ($username === $ec) { + return; + } + } + } + // add Tab label $rcmail->output->add_label('password'); $this->register_action('plugin.password', array($this, 'password_init')); @@ -73,7 +89,6 @@ class password extends rcube_plugin function password_save() { $rcmail = rcmail::get_instance(); - $this->load_config(); $this->add_texts('localization/'); $this->register_handler('plugin.body', array($this, 'password_form')); @@ -87,7 +102,6 @@ class password extends rcube_plugin $rcmail->output->command('display_message', $this->gettext('nopassword'), 'error'); } else { - $charset = strtoupper($rcmail->config->get('password_charset', 'ISO-8859-1')); $rc_charset = strtoupper($rcmail->output->get_charset()); @@ -159,7 +173,6 @@ class password extends rcube_plugin function password_form() { $rcmail = rcmail::get_instance(); - $this->load_config(); // add some labels to client $rcmail->output->add_label( |
