2 * This module handles shared rooms, inter-Citadel mail, and outbound
3 * mailing list processing.
5 * Copyright (c) 2000-2012 by the citadel.org team
7 * This program is open source software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License, version 3.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * ** NOTE ** A word on the S_NETCONFIGS semaphore:
16 * This is a fairly high-level type of critical section. It ensures that no
17 * two threads work on the netconfigs files at the same time. Since we do
18 * so many things inside these, here are the rules:
19 * 1. begin_critical_section(S_NETCONFIGS) *before* begin_ any others.
20 * 2. Do *not* perform any I/O with the client during these sections.
25 * Duration of time (in seconds) after which pending list subscribe/unsubscribe
26 * requests that have not been confirmed will be deleted.
28 #define EXP 259200 /* three days */
40 #include <sys/types.h>
42 #if TIME_WITH_SYS_TIME
43 # include <sys/time.h>
47 # include <sys/time.h>
55 # if HAVE_SYS_SYSCALL_H
56 # include <sys/syscall.h>
63 #include <libcitadel.h>
66 #include "citserver.h"
72 #include "internet_addressing.h"
73 #include "serv_network.h"
74 #include "clientsocket.h"
76 #include "citadel_dirs.h"
80 #include "ctdl_module.h"
92 #define IFTODT(mode) (((mode) & 0170000) >> 12)
93 #define DTTOIF(dirtype) ((dirtype) << 12)
97 void ParseLastSent(const CfgLineType *ThisOne, StrBuf *Line, const char *LinePos, OneRoomNetCfg *OneRNCFG)
100 nptr = (RoomNetCfgLine *)
101 malloc(sizeof(RoomNetCfgLine));
102 memset(nptr, 0, sizeof(RoomNetCfgLine));
103 OneRNCFG->lastsent = extract_long(LinePos, 0);
104 OneRNCFG->NetConfigs[ThisOne->C] = nptr;
107 void ParseRoomAlias(const CfgLineType *ThisOne, StrBuf *Line, const char *LinePos, OneRoomNetCfg *rncfg)
109 if (rncfg->Sender != NULL)
112 ParseGeneric(ThisOne, Line, LinePos, rncfg);
113 rncfg->Sender = NewStrBufDup(rncfg->NetConfigs[roommailalias]->Value[0]);
116 void ParseSubPendingLine(const CfgLineType *ThisOne, StrBuf *Line, const char *LinePos, OneRoomNetCfg *OneRNCFG)
118 if (time(NULL) - extract_long(LinePos, 3) > EXP)
119 return; /* expired subscription... */
121 ParseGeneric(ThisOne, Line, LinePos, OneRNCFG);
123 void ParseUnSubPendingLine(const CfgLineType *ThisOne, StrBuf *Line, const char *LinePos, OneRoomNetCfg *OneRNCFG)
125 if (time(NULL) - extract_long(LinePos, 2) > EXP)
126 return; /* expired subscription... */
128 ParseGeneric(ThisOne, Line, LinePos, OneRNCFG);
132 void SerializeLastSent(const CfgLineType *ThisOne, StrBuf *OutputBuffer, OneRoomNetCfg *RNCfg, RoomNetCfgLine *data)
134 StrBufAppendBufPlain(OutputBuffer, CKEY(ThisOne->Str), 0);
135 StrBufAppendPrintf(OutputBuffer, "|%ld\n", RNCfg->lastsent);
138 void DeleteLastSent(const CfgLineType *ThisOne, RoomNetCfgLine **data)
144 static const RoomNetCfg SpoolCfgs [4] = {
151 static const long SpoolCfgsCopyN [4] = {
155 int HaveSpoolConfig(OneRoomNetCfg* RNCfg)
159 for (i=0; i < 4; i++) if (RNCfg->NetConfigs[SpoolCfgs[i]] == NULL) interested = 1;
165 void InspectQueuedRoom(SpoolControl **pSC,
166 RoomProcList *room_to_spool,
167 HashList *working_ignetcfg,
168 HashList *the_netmap)
173 sc = (SpoolControl*)malloc(sizeof(SpoolControl));
174 memset(sc, 0, sizeof(SpoolControl));
175 sc->RNCfg = room_to_spool->OneRNCfg;
176 sc->lastsent = room_to_spool->lastsent;
177 sc->working_ignetcfg = working_ignetcfg;
178 sc->the_netmap = the_netmap;
181 * If the room doesn't exist, don't try to perform its networking tasks.
182 * Normally this should never happen, but once in a while maybe a room gets
183 * queued for networking and then deleted before it can happen.
185 if (CtdlGetRoom(&sc->room, room_to_spool->name) != 0) {
186 syslog(LOG_CRIT, "ERROR: cannot load <%s>\n", room_to_spool->name);
190 if (sc->room.QRhighest <= sc->lastsent)
192 syslog(LOG_DEBUG, "nothing to do for <%s>\n", room_to_spool->name);
197 if (sc->RNCfg == NULL)
198 sc->RNCfg = CtdlGetNetCfgForRoom(sc->room.QRnumber);
200 if (!HaveSpoolConfig(sc->RNCfg))
203 /* nothing to do for this room... */
207 /* Now lets remember whats needed for the actual work... */
209 for (i=0; i < 4; i++)
211 aggregate_recipients(&sc->Users[SpoolCfgs[i]],
217 if (StrLength(sc->RNCfg->Sender) > 0)
218 sc->Users[roommailalias] = NewStrBufDup(sc->RNCfg->Sender);
225 void CalcListID(SpoolControl *sc)
229 struct CitContext *CCC = CC;
230 char filename[PATH_MAX];
231 #define MAX_LISTIDLENGTH 150
233 assoc_file_name(filename, sizeof filename, &sc->room, ctdl_info_dir);
234 fd = open(filename, 0);
239 if ((fstat(fd, &stbuf) == 0) &&
242 sc->RoomInfo = NewStrBufPlain(NULL, stbuf.st_size + 1);
243 StrBufReadBLOB(sc->RoomInfo, &fd, 0, stbuf.st_size, &err);
248 sc->ListID = NewStrBufPlain(NULL, 1024);
249 if (StrLength(sc->RoomInfo) > 0)
251 const char *Pos = NULL;
252 StrBufSipLine(sc->ListID, sc->RoomInfo, &Pos);
254 if (StrLength(sc->ListID) > MAX_LISTIDLENGTH)
256 StrBufCutAt(sc->ListID, MAX_LISTIDLENGTH, NULL);
257 StrBufAppendBufPlain(sc->ListID, HKEY("..."), 0);
259 StrBufAsciify(sc->ListID, ' ');
263 StrBufAppendBufPlain(sc->ListID, CCC->room.QRname, -1, 0);
266 StrBufAppendBufPlain(sc->ListID, HKEY("<"), 0);
268 if (StrLength(sc->Users[roommailalias]) > 0)
273 Pos = StrLength(sc->ListID);
274 StrBufAppendBuf(sc->ListID, sc->Users[roommailalias], 0);
275 AtPos = strchr(ChrPtr(sc->ListID) + Pos, '@');
279 StrBufPeek(sc->ListID, AtPos, 0, '.');
284 StrBufAppendBufPlain(sc->ListID, HKEY("room_"), 0);
285 StrBufAppendBufPlain(sc->ListID, sc->room.QRname, -1, 0);
286 StrBufAppendBufPlain(sc->ListID, HKEY("."), 0);
287 StrBufAppendBufPlain(sc->ListID, config.c_fqdn, -1, 0);
290 * roomname <Room-Number.list-id.fqdn>
291 * according to rfc2919.txt it only has to be a uniq identifier
292 * under the domain of the system;
293 * in general MUAs use it to calculate the reply address nowadays.
296 StrBufAppendBufPlain(sc->ListID, HKEY(">"), 0);
298 if (StrLength(sc->Users[roommailalias]) == 0)
300 sc->Users[roommailalias] = NewStrBuf();
302 StrBufPrintf(sc->Users[roommailalias],
307 StrBufAsciify(sc->Users[roommailalias], '_');
308 StrBufLowerCase(sc->Users[roommailalias]);
315 * Batch up and send all outbound traffic from the current room
317 void network_spoolout_room(SpoolControl *sc)
319 struct CitContext *CCC = CC;
325 * If the room doesn't exist, don't try to perform its networking tasks.
326 * Normally this should never happen, but once in a while maybe a room gets
327 * queued for networking and then deleted before it can happen.
329 memcpy (&CCC->room, &sc->room, sizeof(ctdlroom));
331 syslog(LOG_INFO, "Networking started for <%s>\n", CCC->room.QRname);
333 /* If there are digest recipients, we have to build a digest */
334 if (sc->Users[digestrecp] != NULL) {
335 sc->digestfp = tmpfile();
336 fprintf(sc->digestfp, "Content-type: text/plain\n\n");
341 /* remember where we started... */
342 lastsent = sc->lastsent;
344 /* Do something useful */
345 CtdlForEachMessage(MSGS_GT, sc->lastsent, NULL, NULL, NULL,
346 network_spool_msg, sc);
348 /* If we wrote a digest, deliver it and then close it */
349 if (StrLength(sc->Users[roommailalias]) > 0)
352 len = StrLength(sc->Users[roommailalias]);
353 if (len + 1 > sizeof(buf))
354 len = sizeof(buf) - 1;
355 memcpy(buf, ChrPtr(sc->Users[roommailalias]), len);
360 snprintf(buf, sizeof buf, "room_%s@%s",
361 CCC->room.QRname, config.c_fqdn);
364 for (i=0; buf[i]; ++i) {
365 buf[i] = tolower(buf[i]);
366 if (isspace(buf[i])) buf[i] = '_';
368 if (sc->digestfp != NULL) {
369 fprintf(sc->digestfp,
370 " -----------------------------------"
371 "------------------------------------"
373 "You are subscribed to the '%s' "
375 "To post to the list: %s\n",
376 CCC->room.QRname, buf
378 network_deliver_digest(sc); /* deliver and close */
381 /* Now rewrite the config file */
382 if (sc->lastsent != lastsent)
384 sc->RNCfg = CtdlGetNetCfgForRoom(sc->room.QRnumber);
386 sc->RNCfg->lastsent = sc->lastsent;
387 sc->RNCfg->changed = 1;
389 end_critical_section(S_NETCONFIGS);
393 * Process a buffer containing a single message from a single file
394 * from the inbound queue
396 void network_process_buffer(char *buffer, long size, HashList *working_ignetcfg, HashList *the_netmap, int *netmap_changed)
399 struct CitContext *CCC = CC;
401 struct CtdlMessage *msg = NULL;
404 struct recptypes *recp = NULL;
405 char target_room[ROOMNAMELEN];
406 struct ser_ret sermsg;
407 char *oldpath = NULL;
408 char filename[PATH_MAX];
410 const StrBuf *nexthop = NULL;
411 unsigned char firstbyte;
412 unsigned char lastbyte;
414 QN_syslog(LOG_DEBUG, "network_process_buffer() processing %ld bytes\n", size);
416 /* Validate just a little bit. First byte should be FF and * last byte should be 00. */
417 firstbyte = buffer[0];
418 lastbyte = buffer[size-1];
419 if ( (firstbyte != 255) || (lastbyte != 0) ) {
420 QN_syslog(LOG_ERR, "Corrupt message ignored. Length=%ld, firstbyte = %d, lastbyte = %d\n",
421 size, firstbyte, lastbyte);
425 /* Set default target room to trash */
426 strcpy(target_room, TWITROOM);
428 /* Load the message into memory */
429 msg = (struct CtdlMessage *) malloc(sizeof(struct CtdlMessage));
430 memset(msg, 0, sizeof(struct CtdlMessage));
431 msg->cm_magic = CTDLMESSAGE_MAGIC;
432 msg->cm_anon_type = buffer[1];
433 msg->cm_format_type = buffer[2];
435 for (pos = 3; pos < size; ++pos) {
437 len = strlen(buffer + pos + 1);
438 msg->cm_fields[field] = malloc(len + 1);
439 memcpy (msg->cm_fields[field], buffer+ pos + 1, len + 1);
443 /* Check for message routing */
444 if (msg->cm_fields['D'] != NULL) {
445 if (strcasecmp(msg->cm_fields['D'], config.c_nodename)) {
447 /* route the message */
448 Buf = NewStrBufPlain(msg->cm_fields['D'], -1);
449 if (CtdlIsValidNode(&nexthop,
455 /* prepend our node to the path */
456 if (msg->cm_fields['P'] != NULL) {
457 oldpath = msg->cm_fields['P'];
458 msg->cm_fields['P'] = NULL;
461 oldpath = strdup("unknown_user");
463 size = strlen(oldpath) + SIZ;
464 msg->cm_fields['P'] = malloc(size);
465 snprintf(msg->cm_fields['P'], size, "%s!%s",
466 config.c_nodename, oldpath);
469 /* serialize the message */
470 serialize_message(&sermsg, msg);
473 if (StrLength(nexthop) == 0) {
484 QN_syslog(LOG_DEBUG, "Appending to %s\n", filename);
485 fp = fopen(filename, "ab");
487 fwrite(sermsg.ser, sermsg.len, 1, fp);
491 QN_syslog(LOG_ERR, "%s: %s\n", filename, strerror(errno));
494 CtdlFreeMessage(msg);
499 else { /* invalid destination node name */
503 "A message you sent could not be delivered due to an invalid destination node"
504 " name. Please check the address and try sending the message again.\n");
513 * Check to see if we already have a copy of this message, and
514 * abort its processing if so. (We used to post a warning to Aide>
515 * every time this happened, but the network is now so densely
516 * connected that it's inevitable.)
518 if (network_usetable(msg) != 0) {
519 CtdlFreeMessage(msg);
523 /* Learn network topology from the path */
524 if ((msg->cm_fields['N'] != NULL) && (msg->cm_fields['P'] != NULL)) {
525 NetworkLearnTopology(msg->cm_fields['N'],
531 /* Is the sending node giving us a very persuasive suggestion about
532 * which room this message should be saved in? If so, go with that.
534 if (msg->cm_fields['C'] != NULL) {
535 safestrncpy(target_room, msg->cm_fields['C'], sizeof target_room);
538 /* Otherwise, does it have a recipient? If so, validate it... */
539 else if (msg->cm_fields['R'] != NULL) {
540 recp = validate_recipients(msg->cm_fields['R'], NULL, 0);
541 if (recp != NULL) if (recp->num_error != 0) {
543 "A message you sent could not be delivered due to an invalid address.\n"
544 "Please check the address and try sending the message again.\n");
546 free_recipients(recp);
547 QNM_syslog(LOG_DEBUG, "Bouncing message due to invalid recipient address.\n");
550 strcpy(target_room, ""); /* no target room if mail */
553 /* Our last shot at finding a home for this message is to see if
554 * it has the O field (Originating room) set.
556 else if (msg->cm_fields['O'] != NULL) {
557 safestrncpy(target_room, msg->cm_fields['O'], sizeof target_room);
560 /* Strip out fields that are only relevant during transit */
561 if (msg->cm_fields['D'] != NULL) {
562 free(msg->cm_fields['D']);
563 msg->cm_fields['D'] = NULL;
565 if (msg->cm_fields['C'] != NULL) {
566 free(msg->cm_fields['C']);
567 msg->cm_fields['C'] = NULL;
570 /* save the message into a room */
571 if (PerformNetprocHooks(msg, target_room) == 0) {
572 msg->cm_flags = CM_SKIP_HOOKS;
573 CtdlSubmitMsg(msg, recp, target_room, 0);
575 CtdlFreeMessage(msg);
576 free_recipients(recp);
581 * Process a single message from a single file from the inbound queue
583 void network_process_message(FILE *fp,
586 HashList *working_ignetcfg,
587 HashList *the_netmap,
594 hold_pos = ftell(fp);
595 size = msgend - msgstart + 1;
596 buffer = malloc(size);
597 if (buffer != NULL) {
598 fseek(fp, msgstart, SEEK_SET);
599 if (fread(buffer, size, 1, fp) > 0) {
600 network_process_buffer(buffer,
609 fseek(fp, hold_pos, SEEK_SET);
614 * Process a single file from the inbound queue
616 void network_process_file(char *filename,
617 HashList *working_ignetcfg,
618 HashList *the_netmap,
621 struct CitContext *CCC = CC;
623 long msgstart = (-1L);
629 fp = fopen(filename, "rb");
631 QN_syslog(LOG_CRIT, "Error opening %s: %s\n", filename, strerror(errno));
635 fseek(fp, 0L, SEEK_END);
636 QN_syslog(LOG_INFO, "network: processing %ld bytes from %s\n", ftell(fp), filename);
639 /* Look for messages in the data stream and break them out */
640 while (ch = getc(fp), ch >= 0) {
643 if (msgstart >= 0L) {
645 network_process_message(fp,
659 if (msgstart >= 0L) {
660 network_process_message(fp,
674 * Process anything in the inbound queue
676 void network_do_spoolin(HashList *working_ignetcfg, HashList *the_netmap, int *netmap_changed)
678 struct CitContext *CCC = CC;
681 struct dirent *filedir_entry;
683 char filename[PATH_MAX];
684 static time_t last_spoolin_mtime = 0L;
689 * Check the spoolin directory's modification time. If it hasn't
690 * been touched, we don't need to scan it.
692 if (stat(ctdl_netin_dir, &statbuf)) return;
693 if (statbuf.st_mtime == last_spoolin_mtime) {
694 QNM_syslog(LOG_DEBUG, "network: nothing in inbound queue\n");
697 last_spoolin_mtime = statbuf.st_mtime;
698 QNM_syslog(LOG_DEBUG, "network: processing inbound queue\n");
701 * Ok, there's something interesting in there, so scan it.
703 dp = opendir(ctdl_netin_dir);
704 if (dp == NULL) return;
706 d = (struct dirent *)malloc(offsetof(struct dirent, d_name) + PATH_MAX + 1);
712 while ((readdir_r(dp, d, &filedir_entry) == 0) &&
713 (filedir_entry != NULL))
715 #ifdef _DIRENT_HAVE_D_NAMLEN
716 d_namelen = filedir_entry->d_namelen;
719 d_namelen = strlen(filedir_entry->d_name);
722 #ifdef _DIRENT_HAVE_D_TYPE
723 d_type = filedir_entry->d_type;
727 if ((d_namelen > 1) && filedir_entry->d_name[d_namelen - 1] == '~')
728 continue; /* Ignore backup files... */
730 if ((d_namelen == 1) &&
731 (filedir_entry->d_name[0] == '.'))
734 if ((d_namelen == 2) &&
735 (filedir_entry->d_name[0] == '.') &&
736 (filedir_entry->d_name[1] == '.'))
739 if (d_type == DT_UNKNOWN) {
747 filedir_entry->d_name);
749 if (lstat(path, &s) == 0) {
750 d_type = IFTODT(s.st_mode);
758 case DT_LNK: /* TODO: check whether its a file or a directory */
766 network_process_file(filename,
778 * Step 1: consolidate files in the outbound queue into one file per neighbor node
779 * Step 2: delete any files in the outbound queue that were for neighbors who no longer exist.
781 void network_consolidate_spoolout(HashList *working_ignetcfg, HashList *the_netmap)
783 struct CitContext *CCC = CC;
789 struct dirent *filedir_entry;
791 char spooloutfilename[PATH_MAX];
792 char filename[PATH_MAX];
793 const StrBuf *nexthop;
801 /* Step 1: consolidate files in the outbound queue into one file per neighbor node */
802 d = (struct dirent *)malloc(offsetof(struct dirent, d_name) + PATH_MAX + 1);
803 if (d == NULL) return;
805 dp = opendir(ctdl_netout_dir);
811 NextHop = NewStrBuf();
812 memset(&IOB, 0, sizeof(IOBuffer));
813 memset(&FDIO, 0, sizeof(FDIOBuffer));
816 while ((readdir_r(dp, d, &filedir_entry) == 0) &&
817 (filedir_entry != NULL))
819 #ifdef _DIRENT_HAVE_D_NAMLEN
820 d_namelen = filedir_entry->d_namelen;
823 d_namelen = strlen(filedir_entry->d_name);
826 #ifdef _DIRENT_HAVE_D_TYPE
827 d_type = filedir_entry->d_type;
831 if (d_type == DT_DIR)
834 if ((d_namelen > 1) && filedir_entry->d_name[d_namelen - 1] == '~')
835 continue; /* Ignore backup files... */
837 if ((d_namelen == 1) &&
838 (filedir_entry->d_name[0] == '.'))
841 if ((d_namelen == 2) &&
842 (filedir_entry->d_name[0] == '.') &&
843 (filedir_entry->d_name[1] == '.'))
846 pch = strchr(filedir_entry->d_name, '@');
854 filedir_entry->d_name);
857 filedir_entry->d_name,
858 pch - filedir_entry->d_name);
860 snprintf(spooloutfilename,
861 sizeof spooloutfilename,
866 QN_syslog(LOG_DEBUG, "Consolidate %s to %s\n", filename, ChrPtr(NextHop));
867 if (CtdlNetworkTalkingTo(SKEY(NextHop), NTT_CHECK)) {
870 "Currently online with %s - skipping for now\n",
878 const char *err = NULL;
879 CtdlNetworkTalkingTo(SKEY(NextHop), NTT_ADD);
881 infd = open(filename, O_RDONLY);
885 "failed to open %s for reading due to %s; skipping.\n",
886 filename, strerror(errno)
888 CtdlNetworkTalkingTo(SKEY(NextHop), NTT_REMOVE);
892 outfd = open(spooloutfilename,
893 O_EXCL|O_CREAT|O_NONBLOCK|O_WRONLY,
897 outfd = open(spooloutfilename,
898 O_EXCL|O_NONBLOCK|O_WRONLY,
904 "failed to open %s for reading due to %s; skipping.\n",
905 spooloutfilename, strerror(errno)
908 CtdlNetworkTalkingTo(SKEY(NextHop), NTT_REMOVE);
912 dsize = lseek(outfd, 0, SEEK_END);
913 lseek(outfd, -dsize, SEEK_SET);
915 fstat(infd, &statbuf);
916 fsize = statbuf.st_size;
918 fsize = lseek(infd, 0, SEEK_END);
921 FDIOBufferInit(&FDIO, &IOB, outfd, fsize + dsize);
922 FDIO.ChunkSendRemain = fsize;
923 FDIO.TotalSentAlready = dsize;
926 do {} while ((FileMoveChunked(&FDIO, &err) > 0) && (err == NULL));
930 "Spoolfile %s now "SIZE_T_FMT" k\n",
938 "failed to append to %s [%s]; rolling back..\n",
939 spooloutfilename, strerror(errno)
941 /* whoops partial append?? truncate spooloutfilename again! */
942 ftruncate(outfd, dsize);
944 FDIOBufferDelete(&FDIO);
947 CtdlNetworkTalkingTo(SKEY(NextHop), NTT_REMOVE);
953 FreeStrBuf(&NextHop);
955 "skipping Spoolcleanup because of %d files unprocessed.\n",
962 /* Step 2: delete any files in the outbound queue that were for neighbors who no longer exist */
963 dp = opendir(ctdl_netout_dir);
965 FreeStrBuf(&NextHop);
970 while ((readdir_r(dp, d, &filedir_entry) == 0) &&
971 (filedir_entry != NULL))
973 #ifdef _DIRENT_HAVE_D_NAMLEN
974 d_namelen = filedir_entry->d_namelen;
977 d_namelen = strlen(filedir_entry->d_name);
980 #ifdef _DIRENT_HAVE_D_TYPE
981 d_type = filedir_entry->d_type;
985 if (d_type == DT_DIR)
988 if ((d_namelen == 1) &&
989 (filedir_entry->d_name[0] == '.'))
992 if ((d_namelen == 2) &&
993 (filedir_entry->d_name[0] == '.') &&
994 (filedir_entry->d_name[1] == '.'))
997 pch = strchr(filedir_entry->d_name, '@');
998 if (pch == NULL) /* no @ in name? consolidated file. */
1001 StrBufPlain(NextHop,
1002 filedir_entry->d_name,
1003 pch - filedir_entry->d_name);
1009 filedir_entry->d_name
1012 i = CtdlIsValidNode(&nexthop,
1018 if ( (i != 0) || (StrLength(nexthop) > 0) ) {
1022 FreeStrBuf(&NextHop);
1027 void free_spoolcontrol_struct(SpoolControl **sc)
1029 free_spoolcontrol_struct_members(*sc);
1034 void free_spoolcontrol_struct_members(SpoolControl *sc)
1037 FreeStrBuf(&sc->RoomInfo);
1038 FreeStrBuf(&sc->ListID);
1039 for (i = 0; i < maxRoomNetCfg; i++)
1040 FreeStrBuf(&sc->Users[i]);
1046 * It's ok if these directories already exist. Just fail silently.
1048 void create_spool_dirs(void) {
1049 if ((mkdir(ctdl_spool_dir, 0700) != 0) && (errno != EEXIST))
1050 syslog(LOG_EMERG, "unable to create directory [%s]: %s", ctdl_spool_dir, strerror(errno));
1051 if (chown(ctdl_spool_dir, CTDLUID, (-1)) != 0)
1052 syslog(LOG_EMERG, "unable to set the access rights for [%s]: %s", ctdl_spool_dir, strerror(errno));
1053 if ((mkdir(ctdl_netin_dir, 0700) != 0) && (errno != EEXIST))
1054 syslog(LOG_EMERG, "unable to create directory [%s]: %s", ctdl_netin_dir, strerror(errno));
1055 if (chown(ctdl_netin_dir, CTDLUID, (-1)) != 0)
1056 syslog(LOG_EMERG, "unable to set the access rights for [%s]: %s", ctdl_netin_dir, strerror(errno));
1057 if ((mkdir(ctdl_nettmp_dir, 0700) != 0) && (errno != EEXIST))
1058 syslog(LOG_EMERG, "unable to create directory [%s]: %s", ctdl_nettmp_dir, strerror(errno));
1059 if (chown(ctdl_nettmp_dir, CTDLUID, (-1)) != 0)
1060 syslog(LOG_EMERG, "unable to set the access rights for [%s]: %s", ctdl_nettmp_dir, strerror(errno));
1061 if ((mkdir(ctdl_netout_dir, 0700) != 0) && (errno != EEXIST))
1062 syslog(LOG_EMERG, "unable to create directory [%s]: %s", ctdl_netout_dir, strerror(errno));
1063 if (chown(ctdl_netout_dir, CTDLUID, (-1)) != 0)
1064 syslog(LOG_EMERG, "unable to set the access rights for [%s]: %s", ctdl_netout_dir, strerror(errno));
1068 * Module entry point
1070 CTDL_MODULE_INIT(network_spool)
1074 CtdlREGISTERRoomCfgType(subpending, ParseSubPendingLine, 0, 5, SerializeGeneric, DeleteGenericCfgLine); /// todo: move this to mailinglist manager
1075 CtdlREGISTERRoomCfgType(unsubpending, ParseUnSubPendingLine, 0, 4, SerializeGeneric, DeleteGenericCfgLine); /// todo: move this to mailinglist manager
1076 CtdlREGISTERRoomCfgType(lastsent, ParseLastSent, 1, 1, SerializeLastSent, DeleteLastSent);
1077 CtdlREGISTERRoomCfgType(ignet_push_share, ParseGeneric, 0, 2, SerializeGeneric, DeleteGenericCfgLine); // [remotenode|remoteroomname (optional)]// todo: move this to the ignet client
1078 CtdlREGISTERRoomCfgType(listrecp, ParseGeneric, 0, 1, SerializeGeneric, DeleteGenericCfgLine);
1079 CtdlREGISTERRoomCfgType(digestrecp, ParseGeneric, 0, 1, SerializeGeneric, DeleteGenericCfgLine);
1080 CtdlREGISTERRoomCfgType(participate, ParseGeneric, 0, 1, SerializeGeneric, DeleteGenericCfgLine);
1081 CtdlREGISTERRoomCfgType(roommailalias, ParseRoomAlias, 0, 1, SerializeGeneric, DeleteGenericCfgLine);
1083 create_spool_dirs();
1084 //////todo CtdlRegisterCleanupHook(destroy_network_queue_room);
1086 return "network_spool";