summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xfot.py2
-rw-r--r--login.py11
2 files changed, 9 insertions, 4 deletions
diff --git a/fot.py b/fot.py
index ae6d564..c2470cf 100755
--- a/fot.py
+++ b/fot.py
@@ -119,7 +119,7 @@ for server in config.sections():
reactor.connectTCP(config.get(server, 'host'), config.getint(server, 'port'), factory)
# TODO: Fix user/pass
-loginfactory = login.getManholeFactory(globals(), user = 'pass')
+loginfactory = login.getManholeFactory(globals(), os.path.expanduser('~/.fot.users'))
reactor.listenTCP(3333, loginfactory)
reactor.run()
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()