97
97
ftpserver.FTPHandler.ftp_NLST(self, path)
99
def ftp_SITE_CHMOD(self, line):
101
mode, path = line.split(None, 1)
104
# We catch both malformed line and malformed mode with the same
106
self.respond("500 'SITE CHMOD %s': command not understood."
108
self.log('FAIL SITE CHMOD ' % line)
110
ftp_path = self.fs.fs2ftp(path)
112
self.run_as_current_user(self.fs.chmod, self.fs.ftp2fs(path), mode)
114
why = ftpserver._strerror(err)
115
self.log('FAIL SITE CHMOD 0%03o "%s". %s.' % (mode, ftp_path, why))
116
self.respond('550 %s.' % why)
118
self.log('OK SITE CHMOD 0%03o "%s".' % (mode, ftp_path))
119
self.respond('200 SITE CHMOD succesful.')
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
99
def log_cmd(self, cmd, arg, respcode, respstr):
100
# base class version choke on unicode, the alternative is to just
101
# provide an empty implementation and relies on the client to do
102
# the logging for debugging purposes. Not worth the trouble so far
104
if cmd in ("DELE", "RMD", "RNFR", "RNTO", "MKD"):
105
line = '"%s" %s' % (' '.join([cmd, unicode(arg)]).strip(), respcode)
109
# An empty password is valid, hence the arg is neither mandatory nor forbidden
110
ftpserver.proto_cmds['PASS']['arg'] = None
151
112
class ftp_server(ftpserver.FTPServer):