This file is indexed.

/usr/share/horde/passwd/lib/Driver/Expectpecl.php is in php-horde-passwd 5.0.2-3+deb8u1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
/**
 * Copyright 2006-2014 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.horde.org/licenses/gpl.
 *
 * @category  Horde
 * @copyright 2006-2014 Horde LLC
 * @license   http://www.horde.org/licenses/gpl GPL
 * @package   Passwd
 */

/**
 * A PECL expect implementation of the Passwd system.
 *
 * Copyright 2006-2014 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.horde.org/licenses/gpl.
 *
 * @author    Duck <duck@obala.net>
 * @category  Horde
 * @copyright 2006-2014 Horde LLC
 * @license   http://www.horde.org/licenses/gpl GPL
 * @package   Passwd
 */
class Passwd_Driver_Expectpecl extends Passwd_Driver
{
    /**
     * Expect connection handle.
     *
     * @var resource
     */
    protected $_stream;

    /**
     * Handles expect communication.
     *
     * @param string $expect  String to expect.
     * @param string $error   Error message.
     *
     * @throws Passwd_Exception
     */
    protected function _ctl($expect, $error)
    {
        $result = expect_expectl($this->_stream, array(
            array(
                0 => $expect,
                1 => 'ok',
                2 => EXP_REGEXP
            )
        ));

        switch ($result) {
        case EXP_EOF:
            throw new Passwd_Exception(_("End of file."));

        case EXP_TIMEOUT:
            throw new Passwd_Exception(_("Time out."));

        case EXP_FULLBUFFER:
            throw new Passwd_Exception(_("Full buffer."));

        case 'ok':
            return;

        default:
            throw new Passwd_Exception($error);
        }
    }

    /**
     */
    protected function _changePassword($user, $oldpass, $newpass)
    {
        if (!Horde_Util::loadExtension('expect')) {
            throw new Passwd_Exception(_("expect extension cannot be loaded"));
        }

        // Set up parameters
        foreach (array('logfile', 'loguser', 'timeout') as $val) {
            if (isset($this->_params[$val])) {
                ini_set('expect.' . $val, $this->_params[$val]);
            }
        }

        // Open connection
        $call = sprintf(
            'ssh %s@%s %s',
            $user,
            $this->_params['host'],
            $this->_params['program']
        );
        if (!($this->_stream = expect_popen($call))) {
            throw new Passwd_Exception(_("Unable to open expect stream"));
        }

        // Log in
        $this->_ctl(
            '(P|p)assword.*',
            _("Could not login to system (no password prompt)")
        );

        // Send login password
        fwrite($this->_stream, $oldpass . "\n");

        // Expect old password prompt
        $this->_ctl(
            '((O|o)ld|login|current).* (P|p)assword.*',
            _("Could not start passwd program (no old password prompt)")
        );

        // Send old password
        fwrite($this->_stream, $oldpass . "\n");

        // Expect new password prompt
        $this->_ctl(
            '(N|n)ew.* (P|p)assword.*',
            _("Could not change password (bad old password?)")
        );

        // Send new password
        fwrite($this->_stream, $newpass . "\n");

        // Expect reenter password prompt
        $this->_ctl(
            "((R|r)e-*enter.*(P|p)assword|Retype new( UNIX)? password|(V|v)erification|(V|v)erify|(A|a)gain).*",
            _("New password not valid (too short, bad password, too similar, ...)")
        );

        // Send new password
        fwrite($this->_stream, $newpass . "\n");

        // Expect successfully message
        $this->_ctl(
            '((P|p)assword.* changed|successfully)',
            _("Could not change password.")
        );
    }

}