SSH2: More multi-factor authentication changes

Previously to do multi-factor authentication you'd have to do this:

$ssh->login($user, 'pass1');
$ssh->login($user, 'pass2');

Now you can do this too:

$ssh->login($user, 'pass1', 'pass2');
This commit is contained in:
terrafrost 2013-04-20 14:33:07 -05:00
parent ccd4ce1d19
commit 04c24f6bbc
1 changed files with 28 additions and 4 deletions

View File

@ -1461,16 +1461,40 @@ class Net_SSH2 {
/**
* Login
*
* The $password parameter can be a plaintext password or a Crypt_RSA object.
* The $password parameter can be a plaintext password, a Crypt_RSA object or an array
*
* @param String $username
* @param Mixed $password
* @param Mixed $...
* @return Boolean
* @see _login_helper
* @access public
*/
function login($username)
{
$args = array_slice(func_get_args(), 1);
if (empty($args)) {
return $this->_login_helper($username);
}
foreach ($args as $arg) {
if ($this->_login_helper($username, $arg)) {
return true;
}
}
return false;
}
/**
* Login Helper
*
* @param String $username
* @param optional String $password
* @return Boolean
* @access public
* @access private
* @internal It might be worthwhile, at some point, to protect against {@link http://tools.ietf.org/html/rfc4251#section-9.3.9 traffic analysis}
* by sending dummy SSH_MSG_IGNORE messages.
*/
function login($username, $password = null)
function _login_helper($username, $password = null)
{
if (!($this->bitmap & NET_SSH2_MASK_CONSTRUCTOR)) {
return false;
@ -3130,4 +3154,4 @@ class Net_SSH2 {
}
return $this->exit_status;
}
}
}