summaryrefslogtreecommitdiffstats
path: root/libexec/ftpd/ftpcmd.y
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2001-04-15 20:59:29 +0000
committerphk <phk@FreeBSD.org>2001-04-15 20:59:29 +0000
commita463dd29ce46668294dfb16124f9b12e75613c93 (patch)
tree181d4831c50020ca22cb64a4d7affa999290c5ff /libexec/ftpd/ftpcmd.y
parent82c5492b1c98cac1a21f52151237dcbbca7164d8 (diff)
downloadFreeBSD-src-a463dd29ce46668294dfb16124f9b12e75613c93.zip
FreeBSD-src-a463dd29ce46668294dfb16124f9b12e75613c93.tar.gz
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 ?
Diffstat (limited to 'libexec/ftpd/ftpcmd.y')
-rw-r--r--libexec/ftpd/ftpcmd.y16
1 files changed, 15 insertions, 1 deletions
diff --git a/libexec/ftpd/ftpcmd.y b/libexec/ftpd/ftpcmd.y
index 14ac122..f3bff5d 100644
--- a/libexec/ftpd/ftpcmd.y
+++ b/libexec/ftpd/ftpcmd.y
@@ -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" },
OpenPOWER on IntegriCloud