Open mpkondrashin opened 1 year ago
I do not see any sftp.WithServerWorkingDirectory(…)
option in master, or in a PR.
The Server
struct is known to be of a limited use, since it works only with the raw filesystem and has no ability to add a subdirectory option. The core problem relevant here is that getting a proper chroot
to work is an infamously Difficult Problem™, and so we have actively avoided attempting to bodge this functionality into the Server
implementation. If the Server
does not suit ones needs, then we strongly recommend that one should move on to the RequestServer
implementation, which allows for significantly more control (and more well behaved control) over how file requests are handled.
I have faced the product (it acts as sFTP client) that accepts only absolute paths in sFTP server configuration (/file.zip and not file.zip). Issue is that even if I provide correct wordDir (by using sftp.WithServerWorkingDirectory(...)), sftp Server writes files to the root of my filesystem (C:\file.zip). There is not chance for me to change the product I am using sftp with, so question is, does it make sense to have mandatory workDir that will be added to any path, provided in put command?
I see two possible solutions: