#include <libcitadel.h>
#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;
{
int i;
- for (i = 0; i < ThisOne->nSegments; i++)
+ if (*data == NULL)
+ return;
+
+ for (i = 0; i < (*data)->nValues; i++)
{
FreeStrBuf(&(*data)->Value[i]);
}
}
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)
const CfgLineType *pCfg;
StrBuf *Line;
StrBuf *InStr;
- OneRoomNetCfg *OneRNCfg;
+ OneRoomNetCfg *OneRNCfg = NULL;
fd = open(filename, O_NONBLOCK|O_RDONLY);
if (fd == -1) {
*pOneRNCfg = NULL;
return 0;
}
+ fchown(fd, CTDLUID, (-1));
+ fchmod(fd, 0600);
+
if (*pOneRNCfg != NULL)
+ {
OneRNCfg = *pOneRNCfg;
+ FreeRoomNetworkStructContent (OneRNCfg);
+ }
else
OneRNCfg = malloc(sizeof(OneRoomNetCfg));
memset(OneRNCfg, 0, sizeof(OneRoomNetCfg));
*pOneRNCfg = OneRNCfg;
Line = NewStrBuf();
+ InStr = NewStrBuf();
while (StrBufTCP_read_line(Line, &fd, 0, &ErrStr) >= 0) {
if (StrLength(Line) == 0)
continue;
Pos = NULL;
- InStr = NewStrBufPlain(NULL, StrLength(Line));
StrBufExtract_NextToken(InStr, Line, &Pos, '|');
pCfg = GetCfgTypeByStr(SKEY(InStr));
RoomNetCfgLine *pNext, *pName;
pCfg = GetCfgTypeByEnum(eCfg, CfgIt);
- pName= OneRNCfg->NetConfigs[pCfg->C];
+ pName= OneRNCfg->NetConfigs[eCfg];
while (pName != NULL)
{
pNext = pName->next;
- pCfg->DeAllocator(pCfg, &pName);
+ if (pCfg != NULL)
+ {
+ pCfg->DeAllocator(pCfg, &pName);
+ }
+ else
+ {
+ DeleteGenericCfgLine(NULL, &pName);
+ }
pName = pNext;
}
}
FreeStrBuf(&OneRNCfg->Sender);
FreeStrBuf(&OneRNCfg->RoomInfo);
FreeStrBuf(&OneRNCfg->misc);
+ memset(OneRNCfg, 0, sizeof(OneRoomNetCfg));
}
void vFreeRoomNetworkStruct(void *vOneRoomNetCfg)
{
(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
{HKEY("postmaster,")},
{HKEY("abuse,")}
};
-
void cmd_snet(char *argbuf)
{
struct CitContext *CCC = CC;
RNCfg = CtdlGetNetCfgForRoom(CCC->room.QRnumber);
if (RNCfg != NULL)
{
- FreeRoomNetworkStructContent(RNCfg);
ReadRoomNetConfigFile(&RNCfg, filename);
}
else
ReadRoomNetConfigFile(&RNCfg, filename);
Put(RoomConfigs, LKEY(CCC->room.QRnumber), RNCfg, vFreeRoomNetworkStruct);
}
+
+ PerformRoomHooks(&CCC->room);
}
end_critical_section(S_NETCONFIGS);
}
}
nptr = nptr->next;
}
+ i++;
}
return 0;
}
const char* RemoteIdentifier)
{
OneRoomNetCfg *RNCfg;
- char filename[SIZ];
int found;
if (RemoteIdentifier == NULL)
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);
}
CtdlAideFPMessage(
err_buf,
"IGNet Networking.",
- 2, strs, (long*) &lens);
+ 2, strs, (long*) &lens,
+ CCC->cs_pid, 0,
+ time(NULL));
DeleteHash(&working_ignetcfg);
FreeStrBuf(&NodeStr);
CtdlAideFPMessage(
err_buf,
"IGNet Networking.",
- 2, strs, (long*) &lens);
+ 2, strs,
+ (long*) &lens,
+ CCC->cs_pid, 0,
+ time(NULL));
DeleteHash(&working_ignetcfg);
FreeStrBuf(&NodeStr);
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);
}
/*