34
34
from bzrlib.tests import test_server
37
# Convert the pyftplib string version into a tuple to avoid traps in string
39
pyftplib_version = tuple(map(int, ftpserver.__ver__.split('.')))
37
42
class AnonymousWithWriteAccessAuthorizer(ftpserver.DummyAuthorizer):
39
44
def _check_permissions(self, username, perm):
113
118
self.log('OK SITE CHMOD 0%03o "%s".' % (mode, ftp_path))
114
119
self.respond('200 SITE CHMOD succesful.')
117
# pyftpdlib says to define SITE commands by declaring ftp_SITE_<CMD> methods,
118
# but fails to recognize them.
119
ftpserver.proto_cmds['SITE CHMOD'] = ftpserver._CommandProperty(
120
perm='w', # Best fit choice even if not exactly right (can be d, f or m too)
121
auth_needed=True, arg_needed=True, check_path=False,
122
help='Syntax: SITE CHMOD <SP> octal_mode_bits file-name (chmod file)',
124
# An empty password is valid, hence the arg is neither mandatory not forbidden
125
ftpserver.proto_cmds['PASS'].arg_needed = None
121
if pyftplib_version >= (0, 6, 0):
122
def log_cmd(self, cmd, arg, respcode, respstr):
123
# base class version choke on unicode, the alternative is to just
124
# provide an empty implementation and relies on the client to do
125
# the logging for debugging purposes. Not worth the trouble so far
127
if cmd in ("DELE", "RMD", "RNFR", "RNTO", "MKD"):
128
line = '"%s" %s' % (' '.join([cmd, unicode(arg)]).strip(),
133
if pyftplib_version < (0, 6,0):
134
# pyftpdlib says to define SITE commands by declaring ftp_SITE_<CMD>
135
# methods, but fails to recognize them.
136
ftpserver.proto_cmds['SITE CHMOD'] = ftpserver._CommandProperty(
137
# Best fit choice even if not exactly right (can be d, f or m too)
139
auth_needed=True, arg_needed=True, check_path=False,
140
help='Syntax: SITE CHMOD <SP> octal_mode_bits file-name (chmod file)',
142
# An empty password is valid, hence the arg is neither mandatory not
144
ftpserver.proto_cmds['PASS'].arg_needed = None
146
# Same rationale as above (the password should be optional), but the hole
147
# in pyftplib-0.6.0 is narrower
148
ftpserver.proto_cmds['PASS']['arg'] = None
128
151
class ftp_server(ftpserver.FTPServer):