sftp-server: Add nanoseconds support

Ron Frederick ronf at timeheart.net
Sat Sep 4 16:40:34 AEST 2021


On Sep 3, 2021, at 10:23 PM, David Newall <openssh at davidnewall.com> wrote:
> On 3/9/21 11:26 pm, Opty wrote:
>> please, consider adding nanoseconds support to sftp-server.
> 
> I'm not sure what time you want returned with nanosecond-resolution, but, perhaps you mean the creation or last modification time of remote files and directories.  I don't know what resolution SFTP provides but it can't be greater than the underlying filesystem.  Most of them have second-resolution.
> 
> I don't think openssh's sftp server can have a different resolution without breaking compatibility with every sftp client.


There is a version of the SFTP protocol defined which supports sub-second times, but it’s not widely implemented. A spec for the latest version can be found at https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-13 <https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-13>, which describes SFTP version 6, whereas most SFTP implementations (including OpenSSH last time I checked) only implement version 3.

It looks like the SUBSECOND_TIMES flag was added in version -04 of this draft (https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-04 <https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-04>), which sets an SFTP version number of 4. Section 10 of this draft summarizes the proposed differences between versions 3 and 4:

10.1 Changes between versions 4 and 3

   Many of the changes between version 4 and version 3 are to the
   attribute structure to make it more flexible for non-unix platforms.

   o  Clarify the use of stderr by the server.

   o  Clarify handling of very large read requests by the server.

   o  Make all filenames UTF-8.

   o  Added 'newline' extension.

   o  Made time fields 64 bit, and optionally have nanosecond resultion.

   o  Made file attribute owner and group strings so they can actually
      be used on disparate systems.

   o  Added createtime field, and added separate flags for atime,
      createtime, and mtime so they can be set separately.

   o  Split the file type out of the permissions field and into it's own
      field (which is always present.)

   o  Added acl attribute.

   o  Added SSH_FXF_TEXT file open flag.

   o  Added flags field to the get stat commands so that the client can
      specifically request information the server might not normally
      included for performance reasons.

   o  Removed the long filename from the names structure-- it can now be
      built from information available in the attrs structure.

   o  Added reserved range of packet numbers for extensions.

   o  Added several additional error codes.

It’s not legal to change the meaning of the SFTP file attribute flags that specify what attributes are present without changing the SFTP version number, so implementing sub-second files by itself would not be straightforward. You’d have to implement the rest of the changes proposed here as well, and it would only be useful if both the SFTP client and SFTP server had this new support and were able to negotiate the higher version number.
-- 
Ron Frederick
ronf at timeheart.net





More information about the openssh-unix-dev mailing list