Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I had asked a related question on Super User:

A use case of a system "receiving" files over FTP would be, for example, the way WordPress plugins are installed via 1-click where WordPress initiates a file transfer to the local Linux box from the remote WordPress plugin repository using ftp(s)

More specifically this screen:

WP asking for ftp info during plugin install

My initial understanding that WordPress would transfer the files from the WordPress plugin repository, like how a FTP client would do. But further discussions on chat have left me confused as to why would WordPress require the FTP details of the web server?

What am I missing here?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

When you do something that requires WordPress write to the filesystem, it does a check to see if it has permissions to do so by writing a temp file. If this check fails it will ask for FTP details in order to write the files to your server.

EDIT

look in wp-admin/includes/file.php, line 843, for the get_filesystem_method function that does this check.

share|improve this answer
    
THanks, @Milo. I'll have a look at the files. –  Sathya Jul 24 '11 at 5:40

The wp-admin/includes/file.php **get_filesystem_method()** uses an erroneous test to determine if it can write a file. At line 853:

if ( getmyuid() == @fileowner($temp_file_name) )

The use of getmyuid() is wrong for unix - instead that should be posix_getuid(). The problem is the getmyuid() will return the owner of the script file not the user that is running the script. On unix, that means if the file was installed by root and the webserver is running as user www-data then test will fail even thought the file is written during the test.

So to fix, change the line with getmyuid() to:

if ( posix_getuid() == @fileowner($temp_file_name) )
share|improve this answer
    
Since it is part of core, you should not change it as the next WordPress upgrade will override it. If it is a bug you should probably report it here core.trac.wordpress.org –  Mark Kaplun Dec 6 '12 at 7:49
    
How do you tell what user WordPress is running as? –  AlxVallejo May 12 at 2:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.