Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. <?php
  2. /**
  3. * DBMail Password Driver
  4. *
  5. * Driver that adds functionality to change the users DBMail password.
  6. * The code is derrived from the Squirrelmail "Change SASL Password" Plugin
  7. * by Galen Johnson.
  8. *
  9. * It only works with dbmail-users 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 1.0
  15. *
  16. * Copyright (C) 2005-2013, The Roundcube Dev Team
  17. *
  18. * This program is free software: you can redistribute it and/or modify
  19. * it under the terms of the GNU General Public License as published by
  20. * the Free Software Foundation, either version 3 of the License, or
  21. * (at your option) any later version.
  22. *
  23. * This program is distributed in the hope that it will be useful,
  24. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26. * GNU General Public License for more details.
  27. *
  28. * You should have received a copy of the GNU General Public License
  29. * along with this program. If not, see http://www.gnu.org/licenses/.
  30. */
  31. class rcube_dbmail_password
  32. {
  33. function save($currpass, $newpass)
  34. {
  35. $curdir = RCUBE_PLUGINS_DIR . 'password/helpers';
  36. $username = escapeshellarg($_SESSION['username']);
  37. $password = escapeshellarg($newpass);
  38. $args = rcmail::get_instance()->config->get('password_dbmail_args', '');
  39. $command = "$curdir/chgdbmailusers -c $username -w $password $args";
  40. if (strlen($command) > 1024) {
  41. rcube::raise_error(array(
  42. 'code' => 600,
  43. 'type' => 'php',
  44. 'file' => __FILE__, 'line' => __LINE__,
  45. 'message' => "Password plugin: The command is too long."
  46. ), true, false);
  47. return PASSWORD_ERROR;
  48. }
  49. exec($command, $output, $returnvalue);
  50. if ($returnvalue == 0) {
  51. return PASSWORD_SUCCESS;
  52. }
  53. else {
  54. rcube::raise_error(array(
  55. 'code' => 600,
  56. 'type' => 'php',
  57. 'file' => __FILE__, 'line' => __LINE__,
  58. 'message' => "Password plugin: Unable to execute $curdir/chgdbmailusers"
  59. ), true, false);
  60. }
  61. return PASSWORD_ERROR;
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement