Skip to content

Commit

Permalink
Tagging the 0.1.1 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Jul 17, 2007
0 parents commit d171bdc
Show file tree
Hide file tree
Showing 16 changed files with 2,854 additions and 0 deletions.
20 changes: 20 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

History
=======


Version: v0.1.1 - Date: 2007-02-22
----------------------------------

- port selection on PASV command has been randomized (this to prevent a remote user
to know how many data connections are in progress on the server).
- fixed bug in demo/unix_ftpd.py script (reported by Roger Erens).
- (little) modification to add_anonymous method of dummy_authorizer class.
- "ftp_server.serve_forever" automatically re-use address if current system is unix.
- license changed into a MIT style one.


Version: v0.1.0 - Date: 2007-02-22
----------------------------------

- first proof of concept beta release.
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
======================================================================
Copyright (C) 2007 billiejoex <billiejoex@gmail.com>

All Rights Reserved

Permission to use, copy, modify, and distribute this software and
its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that copyright notice and this permission
notice appear in supporting documentation, and that the name of
billiejoex not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.

billiejoex DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
NO EVENT billiejoex BE LIABLE FOR ANY SPECIAL, INDIRECT OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
======================================================================
18 changes: 18 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Documentation
=============

- Check doc/pyftpdlib.html.


Requirements
============

- Python 2.2 or higher.


Install
=======

- Just run:
> python setup.py install

5 changes: 5 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

TODO
====

- Check pyftpdlib/FTPServer.py
15 changes: 15 additions & 0 deletions demo/basic_ftpd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python
# basic_ftpd.py

import os
from pyftpdlib import FTPServer

if __name__ == "__main__":
authorizer = FTPServer.dummy_authorizer()
authorizer.add_user ('user', '12345', os.getcwd(), perm=('r', 'w'))
authorizer.add_anonymous (os.getcwd())
ftp_handler = FTPServer.ftp_handler
ftp_handler.authorizer = authorizer
address = ('127.0.0.1', 21)
ftpd = FTPServer.ftp_server (address, ftp_handler)
ftpd.serve_forever()
34 changes: 34 additions & 0 deletions demo/md5_ftpd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env python
# md5_ftpd.py

# FTPd storing passwords as hash digest (platform independent).

import md5
import os
from pyftpdlib import FTPServer

class dummy_encrypted_authorizer(FTPServer.dummy_authorizer):

def __init__(self):
FTPServer.dummy_authorizer.__init__(self)

def validate_authentication(self, username, password):
if username == 'anonymous':
if self.has_user('anonymous'):
return 1
else:
return 0
hash = md5.new(password).hexdigest()
return self.user_table[username]['pwd'] == hash

if __name__ == "__main__":
# get an hash digest from a clear-text password
hash = md5.new('12345').hexdigest()
authorizer = dummy_encrypted_authorizer()
authorizer.add_user('user', hash, os.getcwd(), perm=('r', 'w'))
authorizer.add_anonymous(os.getcwd())
ftp_handler = FTPServer.ftp_handler
ftp_handler.authorizer = authorizer
address = ('', 21)
ftpd = FTPServer.ftp_server(address, ftp_handler)
ftpd.serve_forever()
47 changes: 47 additions & 0 deletions demo/unix_ftpd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env python
# unix_ftpd.py

# FTPd using local unix account database to authenticate users and get
# their home directories (users must be created previously).

import os
import pwd, spwd, crypt
from pyftpdlib import FTPServer

class unix_authorizer(FTPServer.dummy_authorizer):

def __init__(self):
FTPServer.dummy_authorizer.__init__(self)

def add_user(self, username, home='', perm=('r')):
assert username in [i[0] for i in pwd.getpwall()], 'No such user "%s".' %username
pw = spwd.getspnam(username).sp_pwd
if not home:
home = pwd.getpwnam(username).pw_dir
assert os.path.isdir(home), 'No such directory "%s".' %home
dic = {'pwd' : pw,
'home' : home,
'perm' : perm
}
self.user_table[username] = dic

def validate_authentication(self, username, password):
if username == 'anonymous':
if self.has_user('anonymous'):
return 1
else:
return 0
else:
pw1 = spwd.getspnam(username).sp_pwd
pw2 = crypt.crypt(password, pw1)
return pw1 == pw2

if __name__ == "__main__":
authorizer = unix_authorizer()
authorizer.add_user('user', perm=('r', 'w'))
authorizer.add_anonymous(os.getcwd())
ftp_handler = FTPServer.ftp_handler
ftp_handler.authorizer = authorizer
address = ('', 21)
ftpd = FTPServer.ftp_server(address, ftp_handler)
ftpd.serve_forever()
55 changes: 55 additions & 0 deletions demo/winNT_ftpd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# winFTPserver.py
# Basic authorizer for Windows NT accounts (users must be created previously).

import os
import win32security, win32net, pywintypes
from pyftpdlib import FTPServer

class winNT_authorizer(FTPServer.dummy_authorizer):

def __init__(self):
FTPServer.dummy_authorizer.__init__(self)

def add_user(self, username, home, perm=('r')):
# check if user exists
users = [elem['name'] for elem in win32net.NetUserEnum(None, 0)[0]]
assert username in users, 'No such user "%s".' %username
assert os.path.isdir(home), 'No such directory "%s".' %home
dic = {'pwd' : None,
'home' : home,
'perm' : perm
}
self.user_table[username] = dic

def validate_authentication(self, username, password):
if username == 'anonymous':
if self.has_user('anonymous'):
return 1
else:
return 0
else:
try:
# check credentials
win32security.LogonUser (
username,
None,
password,
win32security.LOGON32_LOGON_NETWORK,
win32security.LOGON32_PROVIDER_DEFAULT
)
return 1
except pywintypes.error, err:
return 0


if __name__ == "__main__":
authorizer = winNT_authorizer()
authorizer.add_user ('user', os.getcwd(),perm=('r', 'w'))
authorizer.add_anonymous (os.getcwd())
ftp_handler = FTPServer.ftp_handler
ftp_handler.authorizer = authorizer
address = ('', 21)
ftpd = FTPServer.ftp_server(address, ftp_handler)
ftpd.serve_forever()


95 changes: 95 additions & 0 deletions doc/pyftpdlib.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
BODY {
BORDER-RIGHT: 0px; PADDING-RIGHT: 0px; BORDER-TOP: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN-LEFT: 2em; BORDER-LEFT: 0px; MARGIN-RIGHT: 2em; PADDING-TOP: 0px; BORDER-BOTTOM: 0px; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; FONT-SIZE: 12pt
}
.done {
COLOR: #005500; BACKGROUND-COLOR: #99ff99
}
.notdone {
COLOR: #550000; BACKGROUND-COLOR: #ff9999
}
PRE {
BORDER-RIGHT: black thin solid; PADDING-RIGHT: 1em; BORDER-TOP: black thin solid; PADDING-LEFT: 1em; FONT-SIZE: 12pt; PADDING-BOTTOM: 1em; BORDER-LEFT: black thin solid; PADDING-TOP: 1em; BORDER-BOTTOM: black thin solid; FONT-FAMILY: Neep Alt, Courier New, Courier
}
.boxed {
BORDER-RIGHT: black thin solid; PADDING-RIGHT: 1em; BORDER-TOP: black thin solid; PADDING-LEFT: 1em; PADDING-BOTTOM: 1em; BORDER-LEFT: black thin solid; PADDING-TOP: 1em; BORDER-BOTTOM: black thin solid
}
.shell {
BACKGROUND-COLOR: #ffffdd
}
.python {
BACKGROUND-COLOR: #FFFFFF; font-family: Lucida,Courier New; FONT-SIZE: 10pt
}

}
.doit {
BORDER-RIGHT: blue thin dashed; BORDER-TOP: blue thin dashed; BORDER-LEFT: blue thin dashed; BORDER-BOTTOM: blue thin dashed; BACKGROUND-COLOR: #0ef
}
.py-src-comment {
COLOR: #1111cc
}
.py-src-keyword {
FONT-WEIGHT: bold; COLOR: #3333cc
}
.py-src-parameter {
FONT-WEIGHT: bold; COLOR: #000066
}
.py-src-identifier {
COLOR: #cc0000
}
.py-src-string {
COLOR: #115511
}
.py-src-endmarker {
DISPLAY: block
}
.py-listing {
BORDER-RIGHT: black thin solid; BORDER-TOP: black thin solid; MARGIN: 1ex; BORDER-LEFT: black thin solid; BORDER-BOTTOM: black thin solid; BACKGROUND-COLOR: #eee
}
.html-listing {
BORDER-RIGHT: black thin solid; BORDER-TOP: black thin solid; MARGIN: 1ex; BORDER-LEFT: black thin solid; BORDER-BOTTOM: black thin solid; BACKGROUND-COLOR: #eee
}
.listing {
BORDER-RIGHT: black thin solid; BORDER-TOP: black thin solid; MARGIN: 1ex; BORDER-LEFT: black thin solid; BORDER-BOTTOM: black thin solid; BACKGROUND-COLOR: #eee
}
.py-listing PRE {
BORDER-RIGHT: medium none; BORDER-TOP: medium none; MARGIN: 0px; BORDER-LEFT: medium none; BORDER-BOTTOM: black thin solid
}
.html-listing PRE {
BORDER-RIGHT: medium none; BORDER-TOP: medium none; MARGIN: 0px; BORDER-LEFT: medium none; BORDER-BOTTOM: black thin solid
}
.listing PRE {
BORDER-RIGHT: medium none; BORDER-TOP: medium none; MARGIN: 0px; BORDER-LEFT: medium none; BORDER-BOTTOM: black thin solid
}
.py-listing .python {
BORDER-RIGHT: medium none; BORDER-TOP: medium none; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; BORDER-LEFT: medium none; BORDER-BOTTOM: black thin solid
}
.html-listing .htmlsource {
BORDER-RIGHT: medium none; BORDER-TOP: medium none; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; BORDER-LEFT: medium none; BORDER-BOTTOM: black thin solid
}
.caption {
PADDING-BOTTOM: 0.5em; PADDING-TOP: 0.5em; TEXT-ALIGN: center
}
.filename {
FONT-STYLE: italic
}
.manhole-output {
COLOR: blue
}
HR {
DISPLAY: inline
}
UL {
PADDING-RIGHT: 0px; PADDING-LEFT: 1em; PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0px 1em; BORDER-LEFT: 1em; PADDING-TOP: 0px
}
LI {
PADDING-RIGHT: 2px; PADDING-LEFT: 2px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px
}
DT {
FONT-WEIGHT: bold; MARGIN-LEFT: 1ex
}
DD {
MARGIN-BOTTOM: 1em
}
DIV.note {
BORDER-RIGHT: black thin solid; PADDING-RIGHT: 5%; BORDER-TOP: black thin solid; MARGIN-TOP: 1ex; PADDING-LEFT: 5%; MARGIN-LEFT: 5%; BORDER-LEFT: black thin solid; MARGIN-RIGHT: 5%; PADDING-TOP: 1ex; BORDER-BOTTOM: black thin solid; BACKGROUND-COLOR: #ffffcc
}

0 comments on commit d171bdc

Please sign in to comment.