FTP Server - how do I disallow changing directory? FTPBaseFileSystem sends '200

Giganews Newsgroups
Subject: FTP Server - how do I disallow changing directory? FTPBaseFileSystem sends '200
Posted by:  TJ Nannon (in…@cheddar.mailworks.org)
Date: Tue, 07 Dec 2004

In my ChangeDir() handler in my derivative of
FTPBaseFileSystem, I want to handle an attempt to
change-directory into a non-existent dir, with an error like
550.  This works for an attempt to retrieve a non-existent
file, but for the change-dir case, Indy always returns "200",
a generic success case, when I throw an exception.  I've tried
many different exceptions...

Any help is greatly appreciated.

The relevent handlers:

public override void ChangeDir(FTPServerContextBase AContext, ref string VDirectory)
{
  throw new EIdFileSystemFileNotFound ( "no such dir (FS)" );
}

public override void RetrieveFile(FTPServerContextBase AContext, string AFileName, ref Borland.Vcl.TStream VStream)
{
  throw new EIdFileSystemFileNotFound ( "can't retrieve file - file not found (FS)" );
}

A session demonstrating the erroneous '200' responses to 'cd NOSUCHDIR':

ftp> open localhost
Connected to ...
220 Indy FTP Server (Indy: 10.0.51)
User (...:(none)):
331 User name okay, need password.

230 User logged in, proceed.
ftp> PWD
257 "" is working directory.
ftp> cd NOSUCHDIR
200-Ok
200 no such dir (FS)
ftp> PWD
257 "" is working directory.
ftp> cd NOSUCHDIR
200-Ok
200 no such dir (FS)
ftp> PWD
257 "" is working directory.
ftp> get NOSUCHFILE
200 PORT Command successful.
550 can't retrieve file - file not found (FS)
ftp> quit
221 Goodbye.

I'm using Indy 10.0.51 in .net.

Thanks.

Replies