from allmydata.control import ControlServer
from allmydata.introducer.client import IntroducerClient
from allmydata.util import hashutil, base32, pollmixin, log, keyutil, idlib
-from allmydata.util.encodingutil import get_filesystem_encoding
+from allmydata.util.encodingutil import get_filesystem_encoding, \
+ from_utf8_or_none
from allmydata.util.fileutil import abspath_expanduser_unicode
from allmydata.util.abbreviate import parse_abbreviated_size
from allmydata.util.time_format import parse_duration, parse_date
def init_ftp_server(self):
if self.get_config("ftpd", "enabled", False, boolean=True):
- accountfile = from_utf8_or_none(self.get_config("ftpd", "accounts.file", None))
+ accountfile = from_utf8_or_none(
+ self.get_config("ftpd", "accounts.file", None))
+ if accountfile:
+ accountfile = abspath_expanduser_unicode(accountfile, base=self.basedir)
accounturl = self.get_config("ftpd", "accounts.url", None)
ftp_portstr = self.get_config("ftpd", "port", "8021")
def init_sftp_server(self):
if self.get_config("sftpd", "enabled", False, boolean=True):
- accountfile = from_utf8_or_none(self.get_config("sftpd", "accounts.file", None))
+ accountfile = from_utf8_or_none(
+ self.get_config("sftpd", "accounts.file", None))
+ if accountfile:
+ accountfile = abspath_expanduser_unicode(accountfile, base=self.basedir)
accounturl = self.get_config("sftpd", "accounts.url", None)
sftp_portstr = self.get_config("sftpd", "port", "8022")
pubkey_file = from_utf8_or_none(self.get_config("sftpd", "host_pubkey_file"))
+from types import NoneType
+
from zope.interface import implements
from twisted.application import service, strports
from twisted.internet import defer
NoSuchChildError
from allmydata.immutable.upload import FileHandle
from allmydata.util.fileutil import EncryptedTemporaryFile
+from allmydata.util.assertutil import precondition
class ReadFile:
implements(ftp.IReadFile)
class FTPServer(service.MultiService):
def __init__(self, client, accountfile, accounturl, ftp_portstr):
- precondition(isinstance(accountfile, unicode), accountfile)
+ precondition(isinstance(accountfile, (unicode, NoneType)), accountfile)
service.MultiService.__init__(self)
r = Dispatcher(client)
from allmydata.util.assertutil import _assert, precondition
from allmydata.util.consumer import download_to_data
+from allmydata.util.encodingutil import get_filesystem_encoding
from allmydata.interfaces import IFileNode, IDirectoryNode, ExistingChildError, \
NoSuchChildError, ChildOfWrongTypeError
from allmydata.mutable.common import NotWriteableError
class SFTPServer(service.MultiService):
def __init__(self, client, accountfile, accounturl,
sftp_portstr, pubkey_file, privkey_file):
- precondition(isinstance(accountfile, unicode), accountfile)
+ precondition(isinstance(accountfile, (unicode, NoneType)), accountfile)
precondition(isinstance(pubkey_file, unicode), pubkey_file)
precondition(isinstance(privkey_file, unicode), privkey_file)
service.MultiService.__init__(self)
import allmydata
from allmydata.node import Node, OldConfigError, OldConfigOptionError, MissingConfigEntry, UnescapedHashError
+from allmydata.frontends.auth import NeedRootcapLookupScheme
from allmydata import client
from allmydata.storage_client import StorageFarmBroker
from allmydata.manhole import AuthorizedKeysManhole
expected = fileutil.abspath_expanduser_unicode(u"relative", abs_basedir)
self.failUnlessReallyEqual(m.keyfile, expected)
+ # TODO: also test config options for SFTP.
+
+ def test_ftp_auth_keyfile(self):
+ basedir = u"client.Basic.test_ftp_auth_keyfile"
+ os.mkdir(basedir)
+ fileutil.write(os.path.join(basedir, "tahoe.cfg"),
+ (BASECONFIG +
+ "[ftpd]\n"
+ "enabled = true\n"
+ "port = tcp:0:interface=127.0.0.1\n"
+ "accounts.file = private/accounts\n"))
+ os.mkdir(os.path.join(basedir, "private"))
+ fileutil.write(os.path.join(basedir, "private", "accounts"), "\n")
+ c = client.Client(basedir) # just make sure it can be instantiated
+ del c
+
+ def test_ftp_auth_url(self):
+ basedir = u"client.Basic.test_ftp_auth_url"
+ os.mkdir(basedir)
+ fileutil.write(os.path.join(basedir, "tahoe.cfg"),
+ (BASECONFIG +
+ "[ftpd]\n"
+ "enabled = true\n"
+ "port = tcp:0:interface=127.0.0.1\n"
+ "accounts.url = http://0.0.0.0/\n"))
+ c = client.Client(basedir) # just make sure it can be instantiated
+ del c
+
+ def test_ftp_auth_no_accountfile_or_url(self):
+ basedir = u"client.Basic.test_ftp_auth_no_accountfile_or_url"
+ os.mkdir(basedir)
+ fileutil.write(os.path.join(basedir, "tahoe.cfg"),
+ (BASECONFIG +
+ "[ftpd]\n"
+ "enabled = true\n"
+ "port = tcp:0:interface=127.0.0.1\n"))
+ self.failUnlessRaises(NeedRootcapLookupScheme, client.Client, basedir)
+
def _permute(self, sb, key):
return [ s.get_longname() for s in sb.get_servers_for_psi(key) ]