From 3dd92e56e453a2c7d801b6a7e05ac2036ab177ed Mon Sep 17 00:00:00 2001 From: terrafrost Date: Thu, 29 May 2014 16:14:03 -0500 Subject: [PATCH 1/3] SFTP/Stream: use $scheme instead of 'sftp' This makes it easier for someone to change the scheme (which can be done by changng the stream_wrapper_register call at the bottom of the file) --- phpseclib/Net/SFTP/Stream.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/phpseclib/Net/SFTP/Stream.php b/phpseclib/Net/SFTP/Stream.php index dfb3a5a9..a3871ba1 100644 --- a/phpseclib/Net/SFTP/Stream.php +++ b/phpseclib/Net/SFTP/Stream.php @@ -180,24 +180,24 @@ class Net_SFTP_Stream if (isset($this->context)) { $context = stream_context_get_options($this->context); } - if (isset($context['sftp']['session'])) { - $sftp = $context['sftp']['session']; + if (isset($context[$scheme]['session'])) { + $sftp = $context[$scheme]['session']; } - if (isset($context['sftp']['sftp'])) { - $sftp = $context['sftp']['sftp']; + if (isset($context[$scheme]['sftp'])) { + $sftp = $context[$scheme]['sftp']; } if (isset($sftp) && is_object($sftp) && get_class($sftp) == 'Net_SFTP') { $this->sftp = $sftp; return $path; } - if (isset($context['sftp']['username'])) { - $user = $context['sftp']['username']; + if (isset($context[$scheme]['username'])) { + $user = $context[$scheme]['username']; } - if (isset($context['sftp']['password'])) { - $pass = $context['sftp']['password']; + if (isset($context[$scheme]['password'])) { + $pass = $context[$scheme]['password']; } - if (isset($context['sftp']['privkey']) && is_object($context['sftp']['privkey']) && get_Class($context['sftp']['privkey']) == 'Crypt_RSA') { - $pass = $context['sftp']['privkey']; + if (isset($context[$scheme]['privkey']) && is_object($context[$scheme]['privkey']) && get_Class($context[$scheme]['privkey']) == 'Crypt_RSA') { + $pass = $context[$scheme]['privkey']; } if (!isset($user) || !isset($pass)) { From c0e3795319b35f7ee2a8a441657d94a263b3fb87 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Thu, 29 May 2014 16:23:28 -0500 Subject: [PATCH 2/3] SFTP/Stream: add explanation as to why nlist() is used here --- phpseclib/Net/SFTP/Stream.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/phpseclib/Net/SFTP/Stream.php b/phpseclib/Net/SFTP/Stream.php index a3871ba1..78cd6626 100644 --- a/phpseclib/Net/SFTP/Stream.php +++ b/phpseclib/Net/SFTP/Stream.php @@ -517,7 +517,20 @@ class Net_SFTP_Stream * Open directory handle * * The only $options is "whether or not to enforce safe_mode (0x04)". Since safe mode was deprecated in 5.3 and - * removed in 5.4 I'm just going to ignore it + * removed in 5.4 I'm just going to ignore it. + * + * Also, nlist() is the best that this function is realistically going to be able to do. When an SFTP client + * sends a SSH_FXP_READDIR packet you don't generally get info on just one file but on multiple files. quoting + * the SFTP specs: + * + * The SSH_FXP_NAME response has the following format: + * + * uint32 id + * uint32 count + * repeats count times: + * string filename + * string longname + * ATTRS attrs * * @param String $path * @param Integer $options From 7252017268b15fed92decdf04bd37219b4845617 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Thu, 29 May 2014 16:49:04 -0500 Subject: [PATCH 3/3] SFTP/Stream: fix capatilization --- phpseclib/Net/SFTP/Stream.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpseclib/Net/SFTP/Stream.php b/phpseclib/Net/SFTP/Stream.php index 78cd6626..2f11abaa 100644 --- a/phpseclib/Net/SFTP/Stream.php +++ b/phpseclib/Net/SFTP/Stream.php @@ -520,7 +520,7 @@ class Net_SFTP_Stream * removed in 5.4 I'm just going to ignore it. * * Also, nlist() is the best that this function is realistically going to be able to do. When an SFTP client - * sends a SSH_FXP_READDIR packet you don't generally get info on just one file but on multiple files. quoting + * sends a SSH_FXP_READDIR packet you don't generally get info on just one file but on multiple files. Quoting * the SFTP specs: * * The SSH_FXP_NAME response has the following format: