Subject: 'popper' for 2.11BSD (#103) Index: local/popper 2.11BSD Description: A new program to be installed on the system. All known 'long' vs 'int' bugs have been fixed (there were a lot of them). Repeat-By: N/A Fix: Cut where indicated, unpack the shar file, cd /usr/src/local/popper, make all, make install. If you plan on offering POP service you will need to add (or uncomment) a line like the following to /etc/inetd.conf: pop stream tcp nowait root /usr/local/popper popper ===========================cut here================================= #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create: # /usr/src/local/popper # This archive created: Mon Jan 25 10:00:38 1993 export PATH; PATH=/bin:/usr/bin:$PATH if test ! -d '/usr/src/local/popper' then mkdir '/usr/src/local/popper' fi cd '/usr/src/local/popper' if test -f 'pop3.rfc1081' then echo shar: "will not over-write existing file 'pop3.rfc1081'" else sed 's/^X//' << \SHAR_EOF > 'pop3.rfc1081' X X X X X X XNetwork Working Group M. Rose XRequest for Comments: 1081 TWG X November 1988 X X Post Office Protocol - Version 3 X X XStatus of this Memo X X This memo suggests a simple method for workstations to dynamically X access mail from a mailbox server. This RFC specifies a proposed X protocol for the Internet community, and requests discussion and X suggestions for improvements. Distribution of this memo is X unlimited. X X This memo is based on RFC 918 (since revised as RFC 937). Although X similar in form to the original Post Office Protocol (POP) proposed X for the Internet community, the protocol discussed in this memo is X similar in spirit to the ideas investigated by the MZnet project at X the University of California, Irvine. X X Further, substantial work was done on examining POP in a PC-based X environment. This work, which resulted in additional functionality X in this protocol, was performed by the ACIS Networking Systems Group X at Stanford University. The author gratefully acknowledges their X interest. X XIntroduction X X On certain types of smaller nodes in the Internet it is often X impractical to maintain a message transport system (MTS). For X example, a workstation may not have sufficient resources (cycles, X disk space) in order to permit a SMTP server and associated local X mail delivery system to be kept resident and continuously running. X Similarly, it may be expensive (or impossible) to keep a personal X computer interconnected to an IP-style network for long amounts of X time (the node is lacking the resource known as "connectivity"). X X Despite this, it is often very useful to be able to manage mail on X these smaller nodes, and they often support a user agent (UA) to aid X the tasks of mail handling. To solve this problem, a node which can X support an MTS entity offers a maildrop service to these less endowed X nodes. The Post Office Protocol - Version 3 (POP3) is intended to X permit a workstation to dynamically access a maildrop on a server X host in a useful fashion. Usually, this means that the POP3 is used X to allow a workstation to retrieve mail that the server is holding X for it. X X X X XRose [Page 1] X XRFC 1081 POP3 November 1988 X X X For the remainder of this memo, the term "client host" refers to a X host making use of the POP3 service, while the term "server host" X refers to a host which offers the POP3 service. X XA Short Digression X X This memo does not specify how a client host enters mail into the X transport system, although a method consistent with the philosophy of X this memo is presented here: X X When the user agent on a client host wishes to enter a message X into the transport system, it establishes an SMTP connection to X its relay host (this relay host could be, but need not be, the X POP3 server host for the client host). X X If this method is followed, then the client host appears to the MTS X as a user agent, and should NOT be regarded as a "trusted" MTS entity X in any sense whatsoever. This concept, along with the role of the X POP3 as a part of a split-UA model is discussed later in this memo. X X Initially, the server host starts the POP3 service by listening on X TCP port 110. When a client host wishes to make use of the service, X it establishes a TCP connection with the server host. When the X connection is established, the POP3 server sends a greeting. The X client and POP3 server then exchange commands and responses X (respectively) until the connection is closed or aborted. X X Commands in the POP3 consist of a keyword possibly followed by an X argument. All commands are terminated by a CRLF pair. X X Responses in the POP3 consist of a success indicator and a keyword X possibly followed by additional information. All responses are X terminated by a CRLF pair. There are currently two success X indicators: positive ("+OK") and negative ("-ERR"). X X Responses to certain commands are multi-line. In these cases, which X are clearly indicated below, after sending the first line of the X response and a CRLF, any additional lines are sent, each terminated X by a CRLF pair. When all lines of the response have been sent, a X final line is sent, consisting of a termination octet (decimal code X 046, ".") and a CRLF pair. If any line of the multi-line response X begins with the termination octet, the line is "byte-stuffed" by X pre-pending the termination octet to that line of the response. X Hence a multi-line response is terminated with the five octets X "CRLF.CRLF". When examining a multi-line response, the client checks X to see if the line begins with the termination octet. If so and if X octets other than CRLF follow, the the first octet of the line (the X termination octet) is stripped away. If so and if CRLF immediately X X X XRose [Page 2] X XRFC 1081 POP3 November 1988 X X X follows the termination character, then the response from the POP X server is ended and the line containing ".CRLF" is not considered X part of the multi-line response. X X A POP3 session progresses through a number of states during its X lifetime. Once the TCP connection has been opened and the POP3 X server has sent the greeting, the session enters the AUTHORIZATION X state. In this state, the client must identify itself to the POP3 X server. Once the client has successfully done this, the server X acquires resources associated with the client's maildrop, and the X session enters the TRANSACTION state. In this state, the client X requests actions on the part of the POP3 server. When the client has X finished its transactions, the session enters the UPDATE state. In X this state, the POP3 server releases any resources acquired during X the TRANSACTION state and says goodbye. The TCP connection is then X closed. X XThe AUTHORIZATION State X X Once the TCP connection has been opened by a POP3 client, the POP3 X server issues a one line greeting. This can be any string terminated X by CRLF. An example might be: X X S. +OK dewey POP3 server ready (Comments to: PostMaster@UDEL.EDU) X X Note that this greeting is a POP3 reply. The POP3 server should X always give a positive response as the greeting. X X The POP3 session is now in the AUTHORIZATION state. The client must X now issue the USER command. If the POP3 server responds with a X positive success indicator ("+OK"), then the client may issue either X the PASS command to complete the authorization, or the QUIT command X to terminate the POP3 session. If the POP3 server responds with a X negative success indicator ("-ERR") to the USER command, then the X client may either issue a new USER command or may issue the QUIT X command. X X When the client issues the PASS command, the POP3 server uses the X argument pair from the USER and PASS commands to determine if the X client should be given access to the appropriate maildrop. If so, X the POP3 server then acquires an exclusive-access lock on the X maildrop. If the lock is successfully acquired, the POP3 server X parses the maildrop into individual messages (read note below), X determines the last message (if any) present in the maildrop that was X referenced by the RETR command, and responds with a positive success X indicator. The POP3 session now enters the TRANSACTION state. If X the lock can not be acquired or the client should is denied access to X the appropriate maildrop or the maildrop can't be parsed for some X X X XRose [Page 3] X XRFC 1081 POP3 November 1988 X X X reason, the POP3 server responds with a negative success indicator. X (If a lock was acquired but the POP3 server intends to respond with a X negative success indicator, the POP3 server must release the lock X prior to rejecting the command.) At this point, the client may X either issue a new USER command and start again, or the client may X issue the QUIT command. X X NOTE: Minimal implementations of the POP3 need only be X able to break a maildrop into its component messages; X they need NOT be able to parse individual messages. X More advanced implementations may wish to have this X capability, for reasons discussed later. X X After the POP3 server has parsed the maildrop into individual X messages, it assigns a message-id to each message, and notes the size X of the message in octets. The first message in the maildrop is X assigned a message-id of "1", the second is assigned "2", and so on, X so that the n'th message in a maildrop is assigned a message-id of X "n". In POP3 commands and responses, all message-id's and message X sizes are expressed in base-10 (i.e., decimal). X X It sets the "highest number accessed" to be that of the last message X referenced by the RETR command. X X Here are summaries for the three POP3 commands discussed thus far: X X USER name X Arguments: a server specific user-id (required) X Restrictions: may only be given in the AUTHORIZATION X state after the POP3 greeting or after an X unsuccessful USER or PASS command X Possible Responses: X +OK name is welcome here X -ERR never heard of name X Examples: X C: USER mrose X S: +OK mrose is a real hoopy frood X ... X C: USER frated X S: -ERR sorry, frated doesn't get his mail here X X PASS string X Arguments: a server/user-id specific password (required) X Restrictions: may only be given in the AUTHORIZATION X state after a successful USER command X Possible Responses: X +OK maildrop locked and ready X -ERR invalid password X X X XRose [Page 4] X XRFC 1081 POP3 November 1988 X X X -ERR unable to lock maildrop X Examples: X C: USER mrose X S: +OK mrose is a real hoopy frood X C: PASS secret X S: +OK mrose's maildrop has 2 messages X (320 octets) X ... X C: USER mrose X S: +OK mrose is a real hoopy frood X C: PASS secret X S: -ERR unable to lock mrose's maildrop, file X already locked X X QUIT X Arguments: none X Restrictions: none X Possible Responses: X +OK X Examples: X C: QUIT X S: +OK dewey POP3 server signing off X X XThe TRANSACTION State X X Once the client has successfully identified itself to the POP3 server X and the POP3 server has locked and burst the appropriate maildrop, X the POP3 session is now in the TRANSACTION state. The client may now X issue any of the following POP3 commands repeatedly. After each X command, the POP3 server issues a response. Eventually, the client X issues the QUIT command and the POP3 session enters the UPDATE state. X X Here are the POP3 commands valid in the TRANSACTION state: X X STAT X Arguments: none X Restrictions: may only be given in the TRANSACTION state. X Discussion: X X The POP3 server issues a positive response with a line X containing information for the maildrop. This line is X called a "drop listing" for that maildrop. X X In order to simplify parsing, all POP3 servers are X required to use a certain format for drop listings. X The first octets present must indicate the number of X messages in the maildrop. Following this is the size X X X XRose [Page 5] X XRFC 1081 POP3 November 1988 X X X of the maildrop in octets. This memo makes no X requirement on what follows the maildrop size. X Minimal implementations should just end that line of X the response with a CRLF pair. More advanced X implementations may include other information. X X NOTE: This memo STRONGLY discourages X implementations from supplying additional X information in the drop listing. Other, X optional, facilities are discussed later on X which permit the client to parse the messages X in the maildrop. X X Note that messages marked as deleted are not counted in X either total. X X Possible Responses: X +OK nn mm X Examples: X C: STAT X S: +OK 2 320 X X LIST [msg] X Arguments: a message-id (optionally) If a message-id is X given, it may NOT refer to a message marked as X deleted. X Restrictions: may only be given in the TRANSACTION state. X Discussion: X X If an argument was given and the POP3 server issues a X positive response with a line containing information X for that message. This line is called a "scan listing" X for that message. X X If no argument was given and the POP3 server issues a X positive response, then the response given is X multi-line. After the initial +OK, for each message X in the maildrop, the POP3 server responds with a line X containing information for that message. This line X is called a "scan listing" for that message. X X In order to simplify parsing, all POP3 servers are X required to use a certain format for scan listings. X The first octets present must be the message-id of X the message. Following the message-id is the size of X the message in octets. This memo makes no requirement X on what follows the message size in the scan listing. X Minimal implementations should just end that line of X X X XRose [Page 6] X XRFC 1081 POP3 November 1988 X X X the response with a CRLF pair. More advanced X implementations may include other information, as X parsed from the message. X X NOTE: This memo STRONGLY discourages X implementations from supplying additional X information in the scan listing. Other, optional, X facilities are discussed later on which permit X the client to parse the messages in the maildrop. X X Note that messages marked as deleted are not listed. X X Possible Responses: X +OK scan listing follows X -ERR no such message X Examples: X C: LIST X S: +OK 2 messages (320 octets) X S: 1 120 X S: 2 200 X S: . X ... X C: LIST 2 X S: +OK 2 200 X ... X C: LIST 3 X S: -ERR no such message, only 2 messages in X maildrop X X RETR msg X Arguments: a message-id (required) This message-id may X NOT refer to a message marked as deleted. X Restrictions: may only be given in the TRANSACTION state. X Discussion: X X If the POP3 server issues a positive response, then the X response given is multi-line. After the initial +OK, X the POP3 server sends the message corresponding to the X given message-id, being careful to byte-stuff the X termination character (as with all multi-line X responses). X X If the number associated with this message is higher X than the "highest number accessed" in the maildrop, the X POP3 server updates the "highest number accessed" to X the number associated with this message. X X X X X XRose [Page 7] X XRFC 1081 POP3 November 1988 X X X Possible Responses: X +OK message follows X -ERR no such message X Examples: X C: RETR 1 X S: +OK 120 octets X S: X S: . X X DELE msg X Arguments: a message-id (required) This message-id X may NOT refer to a message marked as deleted. X Restrictions: may only be given in the TRANSACTION state. X Discussion: X X The POP3 server marks the message as deleted. Any X future reference to the message-id associated with the X message in a POP3 command generates an error. The POP3 X server does not actually delete the message until the X POP3 session enters the UPDATE state. X X If the number associated with this message is higher X than the "highest number accessed" in the maildrop, X the POP3 server updates the "highest number accessed" X to the number associated with this message. X X Possible Responses: X +OK message deleted X -ERR no such message X Examples: X C: DELE 1 X S: +OK message 1 deleted X ... X C: DELE 2 X S: -ERR message 2 already deleted X X NOOP X Arguments: none X Restrictions: may only be given in the TRANSACTION state. X Discussion: X X The POP3 server does nothing, it merely replies with a X positive response. X X Possible Responses: X +OK X X X X X XRose [Page 8] X XRFC 1081 POP3 November 1988 X X X Examples: X C: NOOP X S: +OK X X LAST X Arguments: none X Restrictions: may only be issued in the TRANSACTION state. X Discussion: X X The POP3 server issues a positive response with a line X containing the highest message number which accessed. X Zero is returned in case no message in the maildrop has X been accessed during previous transactions. A client X may thereafter infer that messages, if any, numbered X greater than the response to the LAST command are X messages not yet accessed by the client. X X Possible Response: X +OK nn X X Examples: X C: STAT X S: +OK 4 320 X C: LAST X S: +OK 1 X C: RETR 3 X S: +OK 120 octets X S: X S: . X C: LAST X S: +OK 3 X C: DELE 2 X S: +OK message 2 deleted X C: LAST X S: +OK 3 X C: RSET X S: +OK X C: LAST X S: +OK 1 X X RSET X Arguments: none X Restrictions: may only be given in the TRANSACTION X state. X Discussion: X X If any messages have been marked as deleted by the POP3 X X X XRose [Page 9] X XRFC 1081 POP3 November 1988 X X X server, they are unmarked. The POP3 server then X replies with a positive response. In addition, the X "highest number accessed" is also reset to the value X determined at the beginning of the POP3 session. X X Possible Responses: X +OK X Examples: X C: RSET X S: +OK maildrop has 2 messages (320 octets) X X X XThe UPDATE State X X When the client issues the QUIT command from the TRANSACTION state, X the POP3 session enters the UPDATE state. (Note that if the client X issues the QUIT command from the AUTHORIZATION state, the POP3 X session terminates but does NOT enter the UPDATE state.) X X QUIT X Arguments: none X Restrictions: none X Discussion: X X The POP3 server removes all messages marked as deleted X from the maildrop. It then releases the X exclusive-access lock on the maildrop and replies as X to the success of X these operations. The TCP connection is then closed. X X Possible Responses: X +OK X Examples: X C: QUIT X S: +OK dewey POP3 server signing off (maildrop X empty) X ... X C: QUIT X S: +OK dewey POP3 server signing off (2 messages X left) X ... X X XOptional POP3 Commands X X The POP3 commands discussed above must be supported by all minimal X implementations of POP3 servers. X X X XRose [Page 10] X XRFC 1081 POP3 November 1988 X X X The optional POP3 commands described below permit a POP3 client X greater freedom in message handling, while preserving a simple POP3 X server implementation. X X NOTE: This memo STRONGLY encourages implementations to X support these commands in lieu of developing augmented X drop and scan listings. In short, the philosophy of X this memo is to put intelligence in the part of the X POP3 client and not the POP3 server. X X TOP msg n X Arguments: a message-id (required) and a number. This X message-id may NOT refer to a message marked as X deleted. X Restrictions: may only be given in the TRANSACTION state. X Discussion: X X If the POP3 server issues a positive response, then X the response given is multi-line. After the initial X +OK, the POP3 server sends the headers of the message, X the blank line separating the headers from the body, X and then the number of lines indicated message's body, X being careful to byte-stuff the termination character X (as with all multi-line responses). X X Note that if the number of lines requested by the POP3 X client is greater than than the number of lines in the X body, then the POP3 server sends the entire message. X X Possible Responses: X +OK top of message follows X -ERR no such message X Examples: X C: TOP 10 X S: +OK X S: X S: . X ... X C: TOP 100 X S: -ERR no such message X X RPOP user X Arguments: a client specific user-id (required) X Restrictions: may only be given in the AUTHORIZATION X state after a successful USER command; in addition, X may only be given if the client used a reserved X X X XRose [Page 11] X XRFC 1081 POP3 November 1988 X X X (privileged) TCP port to connect to the server. X Discussion: X X The RPOP command may be used instead of the PASS X command to authenticate access to the maildrop. In X order for this command to be successful, the POP3 X client must use a reserved TCP port (port < 1024) to X connect tothe server. The POP3 server uses the X argument pair from the USER and RPOP commands to X determine if the client should be given access to X the appropriate maildrop. Unlike the PASS command X however, the POP3 server considers if the remote user X specified by the RPOP command who resides on the POP3 X client host is allowed to access the maildrop for the X user specified by the USER command (e.g., on Berkeley X UNIX, the .rhosts mechanism is used). With the X exception of this differing in authentication, this X command is identical to the PASS command. X X Note that the use of this feature has allowed much wider X penetration into numerous hosts on local networks (and X sometimes remote networks) by those who gain illegal X access to computers by guessing passwords or otherwise X breaking into the system. X X Possible Responses: X +OK maildrop locked and ready X -ERR permission denied X Examples: X C: USER mrose X S: +OK mrose is a real hoopy frood X C: RPOP mrose X S: +OK mrose's maildrop has 2 messages (320 X octets) X X Minimal POP3 Commands: X USER name valid in the AUTHORIZATION state X PASS string X QUIT X X STAT valid in the TRANSACTION state X LIST [msg] X RETR msg X DELE msg X NOOP X LAST X RSET X X X X XRose [Page 12] X XRFC 1081 POP3 November 1988 X X X QUIT valid in the UPDATE state X X Optional POP3 Commands: X RPOP user valid in the AUTHORIZATION state X X TOP msg n valid in the TRANSACTION state X X POP3 Replies: X +OK X -ERR X X Note that with the exception of the STAT command, the reply given X by the POP3 server to any command is significant only to "+OK" X and "-ERR". Any text occurring after this reply may be ignored X by the client. X XExample POP3 Session X X S: X ... X C: X S: +OK dewey POP3 server ready (Comments to: PostMaster@UDEL.EDU) X C: USER mrose X S: +OK mrose is a real hoopy frood X C: PASS secret X S: +OK mrose's maildrop has 2 messages (320 octets) X C: STAT X S: +OK 2 320 X C: LIST X S: +OK 2 messages (320 octets) X S: 1 120 X S: 2 200 X S: . X C: RETR 1 X S: +OK 120 octets X S: X S: . X C: DELE 1 X S: +OK message 1 deleted X C: RETR 2 X S: +OK 200 octets X S: X S: . X C: DELE 2 X S: +OK message 2 deleted X C: QUIT X X X X X XRose [Page 13] X XRFC 1081 POP3 November 1988 X X X S: +OK dewey POP3 server signing off (maildrop empty) X C: X S: X XMessage Format X X All messages transmitted during a POP3 session are assumed to conform X to the standard for the format of Internet text messages [RFC822]. X X It is important to note that the byte count for a message on the X server host may differ from the octet count assigned to that message X due to local conventions for designating end-of-line. Usually, X during the AUTHORIZATION state of the POP3 session, the POP3 client X can calculate the size of each message in octets when it parses the X maildrop into messages. For example, if the POP3 server host X internally represents end-of-line as a single character, then the X POP3 server simply counts each occurrence of this character in a X message as two octets. Note that lines in the message which start X with the termination octet need not be counted twice, since the POP3 X client will remove all byte-stuffed termination characters when it X receives a multi-line response. X XThe POP and the Split-UA model X X The underlying paradigm in which the POP3 functions is that of a X split-UA model. The POP3 client host, being a remote PC based X workstation, acts solely as a client to the message transport system. X It does not provide delivery/authentication services to others. X Hence, it is acting as a UA, on behalf of the person using the X workstation. Furthermore, the workstation uses SMTP to enter mail X into the MTS. X X In this sense, we have two UA functions which interface to the X message transport system: Posting (SMTP) and Retrieval (POP3). The X entity which supports this type of environment is called a split-UA X (since the user agent is split between two hosts which must X interoperate to provide these functions). X X ASIDE: Others might term this a remote-UA instead. X There are arguments supporting the use of both terms. X X This memo has explicitly referenced TCP as the underlying transport X agent for the POP3. This need not be the case. In the MZnet split- X UA, for example, personal micro-computer systems are used which do X not have IP-style networking capability. To connect to the POP3 X server host, a PC establishes a terminal connection using some simple X protocol (PhoneNet). A program on the PC drives the connection, X first establishing a login session as a normal user. The login shell X X X XRose [Page 14] X XRFC 1081 POP3 November 1988 X X X for this pseudo-user is a program which drives the other half of the X terminal protocol and communicates with one of two servers. Although X MZnet can support several PCs, a single pseudo-user login is present X on the server host. The user-id and password for this pseudo-user X login is known to all members of MZnet. Hence, the first action of X the login shell, after starting the terminal protocol, is to demand a X USER/PASS authorization pair from the PC. This second level of X authorization is used to ascertain who is interacting with the MTS. X Although the server host is deemed to support a "trusted" MTS entity, X PCs in MZnet are not. Naturally, the USER/PASS authorization pair X for a PC is known only to the owner of the PC (in theory, at least). X X After successfully verifying the identity of the client, a modified X SMTP server is started, and the PC posts mail with the server host. X After the QUIT command is given to the SMTP server and it terminates, X a modified POP3 server is started, and the PC retrieves mail from the X server host. After the QUIT command is given to the POP3 server and X it terminates, the login shell for the pseudo-user terminates the X terminal protocol and logs the job out. The PC then closes the X terminal connection to the server host. X X The SMTP server used by MZnet is modified in the sense that it knows X that it's talking to a user agent and not a "trusted" entity in the X message transport system. Hence, it does performs the validation X activities normally performed by an entity in the MTS when it accepts X a message from a UA. X X The POP3 server used by MZnet is modified in the sense that it does X not require a USER/PASS combination before entering the TRANSACTION X state. The reason for this (of course) is that the PC has already X identified itself during the second-level authorization step X described above. X X NOTE: Truth in advertising laws require that the author X of this memo state that MZnet has not actually been X fully implemented. The concepts presented and proven X by the project led to the notion of the MZnet X split-slot model. This notion has inspired the X split-UA concept described in this memo, led to the X author's interest in the POP, and heavily influenced X the the description of the POP3 herein. X X In fact, some UAs present in the Internet already support the notion X of posting directly to an SMTP server and retrieving mail directly X from a POP server, even if the POP server and client resided on the X same host! X X ASIDE: this discussion raises an issue which this memo X X X XRose [Page 15] X XRFC 1081 POP3 November 1988 X X X purposedly avoids: how does SMTP know that it's talking X to a "trusted" MTS entity? X XReferences X X [MZnet] Stefferud, E., J. Sweet, and T. Domae, "MZnet: Mail X Service for Personal Micro-Computer Systems", X Proceedings, IFIP 6.5 International Conference on X Computer Message Systems, Nottingham, U.K., May 1984. X X [RFC821] Postel, J., "Simple Mail Transfer Protocol", X USC/Information Sciences Institute, August 1982. X X [RFC822] Crocker, D., "Standard for the Format of ARPA-Internet X Text Messages", University of Delaware, August 1982. X X [RFC937] Butler, M., J. Postel, D. Chase, J. Goldberger, and J. X Reynolds, "Post Office Protocol - Version 2", RFC 937, X USC/Information Sciences Institute, February 1985. X X [RFC1010] Reynolds, J., and J. Postel, "Assigned Numbers", RFC X 1010, USC/Information Sciences Institute, May 1987. X XAuthor's Address: X X X Marshall Rose X The Wollongong Group X 1129 San Antonio Rd. X Palo Alto, California 94303 X X Phone: (415) 962-7100 X X Email: MRose@TWG.COM X X X X X X X X X X X X X X X X X XRose [Page 16] SHAR_EOF fi if test -f 'pop3e.rfc1082' then echo shar: "will not over-write existing file 'pop3e.rfc1082'" else sed 's/^X//' << \SHAR_EOF > 'pop3e.rfc1082' X X X X X X XNetwork Working Group M. Rose XRequest for Comments: 1082 TWG X November 1988 X X X X Post Office Protocol - Version 3 X Extended Service Offerings X XStatus of This Memo X X This memo suggests a simple method for workstations to dynamically X access mail from a discussion group server, as an extension to an X earlier memo which dealt with dynamically accessing mail from a X mailbox server using the Post Office Protocol - Version 3 (POP3). X This RFC specifies a proposed protocol for the Internet community, X and requests discussion and suggestions for improvements. All of the X extensions described in this memo to the POP3 are OPTIONAL. X Distribution of this memo is unlimited. X XIntroduction and Motivation X X It is assumed that the reader is familiar with RFC 1081 that X discusses the Post Office Protocol - Version 3 (POP3) [RFC1081]. X This memo describes extensions to the POP3 which enhance the service X it offers to clients. This additional service permits a client host X to access discussion group mail, which is often kept in a separate X spool area, using the general POP3 facilities. X X The next section describes the evolution of discussion groups and the X technologies currently used to implement them. To summarize: X X o An exploder is used to map from a single address to X a list of addresses which subscribe to the list, and redirects X any subsequent error reports associated with the delivery of X each message. This has two primary advantages: X - Subscribers need know only a single address X - Responsible parties get the error reports and not X the subscribers X X X X X X X X X X X X XRose [Page 1] X XRFC 1082 POP3 Extended Service November 1988 X X X o Typically, each subscription address is not a person's private X maildrop, but a system-wide maildrop, which can be accessed X by more than one user. This has several advantages: X - Only a single copy of each message need traverse the X net for a given site (which may contain several local X hosts). This conserves bandwidth and cycles. X - Only a single copy of each message need reside on each X subscribing host. This conserves disk space. X - The private maildrop for each user is not cluttered X with discussion group mail. X X Despite this optimization of resources, further economy can be X achieved at sites with more than one host. Typically, sites with X more than one host either: X X 1. Replicate discussion group mail on each host. This X results in literally gigabytes of disk space committed to X unnecessarily store redundant information. X X 2. Keep discussion group mail on one host and give all users a X login on that host (in addition to any other logins they may X have). This is usually a gross inconvenience for users who X work on other hosts, or a burden to users who are forced to X work on that host. X X As discussed in [RFC1081], the problem of giving workstations dynamic X access to mail from a mailbox server has been explored in great X detail (originally there was [RFC918], this prompted the author to X write [RFC1081], independently of this [RFC918] was upgraded to X [RFC937]). A natural solution to the problem outlined above is to X keep discussion group mail on a mailbox server at each site and X permit different hosts at that site to employ the POP3 to access X discussion group mail. If implemented properly, this avoids the X problems of both strategies outlined above. X X ASIDE: It might be noted that a good distributed filesystem X could also solve this problem. Sadly, "good" X distributed filesystems, which do not suffer X unacceptable response time for interactive use, are X few and far between these days! X X Given this motivation, now let's consider discussion groups, both in X general and from the point of view of a user agent. Following this, X extensions to the POP3 defined in [RFC1081] are presented. Finally, X some additional policy details are discussed along with some initial X experiences. X X X X X XRose [Page 2] X XRFC 1082 POP3 Extended Service November 1988 X X XWhat's in a Discussion Group X X Since mailers and user agents first crawled out of the primordial X ARPAnet, the value of discussion groups have been appreciated, X (though their implementation has not always been well-understood). X X Described simply, a discussion group is composed of a number of X subscribers with a common interest. These subscribers post mail to a X single address, known as a distribution address. From this X distribution address, a copy of the message is sent to each X subscriber. Each group has a moderator, which is the person that X administrates the group. The moderator can usually be reached at a X special address, known as a request address. Usually, the X responsibilities of the moderator are quite simple, since the mail X system handles the distribution to subscribers automatically. In X some cases, the interest group, instead of being distributed directly X to its subscribers, is put into a digest format by the moderator and X then sent to the subscribers. Although this requires more work on X the part of the moderator, such groups tend to be better organized. X X Unfortunately, there are a few problems with the scheme outlined X above. First, if two users on the same host subscribe to the same X interest group, two copies of the message get delivered. This is X wasteful of both processor and disk resources. X X Second, some of these groups carry a lot of traffic. Although X subscription to an group does indicate interest on the part of a X subscriber, it is usually not interesting to get 50 messages or so X delivered to the user's private maildrop each day, interspersed with X personal mail, that is likely to be of a much more important and X timely nature. X X Third, if a subscriber on the distribution list for a group becomes X "bad" somehow, the originator of the message and not the moderator of X the group is notified. It is not uncommon for a large list to have X 10 or so bogus addresses present. This results in the originator X being flooded with "error messages" from mailers across the Internet X stating that a given address on the list was bad. Needless to say, X the originator usually could not care less if the bogus addresses got X a copy of the message or not. The originator is merely interested in X posting a message to the group at large. Furthermore, the moderator X of the group does care if there are bogus addresses on the list, but X ironically does not receive notification. X X There are various approaches which can be used to solve some or all X of these problems. Usually these involve placing an exploder agent X at the distribution source of the discussion group, which expands the X name of the group into the list of subscription addresses for the X X X XRose [Page 3] X XRFC 1082 POP3 Extended Service November 1988 X X X group. In the process, the exploder will also change the address X that receives error notifications to be the request address or other X responsible party. X X A complementary approach, used in order to cut down on resource X utilization of all kinds, replaces all the subscribers at a single X host (or group of hosts under a single administration) with a single X address at that host. This address maps to a file on the host, X usually in a spool area, which all users can access. (Advanced X implementations can also implement private discussion groups this X way, in which a single copy of each message is kept, but is X accessible to only a select number of users on the host.) X X The two approaches can be combined to avoid all of the problems X described above. X X Finally, a third approach can be taken, which can be used to aid user X agents processing mail for the discussion group: In order to speed X querying of the maildrop which contains the local host's copy of the X discussion group, two other items are usually associated with the X discussion group, on a local basis. These are the maxima and the X last-date. Each time a message is received for the group on the X local host, the maxima is increased by at least one. Furthermore, X when a new maxima is generated, the current date is determined. This X is called the last date. As the message is entered into the local X maildrop, it is given the current maxima and last-date. This permits X the user agent to quickly determine if new messages are present in X the maildrop. X X NOTE: The maxima may be characterized as a monotonically X increasing quanity. Although sucessive values of the X maxima need not be consecutive, any maxima assigned X is always greater than any previously assigned value. X XDefinition of Terms X X To formalize these notions somewhat, consider the following 7 X parameters which describe a given discussion group from the X perspective of the user agent (the syntax given is from [RFC822]): X X X X X X X X X X X X XRose [Page 4] X XRFC 1082 POP3 Extended Service November 1988 X X X NAME Meaning: the name of the discussion group X Syntax: TOKEN (ALPHA *[ ALPHA / DIGIT / "-" ]) X (case-insensitive recognition) X Example: unix-wizards X X ALIASES Meaning: alternates names for the group, which X are locally meaningful; these are X typically used to shorten user typein X Syntax: TOKEN (case-insensitive recognition) X Example: uwiz X X ADDRESS Meaning: the primary source of the group X Syntax: 822 address X Example: Unix-Wizards@BRL.MIL X X REQUEST Meaning: the primary moderator of the group X Syntax: 822 address X Example: Unix-Wizards-Request@BRL.MIL X X FLAGS Meaning: locally meaningful flags associated X with the discussion group; this memo X leaves interpretation of this X parameter to each POP3 implementation X Syntax: octal number X Example: 01 X X MAXIMA Meaning: the magic cookie associated with the X last message locally received for the X group; it is the property of the magic X cookie that it's value NEVER X decreases, and increases by at least X one each time a message is locally X received X Syntax: decimal number X Example: 1004 X X LASTDATE Meaning: the date that the last message was X locally received X Syntax: 822 date X Example: Thu, 19 Dec 85 10:26:48 -0800 X X Note that the last two values are locally determined for the maildrop X associated with the discussion group and with each message in that X maildrop. Note however that the last message in the maildrop have a X different MAXIMA and LASTDATE than the discussion group. This often X occurs when the maildrop has been archived. X X X X X XRose [Page 5] X XRFC 1082 POP3 Extended Service November 1988 X X X Finally, some local systems provide mechanisms for automatically X archiving discussion group mail. In some cases, a two-level archive X scheme is used: current mail is kept in the standard maildrop, X recent mail is kept in an archive maildrop, and older mail is kept X off-line. With this scheme, in addition to having a "standard" X maildrop for each discussion group, an "archive" maildrop may also be X available. This permits a user agent to examine the most recent X archive using the same mechanisms as those used on the current mail. X XThe XTND Command X X The following commands are valid only in the TRANSACTION state of the X POP3. This implies that the POP3 server has already opened the X user's maildrop (which may be empty). This maildrop is called the X "default maildrop". The phrase "closes the current maildrop" has two X meanings, depending on whether the current maildrop is the default X maildrop or is a maildrop associated with a discussion group. X X In the former context, when the current maildrop is closed any X messages marked as deleted are removed from the maildrop currently in X use. The exclusive-access lock on the maildrop is then released X along with any implementation-specific resources (e.g., file- X descriptors). X X In the latter context, a maildrop associated with a discussion group X is considered to be read-only to the POP3 client. In this case, the X phrase "closes the current maildrop" merely means that any X implementation-specific resources are released. (Hence, the POP3 X command DELE is a no-op.) X X All the new facilities are introduced via a single POP3 command, X XTND. All positive reponses to the XTND command are multi-line. X X The most common multi-line response to the commands contains a X "discussion group listing" which presents the name of the discussion X group along with it's maxima. In order to simplify parsing all POP3 X servers are required to use a certain format for discussion group X listings: X X NAME SP MAXIMA X X This memo makes no requirement on what follows the maxima in the X listing. Minimal implementations should just end that line of the X response with a CRLF pair. More advanced implementations may include X other information, as parsed from the message. X X NOTE: This memo STRONGLY discourages implementations from X supplying additional information in the listing. X X X XRose [Page 6] X XRFC 1082 POP3 Extended Service November 1988 X X X XTND BBOARDS [name] X Arguments: the name of a discussion group (optionally) X Restrictions: may only be given in the TRANSACTION state. X Discussion: X X If an argument was given, the POP3 server closes the current X maildrop. The POP3 server then validates the argument as the name of X a discussion group. If this is successful, it opens the maildrop X associated with the group, and returns a multi-line response X containing the discussion group listing. If the discussion group X named is not valid, or the associated archive maildrop is not X readable by the user, then an error response is returned. X X If no argument was given, the POP3 server issues a multi-line X response. After the initial +OK, for each discussion group known, X the POP3 server responds with a line containing the listing for that X discussion group. Note that only world-readable discussion groups X are included in the multi-line response. X X In order to aid user agents, this memo requires an extension to the X scan listing when an "XTND BBOARDS" command has been given. X Normally, a scan listing, as generated by the LIST, takes the form: X X MSGNO SIZE X X where MSGNO is the number of the message being listed and SIZE is the X size of the message in octets. When reading a maildrop accessed via X "XTND BBOARDS", the scan listing takes the form X X MSGNO SIZE MAXIMA X X where MAXIMA is the maxima that was assigned to the message when it X was placed in the BBoard. X X Possible Responses: X +OK XTND X -ERR no such bboard X Examples: X C: XTND BBOARDS X S: +OK XTND X S: system 10 X S: mh-users 100 X S: . X C: XTND BBOARDS system X S: + OK XTND X S: system 10 X S: . X X X X XRose [Page 7] X XRFC 1082 POP3 Extended Service November 1988 X X X XTND ARCHIVE name X Arguments: the name of a discussion group (required) X Restrictions: may only be given in the TRANSACTION state. X Discussion: X X The POP3 server closes the current maildrop. The POP3 server then X validates the argument as the name of a discussion group. If this is X successful, it opens the archive maildrop associated with the group, X and returns a multi-line response containing the discussion group X listing. If the discussion group named is not valid, or the X associated archive maildrop is not readable by the user, then an X error response is returned. X X In addition, the scan listing generated by the LIST command is X augmented (as described above). X X Possible Responses: X +OK XTND X -ERR no such bboard Examples: X C: XTND ARCHIVE system X S: + OK XTND X S: system 3 X S: . X X XTND X-BBOARDS name X Arguments: the name of a discussion group (required) X Restrictions: may only be given in the TRANSACTION state. X Discussion: X X The POP3 server validates the argument as the name of a X discussion group. If this is unsuccessful, then an error X response is returned. Otherwise a multi-line response is X returned. The first 14 lines of this response (after the X initial +OK) are defined in this memo. Minimal implementations X need not include other information (and may omit certain X information, outputing a bare CRLF pair). More advanced X implementations may include other information. X X Line Information (refer to "Definition of Terms") X ---- ----------- X 1 NAME X 2 ALIASES, separated by SP X 3 system-specific: maildrop X 4 system-specific: archive maildrop X 5 system-specific: information X 6 system-specific: maildrop map X 7 system-specific: encrypted password X 8 system-specific: local leaders, separated by SP X X X XRose [Page 8] X XRFC 1082 POP3 Extended Service November 1988 X X X 9 ADDRESS X 10 REQUEST X 11 system-specific: incoming feed X 12 system-specific: outgoing feeds X 13 FLAGS SP MAXIMA X 14 LASTDATE X X Most of this information is entirely too specific to the UCI Version X of the Rand MH Message Handling System [MRose85]. Nevertheless, X lines 1, 2, 9, 10, 13, and 14 are of general interest, regardless of X the implementation. X X Possible Responses: X +OK XTND X -ERR no such bboard X Examples: X C: XTND X-BBOARDS system X S: + OK XTND X S: system X S: local general X S: /usr/bboards/system.mbox X S: /usr/bboards/archive/system.mbox X S: /usr/bboards/.system.cnt X S: /usr/bboards/.system.map X S: * X S: mother X S: system@nrtc.northrop.com X S: system-request@nrtc.northrop.com X S: X S: dist-system@nrtc-gremlin.northrop.com X S: 01 10 X S: Thu, 19 Dec 85 00:08:49 -0800 X S: . X XPolicy Notes X X Depending on the particular entity administrating the POP3 service X host, two additional policies might be implemented: X X 1. Private Discussion Groups X X In the general case, discussion groups are world-readable, any user, X once logged in (via a terminal, terminal server, or POP3, etc.), is X able to read the maildrop for each discussion group known to the POP3 X service host. Nevertheless, it is desirable, usually for privacy X reasons, to implement private discussion groups as well. X X Support of this is consistent with the extensions outlined in this X X X XRose [Page 9] X XRFC 1082 POP3 Extended Service November 1988 X X X memo. Once the AUTHORIZATION state has successfully concluded, the X POP3 server grants the user access to exactly those discussion groups X the POP3 service host permits the authenticated user to access. As a X "security" feature, discussion groups associated with unreadable X maildrops should not be listed in a positive response to the XTND X BBOARDS command. X X 2. Anonymous POP3 Users X X In order to minimize the authentication problem, a policy permitting X "anonymous" access to the world-readable maildrops for discussion X groups on the POP3 server may be implemented. X X Support of this is consistent with the extensions outlined in this X memo. The POP3 server can be modified to accept a USER command for a X well-known pseudonym (i.e., "anonymous") which is valid with any PASS X command. As a "security" feature, it is advisable to limit this kind X of access to only hosts at the local site, or to hosts named in an X access list. X XExperiences and Conclusions X X All of the facilities described in this memo and in [RFC1081] have X been implemented in MH #6.1. Initial experiences have been, on the X whole, very positive. X X After the first implementation, some performance tuning was required. X This consisted primarily of caching the datastructures which describe X discussion groups in the POP3 server. A second optimization X pertained to the client: the program most commonly used to read X BBoards in MH was modified to retrieve messages only when needed. X Two schemes are used: X X o If only the headers (and the first few lines of the body) of X the message are required (e.g., for a scan listing), then only X these are retrieved. The resulting output is then cached, on X a per-message basis. X X o If the entire message is required, then it is retrieved intact, X and cached locally. X X With these optimizations, response time is quite adequate when the X POP3 server and client are connected via a high-speed local area X network. In fact, the author uses this mechanism to access certain X private discussion groups over the Internet. In this case, response X is still good. When a 9.6Kbps modem is inserted in the path, X response went from good to almost tolerable (fortunately the author X only reads a few discussion groups in this fashion). X X X XRose [Page 10] X XRFC 1082 POP3 Extended Service November 1988 X X X To conclude: the POP3 is a good thing, not only for personal mail but X for discussion group mail as well. X X XReferences X X [RFC1081] Rose, M., "Post Office Protocol - Verison 3 (POP3)", RFC X 1081, TWG, November 1988. X X [MRose85] Rose, M., and J. Romine, "The Rand MH Message Handling X System: User's Manual", University of California, Irvine, X November 1985. X X [RFC822] Crocker, D., "Standard for the Format of ARPA-Internet X Text Messages", RFC 822, University of Delaware, August X 1982. X X [RFC918] Reynolds, J., "Post Office Protocol", RFC 918, X USC/Information Sciences Institute, October 1984. X X [RFC937] Butler, M., J. Postel, D. Chase, J. Goldberger, and J. X Reynolds, "Post Office Protocol - Version 2", RFC 937, X USC/Information Sciences Institute, February 1985. X XAuthor's Address: X X X Marshall Rose X The Wollongong Group X 1129 San Antonio Rd. X Palo Alto, California 94303 X X Phone: (415) 962-7100 X X Email: MRose@TWG.COM X X X X X X X X X X X X X X X X XRose [Page 11] X SHAR_EOF fi if test -f 'pop_dele.c' then echo shar: "will not over-write existing file 'pop_dele.c'" else sed 's/^X//' << \SHAR_EOF > 'pop_dele.c' X/* X * Copyright (c) 1989 Regents of the University of California. X * All rights reserved. The Berkeley software License Agreement X * specifies the terms and conditions for redistribution. X */ X X#ifndef lint Xstatic char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n"; Xstatic char SccsId[] = "@(#)@(#)pop_dele.c 2.1 2.1 3/18/91"; X#endif not lint X X#include X#include X#include X#include "popper.h" X X/* X * dele: Delete a message from the POP maildrop X */ Xpop_dele (p) XPOP * p; X{ X MsgInfoList * mp; /* Pointer to message info list */ X int msg_num; X X /* Convert the message number parameter to an integer */ X msg_num = atoi(p->pop_parm[1]); X X /* Is requested message out of range? */ X if ((msg_num < 1) || (msg_num > p->msg_count)) X return (pop_msg (p,POP_FAILURE,"Message %u does not exist.",msg_num)); X X /* Get a pointer to the message in the message list */ X mp = &(p->mlp[msg_num-1]); X X /* Is the message already flagged for deletion? */ X if (mp->del_flag) X return (pop_msg (p,POP_FAILURE,"Message %u has already been deleted.", X msg_num)); X X /* Flag the message for deletion */ X mp->del_flag = TRUE; X X#ifdef DEBUG X if(p->debug) X pop_log(p,POP_DEBUG,"Deleting message %u at offset %ld of length %ld\n", X mp->number,mp->offset,mp->length); X#endif DEBUG X X /* Update the messages_deleted and bytes_deleted counters */ X p->msgs_deleted++; X p->bytes_deleted += mp->length; X X /* Update the last-message-accessed number if it is lower than X the deleted message */ X if (p->last_msg < msg_num) p->last_msg = msg_num; X X return (pop_msg (p,POP_SUCCESS,"Message %u has been deleted.",msg_num)); X} SHAR_EOF fi if test -f 'pop_dropcopy.c' then echo shar: "will not over-write existing file 'pop_dropcopy.c'" else sed 's/^X//' << \SHAR_EOF > 'pop_dropcopy.c' X/* X * Copyright (c) 1989 Regents of the University of California. X * All rights reserved. The Berkeley software License Agreement X * specifies the terms and conditions for redistribution. X */ X X#ifndef lint Xstatic char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n"; Xstatic char SccsId[] = "@(#)@(#)pop_dropcopy.c 2.6 2.6 4/3/91"; X#endif not lint X X#include X#include X#include X#include X#include X#include X#include X#include "popper.h" X Xextern int errno; Xextern int sys_nerr; Xextern char *sys_errlist[]; X X/* X * dropcopy: Make a temporary copy of the user's mail drop and X * save a stream pointer for it. X */ X Xpop_dropcopy(p,pwp) XPOP * p; Xstruct passwd * pwp; X{ X int mfd; /* File descriptor for X the user's maildrop */ X int dfd; /* File descriptor for X the SERVER maildrop */ X FILE *tf; /* The temp file */ X char template[POP_TMPSIZE]; /* Temp name holder */ X char buffer[BUFSIZ]; /* Read buffer */ X long offset; /* Old/New boundary */ X int nchar; /* Bytes written/read */ X struct stat mybuf; /* For lstat() */ X X /* Create a temporary maildrop into which to copy the updated maildrop */ X (void)sprintf(p->temp_drop,POP_DROP,p->user); X X#ifdef DEBUG X if(p->debug) X pop_log(p,POP_DEBUG,"Creating temporary maildrop '%s'", X p->temp_drop); X#endif DEBUG X X /* Here we work to make sure the user doesn't cause us to remove or X * write over existing files by limiting how much work we do while X * running as root. X */ X X /* First create a unique file. Would prefer mkstemp, but Ultrix...*/ X strcpy(template,POP_TMPDROP); X (void) mktemp(template); X if ( (tf=fopen(template,"w+")) == NULL ) { /* failure, bail out */ X pop_log(p,POP_PRIORITY, X "Unable to create temporary temporary maildrop '%s': %s",template, X (errno < sys_nerr) ? sys_errlist[errno] : "") ; X return pop_msg(p,POP_FAILURE, X "System error, can't create temporary file."); X } X X /* Now give this file to the user */ X (void) chown(template,pwp->pw_uid, pwp->pw_gid); X (void) chmod(template,0600); X X /* Now link this file to the temporary maildrop. If this fails it X * is probably because the temporary maildrop already exists. If so, X * this is ok. We can just go on our way, because by the time we try X * to write into the file we will be running as the user. X */ X (void) link(template,p->temp_drop); X (void) fclose(tf); X (void) unlink(template); X X /* Now we run as the user. */ X (void) setuid(pwp->pw_uid); X (void) setgid(pwp->pw_gid); X X#ifdef DEBUG X if(p->debug)pop_log(p,POP_DEBUG,"uid = %u, gid = %u",getuid(),getgid()); X#endif DEBUG X X /* Open for append, this solves the crash recovery problem */ X if ((dfd = open(p->temp_drop,O_RDWR|O_APPEND|O_CREAT,0600)) == -1){ X pop_log(p,POP_PRIORITY, X "Unable to open temporary maildrop '%s': %s",p->temp_drop, X (errno < sys_nerr) ? sys_errlist[errno] : "") ; X return pop_msg(p,POP_FAILURE, X "System error, can't open temporary file, do you own it?"); X } X X /* Lock the temporary maildrop */ X if ( flock (dfd, LOCK_EX|LOCK_NB) == -1 ) X switch(errno) { X case EWOULDBLOCK: X return pop_msg(p,POP_FAILURE, X "Maildrop lock busy! Is another session active?"); X /* NOTREACHED */ X default: X return pop_msg(p,POP_FAILURE,"flock: '%s': %s", p->temp_drop, X (errno < sys_nerr) ? sys_errlist[errno] : ""); X /* NOTREACHED */ X } X X /* May have grown or shrunk between open and lock! */ X offset = lseek(dfd,0L,L_XTND); X X /* Open the user's maildrop, If this fails, no harm in assuming empty */ X if ((mfd = open(p->drop_name,O_RDWR)) > 0) { X X /* Lock the maildrop */ X if (flock (mfd,LOCK_EX) == -1) { X (void)close(mfd) ; X return pop_msg(p,POP_FAILURE, "flock: '%s': %s", p->temp_drop, X (errno < sys_nerr) ? sys_errlist[errno] : ""); X } X X /* Copy the actual mail drop into the temporary mail drop */ X while ( (nchar=read(mfd,buffer,BUFSIZ)) > 0 ) X if ( nchar != write(dfd,buffer,nchar) ) { X nchar = -1 ; X break ; X } X X if ( nchar != 0 ) { X /* Error adding new mail. Truncate to original size, X and leave the maildrop as is. The user will not X see the new mail until the error goes away. X Should let them process the current backlog, in case X the error is a quota problem requiring deletions! */ X (void)ftruncate(dfd,offset) ; X } else { X /* Mail transferred! Zero the mail drop NOW, that we X do not have to do gymnastics to figure out what's new X and what is old later */ X (void)ftruncate(mfd,0L) ; X } X X /* Close the actual mail drop */ X (void)close (mfd); X } X X /* Acquire a stream pointer for the temporary maildrop */ X if ( (p->drop = fdopen(dfd,"a+")) == NULL ) { X (void)close(dfd) ; X return pop_msg(p,POP_FAILURE,"Cannot assign stream for %s", X p->temp_drop); X } X X rewind (p->drop); X X return(POP_SUCCESS); X} SHAR_EOF fi if test -f 'pop_dropinfo.c' then echo shar: "will not over-write existing file 'pop_dropinfo.c'" else sed 's/^X//' << \SHAR_EOF > 'pop_dropinfo.c' X/* X * Copyright (c) 1989 Regents of the University of California. X * All rights reserved. The Berkeley software License Agreement X * specifies the terms and conditions for redistribution. X */ X X#ifndef lint Xstatic char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n"; Xstatic char SccsId[] = "@(#)@(#)pop_dropinfo.c 2.1 2.1 3/18/91"; X#endif not lint X X#include X#include X#include X#include X#include X#include X#include "popper.h" X Xextern int errno; Xextern int sys_nerr; Xextern char *sys_errlist[]; X X/* X * dropinfo: Extract information about the POP maildrop and store X * it for use by the other POP routines. X */ X Xpop_dropinfo(p) XPOP * p; X{ X char buffer[BUFSIZ]; /* Read buffer */ X MsgInfoList * mp; /* Pointer to message X info list */ X register int msg_num; /* Current message X counter */ X int nchar; /* Bytes written/read */ X X /* Initialize maildrop status variables in the POP parameter block */ X p->msg_count = 0; X p->msgs_deleted = 0; X p->last_msg = 0; X p->bytes_deleted = 0; X p->drop_size = 0; X X /* Allocate memory for message information structures */ X p->msg_count = ALLOC_MSGS; X p->mlp = (MsgInfoList *)calloc((unsigned)p->msg_count,sizeof(MsgInfoList)); X if (p->mlp == NULL){ X (void)fclose (p->drop); X p->msg_count = 0; X return pop_msg (p,POP_FAILURE, X "Can't build message list for '%s': Out of memory", p->user); X } X X rewind (p->drop); X X /* Scan the file, loading the message information list with X information about each message */ X X for (msg_num = p->drop_size = 0, mp = p->mlp - 1; X fgets(buffer,MAXMSGLINELEN,p->drop);) { X X nchar = strlen(buffer); X X if (strncmp(buffer,"From ",5) == 0) { X X if (++msg_num > p->msg_count) { X p->mlp=(MsgInfoList *) realloc(p->mlp, X (p->msg_count+=ALLOC_MSGS)*sizeof(MsgInfoList)); X if (p->mlp == NULL){ X (void)fclose (p->drop); X p->msg_count = 0; X return pop_msg (p,POP_FAILURE, X "Can't build message list for '%s': Out of memory", X p->user); X } X mp = p->mlp + msg_num - 2; X } X#ifdef DEBUG X if(p->debug) X pop_log(p,POP_DEBUG, X "Msg %u at offset %ld is %ld octets long and has %u lines.", X mp->number,mp->offset,mp->length,mp->lines); X#endif DEBUG X ++mp; X mp->number = msg_num; X mp->length = 0; X mp->lines = 0; X mp->offset = ftell(p->drop) - nchar; X mp->del_flag = FALSE; X mp->retr_flag = FALSE; X#ifdef DEBUG X if(p->debug) X pop_log(p,POP_DEBUG, "Msg %u being added to list", mp->number); X#endif DEBUG X } X mp->length += nchar; X p->drop_size += nchar; X mp->lines++; X } X p->msg_count = msg_num; X X#ifdef DEBUG X if(p->debug && msg_num > 0) { X register i; X for (i = 0, mp = p->mlp; i < p->msg_count; i++, mp++) X pop_log(p,POP_DEBUG, X "Msg %u at offset %ld is %ld octets long and has %u lines.", X mp->number,mp->offset,mp->length,mp->lines); X } X#endif DEBUG X X return(POP_SUCCESS); X} SHAR_EOF fi if test -f 'pop_get_command.c' then echo shar: "will not over-write existing file 'pop_get_command.c'" else sed 's/^X//' << \SHAR_EOF > 'pop_get_command.c' X/* X * Copyright (c) 1989 Regents of the University of California. X * All rights reserved. The Berkeley software License Agreement X * specifies the terms and conditions for redistribution. X */ X X#ifndef lint Xstatic char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n"; Xstatic char SccsId[] = "@(#)@(#)pop_get_command.c 2.1 2.1 3/18/91"; X#endif not lint X X#include X#include X#include X#include "popper.h" X X/* X * get_command: Extract the command from an input line form a POP client X */ X Xstatic state_table states[] = { X auth1, "user", 1, 1, pop_user, {auth1, auth2}, X auth2, "pass", 1, 1, pop_pass, {auth1, trans}, X#ifdef RPOP X auth2, "rpop", 1, 1, pop_rpop, {auth1, trans}, X#endif RPOP X auth1, "quit", 0, 0, pop_quit, {halt, halt}, X auth2, "quit", 0, 0, pop_quit, {halt, halt}, X trans, "stat", 0, 0, pop_stat, {trans, trans}, X trans, "list", 0, 1, pop_list, {trans, trans}, X trans, "retr", 1, 1, pop_send, {trans, trans}, X trans, "dele", 1, 1, pop_dele, {trans, trans}, X trans, "noop", 0, 0, NULL, {trans, trans}, X trans, "rset", 0, 0, pop_rset, {trans, trans}, X trans, "top", 2, 2, pop_send, {trans, trans}, X trans, "last", 0, 0, pop_last, {trans, trans}, X trans, "xtnd", 1, 99, pop_xtnd, {trans, trans}, X trans, "quit", 0, 0, pop_updt, {halt, halt}, X (state) 0, NULL, 0, 0, NULL, {halt, halt}, X}; X Xstate_table *pop_get_command(p,mp) XPOP * p; Xregister char * mp; /* Pointer to unparsed line X received from the client */ X{ X state_table * s; X char buf[MAXMSGLINELEN]; X X /* Save a copy of the original client line */ X#ifdef DEBUG X if(p->debug) strcpy (buf,mp); X#endif DEBUG X X /* Parse the message into the parameter array */ X if ((p->parm_count = pop_parse(p,mp)) < 0) return(NULL); X X /* Do not log cleartext passwords */ X#ifdef DEBUG X if(p->debug){ X if(strcmp(p->pop_command,"pass") == 0) X pop_log(p,POP_DEBUG,"Received: \"%s xxxxxxxxx\"",p->pop_command); X else { X /* Remove trailing */ X buf[strlen(buf)-2] = '\0'; X pop_log(p,POP_DEBUG,"Received: \"%s\"",buf); X } X } X#endif DEBUG X X /* Search for the POP command in the command/state table */ X for (s = states; s->command; s++) { X X /* Is this a valid command for the current operating state? */ X if (strcmp(s->command,p->pop_command) == 0 X && s->ValidCurrentState == p->CurrentState) { X X /* Were too few parameters passed to the command? */ X if (p->parm_count < s->min_parms) X return((state_table *)pop_msg(p,POP_FAILURE, X "Too few arguments for the %s command.",p->pop_command)); X X /* Were too many parameters passed to the command? */ X if (p->parm_count > s->max_parms) X return((state_table *)pop_msg(p,POP_FAILURE, X "Too many arguments for the %s command.",p->pop_command)); X X /* Return a pointer to the entry for this command in X the command/state table */ X return (s); X } X } X /* The client command was not located in the command/state table */ X return((state_table *)pop_msg(p,POP_FAILURE, X "Unknown command: \"%s\".",p->pop_command)); X} SHAR_EOF fi if test -f 'pop_get_subcommand.c' then echo shar: "will not over-write existing file 'pop_get_subcommand.c'" else sed 's/^X//' << \SHAR_EOF > 'pop_get_subcommand.c' X/* X * Copyright (c) 1989 Regents of the University of California. X * All rights reserved. The Berkeley software License Agreement X * specifies the terms and conditions for redistribution. X */ X X#ifndef lint Xstatic char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n"; Xstatic char SccsId[] = "@(#)@(#)pop_get_subcommand.c 2.1 2.1 3/18/91"; X#endif not lint X X#include X#include X#include X#include "popper.h" X X/* X * get_subcommand: Extract a POP XTND subcommand from a client input line X */ X Xstatic xtnd_table subcommands[] = { X "xmit", 0, 0, pop_xmit, X NULL X}; X Xxtnd_table *pop_get_subcommand(p) XPOP * p; X{ X xtnd_table * s; X X /* Search for the POP command in the command/state table */ X for (s = subcommands; s->subcommand; s++) { X X if (strcmp(s->subcommand,p->pop_subcommand) == 0) { X X /* Were too few parameters passed to the subcommand? */ X if ((p->parm_count-1) < s->min_parms) X return((xtnd_table *)pop_msg(p,POP_FAILURE, X "Too few arguments for the %s %s command.", X p->pop_command,p->pop_subcommand)); X X /* Were too many parameters passed to the subcommand? */ X if ((p->parm_count-1) > s->max_parms) X return((xtnd_table *)pop_msg(p,POP_FAILURE, X "Too many arguments for the %s %s command.", X p->pop_command,p->pop_subcommand)); X X /* Return a pointer to the entry for this subcommand X in the XTND command table */ X return (s); X } X } X /* The client subcommand was not located in the XTND command table */ X return((xtnd_table *)pop_msg(p,POP_FAILURE, X "Unknown command: \"%s %s\".",p->pop_command,p->pop_subcommand)); X} SHAR_EOF fi if test -f 'pop_init.c' then echo shar: "will not over-write existing file 'pop_init.c'" else sed 's/^X//' << \SHAR_EOF > 'pop_init.c' X/* X * Copyright (c) 1989 Regents of the University of California. X * All rights reserved. The Berkeley software License Agreement X * specifies the terms and conditions for redistribution. X */ X X#ifndef lint Xstatic char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n"; Xstatic char SccsId[] = "@(#)@(#)pop_init.c 2.1 2.1 3/18/91"; X#endif not lint X X#include X#include X#include X#include X#include X#include X#include X#include "popper.h" X Xextern int errno; X X/* X * init: Start a Post Office Protocol session X */ X Xpop_init(p,argcount,argmessage) XPOP * p; Xint argcount; Xchar ** argmessage; X{ X X struct sockaddr_in cs; /* Communication parameters */ X struct hostent * ch; /* Client host information */ X int errflag = 0; X int c; X int len; X extern char * optarg; X int options = 0; X int sp = 0; /* Socket pointer */ X char * trace_file_name; X X /* Initialize the POP parameter block */ X bzero ((char *)p,(int)sizeof(POP)); X X /* Save my name in a global variable */ X p->myname = argmessage[0]; X X /* Get the name of our host */ X (void)gethostname(p->myhost,MAXHOSTNAMELEN); X X /* Open the log file */ X#ifdef SYSLOG42 X (void)openlog(p->myname,0); X#else X (void)openlog(p->myname,POP_LOGOPTS,POP_FACILITY); X#endif X X /* Process command line arguments */ X while ((c = getopt(argcount,argmessage,"dt:")) != EOF) X switch (c) { X X /* Debugging requested */ X case 'd': X p->debug++; X options |= SO_DEBUG; X break; X X /* Debugging trace file specified */ X case 't': X p->debug++; X if ((p->trace = fopen(optarg,"a+")) == NULL) { X pop_log(p,POP_PRIORITY, X "Unable to open trace file \"%s\", err = %d", X optarg,errno); X exit(-1); X } X trace_file_name = optarg; X break; X X /* Unknown option received */ X default: X errflag++; X } X X /* Exit if bad options specified */ X if (errflag) { X (void)fprintf(stderr,"Usage: %s [-d]\n",argmessage[0]); X exit(-1); X } X X /* Get the address and socket of the client to whom I am speaking */ X len = sizeof(cs); X if (getpeername(sp,(struct sockaddr *)&cs,&len) < 0){ X pop_log(p,POP_PRIORITY, X "Unable to obtain socket and address of client, err = %d",errno); X exit(-1); X } X X /* Save the dotted decimal form of the client's IP address X in the POP parameter block */ X p->ipaddr = inet_ntoa(cs.sin_addr); X X /* Save the client's port */ X p->ipport = ntohs(cs.sin_port); X X /* Get the canonical name of the host to whom I am speaking */ X ch = gethostbyaddr((char *) &cs.sin_addr, sizeof(cs.sin_addr), AF_INET); X if (ch == NULL){ X pop_log(p,POP_PRIORITY, X "Unable to get canonical name of client, err = %d",errno); X p->client = p->ipaddr; X } X /* Save the cannonical name of the client host in X the POP parameter block */ X else { X X#ifndef BIND43 X p->client = ch->h_name; X#else X# include X# include X X /* Distrust distant nameservers */ X extern struct state _res; X struct hostent * ch_again; X char * * addrp; X X /* We already have a fully-qualified name */ X _res.options &= ~RES_DEFNAMES; X X /* See if the name obtained for the client's IP X address returns an address */ X if ((ch_again = gethostbyname(ch->h_name)) == NULL) { X pop_log(p,POP_PRIORITY, X "Client at \"%s\" resolves to an unknown host name \"%s\"", X p->ipaddr,ch->h_name); X p->client = p->ipaddr; X } X else { X /* Save the host name (the previous value was X destroyed by gethostbyname) */ X p->client = ch_again->h_name; X X /* Look for the client's IP address in the list returned X for its name */ X for (addrp=ch_again->h_addr_list; *addrp; ++addrp) X if (bcmp(*addrp,&(cs.sin_addr),sizeof(cs.sin_addr)) == 0) break; X X if (!*addrp) { X pop_log (p,POP_PRIORITY, X "Client address \"%s\" not listed for its host name \"%s\"", X p->ipaddr,ch->h_name); X p->client = p->ipaddr; X } X } X#endif BIND43 X } X X /* Create input file stream for TCP/IP communication */ X if ((p->input = fdopen(sp,"r")) == NULL){ X pop_log(p,POP_PRIORITY, X "Unable to open communication stream for input, err = %d",errno); X exit (-1); X } X X /* Create output file stream for TCP/IP communication */ X if ((p->output = fdopen(sp,"w")) == NULL){ X pop_log(p,POP_PRIORITY, X "Unable to open communication stream for output, err = %d",errno); X exit (-1); X } X X pop_log(p,POP_PRIORITY, X "(v%s) Servicing request from \"%s\" at %s\n", X VERSION,p->client,p->ipaddr); X X#ifdef DEBUG X if (p->trace) X pop_log(p,POP_PRIORITY, X "Tracing session and debugging information in file \"%s\"", X trace_file_name); X else if (p->debug) X pop_log(p,POP_PRIORITY,"Debugging turned on"); X#endif DEBUG X X return(POP_SUCCESS); X} SHAR_EOF fi if test -f 'pop_last.c' then echo shar: "will not over-write existing file 'pop_last.c'" else sed 's/^X//' << \SHAR_EOF > 'pop_last.c' X/* X * Copyright (c) 1989 Regents of the University of California. X * All rights reserved. The Berkeley software License Agreement X * specifies the terms and conditions for redistribution. X */ X X#ifndef lint Xstatic char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n"; Xstatic char SccsId[] = "@(#)@(#)pop_last.c 2.1 2.1 3/18/91"; X#endif not lint X X#include X#include X#include "popper.h" X X/* X * last: Display the last message touched in a POP session X */ X Xint pop_last (p) XPOP * p; X{ X return (pop_msg(p,POP_SUCCESS,"%u is the last message seen.",p->last_msg)); X} SHAR_EOF fi if test -f 'pop_list.c' then echo shar: "will not over-write existing file 'pop_list.c'" else sed 's/^X//' << \SHAR_EOF > 'pop_list.c' X/* X * Copyright (c) 1989 Regents of the University of California. X * All rights reserved. The Berkeley software License Agreement X * specifies the terms and conditions for redistribution. X */ X X#ifndef lint Xstatic char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n"; Xstatic char SccsId[] = "@(#)@(#)pop_list.c 2.1 2.1 3/18/91"; X#endif not lint X X#include X#include X#include "popper.h" X X/* X * list: List the contents of a POP maildrop X */ X Xint pop_list (p) XPOP * p; X{ X MsgInfoList * mp; /* Pointer to message info list */ X register int i; X register int msg_num; X X /* Was a message number provided? */ X if (p->parm_count > 0) { X msg_num = atoi(p->pop_parm[1]); X X /* Is requested message out of range? */ X if ((msg_num < 1) || (msg_num > p->msg_count)) X return (pop_msg (p,POP_FAILURE, X "Message %u does not exist.",msg_num)); X X /* Get a pointer to the message in the message list */ X mp = &p->mlp[msg_num-1]; X X /* Is the message already flagged for deletion? */ X if (mp->del_flag) X return (pop_msg (p,POP_FAILURE, X "Message %u has been deleted.",msg_num)); X X /* Display message information */ X return (pop_msg(p,POP_SUCCESS,"%u %ld",msg_num,mp->length)); X } X X /* Display the entire list of messages */ X pop_msg(p,POP_SUCCESS, X "%u messages (%ld octets)", X p->msg_count-p->msgs_deleted,p->drop_size-p->bytes_deleted); X X /* Loop through the message information list. Skip deleted messages */ X for (i = p->msg_count, mp = p->mlp; i > 0; i--, mp++) { X if (!mp->del_flag) X (void)fprintf(p->output,"%u %ld\r\n",mp->number,mp->length); X } X X /* "." signals the end of a multi-line transmission */ X (void)fprintf(p->output,".\r\n"); X (void)fflush(p->output); X X return(POP_SUCCESS); X} SHAR_EOF fi if test -f 'pop_log.c' then echo shar: "will not over-write existing file 'pop_log.c'" else sed 's/^X//' << \SHAR_EOF > 'pop_log.c' X/* X * Copyright (c) 1989 Regents of the University of California. X * All rights reserved. The Berkeley software License Agreement X * specifies the terms and conditions for redistribution. X */ X X#ifndef lint Xstatic char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n"; Xstatic char SccsId[] = "@(#)@(#)pop_log.c 2.1 2.1 3/18/91"; X#endif not lint X X#include X#include X#include X#include "popper.h" X X/* X * log: Make a log entry X */ X Xstatic char msgbuf[MAXLINELEN]; X Xpop_log(va_alist) Xva_dcl X{ X va_list ap; X POP * p; X int stat; X char * format; X X va_start(ap); X p = va_arg(ap,POP *); X stat = va_arg(ap,int); X format = va_arg(ap,char *); X va_end(ap); X X#ifdef HAVE_VSPRINTF X vsprintf(msgbuf,format,ap); X#else X (void)sprintf (msgbuf,format,((int *)ap)[0],((int *)ap)[1],((int *)ap)[2], X ((int *)ap)[3],((int *)ap)[4],((int *)ap)[5]); X#endif HAVE_VSPRINTF X X if (p->debug && p->trace) { X (void)fprintf(p->trace,"%s\n",msgbuf); X (void)fflush(p->trace); X } X else { X syslog (stat,"%s",msgbuf); X } X X return(stat); X} SHAR_EOF fi if test -f 'pop_lower.c' then echo shar: "will not over-write existing file 'pop_lower.c'" else sed 's/^X//' << \SHAR_EOF > 'pop_lower.c' X/* X * Copyright (c) 1989 Regents of the University of California. X * All rights reserved. The Berkeley software License Agreement X * specifies the terms and conditions for redistribution. X */ X X#ifndef lint Xstatic char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n"; Xstatic char SccsId[] = "@(#)@(#)pop_lower.c 2.1 2.1 3/18/91"; X#endif not lint X X#include X#include X#include X X/* X * lower: Convert a string to lowercase X */ X Xpop_lower (buf) Xchar * buf; X{ X char * mp; X X for (mp = buf; *mp; mp++) X if (isupper(*mp) && isupper(*mp)) *mp = (char)tolower((int)*mp); X} SHAR_EOF fi if test -f 'pop_msg.c' then echo shar: "will not over-write existing file 'pop_msg.c'" else sed 's/^X//' << \SHAR_EOF > 'pop_msg.c' X/* X * Copyright (c) 1989 Regents of the University of California. X * All rights reserved. The Berkeley software License Agreement X * specifies the terms and conditions for redistribution. X */ X X#ifndef lint Xstatic char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n"; Xstatic char SccsId[] = "@(#)@(#)pop_msg.c 2.1 2.1 3/18/91"; X#endif not lint X X#include X#include X#include X#include X#include "popper.h" X X/* X * msg: Send a formatted line to the POP client X */ X Xpop_msg(va_alist) Xva_dcl X{ X POP * p; X int stat; /* POP status indicator */ X char * format; /* Format string for the message */ X va_list ap; X register char * mp; X char message[MAXLINELEN]; X X va_start(ap); X p = va_arg(ap, POP *); X stat = va_arg(ap, int); X format = va_arg(ap, char *); X va_end(ap); X X /* Point to the message buffer */ X mp = message; X X /* Format the POP status code at the beginning of the message */ X if (stat == POP_SUCCESS) X (void)sprintf (mp,"%s ",POP_OK); X else X (void)sprintf (mp,"%s ",POP_ERR); X X /* Point past the POP status indicator in the message message */ X mp += strlen(mp); X X /* Append the message (formatted, if necessary) */ X if (format) X#ifdef HAVE_VSPRINTF X vsprintf(mp,format,ap); X#else X (void)sprintf(mp,format,((int *)ap)[0],((int *)ap)[1],((int *)ap)[2], X ((int *)ap)[3],((int *)ap)[4]); X#endif HAVE_VSPRINTF X X /* Log the message if debugging is turned on */ X#ifdef DEBUG X if (p->debug && stat == POP_SUCCESS) X pop_log(p,POP_DEBUG,"%s",message); X#endif DEBUG X X /* Log the message if a failure occurred */ X if (stat != POP_SUCCESS) X pop_log(p,POP_PRIORITY,"%s",message); X X /* Append the */ X (void)strcat(message, "\r\n"); X X /* Send the message to the client */ X (void)fputs(message,p->output); X (void)fflush(p->output); X X return(stat); X} SHAR_EOF fi if test -f 'pop_parse.c' then echo shar: "will not over-write existing file 'pop_parse.c'" else sed 's/^X//' << \SHAR_EOF > 'pop_parse.c' X/* X * Copyright (c) 1989 Regents of the University of California. X * All rights reserved. The Berkeley software License Agreement X * specifies the terms and conditions for redistribution. X */ X X#ifndef lint Xstatic char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n"; Xstatic char SccsId[] = "@(#)@(#)pop_parse.c 2.1 2.1 3/18/91"; X#endif not lint X X#include X#include X#include X#include "popper.h" X X/* X * parse: Parse a raw input line from a POP client X * into null-delimited tokens X */ X Xpop_parse(p,buf) XPOP * p; Xchar * buf; /* Pointer to a message containing X the line from the client */ X{ X char * mp; X register int i; X X /* Loop through the POP command array */ X for (mp = buf, i = 0; ; i++) { X X /* Skip leading spaces and tabs in the message */ X while (isspace(*mp))mp++; X X /* Are we at the end of the message? */ X if (*mp == 0) break; X X /* Have we already obtained the maximum allowable parameters? */ X if (i >= MAXPARMCOUNT) { X pop_msg(p,POP_FAILURE,"Too many arguments supplied."); X return(-1); X } X X /* Point to the start of the token */ X p->pop_parm[i] = mp; X X /* Search for the first space character (end of the token) */ X while (!isspace(*mp) && *mp) mp++; X X /* Delimit the token with a null */ X if (*mp) *mp++ = 0; X } X X /* Were any parameters passed at all? */ X if (i == 0) return (-1); X X /* Convert the first token (POP command) to lower case */ X pop_lower(p->pop_command); X X /* Return the number of tokens extracted minus the command itself */ X return (i-1); X X} SHAR_EOF fi if test -f 'pop_pass.c' then echo shar: "will not over-write existing file 'pop_pass.c'" else sed 's/^X//' << \SHAR_EOF > 'pop_pass.c' X/* X * Copyright (c) 1989 Regents of the University of California. X * All rights reserved. The Berkeley software License Agreement X * specifies the terms and conditions for redistribution. X */ X X#ifndef lint Xstatic char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n"; Xstatic char SccsId[] = "@(#)@(#)pop_pass.c 2.3 2.3 4/2/91"; X#endif not lint X X#include X#include X#include X#include X#include "popper.h" X X/* X * pass: Obtain the user password from a POP client X */ X Xint pop_pass (p) XPOP * p; X{ X register struct passwd * pw; X char *crypt(); X X /* Look for the user in the password file */ X if ((pw = getpwnam(p->user)) == NULL) X return (pop_msg(p,POP_FAILURE, X "Password supplied for \"%s\" is incorrect.",p->user)); X X /* We don't accept connections from users with null passwords */ X if (pw->pw_passwd == NULL) X return (pop_msg(p,POP_FAILURE, X "Password supplied for \"%s\" is incorrect.",p->user)); X X /* Compare the supplied password with the password file entry */ X if (strcmp (crypt (p->pop_parm[1], pw->pw_passwd), pw->pw_passwd) != 0) X return (pop_msg(p,POP_FAILURE, X "Password supplied for \"%s\" is incorrect.",p->user)); X X /* Build the name of the user's maildrop */ X (void)sprintf(p->drop_name,"%s/%s",POP_MAILDIR,p->user); X X /* Make a temporary copy of the user's maildrop */ X /* and set the group and user id */ X if (pop_dropcopy(p,pw) != POP_SUCCESS) return (POP_FAILURE); X X /* Get information about the maildrop */ X if (pop_dropinfo(p) != POP_SUCCESS) return(POP_FAILURE); X X /* Initialize the last-message-accessed number */ X p->last_msg = 0; X X /* Authorization completed successfully */ X return (pop_msg (p,POP_SUCCESS, X "%s has %u message(s) (%ld octets).", X p->user,p->msg_count,p->drop_size)); X} SHAR_EOF fi if test -f 'pop_quit.c' then echo shar: "will not over-write existing file 'pop_quit.c'" else sed 's/^X//' << \SHAR_EOF > 'pop_quit.c' X/* X * Copyright (c) 1989 Regents of the University of California. X * All rights reserved. The Berkeley software License Agreement X * specifies the terms and conditions for redistribution. X */ X X#ifndef lint Xstatic char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n"; Xstatic char SccsId[] = "@(#)@(#)pop_quit.c 2.1 2.1 3/18/91"; X#endif not lint X X#include X#include X#include "popper.h" X X/* X * quit: Terminate a POP session X */ X Xint pop_quit (p) XPOP * p; X{ X /* Release the message information list */ X if (p->mlp) free ((char *)p->mlp); X X return(POP_SUCCESS); X} SHAR_EOF fi if test -f 'pop_rset.c' then echo shar: "will not over-write existing file 'pop_rset.c'" else sed 's/^X//' << \SHAR_EOF > 'pop_rset.c' X/* X * Copyright (c) 1989 Regents of the University of California. X * All rights reserved. The Berkeley software License Agreement X * specifies the terms and conditions for redistribution. X */ X X#ifndef lint Xstatic char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n"; Xstatic char SccsId[] = "@(#)@(#)pop_rset.c 2.1 2.1 3/18/91"; X#endif not lint X X#include X#include X#include "popper.h" X X/* X * rset: Unflag all messages flagged for deletion in a POP maildrop X */ X Xint pop_rset (p) XPOP * p; X{ X MsgInfoList * mp; /* Pointer to the message info list */ X register int i; X X /* Unmark all the messages */ X for (i = p->msg_count, mp = p->mlp; i > 0; i--, mp++) X mp->del_flag = FALSE; X X /* Reset the messages-deleted and bytes-deleted counters */ X p->msgs_deleted = 0; X p->bytes_deleted = 0; X X /* Reset the last-message-access flag */ X p->last_msg = 0; X X return (pop_msg(p,POP_SUCCESS,"Maildrop has %u messages (%ld octets)", X p->msg_count,p->drop_size)); X} SHAR_EOF fi if test -f 'pop_send.c' then echo shar: "will not over-write existing file 'pop_send.c'" else sed 's/^X//' << \SHAR_EOF > 'pop_send.c' X/* X * Copyright (c) 1989 Regents of the University of California. X * All rights reserved. The Berkeley software License Agreement X * specifies the terms and conditions for redistribution. X */ X X#ifndef lint Xstatic char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n"; Xstatic char SccsId[] = "@(#)@(#)pop_send.c 2.1 2.1 3/18/91"; X#endif not lint X X#include X#include X#include X#include "popper.h" X X/* X * send: Send the header and a specified number of lines X * from a mail message to a POP client. X */ X Xpop_send(p) XPOP * p; X{ X MsgInfoList * mp; /* Pointer to message info list */ X register int msg_num; X register int msg_lines; X char buffer[MAXMSGLINELEN]; X X /* Convert the first parameter into an integer */ X msg_num = atoi(p->pop_parm[1]); X X /* Is requested message out of range? */ X if ((msg_num < 1) || (msg_num > p->msg_count)) X return (pop_msg (p,POP_FAILURE,"Message %u does not exist.",msg_num)); X X /* Get a pointer to the message in the message list */ X mp = &p->mlp[msg_num-1]; X X /* Is the message flagged for deletion? */ X if (mp->del_flag) X return (pop_msg (p,POP_FAILURE, X "Message %u has been deleted.",msg_num)); X X /* If this is a TOP command, get the number of lines to send */ X if (strcmp(p->pop_command,"top") == 0) { X /* Convert the second parameter into an integer */ X msg_lines = atoi(p->pop_parm[2]); X } X else { X /* Assume that a RETR (retrieve) command was issued */ X msg_lines = -1; X /* Flag the message as retreived */ X mp->retr_flag = TRUE; X } X X /* Display the number of bytes in the message */ X pop_msg(p,POP_SUCCESS,"%ld octets",mp->length); X X /* Position to the start of the message */ X (void)fseek(p->drop,mp->offset,0); X X /* Skip the first line (the sendmail "From" line) */ X (void)fgets (buffer,MAXMSGLINELEN,p->drop); X X /* Send the header of the message followed by a blank line */ X while (fgets(buffer,MAXMSGLINELEN,p->drop)) { X pop_sendline (p,buffer); X /* A single newline (blank line) signals the X end of the header. sendline() converts this to a NULL, X so that's what we look for. */ X if (*buffer == 0) break; X } X /* Send the message body */ X while (fgets(buffer,MAXMSGLINELEN,p->drop)) { X /* Look for the start of the next message */ X if (strncmp(buffer,"From ",5) == 0) break; X /* Decrement the lines sent (for a TOP command) */ X if (msg_lines >= 0 && msg_lines-- == 0) break; X pop_sendline(p,buffer); X } X /* "." signals the end of a multi-line transmission */ X (void)fputs(".\r\n",p->output); X (void)fflush(p->output); X X return(POP_SUCCESS); X} X X/* X * sendline: Send a line of a multi-line response to a client. X */ Xpop_sendline(p,buffer) XPOP * p; Xchar * buffer; X{ X char * bp; X X /* Byte stuff lines that begin with the temirnation octet */ X if (*buffer == POP_TERMINATE) (void)fputc(POP_TERMINATE,p->output); X X /* Look for a in the buffer */ X if (bp = index(buffer,NEWLINE)) *bp = 0; X X /* Send the line to the client */ X (void)fputs(buffer,p->output); X X#ifdef DEBUG X if(p->debug)pop_log(p,POP_DEBUG,"Sending line \"%s\"",buffer); X#endif DEBUG X X /* Put a if a newline was removed from the buffer */ X if (bp) (void)fputs ("\r\n",p->output); X} SHAR_EOF fi if test -f 'pop_stat.c' then echo shar: "will not over-write existing file 'pop_stat.c'" else sed 's/^X//' << \SHAR_EOF > 'pop_stat.c' X/* X * Copyright (c) 1989 Regents of the University of California. X * All rights reserved. The Berkeley software License Agreement X * specifies the terms and conditions for redistribution. X */ X X#ifndef lint Xstatic char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n"; Xstatic char SccsId[] = "@(#)@(#)pop_stat.c 2.2 2.2 3/18/91"; X#endif not lint X X#include X#include X#include "popper.h" X X/* X * stat: Display the status of a POP maildrop to its client X */ X Xint pop_stat (p) XPOP * p; X{ X#ifdef DEBUG X if (p->debug) pop_log(p,POP_DEBUG,"%u message(s) (%ld octets).",p->msg_count-p->msgs_deleted,p->drop_size-p->bytes_deleted); X#endif DEBUG X return (pop_msg (p,POP_SUCCESS, X "%u %ld",p->msg_count-p->msgs_deleted,p->drop_size-p->bytes_deleted)); X} SHAR_EOF fi if test -f 'pop_updt.c' then echo shar: "will not over-write existing file 'pop_updt.c'" else sed 's/^X//' << \SHAR_EOF > 'pop_updt.c' X/* X * Copyright (c) 1989 Regents of the University of California. X * All rights reserved. The Berkeley software License Agreement X * specifies the terms and conditions for redistribution. X */ X X#ifndef lint Xstatic char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n"; Xstatic char SccsId[] = "@(#)@(#)pop_updt.c 2.3 2.3 3/20/91"; X#endif not lint X X#include X#include X#include X#include X#include X#include X#include "popper.h" X Xextern int errno; X Xstatic char standard_error[] = X "Error error updating primary drop. Mailbox unchanged"; X X/* X * updt: Apply changes to a user's POP maildrop X */ X Xint pop_updt (p) XPOP * p; X{ X FILE * md; /* Stream pointer for X the user's maildrop */ X int mfd; /* File descriptor for X above */ X char buffer[BUFSIZ]; /* Read buffer */ X X MsgInfoList * mp; /* Pointer to message X info list */ X register int msg_num; /* Current message X counter */ X register int status_written; /* Status header field X written */ X int nchar; /* Bytes read/written */ X X long offset; /* New mail offset */ X X#ifdef DEBUG X if (p->debug) { X pop_log(p,POP_DEBUG,"Performing maildrop update..."); X pop_log(p,POP_DEBUG,"Checking to see if all messages were deleted"); X } X#endif DEBUG X X if (p->msgs_deleted == p->msg_count) { X /* Truncate before close, to avoid race condition, DO NOT UNLINK! X Another process may have opened, and not yet tried to lock */ X (void)ftruncate ((int)fileno(p->drop),0L); X (void)fclose(p->drop) ; X return (POP_SUCCESS); X } X X#ifdef DEBUG X if (p->debug) X pop_log(p,POP_DEBUG,"Opening mail drop \"%s\"",p->drop_name); X#endif DEBUG X X /* Open the user's real maildrop */ X if ((mfd = open(p->drop_name,O_RDWR|O_CREAT,0600)) == -1 || X (md = fdopen(mfd,"r+")) == NULL) { X return pop_msg(p,POP_FAILURE,standard_error); X } X X /* Lock the user's real mail drop */ X if ( flock(mfd,LOCK_EX) == -1 ) { X (void)fclose(md) ; X return pop_msg(p,POP_FAILURE, "flock: '%s': %s", p->temp_drop, X (errno < sys_nerr) ? sys_errlist[errno] : ""); X } X X /* Go to the right places */ X offset = lseek((int)fileno(p->drop),0L,L_XTND) ; X X /* Append any messages that may have arrived during the session X to the temporary maildrop */ X while ((nchar=read(mfd,buffer,BUFSIZ)) > 0) X if ( nchar != write((int)fileno(p->drop),buffer,nchar) ) { X nchar = -1; X break ; X } X if ( nchar != 0 ) { X (void)fclose(md) ; X (void)ftruncate((int)fileno(p->drop),offset) ; X (void)fclose(p->drop) ; X return pop_msg(p,POP_FAILURE,standard_error); X } X X rewind(md); X (void)ftruncate(mfd,0L) ; X X /* Synch stdio and the kernel for the POP drop */ X rewind(p->drop); X (void)lseek((int)fileno(p->drop),0L,L_SET); X X /* Transfer messages not flagged for deletion from the temporary X maildrop to the new maildrop */ X#ifdef DEBUG X if (p->debug) X pop_log(p,POP_DEBUG,"Creating new maildrop \"%s\" from \"%s\"", X p->drop_name,p->temp_drop); X#endif DEBUG X X for (msg_num = 0; msg_num < p->msg_count; ++msg_num) { X X int doing_body; X X /* Get a pointer to the message information list */ X mp = &p->mlp[msg_num]; X X if (mp->del_flag) { X#ifdef DEBUG X if(p->debug) X pop_log(p,POP_DEBUG, X "Message %u flagged for deletion.",mp->number); X#endif DEBUG X continue; X } X X (void)fseek(p->drop,mp->offset,0); X X#ifdef DEBUG X if(p->debug) X pop_log(p,POP_DEBUG,"Copying message %u.",mp->number); X#endif DEBUG X for(status_written = doing_body = 0 ; X fgets(buffer,MAXMSGLINELEN,p->drop);) { X X if (doing_body == 0) { /* Header */ X X /* Update the message status */ X if (strncasecmp(buffer,"Status:",7) == 0) { X if (mp->retr_flag) X (void)fputs("Status: RO\n",md); X else X (void)fputs(buffer, md); X status_written++; X continue; X } X /* A blank line signals the end of the header. */ X if (*buffer == '\n') { X doing_body = 1; X if (status_written == 0) { X if (mp->retr_flag) X (void)fputs("Status: RO\n\n",md); X else X (void)fputs("Status: U\n\n",md); X } X else (void)fputs ("\n", md); X continue; X } X /* Save another header line */ X (void)fputs (buffer, md); X } X else { /* Body */ X if (strncmp(buffer,"From ",5) == 0) break; X (void)fputs (buffer, md); X } X } X } X X /* flush and check for errors now! The new mail will writen X without stdio, since we need not separate messages */ X X (void)fflush(md) ; X if (ferror(md)) { X (void)ftruncate(mfd,0L) ; X (void)fclose(md) ; X (void)fclose(p->drop) ; X return pop_msg(p,POP_FAILURE,standard_error); X } X X /* Go to start of new mail if any */ X (void)lseek((int)fileno(p->drop),offset,L_SET); X X while((nchar=read((int)fileno(p->drop),buffer,BUFSIZ)) > 0) X if ( nchar != write(mfd,buffer,nchar) ) { X nchar = -1; X break ; X } X if ( nchar != 0 ) { X (void)ftruncate(mfd,0L) ; X (void)fclose(md) ; X (void)fclose(p->drop) ; X return pop_msg(p,POP_FAILURE,standard_error); X } X X /* Close the maildrop and empty temporary maildrop */ X (void)fclose(md); X (void)ftruncate((int)fileno(p->drop),0L); X (void)fclose(p->drop); X X return(pop_quit(p)); X} SHAR_EOF fi if test -f 'pop_user.c' then echo shar: "will not over-write existing file 'pop_user.c'" else sed 's/^X//' << \SHAR_EOF > 'pop_user.c' X/* X * Copyright (c) 1989 Regents of the University of California. X * All rights reserved. The Berkeley software License Agreement X * specifies the terms and conditions for redistribution. X */ X X#ifndef lint Xstatic char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n"; Xstatic char SccsId[] = "@(#)@(#)pop_user.c 2.1 2.1 3/18/91"; X#endif not lint X X#include X#include X#include X#include "popper.h" X X/* X * user: Prompt for the user name at the start of a POP session X */ X Xint pop_user (p) XPOP * p; X{ X /* Save the user name */ X (void)strcpy(p->user, p->pop_parm[1]); X X /* Tell the user that the password is required */ X return (pop_msg(p,POP_SUCCESS,"Password required for %s.",p->user)); X} SHAR_EOF fi if test -f 'pop_xmit.c' then echo shar: "will not over-write existing file 'pop_xmit.c'" else sed 's/^X//' << \SHAR_EOF > 'pop_xmit.c' X/* X * Copyright (c) 1989 Regents of the University of California. X * All rights reserved. The Berkeley software License Agreement X * specifies the terms and conditions for redistribution. X */ X X#ifndef lint Xstatic char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n"; Xstatic char SccsId[] = "@(#)@(#)pop_xmit.c 2.1 2.1 3/18/91"; X#endif not lint X X#include X#include X#include X#include X#include "popper.h" X X/* X * xmit: POP XTND function to receive a message from X * a client and send it in the mail X */ X Xpop_xmit (p) XPOP * p; X{ X FILE * tmp; /* File descriptor for X temporary file */ X char buffer[MAXLINELEN]; /* Read buffer */ X char temp_xmit[MAXDROPLEN]; /* Name of the temporary X filedrop */ X union wait stat; X int id, pid; X X /* Create a temporary file into which to copy the user's message */ X (void)mktemp((char *)strcpy(temp_xmit,POP_TMPXMIT)); X#ifdef DEBUG X if(p->debug) X pop_log(p,POP_DEBUG, X "Creating temporary file for sending a mail message \"%s\"\n", X temp_xmit); X#endif DEBUG X if ((tmp = fopen(temp_xmit,"w+")) == NULL) X return (pop_msg(p,POP_FAILURE, X "Unable to create temporary message file \"%s\", errno = %d", X temp_xmit,errno)); X X /* Tell the client to start sending the message */ X pop_msg(p,POP_SUCCESS,"Start sending the message."); X X /* Receive the message */ X#ifdef DEBUG X if(p->debug)pop_log(p,POP_DEBUG,"Receiving mail message"); X#endif DEBUG X while (fgets(buffer,MAXLINELEN,p->input)){ X /* Look for initial period */ X#ifdef DEBUG X if(p->debug)pop_log(p,POP_DEBUG,"Receiving: \"%s\"",buffer); X#endif DEBUG X if (*buffer == '.') { X /* Exit on end of message */ X if (strcmp(buffer,".\r\n") == 0) break; X } X (void)fputs (buffer,tmp); X } X (void)fclose (tmp); X X#ifdef DEBUG X if(p->debug)pop_log(p,POP_DEBUG,"Forking for \"%s\"",MAIL_COMMAND); X#endif DEBUG X /* Send the message */ X switch (pid = fork()) { X case 0: X (void)fclose (p->input); X (void)fclose (p->output); X (void)close(0); X if (open(temp_xmit,O_RDONLY,0) < 0) (void)_exit(1); X (void)execl (MAIL_COMMAND,"send-mail","-t","-oem",NULLCP); X (void)_exit(1); X case -1: X#ifdef DEBUG X if (!p->debug) (void)unlink (temp_xmit); X#endif DEBUG X return (pop_msg(p,POP_FAILURE, X "Unable to execute \"%s\"",MAIL_COMMAND)); X default: X while((id = wait(&stat)) >=0 && id != pid); X if (!p->debug) (void)unlink (temp_xmit); X if (stat.w_retcode) X return (pop_msg(p,POP_FAILURE,"Unable to send message")); X return (pop_msg (p,POP_SUCCESS,"Message sent successfully")); X } X X} SHAR_EOF fi if test -f 'pop_xtnd.c' then echo shar: "will not over-write existing file 'pop_xtnd.c'" else sed 's/^X//' << \SHAR_EOF > 'pop_xtnd.c' X/* X * Copyright (c) 1989 Regents of the University of California. X * All rights reserved. The Berkeley software License Agreement X * specifies the terms and conditions for redistribution. X */ X X#ifndef lint Xstatic char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n"; Xstatic char SccsId[] = "@(#)@(#)pop_xtnd.c 2.1 2.1 3/18/91"; X#endif not lint X X#include X#include X#include "popper.h" X X/* X * xtnd: Handle extensions to the POP protocol suite X */ X Xextern xtnd_table * pop_get_subcommand(); X Xint pop_xtnd (p) XPOP * p; X{ X xtnd_table * x; X X /* Convert the XTND subcommand to lower case */ X pop_lower(p->pop_subcommand); X X /* Search for the subcommand in the XTND command table */ X if ((x = pop_get_subcommand(p)) == NULL) return(POP_FAILURE); X X /* Call the function associated with this subcommand */ X if (x->function) return((*x->function)(p)); X X /* Otherwise assume NOOP */ X return (pop_msg(p,POP_SUCCESS,NULL)); X} SHAR_EOF fi if test -f 'popper.c' then echo shar: "will not over-write existing file 'popper.c'" else sed 's/^X//' << \SHAR_EOF > 'popper.c' X/* X * Copyright (c) 1989 Regents of the University of California. X * All rights reserved. The Berkeley software License Agreement X * specifies the terms and conditions for redistribution. X */ X X#ifndef lint Xstatic char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n"; Xstatic char SccsId[] = "@(#)@(#)popper.c 2.1 2.1 3/18/91"; X#endif not lint X X#include X#include X#include "popper.h" X Xextern state_table * pop_get_command(); X X/* X * popper: Handle a Post Office Protocol version 3 session X */ Xmain (argc, argv) Xint argc; Xchar ** argv; X{ X POP p; X state_table * s; X char message[MAXLINELEN]; X X /* Start things rolling */ X pop_init(&p,argc,argv); X X /* Tell the user that we are listenting */ X pop_msg(&p,POP_SUCCESS, X "UCB Pop server (version %s) at %s starting.",VERSION,p.myhost); X X /* State loop. The POP server is always in a particular state in X which a specific suite of commands can be executed. The following X loop reads a line from the client, gets the command, and processes X it in the current context (if allowed) or rejects it. This continues X until the client quits or an error occurs. */ X X for (p.CurrentState=auth1;p.CurrentState!=halt&&p.CurrentState!=error;) { X X /* Obtain a line from the client */ X if (fgets(message,MAXLINELEN,p.input) == NULL) { X p.CurrentState = error; X pop_msg(&p,POP_FAILURE,"POP server at %s signing off.",p.myhost); X } X else { X /* Search for the command in the command/state table */ X if ((s = pop_get_command(&p,message)) == NULL) continue; X X /* Call the function associated with this command in X the current state */ X if (s->function) p.CurrentState = s->result[(*s->function)(&p)]; X X /* Otherwise assume NOOP and send an OK message to the client */ X else { X p.CurrentState = s->success_state; X pop_msg(&p,POP_SUCCESS,NULL); X } X } X } X X /* Say goodbye to the client */ X pop_msg(&p,POP_SUCCESS,"Pop server at %s signing off.",p.myhost); X X /* Log the end of activity */ X pop_log(&p,POP_PRIORITY, X "(v%s) Ending request from \"%s\" at %s\n",VERSION,p.client,p.ipaddr); X X /* Stop logging */ X closelog(); X X return(0); X} X X#ifdef STRNCASECMP X/* X * Perform a case-insensitive string comparision X */ X#include Xstrncasecmp(str1,str2,len) Xregister char * str1; Xregister char * str2; Xregister int len; X{ X register int i; X char a, X b; X X for (i=len-1;i>=0;i--){ X a = str1[i]; X b = str2[i]; X if (isupper(a)) a = tolower(str1[i]); X if (isupper(b)) b = tolower(str2[i]); X if (a > b) return (1); X if (a < b) return(-1); X } X return(0); X} X#endif STRNCASECMP SHAR_EOF fi if test -f 'popper.h' then echo shar: "will not over-write existing file 'popper.h'" else sed 's/^X//' << \SHAR_EOF > 'popper.h' X/* X * Copyright (c) 1989 Regents of the University of California. X * All rights reserved. The Berkeley software License Agreement X * specifies the terms and conditions for redistribution. X * X * static char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n"; X * static char SccsId[] = "@(#)@(#)popper.h 2.2 2.2 4/2/91"; X * X */ X X/* LINTLIBRARY */ X X/* X * Header file for the POP programs X */ X X#include X#include "version.h" X X#define NULLCP ((char *) 0) X#define SPACE 32 X#define TAB 9 X#define TRUE 1 X#define FALSE 0 X#define NEWLINE '\n' X X#define MAXHOSTNAMELEN 256 X#define MAXUSERNAMELEN 65 X#define MAXDROPLEN 64 X#define MAXLINELEN 1024 X#define MAXMSGLINELEN 1024 X#define MAXCMDLEN 4 X#define MAXPARMCOUNT 5 X#define MAXPARMLEN 10 X#define ALLOC_MSGS 20 X#define MAIL_COMMAND "/usr/lib/sendmail" X X#define POP_FACILITY LOG_LOCAL0 X#define POP_PRIORITY LOG_NOTICE X#define POP_DEBUG LOG_DEBUG X#define POP_LOGOPTS 0 X#define POP_MAILDIR "/usr/spool/mail" X#define POP_DROP "/usr/spool/mail/.%s.pop" X /* POP_TMPSIZE needs to be big enough to hold the string X * defined by POP_TMPDROP. POP_DROP and POP_TMPDROP X * must be in the same filesystem. X */ X#define POP_TMPDROP "/usr/spool/mail/tmpXXXXXX" X#define POP_TMPSIZE 256 X#define POP_TMPXMIT "/tmp/xmitXXXXXX" X#define POP_OK "+OK" X#define POP_ERR "-ERR" X#define POP_SUCCESS 1 X#define POP_FAILURE 0 X#define POP_TERMINATE '.' X Xextern int errno; Xextern int sys_nerr; Xextern char * sys_errlist[]; Xextern char * sys_siglist[]; X X#define pop_command pop_parm[0] /* POP command is first token */ X#define pop_subcommand pop_parm[1] /* POP XTND subcommand is the X second token */ X Xtypedef enum { /* POP processing states */ X auth1, /* Authorization: waiting for X USER command */ X auth2, /* Authorization: waiting for X PASS command */ X trans, /* Transaction */ X update, /* Update: session ended, X process maildrop changes */ X halt, /* (Halt): stop processing X and exit */ X error /* (Error): something really X bad happened */ X} state; X Xtypedef struct { /* State information for X each POP command */ X state ValidCurrentState; /* The operating state of X the command */ X char * command; /* The POP command */ X int min_parms; /* Minimum number of parms X for the command */ X int max_parms; /* Maximum number of parms X for the command */ X int (*function) (); /* The function that process X the command */ X state result[2]; /* The resulting state after X command processing */ X#define success_state result[0] /* State when a command X succeeds */ X} state_table; X Xtypedef struct { /* Table of extensions */ X char * subcommand; /* The POP XTND subcommand */ X int min_parms; /* Minimum number of parms for X the subcommand */ X int max_parms; /* Maximum number of parms for X the subcommand */ X int (*function) (); /* The function that processes X the subcommand */ X} xtnd_table; X Xtypedef struct { /* Message information */ X int number; /* Message number relative to X the beginning of list */ X long length; /* Length of message in X bytes */ X int lines; /* Number of (null-terminated) lines in the message */ X long offset; /* Offset from beginning of X file */ X int del_flag; /* Flag indicating if message X is marked for deletion */ X int retr_flag; /* Flag indicating if message X was retrieved */ X} MsgInfoList; X Xtypedef struct { /* POP parameter block */ X int debug; /* Debugging requested */ X char * myname; /* The name of this POP X daemon program */ X char myhost[MAXHOSTNAMELEN]; /* The name of our host X computer */ X char * client; /* Canonical name of client X computer */ X char * ipaddr; /* Dotted-notation format of X client IP address */ X unsigned short ipport; /* Client port for privileged X operations */ X char user[MAXUSERNAMELEN]; /* Name of the POP user */ X state CurrentState; /* The current POP operational state */ X MsgInfoList * mlp; /* Message information list */ X int msg_count; /* Number of messages in X the maildrop */ X int msgs_deleted; /* Number of messages flagged X for deletion */ X int last_msg; /* Last message touched by X the user */ X long bytes_deleted; /* Number of maildrop bytes X flagged for deletion */ X char drop_name[MAXDROPLEN]; /* The name of the user's X maildrop */ X char temp_drop[MAXDROPLEN]; /* The name of the user's X temporary maildrop */ X long drop_size; /* Size of the maildrop in X bytes */ X FILE * drop; /* (Temporary) mail drop */ X FILE * input; /* Input TCP/IP communication X stream */ X FILE * output; /* Output TCP/IP communication stream */ X FILE * trace; /* Debugging trace file */ X char * pop_parm[MAXPARMCOUNT]; /* Parse POP parameter list */ X int parm_count; /* Number of parameters in X parsed list */ X} POP; X Xextern int pop_dele(); Xextern int pop_last(); Xextern int pop_list(); Xextern int pop_pass(); Xextern int pop_quit(); Xextern int pop_rset(); Xextern int pop_send(); Xextern int pop_stat(); Xextern int pop_updt(); Xextern int pop_user(); Xextern int pop_xtnd(); Xextern int pop_xmit(); Xextern long lseek(); X X#ifdef pdp11 X#define pop_get_subcommand Apop_get_command X#define pop_dropcopy Apop_dropcopy X#define pop_sendline p_sndline X#endif SHAR_EOF fi if test -f 'version.h' then echo shar: "will not over-write existing file 'version.h'" else sed 's/^X//' << \SHAR_EOF > 'version.h' X/* X * Copyright (c) 1989 Regents of the University of California. X * All rights reserved. The Berkeley software License Agreement X * specifies the terms and conditions for redistribution. X * X * static char copyright[] = "Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n"; X * static char SccsId[] = "@(#)@(#)version.h 2.6 2.6 4/3/91"; X * X */ X X/* X * Current version of this POP implementation X */ X X#define VERSION "1.831beta" SHAR_EOF fi if test -f 'popper.8' then echo shar: "will not over-write existing file 'popper.8'" else sed 's/^X//' << \SHAR_EOF > 'popper.8' X.\" Copyright (c) 1980 Regents of the University of California. X.\" All rights reserved. X.\" X.\" Redistribution and use in source and binary forms are permitted X.\" provided that this notice is preserved and that due credit is given X.\" to the University of California at Berkeley. The name of the University X.\" may not be used to endorse or promote products derived from this X.\" software without specific prior written permission. This software X.\" is provided ``as is'' without express or implied warranty. X.\" X.\" @(#)@(#)popper.8 2.3 2.3 (CCS) 4/2/91 Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n X.\" X.TH popper 8 "August 1990" X.UC 6 X.ad X.SH NAME Xpopper \- pop 3 server X.SH SYNOPSIS X.B /usr/etc/popper X[ -d ] X[ -t trace-file] X.SH DESCRIPTION X.I Popper Xis an implementation of the Post Office Protocol server that runs on a Xvariety of Unix computers to manage electronic mail for Macintosh Xand MS-DOS computers. The server was developed at the University of XCalifornia at Berkeley and conforms fully to the specifications in RFC X1081 and RFC 1082. The Berkeley server also has extensions to Xsend electronic mail on behalf of a client. X.PP XThe X.B \-d Xflag sets the socket to debugging and turns on debugging. All debugging Xinformation is saved using syslog(8). The X.B \-t trace\-file Xflag turns on debugging and saves the trace information in X.I trace\-file Xusing fprintf(s). X.SH HOW TO OBTAIN THE SERVER X.PP XThe POP server is available via anonymous ftp from ftp.CC.Berkeley.EDU X(128.32.136.9, 128.32.206.12). It is in two files in the pub directory: Xa compressed Xtar file popper.tar.Z and a Macintosh StuffIt archive in BinHex format Xcalled MacPOP.sit.hqx. X.SH THE POP TRANSACTION CYCLE X.PP XThe Berkeley POP server is a single program (called popper) that is Xlaunched by inetd when it gets a service request on the POP TCP port. X(The official port number specified in RFC 1081 for POP version 3 is Xport 110. However, some POP3 clients attempt to contact the server at Xport 109, the POP version 2 port. Unless you are running both POP2 and XPOP3 servers, you can simply define both ports for use by the POP3 Xserver. This is explained in the installation instructions later on.) XThe popper program initializes and verifies that the peer IP address is Xregistered in the local domain, logging a warning message when a Xconnection is made to a client whose IP address does not have a Xcanonical name. For systems using BSD 4.3 bind, it also checks to see Xif a cannonical name lookup for the client returns the same peer IP Xaddress, logging a warning message if it does not. The the server Xenters the authorization state, during which the client must correctly Xidentify itself by providing a valid Unix userid and password on the Xserver's host machine. No other exchanges are allowed during this Xstate (other than a request to quit.) If authentication fails, a Xwarning message is logged and the session ends. Once the user is Xidentified, popper changes its user and group ids to match that of the Xuser and enters the transaction state. The server makes a temporary Xcopy of the user's maildrop (ordinarily in /usr/spool/mail) which is Xused for all subsequent transactions. These include the bulk of POP Xcommands to retrieve mail, delete mail, undelete mail, and so forth. A XBerkeley extension also allows the user to submit a mail parcel to the Xserver who mails it using the sendmail program (this extension is Xsupported in the HyperMail client distributed with the server). When Xthe client quits, the server enters the final update state during which Xthe network connection is terminated and the user's maildrop is updated Xwith the (possibly) modified temporary maildrop. X.SH LOGGING X.PP XThe POP server uses syslog to keep a record of its activities. On Xsystems with BSD 4.3 syslogging, the server logs (by default) to the X"local0" facility at priority "notice" for all messages except Xdebugging which is logged at priority "debug". The default log file is X/usr/spool/mqueue/POPlog. These can be changed, if desired. On Xsystems with 4.2 syslogging all messages are logged to the local log Xfile, usually /usr/spool/mqueue/syslog. X.SH DEBUGGING X.PP XThe popper program will log debugging information when the -d parameter Xis specified after its invocation in the inetd.conf file. Care should Xbe exercised in using this option since it generates considerable Xoutput in the syslog file. Alternatively, the "-t " option Xwill place debugging information into file "" using fprintf Xinstead of syslog. X.PP XFor SunOS version 3.5, the popper program is launched by inetd from X/etc/servers. This file does not allow you to specify command line Xarguments. Therefore, if you want to enable debugging, you can specify Xa shell script in /etc/servers to be launched instead of popper and in Xthis script call popper with the desired arguments. X.PP XYou can confirm that the POP server is running on Unix by telneting to Xport 110 (or 109 if you set it up that way). For example: X.PP X.nf X%telnet myhost 110 XTrying... XConnected to myhost.berkeley.edu. XEscape character is '^]'. X+OK UCB Pop server (version 1.6) at myhost starting. Xquit XConnection closed by foreign host. X.fi X.SH VERSION 1.7 RELEASE NOTES XExtensive re-write of the maildrop processing code contributed by XViktor Dukhovni that greatly reduces the Xpossibility that the maildrop can be corrupted as the result of Xsimultaneous access by two or more processes. X.PP XAdded "pop_dropcopy" module to create a temporary maildrop from Xthe existing, standard maildrop as root before the setuid and Xsetgid for the user is done. This allows the temporary maildrop Xto be created in a mail spool area that is not world read-writable. X.PP XThis version does *not* send the sendmail "From " delimiter line Xin response to a TOP or RETR command. X.PP XEncased all debugging code in #ifdef DEBUG constructs. This code can Xbe included by specifying the DEGUG compiler flag. Note: You still Xneed to use the -d or -t option to obtain debugging output. X.SH LIMITATIONS XThe POP server copies the user's entire maildrop to /tmp and Xthen operates on that copy. If the maildrop is particularly Xlarge, or inadequate space is available in /tmp, then the Xserver will refuse to continue and terminate the connection. X.PP XSimultaneous modification of a single maildrop can result in Xconfusing results. For example, manipulating messages in a Xmaildrop using the Unix /usr/ucb/mail command while a copy of Xit is being processed by the POP server can cause the changes Xmade by one program to be lost when the other terminates. This Xproblem is being worked on and will be fixed in a later Xrelease. X.SH FILES X.nf X/usr/spool/mail mail files X/etc/inetd.conf pop program invocation X/etc/syslog.conf logging specifications X.fi X.SH "SEE ALSO" Xinetd(8), XRFC1081, XRFC1082 X.SH AUTHORS XBob Campbell, Edward Moy, Austin Shelton, Marshall T Rose, and cast of Xthousands at Rand, UDel, UCI, and elsewhere SHAR_EOF fi if test -f 'README' then echo shar: "will not over-write existing file 'README'" else sed 's/^X//' << \SHAR_EOF > 'README' X@(#)@(#)README 2.6 2.6 4/2/91 X X XThe Post Office Protocol Server: Installation Guide X X X XIntroduction X XThe Post Office Protocol server runs on a variety of Unix[1] computers Xto manage electronic mail for Macintosh and MS-DOS computers. The Xserver was developed at the University of California at Berkeley and Xconforms fully to the specifications in RFC 1081[2] and RFC 1082[3]. XThe Berkeley server also has extensions to send electronic mail on Xbehalf of a client. X XThis guide explains how to install the POP server on your Unix Xcomputer. It assumes that you are not only familiar with Unix but also Xcapable of performing Unix system administration. X X XHow to Obtain the Server X XThe POP server is available via anonymous ftp from ftp.CC.Berkeley.EDU X(128.32.136.9, 128.32.206.12). It is in two files in the pub directory: Xa compressed tar file popper-version.tar.Z and a Macintosh StuffIt archive Xin BinHex format called MacPOP.sit.hqx. X X XContents of the Distribution X XThe distribution contains the following: X X+ All of the C source necessary to create the server program. X X+ A visual representation of how the POP system works. X X+ Reprints of RFC 1081 and RFC 1082. X X+ A HyperCard stack POP client implementation using MacTCP. X X+ A man page for the popper daemon. X X+ This guide. X X XCompatibility X XThe Berkeley POP server has been successfully tested on the following XUnix operating systems: X X+ Berkeley Systems Distribution 4.3 X X+ Sun Microsystems Operating System versions 3.5 and 4.0 X X+ Ultrix version 2.3 X XThe following POP clients operate correctly with the Berkeley POP server: X X+ The Berkeley HyperMail HyperCard stack for the Apple Macintosh X (distributed with the server). X X+ The Stanford University Macintosh Internet Protocol MacMH program. X X+ The Stanford University Personal Computer Internet Protocol MH X program. X X+ The mh version 6.0 programs for Unix. X X XSupport X XThe Berkeley POP server is not officially supported and is without any Xwarranty, explicit or implied. However, we are interested in your Xexperiences using the server. Bugs, comments and suggestions should be Xsent electronically to netinfo@garnet.Berkeley.EDU. X X XOperational Characteristics X XThe POP Transaction Cycle X XThe Berkeley POP server is a single program (called popper) that is Xlaunched by inetd when it gets a service request on the POP TCP port. X(The official port number specified in RFC 1081 for POP version 3 is Xport 110. However, some POP3 clients attempt to contact the server at Xport 109, the POP version 2 port. Unless you are running both POP2 and XPOP3 servers, you can simply define both ports for use by the POP3 Xserver. This is explained in the installation instructions later on.) XThe popper program initializes and verifies that the peer IP address is Xregistered in the local domain, logging a warning message when a Xconnection is made to a client whose IP address does not have a Xcanonical name. For systems using BSD 4.3 bind, it also checks to see Xif a cannonical name lookup for the client returns the same peer IP Xaddress, logging a warning message if it does not. The the server Xenters the authorization state, during which the client must correctly Xidentify itself by providing a valid Unix userid and password on the Xserver's host machine. No other exchanges are allowed during this Xstate (other than a request to quit.) If authentication fails, a Xwarning message is logged and the session ends. Once the user is Xidentified, popper changes its user and group ids to match that of the Xuser and enters the transaction state. The server makes a temporary Xcopy of the user's maildrop (ordinarily in /usr/spool/mail) which is Xused for all subsequent transactions. These include the bulk of POP Xcommands to retrieve mail, delete mail, undelete mail, and so forth. A XBerkeley extension also allows the user to submit a mail parcel to the Xserver who mails it using the sendmail program (this extension is Xsupported in the HyperMail client distributed with the server). When Xthe client quits, the server enters the final update state during which Xthe network connection is terminated and the user's maildrop is updated Xwith the (possibly) modified temporary maildrop. X X XLogging X XThe POP server uses syslog to keep a record of its activities. On Xsystems with BSD 4.3 syslogging, the server logs (by default) to the X"local0" facility at priority "notice" for all messages except Xdebugging which is logged at priority "debug". The default log file is X/usr/spool/mqueue/POPlog. These can be changed, if desired. On Xsystems with 4.2 syslogging all messages are logged to the local log Xfile, usually /usr/spool/mqueue/syslog. X XProblems X XIf the filesystem which holds the /usr/spool/mail fills up users will Xexperience difficulties. The filesystem must have enough space to hold X(approximately) two copies of the largest mail box. Popper (v1.81 and Xabove) is designed to be robust in the face of this problem, but you may Xend up with a situation where some of the user's mail is in X X /usr/spool/mail/.userid.pop X Xand some of the mail is in X X /usr/spool/mail/userid X XIf this happens the System Administrator should clear enough disk space Xso that the filesystem has at least as much free disk as both mailboxes Xhold and probably a little more. Then the user should initiate a POP Xsession, and do nothing but quit. If the POP session ends without an Xerror the user can then use POP or another mail program to clean up his/her Xmailbox. X XAlternatively, the System Administrator can combine the two files (but Xpopper will do this for you if there is enough disk space). X X XDebugging X XThe popper program will log debugging information when the -d parameter Xis specified after its invocation in the inetd.conf file. Care should Xbe exercised in using this option since it generates considerable Xoutput in the syslog file. Alternatively, the "-t " option Xwill place debugging information into file "" using fprintf Xinstead of syslog. (To enable debugging, you must edit the Makefile Xto add -DDEBUG to the compiler options.) X XFor SunOS version 3.5, the popper program is launched by inetd from X/etc/servers. This file does not allow you to specify command line Xarguments. Therefore, if you want to enable debugging, you can specify Xa shell script in /etc/servers to be launched instead of popper and in Xthis script call popper with the desired arguments. X X XInstallation X X1. Examine this file for the latest information, warnings, etc. X X2. Check the Makefile for conformity with your system. X X3. Issue the make command in the directory containing the popper X source. X X4. Issue the make install command in the directory containing the X popper source to copy the program to /usr/etc. X X5. Enable syslogging: X X + For systems with 4.3 syslogging: X X Add the following line to the /etc/syslog.conf file: X X local0.notice;local0.debug /usr/spool/mqueue/POPlog X X Create the empty file /usr/spool/mqueue/POPlog. X X Kill and restart the syslogd daemon. X X + For systems with 4.2 syslogging: X X Be sure that you are logging messages of priority 7 and higher. X For example: X X 7/usr/spool/mqueue/syslog X 9/dev/null X X6. Update /etc/services: X X Add the following line to the /etc/services file: X X pop 110/tcp X X Note: This is the official port number for version 3 of the X Post Office Protocol as defined in RFC 1081. However, some X POP3 clients use port 109, the port number for the previous X version (2) of POP. Therefore you may also want to add the X following line to the /etc/services file: X X pop2 109/tcp X X For Sun systems running yp, also do the following: X X + Change to the /var/yp directory. X X + Issue the make services command. X X7. Update the inetd daemon configuration. Include the second line ONLY if you X are running the server at both ports. X X + On BSD 4.3 and SunOS 4.0 systems, add the following line to the X /etc/inetd.conf file: X X pop stream tcp nowait root /usr/etc/popper popper X pop2 stream tcp nowait root /usr/etc/popper popper X X + On Ultrix systems, add the following line to the X /etc/inetd.conf file: X X pop stream tcp nowait /usr/etc/popper popper X pop2 stream tcp nowait /usr/etc/popper popper X X + On SunOS 3.5 systems, add the following line to the X /etc/servers file: X X pop tcp /usr/etc/popper X pop2 tcp /usr/etc/popper X X Kill and restart the inetd daemon. X XYou can confirm that the POP server is running on Unix by telneting to Xport 110 (or 109 if you set it up that way). For example: X X%telnet myhost 110 XTrying... XConnected to myhost.berkeley.edu. XEscape character is '^]'. X+OK UCB Pop server (version 1.6) at myhost starting. Xquit XConnection closed by foreign host. X X XRelease Notes X X1.83 Make sure that everything we do as root is non-destructive. X X1.82 Make the /usr/spool/mail/.userid.pop file owned by the user rather X than owned by root. X X1.81 There were two versions of 1.7 floating around, 1.7b4 and 1.7b5. X The difference is that 1.7b5 attempted to save disk space on X /usr/spool/mail by deleting the users permanent maildrop after X making the temporary copy. Unfortunately, if compiled with X -DDEBUG, this version could easily wipe out a users' mail file. X This is now fixed. X X This version also fixes a security hole for systems that have X /usr/spool/mail writeable by all users. X X With this version we go to all new SCCS IDs for all files. This X is unfortunate, and we hope it is not too much of a problem. X X Thanks to Steve Dorner of UIUC for pointing out the major problem. X X1.7 Extensive re-write of the maildrop processing code contributed by X Viktor Dukhovni that greatly reduces the X possibility that the maildrop can be corrupted as the result of X simultaneous access by two or more processes. X X Added "pop_dropcopy" module to create a temporary maildrop from X the existing, standard maildrop as root before the setuid and X setgid for the user is done. This allows the temporary maildrop X to be created in a mail spool area that is not world read-writable. X X This version does *not* send the sendmail "From " delimiter line X in response to a TOP or RETR command. X X Encased all debugging code in #ifdef DEBUG constructs. This code can X be included by specifying the DEGUG compiler flag. Note: You still X need to use the -d or -t option to obtain debugging output. X X1.6 Corrects a bug that causes the server to crash on SunOS X 4.0 systems. X X Uses varargs and vsprintf (if available) in pop_log and X pop_msg. This is enabled by the "HAVE_VSPRINTF" X compiler flag. X X For systems with BSD 4.3 bind, performs a cannonical X name lookup and searches the returned address(es) for X the client's address, logging a warning message if it X is not located. This is enabled by the "BIND43" X comiler flag. X X Removed all the includes from popper.h and distributed X them throughout the porgrams files, as needed. X X Reformatted the source to convert tabs to spaces and X shorten lines for display on 80-column terminals. X X1.5 Creates the temporary maildrop with mode "600" and X immediately unlinks it. X X Uses client's IP address in lieu of a canonical name if X the latter cannot be obtained. X X Added "-t " option. The presence of this X option causes debugging output to be placed in the file X "file-name" using fprintf instead of the system log X file using syslog. X X Corrected maildrop parsing problem. X X1.4 Copies user's mail into a temporary maildrop on which X all subsequent activity is performed. X X Added "pop_log" function and replaced "syslog" calls X throughout the code with it. X X1.3 Corrected updating of Status: header line. X X Added strncasecmp for systems that do not have one. X Used strncasecmp in all appropriate places. This is X enabled by the STRNCASECMP compiler flag. X X1.2 Support for version 4.2 syslogging added. This is X enabled by the SYSLOG42 compiler flag. X X1.1 Several bugs fixed. X X1.0 Original version. X X XLimitations X X+ The POP server copies the user's entire maildrop to /tmp and X then operates on that copy. If the maildrop is particularly X large, or inadequate space is available in /tmp, then the X server will refuse to continue and terminate the connection. X X+ Simultaneous modification of a single maildrop can result in X confusing results. For example, manipulating messages in a X maildrop using the Unix /usr/ucb/mail command while a copy of X it is being processed by the POP server can cause the changes X made by one program to be lost when the other terminates. This X problem is being worked on and will be fixed in a later X release. X X XCredits X XThe POP server was written by Edward Moy and Austin Shelton with Xcontributions from Robert Campbell (U.C. Berkeley) and Viktor Dukhovni X(Princeton University). Edward Moy wrote the HyperMail stack and drew Xthe POP operation diagram. This installation guide was written by XAustin Shelton. X X XFootnotes X X[1] Copyright (c) 1990 Regents of the University of California. X All rights reserved. The Berkeley software License Agreement X specifies the terms and conditions for redistribution. Unix is X a registered trademark of AT&T corporation. HyperCard and X Macintosh are registered trademarks of Apple Corporation. X X[2] M. Rose, Post Office Protocol - Version 3. RFC 1081, NIC, X November 1988. X X[3] M. Rose, Post Office Protocol - Version 3 Extended Service X Offerings. RFC 1082, NIC, November 1988. SHAR_EOF fi if test -f 'Makefile' then echo shar: "will not over-write existing file 'Makefile'" else sed 's/^X//' << \SHAR_EOF > 'Makefile' X#@(#)@(#)Makefile 2.5 2.5 4/3/91 X XCSRCS = pop_dele.c pop_dropcopy.c pop_dropinfo.c \ X pop_get_command.c pop_get_subcommand.c pop_init.c \ X pop_last.c pop_list.c pop_log.c pop_lower.c \ X pop_msg.c pop_parse.c pop_pass.c pop_quit.c \ X pop_rset.c pop_send.c pop_stat.c pop_updt.c \ X pop_user.c pop_xtnd.c pop_xmit.c popper.c X XOBJS = pop_dele.o pop_dropcopy.o pop_dropinfo.o \ X pop_get_command.o pop_get_subcommand.o pop_init.o \ X pop_last.o pop_list.o pop_log.o pop_lower.o \ X pop_msg.o pop_parse.o pop_pass.o pop_quit.o \ X pop_rset.o pop_send.o pop_stat.o pop_updt.o \ X pop_user.o pop_xtnd.o pop_xmit.o popper.o X XDOCS = README pop3.rfc1081 pop3e.rfc1082 popper.8 X XINCLUDES = popper.h version.h X XSRCS = ${CSRCS} ${INCLUDES} X XSCCS = /usr/ucb/sccs X XREL = X XMAKEFILE = Makefile X X# Options are: X# BIND43 - If you are using BSD 4.3 domain X# name service. X# DEBUG - Include the debugging code. Note: You X# still have to use the -d or -t flag to X# enable debugging. X# HAVE_VSPRINTF - If the vsprintf functions are available X# on your system. X# SYSLOG42 - For BSD 4.2 syslog (default is BSD 4.3 X# syslog). X# STRNCASECMP - If you do not have strncasecmp() X XCFLAGS = -O -DBIND43 X XTARGET = popper X XTAR = ${TARGET}.tar X XINSTALLDIR = /usr/etc X XMANPAGE = popper.8 X XCATPAGE = popper.0 X XMANDIR = /usr/local/man/cat8 X X X X${TARGET}: ${OBJS} X cc -i ${OBJS} -o ${TARGET} X Xtar: ${SRCS} ${DOCS} ${MAKEFILE} X rm -f ${TAR} *.Z* X tar -cvf ${TAR} ${SRCS} ${DOCS} ${MAKEFILE} X compress ${TAR} X uuencode ${TAR}.Z ${TAR}.Z > ${TAR}.Z.uuencoded X split -300 ${TAR}.Z.uuencoded X mv xaa ${TAR}.Z.uuencoded.xaa X mv xab ${TAR}.Z.uuencoded.xab X mv xac ${TAR}.Z.uuencoded.xac X mv xad ${TAR}.Z.uuencoded.xad X mv xae ${TAR}.Z.uuencoded.xae X Xclean: X rm -f core *.o *.Z* X ${SCCS} clean X Xinstall: ${TARGET} X install -c -m 700 -o root -g staff ${TARGET} ${INSTALLDIR} X Xinstallman: X rm -f ${CATPAGE} X nroff -man ${MANPAGE} > ${CATPAGE} X install -c -m 644 -o root -g staff ${CATPAGE} ${MANDIR} X Xedit: X ${SCCS} edit ${REL} ${SRCS} X Xadmin: X ${SCCS} admin -ft"Copyright (c) 1990 Regents of the University of California.\nAll rights reserved.\n" ${SRCS} X Xsources: ${SRCS} X X${SRCS}: X ${SCCS} get ${REL} $@ -p | expand -4 > $@ X X${DOCS}: X ${SCCS} get README -p | expand -4 > README X ${SCCS} get popper.8 -p | expand -4 > popper.8 X X${OBJS}: popper.h version.h SHAR_EOF fi cd .. exit 0 # End of shell archive