Question

I've been asked to set up a FTP server using python that different users can log in to, and depending on their login will display a different file structure.

Part of the structure will be read only, and another part write, read, create and delete.

The file structure and files won't exist on the server, and will have to be built in a lazy way as the user expands folders by querying external servers.

The servers need to, I guess, mimic the FTP interface/protocol from the outside, but work completely differently internally.

I was wondering how big or difficult a job this would be as I need to provide some type of time scale for getting this working.

Is there anything like this out there already? has anyone done something similar before?

Are there any obvious problems of trying to implement this kind of model?

Was it helpful?

Solution

The twisted project would be the obvious place to start; the following example starts a simple FTP server that authenticates users against a password file but also allows anonymous access

from twisted.protocols.ftp import FTPFactory, FTPRealm
from twisted.cred.portal import Portal
from twisted.cred.checkers import AllowAnonymousAccess, FilePasswordDB
from twisted.internet import reactor

p = Portal(FTPRealm('./'),
           [AllowAnonymousAccess(), FilePasswordDB("pass.dat")])
f = FTPFactory(p)

reactor.listenTCP(21, f)
reactor.run()

You can easily expand from there. How you implement 'files' and 'directories' is completely up to you.

OTHER TIPS

Why python? I mean what python has to do with it? I'd look for some PAM module, able to create user-specific virtual filesystem structure on login, and if there's no ready one, consider modify some pam_mount, something like that..

http://pam-mount.sourceforge.net

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top