diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2010-02-23 21:08:36 +0100 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2010-02-23 21:08:36 +0100 |
commit | 7a7cce4fae7d530e14d7e107555b3fa113609e73 (patch) | |
tree | f2a65e8e81c0a8223dad9415f447cb5b4e05d5a7 | |
parent | 19f5595b2532379c3ec30e4ef02b694f5693b8b1 (diff) |
Use ~/.fot.users to authenticate users.
-rwxr-xr-x | fot.py | 2 | ||||
-rw-r--r-- | login.py | 11 |
2 files changed, 9 insertions, 4 deletions
@@ -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() @@ -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() |