[patch] sftp-server writes uploads to a temporary file then renames them when finished

gabriel russell gabriel at wiccatech.com
Sun Jun 6 13:14:01 EST 2004


Damien Miller wrote:
> 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.

I don't know when it's unreliable. I only work with a tmp file when the 
flags of the open are TRUNK|CREAT|WRITE. Thoes are the flags for a 
"normal" upload. Any other flag combination, even ones that write to a 
file, are left to work normally.

> 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.)

Hmm, nice idea.

> 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.

Yea, I think you are right. I had thought of this earlier, but I only 
worked on it this until I had my fill of coffee and had to go out side 
and get some sunshine. I think I'd like to default to making the tmp 
file hidden as well. I like how rsync names it's tmp files. I'll read 
how they do it and maybe I'll copy their methods.

-G




More information about the openssh-unix-dev mailing list