More AreaMgr/FileMgr fixes, added FileMgr Pause/Resume commands

This commit is contained in:
Michiel Broek 2002-03-02 15:42:08 +00:00
parent f00ac0d11d
commit bcbed5d356
4 changed files with 124 additions and 61 deletions

View File

@ -4633,7 +4633,10 @@ v0.33.20 10-Feb-2002
destination address. destination address.
Corrected spelling errors in the Areamgr and Filemgr help Corrected spelling errors in the Areamgr and Filemgr help
messages. messages.
Removed some debug logging from tge RFC->FTN gate. Removed some debug logging from the RFC->FTN gate.
Implemented the FileMgr and AreaMgr pause and resume commands.
Changed logging when AreaMgr/FileMgr commands did fail.
Some checks improved and fixed some potential sigsegv crashes.
mball: mball:
Will not crash anymore when it needs more then 10 minutes to Will not crash anymore when it needs more then 10 minutes to

View File

@ -631,15 +631,6 @@ void A_Unlinked(faddr *t, char *replyid)
void A_Global(faddr *, char *, FILE *);
void A_Global(faddr *t, char *Cmd, FILE *tmp)
{
ShiftBuf(Cmd, 1);
Syslog('m', " AreaMgr node %s global %s", ascfnode(t, 0x1f), Cmd);
}
void A_Disconnect(faddr *, char *, FILE *); void A_Disconnect(faddr *, char *, FILE *);
void A_Disconnect(faddr *t, char *Area, FILE *tmp) void A_Disconnect(faddr *t, char *Area, FILE *tmp)
{ {
@ -1016,7 +1007,6 @@ int AreaMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int fla
int i, rc = 0, spaces; int i, rc = 0, spaces;
char *Buf; char *Buf;
FILE *tmp, *np; FILE *tmp, *np;
fidoaddr Node;
a_help = a_stat = a_unlnk = a_list = a_query = FALSE; a_help = a_stat = a_unlnk = a_list = a_query = FALSE;
areamgr++; areamgr++;
@ -1048,8 +1038,7 @@ int AreaMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int fla
/* /*
* Make sure we have the nodes record loaded * Make sure we have the nodes record loaded
*/ */
memcpy(&Node, faddr2fido(f), sizeof(fidoaddr)); SearchNodeFaddr(f);
SearchNode(Node);
spaces = 0; spaces = 0;
for (i = 0; i < strlen(Buf); i++) { for (i = 0; i < strlen(Buf); i++) {
@ -1110,8 +1099,6 @@ int AreaMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int fla
MgrPasswd(f, Buf, tmp, 4); MgrPasswd(f, Buf, tmp, 4);
else if (!strncasecmp(Buf, "%notify", 7)) else if (!strncasecmp(Buf, "%notify", 7))
MgrNotify(f, Buf, tmp); MgrNotify(f, Buf, tmp);
else if (*(Buf) == '%')
A_Global(f, Buf, tmp);
else if (*(Buf) == '-') else if (*(Buf) == '-')
A_Disconnect(f, Buf, tmp); A_Disconnect(f, Buf, tmp);
else else

View File

@ -68,11 +68,11 @@ extern int echo_bad; /* Bad fileecho */
extern int echo_dupe; /* Dupe fileecho */ extern int echo_dupe; /* Dupe fileecho */
int filemgr = 0; /* Nr of FileMgr messages */ int filemgr = 0; /* Nr of FileMgr messages */
int f_help = FALSE; int f_help = FALSE; /* Send FileMgr help */
int f_list = FALSE; int f_list = FALSE; /* Send FileMgr list */
int f_query = FALSE; int f_query = FALSE; /* Send FileMgr query */
int f_stat = FALSE; int f_stat = FALSE; /* Send FileMgr status */
int f_unlnk = FALSE; int f_unlnk = FALSE; /* Send FileMgr unlink */
@ -101,8 +101,8 @@ void F_Help(faddr *t, char *replyid)
fprintf(fp, "%%UNLINKED To request a list of available fileecho areas\r"); fprintf(fp, "%%UNLINKED To request a list of available fileecho areas\r");
fprintf(fp, " to which you are not already connected\r"); fprintf(fp, " to which you are not already connected\r");
fprintf(fp, "%%STATUS To request a status report for your system\r"); fprintf(fp, "%%STATUS To request a status report for your system\r");
// fprintf(fp, "%%PAUSE To temporary disconnect from the connected areas\r"); fprintf(fp, "%%PAUSE To temporary disconnect from the connected areas\r");
// fprintf(fp, "%%RESUME To reconnect the temporary disconnected areas\r); fprintf(fp, "%%RESUME To reconnect the temporary disconnected areas\r");
fprintf(fp, "%%PWD=newpwd To set a new AreaMgr and FileMgr password\r"); fprintf(fp, "%%PWD=newpwd To set a new AreaMgr and FileMgr password\r");
// fprintf(fp, "%%RESCAN <area> To request all files from 'area' again\r"); // fprintf(fp, "%%RESCAN <area> To request all files from 'area' again\r");
fprintf(fp, "%%MESSGAE=On/Off To switch the message function on or off\r"); fprintf(fp, "%%MESSGAE=On/Off To switch the message function on or off\r");
@ -149,14 +149,24 @@ void F_Query(faddr *t, char *replyid)
if ((qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", (char *)"Your query request", replyid)) != NULL) { if ((qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", (char *)"Your query request", replyid)) != NULL) {
temp = calloc(PATH_MAX, sizeof(char)); temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/etc/tic.data", getenv("MBSE_ROOT")); sprintf(temp, "%s/etc/tic.data", getenv("MBSE_ROOT"));
fp = fopen(temp, "r"); if ((fp = fopen(temp, "r")) == NULL) {
WriteError("$Can't open %s", temp);
free(temp);
return;
}
fread(&tichdr, sizeof(tichdr), 1, fp); fread(&tichdr, sizeof(tichdr), 1, fp);
Cons = tichdr.syssize / sizeof(System); Cons = tichdr.syssize / sizeof(System);
sprintf(temp, "%s/etc/fgroups.data", getenv("MBSE_ROOT")); sprintf(temp, "%s/etc/fgroups.data", getenv("MBSE_ROOT"));
gp = fopen(temp, "r"); if ((gp = fopen(temp, "r")) == NULL) {
WriteError("$Can't open %s", temp);
free(temp);
fclose(fp);
return;
}
fread(&fgrouphdr, sizeof(fgrouphdr), 1, gp); fread(&fgrouphdr, sizeof(fgrouphdr), 1, gp);
free(temp);
fprintf(qp, "The following is a list of all connected file areas\r\r"); fprintf(qp, "The following is a list of all connected file areas\r\r");
@ -227,7 +237,6 @@ void F_Query(faddr *t, char *replyid)
fprintf(qp, "%s\r", TearLine()); fprintf(qp, "%s\r", TearLine());
CloseMail(qp, t); CloseMail(qp, t);
net_out++; net_out++;
free(temp);
} else } else
WriteError("Can't create netmail"); WriteError("Can't create netmail");
} }
@ -252,15 +261,26 @@ void F_List(faddr *t, char *replyid, int Notify)
if ((qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", (char *)"FileMgr List", replyid)) != NULL) { if ((qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", (char *)"FileMgr List", replyid)) != NULL) {
WriteFileGroups(qp, f); WriteFileGroups(qp, f);
temp = calloc(PATH_MAX, sizeof(char));
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/etc/tic.data", getenv("MBSE_ROOT")); sprintf(temp, "%s/etc/tic.data", getenv("MBSE_ROOT"));
fp = fopen(temp, "r"); if ((fp = fopen(temp, "r")) == NULL) {
WriteError("$Can't open %s", temp);
free(temp);
return;
}
fread(&tichdr, sizeof(tichdr), 1, fp); fread(&tichdr, sizeof(tichdr), 1, fp);
Cons = tichdr.syssize / sizeof(System); Cons = tichdr.syssize / sizeof(System);
sprintf(temp, "%s/etc/fgroups.data", getenv("MBSE_ROOT")); sprintf(temp, "%s/etc/fgroups.data", getenv("MBSE_ROOT"));
gp = fopen(temp, "r"); if ((gp = fopen(temp, "r")) == NULL) {
WriteError("$Can't open %s", temp);
free(temp);
fclose(fp);
return;
}
fread(&fgrouphdr, sizeof(fgrouphdr), 1, gp); fread(&fgrouphdr, sizeof(fgrouphdr), 1, gp);
free(temp);
fprintf(qp, "The following is a list of all file areas\r\r"); fprintf(qp, "The following is a list of all file areas\r\r");
@ -326,7 +346,6 @@ void F_List(faddr *t, char *replyid, int Notify)
fprintf(qp, "%s\r", TearLine()); fprintf(qp, "%s\r", TearLine());
CloseMail(qp, t); CloseMail(qp, t);
net_out++; net_out++;
free(temp);
} else } else
WriteError("Can't create netmail"); WriteError("Can't create netmail");
} }
@ -366,10 +385,14 @@ void F_Status(faddr *t, char *replyid)
fprintf(fp, " Last week Last month Total ever\r"); fprintf(fp, " Last week Last month Total ever\r");
fprintf(fp, " ---------- ---------- ----------\r"); fprintf(fp, " ---------- ---------- ----------\r");
fprintf(fp, "Files sent %-10ld %-10ld %-10ld\r", nodes.FilesSent.lweek, nodes.FilesSent.month[i], nodes.FilesSent.total); fprintf(fp, "Files sent %-10ld %-10ld %-10ld\r", nodes.FilesSent.lweek,
fprintf(fp, "KBytes sent %-10ld %-10ld %-10ld\r", nodes.F_KbSent.lweek, nodes.F_KbSent.month[i], nodes.F_KbSent.total); nodes.FilesSent.month[i], nodes.FilesSent.total);
fprintf(fp, "Files received %-10ld %-10ld %-10ld\r", nodes.FilesRcvd.lweek, nodes.FilesRcvd.month[i], nodes.FilesRcvd.total); fprintf(fp, "KBytes sent %-10ld %-10ld %-10ld\r", nodes.F_KbSent.lweek,
fprintf(fp, "KBytes received %-10ld %-10ld %-10ld\r", nodes.F_KbRcvd.lweek, nodes.F_KbRcvd.month[i], nodes.F_KbRcvd.total); nodes.F_KbSent.month[i], nodes.F_KbSent.total);
fprintf(fp, "Files received %-10ld %-10ld %-10ld\r", nodes.FilesRcvd.lweek,
nodes.FilesRcvd.month[i], nodes.FilesRcvd.total);
fprintf(fp, "KBytes received %-10ld %-10ld %-10ld\r", nodes.F_KbRcvd.lweek,
nodes.F_KbRcvd.month[i], nodes.F_KbRcvd.total);
fprintf(fp, "\rWith regards, %s\r\r", CFG.sysop_name); fprintf(fp, "\rWith regards, %s\r\r", CFG.sysop_name);
@ -398,14 +421,24 @@ void F_Unlinked(faddr *t, char *replyid)
if ((qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", (char *)"Your unlinked request", replyid)) != NULL) { if ((qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", (char *)"Your unlinked request", replyid)) != NULL) {
temp = calloc(PATH_MAX, sizeof(char)); temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/etc/tic.data", getenv("MBSE_ROOT")); sprintf(temp, "%s/etc/tic.data", getenv("MBSE_ROOT"));
fp = fopen(temp, "r"); if ((fp = fopen(temp, "r")) == NULL) {
WriteError("$Can't open %s", temp);
free(temp);
return;
}
fread(&tichdr, sizeof(tichdr), 1, fp); fread(&tichdr, sizeof(tichdr), 1, fp);
Cons = tichdr.syssize / sizeof(System); Cons = tichdr.syssize / sizeof(System);
sprintf(temp, "%s/etc/fgroups.data", getenv("MBSE_ROOT")); sprintf(temp, "%s/etc/fgroups.data", getenv("MBSE_ROOT"));
gp = fopen(temp, "r"); if ((gp = fopen(temp, "r")) == NULL) {
WriteError("$Can't open %s", temp);
free(temp);
fclose(fp);
return;
}
fread(&fgrouphdr, sizeof(fgrouphdr), 1, gp); fread(&fgrouphdr, sizeof(fgrouphdr), 1, gp);
free(temp);
fprintf(qp, "The following is a list of all available file areas\r\r"); fprintf(qp, "The following is a list of all available file areas\r\r");
@ -474,22 +507,12 @@ void F_Unlinked(faddr *t, char *replyid)
fprintf(qp, "%s\r", TearLine()); fprintf(qp, "%s\r", TearLine());
CloseMail(qp, t); CloseMail(qp, t);
net_out++; net_out++;
free(temp);
} else } else
WriteError("Can't create netmail"); WriteError("Can't create netmail");
} }
void F_Global(faddr *, char *, FILE *);
void F_Global(faddr *t, char *Cmd, FILE *tmp)
{
ShiftBuf(Cmd, 1);
Syslog('m', " FileMgr node %s global %s", ascfnode(t, 0x1f), Cmd);
}
void F_Disconnect(faddr *, char *, FILE *); void F_Disconnect(faddr *, char *, FILE *);
void F_Disconnect(faddr *t, char *Area, FILE *tmp) void F_Disconnect(faddr *t, char *Area, FILE *tmp)
{ {
@ -500,7 +523,9 @@ void F_Disconnect(faddr *t, char *Area, FILE *tmp)
Syslog('+', "FileMgr: %s", Area); Syslog('+', "FileMgr: %s", Area);
ShiftBuf(Area, 1); ShiftBuf(Area, 1);
for (i = 0; i < strlen(Area); i++)
Area[i] = toupper(Area[i]);
if (!SearchTic(Area)) { if (!SearchTic(Area)) {
fprintf(tmp, "Area %s not found\n", Area); fprintf(tmp, "Area %s not found\n", Area);
Syslog('+', " Area not found"); Syslog('+', " Area not found");
@ -571,6 +596,8 @@ void F_Connect(faddr *t, char *Area, FILE *tmp)
if (Area[0] == '+') if (Area[0] == '+')
ShiftBuf(Area, 1); ShiftBuf(Area, 1);
for (i = 0; i < strlen(Area); i++)
Area[i] = toupper(Area[i]);
if (!SearchTic(Area)) { if (!SearchTic(Area)) {
fprintf(tmp, "Area %s not found\n", Area); fprintf(tmp, "Area %s not found\n", Area);
@ -640,7 +667,7 @@ void F_All(faddr *, int, FILE *, char *);
void F_All(faddr *t, int Connect, FILE *tmp, char *Grp) void F_All(faddr *t, int Connect, FILE *tmp, char *Grp)
{ {
FILE *fp, *gp; FILE *fp, *gp;
char *Group, temp[PATH_MAX]; char *Group, *temp;
faddr *f; faddr *f;
int i, Link, First = TRUE, Cons; int i, Link, First = TRUE, Cons;
sysconnect Sys; sysconnect Sys;
@ -659,13 +686,25 @@ void F_All(faddr *t, int Connect, FILE *tmp, char *Grp)
} }
f = bestaka_s(t); f = bestaka_s(t);
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/etc/tic.data", getenv("MBSE_ROOT")); sprintf(temp, "%s/etc/tic.data", getenv("MBSE_ROOT"));
fp = fopen(temp, "r+"); if ((fp = fopen(temp, "r+")) == NULL) {
WriteError("$Can't open %s", temp);
free(temp);
return;
}
fread(&tichdr, sizeof(tichdr), 1, fp); fread(&tichdr, sizeof(tichdr), 1, fp);
Cons = tichdr.syssize / sizeof(Sys); Cons = tichdr.syssize / sizeof(Sys);
sprintf(temp, "%s/etc/fgroups.data", getenv("MBSE_ROOT")); sprintf(temp, "%s/etc/fgroups.data", getenv("MBSE_ROOT"));
gp = fopen(temp, "r"); if ((gp = fopen(temp, "r")) == NULL) {
WriteError("$Can't open %s", temp);
free(temp);
fclose(fp);
return;
}
fread(&fgrouphdr, sizeof(fgrouphdr), 1, gp); fread(&fgrouphdr, sizeof(fgrouphdr), 1, gp);
free(temp);
while (TRUE) { while (TRUE) {
Group = GetNodeFileGrp(First); Group = GetNodeFileGrp(First);
@ -736,8 +775,12 @@ void F_All(faddr *t, int Connect, FILE *tmp, char *Grp)
void F_Group(faddr *, char *, int, FILE *); void F_Group(faddr *, char *, int, FILE *);
void F_Group(faddr *t, char *Area, int Connect, FILE *tmp) void F_Group(faddr *t, char *Area, int Connect, FILE *tmp)
{ {
int i;
ShiftBuf(Area, 2); ShiftBuf(Area, 2);
CleanBuf(Area); CleanBuf(Area);
for (i = 0; i < strlen(Area); i++)
Area[i] = toupper(Area[i]);
F_All(t, Connect, tmp, Area); F_All(t, Connect, tmp, Area);
} }
@ -746,10 +789,48 @@ void F_Group(faddr *t, char *Area, int Connect, FILE *tmp)
void F_Pause(faddr *, int, FILE *); void F_Pause(faddr *, int, FILE *);
void F_Pause(faddr *t, int Pause, FILE *tmp) void F_Pause(faddr *t, int Pause, FILE *tmp)
{ {
FILE *fp;
faddr *f;
int i, Cons;
sysconnect Sys;
char *temp;
if (Pause) if (Pause)
Syslog('+', "FileMgr: Pause"); Syslog('+', "FileMgr: Pause");
else else
Syslog('+', "FileMgr: Resume"); Syslog('+', "FileMgr: Resume");
f = bestaka_s(t);
Syslog('m', "Bestaka for %s is %s", ascfnode(t, 0x1f), ascfnode(f, 0x1f));
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/etc/tic.data", getenv("MBSE_ROOT"));
if ((fp = fopen(temp, "r+")) == NULL) {
WriteError("$Can't open %s", temp);
free(temp);
return;
}
fread(&tichdr, sizeof(tichdr), 1, fp);
Cons = tichdr.syssize / sizeof(Sys);
while (fread(&tic, tichdr.recsize, 1, fp) == 1) {
if (tic.Active) {
for (i = 0; i < Cons; i++) {
fread(&Sys, sizeof(Sys), 1, fp);
if ((metric(fido2faddr(Sys.aka), t) == METRIC_EQUAL) && (!Sys.cutoff)) {
Sys.pause = Pause;
fseek(fp, - sizeof(Sys), SEEK_CUR);
fwrite(&Sys, sizeof(Sys), 1, fp);
Syslog('+', "FileMgr: %s area %s", Pause?"Pause":"Resume", msgs.Tag);
fprintf(tmp, "%s area %s\n", Pause?"Pause":"Resume", msgs.Tag);
f_list = TRUE;
}
}
} else {
fseek(fp, tichdr.syssize, SEEK_CUR);
}
}
fclose(fp);
} }
@ -898,8 +979,6 @@ int FileMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int fla
F_Message(f, Buf, tmp); F_Message(f, Buf, tmp);
else if (!strncasecmp(Buf, "%tick", 5)) else if (!strncasecmp(Buf, "%tick", 5))
F_Tick(f, Buf, tmp); F_Tick(f, Buf, tmp);
else if (*(Buf) == '%')
F_Global(f, Buf, tmp);
else if (*(Buf) == '-') else if (*(Buf) == '-')
F_Disconnect(f, Buf, tmp); F_Disconnect(f, Buf, tmp);
else else

View File

@ -189,8 +189,6 @@ void CleanBuf(char *Buf)
*/ */
void MgrPasswd(faddr *t, char *Buf, FILE *tmp, int Len) void MgrPasswd(faddr *t, char *Buf, FILE *tmp, int Len)
{ {
fidoaddr Node;
ShiftBuf(Buf, Len); ShiftBuf(Buf, Len);
CleanBuf(Buf); CleanBuf(Buf);
@ -205,8 +203,7 @@ void MgrPasswd(faddr *t, char *Buf, FILE *tmp, int Len)
fprintf(tmp, "AreaMgr and FileMgr password is now \"%s\"\n", nodes.Apasswd); fprintf(tmp, "AreaMgr and FileMgr password is now \"%s\"\n", nodes.Apasswd);
Syslog('+', "XxxxMgr: Password \"%s\" for node %s", nodes.Apasswd, ascfnode(t, 0x1f)); Syslog('+', "XxxxMgr: Password \"%s\" for node %s", nodes.Apasswd, ascfnode(t, 0x1f));
UpdateNode(); UpdateNode();
memcpy(&Node, faddr2fido(t), sizeof(fidoaddr)); SearchNodeFaddr(t);
SearchNode(Node);
} }
@ -216,8 +213,6 @@ void MgrPasswd(faddr *t, char *Buf, FILE *tmp, int Len)
*/ */
void MgrNotify(faddr *t, char *Buf, FILE *tmp) void MgrNotify(faddr *t, char *Buf, FILE *tmp)
{ {
fidoaddr Node;
/* /*
* First strip leading garbage * First strip leading garbage
*/ */
@ -232,8 +227,7 @@ void MgrNotify(faddr *t, char *Buf, FILE *tmp)
return; return;
UpdateNode(); UpdateNode();
memcpy(&Node, faddr2fido(t), sizeof(fidoaddr)); SearchNodeFaddr(t);
SearchNode(Node);
Syslog('+', "XxxxMgr: Notify %s", GetBool(nodes.Notify)); Syslog('+', "XxxxMgr: Notify %s", GetBool(nodes.Notify));
fprintf(tmp, "AreaMgr and FileMgr Notify is %s\n", GetBool(nodes.Notify)); fprintf(tmp, "AreaMgr and FileMgr Notify is %s\n", GetBool(nodes.Notify));
} }