Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I originally posted this question at StackOverflow, but I'm beginning to think it's more of a server question.

I have installed ProFTPd on an EC2 instance running Ubuntu 10.10. I have managed my proftpd.conf file as well as my server permissions to be able to connect and upload/move files using FTP both remotely using Filezilla, and on the server itself when connecting to 127.0.0.1.

The problem I'm running into is when I try to upload/install a file using Joomla's interface.

I give Joomla the same login information that I give to Filezilla, and the connection is made in the same fashion. The ftp.log file actually shows that Joomla is able to login to the server:

localhost UNKNOWN nobody [17/Jan/2011:14:09:17 +0000] "USER ftpuser" 331 -
localhost UNKNOWN ftpuser [17/Jan/2011:14:09:17 +0000] "PASS (hidden)" 230 -
localhost UNKNOWN ftpuser [17/Jan/2011:14:09:17 +0000] "PASV" 227 -
localhost UNKNOWN ftpuser [17/Jan/2011:14:09:17 +0000] "TYPE I" 200 -
localhost UNKNOWN ftpuser [17/Jan/2011:14:09:17 +0000] "STOR /directory/store/location/file.zip" 550 -

But it fails when attempting the STOR command. I have traced the problem in the Joomla code to the PHP FTP module. The code (with my trace statements added):

if (@ftp_put($this->_conn, $remote, $local, $mode) === false) {
    echo "\n FTP PUT failed.";
    echo "\n Remote: $remote ; Local: $local ; Mode: $mode - Either ASCII: ".FTP_ASCII." or Binary: ".FTP_BINARY;
    echo "\n The user: ".exec("whoami");
    JError::raiseWarning('35', 'JFTP::store: Bad response' );
    return false;
}

Trace ouputs:

FTP PUT failed.
Remote: /directory/store/location/file.zip ; Local: /tmp/phpwuccp4 ; Mode: 2 - Either >ASCII: 1 or Binary: 2
The user: www-data

And in case you were curious, here is an example of the FTP log when using Filezilla:

my_client_ip UNKNOWN nobody [17/Jan/2011:16:45:55 +0000] "USER ftpuser" 331 -
my_client_ip UNKNOWN ftpuser [17/Jan/2011:16:45:55 +0000] "PASS (hidden)" 230 -
my_client_ip UNKNOWN ftpuser [17/Jan/2011:16:45:55 +0000] "OPTS UTF8 ON" - -
my_client_ip UNKNOWN ftpuser [17/Jan/2011:16:45:55 +0000] "PWD" 257 -
my_client_ip UNKNOWN ftpuser [17/Jan/2011:16:45:55 +0000] "TYPE I" 200 -
my_client_ip UNKNOWN ftpuser [17/Jan/2011:16:45:55 +0000] "PASV" 227 -
my_client_ip UNKNOWN ftpuser [17/Jan/2011:16:45:55 +0000] "MLSD" 226 3405
my_client_ip UNKNOWN ftpuser [17/Jan/2011:16:46:06 +0000] "CWD location" 250 3405
my_client_ip UNKNOWN ftpuser [17/Jan/2011:16:46:06 +0000] "PWD" 257 3405
my_client_ip UNKNOWN ftpuser [17/Jan/2011:16:46:06 +0000] "PASV" 227 3405
my_client_ip UNKNOWN ftpuser [17/Jan/2011:16:46:07 +0000] "MLSD" 226 3757
my_client_ip UNKNOWN nobody [17/Jan/2011:16:46:37 +0000] "USER ftpuser" 331 -
my_client_ip UNKNOWN ftpuser [17/Jan/2011:16:46:37 +0000] "PASS (hidden)" 230 -
my_client_ip UNKNOWN ftpuser [17/Jan/2011:16:46:37 +0000] "OPTS UTF8 ON" - -
my_client_ip UNKNOWN ftpuser [17/Jan/2011:16:46:37 +0000] "CWD /location" 250 -
my_client_ip UNKNOWN ftpuser [17/Jan/2011:16:46:37 +0000] "PWD" 257 -
my_client_ip UNKNOWN ftpuser [17/Jan/2011:16:46:37 +0000] "TYPE I" 200 -
my_client_ip UNKNOWN ftpuser [17/Jan/2011:16:46:37 +0000] "PASV" 227 -
my_client_ip UNKNOWN ftpuser [17/Jan/2011:16:46:39 +0000] "STOR file.zip" 226 125317
my_client_ip UNKNOWN ftpuser [17/Jan/2011:16:46:39 +0000] "PASV" 227 -
my_client_ip UNKNOWN ftpuser [17/Jan/2011:16:46:39 +0000] "MLSD" 226 497

share|improve this question
    
Ok, I discovered the answer. It wasn't a permissions error, as a 550 typically is. It was a "Directory not found" error. The home directory for ftpuser was the public_html directory for the Joomla site. So when Joomla was trying to write a file to it's home directory, it was using the address from the root directory - so it was using the directory address twice - e.g. "/address/from/root/address/from/root" instead of just "/address/from/root". I changed the directory Joomla was trying to write to from "/address/from/root" to "/" and it PUT the file to the desired directory. –  MrOodles Jan 17 '11 at 23:11
add comment

1 Answer 1

looks like trying to connect as user "www-data" - at least error shows current user "exec("whoami")",

not sure whether Joomla passes the correct username to the server

if not - www-data is connected and doesn't have rights to create file /directory/store/location/file.zip on the server

share|improve this answer
    
+1. Looks like you need to be using "ftpuser". –  Harv Jan 17 '11 at 18:15
    
I thought this was the problem too, but it turns out that the FTP module in PHP actually sets a different user using it's FTP_login method. So while that particular object was being executed as 'www-data', the FTP functions were actually being executed as 'ftpuser' as shown in the log files. The problem was that the Joomla's FTP user couldn't find the directory it was supposed to write too because it was jailed to it's home directory, and was trying to write to it's home directory using an address from the root directory. –  MrOodles Jan 17 '11 at 23:16
add comment

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.