Initial revision

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@171 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Unknown User d91-jda
1995-10-23 11:20:30 +00:00
parent b1fce0a864
commit b33abb44fd
118 changed files with 23033 additions and 0 deletions

381
appl/popper/README Normal file
View File

@@ -0,0 +1,381 @@
@(#)@(#)README 2.6 2.6 4/2/91
The Post Office Protocol Server: Installation Guide
Introduction
The Post Office Protocol server runs on a variety of Unix[1] computers
to manage electronic mail for Macintosh and MS-DOS computers. The
server was developed at the University of California at Berkeley and
conforms fully to the specifications in RFC 1081[2] and RFC 1082[3].
The Berkeley server also has extensions to send electronic mail on
behalf of a client.
This guide explains how to install the POP server on your Unix
computer. It assumes that you are not only familiar with Unix but also
capable of performing Unix system administration.
How to Obtain the Server
The POP server is available via anonymous ftp from ftp.CC.Berkeley.EDU
(128.32.136.9, 128.32.206.12). It is in two files in the pub directory:
a compressed tar file popper-version.tar.Z and a Macintosh StuffIt archive
in BinHex format called MacPOP.sit.hqx.
Contents of the Distribution
The distribution contains the following:
+ All of the C source necessary to create the server program.
+ A visual representation of how the POP system works.
+ Reprints of RFC 1081 and RFC 1082.
+ A HyperCard stack POP client implementation using MacTCP.
+ A man page for the popper daemon.
+ This guide.
Compatibility
The Berkeley POP server has been successfully tested on the following
Unix operating systems:
+ Berkeley Systems Distribution 4.3
+ Sun Microsystems Operating System versions 3.5 and 4.0
+ Ultrix version 2.3
The following POP clients operate correctly with the Berkeley POP server:
+ The Berkeley HyperMail HyperCard stack for the Apple Macintosh
(distributed with the server).
+ The Stanford University Macintosh Internet Protocol MacMH program.
+ The Stanford University Personal Computer Internet Protocol MH
program.
+ The mh version 6.0 programs for Unix.
Support
The Berkeley POP server is not officially supported and is without any
warranty, explicit or implied. However, we are interested in your
experiences using the server. Bugs, comments and suggestions should be
sent electronically to netinfo@garnet.Berkeley.EDU.
Operational Characteristics
The POP Transaction Cycle
The Berkeley POP server is a single program (called popper) that is
launched by inetd when it gets a service request on the POP TCP port.
(The official port number specified in RFC 1081 for POP version 3 is
port 110. However, some POP3 clients attempt to contact the server at
port 109, the POP version 2 port. Unless you are running both POP2 and
POP3 servers, you can simply define both ports for use by the POP3
server. This is explained in the installation instructions later on.)
The popper program initializes and verifies that the peer IP address is
registered in the local domain, logging a warning message when a
connection is made to a client whose IP address does not have a
canonical name. For systems using BSD 4.3 bind, it also checks to see
if a cannonical name lookup for the client returns the same peer IP
address, logging a warning message if it does not. The the server
enters the authorization state, during which the client must correctly
identify itself by providing a valid Unix userid and password on the
server's host machine. No other exchanges are allowed during this
state (other than a request to quit.) If authentication fails, a
warning message is logged and the session ends. Once the user is
identified, popper changes its user and group ids to match that of the
user and enters the transaction state. The server makes a temporary
copy of the user's maildrop (ordinarily in /usr/spool/mail) which is
used for all subsequent transactions. These include the bulk of POP
commands to retrieve mail, delete mail, undelete mail, and so forth. A
Berkeley extension also allows the user to submit a mail parcel to the
server who mails it using the sendmail program (this extension is
supported in the HyperMail client distributed with the server). When
the client quits, the server enters the final update state during which
the network connection is terminated and the user's maildrop is updated
with the (possibly) modified temporary maildrop.
Logging
The POP server uses syslog to keep a record of its activities. On
systems with BSD 4.3 syslogging, the server logs (by default) to the
"local0" facility at priority "notice" for all messages except
debugging which is logged at priority "debug". The default log file is
/usr/spool/mqueue/POPlog. These can be changed, if desired. On
systems with 4.2 syslogging all messages are logged to the local log
file, usually /usr/spool/mqueue/syslog.
Problems
If the filesystem which holds the /usr/spool/mail fills up users will
experience difficulties. The filesystem must have enough space to hold
(approximately) two copies of the largest mail box. Popper (v1.81 and
above) is designed to be robust in the face of this problem, but you may
end up with a situation where some of the user's mail is in
/usr/spool/mail/.userid.pop
and some of the mail is in
/usr/spool/mail/userid
If this happens the System Administrator should clear enough disk space
so that the filesystem has at least as much free disk as both mailboxes
hold and probably a little more. Then the user should initiate a POP
session, and do nothing but quit. If the POP session ends without an
error the user can then use POP or another mail program to clean up his/her
mailbox.
Alternatively, the System Administrator can combine the two files (but
popper will do this for you if there is enough disk space).
Debugging
The popper program will log debugging information when the -d parameter
is specified after its invocation in the inetd.conf file. Care should
be exercised in using this option since it generates considerable
output in the syslog file. Alternatively, the "-t <file-name>" option
will place debugging information into file "<file-name>" using fprintf
instead of syslog. (To enable debugging, you must edit the Makefile
to add -DDEBUG to the compiler options.)
For SunOS version 3.5, the popper program is launched by inetd from
/etc/servers. This file does not allow you to specify command line
arguments. Therefore, if you want to enable debugging, you can specify
a shell script in /etc/servers to be launched instead of popper and in
this script call popper with the desired arguments.
Installation
1. Examine this file for the latest information, warnings, etc.
2. Check the Makefile for conformity with your system.
3. Issue the make command in the directory containing the popper
source.
4. Issue the make install command in the directory containing the
popper source to copy the program to /usr/etc.
5. Enable syslogging:
+ For systems with 4.3 syslogging:
Add the following line to the /etc/syslog.conf file:
local0.notice;local0.debug /usr/spool/mqueue/POPlog
Create the empty file /usr/spool/mqueue/POPlog.
Kill and restart the syslogd daemon.
+ For systems with 4.2 syslogging:
Be sure that you are logging messages of priority 7 and higher.
For example:
7/usr/spool/mqueue/syslog
9/dev/null
6. Update /etc/services:
Add the following line to the /etc/services file:
pop 110/tcp
Note: This is the official port number for version 3 of the
Post Office Protocol as defined in RFC 1081. However, some
POP3 clients use port 109, the port number for the previous
version (2) of POP. Therefore you may also want to add the
following line to the /etc/services file:
pop2 109/tcp
For Sun systems running yp, also do the following:
+ Change to the /var/yp directory.
+ Issue the make services command.
7. Update the inetd daemon configuration. Include the second line ONLY if you
are running the server at both ports.
+ On BSD 4.3 and SunOS 4.0 systems, add the following line to the
/etc/inetd.conf file:
pop stream tcp nowait root /usr/etc/popper popper
pop2 stream tcp nowait root /usr/etc/popper popper
+ On Ultrix systems, add the following line to the
/etc/inetd.conf file:
pop stream tcp nowait /usr/etc/popper popper
pop2 stream tcp nowait /usr/etc/popper popper
+ On SunOS 3.5 systems, add the following line to the
/etc/servers file:
pop tcp /usr/etc/popper
pop2 tcp /usr/etc/popper
Kill and restart the inetd daemon.
You can confirm that the POP server is running on Unix by telneting to
port 110 (or 109 if you set it up that way). For example:
%telnet myhost 110
Trying...
Connected to myhost.berkeley.edu.
Escape character is '^]'.
+OK UCB Pop server (version 1.6) at myhost starting.
quit
Connection closed by foreign host.
Release Notes
1.83 Make sure that everything we do as root is non-destructive.
1.82 Make the /usr/spool/mail/.userid.pop file owned by the user rather
than owned by root.
1.81 There were two versions of 1.7 floating around, 1.7b4 and 1.7b5.
The difference is that 1.7b5 attempted to save disk space on
/usr/spool/mail by deleting the users permanent maildrop after
making the temporary copy. Unfortunately, if compiled with
-DDEBUG, this version could easily wipe out a users' mail file.
This is now fixed.
This version also fixes a security hole for systems that have
/usr/spool/mail writeable by all users.
With this version we go to all new SCCS IDs for all files. This
is unfortunate, and we hope it is not too much of a problem.
Thanks to Steve Dorner of UIUC for pointing out the major problem.
1.7 Extensive re-write of the maildrop processing code contributed by
Viktor Dukhovni <viktor@math.princeton.edu> that greatly reduces the
possibility that the maildrop can be corrupted as the result of
simultaneous access by two or more processes.
Added "pop_dropcopy" module to create a temporary maildrop from
the existing, standard maildrop as root before the setuid and
setgid for the user is done. This allows the temporary maildrop
to be created in a mail spool area that is not world read-writable.
This version does *not* send the sendmail "From " delimiter line
in response to a TOP or RETR command.
Encased all debugging code in #ifdef DEBUG constructs. This code can
be included by specifying the DEGUG compiler flag. Note: You still
need to use the -d or -t option to obtain debugging output.
1.6 Corrects a bug that causes the server to crash on SunOS
4.0 systems.
Uses varargs and vsprintf (if available) in pop_log and
pop_msg. This is enabled by the "HAVE_VSPRINTF"
compiler flag.
For systems with BSD 4.3 bind, performs a cannonical
name lookup and searches the returned address(es) for
the client's address, logging a warning message if it
is not located. This is enabled by the "BIND43"
comiler flag.
Removed all the includes from popper.h and distributed
them throughout the porgrams files, as needed.
Reformatted the source to convert tabs to spaces and
shorten lines for display on 80-column terminals.
1.5 Creates the temporary maildrop with mode "600" and
immediately unlinks it.
Uses client's IP address in lieu of a canonical name if
the latter cannot be obtained.
Added "-t <file-name>" option. The presence of this
option causes debugging output to be placed in the file
"file-name" using fprintf instead of the system log
file using syslog.
Corrected maildrop parsing problem.
1.4 Copies user's mail into a temporary maildrop on which
all subsequent activity is performed.
Added "pop_log" function and replaced "syslog" calls
throughout the code with it.
1.3 Corrected updating of Status: header line.
Added strncasecmp for systems that do not have one.
Used strncasecmp in all appropriate places. This is
enabled by the STRNCASECMP compiler flag.
1.2 Support for version 4.2 syslogging added. This is
enabled by the SYSLOG42 compiler flag.
1.1 Several bugs fixed.
1.0 Original version.
Limitations
+ The POP server copies the user's entire maildrop to /tmp and
then operates on that copy. If the maildrop is particularly
large, or inadequate space is available in /tmp, then the
server will refuse to continue and terminate the connection.
+ Simultaneous modification of a single maildrop can result in
confusing results. For example, manipulating messages in a
maildrop using the Unix /usr/ucb/mail command while a copy of
it is being processed by the POP server can cause the changes
made by one program to be lost when the other terminates. This
problem is being worked on and will be fixed in a later
release.
Credits
The POP server was written by Edward Moy and Austin Shelton with
contributions from Robert Campbell (U.C. Berkeley) and Viktor Dukhovni
(Princeton University). Edward Moy wrote the HyperMail stack and drew
the POP operation diagram. This installation guide was written by
Austin Shelton.
Footnotes
[1] Copyright (c) 1990 Regents of the University of California.
All rights reserved. The Berkeley software License Agreement
specifies the terms and conditions for redistribution. Unix is
a registered trademark of AT&T corporation. HyperCard and
Macintosh are registered trademarks of Apple Corporation.
[2] M. Rose, Post Office Protocol - Version 3. RFC 1081, NIC,
November 1988.
[3] M. Rose, Post Office Protocol - Version 3 Extended Service
Offerings. RFC 1082, NIC, November 1988.

1
appl/popper/README-KRB4 Normal file
View File

@@ -0,0 +1 @@
Define KERBEROS if you want Kerberos V4 style authentification.

898
appl/popper/pop3.rfc1081 Normal file
View File

@@ -0,0 +1,898 @@
Network Working Group M. Rose
Request for Comments: 1081 TWG
November 1988
Post Office Protocol - Version 3
Status of this Memo
This memo suggests a simple method for workstations to dynamically
access mail from a mailbox server. This RFC specifies a proposed
protocol for the Internet community, and requests discussion and
suggestions for improvements. Distribution of this memo is
unlimited.
This memo is based on RFC 918 (since revised as RFC 937). Although
similar in form to the original Post Office Protocol (POP) proposed
for the Internet community, the protocol discussed in this memo is
similar in spirit to the ideas investigated by the MZnet project at
the University of California, Irvine.
Further, substantial work was done on examining POP in a PC-based
environment. This work, which resulted in additional functionality
in this protocol, was performed by the ACIS Networking Systems Group
at Stanford University. The author gratefully acknowledges their
interest.
Introduction
On certain types of smaller nodes in the Internet it is often
impractical to maintain a message transport system (MTS). For
example, a workstation may not have sufficient resources (cycles,
disk space) in order to permit a SMTP server and associated local
mail delivery system to be kept resident and continuously running.
Similarly, it may be expensive (or impossible) to keep a personal
computer interconnected to an IP-style network for long amounts of
time (the node is lacking the resource known as "connectivity").
Despite this, it is often very useful to be able to manage mail on
these smaller nodes, and they often support a user agent (UA) to aid
the tasks of mail handling. To solve this problem, a node which can
support an MTS entity offers a maildrop service to these less endowed
nodes. The Post Office Protocol - Version 3 (POP3) is intended to
permit a workstation to dynamically access a maildrop on a server
host in a useful fashion. Usually, this means that the POP3 is used
to allow a workstation to retrieve mail that the server is holding
for it.
Rose [Page 1]
RFC 1081 POP3 November 1988
For the remainder of this memo, the term "client host" refers to a
host making use of the POP3 service, while the term "server host"
refers to a host which offers the POP3 service.
A Short Digression
This memo does not specify how a client host enters mail into the
transport system, although a method consistent with the philosophy of
this memo is presented here:
When the user agent on a client host wishes to enter a message
into the transport system, it establishes an SMTP connection to
its relay host (this relay host could be, but need not be, the
POP3 server host for the client host).
If this method is followed, then the client host appears to the MTS
as a user agent, and should NOT be regarded as a "trusted" MTS entity
in any sense whatsoever. This concept, along with the role of the
POP3 as a part of a split-UA model is discussed later in this memo.
Initially, the server host starts the POP3 service by listening on
TCP port 110. When a client host wishes to make use of the service,
it establishes a TCP connection with the server host. When the
connection is established, the POP3 server sends a greeting. The
client and POP3 server then exchange commands and responses
(respectively) until the connection is closed or aborted.
Commands in the POP3 consist of a keyword possibly followed by an
argument. All commands are terminated by a CRLF pair.
Responses in the POP3 consist of a success indicator and a keyword
possibly followed by additional information. All responses are
terminated by a CRLF pair. There are currently two success
indicators: positive ("+OK") and negative ("-ERR").
Responses to certain commands are multi-line. In these cases, which
are clearly indicated below, after sending the first line of the
response and a CRLF, any additional lines are sent, each terminated
by a CRLF pair. When all lines of the response have been sent, a
final line is sent, consisting of a termination octet (decimal code
046, ".") and a CRLF pair. If any line of the multi-line response
begins with the termination octet, the line is "byte-stuffed" by
pre-pending the termination octet to that line of the response.
Hence a multi-line response is terminated with the five octets
"CRLF.CRLF". When examining a multi-line response, the client checks
to see if the line begins with the termination octet. If so and if
octets other than CRLF follow, the the first octet of the line (the
termination octet) is stripped away. If so and if CRLF immediately
Rose [Page 2]
RFC 1081 POP3 November 1988
follows the termination character, then the response from the POP
server is ended and the line containing ".CRLF" is not considered
part of the multi-line response.
A POP3 session progresses through a number of states during its
lifetime. Once the TCP connection has been opened and the POP3
server has sent the greeting, the session enters the AUTHORIZATION
state. In this state, the client must identify itself to the POP3
server. Once the client has successfully done this, the server
acquires resources associated with the client's maildrop, and the
session enters the TRANSACTION state. In this state, the client
requests actions on the part of the POP3 server. When the client has
finished its transactions, the session enters the UPDATE state. In
this state, the POP3 server releases any resources acquired during
the TRANSACTION state and says goodbye. The TCP connection is then
closed.
The AUTHORIZATION State
Once the TCP connection has been opened by a POP3 client, the POP3
server issues a one line greeting. This can be any string terminated
by CRLF. An example might be:
S. +OK dewey POP3 server ready (Comments to: PostMaster@UDEL.EDU)
Note that this greeting is a POP3 reply. The POP3 server should
always give a positive response as the greeting.
The POP3 session is now in the AUTHORIZATION state. The client must
now issue the USER command. If the POP3 server responds with a
positive success indicator ("+OK"), then the client may issue either
the PASS command to complete the authorization, or the QUIT command
to terminate the POP3 session. If the POP3 server responds with a
negative success indicator ("-ERR") to the USER command, then the
client may either issue a new USER command or may issue the QUIT
command.
When the client issues the PASS command, the POP3 server uses the
argument pair from the USER and PASS commands to determine if the
client should be given access to the appropriate maildrop. If so,
the POP3 server then acquires an exclusive-access lock on the
maildrop. If the lock is successfully acquired, the POP3 server
parses the maildrop into individual messages (read note below),
determines the last message (if any) present in the maildrop that was
referenced by the RETR command, and responds with a positive success
indicator. The POP3 session now enters the TRANSACTION state. If
the lock can not be acquired or the client should is denied access to
the appropriate maildrop or the maildrop can't be parsed for some
Rose [Page 3]
RFC 1081 POP3 November 1988
reason, the POP3 server responds with a negative success indicator.
(If a lock was acquired but the POP3 server intends to respond with a
negative success indicator, the POP3 server must release the lock
prior to rejecting the command.) At this point, the client may
either issue a new USER command and start again, or the client may
issue the QUIT command.
NOTE: Minimal implementations of the POP3 need only be
able to break a maildrop into its component messages;
they need NOT be able to parse individual messages.
More advanced implementations may wish to have this
capability, for reasons discussed later.
After the POP3 server has parsed the maildrop into individual
messages, it assigns a message-id to each message, and notes the size
of the message in octets. The first message in the maildrop is
assigned a message-id of "1", the second is assigned "2", and so on,
so that the n'th message in a maildrop is assigned a message-id of
"n". In POP3 commands and responses, all message-id's and message
sizes are expressed in base-10 (i.e., decimal).
It sets the "highest number accessed" to be that of the last message
referenced by the RETR command.
Here are summaries for the three POP3 commands discussed thus far:
USER name
Arguments: a server specific user-id (required)
Restrictions: may only be given in the AUTHORIZATION
state after the POP3 greeting or after an
unsuccessful USER or PASS command
Possible Responses:
+OK name is welcome here
-ERR never heard of name
Examples:
C: USER mrose
S: +OK mrose is a real hoopy frood
...
C: USER frated
S: -ERR sorry, frated doesn't get his mail here
PASS string
Arguments: a server/user-id specific password (required)
Restrictions: may only be given in the AUTHORIZATION
state after a successful USER command
Possible Responses:
+OK maildrop locked and ready
-ERR invalid password
Rose [Page 4]
RFC 1081 POP3 November 1988
-ERR unable to lock maildrop
Examples:
C: USER mrose
S: +OK mrose is a real hoopy frood
C: PASS secret
S: +OK mrose's maildrop has 2 messages
(320 octets)
...
C: USER mrose
S: +OK mrose is a real hoopy frood
C: PASS secret
S: -ERR unable to lock mrose's maildrop, file
already locked
QUIT
Arguments: none
Restrictions: none
Possible Responses:
+OK
Examples:
C: QUIT
S: +OK dewey POP3 server signing off
The TRANSACTION State
Once the client has successfully identified itself to the POP3 server
and the POP3 server has locked and burst the appropriate maildrop,
the POP3 session is now in the TRANSACTION state. The client may now
issue any of the following POP3 commands repeatedly. After each
command, the POP3 server issues a response. Eventually, the client
issues the QUIT command and the POP3 session enters the UPDATE state.
Here are the POP3 commands valid in the TRANSACTION state:
STAT
Arguments: none
Restrictions: may only be given in the TRANSACTION state.
Discussion:
The POP3 server issues a positive response with a line
containing information for the maildrop. This line is
called a "drop listing" for that maildrop.
In order to simplify parsing, all POP3 servers are
required to use a certain format for drop listings.
The first octets present must indicate the number of
messages in the maildrop. Following this is the size
Rose [Page 5]
RFC 1081 POP3 November 1988
of the maildrop in octets. This memo makes no
requirement on what follows the maildrop size.
Minimal implementations should just end that line of
the response with a CRLF pair. More advanced
implementations may include other information.
NOTE: This memo STRONGLY discourages
implementations from supplying additional
information in the drop listing. Other,
optional, facilities are discussed later on
which permit the client to parse the messages
in the maildrop.
Note that messages marked as deleted are not counted in
either total.
Possible Responses:
+OK nn mm
Examples:
C: STAT
S: +OK 2 320
LIST [msg]
Arguments: a message-id (optionally) If a message-id is
given, it may NOT refer to a message marked as
deleted.
Restrictions: may only be given in the TRANSACTION state.
Discussion:
If an argument was given and the POP3 server issues a
positive response with a line containing information
for that message. This line is called a "scan listing"
for that message.
If no argument was given and the POP3 server issues a
positive response, then the response given is
multi-line. After the initial +OK, for each message
in the maildrop, the POP3 server responds with a line
containing information for that message. This line
is called a "scan listing" for that message.
In order to simplify parsing, all POP3 servers are
required to use a certain format for scan listings.
The first octets present must be the message-id of
the message. Following the message-id is the size of
the message in octets. This memo makes no requirement
on what follows the message size in the scan listing.
Minimal implementations should just end that line of
Rose [Page 6]
RFC 1081 POP3 November 1988
the response with a CRLF pair. More advanced
implementations may include other information, as
parsed from the message.
NOTE: This memo STRONGLY discourages
implementations from supplying additional
information in the scan listing. Other, optional,
facilities are discussed later on which permit
the client to parse the messages in the maildrop.
Note that messages marked as deleted are not listed.
Possible Responses:
+OK scan listing follows
-ERR no such message
Examples:
C: LIST
S: +OK 2 messages (320 octets)
S: 1 120
S: 2 200
S: .
...
C: LIST 2
S: +OK 2 200
...
C: LIST 3
S: -ERR no such message, only 2 messages in
maildrop
RETR msg
Arguments: a message-id (required) This message-id may
NOT refer to a message marked as deleted.
Restrictions: may only be given in the TRANSACTION state.
Discussion:
If the POP3 server issues a positive response, then the
response given is multi-line. After the initial +OK,
the POP3 server sends the message corresponding to the
given message-id, being careful to byte-stuff the
termination character (as with all multi-line
responses).
If the number associated with this message is higher
than the "highest number accessed" in the maildrop, the
POP3 server updates the "highest number accessed" to
the number associated with this message.
Rose [Page 7]
RFC 1081 POP3 November 1988
Possible Responses:
+OK message follows
-ERR no such message
Examples:
C: RETR 1
S: +OK 120 octets
S: <the POP3 server sends the entire message here>
S: .
DELE msg
Arguments: a message-id (required) This message-id
may NOT refer to a message marked as deleted.
Restrictions: may only be given in the TRANSACTION state.
Discussion:
The POP3 server marks the message as deleted. Any
future reference to the message-id associated with the
message in a POP3 command generates an error. The POP3
server does not actually delete the message until the
POP3 session enters the UPDATE state.
If the number associated with this message is higher
than the "highest number accessed" in the maildrop,
the POP3 server updates the "highest number accessed"
to the number associated with this message.
Possible Responses:
+OK message deleted
-ERR no such message
Examples:
C: DELE 1
S: +OK message 1 deleted
...
C: DELE 2
S: -ERR message 2 already deleted
NOOP
Arguments: none
Restrictions: may only be given in the TRANSACTION state.
Discussion:
The POP3 server does nothing, it merely replies with a
positive response.
Possible Responses:
+OK
Rose [Page 8]
RFC 1081 POP3 November 1988
Examples:
C: NOOP
S: +OK
LAST
Arguments: none
Restrictions: may only be issued in the TRANSACTION state.
Discussion:
The POP3 server issues a positive response with a line
containing the highest message number which accessed.
Zero is returned in case no message in the maildrop has
been accessed during previous transactions. A client
may thereafter infer that messages, if any, numbered
greater than the response to the LAST command are
messages not yet accessed by the client.
Possible Response:
+OK nn
Examples:
C: STAT
S: +OK 4 320
C: LAST
S: +OK 1
C: RETR 3
S: +OK 120 octets
S: <the POP3 server sends the entire message
here>
S: .
C: LAST
S: +OK 3
C: DELE 2
S: +OK message 2 deleted
C: LAST
S: +OK 3
C: RSET
S: +OK
C: LAST
S: +OK 1
RSET
Arguments: none
Restrictions: may only be given in the TRANSACTION
state.
Discussion:
If any messages have been marked as deleted by the POP3
Rose [Page 9]
RFC 1081 POP3 November 1988
server, they are unmarked. The POP3 server then
replies with a positive response. In addition, the
"highest number accessed" is also reset to the value
determined at the beginning of the POP3 session.
Possible Responses:
+OK
Examples:
C: RSET
S: +OK maildrop has 2 messages (320 octets)
The UPDATE State
When the client issues the QUIT command from the TRANSACTION state,
the POP3 session enters the UPDATE state. (Note that if the client
issues the QUIT command from the AUTHORIZATION state, the POP3
session terminates but does NOT enter the UPDATE state.)
QUIT
Arguments: none
Restrictions: none
Discussion:
The POP3 server removes all messages marked as deleted
from the maildrop. It then releases the
exclusive-access lock on the maildrop and replies as
to the success of
these operations. The TCP connection is then closed.
Possible Responses:
+OK
Examples:
C: QUIT
S: +OK dewey POP3 server signing off (maildrop
empty)
...
C: QUIT
S: +OK dewey POP3 server signing off (2 messages
left)
...
Optional POP3 Commands
The POP3 commands discussed above must be supported by all minimal
implementations of POP3 servers.
Rose [Page 10]
RFC 1081 POP3 November 1988
The optional POP3 commands described below permit a POP3 client
greater freedom in message handling, while preserving a simple POP3
server implementation.
NOTE: This memo STRONGLY encourages implementations to
support these commands in lieu of developing augmented
drop and scan listings. In short, the philosophy of
this memo is to put intelligence in the part of the
POP3 client and not the POP3 server.
TOP msg n
Arguments: a message-id (required) and a number. This
message-id may NOT refer to a message marked as
deleted.
Restrictions: may only be given in the TRANSACTION state.
Discussion:
If the POP3 server issues a positive response, then
the response given is multi-line. After the initial
+OK, the POP3 server sends the headers of the message,
the blank line separating the headers from the body,
and then the number of lines indicated message's body,
being careful to byte-stuff the termination character
(as with all multi-line responses).
Note that if the number of lines requested by the POP3
client is greater than than the number of lines in the
body, then the POP3 server sends the entire message.
Possible Responses:
+OK top of message follows
-ERR no such message
Examples:
C: TOP 10
S: +OK
S: <the POP3 server sends the headers of the
message, a blank line, and the first 10 lines
of the body of the message>
S: .
...
C: TOP 100
S: -ERR no such message
RPOP user
Arguments: a client specific user-id (required)
Restrictions: may only be given in the AUTHORIZATION
state after a successful USER command; in addition,
may only be given if the client used a reserved
Rose [Page 11]
RFC 1081 POP3 November 1988
(privileged) TCP port to connect to the server.
Discussion:
The RPOP command may be used instead of the PASS
command to authenticate access to the maildrop. In
order for this command to be successful, the POP3
client must use a reserved TCP port (port < 1024) to
connect tothe server. The POP3 server uses the
argument pair from the USER and RPOP commands to
determine if the client should be given access to
the appropriate maildrop. Unlike the PASS command
however, the POP3 server considers if the remote user
specified by the RPOP command who resides on the POP3
client host is allowed to access the maildrop for the
user specified by the USER command (e.g., on Berkeley
UNIX, the .rhosts mechanism is used). With the
exception of this differing in authentication, this
command is identical to the PASS command.
Note that the use of this feature has allowed much wider
penetration into numerous hosts on local networks (and
sometimes remote networks) by those who gain illegal
access to computers by guessing passwords or otherwise
breaking into the system.
Possible Responses:
+OK maildrop locked and ready
-ERR permission denied
Examples:
C: USER mrose
S: +OK mrose is a real hoopy frood
C: RPOP mrose
S: +OK mrose's maildrop has 2 messages (320
octets)
Minimal POP3 Commands:
USER name valid in the AUTHORIZATION state
PASS string
QUIT
STAT valid in the TRANSACTION state
LIST [msg]
RETR msg
DELE msg
NOOP
LAST
RSET
Rose [Page 12]
RFC 1081 POP3 November 1988
QUIT valid in the UPDATE state
Optional POP3 Commands:
RPOP user valid in the AUTHORIZATION state
TOP msg n valid in the TRANSACTION state
POP3 Replies:
+OK
-ERR
Note that with the exception of the STAT command, the reply given
by the POP3 server to any command is significant only to "+OK"
and "-ERR". Any text occurring after this reply may be ignored
by the client.
Example POP3 Session
S: <wait for connection on TCP port 110>
...
C: <open connection>
S: +OK dewey POP3 server ready (Comments to: PostMaster@UDEL.EDU)
C: USER mrose
S: +OK mrose is a real hoopy frood
C: PASS secret
S: +OK mrose's maildrop has 2 messages (320 octets)
C: STAT
S: +OK 2 320
C: LIST
S: +OK 2 messages (320 octets)
S: 1 120
S: 2 200
S: .
C: RETR 1
S: +OK 120 octets
S: <the POP3 server sends message 1>
S: .
C: DELE 1
S: +OK message 1 deleted
C: RETR 2
S: +OK 200 octets
S: <the POP3 server sends message 2>
S: .
C: DELE 2
S: +OK message 2 deleted
C: QUIT
Rose [Page 13]
RFC 1081 POP3 November 1988
S: +OK dewey POP3 server signing off (maildrop empty)
C: <close connection>
S: <wait for next connection>
Message Format
All messages transmitted during a POP3 session are assumed to conform
to the standard for the format of Internet text messages [RFC822].
It is important to note that the byte count for a message on the
server host may differ from the octet count assigned to that message
due to local conventions for designating end-of-line. Usually,
during the AUTHORIZATION state of the POP3 session, the POP3 client
can calculate the size of each message in octets when it parses the
maildrop into messages. For example, if the POP3 server host
internally represents end-of-line as a single character, then the
POP3 server simply counts each occurrence of this character in a
message as two octets. Note that lines in the message which start
with the termination octet need not be counted twice, since the POP3
client will remove all byte-stuffed termination characters when it
receives a multi-line response.
The POP and the Split-UA model
The underlying paradigm in which the POP3 functions is that of a
split-UA model. The POP3 client host, being a remote PC based
workstation, acts solely as a client to the message transport system.
It does not provide delivery/authentication services to others.
Hence, it is acting as a UA, on behalf of the person using the
workstation. Furthermore, the workstation uses SMTP to enter mail
into the MTS.
In this sense, we have two UA functions which interface to the
message transport system: Posting (SMTP) and Retrieval (POP3). The
entity which supports this type of environment is called a split-UA
(since the user agent is split between two hosts which must
interoperate to provide these functions).
ASIDE: Others might term this a remote-UA instead.
There are arguments supporting the use of both terms.
This memo has explicitly referenced TCP as the underlying transport
agent for the POP3. This need not be the case. In the MZnet split-
UA, for example, personal micro-computer systems are used which do
not have IP-style networking capability. To connect to the POP3
server host, a PC establishes a terminal connection using some simple
protocol (PhoneNet). A program on the PC drives the connection,
first establishing a login session as a normal user. The login shell
Rose [Page 14]
RFC 1081 POP3 November 1988
for this pseudo-user is a program which drives the other half of the
terminal protocol and communicates with one of two servers. Although
MZnet can support several PCs, a single pseudo-user login is present
on the server host. The user-id and password for this pseudo-user
login is known to all members of MZnet. Hence, the first action of
the login shell, after starting the terminal protocol, is to demand a
USER/PASS authorization pair from the PC. This second level of
authorization is used to ascertain who is interacting with the MTS.
Although the server host is deemed to support a "trusted" MTS entity,
PCs in MZnet are not. Naturally, the USER/PASS authorization pair
for a PC is known only to the owner of the PC (in theory, at least).
After successfully verifying the identity of the client, a modified
SMTP server is started, and the PC posts mail with the server host.
After the QUIT command is given to the SMTP server and it terminates,
a modified POP3 server is started, and the PC retrieves mail from the
server host. After the QUIT command is given to the POP3 server and
it terminates, the login shell for the pseudo-user terminates the
terminal protocol and logs the job out. The PC then closes the
terminal connection to the server host.
The SMTP server used by MZnet is modified in the sense that it knows
that it's talking to a user agent and not a "trusted" entity in the
message transport system. Hence, it does performs the validation
activities normally performed by an entity in the MTS when it accepts
a message from a UA.
The POP3 server used by MZnet is modified in the sense that it does
not require a USER/PASS combination before entering the TRANSACTION
state. The reason for this (of course) is that the PC has already
identified itself during the second-level authorization step
described above.
NOTE: Truth in advertising laws require that the author
of this memo state that MZnet has not actually been
fully implemented. The concepts presented and proven
by the project led to the notion of the MZnet
split-slot model. This notion has inspired the
split-UA concept described in this memo, led to the
author's interest in the POP, and heavily influenced
the the description of the POP3 herein.
In fact, some UAs present in the Internet already support the notion
of posting directly to an SMTP server and retrieving mail directly
from a POP server, even if the POP server and client resided on the
same host!
ASIDE: this discussion raises an issue which this memo
Rose [Page 15]
RFC 1081 POP3 November 1988
purposedly avoids: how does SMTP know that it's talking
to a "trusted" MTS entity?
References
[MZnet] Stefferud, E., J. Sweet, and T. Domae, "MZnet: Mail
Service for Personal Micro-Computer Systems",
Proceedings, IFIP 6.5 International Conference on
Computer Message Systems, Nottingham, U.K., May 1984.
[RFC821] Postel, J., "Simple Mail Transfer Protocol",
USC/Information Sciences Institute, August 1982.
[RFC822] Crocker, D., "Standard for the Format of ARPA-Internet
Text Messages", University of Delaware, August 1982.
[RFC937] Butler, M., J. Postel, D. Chase, J. Goldberger, and J.
Reynolds, "Post Office Protocol - Version 2", RFC 937,
USC/Information Sciences Institute, February 1985.
[RFC1010] Reynolds, J., and J. Postel, "Assigned Numbers", RFC
1010, USC/Information Sciences Institute, May 1987.
Author's Address:
Marshall Rose
The Wollongong Group
1129 San Antonio Rd.
Palo Alto, California 94303
Phone: (415) 962-7100
Email: MRose@TWG.COM
Rose [Page 16]

619
appl/popper/pop3e.rfc1082 Normal file
View File

@@ -0,0 +1,619 @@
Network Working Group M. Rose
Request for Comments: 1082 TWG
November 1988
Post Office Protocol - Version 3
Extended Service Offerings
Status of This Memo
This memo suggests a simple method for workstations to dynamically
access mail from a discussion group server, as an extension to an
earlier memo which dealt with dynamically accessing mail from a
mailbox server using the Post Office Protocol - Version 3 (POP3).
This RFC specifies a proposed protocol for the Internet community,
and requests discussion and suggestions for improvements. All of the
extensions described in this memo to the POP3 are OPTIONAL.
Distribution of this memo is unlimited.
Introduction and Motivation
It is assumed that the reader is familiar with RFC 1081 that
discusses the Post Office Protocol - Version 3 (POP3) [RFC1081].
This memo describes extensions to the POP3 which enhance the service
it offers to clients. This additional service permits a client host
to access discussion group mail, which is often kept in a separate
spool area, using the general POP3 facilities.
The next section describes the evolution of discussion groups and the
technologies currently used to implement them. To summarize:
o An exploder is used to map from a single address to
a list of addresses which subscribe to the list, and redirects
any subsequent error reports associated with the delivery of
each message. This has two primary advantages:
- Subscribers need know only a single address
- Responsible parties get the error reports and not
the subscribers
Rose [Page 1]
RFC 1082 POP3 Extended Service November 1988
o Typically, each subscription address is not a person's private
maildrop, but a system-wide maildrop, which can be accessed
by more than one user. This has several advantages:
- Only a single copy of each message need traverse the
net for a given site (which may contain several local
hosts). This conserves bandwidth and cycles.
- Only a single copy of each message need reside on each
subscribing host. This conserves disk space.
- The private maildrop for each user is not cluttered
with discussion group mail.
Despite this optimization of resources, further economy can be
achieved at sites with more than one host. Typically, sites with
more than one host either:
1. Replicate discussion group mail on each host. This
results in literally gigabytes of disk space committed to
unnecessarily store redundant information.
2. Keep discussion group mail on one host and give all users a
login on that host (in addition to any other logins they may
have). This is usually a gross inconvenience for users who
work on other hosts, or a burden to users who are forced to
work on that host.
As discussed in [RFC1081], the problem of giving workstations dynamic
access to mail from a mailbox server has been explored in great
detail (originally there was [RFC918], this prompted the author to
write [RFC1081], independently of this [RFC918] was upgraded to
[RFC937]). A natural solution to the problem outlined above is to
keep discussion group mail on a mailbox server at each site and
permit different hosts at that site to employ the POP3 to access
discussion group mail. If implemented properly, this avoids the
problems of both strategies outlined above.
ASIDE: It might be noted that a good distributed filesystem
could also solve this problem. Sadly, "good"
distributed filesystems, which do not suffer
unacceptable response time for interactive use, are
few and far between these days!
Given this motivation, now let's consider discussion groups, both in
general and from the point of view of a user agent. Following this,
extensions to the POP3 defined in [RFC1081] are presented. Finally,
some additional policy details are discussed along with some initial
experiences.
Rose [Page 2]
RFC 1082 POP3 Extended Service November 1988
What's in a Discussion Group
Since mailers and user agents first crawled out of the primordial
ARPAnet, the value of discussion groups have been appreciated,
(though their implementation has not always been well-understood).
Described simply, a discussion group is composed of a number of
subscribers with a common interest. These subscribers post mail to a
single address, known as a distribution address. From this
distribution address, a copy of the message is sent to each
subscriber. Each group has a moderator, which is the person that
administrates the group. The moderator can usually be reached at a
special address, known as a request address. Usually, the
responsibilities of the moderator are quite simple, since the mail
system handles the distribution to subscribers automatically. In
some cases, the interest group, instead of being distributed directly
to its subscribers, is put into a digest format by the moderator and
then sent to the subscribers. Although this requires more work on
the part of the moderator, such groups tend to be better organized.
Unfortunately, there are a few problems with the scheme outlined
above. First, if two users on the same host subscribe to the same
interest group, two copies of the message get delivered. This is
wasteful of both processor and disk resources.
Second, some of these groups carry a lot of traffic. Although
subscription to an group does indicate interest on the part of a
subscriber, it is usually not interesting to get 50 messages or so
delivered to the user's private maildrop each day, interspersed with
personal mail, that is likely to be of a much more important and
timely nature.
Third, if a subscriber on the distribution list for a group becomes
"bad" somehow, the originator of the message and not the moderator of
the group is notified. It is not uncommon for a large list to have
10 or so bogus addresses present. This results in the originator
being flooded with "error messages" from mailers across the Internet
stating that a given address on the list was bad. Needless to say,
the originator usually could not care less if the bogus addresses got
a copy of the message or not. The originator is merely interested in
posting a message to the group at large. Furthermore, the moderator
of the group does care if there are bogus addresses on the list, but
ironically does not receive notification.
There are various approaches which can be used to solve some or all
of these problems. Usually these involve placing an exploder agent
at the distribution source of the discussion group, which expands the
name of the group into the list of subscription addresses for the
Rose [Page 3]
RFC 1082 POP3 Extended Service November 1988
group. In the process, the exploder will also change the address
that receives error notifications to be the request address or other
responsible party.
A complementary approach, used in order to cut down on resource
utilization of all kinds, replaces all the subscribers at a single
host (or group of hosts under a single administration) with a single
address at that host. This address maps to a file on the host,
usually in a spool area, which all users can access. (Advanced
implementations can also implement private discussion groups this
way, in which a single copy of each message is kept, but is
accessible to only a select number of users on the host.)
The two approaches can be combined to avoid all of the problems
described above.
Finally, a third approach can be taken, which can be used to aid user
agents processing mail for the discussion group: In order to speed
querying of the maildrop which contains the local host's copy of the
discussion group, two other items are usually associated with the
discussion group, on a local basis. These are the maxima and the
last-date. Each time a message is received for the group on the
local host, the maxima is increased by at least one. Furthermore,
when a new maxima is generated, the current date is determined. This
is called the last date. As the message is entered into the local
maildrop, it is given the current maxima and last-date. This permits
the user agent to quickly determine if new messages are present in
the maildrop.
NOTE: The maxima may be characterized as a monotonically
increasing quanity. Although sucessive values of the
maxima need not be consecutive, any maxima assigned
is always greater than any previously assigned value.
Definition of Terms
To formalize these notions somewhat, consider the following 7
parameters which describe a given discussion group from the
perspective of the user agent (the syntax given is from [RFC822]):
Rose [Page 4]
RFC 1082 POP3 Extended Service November 1988
NAME Meaning: the name of the discussion group
Syntax: TOKEN (ALPHA *[ ALPHA / DIGIT / "-" ])
(case-insensitive recognition)
Example: unix-wizards
ALIASES Meaning: alternates names for the group, which
are locally meaningful; these are
typically used to shorten user typein
Syntax: TOKEN (case-insensitive recognition)
Example: uwiz
ADDRESS Meaning: the primary source of the group
Syntax: 822 address
Example: Unix-Wizards@BRL.MIL
REQUEST Meaning: the primary moderator of the group
Syntax: 822 address
Example: Unix-Wizards-Request@BRL.MIL
FLAGS Meaning: locally meaningful flags associated
with the discussion group; this memo
leaves interpretation of this
parameter to each POP3 implementation
Syntax: octal number
Example: 01
MAXIMA Meaning: the magic cookie associated with the
last message locally received for the
group; it is the property of the magic
cookie that it's value NEVER
decreases, and increases by at least
one each time a message is locally
received
Syntax: decimal number
Example: 1004
LASTDATE Meaning: the date that the last message was
locally received
Syntax: 822 date
Example: Thu, 19 Dec 85 10:26:48 -0800
Note that the last two values are locally determined for the maildrop
associated with the discussion group and with each message in that
maildrop. Note however that the last message in the maildrop have a
different MAXIMA and LASTDATE than the discussion group. This often
occurs when the maildrop has been archived.
Rose [Page 5]
RFC 1082 POP3 Extended Service November 1988
Finally, some local systems provide mechanisms for automatically
archiving discussion group mail. In some cases, a two-level archive
scheme is used: current mail is kept in the standard maildrop,
recent mail is kept in an archive maildrop, and older mail is kept
off-line. With this scheme, in addition to having a "standard"
maildrop for each discussion group, an "archive" maildrop may also be
available. This permits a user agent to examine the most recent
archive using the same mechanisms as those used on the current mail.
The XTND Command
The following commands are valid only in the TRANSACTION state of the
POP3. This implies that the POP3 server has already opened the
user's maildrop (which may be empty). This maildrop is called the
"default maildrop". The phrase "closes the current maildrop" has two
meanings, depending on whether the current maildrop is the default
maildrop or is a maildrop associated with a discussion group.
In the former context, when the current maildrop is closed any
messages marked as deleted are removed from the maildrop currently in
use. The exclusive-access lock on the maildrop is then released
along with any implementation-specific resources (e.g., file-
descriptors).
In the latter context, a maildrop associated with a discussion group
is considered to be read-only to the POP3 client. In this case, the
phrase "closes the current maildrop" merely means that any
implementation-specific resources are released. (Hence, the POP3
command DELE is a no-op.)
All the new facilities are introduced via a single POP3 command,
XTND. All positive reponses to the XTND command are multi-line.
The most common multi-line response to the commands contains a
"discussion group listing" which presents the name of the discussion
group along with it's maxima. In order to simplify parsing all POP3
servers are required to use a certain format for discussion group
listings:
NAME SP MAXIMA
This memo makes no requirement on what follows the maxima in the
listing. Minimal implementations should just end that line of the
response with a CRLF pair. More advanced implementations may include
other information, as parsed from the message.
NOTE: This memo STRONGLY discourages implementations from
supplying additional information in the listing.
Rose [Page 6]
RFC 1082 POP3 Extended Service November 1988
XTND BBOARDS [name]
Arguments: the name of a discussion group (optionally)
Restrictions: may only be given in the TRANSACTION state.
Discussion:
If an argument was given, the POP3 server closes the current
maildrop. The POP3 server then validates the argument as the name of
a discussion group. If this is successful, it opens the maildrop
associated with the group, and returns a multi-line response
containing the discussion group listing. If the discussion group
named is not valid, or the associated archive maildrop is not
readable by the user, then an error response is returned.
If no argument was given, the POP3 server issues a multi-line
response. After the initial +OK, for each discussion group known,
the POP3 server responds with a line containing the listing for that
discussion group. Note that only world-readable discussion groups
are included in the multi-line response.
In order to aid user agents, this memo requires an extension to the
scan listing when an "XTND BBOARDS" command has been given.
Normally, a scan listing, as generated by the LIST, takes the form:
MSGNO SIZE
where MSGNO is the number of the message being listed and SIZE is the
size of the message in octets. When reading a maildrop accessed via
"XTND BBOARDS", the scan listing takes the form
MSGNO SIZE MAXIMA
where MAXIMA is the maxima that was assigned to the message when it
was placed in the BBoard.
Possible Responses:
+OK XTND
-ERR no such bboard
Examples:
C: XTND BBOARDS
S: +OK XTND
S: system 10
S: mh-users 100
S: .
C: XTND BBOARDS system
S: + OK XTND
S: system 10
S: .
Rose [Page 7]
RFC 1082 POP3 Extended Service November 1988
XTND ARCHIVE name
Arguments: the name of a discussion group (required)
Restrictions: may only be given in the TRANSACTION state.
Discussion:
The POP3 server closes the current maildrop. The POP3 server then
validates the argument as the name of a discussion group. If this is
successful, it opens the archive maildrop associated with the group,
and returns a multi-line response containing the discussion group
listing. If the discussion group named is not valid, or the
associated archive maildrop is not readable by the user, then an
error response is returned.
In addition, the scan listing generated by the LIST command is
augmented (as described above).
Possible Responses:
+OK XTND
-ERR no such bboard Examples:
C: XTND ARCHIVE system
S: + OK XTND
S: system 3
S: .
XTND X-BBOARDS name
Arguments: the name of a discussion group (required)
Restrictions: may only be given in the TRANSACTION state.
Discussion:
The POP3 server validates the argument as the name of a
discussion group. If this is unsuccessful, then an error
response is returned. Otherwise a multi-line response is
returned. The first 14 lines of this response (after the
initial +OK) are defined in this memo. Minimal implementations
need not include other information (and may omit certain
information, outputing a bare CRLF pair). More advanced
implementations may include other information.
Line Information (refer to "Definition of Terms")
---- -----------
1 NAME
2 ALIASES, separated by SP
3 system-specific: maildrop
4 system-specific: archive maildrop
5 system-specific: information
6 system-specific: maildrop map
7 system-specific: encrypted password
8 system-specific: local leaders, separated by SP
Rose [Page 8]
RFC 1082 POP3 Extended Service November 1988
9 ADDRESS
10 REQUEST
11 system-specific: incoming feed
12 system-specific: outgoing feeds
13 FLAGS SP MAXIMA
14 LASTDATE
Most of this information is entirely too specific to the UCI Version
of the Rand MH Message Handling System [MRose85]. Nevertheless,
lines 1, 2, 9, 10, 13, and 14 are of general interest, regardless of
the implementation.
Possible Responses:
+OK XTND
-ERR no such bboard
Examples:
C: XTND X-BBOARDS system
S: + OK XTND
S: system
S: local general
S: /usr/bboards/system.mbox
S: /usr/bboards/archive/system.mbox
S: /usr/bboards/.system.cnt
S: /usr/bboards/.system.map
S: *
S: mother
S: system@nrtc.northrop.com
S: system-request@nrtc.northrop.com
S:
S: dist-system@nrtc-gremlin.northrop.com
S: 01 10
S: Thu, 19 Dec 85 00:08:49 -0800
S: .
Policy Notes
Depending on the particular entity administrating the POP3 service
host, two additional policies might be implemented:
1. Private Discussion Groups
In the general case, discussion groups are world-readable, any user,
once logged in (via a terminal, terminal server, or POP3, etc.), is
able to read the maildrop for each discussion group known to the POP3
service host. Nevertheless, it is desirable, usually for privacy
reasons, to implement private discussion groups as well.
Support of this is consistent with the extensions outlined in this
Rose [Page 9]
RFC 1082 POP3 Extended Service November 1988
memo. Once the AUTHORIZATION state has successfully concluded, the
POP3 server grants the user access to exactly those discussion groups
the POP3 service host permits the authenticated user to access. As a
"security" feature, discussion groups associated with unreadable
maildrops should not be listed in a positive response to the XTND
BBOARDS command.
2. Anonymous POP3 Users
In order to minimize the authentication problem, a policy permitting
"anonymous" access to the world-readable maildrops for discussion
groups on the POP3 server may be implemented.
Support of this is consistent with the extensions outlined in this
memo. The POP3 server can be modified to accept a USER command for a
well-known pseudonym (i.e., "anonymous") which is valid with any PASS
command. As a "security" feature, it is advisable to limit this kind
of access to only hosts at the local site, or to hosts named in an
access list.
Experiences and Conclusions
All of the facilities described in this memo and in [RFC1081] have
been implemented in MH #6.1. Initial experiences have been, on the
whole, very positive.
After the first implementation, some performance tuning was required.
This consisted primarily of caching the datastructures which describe
discussion groups in the POP3 server. A second optimization
pertained to the client: the program most commonly used to read
BBoards in MH was modified to retrieve messages only when needed.
Two schemes are used:
o If only the headers (and the first few lines of the body) of
the message are required (e.g., for a scan listing), then only
these are retrieved. The resulting output is then cached, on
a per-message basis.
o If the entire message is required, then it is retrieved intact,
and cached locally.
With these optimizations, response time is quite adequate when the
POP3 server and client are connected via a high-speed local area
network. In fact, the author uses this mechanism to access certain
private discussion groups over the Internet. In this case, response
is still good. When a 9.6Kbps modem is inserted in the path,
response went from good to almost tolerable (fortunately the author
only reads a few discussion groups in this fashion).
Rose [Page 10]
RFC 1082 POP3 Extended Service November 1988
To conclude: the POP3 is a good thing, not only for personal mail but
for discussion group mail as well.
References
[RFC1081] Rose, M., "Post Office Protocol - Verison 3 (POP3)", RFC
1081, TWG, November 1988.
[MRose85] Rose, M., and J. Romine, "The Rand MH Message Handling
System: User's Manual", University of California, Irvine,
November 1985.
[RFC822] Crocker, D., "Standard for the Format of ARPA-Internet
Text Messages", RFC 822, University of Delaware, August
1982.
[RFC918] Reynolds, J., "Post Office Protocol", RFC 918,
USC/Information Sciences Institute, October 1984.
[RFC937] Butler, M., J. Postel, D. Chase, J. Goldberger, and J.
Reynolds, "Post Office Protocol - Version 2", RFC 937,
USC/Information Sciences Institute, February 1985.
Author's Address:
Marshall Rose
The Wollongong Group
1129 San Antonio Rd.
Palo Alto, California 94303
Phone: (415) 962-7100
Email: MRose@TWG.COM
Rose [Page 11]

59
appl/popper/pop_dele.c Normal file
View File

@@ -0,0 +1,59 @@
/*
* Copyright (c) 1989 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#ifndef lint
static char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n";
static char SccsId[] = "@(#)@(#)pop_dele.c 2.1 2.1 3/18/91";
#endif not lint
#include <stdio.h>
#include <sys/types.h>
#include <ctype.h>
#include "popper.h"
/*
* dele: Delete a message from the POP maildrop
*/
pop_dele (p)
POP * p;
{
MsgInfoList * mp; /* Pointer to message info list */
int msg_num;
/* Convert the message number parameter to an integer */
msg_num = atoi(p->pop_parm[1]);
/* Is requested message out of range? */
if ((msg_num < 1) || (msg_num > p->msg_count))
return (pop_msg (p,POP_FAILURE,"Message %d does not exist.",msg_num));
/* Get a pointer to the message in the message list */
mp = &(p->mlp[msg_num-1]);
/* Is the message already flagged for deletion? */
if (mp->del_flag)
return (pop_msg (p,POP_FAILURE,"Message %d has already been deleted.",
msg_num));
/* Flag the message for deletion */
mp->del_flag = TRUE;
#ifdef DEBUG
if(p->debug)
pop_log(p,POP_DEBUG,"Deleting message %u at offset %u of length %u\n",
mp->number,mp->offset,mp->length);
#endif DEBUG
/* Update the messages_deleted and bytes_deleted counters */
p->msgs_deleted++;
p->bytes_deleted += mp->length;
/* Update the last-message-accessed number if it is lower than
the deleted message */
if (p->last_msg < msg_num) p->last_msg = msg_num;
return (pop_msg (p,POP_SUCCESS,"Message %d has been deleted.",msg_num));
}

24
appl/popper/pop_last.c Normal file
View File

@@ -0,0 +1,24 @@
/*
* Copyright (c) 1989 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#ifndef lint
static char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n";
static char SccsId[] = "@(#)@(#)pop_last.c 2.1 2.1 3/18/91";
#endif not lint
#include <stdio.h>
#include <sys/types.h>
#include "popper.h"
/*
* last: Display the last message touched in a POP session
*/
int pop_last (p)
POP * p;
{
return (pop_msg(p,POP_SUCCESS,"%u is the last message seen.",p->last_msg));
}

64
appl/popper/pop_list.c Normal file
View File

@@ -0,0 +1,64 @@
/*
* Copyright (c) 1989 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#ifndef lint
static char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n";
static char SccsId[] = "@(#)@(#)pop_list.c 2.1 2.1 3/18/91";
#endif not lint
#include <stdio.h>
#include <sys/types.h>
#include "popper.h"
/*
* list: List the contents of a POP maildrop
*/
int pop_list (p)
POP * p;
{
MsgInfoList * mp; /* Pointer to message info list */
register int i;
register int msg_num;
/* Was a message number provided? */
if (p->parm_count > 0) {
msg_num = atoi(p->pop_parm[1]);
/* Is requested message out of range? */
if ((msg_num < 1) || (msg_num > p->msg_count))
return (pop_msg (p,POP_FAILURE,
"Message %d does not exist.",msg_num));
/* Get a pointer to the message in the message list */
mp = &p->mlp[msg_num-1];
/* Is the message already flagged for deletion? */
if (mp->del_flag)
return (pop_msg (p,POP_FAILURE,
"Message %d has been deleted.",msg_num));
/* Display message information */
return (pop_msg(p,POP_SUCCESS,"%u %u",msg_num,mp->length));
}
/* Display the entire list of messages */
pop_msg(p,POP_SUCCESS,
"%u messages (%u octets)",
p->msg_count-p->msgs_deleted,p->drop_size-p->bytes_deleted);
/* Loop through the message information list. Skip deleted messages */
for (i = p->msg_count, mp = p->mlp; i > 0; i--, mp++) {
if (!mp->del_flag)
(void)fprintf(p->output,"%u %u\r\n",mp->number,mp->length);
}
/* "." signals the end of a multi-line transmission */
(void)fprintf(p->output,".\r\n");
(void)fflush(p->output);
return(POP_SUCCESS);
}

27
appl/popper/pop_lower.c Normal file
View File

@@ -0,0 +1,27 @@
/*
* Copyright (c) 1989 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#ifndef lint
static char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n";
static char SccsId[] = "@(#)@(#)pop_lower.c 2.1 2.1 3/18/91";
#endif not lint
#include <stdio.h>
#include <sys/types.h>
#include <ctype.h>
/*
* lower: Convert a string to lowercase
*/
pop_lower (buf)
char * buf;
{
char * mp;
for (mp = buf; *mp; mp++)
if (isupper(*mp) && isupper(*mp)) *mp = (char)tolower((int)*mp);
}

64
appl/popper/pop_parse.c Normal file
View File

@@ -0,0 +1,64 @@
/*
* Copyright (c) 1989 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#ifndef lint
static char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n";
static char SccsId[] = "@(#)@(#)pop_parse.c 2.1 2.1 3/18/91";
#endif not lint
#include <stdio.h>
#include <sys/types.h>
#include <ctype.h>
#include "popper.h"
/*
* parse: Parse a raw input line from a POP client
* into null-delimited tokens
*/
pop_parse(p,buf)
POP * p;
char * buf; /* Pointer to a message containing
the line from the client */
{
char * mp;
register int i;
/* Loop through the POP command array */
for (mp = buf, i = 0; ; i++) {
/* Skip leading spaces and tabs in the message */
while (isspace(*mp))mp++;
/* Are we at the end of the message? */
if (*mp == 0) break;
/* Have we already obtained the maximum allowable parameters? */
if (i >= MAXPARMCOUNT) {
pop_msg(p,POP_FAILURE,"Too many arguments supplied.");
return(-1);
}
/* Point to the start of the token */
p->pop_parm[i] = mp;
/* Search for the first space character (end of the token) */
while (!isspace(*mp) && *mp) mp++;
/* Delimit the token with a null */
if (*mp) *mp++ = 0;
}
/* Were any parameters passed at all? */
if (i == 0) return (-1);
/* Convert the first token (POP command) to lower case */
pop_lower(p->pop_command);
/* Return the number of tokens extracted minus the command itself */
return (i-1);
}

27
appl/popper/pop_quit.c Normal file
View File

@@ -0,0 +1,27 @@
/*
* Copyright (c) 1989 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#ifndef lint
static char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n";
static char SccsId[] = "@(#)@(#)pop_quit.c 2.1 2.1 3/18/91";
#endif not lint
#include <stdio.h>
#include <sys/types.h>
#include "popper.h"
/*
* quit: Terminate a POP session
*/
int pop_quit (p)
POP * p;
{
/* Release the message information list */
if (p->mlp) free ((char *)p->mlp);
return(POP_SUCCESS);
}

39
appl/popper/pop_rset.c Normal file
View File

@@ -0,0 +1,39 @@
/*
* Copyright (c) 1989 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#ifndef lint
static char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n";
static char SccsId[] = "@(#)@(#)pop_rset.c 2.1 2.1 3/18/91";
#endif not lint
#include <stdio.h>
#include <sys/types.h>
#include "popper.h"
/*
* rset: Unflag all messages flagged for deletion in a POP maildrop
*/
int pop_rset (p)
POP * p;
{
MsgInfoList * mp; /* Pointer to the message info list */
register int i;
/* Unmark all the messages */
for (i = p->msg_count, mp = p->mlp; i > 0; i--, mp++)
mp->del_flag = FALSE;
/* Reset the messages-deleted and bytes-deleted counters */
p->msgs_deleted = 0;
p->bytes_deleted = 0;
/* Reset the last-message-access flag */
p->last_msg = 0;
return (pop_msg(p,POP_SUCCESS,"Maildrop has %u messages (%u octets)",
p->msg_count,p->drop_size));
}

28
appl/popper/pop_stat.c Normal file
View File

@@ -0,0 +1,28 @@
/*
* Copyright (c) 1989 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#ifndef lint
static char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n";
static char SccsId[] = "@(#)@(#)pop_stat.c 2.2 2.2 3/18/91";
#endif not lint
#include <stdio.h>
#include <sys/types.h>
#include "popper.h"
/*
* stat: Display the status of a POP maildrop to its client
*/
int pop_stat (p)
POP * p;
{
#ifdef DEBUG
if (p->debug) pop_log(p,POP_DEBUG,"%d message(s) (%d octets).",p->msg_count-p->msgs_deleted,p->drop_size-p->bytes_deleted);
#endif DEBUG
return (pop_msg (p,POP_SUCCESS,
"%u %u",p->msg_count-p->msgs_deleted,p->drop_size-p->bytes_deleted));
}

38
appl/popper/pop_xtnd.c Normal file
View File

@@ -0,0 +1,38 @@
/*
* Copyright (c) 1989 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#ifndef lint
static char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n";
static char SccsId[] = "@(#)@(#)pop_xtnd.c 2.1 2.1 3/18/91";
#endif not lint
#include <stdio.h>
#include <sys/types.h>
#include "popper.h"
/*
* xtnd: Handle extensions to the POP protocol suite
*/
extern xtnd_table * pop_get_subcommand();
int pop_xtnd (p)
POP * p;
{
xtnd_table * x;
/* Convert the XTND subcommand to lower case */
pop_lower(p->pop_subcommand);
/* Search for the subcommand in the XTND command table */
if ((x = pop_get_subcommand(p)) == NULL) return(POP_FAILURE);
/* Call the function associated with this subcommand */
if (x->function) return((*x->function)(p));
/* Otherwise assume NOOP */
return (pop_msg(p,POP_SUCCESS,NULL));
}

155
appl/popper/popper.8 Normal file
View File

@@ -0,0 +1,155 @@
.\" Copyright (c) 1980 Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms are permitted
.\" provided that this notice is preserved and that due credit is given
.\" to the University of California at Berkeley. The name of the University
.\" may not be used to endorse or promote products derived from this
.\" software without specific prior written permission. This software
.\" is provided ``as is'' without express or implied warranty.
.\"
.\" @(#)@(#)popper.8 2.3 2.3 (CCS) 4/2/91 Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n
.\"
.TH popper 8 "August 1990"
.UC 6
.ad
.SH NAME
popper \- pop 3 server
.SH SYNOPSIS
.B /usr/etc/popper
[ -d ]
[ -t trace-file]
.SH DESCRIPTION
.I Popper
is an implementation of the Post Office Protocol server that runs on a
variety of Unix computers to manage electronic mail for Macintosh
and MS-DOS computers. The server was developed at the University of
California at Berkeley and conforms fully to the specifications in RFC
1081 and RFC 1082. The Berkeley server also has extensions to
send electronic mail on behalf of a client.
.PP
The
.B \-d
flag sets the socket to debugging and turns on debugging. All debugging
information is saved using syslog(8). The
.B \-t trace\-file
flag turns on debugging and saves the trace information in
.I trace\-file
using fprintf(s).
.SH HOW TO OBTAIN THE SERVER
.PP
The POP server is available via anonymous ftp from ftp.CC.Berkeley.EDU
(128.32.136.9, 128.32.206.12). It is in two files in the pub directory:
a compressed
tar file popper.tar.Z and a Macintosh StuffIt archive in BinHex format
called MacPOP.sit.hqx.
.SH THE POP TRANSACTION CYCLE
.PP
The Berkeley POP server is a single program (called popper) that is
launched by inetd when it gets a service request on the POP TCP port.
(The official port number specified in RFC 1081 for POP version 3 is
port 110. However, some POP3 clients attempt to contact the server at
port 109, the POP version 2 port. Unless you are running both POP2 and
POP3 servers, you can simply define both ports for use by the POP3
server. This is explained in the installation instructions later on.)
The popper program initializes and verifies that the peer IP address is
registered in the local domain, logging a warning message when a
connection is made to a client whose IP address does not have a
canonical name. For systems using BSD 4.3 bind, it also checks to see
if a cannonical name lookup for the client returns the same peer IP
address, logging a warning message if it does not. The the server
enters the authorization state, during which the client must correctly
identify itself by providing a valid Unix userid and password on the
server's host machine. No other exchanges are allowed during this
state (other than a request to quit.) If authentication fails, a
warning message is logged and the session ends. Once the user is
identified, popper changes its user and group ids to match that of the
user and enters the transaction state. The server makes a temporary
copy of the user's maildrop (ordinarily in /usr/spool/mail) which is
used for all subsequent transactions. These include the bulk of POP
commands to retrieve mail, delete mail, undelete mail, and so forth. A
Berkeley extension also allows the user to submit a mail parcel to the
server who mails it using the sendmail program (this extension is
supported in the HyperMail client distributed with the server). When
the client quits, the server enters the final update state during which
the network connection is terminated and the user's maildrop is updated
with the (possibly) modified temporary maildrop.
.SH LOGGING
.PP
The POP server uses syslog to keep a record of its activities. On
systems with BSD 4.3 syslogging, the server logs (by default) to the
"local0" facility at priority "notice" for all messages except
debugging which is logged at priority "debug". The default log file is
/usr/spool/mqueue/POPlog. These can be changed, if desired. On
systems with 4.2 syslogging all messages are logged to the local log
file, usually /usr/spool/mqueue/syslog.
.SH DEBUGGING
.PP
The popper program will log debugging information when the -d parameter
is specified after its invocation in the inetd.conf file. Care should
be exercised in using this option since it generates considerable
output in the syslog file. Alternatively, the "-t <file-name>" option
will place debugging information into file "<file-name>" using fprintf
instead of syslog.
.PP
For SunOS version 3.5, the popper program is launched by inetd from
/etc/servers. This file does not allow you to specify command line
arguments. Therefore, if you want to enable debugging, you can specify
a shell script in /etc/servers to be launched instead of popper and in
this script call popper with the desired arguments.
.PP
You can confirm that the POP server is running on Unix by telneting to
port 110 (or 109 if you set it up that way). For example:
.PP
.nf
%telnet myhost 110
Trying...
Connected to myhost.berkeley.edu.
Escape character is '^]'.
+OK UCB Pop server (version 1.6) at myhost starting.
quit
Connection closed by foreign host.
.fi
.SH VERSION 1.7 RELEASE NOTES
Extensive re-write of the maildrop processing code contributed by
Viktor Dukhovni <viktor@math.princeton.edu> that greatly reduces the
possibility that the maildrop can be corrupted as the result of
simultaneous access by two or more processes.
.PP
Added "pop_dropcopy" module to create a temporary maildrop from
the existing, standard maildrop as root before the setuid and
setgid for the user is done. This allows the temporary maildrop
to be created in a mail spool area that is not world read-writable.
.PP
This version does *not* send the sendmail "From " delimiter line
in response to a TOP or RETR command.
.PP
Encased all debugging code in #ifdef DEBUG constructs. This code can
be included by specifying the DEGUG compiler flag. Note: You still
need to use the -d or -t option to obtain debugging output.
.SH LIMITATIONS
The POP server copies the user's entire maildrop to /tmp and
then operates on that copy. If the maildrop is particularly
large, or inadequate space is available in /tmp, then the
server will refuse to continue and terminate the connection.
.PP
Simultaneous modification of a single maildrop can result in
confusing results. For example, manipulating messages in a
maildrop using the Unix /usr/ucb/mail command while a copy of
it is being processed by the POP server can cause the changes
made by one program to be lost when the other terminates. This
problem is being worked on and will be fixed in a later
release.
.SH FILES
.nf
/usr/spool/mail mail files
/etc/inetd.conf pop program invocation
/etc/syslog.conf logging specifications
.fi
.SH "SEE ALSO"
inetd(8),
RFC1081,
RFC1082
.SH AUTHORS
Bob Campbell, Edward Moy, Austin Shelton, Marshall T Rose, and cast of
thousands at Rand, UDel, UCI, and elsewhere

View File

@@ -0,0 +1,45 @@
Release Notes:
popper-1.831beta is no longer beta 30 July 91
Removed popper-1.7.tar.Z
popper-1.831beta.tar.Z 03 April 91
Changed mkstemp to mktemp for Ultrix. Sigh.
popper-1.83beta.tar.Z 02 April 91
This version makes certain that while running as root we do nothing
at all destructive.
popper-1.82beta.tar.Z 27 March 91
This version fixes problems on Encore MultiMax and some Sun releases
which wouldn't allow a user to ftruncate() a file from an open
file descripter unless the user owns the file. Now the user
owns the /usr/spool/mail/.userid.pop file. Thanks to Ben Levy
of FTP Software and Henry Holtzman of Apple.
popper-1.81beta.tar.Z 20 March 91
This version of popper is supposed to fix three problems reported
with various versions of popper (all called 1.7 or 1.7something).
1) Dropped network connections meant lost mail files. Some 1.7
versions also risked corrupting mail files.
2) Some versions of 1.7 created temporary drop files with world
read and write permissions.
3) Some versions of 1.7 were not careful about opening the temporary
drop file.
popper-1.7.tar.Z 09 September 90 (updated 20 March 91)
This version will exhibit the first problem listed above if it is
compiled with -DDEBUG and run without the "-d" (debug) flag.
If it is compiled without -DDEBUG it will exhibit only the second
and third bug listed above.
Cliff Frost poptest@nettlesome.berkeley.edu
UC Berkeley

15
appl/popper/version.h Normal file
View File

@@ -0,0 +1,15 @@
/*
* Copyright (c) 1989 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
* static char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n";
* static char SccsId[] = "@(#)@(#)version.h 2.6 2.6 4/3/91";
*
*/
/*
* Current version of this POP implementation
*/
#define VERSION "1.831beta"

916
appl/telnet/Config.generic Normal file
View File

@@ -0,0 +1,916 @@
#
# Copyright (c) 1991 The Regents of the University of California.
# All rights reserved.
#
# Redistribution and use in source and binary forms are permitted provided
# that: (1) source distributions retain this entire copyright notice and
# comment, and (2) distributions including binaries display the following
# acknowledgement: ``This product includes software developed by the
# University of California, Berkeley and its contributors'' in the
# documentation or other materials provided with the distribution and in
# all advertising materials mentioning features or use of this software.
# Neither the name of the University nor the names of its contributors may
# be used to endorse or promote products derived from this software without
# specific prior written permission.
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# @(#)Config.generic 5.5 (Berkeley) 3/1/91
#
# This is the configuration file for building all of
# telnet/telnetd/libtelnet. If you want to add your
# own local configuration for a specific machine that
# is already listed here, it is best to create a new
# file called "Config.local", and put the definitions
# there. If you are adding definitions for a new system
# type, you can add them here. In this case, please send
# the new definition, and any changes you have to make to
# the code, back to "dab@cray.com" so that your changes
# can be put into the next release.
#
# Each definition must have the form:
#
# <target>:
# make -f Makefile.generic ${WHAT} \
# <definitions>
# DEFINES=
#
# Variables to be defined when actually compiling the source. Defined
# as: DEFINES="-D<var> -D<var2> ... -D<varn>"
#
# TELNET/TELNETD CONFIGURATION
#
# LINEMODE Turns on support in telnetd for the linemode option.
# (Linemode is always on in the client).
#
# KLUDGELINEMODE Define this to get the kludged up version of linemode
# that was in 4.3BSD. This is a good thing to have
# around for talking to older systems. This has no
# effect on telnetd if LINEMODE has not been defined.
#
# DIAGNOSTICS Turns on diagnostic code in telnetd; adds extra
# logic and checks, and debuging output if started
# with the -D option.
#
# NO_URGENT Define this if you don't want telnetd to send
# IAC DM in urgent mode when the pty output queue
# is flushed.
#
# GENERATE_GA Turns on code to allow the generation of Go Ahead(GA)
# if the server is WONT SGA. This code is imprecise,
# it generates the GA when two seconds have elapsed
# and no input or output has occurred.
#
# AUTHENTICATION Enable the AUTHENTICATION option.
#
# ENCRYPTION Enable the ENCRYPT option.
#
# KRB4 Enable Kerberos Version 4 Authentication code
# in libtelnet/libtelnet.a
#
# KRB5 Enable Kerberos Version 5 Authentication code
# in libtelnet/libtelnet.a
#
# SPX Enable SPX authentication code in.
# libtelnet/libtelnet.a
#
# RSA_ENCPWD
#
# KRB4_ENCPWD
#
#
# DES_ENCRYPTION Enable DES encryption/decryption, requires
# getting a the initial key from Kerberos. This
# works with both Kerberos Version 4 and 5.
#
# ENV_HACK Turn on code to recognize and allow
# interoperability with systems that have their
# definitions for ENV_VALUE and ENV_VAR reversed.
#
# LOCAL SYSYTEM PARAMATERS
#
# TERMCAP Define this if your system is termcap based,
# otherwise a terminfo based system is assumed.
#
# SYSV_TERMIO Use the System V termio structure. (implies USE_TERMIO)
#
# NO_CC_T Define this if your termio.h file does not have
# a typedef for cc_t.
#
# USE_TERMIO Define this if you have the POSIX termios structures.
# This code works under the BSD 4.4 terminal driver.
#
# HAS_GETTOS Define this if you have the setsockopt() option for
# setting the IP Type Of Service bits, (IP_TOS) and
# you have the gettosbyname() function.
#
# NEWINIT Turns on the new init code for UNICOS systems.
#
# STREAMS This system needs <sys/stream.h> for <sys/tty.h>
# (Sun 4.0.3)
#
# FILIO_H This system should use <sys/fileo.h> instead
# of <sys/ioctl.h> (Sun 4.0.3)
#
# HAVE_fd_set This system has a typedef for fd_set, but does
# not have FDSET() defined.
#
# NO_STRING_H If you don't have <string.h>, but have <strings.h>
#
# NO_LOGIN_P If /bin/login doesn't understand the "-p"
# (preserve environment) option.
#
# LOGIN_ARGS if /bin/login understands environment variables
# after the login name. Only used if NO_LOGIN_P
# is defined.
#
# NO_LOGIN_F If /bin/login doesn't understand the "-f" option.
# Only used if AUTHENTICATION is defined.
#
# LOGIN_R This says that /bin/login understands the "-r host"
# option. Only used if NO_LOGIN_F is defined (and
# the system supports the TIOCSTI ioctl).
#
# LOGIN_HOST Only applies if LOGIN_R is defined. This
# specifies the hostname to be passed to "login -r"
# for successfully authenticated logins. This
# defaults to "localhost" (don't forget to include
# the quotes, e.g. -DLOGIN_HOST=\"localhost\").
#
# It can also be set to host (-DLOGIN_HOST=host)
# to have the real hostname passed to "/bin/login -r".
# NOTE: If you do this, then anyone that wants to
# allow authenticated login access will have
# to add those remote hosts to their .rhosts,
# which sort of defeats the whole purpose of
# authenticated login...
#
# NO_BSD_SETJMP For UNICOS releases prior to 7.0. Turns off
# the inclusion of <bsdsetjmp.h>.
#
# STREAMS If the system has streams; causes <sys/stream.h>
# to be included instead of <sys/tty.h>
#
# MUST_ALIGN If !KRB & !HAVE_KRB4_DES_LIB and your words
# must be word aligned.
#
# STREAMSPTY Use /dev/ptmx to get a clean pty. Uses
# streams packet mode rather than Berkeley.
# Appropriate for SVr4 derivatives.
#
# UTMPX System has /etc/utmpx as well as /etc/utmp.
# Use makeutx and modutx to update utmp/x and wtmp/x.
# Appropriate for SVr4 derivatives.
#
# HAS_CGETENT If your system has the cgetent() and cgetstr()
# routines. This is a 4.4BSD feature, that
# eliminates grabbing the getty gettytab.c source.
# You need to include getent.o on the LIB_OBJ
# line if this is defined.
#
# OLD_ENVIRON Support for the old environment option.
#
# NO_MKTIME If you don't have mktime().
# LIB_OBJ=
# This is a list of object files that are needed but are not in
# the standard C library.
#
# strcasecmp.o If you don't have strncasecmp(3)
# strdup.o If you don't have strdup(3)
# setenv.o If you don't have setenv(3) and unsetenv(3)
# setsid.o If you don't have the POSIX setsid() call
# strerror.o If you don't have strerror(3)
# strftime.o If you don't have strftime(3)
# getopt.o If you don't have getopt(3)
# herror.o If you don't have herror(3)
# gettytab.o If you can get gettytab.c from getty source.
# getent.o If you can't get gettytab.c (or have
# HAS_CGETENT defined...)
# mem.o If you don't have mem*(3) routines.
# LIB_SRC=
# This is a list of source modules for specificed in LIB_OBJ.
# This information is used by make for checking dependencies.
# LIBS=
# This is a list of libraries to be included. This will always
# include the telnet library, and will also include either -lcurses
# or -ltermcap, -lutil for 4.4bsd, and -lnet for UNICOS5.0 and earlier.
# Also -lkrb & -ldes if Kerberos.
# LIBPATH=
# This is a list of the paths to all the libraries listed in LIBS.
# This information is used by make for checking dependencies.
# Don't forget libc.a
# VPATH=
# Directory where gettytab.c can be found, if you have it.
# LIBEXEC=
# Directory where the telnetd executable should be installed.
# LCCFLAGS=
# Local flags for ${CC} (like -O)
# AR=
# Name of "ar" program, usually just "ar".
# ARFLAGS
# Flags to pass to ${AR}
# RANLIB
# Name of "ranlib" program, set it to "NONE" if you don't
# have a "ranlib".
all:
@echo "You must specify what type of system you are on,"
@echo "or setup a Config.local file for your system."
@echo "Known system types are:"
@echo
@echo " 4.4bsd 4.3reno 4.4bsd.auth 4.3reno.auth 4.3tahoe 4.3bsd"
@echo " bsdi1.0 bsdi1.0.auth"
@echo " unicos9.0 unicos8.3 unicos8.0 unicos7.C unicos7.0 unicos6.1"
@echo " unicos9.0.auth unicos8.3.auth unicos8.0.auth unicos7.0.auth"
@echo " unicos7.C.auth unicos7.0.des.auth"
@echo " sun3.5 sun4.0.3c sun4.0 sun4.1 sun4.1.auth"
@echo " solaris2.2 solaris2.2.auth"
@echo " dynix3.0.12 dynix3.0.17"
@echo " ultrix3.1 ultrix4.0 ultrix4.1 ultrix4.3 ultrix4.3.auth"
@echo " irix4.0.1"
@echo " hpux8.0"
@echo " next1.0"
@echo " convex"
4.4bsd:
make -f Makefile.generic ${WHAT} \
LIBS="-lutil -ltermcap ../libtelnet/libtelnet.a ${AUTH_LIB}" \
LIBPATH="/usr/lib/libc.a /usr/lib/libtermcap.a \
../libtelnet/libtelnet.a ${AUTH_LIBPATH}" \
DEST=${DESTDIR}/usr/bin \
DEFINES=${ODEFS}"-DLINEMODE -DTERMCAP -DKLUDGELINEMODE \
-DDEFAULT_IM='\"\r\n4.4 BSD UNIX (%h) (%t)\r\n\r\r\n\r\"' \
-DUSE_TERMIO -DDIAGNOSTICS -DENV_HACK -DOLD_ENVIRON \
-DHAS_CGETENT ${AUTH_DEF}" \
INCLUDES="-I.. ${AUTH_INC}" \
LIB_OBJ="getent.o" \
LIB_SRC="getent.c" \
AR=ar ARFLAGS=cq RANLIB=ranlib \
LIBEXEC=${DESTDIR}/usr/libexec \
CC="${CC}" LCCFLAGS="-O"
4.3reno:
make -f Makefile.generic ${WHAT} \
LIBS="-lutil -ltermcap ../libtelnet/libtelnet.a ${AUTH_LIB}" \
LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \
../libtelnet/libtelnet.a ${AUTH_LIBPATH}" \
DEST=${DESTDIR}/usr/bin \
DEFINES=${ODEFS}"-DLINEMODE -DTERMCAP -DKLUDGELINEMODE \
-DDEFAULT_IM='\"\r\n4.3BSD-Reno UNIX (%h) (%t)\r\n\r\r\n\r\"' \
-DUSE_TERMIO -DDIAGNOSTICS -DENV_HACK \
-DOLD_ENVIRON ${AUTH_DEF}" \
INCLUDES="-I.. ${AUTH_INC}" \
LIB_OBJ="gettytab.o" \
LIB_SRC="gettytab.c" \
AR=ar ARFLAGS=cq RANLIB=ranlib \
VPATH=/usr/src/libexec/getty \
LIBEXEC=${DESTDIR}/usr/libexec \
CC="${CC}" LCCFLAGS="-O"
4.4bsd.auth 4.3reno.auth:
make -f ../Config.generic `basename $@ .auth` WHAT=${WHAT} \
AUTH_LIB="-lkrb -ldes" \
AUTH_LIBPATH="/usr/lib/libkrb.a /usr/lib/libdes.a" \
AUTH_DEF="-DAUTHENTICATION -DENCRYPTION \
-DKRB4 -DDES_ENCRYPTION" \
AUTH_INC=-I/usr/include/kerberosIV
4.3tahoe:
@echo $@ is untested... it may or may not work..."
make -f Makefile.generic ${WHAT} \
LIBS="-ltermcap ../libtelnet/libtelnet.a" \
LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \
../libtelnet/libtelnet.a" \
DEST=${DESTDIR}/usr/bin \
DEFINES=${ODEFS}"-DTERMCAP -DKLUDGELINEMODE \
-DDEFAULT_IM='\"\r\n4.3BSD-Tahoe UNIX (%h) (%t)\r\n\r\r\n\r\"'\
-DDIAGNOSTICS -DENV_HACK -DOLD_ENVIRON" \
INCLUDES="-I.." \
LIB_OBJ="strdup.o setsid.o strftime.o gettytab.o" \
LIB_SRC="strdup.c setsid.c strftime.c gettytab.c" \
AR=ar ARFLAGS=cq RANLIB=ranlib \
VPATH=/usr/src/etc/getty \
LIBEXEC=${DESTDIR}/etc \
CC="${CC}" LCCFLAGS="-O"
4.3bsd:
@echo $@ is untested... it may or may not work..."
make -f Makefile.generic ${WHAT} \
LIBS="-ltermcap ../libtelnet/libtelnet.a" \
LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \
../libtelnet/libtelnet.a" \
DEST=${DESTDIR}/usr/bin \
DEFINES=${ODEFS}"-DTERMCAP -DKLUDGELINEMODE \
-DDEFAULT_IM='\"\r\n4.3BSD UNIX (%h) (%t)\r\n\r\r\n\r\"' \
-DDIAGNOSTICS -DENV_HACK -DOLD_ENVIRON" \
INCLUDES="-I.." \
LIB_OBJ="strdup.o setsid.o strftime.o \
gettytab.o getopt.o herror.o" \
LIB_SRC="strdup.c setsid.c strftime.c \
gettytab.c getopt.c herror.c" \
AR=ar ARFLAGS=cq RANLIB=ranlib \
VPATH=/usr/src/etc/getty \
LIBEXEC=${DESTDIR}/etc \
CC="${CC}" LCCFLAGS="-O"
bsdi2.0:
make -f Makefile.generic ${WHAT} \
LIBS="-lutil -ltermcap ../libtelnet/libtelnet.a ${AUTH_LIB}" \
LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \
../libtelnet/libtelnet.a ${AUTH_LIBPATH}" \
DEST=${DESTDIR}/usr/bin \
DEFINES=${ODEFS}"-DLINEMODE -DTERMCAP -DKLUDGELINEMODE \
-DDEFAULT_IM='\"\r\nBSDI BSD/OS 2.0 (%h) (%t)\r\n\r\r\n\r\"' \
-DUSE_TERMIO -DDIAGNOSTICS -DENV_HACK \
-DOLD_ENVIRON ${AUTH_DEF} -DHAS_CGETENT" \
INCLUDES="-I.. ${AUTH_INC}" \
LIB_OBJ="getent.o" \
LIB_SRC="getent.c" \
AR=ar ARFLAGS=cq RANLIB=ranlib \
LIBEXEC=${DESTDIR}/usr/libexec \
CC="${CC}" LCCFLAGS="-O"
bsdi2.0.auth:
make -f ../Config.generic `basename $@ .auth` WHAT=${WHAT} \
AUTH_LIB="-lkrb -ldes" \
AUTH_LIBPATH="/usr/lib/libkrb.a /usr/lib/libdes.a" \
AUTH_DEF="-DAUTHENTICATION -DENCRYPTION \
-DKRB4 -DDES_ENCRYPTION" \
AUTH_INC=-I/usr/include/kerberosIV
bsdi1.1:
make -f Makefile.generic ${WHAT} \
LIBS="-lutil -ltermcap ../libtelnet/libtelnet.a ${AUTH_LIB}" \
LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \
../libtelnet/libtelnet.a ${AUTH_LIBPATH}" \
DEST=${DESTDIR}/usr/bin \
DEFINES=${ODEFS}"-DLINEMODE -DTERMCAP -DKLUDGELINEMODE \
-DDEFAULT_IM='\"\r\nBSDI BSD/386 1.1 (%h) (%t)\r\n\r\r\n\r\"' \
-DUSE_TERMIO -DDIAGNOSTICS -DENV_HACK \
-DOLD_ENVIRON ${AUTH_DEF}" \
INCLUDES="-I.. ${AUTH_INC}" \
LIB_OBJ="gettytab.o" \
LIB_SRC="gettytab.c" \
AR=ar ARFLAGS=cq RANLIB=ranlib \
VPATH=/usr/src/libexec/getty \
LIBEXEC=${DESTDIR}/usr/libexec \
CC="${CC}" LCCFLAGS="-O"
bsdi1.1.auth:
make -f ../Config.generic `basename $@ .auth` WHAT=${WHAT} \
AUTH_LIB="-lkrb -ldes" \
AUTH_LIBPATH="/usr/lib/libkrb.a /usr/lib/libdes.a" \
AUTH_DEF="-DAUTHENTICATION -DENCRYPTION \
-DKRB4 -DDES_ENCRYPTION" \
AUTH_INC=-I/usr/include/kerberosIV
bsdi1.0:
make -f Makefile.generic ${WHAT} \
LIBS="-lutil -ltermcap ../libtelnet/libtelnet.a ${AUTH_LIB}" \
LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \
../libtelnet/libtelnet.a ${AUTH_LIBPATH}" \
DEST=${DESTDIR}/usr/bin \
DEFINES=${ODEFS}"-DLINEMODE -DTERMCAP -DKLUDGELINEMODE \
-DDEFAULT_IM='\"\r\nBSDI BSD/386 1.0 (%h) (%t)\r\n\r\r\n\r\"' \
-DUSE_TERMIO -DDIAGNOSTICS -DENV_HACK \
-DOLD_ENVIRON ${AUTH_DEF}" \
INCLUDES="-I.. ${AUTH_INC}" \
LIB_OBJ="gettytab.o" \
LIB_SRC="gettytab.c" \
AR=ar ARFLAGS=cq RANLIB=ranlib \
VPATH=/usr/src/libexec/getty \
LIBEXEC=${DESTDIR}/usr/libexec \
CC="${CC}" LCCFLAGS="-O"
bsdi1.0.auth:
make -f ../Config.generic `basename $@ .auth` WHAT=${WHAT} \
AUTH_LIB="-lkrb -ldes" \
AUTH_LIBPATH="/usr/lib/libkrb.a /usr/lib/libdes.a" \
AUTH_DEF="-DAUTHENTICATION -DENCRYPTION \
-DKRB4 -DDES_ENCRYPTION"
AUTH_INC=-I/usr/include/kerberosIV
unicos9.1:
make -f Makefile.generic ${WHAT} \
LIBS="-lcurses -L../libtelnet -ltelnet ${AUTH_LIB}" \
LIBPATH="/lib/libc.a /usr/lib/libcurses.a \
../libtelnet/libtelnet.a ${AUTH_LIBPATH}" \
DEST=${DESTDIR}/usr/ucb \
DEFINES=${ODEFS}"-Dvfork=fork -Dsignal=bsdsignal \
-DLINEMODE -DKLUDGELINEMODE \
-DSYSV_TERMIO -DHAS_GETTOS ${AUTH_DEF} \
-DDEFAULT_IM='\"\r\nCray UNICOS 9.1 (%h) (%t)\r\n\r\r\n\r\"' \
-DDIAGNOSTICS -DENV_HACK -DOLD_ENVIRON" \
AR=bld ARFLAGS=cq RANLIB=NONE \
LIBEXEC=${DESTDIR}/etc \
INCLUDES="-I.. ${AUTH_INC}" \
LIB_OBJ="getent.o" \
LIB_SRC="getent.c" \
CC="${CC}" LCCFLAGS="-O"
unicos9.0:
make -f Makefile.generic ${WHAT} \
LIBS="-lcurses -L../libtelnet -ltelnet ${AUTH_LIB}" \
LIBPATH="/lib/libc.a /usr/lib/libcurses.a \
../libtelnet/libtelnet.a ${AUTH_LIBPATH}" \
DEST=${DESTDIR}/usr/ucb \
DEFINES=${ODEFS}"-Dvfork=fork -Dsignal=bsdsignal \
-DLINEMODE -DKLUDGELINEMODE \
-DSYSV_TERMIO -DHAS_GETTOS ${AUTH_DEF} \
-DDEFAULT_IM='\"\r\nCray UNICOS 9.0 (%h) (%t)\r\n\r\r\n\r\"' \
-DDIAGNOSTICS -DENV_HACK -DOLD_ENVIRON" \
AR=bld ARFLAGS=cq RANLIB=NONE \
LIBEXEC=${DESTDIR}/etc \
INCLUDES="-I.. ${AUTH_INC}" \
LIB_OBJ="getent.o" \
LIB_SRC="getent.c" \
CC="${CC}" LCCFLAGS="-O"
unicos8.3:
make -f Makefile.generic ${WHAT} \
LIBS="-lcurses -L../libtelnet -ltelnet ${AUTH_LIB}" \
LIBPATH="/lib/libc.a /usr/lib/libcurses.a \
../libtelnet/libtelnet.a ${AUTH_LIBPATH}" \
DEST=${DESTDIR}/usr/ucb \
DEFINES=${ODEFS}"-Dvfork=fork -Dsignal=bsdsignal \
-DLINEMODE -DKLUDGELINEMODE \
-DSYSV_TERMIO -DHAS_GETTOS ${AUTH_DEF} \
-DDEFAULT_IM='\"\r\nCray UNICOS 8.3 (%h) (%t)\r\n\r\r\n\r\"' \
-DDIAGNOSTICS -DENV_HACK -DOLD_ENVIRON" \
AR=bld ARFLAGS=cq RANLIB=NONE \
LIBEXEC=${DESTDIR}/etc \
INCLUDES="-I.. ${AUTH_INC}" \
LIB_OBJ="getent.o" \
LIB_SRC="getent.c" \
CC="${CC}" LCCFLAGS="-O"
unicos8.0:
make -f Makefile.generic ${WHAT} \
LIBS="-lcurses -L../libtelnet -ltelnet ${AUTH_LIB}" \
LIBPATH="/lib/libc.a /usr/lib/libcurses.a \
../libtelnet/libtelnet.a ${AUTH_LIBPATH}" \
DEST=${DESTDIR}/usr/ucb \
DEFINES=${ODEFS}"-Dvfork=fork -Dsignal=bsdsignal \
-DLINEMODE -DKLUDGELINEMODE \
-DSYSV_TERMIO -DHAS_GETTOS ${AUTH_DEF} \
-DDEFAULT_IM='\"\r\nCray UNICOS 8.0 (%h) (%t)\r\n\r\r\n\r\"' \
-DDIAGNOSTICS -DENV_HACK -DOLD_ENVIRON" \
AR=bld ARFLAGS=cq RANLIB=NONE \
LIBEXEC=${DESTDIR}/etc \
INCLUDES="-I.. ${AUTH_INC}" \
LIB_OBJ="getent.o" \
LIB_SRC="getent.c" \
CC="${CC}" LCCFLAGS="-O"
unicos7.C:
make -f Makefile.generic ${WHAT} \
LIBS="-lcurses -L../libtelnet -ltelnet ${AUTH_LIB}" \
LIBPATH="/lib/libc.a /usr/lib/libcurses.a \
../libtelnet/libtelnet.a ${AUTH_LIBPATH}"\
DEST=${DESTDIR}/usr/ucb \
DEFINES=${ODEFS}"-Dvfork=fork -Dsignal=bsdsignal \
-DLINEMODE -DKLUDGELINEMODE \
-DSYSV_TERMIO -DHAS_GETTOS ${AUTH_DEF} \
-DDEFAULT_IM='\"\r\nCray UNICOS 7.C (%h) (%t)\r\n\r\r\n\r\"' \
-DDIAGNOSTICS -DENV_HACK -DOLD_ENVIRON" \
AR=bld ARFLAGS=cq RANLIB=NONE \
LIBEXEC=${DESTDIR}/etc \
INCLUDES="-I.. ${AUTH_INC}" \
LIB_OBJ="getent.o" \
LIB_SRC="getent.c" \
CC="${CC}" LCCFLAGS="-O"
unicos7.0:
make -f Makefile.generic ${WHAT} \
LIBS="-lcurses -L../libtelnet -ltelnet -lkrb" \
LIBPATH="/lib/libc.a /usr/lib/libcurses.a \
../libtelnet/libtelnet.a /usr/lib/libkrb.a" \
DEST=${DESTDIR}/usr/ucb \
DEFINES=${ODEFS}"-Dvfork=fork -Dsignal=bsdsignal \
-DLINEMODE -DKLUDGELINEMODE \
-DSYSV_TERMIO -DHAS_GETTOS \
-DDEFAULT_IM='\"\r\nCray UNICOS 7.0 (%h) (%t)\r\n\r\r\n\r\"' \
-DDIAGNOSTICS -DENV_HACK -DOLD_ENVIRON" \
AR=bld ARFLAGS=cq RANLIB=NONE \
LIBEXEC=${DESTDIR}/etc \
INCLUDES="-I.." \
LIB_OBJ="getent.o" \
LIB_SRC="getent.c" \
CC="${CC}" LCCFLAGS="-O"
# As of UNICOS 7.0.5.2, there is no longer a /usr/lib/libdes.a
# If you still have a /usr/lib/libdes.a, use the "unicos7.0.des.auth"
# target instead of "unicos7.0.auth".
unicos9.1.auth unicos9.0.auth unicos8.3.auth unicos8.0.auth unicos7.0.auth:
make -f ../Config.generic `basename $@ .auth` WHAT=${WHAT} \
AUTH_LIB=-lkrb AUTH_LIBPATH=/usr/lib/libkrb.a \
AUTH_INC=-I/usr/include/krb \
AUTH_DEF="-DAUTHENTICATION -DENCRYPTION -DKRB4 -DDES_ENCRYPTION"
unicos7.C.auth unicos7.0.des.auth:
make -f ../Config.generic `basename $@ .des.auth` WHAT=${WHAT} \
AUTH_LIB="-lkrb -ldes" \
AUTH_LIBPATH="/usr/lib/libkrb.a /usr/lib/libdes.a" \
AUTH_INC=-I/usr/include/krb \
AUTH_DEF="-DAUTHENTICATION -DENCRYPTION -DKRB4 -DDES_ENCRYPTION"
unicos6.1:
make -f Makefile.generic ${WHAT} \
LIBS="-lcurses -L../libtelnet -ltelnet" \
LIBPATH="/lib/libc.a /usr/lib/libcurses.a \
../libtelnet/libtelnet.a" \
DEST=${DESTDIR}/usr/ucb \
DEFINES=${ODEFS}"-Dvfork=fork -Dsignal=bsdsignal \
-DKLUDGELINEMODE -DUSE_TERMIO -DHAS_GETTOS \
-DLINEMODE -DSYSV_TERMIO -DNEWINIT \
-DNO_LOGIN_F -DNO_LOGIN_P -DNO_BSD_SETJMP \
-DLOGIN_ARGS \
-DDEFAULT_IM='\"\r\nCray UNICOS 6.1 (%h) (%t)\r\n\r\r\n\r\"' \
-DDIAGNOSTICS -DENV_HACK -DOLD_ENVIRON" \
AR=bld ARFLAGS=cq RANLIB=NONE \
LIBEXEC=${DESTDIR}/etc \
INCLUDES="-I.." \
LIB_OBJ="getent.o parsetos.o" \
LIB_SRC="getent.c parsetos.c" \
CC="${CC}" LCCFLAGS="-O"
sun3.5:
@echo $@ is untested... it may or may not work..."
make -f Makefile.generic ${WHAT} \
LIBS="-ltermcap ../libtelnet/libtelnet.a" \
LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \
../libtelnet/libtelnet.a" \
DEST=${DESTDIR}/usr/ucb \
DEFINES=${ODEFS}"-DTERMCAP -DKLUDGELINEMODE \
-DHAVE_fd_set -DNO_MKTIME \
-DDIAGNOSTICS -DENV_HACK -DOLD_ENVIRON \
-DDEFAULT_IM='\"\r\nSunOS UNIX 3.5 (%h) (%t)\r\n\r\r\n\r\"' \
-DNO_LOGIN_P" \
INCLUDES="-I.." \
LIB_OBJ="getent.o strdup.o strerror.o setsid.o \
setenv.o strftime.o strcasecmp.o herror.o" \
LIB_SRC="getent.c strdup.c strerror.c setsid.c \
setenv.c strftime.c strcasecmp.c herror.c" \
AR=ar ARFLAGS=cq RANLIB=ranlib \
LIBEXEC=${DESTDIR}/usr/etc/in.telnetd \
CC="${CC}" LCCFLAGS="-O"
sun3.5.auth:
make -f ../Config.generic `basename $@ .auth` WHAT=${WHAT} \
AUTH_LIB="-lkrb -ldes" \
AUTH_LIBPATH="/usr/lib/libkrb.a /usr/lib/libdes.a" \
AUTH_DEF="-DAUTHENTICATION -DENCRYPTION -DKRB4 -DDES_ENCRYPTION"
sun4.0.3c sun4.0:
@echo $@ is untested... it may or may not work..."
make -f Makefile.generic ${WHAT} \
LIBS="-ltermcap ../libtelnet/libtelnet.a" \
LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \
../libtelnet/libtelnet.a" \
DEST=${DESTDIR}/usr/ucb \
DEFINES=${ODEFS}"-DFILIO_H -DTERMCAP -DUSE_TERMIO -DNO_CC_T \
-DKLUDGELINEMODE \
-DDEFAULT_IM='\"\r\nSunOS UNIX 4.0 (%h) (%t)\r\n\r\r\n\r\"' \
-DSTREAMS -DDIAGNOSTICS -DENV_HACK -DOLD_ENVIRON \
" \
INCLUDES="-I.." \
LIB_OBJ="getent.o strerror.o setsid.o setenv.o \
strcasecmp.o strftime.o herror.o" \
LIB_SRC="getent.c strerror.c setsid.c setenv.c \
strcasecmp.c strftime.c herror.c" \
AR=ar ARFLAGS=cq RANLIB=ranlib \
LIBEXEC=${DESTDIR}/usr/etc/in.telnetd \
CC="${CC}" LCCFLAGS="-O"
sun4.1:
make -f Makefile.generic ${WHAT} \
LIBS="-ltermcap ../libtelnet/libtelnet.a ${AUTH_LIB}" \
LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \
../libtelnet/libtelnet.a ${AUTH_LIBPATH}" \
DEST=${DESTDIR}/usr/ucb \
DEFINES=${ODEFS}"-DFILIO_H -DTERMCAP -DUSE_TERMIO \
-DKLUDGELINEMODE -DSTREAMS \
-DDEFAULT_IM='\"\r\nSunOS UNIX 4.1 (%h) (%t)\r\n\r\r\n\r\"' \
-DDIAGNOSTICS -DENV_HACK -DOLD_ENVIRON ${AUTH_DEF}" \
INCLUDES="-I.. ${AUTH_INC}" \
LIB_OBJ="getent.o strerror.o setenv.o herror.o" \
LIB_SRC="getent.c strerror.c setenv.c herror.c" \
AR=ar ARFLAGS=cq RANLIB=ranlib \
LIBEXEC=${DESTDIR}/usr/etc/in.telnetd \
CC="${CC}" LCCFLAGS="-O"
sun4.1.auth:
make -f ../Config.generic `basename $@ .auth` WHAT=${WHAT} \
AUTH_LIB="-lkrb -ldes" \
AUTH_LIBPATH="/usr/lib/libkrb.a /usr/lib/libdes.a" \
AUTH_DEF="-DAUTHENTICATION -DENCRYPTION -DNO_LOGIN_F -DLOGIN_R \
-DKRB4 -DDES_ENCRYPTION"
sol2.2 solaris2.2:
make -f Makefile.generic ${WHAT} \
LIBS="-ltermlib ../libtelnet/libtelnet.a ${AUTH_LIB}" \
LIBPATH="/usr/ccs/lib/libtermlib.a ../libtelnet/libtelnet.a \
/usr/lib/libc.a /usr/ucblib/libucb.a \
/usr/lib/libsocket.a /usr/lib/libnsl.a" \
DEST=${DESTDIR}/usr/ucb \
DEFINES="-DFILIO_H -DUSE_TERMIO -DKLUDGELINEMODE \
-DSTREAMS -DSTREAMSPTY -DDIAGNOSTICS -DSOLARIS \
-DENV_HACK -DOLD_ENVIRON -DNO_LOGIN_P -DUTMPX \
-DDEFAULT_IM='\"\r\n\r\nUNIX(r) System V Release 4.0 (%h)\r\n\r\n\"' \
-DLOGIN_ARGS ${AUTH_DEF}" \
INCLUDES="-I.. -I/usr/ucbinclude ${AUTH_INC}" \
LIB_OBJ="getent.o strerror.o setenv.o herror.o" \
LIB_SRC="getent.c strerror.c setenv.c herror.c" \
AR=ar ARFLAGS=cq RANLIB=NONE \
LIBEXEC=${DESTDIR}/usr/etc/in.telnetd \
CC="${CC}" LCCFLAGS="-O"
sol2.2.auth solaris2.2.auth:
make -f ../Config.generic `basename $@ .auth` WHAT=${WHAT} \
AUTH_LIB="-lkrb" AUTH_LIBPATH="/usr/lib/libkrb.a" \
AUTH_INC=-I/usr/include/kerberos \
AUTH_DEF="-DAUTHENTICATION -DKRB4"
sol2.3 solaris2.3:
make -f Makefile.generic ${WHAT} \
LIBS="-ltermlib ../libtelnet/libtelnet.a ${AUTH_LIB}" \
LIBPATH="/usr/ccs/lib/libtermlib.a ../libtelnet/libtelnet.a \
/usr/lib/libc.a /usr/ucblib/libucb.a \
/usr/lib/libsocket.a /usr/lib/libnsl.a" \
DEST=${DESTDIR}/usr/ucb \
DEFINES="-DFILIO_H -DUSE_TERMIO -DKLUDGELINEMODE \
-DSTREAMS -DSTREAMSPTY -DDIAGNOSTICS -DSOLARIS \
-DENV_HACK -DOLD_ENVIRON -DNO_LOGIN_P -DUTMPX \
-DDEFAULT_IM='\"\r\n\r\nUNIX(r) System V Release 4.0 (%h)\r\n\r\n\"' \
-DLOGIN_ARGS ${AUTH_DEF}" \
INCLUDES="-I.. -I/usr/ucbinclude ${AUTH_INC}" \
LIB_OBJ="getent.o strerror.o setenv.o herror.o" \
LIB_SRC="getent.c strerror.c setenv.c herror.c" \
AR=ar ARFLAGS=cq RANLIB=NONE \
LIBEXEC=${DESTDIR}/usr/etc/in.telnetd \
CC="${CC}" LCCFLAGS="-O"
sol2.3.auth solaris2.3.auth:
make -f ../Config.generic `basename $@ .auth` WHAT=${WHAT} \
AUTH_LIB="-lkrb /home/poplar36/gw/lib/libdes.a" \
AUTH_LIBPATH="/usr/lib/libkrb.a /home/poplar36/gw/lib/libdes.a"\
AUTH_INC=-I/usr/include/kerberos \
AUTH_DEF="-DAUTHENTICATION -DKRB4 -DENCRYPTION -DDES_ENCRYPTION"
sol2.4 solaris2.4:
make -f Makefile.generic ${WHAT} \
LIBS="-ltermlib ../libtelnet/libtelnet.a -lsocket -lnsl \
${AUTH_LIB}" \
LIBPATH="/usr/ccs/lib/libtermlib.a ../libtelnet/libtelnet.a \
/usr/lib/libc.a /usr/lib/libsocket.a \
/usr/lib/libnsl.a" \
DEST=${DESTDIR}/usr/ucb \
DEFINES="-DFILIO_H -DUSE_TERMIO -DKLUDGELINEMODE \
-DSTREAMS -DSTREAMSPTY -DDIAGNOSTICS -DSOLARIS \
-DENV_HACK -DOLD_ENVIRON -DNO_LOGIN_P -DUTMPX \
-DDEFAULT_IM='\"\r\n\r\nUNIX(r) System V Release 4.0 (%h)\r\n\r\n\"' \
-Dsignal=sigset -DLOGIN_ARGS ${AUTH_DEF}" \
INCLUDES="-I.. ${AUTH_INC}" \
LIB_OBJ="getent.o strerror.o setenv.o herror.o" \
LIB_SRC="getent.c strerror.c setenv.c herror.c" \
AR=ar ARFLAGS=cq RANLIB=NONE \
LIBEXEC=${DESTDIR}/usr/etc/in.telnetd \
CC="${CC}" LCCFLAGS="-O"
sol2.4.auth solaris2.4.auth:
make -f ../Config.generic `basename $@ .auth` WHAT=${WHAT} \
AUTH_LIB="-lkrb " \
AUTH_LIBPATH="/usr/lib/libkrb.a"\
AUTH_INC=-I/usr/include/kerberos \
AUTH_DEF="-DAUTHENTICATION -DKRB4 -DNO_LOGIN_F -DLOGIN_R"
dynix3.0.12:
@echo $@ is untested... it may or may not work..."
make -f Makefile.generic ${WHAT} \
LIBS="-ltermcap ../libtelnet/libtelnet.a" \
LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \
../libtelnet/libtelnet.a" \
DEST=${DESTDIR}/usr/ucb \
DEFINES=${ODEFS}"-DTERMCAP -DKLUDGELINEMODE \
-DDEFAULT_IM='\"\r\nDYNIX(R) V3.0.12 (%h) (%t)\r\n\r\r\n\r\"' \
-DDIAGNOSTICS -DENV_HACK -DOLD_ENVIRON -DNO_STRING_H " \
INCLUDES="-I.." \
LIB_OBJ="getent.o strchr.o strrchr.o strdup.o strerror.o \
setsid.o setenv.o strcasecmp.o strftime.o getopt.o \
mem.o" \
LIB_SRC="getent.c strchr.c strrchr.c strdup.c strerror.c \
setsid.c setenv.c strcasecmp.c strftime.c getopt.c \
mem.o" \
AR=ar ARFLAGS=cq RANLIB=ranlib \
LIBEXEC=${DESTDIR}/usr/etc \
CC="${CC}" LCCFLAGS="-O"
dynix3.0.17:
make -f Makefile.generic ${WHAT} \
LIBS="-ltermcap ../libtelnet/libtelnet.a -lseq" \
LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \
../libtelnet/libtelnet.a /usr/lib/libseq.a" \
DEST=${DESTDIR}/usr/ucb \
DEFINES=${ODEFS}"-DTERMCAP -DKLUDGELINEMODE \
-DDIAGNOSTICS -DENV_HACK -DOLD_ENVIRON -DNO_STRING_H \
-DDEFAULT_IM='\"\r\nDYNIX(R) V3.0.17 (%h) (%t)\r\n\r\r\n\r\"' \
" \
INCLUDES="-I.." \
LIB_OBJ="getent.o strchr.o strrchr.o strdup.o strerror.o \
setsid.o strftime.o mem.o" \
LIB_SRC="getent.c strchr.c strrchr.c strdup.c strerror.c \
setsid.c strftime.c mem.c" \
AR=ar ARFLAGS=cq RANLIB=ranlib \
LIBEXEC=${DESTDIR}/usr/etc \
CC="${CC}" LCCFLAGS="-O"
ultrix3.1:
@echo $@ is untested... it may or may not work..."
make -f Makefile.generic ${WHAT} \
LIBS="-ltermcap ../libtelnet/libtelnet.a" \
LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \
../libtelnet/libtelnet.a" \
DEST=${DESTDIR}/usr/ucb \
DEFINES=${ODEFS}"-DTERMCAP -DKLUDGELINEMODE \
-DNO_LOGIN_F -DNO_LOGIN_P -DNO_LOGIN_H \
-DDIAGNOSTICS -DENV_HACK -DOLD_ENVIRON -DUSE_TERMIO \
-DDEFAULT_IM='\"\r\nULTRIX V3.1 (%h) (%t)\r\n\r\r\n\r\"' \
-YPOSIX" \
INCLUDES="-I.." \
LIB_OBJ="getent.o strdup.o strerror.o setenv.o \
strftime.o herror.o" \
LIB_SRC="getent.c strdup.c strerror.c setenv.c \
strftime.c herror.c" \
AR=ar ARFLAGS=cq RANLIB=ranlib \
LIBEXEC=${DESTDIR}/usr/etc \
CC="${CC}" LCCFLAGS="-O"
ultrix4.0:
@echo $@ is untested... it may or may not work..."
make -f Makefile.generic ${WHAT} \
LIBS="-ltermcap ../libtelnet/libtelnet.a" \
LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \
../libtelnet/libtelnet.a" \
DEST=${DESTDIR}/usr/ucb \
DEFINES=${ODEFS}"-DUSE_TERMIO -DTERMCAP \
-DDEFAULT_IM='\"\r\nULTRIX V4.0 (%h) (%t)\r\n\r\r\n\r\"' \
-DKLUDGELINEMODE -DDIAGNOSTICS \
-DNO_LOGIN_F -DNO_LOGIN_P -DNO_LOGIN_H \
-DENV_HACK -DOLD_ENVIRON" \
INCLUDES="-I.." \
LIB_OBJ="getent.o strdup.o strerror.o setsid.o \
setenv.o strftime.o" \
LIB_SRC="getent.c strdup.c strerror.c setsid.c \
setenv.c strftime.c" \
AR=ar ARFLAGS=cq RANLIB=ranlib \
LIBEXEC=${DESTDIR}/usr/etc \
CC="${CC}" LCCFLAGS="-O"
ultrix4.1:
make -f Makefile.generic ${WHAT} \
LIBS="-ltermcap ../libtelnet/libtelnet.a ${AUTH_LIB}" \
LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \
../libtelnet/libtelnet.a ${AUTH_LIBPATH}" \
DEST=${DESTDIR}/usr/ucb \
DEFINES=${ODEFS}"-DUSE_TERMIO -DTERMCAP \
-DDEFAULT_IM='\"\r\nULTRIX V4.1 (%h) (%t)\r\n\r\r\n\r\"' \
-DKLUDGELINEMODE -DDIAGNOSTICS \
-DNO_LOGIN_F -DNO_LOGIN_P -DNO_LOGIN_H \
-DENV_HACK -DOLD_ENVIRON ${AUTH_DEF}" \
INCLUDES="-I.. ${AUTH_INC}" \
LIB_OBJ="getent.o strdup.o" \
LIB_SRC="getent.c strdup.c" \
AR=ar ARFLAGS=cq RANLIB=ranlib \
LIBEXEC=${DESTDIR}/usr/etc \
CC="${CC}" LCCFLAGS="-O"
ultrix4.1.auth:
make -f ../Config.generic `basename $@ .auth` WHAT=${WHAT} \
AUTH_LIB="-lkrb -ldes" \
AUTH_LIBPATH="/usr/lib/libkrb.a /usr/lib/libdes.a" \
AUTH_DEF="-DAUTHENTICATION -DKRB4"
ultrix4.3:
make -f Makefile.generic ${WHAT} \
LIBS="-ltermcap ../libtelnet/libtelnet.a ${AUTH_LIB}" \
LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \
../libtelnet/libtelnet.a ${AUTH_LIBPATH}" \
DEST=${DESTDIR}/usr/ucb \
DEFINES=${ODEFS}"-DUSE_TERMIO -DTERMCAP \
-DDEFAULT_IM='\"\r\nULTRIX V4.3 (%h) (%t)\r\n\r\r\n\r\"' \
-DKLUDGELINEMODE -DDIAGNOSTICS \
-DNO_LOGIN_F -DNO_LOGIN_P -DNO_LOGIN_H \
-DENV_HACK -DOLD_ENVIRON ${AUTH_DEF}" \
INCLUDES="-I.. ${AUTH_INC}" \
LIB_OBJ="getent.o strdup.o" \
LIB_SRC="getent.c strdup.c" \
AR=ar ARFLAGS=cq RANLIB=ranlib \
LIBEXEC=${DESTDIR}/usr/etc \
CC="${CC}" LCCFLAGS="-O"
ultrix4.3.auth:
make -f ../Config.generic `basename $@ .auth` WHAT=${WHAT} \
AUTH_LIB="-lkrb -ldes" \
AUTH_LIBPATH="/usr/lib/libkrb.a /usr/lib/libdes.a" \
AUTH_DEF="-DAUTHENTICATION -DKRB4"
irix4.0.1:
@echo $@ is untested... it may or may not work..."
make -f Makefile.generic ${WHAT} \
LIBS="-ltermlib ../libtelnet/libtelnet.a" \
LIBPATH="/usr/lib/libc.a /usr/lib/libtermlib.a \
../libtelnet/libtelnet.a" \
DEST=${DESTDIR}/usr/bin \
DEFINES=${ODEFS}"-Dvfork=fork -DUSE_TERMIO \
-DDEFAULT_IM='\"\r\n\r\nIRIX System V.3 (%h) (%t)\r\n\r\r\n\r\"' \
-DNO_LOGIN_F -DNO_LOGIN_P \
-DDIAGNOSTICS " \
INCLUDES="-I.." \
LIB_OBJ="getent.o setenv.o" \
LIB_SRC="getent.c setenv.c" \
AR=ar ARFLAGS=cq RANLIB=NONE \
LIBEXEC=${DESTDIR}/etc \
CC="${CC}" LCCFLAGS="-O"
hpux8.0:
@echo $@ is untested... it may or may not work..."
make -f Makefile.generic ${WHAT} \
LIBS="-ltermcap ../libtelnet/libtelnet.a" \
LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \
../libtelnet/libtelnet.a" \
DEST=${DESTDIR}/usr/bin \
DEFINES=${ODEFS}"-Dvfork=fork -DUSE_TERMIO \
-DDEFAULT_IM='\"\r\n\r\nHP-UX 8.0 (%h) (%t)\r\n\r\r\n\r\"' \
-DNO_LOGIN_F -DNO_LOGIN_P -DNO_LOGIN_H \
-DDIAGNOSTICS -DLOGIN_ARGS" \
INCLUDES="-I.." \
LIB_OBJ="getent.o setenv.o" \
LIB_SRC="getent.c setenv.c" \
AR=ar ARFLAGS=cq RANLIB=NONE \
LIBEXEC=${DESTDIR}/etc \
CC="${CC}" LCCFLAGS="-O"
next1.0:
@echo $@ is untested... it may or may not work..."
make -f Makefile.generic ${WHAT} \
LIBS="../libtelnet/libtelnet.a -ltermcap -lsys_s" \
LIBPATH="/lib/libc.a /lib/libsys_s.a /usr/lib/libtermcap.a \
../libtelnet/libtelnet.a" \
DEST=${DESTDIR}/usr/ucb \
DEFINES=${ODEFS}"-bsd -DTERMCAP -DKLUDGELINEMODE \
-DDEFAULT_IM='\"\r\nNeXT 1.0 (%h) (%t)\r\n\r\r\n\r\"' \
-DDIAGNOSTICS -DENV_HACK -DOLD_ENVIRON \
-DNO_STRING_H -Dgetenv=getenv_" \
INCLUDES="-I.." \
LIB_OBJ="strdup.o setenv.o setsid.o strftime.o \
strcasecmp.o gettytab.o" \
LIB_SRC=s"trdup.c setenv.c setsid.c strftime.c \
strcasecmp.c gettytab.c" \
CC="${CC}" LCCFLAGS="-O" \
VPATH=../../getty \
AR=ar ARFLAGS=cq RANLIB=ranlib \
LIBEXEC=${DESTDIR}/usr/etc
#
# For the convex, make symbolic links to the tc[sg]getattr.c routines,
# because we are using posix stuff, but not the posix library...
# Pass the stuff to Makefile.generic by passing the object/source names
# in through LIB_OBJ and LIB_SRC
#
convex:
@echo $@ is untested... it may or may not work..."
ln -s ../../rel_usr/src/lib/libc/posix/tcsetattr.c tcsetattr.c
ln -s ../../rel_usr/src/lib/libc/posix/tcgetattr.c tcgetattr.c
make -f Makefile.generic ${WHAT} \
LIBS="-ltermcap ../libtelnet/libtelnet.a" \
LIBPATH="../libtelnet/libtelnet.a" \
AR=ar ARFLAGS=cq RANLIB=ranlib \
LIBEXEC=${DESTDIR}/usr/etc/in.telnetd \
CC="${CC}" LCCFLAGS="-g ${OPTLEV} -Dconvex" \
DEFINES=${ODEFS}"-DUSE_TERMIO -DLINEMODE \
-DDEFAULT_IM='\"\r\nConvex (%h) (%t)\r\n\r\r\n\r\"' \
-DDIAGNOSTICS -DENV_HACK -DOLD_ENVIRON" \
INCLUDES="-I.." \
LIB_OBJ="getent.o setsid.o strftime.o \
tcsetattr.o tcgetattr.o" \
LIB_SRC="getent.c setsid.c strftime.c \
tcsetattr.c tcgetattr.c"
clean cleandir:
make -f Makefile.generic $@

105
appl/telnet/Config.local Normal file
View File

@@ -0,0 +1,105 @@
AUTH_LIB = ../../../lib/krb/libkrb.a ../../../lib/des/libdes.a
AUTH_LIBPATH = ../../../lib/krb/libkrb.a ../../../lib/des/libdes.a
AUTH_INC = -I../../../include -I$(VPATH)/../../../include
AUTH_DEF = -DAUTHENTICATION -DENCRYPTION -DKRB4 -DDES_ENCRYPTION
all:
@echo "You must specify what type of system you are on,"
@echo "or setup a Config.local file for your system."
@echo "Known system types are:"
@echo
@echo " sunos4 hpux osf ultrix netbsd"
sunos4:
$(MAKE) VPATH=$(VPATH) -f $(VPATH)/Makefile.generic ${WHAT} \
LIBS="-ltermcap ../libtelnet/libtelnet.a ${AUTH_LIB}" \
LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \
../libtelnet/libtelnet.a ${AUTH_LIBPATH}" \
DEST=${DESTDIR}/usr/ucb \
DEFINES=${ODEFS}"-Dmemmove=memcpy -DFILIO_H \
-DTERMCAP -DUSE_TERMIO \
-DKLUDGELINEMODE -DSTREAMS \
-DDEFAULT_IM='\"\r\nSunOS UNIX 4.1 (%h) (%t)\r\n\r\r\n\r\"' \
-DDIAGNOSTICS -DENV_HACK -DOLD_ENVIRON \
${AUTH_DEF}" \
INCLUDES="-I.. -I$(VPATH)/.. ${AUTH_INC} " \
LIB_OBJ="getent.o strerror.o setenv.o herror.o" \
LIB_SRC="getent.c strerror.c setenv.c herror.c" \
AR=ar ARFLAGS=cq RANLIB=ranlib \
LIBEXEC=${DESTDIR}/usr/etc/in.telnetd \
CC="${CC}" LCCFLAGS="-g"
#-DNO_LOGIN_F -DLOGIN_R
osf:
$(MAKE) VPATH=$(VPATH) -f $(VPATH)/Makefile.generic ${WHAT} \
LIBS="-lutil -ltermcap ../libtelnet/libtelnet.a ${AUTH_LIB}" \
LIBPATH="/usr/lib/libc.a /usr/lib/libtermcap.a \
../libtelnet/libtelnet.a ${AUTH_LIBPATH}" \
DEST=${DESTDIR}/usr/bin \
DEFINES=${ODEFS}" -DTERMCAP -DKLUDGELINEMODE \
-DDEFAULT_IM='\"\r\nDEC OSF/1 (%h) (%t)\r\n\r\r\n\r\"' \
-DUSE_TERMIO -DDIAGNOSTICS -DENV_HACK -DOLD_ENVIRON \
${AUTH_DEF}" \
INCLUDES="-I.. -I$(VPATH)/.. ${AUTH_INC}" \
LIB_OBJ="getent.o" \
LIB_SRC="getent.c" \
AR=ar ARFLAGS=cq RANLIB=ranlib \
LIBEXEC=${DESTDIR}/usr/libexec \
CC="${CC}" LCCFLAGS="-g"
hpux:
$(MAKE) VPATH=$(VPATH) -f $(VPATH)/Makefile.generic ${WHAT} \
LIBS="-ltermcap ../libtelnet/libtelnet.a ${AUTH_LIB}" \
LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \
../libtelnet/libtelnet.a ${AUTH_LIBPATH}" \
DEST=${DESTDIR}/usr/bin \
DEFINES=${ODEFS}"-Dvfork=fork -DUSE_TERMIO \
-DDEFAULT_IM='\"\r\n\r\nHP-UX 9.0 (%h) (%t)\r\n\r\r\n\r\"' \
-DNO_LOGIN_F -DNO_LOGIN_P -DNO_LOGIN_H \
-DDIAGNOSTICS -DLOGIN_ARGS ${AUTH_DEF}" \
INCLUDES="-I.. -I$(VPATH)/.. ${AUTH_INC} " \
LIB_OBJ="getent.o setenv.o" \
LIB_SRC="getent.c setenv.c" \
AR=ar ARFLAGS=cq RANLIB=NONE \
LIBEXEC=${DESTDIR}/etc \
CC="${CC}" LCCFLAGS="-O"
ultrix:
$(MAKE) -f $(VPATH)/Makefile.generic ${WHAT} \
LIBS="-ltermcap ../libtelnet/libtelnet.a ${AUTH_LIB}" \
LIBPATH="/lib/libc.a /usr/lib/libtermcap.a \
../libtelnet/libtelnet.a ${AUTH_LIBPATH}" \
DEST=${DESTDIR}/usr/ucb \
DEFINES=${ODEFS}"-DUSE_TERMIO -DTERMCAP \
-DDEFAULT_IM='\"\r\nULTRIX V4.4 (%h) (%t)\r\n\r\r\n\r\"' \
-DKLUDGELINEMODE -DDIAGNOSTICS \
-DNO_LOGIN_F -DNO_LOGIN_P -DLOGIN_R \
-DENV_HACK -DOLD_ENVIRON ${AUTH_DEF}" \
INCLUDES="-I.. -I$(VPATH)/.. ${AUTH_INC}" \
LIB_OBJ="getent.o strdup.o" \
LIB_SRC="getent.c strdup.c" \
AR=ar ARFLAGS=cq RANLIB=ranlib \
LIBEXEC=${DESTDIR}/usr/etc \
CC="${CC}" LCCFLAGS="-O"
netbsd:
$(MAKE) -f $(VPATH)/Makefile.generic ${WHAT} \
LIBS="-lutil -ltermcap ../libtelnet/libtelnet.a ${AUTH_LIB}" \
LIBPATH="/usr/lib/libc.a /usr/lib/libtermcap.a \
../libtelnet/libtelnet.a ${AUTH_LIBPATH}" \
DEST=${DESTDIR}/usr/bin \
DEFINES=${ODEFS}"-DLINEMODE -DTERMCAP -DKLUDGELINEMODE \
-DDEFAULT_IM='\"\r\nNetBSD 1.0 (%h) (%t)\r\n\r\r\n\r\"' \
-DUSE_TERMIO -DDIAGNOSTICS -DENV_HACK -DOLD_ENVIRON \
-DHAS_CGETENT ${AUTH_DEF}" \
INCLUDES="-I.. -I$(VPATH)/.. ${AUTH_INC}" \
LIB_OBJ="getent.o" \
LIB_SRC="getent.c" \
AR=ar ARFLAGS=cq RANLIB=ranlib \
LIBEXEC=${DESTDIR}/usr/libexec \
CC="${CC}" LCCFLAGS="-O"
clean cleandir:
$(MAKE) -f Makefile.generic $@

View File

@@ -0,0 +1,9 @@
all:
cd libtelnet; make CC="${CC}"
cd telnet; make CC="${CC}"
cd telnetd; make CC="${CC}"
.DEFAULT:
cd libtelnet; make $@ WHAT=${WHAT} CC="${CC}"
cd telnet; make $@ WHAT=${WHAT} CC="${CC}"
cd telnetd; make $@ WHAT=${WHAT} CC="${CC}"

743
appl/telnet/README Normal file
View File

@@ -0,0 +1,743 @@
This is a distribution of both client and server telnet. These programs
have been compiled on:
telnet telnetd
4.4 BSD-Lite x x
4.3 BSD Reno X X
UNICOS 9.1 X X
UNICOS 9.0 X X
UNICOS 8.0 X X
BSDI 2.0 X X
Solaris 2.4 x x (no linemode in server)
SunOs 4.1.4 X X (no linemode in server)
Ultrix 4.3 X X (no linemode in server)
Ultrix 4.1 X X (no linemode in server)
In addition, previous versions have been compiled on the following
machines, but were not available for testing this version.
telnet telnetd
Next1.0 X X
UNICOS 8.3 X X
UNICOS 7.C X X
UNICOS 7.0 X X
SunOs 4.0.3c X X (no linemode in server)
4.3 BSD X X (no linemode in server)
DYNIX V3.0.12 X X (no linemode in server)
Ultrix 3.1 X X (no linemode in server)
Ultrix 4.0 X X (no linemode in server)
SunOs 3.5 X X (no linemode in server)
SunOs 4.1.3 X X (no linemode in server)
Solaris 2.2 x x (no linemode in server)
Solaris 2.3 x x (no linemode in server)
BSDI 1.0 X X
BSDI 1.1 X X
DYNIX V3.0.17.9 X X (no linemode in server)
HP-UX 8.0 x x (no linemode in server)
This code should work, but there are no guarantees.
May 30, 1995
This release represents what is on the 4.4BSD-Lite2 release, which
should be the final BSD release. I will continue to support of
telnet, The code (without encryption) is available via anonymous ftp
from ftp.cray.com, in src/telnet/telnet.YY.MM.DD.NE.tar.Z, where
YY.MM.DD is replaced with the year, month and day of the release.
If you can't find it at one of these places, at some point in the
near future information about the latest releases should be available
from ftp.borman.com.
In addition, the version with the encryption code is available via
ftp from net-dist.mit.edu, in the directory /pub/telnet. There
is a README file there that gives further information on how
to get the distribution.
Questions, comments, bug reports and bug fixes can be sent to
one of these addresses:
dab@borman.com
dab@cray.com
dab@bsdi.com
This release is mainly bug fixes and code cleanup.
Replace all calls to bcopy()/bzero() with calls to
memmove()/memset() and all calls to index()/rindex()
with calls to strchr()/strrchr().
Add some missing diagnostics for option tracing
to telnetd.
Add support for BSDI 2.0 and Solaris 2.4.
Add support for UNICOS 8.0
Get rid of expanded tabs and trailing white spaces.
From Paul Vixie:
Fix for telnet going into an endless spin
when the session dies abnormally.
From Jef Poskanzer:
Changes to allow telnet to compile
under SunOS 3.5.
From Philip Guenther:
makeutx() doesn't expand utmpx,
use pututxline() instead.
From Chris Torek:
Add a sleep(1) before execing login
to avoid race condition that can eat
up the login prompt.
Use terminal speed directly if it is
not an encoded value.
From Steve Parker:
Fix to realloc() call. Fix for execing
login on solaris with no user name.
January 19, 1994
This is a list of some of the changes since the last tar release
of telnet/telnetd. There are probably other changes that aren't
listed here, but this should hit a lot of the main ones.
General:
Changed #define for AUTHENTICATE to AUTHENTICATION
Changed #define for ENCRYPT to ENCRYPTION
Changed #define for DES_ENCRYPT to DES_ENCRYPTION
Added support for SPX authentication: -DSPX
Added support for Kerberos Version 5 authentication: -DKRB5
Added support for ANSI C function prototypes
Added support for the NEW-ENVIRON option (RFC-1572)
including support for USERVAR.
Made support for the old Environment Option (RFC-1408)
conditional on -DOLD_ENVIRON
Added #define ENV_HACK - support for RFC 1571
The encryption code is removed from the public distributions.
Domestic 4.4 BSD distributions contain the encryption code.
ENV_HACK: Code to deal with systems that only implement
the old ENVIRON option, and have reversed definitions
of ENV_VAR and ENV_VAL. Also fixes ENV processing in
client to handle things besides just the default set...
NO_BSD_SETJMP: UNICOS configuration for
UNICOS 6.1/6.0/5.1/5.0 systems.
STREAMSPTY: Use /dev/ptmx to get a clean pty. This
is for SVr4 derivatives (Like Solaris)
UTMPX: For systems that have /etc/utmpx. This is for
SVr4 derivatives (Like Solaris)
Definitions for BSDI 1.0
Definitions for 4.3 Reno and 4.4 BSD.
Definitions for UNICOS 8.0 and UNICOS 7.C
Definitions for Solaris 2.0
Definitions for HP-UX 8.0
Latest Copyright notices from Berkeley.
FLOW-CONTROL: support for RFC-XXXx
Client Specific:
Fix the "send" command to not send garbage...
Fix status message for "skiprc"
Make sure to send NAWS after telnet has been suspended
or an external command has been run, if the window size
has changed.
sysV88 support.
Server Specific:
Support flowcontrol option in non-linemode servers.
-k Server supports Kludge Linemode, but will default to
either single character mode or real Linemode support.
The user will have to explicitly ask to switch into
kludge linemode. ("stty extproc", or escape back to
to telnet and say "mode line".)
-u Specify the length of the hostname field in the utmp
file. Hostname longer than this length will be put
into the utmp file in dotted decimal notation, rather
than putting in a truncated hostname.
-U Registered hosts only. If a reverse hostname lookup
fails, the connection will be refused.
-f/-F
Allows forwarding of credentials for KRB5.
Februrary 22, 1991:
Features:
This version of telnet/telnetd has support for both
the AUTHENTICATION and ENCRYPTION options. The
AUTHENTICATION option is fairly well defined, and
an option number has been assigned to it. The
ENCRYPTION option is still in a state of flux; an
option number has been assigned to, but it is still
subject to change. The code is provided in this release
for experimental and testing purposes.
The telnet "send" command can now be used to send
do/dont/will/wont commands, with any telnet option
name. The rules for when do/dont/will/wont are sent
are still followed, so just because the user requests
that one of these be sent doesn't mean that it will
be sent...
The telnet "getstatus" command no longer requires
that option printing be enabled to see the response
to the "DO STATUS" command.
A -n flag has been added to telnetd to disable
keepalives.
A new telnet command, "auth" has been added (if
AUTHENTICATE is defined). It has four sub-commands,
"status", "disable", "enable" and "help".
A new telnet command, "encrypt" has been added (if
ENCRYPT is defined). It has many sub-commands:
"enable", "type", "start", "stop", "input",
"-input", "output", "-output", "status", and "help".
The LOGOUT option is now supported by both telnet
and telnetd, a new command, "logout", was added
to support this.
Several new toggle options were added:
"autoencrypt", "autodecrypt", "autologin", "authdebug",
"encdebug", "skiprc", "verbose_encrypt"
An "rlogin" interface has been added. If the program
is named "rlogin", or the "-r" flag is given, then
an rlogin type of interface will be used.
~. Terminates the session
~<susp> Suspend the session
~^] Escape to telnet command mode
~~ Pass through the ~.
BUG: If you type the rlogin escape character
in the middle of a line while in rlogin
mode, you cannot erase it or any characters
before it. Hopefully this can be fixed
in a future release...
General changes:
A "libtelnet.a" has now been created. This libraray
contains code that is common to both telnet and
telnetd. This is also where library routines that
are needed, but are not in the standard C library,
are placed.
The makefiles have been re-done. All of the site
specific configuration information has now been put
into a single "Config.generic" file, in the top level
directory. Changing this one file will take care of
all three subdirectories. Also, to add a new/local
definition, a "Config.local" file may be created
at the top level; if that file exists, the subdirectories
will use that file instead of "Config.generic".
Many 1-2 line functions in commands.c have been
removed, and just inserted in-line, or replaced
with a macro.
Bug Fixes:
The non-termio code in both telnet and telnetd was
setting/clearing CTLECH in the sg_flags word. This
was incorrect, and has been changed to set/clear the
LCTLECH bit in the local mode word.
The SRCRT #define has been removed. If IP_OPTIONS
and IPPROTO_IP are defined on the system, then the
source route code is automatically enabled.
The NO_GETTYTAB #define has been removed; there
is a compatability routine that can be built into
libtelnet to achive the same results.
The server, telnetd, has been switched to use getopt()
for parsing the argument list.
The code for getting the input/output speeds via
cfgetispeed()/cfgetospeed() was still not quite
right in telnet. Posix says if the ispeed is 0,
then it is really equal to the ospeed.
The suboption processing code in telnet now has
explicit checks to make sure that we received
the entire suboption (telnetd was already doing this).
The telnet code for processing the terminal type
could cause a core dump if an existing connection
was closed, and a new connection opened without
exiting telnet.
Telnetd was doing a TCSADRAIN when setting the new
terminal settings; This is not good, because it means
that the tcsetattr() will hang waiting for output to
drain, and telnetd is the only one that will drain
the output... The fix is to use TCSANOW which does
not wait.
Telnetd was improperly setting/clearing the ISTRIP
flag in the c_lflag field, it should be using the
c_iflag field.
When the child process of telnetd was opening the
slave side of the pty, it was re-setting the EXTPROC
bit too early, and some of the other initialization
code was wiping it out. This would cause telnetd
to go out of linemode and into single character mode.
One instance of leaving linemode in telnetd forgot
to send a WILL ECHO to the client, the net result
would be that the user would see double character
echo.
If the MODE was being changed several times very
quickly, telnetd could get out of sync with the
state changes and the returning acks; and wind up
being left in the wrong state.
September 14, 1990:
Switch the client to use getopt() for parsing the
argument list. The 4.3Reno getopt.c is included for
systems that don't have getopt().
Use the posix _POSIX_VDISABLE value for what value
to use when disabling special characters. If this
is undefined, it defaults to 0x3ff.
For non-termio systems, TIOCSETP was being used to
change the state of the terminal. This causes the
input queue to be flushed, which we don't want. This
is now changed to TIOCSETN.
Take out the "#ifdef notdef" around the code in the
server that generates a "sync" when the pty oputput
is flushed. The potential problem is that some older
telnet clients may go into an infinate loop when they
receive a "sync", if so, the server can be compiled
with "NO_URGENT" defined.
Fix the client where it was setting/clearing the OPOST
bit in the c_lflag field, not the c_oflag field.
Fix the client where it was setting/clearing the ISTRIP
bit in the c_lflag field, not the c_iflag field. (On
4.3Reno, this is the ECHOPRT bit in the c_lflag field.)
The client also had its interpretation of WILL BINARY
and DO BINARY reversed.
Fix a bug in client that would cause a core dump when
attempting to remove the last environment variable.
In the client, there were a few places were switch()
was being passed a character, and if it was a negative
value, it could get sign extended, and not match
the 8 bit case statements. The fix is to and the
switch value with 0xff.
Add a couple more printoption() calls in the client, I
don't think there are any more places were a telnet
command can be received and not printed out when
"options" is on.
A new flag has been added to the client, "-a". Currently,
this just causes the USER name to be sent across, in
the future this may be used to signify that automatic
authentication is requested.
The USER variable is now only sent by the client if
the "-a" or "-l user" options are explicity used, or
if the user explicitly asks for the "USER" environment
variable to be exported. In the server, if it receives
the "USER" environment variable, it won't print out the
banner message, so that only "Password:" will be printed.
This makes the symantics more like rlogin, and should be
more familiar to the user. (People are not used to
getting a banner message, and then getting just a
"Password:" prompt.)
Re-vamp the code for starting up the child login
process. The code was getting ugly, and it was
hard to tell what was really going on. What we
do now is after the fork(), in the child:
1) make sure we have no controlling tty
2) open and initialize the tty
3) do a setsid()/setpgrp()
4) makes the tty our controlling tty.
On some systems, #2 makes the tty our controlling
tty, and #4 is a no-op. The parent process does
a gets rid of any controlling tty after the child
is fork()ed.
Use the strdup() library routine in telnet, instead
of the local savestr() routine. If you don't have
strdup(), you need to define NO_STRDUP.
Add support for ^T (SIGINFO/VSTATUS), found in the
4.3Reno distribution. This maps to the AYT character.
You need a 4-line bugfix in the kernel to get this
to work properly:
> *** tty_pty.c.ORG Tue Sep 11 09:41:53 1990
> --- tty_pty.c Tue Sep 11 17:48:03 1990
> ***************
> *** 609,613 ****
> if ((tp->t_lflag&NOFLSH) == 0)
> ttyflush(tp, FREAD|FWRITE);
> ! pgsignal(tp->t_pgrp, *(unsigned int *)data);
> return(0);
> }
> --- 609,616 ----
> if ((tp->t_lflag&NOFLSH) == 0)
> ttyflush(tp, FREAD|FWRITE);
> ! pgsignal(tp->t_pgrp, *(unsigned int *)data, 1);
> ! if ((*(unsigned int *)data == SIGINFO) &&
> ! ((tp->t_lflag&NOKERNINFO) == 0))
> ! ttyinfo(tp);
> return(0);
> }
The client is now smarter when setting the telnet escape
character; it only sets it to one of VEOL and VEOL2 if
one of them is undefined, and the other one is not already
defined to the telnet escape character.
Handle TERMIOS systems that have seperate input and output
line speed settings imbedded in the flags.
Many other minor bug fixes.
June 20, 1990:
Re-organize makefiles and source tree. The telnet/Source
directory is now gone, and all the source that was in
telnet/Source is now just in the telnet directory.
Seperate makefile for each system are now gone. There
are two makefiles, Makefile and Makefile.generic.
The "Makefile" has the definitions for the various
system, and "Makefile.generic" does all the work.
There is a variable called "WHAT" that is used to
specify what to make. For example, in the telnet
directory, you might say:
make 4.4bsd WHAT=clean
to clean out the directory.
Add support for the ENVIRON and XDISPLOC options.
In order for the server to work, login has to have
the "-p" option to preserve environment variables.
Add the SOFT_TAB and LIT_ECHO modes in the LINEMODE support.
Add the "-l user" option to command line and open command
(This is passed through the ENVIRON option).
Add the "-e" command line option, for setting the escape
character.
Add the "-D", diagnostic, option to the server. This allows
the server to print out debug information, which is very
useful when trying to debug a telnet that doesn't have any
debugging ability.
Turn off the literal next character when not in LINEMODE.
Don't recognize ^Y locally, just pass it through.
Make minor modifications for Sun4.0 and Sun4.1
Add support for both FORW1 and FORW2 characters. The
telnet escpape character is set to whichever of the
two is not being used. If both are in use, the escape
character is not set, so when in linemode the user will
have to follow the escape character with a <CR> or <EOF)
to get it passed through.
Commands can now be put in single and double quotes, and
a backslash is now an escape character. This is needed
for allowing arbitrary strings to be assigned to environment
variables.
Switch telnetd to use macros like telnet for keeping
track of the state of all the options.
Fix telnetd's processing of options so that we always do
the right processing of the LINEMODE option, regardless
of who initiates the request to turn it on. Also, make
sure that if the other side went "WILL ECHO" in response
to our "DO ECHO", that we send a "DONT ECHO" to get the
option turned back off!
Fix the TERMIOS setting of the terminal speed to handle both
BSD's seperate fields, and the SYSV method of CBAUD bits.
Change how we deal with the other side refusing to enable
an option. The sequence used to be: send DO option; receive
WONT option; send DONT option. Now, the sequence is: send
DO option; receive WONT option. Both should be valid
according to the spec, but there has been at least one
client implementation of telnet identified that can get
really confused by this. (The exact sequence, from a trace
on the server side, is (numbers are number of responses that
we expect to get after that line...):
send WILL ECHO 1 (initial request)
send WONT ECHO 2 (server is changing state)
recv DO ECHO 1 (first reply, ok. expect DONT ECHO next)
send WILL ECHO 2 (server changes state again)
recv DONT ECHO 1 (second reply, ok. expect DO ECHO next)
recv DONT ECHO 0 (third reply, wrong answer. got DONT!!!)
*** send WONT ECHO (send WONT to acknowledge the DONT)
send WILL ECHO 1 (ask again to enable option)
recv DO ECHO 0
recv DONT ECHO 0
send WONT ECHO 1
recv DONT ECHO 0
recv DO ECHO 1
send WILL ECHO 0
(and the last 5 lines loop forever)
The line with the "***" is last of the WILL/DONT/WONT sequence.
The change to the server to not generate that makes this same
example become:
send will ECHO 1
send wont ECHO 2
recv do ECHO 1
send will ECHO 2
recv dont ECHO 1
recv dont ECHO 0
recv do ECHO 1
send will ECHO 0
There is other option negotiation going on, and not sending
the third part changes some of the timings, but this specific
example no longer gets stuck in a loop. The "telnet.state"
file has been modified to reflect this change to the algorithm.
A bunch of miscellaneous bug fixes and changes to make
lint happier.
This version of telnet also has some KERBEROS stuff in
it. This has not been tested, it uses an un-authorized
telnet option number, and uses an out-of-date version
of the (still being defined) AUTHENTICATION option.
There is no support for this code, do not enable it.
March 1, 1990:
CHANGES/BUGFIXES SINCE LAST RELEASE:
Some support for IP TOS has been added. Requires that the
kernel support the IP_TOS socket option (currently this
is only in UNICOS 6.0).
Both telnet and telnetd now use the cc_t typedef. typedefs are
included for systems that don't have it (in termios.h).
SLC_SUSP was not supported properly before. It is now.
IAC EOF was not translated properly in telnetd for SYSV_TERMIO
when not in linemode. It now saves a copy of the VEOF character,
so that when ICANON is turned off and we can't trust it anymore
(because it is now the VMIN character) we use the saved value.
There were two missing "break" commands in the linemode
processing code in telnetd.
Telnetd wasn't setting the kernel window size information
properly. It was using the rows for both rows and columns...
Questions/comments go to
David Borman
Cray Research, Inc.
655F Lone Oak Drive
Eagan, MN 55123
dab@cray.com.
README: You are reading it.
Config.generic:
This file contains all the OS specific definitions. It
has pre-definitions for many common system types, and is
in standard makefile fromat. See the comments at the top
of the file for more information.
Config.local:
This is not part of the distribution, but if this file exists,
it is used instead of "Config.generic". This allows site
specific configuration without having to modify the distributed
"Config.generic" file.
kern.diff:
This file contains the diffs for the changes needed for the
kernel to support LINEMODE is the server. These changes are
for a 4.3BSD system. You may need to make some changes for
your particular system.
There is a new bit in the terminal state word, TS_EXTPROC.
When this bit is set, several aspects of the terminal driver
are disabled. Input line editing, character echo, and
mapping of signals are all disabled. This allows the telnetd
to turn of these functions when in linemode, but still keep
track of what state the user wants the terminal to be in.
New ioctl()s:
TIOCEXT Turn on/off the TS_EXTPROC bit
TIOCGSTATE Get t_state of tty to look at TS_EXTPROC bit
TIOCSIG Generate a signal to processes in the
current process group of the pty.
There is a new mode for packet driver, the TIOCPKT_IOCTL bit.
When packet mode is turned on in the pty, and the TS_EXTPROC
bit is set, then whenever the state of the pty is changed, the
next read on the master side of the pty will have the TIOCPKT_IOCTL
bit set, and the data will contain the following:
struct xx {
struct sgttyb a;
struct tchars b;
struct ltchars c;
int t_state;
int t_flags;
}
This allows the process on the server side of the pty to know
when the state of the terminal has changed, and what the new
state is.
However, if you define USE_TERMIO or SYSV_TERMIO, the code will
expect that the structure returned in the TIOCPKT_IOCTL is
the termio/termios structure.
stty.diff:
This file contains the changes needed for the stty(1) program
to report on the current status of the TS_EXTPROC bit. It also
allows the user to turn on/off the TS_EXTPROC bit. This is useful
because it allows the user to say "stty -extproc", and the
LINEMODE option will be automatically disabled, and saying "stty
extproc" will re-enable the LINEMODE option.
telnet.state:
Both the client and server have code in them to deal
with option negotiation loops. The algorithm that is
used is described in this file.
telnet:
This directory contains the client code. No kernel changes are
needed to use this code.
telnetd:
This directory contains the server code. If LINEMODE or KLUDGELINEMODE
are defined, then the kernel modifications listed above are needed.
libtelnet:
This directory contains code that is common to both the client
and the server.
arpa:
This directory has a new <arpa/telnet.h>
libtelnet/Makefile.4.4:
telnet/Makefile.4.4:
telnetd/Makefile.4.4:
These are the makefiles that can be used on a 4.3Reno
system when this software is installed in /usr/src/lib/libtelnet,
/usr/src/libexec/telnetd, and /usr/src/usr.bin/telnet.
The following TELNET options are supported:
LINEMODE:
The LINEMODE option is supported as per RFC1116. The
FORWARDMASK option is not currently supported.
BINARY: The client has the ability to turn on/off the BINARY
option in each direction. Turning on BINARY from
server to client causes the LITOUT bit to get set in
the terminal driver on both ends, turning on BINARY
from the client to the server causes the PASS8 bit
to get set in the terminal driver on both ends.
TERMINAL-TYPE:
This is supported as per RFC1091. On the server side,
when a terminal type is received, termcap/terminfo
is consulted to determine if it is a known terminal
type. It keeps requesting terminal types until it
gets one that it recongnizes, or hits the end of the
list. The server side looks up the entry in the
termcap/terminfo data base, and generates a list of
names which it then passes one at a time to each
request for a terminal type, duplicating the last
entry in the list before cycling back to the beginning.
NAWS: The Negotiate about Window Size, as per RFC 1073.
TERMINAL-SPEED:
Implemented as per RFC 1079
TOGGLE-FLOW-CONTROL:
Implemented as per RFC 1080
TIMING-MARK:
As per RFC 860
SGA: As per RFC 858
ECHO: As per RFC 857
LOGOUT: As per RFC 727
STATUS:
The server will send its current status upon
request. It does not ask for the clients status.
The client will request the servers current status
from the "send getstatus" command.
ENVIRON:
This option is currently being defined by the IETF
Telnet Working Group, and an RFC has not yet been
issued, but should be in the near future...
X-DISPLAY-LOCATION:
This functionality can be done through the ENVIRON
option, it is added here for completeness.
AUTHENTICATION:
This option is currently being defined by the IETF
Telnet Working Group, and an RFC has not yet been
issued. The basic framework is pretty much decided,
but the definitions for the specific authentication
schemes is still in a state of flux.
ENCRYPTION:
This option is currently being defined by the IETF
Telnet Working Group, and an RFC has not yet been
issued. The draft RFC is still in a state of flux,
so this code may change in the future.

323
appl/telnet/arpa/telnet.h Normal file
View File

@@ -0,0 +1,323 @@
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)telnet.h 8.2 (Berkeley) 12/15/93
*/
#ifndef _TELNET_H_
#define _TELNET_H_
/*
* Definitions for the TELNET protocol.
*/
#define IAC 255 /* interpret as command: */
#define DONT 254 /* you are not to use option */
#define DO 253 /* please, you use option */
#define WONT 252 /* I won't use option */
#define WILL 251 /* I will use option */
#define SB 250 /* interpret as subnegotiation */
#define GA 249 /* you may reverse the line */
#define EL 248 /* erase the current line */
#define EC 247 /* erase the current character */
#define AYT 246 /* are you there */
#define AO 245 /* abort output--but let prog finish */
#define IP 244 /* interrupt process--permanently */
#define BREAK 243 /* break */
#define DM 242 /* data mark--for connect. cleaning */
#define NOP 241 /* nop */
#define SE 240 /* end sub negotiation */
#define EOR 239 /* end of record (transparent mode) */
#define ABORT 238 /* Abort process */
#define SUSP 237 /* Suspend process */
#define xEOF 236 /* End of file: EOF is already used... */
#define SYNCH 242 /* for telfunc calls */
#ifdef TELCMDS
char *telcmds[] = {
"EOF", "SUSP", "ABORT", "EOR",
"SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
"EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0,
};
#else
extern char *telcmds[];
#endif
#define TELCMD_FIRST xEOF
#define TELCMD_LAST IAC
#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \
(unsigned int)(x) >= TELCMD_FIRST)
#define TELCMD(x) telcmds[(x)-TELCMD_FIRST]
/* telnet options */
#define TELOPT_BINARY 0 /* 8-bit data path */
#define TELOPT_ECHO 1 /* echo */
#define TELOPT_RCP 2 /* prepare to reconnect */
#define TELOPT_SGA 3 /* suppress go ahead */
#define TELOPT_NAMS 4 /* approximate message size */
#define TELOPT_STATUS 5 /* give status */
#define TELOPT_TM 6 /* timing mark */
#define TELOPT_RCTE 7 /* remote controlled transmission and echo */
#define TELOPT_NAOL 8 /* negotiate about output line width */
#define TELOPT_NAOP 9 /* negotiate about output page size */
#define TELOPT_NAOCRD 10 /* negotiate about CR disposition */
#define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */
#define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */
#define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */
#define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */
#define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */
#define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */
#define TELOPT_XASCII 17 /* extended ascic character set */
#define TELOPT_LOGOUT 18 /* force logout */
#define TELOPT_BM 19 /* byte macro */
#define TELOPT_DET 20 /* data entry terminal */
#define TELOPT_SUPDUP 21 /* supdup protocol */
#define TELOPT_SUPDUPOUTPUT 22 /* supdup output */
#define TELOPT_SNDLOC 23 /* send location */
#define TELOPT_TTYPE 24 /* terminal type */
#define TELOPT_EOR 25 /* end or record */
#define TELOPT_TUID 26 /* TACACS user identification */
#define TELOPT_OUTMRK 27 /* output marking */
#define TELOPT_TTYLOC 28 /* terminal location number */
#define TELOPT_3270REGIME 29 /* 3270 regime */
#define TELOPT_X3PAD 30 /* X.3 PAD */
#define TELOPT_NAWS 31 /* window size */
#define TELOPT_TSPEED 32 /* terminal speed */
#define TELOPT_LFLOW 33 /* remote flow control */
#define TELOPT_LINEMODE 34 /* Linemode option */
#define TELOPT_XDISPLOC 35 /* X Display Location */
#define TELOPT_OLD_ENVIRON 36 /* Old - Environment variables */
#define TELOPT_AUTHENTICATION 37/* Authenticate */
#define TELOPT_ENCRYPT 38 /* Encryption option */
#define TELOPT_NEW_ENVIRON 39 /* New - Environment variables */
#define TELOPT_EXOPL 255 /* extended-options-list */
#define NTELOPTS (1+TELOPT_NEW_ENVIRON)
#ifdef TELOPTS
char *telopts[NTELOPTS+1] = {
"BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
"STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
"NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
"NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
"DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
"SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
"TACACS UID", "OUTPUT MARKING", "TTYLOC",
"3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
"LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
"ENCRYPT", "NEW-ENVIRON",
0,
};
#define TELOPT_FIRST TELOPT_BINARY
#define TELOPT_LAST TELOPT_NEW_ENVIRON
#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST)
#define TELOPT(x) telopts[(x)-TELOPT_FIRST]
#endif
/* sub-option qualifiers */
#define TELQUAL_IS 0 /* option is... */
#define TELQUAL_SEND 1 /* send option */
#define TELQUAL_INFO 2 /* ENVIRON: informational version of IS */
#define TELQUAL_REPLY 2 /* AUTHENTICATION: client version of IS */
#define TELQUAL_NAME 3 /* AUTHENTICATION: client version of IS */
#define LFLOW_OFF 0 /* Disable remote flow control */
#define LFLOW_ON 1 /* Enable remote flow control */
#define LFLOW_RESTART_ANY 2 /* Restart output on any char */
#define LFLOW_RESTART_XON 3 /* Restart output only on XON */
/*
* LINEMODE suboptions
*/
#define LM_MODE 1
#define LM_FORWARDMASK 2
#define LM_SLC 3
#define MODE_EDIT 0x01
#define MODE_TRAPSIG 0x02
#define MODE_ACK 0x04
#define MODE_SOFT_TAB 0x08
#define MODE_LIT_ECHO 0x10
#define MODE_MASK 0x1f
/* Not part of protocol, but needed to simplify things... */
#define MODE_FLOW 0x0100
#define MODE_ECHO 0x0200
#define MODE_INBIN 0x0400
#define MODE_OUTBIN 0x0800
#define MODE_FORCE 0x1000
#define SLC_SYNCH 1
#define SLC_BRK 2
#define SLC_IP 3
#define SLC_AO 4
#define SLC_AYT 5
#define SLC_EOR 6
#define SLC_ABORT 7
#define SLC_EOF 8
#define SLC_SUSP 9
#define SLC_EC 10
#define SLC_EL 11
#define SLC_EW 12
#define SLC_RP 13
#define SLC_LNEXT 14
#define SLC_XON 15
#define SLC_XOFF 16
#define SLC_FORW1 17
#define SLC_FORW2 18
#define NSLC 18
/*
* For backwards compatability, we define SLC_NAMES to be the
* list of names if SLC_NAMES is not defined.
*/
#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
"ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
"LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0,
#ifdef SLC_NAMES
char *slc_names[] = {
SLC_NAMELIST
};
#else
extern char *slc_names[];
#define SLC_NAMES SLC_NAMELIST
#endif
#define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC)
#define SLC_NAME(x) slc_names[x]
#define SLC_NOSUPPORT 0
#define SLC_CANTCHANGE 1
#define SLC_VARIABLE 2
#define SLC_DEFAULT 3
#define SLC_LEVELBITS 0x03
#define SLC_FUNC 0
#define SLC_FLAGS 1
#define SLC_VALUE 2
#define SLC_ACK 0x80
#define SLC_FLUSHIN 0x40
#define SLC_FLUSHOUT 0x20
#define OLD_ENV_VAR 1
#define OLD_ENV_VALUE 0
#define NEW_ENV_VAR 0
#define NEW_ENV_VALUE 1
#define ENV_ESC 2
#define ENV_USERVAR 3
/*
* AUTHENTICATION suboptions
*/
/*
* Who is authenticating who ...
*/
#define AUTH_WHO_CLIENT 0 /* Client authenticating server */
#define AUTH_WHO_SERVER 1 /* Server authenticating client */
#define AUTH_WHO_MASK 1
/*
* amount of authentication done
*/
#define AUTH_HOW_ONE_WAY 0
#define AUTH_HOW_MUTUAL 2
#define AUTH_HOW_MASK 2
#define AUTHTYPE_NULL 0
#define AUTHTYPE_KERBEROS_V4 1
#define AUTHTYPE_KERBEROS_V5 2
#define AUTHTYPE_SPX 3
#define AUTHTYPE_MINK 4
#define AUTHTYPE_SRA 5
#define AUTHTYPE_CNT 6
/* #define AUTHTYPE_UNSECURE 6 */
#define AUTHTYPE_TEST 99
#ifdef AUTH_NAMES
char *authtype_names[] = {
"NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK",
"SRA", 0,
};
#else
extern char *authtype_names[];
#endif
#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT)
#define AUTHTYPE_NAME(x) authtype_names[x]
/*
* ENCRYPTion suboptions
*/
#define ENCRYPT_IS 0 /* I pick encryption type ... */
#define ENCRYPT_SUPPORT 1 /* I support encryption types ... */
#define ENCRYPT_REPLY 2 /* Initial setup response */
#define ENCRYPT_START 3 /* Am starting to send encrypted */
#define ENCRYPT_END 4 /* Am ending encrypted */
#define ENCRYPT_REQSTART 5 /* Request you start encrypting */
#define ENCRYPT_REQEND 6 /* Request you send encrypting */
#define ENCRYPT_ENC_KEYID 7
#define ENCRYPT_DEC_KEYID 8
#define ENCRYPT_CNT 9
#define ENCTYPE_ANY 0
#define ENCTYPE_DES_CFB64 1
#define ENCTYPE_DES_OFB64 2
#define ENCTYPE_CNT 3
#ifdef ENCRYPT_NAMES
char *encrypt_names[] = {
"IS", "SUPPORT", "REPLY", "START", "END",
"REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
0,
};
char *enctype_names[] = {
"ANY", "DES_CFB64", "DES_OFB64", 0,
};
#else
extern char *encrypt_names[];
extern char *enctype_names[];
#endif
#define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT)
#define ENCRYPT_NAME(x) encrypt_names[x]
#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT)
#define ENCTYPE_NAME(x) enctype_names[x]
#endif /* !_TELNET_H_ */

144
appl/telnet/config.h.in Normal file
View File

@@ -0,0 +1,144 @@
/* config.h.in. Generated automatically from configure.in by autoheader. */
/*
* configuration file for telnet
*
* $Id$
*
*/
#ifndef T_CONFIG_H
#define T_CONFIG_H
/* define this if you want authentication */
#undef AUTHENTICATION
/* define this if you have kerberos 4 */
#undef KRB4
/* define this if you want encryption */
#undef ENCRYPTION
/* Set this if you want des encryption */
#undef DES_ENCRYPTION
/* Set this to the default system lead string for telnetd
* can contain %-escapes: %s=sysname, %m=machine, %r=os-release
* %v=os-version, %t=tty, %h=hostname, %d=date and time
*/
#undef USE_IM
/* define this if you want diagnostics in telnetd */
#undef DIAGNOSTICS
/* define this if you want support for broken ENV_{VALUE,VAR} systems */
#undef ENV_HACK
/* define this if you want support for 4.3BSD kludged line mode */
#undef KLUDGELINEMODE
/* */
#undef OLD_ENVIRON
/* */
#undef STREAMSPTY
#ifdef HAVE_TGETENT
#define TERMCAP 1
#endif
/* Define if you have the cgetent function. */
#undef HAVE_CGETENT
/* Define if you have the gethostbyname function. */
#undef HAVE_GETHOSTBYNAME
/* Define if you have the setupterm function. */
#undef HAVE_SETUPTERM
/* Define if you have the socket function. */
#undef HAVE_SOCKET
/* Define if you have the tgetent function. */
#undef HAVE_TGETENT
/* Define if you have the uname function. */
#undef HAVE_UNAME
/* Define if you have the vfork function. */
#undef HAVE_VFORK
/* Define if you have the vhangup function. */
#undef HAVE_VHANGUP
/* Define if you have the <sac.h> header file. */
#undef HAVE_SAC_H
/* Define if you have the <sys/resource.h> header file. */
#undef HAVE_SYS_RESOURCE_H
/* Define if you have the <sys/select.h> header file. */
#undef HAVE_SYS_SELECT_H
/* Define if you have the <termio.h> header file. */
#undef HAVE_TERMIO_H
/* Define if you have the <termios.h> header file. */
#undef HAVE_TERMIOS_H
/* Define if you have the <utmpx.h> header file. */
#undef HAVE_UTMPX_H
/* Define if you have the nsl library (-lnsl). */
#undef HAVE_LIBNSL
/* Define if you have the socket library (-lsocket). */
#undef HAVE_LIBSOCKET
/* Define if you have the util library (-lutil). */
#undef HAVE_LIBUTIL
/* set this to a sensible login */
#ifndef LOGIN_PATH
#define LOGIN_PATH "/usr/athena/bin/login"
#endif
#ifdef HAVE_TGETENT
#define TERMCAP 1
#endif
#if defined(HAVE_TERMIOS_H) || defined(HAVE_TERMIO_H)
#define USE_TERMIO 1
/* If this is not a POSIX boxen use SYSV, this may not work on CRAY
* se telnetd/desf.h */
#ifndef HAVE_TERMIOS_H
#define SYSV_TERMIO
#endif
#endif /* defined(HAVE_TERMIOS_H) || defined(HAVE_TERMIO_H) */
#ifndef HAVE_VFORK
#define vfork fork
#endif
/* os specific tests ahead */
#ifdef sun
#define FILIO_H 1
#define STREAMS 1
#ifdef __svr4__
#define SOLARIS
#endif
#endif /* sun */
#ifdef _AIX
#define unix /* well, ok... */
#endif
#endif /* T_CONFIG_H */

1631
appl/telnet/configure vendored Executable file

File diff suppressed because it is too large Load Diff

308
appl/telnet/kern.diff Normal file
View File

@@ -0,0 +1,308 @@
*** h/ioctl.h.old Tue May 23 14:50:42 1989
--- h/ioctl.h Tue Aug 29 18:24:49 1989
***************
*** 214,219 ****
--- 214,220 ----
#define TIOCPKT_START 0x08 /* start output */
#define TIOCPKT_NOSTOP 0x10 /* no more ^S, ^Q */
#define TIOCPKT_DOSTOP 0x20 /* now do ^S ^Q */
+ #define TIOCPKT_IOCTL 0x40 /* state change of pty driver */
#define TIOCSTOP _IO('t', 111) /* stop output, like ^S */
#define TIOCSTART _IO('t', 110) /* start output, like ^Q */
#define TIOCMSET _IOW('t', 109, int) /* set all modem bits */
***************
*** 226,231 ****
--- 227,235 ----
#define TIOCUCNTL _IOW('t', 102, int) /* pty: set/clr usr cntl mode */
#define UIOCCMD(n) _IO('u', n) /* usr cntl op "n" */
#define TIOCCONS _IO('t', 98) /* become virtual console */
+ #define TIOCEXT _IOW('t', 97, int) /* pty: external processing */
+ #define TIOCGSTATE _IOR('t', 96, int) /* pty: get internal state */
+ #define TIOCSIG _IO('t', 95) /* pty: generate signal */
#define OTTYDISC 0 /* old, v7 std tty driver */
#define NETLDISC 1 /* line discip for berk net */
*** h/tty.h.old Tue May 23 14:51:01 1989
--- h/tty.h Wed Aug 23 11:30:40 1989
***************
*** 70,75 ****
--- 70,76 ----
struct ttychars t_chars; /* tty */
struct winsize t_winsize; /* window size */
/* be careful of tchars & co. */
+ #ifndef NO_T_CHARS_DEFINES
#define t_erase t_chars.tc_erase
#define t_kill t_chars.tc_kill
#define t_intrc t_chars.tc_intrc
***************
*** 84,89 ****
--- 85,91 ----
#define t_flushc t_chars.tc_flushc
#define t_werasc t_chars.tc_werasc
#define t_lnextc t_chars.tc_lnextc
+ #endif
};
#define TTIPRI 28
***************
*** 124,129 ****
--- 126,132 ----
#define TS_LNCH 0x080000 /* next character is literal */
#define TS_TYPEN 0x100000 /* retyping suspended input (PENDIN) */
#define TS_CNTTB 0x200000 /* counting tab width; leave FLUSHO alone */
+ #define TS_EXTPROC 0x400000 /* external processing of data */
#define TS_LOCAL (TS_BKSL|TS_QUOT|TS_ERASE|TS_LNCH|TS_TYPEN|TS_CNTTB)
*** sys/tty.c.old Tue May 23 14:52:28 1989
--- sys/tty.c Thu Aug 24 09:31:49 1989
***************
*** 275,280 ****
--- 275,285 ----
*/
switch (com) {
+ /* get internal state - needed for TS_EXTPROC bit */
+ case TIOCGSTATE:
+ *(int *)data = tp->t_state;
+ break;
+
/* get discipline number */
case TIOCGETD:
*(int *)data = tp->t_line;
***************
*** 752,757 ****
--- 757,763 ----
*/
if ((tp->t_state&TS_TYPEN) == 0 && (t_flags&PASS8) == 0)
c &= 0177;
+ if ((tp->t_state&TS_EXTPROC) == 0) {
/*
* Check for literal nexting very first
*/
***************
*** 834,839 ****
--- 840,846 ----
else if (c == '\\')
tp->t_state |= TS_BKSL;
}
+ }
/*
* Cbreak mode, don't process line editing
***************
*** 851,856 ****
--- 858,864 ----
goto endcase;
}
+ if ((tp->t_state&TS_EXTPROC) == 0) {
/*
* From here on down cooked mode character
* processing takes place.
***************
*** 911,916 ****
--- 919,925 ----
goto endcase;
}
}
+ }
/*
* Check for input buffer overflow
***************
*** 933,938 ****
--- 942,948 ----
} else if (tp->t_rocount++ == 0)
tp->t_rocol = tp->t_col;
tp->t_state &= ~TS_QUOT;
+ if ((tp->t_state&TS_EXTPROC) == 0) {
if (c == '\\')
tp->t_state |= TS_QUOT;
if (tp->t_state&TS_ERASE) {
***************
*** 948,953 ****
--- 958,964 ----
i--;
}
}
+ }
}
endcase:
/*
***************
*** 998,1005 ****
return (-1);
/*
* Turn tabs to spaces as required
*/
! if (c == '\t' && (tp->t_flags&TBDELAY) == XTABS) {
register int s;
c = 8 - (tp->t_col&7);
--- 1009,1022 ----
return (-1);
/*
* Turn tabs to spaces as required
+ *
+ * Special case if we have external processing, we don't
+ * do the tab expansion because we'll probably get it
+ * wrong. If tab expansion needs to be done, let it
+ * happen externally.
*/
! if ((tp->t_state&TS_EXTPROC) == 0 &&
! c == '\t' && (tp->t_flags&TBDELAY) == XTABS) {
register int s;
c = 8 - (tp->t_col&7);
***************
*** 1497,1503 ****
int s;
char *nextc();
! if ((tp->t_flags&ECHO) == 0)
return;
tp->t_flags &= ~FLUSHO;
c &= 0377;
--- 1514,1520 ----
int s;
char *nextc();
! if ((tp->t_flags&ECHO) == 0 || (tp->t_state&TS_EXTPROC))
return;
tp->t_flags &= ~FLUSHO;
c &= 0377;
***************
*** 1618,1624 ****
if ((tp->t_state&TS_CNTTB) == 0)
tp->t_flags &= ~FLUSHO;
! if ((tp->t_flags&ECHO) == 0)
return;
c &= 0377;
if (tp->t_flags&RAW) {
--- 1635,1641 ----
if ((tp->t_state&TS_CNTTB) == 0)
tp->t_flags &= ~FLUSHO;
! if ((tp->t_flags&ECHO) == 0 || (tp->t_state&TS_EXTPROC))
return;
c &= 0377;
if (tp->t_flags&RAW) {
*** sys/tty_pty.c.old Tue May 23 14:52:43 1989
--- sys/tty_pty.c Tue Aug 29 18:48:36 1989
***************
*** 208,213 ****
--- 208,214 ----
return (EIO);
tp->t_oproc = ptsstart;
(void)(*linesw[tp->t_line].l_modem)(tp, 1);
+ tp->t_state &= ~TS_EXTPROC;
pti = &pt_ioctl[minor(dev)];
pti->pt_flags = 0;
pti->pt_send = 0;
***************
*** 247,252 ****
--- 248,275 ----
error = ureadc((int)pti->pt_send, uio);
if (error)
return (error);
+ if (pti->pt_send & TIOCPKT_IOCTL) {
+ struct xx {
+ struct sgttyb a;
+ struct tchars b;
+ struct ltchars c;
+ int d;
+ int e;
+ } cb;
+ cb.a.sg_ispeed = tp->t_ispeed;
+ cb.a.sg_ospeed = tp->t_ospeed;
+ cb.a.sg_erase = tp->t_erase;
+ cb.a.sg_kill = tp->t_kill;
+ cb.a.sg_flags = tp->t_flags;
+ bcopy((caddr_t)&tp->t_intrc,
+ (caddr_t)&cb.b, sizeof(cb.b));
+ bcopy((caddr_t)&tp->t_suspc,
+ (caddr_t)&cb.c, sizeof(cb.c));
+ cb.d = tp->t_state;
+ cb.e = ((unsigned)tp->t_flags)>>16;
+ cc = MIN(uio->uio_resid, sizeof(cb));
+ uiomove(&cb, cc, UIO_READ, uio);
+ }
pti->pt_send = 0;
return (0);
}
***************
*** 483,488 ****
--- 506,533 ----
* IF CONTROLLER STTY THEN MUST FLUSH TO PREVENT A HANG.
* ttywflush(tp) will hang if there are characters in the outq.
*/
+ if (cmd == TIOCEXT) {
+ /*
+ * When the TS_EXTPROC bit is being toggled, we need
+ * to send an TIOCPKT_IOCTL if the packet driver
+ * is turned on.
+ */
+ if (*(int *)data) {
+ if (pti->pt_flags & PF_PKT) {
+ pti->pt_send |= TIOCPKT_IOCTL;
+ ptcwakeup(tp);
+ }
+ tp->t_state |= TS_EXTPROC;
+ } else {
+ if ((tp->t_state & TS_EXTPROC) &&
+ (pti->pt_flags & PF_PKT)) {
+ pti->pt_send |= TIOCPKT_IOCTL;
+ ptcwakeup(tp);
+ }
+ tp->t_state &= ~TS_EXTPROC;
+ }
+ return (0);
+ } else
if (cdevsw[major(dev)].d_open == ptcopen)
switch (cmd) {
***************
*** 525,530 ****
--- 570,583 ----
while (getc(&tp->t_outq) >= 0)
;
break;
+
+ case TIOCSIG:
+ if (*(unsigned int *)data >= NSIG)
+ return(EINVAL);
+ if ((tp->t_flags&NOFLSH) == 0)
+ ttyflush(tp, FREAD|FWRITE);
+ gsignal(tp->t_pgrp, *(unsigned int *)data);
+ return(0);
}
error = ttioctl(tp, cmd, data, flag);
/*
***************
*** 549,554 ****
--- 602,624 ----
return (0);
}
error = ENOTTY;
+ }
+ /*
+ * If external processing and packet mode send ioctl packet.
+ */
+ if ((tp->t_state & TS_EXTPROC) && (pti->pt_flags & PF_PKT)) {
+ switch(cmd) {
+ case TIOCSETP:
+ case TIOCSETN:
+ case TIOCSETC:
+ case TIOCSLTC:
+ case TIOCLBIS:
+ case TIOCLBIC:
+ case TIOCLSET:
+ pti->pt_send |= TIOCPKT_IOCTL;
+ default:
+ break;
+ }
}
stop = (tp->t_flags & RAW) == 0 &&
tp->t_stopc == CTRL('s') && tp->t_startc == CTRL('q');

View File

@@ -0,0 +1,33 @@
# @(#)Makefile 8.2 (Berkeley) 12/15/93
LIB= telnet
SRCS= auth.c encrypt.c genget.c getent.c misc.c
SRCS+= kerberos.c enc_des.c
#SRCS+= kerberos5.c
CFLAGS+= -DENCRYPTION -DAUTHENTICATION -DHAS_CGETENT
CFLAGS+= -DKRB4 -DDES_ENCRYPTION -I/usr/include/kerberosIV
# These are the sources that have encryption stuff in them.
CRYPT_SRC= auth.c enc-proto.h enc_des.c encrypt.c
CRYPT_SRC+= encrypt.h kerberos.c kerberos5.c krb4encpwd.c
CRYPT_SRC+= misc.c spx.c Makefile
NOCRYPT_DIR=${.CURDIR}/Nocrypt
.include <bsd.lib.mk>
nocrypt:
#ifdef ENCRYPTION
@for i in ${CRYPT_SRC}; do \
if [ ! -d ${NOCRYPT_DIR} ]; then \
echo Creating subdirectory ${NOCRYPT_DIR}; \
mkdir ${NOCRYPT_DIR}; \
fi; \
echo ${NOCRYPT_DIR}/$$i; \
unifdef -UENCRYPTION ${.CURDIR}/$$i | \
sed "s/ || defined(ENCRYPTION)//" > ${NOCRYPT_DIR}/$$i; \
done
placeholder:
#else /* ENCRYPTION */
@echo "Encryption code already removed."
#endif /* ENCRYPTION */

View File

@@ -0,0 +1,45 @@
#
# Copyright (c) 1991 The Regents of the University of California.
# All rights reserved.
#
# Redistribution and use in source and binary forms are permitted provided
# that: (1) source distributions retain this entire copyright notice and
# comment, and (2) distributions including binaries display the following
# acknowledgement: ``This product includes software developed by the
# University of California, Berkeley and its contributors'' in the
# documentation or other materials provided with the distribution and in
# all advertising materials mentioning features or use of this software.
# Neither the name of the University nor the names of its contributors may
# be used to endorse or promote products derived from this software without
# specific prior written permission.
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# @(#)Makefile 5.5 (Berkeley) 3/1/91
#
#
# Everything happens in ../Makefile.config and Makefile.generic
#
SHELL=/bin/sh
all:
@-if test -f ../Config.local; \
then \
echo make -f ../Config.local WHAT=${WHAT} CC="${CC}"; \
make -f ../Config.local WHAT=${WHAT} CC="${CC}"; \
else \
echo make -f ../Config.generic WHAT=${WHAT} CC="${CC}"; \
make -f ../Config.generic WHAT=${WHAT} CC="${CC}"; \
fi
.DEFAULT:
@-if test -f ../Config.local; \
then \
echo make -f ../Config.local WHAT=${WHAT} CC="${CC}" $@; \
make -f ../Config.local WHAT=${WHAT} CC="${CC}" $@; \
else \
echo make -f ../Config.generic WHAT=${WHAT} CC="${CC}" $@; \
make -f ../Config.generic WHAT=${WHAT} CC="${CC}" $@; \
fi

View File

@@ -0,0 +1,114 @@
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)auth-proto.h 8.1 (Berkeley) 6/4/93
*/
/*
* Copyright (C) 1990 by the Massachusetts Institute of Technology
*
* Export of this software from the United States of America is assumed
* to require a specific license from the United States Government.
* It is the responsibility of any person or organization contemplating
* export to obtain such a license before exporting.
*
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
* distribute this software and its documentation for any purpose and
* without fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation, and that
* the name of M.I.T. not be used in advertising or publicity pertaining
* to distribution of the software without specific, written prior
* permission. M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is" without express
* or implied warranty.
*/
#if !defined(P)
#ifdef __STDC__
#define P(x) x
#else
#define P(x) ()
#endif
#endif
#if defined(AUTHENTICATION)
Authenticator *findauthenticator P((int, int));
void auth_init P((char *, int));
int auth_cmd P((int, char **));
void auth_request P((void));
void auth_send P((unsigned char *, int));
void auth_send_retry P((void));
void auth_is P((unsigned char *, int));
void auth_reply P((unsigned char *, int));
void auth_finished P((Authenticator *, int));
int auth_wait P((char *));
void auth_disable_name P((char *));
void auth_gen_printsub P((unsigned char *, int, unsigned char *, int));
#ifdef UNSAFE
int unsafe_init P((Authenticator *, int));
int unsafe_send P((Authenticator *));
void unsafe_is P((Authenticator *, unsigned char *, int));
void unsafe_reply P((Authenticator *, unsigned char *, int));
int unsafe_status P((Authenticator *, char *, int));
void unsafe_printsub P((unsigned char *, int, unsigned char *, int));
#endif
#ifdef SRA
int sra_init P((Authenticator *, int));
int sra_send P((Authenticator *));
void sra_is P((Authenticator *, unsigned char *, int));
void sra_reply P((Authenticator *, unsigned char *, int));
int sra_status P((Authenticator *, char *, int));
void sra_printsub P((unsigned char *, int, unsigned char *, int));
#endif
#ifdef KRB4
int kerberos4_init P((Authenticator *, int));
int kerberos4_send P((Authenticator *));
void kerberos4_is P((Authenticator *, unsigned char *, int));
void kerberos4_reply P((Authenticator *, unsigned char *, int));
int kerberos4_status P((Authenticator *, char *, int));
void kerberos4_printsub P((unsigned char *, int, unsigned char *, int));
#endif
#ifdef KRB5
int kerberos5_init P((Authenticator *, int));
int kerberos5_send P((Authenticator *));
void kerberos5_is P((Authenticator *, unsigned char *, int));
void kerberos5_reply P((Authenticator *, unsigned char *, int));
int kerberos5_status P((Authenticator *, char *, int));
void kerberos5_printsub P((unsigned char *, int, unsigned char *, int));
#endif
#endif

View File

@@ -0,0 +1,87 @@
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)auth.h 8.1 (Berkeley) 6/4/93
*/
/*
* Copyright (C) 1990 by the Massachusetts Institute of Technology
*
* Export of this software from the United States of America is assumed
* to require a specific license from the United States Government.
* It is the responsibility of any person or organization contemplating
* export to obtain such a license before exporting.
*
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
* distribute this software and its documentation for any purpose and
* without fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation, and that
* the name of M.I.T. not be used in advertising or publicity pertaining
* to distribution of the software without specific, written prior
* permission. M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is" without express
* or implied warranty.
*/
#ifndef __AUTH__
#define __AUTH__
#define AUTH_REJECT 0 /* Rejected */
#define AUTH_UNKNOWN 1 /* We don't know who he is, but he's okay */
#define AUTH_OTHER 2 /* We know him, but not his name */
#define AUTH_USER 3 /* We know he name */
#define AUTH_VALID 4 /* We know him, and he needs no password */
#if !defined(P)
#ifdef __STDC__
#define P(x) x
#else
#define P(x) ()
#endif
#endif
typedef struct XauthP {
int type;
int way;
int (*init) P((struct XauthP *, int));
int (*send) P((struct XauthP *));
void (*is) P((struct XauthP *, unsigned char *, int));
void (*reply) P((struct XauthP *, unsigned char *, int));
int (*status) P((struct XauthP *, char *, int));
void (*printsub) P((unsigned char *, int, unsigned char *, int));
} Authenticator;
#include "auth-proto.h"
extern auth_debug_mode;
#endif

View File

@@ -0,0 +1,121 @@
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)enc-proto.h 8.1 (Berkeley) 6/4/93
*
* @(#)enc-proto.h 5.2 (Berkeley) 3/22/91
*/
/*
* Copyright (C) 1990 by the Massachusetts Institute of Technology
*
* Export of this software from the United States of America is assumed
* to require a specific license from the United States Government.
* It is the responsibility of any person or organization contemplating
* export to obtain such a license before exporting.
*
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
* distribute this software and its documentation for any purpose and
* without fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation, and that
* the name of M.I.T. not be used in advertising or publicity pertaining
* to distribution of the software without specific, written prior
* permission. M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is" without express
* or implied warranty.
*/
#if !defined(P)
#ifdef __STDC__
#define P(x) x
#else
#define P(x) ()
#endif
#endif
#if defined(ENCRYPTION)
void encrypt_init P((char *, int));
Encryptions *findencryption P((int));
void encrypt_send_supprt P((void));
void encrypt_auto P((int));
void decrypt_auto P((int));
void encrypt_is P((unsigned char *, int));
void encrypt_reply P((unsigned char *, int));
void encrypt_start_input P((int));
void encrypt_session_key P((Session_Key *, int));
void encrypt_end_input P((void));
void encrypt_start_output P((int));
void encrypt_end_output P((void));
void encrypt_send_request_start P((void));
void encrypt_send_request_end P((void));
void encrypt_send_end P((void));
void encrypt_wait P((void));
void encrypt_send_support P((void));
void encrypt_send_keyid P((int, unsigned char *, int, int));
int net_write P((unsigned char *, int));
#ifdef TELENTD
void encrypt_wait P((void));
#else
int encrypt_cmd P((int, char **));
void encrypt_display P((void));
#endif
void cfb64_encrypt P((unsigned char *, int));
int cfb64_decrypt P((int));
void cfb64_init P((int));
int cfb64_start P((int, int));
int cfb64_is P((unsigned char *, int));
int cfb64_reply P((unsigned char *, int));
void cfb64_session P((Session_Key *, int));
int cfb64_keyid P((int, unsigned char *, int *));
void cfb64_printsub P((unsigned char *, int, unsigned char *, int));
void ofb64_encrypt P((unsigned char *, int));
int ofb64_decrypt P((int));
void ofb64_init P((int));
int ofb64_start P((int, int));
int ofb64_is P((unsigned char *, int));
int ofb64_reply P((unsigned char *, int));
void ofb64_session P((Session_Key *, int));
int ofb64_keyid P((int, unsigned char *, int *));
void ofb64_printsub P((unsigned char *, int, unsigned char *, int));
#if OLD
int des_new_random_key P((Block));
void des_set_random_generator_seed P((Block));
void des_key_sched P((Block, Schedule));
void des_ecb_encrypt P((Block, Block, Schedule, int));
int des_string_to_key P((char *, Block));
#endif
#endif

View File

@@ -0,0 +1,109 @@
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)encrypt.h 8.1 (Berkeley) 6/4/93
*
* @(#)encrypt.h 5.2 (Berkeley) 3/22/91
*/
/*
* Copyright (C) 1990 by the Massachusetts Institute of Technology
*
* Export of this software from the United States of America is assumed
* to require a specific license from the United States Government.
* It is the responsibility of any person or organization contemplating
* export to obtain such a license before exporting.
*
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
* distribute this software and its documentation for any purpose and
* without fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation, and that
* the name of M.I.T. not be used in advertising or publicity pertaining
* to distribution of the software without specific, written prior
* permission. M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is" without express
* or implied warranty.
*/
#ifndef __ENCRYPT__
#define __ENCRYPT__
#define DIR_DECRYPT 1
#define DIR_ENCRYPT 2
typedef unsigned char Block[8];
typedef unsigned char *BlockT;
typedef struct { Block _B; } Schedule[16];
#define VALIDKEY(key) ( key[0] | key[1] | key[2] | key[3] | \
key[4] | key[5] | key[6] | key[7])
#define SAMEKEY(k1, k2) (!bcmp((void *)k1, (void *)k2, sizeof(Block)))
typedef struct {
short type;
int length;
unsigned char *data;
} Session_Key;
#if !defined(P)
#ifdef __STDC__
#define P(x) x
#else
#define P(x) ()
#endif
#endif
typedef struct {
char *name;
int type;
void (*output) P((unsigned char *, int));
int (*input) P((int));
void (*init) P((int));
int (*start) P((int, int));
int (*is) P((unsigned char *, int));
int (*reply) P((unsigned char *, int));
void (*session) P((Session_Key *, int));
int (*keyid) P((int, unsigned char *, int *));
void (*printsub) P((unsigned char *, int, unsigned char *, int));
} Encryptions;
#define SK_DES 1 /* Matched Kerberos v5 KEYTYPE_DES */
#include "enc-proto.h"
extern int encrypt_debug_mode;
extern int (*decrypt_input) P((int));
extern void (*encrypt_output) P((unsigned char *, int));
#endif

View File

@@ -0,0 +1,636 @@
/*
* $Source$
* $Id$
*/
#ifndef lint
static char *rcsid_forward_c =
"$Id$";
#endif /* lint */
#define LIBC_SCCS
/*-
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef lint
static char sccsid[] = "@(#)forward.c 8.2 (Berkeley) 5/30/95";
#endif /* not lint */
/* General-purpose forwarding routines. These routines may be put into */
/* libkrb5.a to allow widespread use */
#if defined(KRB5) && defined(FORWARD)
#include <stdio.h>
#include <pwd.h>
#include <netdb.h>
#include <krb5/krb5.h>
#include <krb5/asn1.h>
#include <krb5/crc-32.h>
#include <krb5/los-proto.h>
#include <krb5/ext-proto.h>
#define KRB5_DEFAULT_LIFE 60*60*8 /* 8 hours */
/* helper function: convert flags to necessary KDC options */
#define flags2options(flags) (flags & KDC_TKT_COMMON_MASK)
/* Get a TGT for use at the remote host */
krb5_error_code
get_for_creds(etype, sumtype, rhost, client, enc_key, forwardable, outbuf)
const krb5_enctype etype;
const krb5_cksumtype sumtype;
char *rhost;
krb5_principal client;
krb5_keyblock *enc_key;
int forwardable; /* Should forwarded TGT also be forwardable? */
krb5_data *outbuf;
{
struct hostent *hp;
krb5_address **addrs;
krb5_error_code retval;
krb5_data *scratch;
krb5_kdc_rep *dec_rep;
krb5_error *err_reply;
krb5_response tgsrep;
krb5_creds creds, tgt;
krb5_ccache cc;
krb5_flags kdcoptions;
krb5_timestamp now;
char *remote_host;
char **hrealms;
int i;
if (!rhost || !(hp = gethostbyname(rhost)))
return KRB5_ERR_BAD_HOSTNAME;
remote_host = (char *) malloc(strlen(hp->h_name)+1);
if (!remote_host)
return ENOMEM;
strcpy(remote_host, hp->h_name);
if (retval = krb5_get_host_realm(remote_host, &hrealms)) {
free(remote_host);
return retval;
}
if (!hrealms[0]) {
free(remote_host);
krb5_xfree(hrealms);
return KRB5_ERR_HOST_REALM_UNKNOWN;
}
/* Count elements */
for(i=0; hp->h_addr_list[i]; i++);
addrs = (krb5_address **) malloc ((i+1)*sizeof(*addrs));
if (!addrs)
return ENOMEM;
for(i=0; hp->h_addr_list[i]; i++) {
addrs[i] = (krb5_address *) malloc(sizeof(krb5_address));
if (addrs[i]) {
addrs[i]->addrtype = hp->h_addrtype;
addrs[i]->length = hp->h_length;
addrs[i]->contents = (unsigned char *)malloc(addrs[i]->length);
if (!addrs[i]->contents) {
krb5_free_addresses(addrs);
return ENOMEM;
}
else
memmove ((char *)addrs[i]->contents, hp->h_addr_list[i],
addrs[i]->length);
}
else {
return ENOMEM;
}
}
addrs[i] = 0;
memset((char *)&creds, 0, sizeof(creds));
if (retval = krb5_copy_principal(client, &creds.client))
return retval;
if (retval = krb5_build_principal_ext(&creds.server,
strlen(hrealms[0]),
hrealms[0],
KRB5_TGS_NAME_SIZE,
KRB5_TGS_NAME,
client->realm.length,
client->realm.data,
0))
return retval;
creds.times.starttime = 0;
if (retval = krb5_timeofday(&now)) {
return retval;
}
creds.times.endtime = now + KRB5_DEFAULT_LIFE;
creds.times.renew_till = 0;
if (retval = krb5_cc_default(&cc)) {
return retval;
}
/* fetch tgt directly from cache */
if (retval = krb5_cc_retrieve_cred (cc,
KRB5_TC_MATCH_SRV_NAMEONLY,
&creds,
&tgt)) {
return retval;
}
/* tgt->client must be equal to creds.client */
if (!krb5_principal_compare(tgt.client, creds.client))
return KRB5_PRINC_NOMATCH;
if (!tgt.ticket.length)
return(KRB5_NO_TKT_SUPPLIED);
kdcoptions = flags2options(tgt.ticket_flags)|KDC_OPT_FORWARDED;
if (!forwardable) /* Reset KDC_OPT_FORWARDABLE */
kdcoptions &= ~(KDC_OPT_FORWARDABLE);
if (retval = krb5_send_tgs(kdcoptions, &creds.times, etype, sumtype,
creds.server,
addrs,
creds.authdata,
0, /* no padata */
0, /* no second ticket */
&tgt, &tgsrep))
return retval;
#undef cleanup
#define cleanup() free(tgsrep.response.data)
switch (tgsrep.message_type) {
case KRB5_TGS_REP:
break;
case KRB5_ERROR:
default:
if (!krb5_is_krb_error(&tgsrep.response)) {
retval = KRB5KRB_AP_ERR_MSG_TYPE;
} else
retval = decode_krb5_error(&tgsrep.response, &err_reply);
if (retval) {
cleanup();
return retval; /* neither proper reply nor error! */
}
retval = err_reply->error + ERROR_TABLE_BASE_krb5;
krb5_free_error(err_reply);
cleanup();
return retval;
}
retval = krb5_decode_kdc_rep(&tgsrep.response,
&tgt.keyblock,
etype, /* enctype */
&dec_rep);
cleanup();
if (retval)
return retval;
#undef cleanup
#define cleanup() {\
memset((char *)dec_rep->enc_part2->session->contents, 0,\
dec_rep->enc_part2->session->length);\
krb5_free_kdc_rep(dec_rep); }
if (dec_rep->msg_type != KRB5_TGS_REP) {
retval = KRB5KRB_AP_ERR_MSG_TYPE;
cleanup();
return retval;
}
/* now it's decrypted and ready for prime time */
if (!krb5_principal_compare(dec_rep->client, tgt.client)) {
cleanup();
return KRB5_KDCREP_MODIFIED;
}
if (retval = mk_cred(dec_rep,
etype,
enc_key,
0,
0,
outbuf))
return retval;
krb5_free_kdc_rep(dec_rep);
return retval;
#undef cleanup
}
/* Create asn.1 encoded KRB-CRED message from the kdc reply. */
krb5_error_code
mk_cred(dec_rep, etype, key, sender_addr, recv_addr, outbuf)
krb5_kdc_rep *dec_rep;
krb5_enctype etype;
krb5_keyblock *key;
krb5_address *sender_addr;
krb5_address *recv_addr;
krb5_data *outbuf;
{
krb5_error_code retval;
krb5_encrypt_block eblock;
krb5_cred ret_cred;
krb5_cred_enc_part cred_enc_part;
krb5_data *scratch;
if (!valid_etype(etype))
return KRB5_PROG_ETYPE_NOSUPP;
ret_cred.tickets = (krb5_ticket **) calloc(2, sizeof(*ret_cred.tickets));
if (!ret_cred.tickets)
return ENOMEM;
ret_cred.tickets[0] = dec_rep->ticket;
ret_cred.tickets[1] = 0;
ret_cred.enc_part.etype = etype;
ret_cred.enc_part.kvno = 0;
cred_enc_part.ticket_info = (krb5_cred_info **)
calloc(2, sizeof(*cred_enc_part.ticket_info));
if (!cred_enc_part.ticket_info) {
krb5_free_tickets(ret_cred.tickets);
return ENOMEM;
}
cred_enc_part.ticket_info[0] = (krb5_cred_info *)
malloc(sizeof(*cred_enc_part.ticket_info[0]));
if (!cred_enc_part.ticket_info[0]) {
krb5_free_tickets(ret_cred.tickets);
krb5_free_cred_enc_part(cred_enc_part);
return ENOMEM;
}
cred_enc_part.nonce = 0;
if (retval = krb5_us_timeofday(&cred_enc_part.timestamp,
&cred_enc_part.usec))
return retval;
cred_enc_part.s_address = (krb5_address *)sender_addr;
cred_enc_part.r_address = (krb5_address *)recv_addr;
cred_enc_part.ticket_info[0]->session = dec_rep->enc_part2->session;
cred_enc_part.ticket_info[0]->client = dec_rep->client;
cred_enc_part.ticket_info[0]->server = dec_rep->enc_part2->server;
cred_enc_part.ticket_info[0]->flags = dec_rep->enc_part2->flags;
cred_enc_part.ticket_info[0]->times = dec_rep->enc_part2->times;
cred_enc_part.ticket_info[0]->caddrs = dec_rep->enc_part2->caddrs;
cred_enc_part.ticket_info[1] = 0;
/* start by encoding to-be-encrypted part of the message */
if (retval = encode_krb5_enc_cred_part(&cred_enc_part, &scratch))
return retval;
#define cleanup_scratch() { (void) memset(scratch->data, 0, scratch->length); krb5_free_data(scratch); }
/* put together an eblock for this encryption */
krb5_use_cstype(&eblock, etype);
ret_cred.enc_part.ciphertext.length = krb5_encrypt_size(scratch->length,
eblock.crypto_entry);
/* add padding area, and zero it */
if (!(scratch->data = realloc(scratch->data,
ret_cred.enc_part.ciphertext.length))) {
/* may destroy scratch->data */
krb5_xfree(scratch);
return ENOMEM;
}
memset(scratch->data + scratch->length, 0,
ret_cred.enc_part.ciphertext.length - scratch->length);
if (!(ret_cred.enc_part.ciphertext.data =
malloc(ret_cred.enc_part.ciphertext.length))) {
retval = ENOMEM;
goto clean_scratch;
}
#define cleanup_encpart() {\
(void) memset(ret_cred.enc_part.ciphertext.data, 0, \
ret_cred.enc_part.ciphertext.length); \
free(ret_cred.enc_part.ciphertext.data); \
ret_cred.enc_part.ciphertext.length = 0; \
ret_cred.enc_part.ciphertext.data = 0;}
/* do any necessary key pre-processing */
if (retval = krb5_process_key(&eblock, key)) {
goto clean_encpart;
}
#define cleanup_prockey() {(void) krb5_finish_key(&eblock);}
/* call the encryption routine */
if (retval = krb5_encrypt((krb5_pointer) scratch->data,
(krb5_pointer)
ret_cred.enc_part.ciphertext.data,
scratch->length, &eblock,
0)) {
goto clean_prockey;
}
/* private message is now assembled-- do some cleanup */
cleanup_scratch();
if (retval = krb5_finish_key(&eblock)) {
cleanup_encpart();
return retval;
}
/* encode private message */
if (retval = encode_krb5_cred(&ret_cred, &scratch)) {
cleanup_encpart();
return retval;
}
cleanup_encpart();
*outbuf = *scratch;
krb5_xfree(scratch);
return 0;
clean_prockey:
cleanup_prockey();
clean_encpart:
cleanup_encpart();
clean_scratch:
cleanup_scratch();
return retval;
#undef cleanup_prockey
#undef cleanup_encpart
#undef cleanup_scratch
}
/* Decode, decrypt and store the forwarded creds in the local ccache. */
krb5_error_code
rd_and_store_for_creds(inbuf, ticket, lusername)
krb5_data *inbuf;
krb5_ticket *ticket;
char *lusername;
{
krb5_encrypt_block eblock;
krb5_creds creds;
krb5_error_code retval;
char ccname[35];
krb5_ccache ccache = NULL;
struct passwd *pwd;
if (retval = rd_cred(inbuf, ticket->enc_part2->session,
&creds, 0, 0)) {
return(retval);
}
if (!(pwd = (struct passwd *) getpwnam(lusername))) {
return -1;
}
sprintf(ccname, "FILE:/tmp/krb5cc_%d", pwd->pw_uid);
if (retval = krb5_cc_resolve(ccname, &ccache)) {
return(retval);
}
if (retval = krb5_cc_initialize(ccache,
ticket->enc_part2->client)) {
return(retval);
}
if (retval = krb5_cc_store_cred(ccache, &creds)) {
return(retval);
}
if (retval = chown(ccname+5, pwd->pw_uid, -1)) {
return(retval);
}
return retval;
}
extern krb5_deltat krb5_clockskew;
#define in_clock_skew(date) (abs((date)-currenttime) < krb5_clockskew)
/* Decode the KRB-CRED message, and return creds */
krb5_error_code
rd_cred(inbuf, key, creds, sender_addr, recv_addr)
const krb5_data *inbuf;
const krb5_keyblock *key;
krb5_creds *creds; /* Filled in */
const krb5_address *sender_addr; /* optional */
const krb5_address *recv_addr; /* optional */
{
krb5_error_code retval;
krb5_encrypt_block eblock;
krb5_cred *credmsg;
krb5_cred_enc_part *credmsg_enc_part;
krb5_data *scratch;
krb5_timestamp currenttime;
if (!krb5_is_krb_cred(inbuf))
return KRB5KRB_AP_ERR_MSG_TYPE;
/* decode private message */
if (retval = decode_krb5_cred(inbuf, &credmsg)) {
return retval;
}
#define cleanup_credmsg() {(void)krb5_xfree(credmsg->enc_part.ciphertext.data); (void)krb5_xfree(credmsg);}
if (!(scratch = (krb5_data *) malloc(sizeof(*scratch)))) {
cleanup_credmsg();
return ENOMEM;
}
#define cleanup_scratch() {(void)memset(scratch->data, 0, scratch->length); (void)krb5_xfree(scratch->data);}
if (retval = encode_krb5_ticket(credmsg->tickets[0], &scratch)) {
cleanup_credmsg();
cleanup_scratch();
return(retval);
}
creds->ticket = *scratch;
if (!(creds->ticket.data = malloc(scratch->length))) {
krb5_xfree(creds->ticket.data);
return ENOMEM;
}
memmove((char *)creds->ticket.data, (char *) scratch->data, scratch->length);
cleanup_scratch();
if (!valid_etype(credmsg->enc_part.etype)) {
cleanup_credmsg();
return KRB5_PROG_ETYPE_NOSUPP;
}
/* put together an eblock for this decryption */
krb5_use_cstype(&eblock, credmsg->enc_part.etype);
scratch->length = credmsg->enc_part.ciphertext.length;
if (!(scratch->data = malloc(scratch->length))) {
cleanup_credmsg();
return ENOMEM;
}
/* do any necessary key pre-processing */
if (retval = krb5_process_key(&eblock, key)) {
cleanup_credmsg();
cleanup_scratch();
return retval;
}
#define cleanup_prockey() {(void) krb5_finish_key(&eblock);}
/* call the decryption routine */
if (retval = krb5_decrypt((krb5_pointer) credmsg->enc_part.ciphertext.data,
(krb5_pointer) scratch->data,
scratch->length, &eblock,
0)) {
cleanup_credmsg();
cleanup_scratch();
cleanup_prockey();
return retval;
}
/* cred message is now decrypted -- do some cleanup */
cleanup_credmsg();
if (retval = krb5_finish_key(&eblock)) {
cleanup_scratch();
return retval;
}
/* now decode the decrypted stuff */
if (retval = decode_krb5_enc_cred_part(scratch, &credmsg_enc_part)) {
cleanup_scratch();
return retval;
}
cleanup_scratch();
#define cleanup_mesg() {(void)krb5_xfree(credmsg_enc_part);}
if (retval = krb5_timeofday(&currenttime)) {
cleanup_mesg();
return retval;
}
if (!in_clock_skew(credmsg_enc_part->timestamp)) {
cleanup_mesg();
return KRB5KRB_AP_ERR_SKEW;
}
if (sender_addr && credmsg_enc_part->s_address &&
!krb5_address_compare(sender_addr,
credmsg_enc_part->s_address)) {
cleanup_mesg();
return KRB5KRB_AP_ERR_BADADDR;
}
if (recv_addr && credmsg_enc_part->r_address &&
!krb5_address_compare(recv_addr,
credmsg_enc_part->r_address)) {
cleanup_mesg();
return KRB5KRB_AP_ERR_BADADDR;
}
if (credmsg_enc_part->r_address) {
krb5_address **our_addrs;
if (retval = krb5_os_localaddr(&our_addrs)) {
cleanup_mesg();
return retval;
}
if (!krb5_address_search(credmsg_enc_part->r_address,
our_addrs)) {
krb5_free_addresses(our_addrs);
cleanup_mesg();
return KRB5KRB_AP_ERR_BADADDR;
}
krb5_free_addresses(our_addrs);
}
if (retval = krb5_copy_principal(credmsg_enc_part->ticket_info[0]->client,
&creds->client)) {
return(retval);
}
if (retval = krb5_copy_principal(credmsg_enc_part->ticket_info[0]->server,
&creds->server)) {
return(retval);
}
if (retval =
krb5_copy_keyblock_contents(credmsg_enc_part->ticket_info[0]->session,
&creds->keyblock)) {
return(retval);
}
#undef clean
#define clean() {\
memset((char *)creds->keyblock.contents, 0, creds->keyblock.length);}
creds->times = credmsg_enc_part->ticket_info[0]->times;
creds->is_skey = FALSE;
creds->ticket_flags = credmsg_enc_part->ticket_info[0]->flags;
if (retval = krb5_copy_addresses(credmsg_enc_part->ticket_info[0]->caddrs,
&creds->addresses)) {
clean();
return(retval);
}
creds->second_ticket.length = 0;
creds->authdata = 0;
cleanup_mesg();
return 0;
#undef clean
#undef cleanup_credmsg
#undef cleanup_scratch
#undef cleanup_prockey
#undef cleanup_mesg
}
#endif /* defined(KRB5) && defined(FORWARD) */

View File

@@ -0,0 +1,105 @@
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef lint
static char sccsid[] = "@(#)genget.c 8.2 (Berkeley) 5/30/95";
#endif /* not lint */
#include <ctype.h>
#define LOWER(x) (isupper(x) ? tolower(x) : (x))
/*
* The prefix function returns 0 if *s1 is not a prefix
* of *s2. If *s1 exactly matches *s2, the negative of
* the length is returned. If *s1 is a prefix of *s2,
* the length of *s1 is returned.
*/
int
isprefix(s1, s2)
register char *s1, *s2;
{
register int n = 0;
char *os1;
register char c1, c2;
if (*s1 == '\0')
return(-1);
os1 = s1;
c1 = *s1;
c2 = *s2;
while (LOWER(c1) == LOWER(c2)) {
if (c1 == '\0')
break;
c1 = *++s1;
c2 = *++s2;
}
return(*s1 ? 0 : (*s2 ? (s1 - os1) : (os1 - s1)));
}
static char *ambiguous; /* special return value for command routines */
char **
genget(name, table, stlen)
char *name; /* name to match */
char **table; /* name entry in table */
int stlen;
{
register char **c, **found;
register int n;
if (name == 0)
return 0;
found = 0;
for (c = table; *c != 0; c = (char **)((char *)c + stlen)) {
if ((n = isprefix(name, *c)) == 0)
continue;
if (n < 0) /* exact match */
return(c);
if (found)
return(&ambiguous);
found = c;
}
return(found);
}
/*
* Function call version of Ambiguous()
*/
int
Ambiguous(s)
char *s;
{
return((char **)s == &ambiguous);
}

View File

@@ -0,0 +1,71 @@
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)key-proto.h 8.1 (Berkeley) 6/4/93
*/
/*
* Copyright (C) 1990 by the Massachusetts Institute of Technology
*
* Export of this software from the United States of America is assumed
* to require a specific license from the United States Government.
* It is the responsibility of any person or organization contemplating
* export to obtain such a license before exporting.
*
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
* distribute this software and its documentation for any purpose and
* without fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation, and that
* the name of M.I.T. not be used in advertising or publicity pertaining
* to distribution of the software without specific, written prior
* permission. M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is" without express
* or implied warranty.
*/
#ifndef __KEY_PROTO__
#define __KEY_PROTO__
#if !defined(P)
#ifdef __STDC__
#define P(x) x
#else
#define P(x) ()
#endif
#endif
int key_file_exists P((void));
void key_lookup P((unsigned char *, Block));
void key_stream_init P((Block, Block, int));
unsigned char key_stream P((int, int));
#endif

View File

@@ -0,0 +1,42 @@
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)misc.h 8.1 (Berkeley) 6/4/93
*/
extern char *UserNameRequested;
extern char *LocalHostName;
extern char *RemoteHostName;
extern int ConnectedCount;
extern int ReservedPort;
#include "misc-proto.h"

View File

@@ -0,0 +1,41 @@
/*
* The routine parsetos() for UNICOS 6.0/6.1 systems. This
* is part of UNICOS 7.0 and later.
*/
#include <stdio.h>
#include <sys/types.h>
#include <netdb.h>
#include <errno.h>
#define MIN_TOS 0
#define MAX_TOS 255
int
parsetos(name, proto)
char *name;
char *proto;
{
register char *c;
int tos;
struct tosent *tosp;
tosp = gettosbyname(name, proto);
if (tosp) {
tos = tosp->t_tos;
} else {
for (c = name; *c; c++) {
if (*c < '0' || *c > '9') {
errno = EINVAL;
return (-1);
}
}
tos = (int)strtol(name, (char **)NULL, 0);
}
if (tos < MIN_TOS || tos > MAX_TOS) {
errno = ERANGE;
return (-1);
}
return (tos);
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)setsid.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
/*
* Emulate the functionality of setsid(), called when forking
* and execing the new process.
*/
extern char *line;
setsid()
{
#ifndef convex
if (setpgrp(0, 0) < 0)
return(-1);
#endif
return(0);
}

72
appl/telnet/stty.diff Normal file
View File

@@ -0,0 +1,72 @@
*** stty.c.old Tue May 23 13:54:29 1989
--- stty.c Wed Aug 23 13:42:32 1989
***************
*** 20,25 ****
--- 20,28 ----
#include <stdio.h>
#include <sys/ioctl.h>
+ #include <sys/types.h>
+ #define NO_T_CHARS_DEFINES
+ #include <sys/tty.h>
struct
{
***************
*** 145,150 ****
--- 148,156 ----
struct winsize win;
int lmode;
int oldisc, ldisc;
+ #ifdef TIOCGSTATE
+ int extproc;
+ #endif
struct special {
char *name;
***************
*** 188,193 ****
--- 194,203 ----
ioctl(1, TIOCLGET, &lmode);
ioctl(1, TIOCGLTC, &ltc);
ioctl(1, TIOCGWINSZ, &win);
+ #ifdef TIOCGSTATE
+ ioctl(1, TIOCGSTATE, &extproc);
+ extproc &= TS_EXTPROC;
+ #endif
if(argc == 1) {
prmodes(0);
exit(0);
***************
*** 292,297 ****
--- 302,316 ----
printf("%d %d\n", win.ws_row, win.ws_col);
exit(0);
}
+ #if defined(TIOCEXT)
+ if (eq("extproc") || eq("-extproc")) {
+ if (**argv == '-')
+ extproc = 0;
+ else
+ extproc = 1;
+ ioctl(1, TIOCEXT, &extproc);
+ }
+ #endif
for(i=0; speeds[i].string; i++)
if(eq(speeds[i].string)) {
mode.sg_ispeed = mode.sg_ospeed = speeds[i].speed;
***************
*** 438,443 ****
--- 457,468 ----
lpit(LPENDIN, "-pendin ");
lpit(LDECCTQ, "-decctlq ");
lpit(LNOFLSH, "-noflsh ");
+ #ifdef TIOCGSTATE
+ if (all==2||extproc) {
+ fprintf(stderr,"-extproc"+(extproc!=0));
+ any++;
+ }
+ #endif
if (any || nothing)
fprintf(stderr,"\n");
} else if (!all)

80
appl/telnet/telnet.state Normal file
View File

@@ -0,0 +1,80 @@
Three pieces of state need to be kept for each side of each option.
(You need the localside, sending WILL/WONT & receiving DO/DONT, and
the remoteside, sending DO/DONT and receiving WILL/WONT)
MY_STATE: What state am I in?
WANT_STATE: What state do I want?
WANT_RESP: How many requests have I initiated?
Default values:
MY_STATE = WANT_STATE = DONT
WANT_RESP = 0
The local setup will change based on the state of the Telnet
variables. When we are the originator, we can either make the
local setup changes at option request time (in which case if
the option is denied we need to change things back) or when
the option is acknowledged.
To initiate a switch to NEW_STATE:
if ((WANT_RESP == 0 && NEW_STATE == MY_STATE) ||
WANT_STATE == NEW_STATE) {
do nothing;
} else {
/*
* This is where the logic goes to change the local setup
* if we are doing so at request initiation
*/
WANT_STATE = NEW_STATE;
send NEW_STATE;
WANT_RESP += 1;
}
When receiving NEW_STATE:
if (WANT_RESP) {
--WANT_RESP;
if (WANT_RESP && (NEW_STATE == MY_STATE))
--WANT_RESP;
}
if (WANT_RESP == 0) {
if (NEW_STATE != WANT_STATE) {
/*
* This is where the logic goes to decide if it is ok
* to switch to NEW_STATE, and if so, do any necessary
* local setup changes.
*/
if (ok_to_switch_to NEW_STATE)
WANT_STATE = NEW_STATE;
else
WANT_RESP++;
* if (MY_STATE != WANT_STATE)
reply with WANT_STATE;
} else {
/*
* This is where the logic goes to change the local setup
* if we are doing so at request acknowledgment
*/
}
}
MY_STATE = NEW_STATE;
* This if() line is not needed, it should be ok to always do the
"reply with WANT_STATE". With the if() line, asking to turn on
an option that the other side doesn't understand is:
Send DO option
Recv WONT option
Without the if() line, it is:
Send DO option
Recv WONT option
Send DONT option
If the other side does not expect to receive the latter case,
but generates the latter case, then there is a potential for
option negotiation loops. An implementation that does not expect
to get the second case should not generate it, an implementation
that does expect to get it may or may not generate it, and things
will still work. Being conservative in what we send, we have the
if() statement in, but we expect the other side to generate the
last response.

View File

@@ -0,0 +1,73 @@
#
# Copyright (c) 1990 The Regents of the University of California.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the University of
# California, Berkeley and its contributors.
# 4. Neither the name of the University nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# @(#)Makefile 8.1 (Berkeley) 6/6/93
#
PROG= telnet
CFLAGS+=-DTERMCAP -DKLUDGELINEMODE -DUSE_TERMIO -DAUTHENTICATION -DENCRYPTION
CFLAGS+=-DENV_HACK
CFLAGS+=-I${.CURDIR}/../../lib
CFLAGS+= -DKRB4
LDADD= -ltermcap -ltelnet
LDADD+= -lkrb -ldes
DPADD= ${LIBTERMCAP}
SRCS= authenc.c commands.c main.c network.c ring.c sys_bsd.c telnet.c \
terminal.c tn3270.c utilities.c
# These are the sources that have encryption stuff in them.
CRYPT_SRC= authenc.c commands.c externs.h main.c network.c
CRYPT_SRC+= ring.c ring.h telnet.c terminal.c utilities.c Makefile
NOCRYPT_DIR=${.CURDIR}/Nocrypt
.include <bsd.prog.mk>
nocrypt:
#ifdef ENCRYPTION
@for i in ${CRYPT_SRC}; do \
if [ ! -d ${NOCRYPT_DIR} ]; then \
echo Creating subdirectory ${NOCRYPT_DIR}; \
mkdir ${NOCRYPT_DIR}; \
fi; \
echo ${NOCRYPT_DIR}/$$i; \
unifdef -UENCRYPTION ${.CURDIR}/$$i | \
sed "s/ || defined(ENCRYPTION)//" > ${NOCRYPT_DIR}/$$i; \
done
placeholder:
#else /* ENCRYPTION */
@echo "Encryption code already removed."
#endif /* ENCRYPTION */

View File

@@ -0,0 +1,45 @@
#
# Copyright (c) 1991 The Regents of the University of California.
# All rights reserved.
#
# Redistribution and use in source and binary forms are permitted provided
# that: (1) source distributions retain this entire copyright notice and
# comment, and (2) distributions including binaries display the following
# acknowledgement: ``This product includes software developed by the
# University of California, Berkeley and its contributors'' in the
# documentation or other materials provided with the distribution and in
# all advertising materials mentioning features or use of this software.
# Neither the name of the University nor the names of its contributors may
# be used to endorse or promote products derived from this software without
# specific prior written permission.
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# @(#)Makefile 5.5 (Berkeley) 3/1/91
#
#
# Everything happens in ../Makefile.config and Makefile.generic
#
SHELL=/bin/sh
all:
@-if test -f ../Config.local; \
then \
echo make -f ../Config.local WHAT=${WHAT} CC="${CC}"; \
make -f ../Config.local WHAT=${WHAT} CC="${CC}"; \
else \
echo make -f ../Config.generic WHAT=${WHAT} CC="${CC}"; \
make -f ../Config.generic WHAT=${WHAT} CC="${CC}"; \
fi
.DEFAULT:
@-if test -f ../Config.local; \
then \
echo make -f ../Config.local WHAT=${WHAT} CC="${CC}" $@; \
make -f ../Config.local WHAT=${WHAT} CC="${CC}" $@; \
else \
echo make -f ../Config.generic WHAT=${WHAT} CC="${CC}" $@; \
make -f ../Config.generic WHAT=${WHAT} CC="${CC}" $@; \
fi

View File

@@ -0,0 +1,89 @@
#
# Copyright (c) 1991 The Regents of the University of California.
# All rights reserved.
#
# Redistribution and use in source and binary forms are permitted provided
# that: (1) source distributions retain this entire copyright notice and
# comment, and (2) distributions including binaries display the following
# acknowledgement: ``This product includes software developed by the
# University of California, Berkeley and its contributors'' in the
# documentation or other materials provided with the distribution and in
# all advertising materials mentioning features or use of this software.
# Neither the name of the University nor the names of its contributors may
# be used to endorse or promote products derived from this software without
# specific prior written permission.
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# @(#)Makefile.generic 5.5 (Berkeley) 3/1/91
#
INCLUDES= -I..
ARPA_TELNET= ../arpa/telnet.h
SRCS= commands.c main.c network.c ring.c \
sys_bsd.c telnet.c terminal.c \
utilities.c ${GETOPT_SRC}
CFLAGS= ${LCCFLAGS} ${INCLUDES} ${DEFINES}
ALLHC= ${SRCS} \
defines.h externs.h fdset.h general.h \
ring.h types.h
OBJS= authenc.o commands.o main.o network.o ring.o sys_bsd.o \
telnet.o terminal.o utilities.o ${GETOPT_OBJ}
MAN= telnet.0
#
# These next three lines are not needed in 4.4BSD
#
.SUFFIXES: .0 .1
.1.0:
nroff -man -h $< > $@
all: telnet
telnet: ${OBJS} ${LIBPATH}
${CC} -o $@ ${CFLAGS} ${OBJS} ${LIBS}
clean: FRC
rm -f ${OBJS} core errs l.errs telnet
cleandir: clean
rm -f ${MAN} tags .depend
clist: FRC ${SRCS}
@for i in ${SRCS} ; \
do (echo ${DIRPATH}$$i); done
hclist: FRC ${ALLHC}
@for i in ${ALLHC} ; \
do (echo ${DIRPATH}$$i); done
depend: FRC ${SRCS}
mkdep ${CFLAGS} `make clist`
install: ${MAN} FRC
install -s -o bin -g bin -m 755 telnet ${DEST}
install -c -o bin -g bin -m 444 telnet.0 ${DESTDIR}/usr/man/cat1
lint: FRC ${SRCS}
lint ${CFLAGS} `make clist`
tags: FRC ${SRCS}
ctags `make hclist`
FRC:
authenc.o: defines.h externs.h general.h ring.h types.h ${ARPA_TELNET}
commands.o: defines.h externs.h general.h ring.h types.h ${ARPA_TELNET}
main.o: defines.h externs.h ring.h
network.o: defines.h externs.h fdset.h ring.h ${ARPA_TELNET}
ring.o: general.h ring.h
sys_bsd.o: defines.h externs.h fdset.h ring.h types.h ${ARPA_TELNET}
telnet.o: defines.h externs.h general.h ring.h types.h ${ARPA_TELNET}
terminal.o: externs.h ring.h types.h ${ARPA_TELNET}
tn3270.o: defines.h externs.h fdset.h general.h ring.h ${ARPA_TELNET}
utilities.o: defines.h externs.h fdset.h general.h ring.h ${ARPA_TELNET}

View File

@@ -0,0 +1,61 @@
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)defines.h 8.1 (Berkeley) 6/6/93
*/
#define settimer(x) clocks.x = clocks.system++
#if !defined(TN3270)
#define SetIn3270()
#endif /* !defined(TN3270) */
#define NETADD(c) { *netoring.supply = c; ring_supplied(&netoring, 1); }
#define NET2ADD(c1,c2) { NETADD(c1); NETADD(c2); }
#define NETBYTES() (ring_full_count(&netoring))
#define NETROOM() (ring_empty_count(&netoring))
#define TTYADD(c) if (!(SYNCHing||flushout)) { \
*ttyoring.supply = c; \
ring_supplied(&ttyoring, 1); \
}
#define TTYBYTES() (ring_full_count(&ttyoring))
#define TTYROOM() (ring_empty_count(&ttyoring))
/* Various modes */
#define MODE_LOCAL_CHARS(m) ((m)&(MODE_EDIT|MODE_TRAPSIG))
#define MODE_LOCAL_ECHO(m) ((m)&MODE_ECHO)
#define MODE_COMMAND_LINE(m) ((m)==-1)
#define CONTROL(x) ((x)&0x1f) /* CTRL(x) is not portable */

View File

@@ -0,0 +1,49 @@
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)fdset.h 8.1 (Berkeley) 6/6/93
*/
/*
* The following is defined just in case someone should want to run
* this telnet on a 4.2 system.
*
*/
#ifndef FD_SETSIZE
#define FD_SET(n, p) ((p)->fds_bits[0] |= (1<<(n)))
#define FD_CLR(n, p) ((p)->fds_bits[0] &= ~(1<<(n)))
#define FD_ISSET(n, p) ((p)->fds_bits[0] & (1<<(n)))
#define FD_ZERO(p) ((p)->fds_bits[0] = 0)
#endif

View File

@@ -0,0 +1,45 @@
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)general.h 8.1 (Berkeley) 6/6/93
*/
/*
* Some general definitions.
*/
#define numberof(x) (sizeof x/sizeof x[0])
#define highestof(x) (numberof(x)-1)
#define ClearElement(x) memset((char *)&x, 0, sizeof x)
#define ClearArray(x) memset((char *)x, 0, sizeof x)

View File

@@ -0,0 +1,86 @@
*** main.c 1995/09/02 12:18:50 1.5
--- main.c 1995/10/03 15:40:58
***************
*** 137,147 ****
rlogin = (strncmp(prompt, "rlog", 4) == 0) ? '~' : _POSIX_VDISABLE;
/*
! * if AUTHENTICATION and ENCRYPTION is set autologin will be
! * se to true after the getopt switch; unless the -K option is
! * passed
*/
! autologin = -1;
while ((ch = getopt(argc, argv, "8EKLS:X:acde:fFk:l:n:rt:x")) != EOF) {
switch(ch) {
--- 137,152 ----
rlogin = (strncmp(prompt, "rlog", 4) == 0) ? '~' : _POSIX_VDISABLE;
/*
! * Default is automatic authentication and encryption.
! * Use -K to dissable it and -Ka to only use authentication.
*/
! #ifdef AUTHENTICATION
! autologin = 1;
! #ifdef ENCRYPTION
! encrypt_auto(1);
! decrypt_auto(1);
! #endif
! #endif
while ((ch = getopt(argc, argv, "8EKLS:X:acde:fFk:l:n:rt:x")) != EOF) {
switch(ch) {
***************
*** 154,160 ****
--- 159,169 ----
case 'K':
#ifdef AUTHENTICATION
autologin = 0;
+ #ifdef ENCRYPTION
+ encrypt_auto(0);
+ decrypt_auto(0);
#endif
+ #endif
break;
case 'L':
eight |= 2; /* binary output only */
***************
*** 239,248 ****
#endif
break;
case 'l':
! if(autologin == 0){
! fprintf(stderr, "%s: Warning: -K ignored\n", prompt);
! autologin = -1;
! }
user = optarg;
break;
case 'n':
--- 248,254 ----
#endif
break;
case 'l':
! autologin = 1;
user = optarg;
break;
case 'n':
***************
*** 290,306 ****
/* NOTREACHED */
}
}
-
- if (autologin == -1) { /* esc@magic.fi; force */
- #if defined(AUTHENTICATION)
- autologin = 1;
- #endif
- #if defined(ENCRYPTION)
- encrypt_auto(1);
- decrypt_auto(1);
- #endif
- }
-
if (autologin == -1)
autologin = (rlogin == _POSIX_VDISABLE) ? 0 : 1;
--- 296,301 ----

105
appl/telnet/telnet/ring.h Normal file
View File

@@ -0,0 +1,105 @@
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)ring.h 8.1 (Berkeley) 6/6/93
*/
#if defined(P)
# undef P
#endif
#if defined(__STDC__) || defined(LINT_ARGS)
# define P(x) x
#else
# define P(x) ()
#endif
/*
* This defines a structure for a ring buffer.
*
* The circular buffer has two parts:
*(((
* full: [consume, supply)
* empty: [supply, consume)
*]]]
*
*/
typedef struct {
unsigned char *consume, /* where data comes out of */
*supply, /* where data comes in to */
*bottom, /* lowest address in buffer */
*top, /* highest address+1 in buffer */
*mark; /* marker (user defined) */
#if defined(ENCRYPTION)
unsigned char *clearto; /* Data to this point is clear text */
unsigned char *encryyptedto; /* Data is encrypted to here */
#endif
int size; /* size in bytes of buffer */
u_long consumetime, /* help us keep straight full, empty, etc. */
supplytime;
} Ring;
/* Here are some functions and macros to deal with the ring buffer */
/* Initialization routine */
extern int
ring_init P((Ring *ring, unsigned char *buffer, int count));
/* Data movement routines */
extern void
ring_supply_data P((Ring *ring, unsigned char *buffer, int count));
#ifdef notdef
extern void
ring_consume_data P((Ring *ring, unsigned char *buffer, int count));
#endif
/* Buffer state transition routines */
extern void
ring_supplied P((Ring *ring, int count)),
ring_consumed P((Ring *ring, int count));
/* Buffer state query routines */
extern int
ring_empty_count P((Ring *ring)),
ring_empty_consecutive P((Ring *ring)),
ring_full_count P((Ring *ring)),
ring_full_consecutive P((Ring *ring));
#if defined(ENCRYPTION)
extern void
ring_encrypt P((Ring *ring, void (*func)())),
ring_clearto P((Ring *ring));
#endif
extern void
ring_clear_mark(),
ring_mark();

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,722 @@
TELNET(1) BSD Reference Manual TELNET(1)
NNAAMMEE
tteellnneett - user interface to the TELNET protocol
SSYYNNOOPPSSIISS
tteellnneett [--88EEFFKKLLaaccddffrrxx] [--SS _t_o_s] [--XX _a_u_t_h_t_y_p_e] [--ee _e_s_c_a_p_e_c_h_a_r] [--kk _r_e_a_l_m]
[--ll _u_s_e_r] [--nn _t_r_a_c_e_f_i_l_e] [_h_o_s_t [port]]
DDEESSCCRRIIPPTTIIOONN
The tteellnneett command is used to communicate with another host using the
TELNET protocol. If tteellnneett is invoked without the _h_o_s_t argument, it en-
ters command mode, indicated by its prompt (tteellnneett>>). In this mode, it
accepts and executes the commands listed below. If it is invoked with
arguments, it performs an ooppeenn command with those arguments.
Options:
--88 Specifies an 8-bit data path. This causes an attempt to negoti-
ate the TELNET BINARY option on both input and output.
--EE Stops any character from being recognized as an escape character.
--FF If Kerberos V5 authentication is being used, the --FF option allows
the local credentials to be forwarded to the remote system, in-
cluding any credentials that have already been forwarded into the
local environment.
--KK Specifies no automatic login to the remote system.
--LL Specifies an 8-bit data path on output. This causes the BINARY
option to be negotiated on output.
--SS _t_o_s Sets the IP type-of-service (TOS) option for the telnet connec-
tion to the value _t_o_s_, which can be a numeric TOS value or, on
systems that support it, a symbolic TOS name found in the
/etc/iptos file.
--XX _a_t_y_p_e
Disables the _a_t_y_p_e type of authentication.
--aa Attempt automatic login. Currently, this sends the user name via
the USER variable of the ENVIRON option if supported by the re-
mote system. The name used is that of the current user as re-
turned by getlogin(2) if it agrees with the current user ID, oth-
erwise it is the name associated with the user ID.
--cc Disables the reading of the user's _._t_e_l_n_e_t_r_c file. (See the
ttooggggllee sskkiipprrcc command on this man page.)
--dd Sets the initial value of the ddeebbuugg toggle to TRUE
--ee _e_s_c_a_p_e _c_h_a_r
Sets the initial tteellnneett tteellnneett escape character to _e_s_c_a_p_e _c_h_a_r_.
If _e_s_c_a_p_e _c_h_a_r is omitted, then there will be no escape charac-
ter.
--ff If Kerberos V5 authentication is being used, the --ff option allows
the local credentials to be forwarded to the remote system.
--kk _r_e_a_l_m
If Kerberos authentication is being used, the --kk option requests
that telnet obtain tickets for the remote host in realm realm in-
stead of the remote host's realm, as determined by
krb_realmofhost(3).
--ll _u_s_e_r
When connecting to the remote system, if the remote system under-
stands the ENVIRON option, then _u_s_e_r will be sent to the remote
system as the value for the variable USER. This option implies
the --aa option. This option may also be used with the ooppeenn com-
mand.
--nn _t_r_a_c_e_f_i_l_e
Opens _t_r_a_c_e_f_i_l_e for recording trace information. See the sseett
ttrraacceeffiillee command below.
--rr Specifies a user interface similar to rlogin(1). In this mode,
the escape character is set to the tilde (~) character, unless
modified by the -e option.
--xx Turns on encryption of the data stream if possible. This option
is not available outside of the United States and Canada.
_h_o_s_t Indicates the official name, an alias, or the Internet address of
a remote host.
_p_o_r_t Indicates a port number (address of an application). If a number
is not specified, the default tteellnneett port is used.
When in rlogin mode, a line of the form ~. disconnects from the remote
host; ~ is the telnet escape character. Similarly, the line ~^Z suspends
the telnet session. The line ~^] escapes to the normal telnet escape
prompt.
Once a connection has been opened, tteellnneett will attempt to enable the
TELNET LINEMODE option. If this fails, then tteellnneett will revert to one of
two input modes: either ``character at a time'' or ``old line by line''
depending on what the remote system supports.
When LINEMODE is enabled, character processing is done on the local sys-
tem, under the control of the remote system. When input editing or char-
acter echoing is to be disabled, the remote system will relay that infor-
mation. The remote system will also relay changes to any special charac-
ters that happen on the remote system, so that they can take effect on
the local system.
In ``character at a time'' mode, most text typed is immediately sent to
the remote host for processing.
In ``old line by line'' mode, all text is echoed locally, and (normally)
only completed lines are sent to the remote host. The ``local echo char-
acter'' (initially ``^E'') may be used to turn off and on the local echo
(this would mostly be used to enter passwords without the password being
echoed).
If the LINEMODE option is enabled, or if the llooccaallcchhaarrss toggle is TRUE
(the default for ``old line by line``; see below), the user's qquuiitt, iinnttrr,
and fflluusshh characters are trapped locally, and sent as TELNET protocol se-
quences to the remote side. If LINEMODE has ever been enabled, then the
user's ssuusspp and eeooff are also sent as TELNET protocol sequences, and qquuiitt
is sent as a TELNET ABORT instead of BREAK There are options (see ttooggggllee
aauuttoofflluusshh and ttooggggllee aauuttoossyynncchh below) which cause this action to flush
subsequent output to the terminal (until the remote host acknowledges the
TELNET sequence) and flush previous terminal input (in the case of qquuiitt
and iinnttrr).
While connected to a remote host, tteellnneett command mode may be entered by
typing the tteellnneett ``escape character'' (initially ``^]''). When in com-
mand mode, the normal terminal editing conventions are available.
The following tteellnneett commands are available. Only enough of each command
to uniquely identify it need be typed (this is also true for arguments to
the mmooddee, sseett, ttooggggllee, uunnsseett, ssllcc, eennvviirroonn, and ddiissppllaayy commands).
aauutthh _a_r_g_u_m_e_n_t _._._.
The auth command manipulates the information sent through the
TELNET AUTHENTICATE option. Valid arguments for the auth com-
mand are as follows:
ddiissaabbllee _t_y_p_e Disables the specified type of authentication.
To obtain a list of available types, use the
aauutthh ddiissaabbllee ?? command.
eennaabbllee _t_y_p_e Enables the specified type of authentication.
To obtain a list of available types, use the
aauutthh eennaabbllee ?? command.
ssttaattuuss Lists the current status of the various types of
authentication.
cclloossee Close a TELNET session and return to command mode.
ddiissppllaayy _a_r_g_u_m_e_n_t _._._.
Displays all, or some, of the sseett and ttooggggllee values (see be-
low).
eennccrryypptt _a_r_g_u_m_e_n_t _._._.
The encrypt command manipulates the information sent through
the TELNET ENCRYPT option.
Note: Because of export controls, the TELNET ENCRYPT option
is not supported outside of the United States and Canada.
Valid arguments for the encrypt command are as follows:
ddiissaabbllee _t_y_p_e [[iinnppuutt||oouuttppuutt]]
Disables the specified type of encryption. If
you omit the input and output, both input and
output are disabled. To obtain a list of avail-
able types, use the eennccrryypptt ddiissaabbllee ?? command.
eennaabbllee _t_y_p_e [[iinnppuutt||oouuttppuutt]]
Enables the specified type of encryption. If
you omit input and output, both input and output
are enabled. To obtain a list of available
types, use the eennccrryypptt eennaabbllee ?? command.
iinnppuutt This is the same as the eennccrryypptt ssttaarrtt iinnppuutt com-
mand.
--iinnppuutt This is the same as the eennccrryypptt ssttoopp iinnppuutt com-
mand.
oouuttppuutt This is the same as the eennccrryypptt ssttaarrtt oouuttppuutt
command.
--oouuttppuutt This is the same as the eennccrryypptt ssttoopp oouuttppuutt com-
mand.
ssttaarrtt [[iinnppuutt||oouuttppuutt]]
Attempts to start encryption. If you omit iinnppuutt
and oouuttppuutt,, both input and output are enabled.
To obtain a list of available types, use the
eennccrryypptt eennaabbllee ?? command.
ssttaattuuss Lists the current status of encryption.
ssttoopp [[iinnppuutt||oouuttppuutt]]
Stops encryption. If you omit input and output,
encryption is on both input and output.
ttyyppee _t_y_p_e Sets the default type of encryption to be used
with later eennccrryypptt ssttaarrtt or eennccrryypptt ssttoopp com-
mands.
eennvviirroonn _a_r_g_u_m_e_n_t_s_._._.
The eennvviirroonn command is used to manipulate the the variables
that my be sent through the TELNET ENVIRON option. The ini-
tial set of variables is taken from the users environment,
with only the DISPLAY and PRINTER variables being exported by
default. The USER variable is also exported if the --aa or --ll
options are used.
Valid arguments for the eennvviirroonn command are:
ddeeffiinnee _v_a_r_i_a_b_l_e _v_a_l_u_e
Define the variable _v_a_r_i_a_b_l_e to have a value of
_v_a_l_u_e_. Any variables defined by this command are
automatically exported. The _v_a_l_u_e may be enclosed
in single or double quotes so that tabs and spaces
may be included.
uunnddeeffiinnee _v_a_r_i_a_b_l_e
Remove _v_a_r_i_a_b_l_e from the list of environment vari-
ables.
eexxppoorrtt _v_a_r_i_a_b_l_e
Mark the variable _v_a_r_i_a_b_l_e to be exported to the
remote side.
uunneexxppoorrtt _v_a_r_i_a_b_l_e
Mark the variable _v_a_r_i_a_b_l_e to not be exported un-
less explicitly asked for by the remote side.
lliisstt List the current set of environment variables.
Those marked with a ** will be sent automatically,
other variables will only be sent if explicitly
requested.
?? Prints out help information for the eennvviirroonn com-
mand.
llooggoouutt Sends the TELNET LOGOUT option to the remote side. This com-
mand is similar to a cclloossee command; however, if the remote
side does not support the LOGOUT option, nothing happens. If,
however, the remote side does support the LOGOUT option, this
command should cause the remote side to close the TELNET con-
nection. If the remote side also supports the concept of sus-
pending a user's session for later reattachment, the logout
argument indicates that you should terminate the session imme-
diately.
mmooddee _t_y_p_e _T_y_p_e is one of several options, depending on the state of the
TELNET session. The remote host is asked for permission to go
into the requested mode. If the remote host is capable of en-
tering that mode, the requested mode will be entered.
cchhaarraacctteerr Disable the TELNET LINEMODE option, or, if the
remote side does not understand the LINEMODE op-
tion, then enter ``character at a time`` mode.
lliinnee Enable the TELNET LINEMODE option, or, if the
remote side does not understand the LINEMODE op-
tion, then attempt to enter ``old-line-by-line``
mode.
iissiigg (--iissiigg) Attempt to enable (disable) the TRAPSIG mode of
the LINEMODE option. This requires that the
LINEMODE option be enabled.
eeddiitt (--eeddiitt) Attempt to enable (disable) the EDIT mode of the
LINEMODE option. This requires that the
LINEMODE option be enabled.
ssooffttttaabbss (--ssooffttttaabbss)
Attempt to enable (disable) the SOFT_TAB mode of
the LINEMODE option. This requires that the
LINEMODE option be enabled.
lliitteecchhoo (--lliitteecchhoo)
Attempt to enable (disable) the LIT_ECHO mode of
the LINEMODE option. This requires that the
LINEMODE option be enabled.
?? Prints out help information for the mmooddee com-
mand.
ooppeenn _h_o_s_t [[--ll] _u_s_e_r][--_p_o_r_t]
Open a connection to the named host. If no port number is
specified, tteellnneett will attempt to contact a TELNET server at
the default port. The host specification may be either a host
name (see hosts(5)) or an Internet address specified in the
``dot notation'' (see inet(3)). The [--ll] option may be used
to specify the user name to be passed to the remote system via
the ENVIRON option. When connecting to a non-standard port,
tteellnneett omits any automatic initiation of TELNET options. When
the port number is preceded by a minus sign, the initial op-
tion negotiation is done. After establishing a connection,
the file _._t_e_l_n_e_t_r_c in the users home directory is opened.
Lines beginning with a # are comment lines. Blank lines are
ignored. Lines that begin without white space are the start
of a machine entry. The first thing on the line is the name
of the machine that is being connected to. The rest of the
line, and successive lines that begin with white space are as-
sumed to be tteellnneett commands and are processed as if they had
been typed in manually to the tteellnneett command prompt.
qquuiitt Close any open TELNET session and exit tteellnneett. An end of file
(in command mode) will also close a session and exit.
sseenndd _a_r_g_u_m_e_n_t_s
Sends one or more special character sequences to the remote
host. The following are the arguments which may be specified
(more than one argument may be specified at a time):
aabboorrtt Sends the TELNET ABORT (Abort processes) sequence.
aaoo Sends the TELNET AO (Abort Output) sequence, which
should cause the remote system to flush all output
_f_r_o_m the remote system _t_o the user's terminal.
aayytt Sends the TELNET AYT (Are You There) sequence, to
which the remote system may or may not choose to re-
spond.
bbrrkk Sends the TELNET BRK (Break) sequence, which may have
significance to the remote system.
eecc Sends the TELNET EC (Erase Character) sequence, which
should cause the remote system to erase the last char-
acter entered.
eell Sends the TELNET EL (Erase Line) sequence, which
should cause the remote system to erase the line cur-
rently being entered.
eeooff Sends the TELNET EOF (End Of File) sequence.
eeoorr Sends the TELNET EOR (End of Record) sequence.
eessccaappee Sends the current tteellnneett escape character (initially
``^'').
ggaa Sends the TELNET GA (Go Ahead) sequence, which likely
has no significance to the remote system.
ggeettssttaattuuss
If the remote side supports the TELNET STATUS command,
ggeettssttaattuuss will send the subnegotiation to request that
the server send its current option status.
iipp Sends the TELNET IP (Interrupt Process) sequence,
which should cause the remote system to abort the cur-
rently running process.
nnoopp Sends the TELNET NOP (No OPeration) sequence.
ssuusspp Sends the TELNET SUSP (SUSPend process) sequence.
ssyynncchh Sends the TELNET SYNCH sequence. This sequence causes
the remote system to discard all previously typed (but
not yet read) input. This sequence is sent as TCP ur-
gent data (and may not work if the remote system is a
4.2BSD system -- if it doesn't work, a lower case
``r'' may be echoed on the terminal).
ddoo _c_m_d
ddoonntt _c_m_d
wwiillll _c_m_d
wwoonntt _c_m_d
Sends the TELNET DO _c_m_d sequence. _C_m_d can be either a
decimal number between 0 and 255, or a symbolic name
for a specific TELNET command. _C_m_d can also be either
hheellpp or ?? to print out help information, including a
list of known symbolic names.
?? Prints out help information for the sseenndd command.
sseett _a_r_g_u_m_e_n_t _v_a_l_u_e
uunnsseett _a_r_g_u_m_e_n_t _v_a_l_u_e
The sseett command will set any one of a number of tteellnneett vari-
ables to a specific value or to TRUE. The special value ooffff
turns off the function associated with the variable, this is
equivalent to using the uunnsseett command. The uunnsseett command will
disable or set to FALSE any of the specified functions. The
values of variables may be interrogated with the ddiissppllaayy com-
mand. The variables which may be set or unset, but not tog-
gled, are listed here. In addition, any of the variables for
the ttooggggllee command may be explicitly set or unset using the
sseett and uunnsseett commands.
aayytt If TELNET is in localchars mode, or LINEMODE is en-
abled, and the status character is typed, a TELNET AYT
sequence (see sseenndd aayytt preceding) is sent to the re-
mote host. The initial value for the "Are You There"
character is the terminal's status character.
eecchhoo This is the value (initially ``^E'') which, when in
``line by line'' mode, toggles between doing local
echoing of entered characters (for normal processing),
and suppressing echoing of entered characters (for en-
tering, say, a password).
eeooff If tteellnneett is operating in LINEMODE or ``old line by
line'' mode, entering this character as the first
character on a line will cause this character to be
sent to the remote system. The initial value of the
eof character is taken to be the terminal's eeooff char-
acter.
eerraassee If tteellnneett is in llooccaallcchhaarrss mode (see ttooggggllee llooccaallcchhaarrss
below), aanndd if tteellnneett is operating in ``character at a
time'' mode, then when this character is typed, a
TELNET EC sequence (see sseenndd eecc above) is sent to the
remote system. The initial value for the erase char-
acter is taken to be the terminal's eerraassee character.
eessccaappee This is the tteellnneett escape character (initially ``^['')
which causes entry into tteellnneett command mode (when con-
nected to a remote system).
fflluusshhoouuttppuutt
If tteellnneett is in llooccaallcchhaarrss mode (see ttooggggllee llooccaallcchhaarrss
below) and the fflluusshhoouuttppuutt character is typed, a
TELNET AO sequence (see sseenndd aaoo above) is sent to the
remote host. The initial value for the flush charac-
ter is taken to be the terminal's fflluusshh character.
ffoorrww11
ffoorrww22 If TELNET is operating in LINEMODE, these are the
characters that, when typed, cause partial lines to be
forwarded to the remote system. The initial value for
the forwarding characters are taken from the termi-
nal's eol and eol2 characters.
iinntteerrrruupptt
If tteellnneett is in llooccaallcchhaarrss mode (see ttooggggllee llooccaallcchhaarrss
below) and the iinntteerrrruupptt character is typed, a TELNET
IP sequence (see sseenndd iipp above) is sent to the remote
host. The initial value for the interrupt character
is taken to be the terminal's iinnttrr character.
kkiillll If tteellnneett is in llooccaallcchhaarrss mode (see ttooggggllee llooccaallcchhaarrss
below), aanndd if tteellnneett is operating in ``character at a
time'' mode, then when this character is typed, a
TELNET EL sequence (see sseenndd eell above) is sent to the
remote system. The initial value for the kill charac-
ter is taken to be the terminal's kkiillll character.
llnneexxtt If tteellnneett is operating in LINEMODE or ``old line by
line`` mode, then this character is taken to be the
terminal's llnneexxtt character. The initial value for the
lnext character is taken to be the terminal's llnneexxtt
character.
qquuiitt If tteellnneett is in llooccaallcchhaarrss mode (see ttooggggllee llooccaallcchhaarrss
below) and the qquuiitt character is typed, a TELNET BRK
sequence (see sseenndd bbrrkk above) is sent to the remote
host. The initial value for the quit character is
taken to be the terminal's qquuiitt character.
rreepprriinntt
If tteellnneett is operating in LINEMODE or ``old line by
line`` mode, then this character is taken to be the
terminal's rreepprriinntt character. The initial value for
the reprint character is taken to be the terminal's
rreepprriinntt character.
rrllooggiinn This is the rlogin escape character. If set, the nor-
mal TELNET escape character is ignored unless it is
preceded by this character at the beginning of a line.
This character, at the beginning of a line followed by
a "." closes the connection; when followed by a ^Z it
suspends the telnet command. The initial state is to
disable the rlogin escape character.
ssttaarrtt If the TELNET TOGGLE-FLOW-CONTROL option has been en-
abled, then this character is taken to be the termi-
nal's ssttaarrtt character. The initial value for the kill
character is taken to be the terminal's ssttaarrtt charac-
ter.
ssttoopp If the TELNET TOGGLE-FLOW-CONTROL option has been en-
abled, then this character is taken to be the termi-
nal's ssttoopp character. The initial value for the kill
character is taken to be the terminal's ssttoopp charac-
ter.
ssuusspp If tteellnneett is in llooccaallcchhaarrss mode, or LINEMODE is en-
abled, and the ssuussppeenndd character is typed, a TELNET
SUSP sequence (see sseenndd ssuusspp above) is sent to the re-
mote host. The initial value for the suspend charac-
ter is taken to be the terminal's ssuussppeenndd character.
ttrraacceeffiillee
This is the file to which the output, caused by
nneettddaattaa or ooppttiioonn tracing being TRUE, will be written.
If it is set to ``--'', then tracing information will
be written to standard output (the default).
wwoorrddeerraassee
If tteellnneett is operating in LINEMODE or ``old line by
line`` mode, then this character is taken to be the
terminal's wwoorrddeerraassee character. The initial value for
the worderase character is taken to be the terminal's
wwoorrddeerraassee character.
?? Displays the legal sseett (uunnsseett) commands.
ssllcc _s_t_a_t_e The ssllcc command (Set Local Characters) is used to set or
change the state of the the special characters when the TELNET
LINEMODE option has been enabled. Special characters are
characters that get mapped to TELNET commands sequences (like
iipp or qquuiitt) or line editing characters (like eerraassee and kkiillll).
By default, the local special characters are exported.
cchheecckk Verify the current settings for the current spe-
cial characters. The remote side is requested to
send all the current special character settings,
and if there are any discrepancies with the local
side, the local side will switch to the remote
value.
eexxppoorrtt Switch to the local defaults for the special char-
acters. The local default characters are those of
the local terminal at the time when tteellnneett was
started.
iimmppoorrtt Switch to the remote defaults for the special
characters. The remote default characters are
those of the remote system at the time when the
TELNET connection was established.
?? Prints out help information for the ssllcc command.
ssttaattuuss Show the current status of tteellnneett. This includes the peer one
is connected to, as well as the current mode.
ttooggggllee _a_r_g_u_m_e_n_t_s _._._.
Toggle (between TRUE and FALSE) various flags that control how
tteellnneett responds to events. These flags may be set explicitly
to TRUE or FALSE using the sseett and uunnsseett commands listed
above. More than one argument may be specified. The state of
these flags may be interrogated with the ddiissppllaayy command.
Valid arguments are:
aauutthhddeebbuugg Turns on debugging information for the authenti-
cation code.
aauuttoofflluusshh If aauuttoofflluusshh and llooccaallcchhaarrss are both TRUE, then
when the aaoo, or qquuiitt characters are recognized
(and transformed into TELNET sequences; see sseett
above for details), tteellnneett refuses to display
any data on the user's terminal until the remote
system acknowledges (via a TELNET TIMING MARK
option) that it has processed those TELNET se-
quences. The initial value for this toggle is
TRUE if the terminal user had not done an "stty
noflsh", otherwise FALSE (see stty(1)).
aauuttooddeeccrryypptt When the TELNET ENCRYPT option is negotiated, by
default the actual encryption (decryption) of
the data stream does not start automatically.
The autoencrypt (autodecrypt) command states
that encryption of the output (input) stream
should be enabled as soon as possible.
Note: Because of export controls, the TELNET
ENCRYPT option is not supported outside the
United States and Canada.
aauuttoollooggiinn If the remote side supports the TELNET
AUTHENTICATION option TELNET attempts to use it
to perform automatic authentication. If the
AUTHENTICATION option is not supported, the us-
er's login name are propagated through the
TELNET ENVIRON option. This command is the same
as specifying _a option on the ooppeenn command.
aauuttoossyynncchh If aauuttoossyynncchh and llooccaallcchhaarrss are both TRUE, then
when either the iinnttrr or qquuiitt characters is typed
(see sseett above for descriptions of the iinnttrr and
qquuiitt characters), the resulting TELNET sequence
sent is followed by the TELNET SYNCH sequence.
This procedure sshhoouulldd cause the remote system to
begin throwing away all previously typed input
until both of the TELNET sequences have been
read and acted upon. The initial value of this
toggle is FALSE.
bbiinnaarryy Enable or disable the TELNET BINARY option on
both input and output.
iinnbbiinnaarryy Enable or disable the TELNET BINARY option on
input.
oouuttbbiinnaarryy Enable or disable the TELNET BINARY option on
output.
ccrrllff If this is TRUE, then carriage returns will be
sent as <CR><LF>. If this is FALSE, then car-
riage returns will be send as <CR><NUL>. The
initial value for this toggle is FALSE.
ccrrmmoodd Toggle carriage return mode. When this mode is
enabled, most carriage return characters re-
ceived from the remote host will be mapped into
a carriage return followed by a line feed. This
mode does not affect those characters typed by
the user, only those received from the remote
host. This mode is not very useful unless the
remote host only sends carriage return, but nev-
er line feed. The initial value for this toggle
is FALSE.
ddeebbuugg Toggles socket level debugging (useful only to
the ssuuppeerr uusseerr). The initial value for this tog-
gle is FALSE.
eennccddeebbuugg Turns on debugging information for the encryp-
tion code.
llooccaallcchhaarrss If this is TRUE, then the fflluusshh, iinntteerrrruupptt,
qquuiitt, eerraassee, and kkiillll characters (see sseett above)
are recognized locally, and transformed into
(hopefully) appropriate TELNET control sequences
(respectively aaoo, iipp, bbrrkk, eecc, and eell; see sseenndd
above). The initial value for this toggle is
TRUE in ``old line by line'' mode, and FALSE in
``character at a time'' mode. When the LINEMODE
option is enabled, the value of llooccaallcchhaarrss is
ignored, and assumed to always be TRUE. If
LINEMODE has ever been enabled, then qquuiitt is
sent as aabboorrtt, and eeooff aanndd are sent as eeooff aanndd
ssuusspp, see sseenndd above).
nneettddaattaa Toggles the display of all network data (in hex-
adecimal format). The initial value for this
toggle is FALSE.
ooppttiioonnss Toggles the display of some internal tteellnneett pro-
tocol processing (having to do with TELNET op-
tions). The initial value for this toggle is
FALSE.
pprreettttyydduummpp When the nneettddaattaa toggle is enabled, if
pprreettttyydduummpp is enabled the output from the
nneettddaattaa command will be formatted in a more user
readable format. Spaces are put between each
character in the output, and the beginning of
any TELNET escape sequence is preceded by a '*'
to aid in locating them.
sskkiipprrcc When the skiprc toggle is TRUE, TELNET skips the
reading of the _._t_e_l_n_e_t_r_c file in the users home
directory when connections are opened. The ini-
tial value for this toggle is FALSE.
tteerrmmddaattaa Toggles the display of all terminal data (in
hexadecimal format). The initial value for this
toggle is FALSE.
vveerrbboossee__eennccrryypptt
When the vveerrbboossee__eennccrryypptt toggle is TRUE, TELNET
prints out a message each time encryption is en-
abled or disabled. The initial value for this
toggle is FALSE. Note: Because of export con-
trols, data encryption is not supported outside
of the United States and Canada.
?? Displays the legal ttooggggllee commands.
zz Suspend tteellnneett. This command only works when the user is using
the csh(1).
!! [_c_o_m_m_a_n_d]
Execute a single command in a subshell on the local system.
If ccoommmmaanndd is omitted, then an interactive subshell is in-
voked.
?? [_c_o_m_m_a_n_d]
Get help. With no arguments, tteellnneett prints a help summary.
If a command is specified, tteellnneett will print the help informa-
tion for just that command.
EENNVVIIRROONNMMEENNTT
TTeellnneett uses at least the HOME, SHELL, DISPLAY, and TERM environment vari-
ables. Other environment variables may be propagated to the other side
via the TELNET ENVIRON option.
FFIILLEESS
~/.telnetrc user customized telnet startup values
HHIISSTTOORRYY
The TTeellnneett command appeared in 4.2BSD.
NNOOTTEESS
On some remote systems, echo has to be turned off manually when in ``old
line by line'' mode.
In ``old line by line'' mode or LINEMODE the terminal's eeooff character is
only recognized (and sent to the remote system) when it is the first
character on a line.
4.2 Berkeley Distribution June 1, 1994 11

1366
appl/telnet/telnet/telnet.1 Normal file

File diff suppressed because it is too large Load Diff

411
appl/telnet/telnet/tn3270.c Normal file
View File

@@ -0,0 +1,411 @@
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef lint
static char sccsid[] = "@(#)tn3270.c 8.2 (Berkeley) 5/30/95";
#endif /* not lint */
#include <sys/types.h>
#include <arpa/telnet.h>
#include "general.h"
#include "defines.h"
#include "ring.h"
#include "externs.h"
#include "fdset.h"
#if defined(TN3270)
#include "../ctlr/screen.h"
#include "../general/globals.h"
#include "../sys_curses/telextrn.h"
#include "../ctlr/externs.h"
#if defined(unix)
int
HaveInput, /* There is input available to scan */
cursesdata, /* Do we dump curses data? */
sigiocount; /* Number of times we got a SIGIO */
char tline[200];
char *transcom = 0; /* transparent mode command (default: none) */
#endif /* defined(unix) */
char Ibuf[8*BUFSIZ], *Ifrontp, *Ibackp;
static char sb_terminal[] = { IAC, SB,
TELOPT_TTYPE, TELQUAL_IS,
'I', 'B', 'M', '-', '3', '2', '7', '8', '-', '2',
IAC, SE };
#define SBTERMMODEL 13
static int
Sent3270TerminalType; /* Have we said we are a 3270? */
#endif /* defined(TN3270) */
void
init_3270()
{
#if defined(TN3270)
#if defined(unix)
HaveInput = 0;
sigiocount = 0;
#endif /* defined(unix) */
Sent3270TerminalType = 0;
Ifrontp = Ibackp = Ibuf;
init_ctlr(); /* Initialize some things */
init_keyboard();
init_screen();
init_system();
#endif /* defined(TN3270) */
}
#if defined(TN3270)
/*
* DataToNetwork - queue up some data to go to network. If "done" is set,
* then when last byte is queued, we add on an IAC EOR sequence (so,
* don't call us with "done" until you want that done...)
*
* We actually do send all the data to the network buffer, since our
* only client needs for us to do that.
*/
int
DataToNetwork(buffer, count, done)
register char *buffer; /* where the data is */
register int count; /* how much to send */
int done; /* is this the last of a logical block */
{
register int loop, c;
int origCount;
origCount = count;
while (count) {
/* If not enough room for EORs, IACs, etc., wait */
if (NETROOM() < 6) {
fd_set o;
FD_ZERO(&o);
netflush();
while (NETROOM() < 6) {
FD_SET(net, &o);
(void) select(net+1, (fd_set *) 0, &o, (fd_set *) 0,
(struct timeval *) 0);
netflush();
}
}
c = ring_empty_count(&netoring);
if (c > count) {
c = count;
}
loop = c;
while (loop) {
if (((unsigned char)*buffer) == IAC) {
break;
}
buffer++;
loop--;
}
if ((c = c-loop)) {
ring_supply_data(&netoring, buffer-c, c);
count -= c;
}
if (loop) {
NET2ADD(IAC, IAC);
count--;
buffer++;
}
}
if (done) {
NET2ADD(IAC, EOR);
netflush(); /* try to move along as quickly as ... */
}
return(origCount - count);
}
#if defined(unix)
void
inputAvailable(signo)
int signo;
{
HaveInput = 1;
sigiocount++;
}
#endif /* defined(unix) */
void
outputPurge()
{
(void) ttyflush(1);
}
/*
* The following routines are places where the various tn3270
* routines make calls into telnet.c.
*/
/*
* DataToTerminal - queue up some data to go to terminal.
*
* Note: there are people who call us and depend on our processing
* *all* the data at one time (thus the select).
*/
int
DataToTerminal(buffer, count)
register char *buffer; /* where the data is */
register int count; /* how much to send */
{
register int c;
int origCount;
origCount = count;
while (count) {
if (TTYROOM() == 0) {
#if defined(unix)
fd_set o;
FD_ZERO(&o);
#endif /* defined(unix) */
(void) ttyflush(0);
while (TTYROOM() == 0) {
#if defined(unix)
FD_SET(tout, &o);
(void) select(tout+1, (fd_set *) 0, &o, (fd_set *) 0,
(struct timeval *) 0);
#endif /* defined(unix) */
(void) ttyflush(0);
}
}
c = TTYROOM();
if (c > count) {
c = count;
}
ring_supply_data(&ttyoring, buffer, c);
count -= c;
buffer += c;
}
return(origCount);
}
/*
* Push3270 - Try to send data along the 3270 output (to screen) direction.
*/
int
Push3270()
{
int save = ring_full_count(&netiring);
if (save) {
if (Ifrontp+save > Ibuf+sizeof Ibuf) {
if (Ibackp != Ibuf) {
memmove(Ibuf, Ibackp, Ifrontp-Ibackp);
Ifrontp -= (Ibackp-Ibuf);
Ibackp = Ibuf;
}
}
if (Ifrontp+save < Ibuf+sizeof Ibuf) {
(void)telrcv();
}
}
return save != ring_full_count(&netiring);
}
/*
* Finish3270 - get the last dregs of 3270 data out to the terminal
* before quitting.
*/
void
Finish3270()
{
while (Push3270() || !DoTerminalOutput()) {
#if defined(unix)
HaveInput = 0;
#endif /* defined(unix) */
;
}
}
/* StringToTerminal - output a null terminated string to the terminal */
void
StringToTerminal(s)
char *s;
{
int count;
count = strlen(s);
if (count) {
(void) DataToTerminal(s, count); /* we know it always goes... */
}
}
#if ((!defined(NOT43)) || defined(PUTCHAR))
/* _putchar - output a single character to the terminal. This name is so that
* curses(3x) can call us to send out data.
*/
void
_putchar(c)
char c;
{
#if defined(sun) /* SunOS 4.0 bug */
c &= 0x7f;
#endif /* defined(sun) */
if (cursesdata) {
Dump('>', &c, 1);
}
if (!TTYROOM()) {
(void) DataToTerminal(&c, 1);
} else {
TTYADD(c);
}
}
#endif /* ((!defined(NOT43)) || defined(PUTCHAR)) */
void
SetIn3270()
{
if (Sent3270TerminalType && my_want_state_is_will(TELOPT_BINARY)
&& my_want_state_is_do(TELOPT_BINARY) && !donebinarytoggle) {
if (!In3270) {
In3270 = 1;
Init3270(); /* Initialize 3270 functions */
/* initialize terminal key mapping */
InitTerminal(); /* Start terminal going */
setconnmode(0);
}
} else {
if (In3270) {
StopScreen(1);
In3270 = 0;
Stop3270(); /* Tell 3270 we aren't here anymore */
setconnmode(0);
}
}
}
/*
* tn3270_ttype()
*
* Send a response to a terminal type negotiation.
*
* Return '0' if no more responses to send; '1' if a response sent.
*/
int
tn3270_ttype()
{
/*
* Try to send a 3270 type terminal name. Decide which one based
* on the format of our screen, and (in the future) color
* capaiblities.
*/
InitTerminal(); /* Sets MaxNumberColumns, MaxNumberLines */
if ((MaxNumberLines >= 24) && (MaxNumberColumns >= 80)) {
Sent3270TerminalType = 1;
if ((MaxNumberLines >= 27) && (MaxNumberColumns >= 132)) {
MaxNumberLines = 27;
MaxNumberColumns = 132;
sb_terminal[SBTERMMODEL] = '5';
} else if (MaxNumberLines >= 43) {
MaxNumberLines = 43;
MaxNumberColumns = 80;
sb_terminal[SBTERMMODEL] = '4';
} else if (MaxNumberLines >= 32) {
MaxNumberLines = 32;
MaxNumberColumns = 80;
sb_terminal[SBTERMMODEL] = '3';
} else {
MaxNumberLines = 24;
MaxNumberColumns = 80;
sb_terminal[SBTERMMODEL] = '2';
}
NumberLines = 24; /* before we start out... */
NumberColumns = 80;
ScreenSize = NumberLines*NumberColumns;
if ((MaxNumberLines*MaxNumberColumns) > MAXSCREENSIZE) {
ExitString("Programming error: MAXSCREENSIZE too small.\n",
1);
/*NOTREACHED*/
}
printsub('>', sb_terminal+2, sizeof sb_terminal-2);
ring_supply_data(&netoring, sb_terminal, sizeof sb_terminal);
return 1;
} else {
return 0;
}
}
#if defined(unix)
int
settranscom(argc, argv)
int argc;
char *argv[];
{
int i;
if (argc == 1 && transcom) {
transcom = 0;
}
if (argc == 1) {
return 1;
}
transcom = tline;
(void) strcpy(transcom, argv[1]);
for (i = 2; i < argc; ++i) {
(void) strcat(transcom, " ");
(void) strcat(transcom, argv[i]);
}
return 1;
}
#endif /* defined(unix) */
#endif /* defined(TN3270) */

View File

@@ -0,0 +1,52 @@
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)types.h 8.1 (Berkeley) 6/6/93
*/
typedef struct {
char *modedescriptions;
char modetype;
} Modelist;
extern Modelist modelist[];
typedef struct {
int
system, /* what the current time is */
echotoggle, /* last time user entered echo character */
modenegotiated, /* last time operating mode negotiated */
didnetreceive, /* last time we read data from network */
gotDM; /* when did we last see a data mark */
} Clocks;
extern Clocks clocks;

View File

@@ -0,0 +1,36 @@
# @(#)Makefile 8.2 (Berkeley) 12/15/93
PROG= telnetd
CFLAGS+=-DLINEMODE -DKLUDGELINEMODE -DUSE_TERMIO -DDIAGNOSTICS
CFLAGS+=-DOLD_ENVIRON -DENV_HACK
CFLAGS+=-DAUTHENTICATION -DENCRYPTION -I${.CURDIR}/../../lib
SRCS= authenc.c global.c slc.c state.c sys_term.c telnetd.c \
termstat.c utility.c
DPADD= ${LIBUTIL} ${LIBTERM}
LDADD= -lutil -ltermcap -ltelnet
LDADD+= -lkrb -ldes
MAN8= telnetd.0
# These are the sources that have encryption stuff in them.
CRYPT_SRC= authenc.c ext.h state.c telnetd.c termstat.c
CRYPT_SRC+= utility.c Makefile
NOCRYPT_DIR=${.CURDIR}/Nocrypt
.include <bsd.prog.mk>
nocrypt:
#ifdef ENCRYPTION
@for i in ${CRYPT_SRC}; do \
if [ ! -d ${NOCRYPT_DIR} ]; then \
echo Creating subdirectory ${NOCRYPT_DIR}; \
mkdir ${NOCRYPT_DIR}; \
fi; \
echo ${NOCRYPT_DIR}/$$i; \
unifdef -UENCRYPTION ${.CURDIR}/$$i | \
sed "s/ || defined(ENCRYPTION)//" > ${NOCRYPT_DIR}/$$i; \
done
placeholder:
#else /* ENCRYPTION */
@echo "Encryption code already removed."
#endif /* ENCRYPTION */

View File

@@ -0,0 +1,45 @@
#
# Copyright (c) 1991 The Regents of the University of California.
# All rights reserved.
#
# Redistribution and use in source and binary forms are permitted provided
# that: (1) source distributions retain this entire copyright notice and
# comment, and (2) distributions including binaries display the following
# acknowledgement: ``This product includes software developed by the
# University of California, Berkeley and its contributors'' in the
# documentation or other materials provided with the distribution and in
# all advertising materials mentioning features or use of this software.
# Neither the name of the University nor the names of its contributors may
# be used to endorse or promote products derived from this software without
# specific prior written permission.
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# @(#)Makefile 5.5 (Berkeley) 3/1/91
#
#
# Everything happens in ../Makefile.config and Makefile.generic
#
SHELL=/bin/sh
all:
@-if test -f ../Config.local; \
then \
echo make -f ../Config.local WHAT=${WHAT} CC="${CC}"; \
make -f ../Config.local WHAT=${WHAT} CC="${CC}"; \
else \
echo make -f ../Config.generic WHAT=${WHAT} CC="${CC}"; \
make -f ../Config.generic WHAT=${WHAT} CC="${CC}"; \
fi
.DEFAULT:
@-if test -f ../Config.local; \
then \
echo make -f ../Config.local WHAT=${WHAT} CC="${CC}" $@; \
make -f ../Config.local WHAT=${WHAT} CC="${CC}" $@; \
else \
echo make -f ../Config.generic WHAT=${WHAT} CC="${CC}" $@; \
make -f ../Config.generic WHAT=${WHAT} CC="${CC}" $@; \
fi

View File

@@ -0,0 +1,71 @@
#
# Copyright (c) 1991 The Regents of the University of California.
# All rights reserved.
#
# Redistribution and use in source and binary forms are permitted provided
# that: (1) source distributions retain this entire copyright notice and
# comment, and (2) distributions including binaries display the following
# acknowledgement: ``This product includes software developed by the
# University of California, Berkeley and its contributors'' in the
# documentation or other materials provided with the distribution and in
# all advertising materials mentioning features or use of this software.
# Neither the name of the University nor the names of its contributors may
# be used to endorse or promote products derived from this software without
# specific prior written permission.
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# @(#)Makefile.generic 5.5 (Berkeley) 3/1/91
#
SRC1= telnetd.c state.c termstat.c slc.c sys_term.c utility.c global.c authenc.c
OBJ1= telnetd.o state.o termstat.o slc.o sys_term.o utility.o global.o authenc.o
OBJS= ${OBJ1} ${GETTYOBJ}
SRCS= ${SRC1} ${GETTYSRC}
MAN= telnetd.0
CFLAGS= ${LCCFLAGS} -I.. ${DEFINES} ${INCLUDES}
ARPA_TELNET = ../arpa/telnet.h
#
# These next three lines are not needed in 4.4BSD
#
.SUFFIXES: .0 .8
.8.0:
nroff -man -h $< > $@
all: telnetd
telnetd: ${OBJS} ${LIBPATH}
${CC} -o $@ ${CFLAGS} ${OBJS} ../../../lib/kafs/libkafs.a ${LIBS}
clean:
rm -f ${OBJS} core telnetd
cleandir: clean
rm -f ${MAN} tags .depend
depend: ${SRCS}
mkdep ${CFLAGS} ${SRCS}
install: ${MAN}
install -s -o bin -g bin -m 755 telnetd ${LIBEXEC}
install -c -o bin -g bin -m 444 ${MAN} ${DESTDIR}/usr/man/cat8
lint: ${SRCS}
lint ${CFLAGS} ${SRCS}
tags: ${SRCS}
ctags ${SRCS}
authenc.o: telnetd.h
global.o: defs.h ext.h ${ARPA_TELNET}
slc.o: telnetd.h defs.h ext.h ${ARPA_TELNET}
state.o: telnetd.h defs.h ext.h ${ARPA_TELNET}
sys_term.o: telnetd.h pathnames.h defs.h ext.h ${ARPA_TELNET}
telnetd.o: telnetd.h defs.h ext.h ${ARPA_TELNET}
termstat.o: telnetd.h defs.h ext.h ${ARPA_TELNET}
utility.o: telnetd.h defs.h ext.h ${ARPA_TELNET}

View File

@@ -0,0 +1,55 @@
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)pathnames.h 8.1 (Berkeley) 6/4/93
*/
#if BSD > 43
# include <paths.h>
# ifndef _PATH_LOGIN
# define _PATH_LOGIN "/usr/bin/login"
# endif
#else
# define _PATH_TTY "/dev/tty"
# ifndef _PATH_LOGIN
# define _PATH_LOGIN "/bin/login"
# endif
#endif
#ifdef BFTPDAEMON
#define BFTPPATH "/usr/ucb/bftp"
#endif /* BFTPDAEMON */

View File

@@ -0,0 +1,555 @@
%!PS-Adobe-3.0
%%Creator: groff version 1.08
%%DocumentNeededResources: font Times-Roman
%%+ font Times-Bold
%%+ font Courier-Bold
%%+ font Courier-Oblique
%%+ font Courier
%%DocumentSuppliedResources: procset grops 1.08 0
%%Pages: 5
%%PageOrder: Ascend
%%Orientation: Portrait
%%EndComments
%%BeginProlog
%%BeginResource: procset grops 1.08 0
/setpacking where{
pop
currentpacking
true setpacking
}if
/grops 120 dict dup begin
/SC 32 def
/A/show load def
/B{0 SC 3 -1 roll widthshow}bind def
/C{0 exch ashow}bind def
/D{0 exch 0 SC 5 2 roll awidthshow}bind def
/E{0 rmoveto show}bind def
/F{0 rmoveto 0 SC 3 -1 roll widthshow}bind def
/G{0 rmoveto 0 exch ashow}bind def
/H{0 rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
/I{0 exch rmoveto show}bind def
/J{0 exch rmoveto 0 SC 3 -1 roll widthshow}bind def
/K{0 exch rmoveto 0 exch ashow}bind def
/L{0 exch rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
/M{rmoveto show}bind def
/N{rmoveto 0 SC 3 -1 roll widthshow}bind def
/O{rmoveto 0 exch ashow}bind def
/P{rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
/Q{moveto show}bind def
/R{moveto 0 SC 3 -1 roll widthshow}bind def
/S{moveto 0 exch ashow}bind def
/T{moveto 0 exch 0 SC 5 2 roll awidthshow}bind def
/SF{
findfont exch
[exch dup 0 exch 0 exch neg 0 0]makefont
dup setfont
[exch/setfont cvx]cvx bind def
}bind def
/MF{
findfont
[5 2 roll
0 3 1 roll
neg 0 0]makefont
dup setfont
[exch/setfont cvx]cvx bind def
}bind def
/level0 0 def
/RES 0 def
/PL 0 def
/LS 0 def
/PLG{
gsave newpath clippath pathbbox grestore
exch pop add exch pop
}bind def
/BP{
/level0 save def
1 setlinecap
1 setlinejoin
72 RES div dup scale
LS{
90 rotate
}{
0 PL translate
}ifelse
1 -1 scale
}bind def
/EP{
level0 restore
showpage
}bind def
/DA{
newpath arcn stroke
}bind def
/SN{
transform
.25 sub exch .25 sub exch
round .25 add exch round .25 add exch
itransform
}bind def
/DL{
SN
moveto
SN
lineto stroke
}bind def
/DC{
newpath 0 360 arc closepath
}bind def
/TM matrix def
/DE{
TM currentmatrix pop
translate scale newpath 0 0 .5 0 360 arc closepath
TM setmatrix
}bind def
/RC/rcurveto load def
/RL/rlineto load def
/ST/stroke load def
/MT/moveto load def
/CL/closepath load def
/FL{
currentgray exch setgray fill setgray
}bind def
/BL/fill load def
/LW/setlinewidth load def
/RE{
findfont
dup maxlength 1 index/FontName known not{1 add}if dict begin
{
1 index/FID ne{def}{pop pop}ifelse
}forall
/Encoding exch def
dup/FontName exch def
currentdict end definefont pop
}bind def
/DEFS 0 def
/EBEGIN{
moveto
DEFS begin
}bind def
/EEND/end load def
/CNT 0 def
/level1 0 def
/PBEGIN{
/level1 save def
translate
div 3 1 roll div exch scale
neg exch neg exch translate
0 setgray
0 setlinecap
1 setlinewidth
0 setlinejoin
10 setmiterlimit
[]0 setdash
/setstrokeadjust where{
pop
false setstrokeadjust
}if
/setoverprint where{
pop
false setoverprint
}if
newpath
/CNT countdictstack def
userdict begin
/showpage{}def
}bind def
/PEND{
clear
countdictstack CNT sub{end}repeat
level1 restore
}bind def
end def
/setpacking where{
pop
setpacking
}if
%%EndResource
%%IncludeResource: font Times-Roman
%%IncludeResource: font Times-Bold
%%IncludeResource: font Courier-Bold
%%IncludeResource: font Courier-Oblique
%%IncludeResource: font Courier
grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72 def/PL
792 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron/Zcaron/scaron/zcaron
/Ydieresis/trademark/quotesingle/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/space
/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright/parenleft
/parenright/asterisk/plus/comma/hyphen/period/slash/zero/one/two/three/four
/five/six/seven/eight/nine/colon/semicolon/less/equal/greater/question/at/A/B/C
/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash
/bracketright/circumflex/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q
/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/tilde/.notdef/quotesinglbase
/guillemotleft/guillemotright/bullet/florin/fraction/perthousand/dagger
/daggerdbl/endash/emdash/ff/fi/fl/ffi/ffl/dotlessi/dotlessj/grave/hungarumlaut
/dotaccent/breve/caron/ring/ogonek/quotedblleft/quotedblright/oe/lslash
/quotedblbase/OE/Lslash/.notdef/exclamdown/cent/sterling/currency/yen/brokenbar
/section/dieresis/copyright/ordfeminine/guilsinglleft/logicalnot/minus
/registered/macron/degree/plusminus/twosuperior/threesuperior/acute/mu
/paragraph/periodcentered/cedilla/onesuperior/ordmasculine/guilsinglright
/onequarter/onehalf/threequarters/questiondown/Agrave/Aacute/Acircumflex/Atilde
/Adieresis/Aring/AE/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute
/Icircumflex/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis
/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls
/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla/egrave/eacute
/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis/eth/ntilde/ograve
/oacute/ocircumflex/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex
/udieresis/yacute/thorn/ydieresis]def/Courier@0 ENC0/Courier RE
/Courier-Oblique@0 ENC0/Courier-Oblique RE/Courier-Bold@0 ENC0/Courier-Bold RE
/Times-Bold@0 ENC0/Times-Bold RE/Times-Roman@0 ENC0/Times-Roman RE
%%EndProlog
%%Page: 1 1
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF -.834(TELNETD \( 8 \))72 48 R(BSD System Manager')
241.42 48 Q 2.5(sM)-.55 G 105.272(anual TELNETD)348.92 48 R 1.666(\(8\))1.666 G
/F1 10/Times-Bold@0 SF -.2(NA)72 108 S(ME).2 E/F2 10/Courier-Bold@0 SF(telnetd)
102 120 Q F0 2.5<ad44>2.5 G(ARP)161.46 120 Q(A)-.92 E/F3 9/Times-Roman@0 SF
(TELNET)2.5 E F0(protocol serv)2.5 E(er)-.15 E F1(SYNOPSIS)72 144 Q F2
(/usr/libexec/telnetd)102 156 Q F0([)3.333 E F2<ad61>2.499 E/F4 10
/Courier-Oblique@0 SF(authmode)6 E F0 3.333(][).833 G F2<ad42>-.834 E F0 3.333
(][).833 G F2<ad44>-.834 E F4(debugmode)6 E F0 3.333(][).833 G F2(\255edebug)
-.834 E F0 3.333(][).833 G F2<ad68>-.834 E F0(]).833 E([)228.833 168 Q F2<ad49>
2.499 E F4(initid)A F0 3.333(][).833 G F2<ad6c>-.834 E F0 3.333(][).833 G F2
<ad6b>-.834 E F0 3.333(][).833 G F2<ad6e>-.834 E F0 3.333(][).833 G F2<ad72>
-.834 E F4(lowpty-highpty)A F0 3.333(][).833 G F2<ad73>-.834 E F0 3.333(][).833
G F2<ad53>-.834 E F4(tos)228 180 Q F0 3.333(][).833 G F2<ad75>-.834 E F4(len)6
E F0 3.333(][).833 G F2<ad55>-.834 E F0 3.333(][).833 G F2<ad58>-.834 E F4
(authtype)6 E F0 3.333(][).833 G F2(\255debug)-.834 E F0([)6.833 E F4(port).833
E F0 .833(]]).833 G F1(DESCRIPTION)72 204 Q F0(The)102 216 Q F2(telnetd)3.044 E
F0 .544(command is a serv)3.044 F .544(er which supports the)-.15 F F3 -.36(DA)
3.044 G(RP).36 E(A)-.828 E F0(standard)3.044 E F3(TELNET)3.044 E F0 .543
(virtual terminal protocol.)3.044 F F2(Telnetd)102 228 Q F0 .221
(is normally in)2.721 F -.2(vo)-.4 G -.1(ke).2 G 2.721(db).1 G 2.721(yt)234.184
228 S .221(he internet serv)244.685 228 R .221(er \(see)-.15 F/F5 10/Courier@0
SF(inetd)2.721 E F0 2.942(\(8\)\) for)B .221(requests to connect to the)2.721 F
F3(TELNET)2.721 E F0 .673(port as indicated by the)102 240 R F5(/etc/services)
3.173 E F0 .673(\214le \(see)3.173 F F5(services)3.173 E F0 3.846(\(5\)\). The)
B F2(\255debug)4.839 E F0 .672(option may be used to)3.173 F .145(start up)102
252 R F2(telnetd)2.645 E F0(manually)2.645 E 2.645(,i)-.65 G .145
(nstead of through)223.65 252 R F5(inetd)2.645 E F0 2.79(\(8\). If)B .145
(started up this w)2.645 F(ay)-.1 E(,)-.65 E F4(port)2.645 E F0 .145
(may be speci\214ed to)2.645 F(run)102 264 Q F2(telnetd)2.5 E F0
(on an alternate)2.5 E F3(TCP)2.5 E F0(port number)2.5 E(.)-.55 E(The)102 282 Q
F2(telnetd)2.5 E F0(command accepts the follo)2.5 E(wing options:)-.25 E F2
<ad61>103.666 300 Q F4(authmode)6 E F0 .106(This option may be used for specif\
ying what mode should be used for authentication.)173 312 R(Note)5.106 E 2.778
(that this option is only useful if)173 324 R F2(telnetd)5.279 E F0 2.779
(has been compiled with support for the)5.279 F F5(AUTHENTICATION)173 336 Q F0
2.5(option. There)2.5 F(are se)2.5 E -.15(ve)-.25 G(ral v).15 E(alid v)-.25 E
(alues for)-.25 E F4(authmode:)2.5 E F0(deb)173 354 Q 8.26(ug T)-.2 F
(urns on authentication deb)-.45 E(ugging code.)-.2 E 15.84(user Only)173 372 R
(allo)2.923 E 2.923(wc)-.25 G .423(onnections when the remote user can pro)
260.256 372 R .422(vide v)-.15 F .422(alid authentication in-)-.25 F 1.277
(formation to identify the remote user)208 384 R 3.777(,a)-.4 G 1.277
(nd is allo)372.181 384 R 1.277(wed access to the speci\214ed ac-)-.25 F
(count without pro)208 396 Q(viding a passw)-.15 E(ord.)-.1 E -.25(va)173 414 S
12.75(lid Only).25 F(allo)2.923 E 2.923(wc)-.25 G .423
(onnections when the remote user can pro)260.256 414 R .422(vide v)-.15 F .422
(alid authentication in-)-.25 F .742(formation to identify the remote user)208
426 R 5.743(.T)-.55 G(he)372.995 426 Q F5(login)3.243 E F0 .743
(\(1\) command will pro)B .743(vide an)-.15 F(y)-.15 E .53(additional user v)
208 438 R .529(eri\214cation needed if the remote user is not allo)-.15 F .529
(wed automatic ac-)-.25 F(cess to the speci\214ed account.)208 450 Q 11.95
(other Only)173 468 R(allo)3.028 E 3.029(wc)-.25 G .529
(onnections that supply some authentication information.)260.467 468 R .529
(This option)5.529 F .079(is currently not supported by an)208 480 R 2.578(yo)
-.15 G 2.578(ft)347.752 480 S .078(he e)356.44 480 R .078
(xisting authentication mechanisms, and is)-.15 F(thus the same as specifying)
208 492 Q F2 -3.5(\255a valid)4.166 F F0(.)A 13.06(none This)173 510 R .869
(is the def)3.369 F .869(ault state.)-.1 F .869
(Authentication information is not required.)5.869 F .87(If no or in-)5.869 F
(suf)208 522 Q .394(\214cient authentication information is pro)-.25 F .393
(vided, then the)-.15 F F5(login)2.893 E F0 .393(\(1\) program will)B(pro)208
534 Q(vide the necessary user v)-.15 E(eri\214cation.)-.15 E(of)173 552 Q 23.59
(fT)-.25 G 1.385(his disables the authentication code.)214.11 552 R 1.385
(All user v)6.385 F 1.385(eri\214cation will happen through)-.15 F(the)208 564
Q F5(login)2.5 E F0(\(1\) program.)A F2<ad42>103.666 582 Q F0 .82
(Speci\214es bftp serv)173 582 R .82(er mode.)-.15 F .819(In this mode,)5.82 F
F2(telnetd)3.319 E F0 .819(causes login to start a)3.319 F F5(bftp)3.319 E F0
.819(\(1\) ses-)B .747(sion rather than the user')173 594 R 3.247(sn)-.55 G
.747(ormal shell.)286.995 594 R .748
(In bftp daemon mode normal logins are not sup-)5.747 F
(ported, and it must be used on a port other than the normal)173 606 Q F3
(TELNET)2.5 E F0(port.)2.5 E F2<ad44>103.666 624 Q F4(debugmode)6 E F0 .827
(This option may be used for deb)173 636 R .827(ugging purposes.)-.2 F .827
(This allo)5.827 F(ws)-.25 E F2(telnetd)3.327 E F0 .827(to print out de-)3.327
F -.2(bu)173 648 S .827(gging information to the connection, allo).2 F .827
(wing the user to see what)-.25 F F2(telnetd)3.327 E F0 .827(is doing.)3.327 F
(There are se)173 660 Q -.15(ve)-.25 G(ral possible v).15 E(alues for)-.25 E F4
(debugmode:)2.5 E F2(options)173 678 Q F0(Prints information about the ne)226
678 Q(gotiation of)-.15 E F3(TELNET)2.5 E F0(options.)2.5 E(4.2 Berk)72 750 Q
(ele)-.1 E 2.5(yD)-.15 G(istrib)132.57 750 Q 95.71(ution February)-.2 F
(3, 1994)2.5 E(1)535 750 Q EP
%%Page: 2 2
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF -.834(TELNETD \( 8 \))72 48 R(BSD System Manager')
241.42 48 Q 2.5(sM)-.55 G 105.272(anual TELNETD)348.92 48 R 1.666(\(8\))1.666 G
/F1 10/Courier-Bold@0 SF(report)173 96 Q F0 2.438(Prints the)226 96 R F1
(options)4.938 E F0 2.437(information, plus some additional information about)
4.938 F(what processing is going on.)226 108 Q F1(netdata)173 126 Q F0
(Displays the data stream recei)226 126 Q -.15(ve)-.25 G 2.5(db).15 G(y)367.51
126 Q F1(telnetd.)2.5 E(ptydata)173 144 Q F0(Displays data written to the pty)
226 144 Q(.)-.65 E F1(exercise)173 162 Q F0(Has not been implemented yet.)5 E
F1(\255debug)103.666 180 Q F0(Enables deb)173 180 Q(ugging on each sock)-.2 E
(et created by)-.1 E F1(telnetd)2.5 E F0(\(see)2.5 E/F2 10/Courier@0 SF
(SO_DEBUG)2.5 E F0(in)2.5 E F2(socket)2.5 E F0(\(2\)\).)A F1(\255edebug)103.666
198 Q F0(If)173 198 Q F1(telnetd)3.161 E F0 .662
(has been compiled with support for data encryption, then the)3.161 F F1
(\255edebug)4.828 E F0(op-)3.162 E(tion may be used to enable encryption deb)
173 210 Q(ugging code.)-.2 E F1<ad68>103.666 228 Q F0(Disables the printing of\
host-speci\214c information before login has been completed.)173 228 Q F1
<ad49>103.666 246 Q/F3 10/Courier-Oblique@0 SF(initid)7.171 E F0 1.171
(This option is only applicable to)174.171 246 R/F4 9/Times-Roman@0 SF(UNICOS)
3.671 E F0 1.171(systems prior to 7.0.)3.671 F 1.17(It speci\214es the)6.171 F
F2(ID)3.67 E F0(from)3.67 E F2(/etc/inittab)173 258 Q F0
(to use when init starts login sessions.)2.5 E(The def)5 E(ault)-.1 E F2(ID)2.5
E F0(is)2.5 E F2(fe.)2.5 E F1<ad6b>103.666 276 Q F0 .556
(This option is only useful if)173 276 R F1(telnetd)3.056 E F0 .557
(has been compiled with both linemode and kludge)3.056 F .521
(linemode support.)173 288 R .521(If the)5.521 F F1<ad6b>4.687 E F0 .52
(option is speci\214ed, then if the remote client does not support)3.02 F(the)
173 300 Q F2(LINEMODE)3.697 E F0 1.197(option, then)3.697 F F1(telnetd)3.697 E
F0 1.197(will operate in character at a time mode.)3.697 F 1.198(It will)6.198
F .148(still support kludge linemode, b)173 312 R .147
(ut will only go into kludge linemode if the remote client re-)-.2 F 2.06
(quests it.)173 324 R 2.061(\(This is done by by the client sending)7.06 F F2
2.061(DONT SUPPRESS-GO-AHEAD)4.561 F F0(and)4.561 E F2 .1(DONT ECHO)173 336 R
F0 .1(.\) The)B F1<ad6b>4.266 E F0 .1
(option is most useful when there are remote clients that do not sup-)2.6 F .67
(port kludge linemode, b)173 348 R .67(ut pass the heuristic \(if the)-.2 F
3.17(yr)-.15 G .67(espond with)390.88 348 R F2 .67(WILL TIMING-MARK)3.17 F F0
(in response to a)173 360 Q F2(DO TIMING-MARK\))2.5 E F0
(for kludge linemode support.)2.5 E F1<ad6c>103.666 378 Q F0 .672
(Speci\214es line mode.)173 378 R -.35(Tr)5.672 G .671
(ies to force clients to use line- at-a-time mode.).35 F .671(If the)5.671 F F2
(LINEMODE)3.171 E F0(option is not supported, it will go into kludge linemode.)
173 390 Q F1<ad6e>103.666 408 Q F0(Disable)173 408 Q F2(TCP)3.488 E F0 -.1(ke)
3.488 G(ep-ali).1 E -.15(ve)-.25 G 3.488(s. Normally).15 F F1(telnetd)3.488 E
F0 .988(enables the)3.488 F F4(TCP)3.489 E F0 -.1(ke)3.489 G(ep-ali).1 E 1.289
-.15(ve m)-.25 H .989(echanism to).15 F .602(probe connections that ha)173 420
R .902 -.15(ve b)-.2 H .602
(een idle for some period of time to determine if the client is).15 F 1.124
(still there, so that idle connections from machines that ha)173 432 R 1.424
-.15(ve c)-.2 H 1.124(rashed or can no longer be).15 F
(reached may be cleaned up.)173 444 Q F1<ad72>103.666 462 Q F3(lowpty-highpty)6
E F0 .772(This option is only enabled when)173 474 R F1(telnetd)3.272 E F0 .771
(is compiled for)3.271 F F2(UNICOS.)3.271 E F0 .771(It speci\214es an in-)3.271
F(clusi)173 486 Q 3.232 -.15(ve r)-.25 H 2.932(ange of pseudo-terminal de).15 F
2.932(vices to use.)-.25 F 2.933(If the system has sysconf v)7.933 F(ariable)
-.25 E F2(_SC_CRAY_NPTY)173 498 Q F0 1.486(con\214gured, the def)3.986 F 1.486
(ault pty search range is 0 to)-.1 F F2(_SC_CRAY_NPTY;)3.986 E F0 .72
(otherwise, the def)173 510 R .72(ault range is 0 to 128.)-.1 F(Either)5.72 E
F3(lowpty)3.22 E F0(or)3.22 E F3(highpty)3.22 E F0 .72(may be omitted to)3.22 F
(allo)173 522 Q 2.6(wc)-.25 G .1(hanging either end of the search range.)202.01
522 R(If)5.1 E F3(lowpty)2.6 E F0 .1(is omitted, the - character is still)2.6 F
(required so that)173 534 Q F1(telnetd)2.5 E F0(can dif)2.5 E(ferentiate)-.25 E
F3(highpty)2.5 E F0(from)2.5 E F3(lowpty)2.5 E F0(.)A F1<ad73>103.666 552 Q F0
1.391(This option is only enabled if)173 552 R F1(telnetd)3.891 E F0 1.391
(is compiled with support for)3.891 F F4(SecurID)3.891 E F0 3.891(cards. It)
3.891 F .787(causes the)173 564 R F1<ad73>4.953 E F0 .786
(option to be passed on to)3.286 F F2(login)3.286 E F0 4.072(\(1\), and)B .786
(thus is only useful if)3.286 F F2(login)3.286 E F0(\(1\))A .48(supports the)
173 576 R F1<ad73>4.646 E F0 .48(\215ag to indicate that only)2.98 F F4
(SecurID)2.98 E F0 -.25(va)2.98 G .481(lidated logins are allo).25 F .481
(wed, and is usu-)-.25 F
(ally useful for controlling remote logins from outside of a \214re)173 588 Q
-.1(wa)-.25 G(ll.).1 E F1<ad53>103.666 606 Q F3(tos)6 E F1<ad75>103.666 624 Q
F3(len)6.628 E F0 .628
(This option is used to specify the size of the \214eld in the)173.628 624 R F2
(utmp)3.127 E F0 .627(structure that holds the re-)3.127 F 1(mote host name.)
173 636 R 1(If the resolv)6 F 1(ed host name is longer than)-.15 F F3(len)3.5 E
F0 3.5(,t)C 1(he dotted decimal v)441.99 636 R(alue)-.25 E .046
(will be used instead.)173 648 R .046(This allo)5.046 F .046(ws hosts with v)
-.25 F .045(ery long host names that o)-.15 F -.15(ve)-.15 G(r\215o).15 E 2.545
(wt)-.25 G .045(his \214eld to)497.68 648 R .996
(still be uniquely identi\214ed.)173 660 R(Specifying)5.997 E F1(\255u0)5.163 E
F0 .997(indicates that only dotted decimal addresses)3.497 F
(should be put into the)173 672 Q F2(utmp)2.5 E F0(\214le.)2.5 E F1<ad55>
103.666 690 Q F0 .422(This option causes)173 690 R F1(telnetd)2.922 E F0 .422
(to refuse connections from addresses that cannot be mapped)2.922 F(4.2 Berk)72
750 Q(ele)-.1 E 2.5(yD)-.15 G(istrib)132.57 750 Q 95.71(ution February)-.2 F
(3, 1994)2.5 E(2)535 750 Q EP
%%Page: 3 3
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF -.834(TELNETD \( 8 \))72 48 R(BSD System Manager')
241.42 48 Q 2.5(sM)-.55 G 105.272(anual TELNETD)348.92 48 R 1.666(\(8\))1.666 G
(back into a symbolic name via the)173 96 Q/F1 10/Courier@0 SF(gethostbyaddr)
2.5 E F0(\(3\) routine.)A/F2 10/Courier-Bold@0 SF<ad58>103.666 114 Q/F3 10
/Courier-Oblique@0 SF(authtype)6 E F0 .123(This option is only v)173 126 R .123
(alid if)-.25 F F2(telnetd)2.623 E F0 .123(has been b)2.623 F .124
(uilt with support for the authentication op-)-.2 F 2.968(tion. It)173 138 R
.467(disables the use of)2.968 F F3(authtype)2.967 E F0 .467
(authentication, and can be used to temporarily dis-)2.967 F
(able a speci\214c authentication type without ha)173 150 Q(ving to recompile)
-.2 E F2(telnetd)2.5 E F0(.)A F2(Telnetd)102 168 Q F0 .851
(operates by allocating a pseudo-terminal de)3.351 F .851(vice \(see)-.25 F F1
(pty)3.351 E F0 4.202(\(4\)\) for)B 3.351(ac)3.351 G .852
(lient, then creating a login)431.882 168 R .757(process which has the sla)102
180 R 1.057 -.15(ve s)-.2 H .757(ide of the pseudo-terminal as).15 F F1(stdin)
3.257 E F0(,)A F1(stdout)3.256 E F0(and)3.256 E F1(stderr)3.256 E F0(.)A F2
(Telnetd)3.256 E F0(ma-)3.256 E .483
(nipulates the master side of the pseudo-terminal, implementing the)102 192 R
/F4 9/Times-Roman@0 SF(TELNET)2.984 E F0 .484(protocol and passing characters)
2.984 F(between the remote client and the login process.)102 204 Q .538(When a)
102 222 R F4(TELNET)3.038 E F0 .538(session is started up,)3.038 F F2(telnetd)
3.038 E F0(sends)3.038 E F4(TELNET)3.038 E F0 .538
(options to the client side indicating a will-)3.038 F(ingness to do the follo)
102 234 Q(wing)-.25 E F4(TELNET)2.5 E F0
(options, which are described in more detail belo)2.5 E(w:)-.25 E F1
(DO AUTHENTICATION)132 252 Q(WILL ENCRYPT)132 264 Q(DO TERMINAL TYPE)132 276 Q
(DO TSPEED)132 288 Q(DO XDISPLOC)132 300 Q(DO NEW-ENVIRON)132 312 Q(DO ENVIRON)
132 324 Q(WILL SUPPRESS GO AHEAD)132 336 Q(DO ECHO)132 348 Q(DO LINEMODE)132
360 Q(DO NAWS)132 372 Q(WILL STATUS)132 384 Q(DO LFLOW)132 396 Q
(DO TIMING-MARK)132 408 Q F0 .468(The pseudo-terminal allocated to the client \
is con\214gured to operate in cook)102 426 R .468(ed mode, and with)-.1 F F1
.469(XTABS and)2.969 F(CRMOD)102 438 Q F0(enabled \(see)2.5 E F1(tty)2.5 E F0
(\(4\)\).)A F2(Telnetd)102 456 Q F0(has support for enabling locally the follo)
2.5 E(wing)-.25 E F4(TELNET)2.5 E F0(options:)2.5 E .558(WILL ECHO)102 474 R
.558(When the)209.558 474 R F1(LINEMODE)3.057 E F0 .557(option is enabled, a)
3.057 F F1 .557(WILL ECHO)3.057 F F0(or)3.057 E F1 .557(WONT ECHO)3.057 F F0
.557(will be)3.057 F .487
(sent to the client to indicate the current state of terminal echoing.)209 486
R .487(When terminal)5.487 F .409(echo is not desired, a)209 498 R F1 .408
(WILL ECHO)2.908 F F0 .408(is sent to indicate that)2.908 F F4(telnetd)2.908 E
F0 .408(will tak)2.908 F 2.908(ec)-.1 G .408(are of)516.552 498 R 1.811
(echoing an)209 510 R 4.311(yd)-.15 G 1.811
(ata that needs to be echoed to the terminal, and then nothing is)268.572 510 R
3.876(echoed. When)209 522 R 1.376(terminal echo is desired, a)3.876 F F1 1.375
(WONT ECHO)3.875 F F0 1.375(is sent to indicate that)3.875 F F4(telnetd)209 534
Q F0 .11(will not be doing an)2.61 F 2.61(yt)-.15 G .11
(erminal echoing, so the client should do an)326.788 534 R 2.611(yt)-.15 G
(erminal)509.45 534 Q(echoing that is needed.)209 546 Q .243(WILL BIN)102 564 R
(AR)-.35 E 42.18(YI)-.65 G .243(ndicates that the client is willing to send a \
8 bits of data, rather than the normal 7)212.573 564 R(bits of the Netw)209 576
Q(ork V)-.1 E(irtual T)-.6 E(erminal.)-.7 E(WILL SGA)102 594 Q
(Indicates that it will not be sending)209 594 Q F1(IAC GA,)2.5 E F0
(go ahead, commands.)2.5 E .366(WILL ST)102 612 R -1.11(AT)-.93 G 41.27
(US Indicates)1.11 F 2.866(aw)2.866 G .366
(illingness to send the client, upon request, of the current status of all)
262.858 612 R F4(TELNET)209 624 Q F0(options.)2.5 E .51(WILL TIMING-MARK)102
642 R(Whene)209.51 642 Q -.15(ve)-.25 G 3.01(ra).15 G F1 .509(DO TIMING-MARK)
-.001 F F0 .509(command is recei)3.009 F -.15(ve)-.25 G .509(d, it is al).15 F
-.1(wa)-.1 G .509(ys responded to).1 F(with a)209 654 Q F1(WILL TIMING-MARK)2.5
E F0 .726(WILL LOGOUT)102 672 R .726(When a)209.726 672 R F1 .726(DO LOGOUT)
3.226 F F0 .726(is recei)3.226 F -.15(ve)-.25 G .726(d, a).15 F F1 .726
(WILL LOGOUT)3.226 F F0 .726(is sent in response, and the)3.226 F(4.2 Berk)72
750 Q(ele)-.1 E 2.5(yD)-.15 G(istrib)132.57 750 Q 95.71(ution February)-.2 F
(3, 1994)2.5 E(3)535 750 Q EP
%%Page: 4 4
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF -.834(TELNETD \( 8 \))72 48 R(BSD System Manager')
241.42 48 Q 2.5(sM)-.55 G 105.272(anual TELNETD)348.92 48 R 1.666(\(8\))1.666 G
/F1 9/Times-Roman@0 SF(TELNET)209 96 Q F0(session is shut do)2.5 E(wn.)-.25 E
.118(WILL ENCR)102 114 R 32.1(YPT Only)-.65 F .118(sent if)2.618 F/F2 10
/Courier-Bold@0 SF(telnetd)2.618 E F0 .118
(is compiled with support for data encryption, and indicates)2.618 F 2.5(aw)209
126 S(illingness to decrypt the data stream.)223.16 126 Q F2(Telnetd)102 144 Q
F0(has support for enabling remotely the follo)2.5 E(wing)-.25 E F1(TELNET)2.5
E F0(options:)2.5 E(DO BIN)102 162 Q(AR)-.35 E 52.73(YS)-.65 G
(ent to indicate that)214.56 162 Q F1(telnetd)2.5 E F0(is willing to recei)2.5
E .3 -.15(ve a)-.25 H 2.5(n8b).15 G(it data stream.)423.918 162 Q(DO LFLO)102
180 Q 55.97(WR)-.35 G(equests that the client handle \215o)215.67 180 Q 2.5(wc)
-.25 G(ontrol characters remotely)358.18 180 Q(.)-.65 E .967(DO ECHO)102 198 R
.967(This is not really supported, b)209.967 198 R .967
(ut is sent to identify a 4.2BSD)-.2 F/F3 10/Courier@0 SF(telnet)3.468 E F0
.968(\(1\) client,)B .365(which will improperly respond with)209 210 R F3 .365
(WILL ECHO.)2.865 F F0 .365(If a)2.865 F F3 .365(WILL ECHO)2.865 F F0 .365
(is recei)2.865 F -.15(ve)-.25 G(d,).15 E(a)209 222 Q F3(DONT ECHO)2.5 E F0
(will be sent in response.)2.5 E .445(DO TERMIN)102 240 R 7.92
(AL-TYPE Indicates)-.35 F 2.945(ad)2.945 G .445
(esire to be able to request the name of the type of terminal that is at-)
260.875 240 R(tached to the client side of the connection.)209 252 Q(DO SGA)102
270 Q(Indicates that it does not need to recei)209 270 Q -.15(ve)-.25 G F3
(IAC GA,)2.65 E F0(the go ahead command.)2.5 E .006(DO N)102 288 R -.9(AW)-.35
G 61.87(SR).9 G .006(equests that the client inform the serv)215.676 288 R .005
(er when the windo)-.15 F 2.505(w\()-.25 G .005(display\) size changes.)452.51
288 R(DO TERMIN)102 306 Q(AL-SPEED)-.35 E 1.029(Indicates a desire to be able \
to request information about the speed of the serial)209 318 R
(line to which the client is attached.)209 330 Q .469(DO XDISPLOC)102 348 R
.469(Indicates a desire to be able to request the name of the X windo)209.469
348 R .468(ws display that is)-.25 F(associated with the telnet client.)209 360
Q 1.008(DO NEW)102 378 R(-ENVIR)-.65 E 17.52(ON Indicates)-.4 F 3.508(ad)3.508
G 1.008(esire to be able to request en)262.564 378 R 1.009(vironment v)-.4 F
1.009(ariable information, as de-)-.25 F(scribed in RFC 1572.)209 390 Q 1.009
(DO ENVIR)102 408 R 42.97(ON Indicates)-.4 F 3.509(ad)3.509 G 1.009
(esire to be able to request en)262.567 408 R 1.008(vironment v)-.4 F 1.008
(ariable information, as de-)-.25 F(scribed in RFC 1408.)209 420 Q .886
(DO LINEMODE)102 438 R .886(Only sent if)209.886 438 R F2(telnetd)3.386 E F0
.886(is compiled with support for linemode, and requests that)3.386 F
(the client do line by line processing.)209 450 Q 1.292(DO TIMING-MARK)102 468
R 1.292(Only sent if)210.292 468 R F2(telnetd)3.792 E F0 1.291
(is compiled with support for both linemode and kludge)3.792 F 2.029
(linemode, and the client responded with)209 480 R F3 2.029(WONT LINEMODE.)
4.529 F F0 2.029(If the client re-)4.529 F 3.375(sponds with)209 492 R F3 3.375
(WILL TM,)5.875 F F0 3.375(the it is assumed that the client supports kludge)
5.875 F 2.5(linemode. Note)209 504 R(that the)2.5 E([)3.333 E F2<ad6b>2.499 E
F0 2.5(]o).833 G(ption can be used to disable this.)338.205 504 Q(DO A)102 522
Q(UTHENTICA)-.55 E(TION)-1.11 E .618(Only sent if)209 534 R F2(telnetd)3.118 E
F0 .618(is compiled with support for authentication, and indicates)3.118 F 2.5
(aw)209 546 S(illingness to recei)223.16 546 Q .3 -.15(ve a)-.25 H
(uthentication information for automatic login.).15 E .118(DO ENCR)102 564 R
42.65(YPT Only)-.65 F .118(sent if)2.618 F F2(telnetd)2.618 E F0 .118
(is compiled with support for data encryption, and indicates)2.618 F 2.5(aw)209
576 S(illingness to decrypt the data stream.)223.16 576 Q/F4 10/Times-Bold@0 SF
(ENVIR)72 600 Q(ONMENT)-.3 E(FILES)72 612 Q F3(/etc/services)102 624 Q
(/etc/inittab)102 636 Q F0(\(UNICOS systems only\))2.5 E F3(/etc/iptos)102 648
Q F0(\(if supported\))2.5 E F3(/usr/ucb/bftp)102 660 Q F0(\(if supported\))2.5
E(4.2 Berk)72 750 Q(ele)-.1 E 2.5(yD)-.15 G(istrib)132.57 750 Q 95.71
(ution February)-.2 F(3, 1994)2.5 E(4)535 750 Q EP
%%Page: 5 5
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF -.834(TELNETD \( 8 \))72 48 R(BSD System Manager')
241.42 48 Q 2.5(sM)-.55 G 105.272(anual TELNETD)348.92 48 R 1.666(\(8\))1.666 G
/F1 10/Times-Bold@0 SF(SEE ALSO)72 96 Q/F2 10/Courier@0 SF(telnet)102 108 Q F0
(\(1\),)A F2(login)5 E F0(\(1\),)A F2(bftp)5 E F0(\(1\) \(if supported\))A F1
(ST)72 132 Q(AND)-.9 E(ARDS)-.35 E/F3 10/Courier-Bold@0 SF(RFC-854)102 144 Q/F4
9/Times-Roman@0 SF(TELNET)155 144 Q F0(PR)2.5 E -1.88 -.4(OT O)-.4 H
(COL SPECIFICA).4 E(TION)-1.11 E F3(RFC-855)102 156 Q F0
(TELNET OPTION SPECIFICA)155 156 Q(TIONS)-1.11 E F3(RFC-856)102 168 Q F0
(TELNET BIN)155 168 Q(AR)-.35 E 2.5(YT)-.65 G(RANSMISSION)241.21 168 Q F3
(RFC-857)102 180 Q F0(TELNET ECHO OPTION)155 180 Q F3(RFC-858)102 192 Q F0
(TELNET SUPPRESS GO AHEAD OPTION)155 192 Q F3(RFC-859)102 204 Q F0(TELNET ST)
155 204 Q -1.11(AT)-.93 G(US OPTION)1.11 E F3(RFC-860)102 216 Q F0
(TELNET TIMING MARK OPTION)155 216 Q F3(RFC-861)102 228 Q F0
(TELNET EXTENDED OPTIONS - LIST OPTION)155 228 Q F3(RFC-885)102 240 Q F0
(TELNET END OF RECORD OPTION)155 240 Q F3(RFC-1073)102 252 Q F0 -.7(Te)5 G
(lnet W).7 E(indo)-.4 E 2.5(wS)-.25 G(ize Option)224.2 252 Q F3(RFC-1079)102
264 Q F0 -.7(Te)5 G(lnet T).7 E(erminal Speed Option)-.7 E F3(RFC-1091)102 276
Q F0 -.7(Te)5 G(lnet T).7 E(erminal-T)-.7 E(ype Option)-.8 E F3(RFC-1096)102
288 Q F0 -.7(Te)5 G(lnet X Display Location Option).7 E F3(RFC-1123)102 300 Q
F0(Requirements for Internet Hosts -- Application and Support)5 E F3(RFC-1184)
102 312 Q F0 -.7(Te)5 G(lnet Linemode Option).7 E F3(RFC-1372)102 324 Q F0 -.7
(Te)5 G(lnet Remote Flo).7 E 2.5(wC)-.25 G(ontrol Option)245.44 324 Q F3
(RFC-1416)102 336 Q F0 -.7(Te)5 G(lnet Authentication Option).7 E F3(RFC-1411)
102 348 Q F0 -.7(Te)5 G(lnet Authentication: K).7 E(erberos V)-.25 E(ersion 4)
-1.11 E F3(RFC-1412)102 360 Q F0 -.7(Te)5 G(lnet Authentication: SPX).7 E F3
(RFC-1571)102 372 Q F0 -.7(Te)5 G(lnet En).7 E
(vironment Option Interoperability Issues)-.4 E F3(RFC-1572)102 384 Q F0 -.7
(Te)5 G(lnet En).7 E(vironment Option)-.4 E F1 -.1(BU)72 408 S(GS).1 E F0(Some)
102 420 Q F4(TELNET)2.5 E F0(commands are only partially implemented.)2.5 E
.082(Because of b)102 438 R .082(ugs in the original 4.2 BSD)-.2 F F2(telnet)
2.582 E F0(\(1\),)A F3(telnetd)5.164 E F0 .082
(performs some dubious protocol e)2.582 F(xchanges)-.15 E(to try to disco)102
450 Q -.15(ve)-.15 G 2.5(ri).15 G 2.5(ft)175.03 450 S
(he remote client is, in f)183.64 450 Q(act, a 4.2 BSD)-.1 E F2(telnet)2.5 E F0
(\(1\).)A(Binary mode has no common interpretation e)102 468 Q
(xcept between similar operating systems \(Unix in this case\).)-.15 E
(The terminal type name recei)102 486 Q -.15(ve)-.25 G 2.5(df).15 G
(rom the remote client is con)239.06 486 Q -.15(ve)-.4 G(rted to lo).15 E
(wer case.)-.25 E F3(Telnetd)102 504 Q F0(ne)2.5 E -.15(ve)-.25 G 2.5(rs).15 G
(ends)174.7 504 Q F4(TELNET)2.5 E F2(IAC GA)2.5 E F0(\(go ahead\) commands.)2.5
E(4.2 Berk)72 750 Q(ele)-.1 E 2.5(yD)-.15 G(istrib)132.57 750 Q 95.71
(ution February)-.2 F(3, 1994)2.5 E(5)535 750 Q EP
%%Trailer
end
%%EOF

View File

@@ -0,0 +1,322 @@
TELNETD(8) BSD System Manager's Manual TELNETD(8)
NNAAMMEE
tteellnneettdd - DARPA TELNET protocol server
SSYYNNOOPPSSIISS
//uussrr//lliibbeexxeecc//tteellnneettdd [--BBUUhhllkknnss] [--DD _d_e_b_u_g_m_o_d_e] [--II_i_n_i_t_i_d] [--SS _t_o_s] [--XX
_a_u_t_h_t_y_p_e] [--aa _a_u_t_h_m_o_d_e] [--eeddeebbuugg] [--rr_l_o_w_p_t_y_-_h_i_g_h_p_t_y]
[--uu _l_e_n] [--ddeebbuugg [_p_o_r_t]]
DDEESSCCRRIIPPTTIIOONN
The tteellnneettdd command is a server which supports the DARPA standard TELNET
virtual terminal protocol. TTeellnneettdd is normally invoked by the internet
server (see inetd(8)) for requests to connect to the TELNET port as in-
dicated by the _/_e_t_c_/_s_e_r_v_i_c_e_s file (see services(5)). The --ddeebbuugg option
may be used to start up tteellnneettdd manually, instead of through inetd(8).
If started up this way, _p_o_r_t may be specified to run tteellnneettdd on an alter-
nate TCP port number.
The tteellnneettdd command accepts the following options:
--aa _a_u_t_h_m_o_d_e This option may be used for specifying what mode should be
used for authentication. Note that this option is only use-
ful if tteellnneettdd has been compiled with support for the
AUTHENTICATION option. There are several valid values for
_a_u_t_h_m_o_d_e_:
debug Turns on authentication debugging code.
user Only allow connections when the remote user can pro-
vide valid authentication information to identify the
remote user, and is allowed access to the specified
account without providing a password.
valid Only allow connections when the remote user can pro-
vide valid authentication information to identify the
remote user. The login(1) command will provide any
additional user verification needed if the remote us-
er is not allowed automatic access to the specified
account.
other Only allow connections that supply some authentica-
tion information. This option is currently not sup-
ported by any of the existing authentication mecha-
nisms, and is thus the same as specifying --aa vvaalliidd.
none This is the default state. Authentication informa-
tion is not required. If no or insufficient authen-
tication information is provided, then the login(1)
program will provide the necessary user verification.
off This disables the authentication code. All user ver-
ification will happen through the login(1) program.
--BB Specifies bftp server mode. In this mode, tteellnneettdd causes
login to start a bftp(1) session rather than the user's nor-
mal shell. In bftp daemon mode normal logins are not sup-
ported, and it must be used on a port other than the normal
TELNET port.
--DD _d_e_b_u_g_m_o_d_e
This option may be used for debugging purposes. This allows
tteellnneettdd to print out debugging information to the connec-
tion, allowing the user to see what tteellnneettdd is doing. There
are several possible values for _d_e_b_u_g_m_o_d_e_:
ooppttiioonnss Prints information about the negotiation of TELNET
options.
rreeppoorrtt Prints the ooppttiioonnss information, plus some addi-
tional information about what processing is going
on.
nneettddaattaa Displays the data stream received by tteellnneettdd..
ppttyyddaattaa Displays data written to the pty.
eexxeerrcciissee Has not been implemented yet.
--ddeebbuugg Enables debugging on each socket created by tteellnneettdd (see
SO_DEBUG in socket(2)).
--eeddeebbuugg If tteellnneettdd has been compiled with support for data encryp-
tion, then the --eeddeebbuugg option may be used to enable encryp-
tion debugging code.
--hh Disables the printing of host-specific information before
login has been completed.
--II _i_n_i_t_i_d This option is only applicable to UNICOS systems prior to
7.0. It specifies the ID from _/_e_t_c_/_i_n_i_t_t_a_b to use when init
starts login sessions. The default ID is fe.
--kk This option is only useful if tteellnneettdd has been compiled with
both linemode and kludge linemode support. If the --kk option
is specified, then if the remote client does not support the
LINEMODE option, then tteellnneettdd will operate in character at a
time mode. It will still support kludge linemode, but will
only go into kludge linemode if the remote client requests
it. (This is done by by the client sending DONT SUPPRESS-
GO-AHEAD and DONT ECHO.) The --kk option is most useful when
there are remote clients that do not support kludge
linemode, but pass the heuristic (if they respond with WILL
TIMING-MARK in response to a DO TIMING-MARK) for kludge
linemode support.
--ll Specifies line mode. Tries to force clients to use line-
at-a-time mode. If the LINEMODE option is not supported, it
will go into kludge linemode.
--nn Disable TCP keep-alives. Normally tteellnneettdd enables the TCP
keep-alive mechanism to probe connections that have been
idle for some period of time to determine if the client is
still there, so that idle connections from machines that
have crashed or can no longer be reached may be cleaned up.
--rr _l_o_w_p_t_y_-_h_i_g_h_p_t_y
This option is only enabled when tteellnneettdd is compiled for
UNICOS. It specifies an inclusive range of pseudo-terminal
devices to use. If the system has sysconf variable
_SC_CRAY_NPTY configured, the default pty search range is 0
to _SC_CRAY_NPTY; otherwise, the default range is 0 to 128.
Either _l_o_w_p_t_y or _h_i_g_h_p_t_y may be omitted to allow changing
either end of the search range. If _l_o_w_p_t_y is omitted, the -
character is still required so that tteellnneettdd can differenti-
ate _h_i_g_h_p_t_y from _l_o_w_p_t_y.
--ss This option is only enabled if tteellnneettdd is compiled with sup-
port for SecurID cards. It causes the --ss option to be
passed on to login(1), and thus is only useful if login(1)
supports the --ss flag to indicate that only SecurID validated
logins are allowed, and is usually useful for controlling
remote logins from outside of a firewall.
--SS _t_o_s
--uu _l_e_n This option is used to specify the size of the field in the
utmp structure that holds the remote host name. If the re-
solved host name is longer than _l_e_n, the dotted decimal val-
ue will be used instead. This allows hosts with very long
host names that overflow this field to still be uniquely
identified. Specifying --uu00 indicates that only dotted deci-
mal addresses should be put into the _u_t_m_p file.
--UU This option causes tteellnneettdd to refuse connections from ad-
dresses that cannot be mapped back into a symbolic name via
the gethostbyaddr(3) routine.
--XX _a_u_t_h_t_y_p_e This option is only valid if tteellnneettdd has been built with
support for the authentication option. It disables the use
of _a_u_t_h_t_y_p_e authentication, and can be used to temporarily
disable a specific authentication type without having to re-
compile tteellnneettdd.
TTeellnneettdd operates by allocating a pseudo-terminal device (see pty(4)) for
a client, then creating a login process which has the slave side of the
pseudo-terminal as stdin, stdout and stderr. TTeellnneettdd manipulates the mas-
ter side of the pseudo-terminal, implementing the TELNET protocol and
passing characters between the remote client and the login process.
When a TELNET session is started up, tteellnneettdd sends TELNET options to the
client side indicating a willingness to do the following TELNET options,
which are described in more detail below:
DO AUTHENTICATION
WILL ENCRYPT
DO TERMINAL TYPE
DO TSPEED
DO XDISPLOC
DO NEW-ENVIRON
DO ENVIRON
WILL SUPPRESS GO AHEAD
DO ECHO
DO LINEMODE
DO NAWS
WILL STATUS
DO LFLOW
DO TIMING-MARK
The pseudo-terminal allocated to the client is configured to operate in
cooked mode, and with XTABS and CRMOD enabled (see tty(4)).
TTeellnneettdd has support for enabling locally the following TELNET options:
WILL ECHO When the LINEMODE option is enabled, a WILL ECHO or
WONT ECHO will be sent to the client to indicate the
current state of terminal echoing. When terminal echo
is not desired, a WILL ECHO is sent to indicate that
telnetd will take care of echoing any data that needs
to be echoed to the terminal, and then nothing is
echoed. When terminal echo is desired, a WONT ECHO is
sent to indicate that telnetd will not be doing any
terminal echoing, so the client should do any terminal
echoing that is needed.
WILL BINARY Indicates that the client is willing to send a 8 bits
of data, rather than the normal 7 bits of the Network
Virtual Terminal.
WILL SGA Indicates that it will not be sending IAC GA, go
ahead, commands.
WILL STATUS Indicates a willingness to send the client, upon re-
quest, of the current status of all TELNET options.
WILL TIMING-MARK Whenever a DO TIMING-MARK command is received, it is
always responded to with a WILL TIMING-MARK
WILL LOGOUT When a DO LOGOUT is received, a WILL LOGOUT is sent in
response, and the TELNET session is shut down.
WILL ENCRYPT Only sent if tteellnneettdd is compiled with support for data
encryption, and indicates a willingness to decrypt the
data stream.
TTeellnneettdd has support for enabling remotely the following TELNET options:
DO BINARY Sent to indicate that telnetd is willing to receive an
8 bit data stream.
DO LFLOW Requests that the client handle flow control charac-
ters remotely.
DO ECHO This is not really supported, but is sent to identify
a 4.2BSD telnet(1) client, which will improperly re-
spond with WILL ECHO. If a WILL ECHO is received, a
DONT ECHO will be sent in response.
DO TERMINAL-TYPE Indicates a desire to be able to request the name of
the type of terminal that is attached to the client
side of the connection.
DO SGA Indicates that it does not need to receive IAC GA, the
go ahead command.
DO NAWS Requests that the client inform the server when the
window (display) size changes.
DO TERMINAL-SPEED Indicates a desire to be able to request information
about the speed of the serial line to which the client
is attached.
DO XDISPLOC Indicates a desire to be able to request the name of
the X windows display that is associated with the tel-
net client.
DO NEW-ENVIRON Indicates a desire to be able to request environment
variable information, as described in RFC 1572.
DO ENVIRON Indicates a desire to be able to request environment
variable information, as described in RFC 1408.
DO LINEMODE Only sent if tteellnneettdd is compiled with support for
linemode, and requests that the client do line by line
processing.
DO TIMING-MARK Only sent if tteellnneettdd is compiled with support for both
linemode and kludge linemode, and the client responded
with WONT LINEMODE. If the client responds with WILL
TM, the it is assumed that the client supports kludge
linemode. Note that the [--kk] option can be used to
disable this.
DO AUTHENTICATION Only sent if tteellnneettdd is compiled with support for au-
thentication, and indicates a willingness to receive
authentication information for automatic login.
DO ENCRYPT Only sent if tteellnneettdd is compiled with support for data
encryption, and indicates a willingness to decrypt the
data stream.
EENNVVIIRROONNMMEENNTT
FFIILLEESS
_/_e_t_c_/_s_e_r_v_i_c_e_s
_/_e_t_c_/_i_n_i_t_t_a_b (UNICOS systems only)
_/_e_t_c_/_i_p_t_o_s (if supported)
_/_u_s_r_/_u_c_b_/_b_f_t_p (if supported)
SSEEEE AALLSSOO
telnet(1), login(1), bftp(1) (if supported)
SSTTAANNDDAARRDDSS
RRFFCC--885544 TELNET PROTOCOL SPECIFICATION
RRFFCC--885555 TELNET OPTION SPECIFICATIONS
RRFFCC--885566 TELNET BINARY TRANSMISSION
RRFFCC--885577 TELNET ECHO OPTION
RRFFCC--885588 TELNET SUPPRESS GO AHEAD OPTION
RRFFCC--885599 TELNET STATUS OPTION
RRFFCC--886600 TELNET TIMING MARK OPTION
RRFFCC--886611 TELNET EXTENDED OPTIONS - LIST OPTION
RRFFCC--888855 TELNET END OF RECORD OPTION
RRFFCC--11007733 Telnet Window Size Option
RRFFCC--11007799 Telnet Terminal Speed Option
RRFFCC--11009911 Telnet Terminal-Type Option
RRFFCC--11009966 Telnet X Display Location Option
RRFFCC--11112233 Requirements for Internet Hosts -- Application and Support
RRFFCC--11118844 Telnet Linemode Option
RRFFCC--11337722 Telnet Remote Flow Control Option
RRFFCC--11441166 Telnet Authentication Option
RRFFCC--11441111 Telnet Authentication: Kerberos Version 4
RRFFCC--11441122 Telnet Authentication: SPX
RRFFCC--11557711 Telnet Environment Option Interoperability Issues
RRFFCC--11557722 Telnet Environment Option
BBUUGGSS
Some TELNET commands are only partially implemented.
Because of bugs in the original 4.2 BSD telnet(1), tteellnneettdd performs some
dubious protocol exchanges to try to discover if the remote client is, in
fact, a 4.2 BSD telnet(1).
Binary mode has no common interpretation except between similar operating
systems (Unix in this case).
The terminal type name received from the remote client is converted to
lower case.
TTeellnneettdd never sends TELNET IAC GA (go ahead) commands.
4.2 Berkeley Distribution June 1, 1994 5

View File

@@ -0,0 +1,607 @@
.\" Copyright (c) 1983, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)telnetd.8 8.4 (Berkeley) 6/1/94
.\"
.Dd June 1, 1994
.Dt TELNETD 8
.Os BSD 4.2
.Sh NAME
.Nm telnetd
.Nd DARPA
.Tn TELNET
protocol server
.Sh SYNOPSIS
.Nm /usr/libexec/telnetd
.Op Fl BUhlkns
.Op Fl D Ar debugmode
.Op Fl I Ns Ar initid
.Op Fl S Ar tos
.Op Fl X Ar authtype
.Op Fl a Ar authmode
.Op Fl edebug
.Op Fl r Ns Ar lowpty-highpty
.Op Fl u Ar len
.Op Fl debug Op Ar port
.Sh DESCRIPTION
The
.Nm telnetd
command is a server which supports the
.Tn DARPA
standard
.Tn TELNET
virtual terminal protocol.
.Nm Telnetd
is normally invoked by the internet server (see
.Xr inetd 8 )
for requests to connect to the
.Tn TELNET
port as indicated by the
.Pa /etc/services
file (see
.Xr services 5 ) .
The
.Fl debug
option may be used to start up
.Nm telnetd
manually, instead of through
.Xr inetd 8 .
If started up this way,
.Ar port
may be specified to run
.Nm telnetd
on an alternate
.Tn TCP
port number.
.Pp
The
.Nm telnetd
command accepts the following options:
.Bl -tag -width "-a authmode"
.It Fl a Ar authmode
This option may be used for specifying what mode should
be used for authentication.
Note that this option is only useful if
.Nm telnetd
has been compiled with support for the
.Dv AUTHENTICATION
option.
There are several valid values for
.Ar authmode:
.Bl -tag -width debug
.It debug
Turns on authentication debugging code.
.It user
Only allow connections when the remote user
can provide valid authentication information
to identify the remote user,
and is allowed access to the specified account
without providing a password.
.It valid
Only allow connections when the remote user
can provide valid authentication information
to identify the remote user.
The
.Xr login 1
command will provide any additional user verification
needed if the remote user is not allowed automatic
access to the specified account.
.It other
Only allow connections that supply some authentication information.
This option is currently not supported
by any of the existing authentication mechanisms,
and is thus the same as specifying
.Fl a
.Cm valid .
.It none
This is the default state.
Authentication information is not required.
If no or insufficient authentication information
is provided, then the
.Xr login 1
program will provide the necessary user
verification.
.It off
This disables the authentication code.
All user verification will happen through the
.Xr login 1
program.
.El
.It Fl B
Specifies bftp server mode. In this mode,
.Nm telnetd
causes login to start a
.Xr bftp 1
session rather than the user's
normal shell. In bftp daemon mode normal
logins are not supported, and it must be used
on a port other than the normal
.Tn TELNET
port.
.It Fl D Ar debugmode
This option may be used for debugging purposes.
This allows
.Nm telnetd
to print out debugging information
to the connection, allowing the user to see what
.Nm telnetd
is doing.
There are several possible values for
.Ar debugmode:
.Bl -tag -width exercise
.It Cm options
Prints information about the negotiation of
.Tn TELNET
options.
.It Cm report
Prints the
.Cm options
information, plus some additional information
about what processing is going on.
.It Cm netdata
Displays the data stream received by
.Nm telnetd.
.It Cm ptydata
Displays data written to the pty.
.It Cm exercise
Has not been implemented yet.
.El
.It Fl debug
Enables debugging on each socket created by
.Nm telnetd
(see
.Dv SO_DEBUG
in
.Xr socket 2 ) .
.It Fl edebug
If
.Nm telnetd
has been compiled with support for data encryption, then the
.Fl edebug
option may be used to enable encryption debugging code.
.It Fl h
Disables the printing of host-specific information before
login has been completed.
.It Fl I Ar initid
This option is only applicable to
.Tn UNICOS
systems prior to 7.0.
It specifies the
.Dv ID
from
.Pa /etc/inittab
to use when init starts login sessions. The default
.Dv ID
is
.Dv fe.
.It Fl k
This option is only useful if
.Nm telnetd
has been compiled with both linemode and kludge linemode
support. If the
.Fl k
option is specified, then if the remote client does not
support the
.Dv LINEMODE
option, then
.Nm telnetd
will operate in character at a time mode.
It will still support kludge linemode, but will only
go into kludge linemode if the remote client requests
it.
(This is done by by the client sending
.Dv DONT SUPPRESS-GO-AHEAD
and
.Dv DONT ECHO . )
The
.Fl k
option is most useful when there are remote clients
that do not support kludge linemode, but pass the heuristic
(if they respond with
.Dv WILL TIMING-MARK
in response to a
.Dv DO TIMING-MARK)
for kludge linemode support.
.It Fl l
Specifies line mode. Tries to force clients to use line-
at-a-time mode.
If the
.Dv LINEMODE
option is not supported, it will go
into kludge linemode.
.It Fl n
Disable
.Dv TCP
keep-alives. Normally
.Nm telnetd
enables the
.Tn TCP
keep-alive mechanism to probe connections that
have been idle for some period of time to determine
if the client is still there, so that idle connections
from machines that have crashed or can no longer
be reached may be cleaned up.
.It Fl r Ar lowpty-highpty
This option is only enabled when
.Nm telnetd
is compiled for
.Dv UNICOS.
It specifies an inclusive range of pseudo-terminal devices to
use. If the system has sysconf variable
.Dv _SC_CRAY_NPTY
configured, the default pty search range is 0 to
.Dv _SC_CRAY_NPTY;
otherwise, the default range is 0 to 128. Either
.Ar lowpty
or
.Ar highpty
may be omitted to allow changing
either end of the search range. If
.Ar lowpty
is omitted, the - character is still required so that
.Nm telnetd
can differentiate
.Ar highpty
from
.Ar lowpty .
.It Fl s
This option is only enabled if
.Nm telnetd
is compiled with support for
.Tn SecurID
cards.
It causes the
.Fl s
option to be passed on to
.Xr login 1 ,
and thus is only useful if
.Xr login 1
supports the
.Fl s
flag to indicate that only
.Tn SecurID
validated logins are allowed, and is
usually useful for controlling remote logins
from outside of a firewall.
.It Fl S Ar tos
.It Fl u Ar len
This option is used to specify the size of the field
in the
.Dv utmp
structure that holds the remote host name.
If the resolved host name is longer than
.Ar len ,
the dotted decimal value will be used instead.
This allows hosts with very long host names that
overflow this field to still be uniquely identified.
Specifying
.Fl u0
indicates that only dotted decimal addresses
should be put into the
.Pa utmp
file.
.ne 1i
.It Fl U
This option causes
.Nm telnetd
to refuse connections from addresses that
cannot be mapped back into a symbolic name
via the
.Xr gethostbyaddr 3
routine.
.It Fl X Ar authtype
This option is only valid if
.Nm telnetd
has been built with support for the authentication option.
It disables the use of
.Ar authtype
authentication, and
can be used to temporarily disable
a specific authentication type without having to recompile
.Nm telnetd .
.El
.Pp
.Nm Telnetd
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
.Dv stdin ,
.Dv stdout
and
.Dv stderr .
.Nm Telnetd
manipulates the master side of the pseudo-terminal,
implementing the
.Tn TELNET
protocol and passing characters
between the remote client and the login process.
.Pp
When a
.Tn TELNET
session is started up,
.Nm telnetd
sends
.Tn TELNET
options to the client side indicating
a willingness to do the
following
.Tn TELNET
options, which are described in more detail below:
.Bd -literal -offset indent
DO AUTHENTICATION
WILL ENCRYPT
DO TERMINAL TYPE
DO TSPEED
DO XDISPLOC
DO NEW-ENVIRON
DO ENVIRON
WILL SUPPRESS GO AHEAD
DO ECHO
DO LINEMODE
DO NAWS
WILL STATUS
DO LFLOW
DO TIMING-MARK
.Ed
.Pp
The pseudo-terminal allocated to the client is configured
to operate in \*(lqcooked\*(rq mode, and with
.Dv XTABS and
.Dv CRMOD
enabled (see
.Xr tty 4 ) .
.Pp
.Nm Telnetd
has support for enabling locally the following
.Tn TELNET
options:
.Bl -tag -width "DO AUTHENTICATION"
.It "WILL ECHO"
When the
.Dv LINEMODE
option is enabled, a
.Dv WILL ECHO
or
.Dv WONT ECHO
will be sent to the client to indicate the
current state of terminal echoing.
When terminal echo is not desired, a
.Dv WILL ECHO
is sent to indicate that
.Tn telnetd
will take care of echoing any data that needs to be
echoed to the terminal, and then nothing is echoed.
When terminal echo is desired, a
.Dv WONT ECHO
is sent to indicate that
.Tn telnetd
will not be doing any terminal echoing, so the
client should do any terminal echoing that is needed.
.It "WILL BINARY"
Indicates that the client is willing to send a
8 bits of data, rather than the normal 7 bits
of the Network Virtual Terminal.
.It "WILL SGA"
Indicates that it will not be sending
.Dv IAC GA,
go ahead, commands.
.It "WILL STATUS"
Indicates a willingness to send the client, upon
request, of the current status of all
.Tn TELNET
options.
.It "WILL TIMING-MARK"
Whenever a
.Dv DO TIMING-MARK
command is received, it is always responded
to with a
.Dv WILL TIMING-MARK
.ne 1i
.It "WILL LOGOUT"
When a
.Dv DO LOGOUT
is received, a
.Dv WILL LOGOUT
is sent in response, and the
.Tn TELNET
session is shut down.
.It "WILL ENCRYPT"
Only sent if
.Nm telnetd
is compiled with support for data encryption, and
indicates a willingness to decrypt
the data stream.
.El
.Pp
.Nm Telnetd
has support for enabling remotely the following
.Tn TELNET
options:
.Bl -tag -width "DO AUTHENTICATION"
.It "DO BINARY"
Sent to indicate that
.Tn telnetd
is willing to receive an 8 bit data stream.
.It "DO LFLOW"
Requests that the client handle flow control
characters remotely.
.It "DO ECHO"
This is not really supported, but is sent to identify a 4.2BSD
.Xr telnet 1
client, which will improperly respond with
.Dv WILL ECHO.
If a
.Dv WILL ECHO
is received, a
.Dv DONT ECHO
will be sent in response.
.It "DO TERMINAL-TYPE"
Indicates a desire to be able to request the
name of the type of terminal that is attached
to the client side of the connection.
.It "DO SGA"
Indicates that it does not need to receive
.Dv IAC GA,
the go ahead command.
.It "DO NAWS"
Requests that the client inform the server when
the window (display) size changes.
.It "DO TERMINAL-SPEED"
Indicates a desire to be able to request information
about the speed of the serial line to which
the client is attached.
.It "DO XDISPLOC"
Indicates a desire to be able to request the name
of the X windows display that is associated with
the telnet client.
.It "DO NEW-ENVIRON"
Indicates a desire to be able to request environment
variable information, as described in RFC 1572.
.It "DO ENVIRON"
Indicates a desire to be able to request environment
variable information, as described in RFC 1408.
.It "DO LINEMODE"
Only sent if
.Nm telnetd
is compiled with support for linemode, and
requests that the client do line by line processing.
.It "DO TIMING-MARK"
Only sent if
.Nm telnetd
is compiled with support for both linemode and
kludge linemode, and the client responded with
.Dv WONT LINEMODE.
If the client responds with
.Dv WILL TM,
the it is assumed that the client supports
kludge linemode.
Note that the
.Op Fl k
option can be used to disable this.
.It "DO AUTHENTICATION"
Only sent if
.Nm telnetd
is compiled with support for authentication, and
indicates a willingness to receive authentication
information for automatic login.
.It "DO ENCRYPT"
Only sent if
.Nm telnetd
is compiled with support for data encryption, and
indicates a willingness to decrypt
the data stream.
.Sh ENVIRONMENT
.Sh FILES
.Pa /etc/services
.br
.Pa /etc/inittab
(UNICOS systems only)
.br
.Pa /etc/iptos
(if supported)
.br
.Pa /usr/ucb/bftp
(if supported)
.Sh "SEE ALSO"
.Xr telnet 1 ,
.Xr login 1 ,
.Xr bftp 1
(if supported)
.Sh STANDARDS
.Bl -tag -compact -width RFC-1572
.It Cm RFC-854
.Tn TELNET
PROTOCOL SPECIFICATION
.It Cm RFC-855
TELNET OPTION SPECIFICATIONS
.It Cm RFC-856
TELNET BINARY TRANSMISSION
.It Cm RFC-857
TELNET ECHO OPTION
.It Cm RFC-858
TELNET SUPPRESS GO AHEAD OPTION
.It Cm RFC-859
TELNET STATUS OPTION
.It Cm RFC-860
TELNET TIMING MARK OPTION
.It Cm RFC-861
TELNET EXTENDED OPTIONS - LIST OPTION
.It Cm RFC-885
TELNET END OF RECORD OPTION
.It Cm RFC-1073
Telnet Window Size Option
.It Cm RFC-1079
Telnet Terminal Speed Option
.It Cm RFC-1091
Telnet Terminal-Type Option
.It Cm RFC-1096
Telnet X Display Location Option
.It Cm RFC-1123
Requirements for Internet Hosts -- Application and Support
.It Cm RFC-1184
Telnet Linemode Option
.It Cm RFC-1372
Telnet Remote Flow Control Option
.It Cm RFC-1416
Telnet Authentication Option
.It Cm RFC-1411
Telnet Authentication: Kerberos Version 4
.It Cm RFC-1412
Telnet Authentication: SPX
.It Cm RFC-1571
Telnet Environment Option Interoperability Issues
.It Cm RFC-1572
Telnet Environment Option
.Sh BUGS
Some
.Tn TELNET
commands are only partially implemented.
.Pp
Because of bugs in the original 4.2 BSD
.Xr telnet 1 ,
.Nm telnetd
performs some dubious protocol exchanges to try to discover if the remote
client is, in fact, a 4.2 BSD
.Xr telnet 1 .
.Pp
Binary mode
has no common interpretation except between similar operating systems
(Unix in this case).
.Pp
The terminal type name received from the remote client is converted to
lower case.
.Pp
.Nm Telnetd
never sends
.Tn TELNET
.Dv IAC GA
(go ahead) commands.

View File

@@ -0,0 +1,49 @@
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)telnetd.h 8.1 (Berkeley) 6/4/93
*/
#include "defs.h"
#include "ext.h"
#ifdef DIAGNOSTICS
#define DIAG(a,b) if (diagnostic & (a)) b
#else
#define DIAG(a,b)
#endif
/* other external variables */
extern char **environ;
extern int errno;

21
appl/xnlock/README Normal file
View File

@@ -0,0 +1,21 @@
xnlock -- Dan Heller, 1990
"nlock" is a "new lockscreen" type program... something that prevents
screen burnout by making most of it "black" while providing something
of interest to be displayed in case anyone is watching. The program
also provides added security.
"xnlock" is the X11 version of the program.
Original sunview version written by Dan Heller 1985 (not included).
For a real description of how this program works, read the
man page or just try running it.
The one major outstanding bug with this program is that every
once in a while, two horizontal lines appear below the little
figure that runs around the screen. If someone can find and
fix this bug, *please* let me know -- I don't have time to
look and if I waited till I had time, you'd never see this
program... It has something to do with the "looking down"
position and then directly moving up and right or left...

38
appl/xnlock/nose.0.left Normal file
View File

@@ -0,0 +1,38 @@
#define nose_0_left_width 64
#define nose_0_left_height 64
static char nose_0_left_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x40,0x00,
0x00,0x04,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x40,
0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x04,0x00,0x00,0x00,0x00,
0x40,0x00,0x00,0x04,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,
0x08,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x20,0x00,
0x00,0xf8,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0xf0,0x03,0x00,0x00,0x80,0x00,
0x00,0x00,0x0e,0x0c,0x00,0x00,0x80,0x01,0x00,0x00,0x03,0x30,0x00,0x00,0x00,
0x01,0x00,0x80,0x00,0x40,0x00,0x00,0x00,0x02,0x00,0x40,0x00,0xc0,0x00,0x00,
0x00,0x02,0x00,0x20,0x00,0x80,0x00,0x00,0x00,0x04,0x00,0x10,0x00,0x00,0x00,
0x00,0x00,0x04,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x08,0x00,0x00,
0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,
0x00,0x00,0x00,0x00,0x10,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x08,
0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x10,0x00,
0x08,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x10,
0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x00,0x01,0x00,0x00,
0x18,0x00,0x20,0x00,0x00,0x01,0x00,0x00,0x08,0x00,0x40,0x00,0x80,0x00,0x00,
0x00,0x08,0x00,0x80,0x00,0x40,0x00,0x00,0x00,0x0c,0x00,0x00,0x01,0x20,0x00,
0x00,0x00,0x04,0x00,0x00,0x06,0x18,0x00,0x00,0x00,0x06,0x00,0x00,0xf8,0x07,
0x00,0x00,0x00,0x02,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0x01,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x0f,0x00,0x00,0x00,
0x00,0xff,0x00,0x04,0x10,0x00,0x00,0x00,0xc0,0x00,0x03,0x03,0x10,0x00,0x00,
0x00,0x30,0x00,0x0c,0x01,0x20,0x00,0x00,0x00,0x08,0x00,0x98,0x00,0x20,0x00,
0x00,0x00,0x0c,0x03,0x60,0x00,0x20,0x00,0x00,0x00,0xc2,0x00,0xc0,0x00,0x20,
0x00,0x00,0x00,0x42,0x00,0x80,0x00,0x20,0x00,0x00,0x00,0x21,0x00,0x00,0x01,
0x20,0x00,0x00,0x00,0x21,0x00,0x00,0x01,0x20,0x00,0x00,0x00,0x21,0x00,0x00,
0x00,0x20,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x01,0x00,
0x00,0x00,0x40,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x02,
0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
0x18,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x10,0x00,0x00,
0x00,0xc0,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00};

38
appl/xnlock/nose.0.right Normal file
View File

@@ -0,0 +1,38 @@
#define nose_0_right_width 64
#define nose_0_right_height 64
static char nose_0_right_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x20,0x00,
0x00,0x02,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x20,
0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x02,0x00,0x00,0x00,0x00,
0x20,0x00,0x00,0x02,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,
0x04,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x10,0x00,
0x00,0xfc,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x01,0x00,0x00,0xc0,0x0f,
0x00,0x00,0x80,0x01,0x00,0x00,0x30,0x70,0x00,0x00,0x80,0x00,0x00,0x00,0x0c,
0xc0,0x00,0x00,0x40,0x00,0x00,0x00,0x02,0x00,0x01,0x00,0x40,0x00,0x00,0x00,
0x03,0x00,0x02,0x00,0x20,0x00,0x00,0x00,0x01,0x00,0x04,0x00,0x20,0x00,0x00,
0x00,0x00,0x00,0x08,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x10,0x00,
0x00,0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x08,
0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x10,0x00,
0x08,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x10,
0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x08,0x00,0x00,0x00,0x00,0x00,
0x10,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x18,0x00,0x00,0x80,0x00,
0x00,0x08,0x00,0x10,0x00,0x00,0x80,0x00,0x00,0x04,0x00,0x10,0x00,0x00,0x00,
0x01,0x00,0x02,0x00,0x30,0x00,0x00,0x00,0x02,0x00,0x01,0x00,0x20,0x00,0x00,
0x00,0x04,0x80,0x00,0x00,0x60,0x00,0x00,0x00,0x18,0x60,0x00,0x00,0x40,0x00,
0x00,0x00,0xe0,0x1f,0x00,0x00,0x80,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x1f,0x00,0x00,0x00,0x00,0x00,
0x00,0x08,0x20,0x00,0xff,0x00,0x00,0x00,0x00,0x08,0xc0,0xc0,0x00,0x03,0x00,
0x00,0x00,0x04,0x80,0x30,0x00,0x0c,0x00,0x00,0x00,0x04,0x00,0x19,0x00,0x10,
0x00,0x00,0x00,0x04,0x00,0x06,0xc0,0x30,0x00,0x00,0x00,0x04,0x00,0x03,0x00,
0x43,0x00,0x00,0x00,0x04,0x00,0x01,0x00,0x42,0x00,0x00,0x00,0x04,0x80,0x00,
0x00,0x84,0x00,0x00,0x00,0x04,0x80,0x00,0x00,0x84,0x00,0x00,0x00,0x04,0x00,
0x00,0x00,0x84,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x02,
0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x40,0x00,0x00,0x00,
0x02,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x20,0x00,0x00,
0x00,0x04,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x0e,0x00,
0x00,0x00,0xf0,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00};

38
appl/xnlock/nose.1.left Normal file
View File

@@ -0,0 +1,38 @@
#define nose_1_left_width 64
#define nose_1_left_height 64
static char nose_1_left_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x40,0x00,
0x00,0x04,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x40,
0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x04,0x00,0x00,0x00,0x00,
0x40,0x00,0x00,0x04,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,
0x08,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x20,0x00,
0x00,0xf8,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0xf0,0x03,0x00,0x00,0x80,0x00,
0x00,0x00,0x0e,0x0c,0x00,0x00,0x80,0x01,0x00,0x00,0x03,0x30,0x00,0x00,0x00,
0x01,0x00,0x80,0x00,0x40,0x00,0x00,0x00,0x02,0x00,0x40,0x00,0xc0,0x00,0x00,
0x00,0x02,0x00,0x20,0x00,0x80,0x00,0x00,0x00,0x04,0x00,0x10,0x00,0x00,0x00,
0x00,0x00,0x04,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x08,0x00,0x00,
0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,
0x00,0x00,0x00,0x00,0x10,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x08,
0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x10,0x00,
0x08,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x10,
0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x00,0x01,0x00,0x00,
0x18,0x00,0x10,0x00,0x00,0x01,0x00,0x00,0x08,0x00,0x20,0x00,0x80,0x00,0x00,
0x00,0x08,0x00,0x40,0x00,0x40,0x00,0x00,0x00,0x0c,0x00,0x80,0x00,0x20,0x00,
0x00,0x00,0xe4,0x00,0x00,0x03,0x18,0x00,0x00,0x00,0x26,0x03,0x00,0xfc,0x07,
0x00,0x00,0x00,0x12,0x0c,0x00,0x00,0xf8,0xff,0xff,0xff,0x11,0x10,0x80,0x1f,
0x00,0x00,0x00,0x00,0x08,0x20,0x60,0x60,0xc0,0x07,0x00,0x00,0x04,0x40,0x10,
0xc0,0x20,0x08,0x00,0x1f,0x02,0x40,0x08,0x00,0x21,0x10,0xc0,0x60,0x02,0x40,
0x04,0x00,0x12,0x20,0x20,0x80,0x02,0x20,0xc2,0x00,0x14,0x40,0x18,0x00,0x03,
0x20,0x22,0x00,0x0c,0x80,0x04,0x03,0x02,0x10,0x12,0x00,0x08,0x80,0x86,0x00,
0x04,0x10,0x12,0x00,0x10,0x80,0x42,0x00,0x18,0x08,0x12,0x00,0x10,0x40,0x42,
0x00,0x00,0x04,0x02,0x00,0x20,0x40,0x42,0x00,0x00,0x04,0x02,0x00,0x00,0x20,
0x42,0x00,0x00,0x02,0x04,0x00,0x00,0x20,0x02,0x00,0x00,0x01,0x04,0x00,0x00,
0x20,0x02,0x00,0x00,0x01,0x08,0x00,0x00,0x20,0x04,0x00,0x80,0x00,0x10,0x00,
0x00,0x20,0x0c,0x00,0x80,0x00,0x60,0x00,0x00,0x10,0x08,0x00,0x40,0x00,0x80,
0xff,0xff,0x0f,0x30,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0x0f,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00};

38
appl/xnlock/nose.1.right Normal file
View File

@@ -0,0 +1,38 @@
#define nose_1_right_width 64
#define nose_1_right_height 64
static char nose_1_right_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x20,0x00,
0x00,0x02,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x20,
0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x02,0x00,0x00,0x00,0x00,
0x20,0x00,0x00,0x02,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,
0x04,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x10,0x00,
0x00,0xfc,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x01,0x00,0x00,0xc0,0x0f,
0x00,0x00,0x80,0x01,0x00,0x00,0x30,0x70,0x00,0x00,0x80,0x00,0x00,0x00,0x0c,
0xc0,0x00,0x00,0x40,0x00,0x00,0x00,0x02,0x00,0x01,0x00,0x40,0x00,0x00,0x00,
0x03,0x00,0x02,0x00,0x20,0x00,0x00,0x00,0x01,0x00,0x04,0x00,0x20,0x00,0x00,
0x00,0x00,0x00,0x08,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x10,0x00,
0x00,0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x08,
0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x10,0x00,
0x08,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x10,
0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x08,0x00,0x00,0x00,0x00,0x00,
0x10,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x18,0x00,0x00,0x80,0x00,
0x00,0x08,0x00,0x10,0x00,0x00,0x80,0x00,0x00,0x08,0x00,0x10,0x00,0x00,0x00,
0x01,0x00,0x04,0x00,0x30,0x00,0x00,0x00,0x02,0x00,0x02,0x00,0x27,0x00,0x00,
0x00,0x04,0x00,0x01,0xc0,0x64,0x00,0x00,0x00,0x18,0xc0,0x00,0x30,0x48,0x00,
0x00,0x00,0xe0,0x3f,0x00,0x08,0x88,0xff,0xff,0xff,0x1f,0x00,0x00,0x04,0x10,
0x00,0x00,0x00,0x00,0xf8,0x01,0x02,0x20,0x00,0x00,0xe0,0x03,0x06,0x06,0x02,
0x40,0xf8,0x00,0x10,0x04,0x03,0x08,0x02,0x40,0x06,0x03,0x08,0x84,0x00,0x10,
0x04,0x40,0x01,0x04,0x04,0x48,0x00,0x20,0x04,0xc0,0x00,0x18,0x02,0x28,0x00,
0x43,0x08,0x40,0xc0,0x20,0x01,0x30,0x00,0x44,0x08,0x20,0x00,0x61,0x01,0x10,
0x00,0x48,0x10,0x18,0x00,0x42,0x01,0x08,0x00,0x48,0x20,0x00,0x00,0x42,0x02,
0x08,0x00,0x48,0x20,0x00,0x00,0x42,0x02,0x04,0x00,0x40,0x40,0x00,0x00,0x42,
0x04,0x00,0x00,0x40,0x80,0x00,0x00,0x40,0x04,0x00,0x00,0x20,0x80,0x00,0x00,
0x40,0x04,0x00,0x00,0x20,0x00,0x01,0x00,0x20,0x04,0x00,0x00,0x10,0x00,0x01,
0x00,0x30,0x04,0x00,0x00,0x08,0x00,0x02,0x00,0x10,0x08,0x00,0x00,0x06,0x00,
0x0c,0x00,0x0c,0xf0,0xff,0xff,0x01,0x00,0xf0,0xff,0x03,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00};

38
appl/xnlock/nose.down Normal file
View File

@@ -0,0 +1,38 @@
#define nose_down_width 64
#define nose_down_height 64
static char nose_down_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xfc,0xff,0x01,0x00,0x00,0x00,0x00,0xc0,0x03,0x00,0x1e,0x00,
0x00,0x00,0x00,0x38,0x00,0x00,0xe0,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,
0x03,0x00,0x00,0x80,0x01,0x00,0x00,0x00,0x04,0x00,0x00,0x40,0x00,0x00,0x00,
0x00,0x08,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x10,0x00,0x80,
0x1f,0x00,0x40,0x00,0x00,0x08,0x00,0x60,0x60,0x00,0x80,0x00,0x00,0x08,0x00,
0x10,0x80,0x00,0x80,0x00,0x00,0x04,0x00,0x08,0x00,0x01,0x00,0x01,0x00,0x04,
0x00,0x08,0x00,0x01,0x00,0x01,0x00,0x02,0x00,0x18,0x80,0x01,0x00,0x02,0x00,
0x02,0x00,0x68,0x60,0x01,0x00,0x02,0x00,0x02,0x00,0x88,0x1f,0x01,0x00,0x02,
0x00,0x02,0x00,0x08,0x00,0x01,0x00,0x02,0x00,0x02,0x00,0x10,0x80,0x00,0x00,
0x03,0x00,0x06,0x00,0x60,0x60,0x00,0x80,0x02,0x00,0x0c,0x00,0x80,0x1f,0x00,
0x40,0x01,0x00,0x14,0x00,0x00,0x00,0x00,0x20,0x01,0x00,0x28,0x00,0x00,0x00,
0x00,0x90,0x00,0x00,0x50,0x00,0x00,0x00,0x00,0x48,0x00,0x00,0xa0,0x01,0x00,
0x00,0x00,0x26,0x00,0x00,0x40,0x1e,0x00,0x00,0xc0,0x11,0x00,0x00,0x80,0xe1,
0x03,0x00,0x3c,0x0c,0x00,0x00,0x00,0x0e,0xfc,0xff,0x83,0x03,0x00,0x00,0x00,
0xf0,0x01,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0x0f,0x00,0x00,0x00,
0x00,0x80,0x03,0x00,0x0c,0x00,0x00,0x00,0x00,0x80,0x02,0x00,0x14,0x00,0x00,
0x00,0x00,0x60,0x04,0x00,0x12,0x00,0x00,0xc0,0x7f,0x10,0x04,0x00,0x22,0xe0,
0x01,0x70,0xc0,0x18,0x08,0x00,0x61,0x1c,0x06,0x10,0x00,0x0f,0x30,0xc0,0x80,
0x07,0x08,0x08,0x00,0x06,0xc0,0x3f,0x80,0x01,0x08,0x08,0x00,0x18,0x00,0x02,
0xc0,0x00,0x10,0x04,0x00,0x30,0x00,0x05,0x30,0x00,0x10,0x04,0x00,0x00,0x80,
0x08,0x18,0x00,0x20,0x04,0x00,0x00,0x80,0x08,0x00,0x00,0x20,0x04,0x00,0x00,
0x40,0x10,0x00,0x00,0x20,0x24,0x00,0x00,0x40,0x10,0x00,0x00,0x22,0x24,0x00,
0x00,0x40,0x10,0x00,0x00,0x22,0x44,0x00,0x00,0x40,0x10,0x00,0x00,0x11,0x84,
0x01,0x00,0xc0,0x18,0x00,0xc0,0x10,0x08,0x00,0x00,0x80,0x08,0x00,0x00,0x08,
0x30,0x00,0x00,0x80,0x08,0x00,0x00,0x04,0xe0,0xff,0xff,0xff,0xf8,0xff,0xff,
0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00};

38
appl/xnlock/nose.front Normal file
View File

@@ -0,0 +1,38 @@
#define nose_front_width 64
#define nose_front_height 64
static char nose_front_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x40,0x00,
0x00,0x04,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x40,
0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x04,0x00,0x00,0x00,0x00,
0x40,0x00,0x00,0x04,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,
0x08,0x00,0xc0,0x1f,0x00,0x20,0x00,0x00,0x08,0x00,0x30,0x60,0x00,0x20,0x00,
0x00,0xf8,0xff,0x0f,0x80,0xff,0x3f,0x00,0x00,0x00,0x02,0x02,0x00,0x82,0x00,
0x00,0x00,0x00,0x03,0x01,0x00,0x84,0x01,0x00,0x00,0x00,0x81,0x00,0x00,0x08,
0x01,0x00,0x00,0x80,0x80,0x00,0x00,0x08,0x02,0x00,0x00,0x80,0x40,0x00,0x00,
0x10,0x02,0x00,0x00,0x40,0x40,0x00,0x00,0x10,0x04,0x00,0x00,0x40,0x20,0x00,
0x00,0x20,0x04,0x00,0x00,0x60,0x20,0x00,0x00,0x20,0x0c,0x00,0x00,0x20,0x20,
0x00,0x00,0x20,0x08,0x00,0x00,0x20,0x20,0x00,0x00,0x20,0x08,0x00,0x00,0x10,
0x20,0x00,0x00,0x20,0x10,0x00,0x00,0x10,0x20,0x00,0x00,0x20,0x10,0x00,0x00,
0x10,0x20,0x00,0x00,0x20,0x10,0x00,0x00,0x10,0x40,0x00,0x00,0x10,0x10,0x00,
0x00,0x10,0x40,0x00,0x00,0x10,0x10,0x00,0x00,0x10,0x80,0x00,0x00,0x08,0x10,
0x00,0x00,0x10,0x80,0x00,0x00,0x08,0x10,0x00,0x00,0x30,0x00,0x01,0x00,0x04,
0x18,0x00,0x00,0x20,0x00,0x02,0x00,0x02,0x08,0x00,0x00,0x20,0x00,0x0c,0x80,
0x01,0x08,0x00,0x00,0x60,0x00,0x30,0x60,0x00,0x0c,0x00,0x00,0x40,0x00,0xc0,
0x1f,0x00,0x04,0x00,0x00,0xc0,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x01,
0x00,0x00,0x00,0x02,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0x01,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x0f,0xc0,0x0f,0x00,0x00,0x00,
0x00,0x40,0x10,0x20,0x10,0x00,0x00,0x00,0x00,0x20,0x60,0x30,0x20,0x00,0x00,
0x00,0x00,0x20,0xc0,0x18,0x20,0x00,0x00,0xc0,0x7f,0x10,0x80,0x0d,0x40,0xe0,
0x01,0x70,0xc0,0x18,0x00,0x05,0x40,0x1c,0x06,0x10,0x00,0x0f,0x00,0x05,0x80,
0x07,0x08,0x08,0x00,0x06,0x00,0x05,0x80,0x01,0x08,0x08,0x00,0x18,0x00,0x05,
0xc0,0x00,0x10,0x04,0x00,0x30,0x00,0x05,0x30,0x00,0x10,0x04,0x00,0x00,0x80,
0x08,0x18,0x00,0x20,0x04,0x00,0x00,0x80,0x08,0x00,0x00,0x20,0x04,0x00,0x00,
0x40,0x10,0x00,0x00,0x20,0x24,0x00,0x00,0x40,0x10,0x00,0x00,0x22,0x24,0x00,
0x00,0x40,0x10,0x00,0x00,0x22,0x44,0x00,0x00,0x40,0x10,0x00,0x00,0x11,0x84,
0x01,0x00,0xc0,0x18,0x00,0xc0,0x10,0x08,0x00,0x00,0x80,0x08,0x00,0x00,0x08,
0x30,0x00,0x00,0x80,0x08,0x00,0x00,0x04,0xe0,0xff,0xff,0xff,0xf8,0xff,0xff,
0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00};

View File

@@ -0,0 +1,38 @@
#define nose_left_front_width 64
#define nose_left_front_height 64
static char nose_left_front_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x40,0x00,
0x00,0x04,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x40,
0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x04,0x00,0x00,0x00,0x00,
0x40,0x00,0x00,0x04,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,
0x08,0x00,0xe0,0x0f,0x00,0x20,0x00,0x00,0x08,0x00,0x18,0x30,0x00,0x20,0x00,
0x00,0xf8,0xff,0x07,0xc0,0xff,0x3f,0x00,0x00,0x00,0x02,0x01,0x00,0x81,0x00,
0x00,0x00,0x00,0x83,0x00,0x00,0x82,0x01,0x00,0x00,0x00,0x41,0x00,0x00,0x04,
0x01,0x00,0x00,0x80,0x40,0x00,0x00,0x04,0x02,0x00,0x00,0x80,0x20,0x00,0x00,
0x08,0x02,0x00,0x00,0x40,0x20,0x00,0x00,0x08,0x04,0x00,0x00,0x40,0x10,0x00,
0x00,0x10,0x04,0x00,0x00,0x60,0x10,0x00,0x00,0x10,0x0c,0x00,0x00,0x20,0x10,
0x00,0x00,0x10,0x08,0x00,0x00,0x30,0x10,0x00,0x00,0x10,0x08,0x00,0x00,0x10,
0x10,0x00,0x00,0x10,0x10,0x00,0x00,0x10,0x10,0x00,0x00,0x10,0x10,0x00,0x00,
0x10,0x10,0x00,0x00,0x10,0x10,0x00,0x00,0x10,0x20,0x00,0x00,0x08,0x10,0x00,
0x00,0x10,0x20,0x00,0x00,0x08,0x10,0x00,0x00,0x10,0x40,0x00,0x00,0x04,0x10,
0x00,0x00,0x30,0x40,0x00,0x00,0x04,0x10,0x00,0x00,0x20,0x80,0x00,0x00,0x02,
0x18,0x00,0x00,0x20,0x00,0x01,0x00,0x01,0x08,0x00,0x00,0x60,0x00,0x06,0xc0,
0x00,0x08,0x00,0x00,0x80,0x00,0x18,0x30,0x00,0x0c,0x00,0x00,0x80,0x00,0xe0,
0x0f,0x00,0x04,0x00,0x00,0x80,0x01,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x01,
0x00,0x00,0x00,0x02,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0x01,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x0f,0x00,0x00,0x00,
0x00,0xff,0x00,0x04,0x10,0x00,0x00,0x00,0xe0,0x00,0x07,0x02,0x10,0x00,0x00,
0x00,0x30,0x00,0x8c,0x01,0x20,0x00,0x00,0x00,0x0c,0x00,0x90,0x00,0x20,0x00,
0x00,0x00,0x04,0x03,0x60,0x00,0x20,0x00,0x00,0x00,0xc2,0x00,0xc0,0x00,0x20,
0x00,0x00,0x00,0x42,0x00,0x00,0x01,0x20,0x00,0x00,0x00,0x21,0x00,0x00,0x02,
0x20,0x00,0x00,0x00,0x21,0x00,0x00,0x06,0x20,0x00,0x00,0x00,0x21,0x00,0x00,
0x00,0x20,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x03,0x00,
0x00,0x00,0x40,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x02,
0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
0x18,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x10,0x00,0x00,
0x00,0xc0,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00};

View File

@@ -0,0 +1,38 @@
#define nose_right_front_width 64
#define nose_right_front_height 64
static char nose_right_front_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x20,0x00,
0x00,0x02,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x20,
0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x02,0x00,0x00,0x00,0x00,
0x20,0x00,0x00,0x02,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,
0x04,0x00,0xf0,0x07,0x00,0x10,0x00,0x00,0x04,0x00,0x0c,0x18,0x00,0x10,0x00,
0x00,0xfc,0xff,0x03,0xe0,0xff,0x1f,0x00,0x00,0x00,0x81,0x00,0x80,0x40,0x00,
0x00,0x00,0x80,0x41,0x00,0x00,0xc1,0x00,0x00,0x00,0x80,0x20,0x00,0x00,0x82,
0x00,0x00,0x00,0x40,0x20,0x00,0x00,0x02,0x01,0x00,0x00,0x40,0x10,0x00,0x00,
0x04,0x01,0x00,0x00,0x20,0x10,0x00,0x00,0x04,0x02,0x00,0x00,0x20,0x08,0x00,
0x00,0x08,0x02,0x00,0x00,0x30,0x08,0x00,0x00,0x08,0x06,0x00,0x00,0x10,0x08,
0x00,0x00,0x08,0x04,0x00,0x00,0x10,0x08,0x00,0x00,0x08,0x0c,0x00,0x00,0x08,
0x08,0x00,0x00,0x08,0x08,0x00,0x00,0x08,0x08,0x00,0x00,0x08,0x08,0x00,0x00,
0x08,0x08,0x00,0x00,0x08,0x08,0x00,0x00,0x08,0x10,0x00,0x00,0x04,0x08,0x00,
0x00,0x08,0x10,0x00,0x00,0x04,0x08,0x00,0x00,0x08,0x20,0x00,0x00,0x02,0x08,
0x00,0x00,0x08,0x20,0x00,0x00,0x02,0x0c,0x00,0x00,0x18,0x40,0x00,0x00,0x01,
0x04,0x00,0x00,0x10,0x80,0x00,0x80,0x00,0x04,0x00,0x00,0x10,0x00,0x03,0x60,
0x00,0x06,0x00,0x00,0x30,0x00,0x0c,0x18,0x00,0x01,0x00,0x00,0x20,0x00,0xf0,
0x07,0x00,0x01,0x00,0x00,0x60,0x00,0x00,0x00,0x80,0x01,0x00,0x00,0x40,0x00,
0x00,0x00,0x80,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x1f,0x00,0x00,0x00,0x00,0x00,
0x00,0x08,0x20,0x00,0xff,0x00,0x00,0x00,0x00,0x08,0x40,0xe0,0x00,0x07,0x00,
0x00,0x00,0x04,0x80,0x31,0x00,0x0c,0x00,0x00,0x00,0x04,0x00,0x09,0x00,0x30,
0x00,0x00,0x00,0x04,0x00,0x06,0xc0,0x20,0x00,0x00,0x00,0x04,0x00,0x03,0x00,
0x43,0x00,0x00,0x00,0x04,0x80,0x00,0x00,0x42,0x00,0x00,0x00,0x04,0x40,0x00,
0x00,0x84,0x00,0x00,0x00,0x04,0x60,0x00,0x00,0x84,0x00,0x00,0x00,0x04,0x00,
0x00,0x00,0x84,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x02,
0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x40,0x00,0x00,0x00,
0x02,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x20,0x00,0x00,
0x00,0x04,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x0e,0x00,
0x00,0x00,0xf0,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00};

860
appl/xnlock/xnlock.c.save Normal file
View File

@@ -0,0 +1,860 @@
/*
* xnlock -- Dan Heller, 1990
* "nlock" is a "new lockscreen" type program... something that prevents
* screen burnout by making most of it "black" while providing something
* of interest to be displayed in case anyone is watching.
* "xnlock" is the X11 version of the program.
* Original sunview version written by Dan Heller 1985 (not included here).
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include "protos.h"
#endif
#include <stdio.h>
#include <X11/StringDefs.h>
#include <X11/Intrinsic.h>
#include <X11/keysym.h>
#include <X11/Shell.h>
#include <X11/Xos.h>
#include <ctype.h>
#include <pwd.h>
#ifdef KERBEROS
#include <krb.h>
#include <kafs.h>
#endif
char STRING[] = "****************";
#define MAX_PASSWD_LENGTH (sizeof(STRING))
/* The program should be something that outputs a small amount of text */
#define DEFAULT_PROGRAM "fortune -s"
#define DEFAULT_TEXT "I'm out running around."
#define font_height(font) (font->ascent + font->descent)
#define FONT_NAME "-*-new century schoolbook-*-*-*-18-*"
#define when break;case
#define otherwise break;default
XtAppContext app;
Display *dpy;
unsigned short Width, Height;
Widget widget;
GC gc;
XtIntervalId timeout_id;
char *ProgName, *words, *get_words();
int x, y;
Pixel Black, White;
XFontStruct *font;
struct passwd *pw;
char root_pw[16];
char *def_words = DEFAULT_TEXT;
int time_left, prompt_x, prompt_y, time_x, time_y;
void init_images(), countdown(), post_prompt_box();
unsigned long interval, look();
Pixmap left0, left1, right0, right1, left_front,
right_front, front, down;
int test;
#define FROM_ARGV 1
#define FROM_PROGRAM 2
#define FROM_FILE 3
#define FROM_RESRC 4
int getwordsfrom = FROM_RESRC;
#define IS_MOVING 1
#define GET_PASSWD 2
int state; /* indicates states: walking or getting passwd */
void ClearWindow(), GetPasswd(), Visibility(), move();
struct _resrcs {
Pixel fg, bg;
XFontStruct *font;
Boolean ignore_passwd;
Boolean do_reverse;
Boolean accept_root;
char *text, *text_prog, *file;
} Resrcs;
static XtResource resources[] = {
{ XtNfont, XtCFont, XtRFontStruct, sizeof (XFontStruct *),
XtOffsetOf(struct _resrcs,font), XtRImmediate, NULL },
{ XtNforeground, XtCForeground, XtRPixel, sizeof (Pixel),
/* note: the background is really the foreground color */
XtOffsetOf(struct _resrcs,fg), XtRString, XtDefaultBackground },
{ XtNbackground, XtCBackground, XtRPixel, sizeof (Pixel),
/* note: the foreground is really the background color */
XtOffsetOf(struct _resrcs,bg), XtRString, XtDefaultForeground },
{ XtNreverseVideo, XtCReverseVideo, XtRBoolean, sizeof(Boolean),
XtOffsetOf(struct _resrcs,do_reverse), XtRImmediate, (char *)False },
{ "ignorePasswd", "IgnorePasswd", XtRBoolean, sizeof(Boolean),
XtOffsetOf(struct _resrcs,ignore_passwd), XtRImmediate, (char *)False },
{ "acceptRootPasswd", "AcceptRootPasswd", XtRBoolean, sizeof(Boolean),
XtOffsetOf(struct _resrcs,accept_root), XtRImmediate, (char *)True },
{ "text", "Text", XtRString, sizeof(char *),
XtOffsetOf(struct _resrcs,text), XtRImmediate, DEFAULT_TEXT },
{ "program", "Program", XtRString, sizeof(char *),
XtOffsetOf(struct _resrcs,text_prog), XtRImmediate, DEFAULT_PROGRAM },
{ "file", "File", XtRString, sizeof(char *),
XtOffsetOf(struct _resrcs,file), XtRImmediate, NULL },
};
static XrmOptionDescRec options[] = {
{ "-fn", "font", XrmoptionSepArg, NULL },
{ "-fg", "foreground", XrmoptionSepArg, NULL },
{ "-bg", "background", XrmoptionSepArg, NULL },
{ "-rv", "reverseVideo", XrmoptionNoArg, "True" },
{ "-norv", "reverseVideo", XrmoptionNoArg, "False" },
{ "-ip", "ignorePasswd", XrmoptionNoArg, "True" },
{ "-noip", "ignorePasswd", XrmoptionNoArg, "False" },
{ "-ar", "acceptRootPasswd", XrmoptionNoArg, "True" },
{ "-noar", "acceptRootPasswd", XrmoptionNoArg, "False" },
};
int
main (argc, argv)
int argc;
char *argv[];
{
register int i;
int foo;
Widget override;
XGCValues gcvalues;
char **list;
if ((ProgName = rindex(*argv, '/')) != 0)
ProgName++;
else
ProgName = *argv;
/* getpwuid() returns static pointer, so get root's passwd first */
if (!(pw = getpwuid(0)))
printf("%s: can't get root's passwd!\n", ProgName), exit(1);
strcpy(root_pw, pw->pw_passwd);
if (!(pw = getpwuid(getuid())))
printf("%s: Intruder alert!\n", ProgName), exit(1);
XtToolkitInitialize();
app = XtCreateApplicationContext();
dpy = XtOpenDisplay(app, NULL,
"xnlock", "XNlock", options, XtNumber(options), &argc, argv);
if (dpy == 0)
{
fprintf(stderr, "Error: Can't open display:\n");
exit(1);
}
Width = DisplayWidth(dpy, DefaultScreen(dpy)) + 2;
Height = DisplayHeight(dpy, DefaultScreen(dpy)) + 2;
override = XtVaAppCreateShell("xnlock", "XNlock",
overrideShellWidgetClass, dpy, XtNx, -1, XtNy, -1, NULL);
XtGetApplicationResources(override, &Resrcs,
resources, XtNumber(resources), NULL, 0);
XtAddEventHandler(override, VisibilityChangeMask, FALSE, Visibility, NULL);
widget = XtVaCreateManagedWidget("_foo", widgetClass, override,
XtNwidth, Width,
XtNheight, Height,
NULL);
init_words(--argc, ++argv);
init_images();
/* the background is black and the little guy is white */
Black = Resrcs.do_reverse? Resrcs.fg : Resrcs.bg;
White = Resrcs.do_reverse? Resrcs.bg : Resrcs.fg;
gcvalues.foreground = Black;
gcvalues.background = White;
if (!(font = Resrcs.font)) {
list = XListFonts(dpy, FONT_NAME, 32767, &foo);
for (i = 0; i < foo; i++)
if ((font = XLoadQueryFont(dpy, list[i])) != 0)
break;
if (!font)
{
list = XListFonts(dpy, "fixed", 1, &foo);
font = XLoadQueryFont(dpy, list[0]);
}
if (!font)
XtError("Can't find a font (so call me stupid).");
XFreeFontNames(list);
}
gcvalues.font = font->fid;
gcvalues.graphics_exposures = False;
gc = XCreateGC(dpy, DefaultRootWindow(dpy),
GCForeground | GCBackground | GCGraphicsExposures | GCFont,
&gcvalues);
x = Width / 2;
y = Height / 2;
srand (time(0));
state = IS_MOVING;
{
static XtActionsRec actions[] = {
{ "ClearWindow", ClearWindow },
{ "GetPasswd", GetPasswd },
};
XtAppAddActions(app, actions, XtNumber(actions));
XtOverrideTranslations(widget,
XtParseTranslationTable(
"<Expose>: ClearWindow() \n\
<BtnDown>: GetPasswd() \n\
<KeyPress>: GetPasswd()"));
}
XtRealizeWidget(override);
#if 0
XGrabServer(dpy);
#else
XGrabPointer(dpy, XtWindow(widget), TRUE, 0, GrabModeAsync,
GrabModeAsync, XtWindow(widget), None, CurrentTime);
XGrabKeyboard(dpy, XtWindow(widget), TRUE, GrabModeAsync,
GrabModeAsync, CurrentTime);
#endif
ScreenSaver(1);
XtAppMainLoop(app);
exit(0);
}
static void
leave()
{
#if 0
XUngrabServer(dpy);
#else
XUngrabPointer(dpy, CurrentTime);
XUngrabKeyboard(dpy, CurrentTime);
#endif
ScreenSaver(0);
exit(0);
}
static void
ScreenSaver(save)
{
static int timeout, interval, prefer_blank, allow_exp;
if (save) {
XGetScreenSaver(dpy, &timeout, &interval, &prefer_blank, &allow_exp);
XSetScreenSaver(dpy, 0, interval, prefer_blank, allow_exp);
} else
/* restore state */
XSetScreenSaver(dpy, timeout, interval, prefer_blank, allow_exp);
}
static void
ClearWindow(w, event)
Widget w;
XExposeEvent *event;
{
if (!XtIsRealized(w))
return;
XSetForeground(dpy, gc, Black);
XFillRectangle(dpy, XtWindow(w), gc,
event->x, event->y, event->width, event->height);
XSetForeground(dpy, gc, White);
XSetBackground(dpy, gc, Black);
if (state == GET_PASSWD)
post_prompt_box(XtWindow(w));
if (timeout_id == 0 && event->count == 0) {
timeout_id = XtAppAddTimeOut(app, 1000L, move, NULL);
/* first grab the input focus */
XSetInputFocus(dpy, XtWindow(w), RevertToPointerRoot, CurrentTime);
/* now grab the pointer and keyboard and contrain to this window */
XGrabPointer(dpy, XtWindow(w), TRUE, 0, GrabModeAsync,
GrabModeAsync, XtWindow(w), None, CurrentTime);
}
}
static void
Visibility(w, client_data, event)
Widget w;
XtPointer client_data;
XVisibilityEvent *event;
{
XRaiseWindow(dpy, XtWindow(w));
}
static void
init_words (argc, argv)
int argc;
char *argv[];
{
char buf[BUFSIZ];
while (*argv && **argv == '-') {
switch(argv[0][1]) {
case 'p':
getwordsfrom = FROM_PROGRAM;
if (!*++argv)
puts("specify a program name to get text from!"), exit(1);
Resrcs.text_prog = *argv;
case 'f':
getwordsfrom = FROM_FILE;
if (argv[1])
Resrcs.file = *++argv;
else {
sprintf(buf, "%s/.msgfile", pw->pw_dir);
Resrcs.file = strcpy(XtMalloc(strlen(buf)+1), buf);
}
default :
printf("usage: %s [options] [message]\n", ProgName);
puts("-fg color foreground color");
puts("-bg color background color");
puts("-rv reverse foreground/background colors");
puts("-nrv no reverse video");
puts("-ip ignore passwd");
puts("-nip don't ignore passwd");
puts("-ar accept root's passwd to unlock");
puts("-nar don't accept root's passwd");
puts("-f [file] message is read from file or ~/.msgfile");
puts("-prog program text is gotten from executing `program'");
exit(1);
}
argv++;
}
if (*argv) {
if (getwordsfrom != FROM_RESRC)
puts("I don't know what text you want displayed.");
getwordsfrom = FROM_ARGV;
} else if (!getwordsfrom)
if (Resrcs.text)
getwordsfrom = FROM_RESRC;
else if (Resrcs.file)
getwordsfrom = FROM_FILE;
else
getwordsfrom = FROM_PROGRAM;
words = get_words(argv); /* if getwordsfrom != FROM_ARGV, argv is a nop */
}
static char *
get_words(argv)
char **argv;
{
FILE *pp;
static char buf[BUFSIZ];
register char *p = buf;
if (getwordsfrom == FROM_RESRC)
return Resrcs.text;
if (getwordsfrom == FROM_PROGRAM) {
if (!(pp = popen(Resrcs.text_prog, "r"))) {
perror(Resrcs.text_prog);
return def_words;
}
} else if (getwordsfrom == FROM_FILE)
if (!(pp = fopen(Resrcs.file, "r"))) {
perror(Resrcs.file);
return def_words;
}
else if (getwordsfrom != FROM_PROGRAM && getwordsfrom != FROM_FILE)
return def_words;
buf[0] = 0;
if (getwordsfrom == FROM_ARGV) {
while (*argv) {
p += strlen(strcpy(p, *argv));
if (*++argv)
strcpy(p++, " ");
}
return buf;
}
/* BUG Alert: does not check for overflow */
while (fgets(p, sizeof buf, pp))
p += strlen(p);
if (getwordsfrom == FROM_PROGRAM)
(void) pclose(pp);
else
(void) fclose (pp);
if (!buf[0])
return def_words;
return buf;
}
#define PROMPT "Password: "
#define FAIL_MSG "Sorry, try again"
static void
GetPasswd(w, event)
Widget w;
XKeyEvent *event;
{
static char passwd[MAX_PASSWD_LENGTH];
static int cnt;
char c;
KeySym keysym;
if (event->type == ButtonPress) {
x = event->x, y = event->y, test = 2;
return;
}
if (state == IS_MOVING) {
/* guy is running around--change to post prompt box. */
XtRemoveTimeOut(timeout_id);
state = GET_PASSWD;
if (Resrcs.ignore_passwd || !strlen(pw->pw_passwd))
leave();
post_prompt_box(XtWindow(w));
cnt = 0;
time_left = 30;
countdown(&time_left);
return;
}
if (event->type != KeyPress)
return;
if (!XLookupString(event, &c, 1, &keysym, 0))
return;
if (keysym == XK_Return || keysym == XK_Linefeed) {
passwd[cnt] = 0;
XtRemoveTimeOut(timeout_id);
/*
* First try with root password, if allowed.
*/
if (Resrcs.accept_root &&
(root_pw[0] == 0 && cnt == 0 ||
cnt && root_pw[0] && !strcmp(crypt(passwd, root_pw), root_pw)))
leave();
/*
* Try to verify as user.
*/
#ifdef KERBEROS
{
char realm[REALM_SZ];
if (krb_get_lrealm(realm, 1) == KSUCCESS)
{
if (KSUCCESS ==
krb_get_pw_in_tkt(pw->pw_name,
"",
realm,
"krbtgt",
realm,
DEFAULT_TKT_LIFE,
passwd))
{
if (k_hasafs())
{
int k_errno;
if ((k_errno = k_afsklog(NULL)) != KSUCCESS)
fprintf(stderr,
"%s: Warning %s\n",
ProgName,
krb_err_txt[k_errno]);
}
leave();
}
}
}
#endif /* KERBEROS */
if (!strcmp(crypt(passwd, pw->pw_passwd), pw->pw_passwd))
leave();
XDrawImageString(dpy, XtWindow(widget), gc,
time_x, time_y, FAIL_MSG, strlen(FAIL_MSG));
time_left = 0;
state = IS_MOVING;
timeout_id = XtAppAddTimeOut(app, 2000L, countdown, &time_left);
return;
}
if (keysym == XK_BackSpace || keysym == XK_Delete || keysym == XK_Left) {
if (cnt)
passwd[cnt--] = ' ';
} else if (isprint(c))
if (cnt >= MAX_PASSWD_LENGTH)
XBell(dpy, 50);
else
passwd[cnt++] = c;
else
return;
XDrawImageString(dpy, XtWindow(w), gc,
prompt_x, prompt_y, STRING, cnt);
XDrawImageString(dpy, XtWindow(w), gc,
prompt_x + XTextWidth(font, STRING, cnt),
prompt_y, " ", 11-cnt);
}
static void
post_prompt_box(window)
Window window;
{
char s[32];
int width = (Width / 3);
int height = font_height(font) * 6;
int box_x, box_y;
/* make sure the entire nose icon fits in the box */
if (height < 100)
height = 100;
time_x = prompt_x = Width / 3;
time_y = prompt_y = Height / 2;
box_x = prompt_x - 105;
box_y = prompt_y - 3 * font_height(font);
sprintf (s, "User: %s", pw->pw_name);
/* erase current guy -- text message may still exist */
XSetForeground(dpy, gc, Black);
XFillRectangle(dpy, window, gc, x, y, 64, 64);
talk(1); /* forcefully erase message if one is being displayed */
/* Clear area in middle of screen for prompt box */
XSetForeground(dpy, gc, White);
XFillRectangle(dpy, window, gc, box_x, box_y, width, height);
XSetForeground(dpy, gc, Black);
/* make a box that's 5 pixels thick. Then add a thin box inside it */
XSetLineAttributes(dpy, gc, 5, 0, 0, 0);
XDrawRectangle(dpy, window, gc, box_x+5, box_y+5, width-10, height-10);
XSetLineAttributes(dpy, gc, 0, 0, 0, 0);
XDrawRectangle(dpy, window, gc, box_x+12, box_y+12, width-23, height-23);
XDrawString(dpy, window, gc,
prompt_x, prompt_y-font_height(font), s, strlen(s));
XDrawString(dpy, window, gc, prompt_x, prompt_y, PROMPT, strlen(PROMPT));
/* set background for copyplane and DrawImageString; need reverse video */
XSetBackground(dpy, gc, White);
XCopyPlane(dpy, right0, window, gc, 0,0, 64,64,
box_x + 20, box_y + (height - 64)/2, 1L);
prompt_x += XTextWidth(font, PROMPT, strlen(PROMPT));
time_y += 2*font_height(font);
}
static void
countdown(timeout)
int *timeout;
{
char buf[16];
if (--(*timeout) < 0) {
XExposeEvent event;
XtRemoveTimeOut(timeout_id);
state = IS_MOVING;
event.x = event.y = 0;
event.width = Width, event.height = Height;
ClearWindow(widget, &event);
timeout_id = XtAppAddTimeOut(app, 200L, move, NULL);
return;
}
sprintf(buf, "Time: %2.d ", (*timeout)+1);
XDrawImageString(dpy, XtWindow(widget), gc,
time_x, time_y, buf, strlen(buf));
XtAppAddTimeOut(app, 1000L, countdown, timeout);
}
#include "nose.0.left"
#include "nose.1.left"
#include "nose.0.right"
#include "nose.1.right"
#include "nose.left.front"
#include "nose.right.front"
#include "nose.front"
#include "nose.down"
static void
init_images()
{
static Pixmap *images[] = {
&left0, &left1, &right0, &right1,
&left_front, &right_front, &front, &down
};
static char *bits[] = {
nose_0_left_bits, nose_1_left_bits, nose_0_right_bits,
nose_1_right_bits, nose_left_front_bits, nose_right_front_bits,
nose_front_bits, nose_down_bits
};
int i;
for (i = 0; i < XtNumber(images); i++)
if (!(*images[i] =
XCreatePixmapFromBitmapData(dpy, DefaultRootWindow(dpy),
bits[i], 64, 64, 1, 0, 1)))
XtError("Can't load nose images");
}
#define LEFT 001
#define RIGHT 002
#define DOWN 004
#define UP 010
#define FRONT 020
#define X_INCR 3
#define Y_INCR 2
static void
move()
{
static int length, dir;
if (!length) {
register int tries = 0;
dir = 0;
if ((rand() & 1) && think()) {
talk(0); /* sets timeout to itself */
return;
}
if (!(rand() % 3) && (interval = look())) {
timeout_id = XtAppAddTimeOut(app, interval, move, NULL);
return;
}
interval = 20 + rand() % 100;
do {
if (!tries)
length = Width/100 + rand() % 90, tries = 8;
else
tries--;
switch (rand() % 8) {
case 0:
if (x - X_INCR*length >= 5)
dir = LEFT;
case 1:
if (x + X_INCR*length <= Width - 70)
dir = RIGHT;
case 2:
if (y - (Y_INCR*length) >= 5)
dir = UP, interval = 40;
case 3:
if (y + Y_INCR*length <= Height - 70)
dir = DOWN, interval = 20;
case 4:
if (x - X_INCR*length >= 5 && y - (Y_INCR*length) >= 5)
dir = (LEFT|UP);
case 5:
if (x + X_INCR * length <= Width - 70 &&
y-Y_INCR * length >= 5)
dir = (RIGHT|UP);
case 6:
if (x - X_INCR * length >= 5 &&
y + Y_INCR * length <= Height - 70)
dir = (LEFT|DOWN);
case 7:
if (x + X_INCR*length <= Width - 70 &&
y + Y_INCR*length <= Height - 70)
dir = (RIGHT|DOWN);
}
} while (!dir);
}
walk(dir);
--length;
timeout_id = XtAppAddTimeOut(app, interval, move, NULL);
}
static void
walk(dir)
register int dir;
{
register int incr = 0;
static int lastdir;
static int up = 1;
static Pixmap frame;
if (dir & (LEFT|RIGHT)) { /* left/right movement (mabye up/down too) */
up = -up; /* bouncing effect (even if hit a wall) */
if (dir & LEFT) {
incr = X_INCR;
frame = (up < 0) ? left0 : left1;
} else {
incr = -X_INCR;
frame = (up < 0) ? right0 : right1;
}
if ((lastdir == FRONT || lastdir == DOWN) && dir & UP) {
/* workaround silly bug that leaves screen dust when
* guy is facing forward or down and moves up-left/right.
*/
XCopyPlane(dpy, frame, XtWindow(widget), gc, 0, 0, 64,64, x, y, 1L);
XFlush(dpy);
}
/* note that maybe neither UP nor DOWN is set! */
if (dir & UP && y > Y_INCR)
y -= Y_INCR;
else if (dir & DOWN && y < Height - 64)
y += Y_INCR;
}
/* Explicit up/down movement only (no left/right) */
else if (dir == UP)
XCopyPlane(dpy, front, XtWindow(widget), gc,
0,0, 64,64, x, y -= Y_INCR, 1L);
else if (dir == DOWN)
XCopyPlane(dpy, down, XtWindow(widget), gc,
0,0, 64,64, x, y += Y_INCR, 1L);
else if (dir == FRONT && frame != front) {
if (up > 0)
up = -up;
if (lastdir & LEFT)
frame = left_front;
else if (lastdir & RIGHT)
frame = right_front;
else
frame = front;
XCopyPlane(dpy, frame, XtWindow(widget), gc, 0, 0, 64,64, x, y, 1L);
}
if (dir & LEFT)
while(--incr >= 0) {
XCopyPlane(dpy, frame, XtWindow(widget), gc,
0,0, 64,64, --x, y+up, 1L);
XFlush(dpy);
}
else if (dir & RIGHT)
while(++incr <= 0) {
XCopyPlane(dpy, frame, XtWindow(widget), gc,
0,0, 64,64, ++x, y+up, 1L);
XFlush(dpy);
}
lastdir = dir;
}
static int
think()
{
if (rand() & 1)
walk(FRONT);
if (rand() & 1) {
if (getwordsfrom > 1)
words = get_words((char **)NULL);
return 1;
}
return 0;
}
#define MAXLINES 40
static void
talk(force_erase)
int force_erase;
{
int width = 0, height, Z, total = 0;
static int X, Y, talking;
static struct { int x, y, width, height; } s_rect;
register char *p, *p2;
char buf[BUFSIZ], *strcpy(), *index(), args[MAXLINES][256];
/* clear what we've written */
if (talking || force_erase) {
if (!talking)
return;
if (talking == 2) {
XSetForeground(dpy, gc, Black);
XDrawString(dpy, XtWindow(widget), gc, X, Y, words, strlen(words));
XSetForeground(dpy, gc, White);
} else if (talking == 1) {
XSetForeground(dpy, gc, Black);
XFillRectangle(dpy, XtWindow(widget), gc, s_rect.x-5, s_rect.y-5,
s_rect.width+10, s_rect.height+10);
XSetForeground(dpy, gc, White);
}
talking = 0;
if (!force_erase)
timeout_id = XtAppAddTimeOut(app, 40L, move, NULL);
return;
}
talking = 1;
walk(FRONT);
p = strcpy(buf, words);
/* possibly avoid a lot of work here
* if no CR or only one, then just print the line
*/
if (!(p2 = index(p, '\n')) || !p2[1]) {
register int w;
if (p2)
*p2 = 0;
w = XTextWidth(font, words, strlen(words));
X = x + 32 - w/2;
Y = y - 5 - font_height(font);
/* give us a nice 5 pixel margin */
if (X < 5)
X = 5;
else if (X + w + 15 > Width + 5)
X = Width - w - 5;
if (Y < 5)
Y = y + 64 + 5 + font_height(font);
XDrawString(dpy, XtWindow(widget), gc, X, Y, words, strlen(words));
timeout_id = XtAppAddTimeOut(app, 5000L, (XtTimerCallbackProc)talk,
NULL);
talking++;
return;
}
/* p2 now points to the first '\n' */
for (height = 0; p; height++) {
int w;
*p2 = 0;
if ((w = XTextWidth(font, p, p2 - p)) > width)
width = w;
total += p2 - p; /* total chars; count to determine reading time */
strcpy(args[height], p);
if (height == MAXLINES - 1) {
puts("Message too long!");
break;
}
p = p2+1;
if (!(p2 = index(p, '\n')))
break;
}
height++;
/* Figure out the height and width in pixels (height, width) extend
* the new box by 15 pixels on the sides (30 total) top and bottom.
*/
s_rect.width = width + 30;
s_rect.height = height * font_height(font) + 30;
if (x - s_rect.width - 10 < 5)
s_rect.x = 5;
else
if ((s_rect.x = x+32-(s_rect.width+15)/2)
+ s_rect.width+15 > Width-5)
s_rect.x = Width - 15 - s_rect.width;
if (y - s_rect.height - 10 < 5)
s_rect.y = y + 64 + 5;
else
s_rect.y = y - 5 - s_rect.height;
XSetForeground(dpy, gc, White);
XFillRectangle(dpy, XtWindow(widget), gc,
s_rect.x-5, s_rect.y-5, s_rect.width+10, s_rect.height+10);
XSetForeground(dpy, gc, Black);
/* make a box that's 5 pixels thick. Then add a thin box inside it */
XSetLineAttributes(dpy, gc, 5, 0, 0, 0);
XDrawRectangle(dpy, XtWindow(widget), gc,
s_rect.x, s_rect.y, s_rect.width-1, s_rect.height-1);
XSetLineAttributes(dpy, gc, 0, 0, 0, 0);
XDrawRectangle(dpy, XtWindow(widget), gc,
s_rect.x + 7, s_rect.y + 7, s_rect.width - 15, s_rect.height - 15);
X = 15;
Y = 15 + font_height(font);
/* now print each string in reverse order (start at bottom of box) */
for (Z = 0; Z < height; Z++) {
XDrawString(dpy, XtWindow(widget), gc, s_rect.x+X, s_rect.y+Y,
args[Z], strlen(args[Z]));
Y += font_height(font);
}
timeout_id = XtAppAddTimeOut(app, (total/15) * 1000,
(XtTimerCallbackProc)talk, NULL);
}
static unsigned long
look()
{
if (rand() % 3) {
XCopyPlane(dpy, (rand() & 1)? down : front, XtWindow(widget), gc,
0, 0, 64,64, x, y, 1L);
return 1000L;
}
if (!(rand() % 5))
return 0;
if (rand() % 3) {
XCopyPlane(dpy, (rand() & 1)? left_front : right_front,
XtWindow(widget), gc, 0, 0, 64,64, x, y, 1L);
return 1000L;
}
if (!(rand() % 5))
return 0;
XCopyPlane(dpy, (rand() & 1)? left0 : right0, XtWindow(widget), gc,
0, 0, 64,64, x, y, 1L);
return 1000L;
}

123
appl/xnlock/xnlock.man Normal file
View File

@@ -0,0 +1,123 @@
.\" xnlock -- Dan Heller 1985 <argv@sun.com>
.TH XNLOCK 1L "19 April 1990"
.SH NAME
xnlock \- amusing lock screen program with message for passers-by
.SH SYNOPSIS
.B xnlock
[
\fIoptions\fP
]
[
\fImessage\fP
]
.SH DESCRIPTION
.I xnlock
is a program that acts as a screen saver for workstations running X11.
It also "locks" the screen such that the workstation can be left
unattended without worry that someone else will walk up to it and
mess everything up. When \fIxnlock\fP is running, a little man with
a big nose and a hat runs around spewing out messages to the screen.
By default, the messages are "humorous", but that depends on your
sense of humor.
.LP
If a key or mouse button is pressed, a prompt is printed requesting the
user's password. If a RETURN is not typed within 30 seconds,
the little man resumes running around.
.LP
Text on the command line is used as the message. For example:
.br
% xnlock I\'m out to lunch for a couple of hours.
.br
Note the need to quote shell metacharacters.
.LP
In the absence of flags or text, \fIxnlock\fP displays random fortunes.
.SH OPTIONS
Command line options override all resource specifications.
All arguments that are not associated with a command line option
is taken to be message text that the little man will "say" every
once in a while. The resource \fBxnlock.text\fP may be set to
a string.
.TP
.BI \-fn " fontname"
The default font is the first 18 point font in the \fInew century schoolbook\fP
family. While larger fonts are recokmmended over smaller ones, any font
in the server's font list will work. The resource to use for this option
is \fBxnlock.font\fP.
.TP
.BI \-filename " filename"
Take the message to be displayed from the file \fIfilename\fP.
If \fIfilename\fP is not specified, \fI$HOME/.msgfile\fP is used.
If the contents of the file are changed during runtime, the most recent text
of the file is used (allowing the displayed message to be altered remotely).
Carriage returns within the text are allowed, but tabs or other control
characters are not translated and should not be used.
The resource available for this option is \fBxnlock.file\fP.
.TP
.BI \-ar
Accept root's password to unlock screen. This option is true by
default. The reason for this is so that someone's screen may be
unlocked by autorized users in case of emergency and the person
running the program is still out to lunch. The resource available
for specifying this option is \fBxnlock.acceptRootPasswd\fP.
.TP
.BI \-noar
Don't accept root's password. This option is for paranoids who
fear their peers might breakin using root's password and remove
their files anyway. Specifying this option on the command line
overrides the \fBxnlock.acceptRootPasswd\fP if set to True.
.TP
.BI \-ip
Ignore password prompt.
The resource available for this option is \fBxnlock.ignorePasswd\fP.
.TP
.BI \-noip
Don't ignore password prompt. This is available in order to
override the resource \fBignorePasswd\fP if set to True.
.TP
.BI -fg " color"
Specifies the foreground color. The resource available for this
is \fBxnlock.foreground\fP.
.TP
.BI -bg " color"
Specifies the background color. The resource available for this
is \fBxnlock.background\fP.
.TP
.BI \-rv
Reverse the foreground and background colors.
The resource for this is \fBxvnlock.reverseVideo\fP.
.TP
.BI \-norv
Don't use reverse video. This is available to override the reverseVideo
resource if set to True.
.TP
.BI \-prog " program"
Receive message text from the running program \fIprogram\fP. If there
are arguments to \fIprogram\fP, encase them with the name of the program in
quotes (e.g. xnlock -t "fortune -o").
The resource for this is \fBxnlock.program\fP.
.SH RESOURCES
.br
xnlock.font: fontname
.br
xnlock.foreground: color
.br
xnlock.background: color
.br
xnlock.reverseVideo: True/False
.br
xnlock.text: Some random text string
.br
xnlock.program: program [args]
.br
xnlock.ignorePasswd: True/False
.br
xnlock.acceptRootPasswd: True/False
.SH FILES
\fIxnlock\fP executable file
.br
~/.msgfile default message file
.SH AUTHOR
Dan Heller <argv@sun.com> Copyright (c) 1985, 1990.
.br
The original version of this program was written using pixrects on
a Sun 2 running SunOS 1.1.

51
lib/des/3cbc_enc.c Normal file
View File

@@ -0,0 +1,51 @@
/* 3cbc_enc.c */
/* Copyright (C) 1993 Eric Young - see README for more details */
#include "des_locl.h"
static void
xp(des_cblock *arg)
{
unsigned char *a = (unsigned char *) arg;
int i;
for(i=0; i<8; i++) printf("%02X",a[i]);printf("\n");
}
int des_3cbc_encrypt(des_cblock (*input), des_cblock (*output), long int length, struct des_ks_struct *ks1, struct des_ks_struct *ks2, des_cblock (*iv1), des_cblock (*iv2), int encrypt)
{
int off=length/8-1;
des_cblock niv1,niv2;
printf("3cbc\n");
xp(iv1);
xp(iv1);
xp(iv2);
xp(input);
if (encrypt == DES_ENCRYPT)
{
des_cbc_encrypt(input,output,length,ks1,iv1,encrypt);
if (length >= sizeof(des_cblock))
memcpy(niv1,output[off],sizeof(des_cblock));
des_cbc_encrypt(output,output,length,ks2,iv1,!encrypt);
des_cbc_encrypt(output,output,length,ks1,iv2, encrypt);
if (length >= sizeof(des_cblock))
memcpy(niv2,output[off],sizeof(des_cblock));
memcpy(*iv1,niv1,sizeof(des_cblock));
}
else
{
if (length >= sizeof(des_cblock))
memcpy(niv1,input[off],sizeof(des_cblock));
des_cbc_encrypt(input,output,length,ks1,iv1,encrypt);
des_cbc_encrypt(output,output,length,ks2,iv2,!encrypt);
if (length >= sizeof(des_cblock))
memcpy(niv2,output[off],sizeof(des_cblock));
des_cbc_encrypt(output,output,length,ks1,iv2, encrypt);
}
memcpy(iv1,niv1,sizeof(des_cblock));
memcpy(iv2,niv2,sizeof(des_cblock));
xp(iv1);
xp(iv1);
xp(iv2);
xp(output);
return(0);
}

26
lib/des/3ecb_enc.c Normal file
View File

@@ -0,0 +1,26 @@
/* 3ecb_enc.c */
/* Copyright (C) 1993 Eric Young - see README for more details */
#include "des_locl.h"
int des_3ecb_encrypt(des_cblock (*input), des_cblock (*output), struct des_ks_struct *ks1, struct des_ks_struct *ks2, int encrypt)
{
register u_int32_t l0,l1;
register unsigned char *in,*out;
u_int32_t ll[2];
in=(unsigned char *)input;
out=(unsigned char *)output;
c2l(in,l0);
c2l(in,l1);
ll[0]=l0;
ll[1]=l1;
des_encrypt(ll,ll,ks1,encrypt);
des_encrypt(ll,ll,ks2,!encrypt);
des_encrypt(ll,ll,ks1,encrypt);
l0=ll[0];
l1=ll[1];
l2c(l0,out);
l2c(l1,out);
return(0);
}

105
lib/des/ARTISTIC Normal file
View File

@@ -0,0 +1,105 @@
The "Artistic License"
Preamble
The intent of this document is to state the conditions under which a
Package may be copied, such that the Copyright Holder maintains some
semblance of artistic control over the development of the package,
while giving the users of the package the right to use and distribute
the Package in a more-or-less customary fashion, plus the right to make
reasonable modifications.
Definitions:
"Package" refers to the collection of files distributed by the
Copyright Holder, and derivatives of that collection of files
created through textual modification.
"Standard Version" refers to such a Package if it has not been
modified, or has been modified in accordance with the wishes
of the Copyright Holder as specified below.
"Copyright Holder" is whoever is named in the copyright or
copyrights for the package.
"You" is you, if you're thinking about copying or distributing
this Package.
"Reasonable copying fee" is whatever you can justify on the
basis of media cost, duplication charges, time of people involved,
and so on. (You will not be required to justify it to the
Copyright Holder, but only to the computing community at large
as a market that must bear the fee.)
"Freely Available" means that no fee is charged for the item
itself, though there may be fees involved in handling the item.
It also means that recipients of the item may redistribute it
under the same conditions they received it.
1. You may make and give away verbatim copies of the source form of the
Standard Version of this Package without restriction, provided that you
duplicate all of the original copyright notices and associated disclaimers.
2. You may apply bug fixes, portability fixes and other modifications
derived from the Public Domain or from the Copyright Holder. A Package
modified in such a way shall still be considered the Standard Version.
3. You may otherwise modify your copy of this Package in any way, provided
that you insert a prominent notice in each changed file stating how and
when you changed that file, and provided that you do at least ONE of the
following:
a) place your modifications in the Public Domain or otherwise make them
Freely Available, such as by posting said modifications to Usenet or
an equivalent medium, or placing the modifications on a major archive
site such as uunet.uu.net, or by allowing the Copyright Holder to include
your modifications in the Standard Version of the Package.
b) use the modified Package only within your corporation or organization.
c) rename any non-standard executables so the names do not conflict
with standard executables, which must also be provided, and provide
a separate manual page for each non-standard executable that clearly
documents how it differs from the Standard Version.
d) make other distribution arrangements with the Copyright Holder.
4. You may distribute the programs of this Package in object code or
executable form, provided that you do at least ONE of the following:
a) distribute a Standard Version of the executables and library files,
together with instructions (in the manual page or equivalent) on where
to get the Standard Version.
b) accompany the distribution with the machine-readable source of
the Package with your modifications.
c) give non-standard executables non-standard names, and clearly
document the differences in manual pages (or equivalent), together
with instructions on where to get the Standard Version.
d) make other distribution arrangements with the Copyright Holder.
5. You may charge a reasonable copying fee for any distribution of this
Package. You may charge any fee you choose for support of this
Package. You may not charge a fee for this Package itself. However,
you may distribute this Package in aggregate with other (possibly
commercial) programs as part of a larger (possibly commercial) software
distribution provided that you do not advertise this Package as a
product of your own.
6. Any programs linked with this library do not automatically fall
under the copyright of this Package, but belong to whomever generated
them, and may be sold commercially, and may be aggregated with this
Package.
7. The name of the Copyright Holder may not be used to endorse or promote
products derived from this software without specific prior written permission.
8. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
The End

16
lib/des/CHANGES Normal file
View File

@@ -0,0 +1,16 @@
The main changes in this package since it was last posted to
comp.sources.misc are
The main changes are
- Major changes to the Copyright restrictions.
- Lots and lots of features added to the des(1) command, including
- Triple DES, both triple ECB and triple CBC options.
- uuencodeing/uudecoding built in to des(1).
- generate checksums.
- hex keys.
- Cleaned up the prototypes in des.h
- Filenames are now mostly <= 8 characters long.
- OFB, CFB, triple ECB and triple CBC modes of DES added to the library.
- Compiles and runs of all 64bit machines I could test the code on
(Cray, ETA10, DEC Alpha).
- It really does work with kerberos v 4 now :-).

489
lib/des/COPYING Normal file
View File

@@ -0,0 +1,489 @@
Copyright (C) 1993 Eric Young
This is a DES implementation written by Eric Young (eay@psych.psy.uq.oz.au)
The implementation was written so as to conform with the manual entry
for the des_crypt(3) library routines from MIT's project Athena.
GNU LIBRARY GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the library GPL. It is
numbered 2 because it goes with version 2 of the ordinary GPL.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Library General Public License, applies to some
specially designated Free Software Foundation software, and to any
other libraries whose authors decide to use it. You can use it for
your libraries, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if
you distribute copies of the library, or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link a program with the library, you must provide
complete object files to the recipients so that they can relink them
with the library, after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
Our method of protecting your rights has two steps: (1) copyright
the library, and (2) offer you this license which gives you legal
permission to copy, distribute and/or modify the library.
Also, for each distributor's protection, we want to make certain
that everyone understands that there is no warranty for this free
library. If the library is modified by someone else and passed on, we
want its recipients to know that what they have is not the original
version, so that any problems introduced by others will not reflect on
the original authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that companies distributing free
software will individually obtain patent licenses, thus in effect
transforming the program into proprietary software. To prevent this,
we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary
GNU General Public License, which was designed for utility programs. This
license, the GNU Library General Public License, applies to certain
designated libraries. This license is quite different from the ordinary
one; be sure to read it in full, and don't assume that anything in it is
the same as in the ordinary license.
The reason we have a separate public license for some libraries is that
they blur the distinction we usually make between modifying or adding to a
program and simply using it. Linking a program with a library, without
changing the library, is in some sense simply using the library, and is
analogous to running a utility program or application program. However, in
a textual and legal sense, the linked executable is a combined work, a
derivative of the original library, and the ordinary General Public License
treats it as such.
Because of this blurred distinction, using the ordinary General
Public License for libraries did not effectively promote software
sharing, because most developers did not use the libraries. We
concluded that weaker conditions might promote sharing better.
However, unrestricted linking of non-free programs would deprive the
users of those programs of all benefit from the free status of the
libraries themselves. This Library General Public License is intended to
permit developers of non-free programs to use free libraries, while
preserving your freedom as a user of such programs to change the free
libraries that are incorporated in them. (We have not seen how to achieve
this as regards changes in header files, but we have achieved it as regards
changes in the actual functions of the Library.) The hope is that this
will lead to faster development of free libraries.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, while the latter only
works together with the library.
Note that it is possible for a library to be covered by the ordinary
General Public License rather than by this special one.
GNU LIBRARY GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library which
contains a notice placed by the copyright holder or other authorized
party saying it may be distributed under the terms of this Library
General Public License (also called "this License"). Each licensee is
addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also compile or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
c) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
d) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the source code distributed need not include anything that is normally
distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Library General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

60
lib/des/FILES Normal file
View File

@@ -0,0 +1,60 @@
/* General stuff */
CHANGES - Changes since the last posting to comp.sources.misc.
ARTISTIC - Copying info.
COPYING - Copying info.
MODES.DES - A description of the features of the different modes of DES.
FILES - This file.
INSTALL - How to make things compile.
Imakefile - For use with kerberos.
README - What this package is.
VERSION - Which version this is.
KERBEROS - Kerberos version 4 notes.
makefile - The make file.
times - Some outputs from 'speed' on my local machines.
vms.com - For use when compiling under VMS
/* My sunOS des(1) replacement */
des.c - des(1) source code.
des.man - des(1) manual.
/* Testing and timing programs. */
destest.c - Source for libdes.a test program.
speed.c - Source for libdes.a timing program.
rpw.c - Source for libdes.a testing password reading routines.
/* libdes.a source code */
des_crypt.man - libdes.a manual page.
des.h - Public libdes.a header file.
ecb_enc.c - des_ecb_encrypt() source, this contains the basic DES code.
3ecb_enc.c - des_3ecb_encrypt() source.
cbc_ckm.c - des_cbc_cksum() source.
cbc_enc.c - des_cbc_encrypt() source.
3cbc_enc.c - des_3cbc_encrypt() source.
cfb_enc.c - des_cfb_encrypt() source.
ofb_enc.c - des_cfb_encrypt() source.
enc_read.c - des_enc_read() source.
enc_writ.c - des_enc_write() source.
pcbc_enc.c - des_pcbc_encrypt() source.
qud_cksm.c - quad_cksum() source.
rand_key.c - des_random_key() source.
read_pwd.c - Source for des_read_password() plus related functions.
set_key.c - Source for des_set_key().
str2key.c - Covert a string of any length into a key.
fcrypt.c - A small, fast version of crypt(3).
des_locl.h - Internal libdes.a header file.
podd.h - Odd parity tables - used in des_set_key().
sk.h - Lookup tables used in des_set_key().
spr.h - What is left of the S tables - used in ecb_encrypt().
/* The perl scripts - you can ignore these files they are only
* included for the curious */
des.pl - des in perl anyone? des_set_key and des_ecb_encrypt
both done in a perl library.
testdes.pl - Testing program for des.pl
doIP - Perl script used to develop IP xor/shift code.
doPC1 - Perl script used to develop PC1 xor/shift code.
doPC2 - Generates sk.h.
PC1 - Output of doPC1 should be the same as output from PC1.
PC2 - used in development of doPC2.
shifts.pl - Perl library used by my perl scripts.

53
lib/des/INSTALL Normal file
View File

@@ -0,0 +1,53 @@
Check the CC and CFLAGS lines in the makefile
If your C library does not support the times(3) function, change the
#define TIMES to
#undef TIMES in speed.c
If it does, check the HZ value for the times(3) function.
If your system does not define CLK_TCK it will be assumed to
be 60.
If possible use gcc v 2.2.2
Turn on the maximum optimising
type 'make'
run './destest' to check things are ok.
run './rpw' to check the tty code for reading passwords works.
run './speed' to see how fast those optimisations make the library run :-)
A make install will by default install
libdes.a in /usr/local/lib/libdes.a
des in /usr/local/bin/des
des_crypt.man in /usr/local/man/man3/des_crypt.3
des.man in /usr/local/man/man1/des.1
des.h in /usr/include/des.h
des(1) should be compatible with sunOS's but I have been unable to
test it.
These routines should compile on MSDOS, most 32bit and 64bit version
of Unix (BSD and SYSV) and VMS, without modification.
The only problems should be #include files that are in the wrong places.
These routines can be compiled under MSDOS.
I have successfully encrypted files using des(1) under MSDOS and then
decrypted the files on a SparcStation.
I have been able to compile and test the routines with
Microsoft C v 5.1 and Turbo C v 2.0.
The code in this library is in no way optimised for the 16bit
operation of MSDOS. Microsoft C generates code that is 40% slower
than Turbo C's code. I believe this is due to problems it has with
code generation with the 32bit shift operation in the IP and FP
sections. I have added some 16bit optimization in ecb_encrypt.c
and this generated a %70 speedup under Turbo C. Such are the
limitations of DOS compilers :-(.
For Turbo C v 2.0, make sure to define MSDOS, in the relevant menu.
There is an alternative version of the D_ENCRYPT macro that can be
enabled with the -DALT_ECB option in the makefile. This alternative
macro can make a +-%20 speed difference to the DES encryption speed,
depending on the compiler/CPU combinations.
It has its greatest effect on Sparc machines when using the sun compiler.
If in doubt, try enable/disable it and running speed.

33
lib/des/Imakefile Normal file
View File

@@ -0,0 +1,33 @@
# This Imakefile has not been tested for a while but it should still
# work when placed in the correct directory in the kerberos v 4 distribution
SRCS= cbc_cksm.c cbc_enc.c ecb_enc.c pcbc_enc.c \
qud_cksm.c rand_key.c read_pwd.c set_key.c str2key.c \
enc_read.c enc_writ.c cfb_enc.c \
3ecb_enc.c ofb_enc.c 3cbc_enc.c rnd_keys.c
OBJS= cbc_cksm.o cbc_enc.o ecb_enc.o pcbc_enc.o \
qud_cksm.o rand_key.o read_pwd.o set_key.o str2key.o \
enc_read.o enc_writ.o cfb_enc.o \
3ecb_enc.o ofb_enc.o 3cbc_enc.o rnd_keys.o
GENERAL=COPYING FILES INSTALL Imakefile README VERSION makefile times \
vms.com KERBEROS
DES= des.c des.man
TESTING=destest.c speed.c rpw.c
LIBDES= des_crypt.man des.h des_locl.h podd.h sk.h spr.h
PERL= des.pl testdes.pl doIP doPC1 doPC2 PC1 PC2 shifts.pl
CODE= $(GENERAL) $(DES) $(TESTING) $(SRCS) $(LIBDES) $(PERL)
SRCDIR=$(SRCTOP)/lib/des
library_obj_rule()
install_library_target(des,$(OBJS),$(SRCS),)
test(destest,libdes.a,)
test(rpw,libdes.a,)
test(speed,libdes.a,)
test(des,libdes.a,)

38
lib/des/KERBEROS Normal file
View File

@@ -0,0 +1,38 @@
To use this library with Bones (kerberos without DES):
1) Get my modified Bones - eBones. It can be found on
gondwana.ecr.mu.oz.au (128.250.1.63) /pub/athena/eBones-p9.tar.Z
and
nic.funet.fi (128.214.6.100) /pub/unix/security/Kerberos/eBones-p9.tar.Z
2) Unpack this library in src/lib/des, makeing sure it is version
3.00 or greater (libdes.tar.93-10-07.Z). This versions differences
from the version in comp.sources.misc volume 29 patchlevel2.
The primarily difference is that it should compile under kerberos :-).
It can be found at.
ftp.psy.uq.oz.au (130.102.32.1) /pub/DES/libdes.tar.93-10-07.Z
Now do a normal kerberos build and things should work.
One problem I found when I was build on my local sun.
---
For sunOS 4.1.1 apply the following patch to src/util/ss/make_commands.c
*** make_commands.c.orig Fri Jul 3 04:18:35 1987
--- make_commands.c Wed May 20 08:47:42 1992
***************
*** 98,104 ****
if (!rename(o_file, z_file)) {
if (!vfork()) {
chdir("/tmp");
! execl("/bin/ld", "ld", "-o", o_file+5, "-s", "-r", "-n",
z_file+5, 0);
perror("/bin/ld");
_exit(1);
--- 98,104 ----
if (!rename(o_file, z_file)) {
if (!vfork()) {
chdir("/tmp");
! execl("/bin/ld", "ld", "-o", o_file+5, "-s", "-r",
z_file+5, 0);
perror("/bin/ld");
_exit(1);

84
lib/des/MODES.DES Normal file
View File

@@ -0,0 +1,84 @@
Modes of DES
Quite a bit of the following information has been taken from
AS 2805.5.2
Australian Standard
Electronic funds transfer - Requirements for interfaces,
Part 5.2: Modes of operation for an n-bit block cipher algorithm
Appendix A
There are several different modes in which DES can be used, they are
as follows.
Electronic Codebook Mode (ECB) (des_ecb_encrypt())
- 64 bits are enciphered at a time.
- The order of the blocks can be rearranged without detection.
- The same plaintext block always produces the same ciphertext block
(for the same key) making it vulnerable to a 'dictionary attack'.
- An error will only affect one ciphertext block.
Cipher Block Chaining Mode (CBC) (des_cbc_encrypt())
- a multiple of 64 bits are enciphered at a time.
- The CBC mode produces the same ciphertext whenever the same
plaintext is encrypted using the same key and starting variable.
- The chaining operation makes the ciphertext blocks dependent on the
current and all preceding plaintext blocks and therefore blocks can not
be rearranged.
- The use of different starting variables prevents the same plaintext
enciphering to the same ciphertext.
- An error will affect the current and the following ciphertext blocks.
Cipher Feedback Mode (CFB) (des_cfb_encrypt())
- a number of bits (j) <= 64 are enciphered at a time.
- The CFB mode produces the same ciphertext whenever the same
plaintext is encrypted using the same key and starting variable.
- The chaining operation makes the ciphertext variables dependent on the
current and all preceding variables and therefore j-bit variables are
chained together and con not be rearranged.
- The use of different starting variables prevents the same plaintext
enciphering to the same ciphertext.
- The strength of the CFB mode depends on the size of k (maximal if
j == k). In my implementation this is always the case.
- Selection of a small value for j will require more cycles through
the encipherment algorithm per unit of plaintext and thus cause
greater processing overheads.
- Only multiples of j bits can be enciphered.
- An error will affect the current and the following ciphertext variables.
Output Feedback Mode (OFB) (des_ofb_encrypt())
- a number of bits (j) <= 64 are enciphered at a time.
- The OFB mode produces the same ciphertext whenever the same
plaintext enciphered using the same key and starting variable. More
over, in the OFB mode the same key stream is produced when the same
key and start variable are used. Consequently, for security reasons
a specific start variable should be used only once for a given key.
- The absence of chaining makes the OFB more vulnerable to specific attacks.
- The use of different start variables values prevents the same
plaintext enciphering to the same ciphertext, by producing different
key streams.
- Selection of a small value for j will require more cycles through
the encipherment algorithm per unit of plaintext and thus cause
greater processing overheads.
- Only multiples of j bits can be enciphered.
- OFB mode of operation does not extend ciphertext errors in the
resultant plaintext output. Every bit error in the ciphertext causes
only one bit to be in error in the deciphered plaintext.
- OFB mode is not self-synchronising. If the two operation of
encipherment and decipherment get out of synchronism, the system needs
to be re-initialised.
- Each re-initialisation should use a value of the start variable
different from the start variable values used before with the same
key. The reason for this is that an identical bit stream would be
produced each time from the same parameters. This would be
susceptible to a ' known plaintext' attack.
Triple ECB Mode (des_3ecb_encrypt())
- Encrypt with key1, decrypt with key2 and encrypt with key1 again.
- As for ECB encryption but increases the effective key length to 112 bits.
- If both keys are the same it is equivalent to encrypting once with
just one key.
Triple CBC Mode (des_3cbc_encrypt())
- Encrypt with key1, decrypt with key2 and encrypt with key1 again.
- As for CBC encryption but increases the effective key length to 112 bits.
- If both keys are the same it is equivalent to encrypting once with
just one key.

28
lib/des/PC1 Executable file
View File

@@ -0,0 +1,28 @@
#!/usr/local/bin/perl
@PC1=( 57,49,41,33,25,17, 9,
1,58,50,42,34,26,18,
10, 2,59,51,43,35,27,
19,11, 3,60,52,44,36,
"-","-","-","-",
63,55,47,39,31,23,15,
7,62,54,46,38,30,22,
14, 6,61,53,45,37,29,
21,13, 5,28,20,12, 4,
"-","-","-","-",
);
foreach (@PC1)
{
if ($_ ne "-")
{
$_--;
$_=int($_/8)*8+7-($_%8);
printf "%2d ",$_;
}
else
{ print "-- "; }
print "\n" if (((++$i) % 8) == 0);
print "\n" if ((($i) % 32) == 0);
}

57
lib/des/PC2 Executable file
View File

@@ -0,0 +1,57 @@
#!/usr/local/bin/perl
@PC2_C=(14,17,11,24, 1, 5,
3,28,15, 6,21,10,
23,19,12, 4,26, 8,
16, 7,27,20,13, 2,
);
@PC2_D=(41,52,31,37,47,55,
30,40,51,45,33,48,
44,49,39,56,34,53,
46,42,50,36,29,32,
);
foreach (@PC2_C) {
if ($_ ne "-")
{
$_--;
printf "%2d ",$_; }
else { print "-- "; }
$C{$_}=1;
print "\n" if (((++$i) % 8) == 0);
}
$i=0;
print "\n";
foreach (@PC2_D) {
if ($_ ne "-")
{
$_-=29;
printf "%2d ",$_; }
else { print "-- "; }
$D{$_}=1;
print "\n" if (((++$i) % 8) == 0); }
print "\n";
foreach $i (0 .. 27)
{
$_=$C{$i};
if ($_ ne "-") {printf "%2d ",$_;}
else { print "-- "; }
print "\n" if (((++$i) % 8) == 0);
}
print "\n";
print "\n";
foreach $i (0 .. 27)
{
$_=$D{$i};
if ($_ ne "-") {printf "%2d ",$_;}
else { print "-- "; }
print "\n" if (((++$i) % 8) == 0);
}
print "\n";
sub numsort
{
$a-$b;
}

56
lib/des/README Normal file
View File

@@ -0,0 +1,56 @@
libdes, Version 3.00 93/10/07
Copyright (c) 1993, Eric Young
All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of either:
a) the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any
later version, or
b) the "Artistic License" which comes with this Kit.
This program 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 either
the GNU General Public License or the Artistic License for more details.
You should have received a copy of the Artistic License with this
Kit, in the file named "Artistic". If not, I'll be glad to provide one.
You should also have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
---
This kit builds a DES encryption library and a DES encryption program.
It suports ecb, cbc, ofb, cfb, triple ecb, triple cbc and MIT's pcbc
encryption modes and also has a fast implementation of crypt(3).
It contains support routines to read keys from a terminal,
generate a random key, generate a key from an arbitary length string,
read/write encrypted data from/to a file descriptor.
The implementation was written so as to conform with the manual entry
for the des_crypt(3) library routines from MIT's project Athena.
destest should be run after compilation to test the des routines.
rpw should be run after compilation to test the read password routines.
The des program is a replacement for the sun des command. I believe it
conforms to the sun version.
The Imakefile is setup for use in the kerberos distribution.
These routines are best compiled with gcc or any other good
optimising compiler.
Just turn you optimiser up to the highest settings and run destest
after the build to make sure everything works.
I believe these routines are close to the fastest and most portable DES
routines that use small lookup tables (4.5k) that are publicly available.
The fcrypt routine is faster than ufc's fcrypt (when compiling with
gcc2 -O2) on the sparc 2 (1410 vs 1270) but is not so good on other machines
(on a sun3/260 168 vs 336).
Eric Young (eay@psych.psy.uq.oz.au)

185
lib/des/VERSION Normal file
View File

@@ -0,0 +1,185 @@
Release apon comp.sources.misc
Version 3.01 08/10/93
Added des_3cbc_encrypt()
Version 3.00 07/10/93
Fixed up documentation.
quad_cksum definitly compatable with MIT's now.
Version 2.30 24/08/93
Tripple DES now defaults to tripple cbc but can do tripple ecb
with the -b flag.
Fixed some MSDOS uuen/uudecoding problems, thanks to
Added prototypes.
Version 2.22 29/06/93
Fixed a bug in des_is_weak_key() which stopped it working :-(
thanks to engineering@MorningStar.Com.
Version 2.21 03/06/93
des(1) with no arguments gives quite a bit of help.
Added -c (generate ckecksum) flag to des(1).
Added -3 (tripple DES) flag to des(1).
Added cfb and ofb routines to the library.
Version 2.20 11/03/93
Added -u (uuencode) flag to des(1).
I have been playing with byte order in quad_cksum to make it
compatible with MIT's version. All I can say is aviod this
function if possible since MIT's output is endian dependent.
Version 2.12 14/10/92
Added MSDOS specific macro in ecb_encrypt which gives a %70
speed up when the code is compiled with turbo C.
Version 2.11 12/10/92
Speedup in set_key (recoding of PC-1)
I now do it in 47 simple operations, down from 60.
Thanks to John Fletcher (john_fletcher@lccmail.ocf.llnl.gov)
for motivating me to look for a faster system :-)
The speedup is probably less that 1% but it is still 13
instructions less :-).
Version 2.10 06/10/92
The code now works on the 64bit ETA10 and CRAY without modifications or
#defines. I believe the code should work on any machine that
defines long, int or short to be 8 bytes long.
Thanks to Shabbir J. Safdar (shabby@mentor.cc.purdue.edu)
for helping me fix the code to run on 64bit machines (he had
access to an ETA10).
Thanks also to John Fletcher <john_fletcher@lccmail.ocf.llnl.gov>
for testing the routines on a CRAY.
read_password.c has been renamed to read_passwd.c
string_to_key.c has been renamed to string2key.c
Version 2.00 14/09/92
Made mods so that the library should work on 64bit CPU's.
Removed all my uchar and ulong defs. To many different
versions of unix define them in their header files in too many
different combinations :-)
IRIX - Sillicon Graphics mods (mostly in read_password.c).
Thanks to Andrew Daviel (advax@erich.triumf.ca)
Version 1.99 26/08/92
Fixed a bug or 2 in enc_read.c
Fixed a bug in enc_write.c
Fixed a pseudo bug in fcrypt.c (very obscure).
Version 1.98 31/07/92
Support for the ETA10. This is a strange machine that defines
longs and ints as 8 bytes and shorts as 4 bytes.
Since I do evil things with long * that assume that they are 4
bytes. Look in the Makefile for the option to compile for
this machine. quad_cksum appears to have problems but I
will don't have the time to fix it right now, and this is not
a function that uses DES and so will not effect the main uses
of the library.
Version 1.97 20/05/92 eay
Fixed the Imakefile and made some changes to des.h to fix some
problems when building this package with Kerberos v 4.
Version 1.96 18/05/92 eay
Fixed a small bug in string_to_key() where problems could
occur if des_check_key was set to true and the string
generated a weak key.
Patch2 posted to comp.sources.misc
Version 1.95 13/05/92 eay
Added an alternative version of the D_ENCRYPT macro in
ecb_encrypt and fcrypt. Depending on the compiler, one version or the
other will be faster. This was inspired by
Dana How <how@isl.stanford.edu>, and her pointers about doing the
*(ulong *)((uchar *)ptr+(value&0xfc))
vs
ptr[value&0x3f]
to stop the C compiler doing a <<2 to convert the long array index.
Version 1.94 05/05/92 eay
Fixed an incompatibility between my string_to_key and the MIT
version. When the key is longer than 8 chars, I was wrapping
with a different method. To use the old version, define
OLD_STR_TO_KEY in the makefile. Thanks to
viktor@newsu.shearson.com (Viktor Dukhovni).
Version 1.93 28/04/92 eay
Fixed the VMS mods so that echo is now turned off in
read_password. Thanks again to brennan@coco.cchs.su.oz.AU.
MSDOS support added. The routines can be compiled with
Turbo C (v2.0) and MSC (v5.1). Make sure MSDOS is defined.
Patch1 posted to comp.sources.misc
Version 1.92 13/04/92 eay
Changed D_ENCRYPT so that the rotation of R occurs outside of
the loop. This required rotating all the longs in sp.h (now
called spr.h). Thanks to Richard Outerbridge <71755.204@CompuServe.COM>
speed.c has been changed so it will work without SIGALRM. If
times(3) is not present it will try to use ftime() instead.
Version 1.91 08/04/92 eay
Added -E/-D options to des(1) so it can use string_to_key.
Added SVR4 mods suggested by witr@rwwa.COM
Added VMS mods suggested by brennan@coco.cchs.su.oz.AU. If
anyone knows how to turn of tty echo in VMS please tell me or
implement it yourself :-).
Changed FILE *IN/*OUT to *DES_IN/*DES_OUT since it appears VMS
does not like IN/OUT being used.
Libdes posted to comp.sources.misc
Version 1.9 24/03/92 eay
Now contains a fast small crypt replacement.
Added des(1) command.
Added des_rw_mode so people can use cbc encryption with
enc_read and enc_write.
Version 1.8 15/10/91 eay
Bug in cbc_cksum.
Many thanks to Keith Reynolds (keithr@sco.COM) for pointing this
one out.
Version 1.7 24/09/91 eay
Fixed set_key :-)
set_key is 4 times faster and takes less space.
There are a few minor changes that could be made.
Version 1.6 19/09/1991 eay
Finally go IP and FP finished.
Now I need to fix set_key.
This version is quite a bit faster that 1.51
Version 1.52 15/06/1991 eay
20% speedup in ecb_encrypt by changing the E bit selection
to use 2 32bit words. This also required modification of the
sp table. There is still a way to speedup the IP and IP-1
(hints from outer@sq.com) still working on this one :-(.
Version 1.51 07/06/1991 eay
Faster des_encrypt by loop unrolling
Fixed bug in quad_cksum.c (thanks to hughes@logos.ucs.indiana.edu)
Version 1.50 28/05/1991 eay
Optimized the code a bit more for the sparc. I have improved the
speed of the inner des_encrypt by speeding up the initial and
final permutations.
Version 1.40 23/10/1990 eay
Fixed des_random_key, it did not produce a random key :-(
Version 1.30 2/10/1990 eay
Have made des_quad_cksum the same as MIT's, the full package
should be compatible with MIT's
Have tested on a DECstation 3100
Still need to fix des_set_key (make it faster).
Does des_cbc_encrypts at 70.5k/sec on a 3100.
Version 1.20 18/09/1990 eay
Fixed byte order dependencies.
Fixed (I hope) all the word alignment problems.
Speedup in des_ecb_encrypt.
Version 1.10 11/09/1990 eay
Added des_enc_read and des_enc_write.
Still need to fix des_quad_cksum.
Still need to document des_enc_read and des_enc_write.
Version 1.00 27/08/1990 eay

72
lib/des/cbc_enc.c Normal file
View File

@@ -0,0 +1,72 @@
/* cbc_enc.c */
/* Copyright (C) 1993 Eric Young - see README for more details */
#include "des_locl.h"
int des_cbc_encrypt(des_cblock (*input), des_cblock (*output), long int length, struct des_ks_struct *schedule, des_cblock (*ivec), int encrypt)
{
register u_int32_t tin0,tin1;
register u_int32_t tout0,tout1,xor0,xor1;
register unsigned char *in,*out;
register long l=length;
u_int32_t tout[2],tin[2];
unsigned char *iv;
in=(unsigned char *)input;
out=(unsigned char *)output;
iv=(unsigned char *)ivec;
if (encrypt)
{
c2l(iv,tout0);
c2l(iv,tout1);
for (; l>0; l-=8)
{
if (l >= 8)
{
c2l(in,tin0);
c2l(in,tin1);
}
else
c2ln(in,tin0,tin1,l);
tin0^=tout0;
tin1^=tout1;
tin[0]=tin0;
tin[1]=tin1;
des_encrypt(tin,tout,
schedule,encrypt);
tout0=tout[0];
tout1=tout[1];
l2c(tout0,out);
l2c(tout1,out);
}
}
else
{
c2l(iv,xor0);
c2l(iv,xor1);
for (; l>0; l-=8)
{
c2l(in,tin0);
c2l(in,tin1);
tin[0]=tin0;
tin[1]=tin1;
des_encrypt(tin,tout,
schedule,encrypt);
tout0=tout[0]^xor0;
tout1=tout[1]^xor1;
if (l >= 8)
{
l2c(tout0,out);
l2c(tout1,out);
}
else
l2cn(tout0,tout1,out,l);
xor0=tin0;
xor1=tin1;
}
}
tin0=tin1=tout0=tout1=xor0=xor1=0;
tin[0]=tin[1]=tout[0]=tout[1]=0;
return(0);
}

99
lib/des/cfb_enc.c Normal file
View File

@@ -0,0 +1,99 @@
/* cfb_enc.c */
/* Copyright (C) 1993 Eric Young - see README for more details */
#include "des_locl.h"
/* The input and output are loaded in multiples of 8 bits.
* What this means is that if you hame numbits=12 and length=2
* the first 12 bits will be retrieved from the first byte and half
* the second. The second 12 bits will come from the 3rd and half the 4th
* byte.
*/
int des_cfb_encrypt(unsigned char *in, unsigned char *out, int numbits, long int length, struct des_ks_struct *schedule, des_cblock (*ivec), int encrypt)
{
register u_int32_t d0,d1,v0,v1,n=(numbits+7)/8;
register u_int32_t mask0,mask1;
register long l=length;
register int num=numbits;
u_int32_t ti[2],to[2];
unsigned char *iv;
if (num > 64) return(0);
if (num > 32)
{
mask0=0xffffffff;
if (num == 64)
mask1=mask0;
else
mask1=(1L<<(num-32))-1;
}
else
{
if (num == 32)
mask0=0xffffffff;
else
mask0=(1L<<num)-1;
mask1=0x00000000;
}
iv=(unsigned char *)ivec;
c2l(iv,v0);
c2l(iv,v1);
if (encrypt)
{
while (l-- > 0)
{
ti[0]=v0;
ti[1]=v1;
des_encrypt(ti,to,
schedule,DES_ENCRYPT);
c2ln(in,d0,d1,n);
in+=n;
d0=(d0^to[0])&mask0;
d1=(d1^to[1])&mask1;
l2cn(d0,d1,out,n);
out+=n;
if (num > 32)
{
v0=((v1>>(num-32))|(d0<<(64-num)))&0xffffffff;
v1=((d0>>(num-32))|(d1<<(64-num)))&0xffffffff;
}
else
{
v0=((v0>>num)|(v1<<(32-num)))&0xffffffff;
v1=((v1>>num)|(d0<<(32-num)))&0xffffffff;
}
}
}
else
{
while (l-- > 0)
{
ti[0]=v0;
ti[1]=v1;
des_encrypt(ti,to,
schedule,DES_ENCRYPT);
c2ln(in,d0,d1,n);
in+=n;
if (num > 32)
{
v0=((v1>>(num-32))|(d0<<(64-num)))&0xffffffff;
v1=((d0>>(num-32))|(d1<<(64-num)))&0xffffffff;
}
else
{
v0=((v0>>num)|(v1<<(32-num)))&0xffffffff;
v1=((v1>>num)|(d0<<(32-num)))&0xffffffff;
}
d0=(d0^to[0])&mask0;
d1=(d1^to[1])&mask1;
l2cn(d0,d1,out,n);
out+=n;
}
}
iv=(unsigned char *)ivec;
l2c(v0,iv);
l2c(v1,iv);
v0=v1=d0=d1=ti[0]=ti[1]=to[0]=to[1]=0;
return(0);
}

842
lib/des/des.c Normal file
View File

@@ -0,0 +1,842 @@
/* des.c */
/* Copyright (C) 1993 Eric Young - see README for more details */
#include <stdio.h>
#include <string.h>
#ifdef VMS
#include <types.h>
#include <stat.h>
#else
#if !defined(_IRIX)
#include <sys/types.h>
#endif
#include <sys/stat.h>
#endif
#include "des_locl.h"
void usage(void);
void doencryption(void);
int uufwrite(char *data, int size, int num, FILE *fp);
void uufwriteEnd(FILE *fp);
int uufread(char *out,int size,int num,FILE *fp);
int uuencode(unsigned char *in,int num,unsigned char *out);
int uudecode(unsigned char *in,int num,unsigned char *out);
#ifdef VMS
#define EXIT(a) exit(a&0x10000000)
#else
#define EXIT(a) exit(a)
#endif
#define BUFSIZE (8*1024)
#define VERIFY 1
#define KEYSIZ 8
#define KEYSIZB 1024 /* should hit tty line limit first :-) */
char key[KEYSIZB+1];
int do_encrypt,longk=0;
char *in=NULL,*out=NULL;
FILE *DES_IN,*DES_OUT,*CKSUM_OUT;
char uuname[200];
char uubuf[50];
int uubufnum;
#define INUUBUFN (45*100)
#define OUTUUBUF (65*100)
char b[OUTUUBUF];
char bb[300];
des_cblock cksum={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
char cksumname[200]="";
int cflag,eflag,dflag,kflag,bflag,fflag,sflag,uflag,flag3,hflag,error;
void
main(int argc, char **argv)
{
int i;
struct stat ins,outs;
char *p;
cflag=eflag=dflag=kflag=hflag=bflag=fflag=sflag=uflag=flag3=0,error=0;
memset(key,0,sizeof(key));
for (i=1; i<argc; i++)
{
p=argv[i];
if ((p[0] == '-') && (p[1] != '\0'))
{
p++;
while (*p)
{
switch (*(p++))
{
case '3':
flag3=1;
/* bflag=0; */
longk=1;
break;
case 'c':
cflag=1;
strncpy(cksumname,p,200);
p+=strlen(cksumname);
break;
case 'C':
cflag=1;
longk=1;
strncpy(cksumname,p,200);
p+=strlen(cksumname);
break;
case 'e':
eflag=1;
break;
case 'E':
eflag=1;
longk=1;
break;
case 'd':
dflag=1;
break;
case 'D':
dflag=1;
longk=1;
break;
case 'b':
bflag=1;
flag3=0;
break;
case 'f':
fflag=1;
break;
case 's':
sflag=1;
break;
case 'u':
uflag=1;
strncpy(uuname,p,200);
p+=strlen(uuname);
break;
case 'h':
hflag=1;
break;
case 'k':
kflag=1;
if ((i+1) == argc)
{
fputs("must have a key with the -k option\n",stderr);
error=1;
}
else
{
int j;
i++;
strncpy(key,argv[i],KEYSIZB);
for (j=strlen(argv[i])-1; j>=0; j--)
argv[i][j]='\0';
}
break;
default:
fprintf(stderr,"'%c' unknown flag\n",p[-1]);
error=1;
break;
}
}
}
else
{
if (in == NULL)
in=argv[i];
else if (out == NULL)
out=argv[i];
else
error=1;
}
}
if (error) usage();
/* We either
* do checksum or
* do encrypt or
* do decrypt or
* do decrypt then ckecksum or
* do checksum then encrypt
*/
if (((eflag+dflag) == 1) || cflag)
{
if (eflag) do_encrypt=DES_ENCRYPT;
if (dflag) do_encrypt=DES_DECRYPT;
}
else
usage();
if ( (in != NULL) &&
(out != NULL) &&
#ifndef MSDOS
(stat(in,&ins) != -1) &&
(stat(out,&outs) != -1) &&
(ins.st_dev == outs.st_dev) &&
(ins.st_ino == outs.st_ino))
#else /* MSDOS */
(strcmp(in,out) == 0))
#endif
{
fputs("input and output file are the same\n",stderr);
EXIT(3);
}
if (!kflag)
if (des_read_pw_string(key,KEYSIZB+1,"Enter key:",eflag?VERIFY:0))
{
fputs("password error\n",stderr);
EXIT(2);
}
if (in == NULL)
DES_IN=stdin;
else if ((DES_IN=fopen(in,"r")) == NULL)
{
perror("opening input file");
EXIT(4);
}
CKSUM_OUT=stdout;
if (out == NULL)
{
DES_OUT=stdout;
CKSUM_OUT=stderr;
}
else if ((DES_OUT=fopen(out,"w")) == NULL)
{
perror("opening output file");
EXIT(5);
}
#ifdef MSDOS
/* This should set the file to binary mode. */
{
#include <fcntl.h>
if (!(uflag && dflag))
setmode(fileno(DES_IN),O_BINARY);
if (!(uflag && eflag))
setmode(fileno(DES_OUT),O_BINARY);
}
#endif
doencryption();
fclose(DES_IN);
fclose(DES_OUT);
EXIT(0);
}
void
usage(void)
{
char **u;
static char *usage[]={
"des <options> [input-file [output-file]]",
"options:",
"-e : encrypt using sunOS compatible user key to DES key conversion.",
"-E : encrypt ",
"-d : decrypt using sunOS compatible user key to DES key conversion.",
"-D : decrypt ",
"-c[ckname] : generate a cbc_cksum using sunOS compatible user key to",
" DES key conversion and output to ckname (stdout default,",
" stderr if data being output on stdout). The checksum is",
" generated before encryption and after decryption if used",
" in conjunction with -[eEdD].",
"-C[ckname] : generate a cbc_cksum as for -c but compatible with -[ED].",
"-k key : use key 'key'",
"-h : the key that is entered will be a hexidecimal number",
"-u[uuname] : input file is uudecoded if -[dD] or output uuencoded",
" data if -[eE] (uuname is the filename to put in the",
" uuencode header).",
"-b : encrypt using DES in ecb encryption mode, the defaut is",
" cbc mode.",
"-3 : encrypt using tripple DES encryption. This uses 2 keys",
" generated from the input key. If the input key is less",
" than 8 characters long, this is equivelent to normal",
" encryption. Default is tripple cbc, -b makes it tripple ecb.",
NULL
};
for (u=usage; *u; u++)
{
fputs(*u,stderr);
fputc('\n',stderr);
}
EXIT(1);
}
void
doencryption(void)
{
register int i;
des_key_schedule ks,ks2;
unsigned char iv[8],iv2[8],iv3[8];
char *p;
int num=0,j,k,l,rem,ll,len,last,ex=0;
des_cblock kk,k2;
FILE *O;
int Exit=0;
#ifndef MSDOS
static unsigned char buf[BUFSIZE+8],obuf[BUFSIZE+8];
#else
static unsigned char *buf=NULL,*obuf=NULL;
if (buf == NULL)
{
if ( (( buf=(unsigned char *)malloc(BUFSIZE+8)) == NULL) ||
((obuf=(unsigned char *)malloc(BUFSIZE+8)) == NULL))
{
fputs("Not enough memory\n",stderr);
Exit=10;
goto problems;
}
}
#endif
if (hflag)
{
j=(flag3?16:8);
p=key;
for (i=0; i<j; i++)
{
k=0;
if ((*p <= '9') && (*p >= '0'))
k=(*p-'0')<<4;
else if ((*p <= 'f') && (*p >= 'a'))
k=(*p-'a'+10)<<4;
else if ((*p <= 'F') && (*p >= 'A'))
k=(*p-'A'+10)<<4;
else
{
fputs("Bad hex key\n",stderr);
Exit=9;
goto problems;
}
p++;
if ((*p <= '9') && (*p >= '0'))
k|=(*p-'0');
else if ((*p <= 'f') && (*p >= 'a'))
k|=(*p-'a'+10);
else if ((*p <= 'F') && (*p >= 'A'))
k|=(*p-'A'+10);
else
{
fputs("Bad hex key\n",stderr);
Exit=9;
goto problems;
}
p++;
if (i < 8)
kk[i]=k;
else
k2[i-8]=k;
}
des_set_key((des_cblock *)k2,ks2);
memset(k2,0,sizeof(k2));
}
else if (longk || flag3)
{
if (flag3)
{
des_string_to_2keys(key,(des_cblock *)kk,(des_cblock *)k2);
des_set_key((des_cblock *)k2,ks2);
memset(k2,0,sizeof(k2));
}
else
des_string_to_key(key,(des_cblock *)kk);
}
else
for (i=0; i<KEYSIZ; i++)
{
l=0;
k=key[i];
for (j=0; j<8; j++)
{
if (k&1) l++;
k>>=1;
}
if (l & 1)
kk[i]=key[i]&0x7f;
else
kk[i]=key[i]|0x80;
}
des_set_key((des_cblock *)kk,ks);
memset(key,0,sizeof(key));
memset(kk,0,sizeof(kk));
/* woops - A bug that does not showup under unix :-( */
memset(iv,0,sizeof(iv));
memset(iv2,0,sizeof(iv2));
memset(iv3,0,sizeof(iv3));
l=1;
rem=0;
/* first read */
if (eflag || (!dflag && cflag))
{
for (;;)
{
num=l=fread(&(buf[rem]),1,BUFSIZE,DES_IN);
l+=rem;
num+=rem;
if (l < 0)
{
perror("read error");
Exit=6;
goto problems;
}
rem=l%8;
len=l-rem;
if (feof(DES_IN))
{
srandom(time(NULL));
for (i=7-rem; i>0; i--)
buf[l++]=random()&0xff;
buf[l++]=rem;
ex=1;
len+=rem;
}
else
l-=rem;
if (cflag)
{
des_cbc_cksum((des_cblock *)buf,(des_cblock *)cksum,
(long)len,ks,(des_cblock *)cksum);
if (!eflag)
{
if (feof(DES_IN)) break;
else continue;
}
}
if (bflag && !flag3)
for (i=0; i<l; i+=8)
des_ecb_encrypt(
(des_cblock *)&(buf[i]),
(des_cblock *)&(obuf[i]),
ks,do_encrypt);
else if (flag3 && bflag)
for (i=0; i<l; i+=8)
des_3ecb_encrypt(
(des_cblock *)&(buf[i]),
(des_cblock *)&(obuf[i]),
ks,ks2,do_encrypt);
else if (flag3 && !bflag)
{
char tmpbuf[8];
if (rem) memcpy(tmpbuf,&(buf[l]),rem);
des_3cbc_encrypt(
(des_cblock *)buf,(des_cblock *)obuf,
(long)l,ks,ks2,(des_cblock *)iv,
(des_cblock *)iv2,do_encrypt);
if (rem) memcpy(&(buf[l]),tmpbuf,rem);
}
else
{
des_cbc_encrypt(
(des_cblock *)buf,(des_cblock *)obuf,
(long)l,ks,(des_cblock *)iv,do_encrypt);
if (l >= 8) memcpy(iv,&(obuf[l-8]),8);
}
if (rem) memcpy(buf,&(buf[l]),rem);
i=0;
while (i < l)
{
if (uflag)
j=uufwrite(obuf,1,l-i,DES_OUT);
else
j=fwrite(obuf,1,l-i,DES_OUT);
if (j == -1)
{
perror("Write error");
Exit=7;
goto problems;
}
i+=j;
}
if (feof(DES_IN))
{
if (uflag) uufwriteEnd(DES_OUT);
break;
}
}
}
else /* decrypt */
{
ex=1;
for (;;)
{
if (ex) {
if (uflag)
l=uufread(buf,1,BUFSIZE,DES_IN);
else
l=fread(buf,1,BUFSIZE,DES_IN);
ex=0;
rem=l%8;
l-=rem;
}
if (l < 0)
{
perror("read error");
Exit=6;
goto problems;
}
if (bflag && !flag3)
for (i=0; i<l; i+=8)
des_ecb_encrypt(
(des_cblock *)&(buf[i]),
(des_cblock *)&(obuf[i]),
ks,do_encrypt);
else if (flag3 && bflag)
for (i=0; i<l; i+=8)
des_3ecb_encrypt(
(des_cblock *)&(buf[i]),
(des_cblock *)&(obuf[i]),
ks,ks2,do_encrypt);
else if (flag3 && !bflag)
{
des_3cbc_encrypt(
(des_cblock *)buf,(des_cblock *)obuf,
(long)l,ks,ks2,(des_cblock *)iv,
(des_cblock *)iv2,do_encrypt);
}
else
{
des_cbc_encrypt(
(des_cblock *)buf,(des_cblock *)obuf,
(long)l,ks,(des_cblock *)iv,do_encrypt);
if (l >= 8) memcpy(iv,&(buf[l-8]),8);
}
if (uflag)
ll=uufread(&(buf[rem]),1,BUFSIZE,DES_IN);
else
ll=fread(&(buf[rem]),1,BUFSIZE,DES_IN);
ll+=rem;
rem=ll%8;
ll-=rem;
if (feof(DES_IN) && (ll == 0))
{
last=obuf[l-1];
if ((last > 7) || (last < 0))
{
fputs("The file was not decrypted correctly.\n",
stderr);
/*Exit=8;
goto problems;*/
last=0;
}
l=l-8+last;
}
i=0;
if (cflag) des_cbc_cksum((des_cblock *)obuf,
(des_cblock *)cksum,(long)l/8*8,ks,
(des_cblock *)cksum);
while (i != l)
{
j=fwrite(obuf,1,l-i,DES_OUT);
if (j == -1)
{
perror("Write error");
Exit=7;
goto problems;
}
i+=j;
}
l=ll;
if ((l == 0) && feof(DES_IN)) break;
}
}
if (cflag)
{
l=0;
if (cksumname[0] != '\0')
{
if ((O=fopen(cksumname,"w")) != NULL)
{
CKSUM_OUT=O;
l=1;
}
}
for (i=0; i<8; i++)
fprintf(CKSUM_OUT,"%02X",cksum[i]);
fprintf(CKSUM_OUT,"\n");
if (l) fclose(CKSUM_OUT);
}
problems:
memset(buf,0,sizeof(buf));
memset(obuf,0,sizeof(obuf));
memset(ks,0,sizeof(ks));
memset(ks2,0,sizeof(ks2));
memset(iv,0,sizeof(iv));
memset(iv2,0,sizeof(iv2));
memset(iv3,0,sizeof(iv3));
memset(kk,0,sizeof(kk));
memset(k2,0,sizeof(k2));
memset(uubuf,0,sizeof(uubuf));
memset(b,0,sizeof(b));
memset(bb,0,sizeof(bb));
memset(cksum,0,sizeof(cksum));
if (Exit) EXIT(Exit);
}
int uufwrite(char *data, int size, int num, FILE *fp)
/* We ignore this parameter but it should be > ~50 I believe */
{
int i,j,left,rem,ret=num;
static int start=1;
if (start)
{
fprintf(fp,"begin 600 %s\n",
(uuname[0] == '\0')?"text.d":uuname);
start=0;
}
if (uubufnum)
{
if (uubufnum+num < 45)
{
memcpy(&(uubuf[uubufnum]),data,num);
uubufnum+=num;
return(num);
}
else
{
i=45-uubufnum;
memcpy(&(uubuf[uubufnum]),data,i);
j=uuencode(uubuf,45,b);
fwrite(b,1,j,fp);
uubufnum=0;
data+=i;
num-=i;
}
}
for (i=0; i<(num-INUUBUFN); i+=INUUBUFN)
{
j=uuencode(&(data[i]),INUUBUFN,b);
fwrite(b,1,j,fp);
}
rem=(num-i)%45;
left=(num-i-rem);
if (left)
{
j=uuencode(&(data[i]),left,b);
fwrite(b,1,j,fp);
i+=left;
}
if (i != num)
{
memcpy(uubuf,&(data[i]),rem);
uubufnum=rem;
}
return(ret);
}
void
uufwriteEnd(FILE *fp)
{
int j;
static char *end=" \nend\n";
if (uubufnum != 0)
{
uubuf[uubufnum]='\0';
uubuf[uubufnum+1]='\0';
uubuf[uubufnum+2]='\0';
j=uuencode(uubuf,uubufnum,b);
fwrite(b,1,j,fp);
}
fwrite(end,1,strlen(end),fp);
}
int uufread(char *out, int size, int num, FILE *fp)
/* should always be > ~ 60; I actually ignore this parameter :-) */
{
int i,j,tot;
static int done=0;
static int valid=0;
static int start=1;
if (start)
{
for (;;)
{
b[0]='\0';
fgets(b,300,fp);
if (b[0] == '\0')
{
fprintf(stderr,"no 'begin' found in uuencoded input\n");
return(-1);
}
if (strncmp(b,"begin ",6) == 0) break;
}
start=0;
}
if (done) return(0);
tot=0;
if (valid)
{
memcpy(out,bb,valid);
tot=valid;
valid=0;
}
for (;;)
{
b[0]='\0';
fgets(b,300,fp);
if (b[0] == '\0') break;
i=strlen(b);
if ((b[0] == 'e') && (b[1] == 'n') && (b[2] == 'd'))
{
done=1;
while (!feof(fp))
{
fgets(b,300,fp);
}
break;
}
i=uudecode(b,i,bb);
if (i < 0) break;
if ((i+tot+8) > num)
{
/* num to copy to make it a multiple of 8 */
j=(num/8*8)-tot-8;
memcpy(&(out[tot]),bb,j);
tot+=j;
memcpy(bb,&(bb[j]),i-j);
valid=i-j;
break;
}
memcpy(&(out[tot]),bb,i);
tot+=i;
}
return(tot);
}
#define ccc2l(c,l) (l =((u_int32_t)(*((c)++)))<<16, \
l|=((u_int32_t)(*((c)++)))<< 8, \
l|=((u_int32_t)(*((c)++))))
#define l2ccc(l,c) (*((c)++)=(unsigned char)(((l)>>16)&0xff), \
*((c)++)=(unsigned char)(((l)>> 8)&0xff), \
*((c)++)=(unsigned char)(((l) )&0xff))
int uuencode(unsigned char *in, int num, unsigned char *out)
{
int j,i,n,tot=0;
u_int32_t l;
register unsigned char *p;
p=out;
for (j=0; j<num; j+=45)
{
if (j+45 > num)
i=(num-j);
else i=45;
*(p++)=i+' ';
for (n=0; n<i; n+=3)
{
ccc2l(in,l);
*(p++)=((l>>18)&0x3f)+' ';
*(p++)=((l>>12)&0x3f)+' ';
*(p++)=((l>> 6)&0x3f)+' ';
*(p++)=((l )&0x3f)+' ';
tot+=4;
}
*(p++)='\n';
tot+=2;
}
*p='\0';
l=0;
return(tot);
}
int uudecode(unsigned char *in, int num, unsigned char *out)
{
int j,i,k;
unsigned int n,space=0;
u_int32_t l;
u_int32_t w,x,y,z;
unsigned int blank='\n'-' ';
for (j=0; j<num; )
{
n= *(in++)-' ';
if (n == blank)
{
n=0;
in--;
}
if (n > 60)
{
fprintf(stderr,"uuencoded line length too long\n");
return(-1);
}
j++;
for (i=0; i<n; j+=4,i+=3)
{
/* the following is for cases where spaces are
* removed from lines.
*/
if (space)
{
w=x=y=z=0;
}
else
{
w= *(in++)-' ';
x= *(in++)-' ';
y= *(in++)-' ';
z= *(in++)-' ';
}
if ((w > 63) || (x > 63) || (y > 63) || (z > 63))
{
k=0;
if (w == blank) k=1;
if (x == blank) k=2;
if (y == blank) k=3;
if (z == blank) k=4;
space=1;
switch (k) {
case 1: w=0; in--;
case 2: x=0; in--;
case 3: y=0; in--;
case 4: z=0; in--;
break;
case 0:
space=0;
fprintf(stderr,"bad uuencoded data values\n");
w=x=y=z=0;
return(-1);
break;
}
}
l=(w<<18)|(x<<12)|(y<< 6)|(z );
l2ccc(l,out);
}
if (*(in++) != '\n')
{
fprintf(stderr,"missing nl in uuencoded line\n");
w=x=y=z=0;
return(-1);
}
j++;
}
*out='\0';
w=x=y=z=0;
return(n);
}

187
lib/des/des.man Normal file
View File

@@ -0,0 +1,187 @@
.TH DES 1
.SH NAME
des - encrypt or decrypt data using Data Encryption Standard
.SH SYNOPSIS
.B des
(
.B \-e
|
.B \-E
) | (
.B \-d
|
.B \-D
) | (
.B \-\fR[\fPcC\fR][\fPckname\fR]\fP
) |
[
.B \-b3hfs
] [
.B \-k
.I key
]
] [
.B \-u\fR[\fIuuname\fR]
[
.I input-file
[
.I output-file
] ]
.SH DESCRIPTION
.B des
encrypts and decrypts data using the
Data Encryption Standard algorithm.
One of
.B \-e, \-E
(for encrypt) or
.B \-d, \-D
(for decrypt) must be specified.
It is also possible to use
.B \-c
or
.B \-C
in conjunction or instead of the a encrypt/decrypt option to generate
a 16 character hexadecimal checksum, generated via the
.I des_cbc_cksum.
.LP
Two standard encryption modes are supported by the
.B des
program, Cipher Block Chaining (the default) and Electronic Code Book
(specified with
.B \-b
).
.LP
The key used for the DES
algorithm is obtained by prompting the user unless the
.B `\-k
.I key'
option is given.
If the key is an argument to the
.B des
command, it is potentially visible to users executing
.BR ps (1)
or a derivative. To minimise this possibility,
.B des
takes care to destroy the key argument immediately upon entry.
If your shell keeps a history file be careful to make sure it is not
world readable.
.LP
Since this program attempts to maintain compatability with sunOS's
des(1) command, there are 2 different methods used to convert the user
supplied key to a des key.
Whenever and one or more of
.B \-E, \-D, \-C
or
.B \-3
options are used, the key conversion procedure will not be compatible
with the sunOS des(1) version but will use all the user supplied
character to generate the des key.
.B des
command reads from standard input unless
.I input-file
is specified and writes to standard output unless
.I output-file
is given.
.SH OPTIONS
.TP
.B \-b
Select ECB
(eight bytes at a time) encryption mode.
.TP
.B \-3
Encrypt using triple encryption.
By default triple cbc encryption is used but if the
.B \-b
option is used then triple ecb encryption is performed.
If the key is less than 8 characters long, the flag has no effect.
.TP
.B \-e
Encrypt data using an 8 byte key in a manner compatible with sunOS
des(1).
.TP
.B \-E
Encrypt data using a key of nearly unlimited length (1024 bytes).
This will product a more secure encryption.
.TP
.B \-d
Decrypt data that was encrypted with the \-e option.
.TP
.B \-D
Decrypt data that was encrypted with the \-E option.
.TP
.B \-c
Generate a 16 character hexadecimal cbc checksum and output this to
stderr.
If a filename was specified after the
.B \-c
option, the checksum is output to that file.
The checksum is generated using a key generated in a sunOS compatible
manner.
.TP
.B \-C
A cbc checksum is generated in the same manner as described for the
.B \-c
option but the DES key is generated in the same manner as used for the
.B \-E
and
.B \-D
options
.TP
.B \-f
Does nothing - allowed for compatibility with sunOS des(1) command.
.TP
.B \-s
Does nothing - allowed for compatibility with sunOS des(1) command.
.TP
.B "\-k \fIkey\fP"
Use the encryption
.I key
specified.
.TP
.B "\-h"
The
.I key
is assumed to be a 16 character hexadecimal number.
If the
.B "\-3"
option is used the key is assumed to be a 32 character hexadecimal
number.
.TP
.B \-u
This flag is used to read and write uuencoded files. If decrypting,
the input file is assumed to contain uuencoded, DES encrypted data.
If encrypting, the characters following the -u are used as the name of
the uuencoded file to embed in the begin line of the uuencoded
output. If there is no name specified after the -u, the name text.des
will be embedded in the header.
.SH SEE ALSO
.B ps (1)
.B des_crypt(3)
.SH BUGS
.LP
The problem with using the
.B -e
option is the short key length.
It would be better to use a real 56-bit key rather than an
ASCII-based 56-bit pattern. Knowing that the key was derived from ASCII
radically reduces the time necessary for a brute-force cryptographic attack.
My attempt to remove this problem is to add an alternative text-key to
DES-key function. This alternative function (accessed via
.B -E, -D, -S
and
.B -3
)
uses DES to help generate the key.
.LP
Be carefully when using the -u option. Doing des -ud <filename> will
not decrypt filename (the -u option will gobble the d option).
.LP
The VMS operating system operates in a world where files are always a
multiple of 512 bytes. This causes problems when encrypted data is
send from unix to VMS since a 88 byte file will suddenly be padded
with 424 null bytes. To get around this problem, use the -u option
to uuencode the data before it is send to the VMS system.
.SH AUTHOR
.LP
Eric Young (eay@psych.psy.uq.oz.au), Psychology Department,
University of Queensland, Australia.

536
lib/des/des.pl Normal file
View File

@@ -0,0 +1,536 @@
#!/usr/local/bin/perl
# Copyright (C) 1993 Eric Young
# des.pl - eric young 22/11/1991 eay@psych.psy.uq.oz.au
# eay - 92/08/31 - I think I have fixed all problems for 64bit
# versions of perl but I could be wrong since I have not tested it yet :-).
#
# This is an implementation of DES in perl.
# The two routines (des_set_key and des_ecb_encrypt)
# take 8 byte objects as arguments.
#
# des_set_key takes an 8 byte string as a key and returns a key schedule
# for use in calls to des_ecb_encrypt.
# des_ecb_encrypt takes three arguments, the first is a key schedule
# (make sure to pass it by reference with the *), the second is 1
# to encrypt, 0 to decrypt. The third argument is an 8 byte object
# to encrypt. The function returns an 8 byte object that has been
# DES encrypted.
#
# example:
# require 'des.pl'
#
# $key =pack("C8",0x12,0x23,0x45,0x67,0x89,0xab,0xcd,0xef);
# @ks= &des_set_key($key);
#
# $outbytes= &des_ecb_encrypt(*ks,1,$data);
# @enc =unpack("C8",$outbytes);
#
package des;
# The following 8 arrays are used in des_set_key
@skb0=(
# for C bits (numbered as per FIPS 46) 1 2 3 4 5 6
0x00000000,0x00000010,0x20000000,0x20000010,
0x00010000,0x00010010,0x20010000,0x20010010,
0x00000800,0x00000810,0x20000800,0x20000810,
0x00010800,0x00010810,0x20010800,0x20010810,
0x00000020,0x00000030,0x20000020,0x20000030,
0x00010020,0x00010030,0x20010020,0x20010030,
0x00000820,0x00000830,0x20000820,0x20000830,
0x00010820,0x00010830,0x20010820,0x20010830,
0x00080000,0x00080010,0x20080000,0x20080010,
0x00090000,0x00090010,0x20090000,0x20090010,
0x00080800,0x00080810,0x20080800,0x20080810,
0x00090800,0x00090810,0x20090800,0x20090810,
0x00080020,0x00080030,0x20080020,0x20080030,
0x00090020,0x00090030,0x20090020,0x20090030,
0x00080820,0x00080830,0x20080820,0x20080830,
0x00090820,0x00090830,0x20090820,0x20090830,
);
@skb1=(
# for C bits (numbered as per FIPS 46) 7 8 10 11 12 13
0x00000000,0x02000000,0x00002000,0x02002000,
0x00200000,0x02200000,0x00202000,0x02202000,
0x00000004,0x02000004,0x00002004,0x02002004,
0x00200004,0x02200004,0x00202004,0x02202004,
0x00000400,0x02000400,0x00002400,0x02002400,
0x00200400,0x02200400,0x00202400,0x02202400,
0x00000404,0x02000404,0x00002404,0x02002404,
0x00200404,0x02200404,0x00202404,0x02202404,
0x10000000,0x12000000,0x10002000,0x12002000,
0x10200000,0x12200000,0x10202000,0x12202000,
0x10000004,0x12000004,0x10002004,0x12002004,
0x10200004,0x12200004,0x10202004,0x12202004,
0x10000400,0x12000400,0x10002400,0x12002400,
0x10200400,0x12200400,0x10202400,0x12202400,
0x10000404,0x12000404,0x10002404,0x12002404,
0x10200404,0x12200404,0x10202404,0x12202404,
);
@skb2=(
# for C bits (numbered as per FIPS 46) 14 15 16 17 19 20
0x00000000,0x00000001,0x00040000,0x00040001,
0x01000000,0x01000001,0x01040000,0x01040001,
0x00000002,0x00000003,0x00040002,0x00040003,
0x01000002,0x01000003,0x01040002,0x01040003,
0x00000200,0x00000201,0x00040200,0x00040201,
0x01000200,0x01000201,0x01040200,0x01040201,
0x00000202,0x00000203,0x00040202,0x00040203,
0x01000202,0x01000203,0x01040202,0x01040203,
0x08000000,0x08000001,0x08040000,0x08040001,
0x09000000,0x09000001,0x09040000,0x09040001,
0x08000002,0x08000003,0x08040002,0x08040003,
0x09000002,0x09000003,0x09040002,0x09040003,
0x08000200,0x08000201,0x08040200,0x08040201,
0x09000200,0x09000201,0x09040200,0x09040201,
0x08000202,0x08000203,0x08040202,0x08040203,
0x09000202,0x09000203,0x09040202,0x09040203,
);
@skb3=(
# for C bits (numbered as per FIPS 46) 21 23 24 26 27 28
0x00000000,0x00100000,0x00000100,0x00100100,
0x00000008,0x00100008,0x00000108,0x00100108,
0x00001000,0x00101000,0x00001100,0x00101100,
0x00001008,0x00101008,0x00001108,0x00101108,
0x04000000,0x04100000,0x04000100,0x04100100,
0x04000008,0x04100008,0x04000108,0x04100108,
0x04001000,0x04101000,0x04001100,0x04101100,
0x04001008,0x04101008,0x04001108,0x04101108,
0x00020000,0x00120000,0x00020100,0x00120100,
0x00020008,0x00120008,0x00020108,0x00120108,
0x00021000,0x00121000,0x00021100,0x00121100,
0x00021008,0x00121008,0x00021108,0x00121108,
0x04020000,0x04120000,0x04020100,0x04120100,
0x04020008,0x04120008,0x04020108,0x04120108,
0x04021000,0x04121000,0x04021100,0x04121100,
0x04021008,0x04121008,0x04021108,0x04121108,
);
@skb4=(
# for D bits (numbered as per FIPS 46) 1 2 3 4 5 6
0x00000000,0x10000000,0x00010000,0x10010000,
0x00000004,0x10000004,0x00010004,0x10010004,
0x20000000,0x30000000,0x20010000,0x30010000,
0x20000004,0x30000004,0x20010004,0x30010004,
0x00100000,0x10100000,0x00110000,0x10110000,
0x00100004,0x10100004,0x00110004,0x10110004,
0x20100000,0x30100000,0x20110000,0x30110000,
0x20100004,0x30100004,0x20110004,0x30110004,
0x00001000,0x10001000,0x00011000,0x10011000,
0x00001004,0x10001004,0x00011004,0x10011004,
0x20001000,0x30001000,0x20011000,0x30011000,
0x20001004,0x30001004,0x20011004,0x30011004,
0x00101000,0x10101000,0x00111000,0x10111000,
0x00101004,0x10101004,0x00111004,0x10111004,
0x20101000,0x30101000,0x20111000,0x30111000,
0x20101004,0x30101004,0x20111004,0x30111004,
);
@skb5=(
# for D bits (numbered as per FIPS 46) 8 9 11 12 13 14
0x00000000,0x08000000,0x00000008,0x08000008,
0x00000400,0x08000400,0x00000408,0x08000408,
0x00020000,0x08020000,0x00020008,0x08020008,
0x00020400,0x08020400,0x00020408,0x08020408,
0x00000001,0x08000001,0x00000009,0x08000009,
0x00000401,0x08000401,0x00000409,0x08000409,
0x00020001,0x08020001,0x00020009,0x08020009,
0x00020401,0x08020401,0x00020409,0x08020409,
0x02000000,0x0A000000,0x02000008,0x0A000008,
0x02000400,0x0A000400,0x02000408,0x0A000408,
0x02020000,0x0A020000,0x02020008,0x0A020008,
0x02020400,0x0A020400,0x02020408,0x0A020408,
0x02000001,0x0A000001,0x02000009,0x0A000009,
0x02000401,0x0A000401,0x02000409,0x0A000409,
0x02020001,0x0A020001,0x02020009,0x0A020009,
0x02020401,0x0A020401,0x02020409,0x0A020409,
);
@skb6=(
# for D bits (numbered as per FIPS 46) 16 17 18 19 20 21
0x00000000,0x00000100,0x00080000,0x00080100,
0x01000000,0x01000100,0x01080000,0x01080100,
0x00000010,0x00000110,0x00080010,0x00080110,
0x01000010,0x01000110,0x01080010,0x01080110,
0x00200000,0x00200100,0x00280000,0x00280100,
0x01200000,0x01200100,0x01280000,0x01280100,
0x00200010,0x00200110,0x00280010,0x00280110,
0x01200010,0x01200110,0x01280010,0x01280110,
0x00000200,0x00000300,0x00080200,0x00080300,
0x01000200,0x01000300,0x01080200,0x01080300,
0x00000210,0x00000310,0x00080210,0x00080310,
0x01000210,0x01000310,0x01080210,0x01080310,
0x00200200,0x00200300,0x00280200,0x00280300,
0x01200200,0x01200300,0x01280200,0x01280300,
0x00200210,0x00200310,0x00280210,0x00280310,
0x01200210,0x01200310,0x01280210,0x01280310,
);
@skb7=(
# for D bits (numbered as per FIPS 46) 22 23 24 25 27 28
0x00000000,0x04000000,0x00040000,0x04040000,
0x00000002,0x04000002,0x00040002,0x04040002,
0x00002000,0x04002000,0x00042000,0x04042000,
0x00002002,0x04002002,0x00042002,0x04042002,
0x00000020,0x04000020,0x00040020,0x04040020,
0x00000022,0x04000022,0x00040022,0x04040022,
0x00002020,0x04002020,0x00042020,0x04042020,
0x00002022,0x04002022,0x00042022,0x04042022,
0x00000800,0x04000800,0x00040800,0x04040800,
0x00000802,0x04000802,0x00040802,0x04040802,
0x00002800,0x04002800,0x00042800,0x04042800,
0x00002802,0x04002802,0x00042802,0x04042802,
0x00000820,0x04000820,0x00040820,0x04040820,
0x00000822,0x04000822,0x00040822,0x04040822,
0x00002820,0x04002820,0x00042820,0x04042820,
0x00002822,0x04002822,0x00042822,0x04042822,
);
@shifts2=(0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0);
# used in ecb_encrypt
@SP0=(
0x00410100, 0x00010000, 0x40400000, 0x40410100,
0x00400000, 0x40010100, 0x40010000, 0x40400000,
0x40010100, 0x00410100, 0x00410000, 0x40000100,
0x40400100, 0x00400000, 0x00000000, 0x40010000,
0x00010000, 0x40000000, 0x00400100, 0x00010100,
0x40410100, 0x00410000, 0x40000100, 0x00400100,
0x40000000, 0x00000100, 0x00010100, 0x40410000,
0x00000100, 0x40400100, 0x40410000, 0x00000000,
0x00000000, 0x40410100, 0x00400100, 0x40010000,
0x00410100, 0x00010000, 0x40000100, 0x00400100,
0x40410000, 0x00000100, 0x00010100, 0x40400000,
0x40010100, 0x40000000, 0x40400000, 0x00410000,
0x40410100, 0x00010100, 0x00410000, 0x40400100,
0x00400000, 0x40000100, 0x40010000, 0x00000000,
0x00010000, 0x00400000, 0x40400100, 0x00410100,
0x40000000, 0x40410000, 0x00000100, 0x40010100,
);
@SP1=(
0x08021002, 0x00000000, 0x00021000, 0x08020000,
0x08000002, 0x00001002, 0x08001000, 0x00021000,
0x00001000, 0x08020002, 0x00000002, 0x08001000,
0x00020002, 0x08021000, 0x08020000, 0x00000002,
0x00020000, 0x08001002, 0x08020002, 0x00001000,
0x00021002, 0x08000000, 0x00000000, 0x00020002,
0x08001002, 0x00021002, 0x08021000, 0x08000002,
0x08000000, 0x00020000, 0x00001002, 0x08021002,
0x00020002, 0x08021000, 0x08001000, 0x00021002,
0x08021002, 0x00020002, 0x08000002, 0x00000000,
0x08000000, 0x00001002, 0x00020000, 0x08020002,
0x00001000, 0x08000000, 0x00021002, 0x08001002,
0x08021000, 0x00001000, 0x00000000, 0x08000002,
0x00000002, 0x08021002, 0x00021000, 0x08020000,
0x08020002, 0x00020000, 0x00001002, 0x08001000,
0x08001002, 0x00000002, 0x08020000, 0x00021000,
);
@SP2=(
0x20800000, 0x00808020, 0x00000020, 0x20800020,
0x20008000, 0x00800000, 0x20800020, 0x00008020,
0x00800020, 0x00008000, 0x00808000, 0x20000000,
0x20808020, 0x20000020, 0x20000000, 0x20808000,
0x00000000, 0x20008000, 0x00808020, 0x00000020,
0x20000020, 0x20808020, 0x00008000, 0x20800000,
0x20808000, 0x00800020, 0x20008020, 0x00808000,
0x00008020, 0x00000000, 0x00800000, 0x20008020,
0x00808020, 0x00000020, 0x20000000, 0x00008000,
0x20000020, 0x20008000, 0x00808000, 0x20800020,
0x00000000, 0x00808020, 0x00008020, 0x20808000,
0x20008000, 0x00800000, 0x20808020, 0x20000000,
0x20008020, 0x20800000, 0x00800000, 0x20808020,
0x00008000, 0x00800020, 0x20800020, 0x00008020,
0x00800020, 0x00000000, 0x20808000, 0x20000020,
0x20800000, 0x20008020, 0x00000020, 0x00808000,
);
@SP3=(
0x00080201, 0x02000200, 0x00000001, 0x02080201,
0x00000000, 0x02080000, 0x02000201, 0x00080001,
0x02080200, 0x02000001, 0x02000000, 0x00000201,
0x02000001, 0x00080201, 0x00080000, 0x02000000,
0x02080001, 0x00080200, 0x00000200, 0x00000001,
0x00080200, 0x02000201, 0x02080000, 0x00000200,
0x00000201, 0x00000000, 0x00080001, 0x02080200,
0x02000200, 0x02080001, 0x02080201, 0x00080000,
0x02080001, 0x00000201, 0x00080000, 0x02000001,
0x00080200, 0x02000200, 0x00000001, 0x02080000,
0x02000201, 0x00000000, 0x00000200, 0x00080001,
0x00000000, 0x02080001, 0x02080200, 0x00000200,
0x02000000, 0x02080201, 0x00080201, 0x00080000,
0x02080201, 0x00000001, 0x02000200, 0x00080201,
0x00080001, 0x00080200, 0x02080000, 0x02000201,
0x00000201, 0x02000000, 0x02000001, 0x02080200,
);
@SP4=(
0x01000000, 0x00002000, 0x00000080, 0x01002084,
0x01002004, 0x01000080, 0x00002084, 0x01002000,
0x00002000, 0x00000004, 0x01000004, 0x00002080,
0x01000084, 0x01002004, 0x01002080, 0x00000000,
0x00002080, 0x01000000, 0x00002004, 0x00000084,
0x01000080, 0x00002084, 0x00000000, 0x01000004,
0x00000004, 0x01000084, 0x01002084, 0x00002004,
0x01002000, 0x00000080, 0x00000084, 0x01002080,
0x01002080, 0x01000084, 0x00002004, 0x01002000,
0x00002000, 0x00000004, 0x01000004, 0x01000080,
0x01000000, 0x00002080, 0x01002084, 0x00000000,
0x00002084, 0x01000000, 0x00000080, 0x00002004,
0x01000084, 0x00000080, 0x00000000, 0x01002084,
0x01002004, 0x01002080, 0x00000084, 0x00002000,
0x00002080, 0x01002004, 0x01000080, 0x00000084,
0x00000004, 0x00002084, 0x01002000, 0x01000004,
);
@SP5=(
0x10000008, 0x00040008, 0x00000000, 0x10040400,
0x00040008, 0x00000400, 0x10000408, 0x00040000,
0x00000408, 0x10040408, 0x00040400, 0x10000000,
0x10000400, 0x10000008, 0x10040000, 0x00040408,
0x00040000, 0x10000408, 0x10040008, 0x00000000,
0x00000400, 0x00000008, 0x10040400, 0x10040008,
0x10040408, 0x10040000, 0x10000000, 0x00000408,
0x00000008, 0x00040400, 0x00040408, 0x10000400,
0x00000408, 0x10000000, 0x10000400, 0x00040408,
0x10040400, 0x00040008, 0x00000000, 0x10000400,
0x10000000, 0x00000400, 0x10040008, 0x00040000,
0x00040008, 0x10040408, 0x00040400, 0x00000008,
0x10040408, 0x00040400, 0x00040000, 0x10000408,
0x10000008, 0x10040000, 0x00040408, 0x00000000,
0x00000400, 0x10000008, 0x10000408, 0x10040400,
0x10040000, 0x00000408, 0x00000008, 0x10040008,
);
@SP6=(
0x00000800, 0x00000040, 0x00200040, 0x80200000,
0x80200840, 0x80000800, 0x00000840, 0x00000000,
0x00200000, 0x80200040, 0x80000040, 0x00200800,
0x80000000, 0x00200840, 0x00200800, 0x80000040,
0x80200040, 0x00000800, 0x80000800, 0x80200840,
0x00000000, 0x00200040, 0x80200000, 0x00000840,
0x80200800, 0x80000840, 0x00200840, 0x80000000,
0x80000840, 0x80200800, 0x00000040, 0x00200000,
0x80000840, 0x00200800, 0x80200800, 0x80000040,
0x00000800, 0x00000040, 0x00200000, 0x80200800,
0x80200040, 0x80000840, 0x00000840, 0x00000000,
0x00000040, 0x80200000, 0x80000000, 0x00200040,
0x00000000, 0x80200040, 0x00200040, 0x00000840,
0x80000040, 0x00000800, 0x80200840, 0x00200000,
0x00200840, 0x80000000, 0x80000800, 0x80200840,
0x80200000, 0x00200840, 0x00200800, 0x80000800,
);
@SP7=(
0x04100010, 0x04104000, 0x00004010, 0x00000000,
0x04004000, 0x00100010, 0x04100000, 0x04104010,
0x00000010, 0x04000000, 0x00104000, 0x00004010,
0x00104010, 0x04004010, 0x04000010, 0x04100000,
0x00004000, 0x00104010, 0x00100010, 0x04004000,
0x04104010, 0x04000010, 0x00000000, 0x00104000,
0x04000000, 0x00100000, 0x04004010, 0x04100010,
0x00100000, 0x00004000, 0x04104000, 0x00000010,
0x00100000, 0x00004000, 0x04000010, 0x04104010,
0x00004010, 0x04000000, 0x00000000, 0x00104000,
0x04100010, 0x04004010, 0x04004000, 0x00100010,
0x04104000, 0x00000010, 0x00100010, 0x04004000,
0x04104010, 0x00100000, 0x04100000, 0x04000010,
0x00104000, 0x00004010, 0x04004010, 0x04100000,
0x00000010, 0x04104000, 0x00104010, 0x00000000,
0x04000000, 0x04100010, 0x00004000, 0x00104010,
);
sub main'des_set_key
{
local($param)=@_;
local(@key);
local($c,$d,$i,$s,$t);
local(@ks)=();
# Get the bytes in the order we want.
@key=unpack("C8",$param);
$c= ($key[0] )|
($key[1]<< 8)|
($key[2]<<16)|
($key[3]<<24);
$d= ($key[4] )|
($key[5]<< 8)|
($key[6]<<16)|
($key[7]<<24);
&doPC1(*c,*d);
for $i (@shifts2)
{
if ($i)
{
$c=($c>>2)|($c<<26);
$d=($d>>2)|($d<<26);
}
else
{
$c=($c>>1)|($c<<27);
$d=($d>>1)|($d<<27);
}
$c&=0x0fffffff;
$d&=0x0fffffff;
$s= $skb0[ ($c )&0x3f ]|
$skb1[(($c>> 6)&0x03)|(($c>> 7)&0x3c)]|
$skb2[(($c>>13)&0x0f)|(($c>>14)&0x30)]|
$skb3[(($c>>20)&0x01)|(($c>>21)&0x06) |
(($c>>22)&0x38)];
$t= $skb4[ ($d )&0x3f ]|
$skb5[(($d>> 7)&0x03)|(($d>> 8)&0x3c)]|
$skb6[ ($d>>15)&0x3f ]|
$skb7[(($d>>21)&0x0f)|(($d>>22)&0x30)];
push(@ks,(($t<<16)|($s&0x0000ffff))&0xffffffff);
$s= ($s>>16)|($t&0xffff0000) ;
push(@ks,(($s<<4)|($s>>28))&0xffffffff);
}
@ks;
}
sub doPC1
{
local(*a,*b)=@_;
local($t);
$t=(($b>>4)^$a)&0x0f0f0f0f;
$b^=($t<<4); $a^=$t;
# do $a first
$t=(($a<<18)^$a)&0xcccc0000;
$a=$a^$t^($t>>18);
$t=(($a<<17)^$a)&0xaaaa0000;
$a=$a^$t^($t>>17);
$t=(($a<< 8)^$a)&0x00ff0000;
$a=$a^$t^($t>> 8);
$t=(($a<<17)^$a)&0xaaaa0000;
$a=$a^$t^($t>>17);
# now do $b
$t=(($b<<24)^$b)&0xff000000;
$b=$b^$t^($t>>24);
$t=(($b<< 8)^$b)&0x00ff0000;
$b=$b^$t^($t>> 8);
$t=(($b<<14)^$b)&0x33330000;
$b=$b^$t^($t>>14);
$b=(($b&0x00aa00aa)<<7)|(($b&0x55005500)>>7)|($b&0xaa55aa55);
$b=($b>>8)|(($a&0xf0000000)>>4);
$a&=0x0fffffff;
}
sub doIP
{
local(*a,*b)=@_;
local($t);
$t=(($b>> 4)^$a)&0x0f0f0f0f;
$b^=($t<< 4); $a^=$t;
$t=(($a>>16)^$b)&0x0000ffff;
$a^=($t<<16); $b^=$t;
$t=(($b>> 2)^$a)&0x33333333;
$b^=($t<< 2); $a^=$t;
$t=(($a>> 8)^$b)&0x00ff00ff;
$a^=($t<< 8); $b^=$t;
$t=(($b>> 1)^$a)&0x55555555;
$b^=($t<< 1); $a^=$t;
$t=$a;
$a=$b&0xffffffff;
$b=$t&0xffffffff;
}
sub doFP
{
local(*a,*b)=@_;
local($t);
$t=(($b>> 1)^$a)&0x55555555;
$b^=($t<< 1); $a^=$t;
$t=(($a>> 8)^$b)&0x00ff00ff;
$a^=($t<< 8); $b^=$t;
$t=(($b>> 2)^$a)&0x33333333;
$b^=($t<< 2); $a^=$t;
$t=(($a>>16)^$b)&0x0000ffff;
$a^=($t<<16); $b^=$t;
$t=(($b>> 4)^$a)&0x0f0f0f0f;
$b^=($t<< 4); $a^=$t;
$a&=0xffffffff;
$b&=0xffffffff;
}
sub main'des_ecb_encrypt
{
local(*ks,$encrypt,$in)=@_;
local($l,$r,$inc,$start,$end,$i,$t,$u,@input);
@input=unpack("C8",$in);
# Get the bytes in the order we want.
$l= ($input[0] )|
($input[1]<< 8)|
($input[2]<<16)|
($input[3]<<24);
$r= ($input[4] )|
($input[5]<< 8)|
($input[6]<<16)|
($input[7]<<24);
$l&=0xffffffff;
$r&=0xffffffff;
&doIP(*l,*r);
if ($encrypt)
{
for ($i=0; $i<32; $i+=4)
{
$t=(($r<<1)|($r>>31))&0xffffffff;
$u=$t^$ks[$i ];
$t=$t^$ks[$i+1];
$t=(($t>>4)|($t<<28))&0xffffffff;
$l^= $SP1[ $t &0x3f]|
$SP3[($t>> 8)&0x3f]|
$SP5[($t>>16)&0x3f]|
$SP7[($t>>24)&0x3f]|
$SP0[ $u &0x3f]|
$SP2[($u>> 8)&0x3f]|
$SP4[($u>>16)&0x3f]|
$SP6[($u>>24)&0x3f];
$t=(($l<<1)|($l>>31))&0xffffffff;
$u=$t^$ks[$i+2];
$t=$t^$ks[$i+3];
$t=(($t>>4)|($t<<28))&0xffffffff;
$r^= $SP1[ $t &0x3f]|
$SP3[($t>> 8)&0x3f]|
$SP5[($t>>16)&0x3f]|
$SP7[($t>>24)&0x3f]|
$SP0[ $u &0x3f]|
$SP2[($u>> 8)&0x3f]|
$SP4[($u>>16)&0x3f]|
$SP6[($u>>24)&0x3f];
}
}
else
{
for ($i=30; $i>0; $i-=4)
{
$t=(($r<<1)|($r>>31))&0xffffffff;
$u=$t^$ks[$i ];
$t=$t^$ks[$i+1];
$t=(($t>>4)|($t<<28))&0xffffffff;
$l^= $SP1[ $t &0x3f]|
$SP3[($t>> 8)&0x3f]|
$SP5[($t>>16)&0x3f]|
$SP7[($t>>24)&0x3f]|
$SP0[ $u &0x3f]|
$SP2[($u>> 8)&0x3f]|
$SP4[($u>>16)&0x3f]|
$SP6[($u>>24)&0x3f];
$t=(($l<<1)|($l>>31))&0xffffffff;
$u=$t^$ks[$i-2];
$t=$t^$ks[$i-1];
$t=(($t>>4)|($t<<28))&0xffffffff;
$r^= $SP1[ $t &0x3f]|
$SP3[($t>> 8)&0x3f]|
$SP5[($t>>16)&0x3f]|
$SP7[($t>>24)&0x3f]|
$SP0[ $u &0x3f]|
$SP2[($u>> 8)&0x3f]|
$SP4[($u>>16)&0x3f]|
$SP6[($u>>24)&0x3f];
}
}
&doFP(*l,*r);
pack("C8",$l&0xff,$l>>8,$l>>16,$l>>24,
$r&0xff,$r>>8,$r>>16,$r>>24);
}

BIN
lib/des/des.x Normal file

Binary file not shown.

381
lib/des/des_crypt.3 Normal file
View File

@@ -0,0 +1,381 @@
.\" $Source$
.\" $Author$
.\" $Header$
.\" Copyright 1989 by the Massachusetts Institute of Technology.
.\"
.\" For copying and distribution information,
.\" please see the file <mit-copyright.h>.
.\"
.TH DES_CRYPT 3 "Kerberos Version 4.0" "MIT Project Athena"
.SH NAME
des_read_password, des_string_to_key, des_random_key, des_set_key,
des_ecb_encrypt, des_cbc_encrypt, des_pcbc_encrypt, des_cbc_cksum,
des_quad_cksum, \- (new) DES encryption
.SH SYNOPSIS
.nf
.nj
.ft B
#include <des.h>
.PP
.ft B
.B int des_read_password(key,prompt,verify)
des_cblock *key;
char *prompt;
int verify;
.PP
.ft B
int des_string_to_key(str,key)
char *str;
des_cblock key;
.PP
.ft B
int des_random_key(key)
des_cblock *key;
.PP
.ft B
int des_set_key(key,schedule)
des_cblock *key;
des_key_schedule schedule;
.PP
.ft B
int des_ecb_encrypt(input,output,schedule,encrypt)
des_cblock *input;
des_cblock *output;
des_key_schedule schedule;
int encrypt;
.PP
.ft B
int des_cbc_encrypt(input,output,length,schedule,ivec,encrypt)
des_cblock *input;
des_cblock *output;
long length;
des_key_schedule schedule;
des_cblock *ivec;
int encrypt;
.PP
.ft B
int des_pcbc_encrypt(input,output,length,schedule,ivec,encrypt)
des_cblock *input;
des_cblock *output;
long length;
des_key_schedule schedule;
des_cblock *ivec;
int encrypt;
.PP
.ft B
unsigned long des_cbc_cksum(input,output,length,schedule,ivec)
des_cblock *input;
des_cblock *output;
long length;
des_key_schedule schedule;
des_cblock *ivec;
.PP
.ft B
unsigned long quad_cksum(input,output,length,out_count,seed)
des_cblock *input;
des_cblock *output;
long length;
int out_count;
des_cblock *seed;
.PP
.fi
.SH DESCRIPTION
This library supports various DES encryption related operations. It differs
from the
.I crypt, setkey, and encrypt
library routines in that it provides
a true DES encryption, without modifying the algorithm,
and executes much faster.
.PP
For each key that may be simultaneously active, create a
.B des_key_schedule
struct,
defined in "des.h". Next, create key schedules (from the 8-byte keys) as
needed, via
.I des_set_key,
prior to using the encryption or checksum routines. Then
setup the input and output areas. Make sure to note the restrictions
on lengths being multiples of eight bytes. Finally, invoke the
encryption/decryption routines,
.I des_ecb_encrypt
or
.I des_cbc_encrypt
or
.I des_pcbc_encrypt,
or, to generate a cryptographic checksum, use
.I quad_cksum
(fast) or
.I des_cbc_cksum
(slow).
.PP
A
.I des_cblock
struct is an 8 byte block used as the fundamental unit for DES data and
keys, and is defined as:
.PP
.B typedef unsigned char des_cblock[8];
.PP
and a
.I des_key_schedule,
is defined as:
.PP
.B typedef struct des_ks_struct {des_cblock _;} des_key_schedule[16];
.PP
.I des_read_password
writes the string specified by
.I prompt
to the standard
output, turns off echo (if possible)
and reads an input string from standard input until terminated with a newline.
If
.I verify
is non-zero, it prompts and reads input again, for use
in applications such as changing a password; both
versions are compared, and the input is requested repeatedly until they
match. Then
.I des_read_password
converts the input string into a valid DES key, internally
using the
.I des_string_to_key
routine. The newly created key is copied to the
area pointed to by the
.I key
argument.
.I des_read_password
returns a zero if no errors occurred, or a -1
indicating that an error
occurred trying to manipulate the terminal echo.
.PP
.PP
.I des_string_to_key
converts an arbitrary length null-terminated string
to an 8 byte DES key, with odd byte parity, per FIPS specification.
A one-way function is used to convert the string to a key, making it
very difficult to reconstruct the string from the key.
The
.I str
argument is a pointer to the string, and
.I key
should
point to a
.I des_cblock
supplied by the caller to receive the generated key.
No meaningful value is returned. Void is not used for compatibility with
other compilers.
.PP
.PP
.I des_random_key
generates a random DES encryption key (eight bytes), set to odd parity per
FIPS
specifications.
This routine uses the current time, process id, and a counter
as a seed for the random number generator.
The caller must supply space for the output key, pointed to
by argument
.I key,
then after calling
.I des_random_key
should
call the
.I des_set_key
routine when needed.
No meaningful value is returned. Void is not used for compatibility
with other compilers.
.PP
.PP
.I des_set_key
calculates a key schedule from all eight bytes of the input key, pointed
to by the
.I key
argument, and outputs the schedule into the
.I des_key_schedule
indicated by the
.I schedule
argument. Make sure to pass a valid eight byte
key; no padding is done. The key schedule may then be used in subsequent
encryption/decryption/checksum operations. Many key schedules may be
cached for later use. The user is responsible to clear keys and schedules
as soon as no longer needed, to prevent their disclosure.
The routine also checks the key
parity, and returns a zero if the key parity is correct (odd), a -1
indicating a key parity error, or a -2 indicating use of an illegal
weak key. If an error is returned, the key schedule was not created.
.PP
.PP
.I des_ecb_encrypt
is the basic DES encryption routine that encrypts or decrypts a single 8-byte
block in
.B electronic code book
mode. It always transforms the input data, pointed to by
.I input,
into the output data, pointed to by the
.I output
argument.
.PP
If the
.I encrypt
argument is non-zero, the
.I input
(cleartext) is encrypted into the
.I output
(ciphertext) using the key_schedule specified by the
.I schedule
argument, previously set via
.I des_set_key
.PP
If encrypt is zero, the
.I input
(now ciphertext) is decrypted into the
.I output
(now cleartext).
.PP
Input and output may overlap.
.PP
No meaningful value is returned. Void is not used for compatibility
with other compilers.
.PP
.PP
.I des_cbc_encrypt
encrypts/decrypts using the
.B cipher-block-chaining mode of DES.
If the
.I encrypt
argument is non-zero, the routine cipher-block-chain encrypts
the cleartext data pointed to by the
.I input
argument into the ciphertext pointed to by the
.I output
argument, using the key schedule provided by the
.I schedule
argument, and initialization vector provided by the
.I ivec
argument.
If the
.I length
argument is not an integral
multiple of eight bytes, the last block is copied to a temp and zero
filled (highest addresses). The output is ALWAYS an integral multiple
of eight bytes.
.PP
If
.I encrypt
is zero, the routine cipher-block chain decrypts the (now) ciphertext
data pointed to by the
.I input
argument into (now) cleartext pointed to by the
.I output
argument using the key schedule provided by the
.I schedule
argument, and initialization vector provided by the
.I ivec
argument. Decryption ALWAYS operates on integral
multiples of 8 bytes, so it will round the
.I length
provided up to the
appropriate multiple. Consequently, it will always produce the rounded-up
number of bytes of output cleartext. The application must determine if
the output cleartext was zero-padded due to original cleartext lengths that
were not integral multiples of 8.
.PP
No errors or meaningful values are returned. Void is not used for
compatibility with other compilers.
.PP
A characteristic of cbc mode is that changing a single bit of the
cleartext, then encrypting using cbc mode,
affects ALL the subsequent ciphertext. This makes cryptanalysis
much more difficult. However, modifying a single bit of the ciphertext,
then decrypting, only affects the resulting cleartext from
the modified block and the succeeding block. Therefore,
.I des_pcbc_encrypt
is STRONGLY recommended for applications where
indefinite propagation of errors is required in order to detect modifications.
.PP
.PP
.I des_pcbc_encrypt
encrypts/decrypts using a modified block chaining mode. Its calling
sequence is identical to
.I des_cbc_encrypt.
It differs in its error propagation characteristics.
.PP
.I des_pcbc_encrypt
is highly recommended for most encryption purposes, in that
modification of a single bit of the ciphertext will affect ALL the
subsequent (decrypted) cleartext. Similarly, modifying a single bit of
the cleartext will affect ALL the subsequent (encrypted) ciphertext.
"PCBC" mode, on encryption, "xors" both the
cleartext of block N and the ciphertext resulting from block N with the
cleartext for block N+1 prior to encrypting block N+1.
.PP
.I des_cbc_cksum
produces an 8 byte cryptographic checksum by cipher-block-chain
encrypting the cleartext data pointed to by the
.I input
argument. All of the ciphertext output is discarded, except the
last 8-byte ciphertext block, which is written into the area pointed to by
the
.I output
argument.
It uses the key schedule,
provided by the
.I schedule
argument and initialization vector provided by the
.I ivec
argument.
If the
.I length
argument is not an integral
multiple of eight bytes, the last cleartext block is copied to a temp and zero
filled (highest addresses). The output is ALWAYS eight bytes.
.PP
The routine also returns an unsigned long, which is the last (highest address)
half of the 8 byte checksum computed.
.PP
.PP
.I quad_cksum
produces a checksum by chaining quadratic operations on the cleartext data
pointed to by the
.I input
argument. The
.I length
argument specifies the length of the
input -- only exactly that many bytes are included for the checksum,
without any padding.
.PP
The algorithm may be iterated over the same input data, if the
.I out_count
argument is 2, 3 or 4, and the optional
.I output
argument is a non-null pointer .
The default is one iteration, and it will not run
more than 4 times. Multiple iterations run slower, but provide
a longer checksum if desired. The
.I seed
argument provides an 8-byte seed for the first iteration. If multiple iterations are
requested, the results of one iteration are automatically used as
the seed for the next iteration.
.PP
It returns both an unsigned long checksum value, and
if the
.I output
argument is not a null pointer, up to 16 bytes of
the computed checksum are written into the output.
.PP
.PP
.SH FILES
/usr/include/des.h
.br
/usr/lib/libdes.a
.SH "SEE ALSO"
.SH DIAGNOSTICS
.SH BUGS
This software has not yet been compiled or tested on machines other than the
VAX and the IBM PC.
.SH AUTHORS
Steve Miller, MIT Project Athena/Digital Equipment Corporation
.SH RESTRICTIONS
COPYRIGHT 1985,1986 Massachusetts Institute of Technology
.PP
This software may not be exported outside of the US without a special
license from the US Dept of Commerce. It may be replaced by any secret
key block cipher with block length and key length of 8 bytes, as long
as the interface is the same as described here.

502
lib/des/des_crypt.man Normal file
View File

@@ -0,0 +1,502 @@
.TH DES_CRYPT 3
.SH NAME
des_read_password, des_read_2password,
des_string_to_key, des_string_to_2key, des_read_pw_string,
des_random_key, des_set_key,
des_key_sched, des_ecb_encrypt, des_3ecb_encrypt, des_cbc_encrypt,
des_3cbc_encrypt,
des_pcbc_encrypt, des_cfb_encrypt, des_ofb_encrypt,
des_cbc_cksum, des_quad_cksum,
des_enc_read, des_enc_write, des_set_odd_parity,
des_is_weak_key, crypt \- (non USA) DES encryption
.SH SYNOPSIS
.nf
.nj
.ft B
#include <des.h>
.PP
.B int des_read_password(key,prompt,verify)
des_cblock *key;
char *prompt;
int verify;
.PP
.B int des_read_2password(key1,key2,prompt,verify)
des_cblock *key1,*key2;
char *prompt;
int verify;
.PP
.B int des_string_to_key(str,key)
char *str;
des_cblock *key;
.PP
.B int des_string_to_2keys(str,key1,key2)
char *str;
des_cblock *key1,*key2;
.PP
.B int des_read_pw_string(buf,length,prompt,verify)
char *buf;
int length;
char *prompt;
int verify;
.PP
.B int des_random_key(key)
des_cblock *key;
.PP
.B int des_set_key(key,schedule)
des_cblock *key;
des_key_schedule schedule;
.PP
.B int des_key_sched(key,schedule)
des_cblock *key;
des_key_schedule schedule;
.PP
.B int des_ecb_encrypt(input,output,schedule,encrypt)
des_cblock *input;
des_cblock *output;
des_key_schedule schedule;
int encrypt;
.PP
.B int des_3ecb_encrypt(input,output,ks1,ks2,encrypt)
des_cblock *input;
des_cblock *output;
des_key_schedule ks1,ks2;
int encrypt;
.PP
.B int des_cbc_encrypt(input,output,length,schedule,ivec,encrypt)
des_cblock *input;
des_cblock *output;
long length;
des_key_schedule schedule;
des_cblock *ivec;
int encrypt;
.PP
.B int des_3cbc_encrypt(input,output,length,sk1,sk2,ivec1,ivec2,encrypt)
des_cblock *input;
des_cblock *output;
long length;
des_key_schedule sk1;
des_key_schedule sk2;
des_cblock *ivec1;
des_cblock *ivec2;
int encrypt;
.PP
.B int des_pcbc_encrypt(input,output,length,schedule,ivec,encrypt)
des_cblock *input;
des_cblock *output;
long length;
des_key_schedule schedule;
des_cblock *ivec;
int encrypt;
.PP
.B int des_cfb_encrypt(input,output,numbits,length,schedule,ivec,encrypt)
unsigned char *input;
unsigned char *output;
int numbits;
long length;
des_key_schedule schedule;
des_cblock *ivec;
int encrypt;
.PP
.B int des_ofb_encrypt(input,output,numbits,length,schedule,ivec)
unsigned char *input,*output;
int numbits;
long length;
des_key_schedule schedule;
des_cblock *ivec;
.PP
.B unsigned long des_cbc_cksum(input,output,length,schedule,ivec)
des_cblock *input;
des_cblock *output;
long length;
des_key_schedule schedule;
des_cblock *ivec;
.PP
.B unsigned long des_quad_cksum(input,output,length,out_count,seed)
des_cblock *input;
des_cblock *output;
long length;
int out_count;
des_cblock *seed;
.PP
.B int des_check_key;
.PP
.B int des_enc_read(fd,buf,len,sched,iv)
int fd;
char *buf;
int len;
des_key_schedule sched;
des_cblock *iv;
.PP
.B int des_enc_write(fd,buf,len,sched,iv)
int fd;
char *buf;
int len;
des_key_schedule sched;
des_cblock *iv;
.PP
.B extern int des_rw_mode;
.PP
.B void des_set_odd_parity(key)
des_cblock *key;
.PP
.B int des_is_weak_key(key)
des_cblock *key;
.PP
.B char *crypt(passwd,salt)
char *passwd;
char *salt;
.PP
.fi
.SH DESCRIPTION
This library contains a fast implementation of the DES encryption
algorithm.
.PP
There are two phases to the use of DES encryption.
The first is the generation of a
.I des_key_schedule
from a key,
the second is the actual encryption.
A des key is of type
.I des_cblock.
This type is made from 8 characters with odd parity.
The least significant bit in the character is the parity bit.
The key schedule is an expanded form of the key; it is used to speed the
encryption process.
.PP
.I des_read_password
writes the string specified by prompt to the standard output,
turns off echo and reads an input string from standard input
until terminated with a newline.
If verify is non-zero, it prompts and reads the input again and verifies
that both entered passwords are the same.
The entered string is converted into a des key by using the
.I des_string_to_key
routine.
The new key is placed in the
.I des_cblock
that was passed (by reference) to the routine.
If there were no errors,
.I des_read_password
returns 0,
-1 is returned if there was a terminal error and 1 is returned for
any other error.
.PP
.I des_read_2password
operates in the same way as
.I des_read_password
except that it generates 2 keys by using the
.I des_string_to_2key
function.
.PP
.I des_read_pw_string
is called by
.I des_read_password
to read and verify a string from a terminal device.
The string is returned in
.I buf.
The size of
.I buf
is passed to the routine via the
.I length
parameter.
.PP
.I des_string_to_key
converts a string into a valid des key.
.PP
.I des_string_to_2key
converts a string into 2 valid des keys.
This routine is best suited for used to generate keys for use with
.I des_3ecb_encrypt.
.PP
.I des_random_key
returns a random key that is made of a combination of process id,
time and an increasing counter.
.PP
Before a des key can be used it is converted into a
.I des_key_schedule
via the
.I des_set_key
routine.
If the
.I des_check_key
flag is non-zero,
.I des_set_key
will check that the key passed is of odd parity and is not a week or
semi-weak key.
If the parity is wrong,
then -1 is returned.
If the key is a weak key,
then -2 is returned.
If an error is returned,
the key schedule is not generated.
.PP
.I des_key_sched
is another name for the
.I des_set_key
function.
.PP
The following routines mostly operate on an input and output stream of
.I des_cblock's.
.PP
.I des_ecb_encrypt
is the basic DES encryption routine that encrypts or decrypts a single 8-byte
.I des_cblock
in
.I electronic code book
mode.
It always transforms the input data, pointed to by
.I input,
into the output data,
pointed to by the
.I output
argument.
If the
.I encrypt
argument is non-zero (DES_ENCRYPT),
the
.I input
(cleartext) is encrypted in to the
.I output
(ciphertext) using the key_schedule specified by the
.I schedule
argument,
previously set via
.I des_set_key.
If
.I encrypt
is zero (DES_DECRYPT),
the
.I input
(now ciphertext)
is decrypted into the
.I output
(now cleartext).
Input and output may overlap.
No meaningful value is returned.
.PP
.I des_3ecb_encrypt
encrypts/decrypts the
.I input
block by using triple ecb DES encryption.
This involves encrypting the input with
.I ks1,
decryption with the key schedule
.I ks2,
and then encryption with the first again.
This routine greatly reduces the chances of brute force breaking of
DES and has the advantage of if
.I ks1
and
.I ks2
are the same, it is equivalent to just encryption using ecb mode and
.I ks1
as the key.
.PP
.I des_cbc_encrypt
encrypts/decrypts using the
.I cipher-block-chaining
mode of DES.
If the
.I encrypt
argument is non-zero,
the routine cipher-block-chain encrypts the cleartext data pointed to by the
.I input
argument into the ciphertext pointed to by the
.I output
argument,
using the key schedule provided by the
.I schedule
argument,
and initialisation vector provided by the
.I ivec
argument.
If the
.I length
argument is not an integral multiple of eight bytes,
the last block is copied to a temporary area and zero filled.
The output is always
an integral multiple of eight bytes.
To make multiple cbc encrypt calls on a large amount of data appear to
be one
.I des_cbc_encrypt
call, the
.I ivec
of subsequent calls should be the last 8 bytes of the output.
.PP
.I des_3cbc_encrypt
encrypts/decrypts the
.I input
block by using triple cbc DES encryption.
This involves encrypting the input with key schedule
.I ks1,
decryption with the key schedule
.I ks2,
and then encryption with the first again.
2 initialisation vectors are required,
.I ivec1
and
.I ivec2.
Unlike
.I des_cbc_encrypt,
these initialisation vectors are modified by the subroutine.
This routine greatly reduces the chances of brute force breaking of
DES and has the advantage of if
.I ks1
and
.I ks2
are the same, it is equivalent to just encryption using cbc mode and
.I ks1
as the key.
.PP
.I des_pcbc_encrypt
encrypt/decrypts using a modified block chaining mode.
It provides better error propagation characteristics than cbc
encryption.
.PP
.I des_cfb_encrypt
encrypt/decrypts using cipher feedback mode. This method takes an
array of characters as input and outputs and array of characters. It
does not require any padding to 8 character groups. Note: the ivec
variable is changed and the new changed value needs to be passed to
the next call to this function. Since this function runs a complete
DES ecb encryption per numbits, this function is only suggested for
use when sending small numbers of characters.
.PP
.I des_ofb_encrypt
encrypt using output feedback mode. This method takes an
array of characters as input and outputs and array of characters. It
does not require any padding to 8 character groups. Note: the ivec
variable is changed and the new changed value needs to be passed to
the next call to this function. Since this function runs a complete
DES ecb encryption per numbits, this function is only suggested for
use when sending small numbers of characters.
.PP
.I des_cbc_cksum
produces an 8 byte checksum based on the input stream (via cbc encryption).
The last 4 bytes of the checksum is returned and the complete 8 bytes is
placed in
.I output.
.PP
.I des_quad_cksum
returns a 4 byte checksum from the input bytes.
The algorithm can be iterated over the input,
depending on
.I out_count,
1, 2, 3 or 4 times.
If
.I output
is non-NULL,
the 8 bytes generated by each pass are written into
.I output.
.PP
.I des_enc_write
is used to write
.I len
bytes
to file descriptor
.I fd
from buffer
.I buf.
The data is encrypted via
.I pcbc_encrypt
(default) using
.I sched
for the key and
.I iv
as a starting vector.
The actual data send down
.I fd
consists of 4 bytes (in network byte order) containing the length of the
following encrypted data. The encrypted data then follows, padded with random
data out to a multiple of 8 bytes.
.PP
.I des_enc_read
is used to read
.I len
bytes
from file descriptor
.I fd
into buffer
.I buf.
The data being read from
.I fd
is assumed to have come from
.I des_enc_write
and is decrypted using
.I sched
for the key schedule and
.I iv
for the initial vector.
The
.I des_enc_read/des_enc_write
pair can be used to read/write to files, pipes and sockets.
I have used them in implementing a version of rlogin in which all
data is encrypted.
.PP
.I des_rw_mode
is used to specify the encryption mode to use with
.I des_enc_read
and
.I des_end_write.
If set to
.I DES_PCBC_MODE
(the default), des_pcbc_encrypt is used.
If set to
.I DES_CBC_MODE
des_cbc_encrypt is used.
These two routines and the variable are not part of the normal MIT library.
.PP
.I des_set_odd_parity
sets the parity of the passed
.I key
to odd. This routine is not part of the standard MIT library.
.PP
.I des_is_weak_key
returns 1 is the passed key is a weak key (pick again :-),
0 if it is ok.
This routine is not part of the standard MIT library.
.PP
.I crypt
is a replacement for the normal system crypt.
It is much faster than the system crypt.
.PP
.SH FILES
/usr/include/des.h
.br
/usr/lib/libdes.a
.PP
The encryption routines have been tested on 16bit, 32bit and 64bit
machines of various endian and even works under VMS.
.PP
.SH BUGS
.PP
If you think this manual is sparse,
read the des_crypt(3) manual from the MIT kerberos (or bones outside
of the USA) distribution.
.PP
.I des_cfb_encrypt
and
.I des_ofb_encrypt
operates on input of 8 bits. What this means is that if you set
numbits to 12, and length to 2, the first 12 bits will come from the 1st
input byte and the low half of the second input byte. The second 12
bits will have the low 8 bits taken from the 3rd input byte and the
top 4 bits taken from the 4th input byte. The same holds for output.
This function has been implemented this way because most people will
be using a multiple of 8 and because once you get into pulling bytes input
bytes apart things get ugly!
.PP
.I des_read_pw_string
is the most machine/OS dependent function and normally generates the
most problems when porting this code.
.PP
.I des_string_to_key
is probably different from the MIT version since there are lots
of fun ways to implement one-way encryption of a text string.
.PP
The routines are optimised for 32 bit machines and so are not efficient
on IBM PCs.
.SH AUTHOR
Eric Young (eay@psych.psy.uq.oz.au),
Psychology Department,
University of Queensland, Australia.

174
lib/des/des_locl.h Normal file
View File

@@ -0,0 +1,174 @@
/* des_locl.h */
/* Copyright (C) 1993 Eric Young - see README for more details */
#ifndef __des_locl_h
#define __des_locl_h
#include "config.h"
#include "protos.h"
#include <stdio.h>
#include <memory.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#include "des.h"
#define ITERATIONS 16
#define HALF_ITERATIONS 8
/* used in des_read and des_write */
#define MAXWRITE (1024*16)
#define BSIZE (MAXWRITE+4)
#define c2l(c,l) (l =((u_int32_t)(*((c)++))) , \
l|=((u_int32_t)(*((c)++)))<< 8, \
l|=((u_int32_t)(*((c)++)))<<16, \
l|=((u_int32_t)(*((c)++)))<<24)
/* NOTE - c is not incremented as per c2l */
#define c2ln(c,l1,l2,n) { \
c+=n; \
l1=l2=0; \
switch (n) { \
case 8: l2|=((u_int32_t)(*(--(c))))<<24; \
case 7: l2|=((u_int32_t)(*(--(c))))<<16; \
case 6: l2|=((u_int32_t)(*(--(c))))<< 8; \
case 5: l2|=((u_int32_t)(*(--(c)))); \
case 4: l1|=((u_int32_t)(*(--(c))))<<24; \
case 3: l1|=((u_int32_t)(*(--(c))))<<16; \
case 2: l1|=((u_int32_t)(*(--(c))))<< 8; \
case 1: l1|=((u_int32_t)(*(--(c)))); \
} \
}
#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
*((c)++)=(unsigned char)(((l)>> 8)&0xff), \
*((c)++)=(unsigned char)(((l)>>16)&0xff), \
*((c)++)=(unsigned char)(((l)>>24)&0xff))
/* replacements for htonl and ntohl since I have no idea what to do
* when faced with machines with 8 byte longs. */
#define HDRSIZE 4
#define n2l(c,l) (l =((u_int32_t)(*((c)++)))<<24, \
l|=((u_int32_t)(*((c)++)))<<16, \
l|=((u_int32_t)(*((c)++)))<< 8, \
l|=((u_int32_t)(*((c)++))))
#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24)&0xff), \
*((c)++)=(unsigned char)(((l)>>16)&0xff), \
*((c)++)=(unsigned char)(((l)>> 8)&0xff), \
*((c)++)=(unsigned char)(((l) )&0xff))
/* NOTE - c is not incremented as per l2c */
#define l2cn(l1,l2,c,n) { \
c+=n; \
switch (n) { \
case 8: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
case 7: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
case 6: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
case 4: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
case 3: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
case 2: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
} \
}
/* The changes to this macro may help or hinder, depending on the
* compiler and the achitecture. gcc2 always seems to do well :-).
* Inspired by Dana How <how@isl.stanford.edu>
* DO NOT use the alternative version on machines with 8 byte longs. */
#ifdef ALT_ECB
#define D_ENCRYPT(L,R,S) \
u=((R^s[S ])<<2); \
t= R^s[S+1]; \
t=((t>>2)+(t<<30)); \
L^= \
*(u_int32_t *)(des_SP+0x0100+((t )&0xfc))+ \
*(u_int32_t *)(des_SP+0x0300+((t>> 8)&0xfc))+ \
*(u_int32_t *)(des_SP+0x0500+((t>>16)&0xfc))+ \
*(u_int32_t *)(des_SP+0x0700+((t>>24)&0xfc))+ \
*(u_int32_t *)(des_SP+ ((u )&0xfc))+ \
*(u_int32_t *)(des_SP+0x0200+((u>> 8)&0xfc))+ \
*(u_int32_t *)(des_SP+0x0400+((u>>16)&0xfc))+ \
*(u_int32_t *)(des_SP+0x0600+((u>>24)&0xfc));
#else /* original version */
#ifdef MSDOS
#define D_ENCRYPT(L,R,S) \
U.l=R^s[S+1]; \
T.s[0]=((U.s[0]>>4)|(U.s[1]<<12))&0x3f3f; \
T.s[1]=((U.s[1]>>4)|(U.s[0]<<12))&0x3f3f; \
U.l=(R^s[S ])&0x3f3f3f3f; \
L^= des_SPtrans[1][(T.c[0])]| \
des_SPtrans[3][(T.c[1])]| \
des_SPtrans[5][(T.c[2])]| \
des_SPtrans[7][(T.c[3])]| \
des_SPtrans[0][(U.c[0])]| \
des_SPtrans[2][(U.c[1])]| \
des_SPtrans[4][(U.c[2])]| \
des_SPtrans[6][(U.c[3])];
#else
#define D_ENCRYPT(L,R,S) \
u=(R^s[S ]); \
t=R^s[S+1]; \
t=((t>>4)+(t<<28)); \
L^= des_SPtrans[1][(t )&0x3f]| \
des_SPtrans[3][(t>> 8)&0x3f]| \
des_SPtrans[5][(t>>16)&0x3f]| \
des_SPtrans[7][(t>>24)&0x3f]| \
des_SPtrans[0][(u )&0x3f]| \
des_SPtrans[2][(u>> 8)&0x3f]| \
des_SPtrans[4][(u>>16)&0x3f]| \
des_SPtrans[6][(u>>24)&0x3f];
#endif
#endif
/* IP and FP
* The problem is more of a geometric problem that random bit fiddling.
0 1 2 3 4 5 6 7 62 54 46 38 30 22 14 6
8 9 10 11 12 13 14 15 60 52 44 36 28 20 12 4
16 17 18 19 20 21 22 23 58 50 42 34 26 18 10 2
24 25 26 27 28 29 30 31 to 56 48 40 32 24 16 8 0
32 33 34 35 36 37 38 39 63 55 47 39 31 23 15 7
40 41 42 43 44 45 46 47 61 53 45 37 29 21 13 5
48 49 50 51 52 53 54 55 59 51 43 35 27 19 11 3
56 57 58 59 60 61 62 63 57 49 41 33 25 17 9 1
The output has been subject to swaps of the form
0 1 -> 3 1 but the odd and even bits have been put into
2 3 2 0
different words. The main trick is to remember that
t=((l>>size)^r)&(mask);
r^=t;
l^=(t<<size);
can be used to swap and move bits between words.
So l = 0 1 2 3 r = 16 17 18 19
4 5 6 7 20 21 22 23
8 9 10 11 24 25 26 27
12 13 14 15 28 29 30 31
becomes (for size == 2 and mask == 0x3333)
t = 2^16 3^17 -- -- l = 0 1 16 17 r = 2 3 18 19
6^20 7^21 -- -- 4 5 20 21 6 7 22 23
10^24 11^25 -- -- 8 9 24 25 10 11 24 25
14^28 15^29 -- -- 12 13 28 29 14 15 28 29
Thanks for hints from Richard Outerbridge - he told me IP&FP
could be done in 15 xor, 10 shifts and 5 ands.
When I finally started to think of the problem in 2D
I first got ~42 operations without xors. When I remembered
how to use xors :-) I got it to its final state.
*/
#define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\
(b)^=(t),\
(a)^=((t)<<(n)))
#endif /* __des_locl_h */

373
lib/des/destest.c Normal file
View File

@@ -0,0 +1,373 @@
/* destest.c */
/* Copyright (C) 1993 Eric Young - see README for more details */
#include <stdio.h>
#include "des_locl.h" /* for des.h and bcopy macros */
/* tisk tisk - the test keys don't all have odd parity :-( */
#if defined(__STDC__) || defined(VMS) || defined(M_XENIX) || defined(MSDOS)
#include <string.h>
#define bcopy(f,t,n) memcpy(t,f,(size_t)(n))
#define bzero(s,n) memset(s,0,(size_t)(n))
#define bcmp(a,b,n) memcmp(a, b,(size_t)(n))
#define index(s,c) strchr(s,c)
#endif
/* test data */
#define NUM_TESTS 34
static unsigned char key_data[NUM_TESTS][8]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10,
0x7C,0xA1,0x10,0x45,0x4A,0x1A,0x6E,0x57,
0x01,0x31,0xD9,0x61,0x9D,0xC1,0x37,0x6E,
0x07,0xA1,0x13,0x3E,0x4A,0x0B,0x26,0x86,
0x38,0x49,0x67,0x4C,0x26,0x02,0x31,0x9E,
0x04,0xB9,0x15,0xBA,0x43,0xFE,0xB5,0xB6,
0x01,0x13,0xB9,0x70,0xFD,0x34,0xF2,0xCE,
0x01,0x70,0xF1,0x75,0x46,0x8F,0xB5,0xE6,
0x43,0x29,0x7F,0xAD,0x38,0xE3,0x73,0xFE,
0x07,0xA7,0x13,0x70,0x45,0xDA,0x2A,0x16,
0x04,0x68,0x91,0x04,0xC2,0xFD,0x3B,0x2F,
0x37,0xD0,0x6B,0xB5,0x16,0xCB,0x75,0x46,
0x1F,0x08,0x26,0x0D,0x1A,0xC2,0x46,0x5E,
0x58,0x40,0x23,0x64,0x1A,0xBA,0x61,0x76,
0x02,0x58,0x16,0x16,0x46,0x29,0xB0,0x07,
0x49,0x79,0x3E,0xBC,0x79,0xB3,0x25,0x8F,
0x4F,0xB0,0x5E,0x15,0x15,0xAB,0x73,0xA7,
0x49,0xE9,0x5D,0x6D,0x4C,0xA2,0x29,0xBF,
0x01,0x83,0x10,0xDC,0x40,0x9B,0x26,0xD6,
0x1C,0x58,0x7F,0x1C,0x13,0x92,0x4F,0xEF,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
0x1F,0x1F,0x1F,0x1F,0x0E,0x0E,0x0E,0x0E,
0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1,0xFE,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10};
static unsigned char plain_data[NUM_TESTS][8]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
0x01,0xA1,0xD6,0xD0,0x39,0x77,0x67,0x42,
0x5C,0xD5,0x4C,0xA8,0x3D,0xEF,0x57,0xDA,
0x02,0x48,0xD4,0x38,0x06,0xF6,0x71,0x72,
0x51,0x45,0x4B,0x58,0x2D,0xDF,0x44,0x0A,
0x42,0xFD,0x44,0x30,0x59,0x57,0x7F,0xA2,
0x05,0x9B,0x5E,0x08,0x51,0xCF,0x14,0x3A,
0x07,0x56,0xD8,0xE0,0x77,0x47,0x61,0xD2,
0x76,0x25,0x14,0xB8,0x29,0xBF,0x48,0x6A,
0x3B,0xDD,0x11,0x90,0x49,0x37,0x28,0x02,
0x26,0x95,0x5F,0x68,0x35,0xAF,0x60,0x9A,
0x16,0x4D,0x5E,0x40,0x4F,0x27,0x52,0x32,
0x6B,0x05,0x6E,0x18,0x75,0x9F,0x5C,0xCA,
0x00,0x4B,0xD6,0xEF,0x09,0x17,0x60,0x62,
0x48,0x0D,0x39,0x00,0x6E,0xE7,0x62,0xF2,
0x43,0x75,0x40,0xC8,0x69,0x8F,0x3C,0xFA,
0x07,0x2D,0x43,0xA0,0x77,0x07,0x52,0x92,
0x02,0xFE,0x55,0x77,0x81,0x17,0xF1,0x2A,
0x1D,0x9D,0x5C,0x50,0x18,0xF7,0x28,0xC2,
0x30,0x55,0x32,0x28,0x6D,0x6F,0x29,0x5A,
0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
static unsigned char cipher_data[NUM_TESTS][8]={
0x8C,0xA6,0x4D,0xE9,0xC1,0xB1,0x23,0xA7,
0x73,0x59,0xB2,0x16,0x3E,0x4E,0xDC,0x58,
0x95,0x8E,0x6E,0x62,0x7A,0x05,0x55,0x7B,
0xF4,0x03,0x79,0xAB,0x9E,0x0E,0xC5,0x33,
0x17,0x66,0x8D,0xFC,0x72,0x92,0x53,0x2D,
0x8A,0x5A,0xE1,0xF8,0x1A,0xB8,0xF2,0xDD,
0x8C,0xA6,0x4D,0xE9,0xC1,0xB1,0x23,0xA7,
0xED,0x39,0xD9,0x50,0xFA,0x74,0xBC,0xC4,
0x69,0x0F,0x5B,0x0D,0x9A,0x26,0x93,0x9B,
0x7A,0x38,0x9D,0x10,0x35,0x4B,0xD2,0x71,
0x86,0x8E,0xBB,0x51,0xCA,0xB4,0x59,0x9A,
0x71,0x78,0x87,0x6E,0x01,0xF1,0x9B,0x2A,
0xAF,0x37,0xFB,0x42,0x1F,0x8C,0x40,0x95,
0x86,0xA5,0x60,0xF1,0x0E,0xC6,0xD8,0x5B,
0x0C,0xD3,0xDA,0x02,0x00,0x21,0xDC,0x09,
0xEA,0x67,0x6B,0x2C,0xB7,0xDB,0x2B,0x7A,
0xDF,0xD6,0x4A,0x81,0x5C,0xAF,0x1A,0x0F,
0x5C,0x51,0x3C,0x9C,0x48,0x86,0xC0,0x88,
0x0A,0x2A,0xEE,0xAE,0x3F,0xF4,0xAB,0x77,
0xEF,0x1B,0xF0,0x3E,0x5D,0xFA,0x57,0x5A,
0x88,0xBF,0x0D,0xB6,0xD7,0x0D,0xEE,0x56,
0xA1,0xF9,0x91,0x55,0x41,0x02,0x0B,0x56,
0x6F,0xBF,0x1C,0xAF,0xCF,0xFD,0x05,0x56,
0x2F,0x22,0xE4,0x9B,0xAB,0x7C,0xA1,0xAC,
0x5A,0x6B,0x61,0x2C,0xC2,0x6C,0xCE,0x4A,
0x5F,0x4C,0x03,0x8E,0xD1,0x2B,0x2E,0x41,
0x63,0xFA,0xC0,0xD0,0x34,0xD9,0xF7,0x93,
0x61,0x7B,0x3A,0x0C,0xE8,0xF0,0x71,0x00,
0xDB,0x95,0x86,0x05,0xF8,0xC8,0xC6,0x06,
0xED,0xBF,0xD1,0xC6,0x6C,0x29,0xCC,0xC7,
0x35,0x55,0x50,0xB2,0x15,0x0E,0x24,0x51,
0xCA,0xAA,0xAF,0x4D,0xEA,0xF1,0xDB,0xAE,
0xD5,0xD4,0x4F,0xF7,0x20,0x68,0x3D,0x0D,
0x2A,0x2B,0xB0,0x08,0xDF,0x97,0xC2,0xF2};
static unsigned char cbc_key[8]={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef};
static unsigned char cbc_iv[8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10};
static unsigned char cbc_data[40]="7654321 Now is the time for ";
static unsigned char cbc_ok[32]={
0xcc,0xd1,0x73,0xff,0xab,0x20,0x39,0xf4,
0xac,0xd8,0xae,0xfd,0xdf,0xd8,0xa1,0xeb,
0x46,0x8e,0x91,0x15,0x78,0x88,0xba,0x68,
0x1d,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4};
static unsigned char pcbc_ok[32]={
0xcc,0xd1,0x73,0xff,0xab,0x20,0x39,0xf4,
0x6d,0xec,0xb4,0x70,0xa0,0xe5,0x6b,0x15,
0xae,0xa6,0xbf,0x61,0xed,0x7d,0x9c,0x9f,
0xf7,0x17,0x46,0x3b,0x8a,0xb3,0xcc,0x88};
static unsigned char cksum_ok[8]={
0x1d,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4};
static unsigned char cfb_key[8]={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef};
static unsigned char cfb_iv[8]={0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef};
static unsigned char cfb_buf1[24],cfb_buf2[24],cfb_tmp[8];
static unsigned char cfb_plain[24]=
{
0x4e,0x6f,0x77,0x20,0x69,0x73,
0x20,0x74,0x68,0x65,0x20,0x74,
0x69,0x6d,0x65,0x20,0x66,0x6f,
0x72,0x20,0x61,0x6c,0x6c,0x20
};
static unsigned char cfb_cipher[24]=
{
0xf3,0x1f,0xda,0x07,0x01,0x14,
0x62,0xee,0x18,0x7f,0x43,0xd8,
0x0a,0x7c,0xd9,0xb5,0xb0,0xd2,
0x90,0xda,0x6e,0x5b,0x9a,0x87
};
static unsigned char ofb_key[8]={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef};
static unsigned char ofb_iv[8]={0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef};
static unsigned char ofb_plain[24]=
{
0x4e,0x6f,0x77,0x20,0x69,0x73,
0x20,0x74,0x68,0x65,0x20,0x74,
0x69,0x6d,0x65,0x20,0x66,0x6f,
0x72,0x20,0x61,0x6c,0x6c,0x20
};
static unsigned char ofb_buf1[24],ofb_buf2[24],ofb_tmp[8];
static unsigned char ofb_cipher[24]=
{
0xf3,0x09,0x62,0x49,0xc7,0xf4,0x6e,0x51,
0x35,0xf2,0x4a,0x24,0x2e,0xeb,0x3d,0x3f,
0x3d,0x6d,0x5b,0xe3,0x25,0x5a,0xf8,0xc3
};
char *malloc(size_t);
char *pt(unsigned char *p);
int
main(void)
{
int i,j;
des_cblock in,out,outin;
des_key_schedule ks;
unsigned char cbc_in[40],cbc_out[40];
u_int32_t cs;
unsigned char qret[4][4];
u_int32_t lqret[4];
char *str;
printf("Doing ecb\n");
for (i=0; i<NUM_TESTS; i++)
{
if ((j=des_key_sched((des_cblock *)(key_data[i]),ks)) != 0)
printf("Key error %2d:%d\n",i+1,j);
bcopy(plain_data[i],in,8);
bzero(out,8);
bzero(outin,8);
des_ecb_encrypt((des_cblock *)in,(des_cblock *)out,ks,DES_ENCRYPT);
des_ecb_encrypt((des_cblock *)out,(des_cblock *)outin,ks,DES_DECRYPT);
if (bcmp(out,cipher_data[i],8) != 0)
{
printf("Encryption error %2d\nk=%s p=%s o=%s act=%s\n",
i+1,pt(key_data[i]),pt(in),pt(cipher_data[i]),
pt(out));
}
if (bcmp(in,outin,8) != 0)
{
printf("Decryption error %2d\nk=%s p=%s o=%s act=%s\n",
i+1,pt(key_data[i]),pt(out),pt(in),pt(outin));
}
}
printf("Doing cbc\n");
if ((j=des_key_sched((des_cblock *)cbc_key,ks)) != 0)
printf("Key error %2d:%d\n",i+1,j);
bzero(cbc_out,40);
bzero(cbc_in,40);
des_cbc_encrypt((des_cblock *)cbc_data,(des_cblock *)cbc_out,
(long)strlen(cbc_data),ks,(des_cblock *)cbc_iv,DES_ENCRYPT);
if (bcmp(cbc_out,cbc_ok,32) != 0)
printf("cbc_encrypt encrypt error\n");
des_cbc_encrypt((des_cblock *)cbc_out,(des_cblock *)cbc_in,
(long)strlen(cbc_data),ks,(des_cblock *)cbc_iv,DES_DECRYPT);
if (bcmp(cbc_in,cbc_data,32) != 0)
printf("cbc_encrypt decrypt error\n");
printf("Doing pcbc\n");
if ((j=des_key_sched((des_cblock *)cbc_key,ks)) != 0)
printf("Key error %2d:%d\n",i+1,j);
bzero(cbc_out,40);
bzero(cbc_in,40);
des_pcbc_encrypt((des_cblock *)cbc_data,(des_cblock *)cbc_out,
(long)strlen(cbc_data),ks,(des_cblock *)cbc_iv,DES_ENCRYPT);
if (bcmp(cbc_out,pcbc_ok,32) != 0)
printf("pcbc_encrypt encrypt error\n");
des_pcbc_encrypt((des_cblock *)cbc_out,(des_cblock *)cbc_in,
(long)strlen(cbc_data),ks,(des_cblock *)cbc_iv,DES_DECRYPT);
if (bcmp(cbc_in,cbc_data,32) != 0)
printf("pcbc_encrypt decrypt error\n");
printf("Doing cfb\n");
des_key_sched((des_cblock *)cfb_key,ks);
bcopy(cfb_iv,cfb_tmp,sizeof(cfb_iv));
des_cfb_encrypt(cfb_plain,cfb_buf1,8,(long)sizeof(cfb_plain),ks,
(des_cblock *)cfb_tmp,DES_ENCRYPT);
if (bcmp(cfb_cipher,cfb_buf1,sizeof(cfb_buf1)) != 0)
printf("cfb_encrypt encrypt error\n");
bcopy(cfb_iv,cfb_tmp,sizeof(cfb_iv));
des_cfb_encrypt(cfb_buf1,cfb_buf2,8,(long)sizeof(cfb_buf1),ks,
(des_cblock *)cfb_tmp,DES_DECRYPT);
if (bcmp(cfb_plain,cfb_buf2,sizeof(cfb_buf2)) != 0)
printf("cfb_encrypt decrypt error\n");
bcopy(cfb_iv,cfb_tmp,sizeof(cfb_iv));
for (i=0; i<sizeof(cfb_plain); i++)
des_cfb_encrypt(&(cfb_plain[i]),&(cfb_buf1[i]),
8,(long)1,ks,(des_cblock *)cfb_tmp,DES_ENCRYPT);
if (bcmp(cfb_cipher,cfb_buf1,sizeof(cfb_buf1)) != 0)
printf("cfb_encrypt small encrypt error\n");
bcopy(cfb_iv,cfb_tmp,sizeof(cfb_iv));
for (i=0; i<sizeof(cfb_plain); i++)
des_cfb_encrypt(&(cfb_buf1[i]),&(cfb_buf2[i]),
8,(long)1,ks,(des_cblock *)cfb_tmp,DES_DECRYPT);
if (bcmp(cfb_plain,cfb_buf2,sizeof(cfb_buf2)) != 0)
printf("cfb_encrypt small decrypt error\n");
printf("Doing ofb\n");
des_key_sched((des_cblock *)ofb_key,ks);
bcopy(ofb_iv,ofb_tmp,sizeof(ofb_iv));
des_ofb_encrypt(ofb_plain,ofb_buf1,64,(long)sizeof(cfb_plain)/8,ks,
(des_cblock *)ofb_tmp);
if (bcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0)
printf("ofb_encrypt encrypt error\n");
bcopy(ofb_iv,ofb_tmp,sizeof(ofb_iv));
des_ofb_encrypt(ofb_buf1,ofb_buf2,64,(long)sizeof(ofb_buf1)/8,ks,
(des_cblock *)ofb_tmp);
if (bcmp(ofb_plain,ofb_buf2,sizeof(ofb_buf2)) != 0)
printf("ofb_encrypt decrypt error\n");
printf("Doing cbc_cksum\n");
des_cbc_cksum((des_cblock *)cbc_data,(des_cblock *)cbc_out,
(long)strlen(cbc_data),ks,(des_cblock *)cbc_iv);
if (bcmp(cbc_out,cksum_ok,8) != 0)
printf("cbc_cksum error\n");
printf("Doing quad_cksum\n");
cs=des_quad_cksum((des_cblock *)cbc_data,(des_cblock *)qret,
(long)strlen(cbc_data),2,(des_cblock *)cbc_iv);
for (i=0; i<4; i++)
{
lqret[i]=0;
bcopy(&(qret[i][0]),&(lqret[i]),4);
}
{ /* Big-endian fix */
static u_int32_t l=1;
static unsigned char *c=(unsigned char *)&l;
u_int32_t ll;
if (!c[0])
{
ll=lqret[0]^lqret[3];
lqret[0]^=ll;
lqret[3]^=ll;
ll=lqret[1]^lqret[2];
lqret[1]^=ll;
lqret[2]^=ll;
}
}
if (cs != 0x70d7a63a)
printf("quad_cksum error, ret %08x should be 70d7a63a\n",cs);
if (lqret[0] != 0x327eba8d)
printf("quad_cksum error, out[0] %08x is not %08x\n",
lqret[0],0x327eba8d);
if (lqret[1] != 0x201a49cc)
printf("quad_cksum error, out[1] %08x is not %08x\n",
lqret[1],0x201a49cc);
if (lqret[2] != 0x70d7a63a)
printf("quad_cksum error, out[2] %08x is not %08x\n",
lqret[2],0x70d7a63a);
if (lqret[3] != 0x501c2c26)
printf("quad_cksum error, out[3] %08x is not %08x\n",
lqret[3],0x501c2c26);
printf("input word alignment test");
for (i=0; i<4; i++)
{
printf(" %d",i);
des_cbc_encrypt((des_cblock *)&(cbc_out[i]),(des_cblock *)cbc_in,
(long)strlen(cbc_data),ks,(des_cblock *)cbc_iv,
DES_ENCRYPT);
}
printf("\noutput word alignment test");
for (i=0; i<4; i++)
{
printf(" %d",i);
des_cbc_encrypt((des_cblock *)cbc_out,(des_cblock *)&(cbc_in[i]),
(long)strlen(cbc_data),ks,(des_cblock *)cbc_iv,
DES_ENCRYPT);
}
printf("\n");
printf("fast crypt test ");
str=crypt("testing","ef");
if (strcmp("efGnQx2725bI2",str) != 0)
printf("fast crypt error, %x should be efGnQx2725bI2\n",str);
str=crypt("bca76;23","yA");
if (strcmp("yA1Rp/1hZXIJk",str) != 0)
printf("fast crypt error, %x should be yA1Rp/1hZXIJk\n",str);
printf("\n");
exit(0);
}
char *pt(unsigned char *p)
{
char *ret;
int i;
static char *f="0123456789ABCDEF";
ret=(char *)malloc(17);
for (i=0; i<8; i++)
{
ret[i*2]=f[(p[i]>>4)&0xf];
ret[i*2+1]=f[p[i]&0xf];
}
ret[16]='\0';
return(ret);
}

46
lib/des/doIP Executable file
View File

@@ -0,0 +1,46 @@
#!/usr/local/bin/perl
@l=(
0, 1, 2, 3, 4, 5, 6, 7,
8, 9,10,11,12,13,14,15,
16,17,18,19,20,21,22,23,
24,25,26,27,28,29,30,31
);
@r=(
32,33,34,35,36,37,38,39,
40,41,42,43,44,45,46,47,
48,49,50,51,52,53,54,55,
56,57,58,59,60,61,62,63
);
require 'shifts.pl';
sub PERM_OP
{
local(*a,*b,*t,$n,$m)=@_;
@z=&shift(*a,-$n);
@z=&xor(*b,*z);
@z=&and(*z,$m);
@b=&xor(*b,*z);
@z=&shift(*z,$n);
@a=&xor(*a,*z);
}
@L=@l;
@R=@r;
&PERM_OP(*R,*L,*T,4,0x0f0f0f0f);
&PERM_OP(*L,*R,*T,16,0x0000ffff);
&PERM_OP(*R,*L,*T,2,0x33333333);
&PERM_OP(*L,*R,*T,8,0x00ff00ff);
&PERM_OP(*R,*L,*T,1,0x55555555);
&printit(@L);
&printit(@R);
&PERM_OP(*R,*L,*T,1,0x55555555);
&PERM_OP(*L,*R,*T,8,0x00ff00ff);
&PERM_OP(*R,*L,*T,2,0x33333333);
&PERM_OP(*L,*R,*T,16,0x0000ffff);
&PERM_OP(*R,*L,*T,4,0x0f0f0f0f);
&printit(@L);
&printit(@R);

110
lib/des/doPC1 Executable file
View File

@@ -0,0 +1,110 @@
#!/usr/local/bin/perl
@l=(
0, 1, 2, 3, 4, 5, 6, 7,
8, 9,10,11,12,13,14,15,
16,17,18,19,20,21,22,23,
24,25,26,27,28,29,30,31
);
@r=(
32,33,34,35,36,37,38,39,
40,41,42,43,44,45,46,47,
48,49,50,51,52,53,54,55,
56,57,58,59,60,61,62,63
);
require 'shifts.pl';
sub PERM_OP
{
local(*a,*b,*t,$n,$m)=@_;
@z=&shift(*a,-$n);
@z=&xor(*b,*z);
@z=&and(*z,$m);
@b=&xor(*b,*z);
@z=&shift(*z,$n);
@a=&xor(*a,*z);
}
sub HPERM_OP2
{
local(*a,*t,$n,$m)=@_;
local(@x,@y,$i);
@z=&shift(*a,16-$n);
@z=&xor(*a,*z);
@z=&and(*z,$m);
@a=&xor(*a,*z);
@z=&shift(*z,$n-16);
@a=&xor(*a,*z);
}
sub HPERM_OP
{
local(*a,*t,$n,$m)=@_;
local(@x,@y,$i);
for ($i=0; $i<16; $i++)
{
$x[$i]=$a[$i];
$y[$i]=$a[16+$i];
}
@z=&shift(*x,-$n);
@z=&xor(*y,*z);
@z=&and(*z,$m);
@y=&xor(*y,*z);
@z=&shift(*z,$n);
@x=&xor(*x,*z);
for ($i=0; $i<16; $i++)
{
$a[$i]=$x[$i];
$a[16+$i]=$y[$i];
}
}
@L=@l;
@R=@r;
print "---\n"; &printit(@R);
&PERM_OP(*R,*L,*T,4,0x0f0f0f0f);
print "---\n"; &printit(@R);
&HPERM_OP2(*L,*T,-2,0xcccc0000);
&HPERM_OP2(*R,*T,-2,0xcccc0000);
print "---\n"; &printit(@R);
&PERM_OP(*R,*L,*T,1,0x55555555);
print "---\n"; &printit(@R);
&PERM_OP(*L,*R,*T,8,0x00ff00ff);
print "---\n"; &printit(@R);
&PERM_OP(*R,*L,*T,1,0x55555555);
print "---\n"; &printit(@R);
# &printit(@L);
&printit(@R);
print <<"EOF";
==============================
63 55 47 39 31 23 15 7
62 54 46 38 30 22 14 6
61 53 45 37 29 21 13 5
60 52 44 36 -- -- -- --
57 49 41 33 25 17 9 1
58 50 42 34 26 18 10 2
59 51 43 35 27 19 11 3
28 20 12 4 -- -- -- --
EOF
exit(1);
@A=&and(*R,0x000000ff);
@A=&shift(*A,16);
@B=&and(*R,0x0000ff00);
@C=&and(*R,0x00ff0000);
@C=&shift(*C,-16);
@D=&and(*L,0xf0000000);
@D=&shift(*D,-4);
@A=&or(*A,*B);
@B=&or(*D,*C);
@R=&or(*A,*B);
@L=&and(*L,0x0fffffff);
&printit(@L);
&printit(@R);

94
lib/des/doPC2 Executable file
View File

@@ -0,0 +1,94 @@
#!/usr/local/bin/perl
@PC2_C=(14,17,11,24, 1, 5,
3,28,15, 6,21,10,
23,19,12, 4,26, 8,
16, 7,27,20,13, 2,
);
@PC2_D=(41,52,31,37,47,55,
30,40,51,45,33,48,
44,49,39,56,34,53,
46,42,50,36,29,32,
);
$i=0;
foreach (@PC2_C) {
$_--;
# printf "%2d,",$_;
$C{$_}=$i;
++$i;
# print "\n" if ((($i) % 8) == 0);
}
$i=0;
#print "\n";
foreach (@PC2_D) {
$_-=28;
$_--;
# printf "%2d,",$_;
$D{$_}=$i;
$i++;
# print "\n" if ((($i) % 8) == 0);
}
#print "\n";
foreach $i (0 .. 27)
{
$_=$C{$i};
# printf "%2d,",$_;
$i++;
# print "\n" if ((($i) % 8) == 0);
}
#print "\n";
#print "\n";
foreach $i (0 .. 27)
{
$_=$D{$i};
# printf "%2d,",$_;
$i++;
# print "\n" if ((($i) % 8) == 0);
}
#print "\n";
print "static ulong skb[8][64]={\n";
&doit("C",*C, 0, 1, 2, 3, 4, 5);
&doit("C",*C, 6, 7, 9,10,11,12);
&doit("C",*C,13,14,15,16,18,19);
&doit("C",*C,20,22,23,25,26,27);
&doit("D",*D, 0, 1, 2, 3, 4, 5);
&doit("D",*D, 7, 8,10,11,12,13);
&doit("D",*D,15,16,17,18,19,20);
&doit("D",*D,21,22,23,24,26,27);
print "};\n";
sub doit
{
local($l,*A,@b)=@_;
local(@out);
printf("/* for $l bits (numbered as per FIPS 46) %d %d %d %d %d %d */\n",
$b[0]+1, $b[1]+1, $b[2]+1, $b[3]+1, $b[4]+1, $b[5]+1);
for ($i=0; $i<64; $i++)
{
$out[$i]=0;
$j=1;
#print "\n";
for ($k=0; $k<6; $k++)
{
$l=$A{$b[$k]};
#print"$l - ";
if ((1<<$k) & $i)
{
$ll=int($l/6)*8+($l%6);
$out[$i]|=1<<($ll);
}
}
$pp=$out[$i];
$pp=($pp&0xff0000ff)| (($pp&0x00ff0000)>>8)|
(($pp&0x0000ff00)<<8);
printf("0x%08X,",$pp);
print "\n" if (($i+1) % 4 == 0);
}
}

110
lib/des/ecb_enc.c Normal file
View File

@@ -0,0 +1,110 @@
/* ecb_enc.c */
/* Copyright (C) 1993 Eric Young - see README for more details */
#include "des_locl.h"
#include "spr.h"
int des_ecb_encrypt(des_cblock (*input), des_cblock (*output), struct des_ks_struct *ks, int encrypt)
{
register u_int32_t l0,l1;
register unsigned char *in,*out;
u_int32_t ll[2];
in=(unsigned char *)input;
out=(unsigned char *)output;
c2l(in,l0);
c2l(in,l1);
ll[0]=l0;
ll[1]=l1;
des_encrypt(ll,ll,ks,encrypt);
l0=ll[0];
l1=ll[1];
l2c(l0,out);
l2c(l1,out);
l0=l1=ll[0]=ll[1]=0;
return(0);
}
int des_encrypt(u_int32_t *input, u_int32_t *output, struct des_ks_struct *ks, int encrypt)
{
register u_int32_t l,r,t,u;
#ifdef ALT_ECB
register unsigned char *des_SP=(unsigned char *)des_SPtrans;
#endif
#ifdef MSDOS
union fudge {
u_int32_t l;
unsigned short s[2];
unsigned char c[4];
} U,T;
#endif
register int i;
register u_int32_t *s;
l=input[0];
r=input[1];
/* do IP */
PERM_OP(r,l,t, 4,0x0f0f0f0f);
PERM_OP(l,r,t,16,0x0000ffff);
PERM_OP(r,l,t, 2,0x33333333);
PERM_OP(l,r,t, 8,0x00ff00ff);
PERM_OP(r,l,t, 1,0x55555555);
/* r and l are reversed - remember that :-) - fix
* it in the next step */
/* Things have been modified so that the initial rotate is
* done outside the loop. This required the
* des_SPtrans values in sp.h to be rotated 1 bit to the right.
* One perl script later and things have a 5% speed up on a sparc2.
* Thanks to Richard Outerbridge <71755.204@CompuServe.COM>
* for pointing this out. */
t=(r<<1)|(r>>31);
r=(l<<1)|(l>>31);
l=t;
/* clear the top bits on machines with 8byte longs */
l&=0xffffffff;
r&=0xffffffff;
s=(u_int32_t *)ks;
/* I don't know if it is worth the effort of loop unrolling the
* inner loop */
if (encrypt)
{
for (i=0; i<32; i+=4)
{
D_ENCRYPT(l,r,i+0); /* 1 */
D_ENCRYPT(r,l,i+2); /* 2 */
}
}
else
{
for (i=30; i>0; i-=4)
{
D_ENCRYPT(l,r,i-0); /* 16 */
D_ENCRYPT(r,l,i-2); /* 15 */
}
}
l=(l>>1)|(l<<31);
r=(r>>1)|(r<<31);
/* clear the top bits on machines with 8byte longs */
l&=0xffffffff;
r&=0xffffffff;
/* swap l and r
* we will not do the swap so just remember they are
* reversed for the rest of the subroutine
* luckily FP fixes this problem :-) */
PERM_OP(r,l,t, 1,0x55555555);
PERM_OP(l,r,t, 8,0x00ff00ff);
PERM_OP(r,l,t, 2,0x33333333);
PERM_OP(l,r,t,16,0x0000ffff);
PERM_OP(r,l,t, 4,0x0f0f0f0f);
output[0]=l;
output[1]=r;
l=r=t=u=0;
return(0);
}

155
lib/des/enc_read.c Normal file
View File

@@ -0,0 +1,155 @@
/* enc_read.c */
/* Copyright (C) 1993 Eric Young - see README for more details */
#include <unistd.h>
#include <errno.h>
#include "des_locl.h"
/* This has some uglies in it but it works - even over sockets. */
extern int errno;
int des_rw_mode=DES_PCBC_MODE;
int des_enc_read(int fd, char *buf, int len, struct des_ks_struct *sched, des_cblock (*iv))
{
/* data to be unencrypted */
int net_num=0;
unsigned char net[BSIZE];
/* extra unencrypted data
* for when a block of 100 comes in but is des_read one byte at
* a time. */
static char unnet[BSIZE];
static int unnet_start=0;
static int unnet_left=0;
int i;
long num=0,rnum;
unsigned char *p;
/* left over data from last decrypt */
if (unnet_left != 0)
{
if (unnet_left < len)
{
/* we still still need more data but will return
* with the number of bytes we have - should always
* check the return value */
memcpy(buf,&(unnet[unnet_start]),unnet_left);
/* eay 26/08/92 I had the next 2 lines
* reversed :-( */
i=unnet_left;
unnet_start=unnet_left=0;
}
else
{
memcpy(buf,&(unnet[unnet_start]),len);
unnet_start+=len;
unnet_left-=len;
i=len;
}
return(i);
}
/* We need to get more data. */
if (len > MAXWRITE) len=MAXWRITE;
/* first - get the length */
net_num=0;
while (net_num < HDRSIZE)
{
i=read(fd,&(net[net_num]),HDRSIZE-net_num);
if ((i == -1) && (errno == EINTR)) continue;
if (i <= 0) return(0);
net_num+=i;
}
/* we now have at net_num bytes in net */
p=net;
num=0;
n2l(p,num);
/* num should be rounded up to the next group of eight
* we make sure that we have read a multiple of 8 bytes from the net.
*/
if ((num > MAXWRITE) || (num < 0)) /* error */
return(-1);
rnum=(num < 8)?8:((num+7)/8*8);
net_num=0;
while (net_num < rnum)
{
i=read(fd,&(net[net_num]),rnum-net_num);
if ((i == -1) && (errno == EINTR)) continue;
if (i <= 0) return(0);
net_num+=i;
}
/* Check if there will be data left over. */
if (len < num)
{
if (des_rw_mode & DES_PCBC_MODE)
des_pcbc_encrypt((des_cblock *)net,(des_cblock *)unnet,
num,sched,iv,DES_DECRYPT);
else
des_cbc_encrypt((des_cblock *)net,(des_cblock *)unnet,
num,sched,iv,DES_DECRYPT);
memcpy(buf,unnet,len);
unnet_start=len;
unnet_left=num-len;
/* The following line is done because we return num
* as the number of bytes read. */
num=len;
}
else
{
/* >output is a multiple of 8 byes, if len < rnum
* >we must be careful. The user must be aware that this
* >routine will write more bytes than he asked for.
* >The length of the buffer must be correct.
* FIXED - Should be ok now 18-9-90 - eay */
if (len < rnum)
{
char tmpbuf[BSIZE];
if (des_rw_mode & DES_PCBC_MODE)
des_pcbc_encrypt((des_cblock *)net,
(des_cblock *)tmpbuf,
num,sched,iv,DES_DECRYPT);
else
des_cbc_encrypt((des_cblock *)net,
(des_cblock *)tmpbuf,
num,sched,iv,DES_DECRYPT);
/* eay 26/08/92 fix a bug that returned more
* bytes than you asked for (returned len bytes :-( */
memcpy(buf,tmpbuf,num);
}
else if (num >= 8)
{
if (des_rw_mode & DES_PCBC_MODE)
des_pcbc_encrypt((des_cblock *)net,
(des_cblock *)buf,num,sched,iv,
DES_DECRYPT);
else
des_cbc_encrypt((des_cblock *)net,
(des_cblock *)buf,num,sched,iv,
DES_DECRYPT);
}
else
{
if (des_rw_mode & DES_PCBC_MODE)
des_pcbc_encrypt((des_cblock *)net,
(des_cblock *)buf,8,sched,iv,
DES_DECRYPT);
else
des_cbc_encrypt((des_cblock *)net,
(des_cblock *)buf,8,sched,iv,
DES_DECRYPT);
#ifdef LEFT_JUSTIFIED
memcpy(buf, buf, num);
#else
memcpy(buf, buf+(8-num), num);
#endif
}
}
return(num);
}

94
lib/des/enc_writ.c Normal file
View File

@@ -0,0 +1,94 @@
/* enc_writ.c */
/* Copyright (C) 1993 Eric Young - see README for more details */
#include <unistd.h>
#include <errno.h>
#include "des_locl.h"
int des_enc_write(int fd, char *buf, int len, struct des_ks_struct *sched, des_cblock (*iv))
{
long rnum;
int i,j,k,outnum;
char outbuf[BSIZE+HDRSIZE];
char shortbuf[8];
char *p;
static int start=1;
/* If we are sending less than 8 bytes, the same char will look
* the same if we don't pad it out with random bytes */
if (start)
{
start=0;
srand(time(NULL));
}
/* lets recurse if we want to send the data in small chunks */
if (len > MAXWRITE)
{
j=0;
for (i=0; i<len; i+=k)
{
k=des_enc_write(fd,&(buf[i]),
((len-i) > MAXWRITE)?MAXWRITE:(len-i),sched,iv);
if (k < 0)
return(k);
else
j+=k;
}
return(j);
}
/* write length first */
p=outbuf;
l2n(len,p);
/* pad short strings */
if (len < 8)
{
#ifdef LEFT_JUSTIFIED
p=shortbuf;
memcpy(shortbuf,buf,len);
for (i=len; i<8; i++)
shortbuf[i]=rand();
rnum=8;
#else
p=shortbuf;
for (i=0; i<8-len; i++)
shortbuf[i]=rand();
memcpy(shortbuf + 8 - len, buf, len);
rnum=8;
#endif
}
else
{
p=buf;
rnum=((len+7)/8*8); /* round up to nearest eight */
}
if (des_rw_mode & DES_PCBC_MODE)
des_pcbc_encrypt((des_cblock *)p,(des_cblock *)&(outbuf[HDRSIZE]),
(long)((len<8)?8:len),sched,iv,DES_ENCRYPT);
else
des_cbc_encrypt((des_cblock *)p,(des_cblock *)&(outbuf[HDRSIZE]),
(long)((len<8)?8:len),sched,iv,DES_ENCRYPT);
/* output */
outnum=rnum+HDRSIZE;
for (j=0; j<outnum; j+=i)
{
/* eay 26/08/92 I was not doing writing from where we
* got upto. */
i=write(fd,&(outbuf[j]),(int)(outnum-j));
if (i == -1)
{
if (errno == EINTR)
i=0;
else /* This is really a bad error - very bad
* It will stuff-up both ends. */
return(-1);
}
}
return(len);
}

Some files were not shown because too many files have changed in this diff Show More