Bug 63248

Summary: [PATCH] FTP action "feat" support
Product: Ant Reporter: Eugène Adell <eugene.adell>
Component: Optional TasksAssignee: Ant Notifications List <notifications>
Status: NEW ---    
Severity: enhancement Keywords: PatchAvailable
Priority: P2    
Version: 1.10.5   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: patch
ftp.html
new patch for 1.10.7
results when testing the patch

Description Eugène Adell 2019-03-08 21:15:50 UTC
Among the few actions implemented for the FTP task, "feat" could be added to let users make a fingerprint of the supported features of an FTP server.
Comment 1 Eugène Adell 2019-03-08 21:19:28 UTC
Created attachment 36479 [details]
patch

suggested patch that introduces feat action

The output will be something like :

feat:
      [ftp] Opening FTP connection to localhost
      [ftp] connected
      [ftp] logging in to FTP server
      [ftp] login succeeded
      [ftp] Doing Feat Command:
      [ftp]  SIZE
      [ftp]  MDTM
      [ftp]  REST STREAM
      [ftp]  LANG en;zh-tw;ja;is
      [ftp]  MLST Size;Modify;Type;Perm
      [ftp]  AUTH SSL
      [ftp]  AUTH TLS
      [ftp]  MODE Z
      [ftp]  UTF8
      [ftp]  TVFS
      [ftp]  MD5
      [ftp]  MMD5
      [ftp]  MFMT
      [ftp] disconnecting

feat:
      [ftp] Opening FTP connection to ftp.ietf.org
      [ftp] connected
      [ftp] logging in to FTP server
      [ftp] login succeeded
      [ftp] Doing Feat Command:
      [ftp]  LANG ru-RU;zh-TW;es-ES;fr-FR;en-US*;zh-CN;it-IT
      [ftp]  MDTM
      [ftp]  TVFS
      [ftp]  MFMT
      [ftp]  SIZE
      [ftp]  MFF modify;UNIX.group;UNIX.mode;
      [ftp]  REST STREAM
      [ftp]  MLST modify*;perm*;size*;type*;unique*;UNIX.group*;UNIX.mode*;UNIX.owner*;
      [ftp]  UTF8
      [ftp]  EPRT
      [ftp]  EPSV
      [ftp] disconnecting
Comment 2 Jaikiran Pai 2019-05-17 05:27:53 UTC
I had a look at the patch and it looks mostly fine to me. Except this bit:

> +        if (ftp.sendCommand("FEAT") != 211) {
> +            log("Failed to issue Feat Command: ", Project.MSG_WARN);

I read the RFC for this command[1]. It states that:

> Where a server-FTP process does not support the FEAT command, it will
>   respond to the FEAT command with a 500 or 502 reply.  This is simply
>   the normal "unrecognized command" reply that any unknown command
>   would elicit.  Errors in the command syntax, such as giving
>   parameters, will result in a 501 reply.
>
>   Server-FTP processes that recognize the FEAT command, but implement
>   no extended features, and therefore have nothing to report, SHOULD
>   respond with the "no-features" 211 reply.  However, as this case is
>   practically indistinguishable from a server-FTP that does not
>   recognize the FEAT command, a 500 or 502 reply MAY also be used.  The
>   "no-features" reply MUST NOT use the multi-line response format,
>   exactly one response line is required and permitted.

So based on that, a response code of 211 implies no-features. However, in the patch, the code expects a 211 response and only then considers the rest of the reply strings and prints them out. That looks wrong IMO.

[1] https://tools.ietf.org/html/rfc2389
Comment 3 Eugène Adell 2019-05-19 10:07:06 UTC
The 211 return code is for both cases no-features and feature-listing, which means that the command is supported and we are then receiving a list of 0 or more features.

It is mentioned here :
"        no-features     = "211" SP *TCHAR CRLF
        feature-listing = "211-" *TCHAR CRLF
                          1*( SP feature CRLF )"

and in the example :
"        S> 211-Extensions supported:
        S>  MLST size*;create;modify*;perm;media-type"

However the server has the possibility to choose a 500 or a 502 return code instead of a 211 when it supports the command but has no feature implemented. In this case the patch will print a failure message, which is the normal behavior for anything which is not the expected return code (correct me if I'm wrong).
Comment 4 J.M. (Martijn) Kruithof 2019-07-12 15:05:45 UTC
Could you please also update the manual on how to use this?
Comment 5 Eugène Adell 2019-07-17 19:44:25 UTC
Created attachment 36666 [details]
ftp.html

Minimalist update of the documentation to mention this new command.

There's no full description of all commands supported. For example : "site" is not particularly documented, and I am not sure "feat" deserves more than "site", as it doesn't even take any argument.

Maybe we can add 2 entries (for "site" and "feat") in the Note about remotedir attribute, and this would be enough ?
Comment 6 Eugène Adell 2019-09-08 12:39:29 UTC
Created attachment 36767 [details]
new patch for 1.10.7

patch for FTP.java, replaces previous version
Comment 7 Eugène Adell 2019-09-08 12:41:25 UTC
Created attachment 36768 [details]
results when testing the patch

3 tests of the new FEAT command, with positive result