diff options
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/password/README | 8 | ||||
| -rw-r--r-- | plugins/password/config.inc.php.dist | 6 | ||||
| -rw-r--r-- | plugins/password/drivers/chpasswd.php | 37 |
3 files changed, 51 insertions, 0 deletions
diff --git a/plugins/password/README b/plugins/password/README index 400a5e7a5..46f1b3cac 100644 --- a/plugins/password/README +++ b/plugins/password/README @@ -36,6 +36,7 @@ 2.8. Virtualmin (virtualmin) 2.9. hMailServer (hmail) 2.10. PAM (pam) + 2.11. Chpasswd (chpasswd) 3. Driver API @@ -214,6 +215,13 @@ 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. + + 3. Driver API ------------- diff --git a/plugins/password/config.inc.php.dist b/plugins/password/config.inc.php.dist index 98cdc1d72..4030c008a 100644 --- a/plugins/password/config.inc.php.dist +++ b/plugins/password/config.inc.php.dist @@ -236,4 +236,10 @@ $rcmail_config['password_ximss_host'] = 'mail.example.com'; // XIMSS port on Communigate server $rcmail_config['password_ximss_port'] = 11024; + +// chpasswd Driver options +// --------------------- +// Command to use +$rcmail_config['password_chpasswd_cmd'] = 'sudo /usr/sbin/chpasswd 2> /dev/null'; + ?> diff --git a/plugins/password/drivers/chpasswd.php b/plugins/password/drivers/chpasswd.php new file mode 100644 index 000000000..ed15a054e --- /dev/null +++ b/plugins/password/drivers/chpasswd.php @@ -0,0 +1,37 @@ +<?php + +/** + * chpasswd Driver + * + * Driver that adds functionality to change the systems user password via + * the 'chpasswd' command. + * + * For installation instructions please read the README file. + * + * @version 1.0 + * @author Alex Cartwright <acartwright@mutinydesign.co.uk) + */ + +function password_save($currpass, $newpass) +{ + $cmd = sprintf('echo \'%1$s:%2$s\' | %3$s; echo $?', + addcslashes($_SESSION['username'], "'"), + addcslashes($newpass, "'"), + rcmail::get_instance()->config->get('password_chpasswd_cmd')); + + if (exec($cmd) == 0) { + return PASSWORD_SUCCESS; + } + else { + raise_error(array( + 'code' => 600, + 'type' => 'php', + 'file' => __FILE__, + 'message' => "Password plugin: Unable to execute $cmd" + ), true, false); + } + + return PASSWORD_ERROR; +} + +?> |
