Added locking for mbsetup
This commit is contained in:
parent
e3961d8449
commit
ff8ee89ac1
11
ChangeLog
11
ChangeLog
@ -4665,6 +4665,13 @@ v0.33.20 10-Feb-2002
|
||||
Fixed a non understandable logmessage in check if nodes are
|
||||
connected to file and or mail groups.
|
||||
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:
|
||||
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.
|
||||
It will use the registration date instead.
|
||||
|
||||
mbstat:
|
||||
The timeout for the wait command was wrong due to a wrong
|
||||
upsdown semafore test.
|
||||
|
||||
hatch:
|
||||
A new shellscript to hatch files in a tic area.
|
||||
|
||||
|
@ -34,6 +34,9 @@
|
||||
#include "mutil.h"
|
||||
|
||||
|
||||
extern int bbs_free;
|
||||
|
||||
|
||||
static void die(int onsig)
|
||||
{
|
||||
signal(onsig, SIG_IGN);
|
||||
@ -420,6 +423,8 @@ int main(int argc, char *argv[])
|
||||
pw = getpwuid(getuid());
|
||||
InitClient(pw->pw_name);
|
||||
Syslog(' ', "Started by %s", pw->pw_name);
|
||||
bbs_free = FALSE;
|
||||
|
||||
|
||||
/*
|
||||
* Setup several signals so when the program terminate's it
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "mutil.h"
|
||||
|
||||
extern int ttyfd;
|
||||
int bbs_free;
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
time_t now;
|
||||
char *p;
|
||||
char *p, buf[128];
|
||||
|
||||
now = time(NULL);
|
||||
if (now != lasttime) {
|
||||
@ -382,6 +383,27 @@ void show_date(int fg, int bg, int y, int x)
|
||||
p = asctime(gmtime(&now));
|
||||
Striplf(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)
|
||||
locate(y, x);
|
||||
set_color(fg, bg);
|
||||
|
@ -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_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
|
||||
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_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
|
||||
|
@ -42,6 +42,7 @@
|
||||
|
||||
|
||||
int sock; /* Connected socket */
|
||||
extern int bbs_free;
|
||||
|
||||
|
||||
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.
|
||||
*/
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
int yes_no(char *);
|
||||
void errmsg(const char *, ...);
|
||||
int check_free(void);
|
||||
void open_bbs(void);
|
||||
void show_field(int, int, char *, int, int);
|
||||
void newinsert(int, int, int);
|
||||
char *edit_field(int, int, int, int, char *);
|
||||
|
@ -309,6 +309,9 @@ void EditDomain(void)
|
||||
long offset;
|
||||
struct domrec tdomtrans;
|
||||
|
||||
if (! check_free())
|
||||
return;
|
||||
|
||||
clr_index();
|
||||
working(1, 0, 0);
|
||||
IsDoing("Browsing Menu");
|
||||
@ -366,6 +369,7 @@ void EditDomain(void)
|
||||
strcpy(pick, select_menurec(records));
|
||||
|
||||
if (strncmp(pick, "-", 1) == 0) {
|
||||
open_bbs();
|
||||
CloseDomain(FALSE);
|
||||
return;
|
||||
}
|
||||
|
@ -487,6 +487,8 @@ void EditFilearea(void)
|
||||
}
|
||||
working(0, 0, 0);
|
||||
o = 0;
|
||||
if (! check_free())
|
||||
return;
|
||||
|
||||
for (;;) {
|
||||
clr_index();
|
||||
@ -527,6 +529,7 @@ void EditFilearea(void)
|
||||
strcpy(pick, select_filearea(records, 20));
|
||||
|
||||
if (strncmp(pick, "-", 1) == 0) {
|
||||
open_bbs();
|
||||
CloseFilearea(FileForced);
|
||||
return;
|
||||
}
|
||||
|
@ -136,6 +136,8 @@ void E_F(long areanr)
|
||||
working(2, 0, 0);
|
||||
return;
|
||||
}
|
||||
if (! check_free())
|
||||
return;
|
||||
|
||||
fseek(fil, 0, SEEK_END);
|
||||
records = ftell(fil) / sizeof(file);
|
||||
@ -216,6 +218,7 @@ void E_F(long areanr)
|
||||
|
||||
if (strncmp(menu, "-", 1) == 0) {
|
||||
fclose(fil);
|
||||
open_bbs();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -503,6 +503,8 @@ void EditFGroup(void)
|
||||
}
|
||||
working(0, 0, 0);
|
||||
o = 0;
|
||||
if (! check_free())
|
||||
return;
|
||||
|
||||
for (;;) {
|
||||
clr_index();
|
||||
@ -544,6 +546,7 @@ void EditFGroup(void)
|
||||
|
||||
if (strncmp(pick, "-", 1) == 0) {
|
||||
CloseFGroup(FALSE);
|
||||
open_bbs();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -408,6 +408,8 @@ void EditFidonet(void)
|
||||
IsDoing("Browsing Menu");
|
||||
|
||||
working(0, 0, 0);
|
||||
if (! check_free())
|
||||
return;
|
||||
|
||||
for (;;) {
|
||||
clr_index();
|
||||
@ -445,6 +447,7 @@ void EditFidonet(void)
|
||||
|
||||
if (strncmp(pick, "-", 1) == 0) {
|
||||
CloseFidonet(FALSE);
|
||||
open_bbs();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1493,6 +1493,9 @@ void global_menu(void)
|
||||
{
|
||||
unsigned long crc, crc1;
|
||||
|
||||
if (! check_free())
|
||||
return;
|
||||
|
||||
if (cf_open() == -1)
|
||||
return;
|
||||
|
||||
@ -1561,6 +1564,7 @@ void global_menu(void)
|
||||
Syslog('+', "Saved main config");
|
||||
}
|
||||
}
|
||||
open_bbs();
|
||||
return;
|
||||
case 1:
|
||||
e_fidoakas();
|
||||
|
@ -433,8 +433,6 @@ int EditConnections(FILE *fil)
|
||||
if (System.aka.zone) {
|
||||
set_color(CYAN,BLACK);
|
||||
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 {
|
||||
set_color(LIGHTBLUE, BLACK);
|
||||
sprintf(temp, "%3d.", o+i);
|
||||
@ -1251,6 +1249,8 @@ void EditMsgarea(void)
|
||||
}
|
||||
working(0, 0, 0);
|
||||
o = 0;
|
||||
if (! check_free())
|
||||
return;
|
||||
|
||||
for (;;) {
|
||||
clr_index();
|
||||
@ -1288,6 +1288,7 @@ void EditMsgarea(void)
|
||||
|
||||
if (strncmp(pick, "-", 1) == 0) {
|
||||
CloseMsgarea(MailForced);
|
||||
open_bbs();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -440,6 +440,8 @@ void EditMGroup(void)
|
||||
}
|
||||
working(0, 0, 0);
|
||||
o = 0;
|
||||
if (! check_free())
|
||||
return;
|
||||
|
||||
for (;;) {
|
||||
clr_index();
|
||||
@ -481,6 +483,7 @@ void EditMGroup(void)
|
||||
|
||||
if (strncmp(pick, "-", 1) == 0) {
|
||||
CloseMGroup(FALSE);
|
||||
open_bbs();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -921,6 +921,8 @@ void EditNodes(void)
|
||||
}
|
||||
working(0, 0, 0);
|
||||
o = 0;
|
||||
if (! check_free())
|
||||
return;
|
||||
|
||||
for (;;) {
|
||||
clr_index();
|
||||
@ -962,6 +964,7 @@ void EditNodes(void)
|
||||
|
||||
if (strncmp(pick, "-", 1) == 0) {
|
||||
CloseNoderec(FALSE);
|
||||
open_bbs();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -977,6 +977,8 @@ void EditTicarea(void)
|
||||
}
|
||||
working(0, 0, 0);
|
||||
o = 0;
|
||||
if (! check_free())
|
||||
return;
|
||||
|
||||
for (;;) {
|
||||
clr_index();
|
||||
@ -1015,6 +1017,7 @@ Comment);
|
||||
|
||||
if (strncmp(pick, "-", 1) == 0) {
|
||||
CloseTicarea(FALSE);
|
||||
open_bbs();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -566,6 +566,8 @@ void EditUsers(void)
|
||||
}
|
||||
working(0, 0, 0);
|
||||
o = 0;
|
||||
if (! check_free())
|
||||
return;
|
||||
|
||||
for (;;) {
|
||||
clr_index();
|
||||
@ -607,6 +609,7 @@ void EditUsers(void)
|
||||
|
||||
if (strncmp(pick, "-", 1) == 0) {
|
||||
CloseUsers(FALSE);
|
||||
open_bbs();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -70,10 +70,12 @@
|
||||
|
||||
mode_t oldmask; /* Old umask value */
|
||||
extern int do_quiet; /* Suppress log to screen */
|
||||
extern int bbs_free; /* Free/Busy status */
|
||||
int exp_golded = FALSE; /* Export GoldED config */
|
||||
int init = FALSE; /* Run init only */
|
||||
|
||||
|
||||
|
||||
static void die(int onsig)
|
||||
{
|
||||
FILE *fp;
|
||||
@ -423,6 +425,7 @@ int main(int argc, char *argv[])
|
||||
Syslog(' ', "MBSETUP v%s started by %s", VERSION, pw->pw_name);
|
||||
if (init)
|
||||
Syslog('+', "Cmd: mbsetup init");
|
||||
bbs_free = FALSE;
|
||||
initdatabases();
|
||||
|
||||
if (!init) {
|
||||
|
@ -32,10 +32,13 @@
|
||||
#include "../lib/structs.h"
|
||||
#include "../lib/ansi.h"
|
||||
#include "../lib/common.h"
|
||||
#include "../lib/clcomm.h"
|
||||
#include "screen.h"
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
time_t now;
|
||||
char *p;
|
||||
char *p, buf[128];
|
||||
|
||||
now = time(NULL);
|
||||
if (now != lasttime) {
|
||||
@ -107,6 +110,27 @@ void show_date(int fg, int bg, int y, int x)
|
||||
p = asctime(gmtime(&now));
|
||||
Striplf(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)
|
||||
locate(y, x);
|
||||
set_color(fg, bg);
|
||||
|
@ -449,6 +449,7 @@ char *reg_fre(void)
|
||||
for (i = 1; i < MAXCLIENT; i++) {
|
||||
if (reginfo[i].pid) {
|
||||
if ((!strncmp(reginfo[i].prg, "mbsebbs", 7)) ||
|
||||
(!strncmp(reginfo[i].prg, "mbnewusr", 8)) ||
|
||||
(!strncmp(reginfo[i].prg, "mbftpd", 6)))
|
||||
users++;
|
||||
|
||||
|
Reference in New Issue
Block a user