SFTP's handling of "." and ".."

Damien Miller djm at mindrot.org
Fri Jul 4 18:02:40 AEST 2025


On Fri, 4 Jul 2025, Philipp Marek via openssh-unix-dev wrote:

> Is this enough?

I think so?

> What about
> 
>    put -r ../  dest
>    put -r ../. dest
>    put -r ../.. dest

The "filename" variable I check in my patch comes from basename(3),
so it should be the final path component only.

AFAIK basename("../") yields "..", so the 2nd case should be ok too.

> I guess this resolves to the question whether source path structures
> should be built in the destination (like -R for rsync says) or not.
> 
>    put -r ../../foo/.. dest
> 
> With foo being a symlink the intention might not be clear (which
> containing directory, of the symlink or its target?)

I don't see the ambuguity here, the thing that will be transferred here
will always be the contents of whatever directory ../../foo resolves to
as sftp doesn't transfer symlinks (though maybe one day we'll get around
to implementing https://bugzilla.mindrot.org/show_bug.cgi?id=428)

-d


More information about the openssh-unix-dev mailing list