From 9749aa936c854db4025564943d0244d6865084ad Mon Sep 17 00:00:00 2001 From: rubencm Date: Sun, 2 Feb 2020 22:00:38 +0000 Subject: [PATCH 1/2] [ticket/16351] Use CHMOD constants from filesystem_interface PHPBB3-16351 --- phpBB/includes/acp/acp_attachments.php | 2 +- phpBB/includes/constants.php | 8 ++++---- phpBB/includes/functions_compress.php | 10 +++++----- phpBB/includes/functions_messenger.php | 4 ++-- phpBB/includes/functions_posting.php | 2 +- phpBB/phpbb/cache/driver/file.php | 2 +- phpBB/phpbb/files/filespec.php | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php index 6298c7b0f2..3d2c9a5e31 100644 --- a/phpBB/includes/acp/acp_attachments.php +++ b/phpBB/includes/acp/acp_attachments.php @@ -1480,7 +1480,7 @@ class acp_attachments try { - $this->filesystem->phpbb_chmod($phpbb_root_path . $upload_dir, CHMOD_READ | CHMOD_WRITE); + $this->filesystem->phpbb_chmod($phpbb_root_path . $upload_dir, \phpbb\filesystem\filesystem_interface::CHMOD_READ | \phpbb\filesystem\filesystem_interface::CHMOD_WRITE); } catch (\phpbb\filesystem\exception\filesystem_exception $e) { diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index 1c77366380..45519843e3 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -225,10 +225,10 @@ define('REFERER_VALIDATE_HOST', 1); define('REFERER_VALIDATE_PATH', 2); // phpbb_chmod() permissions -@define('CHMOD_ALL', 7); -@define('CHMOD_READ', 4); -@define('CHMOD_WRITE', 2); -@define('CHMOD_EXECUTE', 1); +@define('CHMOD_ALL', 7); // @deprecated 3.2 +@define('CHMOD_READ', 4); // @deprecated 3.2 +@define('CHMOD_WRITE', 2); // @deprecated 3.2 +@define('CHMOD_EXECUTE', 1); // @deprecated 3.2 // Captcha code length define('CAPTCHA_MIN_CHARS', 4); diff --git a/phpBB/includes/functions_compress.php b/phpBB/includes/functions_compress.php index e86da77b38..107eeef19c 100644 --- a/phpBB/includes/functions_compress.php +++ b/phpBB/includes/functions_compress.php @@ -296,7 +296,7 @@ class compress_zip extends compress try { - $this->filesystem->phpbb_chmod($str, CHMOD_READ | CHMOD_WRITE); + $this->filesystem->phpbb_chmod($str, \phpbb\filesystem\filesystem_interface::CHMOD_READ | \phpbb\filesystem\filesystem_interface::CHMOD_WRITE); } catch (\phpbb\filesystem\exception\filesystem_exception $e) { @@ -333,7 +333,7 @@ class compress_zip extends compress try { - $this->filesystem->phpbb_chmod($str, CHMOD_READ | CHMOD_WRITE); + $this->filesystem->phpbb_chmod($str, \phpbb\filesystem\filesystem_interface::CHMOD_READ | \phpbb\filesystem\filesystem_interface::CHMOD_WRITE); } catch (\phpbb\filesystem\exception\filesystem_exception $e) { @@ -636,7 +636,7 @@ class compress_tar extends compress try { - $this->filesystem->phpbb_chmod($str, CHMOD_READ | CHMOD_WRITE); + $this->filesystem->phpbb_chmod($str, \phpbb\filesystem\filesystem_interface::CHMOD_READ | \phpbb\filesystem\filesystem_interface::CHMOD_WRITE); } catch (\phpbb\filesystem\exception\filesystem_exception $e) { @@ -671,7 +671,7 @@ class compress_tar extends compress try { - $this->filesystem->phpbb_chmod($str, CHMOD_READ | CHMOD_WRITE); + $this->filesystem->phpbb_chmod($str, \phpbb\filesystem\filesystem_interface::CHMOD_READ | \phpbb\filesystem\filesystem_interface::CHMOD_WRITE); } catch (\phpbb\filesystem\exception\filesystem_exception $e) { @@ -688,7 +688,7 @@ class compress_tar extends compress try { - $this->filesystem->phpbb_chmod($target_filename, CHMOD_READ); + $this->filesystem->phpbb_chmod($target_filename, \phpbb\filesystem\filesystem_interface::CHMOD_READ); } catch (\phpbb\filesystem\exception\filesystem_exception $e) { diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index ec297b536a..d7bea8e734 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -1013,7 +1013,7 @@ class queue try { - $this->filesystem->phpbb_chmod($this->cache_file, CHMOD_READ | CHMOD_WRITE); + $this->filesystem->phpbb_chmod($this->cache_file, \phpbb\filesystem\filesystem_interface::CHMOD_READ | \phpbb\filesystem\filesystem_interface::CHMOD_WRITE); } catch (\phpbb\filesystem\exception\filesystem_exception $e) { @@ -1067,7 +1067,7 @@ class queue try { - $this->filesystem->phpbb_chmod($this->cache_file, CHMOD_READ | CHMOD_WRITE); + $this->filesystem->phpbb_chmod($this->cache_file, \phpbb\filesystem\filesystem_interface::CHMOD_READ | \phpbb\filesystem\filesystem_interface::CHMOD_WRITE); } catch (\phpbb\filesystem\exception\filesystem_exception $e) { diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 1956f65666..3abfaff6bf 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -717,7 +717,7 @@ function create_thumbnail($source, $destination, $mimetype) try { - $phpbb_filesystem->phpbb_chmod($destination, CHMOD_READ | CHMOD_WRITE); + $phpbb_filesystem->phpbb_chmod($destination, \phpbb\filesystem\filesystem_interface::CHMOD_READ | \phpbb\filesystem\filesystem_interface::CHMOD_WRITE); } catch (\phpbb\filesystem\exception\filesystem_exception $e) { diff --git a/phpBB/phpbb/cache/driver/file.php b/phpBB/phpbb/cache/driver/file.php index de6f444251..36150d0589 100644 --- a/phpBB/phpbb/cache/driver/file.php +++ b/phpBB/phpbb/cache/driver/file.php @@ -581,7 +581,7 @@ class file extends \phpbb\cache\driver\base try { - $this->filesystem->phpbb_chmod($file, CHMOD_READ | CHMOD_WRITE); + $this->filesystem->phpbb_chmod($file, \phpbb\filesystem\filesystem_interface::CHMOD_READ | \phpbb\filesystem\filesystem_interface::CHMOD_WRITE); } catch (\phpbb\filesystem\exception\filesystem_exception $e) { diff --git a/phpBB/phpbb/files/filespec.php b/phpBB/phpbb/files/filespec.php index 6847bca4cb..36f38e676f 100644 --- a/phpBB/phpbb/files/filespec.php +++ b/phpBB/phpbb/files/filespec.php @@ -408,7 +408,7 @@ class filespec return false; } - $chmod = ($chmod === false) ? CHMOD_READ | CHMOD_WRITE : $chmod; + $chmod = ($chmod === false) ? \phpbb\filesystem\filesystem_interface::CHMOD_READ | \phpbb\filesystem\filesystem_interface::CHMOD_WRITE : $chmod; // We need to trust the admin in specifying valid upload directories and an attacker not being able to overwrite it... $this->destination_path = $this->phpbb_root_path . $destination; From 2ed21c98d5c374dbf7f0c8d6f02eff786fda90b8 Mon Sep 17 00:00:00 2001 From: rubencm Date: Fri, 14 Feb 2020 13:11:44 +0000 Subject: [PATCH 2/2] [ticket/16351] Update commends PHPBB3-16351 --- phpBB/includes/constants.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index 45519843e3..d2e038d5d8 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -225,10 +225,10 @@ define('REFERER_VALIDATE_HOST', 1); define('REFERER_VALIDATE_PATH', 2); // phpbb_chmod() permissions -@define('CHMOD_ALL', 7); // @deprecated 3.2 -@define('CHMOD_READ', 4); // @deprecated 3.2 -@define('CHMOD_WRITE', 2); // @deprecated 3.2 -@define('CHMOD_EXECUTE', 1); // @deprecated 3.2 +@define('CHMOD_ALL', 7); // @deprecated 3.2.10 +@define('CHMOD_READ', 4); // @deprecated 3.2.10 +@define('CHMOD_WRITE', 2); // @deprecated 3.2.10 +@define('CHMOD_EXECUTE', 1); // @deprecated 3.2.10 // Captcha code length define('CAPTCHA_MIN_CHARS', 4);