From: Daira Hopwood Date: Tue, 3 Mar 2015 20:06:35 +0000 (+0000) Subject: Ensure that path parameters to SFTPServer and FTPServer constructors are unicode... X-Git-Tag: allmydata-tahoe-1.10.1a1~52 X-Git-Url: https://git.rkrishnan.org/pf/content/simplejson/frontends/%3C?a=commitdiff_plain;h=3066039f0f802406675e30f5521f98fb79d444a8;p=tahoe-lafs%2Ftahoe-lafs.git Ensure that path parameters to SFTPServer and FTPServer constructors are unicode. refs #2388 Signed-off-by: Daira Hopwood --- diff --git a/src/allmydata/client.py b/src/allmydata/client.py index 42c2ff38..b67c78b0 100644 --- a/src/allmydata/client.py +++ b/src/allmydata/client.py @@ -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, diff --git a/src/allmydata/frontends/ftpd.py b/src/allmydata/frontends/ftpd.py index 4ccb0919..c625f2ac 100644 --- a/src/allmydata/frontends/ftpd.py +++ b/src/allmydata/frontends/ftpd.py @@ -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) diff --git a/src/allmydata/frontends/sftpd.py b/src/allmydata/frontends/sftpd.py index f6e11ced..a18af9c4 100644 --- a/src/allmydata/frontends/sftpd.py +++ b/src/allmydata/frontends/sftpd.py @@ -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}