]> code.citadel.org Git - citadel.git/blobdiff - citadel/msgbase.c
* Buffered output needs to be flushed in several places. Added calls to
[citadel.git] / citadel / msgbase.c
index 16b4267bbf3f2c4e429dfec870e28dbb42e4893f..17e9603cd9a9f8d474786867c14215e85ad1efdf 100644 (file)
@@ -322,6 +322,9 @@ void CtdlSetSeen(long target_msgnum, int target_setting, int which_set) {
        int num_msgs = 0;
        char vset[SIZ];
 
+       lprintf(CTDL_DEBUG, "CtdlSetSeen(%ld, %d, %d)\n",
+               target_msgnum, target_setting, which_set);
+
        /* Learn about the user and room in question */
        CtdlGetRelationship(&vbuf, &CC->user, &CC->room);
 
@@ -472,7 +475,7 @@ int CtdlForEachMessage(int mode, long ref,
        if (num_msgs > 0) {
                if (compare != NULL) {
                        for (a = 0; a < num_msgs; ++a) {
-                               msg = CtdlFetchMessage(msglist[a]);
+                               msg = CtdlFetchMessage(msglist[a], 1);
                                if (msg != NULL) {
                                        if (CtdlMsgCmp(msg, compare)) {
                                                msglist[a] = 0L;
@@ -781,7 +784,7 @@ void mime_download(char *name, char *filename, char *partnum, char *disp,
  * NOTE: Caller is responsible for freeing the returned CtdlMessage struct
  *       using the CtdlMessageFree() function.
  */
-struct CtdlMessage *CtdlFetchMessage(long msgnum)
+struct CtdlMessage *CtdlFetchMessage(long msgnum, int with_body)
 {
        struct cdbdata *dmsgtext;
        struct cdbdata *dbigmsg;
@@ -1077,23 +1080,19 @@ int CtdlOutputMsg(long msg_num,         /* message number (local) to fetch */
                return(om_not_logged_in);
        }
 
-       /* FIXME ... small security issue
-        * We need to check to make sure the requested message is actually
-        * in the current room, and set msg_ok to 1 only if it is.  This
-        * functionality is currently missing because I'm in a hurry to replace
-        * broken production code with nonbroken pre-beta code.  :(   -- ajc
-        *
-        if (!msg_ok) {
-        if (do_proto) cprintf("%d Message %ld is not in this room.\n",
-        ERROR + MESSAGE_NOT_FOUND, msg_num);
-        return(om_no_such_msg);
-        }
-        */
+       /* FIXME: check message id against msglist for this room */
 
        /*
-        * Fetch the message from disk.
+        * Fetch the message from disk.  If we're in sooper-fast headers
+        * only mode, request that we don't even bother loading the body
+        * into memory.
         */
-       TheMessage = CtdlFetchMessage(msg_num);
+       if (headers_only == HEADERS_FAST) {
+               TheMessage = CtdlFetchMessage(msg_num, 0);
+       }
+       else {
+               TheMessage = CtdlFetchMessage(msg_num, 1);
+       }
 
        if (TheMessage == NULL) {
                if (do_proto) cprintf("%d Can't locate msg %ld on disk\n",
@@ -1541,7 +1540,7 @@ void cmd_msg3(char *cmdbuf)
        }
 
        msgnum = extract_long(cmdbuf, 0);
-       msg = CtdlFetchMessage(msgnum);
+       msg = CtdlFetchMessage(msgnum, 1);
        if (msg == NULL) {
                cprintf("%d Message %ld not found.\n", 
                        ERROR + MESSAGE_NOT_FOUND, msgnum);
@@ -1627,7 +1626,7 @@ int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int flags) {
        if (  (flags & SM_VERIFY_GOODNESS)
           || (flags & SM_DO_REPL_CHECK)
           ) {
-               msg = CtdlFetchMessage(msgid);
+               msg = CtdlFetchMessage(msgid, 1);
                if (msg == NULL) return(ERROR + ILLEGAL_VALUE);
        }
 
@@ -1781,8 +1780,12 @@ long send_message(struct CtdlMessage *msg) {
                retval = 0L;
        } else {
                if (is_bigmsg) {
-                       cdb_store(CDB_BIGMSGS, &newmsgid, sizeof(long),
-                               holdM, strlen(holdM) );
+                       cdb_store(CDB_BIGMSGS,
+                               &newmsgid,
+                               sizeof(long),
+                               holdM,
+                               (strlen(holdM) + 1)
+                       );
                }
                retval = newmsgid;
        }
@@ -1852,7 +1855,7 @@ void check_repl(long msgnum, void *userdata) {
        time_t timestamp = (-1L);
 
        lprintf(CTDL_DEBUG, "check_repl() found message %ld\n", msgnum);
-       msg = CtdlFetchMessage(msgnum);
+       msg = CtdlFetchMessage(msgnum, 1);
        if (msg == NULL) return;
        if (msg->cm_fields['T'] != NULL) {
                timestamp = atol(msg->cm_fields['T']);
@@ -2456,6 +2459,9 @@ int CtdlDoIHavePermissionToPostInThisRoom(char *errmsgbuf, size_t n) {
  */
 int CtdlCheckInternetMailPermission(struct ctdluser *who) {
 
+       /* Do not allow twits to send Internet mail */
+       if (who->axlevel <= 2) return(0);
+
        /* Globally enabled? */
        if (config.c_restrict == 0) return(1);
 
@@ -2782,6 +2788,7 @@ void cmd_ent0(char *entargs)
 
        /* Read in the message from the client. */
        cprintf("%d send message\n", SEND_LISTING);
+       flush_output();
        msg = CtdlMakeMessage(&CC->user, recp,
                CC->room.QRname, anonymous, format_type,
                masquerade_as, subject, NULL);
@@ -3264,7 +3271,7 @@ char *CtdlGetSysConfig(char *sysconfname) {
                conf = NULL;
        }
        else {
-               msg = CtdlFetchMessage(msgnum);
+               msg = CtdlFetchMessage(msgnum, 1);
                if (msg != NULL) {
                        conf = strdup(msg->cm_fields['M']);
                        CtdlFreeMessage(msg);