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"
75 #include "citadel_dirs.h"
79 #include "ctdl_module.h"
91 #define IFTODT(mode) (((mode) & 0170000) >> 12)
92 #define DTTOIF(dirtype) ((dirtype) << 12)
96 void ParseLastSent(const CfgLineType *ThisOne, StrBuf *Line, const char *LinePos, OneRoomNetCfg *OneRNCFG)
99 nptr = (RoomNetCfgLine *)
100 malloc(sizeof(RoomNetCfgLine));
101 memset(nptr, 0, sizeof(RoomNetCfgLine));
102 OneRNCFG->lastsent = extract_long(LinePos, 0);
103 OneRNCFG->NetConfigs[ThisOne->C] = nptr;
106 void ParseRoomAlias(const CfgLineType *ThisOne, StrBuf *Line, const char *LinePos, OneRoomNetCfg *rncfg)
108 if (rncfg->Sender != NULL)
111 ParseGeneric(ThisOne, Line, LinePos, rncfg);
112 rncfg->Sender = NewStrBufDup(rncfg->NetConfigs[roommailalias]->Value[0]);
115 void ParseSubPendingLine(const CfgLineType *ThisOne, StrBuf *Line, const char *LinePos, OneRoomNetCfg *OneRNCFG)
117 if (time(NULL) - extract_long(LinePos, 3) > EXP)
118 return; /* expired subscription... */
120 ParseGeneric(ThisOne, Line, LinePos, OneRNCFG);
122 void ParseUnSubPendingLine(const CfgLineType *ThisOne, StrBuf *Line, const char *LinePos, OneRoomNetCfg *OneRNCFG)
124 if (time(NULL) - extract_long(LinePos, 2) > EXP)
125 return; /* expired subscription... */
127 ParseGeneric(ThisOne, Line, LinePos, OneRNCFG);
131 void SerializeLastSent(const CfgLineType *ThisOne, StrBuf *OutputBuffer, OneRoomNetCfg *RNCfg, RoomNetCfgLine *data)
133 StrBufAppendBufPlain(OutputBuffer, CKEY(ThisOne->Str), 0);
134 StrBufAppendPrintf(OutputBuffer, "|%ld\n", RNCfg->lastsent);
137 void DeleteLastSent(const CfgLineType *ThisOne, RoomNetCfgLine **data)
143 static const RoomNetCfg SpoolCfgs [4] = {
150 static const long SpoolCfgsCopyN [4] = {
154 int HaveSpoolConfig(OneRoomNetCfg* RNCfg)
158 for (i=0; i < 4; i++) if (RNCfg->NetConfigs[SpoolCfgs[i]] == NULL) interested = 1;
162 void Netmap_AddMe(struct CtdlMessage *msg, const char *defl, long defllen)
167 /* prepend our node to the path */
168 if (CM_IsEmpty(msg, eMessagePath)) {
169 CM_SetField(msg, eMessagePath, defl, defllen);
171 node_len = configlen.c_nodename;
174 memcpy(buf, config.c_nodename, node_len);
176 buf[node_len + 1] = '\0';
177 CM_PrependToField(msg, eMessagePath, buf, node_len + 1);
180 void InspectQueuedRoom(SpoolControl **pSC,
181 RoomProcList *room_to_spool,
182 HashList *working_ignetcfg,
183 HashList *the_netmap)
188 sc = (SpoolControl*)malloc(sizeof(SpoolControl));
189 memset(sc, 0, sizeof(SpoolControl));
190 sc->RNCfg = room_to_spool->OneRNCfg;
191 sc->lastsent = room_to_spool->lastsent;
192 sc->working_ignetcfg = working_ignetcfg;
193 sc->the_netmap = the_netmap;
196 * If the room doesn't exist, don't try to perform its networking tasks.
197 * Normally this should never happen, but once in a while maybe a room gets
198 * queued for networking and then deleted before it can happen.
200 if (CtdlGetRoom(&sc->room, room_to_spool->name) != 0) {
201 syslog(LOG_CRIT, "ERROR: cannot load <%s>\n", room_to_spool->name);
205 if (sc->room.QRhighest <= sc->lastsent)
207 syslog(LOG_DEBUG, "nothing to do for <%s>\n", room_to_spool->name);
212 begin_critical_section(S_NETCONFIGS);
213 if (sc->RNCfg == NULL)
214 sc->RNCfg = CtdlGetNetCfgForRoom(sc->room.QRnumber);
216 if (!HaveSpoolConfig(sc->RNCfg))
218 end_critical_section(S_NETCONFIGS);
220 /* nothing to do for this room... */
224 /* Now lets remember whats needed for the actual work... */
226 for (i=0; i < 4; i++)
228 aggregate_recipients(&sc->Users[SpoolCfgs[i]],
234 if (StrLength(sc->RNCfg->Sender) > 0)
235 sc->Users[roommailalias] = NewStrBufDup(sc->RNCfg->Sender);
236 end_critical_section(S_NETCONFIGS);
243 void CalcListID(SpoolControl *sc)
248 struct CitContext *CCC = CC;
249 char filename[PATH_MAX];
250 #define MAX_LISTIDLENGTH 150
252 assoc_file_name(filename, sizeof filename, &sc->room, ctdl_info_dir);
253 fd = open(filename, 0);
258 if ((fstat(fd, &stbuf) == 0) &&
261 sc->RoomInfo = NewStrBufPlain(NULL, stbuf.st_size + 1);
262 StrBufReadBLOB(sc->RoomInfo, &fd, 0, stbuf.st_size, &err);
267 sc->ListID = NewStrBufPlain(NULL, 1024);
268 if (StrLength(sc->RoomInfo) > 0)
270 const char *Pos = NULL;
271 StrBufSipLine(sc->ListID, sc->RoomInfo, &Pos);
273 if (StrLength(sc->ListID) > MAX_LISTIDLENGTH)
275 StrBufCutAt(sc->ListID, MAX_LISTIDLENGTH, NULL);
276 StrBufAppendBufPlain(sc->ListID, HKEY("..."), 0);
278 StrBufAsciify(sc->ListID, ' ');
282 StrBufAppendBufPlain(sc->ListID, CCC->room.QRname, -1, 0);
285 StrBufAppendBufPlain(sc->ListID, HKEY("<"), 0);
286 RoomName = NewStrBufPlain (sc->room.QRname, -1);
287 StrBufAsciify(RoomName, '_');
288 StrBufReplaceChars(RoomName, ' ', '_');
290 if (StrLength(sc->Users[roommailalias]) > 0)
295 Pos = StrLength(sc->ListID);
296 StrBufAppendBuf(sc->ListID, sc->Users[roommailalias], 0);
297 AtPos = strchr(ChrPtr(sc->ListID) + Pos, '@');
301 StrBufPeek(sc->ListID, AtPos, 0, '.');
306 StrBufAppendBufPlain(sc->ListID, HKEY("room_"), 0);
307 StrBufAppendBuf(sc->ListID, RoomName, 0);
308 StrBufAppendBufPlain(sc->ListID, HKEY("."), 0);
309 StrBufAppendBufPlain(sc->ListID, config.c_fqdn, -1, 0);
312 * roomname <Room-Number.list-id.fqdn>
313 * according to rfc2919.txt it only has to be a uniq identifier
314 * under the domain of the system;
315 * in general MUAs use it to calculate the reply address nowadays.
318 StrBufAppendBufPlain(sc->ListID, HKEY(">"), 0);
320 if (StrLength(sc->Users[roommailalias]) == 0)
322 sc->Users[roommailalias] = NewStrBuf();
324 StrBufAppendBufPlain(sc->Users[roommailalias], HKEY("room_"), 0);
325 StrBufAppendBuf(sc->Users[roommailalias], RoomName, 0);
326 StrBufAppendBufPlain(sc->Users[roommailalias], HKEY("@"), 0);
327 StrBufAppendBufPlain(sc->Users[roommailalias], config.c_fqdn, -1, 0);
329 StrBufLowerCase(sc->Users[roommailalias]);
332 FreeStrBuf(&RoomName);
337 * Batch up and send all outbound traffic from the current room
339 void network_spoolout_room(SpoolControl *sc)
341 struct CitContext *CCC = CC;
347 * If the room doesn't exist, don't try to perform its networking tasks.
348 * Normally this should never happen, but once in a while maybe a room gets
349 * queued for networking and then deleted before it can happen.
351 memcpy (&CCC->room, &sc->room, sizeof(ctdlroom));
353 syslog(LOG_INFO, "Networking started for <%s>\n", CCC->room.QRname);
355 /* If there are digest recipients, we have to build a digest */
356 if (sc->Users[digestrecp] != NULL) {
357 sc->digestfp = tmpfile();
358 fprintf(sc->digestfp, "Content-type: text/plain\n\n");
363 /* remember where we started... */
364 lastsent = sc->lastsent;
366 /* Do something useful */
367 CtdlForEachMessage(MSGS_GT, sc->lastsent, NULL, NULL, NULL,
368 network_spool_msg, sc);
370 /* If we wrote a digest, deliver it and then close it */
371 if (StrLength(sc->Users[roommailalias]) > 0)
374 len = StrLength(sc->Users[roommailalias]);
375 if (len + 1 > sizeof(buf))
376 len = sizeof(buf) - 1;
377 memcpy(buf, ChrPtr(sc->Users[roommailalias]), len);
382 snprintf(buf, sizeof buf, "room_%s@%s",
383 CCC->room.QRname, config.c_fqdn);
386 for (i=0; buf[i]; ++i) {
387 buf[i] = tolower(buf[i]);
388 if (isspace(buf[i])) buf[i] = '_';
390 if (sc->digestfp != NULL) {
391 fprintf(sc->digestfp,
392 " -----------------------------------"
393 "------------------------------------"
395 "You are subscribed to the '%s' "
397 "To post to the list: %s\n",
398 CCC->room.QRname, buf
400 network_deliver_digest(sc); /* deliver and close */
403 /* Now rewrite the config file */
404 if (sc->lastsent != lastsent)
406 begin_critical_section(S_NETCONFIGS);
407 sc->RNCfg = CtdlGetNetCfgForRoom(sc->room.QRnumber);
409 sc->RNCfg->lastsent = sc->lastsent;
410 sc->RNCfg->changed = 1;
411 end_critical_section(S_NETCONFIGS);
416 * Process a buffer containing a single message from a single file
417 * from the inbound queue
419 void network_process_buffer(char *buffer, long size, HashList *working_ignetcfg, HashList *the_netmap, int *netmap_changed)
422 struct CitContext *CCC = CC;
424 struct CtdlMessage *msg = NULL;
427 recptypes *recp = NULL;
428 char target_room[ROOMNAMELEN];
429 struct ser_ret sermsg;
430 char filename[PATH_MAX];
432 const StrBuf *nexthop = NULL;
433 unsigned char firstbyte;
434 unsigned char lastbyte;
436 QN_syslog(LOG_DEBUG, "network_process_buffer() processing %ld bytes\n", size);
438 /* Validate just a little bit. First byte should be FF and * last byte should be 00. */
439 firstbyte = buffer[0];
440 lastbyte = buffer[size-1];
441 if ( (firstbyte != 255) || (lastbyte != 0) ) {
442 QN_syslog(LOG_ERR, "Corrupt message ignored. Length=%ld, firstbyte = %d, lastbyte = %d\n",
443 size, firstbyte, lastbyte);
447 /* Set default target room to trash */
448 strcpy(target_room, TWITROOM);
450 /* Load the message into memory */
451 msg = (struct CtdlMessage *) malloc(sizeof(struct CtdlMessage));
452 memset(msg, 0, sizeof(struct CtdlMessage));
453 msg->cm_magic = CTDLMESSAGE_MAGIC;
454 msg->cm_anon_type = buffer[1];
455 msg->cm_format_type = buffer[2];
457 for (pos = 3; pos < size; ++pos) {
459 len = strlen(buffer + pos + 1);
460 CM_SetField(msg, field, buffer + pos + 1, len);
464 /* Check for message routing */
465 if (!CM_IsEmpty(msg, eDestination)) {
466 if (strcasecmp(msg->cm_fields[eDestination], config.c_nodename)) {
468 /* route the message */
469 Buf = NewStrBufPlain(CM_KEY(msg,eDestination));
470 if (CtdlIsValidNode(&nexthop,
476 Netmap_AddMe(msg, HKEY("unknown_user"));
478 /* serialize the message */
479 CtdlSerializeMessage(&sermsg, msg);
482 if (StrLength(nexthop) == 0) {
493 QN_syslog(LOG_DEBUG, "Appending to %s\n", filename);
494 fp = fopen(filename, "ab");
496 fwrite(sermsg.ser, sermsg.len, 1, fp);
500 QN_syslog(LOG_ERR, "%s: %s\n", filename, strerror(errno));
508 else { /* invalid destination node name */
512 "A message you sent could not be delivered due to an invalid destination node"
513 " name. Please check the address and try sending the message again.\n");
522 * Check to see if we already have a copy of this message, and
523 * abort its processing if so. (We used to post a warning to Aide>
524 * every time this happened, but the network is now so densely
525 * connected that it's inevitable.)
527 if (network_usetable(msg) != 0) {
532 /* Learn network topology from the path */
533 if (!CM_IsEmpty(msg, eNodeName) && !CM_IsEmpty(msg, eMessagePath)) {
534 NetworkLearnTopology(msg->cm_fields[eNodeName],
535 msg->cm_fields[eMessagePath],
540 /* Is the sending node giving us a very persuasive suggestion about
541 * which room this message should be saved in? If so, go with that.
543 if (!CM_IsEmpty(msg, eRemoteRoom)) {
544 safestrncpy(target_room, msg->cm_fields[eRemoteRoom], sizeof target_room);
547 /* Otherwise, does it have a recipient? If so, validate it... */
548 else if (!CM_IsEmpty(msg, eRecipient)) {
549 recp = validate_recipients(msg->cm_fields[eRecipient], NULL, 0);
550 if (recp != NULL) if (recp->num_error != 0) {
552 "A message you sent could not be delivered due to an invalid address.\n"
553 "Please check the address and try sending the message again.\n");
555 free_recipients(recp);
556 QNM_syslog(LOG_DEBUG, "Bouncing message due to invalid recipient address.\n");
559 strcpy(target_room, ""); /* no target room if mail */
562 /* Our last shot at finding a home for this message is to see if
563 * it has the eOriginalRoom (O) field (Originating room) set.
565 else if (!CM_IsEmpty(msg, eOriginalRoom)) {
566 safestrncpy(target_room, msg->cm_fields[eOriginalRoom], sizeof target_room);
569 /* Strip out fields that are only relevant during transit */
570 CM_FlushField(msg, eDestination);
571 CM_FlushField(msg, eRemoteRoom);
573 /* save the message into a room */
574 if (PerformNetprocHooks(msg, target_room) == 0) {
575 msg->cm_flags = CM_SKIP_HOOKS;
576 CtdlSubmitMsg(msg, recp, target_room, 0);
579 free_recipients(recp);
584 * Process a single message from a single file from the inbound queue
586 void network_process_message(FILE *fp,
589 HashList *working_ignetcfg,
590 HashList *the_netmap,
597 hold_pos = ftell(fp);
598 size = msgend - msgstart + 1;
599 buffer = malloc(size);
600 if (buffer != NULL) {
601 fseek(fp, msgstart, SEEK_SET);
602 if (fread(buffer, size, 1, fp) > 0) {
603 network_process_buffer(buffer,
612 fseek(fp, hold_pos, SEEK_SET);
617 * Process a single file from the inbound queue
619 void network_process_file(char *filename,
620 HashList *working_ignetcfg,
621 HashList *the_netmap,
624 struct CitContext *CCC = CC;
626 long msgstart = (-1L);
632 fp = fopen(filename, "rb");
634 QN_syslog(LOG_CRIT, "Error opening %s: %s\n", filename, strerror(errno));
638 fseek(fp, 0L, SEEK_END);
639 QN_syslog(LOG_INFO, "network: processing %ld bytes from %s\n", ftell(fp), filename);
642 /* Look for messages in the data stream and break them out */
643 while (ch = getc(fp), ch >= 0) {
646 if (msgstart >= 0L) {
648 network_process_message(fp,
663 if (msgstart >= 0L) {
664 network_process_message(fp,
675 "network: processed %d messages in %s\n",
685 * Process anything in the inbound queue
687 void network_do_spoolin(HashList *working_ignetcfg, HashList *the_netmap, int *netmap_changed)
689 struct CitContext *CCC = CC;
692 struct dirent *filedir_entry;
694 char filename[PATH_MAX];
695 static time_t last_spoolin_mtime = 0L;
700 * Check the spoolin directory's modification time. If it hasn't
701 * been touched, we don't need to scan it.
703 if (stat(ctdl_netin_dir, &statbuf)) return;
704 if (statbuf.st_mtime == last_spoolin_mtime) {
705 QNM_syslog(LOG_DEBUG, "network: nothing in inbound queue\n");
708 last_spoolin_mtime = statbuf.st_mtime;
709 QNM_syslog(LOG_DEBUG, "network: processing inbound queue\n");
712 * Ok, there's something interesting in there, so scan it.
714 dp = opendir(ctdl_netin_dir);
715 if (dp == NULL) return;
717 d = (struct dirent *)malloc(offsetof(struct dirent, d_name) + PATH_MAX + 1);
723 while ((readdir_r(dp, d, &filedir_entry) == 0) &&
724 (filedir_entry != NULL))
726 #ifdef _DIRENT_HAVE_D_NAMLEN
727 d_namelen = filedir_entry->d_namlen;
730 d_namelen = strlen(filedir_entry->d_name);
733 #ifdef _DIRENT_HAVE_D_TYPE
734 d_type = filedir_entry->d_type;
738 if ((d_namelen > 1) && filedir_entry->d_name[d_namelen - 1] == '~')
739 continue; /* Ignore backup files... */
741 if ((d_namelen == 1) &&
742 (filedir_entry->d_name[0] == '.'))
745 if ((d_namelen == 2) &&
746 (filedir_entry->d_name[0] == '.') &&
747 (filedir_entry->d_name[1] == '.'))
750 if (d_type == DT_UNKNOWN) {
758 filedir_entry->d_name);
760 if (lstat(path, &s) == 0) {
761 d_type = IFTODT(s.st_mode);
769 case DT_LNK: /* TODO: check whether its a file or a directory */
777 network_process_file(filename,
789 * Step 1: consolidate files in the outbound queue into one file per neighbor node
790 * Step 2: delete any files in the outbound queue that were for neighbors who no longer exist.
792 void network_consolidate_spoolout(HashList *working_ignetcfg, HashList *the_netmap)
794 struct CitContext *CCC = CC;
800 struct dirent *filedir_entry;
802 char spooloutfilename[PATH_MAX];
803 char filename[PATH_MAX];
804 const StrBuf *nexthop;
812 /* Step 1: consolidate files in the outbound queue into one file per neighbor node */
813 d = (struct dirent *)malloc(offsetof(struct dirent, d_name) + PATH_MAX + 1);
814 if (d == NULL) return;
816 dp = opendir(ctdl_netout_dir);
822 NextHop = NewStrBuf();
823 memset(&IOB, 0, sizeof(IOBuffer));
824 memset(&FDIO, 0, sizeof(FDIOBuffer));
827 while ((readdir_r(dp, d, &filedir_entry) == 0) &&
828 (filedir_entry != NULL))
830 #ifdef _DIRENT_HAVE_D_NAMLEN
831 d_namelen = filedir_entry->d_namlen;
834 d_namelen = strlen(filedir_entry->d_name);
837 #ifdef _DIRENT_HAVE_D_TYPE
838 d_type = filedir_entry->d_type;
842 if (d_type == DT_DIR)
845 if ((d_namelen > 1) && filedir_entry->d_name[d_namelen - 1] == '~')
846 continue; /* Ignore backup files... */
848 if ((d_namelen == 1) &&
849 (filedir_entry->d_name[0] == '.'))
852 if ((d_namelen == 2) &&
853 (filedir_entry->d_name[0] == '.') &&
854 (filedir_entry->d_name[1] == '.'))
857 pch = strchr(filedir_entry->d_name, '@');
865 filedir_entry->d_name);
868 filedir_entry->d_name,
869 pch - filedir_entry->d_name);
871 snprintf(spooloutfilename,
872 sizeof spooloutfilename,
877 QN_syslog(LOG_DEBUG, "Consolidate %s to %s\n", filename, ChrPtr(NextHop));
878 if (CtdlNetworkTalkingTo(SKEY(NextHop), NTT_CHECK)) {
881 "Currently online with %s - skipping for now\n",
889 const char *err = NULL;
890 CtdlNetworkTalkingTo(SKEY(NextHop), NTT_ADD);
892 infd = open(filename, O_RDONLY);
896 "failed to open %s for reading due to %s; skipping.\n",
897 filename, strerror(errno)
899 CtdlNetworkTalkingTo(SKEY(NextHop), NTT_REMOVE);
903 outfd = open(spooloutfilename,
904 O_EXCL|O_CREAT|O_NONBLOCK|O_WRONLY,
908 outfd = open(spooloutfilename,
909 O_EXCL|O_NONBLOCK|O_WRONLY,
915 "failed to open %s for reading due to %s; skipping.\n",
916 spooloutfilename, strerror(errno)
919 CtdlNetworkTalkingTo(SKEY(NextHop), NTT_REMOVE);
923 dsize = lseek(outfd, 0, SEEK_END);
924 lseek(outfd, -dsize, SEEK_SET);
926 fstat(infd, &statbuf);
927 fsize = statbuf.st_size;
929 fsize = lseek(infd, 0, SEEK_END);
932 FDIOBufferInit(&FDIO, &IOB, outfd, fsize + dsize);
933 FDIO.ChunkSendRemain = fsize;
934 FDIO.TotalSentAlready = dsize;
937 do {} while ((FileMoveChunked(&FDIO, &err) > 0) && (err == NULL));
941 "Spoolfile %s now "SIZE_T_FMT" k\n",
949 "failed to append to %s [%s]; rolling back..\n",
950 spooloutfilename, strerror(errno)
952 /* whoops partial append?? truncate spooloutfilename again! */
953 ftruncate(outfd, dsize);
955 FDIOBufferDelete(&FDIO);
958 CtdlNetworkTalkingTo(SKEY(NextHop), NTT_REMOVE);
964 FreeStrBuf(&NextHop);
966 "skipping Spoolcleanup because of %d files unprocessed.\n",
973 /* Step 2: delete any files in the outbound queue that were for neighbors who no longer exist */
974 dp = opendir(ctdl_netout_dir);
976 FreeStrBuf(&NextHop);
981 while ((readdir_r(dp, d, &filedir_entry) == 0) &&
982 (filedir_entry != NULL))
984 #ifdef _DIRENT_HAVE_D_NAMLEN
985 d_namelen = filedir_entry->d_namlen;
988 d_namelen = strlen(filedir_entry->d_name);
991 #ifdef _DIRENT_HAVE_D_TYPE
992 d_type = filedir_entry->d_type;
996 if (d_type == DT_DIR)
999 if ((d_namelen == 1) &&
1000 (filedir_entry->d_name[0] == '.'))
1003 if ((d_namelen == 2) &&
1004 (filedir_entry->d_name[0] == '.') &&
1005 (filedir_entry->d_name[1] == '.'))
1008 pch = strchr(filedir_entry->d_name, '@');
1009 if (pch == NULL) /* no @ in name? consolidated file. */
1012 StrBufPlain(NextHop,
1013 filedir_entry->d_name,
1014 pch - filedir_entry->d_name);
1020 filedir_entry->d_name
1023 i = CtdlIsValidNode(&nexthop,
1029 if ( (i != 0) || (StrLength(nexthop) > 0) ) {
1033 FreeStrBuf(&NextHop);
1038 void free_spoolcontrol_struct(SpoolControl **sc)
1040 free_spoolcontrol_struct_members(*sc);
1045 void free_spoolcontrol_struct_members(SpoolControl *sc)
1048 FreeStrBuf(&sc->RoomInfo);
1049 FreeStrBuf(&sc->ListID);
1050 for (i = 0; i < maxRoomNetCfg; i++)
1051 FreeStrBuf(&sc->Users[i]);
1057 * It's ok if these directories already exist. Just fail silently.
1059 void create_spool_dirs(void) {
1060 if ((mkdir(ctdl_spool_dir, 0700) != 0) && (errno != EEXIST))
1061 syslog(LOG_EMERG, "unable to create directory [%s]: %s", ctdl_spool_dir, strerror(errno));
1062 if (chown(ctdl_spool_dir, CTDLUID, (-1)) != 0)
1063 syslog(LOG_EMERG, "unable to set the access rights for [%s]: %s", ctdl_spool_dir, strerror(errno));
1064 if ((mkdir(ctdl_netin_dir, 0700) != 0) && (errno != EEXIST))
1065 syslog(LOG_EMERG, "unable to create directory [%s]: %s", ctdl_netin_dir, strerror(errno));
1066 if (chown(ctdl_netin_dir, CTDLUID, (-1)) != 0)
1067 syslog(LOG_EMERG, "unable to set the access rights for [%s]: %s", ctdl_netin_dir, strerror(errno));
1068 if ((mkdir(ctdl_nettmp_dir, 0700) != 0) && (errno != EEXIST))
1069 syslog(LOG_EMERG, "unable to create directory [%s]: %s", ctdl_nettmp_dir, strerror(errno));
1070 if (chown(ctdl_nettmp_dir, CTDLUID, (-1)) != 0)
1071 syslog(LOG_EMERG, "unable to set the access rights for [%s]: %s", ctdl_nettmp_dir, strerror(errno));
1072 if ((mkdir(ctdl_netout_dir, 0700) != 0) && (errno != EEXIST))
1073 syslog(LOG_EMERG, "unable to create directory [%s]: %s", ctdl_netout_dir, strerror(errno));
1074 if (chown(ctdl_netout_dir, CTDLUID, (-1)) != 0)
1075 syslog(LOG_EMERG, "unable to set the access rights for [%s]: %s", ctdl_netout_dir, strerror(errno));
1079 * Module entry point
1081 CTDL_MODULE_INIT(network_spool)
1085 CtdlREGISTERRoomCfgType(subpending, ParseSubPendingLine, 0, 5, SerializeGeneric, DeleteGenericCfgLine); /// todo: move this to mailinglist manager
1086 CtdlREGISTERRoomCfgType(unsubpending, ParseUnSubPendingLine, 0, 4, SerializeGeneric, DeleteGenericCfgLine); /// todo: move this to mailinglist manager
1087 CtdlREGISTERRoomCfgType(lastsent, ParseLastSent, 1, 1, SerializeLastSent, DeleteLastSent);
1088 CtdlREGISTERRoomCfgType(ignet_push_share, ParseGeneric, 0, 2, SerializeGeneric, DeleteGenericCfgLine); // [remotenode|remoteroomname (optional)]// todo: move this to the ignet client
1089 CtdlREGISTERRoomCfgType(listrecp, ParseGeneric, 0, 1, SerializeGeneric, DeleteGenericCfgLine);
1090 CtdlREGISTERRoomCfgType(digestrecp, ParseGeneric, 0, 1, SerializeGeneric, DeleteGenericCfgLine);
1091 CtdlREGISTERRoomCfgType(participate, ParseGeneric, 0, 1, SerializeGeneric, DeleteGenericCfgLine);
1092 CtdlREGISTERRoomCfgType(roommailalias, ParseRoomAlias, 0, 1, SerializeGeneric, DeleteGenericCfgLine);
1094 create_spool_dirs();
1095 //////todo CtdlRegisterCleanupHook(destroy_network_queue_room);
1097 return "network_spool";