Commit Graph

77 Commits

Author SHA1 Message Date
Stephen Heumann
de9fad8d67 More small changes for GNO and ORCA/C compatibility.
In particular, address a couple instances where GNO's sockets implementation doesn't comply with modern standards.
Also, add a few missing prototypes so we can use ORCA/C prototype-checking lint functionality.
2015-05-31 19:52:28 -05:00
Stephen Heumann
9bab5c3dec Add an implementation of getaddrinfo and getnameinfo, which are missing in GNO.
These are adapted from a version in netperf.
2015-05-31 16:56:05 -05:00
Stephen Heumann
581990e767 Misc. small changes for GNO and ORCA/C compatibility 2015-05-31 15:27:34 -05:00
Stephen Heumann
cfa9287257 Back out recently-added code that uses mmap. 2015-05-31 10:12:25 -05:00
Stephen Heumann
e8c6388223 Get rid of __FBSDID macros, which aren't defined in GNO (and thus prevent compilation). 2015-05-30 22:26:48 -05:00
Stephen Heumann
327170235b 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)
2015-05-30 22:12:01 -05:00
ngie
052bf438de Add baud rate support to telnet(1)
This implements part of RFC-2217

It's based off a patch originally written by Sujal Patel at Isilon, and
contributions from other Isilon employees.

PR: 173728
Phabric: D995
Reviewed by: markj, markm
MFC after: 2 weeks
Sponsored by: EMC / Isilon Storage Division


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@274364 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2014-11-11 04:06:05 +00:00
marcel
2d43ae29e1 Improve upon previous commit:
1.  Check return of mmap(2) (*)
2.  Avoid FD leak when fstat fails.
3.  Fix style(9).

(*) Pointed out by jmg@


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@262679 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2014-03-02 03:34:06 +00:00
marcel
2c30da6c4a Revive support for /etc/issue, lost due revision 81963.
Obtained from:	Juniper Networks, Inc.


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@262673 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2014-03-02 00:47:47 +00:00
sjg
839f5deaca Propagate ancient fix from Junos.
Use of -h is not supposed to depend on AUTHENTICATION being defined.

Reviewed by: markm


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@257773 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2013-11-07 00:36:39 +00:00
marcel
d37ea43702 Fix "automatic" login, broken by revision 69825 (12 years, 5 months ago).
The "automatic" login feature is described as follows:
The USER environment variable holds the name of the person telnetting in.
This is the username of the person on the client machine. The traditional
behaviour is to execute login(1) with this username first, meaning that
login(1) will prompt for the password only. If login fails, login(1) will
retry, but now prompt for the username before prompting for the password.

This feature got broken by how the environment got scrubbed. Before the
change in r69825 we removed variables that we deemed dangerous. Starting
with r69825 we only keep those variable we know to be safe.

The USER environment variable fell through the cracks. It suddenly got
scrubbed (i.e. removed from the environment) while still being checked
for. It also got explicitly removed from the environment to handle the
failed login case.

The fix is to obtain the value of the USER environment variable before
we scrub the environment and used the "cached" in subsequent checks.
This guarantees that the environment does not contain the USER variable
in the end, while still being able to implement "automatic" login.

Obtained from:	Juniper Networks, Inc.


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@251188 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2013-05-31 17:30:12 +00:00
kevlo
6b099757e8 Make sure that each va_start has one and only one matching va_end,
especially in error cases.


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@241021 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2012-09-28 07:51:30 +00:00
dim
bd32956cba In contrib/telnet/telnetd/utility.c, fix a few warnings about format
strings not being literals.

MFC after:	1 week


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@228589 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2011-12-16 16:53:54 +00:00
ed
b3741997b0 Forgot a part that was missing in the previous commit.
There is no need to call trimdomain() anymore now that ut_host is big
enough to fit decent hostnames.


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@202214 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2010-01-13 18:46:50 +00:00
ed
22cdf6fd37 Let telnetd build without utmp and logwtmp(3).
Just like rlogind, there is no need to change the ownership of the
terminal during shutdown anymore. Also don't call logwtmp, because the
login(1)/PAM is responsible for doing this. Also use SHUT_RDWR instead
of 2.


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@202212 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2010-01-13 18:37:42 +00:00
ed
29b3953035 Remove unneeded inclusion of <utmp.h> and dead variables.
git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@201047 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2009-12-27 11:56:32 +00:00
cperciva
1d2eb11519 Correctly scrub telnetd's environment.
Approved by:	so (cperciva)
Security:	FreeBSD-SA-09:05.telnetd


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@188699 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2009-02-16 21:56:17 +00:00
ed
8d9786e342 Use strlcpy() instead of strcpy().
Requested by:	mlaier


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@184938 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2008-11-13 20:40:38 +00:00
ed
7aa7324a8f Convert telnetd(8) to use posix_openpt(2).
Some time ago I got some reports MPSAFE TTY broke telnetd(8). Even
though it turned out to be a different problem within the TTY code, I
spotted a small issue with telnetd(8). Instead of allocating PTY's using
openpty(3) or posix_openpt(2), it used its own PTY allocation routine.
This means that telnetd(8) still uses /dev/ptyXX-style devices.

I've also increased the size of line[]. Even though 16 should be enough,
we already use 13 bytes ("/dev/pts/999", including '\0'). 32 bytes gives
us a little more freedom.

Also enable -DSTREAMSPTY. Otherwise telnetd(8) strips the PTY's pathname
to the latest slash instead of just removing "/dev/" (e.g. /dev/pts/0 ->
0, instead of pts/0).

Reviewed by:	rink


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@184935 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2008-11-13 19:05:27 +00:00
trhodes
180a45c5fb List authentication types supported with "-X" taken from the libtelnet
code.

PR:		121721


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@182419 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2008-08-29 00:04:37 +00:00
jhb
d76e719277 Don't attempt authentication at all if it has been disabled via '-a off'.
This works around a bug in HP-UX's telnet client and also gives a much
saner user experience when using FreeBSD's telnet client.

PR:		bin/19405
Submitted by:	Joel Ray Holveck   joelh of gnu.org
MFC after:	1 month


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@180931 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2008-07-28 18:58:16 +00:00
ru
7fe816d452 Remove bogus casts of valid integer ioctl() arguments.
git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@162671 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2006-09-26 21:46:12 +00:00
ume
b88638bb41 NI_WITHSCOPEID cleanup
git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@146468 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2005-05-21 15:28:42 +00:00
ru
26fb67c648 - Soften sentence breaks.
- Remove double whitespace.
- Sort sections.


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@140601 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2005-01-21 21:57:05 +00:00
maxim
82ff960df9 o Make telnet[d] -S (IP TOS) flag really work. We do not have
/etc/iptos implementation so only numeric values supported.

o telnetd.8: steal the -S flag description from telnet.1, bump
the date of the document.

MFC after:	6 weeks


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@139937 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2005-01-09 10:24:46 +00:00
maxim
10faff8b17 o Add -4 and -6 flags to a man page and usage(). Bump the man page
date.


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@139713 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2005-01-05 09:59:38 +00:00
kan
5adbfa7aec Add missing () to function invocation.
git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@132753 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2004-07-28 05:37:18 +00:00
harti
6a39aef766 Implement what has been documented for a long time: make -debug switch
on socket debugging.

Okay'ed by: markm


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@118865 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2003-08-13 10:56:40 +00:00
markm
4369ac2a7f Fix up external variables named "debug" that have a horrible habit
of conflicting with other, similarly named functions in static
libraries. This is done mostly by renaming the var if it is shared
amongst modules, or making it static otherwise.

OK'ed by:	re(scottl)


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@114911 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2003-05-11 18:17:00 +00:00
obrien
90a2e082b9 Use __FBSDID vs. rcsid[]. Also protect sccs[] and copyright[] from GCC 3.3.
git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@114630 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2003-05-04 02:54:49 +00:00
markm
5a5138f8df Catch up with "base" telnet.
s/FALL THROUGH/FALLTHROUGH/ for lint(1).


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@103956 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2002-09-25 07:28:04 +00:00
jmallett
e151b0ff25 Don't risk catching a signal while handling a signal for a dying child, as we
can then end up not properly clearing wtmp/utmp entries.

PR:		bin/37934
Submitted by:	Sandeep Kumar <skumar@juniper.net>
Reviewed by:	markm
MFC after:	2 weeks


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@97341 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2002-05-27 08:10:24 +00:00
sheldonh
48a0b67941 Don't use non-signal-safe functions (exit(3) in this case) in
signal handlers.  In this case, use _exit(2) instead, following
the call to shutdown(2).

This fixes rare telnetd hangs.

PR:		misc/33672
Submitted by:	Umesh Krishnaswamy <umesh@juniper.net>
MFC after:	1 month


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@90242 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2002-02-05 15:20:02 +00:00
ru
415314d0f6 mdoc(7) police: remove -r from SYNOPSIS, sort -p in DESCRIPTION.
git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@87882 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2001-12-14 14:41:07 +00:00
ru
c166211dae Fixed bugs from previous revision.
Removed -s from SYNOPSIS and restored -S in DESCRIPTION.


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@87358 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2001-12-04 16:02:36 +00:00
markm
ba361ec27c More help for alpha WARNS=2. This code is, erm, unusual. Anyone who
feels like rewriting it will meet no objection from me.


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@87267 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2001-12-03 12:16:40 +00:00
markm
a88d48b9df Damn. The previous mega-commit was incomplete WRT ANSIfication. This
fixes that.


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@87155 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2001-11-30 22:28:07 +00:00
markm
820d180830 Very large style makeover.
1) ANSIfy.
2) Clean up ifdefs so that
   a) ones that never/always apply are appropriately either
      fully removed, or just the #if junk is removed.
   b) change #if defined(FOO) for appropiate values of FOO.
      (currently AUTHENTICATION and ENCRYPTION)
3) WARNS=2 fixing
4) GC other unused stuff

This code can now be unifdef(1)ed to make non-crypto telnet.


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@87139 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2001-11-30 21:06:38 +00:00
markm
3efb267b2d Manually unifdef(1) CRAY, UNICOS, hpux and sun uselsess code.
git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@82497 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2001-08-29 14:16:17 +00:00
dd
ee8be0d9e9 Remove description of an option that only applies to UNICOS < 7.0.
That define may still be present in the source, but I don't think
anyone has plans to try to use it.

Obtained from:	NetBSD


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@82326 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2001-08-25 21:29:12 +00:00
markm
0fd2377dcc 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.


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@81965 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2001-08-20 12:28:40 +00:00
ru
02129244b2 mdoc(7) police: s/BSD/.Bx/ where appropriate.
git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@81622 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2001-08-14 10:01:54 +00:00
kris
9de6e7ba10 output_data(), output_datalen() and netflush() didn't actually guarantee
to do what they are supposed to: under some circumstances output data would
be truncated, or the buffer would not actually be flushed (possibly leading
to overflows when the caller assumes the operation succeeded).  Change the
semantics so that these functions ensure they complete the operation before
returning.

Comment out diagnostic code enabled by '-D reports' which causes an
infinite recursion and an eventual crash.

Patch developed with assistance from ru and assar.


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@80224 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2001-07-23 21:52:26 +00:00
ru
2c684cfa07 More potential buffer overflow fixes.
o Fixed `nfrontp' calculations in output_data().  If `remaining' is
  initially zero, it was possible for `nfrontp' to be decremented.

Noticed by:	dillon

o Replaced leaking writenet() with output_datalen():

:  * writenet
:  *
:  * Just a handy little function to write a bit of raw data to the net.
:  * It will force a transmit of the buffer if necessary
:  *
:  * arguments
:  *    ptr - A pointer to a character string to write
:  *    len - How many bytes to write
:  */
: 	void
: writenet(ptr, len)
: 	register unsigned char *ptr;
: 	register int len;
: {
: 	/* flush buffer if no room for new data) */
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: 	if ((&netobuf[BUFSIZ] - nfrontp) < len) {
: 		/* if this fails, don't worry, buffer is a little big */
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: 		netflush();
: 	}
:
: 	memmove(nfrontp, ptr, len);
: 	nfrontp += len;
:
: }  /* end of writenet */

What an irony!  :-)

o Optimized output_datalen() a bit.


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@80038 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2001-07-20 12:02:30 +00:00
ru
819182e3f6 vsnprintf() can return a value larger than the buffer size.
Submitted by:	assar
Obtained from:	OpenBSD


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@79992 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2001-07-19 18:58:31 +00:00
ru
b3fb8c9630 Fixed the exploitable remote buffer overflow.
Reported on:	bugtraq
Obtained from:	Heimdal, NetBSD
Reviewed by:	obrien, imp


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@79981 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2001-07-19 17:48:57 +00:00
ru
bcdf745b83 mdoc(7) police: removed HISTORY info from the .Os call.
git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@79528 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2001-07-10 10:42:19 +00:00
asmodai
ed8b315538 Synch: Add $FreeBSD$.
git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@72139 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2001-02-07 21:58:16 +00:00
asmodai
47df13c3d8 Fix typo: seperate -> separate.
Seperate does not exist in the english language.

Submitted to look at by:	kris


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@72089 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2001-02-06 10:39:38 +00:00
asmodai
80f3e3bc78 Fix typo: wierd -> weird.
There is no such thing as wierd in the english language.


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@72083 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2001-02-06 09:32:26 +00:00