You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sasl.php 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * SASL Password Driver
  4. *
  5. * Driver that adds functionality to change the users Cyrus/SASL password.
  6. * The code is derrived from the Squirrelmail "Change SASL Password" Plugin
  7. * by Galen Johnson.
  8. *
  9. * It only works with saslpasswd2 on the same host where Roundcube runs
  10. * and requires shell access and gcc in order to compile the binary.
  11. *
  12. * For installation instructions please read the README file.
  13. *
  14. * @version 2.0
  15. * @author Thomas Bruederli
  16. *
  17. * Copyright (C) 2005-2013, The Roundcube Dev Team
  18. *
  19. * This program is free software: you can redistribute it and/or modify
  20. * it under the terms of the GNU General Public License as published by
  21. * the Free Software Foundation, either version 3 of the License, or
  22. * (at your option) any later version.
  23. *
  24. * This program is distributed in the hope that it will be useful,
  25. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. * GNU General Public License for more details.
  28. *
  29. * You should have received a copy of the GNU General Public License
  30. * along with this program. If not, see http://www.gnu.org/licenses/.
  31. */
  32. class rcube_sasl_password
  33. {
  34. function save($currpass, $newpass)
  35. {
  36. $curdir = RCUBE_PLUGINS_DIR . 'password/helpers';
  37. $username = escapeshellcmd($_SESSION['username']);
  38. $args = rcmail::get_instance()->config->get('password_saslpasswd_args', '');
  39. if ($fh = popen("$curdir/chgsaslpasswd -p $args $username", 'w')) {
  40. fwrite($fh, $newpass."\n");
  41. $code = pclose($fh);
  42. if ($code == 0)
  43. return PASSWORD_SUCCESS;
  44. }
  45. else {
  46. rcube::raise_error(array(
  47. 'code' => 600,
  48. 'type' => 'php',
  49. 'file' => __FILE__, 'line' => __LINE__,
  50. 'message' => "Password plugin: Unable to execute $curdir/chgsaslpasswd"
  51. ), true, false);
  52. }
  53. return PASSWORD_ERROR;
  54. }
  55. }