diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 3db9ec81..9c0c71e3 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -2512,7 +2512,7 @@ class SSH2 $this->is_timeout = false; $this->stdErrorLog = ''; - if (!($this->bitmap & self::MASK_LOGIN)) { + if (!$this->isAuthenticated()) { return false; } @@ -2811,7 +2811,7 @@ class SSH2 $this->curTimeout = $this->timeout; $this->is_timeout = false; - if (!($this->bitmap & self::MASK_LOGIN)) { + if (!$this->isAuthenticated()) { throw new \RuntimeException('Operation disallowed prior to login()'); } @@ -2852,7 +2852,7 @@ class SSH2 */ function write($cmd) { - if (!($this->bitmap & self::MASK_LOGIN)) { + if (!$this->isAuthenticated()) { throw new \RuntimeException('Operation disallowed prior to login()'); } @@ -3153,7 +3153,7 @@ class 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 & self::MASK_CONNECTED) && !($this->bitmap & self::MASK_LOGIN) && ord($payload[0]) == NET_SSH2_MSG_USERAUTH_BANNER) { + if (($this->bitmap & self::MASK_CONNECTED) && !$this->isAuthenticated() && ord($payload[0]) == NET_SSH2_MSG_USERAUTH_BANNER) { Strings::shift($payload, 1); if (strlen($payload) < 4) { return false; @@ -3164,7 +3164,7 @@ class SSH2 } // only called when we've already logged in - if (($this->bitmap & self::MASK_CONNECTED) && ($this->bitmap & self::MASK_LOGIN)) { + if (($this->bitmap & self::MASK_CONNECTED) && $this->isAuthenticated()) { switch (ord($payload[0])) { case NET_SSH2_MSG_GLOBAL_REQUEST: // see http://tools.ietf.org/html/rfc4254#section-4 if (strlen($payload) < 4) {