diff --git a/ChangeLog b/ChangeLog index 59b02c48..aaec745f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,8 +8,6 @@ v0.39.2 21-Nov-2003 in cvs because I need to test it on several machines at once. general: - With the use of a proxy based on the iftelnetd from the ifmail - package incoming telnet sessions are now supported. Outgoing telnet finally works. common.a: @@ -23,12 +21,6 @@ v0.39.2 21-Nov-2003 Made outgoing telnet calls working with the help of sources from other open source projects. - mbtelnetd: - New program, a proxy to handle incoming telnet/vmodem sessions. - Based on the work of Serge Terekhov, 2:5000/13@fidonet and - Vadim Kurland, vadim@gu.kiev.ua and Vadim Zaliva, - lord@crocodile.kiev.ua. - mbtask: Restored ITN protocol. diff --git a/mbcico/.cvsignore b/mbcico/.cvsignore index 775b0604..7d604d12 100644 --- a/mbcico/.cvsignore +++ b/mbcico/.cvsignore @@ -1 +1 @@ -filelist mbcico mbout mbtelnetd +filelist mbcico mbout diff --git a/mbcico/Makefile b/mbcico/Makefile index 6ba410fc..7f886826 100644 --- a/mbcico/Makefile +++ b/mbcico/Makefile @@ -12,7 +12,7 @@ SRCS = zmmisc.c zmrle.c zmrecv.c zmsend.c binkp.c md5b.c \ filetime.c ftsc.c atoul.c portsel.c \ ttyio.c lutil.c scanout.c emsi.c ulock.c \ callstat.c session.c call.c mbcico.c \ - outstat.c nlinfo.c mbout.c mbtelnetd.c telnio.c + outstat.c nlinfo.c mbout.c telnio.c HDRS = zmodem.h binkp.h config.h statetbl.h md5b.h \ xmsend.h xmrecv.h m7recv.h m7send.h hydra.h inbound.h \ answer.h chat.h dial.h dietifna.h emsidat.h filelist.h \ @@ -21,7 +21,7 @@ HDRS = zmodem.h binkp.h config.h statetbl.h md5b.h \ filetime.h ftsc.h atoul.h portsel.h \ ttyio.h lutil.h scanout.h emsi.h ulock.h \ callstat.h session.h call.h mbcico.h \ - outstat.h nlinfo.h mbtelnetd.h telnio.h + outstat.h nlinfo.h telnio.h MBCICO_OBJS = zmmisc.o zmrle.o zmrecv.o zmsend.o binkp.o md5b.o \ xmsend.o xmrecv.o m7recv.o m7send.o hydra.o inbound.o \ answer.o chat.o dial.o dietifna.o emsidat.o filelist.o \ @@ -31,11 +31,10 @@ MBCICO_OBJS = zmmisc.o zmrle.o zmrecv.o zmsend.o binkp.o md5b.o \ ttyio.o lutil.o scanout.o emsi.o ulock.o \ callstat.o session.o call.o telnio.o mbcico.o MBOUT_OBJS = outstat.o nlinfo.o mbout.o scanout.o callstat.o -MBTEL_OBJS = mbtelnetd.o telnio.o LIBS += ../lib/libclcomm.a ../lib/libcommon.a \ ../lib/libmsgbase.a ../lib/libdbase.a ../lib/libnodelist.a OTHER = Makefile README -TARGET = mbcico mbout mbtelnetd +TARGET = mbcico mbout ############################################################################# @@ -50,7 +49,6 @@ clean: install: all ${INSTALL} -c -s -g ${GROUP} -o ${OWNER} -m 4751 mbcico ${BINDIR} ${INSTALL} -c -s -g ${GROUP} -o ${OWNER} -m 0755 mbout ${BINDIR} - ${INSTALL} -c -s -g ${GROUP} -o ${OWNER} -m 0755 mbtelnetd ${BINDIR} mbcico: ${MBCICO_OBJS} ${LIBS} ${CC} -o mbcico ${MBCICO_OBJS} ${LIBS} @@ -60,10 +58,6 @@ mbout: ${MBOUT_OBJS} ${LIBS} ${CC} -o mbout ${MBOUT_OBJS} ${LIBS} strip mbout -mbtelnetd: ${MBTEL_OBJS} ${LIBS} - ${CC} -o mbtelnetd ${MBTEL_OBJS} ${LIBS} - strip mbtelnetd - filelist: Makefile BASE=`pwd`; \ BASE=`basename $${BASE}`; \ @@ -138,6 +132,5 @@ mbcico.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/recor outstat.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/nodelist.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbftn.h ../lib/mberrors.h scanout.h callstat.h outstat.h nlinfo.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/common.h ../lib/nodelist.h ../lib/clcomm.h nlinfo.h mbout.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/nodelist.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbftn.h ../lib/mberrors.h outstat.h nlinfo.h -mbtelnetd.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/mberrors.h hydra.h telnio.h mbtelnetd.h telnio.o: ../config.h ../lib/libs.h ../lib/clcomm.h hydra.h telnio.h # End of generated dependencies diff --git a/mbcico/mbcico.c b/mbcico/mbcico.c index 9a32d950..2d2335bc 100644 --- a/mbcico/mbcico.c +++ b/mbcico/mbcico.c @@ -357,11 +357,6 @@ int main(int argc, char *argv[]) if (rc > maxrc) maxrc=rc; } else { - if (telnet) { - WriteError("Incoming telnet call is not supported anymore"); - WriteError("Install mbtelnetd to handle telnet inbound traffic"); - die(MBERR_COMMANDLINE); - } /* slave */ if (!answermode && tcp_mode == TCPMODE_IBN) answermode = xstrcpy((char *)"ibn"); diff --git a/mbcico/mbtelnetd.c b/mbcico/mbtelnetd.c deleted file mode 100644 index 6aa4ef5a..00000000 --- a/mbcico/mbtelnetd.c +++ /dev/null @@ -1,247 +0,0 @@ -/***************************************************************************** - * - * $Id$ - * Purpose ...............: Fidonet telnet proxy - * - ***************************************************************************** - * Copyright (C) 1997-2003 - * - * Michiel Broek FIDO: 2:280/2802 - * Beekmansbos 10 - * 1971 BV IJmuiden - * the Netherlands - * - * This file is part of MBSE BBS. - * - * This BBS is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * MBSE BBS is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with MBSE BBS; see the file COPYING. If not, write to the Free - * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - *****************************************************************************/ - - -/* - Simple proxy daemon for ifcico to work with SIO/VMODEM. - ======================================================== - Written by: Vadim Zaliva, lord@crocodile.kiev.ua, 2:463/80 - - This software is provided ``as is'' without express or implied warranty. - Feel free to distribute it. - - Feel free to contact me with improovments request - and bug reports. - - Some parts of this code are taken from - 1. serge terekhov, 2:5000/13@fidonet path for ifmail - 2. Vadim Kurland, vadim@gu.kiev.ua transl daemon. - Thanks them. - */ - -#include "../config.h" -#include "../lib/libs.h" -#include "../lib/structs.h" -#include "../lib/users.h" -#include "../lib/records.h" -#include "../lib/common.h" -#include "../lib/clcomm.h" -#include "../lib/dbcfg.h" -#include "../lib/mberrors.h" -#include "hydra.h" -#include "telnio.h" -#include "mbtelnetd.h" - - -#define MBT_TIMEOUT 3600 - - -void die(int); -void com_gw(int); - - -char *envptr = NULL; -time_t t_start, t_end; - - -void die(int onsig) -{ - signal(onsig, SIG_IGN); - - if (onsig) { - if (onsig <= NSIG) - WriteError("Terminated on signal %d (%s)", onsig, SigName[onsig]); - else - Syslog('+', "Terminated with error %d", onsig); - } - - t_end = time(NULL); - Syslog(' ', "MBTELNETD finished in %s", t_elapsed(t_start, t_end)); - if (envptr) - free(envptr); - ExitClient(onsig); -} - - - -int main(int ac, char **av) -{ - struct sockaddr_in peeraddr; - int addrlen = sizeof(struct sockaddr_in); - char *remote_name = NULL; - char *remote_port = NULL; - int s; /* socket to remote*/ - int i; - struct hostent *hp; - struct servent *sp; - struct sockaddr_in server; - char *tmp = NULL; - struct passwd *pw; - - /* - * The next trick is to supply a fake environment variable - * MBSE_ROOT in case we are started from inetd or mgetty, - * this will setup the variable so InitConfig() will work. - * The /etc/passwd must point to the correct homedirectory. - */ - pw = getpwuid(getuid()); - if (getenv("MBSE_ROOT") == NULL) { - envptr = xstrcpy((char *)"MBSE_ROOT="); - envptr = xstrcat(envptr, pw->pw_dir); - putenv(envptr); - } - - InitConfig(); - t_start = time(NULL); - - InitClient(pw->pw_name, (char *)"mbtelnetd", CFG.location, CFG.logfile, - CFG.util_loglevel, CFG.error_log, CFG.mgrlog, CFG.debuglog); - - Syslog(' ', " "); - Syslog(' ', "MBTELNETDv%s", VERSION); - - /* - * Catch all signals we can, and ignore the rest. - */ - for (i = 0; i < NSIG; i++) { - if ((i == SIGINT) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV) || (i == SIGTERM) || (i == SIGKILL)) { - signal(i, (void (*))die); - } else { - signal(i, SIG_IGN); - } - } - - remote_name = xstrcpy((char *)"localhost"); - remote_port = xstrcpy((char *)"fido"); - - if (getpeername(0,(struct sockaddr*)&peeraddr,&addrlen) == 0) { - tmp = strdup(inet_ntoa(peeraddr.sin_addr)); - Syslog('+', "Incoming TCP connection from %s", tmp ? tmp : "Unknown"); - Syslog('+', "Rerouting to %s:%s", remote_name, remote_port); - } - - if (tmp) - free(tmp); - - if ((sp = getservbyname(remote_port, "tcp")) == NULL) { - WriteError("Can't find service: %s", remote_port); - free(remote_name); - free(remote_port); - die(MBERR_INIT_ERROR); - } - - if ((s = socket(AF_INET,SOCK_STREAM,0)) == -1) { - WriteError("Can't create Internet domain socket"); - free(remote_name); - free(remote_port); - die(MBERR_INIT_ERROR); - } - - if ((hp = gethostbyname(remote_name)) == NULL) { - WriteError("%s - Unknown host", remote_name); - free(remote_name); - free(remote_port); - die(MBERR_INIT_ERROR); - } - - memset(&server,0,sizeof(server)); - memcpy((char *)&server.sin_addr,hp->h_addr,hp->h_length); - - server.sin_family=hp->h_addrtype; - server.sin_port = sp->s_port; - - if (connect(s,(struct sockaddr *)&server,sizeof(server)) == -1) { - WriteError("Can't connect %s", remote_name); - free(remote_name); - free(remote_port); - die(MBERR_INIT_ERROR); - } - - telnet_init(); - - tmp = calloc(81, sizeof(char )); - sprintf(tmp, "mbtelnetd v%s\r\n", VERSION); - telnet_write(tmp, strlen(tmp)); - free(tmp); - - com_gw(s); - - free(remote_name); - free(remote_port); - close(s); - die(0); - return 0; -} - - - -void com_gw(int in) -{ - fd_set fds; - int n, fdsbits; - static struct timeval tout = { MBT_TIMEOUT, 0 }; - unsigned char buf[H_ZIPBUFLEN]; - - alarm(0); - fdsbits = in + 1; - - while (TRUE) { - FD_ZERO(& fds); - FD_SET (in, &fds); - FD_SET (0 , &fds); - FD_SET (1 , &fds); - - tout.tv_sec = MBT_TIMEOUT; - tout.tv_usec = 0; - if ((n = select(fdsbits, &fds, NULL, NULL, &tout)) > 0) { - if (FD_ISSET(in, &fds)) { - if ((n = read(in, buf, sizeof buf)) > 0) { - if (telnet_write(buf, n) < 0) { - goto bad; - } - } else { - goto bad; - } - } - if (FD_ISSET(0, &fds)) { - if ((n = telnet_read(buf, sizeof buf)) > 0) { - if (write(in, buf, n) < 0) goto bad; - } else { - goto bad; - } - } - } else { - goto bad; - } - } -bad: ; -} - - diff --git a/mbcico/mbtelnetd.h b/mbcico/mbtelnetd.h deleted file mode 100644 index dbea7ed6..00000000 --- a/mbcico/mbtelnetd.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _MBTELNETD_H -#define _MBTELNETD_H - -/* $Id$ */ - - -#endif diff --git a/mbcico/ttyio.c b/mbcico/ttyio.c index 7aa03c78..59d75df1 100644 --- a/mbcico/ttyio.c +++ b/mbcico/ttyio.c @@ -45,7 +45,6 @@ extern int hanged_up; extern int telnet; -extern int master; extern char *inetaddr; #define TT_BUFSIZ 1024 @@ -246,7 +245,7 @@ static int tty_read(char *buf, int size, int tot) } rc=-tty_status; } else { - if (master && telnet) { + if (telnet) { rc = telnet_buffer(buf, rc); } } @@ -261,7 +260,7 @@ int tty_write(char *buf, int size) int result; tty_status=0; - if (telnet && master) + if (telnet) result = telnet_write(buf, size); else result = write(1, buf, size); @@ -581,7 +580,7 @@ int tty_putget(char **obuf, int *osize, char **ibuf, int *isize) WriteError("$tty_putget: read failed"); tty_status=STAT_ERROR; } else { - if (master && telnet) { + if (telnet) { rc = telnet_buffer(*ibuf, rc); } (*ibuf)+=rc; @@ -590,7 +589,7 @@ int tty_putget(char **obuf, int *osize, char **ibuf, int *isize) } if (FD_ISSET(1,&writefds) && *osize) { - if (telnet && master) + if (telnet) rc = telnet_write(*obuf,*osize); else rc=write(1,*obuf,*osize);