diff options
author | Stanislav Malyshev <stas@php.net> | 2020-02-15 22:17:14 -0800 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2020-02-17 00:20:17 -0800 |
commit | bbcb8cab8cdace25d481f2ade0539f75b0fa8c43 (patch) | |
tree | a2f4ca1346b7e6ad815767a84d5a4a7985761b3a /ext/phar/tests/bug79082.phpt | |
parent | 282bfb109ecd07cd76761c098304a45bd214e439 (diff) | |
download | php-git-bbcb8cab8cdace25d481f2ade0539f75b0fa8c43.tar.gz |
Fix bug #79082 - Files added to tar with Phar::buildFromIterator have all-access permissions
Diffstat (limited to 'ext/phar/tests/bug79082.phpt')
-rw-r--r-- | ext/phar/tests/bug79082.phpt | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/ext/phar/tests/bug79082.phpt b/ext/phar/tests/bug79082.phpt new file mode 100644 index 0000000000..ca453d1b57 --- /dev/null +++ b/ext/phar/tests/bug79082.phpt @@ -0,0 +1,52 @@ +--TEST-- +Phar: Bug #79082: Files added to tar with Phar::buildFromIterator have all-access permissions +--SKIPIF-- +<?php +if (!extension_loaded("phar")) die("skip"); +if (defined("PHP_WINDOWS_VERSION_MAJOR")) die("skip not for Windows") +?> +--FILE-- +<?php +umask(022); +var_dump(decoct(umask())); +chmod(__DIR__ . '/test79082/test79082-testfile', 0644); +chmod(__DIR__ . '/test79082/test79082-testfile2', 0400); + +foreach([Phar::TAR => 'tar', Phar::ZIP => 'zip'] as $mode => $ext) { + clearstatcache(); + $phar = new PharData(__DIR__ . '/test79082.' . $ext, null, null, $mode); + $phar->buildFromIterator(new \RecursiveDirectoryIterator(__DIR__ . '/test79082', \FilesystemIterator::SKIP_DOTS), __DIR__ . '/test79082'); + $phar->extractTo(__DIR__); + var_dump(decoct(stat(__DIR__ . '/test79082-testfile')['mode'])); + var_dump(decoct(stat(__DIR__ . '/test79082-testfile2')['mode'])); + unlink(__DIR__ . '/test79082-testfile'); + unlink(__DIR__ . '/test79082-testfile2'); +} +foreach([Phar::TAR => 'tar', Phar::ZIP => 'zip'] as $mode => $ext) { + clearstatcache(); + $phar = new PharData(__DIR__ . '/test79082-d.' . $ext, null, null, $mode); + $phar->buildFromDirectory(__DIR__ . '/test79082'); + $phar->extractTo(__DIR__); + var_dump(decoct(stat(__DIR__ . '/test79082-testfile')['mode'])); + var_dump(decoct(stat(__DIR__ . '/test79082-testfile2')['mode'])); + unlink(__DIR__ . '/test79082-testfile'); + unlink(__DIR__ . '/test79082-testfile2'); +} +?> +--CLEAN-- +<? +unlink(__DIR__ . '/test79082.tar'); +unlink(__DIR__ . '/test79082.zip'); +unlink(__DIR__ . '/test79082-d.tar'); +unlink(__DIR__ . '/test79082-d.zip'); +?> +--EXPECT-- +string(2) "22" +string(6) "100644" +string(6) "100400" +string(6) "100644" +string(6) "100400" +string(6) "100644" +string(6) "100400" +string(6) "100644" +string(6) "100400" |