summaryrefslogtreecommitdiffstats
path: root/crypto/telnet/telnetd
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>2001-08-20 12:28:40 +0000
committermarkm <markm@FreeBSD.org>2001-08-20 12:28:40 +0000
commit62fa01a04b42f494fdbb2d37f587cf04a6d1aacb (patch)
tree2ba46740530084e43c8757dfe6c194c01635f8d3 /crypto/telnet/telnetd
parent83e59be2f658dd3a79d19c79cb5e76b14fd75880 (diff)
downloadFreeBSD-src-62fa01a04b42f494fdbb2d37f587cf04a6d1aacb.zip
FreeBSD-src-62fa01a04b42f494fdbb2d37f587cf04a6d1aacb.tar.gz
Code merge and diff reduce with "base" telnet. This is the "later"
telnet, so it was treated as the reference code, except where later commits were made to "base" telnet.
Diffstat (limited to 'crypto/telnet/telnetd')
-rw-r--r--crypto/telnet/telnetd/ext.h2
-rw-r--r--crypto/telnet/telnetd/pathnames.h2
-rw-r--r--crypto/telnet/telnetd/state.c5
-rw-r--r--crypto/telnet/telnetd/sys_term.c32
-rw-r--r--crypto/telnet/telnetd/telnetd.838
-rw-r--r--crypto/telnet/telnetd/telnetd.c9
-rw-r--r--crypto/telnet/telnetd/termstat.c32
-rw-r--r--crypto/telnet/telnetd/utility.c6
8 files changed, 76 insertions, 50 deletions
diff --git a/crypto/telnet/telnetd/ext.h b/crypto/telnet/telnetd/ext.h
index 0744db1..1492f82 100644
--- a/crypto/telnet/telnetd/ext.h
+++ b/crypto/telnet/telnetd/ext.h
@@ -85,7 +85,7 @@ extern char *unptyip; /* pointer to remaining characters in buffer */
#endif
extern int pty, net;
-extern char *line;
+extern char line[16];
extern int SYNCHing; /* we are in TELNET SYNCH mode */
#ifndef P
diff --git a/crypto/telnet/telnetd/pathnames.h b/crypto/telnet/telnetd/pathnames.h
index b4ce9ce..ed8ee88 100644
--- a/crypto/telnet/telnetd/pathnames.h
+++ b/crypto/telnet/telnetd/pathnames.h
@@ -43,7 +43,7 @@
# endif
#else
-
+
# define _PATH_TTY "/dev/tty"
# ifndef _PATH_LOGIN
# define _PATH_LOGIN "/bin/login"
diff --git a/crypto/telnet/telnetd/state.c b/crypto/telnet/telnetd/state.c
index f5b1299..6d7ca94 100644
--- a/crypto/telnet/telnetd/state.c
+++ b/crypto/telnet/telnetd/state.c
@@ -721,6 +721,7 @@ wontoption(option)
*/
if (lmodetype != REAL_LINEMODE)
break;
+ lmodetype = KLUDGE_LINEMODE;
# endif /* KLUDGELINEMODE */
clientstat(TELOPT_LINEMODE, WONT, 0);
break;
@@ -1551,10 +1552,14 @@ send_status()
if (my_want_state_is_will(i)) {
ADD(WILL);
ADD_DATA(i);
+ if (i == IAC)
+ ADD(IAC);
}
if (his_want_state_is_will(i)) {
ADD(DO);
ADD_DATA(i);
+ if (i == IAC)
+ ADD(IAC);
}
}
diff --git a/crypto/telnet/telnetd/sys_term.c b/crypto/telnet/telnetd/sys_term.c
index 7d0811f..16e16c4 100644
--- a/crypto/telnet/telnetd/sys_term.c
+++ b/crypto/telnet/telnetd/sys_term.c
@@ -481,14 +481,10 @@ getnpty()
*
* Returns the file descriptor of the opened pty.
*/
-#ifndef __GNUC__
-char *line = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
-#else
-static char Xline[] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
-char *line = Xline;
-#endif
#ifdef CRAY
-char *myline = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
+char myline[16];
+#else
+char line[16];
#endif /* CRAY */
int
@@ -517,7 +513,8 @@ int *ptynum;
#endif
#ifndef __hpux
- (void) strcpy(line, "/dev/ptyXX");
+ (void) strcpy(line, _PATH_DEV);
+ (void) strcat(line, "ptyXX");
p1 = &line[8];
p2 = &line[9];
#else
@@ -568,11 +565,11 @@ int *ptynum;
struct stat sb;
for (*ptynum = lowpty; *ptynum <= highpty; (*ptynum)++) {
- (void) sprintf(myline, "/dev/pty/%03d", *ptynum);
+ (void) sprintf(myline, "%spty/%03d", _PATH_DEV, *ptynum);
p = open(myline, 2);
if (p < 0)
continue;
- (void) sprintf(line, "/dev/ttyp%03d", *ptynum);
+ (void) sprintf(line, "%sp%03d", _PATH_TTY, *ptynum);
/*
* Here are some shenanigans to make sure that there
* are no listeners lurking on the line.
@@ -1300,6 +1297,7 @@ cleanopen(line)
(void) signal(SIGHUP, SIG_IGN);
(void) ioctl(t, TCVHUP, (char *)0);
(void) signal(SIGHUP, SIG_DFL);
+ setpgrp();
#ifdef UNICOS7x
if (secflag) {
@@ -1359,7 +1357,7 @@ login_tty(t)
* the indirect /dev/tty interface.
*/
close(t);
- if ((t = open("/dev/tty", O_RDWR)) < 0)
+ if ((t = open(_PATH_TTY, O_RDWR)) < 0)
fatalperror(net, "open(/dev/tty)");
# endif
# else
@@ -1452,7 +1450,7 @@ startslave(host, autologin, autoname)
wtmp.ut_pid = pid;
SCPYN(wtmp.ut_user, "LOGIN");
SCPYN(wtmp.ut_host, host);
- SCPYN(wtmp.ut_line, line + sizeof("/dev/") - 1);
+ SCPYN(wtmp.ut_line, line + sizeof(_PATH_DEV) - 1);
#ifndef __hpux
SCPYN(wtmp.ut_id, wtmp.ut_line+3);
#else
@@ -1584,7 +1582,7 @@ start_login(host, autologin, name)
memset(&utmpx, 0, sizeof(utmpx));
SCPYN(utmpx.ut_user, ".telnet");
- SCPYN(utmpx.ut_line, line + sizeof("/dev/") - 1);
+ SCPYN(utmpx.ut_line, line + sizeof(_PATH_DEV) - 1);
utmpx.ut_pid = pid;
utmpx.ut_id[0] = 't';
utmpx.ut_id[1] = 'n';
@@ -1898,7 +1896,7 @@ cleanup(sig)
# if (BSD > 43) || defined(convex)
char *p;
- p = line + sizeof("/dev/") - 1;
+ p = line + sizeof(_PATH_DEV) - 1;
if (logout(p))
logwtmp(p, "", "");
(void)chmod(line, 0666);
@@ -2209,7 +2207,7 @@ cleantmpdir(jid, tpath, user)
tpath);
break;
case 0:
- execl(CLEANTMPCMD, CLEANTMPCMD, user, tpath, 0);
+ execl(CLEANTMPCMD, CLEANTMPCMD, user, tpath, (char *)0);
syslog(LOG_ERR, "TMPDIR cleanup(%s): execl(%s) failed: %m",
tpath, CLEANTMPCMD);
exit(1);
@@ -2247,7 +2245,7 @@ rmut()
* This updates the utmpx and utmp entries and make a wtmp/x entry
*/
- SCPYN(utmpx.ut_line, line + sizeof("/dev/") - 1);
+ SCPYN(utmpx.ut_line, line + sizeof(_PATH_DEV) - 1);
utxp = getutxline(&utmpx);
if (utxp) {
utxp->ut_type = DEAD_PROCESS;
@@ -2308,7 +2306,7 @@ rmut()
}
(void) chmod(line, 0666);
(void) chown(line, 0, 0);
- line[strlen("/dev/")] = 'p';
+ line[strlen(_PATH_DEV)] = 'p';
(void) chmod(line, 0666);
(void) chown(line, 0, 0);
} /* end of rmut */
diff --git a/crypto/telnet/telnetd/telnetd.8 b/crypto/telnet/telnetd/telnetd.8
index 029b8e8..20093df 100644
--- a/crypto/telnet/telnetd/telnetd.8
+++ b/crypto/telnet/telnetd/telnetd.8
@@ -76,7 +76,7 @@ option may be used to start up
.Nm
manually, instead of through
.Xr inetd 8 .
-If started up this way,
+If started up this way,
.Ar port
may be specified to run
.Nm
@@ -156,7 +156,7 @@ to print out debugging information
to the connection, allowing the user to see what
.Nm
is doing.
-There are several possible values for
+There are several possible values for
.Ar debugmode :
.Bl -tag -width exercise
.It Cm options
@@ -164,7 +164,7 @@ Print information about the negotiation of
.Tn TELNET
options.
.It Cm report
-Print the
+Print the
.Cm options
information, plus some additional information
about what processing is going on.
@@ -339,7 +339,7 @@ a specific authentication type without having to recompile
operates by allocating a pseudo-terminal device (see
.Xr pty 4 )
for a client, then creating a login process which has
-the slave side of the pseudo-terminal as
+the slave side of the pseudo-terminal as
.Dv stdin ,
.Dv stdout
and
@@ -353,7 +353,7 @@ between the remote client and the login process.
.Pp
When a
.Tn TELNET
-session is started up,
+session is started up,
.Nm
sends
.Tn TELNET
@@ -432,7 +432,7 @@ Whenever a
.Dv DO TIMING-MARK
command is received, it is always responded
to with a
-.Dv WILL TIMING-MARK
+.Dv WILL TIMING-MARK .
.It "WILL LOGOUT"
When a
.Dv DO LOGOUT
@@ -528,9 +528,34 @@ is compiled with support for data encryption, and
indicates a willingness to decrypt
the data stream.
.El
+.Sh NOTES
+By default
+.Nm
+will read the
+.Em \&he ,
+.Em \&hn ,
+and
+.Em \&im
+capabilities from
+.Pa /etc/gettytab
+and use that information (if present) to determine
+what to display before the login: prompt. You can
+also use a System V style
+.Pa /etc/issue
+file by using the
+.Em \&if
+capability, which will override
+.Em \&im .
+The information specified in either
+.Em \&im
+or
+.Em \&if
+will be displayed to both console and remote logins.
+.\" .Sh ENVIRONMENT
.Sh FILES
.Bl -tag -width /usr/ucb/bftp -compact
.It Pa /etc/services
+.It Pa /etc/gettytab
.It Pa /etc/inittab
(UNICOS systems only)
.It Pa /etc/iptos
@@ -541,6 +566,7 @@ the data stream.
.Sh "SEE ALSO"
.Xr bftp 1 ,
.Xr login 1 ,
+.Xr gettytab 5 ,
.Xr telnet 1
(if supported)
.Sh STANDARDS
diff --git a/crypto/telnet/telnetd/telnetd.c b/crypto/telnet/telnetd/telnetd.c
index 7ae4568..0ddb266 100644
--- a/crypto/telnet/telnetd/telnetd.c
+++ b/crypto/telnet/telnetd/telnetd.c
@@ -60,7 +60,9 @@ static const char rcsid[] =
#include <err.h>
#include <arpa/inet.h>
+#include <sys/mman.h>
#include <libutil.h>
+#include <paths.h>
#include <utmp.h>
#if defined(_SC_CRAY_SECURE_SYS)
@@ -847,7 +849,6 @@ doit(who)
#else
for (;;) {
char *lp;
- extern char *line, *getpty();
if ((lp = getpty()) == NULL)
fatal(net, "Out of ptys");
@@ -867,10 +868,10 @@ doit(who)
if (secflag) {
char slave_dev[16];
- sprintf(tty_dev, "/dev/pty/%03d", ptynum);
+ sprintf(tty_dev, "%spty/%03d", _PATH_DEV, ptynum);
if (setdevs(tty_dev, &dv) < 0)
fatal(net, "cannot set pty security");
- sprintf(slave_dev, "/dev/ttyp%03d", ptynum);
+ sprintf(slave_dev, "%sp%03d", _PATH_TTY, ptynum);
if (setdevs(slave_dev, &dv) < 0)
fatal(net, "cannot set tty security");
}
@@ -880,7 +881,7 @@ doit(who)
if (realhostname_sa(remote_hostname, sizeof(remote_hostname) - 1,
who, who->sa_len) == HOSTNAME_INVALIDADDR && registerd_host_only)
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';
trimdomain(remote_hostname, UT_HOSTSIZE);
diff --git a/crypto/telnet/telnetd/termstat.c b/crypto/telnet/telnetd/termstat.c
index a24135b..ae83163 100644
--- a/crypto/telnet/telnetd/termstat.c
+++ b/crypto/telnet/telnetd/termstat.c
@@ -171,30 +171,30 @@ localstat()
if (uselinemode) {
/*
- * Check for state of BINARY options.
+ * Check for state of BINARY options.
*
* We only need to do the binary dance if we are actually going
* to use linemode. As this confuses some telnet clients
* that don't support linemode, and doesn't gain us
* anything, we don't do it unless we're doing linemode.
* -Crh (henrich@msu.edu)
- */
+ */
- if (tty_isbinaryin()) {
- if (his_want_state_is_wont(TELOPT_BINARY))
- send_do(TELOPT_BINARY, 1);
- } else {
- if (his_want_state_is_will(TELOPT_BINARY))
- send_dont(TELOPT_BINARY, 1);
- }
+ if (tty_isbinaryin()) {
+ if (his_want_state_is_wont(TELOPT_BINARY))
+ send_do(TELOPT_BINARY, 1);
+ } else {
+ if (his_want_state_is_will(TELOPT_BINARY))
+ send_dont(TELOPT_BINARY, 1);
+ }
- if (tty_isbinaryout()) {
- if (my_want_state_is_wont(TELOPT_BINARY))
- send_will(TELOPT_BINARY, 1);
- } else {
- if (my_want_state_is_will(TELOPT_BINARY))
- send_wont(TELOPT_BINARY, 1);
- }
+ if (tty_isbinaryout()) {
+ if (my_want_state_is_wont(TELOPT_BINARY))
+ send_will(TELOPT_BINARY, 1);
+ } else {
+ if (my_want_state_is_will(TELOPT_BINARY))
+ send_wont(TELOPT_BINARY, 1);
+ }
}
#ifdef ENCRYPTION
diff --git a/crypto/telnet/telnetd/utility.c b/crypto/telnet/telnetd/utility.c
index 48eac65..f9b4e46 100644
--- a/crypto/telnet/telnetd/utility.c
+++ b/crypto/telnet/telnetd/utility.c
@@ -43,6 +43,7 @@ static const char rcsid[] =
#include <locale.h>
#include <sys/utsname.h>
#endif
+#include <string.h>
#define PRINTOPTIONS
#include "telnetd.h"
@@ -438,11 +439,6 @@ putf(cp, where)
char *slash;
time_t t;
char db[100];
-#ifdef STREAMSPTY
- extern char *strchr();
-#else
- extern char *strrchr();
-#endif
#ifdef __FreeBSD__
static struct utsname kerninfo;
OpenPOWER on IntegriCloud