summaryrefslogtreecommitdiff
path: root/login.py
diff options
context:
space:
mode:
Diffstat (limited to 'login.py')
-rw-r--r--login.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/login.py b/login.py
index 869f678..6c95e56 100644
--- a/login.py
+++ b/login.py
@@ -1,7 +1,11 @@
from twisted.cred import portal, checkers
from twisted.conch import manhole, manhole_ssh
+import hashlib
-def getManholeFactory(namespace, **passwords):
+def hash(username, netpass, localpass):
+ return hashlib.sha1(netpass).hexdigest()
+
+def getManholeFactory(namespace, filename):
def getManhole(_):
return manhole.Manhole(namespace)
@@ -9,12 +13,13 @@ def getManholeFactory(namespace, **passwords):
realm.chainedProtocolFactory.protocolFactory = getManhole
p = portal.Portal(realm)
- p.registerChecker(checkers.InMemoryUsernamePasswordDatabaseDontUse(**passwords))
+ p.registerChecker(checkers.FilePasswordDB(filename, hash = hash))
return manhole_ssh.ConchFactory(p)
if __name__ == '__main__':
from twisted.internet import reactor
- factory = getManholeFactory({'x': 'foo'}, user = 'pass')
+ import os
+ factory = getManholeFactory({'x': 'foo'}, os.path.expanduser('~/.fot.users'))
reactor.listenTCP(5022, factory)
reactor.run()