emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

tiny patch to ange-ftp


From: Katsumi Yamaoka
Subject: tiny patch to ange-ftp
Date: Fri, 05 Aug 2005 23:45:03 +0900
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

Hi,

While it is said that the plain ftp is not secure, it is still
useful to be used in the intra net.  Actually, I was using the
old ange-ftp.el (w/ some modifications) in the office to manage
remote files since it was pretty fast than tramp and ssh.

There are two reasons why I used the old ange-ftp.el.  One is
that the recent one (which runs with tramp-ftp.el) issues the cd
command for a remote file, not a directory, when I open two
dired windows (one is for the local directory, the other is for
the remote directory) and copy the local file to the remote
directory using the C (dired-do-copy) command.  It breaks the
dired session even though the file copying is actually
successful.  For instance, it can be observed at the ftp session
as follows when copying the local file "~/FILE" to the remote
directory "/ftp:address@hidden:/tmp/".

ftp> type binary
200 Switching to Binary mode.
put /home/yamaoka/FILE /tmp/FILE
ftp> 227 Entering Passive Mode (127,0,0,1,214,62)
150 Ok to send data.
226 File receive OK.
type ascii
ftp> 200 Switching to ASCII mode.
cd /tmp/FILE
ftp> 550 Failed to change directory.
cd /tmp/FILE
ftp> 550 Failed to change directory.

The other is that Emacs reports errors when I open the home
directory of the remote host in which the chroot is applied so
as to change the home directory as the root directory.  Two
typical patterns can be reproduced even by accessing the
anonymous ftp site as follows:

M-x dired RET /ftp:address@hidden:~/ RET

pattern 1 (this is normally observed at the first time)
=========
230-(220 GNU FTP server ready.)
[...]
230 Login successful.
hash
ftp> Hash mark printing on (1024 bytes/hash mark).
pwd
ftp> 257 "/"
cd /home/
ftp> 550 Failed to change directory.
cd /home/
ftp> 550 Failed to change directory.
cd /home/yamaoka/
ftp> 550 Failed to change directory.
cd /home/yamaoka/
ftp> 550 Failed to change directory.

pattern 2 (this is observed after trying it many times)
=========
230-(220 GNU FTP server ready.)
[...]
230 Login successful.
hash
ftp> Hash mark printing on (1024 bytes/hash mark).
pwd
ftp> 257 "/"
cd /ftp:address@hidden:/
ftp> 550 Failed to change directory.
cd /ftp:address@hidden:/
ftp> 550 Failed to change directory.

Recently, I located the causes of the problems and succeeded in
fixing of them.  The patch is below.  Could anyone verify it? 
Thanks in advance.


2005-08-05  Katsumi Yamaoka  <address@hidden>  (tiny change)

        * net/ange-ftp.el (ange-ftp-send-cmd): Make it work properly with
        uploading files.
        (ange-ftp-canonize-filename): Handle file names beginning with ~
        correctly.


--8<---------------cut here---------------start------------->8---
*** ange-ftp.el~        Fri Aug  5 14:08:14 2005
--- ange-ftp.el Fri Aug  5 14:44:11 2005
***************
*** 2328,2335 ****
        ;; We cd and then use `ls' with no directory argument.
        ;; This works around a misfeature of some versions of netbsd ftpd.
        (unless (equal cmd1 ".")
!         (setq result (ange-ftp-cd host user (nth 1 cmd) 'noerror)))
!       (setq cmd1 cmd3)))
  
       ;; First argument is the remote name
       ((progn
--- 2328,2340 ----
        ;; We cd and then use `ls' with no directory argument.
        ;; This works around a misfeature of some versions of netbsd ftpd.
        (unless (equal cmd1 ".")
!         (setq result (ange-ftp-cd host user
!                                   ;; Make sure the target to which
!                                   ;; `cd' is performed is a directory.
!                                   (file-name-directory (nth 1 cmd))
!                                   'noerror)))
!       ;; Concatenate the switches and the target to be used with `ls'.
!       (setq cmd1 (concat "\"" cmd3 " " cmd1 "\""))))
  
       ;; First argument is the remote name
       ((progn
***************
*** 3122,3129 ****
                        (rest (substring name (match-end 0)))
                        (dir (ange-ftp-expand-dir host user tilda)))
                   (if dir
!                      (setq name (if (string-equal dir "/")
!                                     rest (concat dir rest)))
                     (error "User \"%s\" is not known"
                            (substring tilda 1)))))
  
--- 3127,3138 ----
                        (rest (substring name (match-end 0)))
                        (dir (ange-ftp-expand-dir host user tilda)))
                   (if dir
!                      (setq name (cond ((string-equal rest "")
!                                        dir)
!                                       ((string-equal dir "/")
!                                        rest)
!                                       (t
!                                        (concat dir rest))))
                     (error "User \"%s\" is not known"
                            (substring tilda 1)))))
  
--8<---------------cut here---------------end--------------->8---




reply via email to

[Prev in Thread] Current Thread [Next in Thread]