Several changes and protections for the chatserver
This commit is contained in:
parent
3ee82f5eed
commit
06c53cab6d
10
ChangeLog
10
ChangeLog
@ -2,6 +2,16 @@ $Id$
|
||||
|
||||
v0.83.9 23-Jan-2006
|
||||
|
||||
mbtask:
|
||||
In IBC refuse to add a user when there is no known server for
|
||||
that user.
|
||||
Added setup checks for two main configuration settings for IBC
|
||||
and fail to start if they are missing.
|
||||
Don't start connections with IBC servers that miss settings in
|
||||
the chatserver setup.
|
||||
Added some code to trap mbtask crashing during chat and start
|
||||
mail processing.
|
||||
|
||||
|
||||
v0.83.8 22-Jan-2006 - 23-Jan-2006
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Purpose ...............: MBSE BBS Task Manager
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2005
|
||||
* Copyright (C) 1997-2006
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
@ -116,6 +116,8 @@ extern int ping_run; /* Ping running */
|
||||
int sched_run = FALSE; /* Scheduler running */
|
||||
extern int disk_run; /* Disk watch running */
|
||||
extern int ibc_run; /* IBC thread running */
|
||||
extern pthread_mutex_t b_mutex; /* IBC mutex lock */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@ -442,6 +444,7 @@ pid_t launch(char *cmd, char *opts, char *name, int tasktype)
|
||||
int i, rc = 0;
|
||||
pid_t pid = 0;
|
||||
|
||||
Syslog('r', "launch() entered");
|
||||
if (checktasks(0) >= MAXTASKS) {
|
||||
Syslog('?', "Launch: can't execute %s, maximum tasks reached", cmd);
|
||||
return 0;
|
||||
@ -463,6 +466,13 @@ pid_t launch(char *cmd, char *opts, char *name, int tasktype)
|
||||
return 0;
|
||||
}
|
||||
|
||||
rc = pthread_mutex_lock(&b_mutex);
|
||||
if (rc) {
|
||||
WriteError("$launch mutex lock");
|
||||
return 0;
|
||||
}
|
||||
Syslog('r', "launch() mutex locked");
|
||||
|
||||
pid = fork();
|
||||
switch (pid) {
|
||||
case -1:
|
||||
@ -513,6 +523,12 @@ pid_t launch(char *cmd, char *opts, char *name, int tasktype)
|
||||
}
|
||||
}
|
||||
|
||||
rc = pthread_mutex_unlock(&b_mutex);
|
||||
if (rc) {
|
||||
WriteError("$launch mutex unlock");
|
||||
}
|
||||
Syslog('r', "launch() mutex unlocked");
|
||||
|
||||
ptimer = PAUSETIME;
|
||||
|
||||
if (opts)
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Purpose ...............: mbtask - Internet BBS Chat (but it looks like...)
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2005
|
||||
* Copyright (C) 1997-2006
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
@ -251,16 +251,28 @@ int add_user(usr_list **fap, char *server, char *name, char *realname)
|
||||
{
|
||||
usr_list *tmp, *ta;
|
||||
srv_list *sl;
|
||||
int Found = FALSE;
|
||||
|
||||
Syslog('r', "add_user %s %s %s", server, name, realname);
|
||||
Syslog('r', "IBC: add_user (%s, %s, %s)", server, name, realname);
|
||||
|
||||
for (ta = *fap; ta; ta = ta->next) {
|
||||
if ((strcmp(ta->server, server) == 0) && (strcmp(ta->realname, realname) == 0)) {
|
||||
Syslog('-', "IBC: add_user(%s %s %s), already registered", server, name, realname);
|
||||
Syslog('-', "IBC: add_user(%s, %s, %s), already registered", server, name, realname);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (sl = servers; sl; sl = sl->next) {
|
||||
if (strcmp(sl->server, server) == 0) {
|
||||
Found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!Found) {
|
||||
Syslog('-', "IBC: add_user(%s, %s, %s), unknown server", server, name, realname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&b_mutex);
|
||||
|
||||
tmp = (usr_list *)malloc(sizeof(usr_list));
|
||||
@ -305,28 +317,31 @@ void del_user(usr_list **fap, char *server, char *name)
|
||||
{
|
||||
usr_list **tmp, *tmpa;
|
||||
srv_list *sl;
|
||||
int count = 0;
|
||||
|
||||
Syslog('r', "IBC: deluser %s %s", server, printable(name, 0));
|
||||
Syslog('r', "IBC: deluser (%s, %s)", server, printable(name, 0));
|
||||
|
||||
if (*fap == NULL)
|
||||
return;
|
||||
|
||||
if (name)
|
||||
pthread_mutex_lock(&b_mutex);
|
||||
|
||||
tmp = fap;
|
||||
while (*tmp) {
|
||||
if (name && (strcmp((*tmp)->server, server) == 0) && (strcmp((*tmp)->name, name) == 0)) {
|
||||
Syslog('r', "IBC: removed user %s from %s", (*tmp)->name, (*tmp)->server);
|
||||
tmpa = *tmp;
|
||||
*tmp=(*tmp)->next;
|
||||
free(tmpa);
|
||||
usrchg = TRUE;
|
||||
count++;
|
||||
} else if ((name == NULL) && (strcmp((*tmp)->server, server) == 0)) {
|
||||
Syslog('r', "IBC: removed user %s from %s", (*tmp)->name, (*tmp)->server);
|
||||
tmpa = *tmp;
|
||||
*tmp=(*tmp)->next;
|
||||
free(tmpa);
|
||||
usrchg = TRUE;
|
||||
count++;
|
||||
} else {
|
||||
tmp = &((*tmp)->next);
|
||||
}
|
||||
@ -334,12 +349,13 @@ void del_user(usr_list **fap, char *server, char *name)
|
||||
|
||||
for (sl = servers; sl; sl = sl->next) {
|
||||
if ((strcmp(sl->server, server) == 0) && sl->users) {
|
||||
sl->users--;
|
||||
sl->users -= count;
|
||||
if (sl->users < 0)
|
||||
sl->users = 0; /* Just in case, nothing is perfect */
|
||||
srvchg = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (name)
|
||||
pthread_mutex_unlock(&b_mutex);
|
||||
}
|
||||
|
||||
@ -352,11 +368,11 @@ int add_channel(chn_list **fap, char *name, char *owner, char *server)
|
||||
{
|
||||
chn_list *tmp, *ta;
|
||||
|
||||
Syslog('r', "IBC: add_channel %s %s %s", name, owner, server);
|
||||
Syslog('r', "IBC: add_channel (%s, %s, %s)", name, owner, server);
|
||||
|
||||
for (ta = *fap; ta; ta = ta->next) {
|
||||
if ((strcmp(ta->name, name) == 0) && (strcmp(ta->owner, owner) == 0) && (strcmp(ta->server, server) == 0)) {
|
||||
Syslog('-', "IBC: add_channel(%s %s %s), already registered", name, owner, server);
|
||||
Syslog('-', "IBC: add_channel(%s, %s, %s), already registered", name, owner, server);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -655,12 +671,12 @@ void check_servers(void)
|
||||
/*
|
||||
* Local reset, make all crc's invalid so the connections will restart.
|
||||
*/
|
||||
if (local_reset) {
|
||||
pthread_mutex_lock(&b_mutex);
|
||||
if (local_reset)
|
||||
for (tnsl = ncsl; tnsl; tnsl = tnsl->next)
|
||||
tnsl->crc--;
|
||||
pthread_mutex_unlock(&b_mutex);
|
||||
|
||||
}
|
||||
|
||||
if ((fp = fopen(scfgfn, "r"))) {
|
||||
fread(&ibcsrvhdr, sizeof(ibcsrvhdr), 1, fp);
|
||||
@ -754,7 +770,7 @@ void check_servers(void)
|
||||
/*
|
||||
* Check for new configured servers
|
||||
*/
|
||||
if (ibcsrv.Active) {
|
||||
if (ibcsrv.Active && strlen(ibcsrv.myname) && strlen(ibcsrv.server) && strlen(ibcsrv.passwd)) {
|
||||
inlist = FALSE;
|
||||
for (tnsl = ncsl; tnsl; tnsl = tnsl->next) {
|
||||
if (strcmp(tnsl->server, ibcsrv.server) == 0) {
|
||||
@ -1745,6 +1761,16 @@ void *ibc_thread(void *dummy)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (strlen(CFG.bbs_name) == 0) {
|
||||
Syslog('!', "IBC: mbsetup 1.2.1 is empty, cannot start Internet BBS Chat");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (strlen(CFG.myfqdn) == 0) {
|
||||
Syslog('!', "IBC: mbsetup 1.2.10 is empty, cannot start Internet BBS Chat");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
myaddr_in.sin_family = AF_INET;
|
||||
myaddr_in.sin_addr.s_addr = INADDR_ANY;
|
||||
myaddr_in.sin_port = se->s_port;
|
||||
|
Reference in New Issue
Block a user