2 # $Id: unix_ftpd.py 977 2012-01-22 23:05:09Z g.rodola $
4 # pyftpdlib is released under the MIT license, reproduced below:
5 # ======================================================================
6 # Copyright (C) 2007-2012 Giampaolo Rodola' <g.rodola@gmail.com>
10 # Permission is hereby granted, free of charge, to any person
11 # obtaining a copy of this software and associated documentation
12 # files (the "Software"), to deal in the Software without
13 # restriction, including without limitation the rights to use,
14 # copy, modify, merge, publish, distribute, sublicense, and/or sell
15 # copies of the Software, and to permit persons to whom the
16 # Software is furnished to do so, subject to the following
19 # The above copyright notice and this permission notice shall be
20 # included in all copies or substantial portions of the Software.
22 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
24 # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
27 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
29 # OTHER DEALINGS IN THE SOFTWARE.
31 # ======================================================================
33 """A FTPd using local UNIX account database to authenticate users.
35 It temporarily impersonate the system users every time they are going
36 to perform a filesystem operations.
39 from pyftpdlib import ftpserver
40 from pyftpdlib.contrib.authorizers import UnixAuthorizer
41 from pyftpdlib.contrib.filesystems import UnixFilesystem
45 authorizer = UnixAuthorizer(rejected_users=["root"], require_valid_shell=True)
46 ftp_handler = ftpserver.FTPHandler
47 ftp_handler.authorizer = authorizer
48 ftp_handler.abstracted_fs = UnixFilesystem
50 ftpd = ftpserver.FTPServer(address, ftp_handler)
53 if __name__ == "__main__":