gabriel russell
2004-Jun-05 19:31 UTC
[patch] sftp-server writes uploads to a temporary file then renames them when finished
Well, my boss asked me to write this patch and I figured I'd share it in case someone else wanted to use it. It's clearly not for incorporating into the main tree. It would need to be configurable, and since there is no configuration system for sftp, it can't easily be. I could make it look for an environment variable for the tmp-name-suffix and use it's existence to indicate weather or not to use tmp files. - Gabriel -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: sftp-server_tmpfile.patch Url: http://lists.mindrot.org/pipermail/openssh-unix-dev/attachments/20040605/4105ce41/attachment.ksh
Damien Miller
2004-Jun-06 00:43 UTC
[patch] sftp-server writes uploads to a temporary file then renames them when finished
gabriel russell wrote:> Well, my boss asked me to write this patch and I figured I'd share it in > case someone else wanted to use it. It's clearly not for incorporating > into the main tree.This isn't going to be reliable because the filexfer protocol (sftp) doesn't really have a notion of an "upload" - it sees a open, a bunch of writes and a close. While this will usually represent an upload, it could also be modifications to a different file. You could make this a bit more robust by only activating it for creations or truncations.> It would need to be configurable, and since there is > no configuration system for sftp, it can't easily be.When I have made modifications to sftp-server that have required passing in configuration options, I just pass them on the commandline and use a wrapper script in sshd_config's SubSystem directive (because sshd_config doesn't allow the passing of commandline options to subsystems.)> I could make it look for an environment variable for the tmp-name-suffix > and use it's existence to indicate weather or not to use tmp files.You should just use mkstemp to give you a fd to a temporary file, rather than making something that could be clobbered by multiple simultaneous uploads. -d
Seemingly Similar Threads
- sftp-server failing to rename a file
- SFTP: a new command to get filesystem size/free space
- chmod sftp command and setgid/setuid bit
- [PATCH] Adds support for SSH_FXP_LINK request to sftp-server and sftp client
- [Bug 2948] New: implement "copy-data" sftp extension