• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python authorizers.DummyAuthorizer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyftpdlib.authorizers.DummyAuthorizer的典型用法代码示例。如果您正苦于以下问题:Python DummyAuthorizer类的具体用法?Python DummyAuthorizer怎么用?Python DummyAuthorizer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了DummyAuthorizer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self, addr, homedir, *args, **kwargs):
     super(FTPServerThread, self).__init__(*args, **kwargs)
     authorizer = DummyAuthorizer()
     authorizer.add_anonymous(homedir, perm='elradfmwM')
     handler = FTPHandler
     handler.authorizer = authorizer
     self.ftpserver = ThreadedFTPServer(addr, handler)
开发者ID:yaleyang,项目名称:pydeploy,代码行数:7,代码来源:xagent.py


示例2: run

    def run(self):
        """Start the FTP Server for pulsar search."""
        self._log.info('Starting Pulsar Search Interface')
        # Instantiate a dummy authorizer for managing 'virtual' users
        authorizer = DummyAuthorizer()

        # Define a new user having full r/w permissions and a read-only
        # anonymous user
        authorizer.add_user(self._config['login']['user'],
                            self._config['login']['psswd'], '.',
                            perm=self._config['login']['perm'])
        authorizer.add_anonymous(os.getcwd())

        # Instantiate FTP handler class
        handler = FTPHandler
        handler.authorizer = authorizer
        handler.abstracted_fs = PulsarFileSystem

        # Define a customized banner (string returned when client connects)
        handler.banner = "SKA SDP pulsar search interface."

        # Instantiate FTP server class and listen on 0.0.0.0:7878
        address = (self._config['address']['listen'],
                   self._config['address']['port'])
        server = FTPServer(address, handler)

        # set a limit for connections
        server.max_cons = 256
        server.max_cons_per_ip = 5

        # start ftp server
        server.serve_forever()
开发者ID:SKA-ScienceDataProcessor,项目名称:integration-prototype,代码行数:32,代码来源:pulsar_search.py


示例3: main

def main():
    authorizer = DummyAuthorizer()
    authorizer.add_user('admin','123456',os.getcwd(),perm='elradfmw')
 
    for user in auth.data:
        s1=user.split('=')[1]
        ret=s1.split(',')
        authorizer.add_user(ret[0].replace("'",""),ret[1],os.getcwd(),perm=ret[2].strip().replace("'",""))

    #aauthorizer.add_anonymous(os.getcwd())
    dtp_handler = ThrottledDTPHandler
    dtp_handler.read_limit=30720
    dtp_handler.write_limit=30720

    handler = FTPHandler
    handler.authorizer = authorizer
    handler.dtp_handler=dtp_handler
    logging.basicConfig(filename='%s/myftp/logs/pyftpd.log'%BASE_DIR,level=settings.level)

    handler.banner = 'pyftpdlib based ftpd ready'

    address=('',2121)
    server=MultiprocessFTPServer(address,handler)

    server.max_conns=settings.maxconn
    server.max_conns_pre_ip=settings.maxconnperip
    
    server.serve_forever()
开发者ID:willianflasky,项目名称:growup,代码行数:28,代码来源:main.py


示例4: __init__

    def __init__(self, addr=None):
        os.mkdir ('server')
        os.chdir ('server')
        try:
            HOST = socket.gethostbyname ('localhost')
        except socket.error:
            HOST = 'localhost'
        USER = 'user'
        PASSWD = '12345'
        HOME = getcwdu ()

        threading.Thread.__init__(self)
        self.__serving = False
        self.__stopped = False
        self.__lock = threading.Lock()
        self.__flag = threading.Event()
        if addr is None:
            addr = (HOST, 0)

        authorizer = DummyAuthorizer()
        authorizer.add_user(USER, PASSWD, HOME, perm='elradfmwM')  # full perms
        authorizer.add_anonymous(HOME)
        self.handler.authorizer = authorizer
        # lowering buffer sizes = more cycles to transfer data
        # = less false positive test failures
        self.handler.dtp_handler.ac_in_buffer_size = 32768
        self.handler.dtp_handler.ac_out_buffer_size = 32768
        self.server = self.server_class(addr, self.handler)
        self.host, self.port = self.server.socket.getsockname()[:2]
        os.chdir ('..')
开发者ID:AOSC-Dev,项目名称:wget,代码行数:30,代码来源:ftp_server.py


示例5: ftp_server

def ftp_server(command_line_object):
    # current directory
    exfil_directory = os.path.join(os.getcwd(), "data")
    loot_path = exfil_directory + "/"

    # Check to make sure the agent directory exists, and a loot
    # directory for the agent.  If not, make them
    if not os.path.isdir(loot_path):
        os.makedirs(loot_path)

    try:
        authorizer = DummyAuthorizer()
        authorizer.add_user(
            command_line_object.username, command_line_object.password,
            loot_path, perm="lrw")

        handler = FTPHandler
        handler.authorizer = authorizer

        # Define a customized banner (string returned when client connects)
        handler.banner = "Connecting to Egress-Assess's FTP server!"

        server = FTPServer(('', 21), handler)
        server.serve_forever()
    except ValueError:
        print "[*] Error: The directory you provided may not exist!"
        print "[*] Error: Please re-run with a valid FTP directory."
        sys.exit()
开发者ID:johnjohnsp1,项目名称:Egress-Assess,代码行数:28,代码来源:Egress-Assess.py


示例6: main

def main(profiles):
    authorizer = DummyAuthorizer()
    # 将每个profile映射为一个用户
    uploadTmpRoot = tempfile.gettempdir()
    for p, c in profiles.items():
        # perm权限定义说明:
        # Read permissions:
        # "e" = change directory (CWD, CDUP commands)
        # "l" = list files (LIST, NLST, STAT, MLSD, MLST, SIZE commands)
        # "r" = retrieve file from the server (RETR command)
        # Write permissions:

        # "a" = append data to an existing file (APPE command)
        # "d" = delete file or directory (DELE, RMD commands)
        # "f" = rename file or directory (RNFR, RNTO commands)
        # "m" = create directory (MKD command)
        # "w" = store a file to the server (STOR, STOU commands)
        # "M" = change mode/permission (SITE CHMOD command) New in 0.7.0
        # 注意:投产时权限似乎应限制为只写,即:'w'
        uploadTmp = path.join(uploadTmpRoot, p)
        print uploadTmp
        if not path.isdir(uploadTmp):
            mkdir(uploadTmp)

        authorizer.add_user(p, c["upload"].get("password", ""), uploadTmp, perm="ledw")

    handler = UploadHandler
    handler.authorizer = authorizer
    handler.banner = "OSO fileserv"
    address = ("", int(getenv("FTP_PORT", "2121")))
    logging.basicConfig(filename="logs/ftp.log", level=logging.INFO)
    server = FTPServer(address, handler)
    server.max_cons = 256
    server.max_cons_per_ip = 5
    server.serve_forever()
开发者ID:chenchen0,项目名称:fileserv,代码行数:35,代码来源:server.py


示例7: main

def main():
    """
    Main ftp server code
    """
    with open("ABSOLUTE_PATH_OF_config.yaml", 'r') as stream:
        config = yaml.load(stream)
        authorizer = DummyAuthorizer()
        if config.get('user'):
            for each_user in config['user']:
                if not os.path.exists(each_user['details']['home_directory']):
                    os.makedirs(each_user['details']['home_directory'])
                authorizer.add_user(
                    each_user['details']['username'],
                    each_user['details']['password'],
                    each_user['details']['home_directory'],
                    perm=each_user['details']['permission']
                )
        authorizer.add_anonymous('.')
        handler = MyHandler
        handler.certfile = config['certfile']
        handler.authorizer = authorizer
        handler.masquerade_address = config['masquerade_address']
        # requires SSL for both control and data channel
        handler.tls_control_required = True
        handler.tls_data_required = True
        handler.passive_ports = range(60000, 60099)
        server = FTPServer(('', 21), handler)
        server.serve_forever()
开发者ID:santoshghimire,项目名称:python-ftp-server,代码行数:28,代码来源:ftps.py


示例8: main

def main():
    port = 3334
    user = ''
    password = ''
    l = sys.argv

    if (len(l) > 1 and l[1]):
        user = l[1]

    if (len(l) > 2 and l[2]):
        password = l[2]

    if (len(l) > 3 and l[3]):
        port = int(l[3])


    authorizer = DummyAuthorizer()
    authorizer.add_user(user, password, os.getcwd(), perm='elradfmwM')
    authorizer.add_anonymous('.')

    handler = TLS_FTPHandler
    handler.certfile = CERTFILE
    handler.authorizer = authorizer

    server = FTPServer(("127.0.0.1", port), handler)
    server.serve_forever()
开发者ID:peteoconnell,项目名称:brackets-ftp-sync,代码行数:26,代码来源:ftpsd.py


示例9: start_ftp_server

def start_ftp_server():
    cs.CSClient().log(APP_NAME, 'start_ftp_server()...')
    try:
        authorizer = DummyAuthorizer()
        # Define a new user having full r/w permissions and a read-only
        # anonymous user
        authorizer.add_user('user', '12345', FTP_DIR, perm='elradfmwM')
        authorizer.add_anonymous(FTP_DIR)

        # Instantiate FTP handler class
        handler = FTPHandler
        handler.authorizer = authorizer

        # Define a customized banner (string returned when client connects)
        handler.banner = "pyftpdlib based ftpd ready."

        # Instantiate FTP server class and listen on 0.0.0.0:2121.
        # Application can only use ports higher that 1024 and the port
        # will need to be allowed in the router firewall
        address = ('', 2121)
        server = FTPServer(address, handler)

        # set a limit for connections
        server.max_cons = 256
        server.max_cons_per_ip = 5

        # start ftp server
        cs.CSClient().log(APP_NAME, 'Starting FTP server...')
        server.serve_forever()
        # This will run the server in another thread
        # t = Thread(target=server.serve_forever())
        # t.start()

    except Exception as e:
        cs.CSClient().log(APP_NAME, 'Exception occurred! exception: {}'.format(e))
开发者ID:cradlepoint,项目名称:sdk-samples,代码行数:35,代码来源:ftp_server.py


示例10: run

def run(ns):
	"""starts the server."""
	auth = DummyAuthorizer()
	if ns.user is not None:
		auth.add_user(ns.user, ns.pswd, ns.path, perm=ns.perm)
	else:
		auth.add_anonymous(ns.path, perm=ns.perm)
	handler = FTPHandler
	handler.authorizer = auth
	handler.banner = "StaSh v{v} FTP-Server".format(v=_stash.__version__)
	address = ("0.0.0.0", ns.port)
	server = FTPServer(address, handler)
	server.max_cons = 128
	server.max_cons_per_ip = 128
	# setup logging
	logger = logging.getLogger("pyftpdlib")
	logger.setLevel(logging.CRITICAL)
	logger.propagate = False
	# server needs to run in a thread to be killable
	thr = threading.Thread(
		name="FTP-Server Thread", target=server.serve_forever
		)
	thr.daemon = True
	thr.start()
	print("FTP-Server started on {h}:{p}".format(h=address[0], p=str(address[1])))
	try:
		while True:
			time.sleep(0.2)
	except KeyboardInterrupt:
		print("Stopping Server...")
		server.close_all()
开发者ID:BBOOXX,项目名称:stash,代码行数:31,代码来源:ftpserver.py


示例11: main

def main():
    # Instantiate a dummy authorizer for managing 'virtual' users
    authorizer = DummyAuthorizer()
    # Define a new user having full r/w permissions
    authorizer.add_user("user_name", "pass_word", "./", perm="elradfmwM", msg_login="welcome", msg_quit="bye")
    # Define a read-only anonymous user
    authorizer.add_anonymous("./")

    # Instantiate FTP handler class
    handler = FTPHandler
    handler.authorizer = authorizer
    handler.max_login_attempts = 3
    handler.permit_foreign_addresses = True
    handler.tcp_no_delay = True

    # Define a customized banner (string returned when client connects)
    handler.banner = "Welcome to my FTP."

    # Instantiate FTP server class and listen on 127.0.0.1:21
    address = ("0.0.0.0", 2121)
    server = FTPServer(address, handler)

    # set a limit for connections
    server.max_cons = 128
    server.max_cons_per_ip = 2

    absfs = AbstractedFS(u"./", handler)
    absfs.cwd = u"/bbb/ss/"
    # start ftp server
    server.serve_forever()
开发者ID:oska874,项目名称:py-study-code,代码行数:30,代码来源:ftp0.py


示例12: main

def main():
    # Instantiate a dummy authorizer for managing 'virtual' users
    authorizer = DummyAuthorizer()

    # Define a new user having full r/w permissions and a read-only
    # anonymous user
    authorizer.add_user('user', '12345', os.getcwd(), perm='elradfmwM')
    authorizer.add_anonymous(os.getcwd())

    # Instantiate FTP handler class
    handler = FTPHandler
    handler.authorizer = authorizer

    # Define a customized banner (string returned when client connects)
    handler.banner = "pyftpdlib based ftpd ready."

    # Specify a masquerade address and the range of ports to use for
    # passive connections.  Decomment in case you're behind a NAT.
    #handler.masquerade_address = '151.25.42.11'
    #handler.passive_ports = range(60000, 65535)

    # Instantiate FTP server class and listen on 0.0.0.0:2121
    address = ('', 2121)
    server = FTPServer(address, handler)

    # set a limit for connections
    server.max_cons = 256
    server.max_cons_per_ip = 5

    # start ftp server
    server.serve_forever()
开发者ID:070499,项目名称:service.lan.ftp,代码行数:31,代码来源:basic_ftpd.py


示例13: main

def main():
    port = 3334
    user = ''
    password = ''
    l = sys.argv

    if (len(l) > 1 and l[1]):
        user = l[1]

    if (len(l) > 2 and l[2]):
        password = l[2]

    if (len(l) > 3 and l[3]):
        port = int(l[3])


    authorizer = DummyAuthorizer()
    authorizer.add_user(user, password, os.getcwd(), perm='elradfmwM')
    #authorizer.add_anonymous("/home/nobody")

    handler = FTPHandler
    handler.authorizer = authorizer

    logging.basicConfig(level=logging.DEBUG)

    server = FTPServer(("127.0.0.1", port), handler)
    server.serve_forever()
开发者ID:peteoconnell,项目名称:brackets-ftp-sync,代码行数:27,代码来源:ftpd.py


示例14: main

def main():
    authorizer = DummyAuthorizer()
    authorizer.add_user("user", "12345", ".")
    handler = FTPHandler
    handler.authorizer = authorizer
    server = ThreadedFTPServer(("", 2121), handler)
    server.serve_forever()
开发者ID:PonyPC,项目名称:pyftpdlib,代码行数:7,代码来源:multi_thread_ftp.py


示例15: run_server

 def run_server(cls):
     authorizer = DummyAuthorizer()
     authorizer.add_user("user", "password", cls.ftp_dir, perm="elrd")
     handler = FTPHandler
     handler.authorizer = authorizer
     cls.ftpd = FTPServer(("0.0.0.0", 8021), handler)
     cls.ftpd.serve_forever(timeout=0.2, handle_exit=True)
开发者ID:lexman,项目名称:tuttle,代码行数:7,代码来源:test_ftp.py


示例16: Server

class Server(threading.Thread):
	def __init__(self, ip, path, users, port, password):
		super(Server, self).__init__()
		self.ip = ip
		self.path = path
		self.users = users
		self.port = port
		self.auth = DummyAuthorizer()
		self.handler = CustomFTP(self.auth, self.port, path, password)
		# self.handler.authorizer = self.auth
		print 'starting server on port %d' % (self.port)
		[self.add_user(self.path, u, password) for u in self.users]

	def start_thread(self):
		self.start()
		return self

	def add_user(self, path, user, password):
		pathn = os.path.join(path, str(self.port))
		if not os.path.exists(pathn): os.mkdir(pathn)
		self.auth.add_user(user, password, pathn, perm="elr") # elradfmw

	def run(self):
		self.server = ThreadedFTPServer((self.ip, self.port), self.handler)
		self.server.serve_forever()
开发者ID:rozsahegyi,项目名称:ftplab,代码行数:25,代码来源:server.py


示例17: main

def main():
    authorizer = DummyAuthorizer()
    authorizer.add_user('user', '12345', '.')
    handler = FTPHandler
    handler.authorizer = authorizer
    server = MultiprocessFTPServer(('', 2121), handler)
    server.serve_forever()
开发者ID:BroLsd999,项目名称:pyftpdlib,代码行数:7,代码来源:multi_proc_ftp.py


示例18: __init__

class MyServerFtp:
	
	def __init__(self):
		self.error = False
		self.port = 2121
	def __exit__(self, *err	):
        	self.close()
	def serverStart(self,port,location):
		try:
			self.error = False
			self.authorizer = DummyAuthorizer()
			self.authorizer.add_user('user', 'sk', location , perm='elradfmwM')

			self.handler = FTPHandler
			self.handler.authorizer = self.authorizer

			self.handler.banner = "ftp Server ready"
			self.address = ('', port)
			self.server = FTPServer(self.address, self.handler)
	
			self.server.max_cons = 256
			self.server.max_cons_per_ip = 5
			
			self.thread = threading.Thread(target = self.server.serve_forever)
			self.thread.deamon = True
			self.thread.start()
		except socket.error:
			self.error = True
			pass

	def errorOccured(self):
		return self.error

	def serverStop(self):
		self.server.close_all()
开发者ID:Shivakishore14,项目名称:FShare,代码行数:35,代码来源:fsharev1.py


示例19: serve

    def serve(self):
        # current directory
        exfil_directory = os.path.join(os.getcwd(), "data")
        loot_path = exfil_directory + "/"

        # Check to make sure the agent directory exists, and a loot
        # directory for the agent.  If not, make them
        if not os.path.isdir(loot_path):
            os.makedirs(loot_path)

        try:
            authorizer = DummyAuthorizer()
            authorizer.add_user(
                self.username, self.password,
                loot_path, perm="elradfmwM")

            handler = FTPHandler
            handler.authorizer = authorizer

            # Define a customized banner (string returned when client connects)
            handler.banner = "Connecting to Egress-Assess's FTP server!"

            try:
                server = FTPServer(('', self.port), handler)
                server.serve_forever()
            except socket.error:
                print "[*][*] Error: Port %d is currently in use!" % self.port
                print "[*][*] Error: Please restart when port is free!\n"
                sys.exit()
        except ValueError:
            print "[*] Error: The directory you provided may not exist!"
            print "[*] Error: Please re-run with a valid FTP directory."
            sys.exit()
        return
开发者ID:453483289,项目名称:Egress-Assess,代码行数:34,代码来源:ftp_server.py


示例20: start_ftp_server

def start_ftp_server():
    authorizer = DummyAuthorizer()
    authorizer.add_anonymous("ftpvista/test")
    handler = FTPHandler
    handler.authorizer = authorizer
    server = FTPServer(("127.0.0.1", 2121), handler)
    server.serve_forever()
开发者ID:magne4000,项目名称:ftpvista,代码行数:7,代码来源:test.py



注:本文中的pyftpdlib.authorizers.DummyAuthorizer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python logger.info函数代码示例发布时间:2022-05-25
下一篇:
Python db.session函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap