giampaolo / pyftpdlib

Extremely fast and scalable Python FTP server library
MIT License
1.65k stars 266 forks source link

How to make pyftpdlib follow symbolic links? #547

Closed NightMachinery closed 3 years ago

NightMachinery commented 3 years ago

I start the server by

python -m pyftpdlib -i '0.0.0.0' -p 8119 -d ~/Base/shared --debug

I can connect to this server, but I do not see my symbolic links there.

NightMachinery commented 3 years ago

Another client does see the links, but can't enter them:

[I 2021-03-05 13:02:29] 192.168.1.12:51542-[anonymous] USER 'anonymous' logged in.
[D 2021-03-05 13:02:29] 192.168.1.12:51542-[anonymous] <- PWD
[D 2021-03-05 13:02:29] 192.168.1.12:51542-[anonymous] -> 257 "/" is the current directory.
[D 2021-03-05 13:02:29] 192.168.1.12:51542-[anonymous] <- CWD dl
[D 2021-03-05 13:02:29] 192.168.1.12:51542-[anonymous] -> 550 "/" points to a path which is outside the user's root directory.
giampaolo commented 3 years ago

550 "/" points to a path which is outside the user's root directory.

See: https://github.com/giampaolo/pyftpdlib/blob/2a1185dcfc63895c32c5c15b98a0d0c0ed24436f/pyftpdlib/filesystems.py#L204-L213

NightMachinery commented 3 years ago

@giampaolo commented on Mar 5, 2021, 2:14 PM GMT+3:30:

550 "/" points to a path which is outside the user's root directory.

See:

https://github.com/giampaolo/pyftpdlib/blob/2a1185dcfc63895c32c5c15b98a0d0c0ed24436f/pyftpdlib/filesystems.py#L204-L213

Well, is there an option to disable this check, without forking the code? (Monkey patching perhaps?)

giampaolo commented 3 years ago

https://pyftpdlib.readthedocs.io/en/latest/api.html#pyftpdlib.filesystems.UnixFilesystem

Phuker commented 1 year ago
import pyftpdlib.filesystems
import pyftpdlib.__main__

pyftpdlib.filesystems.AbstractedFS.validpath = lambda self, path: True
pyftpdlib.__main__.main()

Save as foo.py, replace python -m pyftpdlib with python foo.py:

python foo.py -i '0.0.0.0' -p 8119 -d ~/Base/shared --debug