From 56e338c132d57a6886d8610220b7f8e2402a0dae Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 22 Dec 2019 02:43:30 +0000 Subject: [PATCH] Upgrade/Install: When creating the `.htaccess` file in `insert_with_markers()`, make sure it has `0644` as a minimum set of permissions. Props rcutmore, dd32, i3anaan. Fixes #40572. git-svn-id: https://develop.svn.wordpress.org/trunk@47005 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/misc.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/wp-admin/includes/misc.php b/src/wp-admin/includes/misc.php index 428b2980a5..6b0c311658 100644 --- a/src/wp-admin/includes/misc.php +++ b/src/wp-admin/includes/misc.php @@ -111,9 +111,16 @@ function insert_with_markers( $filename, $marker, $insertion ) { if ( ! is_writable( dirname( $filename ) ) ) { return false; } + if ( ! touch( $filename ) ) { return false; } + + // Make sure the file is created with a minimum set of permissions. + $perms = fileperms( $filename ); + if ( $perms ) { + chmod( $filename, $perms | 0644 ); + } } elseif ( ! is_writeable( $filename ) ) { return false; }