Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make pyftpdlib follow symbolic links? #547

Closed
NightMachinery opened this issue Mar 5, 2021 · 5 comments
Closed

How to make pyftpdlib follow symbolic links? #547

NightMachinery opened this issue Mar 5, 2021 · 5 comments

Comments

@NightMachinery
Copy link

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
Copy link
Author

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
Copy link
Owner

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

See:

def validpath(self, path):
"""Check whether the path belongs to user's home directory.
Expected argument is a "real" filesystem pathname.
If path is a symbolic link it is resolved to check its real
destination.
Pathnames escaping from user's root directory are considered
not valid.
"""

@NightMachinery
Copy link
Author

@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:

def validpath(self, path):
"""Check whether the path belongs to user's home directory.
Expected argument is a "real" filesystem pathname.
If path is a symbolic link it is resolved to check its real
destination.
Pathnames escaping from user's root directory are considered
not valid.
"""

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

@giampaolo
Copy link
Owner

@Phuker
Copy link

Phuker commented Mar 21, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants