[comp.protocols.tcp-ip] ftp PASSIVE mode

mhw@wittsend.LBP.HARRIS.COM (Michael H. Warfield) (11/05/88)

In article <8811012118.AA06767@vax.ftp.com> joel@VAX.FTP.COM (Joel Gartland) writes:
>	Should a ftp server, after receiving the PASV command, remain in
>passive mode for the rest of the ftp session, or just for the next transfer?
>It doesn't seem to be stated either way in the RFC (959).

     Here are some extracts from RFC-959:

#         PASSIVE (PASV)
#
#            This command requests the server-DTP to "listen" on a data
#            port (which is not its default data port) and to wait for a
#            connection rather than initiate one upon receipt of a
#            transfer command.  The response to this command includes the
#            host and port address this server is listening on.

     This clearly indicates an action to be taken upon receipt of a PASV
command.  Its result is to place the receiving server in a state listening
for a connection.  This would only affect that transfer since the server
would not normally be in a passive listening state for a data transfer.

#      When data is to be transferred between two servers, A and B (refer
#      to Figure 2), the user-PI, C, sets up control connections with
#      both server-PI's.  One of the servers, say A, is then sent a PASV
#      command telling him to "listen" on his data port rather than
#      initiate a connection when he receives a transfer service command.
#      When the user-PI receives an acknowledgment to the PASV command,
#      which includes the identity of the host and port being listened
#      on, the user-PI then sends A's port, a, to B in a PORT command; a
#      reply is returned.  The user-PI may then send the corresponding
#      service commands to A and B.  Server B initiates the connection
#      and the transfer proceeds.  The command-reply sequence is listed
#      below where the messages are vertically synchronous but
#      horizontally asynchronous:
#
#
#         User-PI - Server A                User-PI - Server B
#         ------------------                ------------------
#         
#         C->A : Connect                    C->B : Connect
#         C->A : PASV
#         A->C : 227 Entering Passive Mode. A1,A2,A3,A4,a1,a2
#                                           C->B : PORT A1,A2,A3,A4,a1,a2
#                                           B->C : 200 Okay
#         C->A : STOR                       C->B : RETR
#                    B->A : Connect to HOST-A, PORT-a
#
#                                Figure 3

     Note that the PASV command is followed by a STOR or RETR command.
This implies that its domain of effect covers the data connection only.

     BTW - before I get flamed - It is true that this is a slightly ad-hoc
conclusion and I recognize it as such.  That's why I said IMPLIED.

     When taken as a whole, there is strong indication that the PASV command
is on a connection by connection basis.  Note too that if you assume such
in the client, you are safe.  If you assume that it is on a session basis in
the client you may well get FRIED when you find a server that assumes a
connection basis.  Implimenting the PASV command with a session basis in the
server could well be an unnecessary exercise in frustration.

Michael H. Warfield  (The Mad Wizard)	| gatech.edu!galbp!wittsend!mhw
  (404)  270-2123 / 270-2098		| mhw@wittsend.LBP.HARRIS.COM
An optimist believes we live in the best of all possible worlds.
A pessimist is sure of it!