mirror of
https://github.com/sheumann/telnetd.git
synced 2024-11-22 01:31:54 +00:00
Changes to make telnet & telnetd compile on OS X, and begin adapting them to GNO:
*New makefile *Refer to local versions of telnet-related headers, rather than system ones *Use termcap instead of termios *Change hostname lookup in telnetd back to older code (which assumes IPv4, but that's all GNO supports anyway)
This commit is contained in:
parent
052bf438de
commit
327170235b
90
Makefile
Normal file
90
Makefile
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
LIBTELNET_SRCS = \
|
||||||
|
libtelnet/auth.c \
|
||||||
|
libtelnet/enc_des.c \
|
||||||
|
libtelnet/encrypt.c \
|
||||||
|
libtelnet/genget.c \
|
||||||
|
libtelnet/getent.c \
|
||||||
|
libtelnet/kerberos.c \
|
||||||
|
libtelnet/kerberos5.c \
|
||||||
|
libtelnet/krb4encpwd.c \
|
||||||
|
libtelnet/misc.c \
|
||||||
|
libtelnet/read_password.c \
|
||||||
|
libtelnet/rsaencpwd.c \
|
||||||
|
libtelnet/sra.c
|
||||||
|
# libtelnet/pk.c
|
||||||
|
|
||||||
|
TELNET_SRCS = \
|
||||||
|
telnet/authenc.c \
|
||||||
|
telnet/commands.c \
|
||||||
|
telnet/main.c \
|
||||||
|
telnet/network.c \
|
||||||
|
telnet/ring.c \
|
||||||
|
telnet/sys_bsd.c \
|
||||||
|
telnet/telnet.c \
|
||||||
|
telnet/terminal.c \
|
||||||
|
telnet/utilities.c
|
||||||
|
|
||||||
|
TELNETD_SRCS = \
|
||||||
|
telnetd/authenc.c \
|
||||||
|
telnetd/global.c \
|
||||||
|
telnetd/slc.c \
|
||||||
|
telnetd/state.c \
|
||||||
|
telnetd/sys_term.c \
|
||||||
|
telnetd/telnetd.c \
|
||||||
|
telnetd/termstat.c \
|
||||||
|
telnetd/utility.c
|
||||||
|
|
||||||
|
HEADERS = \
|
||||||
|
arpa/telnet.h \
|
||||||
|
libtelnet/auth-proto.h \
|
||||||
|
libtelnet/auth.h \
|
||||||
|
libtelnet/enc-proto.h \
|
||||||
|
libtelnet/encrypt.h \
|
||||||
|
libtelnet/key-proto.h \
|
||||||
|
libtelnet/misc-proto.h \
|
||||||
|
libtelnet/misc.h \
|
||||||
|
libtelnet/pk.h \
|
||||||
|
telnet/baud.h \
|
||||||
|
telnet/defines.h \
|
||||||
|
telnet/externs.h \
|
||||||
|
telnet/fdset.h \
|
||||||
|
telnet/general.h \
|
||||||
|
telnet/ring.h \
|
||||||
|
telnet/types.h \
|
||||||
|
telnetd/defs.h \
|
||||||
|
telnetd/ext.h \
|
||||||
|
telnetd/pathnames.h \
|
||||||
|
telnetd/telnetd.h
|
||||||
|
|
||||||
|
LIBTELNET_OBJS = $(LIBTELNET_SRCS:.c=.o)
|
||||||
|
TELNET_OBJS = $(TELNET_SRCS:.c=.o)
|
||||||
|
TELNETD_OBJS = $(TELNETD_SRCS:.c=.o)
|
||||||
|
OBJS = $(LIBTELNET_OBJS) $(TELNET_OBJS) $(TELNETD_OBJS)
|
||||||
|
|
||||||
|
INCLUDES = -I libtelnet -I .
|
||||||
|
TELNET_DEFINES = -DTERMCAP -DKLUDGELINEMODE -DENV_HACK -DOPIE
|
||||||
|
TELNETD_DEFINES = -DDIAGNOSTICS -DOLD_ENVIRON -DENV_HACK -DSTREAMSPTY
|
||||||
|
DEFINES = $(TELNET_DEFINES) $(TELNETD_DEFINES)
|
||||||
|
LIBS = -ltermcap
|
||||||
|
# CFLAGS suitable for clang or GCC
|
||||||
|
CFLAGS = -std=c89 -funsigned-char -Wall -Wno-pointer-sign -Wno-unused-variable -Wno-string-plus-int
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
|
all: telnet/telnet telnetd/telnetd
|
||||||
|
|
||||||
|
telnet/telnet: $(TELNET_OBJS) $(LIBTELNET_OBJS)
|
||||||
|
$(CC) $(LIBS) $(TELNET_OBJS) $(LIBTELNET_OBJS) -o $@
|
||||||
|
|
||||||
|
telnetd/telnetd: $(TELNETD_OBJS) $(LIBTELNET_OBJS)
|
||||||
|
$(CC) $(LIBS) $(TELNETD_OBJS) $(LIBTELNET_OBJS) -o $@
|
||||||
|
|
||||||
|
$(OBJS): $(HEADERS)
|
||||||
|
%.o: %.c
|
||||||
|
$(CC) $(INCLUDES) \
|
||||||
|
$(if $(findstring $<,$(TELNET_SRCS)),-I telnet $(TELNET_DEFINES)) \
|
||||||
|
$(if $(findstring $<,$(TELNETD_SRCS)),-I telnetd $(TELNETD_DEFINES)) \
|
||||||
|
$(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
$(RM) $(OBJS) telnet/telnet telnetd/telnetd
|
@ -70,7 +70,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <arpa/telnet.h>
|
#include "arpa/telnet.h"
|
||||||
|
|
||||||
#include "encrypt.h"
|
#include "encrypt.h"
|
||||||
#include "auth.h"
|
#include "auth.h"
|
||||||
|
@ -41,7 +41,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
|
|
||||||
#ifdef ENCRYPTION
|
#ifdef ENCRYPTION
|
||||||
# ifdef AUTHENTICATION
|
# ifdef AUTHENTICATION
|
||||||
#include <arpa/telnet.h>
|
#include "arpa/telnet.h"
|
||||||
#include <openssl/des.h>
|
#include <openssl/des.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -65,7 +65,7 @@ static const char sccsid[] = "@(#)encrypt.c 8.2 (Berkeley) 5/30/95";
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#define ENCRYPT_NAMES
|
#define ENCRYPT_NAMES
|
||||||
#include <arpa/telnet.h>
|
#include "arpa/telnet.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -61,7 +61,7 @@ static const char sccsid[] = "@(#)kerberos.c 8.3 (Berkeley) 5/30/95";
|
|||||||
|
|
||||||
#ifdef KRB4
|
#ifdef KRB4
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <arpa/telnet.h>
|
#include "arpa/telnet.h"
|
||||||
#include <openssl/des.h> /* BSD wont include this in krb.h, so we do it here */
|
#include <openssl/des.h> /* BSD wont include this in krb.h, so we do it here */
|
||||||
#include <krb.h>
|
#include <krb.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -57,7 +57,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
|
|
||||||
#ifdef KRB5
|
#ifdef KRB5
|
||||||
|
|
||||||
#include <arpa/telnet.h>
|
#include "arpa/telnet.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -76,7 +76,7 @@ static char sccsid[] = "@(#)krb4encpwd.c 8.3 (Berkeley) 5/30/95";
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <openssl/des.h>
|
#include <openssl/des.h>
|
||||||
#include <arpa/telnet.h>
|
#include "arpa/telnet.h"
|
||||||
#include <krb.h>
|
#include <krb.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -75,7 +75,7 @@ static char sccsid[] = "@(#)rsaencpwd.c 8.3 (Berkeley) 5/30/95";
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <arpa/telnet.h>
|
#include "arpa/telnet.h"
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -35,7 +35,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#ifdef SRA
|
#ifdef SRA
|
||||||
#ifdef ENCRYPTION
|
#ifdef ENCRYPTION
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <arpa/telnet.h>
|
#include "arpa/telnet.h"
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -42,11 +42,11 @@ __FBSDID("$FreeBSD$");
|
|||||||
#ifdef AUTHENTICATION
|
#ifdef AUTHENTICATION
|
||||||
#ifdef ENCRYPTION
|
#ifdef ENCRYPTION
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <arpa/telnet.h>
|
#include "arpa/telnet.h"
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <libtelnet/encrypt.h>
|
#include "libtelnet/encrypt.h"
|
||||||
#include <libtelnet/misc.h>
|
#include "libtelnet/misc.h"
|
||||||
|
|
||||||
#include "general.h"
|
#include "general.h"
|
||||||
#include "ring.h"
|
#include "ring.h"
|
||||||
|
@ -56,7 +56,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <arpa/telnet.h>
|
#include "arpa/telnet.h"
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
#include "general.h"
|
#include "general.h"
|
||||||
@ -69,10 +69,10 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
#ifdef AUTHENTICATION
|
#ifdef AUTHENTICATION
|
||||||
#include <libtelnet/auth.h>
|
#include "libtelnet/auth.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENCRYPTION
|
#ifdef ENCRYPTION
|
||||||
#include <libtelnet/encrypt.h>
|
#include "libtelnet/encrypt.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <netinet/in_systm.h>
|
#include <netinet/in_systm.h>
|
||||||
|
@ -45,14 +45,11 @@
|
|||||||
#define BSD 43
|
#define BSD 43
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef USE_TERMIO
|
|
||||||
# if BSD > 43 || defined(SYSV_TERMIO)
|
|
||||||
# define USE_TERMIO
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
|
#if !defined(USE_TERMIO)
|
||||||
|
# define USE_OLD_TTY
|
||||||
|
#endif
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#ifdef USE_TERMIO
|
#ifdef USE_TERMIO
|
||||||
@ -63,7 +60,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#if defined(NO_CC_T) || !defined(USE_TERMIO)
|
#if defined(NO_CC_T) || !defined(USE_TERMIO)
|
||||||
# if !defined(USE_TERMIO)
|
# if !defined(USE_TERMIO)
|
||||||
typedef char cc_t;
|
typedef unsigned char cc_t;
|
||||||
# else
|
# else
|
||||||
typedef unsigned char cc_t;
|
typedef unsigned char cc_t;
|
||||||
# endif
|
# endif
|
||||||
@ -214,7 +211,7 @@ extern int (*decrypt_input)(int);
|
|||||||
#define set_his_want_state_dont set_my_want_state_wont
|
#define set_his_want_state_dont set_my_want_state_wont
|
||||||
#define set_his_want_state_wont set_my_want_state_dont
|
#define set_his_want_state_wont set_my_want_state_dont
|
||||||
|
|
||||||
#if defined(USE_TERMIO)
|
#if defined(USE_TERMIO) || defined(__STDC__)
|
||||||
#define SIG_FUNC_RET void
|
#define SIG_FUNC_RET void
|
||||||
#else
|
#else
|
||||||
#define SIG_FUNC_RET int
|
#define SIG_FUNC_RET int
|
||||||
|
@ -50,10 +50,10 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
|
||||||
#ifdef AUTHENTICATION
|
#ifdef AUTHENTICATION
|
||||||
#include <libtelnet/auth.h>
|
#include "libtelnet/auth.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENCRYPTION
|
#ifdef ENCRYPTION
|
||||||
#include <libtelnet/encrypt.h>
|
#include "libtelnet/encrypt.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* These values need to be the same as defined in libtelnet/kerberos5.c */
|
/* These values need to be the same as defined in libtelnet/kerberos5.c */
|
||||||
|
@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <arpa/telnet.h>
|
#include "arpa/telnet.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "ring.h"
|
#include "ring.h"
|
||||||
|
@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <arpa/telnet.h>
|
#include "arpa/telnet.h"
|
||||||
|
|
||||||
#include "ring.h"
|
#include "ring.h"
|
||||||
#include "fdset.h"
|
#include "fdset.h"
|
||||||
|
@ -50,10 +50,9 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <curses.h>
|
#include <curses.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <term.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <arpa/telnet.h>
|
#include "arpa/telnet.h"
|
||||||
|
|
||||||
#include "ring.h"
|
#include "ring.h"
|
||||||
|
|
||||||
@ -62,13 +61,19 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "general.h"
|
#include "general.h"
|
||||||
|
|
||||||
|
#ifdef USE_TERMIO
|
||||||
|
# include <term.h>
|
||||||
|
#else
|
||||||
|
# include <termcap.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef AUTHENTICATION
|
#ifdef AUTHENTICATION
|
||||||
#include <libtelnet/auth.h>
|
#include "libtelnet/auth.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENCRYPTION
|
#ifdef ENCRYPTION
|
||||||
#include <libtelnet/encrypt.h>
|
#include "libtelnet/encrypt.h"
|
||||||
#endif
|
#endif
|
||||||
#include <libtelnet/misc.h>
|
#include "libtelnet/misc.h"
|
||||||
|
|
||||||
#define strip(x) ((my_want_state_is_wont(TELOPT_BINARY)) ? ((x)&0x7f) : (x))
|
#define strip(x) ((my_want_state_is_wont(TELOPT_BINARY)) ? ((x)&0x7f) : (x))
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ static const char sccsid[] = "@(#)terminal.c 8.2 (Berkeley) 2/16/95";
|
|||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include <arpa/telnet.h>
|
#include "arpa/telnet.h"
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -50,7 +50,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
#ifdef ENCRYPTION
|
#ifdef ENCRYPTION
|
||||||
#include <libtelnet/encrypt.h>
|
#include "libtelnet/encrypt.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Ring ttyoring, ttyiring;
|
Ring ttyoring, ttyiring;
|
||||||
|
@ -42,7 +42,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#define TELOPTS
|
#define TELOPTS
|
||||||
#define TELCMDS
|
#define TELCMDS
|
||||||
#define SLC_NAMES
|
#define SLC_NAMES
|
||||||
#include <arpa/telnet.h>
|
#include "arpa/telnet.h"
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
@ -61,10 +61,10 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include "externs.h"
|
#include "externs.h"
|
||||||
|
|
||||||
#ifdef AUTHENTICATION
|
#ifdef AUTHENTICATION
|
||||||
#include <libtelnet/auth.h>
|
#include "libtelnet/auth.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENCRYPTION
|
#ifdef ENCRYPTION
|
||||||
#include <libtelnet/encrypt.h>
|
#include "libtelnet/encrypt.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FILE *NetTrace = 0; /* Not in bss, since needs to stay */
|
FILE *NetTrace = 0; /* Not in bss, since needs to stay */
|
||||||
|
@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
/* Above "#ifdef"s actually "or"'ed together. XXX MarkM
|
/* Above "#ifdef"s actually "or"'ed together. XXX MarkM
|
||||||
*/
|
*/
|
||||||
#include "telnetd.h"
|
#include "telnetd.h"
|
||||||
#include <libtelnet/misc.h>
|
#include "libtelnet/misc.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
net_write(unsigned char *str, int len)
|
net_write(unsigned char *str, int len)
|
||||||
|
@ -68,7 +68,7 @@
|
|||||||
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
|
||||||
#include <arpa/telnet.h>
|
#include "arpa/telnet.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#ifdef __STDC__
|
#ifdef __STDC__
|
||||||
|
@ -42,10 +42,10 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "telnetd.h"
|
#include "telnetd.h"
|
||||||
#ifdef AUTHENTICATION
|
#ifdef AUTHENTICATION
|
||||||
#include <libtelnet/auth.h>
|
#include "libtelnet/auth.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENCRYPTION
|
#ifdef ENCRYPTION
|
||||||
#include <libtelnet/encrypt.h>
|
#include "libtelnet/encrypt.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
unsigned char doopt[] = { IAC, DO, '%', 'c', 0 };
|
unsigned char doopt[] = { IAC, DO, '%', 'c', 0 };
|
||||||
|
@ -41,16 +41,13 @@ __FBSDID("$FreeBSD$");
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/tty.h>
|
#include <sys/tty.h>
|
||||||
#include <libutil.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "telnetd.h"
|
#include "telnetd.h"
|
||||||
#include "pathnames.h"
|
#include "pathnames.h"
|
||||||
#include "types.h"
|
|
||||||
#include "baud.h"
|
|
||||||
|
|
||||||
#ifdef AUTHENTICATION
|
#ifdef AUTHENTICATION
|
||||||
#include <libtelnet/auth.h>
|
#include "libtelnet/auth.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int cleanopen(char *);
|
int cleanopen(char *);
|
||||||
@ -126,7 +123,6 @@ struct termios termbuf, termbuf2; /* pty control structure */
|
|||||||
#endif /* USE_TERMIO */
|
#endif /* USE_TERMIO */
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <libutil.h>
|
|
||||||
|
|
||||||
int cleanopen(char *);
|
int cleanopen(char *);
|
||||||
void scrub_env(void);
|
void scrub_env(void);
|
||||||
@ -809,7 +805,11 @@ getptyslave(void)
|
|||||||
# ifdef LINEMODE
|
# ifdef LINEMODE
|
||||||
waslm = tty_linemode();
|
waslm = tty_linemode();
|
||||||
# endif
|
# endif
|
||||||
|
# ifdef USE_TERMIO
|
||||||
erase = termbuf.c_cc[VERASE];
|
erase = termbuf.c_cc[VERASE];
|
||||||
|
# else
|
||||||
|
erase = termbuf.sg.sg_erase;
|
||||||
|
# endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure that we don't have a controlling tty, and
|
* Make sure that we don't have a controlling tty, and
|
||||||
@ -855,8 +855,13 @@ getptyslave(void)
|
|||||||
*/
|
*/
|
||||||
tty_rspeed((def_rspeed > 0) ? def_rspeed : 9600);
|
tty_rspeed((def_rspeed > 0) ? def_rspeed : 9600);
|
||||||
tty_tspeed((def_tspeed > 0) ? def_tspeed : 9600);
|
tty_tspeed((def_tspeed > 0) ? def_tspeed : 9600);
|
||||||
if (erase)
|
if (erase) {
|
||||||
|
# ifdef USE_TERMIO
|
||||||
termbuf.c_cc[VERASE] = erase;
|
termbuf.c_cc[VERASE] = erase;
|
||||||
|
# else
|
||||||
|
termbuf.sg.sg_erase = erase;
|
||||||
|
# endif
|
||||||
|
}
|
||||||
# ifdef LINEMODE
|
# ifdef LINEMODE
|
||||||
if (waslm)
|
if (waslm)
|
||||||
tty_setlinemode(1);
|
tty_setlinemode(1);
|
||||||
|
@ -44,20 +44,19 @@ __FBSDID("$FreeBSD$");
|
|||||||
|
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <libutil.h>
|
|
||||||
#include <paths.h>
|
#include <paths.h>
|
||||||
#include <termcap.h>
|
#include <termcap.h>
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
#ifdef AUTHENTICATION
|
#ifdef AUTHENTICATION
|
||||||
#include <libtelnet/auth.h>
|
#include "libtelnet/auth.h"
|
||||||
int auth_level = 0;
|
int auth_level = 0;
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENCRYPTION
|
#ifdef ENCRYPTION
|
||||||
#include <libtelnet/encrypt.h>
|
#include "libtelnet/encrypt.h"
|
||||||
#endif
|
#endif
|
||||||
#include <libtelnet/misc.h>
|
#include "libtelnet/misc.h"
|
||||||
|
|
||||||
char remote_hostname[MAXHOSTNAMELEN];
|
char remote_hostname[MAXHOSTNAMELEN];
|
||||||
size_t utmp_len = sizeof(remote_hostname) - 1;
|
size_t utmp_len = sizeof(remote_hostname) - 1;
|
||||||
@ -658,10 +657,13 @@ terminaltypeok(char *s)
|
|||||||
* Get a pty, scan input lines.
|
* Get a pty, scan input lines.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
doit(struct sockaddr *who)
|
doit(struct sockaddr *who_)
|
||||||
{
|
{
|
||||||
int err_; /* XXX */
|
int err_; /* XXX */
|
||||||
|
char *host = NULL;
|
||||||
|
struct hostent *hp;
|
||||||
int ptynum;
|
int ptynum;
|
||||||
|
struct sockaddr_in *who;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find an available pty to use.
|
* Find an available pty to use.
|
||||||
@ -686,30 +688,51 @@ doit(struct sockaddr *who)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* get name of connected client */
|
/* get name of connected client */
|
||||||
if (realhostname_sa(remote_hostname, sizeof(remote_hostname) - 1,
|
if (who_->sa_family != AF_INET)
|
||||||
who, who->sa_len) == HOSTNAME_INVALIDADDR && registerd_host_only)
|
fatal(net, "Non-IPv4 addresses are not supported");
|
||||||
|
who = (struct sockaddr_in *)who_;
|
||||||
|
hp = gethostbyaddr((char *)&who->sin_addr, sizeof (struct in_addr),
|
||||||
|
who->sin_family);
|
||||||
|
|
||||||
|
if (hp == NULL && registerd_host_only) {
|
||||||
fatal(net, "Couldn't resolve your address into a host name.\r\n\
|
fatal(net, "Couldn't resolve your address into a host name.\r\n\
|
||||||
Please contact your net administrator");
|
Please contact your net administrator");
|
||||||
remote_hostname[sizeof(remote_hostname) - 1] = '\0';
|
} else if (hp &&
|
||||||
|
(strlen(hp->h_name) <= (unsigned int)((utmp_len < 0) ? -utmp_len
|
||||||
|
: utmp_len))) {
|
||||||
|
strncpy(remote_hostname, hp->h_name,
|
||||||
|
sizeof(remote_hostname)-1);
|
||||||
|
hp = gethostbyname(remote_hostname);
|
||||||
|
if (hp == NULL)
|
||||||
|
host = inet_ntoa(who->sin_addr);
|
||||||
|
else for (; ; hp->h_addr_list++) {
|
||||||
|
if (hp->h_addr_list[0] == NULL) {
|
||||||
|
/* End of list - ditch it */
|
||||||
|
host = inet_ntoa(who->sin_addr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!bcmp(hp->h_addr_list[0], (caddr_t)&who->sin_addr,
|
||||||
|
sizeof(who->sin_addr))) {
|
||||||
|
host = hp->h_name;
|
||||||
|
break; /* OK! */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
host = inet_ntoa(who->sin_addr);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* We must make a copy because Kerberos is probably going
|
||||||
|
* to also do a gethost* and overwrite the static data...
|
||||||
|
*/
|
||||||
|
strncpy(remote_hostname, host, sizeof(remote_hostname)-1);
|
||||||
|
remote_hostname[sizeof(remote_hostname)-1] = 0;
|
||||||
|
host = remote_hostname;
|
||||||
|
|
||||||
if (!isdigit(remote_hostname[0]) && strlen(remote_hostname) > utmp_len)
|
(void) gethostname(host_name, sizeof (host_name));
|
||||||
err_ = getnameinfo(who, who->sa_len, remote_hostname,
|
|
||||||
sizeof(remote_hostname), NULL, 0,
|
|
||||||
NI_NUMERICHOST);
|
|
||||||
/* XXX: do 'err_' check */
|
|
||||||
|
|
||||||
(void) gethostname(host_name, sizeof(host_name) - 1);
|
|
||||||
host_name[sizeof(host_name) - 1] = '\0';
|
|
||||||
hostname = host_name;
|
hostname = host_name;
|
||||||
|
|
||||||
#ifdef AUTHENTICATION
|
#if defined(AUTHENTICATION) || defined(ENCRYPTION)
|
||||||
#ifdef ENCRYPTION
|
auth_encrypt_init(hostname, host, "TELNETD", 1);
|
||||||
/* The above #ifdefs should actually be "or"'ed, not "and"'ed.
|
|
||||||
* This is a byproduct of needing "#ifdef" and not "#if defined()"
|
|
||||||
* for unifdef. XXX MarkM
|
|
||||||
*/
|
|
||||||
auth_encrypt_init(hostname, remote_hostname, "TELNETD", 1);
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
init_env();
|
init_env();
|
||||||
@ -720,7 +743,7 @@ doit(struct sockaddr *who)
|
|||||||
level = getterminaltype(user_name);
|
level = getterminaltype(user_name);
|
||||||
setenv("TERM", terminaltype ? terminaltype : "network", 1);
|
setenv("TERM", terminaltype ? terminaltype : "network", 1);
|
||||||
|
|
||||||
telnet(net, pty, remote_hostname); /* begin server process */
|
telnet(net, pty, host); /* begin server process */
|
||||||
|
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
} /* end of doit */
|
} /* end of doit */
|
||||||
|
@ -42,7 +42,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include "telnetd.h"
|
#include "telnetd.h"
|
||||||
|
|
||||||
#ifdef ENCRYPTION
|
#ifdef ENCRYPTION
|
||||||
#include <libtelnet/encrypt.h>
|
#include "libtelnet/encrypt.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -48,10 +48,10 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include "telnetd.h"
|
#include "telnetd.h"
|
||||||
|
|
||||||
#ifdef AUTHENTICATION
|
#ifdef AUTHENTICATION
|
||||||
#include <libtelnet/auth.h>
|
#include "libtelnet/auth.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENCRYPTION
|
#ifdef ENCRYPTION
|
||||||
#include <libtelnet/encrypt.h>
|
#include "libtelnet/encrypt.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user