fix dnamlen, they missed the e, so we need to follow.
[citadel.git] / citadel / netconfig.c
index 7fc53c594c8df304a055847f938e6de65c723f8b..d2a39c6c63e11cd1b2e1d02af343c4b631b6e9b1 100644 (file)
@@ -29,7 +29,8 @@
 #include <libcitadel.h>
 
 #include "include/ctdl_module.h"
-
+#include "serv_extensions.h"
+#include "config.h"
 
 void vFreeRoomNetworkStruct(void *vOneRoomNetCfg);
 void FreeRoomNetworkStructContent(OneRoomNetCfg *OneRNCfg);
@@ -146,16 +147,19 @@ void DeleteGenericCfgLine(const CfgLineType *ThisOne, RoomNetCfgLine **data)
 }
 RoomNetCfgLine *DuplicateOneGenericCfgLine(const RoomNetCfgLine *data)
 {
+       int i;
        RoomNetCfgLine *NewData;
 
        NewData = (RoomNetCfgLine*)malloc(sizeof(RoomNetCfgLine));
-       int i;
+       memset(NewData, 0, sizeof(RoomNetCfgLine));
        NewData->Value = (StrBuf **)malloc(sizeof(StrBuf*) * data->nValues);
+       memset(NewData->Value, 0, sizeof(StrBuf*) * data->nValues);
 
        for (i = 0; i < data->nValues; i++)
        {
                NewData->Value[i] = NewStrBufDup(data->Value[i]);
        }
+       NewData->nValues = data->nValues;
        return NewData;
 }
 int ReadRoomNetConfigFile(OneRoomNetCfg **pOneRNCfg, char *filename)
@@ -173,6 +177,9 @@ int ReadRoomNetConfigFile(OneRoomNetCfg **pOneRNCfg, char *filename)
                *pOneRNCfg = NULL;
                return 0;
        }
+       fchown(fd, CTDLUID, (-1));
+       fchmod(fd, 0600);
+
        if (*pOneRNCfg != NULL)
        {
                OneRNCfg = *pOneRNCfg;
@@ -384,6 +391,7 @@ void FreeRoomNetworkStructContent(OneRoomNetCfg *OneRNCfg)
        FreeStrBuf(&OneRNCfg->Sender);
        FreeStrBuf(&OneRNCfg->RoomInfo);
        FreeStrBuf(&OneRNCfg->misc);
+       memset(OneRNCfg, 0, sizeof(OneRoomNetCfg));
 }
 void vFreeRoomNetworkStruct(void *vOneRoomNetCfg)
 {
@@ -435,7 +443,7 @@ void LoadAllNetConfigs(void)
               (filedir_entry != NULL))
        {
 #ifdef _DIRENT_HAVE_D_NAMLEN
-               d_namelen = filedir_entry->d_namelen;
+               d_namelen = filedir_entry->d_namlen;
 #else
                d_namelen = strlen(filedir_entry->d_name);
 #endif
@@ -572,7 +580,6 @@ const ConstStr ForceAliases[nForceAliases] = {
        {HKEY("postmaster,")},
        {HKEY("abuse,")}
 };
-
 void cmd_snet(char *argbuf)
 {
        struct CitContext *CCC = CC;
@@ -715,7 +722,6 @@ void cmd_snet(char *argbuf)
                RNCfg = CtdlGetNetCfgForRoom(CCC->room.QRnumber);
                if (RNCfg != NULL)
                {
-                       FreeRoomNetworkStructContent(RNCfg);
                        ReadRoomNetConfigFile(&RNCfg, filename);
                }
                else
@@ -723,6 +729,8 @@ void cmd_snet(char *argbuf)
                        ReadRoomNetConfigFile(&RNCfg, filename);
                        Put(RoomConfigs, LKEY(CCC->room.QRnumber), RNCfg, vFreeRoomNetworkStruct);
                }
+
+               PerformRoomHooks(&CCC->room);
        }
        end_critical_section(S_NETCONFIGS);
 }
@@ -835,6 +843,7 @@ int is_recipient(OneRoomNetCfg *RNCfg, const char *Name)
                        }
                        nptr = nptr->next;
                }
+               i++;
        }
        return 0;
 }
@@ -922,7 +931,9 @@ void cmd_netp(char *cmdbuf)
                CtdlAideFPMessage(
                        err_buf,
                        "IGNet Networking.",
-                       2, strs, (long*) &lens);
+                       2, strs, (long*) &lens,
+                       CCC->cs_pid, 0,
+                       time(NULL));
 
                DeleteHash(&working_ignetcfg);
                FreeStrBuf(&NodeStr);
@@ -947,7 +958,10 @@ void cmd_netp(char *cmdbuf)
                CtdlAideFPMessage(
                        err_buf,
                        "IGNet Networking.",
-                       2, strs, (long*) &lens);
+                       2, strs,
+                       (long*) &lens,
+                       CCC->cs_pid, 0,
+                       time(NULL));
 
                DeleteHash(&working_ignetcfg);
                FreeStrBuf(&NodeStr);
@@ -1162,13 +1176,16 @@ int CtdlIsValidNode(const StrBuf **nexthop,
 void destroy_network_cfgs(void)
 {
        HashList *pCfgTypeHash = CfgTypeHash;
-       HashList *pRoomConfigs = RoomConfigs;
+       HashList *pRoomConfigs;
 
-       CfgTypeHash = NULL;
+       begin_critical_section(S_NETCONFIGS);
+       pRoomConfigs = RoomConfigs;
        RoomConfigs = NULL;
-       
-       DeleteHash(&pCfgTypeHash);
+       end_critical_section(S_NETCONFIGS);
        DeleteHash(&pRoomConfigs);
+
+       CfgTypeHash = NULL;
+       DeleteHash(&pCfgTypeHash);
 }
 
 /*