Fixed filemgr tick=on crash, added auto echomail area create

This commit is contained in:
Michiel Broek 2002-02-14 21:24:27 +00:00
parent 598b6c2600
commit 62f10ff407
11 changed files with 185 additions and 146 deletions

View File

@ -4604,6 +4604,12 @@ v0.33.20 10-Feb-2002
mbfido:
In AreaMgr and FileMgr changed aka matching for area
connections. Code cleanups.
In FileMgr when %tick=on/off command was received, mbfido
crashed.
Implemented auto area create comparing a new received echo
from a uplink which has a echomail taglist in one of the
mailgroups defined. The area is created with the defaults
from the mailgroup.
mball:
Will not crash anymore when it needs more then 10 minutes to

View File

@ -30,6 +30,7 @@
#include "libs.h"
#include "structs.h"
#include "common.h"
#include "users.h"
#include "records.h"
#include "clcomm.h"
@ -81,6 +82,22 @@ int TestNode(fidoaddr aka)
}
int SearchNodeFaddr(faddr *n)
{
fidoaddr Sys;
memset(&Sys, 0, sizeof(Sys));
Sys.zone = n->zone;
Sys.net = n->net;
Sys.node = n->node;
Sys.point = n->point;
if (n->domain != NULL)
strncpy(Sys.domain, n->domain, 12);
return SearchNode(Sys);
}
int SearchNode(fidoaddr aka)
{

View File

@ -1,3 +1,5 @@
/* $Id$ */
#ifndef _DBNODE_H
#define _DBNODE_H
@ -8,6 +10,7 @@ int nodes_cnt; /* Node records in database */
int InitNode(void); /* Initialize nodes database */
int TestNode(fidoaddr); /* Check if noderecord is loaded */
int SearchNodeFaddr(faddr *); /* Search specified node and load */
int SearchNode(fidoaddr); /* Search specified node and load */
int UpdateNode(void); /* Update record if changed. */
char *GetNodeMailGrp(int); /* Get nodes mailgroup record */

View File

@ -30,6 +30,7 @@
#include "libs.h"
#include "structs.h"
#include "common.h"
#include "users.h"
#include "records.h"
#include "dbnode.h"

View File

@ -189,7 +189,7 @@ mbseq.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/c
notify.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h ../lib/msgtext.h ../lib/dbnode.h filemgr.h areamgr.h sendmail.h notify.h
postnetmail.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/dbcfg.h ../lib/dbuser.h ../lib/dbnode.h ../lib/dbftn.h ../lib/common.h ../lib/clcomm.h tracker.h addpkt.h storenet.h ftn2rfc.h areamgr.h filemgr.h ping.h bounce.h postemail.h
scannews.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/mbinet.h ../lib/dbdupe.h ../lib/dbnode.h ../lib/dbmsgs.h ../lib/msg.h ../lib/msgtext.h mkftnhdr.h hash.h rollover.h pack.h storeecho.h rfc2ftn.h scannews.h
tosspkt.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h ../lib/msgtext.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbmsgs.h ../lib/dbdupe.h ../lib/dbuser.h ../lib/dbftn.h tosspkt.h postnetmail.h postecho.h rollover.h
tosspkt.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h ../lib/msgtext.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbmsgs.h ../lib/dbdupe.h ../lib/dbuser.h ../lib/dbftn.h tosspkt.h postnetmail.h postecho.h rollover.h createm.h
mbfkill.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbfkill.h mbfutil.h
mbfutil.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbfutil.h mbfile.h
mbfindex.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbfutil.h mbfindex.h
@ -202,5 +202,7 @@ virscan.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib
mbftoberep.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbfutil.h mbftoberep.h
mbfmove.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbfutil.h mbfmove.h
mbfdel.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h mbfutil.h mbfmove.h
bounce.o:
bounce.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h ../lib/msgtext.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbtic.h ../lib/dbdupe.h ../lib/dbuser.h ../lib/dbftn.h sendmail.h mgrutil.h postnetmail.h ping.h
createm.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h createm.h
createf.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h createm.h
# End of generated dependencies

View File

@ -36,3 +36,131 @@
#include "../lib/clcomm.h"
#include "createm.h"
#define MCHARS "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
int create_msgarea(char *marea, faddr *p_from)
{
char *temp, *buf, *tag, *desc, *p;
FILE *gp, *ap, *mp;
long offset;
int i;
sysconnect System;
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/etc/mgroups.data", getenv("MBSE_ROOT"));
if ((gp = fopen(temp, "r")) == NULL) {
WriteError("$Can't open %s", temp);
free(temp);
return FALSE;
}
fread(&mgrouphdr, sizeof(mgrouphdr), 1, gp);
fseek(gp, mgrouphdr.hdrsize, SEEK_SET);
while ((fread(&mgroup, mgrouphdr.recsize, 1, gp)) == 1) {
if ((mgroup.UpLink.zone == p_from->zone) && (mgroup.UpLink.net == p_from->net) &&
(mgroup.UpLink.node == p_from->node) && (mgroup.UpLink.point == p_from->point) &&
strlen(mgroup.AreaFile)) {
Syslog('m', "Checking echogroup %s %s", mgroup.Name, mgroup.Comment);
sprintf(temp, "%s/%s", CFG.alists_path , mgroup.AreaFile);
if ((ap = fopen(temp, "r")) == NULL) {
WriteError("$Can't open %s", temp);
free(temp);
fclose(gp);
return FALSE;
} else {
buf = calloc(4097, sizeof(char));
while (fgets(buf, 4096, ap)) {
tag = strtok(buf, "\t \r\n\0");
p = strtok(NULL, "\r\n\0");
desc = p;
while ((*desc == ' ') || (*desc == '\t'))
desc++;
if (strcmp(tag, marea) == 0) {
Syslog('m', "Found tag \"%s\" desc \"%s\"", tag, desc);
sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
if ((mp = fopen(temp, "r+")) == NULL) {
WriteError("$Can't open %s", temp);
fclose(ap);
fclose(gp);
free(buf);
free(temp);
return FALSE;
}
fread(&msgshdr, sizeof(msgshdr), 1, mp);
offset = msgshdr.hdrsize + ((mgroup.StartArea -1) * (msgshdr.recsize + msgshdr.syssize));
if (fseek(mp, offset, SEEK_SET) == -1) {
WriteError("$Can't seek in %s", temp);
fclose(ap);
fclose(gp);
fclose(mp);
free(buf);
free(temp);
return FALSE;
}
while (fread(&msgs, sizeof(msgs), 1, mp) == 1) {
if (!msgs.Active) {
fseek(mp, - msgshdr.recsize, SEEK_CUR);
memset(&msgs, 0, sizeof(msgs));
offset = ((ftell(mp) - msgshdr.hdrsize) / (msgshdr.recsize + msgshdr.syssize)) + 1;
Syslog('m', "Found free slot at %ld", offset);
strncpy(msgs.Tag, tag, 50);
strncpy(msgs.Name, desc, 40);
strncpy(msgs.QWKname, tag, 20);
msgs.MsgKinds = PUBLIC;
msgs.Type = ECHOMAIL;
msgs.DaysOld = CFG.defdays;
msgs.MaxMsgs = CFG.defmsgs;
msgs.UsrDelete = mgroup.UsrDelete;
msgs.RDSec = mgroup.RDSec;
msgs.WRSec = mgroup.WRSec;
msgs.SYSec = mgroup.SYSec;
strncpy(msgs.Group, mgroup.Name, 12);
msgs.Aka = mgroup.UseAka;
strncpy(msgs.Origin, CFG.origin, 50);
msgs.Aliases = mgroup.Aliases;
msgs.NetReply = mgroup.NetReply;
msgs.Active = TRUE;
msgs.Quotes = mgroup.Quotes;
msgs.Rfccode = CHRS_DEFAULT_RFC;
msgs.Ftncode = CHRS_DEFAULT_FTN;
msgs.MaxArticles = CFG.maxarticles;
tag = tl(tag);
sprintf(msgs.Base, "%s/%s", mgroup.BasePath, tag);
fwrite(&msgs, sizeof(msgs), 1, mp);
memset(&System, 0, sizeof(System));
System.aka = mgroup.UpLink;
System.sendto = System.receivefrom = TRUE;
fwrite(&System, sizeof(System), 1, mp);
memset(&System, 0, sizeof(System));
for (i = 1; i < (msgshdr.syssize / sizeof(System)); i++)
fwrite(&System, sizeof(System), 1, mp);
fclose(mp);
fclose(gp);
fclose(ap);
free(buf);
free(temp);
return TRUE;
}
/*
* Skip systems
*/
fseek(mp, msgshdr.syssize, SEEK_CUR);
}
/*
* No free slot at the end, append a slot.
*/
}
}
free(buf);
fclose(ap);
}
}
}
fclose(gp);
return FALSE;
}

View File

@ -4,6 +4,7 @@
#define _CREATEM_H
int create_msgarea(char *, faddr *);
#endif

View File

@ -756,8 +756,6 @@ void F_Pause(faddr *t, int Pause, FILE *tmp)
void F_Message(faddr *t, char *Buf, FILE *tmp)
{
fidoaddr Node;
ShiftBuf(Buf, 8);
CleanBuf(Buf);
@ -769,8 +767,7 @@ void F_Message(faddr *t, char *Buf, FILE *tmp)
return;
UpdateNode();
memcpy(&Node, faddr2fido(t), sizeof(fidoaddr));
SearchNode(Node);
SearchNodeFaddr(t);
Syslog('+', "FileMgr: Message %s", GetBool(nodes.Message));
fprintf(tmp, "FileMgr Message file is %s\n", GetBool(nodes.Message));
}
@ -779,11 +776,9 @@ void F_Message(faddr *t, char *Buf, FILE *tmp)
void F_Tick(faddr *t, char *Buf, FILE *tmp)
{
fidoaddr Node;
ShiftBuf(Buf, 5);
CleanBuf(Buf);
if (!strncasecmp(Buf, "on", 2)) {
nodes.Tic = TRUE;
nodes.AdvTic = FALSE;
@ -795,16 +790,15 @@ void F_Tick(faddr *t, char *Buf, FILE *tmp)
return;
UpdateNode();
memcpy(&Node, faddr2fido(t), sizeof(fidoaddr));
SearchNode(Node);
Syslog('+', "FileMgr: Tick %s, Advanced %s", nodes.Tic, nodes.AdvTic);
SearchNodeFaddr(t);
Syslog('+', "FileMgr: Tick %s, Advanced %s", GetBool(nodes.Tic), GetBool(nodes.AdvTic));
if (nodes.Tic)
if (nodes.AdvTic)
fprintf(tmp, "Tick mode is advanced");
fprintf(tmp, "Tick mode is advanced\n");
else
fprintf(tmp, "Tick mode is normal");
fprintf(tmp, "Tick mode is normal\n");
else
fprintf(tmp, "Tick mode is off");
fprintf(tmp, "Tick mode is off\n");
}
@ -814,7 +808,6 @@ int FileMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int fla
int i, rc = 0, spaces;
char *Buf;
FILE *tmp, *np;
fidoaddr Node;
f_help = f_stat = f_unlnk = f_list = f_query = FALSE;
filemgr++;
@ -837,7 +830,7 @@ int FileMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int fla
net_bad++;
return FALSE;
}
Buf = calloc(2049, sizeof(char));
rewind(fp);
@ -846,8 +839,7 @@ int FileMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int fla
/*
* Make sure we refresh the nodes record.
*/
memcpy(&Node, faddr2fido(f), sizeof(fidoaddr));
SearchNode(Node);
SearchNodeFaddr(f);
spaces = 0;
for (i = 0; i < strlen(Buf); i++) {

View File

@ -83,7 +83,6 @@ int do_unsec = FALSE; /* Unsecure tossing */
int do_learn = FALSE; /* News articles learnmode */
int check_crc = TRUE; /* Check .tic crc values */
int check_dupe = TRUE; /* Check duplicates */
int autocrea = FALSE; /* Autocreate new msg areas */
extern int do_quiet; /* Quiet flag */
extern int e_pid; /* Pid of child process */
extern int show_log; /* Show logging on screen */
@ -131,7 +130,6 @@ void Help(void)
colour(9, 0);
printf(" Options are:\n\n");
colour(3, 0);
printf(" -a -auto Autocreate new msg areas\n");
printf(" -f -full Full Mailscan\n");
printf(" -l -learn Learn News dupes\n");
printf(" -noc -nocrc Skip CRC checking\n");
@ -369,8 +367,6 @@ int main(int argc, char **argv)
do_mail = TRUE;
else if (strncmp(tl(argv[i]), "w", 1) == 0)
do_stat = TRUE;
else if (strncmp(tl(argv[i]), "-a", 2) == 0)
autocrea = TRUE;
else if (strncmp(tl(argv[i]), "-f", 2) == 0)
do_full = TRUE;
else if (strncmp(tl(argv[i]), "-l", 2) == 0)

View File

@ -31,12 +31,12 @@
#include "../lib/libs.h"
#include "../lib/structs.h"
#include "../lib/users.h"
#include "../lib/common.h"
#include "../lib/records.h"
#include "../lib/dbcfg.h"
#include "../lib/dbuser.h"
#include "../lib/dbnode.h"
#include "../lib/dbftn.h"
#include "../lib/common.h"
#include "../lib/clcomm.h"
#include "tracker.h"
#include "addpkt.h"

View File

@ -46,6 +46,7 @@
#include "postnetmail.h"
#include "postecho.h"
#include "rollover.h"
#include "createm.h"
@ -55,7 +56,6 @@
extern int do_quiet;
extern int do_unsec;
extern int check_dupe;
extern int autocrea;
extern time_t t_start;
extern int most_debug;
@ -92,7 +92,6 @@ static int at_zero = 0;
*/
char *aread(char *, int, FILE *);
int importmsg(faddr *, faddr *, faddr *, char *, char *, time_t, int, int, FILE *);
void autocreate(char *, faddr *);
@ -206,26 +205,25 @@ int importmsg(faddr *p_from, faddr *f, faddr *t, char *orig, char *subj,
}
if (!SearchMsgs(marea)) {
WriteError("Unknown echo area %s", marea);
if (autocrea) {
autocreate(marea, p_from);
if (!SearchMsgs(marea)) {
WriteError("Autocreate of area %s failed.", area);
echo_bad++;
echo_in++;
bad = TRUE;
free(marea);
free(buf);
return 4;
}
} else {
Syslog('m', "Unknown echo area %s", marea);
if (!create_msgarea(marea, p_from)) {
WriteError("Create echomail area %s failed", marea);
echo_bad++;
echo_in++;
bad = TRUE;
free(marea);
free(buf);
return 4;
}
if (!SearchMsgs(marea)) {
WriteError("Unknown echo area %s", marea);
echo_bad++;
echo_in++;
bad = TRUE;
free(buf);
free(marea);
free(buf);
return 4;
}
}
}
echomail = TRUE;
free(marea);
@ -246,111 +244,6 @@ int importmsg(faddr *p_from, faddr *f, faddr *t, char *orig, char *subj,
/*
* Create echomail area if it doesn't excist and allowed.
* Contributed by Redy Rodriguez.
*/
void autocreate(char *marea, faddr *p_from)
{
FILE *pMsgs;
char temp[250];
int i;
struct _sysconnect syscon;
if (!SearchMsgs((char *)"DEFAULT")){
WriteError("Can't find DEFAULT area, can't autocreate:");
autocrea = FALSE;
return;
}
sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
if ((pMsgs = fopen(temp, "r+")) == NULL) {
WriteError("$Database error: Can't create %s", temp);
return;
}
strncat(msgs.Name,marea,40-strlen(msgs.Name));
strncpy(msgs.Tag,marea,50);
strncpy(msgs.QWKname,marea,20);
strncat(msgs.Base,marea,64-strlen(msgs.Base));
fseek(pMsgs, 0, SEEK_END);
Syslog('+', "Autocreate area %s", marea);
memset(&syscon, 0, sizeof(syscon));
syscon.aka.zone = p_from->zone;
syscon.aka.node = p_from->node;
syscon.aka.net = p_from->net;
if (SearchFidonet(p_from->zone))
strcpy(syscon.aka.domain,fidonet.domain);
else {
WriteError("New area %s from node of unknown zone %d not created.", marea,p_from->zone);
fclose(pMsgs);
return;
}
syscon.sendto = TRUE;
syscon.receivefrom = TRUE;
if (msgs.Aka.zone == 0) {
for (i = 0; i < 40; i++) {
if (CFG.akavalid[i]) {
msgs.Aka.zone=CFG.aka[i].zone;
msgs.Aka.net=CFG.aka[i].net;
msgs.Aka.node=CFG.aka[i].node;
msgs.Aka.point=CFG.aka[i].point;
strcpy(msgs.Aka.domain,CFG.aka[i].domain);
i=40;
}
}
for (i = 0; i < 40; i++) {
if (CFG.akavalid[i] && (strcmp(CFG.aka[i].domain,msgs.Aka.domain)==0)) {
msgs.Aka.zone=CFG.aka[i].zone;
msgs.Aka.net=CFG.aka[i].net;
msgs.Aka.node=CFG.aka[i].node;
msgs.Aka.point=CFG.aka[i].point;
strcpy(msgs.Aka.domain,CFG.aka[i].domain);
i=40;
}
}
for (i = 0; i < 40; i++) {
if ((CFG.akavalid[i]) && (CFG.aka[i].zone == p_from->zone)) {
msgs.Aka.zone=CFG.aka[i].zone;
msgs.Aka.net=CFG.aka[i].net;
msgs.Aka.node=CFG.aka[i].node;
msgs.Aka.point=CFG.aka[i].point;
strcpy(msgs.Aka.domain,CFG.aka[i].domain);
i=40;
}
}
for (i = 0; i < 40; i++) {
if ((CFG.akavalid[i]) && (CFG.aka[i].zone == p_from->zone) && (CFG.aka[i].net == p_from->net)) {
msgs.Aka.zone=CFG.aka[i].zone;
msgs.Aka.net=CFG.aka[i].net;
msgs.Aka.node=CFG.aka[i].node;
msgs.Aka.point=CFG.aka[i].point;
strcpy(msgs.Aka.domain,CFG.aka[i].domain);
i=40;
}
}
for (i = 0; i < 40; i++) {
if ((CFG.akavalid[i]) && (CFG.aka[i].zone == p_from->zone) &&
(CFG.aka[i].net == p_from->net) && (CFG.aka[i].node == p_from->node)) {
msgs.Aka.zone=CFG.aka[i].zone;
msgs.Aka.net=CFG.aka[i].net;
msgs.Aka.node=CFG.aka[i].node;
msgs.Aka.point=CFG.aka[i].point;
strcpy(msgs.Aka.domain,CFG.aka[i].domain);
i=40;
}
}
}
fwrite(&msgs, msgshdr.recsize, 1, pMsgs);
fwrite(&syscon, sizeof(syscon), 1, pMsgs);
memset(&syscon, 0, sizeof(syscon));
for (i = 1 ; i < CFG.toss_systems; i++ )
fwrite(&syscon, sizeof(syscon), 1, pMsgs);
fclose(pMsgs);
return;
}
/*
* Toss one packet.
*