mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 17:24:07 +02:00
fix handling of 'Everyone' acl when using native backend
This commit is contained in:
parent
91d173cc55
commit
b623cc1d7f
3 changed files with 43 additions and 5 deletions
|
|
@ -185,6 +185,7 @@ class NativeFileInfo implements IFileInfo {
|
||||||
|
|
||||||
foreach (explode(',', $attribute) as $acl) {
|
foreach (explode(',', $attribute) as $acl) {
|
||||||
list($user, $permissions) = explode(':', $acl, 2);
|
list($user, $permissions) = explode(':', $acl, 2);
|
||||||
|
$user = trim($user, '\\');
|
||||||
list($type, $flags, $mask) = explode('/', $permissions);
|
list($type, $flags, $mask) = explode('/', $permissions);
|
||||||
$mask = hexdec($mask);
|
$mask = hexdec($mask);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
namespace Icewind\SMB\Test;
|
namespace Icewind\SMB\Test;
|
||||||
|
|
||||||
|
use Icewind\SMB\ACL;
|
||||||
use Icewind\SMB\BasicAuth;
|
use Icewind\SMB\BasicAuth;
|
||||||
use Icewind\SMB\Exception\InvalidArgumentException;
|
use Icewind\SMB\Exception\InvalidArgumentException;
|
||||||
use Icewind\SMB\IOptions;
|
use Icewind\SMB\IOptions;
|
||||||
|
|
@ -81,4 +82,15 @@ class NativeShareTest extends AbstractShareTest {
|
||||||
);
|
);
|
||||||
$server->listShares();
|
$server->listShares();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testACL() {
|
||||||
|
$this->share->mkdir($this->root . "/test");
|
||||||
|
$listing = $this->share->dir($this->root);
|
||||||
|
|
||||||
|
$this->assertCount(1, $listing);
|
||||||
|
$acls = $listing[0]->getAcls();
|
||||||
|
$acl = $acls['Everyone'];
|
||||||
|
$this->assertEquals($acl->getType(), ACL::TYPE_ALLOW);
|
||||||
|
$this->assertEquals(ACL::MASK_READ, $acl->getMask() & ACL::MASK_READ);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ namespace Icewind\SMB\Test;
|
||||||
use Icewind\SMB\ACL;
|
use Icewind\SMB\ACL;
|
||||||
use Icewind\SMB\IFileInfo;
|
use Icewind\SMB\IFileInfo;
|
||||||
use Icewind\SMB\Wrapped\FileInfo;
|
use Icewind\SMB\Wrapped\FileInfo;
|
||||||
|
use Icewind\SMB\Wrapped\Parser;
|
||||||
|
|
||||||
class ParserTest extends \PHPUnit\Framework\TestCase {
|
class ParserTest extends \PHPUnit\Framework\TestCase {
|
||||||
public function modeProvider() {
|
public function modeProvider() {
|
||||||
|
|
@ -29,7 +30,7 @@ class ParserTest extends \PHPUnit\Framework\TestCase {
|
||||||
* @dataProvider modeProvider
|
* @dataProvider modeProvider
|
||||||
*/
|
*/
|
||||||
public function testParseMode($string, $mode) {
|
public function testParseMode($string, $mode) {
|
||||||
$parser = new \Icewind\SMB\Wrapped\Parser('UTC');
|
$parser = new Parser('UTC');
|
||||||
$this->assertEquals($mode, $parser->parseMode($string), 'Failed parsing ' . $string);
|
$this->assertEquals($mode, $parser->parseMode($string), 'Failed parsing ' . $string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -90,7 +91,7 @@ class ParserTest extends \PHPUnit\Framework\TestCase {
|
||||||
* @dataProvider statProvider
|
* @dataProvider statProvider
|
||||||
*/
|
*/
|
||||||
public function testStat($output, $stat) {
|
public function testStat($output, $stat) {
|
||||||
$parser = new \Icewind\SMB\Wrapped\Parser('UTC');
|
$parser = new Parser('UTC');
|
||||||
$this->assertEquals($stat, $parser->parseStat($output));
|
$this->assertEquals($stat, $parser->parseStat($output));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -124,14 +125,14 @@ class ParserTest extends \PHPUnit\Framework\TestCase {
|
||||||
* @dataProvider dirProvider
|
* @dataProvider dirProvider
|
||||||
*/
|
*/
|
||||||
public function testDir($output, $dir) {
|
public function testDir($output, $dir) {
|
||||||
$parser = new \Icewind\SMB\Wrapped\Parser('CEST');
|
$parser = new Parser('CEST');
|
||||||
$this->assertEquals($dir, $parser->parseDir($output, '', function () {
|
$this->assertEquals($dir, $parser->parseDir($output, '', function () {
|
||||||
return [];
|
return [];
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testParseACL() {
|
public function testParseACLRealWorld() {
|
||||||
$parser = new \Icewind\SMB\Wrapped\Parser('CEST');
|
$parser = new Parser('CEST');
|
||||||
$raw = [
|
$raw = [
|
||||||
"lp_load_ex: refreshing parameters",
|
"lp_load_ex: refreshing parameters",
|
||||||
"Initialising global parameters",
|
"Initialising global parameters",
|
||||||
|
|
@ -176,4 +177,28 @@ class ParserTest extends \PHPUnit\Framework\TestCase {
|
||||||
$result = $parser->parseACLs($raw);
|
$result = $parser->parseACLs($raw);
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testParseACLConstructed() {
|
||||||
|
$parser = new Parser('CEST');
|
||||||
|
$raw = [
|
||||||
|
"REVISION:1",
|
||||||
|
"CONTROL:SR|PD|DI|DP",
|
||||||
|
"OWNER:DESKTOP-MLM38Q5\robin",
|
||||||
|
"GROUP:DESKTOP-MLM38Q5\None",
|
||||||
|
"ACL:Everyone:ALLOWED/0x0/READ",
|
||||||
|
"ACL:Test:DENIED/0x0/R",
|
||||||
|
"ACL:Multiple:ALLOWED/0x0/R|X|D",
|
||||||
|
"ACL:Numeric:ALLOWED/0x0/0x10",
|
||||||
|
"Maximum access: 0x120089"
|
||||||
|
];
|
||||||
|
|
||||||
|
$expected = [
|
||||||
|
"Everyone" => new ACL(ACL::TYPE_ALLOW, 0, ACL::MASK_READ + ACL::MASK_EXECUTE),
|
||||||
|
"Test" => new ACL(ACL::TYPE_DENY, 0, ACL::MASK_READ),
|
||||||
|
"Multiple" => new ACL(ACL::TYPE_ALLOW, 0, ACL::MASK_READ + ACL::MASK_EXECUTE + ACL::MASK_DELETE),
|
||||||
|
"Numeric" => new ACL(ACL::TYPE_ALLOW, 0, 0x10),
|
||||||
|
];
|
||||||
|
$result = $parser->parseACLs($raw);
|
||||||
|
$this->assertEquals($expected, $result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue