]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Ensure that path parameters to SFTPServer and FTPServer constructors are unicode...
authorDaira Hopwood <daira@jacaranda.org>
Tue, 3 Mar 2015 20:06:35 +0000 (20:06 +0000)
committerDaira Hopwood <daira@jacaranda.org>
Tue, 24 Mar 2015 16:46:40 +0000 (16:46 +0000)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/client.py
src/allmydata/frontends/ftpd.py
src/allmydata/frontends/sftpd.py

index 42c2ff384fe2ef6dff487dcc749c09a18d3c5f41..b67c78b039d670399267fbf24f7c6b6a6bc72480 100644 (file)
@@ -458,7 +458,7 @@ class Client(node.Node, pollmixin.PollMixin):
 
     def init_ftp_server(self):
         if self.get_config("ftpd", "enabled", False, boolean=True):
-            accountfile = self.get_config("ftpd", "accounts.file", None)
+            accountfile = from_utf8_or_none(self.get_config("ftpd", "accounts.file", None))
             accounturl = self.get_config("ftpd", "accounts.url", None)
             ftp_portstr = self.get_config("ftpd", "port", "8021")
 
@@ -468,11 +468,11 @@ class Client(node.Node, pollmixin.PollMixin):
 
     def init_sftp_server(self):
         if self.get_config("sftpd", "enabled", False, boolean=True):
-            accountfile = self.get_config("sftpd", "accounts.file", None)
+            accountfile = from_utf8_or_none(self.get_config("sftpd", "accounts.file", None))
             accounturl = self.get_config("sftpd", "accounts.url", None)
             sftp_portstr = self.get_config("sftpd", "port", "8022")
-            pubkey_file = self.get_config("sftpd", "host_pubkey_file")
-            privkey_file = self.get_config("sftpd", "host_privkey_file")
+            pubkey_file = from_utf8_or_none(self.get_config("sftpd", "host_pubkey_file"))
+            privkey_file = from_utf8_or_none(self.get_config("sftpd", "host_privkey_file"))
 
             from allmydata.frontends import sftpd
             s = sftpd.SFTPServer(self, accountfile, accounturl,
index 4ccb091919536f241c9e113b52898233aa52fbe8..c625f2ac21ccbc646eb0528b3487c3e6484ec0cb 100644 (file)
@@ -288,6 +288,7 @@ class Dispatcher:
 
 class FTPServer(service.MultiService):
     def __init__(self, client, accountfile, accounturl, ftp_portstr):
+        precondition(isinstance(accountfile, unicode), accountfile)
         service.MultiService.__init__(self)
 
         r = Dispatcher(client)
index f6e11cedf0022e64ba8f9c8120acac1e48782ddc..a18af9c4e1350df96118b03a1ffad8adcb241719 100644 (file)
@@ -1979,6 +1979,9 @@ class Dispatcher:
 class SFTPServer(service.MultiService):
     def __init__(self, client, accountfile, accounturl,
                  sftp_portstr, pubkey_file, privkey_file):
+        precondition(isinstance(accountfile, unicode), accountfile)
+        precondition(isinstance(pubkey_file, unicode), pubkey_file)
+        precondition(isinstance(privkey_file, unicode), privkey_file)
         service.MultiService.__init__(self)
 
         r = Dispatcher(client)
@@ -1994,8 +1997,8 @@ class SFTPServer(service.MultiService):
             # we could leave this anonymous, with just the /uri/CAP form
             raise NeedRootcapLookupScheme("must provide an account file or URL")
 
-        pubkey = keys.Key.fromFile(pubkey_file)
-        privkey = keys.Key.fromFile(privkey_file)
+        pubkey = keys.Key.fromFile(pubkey_file.encode(get_filesystem_encoding()))
+        privkey = keys.Key.fromFile(privkey_file.encode(get_filesystem_encoding()))
         class SSHFactory(factory.SSHFactory):
             publicKeys = {pubkey.sshType(): pubkey}
             privateKeys = {privkey.sshType(): privkey}