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 as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * ** NOTE ** A word on the S_NETCONFIGS semaphore:
22 * This is a fairly high-level type of critical section. It ensures that no
23 * two threads work on the netconfigs files at the same time. Since we do
24 * so many things inside these, here are the rules:
25 * 1. begin_critical_section(S_NETCONFIGS) *before* begin_ any others.
26 * 2. Do *not* perform any I/O with the client during these sections.
31 * Duration of time (in seconds) after which pending list subscribe/unsubscribe
32 * requests that have not been confirmed will be deleted.
34 #define EXP 259200 /* three days */
46 #include <sys/types.h>
48 #if TIME_WITH_SYS_TIME
49 # include <sys/time.h>
53 # include <sys/time.h>
61 # if HAVE_SYS_SYSCALL_H
62 # include <sys/syscall.h>
69 #include <libcitadel.h>
72 #include "citserver.h"
78 #include "internet_addressing.h"
79 #include "serv_network.h"
80 #include "clientsocket.h"
82 #include "citadel_dirs.h"
90 #include "netconfig.h"
93 #include "ctdl_module.h"
98 int read_spoolcontrol_file(SpoolControl **scc, char *filename)
104 char roomname[ROOMNAMELEN];
107 int skipthisline = 0;
108 namelist *nptr = NULL;
109 maplist *mptr = NULL;
112 fp = fopen(filename, "r");
116 sc = malloc(sizeof(SpoolControl));
117 memset(sc, 0, sizeof(SpoolControl));
120 while (fgets(buf, sizeof buf, fp) != NULL) {
121 buf[strlen(buf)-1] = 0;
123 extract_token(instr, buf, 0, '|', sizeof instr);
124 if (!strcasecmp(instr, strof(lastsent))) {
125 sc->lastsent = extract_long(buf, 1);
127 else if (!strcasecmp(instr, strof(listrecp))) {
129 malloc(sizeof(namelist));
130 nptr->next = sc->listrecps;
131 extract_token(nptr->name, buf, 1, '|', sizeof nptr->name);
132 sc->listrecps = nptr;
134 else if (!strcasecmp(instr, strof(participate))) {
136 malloc(sizeof(namelist));
137 nptr->next = sc->participates;
138 extract_token(nptr->name, buf, 1, '|', sizeof nptr->name);
139 sc->participates = nptr;
141 else if (!strcasecmp(instr, strof(digestrecp))) {
143 malloc(sizeof(namelist));
144 nptr->next = sc->digestrecps;
145 extract_token(nptr->name, buf, 1, '|', sizeof nptr->name);
146 sc->digestrecps = nptr;
148 else if (!strcasecmp(instr, strof(ignet_push_share))) {
149 extract_token(nodename, buf, 1, '|', sizeof nodename);
150 extract_token(roomname, buf, 2, '|', sizeof roomname);
151 mptr = (maplist *) malloc(sizeof(maplist));
152 mptr->next = sc->ignet_push_shares;
153 strcpy(mptr->remote_nodename, nodename);
154 strcpy(mptr->remote_roomname, roomname);
155 sc->ignet_push_shares = mptr;
158 /* Preserve 'other' lines ... *unless* they happen to
159 * be subscribe/unsubscribe pendings with expired
163 if (!strncasecmp(buf, strof(subpending)"|", 11)) {
164 if (time(NULL) - extract_long(buf, 4) > EXP) {
168 if (!strncasecmp(buf, strof(unsubpending)"|", 13)) {
169 if (time(NULL) - extract_long(buf, 3) > EXP) {
174 if (skipthisline == 0) {
175 linesize = strlen(buf);
176 sc->misc = realloc(sc->misc,
177 (miscsize + linesize + 2) );
178 sprintf(&sc->misc[miscsize], "%s\n", buf);
179 miscsize = miscsize + linesize + 1;
189 void free_spoolcontrol_struct(SpoolControl **scc)
192 namelist *nptr = NULL;
193 maplist *mptr = NULL;
196 while (sc->listrecps != NULL) {
197 nptr = sc->listrecps->next;
199 sc->listrecps = nptr;
201 /* Do the same for digestrecps */
202 while (sc->digestrecps != NULL) {
203 nptr = sc->digestrecps->next;
204 free(sc->digestrecps);
205 sc->digestrecps = nptr;
207 /* Do the same for participates */
208 while (sc->participates != NULL) {
209 nptr = sc->participates->next;
210 free(sc->participates);
211 sc->participates = nptr;
213 while (sc->ignet_push_shares != NULL) {
214 mptr = sc->ignet_push_shares->next;
215 free(sc->ignet_push_shares);
216 sc->ignet_push_shares = mptr;
223 int writenfree_spoolcontrol_file(SpoolControl **scc, char *filename)
225 char tempfilename[PATH_MAX];
228 namelist *nptr = NULL;
229 maplist *mptr = NULL;
233 long reltid; /* if we don't have SYS_gettid, use "random" value */
237 len = strlen(filename);
238 memcpy(tempfilename, filename, len + 1);
241 #if defined(HAVE_SYSCALL_H) && defined (SYS_gettid)
242 reltid = syscall(SYS_gettid);
244 gettimeofday(&tv, NULL);
245 /* Promote to time_t; types differ on some OSes (like darwin) */
246 unixtime = tv.tv_sec;
248 sprintf(tempfilename + len, ".%ld-%ld", reltid, unixtime);
251 TmpFD = open(tempfilename, O_CREAT|O_EXCL|O_RDWR, S_IRUSR|S_IWUSR);
253 if ((TmpFD < 0) || (errno != 0)) {
254 syslog(LOG_CRIT, "ERROR: cannot open %s: %s\n",
255 filename, strerror(errno));
256 free_spoolcontrol_struct(scc);
257 unlink(tempfilename);
260 fchown(TmpFD, config.c_ctdluid, 0);
261 StrBufAppendPrintf(Cfg, "lastsent|%ld\n", sc->lastsent);
263 /* Write out the listrecps while freeing from memory at the
264 * same time. Am I clever or what? :)
266 while (sc->listrecps != NULL) {
267 StrBufAppendPrintf(Cfg, "listrecp|%s\n", sc->listrecps->name);
268 nptr = sc->listrecps->next;
270 sc->listrecps = nptr;
272 /* Do the same for digestrecps */
273 while (sc->digestrecps != NULL) {
274 StrBufAppendPrintf(Cfg, "digestrecp|%s\n", sc->digestrecps->name);
275 nptr = sc->digestrecps->next;
276 free(sc->digestrecps);
277 sc->digestrecps = nptr;
279 /* Do the same for participates */
280 while (sc->participates != NULL) {
281 StrBufAppendPrintf(Cfg, "participate|%s\n", sc->participates->name);
282 nptr = sc->participates->next;
283 free(sc->participates);
284 sc->participates = nptr;
286 while (sc->ignet_push_shares != NULL) {
287 StrBufAppendPrintf(Cfg, "ignet_push_share|%s", sc->ignet_push_shares->remote_nodename);
288 if (!IsEmptyStr(sc->ignet_push_shares->remote_roomname)) {
289 StrBufAppendPrintf(Cfg, "|%s", sc->ignet_push_shares->remote_roomname);
291 StrBufAppendPrintf(Cfg, "\n");
292 mptr = sc->ignet_push_shares->next;
293 free(sc->ignet_push_shares);
294 sc->ignet_push_shares = mptr;
296 if (sc->misc != NULL) {
297 StrBufAppendBufPlain(Cfg, sc->misc, -1, 0);
301 rc = write(TmpFD, ChrPtr(Cfg), StrLength(Cfg));
302 if ((rc >=0 ) && (rc == StrLength(Cfg)))
305 rename(tempfilename, filename);
309 "unable to write %s; [%s]; not enough space on the disk?\n",
313 unlink(tempfilename);
321 int is_recipient(SpoolControl *sc, const char *Name)
327 nptr = sc->listrecps;
328 while (nptr != NULL) {
329 if (strncmp(Name, nptr->name, len)==0)
333 /* Do the same for digestrecps */
334 nptr = sc->digestrecps;
335 while (nptr != NULL) {
336 if (strncmp(Name, nptr->name, len)==0)
340 /* Do the same for participates */
341 nptr = sc->participates;
342 while (nptr != NULL) {
343 if (strncmp(Name, nptr->name, len)==0)
352 * Batch up and send all outbound traffic from the current room
354 void network_spoolout_room(RoomProcList *room_to_spool,
355 HashList *working_ignetcfg,
356 HashList *the_netmap)
359 char filename[PATH_MAX];
364 * If the room doesn't exist, don't try to perform its networking tasks.
365 * Normally this should never happen, but once in a while maybe a room gets
366 * queued for networking and then deleted before it can happen.
368 if (CtdlGetRoom(&CC->room, room_to_spool->name) != 0) {
369 syslog(LOG_CRIT, "ERROR: cannot load <%s>\n", room_to_spool->name);
373 assoc_file_name(filename, sizeof filename, &CC->room, ctdl_netcfg_dir);
374 begin_critical_section(S_NETCONFIGS);
376 /* Only do net processing for rooms that have netconfigs */
377 if (!read_spoolcontrol_file(&sc, filename))
379 end_critical_section(S_NETCONFIGS);
382 syslog(LOG_INFO, "Networking started for <%s>\n", CC->room.QRname);
384 sc->working_ignetcfg = working_ignetcfg;
385 sc->the_netmap = the_netmap;
387 /* If there are digest recipients, we have to build a digest */
388 if (sc->digestrecps != NULL) {
389 sc->digestfp = tmpfile();
390 fprintf(sc->digestfp, "Content-type: text/plain\n\n");
393 /* Do something useful */
394 CtdlForEachMessage(MSGS_GT, sc->lastsent, NULL, NULL, NULL,
395 network_spool_msg, sc);
397 /* If we wrote a digest, deliver it and then close it */
398 snprintf(buf, sizeof buf, "room_%s@%s",
399 CC->room.QRname, config.c_fqdn);
400 for (i=0; buf[i]; ++i) {
401 buf[i] = tolower(buf[i]);
402 if (isspace(buf[i])) buf[i] = '_';
404 if (sc->digestfp != NULL) {
405 fprintf(sc->digestfp, " -----------------------------------"
406 "------------------------------------"
408 "You are subscribed to the '%s' "
410 "To post to the list: %s\n",
413 network_deliver_digest(sc); /* deliver and close */
416 /* Now rewrite the config file */
417 writenfree_spoolcontrol_file(&sc, filename);
418 end_critical_section(S_NETCONFIGS);
422 * Process a buffer containing a single message from a single file
423 * from the inbound queue
425 void network_process_buffer(char *buffer, long size, HashList *working_ignetcfg, HashList *the_netmap, int *netmap_changed)
427 struct CitContext *CCC = CC;
429 struct CtdlMessage *msg = NULL;
432 struct recptypes *recp = NULL;
433 char target_room[ROOMNAMELEN];
434 struct ser_ret sermsg;
435 char *oldpath = NULL;
436 char filename[PATH_MAX];
438 const StrBuf *nexthop = NULL;
439 unsigned char firstbyte;
440 unsigned char lastbyte;
442 QN_syslog(LOG_DEBUG, "network_process_buffer() processing %ld bytes\n", size);
444 /* Validate just a little bit. First byte should be FF and * last byte should be 00. */
445 firstbyte = buffer[0];
446 lastbyte = buffer[size-1];
447 if ( (firstbyte != 255) || (lastbyte != 0) ) {
448 QN_syslog(LOG_ERR, "Corrupt message ignored. Length=%ld, firstbyte = %d, lastbyte = %d\n",
449 size, firstbyte, lastbyte);
453 /* Set default target room to trash */
454 strcpy(target_room, TWITROOM);
456 /* Load the message into memory */
457 msg = (struct CtdlMessage *) malloc(sizeof(struct CtdlMessage));
458 memset(msg, 0, sizeof(struct CtdlMessage));
459 msg->cm_magic = CTDLMESSAGE_MAGIC;
460 msg->cm_anon_type = buffer[1];
461 msg->cm_format_type = buffer[2];
463 for (pos = 3; pos < size; ++pos) {
465 msg->cm_fields[field] = strdup(&buffer[pos+1]);
466 pos = pos + strlen(&buffer[(int)pos]);
469 /* Check for message routing */
470 if (msg->cm_fields['D'] != NULL) {
471 if (strcasecmp(msg->cm_fields['D'], config.c_nodename)) {
473 /* route the message */
474 Buf = NewStrBufPlain(msg->cm_fields['D'], -1);
475 if (is_valid_node(&nexthop,
481 /* prepend our node to the path */
482 if (msg->cm_fields['P'] != NULL) {
483 oldpath = msg->cm_fields['P'];
484 msg->cm_fields['P'] = NULL;
487 oldpath = strdup("unknown_user");
489 size = strlen(oldpath) + SIZ;
490 msg->cm_fields['P'] = malloc(size);
491 snprintf(msg->cm_fields['P'], size, "%s!%s",
492 config.c_nodename, oldpath);
495 /* serialize the message */
496 serialize_message(&sermsg, msg);
499 if (StrLength(nexthop) == 0) {
510 QN_syslog(LOG_DEBUG, "Appending to %s\n", filename);
511 fp = fopen(filename, "ab");
513 fwrite(sermsg.ser, sermsg.len, 1, fp);
517 QN_syslog(LOG_ERR, "%s: %s\n", filename, strerror(errno));
520 CtdlFreeMessage(msg);
525 else { /* invalid destination node name */
529 "A message you sent could not be delivered due to an invalid destination node"
530 " name. Please check the address and try sending the message again.\n");
539 * Check to see if we already have a copy of this message, and
540 * abort its processing if so. (We used to post a warning to Aide>
541 * every time this happened, but the network is now so densely
542 * connected that it's inevitable.)
544 if (network_usetable(msg) != 0) {
545 CtdlFreeMessage(msg);
549 /* Learn network topology from the path */
550 if ((msg->cm_fields['N'] != NULL) && (msg->cm_fields['P'] != NULL)) {
551 network_learn_topology(msg->cm_fields['N'],
557 /* Is the sending node giving us a very persuasive suggestion about
558 * which room this message should be saved in? If so, go with that.
560 if (msg->cm_fields['C'] != NULL) {
561 safestrncpy(target_room, msg->cm_fields['C'], sizeof target_room);
564 /* Otherwise, does it have a recipient? If so, validate it... */
565 else if (msg->cm_fields['R'] != NULL) {
566 recp = validate_recipients(msg->cm_fields['R'], NULL, 0);
567 if (recp != NULL) if (recp->num_error != 0) {
569 "A message you sent could not be delivered due to an invalid address.\n"
570 "Please check the address and try sending the message again.\n");
572 free_recipients(recp);
573 QNM_syslog(LOG_DEBUG, "Bouncing message due to invalid recipient address.\n");
576 strcpy(target_room, ""); /* no target room if mail */
579 /* Our last shot at finding a home for this message is to see if
580 * it has the O field (Originating room) set.
582 else if (msg->cm_fields['O'] != NULL) {
583 safestrncpy(target_room, msg->cm_fields['O'], sizeof target_room);
586 /* Strip out fields that are only relevant during transit */
587 if (msg->cm_fields['D'] != NULL) {
588 free(msg->cm_fields['D']);
589 msg->cm_fields['D'] = NULL;
591 if (msg->cm_fields['C'] != NULL) {
592 free(msg->cm_fields['C']);
593 msg->cm_fields['C'] = NULL;
596 /* save the message into a room */
597 if (PerformNetprocHooks(msg, target_room) == 0) {
598 msg->cm_flags = CM_SKIP_HOOKS;
599 CtdlSubmitMsg(msg, recp, target_room, 0);
601 CtdlFreeMessage(msg);
602 free_recipients(recp);
607 * Process a single message from a single file from the inbound queue
609 void network_process_message(FILE *fp,
612 HashList *working_ignetcfg,
613 HashList *the_netmap,
620 hold_pos = ftell(fp);
621 size = msgend - msgstart + 1;
622 buffer = malloc(size);
623 if (buffer != NULL) {
624 fseek(fp, msgstart, SEEK_SET);
625 if (fread(buffer, size, 1, fp) > 0) {
626 network_process_buffer(buffer,
635 fseek(fp, hold_pos, SEEK_SET);
640 * Process a single file from the inbound queue
642 void network_process_file(char *filename,
643 HashList *working_ignetcfg,
644 HashList *the_netmap,
647 struct CitContext *CCC = CC;
649 long msgstart = (-1L);
655 fp = fopen(filename, "rb");
657 QN_syslog(LOG_CRIT, "Error opening %s: %s\n", filename, strerror(errno));
661 fseek(fp, 0L, SEEK_END);
662 QN_syslog(LOG_INFO, "network: processing %ld bytes from %s\n", ftell(fp), filename);
665 /* Look for messages in the data stream and break them out */
666 while (ch = getc(fp), ch >= 0) {
669 if (msgstart >= 0L) {
671 network_process_message(fp,
685 if (msgstart >= 0L) {
686 network_process_message(fp,
700 * Process anything in the inbound queue
702 void network_do_spoolin(HashList *working_ignetcfg, HashList *the_netmap, int *netmap_changed)
704 struct CitContext *CCC = CC;
708 char filename[PATH_MAX];
709 static time_t last_spoolin_mtime = 0L;
712 * Check the spoolin directory's modification time. If it hasn't
713 * been touched, we don't need to scan it.
715 if (stat(ctdl_netin_dir, &statbuf)) return;
716 if (statbuf.st_mtime == last_spoolin_mtime) {
717 QNM_syslog(LOG_DEBUG, "network: nothing in inbound queue\n");
720 last_spoolin_mtime = statbuf.st_mtime;
721 QNM_syslog(LOG_DEBUG, "network: processing inbound queue\n");
724 * Ok, there's something interesting in there, so scan it.
726 dp = opendir(ctdl_netin_dir);
727 if (dp == NULL) return;
729 while (d = readdir(dp), d != NULL) {
730 if ((strcmp(d->d_name, ".")) && (strcmp(d->d_name, ".."))) {
737 network_process_file(filename,
748 * Step 1: consolidate files in the outbound queue into one file per neighbor node
749 * Step 2: delete any files in the outbound queue that were for neighbors who no longer exist.
751 void network_consolidate_spoolout(HashList *working_ignetcfg, HashList *the_netmap)
753 struct CitContext *CCC = CC;
759 struct dirent *filedir_entry;
761 char spooloutfilename[PATH_MAX];
762 char filename[PATH_MAX];
763 const StrBuf *nexthop;
769 /* Step 1: consolidate files in the outbound queue into one file per neighbor node */
770 d = (struct dirent *)malloc(offsetof(struct dirent, d_name) + PATH_MAX + 1);
771 if (d == NULL) return;
773 dp = opendir(ctdl_netout_dir);
779 NextHop = NewStrBuf();
780 memset(&IOB, 0, sizeof(IOBuffer));
781 memset(&FDIO, 0, sizeof(FDIOBuffer));
784 while ((readdir_r(dp, d, &filedir_entry) == 0) &&
785 (filedir_entry != NULL))
787 #ifdef _DIRENT_HAVE_D_NAMELEN
788 d_namelen = filedir_entry->d_namelen;
797 #define IFTODT(mode) (((mode) & 0170000) >> 12)
798 #define DTTOIF(dirtype) ((dirtype) << 12)
800 d_namelen = strlen(filedir_entry->d_name);
802 if ((d_namelen > 1) && filedir_entry->d_name[d_namelen - 1] == '~')
803 continue; /* Ignore backup files... */
805 if ((d_namelen == 1) &&
806 (filedir_entry->d_name[0] == '.'))
809 if ((d_namelen == 2) &&
810 (filedir_entry->d_name[0] == '.') &&
811 (filedir_entry->d_name[1] == '.'))
814 pch = strchr(filedir_entry->d_name, '@');
822 filedir_entry->d_name);
825 filedir_entry->d_name,
826 pch - filedir_entry->d_name);
828 snprintf(spooloutfilename,
829 sizeof spooloutfilename,
834 QN_syslog(LOG_DEBUG, "Consolidate %s to %s\n", filename, ChrPtr(NextHop));
835 if (network_talking_to(SKEY(NextHop), NTT_CHECK)) {
838 "Currently online with %s - skipping for now\n",
846 const char *err = NULL;
847 network_talking_to(SKEY(NextHop), NTT_ADD);
849 infd = open(filename, O_RDONLY);
853 "failed to open %s for reading due to %s; skipping.\n",
854 filename, strerror(errno)
856 network_talking_to(SKEY(NextHop), NTT_REMOVE);
860 outfd = open(spooloutfilename,
861 O_EXCL|O_CREAT|O_NONBLOCK|O_WRONLY,
865 outfd = open(spooloutfilename,
866 O_EXCL|O_NONBLOCK|O_WRONLY,
872 "failed to open %s for reading due to %s; skipping.\n",
873 spooloutfilename, strerror(errno)
876 network_talking_to(SKEY(NextHop), NTT_REMOVE);
880 dsize = lseek(outfd, 0, SEEK_END);
881 lseek(outfd, -dsize, SEEK_SET);
883 fstat(infd, &statbuf);
884 fsize = statbuf.st_size;
886 fsize = lseek(infd, 0, SEEK_END);
889 FDIOBufferInit(&FDIO, &IOB, outfd, fsize + dsize);
890 FDIO.ChunkSendRemain = fsize;
891 FDIO.TotalSentAlready = dsize;
894 do {} while ((FileMoveChunked(&FDIO, &err) > 0) && (err == NULL));
901 "failed to append to %s [%s]; rolling back..\n",
902 spooloutfilename, strerror(errno)
904 /* whoops partial append?? truncate spooloutfilename again! */
905 ftruncate(outfd, dsize);
907 FDIOBufferDelete(&FDIO);
910 network_talking_to(SKEY(NextHop), NTT_REMOVE);
916 FreeStrBuf(&NextHop);
918 "skipping Spoolcleanup because of %d files unprocessed.\n",
925 /* Step 2: delete any files in the outbound queue that were for neighbors who no longer exist */
926 dp = opendir(ctdl_netout_dir);
928 FreeStrBuf(&NextHop);
933 while ((readdir_r(dp, d, &filedir_entry) == 0) &&
934 (filedir_entry != NULL))
936 #ifdef _DIRENT_HAVE_D_NAMELEN
937 d_namelen = filedir_entry->d_namelen;
938 d_type = filedir_entry->d_type;
947 #define IFTODT(mode) (((mode) & 0170000) >> 12)
948 #define DTTOIF(dirtype) ((dirtype) << 12)
950 d_namelen = strlen(filedir_entry->d_name);
952 if ((d_namelen == 1) &&
953 (filedir_entry->d_name[0] == '.'))
956 if ((d_namelen == 2) &&
957 (filedir_entry->d_name[0] == '.') &&
958 (filedir_entry->d_name[1] == '.'))
961 pch = strchr(filedir_entry->d_name, '@');
962 if (pch == NULL) /* no @ in name? consolidated file. */
966 filedir_entry->d_name,
967 pch - filedir_entry->d_name);
973 filedir_entry->d_name
976 i = is_valid_node(&nexthop,
982 if ( (i != 0) || (StrLength(nexthop) > 0) ) {
986 FreeStrBuf(&NextHop);
995 * It's ok if these directories already exist. Just fail silently.
997 void create_spool_dirs(void) {
998 if ((mkdir(ctdl_spool_dir, 0700) != 0) && (errno != EEXIST))
999 syslog(LOG_EMERG, "unable to create directory [%s]: %s", ctdl_spool_dir, strerror(errno));
1000 if (chown(ctdl_spool_dir, CTDLUID, (-1)) != 0)
1001 syslog(LOG_EMERG, "unable to set the access rights for [%s]: %s", ctdl_spool_dir, strerror(errno));
1002 if ((mkdir(ctdl_netin_dir, 0700) != 0) && (errno != EEXIST))
1003 syslog(LOG_EMERG, "unable to create directory [%s]: %s", ctdl_netin_dir, strerror(errno));
1004 if (chown(ctdl_netin_dir, CTDLUID, (-1)) != 0)
1005 syslog(LOG_EMERG, "unable to set the access rights for [%s]: %s", ctdl_netin_dir, strerror(errno));
1006 if ((mkdir(ctdl_nettmp_dir, 0700) != 0) && (errno != EEXIST))
1007 syslog(LOG_EMERG, "unable to create directory [%s]: %s", ctdl_nettmp_dir, strerror(errno));
1008 if (chown(ctdl_nettmp_dir, CTDLUID, (-1)) != 0)
1009 syslog(LOG_EMERG, "unable to set the access rights for [%s]: %s", ctdl_nettmp_dir, strerror(errno));
1010 if ((mkdir(ctdl_netout_dir, 0700) != 0) && (errno != EEXIST))
1011 syslog(LOG_EMERG, "unable to create directory [%s]: %s", ctdl_netout_dir, strerror(errno));
1012 if (chown(ctdl_netout_dir, CTDLUID, (-1)) != 0)
1013 syslog(LOG_EMERG, "unable to set the access rights for [%s]: %s", ctdl_netout_dir, strerror(errno));
1017 * Module entry point
1019 CTDL_MODULE_INIT(network_spool)
1023 create_spool_dirs();
1024 //////todo CtdlRegisterCleanupHook(destroy_network_queue_room);
1026 return "network_spool";