Added checks for mbsetup message edit

This commit is contained in:
Michiel Broek 2002-02-16 14:39:53 +00:00
parent d6deb46033
commit 4379a9594b
5 changed files with 157 additions and 57 deletions

View File

@ -4600,6 +4600,9 @@ v0.33.20 10-Feb-2002
mbsetup:
In message groups added default settings for auto area
creation.
Added servicename filemgr to the filemgr services.
When adding or deleting a message area, several extra checks
are done.
mbfido:
In AreaMgr and FileMgr changed aka matching for area

View File

@ -891,7 +891,7 @@ struct msgareas {
time_t LastPosted; /* Last time msg posted */
char Newsgroup[81]; /* Newsgroup/Mailinglist */
char Distribution[17]; /* Ng distribution */
char Moderator[65]; /* Moderator/Email-address */
char xModerator[65];
int Rfccode; /* RFC characterset */
int Ftncode; /* FTN characterset */
int MaxArticles; /* Max. newsarticles to get */

View File

@ -45,7 +45,7 @@ int create_msgarea(char *marea, faddr *p_from)
char *temp, *buf, *tag, *desc, *p;
FILE *gp, *ap, *mp;
long offset;
int i;
int i, rc = 0;
sysconnect System;
temp = calloc(PATH_MAX, sizeof(char));
@ -102,58 +102,66 @@ int create_msgarea(char *marea, faddr *p_from)
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;
rc = 1;
break;
}
/*
* Skip systems
*/
fseek(mp, msgshdr.syssize, SEEK_CUR);
}
/*
* No free slot at the end, append a slot.
*/
}
if (!rc) {
Syslog('m', "No free slot, append after last record");
fseek(mp, 0, SEEK_END);
rc = 1;
}
offset = ((ftell(mp) - msgshdr.hdrsize) / (msgshdr.recsize + msgshdr.syssize)) + 1;
memset(&msgs, 0, sizeof(msgs));
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);
Syslog('+', "Auto created echo %s, group %s, area %ld, for node %s",
msgs.Tag, msgs.Group, offset, ascfnode(p_from, 0x1f));
return TRUE;
} /* if (strcmp(tag, marea) == 0) */
}
free(buf);
fclose(ap);

View File

@ -304,6 +304,25 @@ void InitMsgRec(void)
void DeleteJAM(char *);
void DeleteJAM(char *Base)
{
char *temp;
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s.jdt", Base);
unlink(temp);
sprintf(temp, "%s.jdx", Base);
unlink(temp);
sprintf(temp, "%s.jhr", Base);
unlink(temp);
sprintf(temp, "%s.jlr", Base);
unlink(temp);
free(temp);
}
int AppendMsgarea(void);
int AppendMsgarea()
{
@ -959,7 +978,8 @@ void MsgGlobal(void)
break;
case 12:if (msgs.Active) {
msgs.Active = FALSE;
memset(&msgs.Name, 0, sizeof(msgs.Name));
DeleteJAM(msgs.Base);
memset(&msgs, 0, sizeof(msgs));
if (SaveMsgRec(marea, FALSE) == 0) {
Done++;
Syslog('+', "Deleted message area %s", msgs.Tag);
@ -994,8 +1014,9 @@ int EditMsgRec(int);
int EditMsgRec(int Area)
{
unsigned long crc1;
int tmp, i, changed = FALSE;
int tmp, i, connections, changed = FALSE, Active;
sysconnect System;
char *temp;
clr_index();
IsDoing("Edit Msg Area");
@ -1042,6 +1063,17 @@ int EditMsgRec(int Area)
show_bool(16,76, msgs.UnSecure);
show_bool(17,76, msgs.OLR_Default);
show_bool(18,76, msgs.OLR_Forced);
connections = 0;
switch (msgs.Type) {
case ECHOMAIL:
case NEWS:
case LIST: fseek(tfil, 0, SEEK_SET);
while (fread(&System, sizeof(System), 1, tfil) == 1)
if (System.aka.zone)
connections++;
show_int(19,76, connections);
break;
}
switch(select_menu(29)) {
case 0:
@ -1053,12 +1085,19 @@ int EditMsgRec(int Area)
crc1 = upd_crc32((char *)&System, crc1, sizeof(sysconnect));
}
if ((MsgCrc != crc1) || (changed)) {
if (yes_no((char *)"Record is changed, save") == 1) {
if (SaveMsgRec(Area, TRUE) == -1)
return -1;
MsgUpdated = 1;
Syslog('+', "Saved record %d", Area);
}
if (msgs.Active && !strlen(msgs.Base)) {
errmsg((char *)"JAM message base is not set");
break;
} else if (msgs.Active && !strlen(msgs.Group) &&
(msgs.Type == ECHOMAIL || msgs.Type == NEWS || msgs.Type == LIST)) {
errmsg((char *)"Message area has no group assigned");
break;
} else if (yes_no((char *)"Record is changed, save") == 1) {
if (SaveMsgRec(Area, TRUE) == -1)
return -1;
MsgUpdated = 1;
Syslog('+', "Saved record %d", Area);
}
}
IsDoing("Browsing Menu");
return 0;
@ -1119,7 +1158,52 @@ int EditMsgRec(int Area)
break;
}
break;
case 18:E_BOOL(16,52, msgs.Active, "Is this area ^Active^")
case 18:Active = edit_bool(16,52, msgs.Active, (char *)"Is this area ^Active^");
if (msgs.Active && !Active) {
/*
* Attempt to deactivate area, do some checks.
*/
if (connections) {
if (yes_no((char *)"There are nodes connected, disconnect them") == 0)
Active = TRUE;
}
if (!Active) {
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s.jhr", msgs.Base);
if (strlen(msgs.Base) && (file_size(temp) != 1024)) {
if (yes_no((char *)"There are messages in this area, delete them") == 0)
Active = TRUE;
}
free(temp);
}
if (!Active) {
/*
* Make it so
*/
DeleteJAM(msgs.Base);
memset(&System, 0, sizeof(System));
fseek(tfil, 0, SEEK_SET);
for (i = 0; i < (msgshdr.syssize / sizeof(sysconnect)); i++)
fwrite(&System, sizeof(System), 1, tfil);
InitMsgRec();
Syslog('+', "Deleted message area %d", Area);
changed = TRUE;
}
}
if (!msgs.Active && Active) {
InitMsgRec();
msgs.Active = TRUE;
/*
* Clear connections, just in case from older mbse versions
* might have left garbage here.
*/
fseek(tfil, 0, SEEK_SET);
memset(&System, 0, sizeof(System));
for (i = 0; i < (msgshdr.syssize / sizeof(sysconnect)); i++)
fwrite(&System, sizeof(System), 1, tfil);
}
SetScreen();
break;
case 19:E_SEC( 17,52, msgs.RDSec, "9.2 EDIT READ SECURITY", SetScreen)
case 20:E_SEC( 18,52, msgs.WRSec, "9.2 EDIT WRITE SECURITY", SetScreen)
case 21:E_SEC( 19,52, msgs.SYSec, "9.2 EDIT SYSOP SECURITY", SetScreen)

View File

@ -64,18 +64,23 @@ int CountService(void)
servhdr.lastupd = time(NULL);
fwrite(&servhdr, sizeof(servhdr), 1, fil);
memset(&servrec, 0, sizeof(servrec));
sprintf(servrec.Service, "UUCP");
servrec.Action = EMAIL;
servrec.Active = TRUE;
sprintf(servrec.Service, "UUCP");
fwrite(&servrec, sizeof(servrec), 1, fil);
sprintf(servrec.Service, "areamgr");
servrec.Action = AREAMGR;
sprintf(servrec.Service, "areamgr");
fwrite(&servrec, sizeof(servrec), 1, fil);
sprintf(servrec.Service, "gecho");
fwrite(&servrec, sizeof(servrec), 1, fil);
sprintf(servrec.Service, "fmail");
fwrite(&servrec, sizeof(servrec), 1, fil);
servrec.Action = FILEMGR;
sprintf(servrec.Service, "filemgr");
fwrite(&servrec, sizeof(servrec), 1, fil);
sprintf(servrec.Service, "allfix");
fwrite(&servrec, sizeof(servrec), 1, fil);
sprintf(servrec.Service, "mbtic");