]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Merge branch 'ftp-2394'
authorBrian Warner <warner@lothar.com>
Tue, 31 Mar 2015 18:07:48 +0000 (11:07 -0700)
committerBrian Warner <warner@lothar.com>
Tue, 31 Mar 2015 18:07:48 +0000 (11:07 -0700)
closes ticket:2394

src/allmydata/_auto_deps.py
src/allmydata/frontends/ftpd.py
src/allmydata/test/test_ftp.py

index 3c00f61d370efc82f29fe6123f2e682dcfb7a946..a42bc17b85fca86fc9e47424b138cb3254571133 100644 (file)
@@ -110,10 +110,12 @@ if sys.platform == "win32":
         #   which includes the fix to <https://twistedmatrix.com/trac/ticket/411>.
         # * The SFTP frontend depends on Twisted 11.0.0 to fix the SSH server
         #   rekeying bug <https://twistedmatrix.com/trac/ticket/4395>
+        # * The FTP frontend depends on Twisted >=11.1.0 for
+        #   filepath.Permissions
         # * We don't want Twisted >= 12.2.0 to avoid a dependency of its endpoints
         #   code on pywin32. <https://tahoe-lafs.org/trac/tahoe-lafs/ticket/2028>
         #
-        "Twisted >= 11.0.0, <= 12.1.0",
+        "Twisted >= 11.1.0, <= 12.1.0",
 
         # * We need Nevow >= 0.9.33 to avoid a bug in Nevow's setup.py
         #   which imported twisted at setup time.
index 9922a86ad8b38429c1626af65b770f5eea80f364..9791b813aca3dea68858c3e3e5527d29463892e8 100644 (file)
@@ -6,6 +6,7 @@ from twisted.application import service, strports
 from twisted.internet import defer
 from twisted.internet.interfaces import IConsumer
 from twisted.cred import portal
+from twisted.python import filepath
 from twisted.protocols import ftp
 
 from allmydata.interfaces import IDirectoryNode, ExistingChildError, \
@@ -61,6 +62,17 @@ class WriteFile:
 class NoParentError(Exception):
     pass
 
+# filepath.Permissions was added in Twisted-11.1.0, which we require. Twisted
+# <15.0.0 expected an int, and only does '&' on it. Twisted >=15.0.0 expects
+# a filepath.Permissions. This satisfies both.
+
+class IntishPermissions(filepath.Permissions):
+    def __init__(self, statModeInt):
+        self._tahoe_statModeInt = statModeInt
+        filepath.Permissions.__init__(self, statModeInt)
+    def __and__(self, other):
+        return self._tahoe_statModeInt & other
+
 class Handler:
     implements(ftp.IFTPShell)
     def __init__(self, client, rootnode, username, convergence):
@@ -200,7 +212,12 @@ class Handler:
             elif key == "directory":
                 value = isdir
             elif key == "permissions":
-                value = 0600
+                # Twisted-14.0.2 (and earlier) expected an int, and used it
+                # in a rendering function that did (mode & NUMBER).
+                # Twisted-15.0.0 expects a
+                # twisted.python.filepath.Permissions , and calls its
+                # .shorthand() method. This provides both.
+                value = IntishPermissions(0600)
             elif key == "hardlinks":
                 value = 1
             elif key == "modified":
index c98a320966224265a11a924942816a2c80556594..9457e540ac8cfcd51c019604b701d7e254c2ed15 100644 (file)
@@ -93,12 +93,12 @@ class Handler(GridTestMixin, ReallyEqualMixin, unittest.TestCase):
 
         expected_root = [
             ('loop',
-             [0, True, 0600, 1, self.FALL_OF_BERLIN_WALL, 'alice', 'alice', '??']),
+             [0, True, ftpd.IntishPermissions(0600), 1, self.FALL_OF_BERLIN_WALL, 'alice', 'alice', '??']),
             ('immutable',
-             [23, False, 0600, 1, self.TURN_OF_MILLENIUM, 'alice', 'alice', '??']),
+             [23, False, ftpd.IntishPermissions(0600), 1, self.TURN_OF_MILLENIUM, 'alice', 'alice', '??']),
             ('mutable',
              # timestamp should be 0 if no timestamp metadata is present
-             [0, False, 0600, 1, 0, 'alice', 'alice', '??'])]
+             [0, False, ftpd.IntishPermissions(0600), 1, 0, 'alice', 'alice', '??'])]
 
         d.addCallback(lambda root: self._compareDirLists(root, expected_root))