FTP: Support for SITE UTIME

Here you can propose new features, make suggestions etc.

Moderators: Hacker, petermad, Stefan2, white

Post Reply
tumasch
Junior Member
Junior Member
Posts: 19
Joined: 2008-04-18, 07:40 UTC

FTP: Support for SITE UTIME

Post by *tumasch »

As metioned in Thread (see below, 'cause its my first post), TC supports MDTM.

But there is another command to set a filedate by FTP: SITE UTIME. I just tested it using Pure-FTPd, it works.

It would be great if you could implement it like you did with MDTM/MFMT, even if this is a speciality for Pure-FTPd.

Thank you!
Last edited by tumasch on 2009-12-23, 11:54 UTC, edited 2 times in total.
tumasch
Junior Member
Junior Member
Posts: 19
Joined: 2008-04-18, 07:40 UTC

Post by *tumasch »

www.ghisler.ch/board/viewtopic.php?t=2386

----

Here some more explanations:

--> I have to look at the SITE UTIME command. Does the server announce it in the FEAT reply?

Unfortunately no:

ftp> FEAT
211-Extensions supported:
EPRT
IDLE
MDTM
SIZE
REST STREAM
MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
MLSD
ESTP
PASV
EPSV
SPSV
ESTA
AUTH TLS
PBSZ
PROT
211 End.

But you can detect if command SITE UTIME is available with:

ftp> SITE UTIME
501 No file name

as you do not get the 500, like you would get if command would not be supported:

ftp> NOTEXISTENTCOMMAND
500 Unknown command

Anyways ... I guess the option to let user select wich method will be used via settings seems to me the most appropriate...
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Thanks for your suggestion! Some questions:
1. What's the exact format of the SITE UTIME parameters?
2. Is there some sort of RFC or draft?
3. What server supports it where you want to use it (not the site, just the software name)?
Author of Total Commander
https://www.ghisler.com
tumasch
Junior Member
Junior Member
Posts: 19
Joined: 2008-04-18, 07:40 UTC

Post by *tumasch »

Good morning!

First, the advantage of implementing this without the support for MLSD is quite small, since you still cannot verify wether the filetime is really set or not. So there's no possibility to syncronize files or folders without changing the original files dates.

The only advantage is that transferred files are stored with their original date.

1. According to http://www.proftpd.org/docs/contrib/mod_site_misc.html it should be:

Code: Select all

The syntax for SITE UTIME is:

  SITE UTIME YYYYMMDDhhmm path

For example:

  SITE UTIME 200402240836 file.txt

There's also an alternative syntax:

SITE UTIME file.txt YYYYMMDDhhmm YYYYMMDDhhmm YYYYMMDDhhmm UTC

You can see both in the source code of the implementation of PureFTPd at http://www.jimjag.com/code/mod_site_utime.c :

Code: Select all

 *    SITE UTIME YYYYMMDDhhmm[ss] path
 *    SITE UTIME path YYYYMMDDhhmm[ss] YYYYMMDDhhmm[ss] YYYYMMDDhhmm[ss] UTC
But like i saw in the internet, the first one is more common.

2. Unfortunately no.

3. In my particularly case, it's Pure-FTPd on my homepage and Jana-Server at home.

Thank you!
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

First, the advantage of implementing this without the support for MLSD is quite small, since you still cannot verify wether the filetime is really set or not.
Even with normal LIST -l you see the file time with seconds resolution for files of the current year. Actually many modern servers support LIST -laT, which gives both the year and the time.

Thanks for the details, I will check whether I can add it. It seems that PureFTPd reports UTIME support when sending HELP SITE to it.
Author of Total Commander
https://www.ghisler.com
tumasch
Junior Member
Junior Member
Posts: 19
Joined: 2008-04-18, 07:40 UTC

Post by *tumasch »

Thank you very much for you efforts!
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

I have added it now for the next version, but the stupid PureFTPd only accepts the second (UTC) variation with 3 times the date. Any idea what the 3 mean? Maybe creation, modification and last access time? What if I want to set only the last modification time?
Author of Total Commander
https://www.ghisler.com
tumasch
Junior Member
Junior Member
Posts: 19
Joined: 2008-04-18, 07:40 UTC

Post by *tumasch »

As i can see in te source code of the site mentioned above

Code: Select all

      if (!site_utime_parsetime(&actime, cmd->argv[3]) ||
          !site_utime_parsetime(&modtime, cmd->argv[4])) {
So seems to be LastAccesTime ModificationTime CreationTime.


Be carefull, theres the need to use UTS at end, else the if is not true:

Code: Select all

if ( (cmd->argc == 7) (...)
Sorry for my delay (did not see your post sooner).

Thanks very much!
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Did you find any explanation on how to send the command to set just the last modification date? The first form with just one date fails with e.g. pure-ftpd.
Author of Total Commander
https://www.ghisler.com
tumasch
Junior Member
Junior Member
Posts: 19
Joined: 2008-04-18, 07:40 UTC

Post by *tumasch »

It fails with which code? Maybe i can find the reason in te source code of pureftpd.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

For example
SITE UTIME 200402240836 file.txt
fails. PureFTPd reports the following error:
500 UTC Only
but TC did send the date in UTC already. It seems that PureFTP only supports the following form:
SITE UTIME file.txt 200402240836 200402240836 200402240836 UTC
Author of Total Commander
https://www.ghisler.com
tumasch
Junior Member
Junior Member
Posts: 19
Joined: 2008-04-18, 07:40 UTC

Post by *tumasch »

pure-ftpd-1.0.28.tar\pure-ftpd-1.0.28\src\ftp_parser.c:

Code: Select all

if (strcasecmp(sitearg2, " UTC") != 0) {
                        addreply_noformat(500, "UTC Only");
                        goto utime_wayout;         
                    }
Try

SITE UTIME 200402240836 UTC file.txt

Does that works?

BTW: This

Code: Select all

*sitearg2-- = 0;
                    if ((sitearg2 = strrchr(sitearg, ' ')) == NULL ||
                        sitearg2 == sitearg) {
                        utime_no_arg:
                        addreply_noformat(501, MSG_MISSING_ARG);
                        goto utime_wayout;
                    }
                    *sitearg2-- = 0;
                    if ((sitearg2 = strrchr(sitearg, ' ')) == NULL ||
                        sitearg2 == sitearg) {
                        goto utime_no_arg;
                    }
                    *sitearg2-- = 0;
                    if ((sitearg2 = strrchr(sitearg, ' ')) == NULL ||
                        sitearg2 == sitearg) {
                        goto utime_no_arg;
                    }
                    *sitearg2++ = 0;
                    if (*sitearg2 == 0) {
                        goto utime_no_arg;         
                    }
                    doutime(sitearg, sitearg2);
looks for me like it would ignore the first 2 arguments if 3 are given. But i'm not a C programmer, so it can be something else!
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

No, doesn't help, I just tried it on ghisler.com:

Code: Select all

SITE UTIME 201002090836 UTC languages.htm
500 UTC Only
SITE UTIME 201002090836 languages.htm UTC
501 Missing argument
Author of Total Commander
https://www.ghisler.com
tumasch
Junior Member
Junior Member
Posts: 19
Joined: 2008-04-18, 07:40 UTC

Post by *tumasch »

Maybe there's another version of PureFTP?

Can you say which one, so i can check the corresponding source code?

Tanks!
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Hmm, how can I find out the installed version? It doesn't tell me when logging in.
Author of Total Commander
https://www.ghisler.com
Post Reply