<div dir="ltr">Hi<div><br></div><div style>I'm experimenting with using ssh:daemon using the ssh_sftpd subsystem (other words the standard erlang/otp sftp daemon) and i'm seeing some strange and inconsistent behavior:</div>
<div style><br></div><div style>(all code is here: <a href="https://github.com/ababkin/hl7_pipeline">https://github.com/ababkin/hl7_pipeline</a>)</div><div style><br></div><div style>when i run the sftpd daemon and try to connect to it with an external sftp client (standard sftp cli on osx lion) to 'put' a file, it seems to try to open a new file for write with these modes/flags: [binary,write,creat,trunc], which results in error.</div>
<div style><br></div><div style>I intercept these in my custom file_handler for sftpd (essentially just log the arguments in the open callback)<br></div><div style><br></div><div style>Doing manually in erl shell:</div><div style>
<div>> Result = file:open("/tmp/da.txt", [binary, write, creat, trunc]).</div><div style>results in: </div><div>{error,badarg}</div><div><br></div><div style>so it looks like file:open doesn't like 'creat' or 'trunc' flags that sftpd tries to pass to it</div>
<div style><br></div><div style>this is from the default file_handler sftpd uses:</div><div style><br></div><div style><pre style="margin-top:0px;margin-bottom:0px;padding:0px;border:0px;font-size:12px;font-family:Consolas,'Liberation Mono',Courier,monospace;color:rgb(51,51,51);line-height:16px">
<div class="" id="LC58" style="margin:0px;padding:0px 0px 0px 10px;border:0px"><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(153,0,0);font-weight:bold">open</span><span class="" style="margin:0px;padding:0px;border:0px">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,128,128)">Path</span><span class="" style="margin:0px;padding:0px;border:0px">,</span> <span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,128,128)">Flags</span><span class="" style="margin:0px;padding:0px;border:0px">,</span> <span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,128,128)">State</span><span class="" style="margin:0px;padding:0px;border:0px">)</span> <span class="" style="margin:0px;padding:0px;border:0px;font-weight:bold">-></span></div>
<div class="" id="LC59" style="margin:0px;padding:0px 0px 0px 10px;border:0px">    <span class="" style="margin:0px;padding:0px;border:0px">{</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(85,85,85)">file</span><span class="" style="margin:0px;padding:0px;border:0px">:</span><span class="" style="margin:0px;padding:0px;border:0px">open</span><span class="" style="margin:0px;padding:0px;border:0px">(</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,128,128)">Path</span><span class="" style="margin:0px;padding:0px;border:0px">,</span> <span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,128,128)">Flags</span><span class="" style="margin:0px;padding:0px;border:0px">),</span> <span class="" style="margin:0px;padding:0px;border:0px;color:rgb(0,128,128)">State</span><span class="" style="margin:0px;padding:0px;border:0px">}.</span></div>
</pre></div><div><br></div><div style>.. i.e just passes the flags as modes to file:open</div><div><br></div></div><div style>these results are further compounded with inconsistent behavior while running on different systems</div>
<div style><br></div><div style>i've tried running sftpd on a mac (lion) and ubuntu, seeing the above results, but trying to run the sftpd on a DS211j (that uses marvell ARM cpu and a version of busybox distro and R15B01 probably somehow cross-compiled specifically for the ARM) is see a different behavior:</div>
<div style><br></div><div style>on the DS211j, if i try to perform same steps as on above systems, the flags i intercept are [raw,binary,write], which writes the file fine and doesn't throw an error like in above cases</div>
<div style><br></div><div style>Tried to run the otp testsuite, but seem to be failing on testsuite build step having to do with hipe </div><div style><br></div><div style>Any insights would be welcome. </div><div style>For now i just overwrite the collection of modes/flags with [raw,binary,write] whenever there is 'write' present in the list, but this seems hacky</div>
<div style><br></div><div style><br></div><div style><br></div><div style><br></div></div>