From: Art Cancro Date: Fri, 28 Jan 2011 17:07:34 +0000 (-0500) Subject: Ok this is it, the best of both worlds. X-Git-Tag: v8.01~252^2~130 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=2342a0ce1ed3316a87fcb1aac6a31ee49f3c982c;p=citadel.git Ok this is it, the best of both worlds. 1. Go back to the 'cache the most recent msglist' and 'binary-search that list' method. 2. Make ONE attempt to reload the msglist if a search fails. --- diff --git a/citadel/msgbase.c b/citadel/msgbase.c index eb1c53ce5..538ab9126 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -654,7 +654,6 @@ int CtdlForEachMessage(int mode, long ref, char *search_string, CC->cached_msglist = msglist; CC->cached_num_msgs = num_msgs; - syslog(LOG_DEBUG, "\033[34m RELOAD \033[0m\n"); } /* @@ -1533,7 +1532,6 @@ int check_cached_msglist(long msgnum) { int max = (CC->cached_num_msgs - 1); while (max >= min) { - syslog(LOG_DEBUG, "\033[35m Checking from %d to %d \033[0m\n", min, max); int middle = min + (max-min) / 2 ; if (msgnum == CC->cached_msglist[middle]) { return om_ok; @@ -1600,14 +1598,27 @@ int CtdlOutputMsg(long msg_num, /* message number (local) to fetch */ return(r); } + /* + * Check to make sure the message is actually IN this room + */ r = check_cached_msglist(msg_num); - if (r == om_ok) { - syslog(LOG_DEBUG, "\033[32m PASS \033[0m\n"); + if (r == om_access_denied) { + /* Not in the cache? We get ONE shot to check it again. */ + CtdlForEachMessage(MSGS_ALL, 0L, NULL, NULL, NULL, NULL, NULL); + r = check_cached_msglist(msg_num); } - else { - syslog(LOG_DEBUG, "\033[31m FAIL \033[0m\n"); + if (r != om_ok) { + syslog(LOG_DEBUG, "\033[31m SECURITY CHECK FAIL \033[0m\n"); + if (do_proto) { + if (r == om_access_denied) { + cprintf("%d message %ld was not found in this room\n", + ERROR + HIGHER_ACCESS_REQUIRED, + msg_num + ); + } + } + return(r); } - /* FIXME after testing, this is where we deny access */ /* * Fetch the message from disk. If we're in HEADERS_FAST mode,