#!/usr/bin/env python3

import string
import random
import sys

from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer
from pyftpdlib.filesystems import UnixFilesystem
from pyftpdlib.authorizers import DummyAuthorizer

ipaddr = str(sys.argv[1])
user = str(sys.argv[2])
passwd = str(sys.argv[3])

def main():
  authorizer = DummyAuthorizer()
  authorizer.add_user(user, passwd, '/tmp', perm='elradfmwMT')
  handler = FTPHandler
  handler.permit_foreign_addresses = True
  handler.authorizer = authorizer
  handler.abstracted_fs = UnixFilesystem
  server = FTPServer((ipaddr, 2121), handler)
  server.serve_forever()

if __name__ == '__main__':
  main()
