from twisted.cred import error, checkers, credentials
from allmydata.util import base32
+class NeedRootcapLookupScheme(Exception):
+ """Accountname+Password-based access schemes require some kind of
+ mechanism to translate name+passwd pairs into a rootcap, either a file of
+ name/passwd/rootcap tuples, or a server to do the translation."""
+
class FTPAvatarID:
def __init__(self, username, rootcap):
self.username = username
d.addCallback(_got_parent)
return d
-from auth import AccountURLChecker, AccountFileChecker
+from auth import AccountURLChecker, AccountFileChecker, NeedRootcapLookupScheme
class Dispatcher:
p.registerChecker(c)
if not accountfile and not accounturl:
# we could leave this anonymous, with just the /uri/CAP form
- raise RuntimeError("must provide some translation")
+ raise NeedRootcapLookupScheme("must provide some translation")
f = ftp.FTPFactory(p)
s = strports.service(ftp_portstr, f)
class FakeStat:
pass
+class BadRemoveRequest(Exception):
+ pass
+
class SFTPHandler:
implements(ISFTPServer)
def __init__(self, user):
d = parent.get(childname)
def _got_child(child):
if must_be_directory and not IDirectoryNode.providedBy(child):
- raise RuntimeError("rmdir called on a file")
+ raise BadRemoveRequest("rmdir called on a file")
if must_be_file and IDirectoryNode.providedBy(child):
- raise RuntimeError("rmfile called on a directory")
+ raise BadRemoveRequest("rmfile called on a directory")
return parent.delete(childname)
d.addCallback(_got_child)
d.addErrback(self._convert_error)
# then you get SFTPHandler(user)
components.registerAdapter(SFTPHandler, SFTPUser, ISFTPServer)
-from auth import AccountURLChecker, AccountFileChecker
+from auth import AccountURLChecker, AccountFileChecker, NeedRootcapLookupScheme
class Dispatcher:
implements(portal.IRealm)
p.registerChecker(c)
if not accountfile and not accounturl:
# we could leave this anonymous, with just the /uri/CAP form
- raise RuntimeError("must provide some translation")
+ raise NeedRootcapLookupScheme("must provide some translation")
pubkey = keys.Key.fromFile(pubkey_file)
privkey = keys.Key.fromFile(privkey_file)