I have question regarding basic_ftpd.py example. I would like it to
let any user with any password(for example setting the same folder for
each user).
For example :
user1 : passw3er login succesfull /home/ftp
user1 : passother login succesfull /home/ftp
user2 : pass3 login succesfull /home/ftp
..... ....
..... .... ....
.... ....
Is there any clean, easy way to do this(i would like to avoid listing
these users in DummyAuthorizer/and it would be nice if any user could
login with any password).
I'm aware of anonymus login, but my use case is a little bit
different.
regards
Dominik
Hi,
you can subclass DummyAuthorizer.validate_authentication() method and
make it return True:
from pyftpdlib import ftpserver
class NoAuthorizer(ftpserver.DummyAuthorizer):
def validate_authentication(self, username, password):
return True
handler = ftpserver.FTPHandler
handler.authorizer = NoAuthorizer()
server = ftpserver.FTPServer(('', 21), handler)
server.serve_forever()
Regards,
Giapaolo
Python version 2.7.1+
pyftpdlib 0.5.0
ftp client: ftp
server side output:
Serving FTP on 0.0.0.0:2222
[]127.0.0.1:41687 Connected.
127.0.0.1:41687 ==> 220 pyftpdlib 0.5.0 ready.
127.0.0.1:41687 <== USER test
127.0.0.1:41687 ==> 331 Username ok, send password.
127.0.0.1:41687 <== PASS ******
127.0.0.1:41687 ==> 530 Authentication failed.
[]@127.0.0.1:41687 Authentication failed.
127.0.0.1:41687 <== SYST
127.0.0.1:41687 ==> 215 UNIX Type: L8
127.0.0.1:41687 <== QUIT
127.0.0.1:41687 ==> 221 Goodbye.
[]@127.0.0.1:41687 Disconnected.
[]127.0.0.1:41688 Connected.
127.0.0.1:41688 ==> 220 pyftpdlib 0.5.0 ready.
127.0.0.1:41688 <== USER zbita
127.0.0.1:41688 ==> 331 Username ok, send password.
127.0.0.1:41688 <== PASS ******
127.0.0.1:41688 ==> 530 Authentication failed.
[]@127.0.0.1:41688 Authentication failed.
127.0.0.1:41688 <== SYST
127.0.0.1:41688 ==> 215 UNIX Type: L8
127.0.0.1:41688 <== QUIT
127.0.0.1:41688 ==> 221 Goodbye.
[]@127.0.0.1:41688 Disconnected.
client side output:
Connected to 0.0.0.0.
220 pyftpdlib 0.5.0 ready.
Name (0.0.0.0:guderski): zbita
331 Username ok, send password.
Password:
530 Authentication failed.
Login failed.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> quit
221 Goodbye.
On 25 Lis, 14:24, Giampaolo Rodolà <g.rod...@gmail.com> wrote:
Sorry, I should have replied more carefully.
You obviosuly also have to re-define all the other methods which are
involved in the login process.
This should work.
from pyftpdlib import ftpserver
class NoAuthorizer(ftpserver.DummyAuthorizer):
def get_home_dir(self, username):
return "/home/your_user"
def validate_authentication(self, username, password):
return True
def get_msg_login(self, username):
return "hello"
def get_msg_quit(self, username):
return "goodbye"
def get_perms(self, username):
r = "elr"
w = "adfmwM"
return r + w
def has_perm(self, username, perm, path=None):
return perm in self.get_perms(username)
def impersonate_user(self,username, password):
def terminate_impersonation(self):
def has_user(self, username):
return True
regards,
Dominik
On 25 Lis, 15:51, Giampaolo Rodolà <g.rod...@gmail.com> wrote: