X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fnetconfig.c;h=f09c852fd32a3786ac5cc1f15c35c4e6fcbde087;hb=0d309c3f9280c215677530e59f68c8c149fd65ce;hp=52adbbddff79cdb60730b3893a4c740a42399562;hpb=6f0f2b51a2ccb6873d3b2c8ecb075535d2516729;p=citadel.git diff --git a/citadel/netconfig.c b/citadel/netconfig.c index 52adbbddf..f09c852fd 100644 --- a/citadel/netconfig.c +++ b/citadel/netconfig.c @@ -29,9 +29,10 @@ #include #include "include/ctdl_module.h" - +#include "serv_extensions.h" void vFreeRoomNetworkStruct(void *vOneRoomNetCfg); +void FreeRoomNetworkStructContent(OneRoomNetCfg *OneRNCfg); HashList *CfgTypeHash = NULL; HashList *RoomConfigs = NULL; @@ -145,16 +146,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) @@ -165,7 +169,7 @@ int ReadRoomNetConfigFile(OneRoomNetCfg **pOneRNCfg, char *filename) const CfgLineType *pCfg; StrBuf *Line; StrBuf *InStr; - OneRoomNetCfg *OneRNCfg; + OneRoomNetCfg *OneRNCfg = NULL; fd = open(filename, O_NONBLOCK|O_RDONLY); if (fd == -1) { @@ -173,7 +177,10 @@ int ReadRoomNetConfigFile(OneRoomNetCfg **pOneRNCfg, char *filename) return 0; } if (*pOneRNCfg != NULL) + { OneRNCfg = *pOneRNCfg; + FreeRoomNetworkStructContent (OneRNCfg); + } else OneRNCfg = malloc(sizeof(OneRoomNetCfg)); memset(OneRNCfg, 0, sizeof(OneRoomNetCfg)); @@ -380,6 +387,7 @@ void FreeRoomNetworkStructContent(OneRoomNetCfg *OneRNCfg) FreeStrBuf(&OneRNCfg->Sender); FreeStrBuf(&OneRNCfg->RoomInfo); FreeStrBuf(&OneRNCfg->misc); + memset(OneRNCfg, 0, sizeof(OneRoomNetCfg)); } void vFreeRoomNetworkStruct(void *vOneRoomNetCfg) { @@ -568,7 +576,6 @@ const ConstStr ForceAliases[nForceAliases] = { {HKEY("postmaster,")}, {HKEY("abuse,")} }; - void cmd_snet(char *argbuf) { struct CitContext *CCC = CC; @@ -711,7 +718,6 @@ void cmd_snet(char *argbuf) RNCfg = CtdlGetNetCfgForRoom(CCC->room.QRnumber); if (RNCfg != NULL) { - FreeRoomNetworkStructContent(RNCfg); ReadRoomNetConfigFile(&RNCfg, filename); } else @@ -719,6 +725,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); } @@ -831,6 +839,7 @@ int is_recipient(OneRoomNetCfg *RNCfg, const char *Name) } nptr = nptr->next; } + i++; } return 0; } @@ -843,7 +852,6 @@ int CtdlNetconfigCheckRoomaccess( const char* RemoteIdentifier) { OneRoomNetCfg *RNCfg; - char filename[SIZ]; int found; if (RemoteIdentifier == NULL) @@ -852,18 +860,18 @@ int CtdlNetconfigCheckRoomaccess( return (ERROR + USERNAME_REQUIRED); } - assoc_file_name(filename, sizeof filename, &CC->room, ctdl_netcfg_dir); begin_critical_section(S_NETCONFIGS); - if (!ReadRoomNetConfigFile(&RNCfg, filename)) + RNCfg = CtdlGetNetCfgForRoom (CC->room.QRnumber); + if (RNCfg == NULL) { end_critical_section(S_NETCONFIGS); snprintf(errmsgbuf, n, "This mailing list only accepts posts from subscribers."); return (ERROR + NO_SUCH_USER); } - end_critical_section(S_NETCONFIGS); found = is_recipient (RNCfg, RemoteIdentifier); - vFreeRoomNetworkStruct(&RNCfg); + end_critical_section(S_NETCONFIGS); + if (found) { return (0); } @@ -919,7 +927,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); @@ -944,7 +954,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); @@ -1161,11 +1174,11 @@ void destroy_network_cfgs(void) HashList *pCfgTypeHash = CfgTypeHash; HashList *pRoomConfigs = RoomConfigs; - CfgTypeHash = NULL; RoomConfigs = NULL; - - DeleteHash(&pCfgTypeHash); DeleteHash(&pRoomConfigs); + + CfgTypeHash = NULL; + DeleteHash(&pCfgTypeHash); } /*