X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fnetconfig.c;h=3161b11003bbff3ad471401f3536b179fc459f22;hb=4f4a70c228427c360d73b5ec1fd5f0726bc20e89;hp=916835e53465f53f98b6f281674197ce1067e4ad;hpb=4fe4a42959a6634f59cf6f45c58a07da5b29cd45;p=citadel.git diff --git a/citadel/netconfig.c b/citadel/netconfig.c index 916835e53..3161b1100 100644 --- a/citadel/netconfig.c +++ b/citadel/netconfig.c @@ -29,9 +29,11 @@ #include #include "include/ctdl_module.h" - +#include "serv_extensions.h" +#include "config.h" void vFreeRoomNetworkStruct(void *vOneRoomNetCfg); +void FreeRoomNetworkStructContent(OneRoomNetCfg *OneRNCfg); HashList *CfgTypeHash = NULL; HashList *RoomConfigs = NULL; @@ -145,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) @@ -172,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; @@ -383,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) { @@ -434,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 @@ -571,7 +580,6 @@ const ConstStr ForceAliases[nForceAliases] = { {HKEY("postmaster,")}, {HKEY("abuse,")} }; - void cmd_snet(char *argbuf) { struct CitContext *CCC = CC; @@ -714,7 +722,6 @@ void cmd_snet(char *argbuf) RNCfg = CtdlGetNetCfgForRoom(CCC->room.QRnumber); if (RNCfg != NULL) { - FreeRoomNetworkStructContent(RNCfg); ReadRoomNetConfigFile(&RNCfg, filename); } else @@ -722,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); } @@ -834,6 +843,7 @@ int is_recipient(OneRoomNetCfg *RNCfg, const char *Name) } nptr = nptr->next; } + i++; } return 0; } @@ -916,12 +926,14 @@ void cmd_netp(char *cmdbuf) lens[0] = strlen(CCC->cs_addr); strs[1] = "SRV_UNKNOWN"; - lens[1] = sizeof("SRV_UNKNOWN" - 1); + lens[1] = sizeof("SRV_UNKNOWN") - 1; CtdlAideFPMessage( err_buf, "IGNet Networking.", - 2, strs, (long*) &lens); + 2, strs, (long*) &lens, + CCC->cs_pid, 0, + time(NULL)); DeleteHash(&working_ignetcfg); FreeStrBuf(&NodeStr); @@ -941,12 +953,15 @@ void cmd_netp(char *cmdbuf) lens[0] = strlen(CCC->cs_addr); strs[1] = "SRV_PW"; - lens[1] = sizeof("SRV_PW" - 1); + lens[1] = sizeof("SRV_PW") - 1; CtdlAideFPMessage( err_buf, "IGNet Networking.", - 2, strs, (long*) &lens); + 2, strs, + (long*) &lens, + CCC->cs_pid, 0, + time(NULL)); DeleteHash(&working_ignetcfg); FreeStrBuf(&NodeStr); @@ -1161,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); } /*