Page 1 of 1

Can't LIST -A but can write

Posted: 2022-05-23 22:45
by flamer
Hi guys,

I have a php script which does a site backup. It doesnt support sftp only ftp.

What it does is, connects to the ftp, creates a file called "is_it_writable" which succeeds as I can see the file get created in its virtual root, but then it does a "LIST" and "CWD" looking for that file and filezilla responds with a 550. The script fails saying it doesn't have write access to the directory. Full log below.

I am behind a router and I have specified custom port list, which are all forwarded on the router, and I can see the incoming connection via wireshark on the ephemeral port so it seems like everything is working in that sense.

Its filezilla 1.4.1. The user has full read+write access to the directory

Code: Select all

<Date> Info [Type] Message
<24/05/2022 10:37:45 AM> FTP Session 72 31.220.xxx.xxx [Trace] Session 0x252c1a7aa60 with ID 72 created.
<24/05/2022 10:37:45 AM> FTP Session 72 31.220.xxx.xxx [Response] 220-FileZilla Server 1.4.1
<24/05/2022 10:37:45 AM> FTP Session 72 31.220.xxx.xxx [Response] 220 Please visit https://filezilla-project.org/
<24/05/2022 10:37:46 AM> FTP Session 72 31.220.xxx.xxx [Command] USER ftpuser1
<24/05/2022 10:37:46 AM> FTP Session 72 31.220.xxx.xxx [Response] 331 Please, specify the password.
<24/05/2022 10:37:46 AM> FTP Session 72 31.220.xxx.xxx [Command] PASS ****
<24/05/2022 10:37:46 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Response] 230 Login successful.
<24/05/2022 10:37:46 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Command] PASV
<24/05/2022 10:37:46 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Response] 227 Entering Passive Mode (202,xxx,xxx,xxx,191,112)
<24/05/2022 10:37:46 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Command] PWD
<24/05/2022 10:37:46 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Response] 257 "/" is current directory.
<24/05/2022 10:37:47 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Command] HELP
<24/05/2022 10:37:47 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Response] 214-The following commands are recognized.
<24/05/2022 10:37:47 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Response] 214 Help ok.
<24/05/2022 10:37:47 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Command] NOOP
<24/05/2022 10:37:47 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Response] 200 Noop ok.
<24/05/2022 10:37:47 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Command] TYPE A
<24/05/2022 10:37:47 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Response] 200 Type set to A
<24/05/2022 10:37:47 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Command] LIST -aln 
<24/05/2022 10:37:47 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Response] 550 Permission denied
<24/05/2022 10:37:48 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Command] NOOP
<24/05/2022 10:37:48 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Response] 200 Noop ok.
<24/05/2022 10:37:48 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Command] CWD test_if_writable
<24/05/2022 10:37:48 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Response] 550 Couldn't open the file or directory
<24/05/2022 10:37:48 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Command] NOOP
<24/05/2022 10:37:48 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Response] 200 Noop ok.
<24/05/2022 10:37:48 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Command] PASV
<24/05/2022 10:37:48 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Response] 227 Entering Passive Mode (202,xxx,xxx,xxx,191,113)
<24/05/2022 10:37:49 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Command] LIST -A test_if_writable
<24/05/2022 10:37:49 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Response] 550 Couldn't open the file or directory
<24/05/2022 10:37:49 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Command] NOOP
<24/05/2022 10:37:49 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Response] 200 Noop ok.
<24/05/2022 10:37:49 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Command] TYPE I
<24/05/2022 10:37:49 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Response] 200 Type set to I
<24/05/2022 10:37:49 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Command] PASV
<24/05/2022 10:37:49 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Response] 227 Entering Passive Mode (202,xxx,xxx,xxx,191,111)
<24/05/2022 10:37:50 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Command] STOR test_if_writable
<24/05/2022 10:37:50 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Response] 150 Starting data transfer.
<24/05/2022 10:37:50 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Response] 226 Operation successful
<24/05/2022 10:37:50 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Command] NOOP
<24/05/2022 10:37:50 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Response] 200 Noop ok.
<24/05/2022 10:37:50 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Command] CWD test_if_writable
<24/05/2022 10:37:50 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Response] 550 Couldn't open the directory
<24/05/2022 10:37:51 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Command] NOOP
<24/05/2022 10:37:51 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Response] 200 Noop ok.
<24/05/2022 10:37:51 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Command] TYPE A
<24/05/2022 10:37:51 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Response] 200 Type set to A
<24/05/2022 10:37:51 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Command] PASV
<24/05/2022 10:37:51 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Response] 227 Entering Passive Mode (202,xxx,xxx,xxx,191,110)
<24/05/2022 10:37:51 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Command] LIST -A test_if_writable
<24/05/2022 10:37:51 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Response] 550 Couldn't open the file or directory
<24/05/2022 10:37:52 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Command] QUIT
<24/05/2022 10:37:52 AM> FTP Session 72 31.220.xxx.xxx ftpuser1 [Response] 221 Goodbye.
<24/05/2022 10:37:52 AM> FTP Server [Status] Session 72 ended gracefully.

Re: Can't LIST -A but can write

Posted: 2022-05-23 22:49
by botg
LIST -aln
As per the FTP specifications: List the file named -aln or the contents of the directory named -aln
LIST -A test_if_writable
List the file named -A test_if_writable or the contents of the directory named -A test_if_writable

Re: Can't LIST -A but can write

Posted: 2022-05-24 00:27
by boco
In other words, LIST only takes a filename or directory as parameter. Additional options like -a or -aln officially never existed and FileZilla Server doesn't support them.

Recommended command is MLSD.

Re: Can't LIST -A but can write

Posted: 2022-05-24 02:43
by flamer
thank you, I renamed the file from "test_if_writable" to "-A test_if_writable" and it actually worked.

Trying to fix the php function correctly now.