Index: wp-admin/includes/file.php
===================================================================
--- wp-admin/includes/file.php	(revision 15646)
+++ wp-admin/includes/file.php	(working copy)
@@ -832,14 +832,18 @@
 function get_filesystem_method($args = array(), $context = false) {
 	$method = defined('FS_METHOD') ? FS_METHOD : false; //Please ensure that this is either 'direct', 'ssh', 'ftpext' or 'ftpsockets'
 
-	if ( ! $method && function_exists('getmyuid') && function_exists('fileowner') ){
+	if ( ! $method && ( function_exists('posix_getuid') || function_exists('getmyuid') ) && function_exists('fileowner') ){
 		if ( !$context )
 			$context = WP_CONTENT_DIR;
 		$context = trailingslashit($context);
 		$temp_file_name = $context . 'temp-write-test-' . time();
 		$temp_handle = @fopen($temp_file_name, 'w');
 		if ( $temp_handle ) {
-			if ( getmyuid() == @fileowner($temp_file_name) )
+			if ( function_exists('posix_getuid') )
+				$uid = posix_getuid(); // *correct* UID of user running script, i.e www's UID
+			else
+				$uid = getmyuid(); // next-best, UID of user owning script, i.e. johndoe's UID
+			if ( $uid == @fileowner($temp_file_name) )
 				$method = 'direct';
 			@fclose($temp_handle);
 			@unlink($temp_file_name);
