1<?php
2/**
3 * Copyright 2002-2017 Horde LLC (http://www.horde.org/)
4 *
5 * See the enclosed file COPYING for license information (GPL). If you
6 * did not receive this file, see http://www.horde.org/licenses/gpl.
7 *
8 * @category  Horde
9 * @copyright 2002-2017 Horde LLC
10 * @license   http://www.horde.org/licenses/gpl GPL
11 * @package   Passwd
12 */
13
14/**
15 * Changes a password on a local vmailmgr daemon.
16 *
17 * @author    Marco Kaiser <bate@php.net>
18 * @category  Horde
19 * @copyright 2002-2017 Horde LLC
20 * @license   http://www.horde.org/licenses/gpl GPL
21 * @package   Passwd
22 */
23class Passwd_Driver_Vmailmgr extends Passwd_Driver
24{
25    /**
26     */
27    protected function _changePassword($user, $oldpass, $newpass)
28    {
29        if (isset($this->_params['vmailinc']) &&
30            is_readable($this->_params['vmailinc'])) {
31            include $this->_params['vmailinc'];
32        } else {
33            throw new Passwd_Exception('vmail.inc not found! (' . $this->_params['vmailinc'] . ')');
34        }
35
36        list($user, $domain) = explode('@', $user);
37        $res = vchpass($domain, $oldpass, $user, $newpass);
38
39        if ($res[0]) {
40            throw new Passwd_Exception(_("Incorrect old password."));
41        }
42    }
43}
44