Hello,
Midnight Commander (mc) is text-based file manager used mainly on Linux/unix
and is capable to work with FTPs. After uploading file it issues a command
SITE CHMOD xxxxx which is not supported by Apache FtpServer. Mc reaction is
displaying red error dialog. This happens after each upload even during
multiple files uploading. It is quite uncomfortable pressing Ok button each
time (especially during multiupload).
My opinion is - if absence of SITE CHMOD command has such a consequence it
would be better to support the command to be there but to do nothing (and
send a note about it to an user). What do you mean?
My solution is attached.
Regards,
Jiří Kuhn
Index: core/src/main/java/org/apache/ftpserver/command/impl/SITE.java
===================================================================
--- core/src/main/java/org/apache/ftpserver/command/impl/SITE.java (revision 712122)
+++ core/src/main/java/org/apache/ftpserver/command/impl/SITE.java (working copy)
@@ -107,5 +107,7 @@
.put("SITE_WHO", new org.apache.ftpserver.command.impl.SITE_WHO());
COMMAND_MAP.put("SITE_ZONE",
new org.apache.ftpserver.command.impl.SITE_ZONE());
+ COMMAND_MAP.put("SITE_CHMOD",
+ new org.apache.ftpserver.command.impl.SITE_CHMOD());
}
}
Index: core/src/main/java/org/apache/ftpserver/command/impl/SITE_CHMOD.java
===================================================================
--- core/src/main/java/org/apache/ftpserver/command/impl/SITE_CHMOD.java (revision 0)
+++ core/src/main/java/org/apache/ftpserver/command/impl/SITE_CHMOD.java (revision 0)
@@ -0,0 +1,27 @@
+package org.apache.ftpserver.command.impl;
+
+import org.apache.ftpserver.command.AbstractCommand;
+import org.apache.ftpserver.ftplet.FtpException;
+import org.apache.ftpserver.ftplet.FtpReply;
+import org.apache.ftpserver.ftplet.FtpRequest;
+import org.apache.ftpserver.impl.FtpIoSession;
+import org.apache.ftpserver.impl.FtpServerContext;
+import org.apache.ftpserver.impl.LocalizedFtpReply;
+
+import java.io.IOException;
+
+/**
+ * Command SITE CHMOD is supported just only to exist but it doesn't anything.
+ * <p/>
+ * The functionality is copied from [EMAIL PROTECTED] SITE_HELP} command.
+ */
+public class SITE_CHMOD extends AbstractCommand {
+ public void execute(FtpIoSession session, FtpServerContext context, FtpRequest request) throws IOException, FtpException {
+ // reset state variables
+ session.resetState();
+
+ // print help message
+ session.write(LocalizedFtpReply.translate(session, request, context,
+ FtpReply.REPLY_200_COMMAND_OKAY, "SITE.CHMOD", null));
+ }
+}
Property changes on: core/src/main/java/org/apache/ftpserver/command/impl/SITE_CHMOD.java
___________________________________________________________________
Name: svn:eol-style
+ native
Index: core/src/main/resources/org/apache/ftpserver/message/FtpStatus.properties
===================================================================
--- core/src/main/resources/org/apache/ftpserver/message/FtpStatus.properties (revision 712122)
+++ core/src/main/resources/org/apache/ftpserver/message/FtpStatus.properties (working copy)
@@ -223,6 +223,7 @@
500.SITE=Execution failed.
530.SITE=Access denied.
200.SITE.HELP=SITE Commands\nDESCUSER \: display user information.\nHELP \: display this message.\nSTAT \: show statistics.\nWHO \: display all connected users.\nZONE \: display timezone.\nEnd.
+200.SITE.CHMOD=Command SITE CHMOD is supported just only to exist but it doesn't anything.
503.SITE.DESCUSER=Can't find the user name.
501.SITE.DESCUSER={output.msg} \: User not found.