Re: digest.sha1 cyrus-imapd.2.4.17 problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Quoting Manel Gimeno Zaragozá <magiza83@xxxxxxxxxxx>, Tue, 25 Jun 2013:

Hello,

A year ago I patch a cyrus 2.4.13 with fastmail imapd patches in order to get digest.sha1 for replica check consistency, and everything was working perfectly, but now my problem is that I'm trying to patch 2.4.17 but sha1 is not created. I can fetch digest.sha1 and rfc822.filesize but no data is stored:

. fetch 1 digest.sha1
* 1 FETCH . OK Completed (0.000 sec)
. fetch 1 rfc822.filesize
* 1 FETCH . OK Completed (0.000 sec)


Hi, this works in my setup

. fetch 1 digest.sha1
* 1 FETCH (DIGEST.SHA1 262d6ca63ddbfd0a5b4adb36859d46890996e71f)
. OK Completed (0.000 sec)
. fetch 1 rfc822.filesize
* 1 FETCH (RFC822.FILESIZE 26894)
. OK Completed (0.000 sec)


I'm using a different patch.  See the one attached.


--
 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
 Rudy Gevaert                             e-mail: Rudy.Gevaert@xxxxxxxx
 Directie ICT, Afdeling Infrastructuur
 Groep Systemen                                      tel: +32 9 264 4750
 Universiteit Gent                                   fax: +32 9 264 4994
 Krijgslaan 281, gebouw S9, 9000 Gent, Belgie               www.UGent.be
 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

>From 048ce01d5318b086b7a4ed67946fcc10561828e4 Mon Sep 17 00:00:00 2001
From: Bron Gondwana <brong@xxxxxxxxx>
Date: Sun, 15 Aug 2010 20:25:44 +1000
Subject: [PATCH 02/10] GUID IMAP COMMANDS

This patch factors out stuff we used to have in the old MD5UUIDs
patch, the following FETCH responses in imapd:

FETCH DIGEST.SHA1 => 40 character hex string (message sha1)
FETCH RFC822.SHA1 => 40 character hex string (message sha1, calculated)
FETCH RFC822.FILESIZE => size of actual file on disk (via stat or mmap)

It also adds a capability string item: "DIGEST=SHA1"

Totally non-standard of course, but way useful for our replication checking
scripts.  Embrace and extend 'r' us.

Anyone feel like writing an RFC for fetching the digest of a message via
IMAP?  If the server calculated it on delivery and cached it then you'd have
a great way to clean up after a UIDVALIDITY change or other destabilising event
without having to fetch every message again.
---
 imap/imapd.c |   15 +++++++++++++++
 imap/imapd.h |    5 ++++-
 imap/index.c |   27 ++++++++++++++++++++++++++-
 3 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/imap/imapd.c b/imap/imapd.c
index 2f774dd..786b7e3 100644
--- a/imap/imapd.c
+++ b/imap/imapd.c
@@ -309,6 +309,7 @@ struct capa_struct base_capabilities[] = {
     { "QRESYNC",               2 },
     { "SCAN",                  2 },
     { "XLIST",                 2 },
+    { "DIGEST=SHA1",           2 },
 
 #ifdef HAVE_SSL
     { "URLAUTH",               2 },
@@ -4064,6 +4065,13 @@ void cmd_fetch(char *tag, char *sequence, int usinguid)
 	    else goto badatt;
 	    break;
 
+	case 'D':
+	    if (!strcmp(fetchatt.s, "DIGEST.SHA1")) {
+		fetchitems |= FETCH_GUID;
+	    }
+	    else goto badatt;
+	    break;
+
 	case 'E':
 	    if (!strcmp(fetchatt.s, "ENVELOPE")) {
 		fetchitems |= FETCH_ENVELOPE;
@@ -4097,6 +4105,7 @@ void cmd_fetch(char *tag, char *sequence, int usinguid)
 	    }
 	    else goto badatt;
 	    break;
+
 	case 'R':
 	    if (!strcmp(fetchatt.s, "RFC822")) {
 		fetchitems |= FETCH_RFC822|FETCH_SETSEEN;
@@ -4113,6 +4122,12 @@ void cmd_fetch(char *tag, char *sequence, int usinguid)
 	    else if (!strcmp(fetchatt.s, "RFC822.TEXT")) {
 		fetchitems |= FETCH_TEXT|FETCH_SETSEEN;
 	    }
+	    else if (!strcmp(fetchatt.s, "RFC822.SHA1")) {
+		fetchitems |= FETCH_SHA1;
+	    }
+	    else if (!strcmp(fetchatt.s, "RFC822.FILESIZE")) {
+		fetchitems |= FETCH_FILESIZE;
+	    }
 	    else if (!strcmp(fetchatt.s, "RFC822.TEXT.PEEK")) {
 		fetchitems |= FETCH_TEXT;
 	    }
diff --git a/imap/imapd.h b/imap/imapd.h
index c251e04..5f4a1a7 100644
--- a/imap/imapd.h
+++ b/imap/imapd.h
@@ -110,7 +110,10 @@ enum {
     FETCH_SETSEEN =             (1<<10),
 /*     FETCH_UNCACHEDHEADER =      (1<<11) -- obsolete */
     FETCH_IS_PARTIAL =          (1<<12), /* this is the PARTIAL command */
-    FETCH_MODSEQ =		(1<<13)
+    FETCH_MODSEQ =		(1<<13),
+    FETCH_GUID   =    (1<<14),
+    FETCH_SHA1   =    (1<<15),
+    FETCH_FILESIZE =  (1<<16)
 };
 
 enum {
diff --git a/imap/index.c b/imap/index.c
index 7b3540d..0d51327 100644
--- a/imap/index.c
+++ b/imap/index.c
@@ -2438,7 +2438,7 @@ static int index_fetchreply(struct index_state *state, uint32_t msgno,
     }
 
     /* Open the message file if we're going to need it */
-    if ((fetchitems & (FETCH_HEADER|FETCH_TEXT|FETCH_RFC822)) ||
+    if ((fetchitems & (FETCH_HEADER|FETCH_TEXT|FETCH_SHA1|FETCH_RFC822)) ||
 	fetchargs->cache_atleast > im->record.cache_version || 
 	fetchargs->binsections || fetchargs->sizesections ||
 	fetchargs->bodysections) {
@@ -2465,6 +2465,12 @@ static int index_fetchreply(struct index_state *state, uint32_t msgno,
 	prot_printf(state->out, "%cUID %u", sepchar, im->record.uid);
 	sepchar = ' ';
     }
+    if (fetchitems & FETCH_GUID) {
+	prot_printf(state->out, "%cDIGEST.SHA1 %s", sepchar,
+		    message_guid_encode(&im->record.guid));
+	sepchar = ' ';
+    }
+
     if (fetchitems & FETCH_INTERNALDATE) {
 	time_t msgdate = im->record.internaldate;
 	char datebuf[30];
@@ -2485,6 +2491,25 @@ static int index_fetchreply(struct index_state *state, uint32_t msgno,
 		    sepchar, im->record.size);
 	sepchar = ' ';
     }
+    if (fetchitems & FETCH_FILESIZE) {
+	if (!msg_base) {
+	    char *fname = mailbox_message_fname(mailbox, im->record.uid);
+	    struct stat sbuf;
+	    /* Find the size of the message file */
+	    if (stat(fname, &sbuf) == -1)
+		syslog(LOG_ERR, "IOERROR: stat on %s: %m", fname);
+	    else
+		msg_size = sbuf.st_size;
+	}
+	prot_printf(state->out, "%cRFC822.FILESIZE %lu", sepchar, msg_size);
+	sepchar = ' ';
+    }
+    if (fetchitems & FETCH_SHA1) {
+	struct message_guid tmpguid;
+	message_guid_generate(&tmpguid, msg_base, msg_size);
+	prot_printf(state->out, "%cRFC822.SHA1 %s", sepchar, message_guid_encode(&tmpguid));
+	sepchar = ' ';
+    }
     if (fetchitems & FETCH_ENVELOPE) {
         if (!mailbox_cacherecord(mailbox, &im->record)) {
 	    prot_printf(state->out, "%cENVELOPE ", sepchar);
-- 
1.7.0.4

----
Cyrus Home Page: http://www.cyrusimap.org/
List Archives/Info: http://lists.andrew.cmu.edu/pipermail/info-cyrus/
To Unsubscribe:
https://lists.andrew.cmu.edu/mailman/listinfo/info-cyrus

[Index of Archives]     [Cyrus SASL]     [Squirrel Mail]     [Asterisk PBX]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [KDE]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux