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

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

wu-ftpd tricks ange-ftp into displaying a file as a directory


From: Francis Litterio
Subject: wu-ftpd tricks ange-ftp into displaying a file as a directory
Date: 09 Aug 2001 13:40:56 -0400

EMACS VERSION: 20.7.1

SYSTEM TYPES: GNU/Linux (Red Hat 6.2), Windows 2000

SYMPTOM:

When ange-ftp.el finds a file on a remote host that is running the
wu-ftpd FTP server (e.g., many GNU/Linux systems run wu-ftpd), instead of
displaying the contents of the file, Emacs displays a dired buffer
showing the file as the sole entry.  For example, finding the file:

  /joe@hostname:/home/joe/.bashrc

results in a dired buffer with the following contents:

  /joe@hostname:/home/joe/.bashrc:
  -rw-r--r--    1 joe     users      4794 Aug  7 11:00 /home/joe/.bashrc

ANALYSIS:

The cause of this problem is that ange-ftp.el decides whether a pathname
is a file or a directory by sending this command to the remote FTP
server:

        ls "-alq" /home/joe/.bashrc/

Notice the trailing '/' that has been appended to the pathname!
ange-ftp.el expects the remote FTP server to return an error containing
the string "Not a directory" if the pathname is not a directory or a
legitimate directory listing if it is a directory.

Unfortunately, wu-ftpd invokes /bin/ls without the trailing '/', which
causes a one-line long-style "ls" listing of that file to be returned to
ange-ftp.el.  That makes ange-ftp.el to think that /home/joe/.bashrc is a
directory containing only the file .bashrc.  Hence, the dired buffer
appears instead of the contents of the file.

I verified that wu-ftpd strips the trailing '/' by replacing /bin/ls on
my GNU/Linux system with a script that echoes the command-line arguments
to a file.

WORKAROUND:

A workaround is to put this form in my .emacs startup file:

        (eval-after-load "ange-ftp"
          (defun ange-ftp-allow-child-lookup (dir file)
            nil))

This works because, ange-ftp-allow-child-lookup is a macro that decides
whether or not ange-ftp.el will use the trailing-'/' trick to decide if a
pathname is a directory or not.  By defining it as a function that always
returns nil, ange-ftp.el always uses a less efficient method: it
generates a long listing of the file's parent directory and parses that.

Forcing the less efficient method to be used all the time is a
non-optimal solution, because the parent directory may be unreadable by
the user or may have thousands of entries in it, causing a long delay for
the user.

If there's any more information I can provide, please contact me by
email.
--
Francis Litterio
franl@world.std.com
http://world.std.com/~franl/
PGP public keys available on keyservers.




reply via email to

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