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.

chpasswd.php 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * chpasswd driver
  4. *
  5. * Driver that adds functionality to change the systems user password via
  6. * the 'chpasswd' command.
  7. *
  8. * For installation instructions please read the README file.
  9. *
  10. * @version 2.0
  11. * @author Alex Cartwright <acartwright@mutinydesign.co.uk>
  12. *
  13. * Copyright (C) 2005-2013, The Roundcube Dev Team
  14. *
  15. * This program is free software: you can redistribute it and/or modify
  16. * it under the terms of the GNU General Public License as published by
  17. * the Free Software Foundation, either version 3 of the License, or
  18. * (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program. If not, see http://www.gnu.org/licenses/.
  27. */
  28. class rcube_chpasswd_password
  29. {
  30. public function save($currpass, $newpass)
  31. {
  32. $cmd = rcmail::get_instance()->config->get('password_chpasswd_cmd');
  33. $username = $_SESSION['username'];
  34. $handle = popen($cmd, "w");
  35. fwrite($handle, "$username:$newpass\n");
  36. if (pclose($handle) == 0) {
  37. return PASSWORD_SUCCESS;
  38. }
  39. else {
  40. rcube::raise_error(array(
  41. 'code' => 600,
  42. 'type' => 'php',
  43. 'file' => __FILE__, 'line' => __LINE__,
  44. 'message' => "Password plugin: Unable to execute $cmd"
  45. ), true, false);
  46. }
  47. return PASSWORD_ERROR;
  48. }
  49. }