From xemacs-m  Thu Apr 24 12:45:38 1997
Received: from master.control.att.com ([135.205.52.13])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id MAA27863
	for <xemacs-beta@xemacs.org>; Thu, 24 Apr 1997 12:45:37 -0500 (CDT)
Received: from i.control.att.com by master.control.att.com with esmtp
	(Smail3.1.29.1 #3) id m0wKSZy-002ixCC; Thu, 24 Apr 97 13:45 EDT
Received: by i.control.att.com (Smail3.1.29.1 #1)
	id m0wKSZx-000mUWC; Thu, 24 Apr 97 13:45 EDT
Message-Id: <m0wKSZx-000mUWC@i.control.att.com>
Date: Thu, 24 Apr 97 13:45 EDT
From: Larry Auton <lda@control.att.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: xemacs-beta@xemacs.org
Subject: Re: need efs to use passive ftp
References: <m0wFVzL-000h9tC@wander.control.att.com>
X-Mailer: VM 6.29 under 20.2 XEmacs Lucid (beta2)

> From: Larry Auton <lda@control.att.com>
> To: xemacs-beta@xemacs.org
> Subject: need efs to use passive ftp
>
> I get to sites outside our corporate network via a gateway.
> As a result, I have to use passive FTP.  I can't find a documented
> method for sending the 'passive' command at the first ftp> prompt.
> If you know, please drop me a line.
> 
> -lda

Well - I don't speak elisp but by using the Monkey-See-Monkey-Do
technique and a few hours of messing about, I've come up with efs
support for people who live behind a firewall that requires passive
ftp.  I don't know who to send it to since none of the mail I sent to
addresses in the efs code asking about passive support was ever
answered or bounced, so I'll just pass it to the list for review.

putting (setq efs-use-passive-mode t) in ~/.emacs does the trick.

Here's the patch:

--- efs.el.orig	Sat Apr  5 13:07:24 1997
+++ efs.el	Thu Apr 24 13:30:56 1997
@@ -1597,6 +1597,9 @@
 getting out of synch with the FTP client, so using this feature routinely
 isn't recommended.")
 
+(defvar efs-use-passive-mode nil
+  "If non-nil, the ftp client will specify passive mode for all transfers.")
+
 ;;; Hooks and crooks.
 
 (defvar efs-ftp-startup-hook nil
@@ -1657,7 +1660,7 @@
 (defvar efs-cmd-ok-cmds
   (concat
    "^quote port \\|^type \\|^quote site \\|^chmod \\|^quote noop\\|"
-   "^quote pasv"))
+   "^quote pasv\\|^passive"))
 ;; Regexp to match commands for which efs-cmd-ok-msgs is a valid server
 ;; response for success.
 
@@ -1690,6 +1693,8 @@
 			; (Sometimes get this with a timeout,
 			; so treat as fatal.)
    "^3[0-5][0-7] \\|"    ; 3yz = positive intermediate reply
+   ;; passive
+   "^[Pp]assive \\|"
    ;; client codes
    "^[Hh]ash mark "))
 ;; Response to indicate that the requested action was successfully completed.
@@ -3656,6 +3661,9 @@
 		  ;; Tell client to send back hash-marks as progress.  It isn't
 		  ;; usually fatal if this command fails.
 		  (efs-guess-hash-mark-size proc)
+
+		  (if efs-use-passive-mode
+		      (efs-passive-mode host user))
 		  
 		  ;; Run any user startup functions
 		  (let ((alist efs-ftp-startup-function-alist)
@@ -4078,6 +4086,11 @@
 					   (efs-fix-path host-type cmd2))
 		    cmd-string (concat "rename " cmd1 " " cmd2))))
 	   
+	   ;; passive command
+	   ((eq cmd0 'passive)
+	    (let ((host-type (efs-host-type host user)))
+	      (setq cmd-string "passive")))
+	
 	   (t
 	    (error "efs: Don't know how to send %s %s %s %s"
 		   cmd0 cmd1 cmd2 cmd3))))
@@ -10899,3 +10912,9 @@
 (run-hooks 'efs-load-hook)
 
 ;;; end of efs.el
+
+;; put ftp into passive mode
+;;
+(defun efs-passive-mode (host user)
+  "requests that ftp client use passive mode for all transfers"
+  (efs-send-cmd host user '( passive )))

