Subject: Re: sftp open directory

From: Joseph Galbraith <[email-masked]>
Date: Wed, 01 Jul 2009 10:25:51 -0600

Andriy Melnyk wrote:
> Hi,
> Could someone explain me the following:
> SSH File Transfer Protocol draft-ietf-secsh-filexfer-13.txt section 8.1.2.
> Opening a Directory says: *To enumerate a directory, the client first
> obtains a handle and then issues directory read requests. When enumeration
> is complete, the handle MUST be closed.*
> 
> Is it mean that when server receives twice OPEN_DIR command for the same
> directory then for the second one it should responds with
> FXP_STATUS(operation fails) because the first one was not closed with
> FXP_CLOSE?
> What is the correct behaviour?

Hi.

The text simply means that after opening a directory, the handle must
be closed at some point.

I admit the text is a bit unclear; however, I think it is pretty clear
that the SFTP protocol in general allows things to occur in parallel.
In fact, there would be no reason to have handles if we weren't going
to allow multiple directories open at the same time.  Since we do
have handles, I believe the spirit, if not letter, of the draft in this
case is that the client MAY issue any sequence of FXP_OPENDIR, 
FXP_READDIR and FXP_CLOSE requests.  The client MUST close each handle
it receives (either through FXP_OPENDIR or FXP_OPEN) when it is done
with them so that the server can release associated resources.

Thanks,

Joseph