diff options
-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() |