paramiko SftpServer doesn't pass O_BINARY
John A Meinel
john at arbash-meinel.com
Fri Dec 2 02:09:59 GMT 2005
In trying to test on Win32, I've been having problems with line-ending
conversions.
It turned out that the StubSFTPServer is actually converting the lines.
What happens is that paramiko/sftp_server.py never passes os.O_BINARY
My workaround is as follows:
=== modified file 'bzrlib/tests/stub_sftp.py'
--- bzrlib/tests/stub_sftp.py
+++ bzrlib/tests/stub_sftp.py
@@ -94,18 +94,19 @@
def open(self, path, flags, attr):
path = self._realpath(path)
try:
+ flags |= os.O_BINARY
fd = os.open(path, flags)
except OSError, e:
return SFTPServer.convert_errno(e.errno)
if (flags & os.O_CREAT) and (attr is not None):
SFTPServer.set_file_attr(path, attr)
if flags & os.O_WRONLY:
- fstr = 'w'
+ fstr = 'wb'
elif flags & os.O_RDWR:
- fstr = 'r+'
+ fstr = 'rb+'
else:
# O_RDONLY (== 0)
- fstr = 'r'
+ fstr = 'rb'
try:
f = os.fdopen(fd, fstr)
except OSError, e:
Now, I thought it would be more important for the actual paramiko server
to be passing the binary flag.
Now, I haven't found a binary flag to pass to the server, but I did some
testing, and the paramiko client when connecting to my openssh server
did open things in binary mode.
So for now, I'm forcing the O_BINARY flag. Is there a better fix?
(Certainly the SftpTransport layer should treat everything as binary.
Higher level operations may not want to)
John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20051201/d098386c/attachment.pgp
More information about the bazaar
mailing list