From b67c690498804130b9fcf2e5b21f70317104fac7 Mon Sep 17 00:00:00 2001 From: Bob4ever Date: Thu, 15 Oct 2015 17:22:21 +0200 Subject: [PATCH 1/2] Fixed a bug in SFTP::chmod not using realpath on the filepath --- phpseclib/Net/SFTP.php | 1 + 1 file changed, 1 insertion(+) diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index b056628f..361aac78 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -1454,6 +1454,7 @@ class Net_SFTP extends Net_SSH2 return true; } + $filename = $this->_realPath($filename); // rather than return what the permissions *should* be, we'll return what they actually are. this will also // tell us if the file actually exists. // incidentally, SFTPv4+ adds an additional 32-bit integer field - flags - to the following: From 579e51c58f07a5ba4e58c574e2e9a8d30c58455a Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 19 Oct 2015 00:06:41 +0200 Subject: [PATCH 2/2] Add test case for GitHub Issue 850: Realpath in SFTP chmod(). --- tests/Functional/Net/SFTPUserStoryTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/Functional/Net/SFTPUserStoryTest.php b/tests/Functional/Net/SFTPUserStoryTest.php index 770ad95b..c01948f4 100644 --- a/tests/Functional/Net/SFTPUserStoryTest.php +++ b/tests/Functional/Net/SFTPUserStoryTest.php @@ -238,6 +238,20 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase /** * @depends testTruncate + * @group github850 + */ + public function testChModOnFile($sftp) + { + $this->assertNotFalse( + $sftp->chmod(0755, 'file1.txt'), + 'Failed asserting that chmod() was successful.' + ); + + return $sftp; + } + + /** + * @depends testChModOnFile */ public function testChDirOnFile($sftp) {