From a14e71f38b441829c1ad945b9094e27a943f5a11 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sun, 6 Apr 2014 23:45:25 -0500 Subject: [PATCH 01/10] SSH2: connect to server in login() function this change will make it so some parameters can be set after the Net_SSH2 object has been created. eg. instead of doing define('NET_SSH2_LOGGING', NET_SSH2_LOG_COMPLEX) one can now do $ssh->setLogging(...) or something. --- phpseclib/Net/SSH2.php | 90 ++++++++++++++++++++++++++++++++---------- 1 file changed, 70 insertions(+), 20 deletions(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 2d88e4b2..c400e543 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -73,10 +73,11 @@ * @access private */ define('NET_SSH2_MASK_CONSTRUCTOR', 0x00000001); -define('NET_SSH2_MASK_LOGIN_REQ', 0x00000002); -define('NET_SSH2_MASK_LOGIN', 0x00000004); -define('NET_SSH2_MASK_SHELL', 0x00000008); -define('NET_SSH2_MASK_WINDOW_ADJUST', 0X00000010); +define('NET_SSH2_MASK_CONNECTED', 0x00000002); +define('NET_SSH2_MASK_LOGIN_REQ', 0x00000004); +define('NET_SSH2_MASK_LOGIN', 0x00000008); +define('NET_SSH2_MASK_SHELL', 0x00000010); +define('NET_SSH2_MASK_WINDOW_ADJUST', 0X00000020); /**#@-*/ /**#@+ @@ -669,6 +670,7 @@ class Net_SSH2 /** * Time of first network activity * + * @var Integer * @access private */ var $last_packet; @@ -684,6 +686,7 @@ class Net_SSH2 /** * Flag to request a PTY when using exec() * + * @var Boolean * @see Net_SSH2::enablePTY() * @access private */ @@ -692,6 +695,7 @@ class Net_SSH2 /** * Flag set while exec() is running when using enablePTY() * + * @var Boolean * @access private */ var $in_request_pty_exec = false; @@ -699,6 +703,7 @@ class Net_SSH2 /** * Flag set after startSubsystem() is called * + * @var Boolean * @access private */ var $in_subsystem; @@ -706,6 +711,7 @@ class Net_SSH2 /** * Contents of stdError * + * @var String * @access private */ var $stdErrorLog; @@ -714,6 +720,7 @@ class Net_SSH2 * The Last Interactive Response * * @see Net_SSH2::_keyboard_interactive_process() + * @var String * @access private */ var $last_interactive_response = ''; @@ -722,6 +729,7 @@ class Net_SSH2 * Keyboard Interactive Request / Responses * * @see Net_SSH2::_keyboard_interactive_process() + * @var Array * @access private */ var $keyboard_requests_responses = array(); @@ -734,6 +742,7 @@ class Net_SSH2 * * @see Net_SSH2::_filter() * @see Net_SSH2::getBannerMessage() + * @var String * @access private */ var $banner_message = ''; @@ -741,7 +750,8 @@ class Net_SSH2 /** * Did read() timeout or return normally? * - * @see Net_SSH2::isTimeout + * @see Net_SSH2::isTimeout() + * @var Boolean * @access private */ var $is_timeout = false; @@ -750,6 +760,7 @@ class Net_SSH2 * Log Boundary * * @see Net_SSH2::_format_log + * @var String * @access private */ var $log_boundary = ':'; @@ -758,6 +769,7 @@ class Net_SSH2 * Log Long Width * * @see Net_SSH2::_format_log + * @var Integer * @access private */ var $log_long_width = 65; @@ -766,10 +778,29 @@ class Net_SSH2 * Log Short Width * * @see Net_SSH2::_format_log + * @var Integer * @access private */ var $log_short_width = 16; + /** + * Hostname + * + * @see Net_SSH2::login() + * @var String + * @access private + */ + var $host; + + /** + * Port Number + * + * @see Net_SSH2::login() + * @var Integer + * @access private + */ + var $port; + /** * Default Constructor. * @@ -797,7 +828,6 @@ class Net_SSH2 include_once 'Crypt/Hash.php'; } - $this->last_packet = strtok(microtime(), ' ') + strtok(''); // == microtime(true) in PHP5 $this->message_numbers = array( 1 => 'NET_SSH2_MSG_DISCONNECT', 2 => 'NET_SSH2_MSG_IGNORE', @@ -868,11 +898,22 @@ class Net_SSH2 61 => 'NET_SSH2_MSG_USERAUTH_INFO_RESPONSE') ); + $this->host = $host; + $this->port = $port; + $this->timeout = $timeout; + } + + function _connect() + { + $timeout = $this->timeout; + + $this->last_packet = strtok(microtime(), ' ') + strtok(''); // == microtime(true) in PHP5 + $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 - $this->fsock = @fsockopen($host, $port, $errno, $errstr, $timeout); + $this->fsock = @fsockopen($this->host, $this->port, $errno, $errstr, $timeout); if (!$this->fsock) { - user_error(rtrim("Cannot connect to $host. Error $errno. $errstr")); - return; + user_error(rtrim("Cannot connect to $this->host:$this->port. Error $errno. $errstr")); + return false; } $elapsed = strtok(microtime(), ' ') + strtok('') - $start; @@ -880,7 +921,7 @@ class Net_SSH2 if ($timeout <= 0) { user_error(rtrim("Cannot connect to $host. Timeout error")); - return; + return false; } $read = array($this->fsock); @@ -893,7 +934,7 @@ class Net_SSH2 // the !count() is done as a workaround for if (!@stream_select($read, $write, $except, $sec, $usec) && !count($read)) { user_error(rtrim("Cannot connect to $host. Banner timeout")); - return; + return false; } /* According to the SSH2 specs, @@ -932,7 +973,7 @@ class Net_SSH2 if ($matches[1] != '1.99' && $matches[1] != '2.0') { user_error("Cannot connect to SSH $matches[1] servers"); - return; + return false; } fputs($this->fsock, $this->identifier . "\r\n"); @@ -940,19 +981,21 @@ class Net_SSH2 $response = $this->_get_binary_packet(); if ($response === false) { user_error('Connection closed by server'); - return; + return false; } if (ord($response[0]) != NET_SSH2_MSG_KEXINIT) { user_error('Expected SSH_MSG_KEXINIT'); - return; + return false; } if (!$this->_key_exchange($response)) { - return; + return false; } - $this->bitmap = NET_SSH2_MASK_CONSTRUCTOR; + $this->bitmap = NET_SSH2_MASK_CONNECTED; + + return true; } /** @@ -1694,6 +1737,13 @@ class Net_SSH2 */ function login($username) { + if (!($this->bitmap & NET_SSH2_MASK_CONSTRUCTOR)) { + $this->bitmap != NET_SSH2_MASK_CONSTRUCTOR; + if (!$this->_connect()) { + return false; + } + } + $args = func_get_args(); return call_user_func_array(array(&$this, '_login'), $args); } @@ -1735,7 +1785,7 @@ class Net_SSH2 */ function _login_helper($username, $password = null) { - if (!($this->bitmap & NET_SSH2_MASK_CONSTRUCTOR)) { + if (!($this->bitmap & NET_SSH2_MASK_CONNECTED)) { return false; } @@ -2687,7 +2737,7 @@ class Net_SSH2 } // see http://tools.ietf.org/html/rfc4252#section-5.4; only called when the encryption has been activated and when we haven't already logged in - if (($this->bitmap & NET_SSH2_MASK_CONSTRUCTOR) && !($this->bitmap & NET_SSH2_MASK_LOGIN) && ord($payload[0]) == NET_SSH2_MSG_USERAUTH_BANNER) { + if (($this->bitmap & NET_SSH2_MASK_CONNECTED) && !($this->bitmap & NET_SSH2_MASK_LOGIN) && ord($payload[0]) == NET_SSH2_MSG_USERAUTH_BANNER) { $this->_string_shift($payload, 1); extract(unpack('Nlength', $this->_string_shift($payload, 4))); $this->banner_message = utf8_decode($this->_string_shift($payload, $length)); @@ -2695,7 +2745,7 @@ class Net_SSH2 } // only called when we've already logged in - if (($this->bitmap & NET_SSH2_MASK_CONSTRUCTOR) && ($this->bitmap & NET_SSH2_MASK_LOGIN)) { + if (($this->bitmap & NET_SSH2_MASK_CONNECTED) && ($this->bitmap & NET_SSH2_MASK_LOGIN)) { switch (ord($payload[0])) { case NET_SSH2_MSG_GLOBAL_REQUEST: // see http://tools.ietf.org/html/rfc4254#section-4 $this->_string_shift($payload, 1); @@ -2907,7 +2957,7 @@ class Net_SSH2 // currently, there's only one possible value for $data_type_code: NET_SSH2_EXTENDED_DATA_STDERR extract(unpack('Ndata_type_code/Nlength', $this->_string_shift($response, 8))); $data = $this->_string_shift($response, $length); - $this->stdErrorLog .= $data; + $this->stdErrorLog.= $data; if ($skip_extended || $this->quiet_mode) { break; } From fc748346fc1aa930ad558923bcdd77f4cee471d0 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sun, 6 Apr 2014 23:56:21 -0500 Subject: [PATCH 02/10] SSH2: add phpdoc header --- phpseclib/Net/SSH2.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index c400e543..9a045e20 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -804,11 +804,10 @@ class Net_SSH2 /** * Default Constructor. * - * Connects to an SSHv2 server - * * @param String $host * @param optional Integer $port * @param optional Integer $timeout + * @see login * @return Net_SSH2 * @access public */ @@ -903,6 +902,12 @@ class Net_SSH2 $this->timeout = $timeout; } + /** + * Connect to an SSHv2 server + * + * @return Boolean + * @access private + */ function _connect() { $timeout = $this->timeout; From f27a49299e5ff74d9a14c7855fb45a57adbbfa53 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Mon, 7 Apr 2014 00:02:03 -0500 Subject: [PATCH 03/10] SSH2: timeout set in constructor != timeout set by setTimeout() --- phpseclib/Net/SSH2.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 9a045e20..e96fc768 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -801,6 +801,17 @@ class Net_SSH2 */ var $port; + /** + * Timeout for Constructor + * + * For historical BC purposes setTimeout() does not effect timeout of constructor + * + * @see Net_SSH2::login() + * @var Integer + * @access private + */ + var $constructorTimeout + /** * Default Constructor. * @@ -899,7 +910,7 @@ class Net_SSH2 $this->host = $host; $this->port = $port; - $this->timeout = $timeout; + $this->constructorTimeout = $timeout; } /** @@ -910,7 +921,7 @@ class Net_SSH2 */ function _connect() { - $timeout = $this->timeout; + $timeout = $this->constructorTimeout; $this->last_packet = strtok(microtime(), ' ') + strtok(''); // == microtime(true) in PHP5 From ab341df973ef282a29c3a7ddc29246bb0ec2308a Mon Sep 17 00:00:00 2001 From: terrafrost Date: Mon, 7 Apr 2014 00:16:54 -0500 Subject: [PATCH 04/10] SSH2: syntax error --- phpseclib/Net/SSH2.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index e96fc768..24ceeb97 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -810,7 +810,7 @@ class Net_SSH2 * @var Integer * @access private */ - var $constructorTimeout + var $constructorTimeout; /** * Default Constructor. From 8f08301744d73d3d47207d8ff445b90ee052b59f Mon Sep 17 00:00:00 2001 From: terrafrost Date: Mon, 7 Apr 2014 00:19:35 -0500 Subject: [PATCH 05/10] SSH2: phpdoc changes --- phpseclib/Net/SSH2.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 24ceeb97..99920a74 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -786,7 +786,8 @@ class Net_SSH2 /** * Hostname * - * @see Net_SSH2::login() + * @see Net_SSH2::Net_SSH2() + * @see Net_SSH2::_connect() * @var String * @access private */ @@ -795,7 +796,8 @@ class Net_SSH2 /** * Port Number * - * @see Net_SSH2::login() + * @see Net_SSH2::Net_SSH2() + * @see Net_SSH2::_connect() * @var Integer * @access private */ @@ -806,7 +808,8 @@ class Net_SSH2 * * For historical BC purposes setTimeout() does not effect timeout of constructor * - * @see Net_SSH2::login() + * @see Net_SSH2::Net_SSH2() + * @see Net_SSH2::_connect() * @var Integer * @access private */ From 6fcfe5c885d4f2adb2628d9986c90a7d13b4b793 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Mon, 7 Apr 2014 00:25:38 -0500 Subject: [PATCH 06/10] SSH2: != -> |= --- phpseclib/Net/SSH2.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 99920a74..1906a724 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -1757,7 +1757,7 @@ class Net_SSH2 function login($username) { if (!($this->bitmap & NET_SSH2_MASK_CONSTRUCTOR)) { - $this->bitmap != NET_SSH2_MASK_CONSTRUCTOR; + $this->bitmap |= NET_SSH2_MASK_CONSTRUCTOR; if (!$this->_connect()) { return false; } From 24bb941799984f70003ea79508756cb86c440f9c Mon Sep 17 00:00:00 2001 From: terrafrost Date: Mon, 7 Apr 2014 00:30:50 -0500 Subject: [PATCH 07/10] SSH1: do fsockopen() call when login has been called --- phpseclib/Net/SSH1.php | 90 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 78 insertions(+), 12 deletions(-) diff --git a/phpseclib/Net/SSH1.php b/phpseclib/Net/SSH1.php index ed70a289..160b77d5 100644 --- a/phpseclib/Net/SSH1.php +++ b/phpseclib/Net/SSH1.php @@ -182,8 +182,9 @@ define('NET_SSH1_RESPONSE_DATA', 2); * @access private */ define('NET_SSH1_MASK_CONSTRUCTOR', 0x00000001); -define('NET_SSH1_MASK_LOGIN', 0x00000002); -define('NET_SSH1_MASK_SHELL', 0x00000004); +define('NET_SSH1_MASK_CONNECTED', 0x00000002); +define('NET_SSH1_MASK_LOGIN', 0x00000004); +define('NET_SSH1_MASK_SHELL', 0x00000008); /**#@-*/ /**#@+ @@ -457,6 +458,48 @@ class Net_SSH1 */ var $log_short_width = 16; + /** + * Hostname + * + * @see Net_SSH1::Net_SSH1() + * @see Net_SSH1::_connect() + * @var String + * @access private + */ + var $host; + + /** + * Port Number + * + * @see Net_SSH1::Net_SSH1() + * @see Net_SSH1::_connect() + * @var Integer + * @access private + */ + var $port; + + /** + * Timeout for Constructor + * + * For historical BC purposes setTimeout() does not effect timeout of constructor + * + * @see Net_SSH1::Net_SSH1() + * @see Net_SSH1::_connect() + * @var Integer + * @access private + */ + var $constructorTimeout; + + /** + * Default cipher + * + * @see Net_SSH1::Net_SSH1() + * @see Net_SSH1::_connect() + * @var Integer + * @access private + */ + var $cipher; + /** * Default Constructor. * @@ -505,10 +548,24 @@ class Net_SSH1 $this->_define_array($this->protocol_flags); - $this->fsock = @fsockopen($host, $port, $errno, $errstr, $timeout); + $this->host = $host; + $this->port = $port; + $this->constructorTimeout = $timeout; + $this->cipher = $cipher; + } + + /** + * Connect to an SSHv1 server + * + * @return Boolean + * @access private + */ + function _connect() + { + $this->fsock = @fsockopen($this->host, $this->port, $errno, $errstr, $this->constructorTimeout); if (!$this->fsock) { - user_error(rtrim("Cannot connect to $host. Error $errno. $errstr")); - return; + user_error(rtrim("Cannot connect to $this->host:$this->port. Error $errno. $errstr")); + return false; } $this->server_identification = $init_line = fgets($this->fsock, 255); @@ -520,11 +577,11 @@ class Net_SSH1 if (!preg_match('#SSH-([0-9\.]+)-(.+)#', $init_line, $parts)) { user_error('Can only connect to SSH servers'); - return; + return false; } if ($parts[1][0] != 1) { user_error("Cannot connect to SSH $parts[1] servers"); - return; + return false; } fputs($this->fsock, $this->identifier."\r\n"); @@ -532,7 +589,7 @@ class Net_SSH1 $response = $this->_get_binary_packet(); if ($response[NET_SSH1_RESPONSE_TYPE] != NET_SSH1_SMSG_PUBLIC_KEY) { user_error('Expected SSH_SMSG_PUBLIC_KEY'); - return; + return false; } $anti_spoofing_cookie = $this->_string_shift($response[NET_SSH1_RESPONSE_DATA], 8); @@ -612,12 +669,12 @@ class Net_SSH1 ); } - $cipher = isset($this->supported_ciphers[$cipher]) ? $cipher : NET_SSH1_CIPHER_3DES; + $cipher = isset($this->supported_ciphers[$this->cipher]) ? $this->cipher : NET_SSH1_CIPHER_3DES; $data = pack('C2a*na*N', NET_SSH1_CMSG_SESSION_KEY, $cipher, $anti_spoofing_cookie, 8 * strlen($double_encrypted_session_key), $double_encrypted_session_key, 0); if (!$this->_send_binary_packet($data)) { user_error('Error sending SSH_CMSG_SESSION_KEY'); - return; + return false; } switch ($cipher) { @@ -656,10 +713,12 @@ class Net_SSH1 if ($response[NET_SSH1_RESPONSE_TYPE] != NET_SSH1_SMSG_SUCCESS) { user_error('Expected SSH_SMSG_SUCCESS'); - return; + return false; } - $this->bitmap = NET_SSH1_MASK_CONSTRUCTOR; + $this->bitmap = NET_SSH1_MASK_CONNECTED; + + return true; } /** @@ -673,6 +732,13 @@ class Net_SSH1 function login($username, $password = '') { if (!($this->bitmap & NET_SSH1_MASK_CONSTRUCTOR)) { + $this->bitmap |= NET_SSH1_MASK_CONSTRUCTOR; + if (!$this->_connect()) { + return false; + } + } + + if (!($this->bitmap & NET_SSH1_MASK_CONNECTED)) { return false; } From 677a291cb330fb74dd3130fac23fc5768666f01a Mon Sep 17 00:00:00 2001 From: terrafrost Date: Mon, 7 Apr 2014 10:26:46 -0500 Subject: [PATCH 08/10] SSH: clarify role of constructor / connection timeout Also, in Net_SSH2::_connect() $host is used in multiple places. Rather than changing all references to {$this->host}:{$this->port} preserve existing $host reference and update it accordingly --- phpseclib/Net/SSH1.php | 15 +++++++++------ phpseclib/Net/SSH2.php | 16 ++++++++++------ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/phpseclib/Net/SSH1.php b/phpseclib/Net/SSH1.php index 160b77d5..649668d7 100644 --- a/phpseclib/Net/SSH1.php +++ b/phpseclib/Net/SSH1.php @@ -479,16 +479,19 @@ class Net_SSH1 var $port; /** - * Timeout for Constructor + * Timeout for initial connection * - * For historical BC purposes setTimeout() does not effect timeout of constructor + * Set by the constructor call. Calling setTimeout() is optional. If it's not called functions like + * exec() won't timeout unless some PHP setting forces it too. The timeout specified in the constructor, + * however, is non-optional. There will be a timeout, whether or not you set it. If you don't it'll be + * 10 seconds. It is used by fsockopen() in that function. * * @see Net_SSH1::Net_SSH1() * @see Net_SSH1::_connect() * @var Integer * @access private */ - var $constructorTimeout; + var $connectionTimeout; /** * Default cipher @@ -550,7 +553,7 @@ class Net_SSH1 $this->host = $host; $this->port = $port; - $this->constructorTimeout = $timeout; + $this->connectionTimeout = $timeout; $this->cipher = $cipher; } @@ -562,9 +565,9 @@ class Net_SSH1 */ function _connect() { - $this->fsock = @fsockopen($this->host, $this->port, $errno, $errstr, $this->constructorTimeout); + $this->fsock = @fsockopen($this->host, $this->port, $errno, $errstr, $this->connectionTimeout); if (!$this->fsock) { - user_error(rtrim("Cannot connect to $this->host:$this->port. Error $errno. $errstr")); + user_error(rtrim("Cannot connect to {$this->host}:{$this->port}. Error $errno. $errstr")); return false; } diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 1906a724..229b01b2 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -804,16 +804,19 @@ class Net_SSH2 var $port; /** - * Timeout for Constructor + * Timeout for initial connection * - * For historical BC purposes setTimeout() does not effect timeout of constructor + * Set by the constructor call. Calling setTimeout() is optional. If it's not called functions like + * exec() won't timeout unless some PHP setting forces it too. The timeout specified in the constructor, + * however, is non-optional. There will be a timeout, whether or not you set it. If you don't it'll be + * 10 seconds. It is used by fsockopen() and the initial stream_select in that function. * * @see Net_SSH2::Net_SSH2() * @see Net_SSH2::_connect() * @var Integer * @access private */ - var $constructorTimeout; + var $connectionTimeout; /** * Default Constructor. @@ -913,7 +916,7 @@ class Net_SSH2 $this->host = $host; $this->port = $port; - $this->constructorTimeout = $timeout; + $this->connectionTimeout = $timeout; } /** @@ -924,14 +927,15 @@ class Net_SSH2 */ function _connect() { - $timeout = $this->constructorTimeout; + $timeout = $this->connectionTimeout; + $host = $this->host . ':' . $this->port; $this->last_packet = strtok(microtime(), ' ') + strtok(''); // == microtime(true) in PHP5 $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 $this->fsock = @fsockopen($this->host, $this->port, $errno, $errstr, $timeout); if (!$this->fsock) { - user_error(rtrim("Cannot connect to $this->host:$this->port. Error $errno. $errstr")); + user_error(rtrim("Cannot connect to $host. Error $errno. $errstr")); return false; } $elapsed = strtok(microtime(), ' ') + strtok('') - $start; From 0ad0bb4c37015852a7bcb745210498cf0831ad94 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Mon, 7 Apr 2014 15:43:31 -0500 Subject: [PATCH 09/10] SSH2: phpdoc updates --- phpseclib/Net/SSH2.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 229b01b2..22f8fe6f 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -759,7 +759,7 @@ class Net_SSH2 /** * Log Boundary * - * @see Net_SSH2::_format_log + * @see Net_SSH2::_format_log() * @var String * @access private */ @@ -768,7 +768,7 @@ class Net_SSH2 /** * Log Long Width * - * @see Net_SSH2::_format_log + * @see Net_SSH2::_format_log() * @var Integer * @access private */ @@ -777,7 +777,7 @@ class Net_SSH2 /** * Log Short Width * - * @see Net_SSH2::_format_log + * @see Net_SSH2::_format_log() * @var Integer * @access private */ @@ -824,7 +824,7 @@ class Net_SSH2 * @param String $host * @param optional Integer $port * @param optional Integer $timeout - * @see login + * @see Net_SSH2::login() * @return Net_SSH2 * @access public */ From 79719e8f74b653f85233d2b4585fd79186e7df96 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Tue, 8 Apr 2014 08:48:12 -0500 Subject: [PATCH 10/10] SSH2: move _connect() call to _login() from login() Per bantu, this is required for it to work with Net/SFTP.php --- phpseclib/Net/SSH2.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 22f8fe6f..3dee6eac 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -1760,13 +1760,6 @@ class Net_SSH2 */ function login($username) { - if (!($this->bitmap & NET_SSH2_MASK_CONSTRUCTOR)) { - $this->bitmap |= NET_SSH2_MASK_CONSTRUCTOR; - if (!$this->_connect()) { - return false; - } - } - $args = func_get_args(); return call_user_func_array(array(&$this, '_login'), $args); } @@ -1783,6 +1776,13 @@ class Net_SSH2 */ function _login($username) { + if (!($this->bitmap & NET_SSH2_MASK_CONSTRUCTOR)) { + $this->bitmap |= NET_SSH2_MASK_CONSTRUCTOR; + if (!$this->_connect()) { + return false; + } + } + $args = array_slice(func_get_args(), 1); if (empty($args)) { return $this->_login_helper($username);