Several mbsetup protections and checks added

This commit is contained in:
Michiel Broek 2003-01-31 21:49:29 +00:00
parent d95fc43626
commit 08542985ff
8 changed files with 606 additions and 526 deletions

View File

@ -92,7 +92,7 @@ m_tty.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/use
mutil.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h ../lib/mberrors.h screen.h mutil.h mutil.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h ../lib/mberrors.h screen.h mutil.h
m_archive.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../paths.h screen.h mutil.h ledit.h stlist.h m_global.h m_archive.h m_archive.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../paths.h screen.h mutil.h ledit.h stlist.h m_global.h m_archive.h
m_fdb.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h screen.h mutil.h ledit.h m_global.h m_farea.h m_fdb.h m_fdb.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h screen.h mutil.h ledit.h m_global.h m_farea.h m_fdb.h
m_global.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/mberrors.h screen.h mutil.h ledit.h m_node.h m_marea.h m_ticarea.h m_new.h m_global.h m_global.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/mberrors.h screen.h mutil.h ledit.h m_node.h m_marea.h m_ticarea.h m_new.h m_fgroup.h m_mgroup.h m_global.h
m_magic.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h screen.h mutil.h ledit.h stlist.h m_ticarea.h m_global.h m_magic.h m_magic.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h screen.h mutil.h ledit.h stlist.h m_ticarea.h m_global.h m_magic.h
m_mgroup.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h screen.h mutil.h ledit.h stlist.h m_global.h m_node.h m_marea.h m_mgroup.h m_mgroup.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h screen.h mutil.h ledit.h stlist.h m_global.h m_node.h m_marea.h m_mgroup.h
m_node.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h screen.h mutil.h ledit.h grlist.h stlist.h m_global.h m_lang.h m_ticarea.h m_marea.h m_node.h m_node.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h screen.h mutil.h ledit.h grlist.h stlist.h m_global.h m_lang.h m_ticarea.h m_marea.h m_node.h

View File

@ -502,9 +502,8 @@ int EditFGrpRec(int Area)
void EditFGroup(void) void EditFGroup(void)
{ {
int records, i, o, x, y; int records, i, o, x, y;
char pick[12]; char pick[12], temp[PATH_MAX];
FILE *fil; FILE *fil;
char temp[PATH_MAX];
long offset; long offset;
clr_index(); clr_index();
@ -575,6 +574,7 @@ void EditFGroup(void)
} }
if (strncmp(pick, "A", 1) == 0) { if (strncmp(pick, "A", 1) == 0) {
if (records < CFG.tic_groups) {
working(1, 0, 0); working(1, 0, 0);
if (AppendFGroup() == 0) { if (AppendFGroup() == 0) {
records++; records++;
@ -582,15 +582,18 @@ void EditFGroup(void)
} else } else
working(2, 0, 0); working(2, 0, 0);
working(0, 0, 0); working(0, 0, 0);
} else {
errmsg("Cannot add group, change global setting in menu 1.13.5");
}
} }
if (strncmp(pick, "N", 1) == 0) if (strncmp(pick, "N", 1) == 0)
if ((o + 20) < records) if ((o + 20) < records)
o = o + 20; o += 20;
if (strncmp(pick, "P", 1) == 0) if (strncmp(pick, "P", 1) == 0)
if ((o - 20) >= 0) if ((o - 20) >= 0)
o = o - 20; o -= 20;
if ((atoi(pick) >= 1) && (atoi(pick) <= records)) { if ((atoi(pick) >= 1) && (atoi(pick) <= records)) {
EditFGrpRec(atoi(pick)); EditFGrpRec(atoi(pick));

View File

@ -44,6 +44,8 @@
#include "m_marea.h" #include "m_marea.h"
#include "m_ticarea.h" #include "m_ticarea.h"
#include "m_new.h" #include "m_new.h"
#include "m_fgroup.h"
#include "m_mgroup.h"
#include "m_global.h" #include "m_global.h"
@ -822,6 +824,8 @@ void e_flags(int Users)
void e_ticconf(void) void e_ticconf(void)
{ {
int temp;
clr_index(); clr_index();
set_color(WHITE, BLACK); set_color(WHITE, BLACK);
mvprintw( 5, 6, "1.13 EDIT FILEECHO PROCESSING"); mvprintw( 5, 6, "1.13 EDIT FILEECHO PROCESSING");
@ -870,17 +874,29 @@ void e_ticconf(void)
case 1: E_INT( 7,18, CFG.tic_days, "Number of days to ^keep^ files on hold.") case 1: E_INT( 7,18, CFG.tic_days, "Number of days to ^keep^ files on hold.")
case 2: E_STR( 8,18,20, CFG.hatchpasswd, "Enter the internal ^hatch^ password.") case 2: E_STR( 8,18,20, CFG.hatchpasswd, "Enter the internal ^hatch^ password.")
case 3: E_INT( 9,18, CFG.drspace, "Enter the minimal ^free drivespace^ in KBytes.") case 3: E_INT( 9,18, CFG.drspace, "Enter the minimal ^free drivespace^ in KBytes.")
case 4: CFG.tic_systems = edit_int(10,18, CFG.tic_systems, case 4: temp = CFG.tic_systems;
(char *)"Enter the maximum number of ^connected systems^ in the database."); temp = edit_int(10,18, temp, (char *)"Enter the maximum number of ^connected systems^ in the database.");
if (temp < CountNoderec()) {
errmsg("You have %d nodes defined", CountNoderec());
show_int(10,18, CFG.tic_systems);
} else {
CFG.tic_systems = temp;
if ((OpenTicarea() == 0)) if ((OpenTicarea() == 0))
CloseTicarea(TRUE); CloseTicarea(TRUE);
working(0, 0, 0); working(0, 0, 0);
}
break; break;
case 5: CFG.tic_groups = edit_int(11,18, CFG.tic_groups, case 5: temp = CFG.tic_groups;
(char *)"Enter the maximum number of ^fileecho groups^ in the database."); temp = edit_int(11,18, temp, (char *)"Enter the maximum number of ^fileecho groups^ in the database.");
if (temp < CountFGroup()) {
errmsg("You have %d groups defined", CountFGroup());
show_int(11,18, CFG.tic_groups);
} else {
CFG.tic_groups = temp;
if ((OpenNoderec() == 0)) if ((OpenNoderec() == 0))
CloseNoderec(TRUE); CloseNoderec(TRUE);
working(0, 0, 0); working(0, 0, 0);
}
break; break;
case 6: E_INT( 12,18, CFG.tic_dupes, "Enter the maximum number of ^dupes^ in the dupe database.") case 6: E_INT( 12,18, CFG.tic_dupes, "Enter the maximum number of ^dupes^ in the dupe database.")
@ -954,6 +970,8 @@ void s_fidomailcfg(void)
void e_fidomailcfg(void) void e_fidomailcfg(void)
{ {
int temp;
s_fidomailcfg(); s_fidomailcfg();
for (;;) { for (;;) {
switch(select_menu(19)) { switch(select_menu(19)) {
@ -968,17 +986,29 @@ void e_fidomailcfg(void)
case 8: E_INT( 14,16, CFG.toss_old, "^Reject^ mail older then days, 0 means never reject.") case 8: E_INT( 14,16, CFG.toss_old, "^Reject^ mail older then days, 0 means never reject.")
case 9: E_INT( 15,16, CFG.defmsgs, "The default maximum number of ^messages^ in each mail area.") case 9: E_INT( 15,16, CFG.defmsgs, "The default maximum number of ^messages^ in each mail area.")
case 10:E_INT( 16,16, CFG.defdays, "The default maximum ^age in days^ in each mail area.") case 10:E_INT( 16,16, CFG.defdays, "The default maximum ^age in days^ in each mail area.")
case 11:CFG.toss_systems = edit_int(17,16, CFG.toss_systems, case 11:temp = CFG.toss_systems;
(char *)"The maximum number of connected ^systems^ in the database."); temp = edit_int(17,16, temp, (char *)"The maximum number of connected ^systems^ in the database.");
if (temp < CountNoderec()) {
errmsg("You have %d nodes defined", CountNoderec());
show_int( 17,16, CFG.toss_systems);
} else {
CFG.toss_systems = temp;
if ((OpenMsgarea() == 0)) if ((OpenMsgarea() == 0))
CloseMsgarea(TRUE); CloseMsgarea(TRUE);
working(0, 0, 0); working(0, 0, 0);
}
break; break;
case 12:CFG.toss_groups = edit_int(18,16, CFG.toss_groups, case 12:temp = CFG.toss_groups;
(char *)"The maximum number of ^groups^ in the database."); temp = edit_int(18,16, temp, (char *)"The maximum number of ^groups^ in the database.");
if (temp < CountMGroup()) {
errmsg("You have %d groups defined", CountMGroup());
show_int( 18,16, CFG.toss_groups);
} else {
CFG.toss_groups = temp;
if ((OpenNoderec() == 0)) if ((OpenNoderec() == 0))
CloseNoderec(TRUE); CloseNoderec(TRUE);
working(0, 0, 0); working(0, 0, 0);
}
break; break;
case 13:E_BOOL(12,58, CFG.addr4d, "Use ^4d^ addressing instead of ^5d^ addressing.") case 13:E_BOOL(12,58, CFG.addr4d, "Use ^4d^ addressing instead of ^5d^ addressing.")
case 14:E_INT( 13,58, CFG.new_split, "Gently ^split^ newfiles reports after n kilobytes (12..60).") case 14:E_INT( 13,58, CFG.new_split, "Gently ^split^ newfiles reports after n kilobytes (12..60).")
@ -1162,6 +1192,8 @@ void s_newfiles(void)
void e_newfiles(void) void e_newfiles(void)
{ {
int temp;
s_newfiles(); s_newfiles();
for (;;) { for (;;) {
set_color(WHITE, BLACK); set_color(WHITE, BLACK);
@ -1172,15 +1204,21 @@ void e_newfiles(void)
switch(select_menu(3)) { switch(select_menu(3)) {
case 0: return; case 0: return;
case 1: E_INT(7,16, CFG.newdays, "Add files younger than this in newfiles report.") case 1: E_INT(7,16, CFG.newdays, "Add files younger than this in newfiles report.")
case 2: E_SEC(8,16, CFG.security, "1.14 NEWFILES REPORTS SECURITY", s_newfiles) case 2: E_SEC(8,16, CFG.security, "1.16 NEWFILES REPORTS SECURITY", s_newfiles)
case 3: CFG.new_groups = edit_int( 9, 16, CFG.new_groups, case 3: temp = CFG.new_groups;
(char *)"The maximum of ^newfiles^ groups in the newfiles database"); temp = edit_int( 9, 16, temp, (char *)"The maximum of ^newfiles^ groups in the newfiles database");
if (temp < CountNewfiles()) {
errmsg("You have %d newfiles reports defined", CountNewfiles());
show_int( 9,16, CFG.new_groups);
} else {
CFG.new_groups = temp;
if (OpenNewfiles() == 0) if (OpenNewfiles() == 0)
CloseNewfiles(TRUE); CloseNewfiles(TRUE);
working(0, 0, 0); working(0, 0, 0);
}
break; break;
} }
}; }
} }

View File

@ -1334,12 +1334,10 @@ int EditMsgRec(int Area)
void EditMsgarea(void) void EditMsgarea(void)
{ {
int records, i, o, y; int records, rc, i, o, y, from, too;
char pick[12]; char pick[12], temp[PATH_MAX];
FILE *fil; FILE *fil;
char temp[PATH_MAX];
long offset; long offset;
int from, too;
sysconnect System; sysconnect System;
clr_index(); clr_index();
@ -1433,16 +1431,42 @@ void EditMsgarea(void)
from = edit_int(LINES -3, 10, from, (char *)"Wich ^area^ you want to move"); from = edit_int(LINES -3, 10, from, (char *)"Wich ^area^ you want to move");
mvprintw(LINES -3,15, "To"); mvprintw(LINES -3,15, "To");
too = edit_int(LINES -3, 18, too, (char *)"Too which ^area^ to move"); too = edit_int(LINES -3, 18, too, (char *)"Too which ^area^ to move");
if ((LoadMsgRec(from, TRUE) == -1) || (!msgs.Active)) { rc = 0;
errmsg((char *)"The originating area is invalid");
/*
* Check originating area
*/
if (from == 0) {
errmsg((char *)"The originating area cannot be zero");
rc = 1;
}
if (!rc && LoadMsgRec(from, TRUE) == -1) {
errmsg((char *)"The originating area does not exist");
rc = 1;
}
if (!rc)
fclose(tfil); fclose(tfil);
} else { if (!rc && !msgs.Active) {
fclose(tfil); errmsg((char *)"The originating area is not in use");
if ((LoadMsgRec(too, TRUE) == -1) || (msgs.Active)) { rc = 1;
errmsg((char *)"The destination area is invalid"); }
fclose(tfil);
} else { if (!rc && (too == 0)) {
errmsg((char *)"The destination area cannot be zero");
rc = 1;
}
if (!rc && LoadMsgRec(too, TRUE) == -1) {
errmsg((char *)"The destination area does not exist");
rc = 1;
}
if (!rc)
fclose(tfil); fclose(tfil);
if (!rc && (msgs.Active)) {
errmsg((char *)"The destination area is in use");
rc = 1;
}
if (!rc) {
LoadMsgRec(from, TRUE); LoadMsgRec(from, TRUE);
SaveMsgRec(too, TRUE); SaveMsgRec(too, TRUE);
LoadMsgRec(from, TRUE); LoadMsgRec(from, TRUE);
@ -1454,7 +1478,7 @@ void EditMsgarea(void)
} }
SaveMsgRec(from, TRUE); SaveMsgRec(from, TRUE);
MsgUpdated = 1; MsgUpdated = 1;
} Syslog('+', "Moved message area %d to %d", from, too);
} }
} }

View File

@ -436,9 +436,8 @@ int EditMGrpRec(int Area)
void EditMGroup(void) void EditMGroup(void)
{ {
int records, i, o, x, y; int records, i, o, x, y;
char pick[12]; char pick[12], temp[PATH_MAX];
FILE *fil; FILE *fil;
char temp[PATH_MAX];
long offset; long offset;
clr_index(); clr_index();
@ -509,6 +508,7 @@ void EditMGroup(void)
} }
if (strncmp(pick, "A", 1) == 0) { if (strncmp(pick, "A", 1) == 0) {
if (records < CFG.toss_groups) {
working(1, 0, 0); working(1, 0, 0);
if (AppendMGroup() == 0) { if (AppendMGroup() == 0) {
records++; records++;
@ -516,7 +516,11 @@ void EditMGroup(void)
} else } else
working(2, 0, 0); working(2, 0, 0);
working(0, 0, 0); working(0, 0, 0);
} else {
errmsg("Cannot add group, change global setting in menu 1.14.12");
} }
}
if (strncmp(pick, "N", 1) == 0) if (strncmp(pick, "N", 1) == 0)
if ((o + 20) < records) if ((o + 20) < records)

View File

@ -437,9 +437,8 @@ int EditNewRec(int Area)
void EditNewfiles(void) void EditNewfiles(void)
{ {
int records, i, o, x, y; int records, i, o, x, y;
char pick[12]; char pick[12], temp[PATH_MAX];
FILE *fil; FILE *fil;
char temp[PATH_MAX];
long offset; long offset;
clr_index(); clr_index();
@ -507,6 +506,7 @@ void EditNewfiles(void)
} }
if (strncmp(pick, "A", 1) == 0) { if (strncmp(pick, "A", 1) == 0) {
if (records > CFG.new_groups) {
working(1, 0, 0); working(1, 0, 0);
if (AppendNewfiles() == 0) { if (AppendNewfiles() == 0) {
records++; records++;
@ -514,6 +514,9 @@ void EditNewfiles(void)
} else } else
working(2, 0, 0); working(2, 0, 0);
working(0, 0, 0); working(0, 0, 0);
} else {
errmsg("Cannot add, change global setting in menu 1.16.3");
}
} }
if (strncmp(pick, "N", 1) == 0) if (strncmp(pick, "N", 1) == 0)

View File

@ -4,7 +4,7 @@
* Purpose ...............: Nodes Setup Program * Purpose ...............: Nodes Setup Program
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2002 * Copyright (C) 1997-2003
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -55,7 +55,6 @@ int NodeUpdated = 0;
* Count nr of nodes records in the database. * Count nr of nodes records in the database.
* Creates the database if it doesn't exist. * Creates the database if it doesn't exist.
*/ */
int CountNoderec(void);
int CountNoderec(void) int CountNoderec(void)
{ {
FILE *fil; FILE *fil;
@ -1181,9 +1180,8 @@ int EditNodeRec(int Area)
void EditNodes(void) void EditNodes(void)
{ {
int records, i, o, x, y; int records, i, o, x, y;
char pick[12]; char pick[12], temp[PATH_MAX];
FILE *fil; FILE *fil;
char temp[PATH_MAX];
long offset; long offset;
clr_index(); clr_index();
@ -1254,6 +1252,7 @@ void EditNodes(void)
} }
if (strncmp(pick, "A", 1) == 0) { if (strncmp(pick, "A", 1) == 0) {
if ((records < CFG.toss_systems) && (records < CFG.tic_systems)) {
working(1, 0, 0); working(1, 0, 0);
if (AppendNoderec() == 0) { if (AppendNoderec() == 0) {
records++; records++;
@ -1261,6 +1260,13 @@ void EditNodes(void)
} else } else
working(2, 0, 0); working(2, 0, 0);
working(0, 0, 0); working(0, 0, 0);
} else {
if ((records + 1) > CFG.toss_systems) {
errmsg("Cannot add node, change global setting in menu 1.14.11");
} else {
errmsg("Cannot add node, change global setting in menu 1.13.4");
}
}
} }
if (strncmp(pick, "N", 1) == 0) if (strncmp(pick, "N", 1) == 0)

View File

@ -1,6 +1,9 @@
#ifndef _NODE_H #ifndef _NODE_H
#define _NODE_H #define _NODE_H
/* $Id$ */
int CountNoderec(void);
int OpenNoderec(void); int OpenNoderec(void);
void CloseNoderec(int); void CloseNoderec(int);
int GroupInNode(char *, int); int GroupInNode(char *, int);
@ -10,4 +13,3 @@ int node_doc(FILE *, FILE *, int);
fidoaddr PullUplink(char *); fidoaddr PullUplink(char *);
#endif #endif