// // // XOVER is used by some clients, even if we don't offer it // void nntp_xover(const char *cmd) { if (CtdlAccessCheck(ac_logged_in_or_guest)) return; citnntp *nntpstate = (citnntp *) CC->session_specific_data; char range[256]; struct listgroup_range lr; extract_token(range, cmd, 1, ' ', sizeof range); lr.lo = atol(range); if (lr.lo <= 0) { lr.lo = nntpstate->current_article_number; lr.hi = nntpstate->current_article_number; } else { char *dash = strchr(range, '-'); if (dash != NULL) { ++dash; lr.hi = atol(dash); if (lr.hi == 0) { lr.hi = LONG_MAX; } if (lr.hi < lr.lo) { lr.hi = lr.lo; } } else { lr.hi = lr.lo; } } cprintf("224 Overview information follows\r\n"); CtdlForEachMessage(MSGS_ALL, 0L, NULL, NULL, NULL, nntp_xover_backend, &lr); cprintf(".\r\n"); }
/* * smtp_queue_thread() * * Run through the queue sending out messages. */ void smtp_do_queue(void) { int num_processed = 0; int num_activated = 0; pthread_setspecific(MyConKey, (void *)&smtp_queue_CC); SMTPCM_syslog(LOG_DEBUG, "processing outbound queue"); if (CtdlGetRoom(&CC->room, SMTP_SPOOLOUT_ROOM) != 0) { SMTPC_syslog(LOG_ERR, "Cannot find room <%s>", SMTP_SPOOLOUT_ROOM); } else { num_processed = CtdlForEachMessage(MSGS_ALL, 0L, NULL, SPOOLMIME, NULL, smtp_do_procmsg, &num_activated); } if (num_activated > 0) { SMTPC_syslog(LOG_INFO, "queue run completed; %d messages processed %d activated", num_processed, num_activated); } }
/* * Scan a room for messages to index. */ void ft_index_room(struct ctdlroom *qrbuf, void *data) { if (server_shutting_down) return; CtdlGetRoom(&CC->room, qrbuf->QRname); CtdlForEachMessage(MSGS_ALL, 0L, NULL, NULL, NULL, ft_index_msg, NULL); }
/* * Fetch the "mortuary" - a list of dead buddies which we keep around forever * so we can remove them from any client's roster that still has them listed */ HashList *xmpp_fetch_mortuary(void) { HashList *mortuary = NewHash(1, NULL); if (!mortuary) { syslog(LOG_ALERT, "NewHash() failed!\n"); return(NULL); } if (CtdlGetRoom(&CC->room, USERCONFIGROOM) != 0) { /* no config room exists - no further processing is required. */ return(mortuary); } CtdlForEachMessage(MSGS_LAST, 1, NULL, XMPPMORTUARY, NULL, xmpp_fetch_mortuary_backend, (void *)mortuary ); return(mortuary); }
int serv_dspam_room(struct ctdlroom *room) { DSPAM_CTX *CTX; /* DSPAM Context */ /* scan for spam; do */ /* probably do: dspam_init; dspam_process dspam_addattribute; dspam_destroy*/ //DSS_NONE //#define DSR_ISSPAM 0x01 //#define DSR_ISINNOCENT 0x02 // dspam_init (cc->username, NULL, ctdl_dspam_home, DSM_PROCESS, // DSF_SIGNATURE | DSF_NOISE); /// todo: if roomname = spam / ham -> learn! if ((room->QRflags & QR_PRIVATE) &&/* Are we sending to a private mailbox? */ (strstr(room->QRname, ".Mail")!=NULL)) { char User[64]; // maybe we should better get our realname here? snprintf(User, 64, "%ld", room->QRroomaide); extract_token(User, room->QRname, 0, '.', sizeof(User)); CTX = dspam_init(User, NULL, ctdl_dspam_dir, DSM_PROCESS, DSF_SIGNATURE | DSF_NOISE); } else return 0;//// /// else -> todo: global user for public rooms etc. if (CTX == NULL) { syslog(LOG_CRIT, "ERROR: dspam_init failed!\n"); return ERROR + INTERNAL_ERROR; } /* Use graham and robinson algorithms, graham's p-values */ CTX->algorithms = DSA_GRAHAM | DSA_BURTON | DSP_GRAHAM; /* Use CHAIN tokenizer */ CTX->tokenizer = DSZ_CHAIN; CtdlForEachMessage(MSGS_GT, 1, NULL, NULL, NULL, dspam_do_msg, (void *) &CTX); return 0; }
// // Implements the GROUP and LISTGROUP commands // void nntp_group(const char *cmd) { if (CtdlAccessCheck(ac_logged_in_or_guest)) return; citnntp *nntpstate = (citnntp *) CC->session_specific_data; char verb[16]; char requested_group[1024]; char message_range[256]; char range_lo[256]; char range_hi[256]; char requested_room[ROOMNAMELEN]; char augmented_roomname[ROOMNAMELEN]; int c = 0; int ok = 0; int ra = 0; struct ctdlroom QRscratch; int msgs, new; long oldest,newest; struct listgroup_range lr; extract_token(verb, cmd, 0, ' ', sizeof verb); extract_token(requested_group, cmd, 1, ' ', sizeof requested_group); extract_token(message_range, cmd, 2, ' ', sizeof message_range); extract_token(range_lo, message_range, 0, '-', sizeof range_lo); extract_token(range_hi, message_range, 1, '-', sizeof range_hi); lr.lo = atoi(range_lo); lr.hi = atoi(range_hi); /* In LISTGROUP mode we can specify an empty name for 'currently selected' */ if ((!strcasecmp(verb, "LISTGROUP")) && (IsEmptyStr(requested_group))) { room_to_newsgroup(requested_group, CC->room.QRname, sizeof requested_group); } /* First try a regular match */ newsgroup_to_room(requested_room, requested_group, sizeof requested_room); c = CtdlGetRoom(&QRscratch, requested_room); /* Then try a mailbox name match */ if (c != 0) { CtdlMailboxName(augmented_roomname, sizeof augmented_roomname, &CC->user, requested_room); c = CtdlGetRoom(&QRscratch, augmented_roomname); if (c == 0) { safestrncpy(requested_room, augmented_roomname, sizeof(requested_room)); } } /* If the room exists, check security/access */ if (c == 0) { /* See if there is an existing user/room relationship */ CtdlRoomAccess(&QRscratch, &CC->user, &ra, NULL); /* normal clients have to pass through security */ if (ra & UA_KNOWN) { ok = 1; } } /* Fail here if no such room */ if (!ok) { cprintf("411 no such newsgroup\r\n"); return; } /* * CtdlUserGoto() formally takes us to the desired room, happily returning * the number of messages and number of new messages. */ memcpy(&CC->room, &QRscratch, sizeof(struct ctdlroom)); CtdlUserGoto(NULL, 0, 0, &msgs, &new, &oldest, &newest); cprintf("211 %d %ld %ld %s\r\n", msgs, oldest, newest, requested_group); // If this is a GROUP command, set the "current article number" to zero, and then stop here. if (!strcasecmp(verb, "GROUP")) { nntpstate->current_article_number = oldest; return; } // If we get to this point we are running a LISTGROUP command. Fetch those message numbers. CtdlForEachMessage(MSGS_ALL, 0L, NULL, NULL, NULL, nntp_listgroup_backend, &lr); cprintf(".\r\n"); }
void inetcfg_init(void) { if (CtdlGetRoom(&CC->room, SYSCONFIGROOM) != 0) return; CtdlForEachMessage(MSGS_LAST, 1, NULL, INTERNETCFG, NULL, inetcfg_init_backend, NULL); }