Skip to content

Do not fail Mkdir when the server does not name the directory - #72

Open
christhomas wants to merge 1 commit into
secsy:masterfrom
antimatter-studios:cth/mkdir-tolerates-unnamed-reply
Open

Do not fail Mkdir when the server does not name the directory#72
christhomas wants to merge 1 commit into
secsy:masterfrom
antimatter-studios:cth/mkdir-tolerates-unnamed-reply

Conversation

@christhomas

Copy link
Copy Markdown

A server answering MKD with 257 has created the directory. RFC 959 asks it to echo the pathname in quotes as well, and not every server does — proftpd and several embedded servers answer a bare 257 Directory created.

Mkdir treats that as a parse failure and returns an error, so the caller sees a failure for a directory that now exists. Retrying then reports that it already does, which is a confusing place to end up from a call that worked.

A reply without a name is a success whose name cannot be read, not a failure. Mkdir now answers with the path it was asked for.

Getwd is deliberately unchanged. It calls the same extractDirName, but there the pathname is the answer — a PWD reply without one has nothing to return, so failing is correct. The added parser test pins that distinction.

How it turned up

An FTP filesystem driver, against a test server that sends exactly this reply. Every Mkdir failed while every directory was created.

Tests

  • TestExtractDirNameRejectsAReplyWithoutAName — needs no server, pins the parser (including that a well-formed reply still parses)
  • TestMkdirAcceptsReplyWithoutAName — stubs the reply and asserts Mkdir carries on

Separate from #71 and does not depend on it; happy to rebase whichever lands second.

A server answering MKD with 257 has created the directory. RFC 959 asks
it to echo the pathname in quotes as well, and not every server does —
proftpd and several embedded servers answer a bare "257 Directory
created".

Mkdir treated that as a parse failure and returned an error, so the
caller saw a failure for a directory that now exists. Retrying then
reports that it already does, which is a confusing place to end up from
a call that worked.

A reply without a name is a success whose name cannot be read, not a
failure. Mkdir now answers with the path it was asked for.

Getwd is left alone deliberately. It calls the same parser, but there
the pathname *is* the answer — a PWD reply without one has nothing to
return, so failing is correct. The added parser test pins that
distinction so a later change cannot relax both at once.

Found by a filesystem driver whose test server sends exactly this reply:
every Mkdir failed while every directory was created.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant