From 6f53717be4de86a4a0593ce6cf4a70665b6b1344 Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 29 Jun 2009 20:23:04 +0000 Subject: [PATCH] Proper permissions for newly created files. Props azaozz. fixes #10170 for trunk git-svn-id: http://svn.automattic.com/wordpress/trunk@11667 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../includes/class-wp-filesystem-direct.php | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/wp-admin/includes/class-wp-filesystem-direct.php b/wp-admin/includes/class-wp-filesystem-direct.php index 7878c2fa2b..03a797734c 100644 --- a/wp-admin/includes/class-wp-filesystem-direct.php +++ b/wp-admin/includes/class-wp-filesystem-direct.php @@ -20,7 +20,6 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { function WP_Filesystem_Direct($arg) { $this->method = 'direct'; $this->errors = new WP_Error(); - $this->permission = umask(); } function connect() { return true; @@ -64,12 +63,22 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { return true; } function chmod($file, $mode = false, $recursive = false) { - if ( ! $mode ) - $mode = $this->permission; if ( ! $this->exists($file) ) return false; + + if ( ! $mode ) { + if ( $this->permission ) + $mode = $this->permission; + elseif ( $this->is_file($file) ) + $mode = FS_CHMOD_FILE; + elseif ( $this->is_dir($file) ) + $mode = FS_CHMOD_DIR; + else + return false; + } + if ( ! $recursive ) - return @chmod($file,$mode); + return @chmod($file, $mode); if ( ! $this->is_dir($file) ) return @chmod($file, $mode); //Is a directory, and we want recursive @@ -197,11 +206,9 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { } function mkdir($path, $chmod = false, $chown = false, $chgrp = false){ - if ( ! $chmod) - $chmod = $this->permission; - - if ( ! @mkdir($path, $chmod) ) + if ( ! @mkdir($path) ) return false; + $this->chmod($path, $chmod); if ( $chown ) $this->chown($path, $chown); if ( $chgrp )