Added locking for mbsetup

This commit is contained in:
Michiel Broek 2002-05-04 19:45:19 +00:00
parent e3961d8449
commit ff8ee89ac1
20 changed files with 148 additions and 5 deletions

View File

@ -4665,6 +4665,13 @@ v0.33.20 10-Feb-2002
Fixed a non understandable logmessage in check if nodes are Fixed a non understandable logmessage in check if nodes are
connected to file and or mail groups. connected to file and or mail groups.
It is now possible to reset a users time left for today. It is now possible to reset a users time left for today.
The top statusbar now displays the bbs Free/Down/Busy status.
Some dangerous menus cannot be entered anymore while some
programs are being used, ie. the bbs must be free. When these
menus are entered, the bbs will be closed for use.
mbmon:
The top statusbar now displays the bbs Free/Down/Busy status.
mbfido: mbfido:
In AreaMgr and FileMgr changed aka matching for area In AreaMgr and FileMgr changed aka matching for area
@ -4838,6 +4845,10 @@ v0.33.20 10-Feb-2002
would kill that user because the last login date wasn't set. would kill that user because the last login date wasn't set.
It will use the registration date instead. It will use the registration date instead.
mbstat:
The timeout for the wait command was wrong due to a wrong
upsdown semafore test.
hatch: hatch:
A new shellscript to hatch files in a tic area. A new shellscript to hatch files in a tic area.

View File

@ -34,6 +34,9 @@
#include "mutil.h" #include "mutil.h"
extern int bbs_free;
static void die(int onsig) static void die(int onsig)
{ {
signal(onsig, SIG_IGN); signal(onsig, SIG_IGN);
@ -420,6 +423,8 @@ int main(int argc, char *argv[])
pw = getpwuid(getuid()); pw = getpwuid(getuid());
InitClient(pw->pw_name); InitClient(pw->pw_name);
Syslog(' ', "Started by %s", pw->pw_name); Syslog(' ', "Started by %s", pw->pw_name);
bbs_free = FALSE;
/* /*
* Setup several signals so when the program terminate's it * Setup several signals so when the program terminate's it

View File

@ -33,6 +33,7 @@
#include "mutil.h" #include "mutil.h"
extern int ttyfd; extern int ttyfd;
int bbs_free;
unsigned char readkey(int y, int x, int fg, int bg) unsigned char readkey(int y, int x, int fg, int bg)
@ -370,7 +371,7 @@ static time_t lasttime;
void show_date(int fg, int bg, int y, int x) void show_date(int fg, int bg, int y, int x)
{ {
time_t now; time_t now;
char *p; char *p, buf[128];
now = time(NULL); now = time(NULL);
if (now != lasttime) { if (now != lasttime) {
@ -382,6 +383,27 @@ void show_date(int fg, int bg, int y, int x)
p = asctime(gmtime(&now)); p = asctime(gmtime(&now));
Striplf(p); Striplf(p);
mvprintw(2, 44, (char *)"%s UTC", p); mvprintw(2, 44, (char *)"%s UTC", p);
/*
* Indicator if bbs is free
*/
strcpy(buf, SockR("SFRE:0;"));
if (strncmp(buf, "100:0;", 6) == 0) {
strcpy(buf, SockR("SBBS:0;"));
if (strncmp(buf, "100:2,1", 7) == 0) {
set_color(WHITE, RED);
mvprintw(2,74, (char *)" Down ");
} else {
set_color(WHITE, BLUE);
mvprintw(2,74, (char *)" Free ");
}
bbs_free = TRUE;
} else {
set_color(WHITE, RED);
mvprintw(2,74, (char *)" Busy ");
bbs_free = FALSE;
}
if (y && x) if (y && x)
locate(y, x); locate(y, x);
set_color(fg, bg); set_color(fg, bg);

View File

@ -96,7 +96,7 @@ m_mgroup.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../li
m_node.o: ../lib/libs.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: ../lib/libs.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_task.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h screen.h mutil.h ledit.h m_task.h m_task.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h screen.h mutil.h ledit.h m_task.h
m_users.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h screen.h mutil.h ledit.h m_lang.h m_global.h m_archive.h m_protocol.h m_users.h m_users.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h screen.h mutil.h ledit.h m_lang.h m_global.h m_archive.h m_protocol.h m_users.h
screen.o: ../lib/libs.h ../lib/structs.h ../lib/ansi.h ../lib/common.h screen.h screen.o: ../lib/libs.h ../lib/structs.h ../lib/ansi.h ../lib/common.h ../lib/clcomm.h screen.h
m_bbs.o: ../lib/libs.h ../lib/structs.h ../lib/common.h screen.h mutil.h ledit.h m_lang.h m_protocol.h m_ol.h m_fgroup.h m_farea.h m_menu.h m_bbs.h m_limits.h m_bbs.o: ../lib/libs.h ../lib/structs.h ../lib/common.h screen.h mutil.h ledit.h m_lang.h m_protocol.h m_ol.h m_fgroup.h m_farea.h m_menu.h m_bbs.h m_limits.h
m_ff.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h screen.h mutil.h ledit.h stlist.h m_global.h m_ff.h m_lang.h m_marea.h m_ff.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h screen.h mutil.h ledit.h stlist.h m_global.h m_ff.h m_lang.h m_marea.h
m_hatch.o: ../lib/libs.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_fgroup.h m_ticarea.h m_hatch.h m_hatch.o: ../lib/libs.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_fgroup.h m_ticarea.h m_hatch.h

View File

@ -42,6 +42,7 @@
int sock; /* Connected socket */ int sock; /* Connected socket */
extern int bbs_free;
int yes_no(char *T_) int yes_no(char *T_)
@ -94,6 +95,47 @@ void errmsg(const char *format, ...)
/*
* Check if bbs is free, if so close it.
*/
int check_free(void)
{
char buf[81];
if (bbs_free) {
strcpy(buf, SockR("SCLO:0;"));
if (strncmp(buf, "100:0;", 6) == 0) {
Syslog('+', "The BBS is closed");
return TRUE;
} else {
errmsg("Cannon continue, failed to close the bbs");
return FALSE;
}
}
errmsg("You cannot edit right now, the system is busy");
return FALSE;
}
/*
* Reopen the bbs.
*/
void open_bbs(void)
{
char buf[81];
strcpy(buf, SockR("SOPE:0;"));
if (strncmp(buf, "100:0;", 6) == 0) {
Syslog('+', "The BBS is open");
} else {
errmsg("Failed to reopen the bbs");
}
}
/* /*
* Safe field display, does not format % characters but displays it. * Safe field display, does not format % characters but displays it.
*/ */

View File

@ -5,6 +5,8 @@
int yes_no(char *); int yes_no(char *);
void errmsg(const char *, ...); void errmsg(const char *, ...);
int check_free(void);
void open_bbs(void);
void show_field(int, int, char *, int, int); void show_field(int, int, char *, int, int);
void newinsert(int, int, int); void newinsert(int, int, int);
char *edit_field(int, int, int, int, char *); char *edit_field(int, int, int, int, char *);

View File

@ -309,6 +309,9 @@ void EditDomain(void)
long offset; long offset;
struct domrec tdomtrans; struct domrec tdomtrans;
if (! check_free())
return;
clr_index(); clr_index();
working(1, 0, 0); working(1, 0, 0);
IsDoing("Browsing Menu"); IsDoing("Browsing Menu");
@ -366,6 +369,7 @@ void EditDomain(void)
strcpy(pick, select_menurec(records)); strcpy(pick, select_menurec(records));
if (strncmp(pick, "-", 1) == 0) { if (strncmp(pick, "-", 1) == 0) {
open_bbs();
CloseDomain(FALSE); CloseDomain(FALSE);
return; return;
} }

View File

@ -487,6 +487,8 @@ void EditFilearea(void)
} }
working(0, 0, 0); working(0, 0, 0);
o = 0; o = 0;
if (! check_free())
return;
for (;;) { for (;;) {
clr_index(); clr_index();
@ -527,6 +529,7 @@ void EditFilearea(void)
strcpy(pick, select_filearea(records, 20)); strcpy(pick, select_filearea(records, 20));
if (strncmp(pick, "-", 1) == 0) { if (strncmp(pick, "-", 1) == 0) {
open_bbs();
CloseFilearea(FileForced); CloseFilearea(FileForced);
return; return;
} }

View File

@ -136,6 +136,8 @@ void E_F(long areanr)
working(2, 0, 0); working(2, 0, 0);
return; return;
} }
if (! check_free())
return;
fseek(fil, 0, SEEK_END); fseek(fil, 0, SEEK_END);
records = ftell(fil) / sizeof(file); records = ftell(fil) / sizeof(file);
@ -216,6 +218,7 @@ void E_F(long areanr)
if (strncmp(menu, "-", 1) == 0) { if (strncmp(menu, "-", 1) == 0) {
fclose(fil); fclose(fil);
open_bbs();
return; return;
} }

View File

@ -503,6 +503,8 @@ void EditFGroup(void)
} }
working(0, 0, 0); working(0, 0, 0);
o = 0; o = 0;
if (! check_free())
return;
for (;;) { for (;;) {
clr_index(); clr_index();
@ -544,6 +546,7 @@ void EditFGroup(void)
if (strncmp(pick, "-", 1) == 0) { if (strncmp(pick, "-", 1) == 0) {
CloseFGroup(FALSE); CloseFGroup(FALSE);
open_bbs();
return; return;
} }

View File

@ -408,6 +408,8 @@ void EditFidonet(void)
IsDoing("Browsing Menu"); IsDoing("Browsing Menu");
working(0, 0, 0); working(0, 0, 0);
if (! check_free())
return;
for (;;) { for (;;) {
clr_index(); clr_index();
@ -445,6 +447,7 @@ void EditFidonet(void)
if (strncmp(pick, "-", 1) == 0) { if (strncmp(pick, "-", 1) == 0) {
CloseFidonet(FALSE); CloseFidonet(FALSE);
open_bbs();
return; return;
} }

View File

@ -1493,6 +1493,9 @@ void global_menu(void)
{ {
unsigned long crc, crc1; unsigned long crc, crc1;
if (! check_free())
return;
if (cf_open() == -1) if (cf_open() == -1)
return; return;
@ -1561,6 +1564,7 @@ void global_menu(void)
Syslog('+', "Saved main config"); Syslog('+', "Saved main config");
} }
} }
open_bbs();
return; return;
case 1: case 1:
e_fidoakas(); e_fidoakas();

View File

@ -433,8 +433,6 @@ int EditConnections(FILE *fil)
if (System.aka.zone) { if (System.aka.zone) {
set_color(CYAN,BLACK); set_color(CYAN,BLACK);
sprintf(temp, "%3d. %s %s", o+i, status, aka2str(System.aka)); sprintf(temp, "%3d. %s %s", o+i, status, aka2str(System.aka));
// System.aka.zone, System.aka.net, System.aka.node,
// System.aka.point, System.aka.domain);
} else { } else {
set_color(LIGHTBLUE, BLACK); set_color(LIGHTBLUE, BLACK);
sprintf(temp, "%3d.", o+i); sprintf(temp, "%3d.", o+i);
@ -1251,6 +1249,8 @@ void EditMsgarea(void)
} }
working(0, 0, 0); working(0, 0, 0);
o = 0; o = 0;
if (! check_free())
return;
for (;;) { for (;;) {
clr_index(); clr_index();
@ -1288,6 +1288,7 @@ void EditMsgarea(void)
if (strncmp(pick, "-", 1) == 0) { if (strncmp(pick, "-", 1) == 0) {
CloseMsgarea(MailForced); CloseMsgarea(MailForced);
open_bbs();
return; return;
} }

View File

@ -440,6 +440,8 @@ void EditMGroup(void)
} }
working(0, 0, 0); working(0, 0, 0);
o = 0; o = 0;
if (! check_free())
return;
for (;;) { for (;;) {
clr_index(); clr_index();
@ -481,6 +483,7 @@ void EditMGroup(void)
if (strncmp(pick, "-", 1) == 0) { if (strncmp(pick, "-", 1) == 0) {
CloseMGroup(FALSE); CloseMGroup(FALSE);
open_bbs();
return; return;
} }

View File

@ -921,6 +921,8 @@ void EditNodes(void)
} }
working(0, 0, 0); working(0, 0, 0);
o = 0; o = 0;
if (! check_free())
return;
for (;;) { for (;;) {
clr_index(); clr_index();
@ -962,6 +964,7 @@ void EditNodes(void)
if (strncmp(pick, "-", 1) == 0) { if (strncmp(pick, "-", 1) == 0) {
CloseNoderec(FALSE); CloseNoderec(FALSE);
open_bbs();
return; return;
} }

View File

@ -977,6 +977,8 @@ void EditTicarea(void)
} }
working(0, 0, 0); working(0, 0, 0);
o = 0; o = 0;
if (! check_free())
return;
for (;;) { for (;;) {
clr_index(); clr_index();
@ -1015,6 +1017,7 @@ Comment);
if (strncmp(pick, "-", 1) == 0) { if (strncmp(pick, "-", 1) == 0) {
CloseTicarea(FALSE); CloseTicarea(FALSE);
open_bbs();
return; return;
} }

View File

@ -566,6 +566,8 @@ void EditUsers(void)
} }
working(0, 0, 0); working(0, 0, 0);
o = 0; o = 0;
if (! check_free())
return;
for (;;) { for (;;) {
clr_index(); clr_index();
@ -607,6 +609,7 @@ void EditUsers(void)
if (strncmp(pick, "-", 1) == 0) { if (strncmp(pick, "-", 1) == 0) {
CloseUsers(FALSE); CloseUsers(FALSE);
open_bbs();
return; return;
} }

View File

@ -70,10 +70,12 @@
mode_t oldmask; /* Old umask value */ mode_t oldmask; /* Old umask value */
extern int do_quiet; /* Suppress log to screen */ extern int do_quiet; /* Suppress log to screen */
extern int bbs_free; /* Free/Busy status */
int exp_golded = FALSE; /* Export GoldED config */ int exp_golded = FALSE; /* Export GoldED config */
int init = FALSE; /* Run init only */ int init = FALSE; /* Run init only */
static void die(int onsig) static void die(int onsig)
{ {
FILE *fp; FILE *fp;
@ -423,6 +425,7 @@ int main(int argc, char *argv[])
Syslog(' ', "MBSETUP v%s started by %s", VERSION, pw->pw_name); Syslog(' ', "MBSETUP v%s started by %s", VERSION, pw->pw_name);
if (init) if (init)
Syslog('+', "Cmd: mbsetup init"); Syslog('+', "Cmd: mbsetup init");
bbs_free = FALSE;
initdatabases(); initdatabases();
if (!init) { if (!init) {

View File

@ -32,10 +32,13 @@
#include "../lib/structs.h" #include "../lib/structs.h"
#include "../lib/ansi.h" #include "../lib/ansi.h"
#include "../lib/common.h" #include "../lib/common.h"
#include "../lib/clcomm.h"
#include "screen.h" #include "screen.h"
extern int init; extern int init;
int bbs_free;
/************************************************************************* /*************************************************************************
@ -95,7 +98,7 @@ static time_t lasttime;
void show_date(int fg, int bg, int y, int x) void show_date(int fg, int bg, int y, int x)
{ {
time_t now; time_t now;
char *p; char *p, buf[128];
now = time(NULL); now = time(NULL);
if (now != lasttime) { if (now != lasttime) {
@ -107,6 +110,27 @@ void show_date(int fg, int bg, int y, int x)
p = asctime(gmtime(&now)); p = asctime(gmtime(&now));
Striplf(p); Striplf(p);
mvprintw(2, 44, (char *)"%s UTC", p); mvprintw(2, 44, (char *)"%s UTC", p);
/*
* Indicator if bbs is free
*/
strcpy(buf, SockR("SFRE:0;"));
if (strncmp(buf, "100:0;", 6) == 0) {
strcpy(buf, SockR("SBBS:0;"));
if (strncmp(buf, "100:2,1", 7) == 0) {
set_color(WHITE, RED);
mvprintw(2,74, (char *)" Down ");
} else {
set_color(WHITE, BLUE);
mvprintw(2,74, (char *)" Free ");
}
bbs_free = TRUE;
} else {
set_color(WHITE, RED);
mvprintw(2,74, (char *)" Busy ");
bbs_free = FALSE;
}
if (y && x) if (y && x)
locate(y, x); locate(y, x);
set_color(fg, bg); set_color(fg, bg);

View File

@ -449,6 +449,7 @@ char *reg_fre(void)
for (i = 1; i < MAXCLIENT; i++) { for (i = 1; i < MAXCLIENT; i++) {
if (reginfo[i].pid) { if (reginfo[i].pid) {
if ((!strncmp(reginfo[i].prg, "mbsebbs", 7)) || if ((!strncmp(reginfo[i].prg, "mbsebbs", 7)) ||
(!strncmp(reginfo[i].prg, "mbnewusr", 8)) ||
(!strncmp(reginfo[i].prg, "mbftpd", 6))) (!strncmp(reginfo[i].prg, "mbftpd", 6)))
users++; users++;