There is no check anymore for a valid tty with network calls, instead a fake ttyinfo record is created

This commit is contained in:
Michiel Broek
2005-10-08 17:58:23 +00:00
parent 8721afe4e4
commit a56aff8a92
15 changed files with 148 additions and 100 deletions

View File

@@ -45,10 +45,6 @@
#include "ttyio.h"
extern int cols;
extern int rows;
int Chg_Language(int NewMode)
{

View File

@@ -43,9 +43,11 @@
#include "timeout.h"
#define RBUFLEN 81
int chat_with_sysop = FALSE; /* Global sysop chat flag */
int chatting = FALSE; /* Global chatting flag */
char rbuf[50][81]; /* Chat receive buffer */ /* FIXME: must be a dynamic buffer */
char rbuf[50][RBUFLEN]; /* Chat receive buffer */ /* FIXME: must be a dynamic buffer */
int rpointer = 0; /* Chat receive pointer */
int rsize = 5; /* Chat receive size */
extern pid_t mypid;
@@ -126,7 +128,7 @@ void DispMsg(char *msg)
{
int i;
strncpy(rbuf[rpointer], msg, 81);
strncpy(rbuf[rpointer], msg, RBUFLEN);
Showline(2 + rpointer, 1, rbuf[rpointer]);
if (rpointer == rsize) {
/*
@@ -135,7 +137,7 @@ void DispMsg(char *msg)
for (i = 0; i <= rsize; i++) {
locate(i + 2, 1);
clrtoeol();
snprintf(rbuf[i], 81, "%s", rbuf[i+1]);
snprintf(rbuf[i], RBUFLEN, "%s", rbuf[i+1]);
Showline(i + 2, 1, rbuf[i]);
}
} else {

View File

@@ -127,8 +127,6 @@ int main(int argc, char **argv)
if ((p = getenv("CALLER_ID")) != NULL)
if (strncmp(p, "none", 4))
Syslog('+', "CALLER %s", p);
if ((p = getenv("REMOTEHOST")) != NULL)
Syslog('+', "REMOTEHOST %s", p);
if ((p = getenv("TERM")) != NULL)
Syslog('+', "TERM=%s %dx%d", p, cols, rows);
else
@@ -188,43 +186,60 @@ int main(int argc, char **argv)
pout(WHITE, BLACK, (char *)COPYRIGHT);
Enter(2);
/*
* Check if this port is available.
*/
snprintf(temp, PATH_MAX, "%s/etc/ttyinfo.data", getenv("MBSE_ROOT"));
if ((pTty = fopen(temp, "r")) == NULL) {
WriteError("Can't read %s", temp);
} else {
fread(&ttyinfohdr, sizeof(ttyinfohdr), 1, pTty);
while (fread(&ttyinfo, ttyinfohdr.recsize, 1, pTty) == 1) {
if (strcmp(ttyinfo.tty, pTTY) == 0)
break;
}
fclose(pTty);
if ((strcmp(ttyinfo.tty, pTTY) != 0) || (!ttyinfo.available)) {
Syslog('+', "No BBS allowed on port \"%s\"", pTTY);
PUTSTR((char *)"No BBS on this port allowed!");
Enter(2);
Fast_Bye(MBERR_OK);
}
/*
* Ask whether to display Connect String
if ((p = getenv("REMOTEHOST")) != NULL) {
/*
* Network connection, no tty checking but fill a ttyinfo record.
*/
if (CFG.iConnectString) {
/* Connected on port */
snprintf(temp, 81, "%s\"%s\" ", (char *) Language(348), ttyinfo.comment);
pout(CYAN, BLACK, temp);
/* on */
snprintf(temp, 81, "%s %s", (char *) Language(135), ctime(&ltime));
PUTSTR(temp);
Enter(1);
memset(&ttyinfo, 0, sizeof(ttyinfo));
snprintf(ttyinfo.comment, 41, "%s", p);
snprintf(ttyinfo.tty, 7, "%s", pTTY);
snprintf(ttyinfo.speed, 21, "10 mbit");
snprintf(ttyinfo.flags, 31, "IBN,IFC,XX");
ttyinfo.type = NETWORK;
ttyinfo.available = TRUE;
snprintf(ttyinfo.name, 36, "Network port #%d", iNode);
} else {
/*
* Check if this port is available.
*/
snprintf(temp, PATH_MAX, "%s/etc/ttyinfo.data", getenv("MBSE_ROOT"));
if ((pTty = fopen(temp, "r")) == NULL) {
WriteError("Can't read %s", temp);
} else {
fread(&ttyinfohdr, sizeof(ttyinfohdr), 1, pTty);
while (fread(&ttyinfo, ttyinfohdr.recsize, 1, pTty) == 1) {
if (strcmp(ttyinfo.tty, pTTY) == 0)
break;
}
fclose(pTty);
if ((strcmp(ttyinfo.tty, pTTY) != 0) || (!ttyinfo.available)) {
Syslog('+', "No BBS allowed on port \"%s\"", pTTY);
PUTSTR((char *)"No BBS on this port allowed!");
Enter(2);
Fast_Bye(MBERR_OK);
}
}
}
/*
* Ask whether to display Connect String
*/
if (CFG.iConnectString) {
/* Connected from */
snprintf(temp, 81, "%s\"%s\" ", (char *) Language(348), ttyinfo.comment);
pout(CYAN, BLACK, temp);
/* line */
snprintf(temp, 81, "%s%d ", (char *) Language(31), iNode);
pout(CYAN, BLACK, temp);
/* on */
snprintf(temp, 81, "%s %s", (char *) Language(135), ctime(&ltime));
PUTSTR(temp);
Enter(1);
}
alarm_on();
Pause();

View File

@@ -120,8 +120,6 @@ int main(int argc, char **argv)
if ((p = getenv("CALLER_ID")) != NULL)
if (strncmp(p, "none", 4))
Syslog('+', "CALLER_ID %s", p);
if ((p = getenv("REMOTEHOST")) != NULL)
Syslog('+', "REMOTEHOST %s", p);
if ((p = getenv("TERM")) != NULL)
Syslog('+', "TERM=%s %dx%d", p, cols, rows);
else
@@ -137,7 +135,7 @@ int main(int argc, char **argv)
InitLanguage();
InitMenu();
memset(&MsgBase, 0, sizeof(MsgBase));
i = getpid();
if ((tty = ttyname(0)) == NULL) {
@@ -188,7 +186,19 @@ int main(int argc, char **argv)
snprintf(temp, 81, "MBSE BBS v%s (Release: %s) on %s/%s", VERSION, ReleaseDate, OsName(), OsCPU());
poutCR(YELLOW, BLACK, temp);
pout(WHITE, BLACK, (char *)COPYRIGHT);
Enter(2);
/*
* Check and report screens that are too small
*/
if ((cols < 80) || (rows < 24)) {
snprintf(temp, 81, "Your screen is set to %dx%d, we use 80x24 at least", cols, rows);
poutCR(LIGHTRED, BLACK, temp);
Enter(1);
cols = 80;
rows = 24;
} else {
Enter(2);
}
/*
* Check users homedirectory, some *nix systems let users in if no
@@ -202,50 +212,65 @@ int main(int argc, char **argv)
Quick_Bye(MBERR_OK);
}
/*
* Check if this port is available. In iNode we set a fake
* line number, this will be used by doors.
*/
snprintf(temp, PATH_MAX, "%s/etc/ttyinfo.data", getenv("MBSE_ROOT"));
if ((pTty = fopen(temp, "r")) == NULL) {
WriteError("Can't read %s", temp);
} else {
fread(&ttyinfohdr, sizeof(ttyinfohdr), 1, pTty);
while (fread(&ttyinfo, ttyinfohdr.recsize, 1, pTty) == 1) {
if (strcmp(ttyinfo.tty, pTTY) == 0)
break;
}
fclose(pTty);
if ((strcmp(ttyinfo.tty, pTTY) != 0) || (!ttyinfo.available)) {
Syslog('+', "No BBS allowed on port \"%s\"", pTTY);
snprintf(temp, 81, "No BBS on this port allowed!\r\n\r\n");
PUTSTR(temp);
Free_Language();
Quick_Bye(MBERR_OK);
}
/*
* Display Connect String if turned on.
if ((p = getenv("REMOTEHOST")) != NULL) {
/*
* Network connection, no tty checking but fill a ttyinfo record.
*/
if (CFG.iConnectString) {
/* Connected on port */
snprintf(temp, 81, "%s\"%s\" ", (char *) Language(348), ttyinfo.comment);
pout(CYAN, BLACK, temp);
/* on */
snprintf(temp, 81, "%s %s", (char *) Language(135), ctime(&ltime));
PUTSTR(temp);
Enter(1);
memset(&ttyinfo, 0, sizeof(ttyinfo));
snprintf(ttyinfo.comment, 41, "%s", p);
snprintf(ttyinfo.tty, 7, "%s", pTTY);
snprintf(ttyinfo.speed, 21, "10 mbit");
snprintf(ttyinfo.flags, 31, "IBN,IFC,XX");
ttyinfo.type = NETWORK;
ttyinfo.available = TRUE;
snprintf(ttyinfo.name, 36, "Network port #%d", iNode);
} else {
/*
* Check if this port is available.
*/
snprintf(temp, PATH_MAX, "%s/etc/ttyinfo.data", getenv("MBSE_ROOT"));
if ((pTty = fopen(temp, "r")) == NULL) {
WriteError("Can't read %s", temp);
} else {
fread(&ttyinfohdr, sizeof(ttyinfohdr), 1, pTty);
while (fread(&ttyinfo, ttyinfohdr.recsize, 1, pTty) == 1) {
if (strcmp(ttyinfo.tty, pTTY) == 0)
break;
}
fclose(pTty);
if ((strcmp(ttyinfo.tty, pTTY) != 0) || (!ttyinfo.available)) {
Syslog('+', "No BBS allowed on port \"%s\"", pTTY);
snprintf(temp, 81, "No BBS on this port allowed!\r\n\r\n");
PUTSTR(temp);
Free_Language();
Quick_Bye(MBERR_OK);
}
}
}
/*
* Display Connect String if turned on.
*/
if (CFG.iConnectString) {
/* Connected from */
snprintf(temp, 81, "%s\"%s\" ", (char *) Language(348), ttyinfo.comment);
pout(CYAN, BLACK, temp);
/* line */
snprintf(temp, 81, "%s%d ", (char *) Language(31), iNode);
pout(CYAN, BLACK, temp);
/* on */
snprintf(temp, 81, "%s %s", (char *) Language(135), ctime(&ltime));
PUTSTR(temp);
Enter(1);
}
/*
* Some debugging for me
*/
Syslog('b', "setlocale(LC_ALL, NULL) returns \"%s\"", printable(setlocale(LC_ALL, NULL), 0));
/* Next is not usefull */
Syslog('b', "nl_langinfo(LC_CTYPE) returns \"%s\"", printable(nl_langinfo(LC_CTYPE), 0));
snprintf(sMailbox, 21, "mailbox");
colour(LIGHTGRAY, BLACK);

View File

@@ -235,7 +235,7 @@ void user(void)
} else
strncpy(FirstName, UserName, sizeof(FirstName)-1);
strncpy(UserName, usrconfig.sUserName, sizeof(UserName)-1);
Syslog('+', "%s On-Line at \"%s\", node %d", UserName, ttyinfo.comment, iNode);
Syslog('+', "%s On-Line from \"%s\", node %d", UserName, ttyinfo.comment, iNode);
IsDoing("Just Logged In");
/*