Implemented areamgr and filemgr access security

This commit is contained in:
Michiel Broek 2002-10-01 19:43:57 +00:00
parent deee7eee60
commit 09ade52535
5 changed files with 161 additions and 131 deletions

View File

@ -5,8 +5,6 @@ WARNING: Extra debug logging enabled for checking internet news dupes.
Since 28-08-2002 mbfido news produces real big logs!!
Extra debug logging will be removed around 14 Oct 2002.
NOTE: Areas security editing is present but doesn't do anything yet.
Work in progress!
MBSEBBS History.
@ -14,6 +12,7 @@ NOTE: Areas security editing is present but doesn't do anything yet.
v0.35.04 29-Sep-2002
general:
Added mail and files security flags for nodes.
upgrade:
Start mbsetup, enter global configuration and exit and save.
@ -34,6 +33,8 @@ v0.35.04 29-Sep-2002
missing echomail areas.
File attaches to our own points were placed in the node's
outbound directory instead of the point outbound.
Files and echomail security flags implemented.
Echomail rescan will also work with newsgroups.
mbsetup:
Added setup for the nodes record for security flags.

View File

@ -222,14 +222,16 @@ void A_List(faddr *t, char *replyid, int Notify)
if ((!strcmp(mgroup.Name, Group)) &&
(g->zone == f->zone) && (g->net == f->net) && (g->node == f->node) && (g->point == f->point)) {
SubTot = 0;
MacroVars("GJI", "sss",mgroup.Name, mgroup.Comment, aka2str(mgroup.UseAka) );
MacroVars("G", "s", mgroup.Name);
MacroVars("J", "s", mgroup.Comment);
MacroVars("I", "s", aka2str(mgroup.UseAka) );
fsetpos(fi,&fileptr);
MacroRead(fi, qp);
fgetpos(fi,&fileptr1);
fseek(mp, msgshdr.hdrsize, SEEK_SET);
while (fread(&msgs, msgshdr.recsize, 1, mp) == 1) {
if (!strcmp(Group, msgs.Group) && msgs.Active) {
if (!strcmp(Group, msgs.Group) && msgs.Active && Access(nodes.Security, msgs.LinkSec)) {
memset(&Stat, ' ', sizeof(Stat));
Stat[sizeof(Stat)-1] = '\0';
@ -252,14 +254,14 @@ void A_List(faddr *t, char *replyid, int Notify)
}
if ( (Notify == LIST_LIST) || (Notify == LIST_NOTIFY)
|| ((Notify == LIST_QUERY) && ((Stat[0]=='S') || (Stat[1]=='R')))
|| ((Notify >= LIST_UNLINK) && ((Stat[0]!='S') && (Stat[1]!='R')))){
MacroVars("XDEsrpc", "sssdddd",
Stat, msgs.Tag, msgs.Name,
(Stat[0] == 'S'),
(Stat[1] == 'R'),
(Stat[2] == 'P'),
(Stat[3] == 'C')
);
|| ((Notify >= LIST_UNLINK) && ((Stat[0]!='S') && (Stat[1]!='R')))){
MacroVars("X", "s", Stat);
MacroVars("D", "s", msgs.Tag);
MacroVars("E", "s", msgs.Name);
MacroVars("s", "d", (Stat[0] == 'S'));
MacroVars("r", "d", (Stat[1] == 'R'));
MacroVars("p", "d", (Stat[2] == 'P'));
MacroVars("c", "d", (Stat[3] == 'C'));
fsetpos(fi,&fileptr1);
MacroRead(fi, qp);
fgetpos(fi,&fileptr2);
@ -324,14 +326,17 @@ void A_Flow(faddr *t, char *replyid, int Notify)
subject = calloc(255, sizeof(char));
f = bestaka_s(t);
MacroVars("sKyY", "sdss", nodes.Sysop, Notify, ascfnode(t, 0xff), ascfnode(f, 0xf));
MacroVars("s", "s", nodes.Sysop);
MacroVars("K", "d", Notify);
MacroVars("y", "s", ascfnode(t, 0xff));
MacroVars("Y", "s", ascfnode(f, 0xff));
if (Notify){
if (Notify) {
Mgrlog("AreaMgr: Flow report to %s", ascfnode(t, 0xff));
sprintf(subject,"AreaMgr Notify Flow Report");
GetRpSubject("areamgr.notify.flow",subject);
fi = OpenMacro("areamgr.notify.flow", nodes.Language, FALSE);
}else{
} else {
Mgrlog("AreaMgr: Flow report");
sprintf(subject,"AreaMgr Flow Report");
GetRpSubject("areamgr.flow",subject);
@ -394,14 +399,16 @@ void A_Flow(faddr *t, char *replyid, int Notify)
if ((!strcmp(mgroup.Name, Group)) &&
(g->zone == f->zone) && (g->net == f->net) && (g->node == f->node) && (g->point == f->point)) {
MacroVars("GJI", "sss",mgroup.Name, mgroup.Comment, aka2str(mgroup.UseAka) );
MacroVars("G", "s", mgroup.Name);
MacroVars("J", "s", mgroup.Comment);
MacroVars("I", "s", aka2str(mgroup.UseAka));
fsetpos(fi,&fileptr);
MacroRead(fi, qp);
fgetpos(fi,&fileptr1);
fseek(mp, msgshdr.hdrsize, SEEK_SET);
while (fread(&msgs, msgshdr.recsize, 1, mp) == 1) {
if (!strcmp(Group, msgs.Group) && msgs.Active) {
if (!strcmp(Group, msgs.Group) && msgs.Active && Access(nodes.Security, msgs.LinkSec)) {
memset(&Stat, ' ', sizeof(Stat));
Stat[sizeof(Stat)-1] = '\0';
@ -416,17 +423,15 @@ void A_Flow(faddr *t, char *replyid, int Notify)
Stat[0] = 'C';
}
}
MacroVars("XAPQRpqrx", "csddddddd",
Stat[0],
msgs.Tag,
msgs.Received.lweek,
msgs.Received.month[lmonth],
msgs.Received.total,
msgs.Posted.lweek,
msgs.Posted.month[lmonth],
msgs.Posted.total,
(Stat[0] == 'C')
);
MacroVars("X", "c", Stat[0]);
MacroVars("A", "s", msgs.Tag);
MacroVars("P", "d", msgs.Received.lweek);
MacroVars("Q", "d", msgs.Received.month[lmonth]);
MacroVars("R", "d", msgs.Received.total);
MacroVars("p", "d", msgs.Posted.lweek);
MacroVars("q", "d", msgs.Posted.month[lmonth]);
MacroVars("r", "d", msgs.Posted.total);
MacroVars("x", "d", (Stat[0] == 'C'));
fsetpos(fi,&fileptr1);
MacroRead(fi, qp);
fgetpos(fi,&fileptr2);
@ -713,6 +718,18 @@ void A_Connect(faddr *t, char *Area, FILE *tmp)
return;
}
if (! Access(nodes.Security, msgs.LinkSec)) {
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Areamgr");
/*
* If node has no access by flags, we lie and say "Area not found"
*/
MacroVars("RABCDE", "ssssss","ERR_CONN_NOTFOUND",Area,"","","","");
MsgResult("areamgr.responses",tmp);
Mgrlog(" %s has no access to %s", ascfnode(t, 0x1f), Area);
MacroClear();
return;
}
memset(&Sys, 0, sizeof(Sys));
memcpy(&Sys.aka, faddr2fido(t), sizeof(fidoaddr));
Sys.sendto = TRUE;
@ -812,7 +829,7 @@ void A_All(faddr *t, int Connect, FILE *tmp, char *Grp)
Temp = fido2faddr(msgs.Aka);
if ((!strcmp(Group, msgs.Group)) && (msgs.Active) && (!msgs.Mandatory) && strlen(msgs.Tag) &&
((msgs.Type == ECHOMAIL) || (msgs.Type == NEWS) || (msgs.Type == LIST)) &&
(metric(Temp, f) < METRIC_NET)) {
(metric(Temp, f) < METRIC_NET) && Access(nodes.Security, msgs.LinkSec)) {
if (Connect) {
Link = FALSE;
@ -1003,13 +1020,14 @@ int AreaMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int fla
if (SearchFidonet(f->zone))
f->domain = xstrcpy(fidonet.domain);
Mgrlog("AreaMgr request from %s", ascfnode(f, 0xff));
Mgrlog("AreaMgr request from %s start", ascfnode(f, 0xff));
/*
* If the password failed, we return silently and don't respond.
*/
if ((!strlen(subj)) || (strcasecmp(subj, nodes.Apasswd))) {
WriteError("AreaMgr: password expected \"%s\", got \"%s\"", nodes.Apasswd, subj);
Mgrlog("AreaMgr request from %s finished", ascfnode(f, 0xff));
net_bad++;
return FALSE;
}
@ -1153,6 +1171,7 @@ int AreaMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int fla
if (a_help)
A_Help(f, replyid);
Mgrlog("AreaMgr request from %s finished", ascfnode(f, 0xff));
return rc;
}

View File

@ -218,7 +218,7 @@ void F_List(faddr *t, char *replyid, int Notify)
fseek(fp, tichdr.hdrsize, SEEK_SET);
while (fread(&tic, tichdr.recsize, 1, fp) == 1) {
if (!strcmp(Group, tic.Group) && tic.Active) {
if (!strcmp(Group, tic.Group) && tic.Active && Access(nodes.Security, tic.LinkSec)) {
memset(&Stat, ' ', sizeof(Stat));
Stat[sizeof(Stat)-1] = '\0';
@ -301,30 +301,28 @@ void F_Status(faddr *t, char *replyid)
i = 11;
else
i = Miy - 1;
MacroVars("ABCDEfGIJabcdefghijkls", "ddddddddddddddddddddds",
nodes.Message,
nodes.Tic,
nodes.AdvTic,
nodes.Notify,
nodes.Billing,
nodes.BillDirect,
nodes.Debet,
nodes.Credit,
nodes.WarnLevel,
nodes.FilesSent.lweek,
nodes.FilesSent.month[i],
nodes.FilesSent.total,
nodes.F_KbSent.lweek,
nodes.F_KbSent.month[i],
nodes.F_KbSent.total,
nodes.FilesRcvd.lweek,
nodes.FilesRcvd.month[i],
nodes.FilesRcvd.total,
nodes.F_KbRcvd.lweek,
nodes.F_KbRcvd.month[i],
nodes.F_KbRcvd.total,
nodes.Sysop
);
MacroVars("A", "d", nodes.Message);
MacroVars("B", "d", nodes.Tic);
MacroVars("C", "d", nodes.AdvTic);
MacroVars("D", "d", nodes.Notify);
MacroVars("E", "d", nodes.Billing);
MacroVars("f", "d", nodes.BillDirect);
MacroVars("G", "d", nodes.Debet);
MacroVars("I", "d", nodes.Credit);
MacroVars("J", "d", nodes.WarnLevel);
MacroVars("a", "d", nodes.FilesSent.lweek);
MacroVars("b", "d", nodes.FilesSent.month[i]);
MacroVars("c", "d", nodes.FilesSent.total);
MacroVars("d", "d", nodes.F_KbSent.lweek);
MacroVars("e", "d", nodes.F_KbSent.month[i]);
MacroVars("f", "d", nodes.F_KbSent.total);
MacroVars("g", "d", nodes.FilesRcvd.lweek);
MacroVars("h", "d", nodes.FilesRcvd.month[i]);
MacroVars("i", "d", nodes.FilesRcvd.total);
MacroVars("j", "d", nodes.F_KbRcvd.lweek);
MacroVars("k", "d", nodes.F_KbRcvd.month[i]);
MacroVars("l", "d", nodes.F_KbRcvd.total);
MacroVars("s", "s", nodes.Sysop);
GetRpSubject("filemgr.status",subject);
if ((fi = OpenMacro("filemgr.status", nodes.Language, FALSE)) == NULL ) {
@ -464,7 +462,7 @@ void F_Connect(faddr *t, char *Area, FILE *tmp)
if (!SearchTic(Area)) {
/*
* Close noderecord, atocreate will destroy it.
* Close noderecord, autocreate will destroy it.
*/
UpdateNode();
@ -539,6 +537,18 @@ void F_Connect(faddr *t, char *Area, FILE *tmp)
return;
}
if (! Access(nodes.Security, tic.LinkSec)) {
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Filemgr");
/*
* If node has no access by flags, we lie and say "Area not found"
*/
MacroVars("RABCDE", "ssssss","ERR_CONN_NOTFOUND",Area,"","","","");
MsgResult("filemgr.responses",tmp);
Mgrlog(" %s has no access to %s", ascfnode(t, 0x1f), Area);
MacroClear();
return;
}
memset(&Sys, 0, sizeof(Sys));
memcpy(&Sys.aka, faddr2fido(t), sizeof(fidoaddr));
Sys.sendto = TRUE;
@ -632,7 +642,7 @@ void F_All(faddr *t, int Connect, FILE *tmp, char *Grp)
Temp = fido2faddr(tic.Aka);
if ((!strcmp(Group, tic.Group)) && tic.Active && strlen(tic.Name) &&
(metric(Temp, f) < METRIC_NET)) {
(metric(Temp, f) < METRIC_NET) && Access(nodes.Security, tic.LinkSec)) {
if (Connect) {
Link = FALSE;
@ -834,7 +844,7 @@ int FileMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int fla
if (SearchFidonet(f->zone))
f->domain = xstrcpy(fidonet.domain);
Mgrlog("FileMgr request from %s", ascfnode(f, 0xff));
Mgrlog("FileMgr request from %s start", ascfnode(f, 0xff));
/*
* If the password failed, we return silently and don't respond.
@ -842,6 +852,7 @@ int FileMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int fla
if ((!strlen(subj)) || (strcasecmp(subj, nodes.Fpasswd))) {
WriteError("FileMgr: password expected \"%s\", got \"%s\"", nodes.Fpasswd, subj);
Mgrlog("FileMgr: password expected \"%s\", got \"%s\"", nodes.Fpasswd, subj);
Mgrlog("FileMgr request from %s finished", ascfnode(f, 0xff));
net_bad++;
return FALSE;
}
@ -977,6 +988,7 @@ int FileMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int fla
if (f_help)
F_Help(f, replyid);
Mgrlog("FileMgr request from %s finished", ascfnode(f, 0xff));
return rc;
}

View File

@ -488,84 +488,82 @@ int RescanOne(faddr *L, char *marea, unsigned long Num)
// 1 -> Unknown area
// 2 -> Node cant rescan this area
{
unsigned long Total, MsgNum, Area = 0;
fa_list *sbl = NULL;
fidoaddr *l;
int First, Found;
unsigned long rescanned;
sysconnect Link;
unsigned long Total, MsgNum, Area = 0;
fa_list *sbl = NULL;
fidoaddr *l;
int First, Found;
unsigned long rescanned;
sysconnect Link;
IsDoing("ReScan mail");
IsDoing("ReScan mail");
if (!do_quiet) {
colour(9, 0);
printf("ReScan mail\n");
colour(3, 0);
fflush(stdout);
}
l = faddr2fido( L );
rescanned = 0L;
if (!SearchMsgs(marea)) {
Mgrlog("ReScan of unknown echo area %s", marea);
return 1;
}
First = TRUE;
Found = FALSE;
while (GetMsgSystem(&Link, First)) {
First = FALSE;
if ((l->zone == Link.aka.zone) && (l->net == Link.aka.net) && (l->node == Link.aka.node) && (l->point == Link.aka.point)) {
Found = TRUE;
break;
}
}
if (!Found) {
Mgrlog("Node %s can't Rescan area %s", L, marea);
return 2;
}
if ((msgs.Active) && ((msgs.Type == ECHOMAIL) || (msgs.Type == NEWS) || (msgs.Type == LIST))) {
if (!do_quiet) {
colour(9, 0);
printf("ReScan mail\n");
colour(3, 0);
fflush(stdout);
}
colour(3, 0);
printf("\r%5ld .. %-40s", Area, msgs.Name);
colour(13, 0);
fflush(stdout);
}
l = faddr2fido( L );
rescanned = 0L;
if (!SearchMsgs(marea)) {
syslog('+',"ReScan of unknown echo area %s", marea);
return 1;
}
if (Msg_Open(msgs.Base)) {
Total = Msg_Number();
MsgNum = 1;
if (Num!=0 && Num<Total)
MsgNum = (Total + 1 - Num);
First = TRUE;
Found = FALSE;
while (GetMsgSystem(&Link, First)) {
First = FALSE;
if ((l->zone == Link.aka.zone) &&
(l->net == Link.aka.net) &&
(l->node == Link.aka.node) &&
(l->point == Link.aka.point)) {
Found = TRUE;
break;
while (MsgNum<=Total){
if (Msg_ReadHeader(MsgNum)) {
if (Msg_Lock(15L)) {
fill_list(&sbl, aka2str(msgs.Aka), NULL);
fill_list(&sbl, aka2str(Link.aka), NULL);
sort_list(&sbl);
ExportEcho(Link, MsgNum, &sbl);
tidy_falist(&sbl);
Msg_UnLock();
rescanned++;
}
}
MsgNum++;
}
Msg_Close();
}
if (!Found) {
Syslog('+',"Node %s can't Rescan area %s", L, marea);
return 2;
}
}
if ((msgs.Active) && (msgs.Type == ECHOMAIL)) {
if (!do_quiet) {
colour(3, 0);
printf("\r%5ld .. %-40s", Area, msgs.Name);
colour(13, 0);
fflush(stdout);
}
if (!do_quiet) {
printf("\r \r");
fflush(stdout);
}
if (Msg_Open(msgs.Base)) {
Total = Msg_Number();
MsgNum = 1;
if (Num!=0 && Num<Total)
MsgNum = (Total + 1 - Num);
while (MsgNum<=Total){
if (Msg_ReadHeader(MsgNum)) {
if (Msg_Lock(15L)) {
fill_list(&sbl, aka2str(msgs.Aka), NULL);
fill_list(&sbl, aka2str(Link.aka), NULL);
sort_list(&sbl);
ExportEcho(Link, MsgNum, &sbl);
tidy_falist(&sbl);
Msg_UnLock();
rescanned++;
}
}
MsgNum++;
}
Msg_Close();
}
}
if (!do_quiet) {
printf("\r \r");
fflush(stdout);
}
Syslog('+',"Rescan OK. %ul messages rescanned", rescanned);
return 0;
Mgrlog("Rescan OK. %ul messages rescanned", rescanned);
return 0;
}

View File

@ -287,7 +287,7 @@ void EditTicSystem(sysconnect *Sys)
if (refresh) {
clr_index();
set_color(WHITE, BLACK);
mvprintw( 5,6, "10.2.25 EDIT CONNECTION");
mvprintw( 5,6, "10.2.26 EDIT CONNECTION");
set_color(CYAN, BLACK);
mvprintw( 7,6, "1. Aka");
mvprintw( 8,6, "2. Send to");
@ -307,7 +307,7 @@ void EditTicSystem(sysconnect *Sys)
switch(select_menu(5)) {
case 0: (* Sys) = S;
return;
case 1: S.aka = PullUplink((char *)"10.2.25");
case 1: S.aka = PullUplink((char *)"10.2.26");
refresh = TRUE;
break;
case 2: E_BOOL( 8,24, S.sendto, "^Send^ files ^to^ this node")
@ -347,7 +347,7 @@ int EditTicConnections(FILE *fil)
for (;;) {
clr_index();
set_color(WHITE, BLACK);
mvprintw( 5, 5, "10.2.25 TIC AREA CONNECTIONS");
mvprintw( 5, 5, "10.2.26 TIC AREA CONNECTIONS");
set_color(CYAN, BLACK);
y = 7;
x = 2;
@ -884,7 +884,7 @@ int EditTicRec(int Area)
}
show_int( 15,74, connections);
switch(select_menu(25)) {
switch(select_menu(26)) {
case 0:
crc1 = 0xffffffff;
crc1 = upd_crc32((char *)&tic, crc1, tichdr.recsize);