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.

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