Revision: 1243
Author: g.rodola
Date: Mon Dec 30 11:46:07 2013 UTC
Log: Fix issue 261: TLS shutdown does not properly work on Windows.
http://code.google.com/p/pyftpdlib/source/detail?r=1243
Modified:
/trunk/HISTORY
/trunk/make.bat
/trunk/pyftpdlib/filesystems.py
/trunk/pyftpdlib/handlers.py
/trunk/test/test_ftpd.py
=======================================
--- /trunk/HISTORY Mon Dec 30 11:14:47 2013 UTC
+++ /trunk/HISTORY Mon Dec 30 11:46:07 2013 UTC
@@ -12,6 +12,10 @@
* #277: added a make file for running tests and for other repetitive tasks
(also for Windows).
+BUG FIXES
+
+ * #261: (FTPS) SSL shutdown does not properly work on Windows.
+
Version: 1.3.0 - Date: 2013-11-07
---------------------------------
=======================================
--- /trunk/make.bat Mon Dec 30 11:14:47 2013 UTC
+++ /trunk/make.bat Mon Dec 30 11:46:07 2013 UTC
@@ -33,6 +33,7 @@
:clean
for /r %%R in (__pycache__) do if exist %%R (rmdir /S /Q %%R)
for /r %%R in (*.pyc) do if exist %%R (del /s %%R)
+ for /r %%R in (*.pyd) do if exist %%R (del /s %%R)
for /r %%R in (*.orig) do if exist %%R (del /s %%R)
for /r %%R in (*.bak) do if exist %%R (del /s %%R)
for /r %%R in (*.rej) do if exist %%R (del /s %%R)
=======================================
--- /trunk/pyftpdlib/filesystems.py Mon Dec 30 11:33:10 2013 UTC
+++ /trunk/pyftpdlib/filesystems.py Mon Dec 30 11:46:07 2013 UTC
@@ -370,7 +370,7 @@
except KeyError:
return uid
else:
- def get_user_by_uid(self):
+ def get_user_by_uid(self, uid):
return "owner"
if grp is not None:
@@ -384,7 +384,7 @@
except KeyError:
return gid
else:
- def get_group_by_gid(self):
+ def get_group_by_gid(self, gid):
return "group"
# --- Listing utilities
=======================================
--- /trunk/pyftpdlib/handlers.py Mon Dec 30 11:33:10 2013 UTC
+++ /trunk/pyftpdlib/handlers.py Mon Dec 30 11:46:07 2013 UTC
@@ -3119,20 +3119,21 @@
twisted/internet/tcp.py code has been used as an example.
"""
self._ssl_closing = True
- # since SSL_shutdown() doesn't report errors, an empty
- # write call is done first, to try to detect if the
- # connection has gone away
- try:
- os.write(self.socket.fileno(), b(''))
- except (OSError, socket.error):
- err = sys.exc_info()[1]
- if err.args[0] in (errno.EINTR, errno.EWOULDBLOCK,
- errno.ENOBUFS):
- return
- elif err.args[0] in _DISCONNECTED:
- return super(SSLConnection, self).close()
- else:
- raise
+ if
os.name == 'posix':
+ # since SSL_shutdown() doesn't report errors, an empty
+ # write call is done first, to try to detect if the
+ # connection has gone away
+ try:
+ os.write(self.socket.fileno(), b(''))
+ except (OSError, socket.error):
+ err = sys.exc_info()[1]
+ if err.args[0] in (errno.EINTR, errno.EWOULDBLOCK,
+ errno.ENOBUFS):
+ return
+ elif err.args[0] in _DISCONNECTED:
+ return super(SSLConnection, self).close()
+ else:
+ raise
# Ok, this a mess, but the underlying OpenSSL API simply
# *SUCKS* and I really couldn't do any better.
#
=======================================
--- /trunk/test/test_ftpd.py Mon Dec 30 11:33:10 2013 UTC
+++ /trunk/test/test_ftpd.py Mon Dec 30 11:46:07 2013 UTC
@@ -55,10 +55,13 @@
import ssl
except ImportError:
ssl = None
-try:
- import sendfile
-except ImportError:
- sendfile = None
+
+sendfile = None
+if
os.name == 'posix':
+ try:
+ import sendfile
+ except ImportError:
+ pass
from pyftpdlib._compat import PY3, u, b, getcwdu, callable
from pyftpdlib.authorizers import DummyAuthorizer, AuthenticationFailed