summaryrefslogtreecommitdiff
path: root/plugins/password
diff options
context:
space:
mode:
authoralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2010-04-22 11:44:25 +0000
committeralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2010-04-22 11:44:25 +0000
commitd24b11b949f7cd6c78f71aee0c51ea76399bb397 (patch)
tree9a53b81c7d8833195e86a9090caf76f90715c9e2 /plugins/password
parent56a8a546892343550974483077ae46769bd438fe (diff)
- Password: PAM driver
git-svn-id: https://svn.roundcube.net/trunk@3532 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'plugins/password')
-rw-r--r--plugins/password/README10
-rw-r--r--plugins/password/drivers/pam.php41
2 files changed, 50 insertions, 1 deletions
diff --git a/plugins/password/README b/plugins/password/README
index 1406fb4d5..400a5e7a5 100644
--- a/plugins/password/README
+++ b/plugins/password/README
@@ -34,7 +34,8 @@
2.6. cPanel (cpanel)
2.7. XIMSS/Communigate (ximms)
2.8. Virtualmin (virtualmin)
- 2.9 hMailServer (hmail)
+ 2.9. hMailServer (hmail)
+ 2.10. PAM (pam)
3. Driver API
@@ -206,6 +207,13 @@
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).
+
+
3. Driver API
-------------
diff --git a/plugins/password/drivers/pam.php b/plugins/password/drivers/pam.php
new file mode 100644
index 000000000..b1b3e9f03
--- /dev/null
+++ b/plugins/password/drivers/pam.php
@@ -0,0 +1,41 @@
+<?php
+
+/**
+ * PAM Password Driver
+ *
+ * @version 1.0
+ * @author Aleksander Machniak
+ */
+
+function password_save($currpass, $newpass)
+{
+ $user = $_SESSION['username'];
+
+ if (extension_loaded('pam')) {
+ if (pam_auth($user, $currpass, $error, false)) {
+ if (pam_chpass($user, $currpass, $newpass)) {
+ return PASSWORD_SUCCESS;
+ }
+ }
+ else {
+ raise_error(array(
+ 'code' => 600,
+ 'type' => 'php',
+ 'file' => __FILE__,
+ 'message' => "Password plugin: PAM authentication failed for user $user: $error"
+ ), true, false);
+ }
+ }
+ else {
+ raise_error(array(
+ 'code' => 600,
+ 'type' => 'php',
+ 'file' => __FILE__,
+ 'message' => "Password plugin: PECL-PAM module not loaded"
+ ), true, false);
+ }
+
+ return PASSWORD_ERROR;
+}
+
+?>