Add the "SITE MD5 filename" facility.

This allows you to determine if the file on the other side is the same
as the one you have without transferring the entire file to compare.

Needless to say, if the server end lies to you this check doesn't work,
but on the other hand, if it lies to you about the files checksum,
what can you trust from it ?
This commit is contained in:
Poul-Henning Kamp 2001-04-15 20:59:29 +00:00
parent cf6490c9c7
commit 53ba84a69e
2 changed files with 16 additions and 1 deletions

View File

@ -69,6 +69,7 @@ static const char rcsid[] =
#include <time.h>
#include <unistd.h>
#include <libutil.h>
#include <md5.h>
#include "extern.h"
@ -126,7 +127,7 @@ extern int epsvall;
CDUP STOU SMNT SYST SIZE MDTM
LPRT LPSV EPRT EPSV
UMASK IDLE CHMOD
UMASK IDLE CHMOD MDFIVE
LEXERR
@ -586,6 +587,18 @@ cmd
{
help(sitetab, $5);
}
| SITE SP MDFIVE check_login SP pathname CRLF
{
char p[64], *q;
if ($4) {
q = MD5File($6, p);
if (q != NULL)
reply(200, "MD5(%s) = %s", $6, p);
else
perror_reply(550, $6);
}
}
| SITE SP UMASK check_login CRLF
{
int oldmask;
@ -1084,6 +1097,7 @@ struct tab cmdtab[] = { /* In order defined in RFC 765 */
};
struct tab sitetab[] = {
{ "MD5", MDFIVE, STR1, 1, "[ <sp> file-name ]" },
{ "UMASK", UMASK, ARGS, 1, "[ <sp> umask ]" },
{ "IDLE", IDLE, ARGS, 1, "[ <sp> maximum-idle-time ]" },
{ "CHMOD", CHMOD, NSTR, 1, "<sp> mode <sp> file-name" },

View File

@ -247,6 +247,7 @@ SITE request.
.It UMASK Ta change umask, e.g. ``SITE UMASK 002''
.It IDLE Ta set idle-timer, e.g. ``SITE IDLE 60''
.It CHMOD Ta "change mode of a file [RW], e.g. ``SITE CHMOD 755 filename''"
.It MD5 Ta "report the files MD5 checksum, e.g. ``SITE MD5 filename''"
.It HELP Ta give help information
.El
.Pp