troglobit/uftpd

Not compateble with KDE dolphin ftp client

garywill opened this issue · 7 comments

Filzilla works fine as client. But when I use KDE dolphin as ftp client, I can't list files.

$ ./uftpd -l debug -n -o ftp=2121 -o writable /
30668> Initializing ...
30668> Serving files as PID 30668 ...
30668> Starting services ...
30668> Opened socket for port 2121
30668> Starting FTP server on port 2121 ...
30668> Not allowed to start TFTP service.  Privileged port.
30668> Serving files from / ...
30668> Created new client session as PID 30669
30669> Client connection from 127.0.0.1
30669> Sent: 220 uftpd (2.7) ready.

30669> Recv: USER user
30669> Sent: 331 Login OK, please enter password.

30669> Recv: PASS 1
30669> User user login from 127.0.0.1
30669> Sent: 230 Guest login OK, access restrictions apply.

30669> Recv: SYST 
30669> Sent: 215 UNIX Type: L8

30669> Recv: PWD 
30669> Sent: 257 "/"

30669> Recv: PASV 
30669> Data server port estabished.  Waiting for client connnect ...
30669> Sent: 227 Entering Passive Mode (127,0,0,1,207,83)

30669> Event on data_listen_sd ...
30669> Client PASV data connection from 127.0.0.1:35518
30669> No pending command, waiting ...
30669> Recv: list -la
30669> Sent: 500 command 'list' not recognized by server.

30669> Recv: TYPE I
30669> Sent: 200 Type set to I.

30669> Recv: PASV 
30669> Data server port estabished.  Waiting for client connnect ...
30669> Sent: 227 Entering Passive Mode (127,0,0,1,175,129)

30669> Event on data_listen_sd ...
30669> Client PASV data connection from 127.0.0.1:34142
30669> No pending command, waiting ...
30669> Recv: list 
30669> Sent: 500 command 'list' not recognized by server.

30669> Recv: SIZE /
30669> Compose path from cwd: , arg: /
30669> Server path from CWD: /
30669> Resulting non-chroot path: /
30669> Sent: 550 No such file, or argument is a directory.

OK, I see two bugs here:

  1. The client sends all commands in CAPS except for 'list', or 'list -la' -- the client should send LIST, but admittedly uftpd should handle mixed caps as well
  2. Absolute path argument to uftpd seems to have stopped working

Thanks for the report, I'll look into it!

Should be fixed now. If you have chance, I'd be grateful if you could verify the fix. Hopefully I can get a fully-tested release out during the weekend.

Thank you for the work!
If you upload a linux x64 binary to somewhere so I can get it run easily , I will be able to verify soon

Uh, I'm not really comfortable distributing binaries to end-users ... but here goes. It's statically linked and packed with upx: http://ftp.troglobit.com/uftpd/uftpd

I tested it.
I can connect with dolphin. There's always an "a" in the path

$ ./uftpd -l debug -n -o ftp=2121 -o writable .
17469> Initializing ...
17469> Serving files as PID 17469 ...
17469> Starting services ...
17469> Opened socket for port 2121
17469> Starting FTP server on port 2121 ...
17469> Not allowed to start TFTP service.  Privileged port.
17469> Serving files from /dev/shm/mem ...
17469> Created new client session as PID 17470
17470> Client connection from 127.0.0.1
17470> Sent: 220 uftpd (2.7) ready.

17470> Recv: USER anonymous
17470> Guest logged in from 127.0.0.1
17470> Sent: 230 Guest login OK, access restrictions apply.

17470> Recv: SYST 
17470> Sent: 215 UNIX Type: L8

17470> Recv: PWD 
17470> Sent: 257 "/"

17470> Recv: PASV 
17470> Data server port estabished.  Waiting for client connnect ...
17470> Sent: 227 Entering Passive Mode (127,0,0,1,139,211)

17470> Event on data_listen_sd ...
17470> Client PASV data connection from 127.0.0.1:54130
17470> No pending command, waiting ...
17470> Recv: LIST -la
17470> Compose path from cwd: /, arg: a
17470> Server path from CWD: /a
17470> Resulting non-chroot path: /dev/shm/mem/a
17470> Reading directory /dev/shm/mem/a ... 4 number of entries
17470> Sent: 125 Data connection already open; transfer starting.

17470> Sending LIST entry 0 of 4 to 127.0.0.1 ...
17470> Found directory entry .
17470> Found directory entry ..
17470> Found directory entry 888
17470> Compose path from cwd: /, arg: a/888
17470> Server path from CWD: /a/888
17470> Resulting non-chroot path: /dev/shm/mem/a/888
17470> LIST drwxr-xr-x 1     0     0           60 Mar 15 22:28 888

17470> Found directory entry t
17470> Compose path from cwd: /, arg: a/t
17470> Server path from CWD: /a/t
17470> Resulting non-chroot path: /dev/shm/mem/a/t
17470> Found directory entry .
17470> Found directory entry ..
17470> Found directory entry 888
17470> Compose path from cwd: /, arg: a/888
17470> Server path from CWD: /a/888
17470> Resulting non-chroot path: /dev/shm/mem/a/888
17470> Found directory entry t
17470> Compose path from cwd: /, arg: a/t
17470> Server path from CWD: /a/t
17470> Resulting non-chroot path: /dev/shm/mem/a/t
17470> LIST -rw-r--r-- 1     0     0            9 Mar 15 22:27 t

However if I manually create a folder "a" in the path, it can list the files inside "a".

Thank you for taking the time to test! Interesting behavior ... your cwd was /dev/shm/mem/ when you started uftpd, right?

Reopening

Found it, uftpd only read "-l" and "a" became the argument to LIST. I've tested with Dolphin and it seems to work properly now, finally. There's a new binary uploaded as well, if you'd like to verify.