1#!/usr/local/bin/python3.8 2 3# Copyright (C) 2007 Giampaolo Rodola' <g.rodola@gmail.com>. 4# Use of this source code is governed by MIT license that can be 5# found in the LICENSE file. 6 7"""A FTPd using local UNIX account database to authenticate users. 8 9It temporarily impersonate the system users every time they are going 10to perform a filesystem operations. 11""" 12 13from pyftpdlib.authorizers import UnixAuthorizer 14from pyftpdlib.filesystems import UnixFilesystem 15from pyftpdlib.handlers import FTPHandler 16from pyftpdlib.servers import FTPServer 17 18 19def main(): 20 authorizer = UnixAuthorizer(rejected_users=["root"], 21 require_valid_shell=True) 22 handler = FTPHandler 23 handler.authorizer = authorizer 24 handler.abstracted_fs = UnixFilesystem 25 server = FTPServer(('', 21), handler) 26 server.serve_forever() 27 28 29if __name__ == "__main__": 30 main() 31