that is corrupting the memory.
$Log$
+ Revision 573.124 2001/04/10 01:04:10 ajc
+ * Finished coding IMAP APPEND. It works, but there's a bug in it somewhere
+ that is corrupting the memory.
+
Revision 573.123 2001/04/03 00:47:23 ajc
* Began implementing IMAP APPEND
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
+
*/
void imap_append(int num_parms, char *parms[]) {
size_t literal_length;
+ struct CtdlMessage *msg;
int ret;
+ char roomname[ROOMNAMELEN];
+ char buf[SIZ];
+ char savedroom[ROOMNAMELEN];
+ int msgs, new;
+
if (num_parms < 4) {
cprintf("%s BAD usage error\r\n", parms[0]);
return;
}
- cprintf("%s NO not implemented yet ** FIXME ** \r\n", parms[0]);
+ lprintf(9, "Converting message...\n");
+ msg = convert_internet_message(IMAP->transmitted_message);
+
+ /* If the user is locally authenticated, FORCE the From: header to
+ * show up as the real sender. FIXME do we really want to do this?
+ */
+ if (CC->logged_in) {
+ if (msg->cm_fields['A'] != NULL) phree(msg->cm_fields['A']);
+ if (msg->cm_fields['N'] != NULL) phree(msg->cm_fields['N']);
+ if (msg->cm_fields['H'] != NULL) phree(msg->cm_fields['H']);
+ msg->cm_fields['A'] = strdoop(CC->usersupp.fullname);
+ msg->cm_fields['N'] = strdoop(config.c_nodename);
+ msg->cm_fields['H'] = strdoop(config.c_humannode);
+ }
+
+ ret = imap_grabroom(roomname, parms[2]);
+ if (ret != 0) {
+ cprintf("%s NO Invalid mailbox name or location, or access denied\r\n",
+ parms[0]);
+ return;
+ }
+
+ /*
+ * usergoto() formally takes us to the desired room. (If another
+ * folder is selected, save its name so we can return there!!!!!)
+ */
+ if (IMAP->selected) {
+ strcpy(savedroom, CC->quickroom.QRname);
+ }
+ usergoto(roomname, 0, &msgs, &new);
+
+ /*
+ * Can we post here?
+ */
+ ret = CtdlDoIHavePermissionToPostInThisRoom(buf);
+
+ if (ret) {
+ /* Nope ... print an error message */
+ cprintf("%s NO %s\r\n", parms[0], buf);
+ }
+
+ else {
+ /* Yes ... go ahead and post! */
+ if (msg != NULL) {
+ CtdlSaveMsg(msg, "", "", 0);
+ }
+ cprintf("%s OK APPEND completed\r\n", parms[0]);
+ }
+
+ /*
+ * IMAP protocol response to client has already been sent by now.
+ *
+ * If another folder is selected, go back to that room so we can resume
+ * our happy day without violent explosions.
+ */
+ if (IMAP->selected) {
+ usergoto(savedroom, 0, &msgs, &new);
+ }
+
+ /* We don't need this buffer anymore */
+ CtdlFreeMessage(msg);
}
}
+/*
+ * Check to see whether we have permission to post a message in the current
+ * room. Returns a *CITADEL ERROR CODE* and puts a message in errmsgbuf, or
+ * returns 0 on success.
+ */
+int CtdlDoIHavePermissionToPostInThisRoom(char *errmsgbuf) {
+
+ if (!(CC->logged_in)) {
+ sprintf(errmsgbuf, "Not logged in.");
+ return (ERROR + NOT_LOGGED_IN);
+ }
+
+ if ((CC->usersupp.axlevel < 2)
+ && ((CC->quickroom.QRflags & QR_MAILBOX) == 0)) {
+ sprintf(errmsgbuf, "Need to be validated to enter "
+ "(except in %s> to sysop)", MAILROOM);
+ return (ERROR + HIGHER_ACCESS_REQUIRED);
+ }
+
+ if ((CC->usersupp.axlevel < 4)
+ && (CC->quickroom.QRflags & QR_NETWORK)) {
+ sprintf(errmsgbuf, "Need net privileges to enter here.");
+ return (ERROR + HIGHER_ACCESS_REQUIRED);
+ }
+
+ if ((CC->usersupp.axlevel < 6)
+ && (CC->quickroom.QRflags & QR_READONLY)) {
+ sprintf(errmsgbuf, "Sorry, this is a read-only room.");
+ return (ERROR + HIGHER_ACCESS_REQUIRED);
+ }
+
+ strcpy(errmsgbuf, "Ok");
+ return(0);
+}
+
int mtsflag = 0;
struct usersupp tempUS;
char buf[SIZ];
+ int err = 0;
post = extract_int(entargs, 0);
extract(recipient, entargs, 1);
/* first check to make sure the request is valid. */
- if (!(CC->logged_in)) {
- cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN);
- return;
- }
- if ((CC->usersupp.axlevel < 2) && ((CC->quickroom.QRflags & QR_MAILBOX) == 0)) {
- cprintf("%d Need to be validated to enter ",
- ERROR + HIGHER_ACCESS_REQUIRED);
- cprintf("(except in %s> to sysop)\n", MAILROOM);
- return;
- }
- if ((CC->usersupp.axlevel < 4) && (CC->quickroom.QRflags & QR_NETWORK)) {
- cprintf("%d Need net privileges to enter here.\n",
- ERROR + HIGHER_ACCESS_REQUIRED);
- return;
- }
- if ((CC->usersupp.axlevel < 6) && (CC->quickroom.QRflags & QR_READONLY)) {
- cprintf("%d Sorry, this is a read-only room.\n",
- ERROR + HIGHER_ACCESS_REQUIRED);
+ err = CtdlDoIHavePermissionToPostInThisRoom(buf);
+ if (err) {
+ cprintf("%d %s\n", err, buf);
return;
}
- mtsflag = 0;
+ /* Check some other permission type things. */
if (post == 2) {
if (CC->usersupp.axlevel < 6) {
int crlf);
int CtdlCopyMsgToRoom(long msgnum, char *dest);
int CtdlDoIHavePermissionToDeleteMessagesFromThisRoom(void);
+int CtdlDoIHavePermissionToPostInThisRoom(char *errmsgbuf);