• R/O
  • SSH
  • HTTPS

pyhabu: Commit


Commit MetaInfo

Revision87 (tree)
Time2007-10-10 10:14:06
Authorliris

Log Message

manhole

Change Summary

Incremental Difference

--- trunk/habu/__init__.py (revision 86)
+++ trunk/habu/__init__.py (revision 87)
@@ -238,7 +238,7 @@
238238 return
239239 for key, config in serverConfig.iteritems():
240240 func = HABU_SERVER_SETUP_FACTORY_TAB.get(key, setupNullServer)
241- server = func(config)
241+ server = func(self, config)
242242 if server:
243243 self.servers.append(server)
244244
--- trunk/habu/server/habuweb.py (revision 86)
+++ trunk/habu/server/habuweb.py (revision 87)
@@ -137,7 +137,7 @@
137137 return self
138138 return resource.Resource.getChild(self, name, request)
139139
140-def createServerFactory(config):
140+def createServerFactory(app, config):
141141 root = HabuRootResource()
142142 resourceConfigs = config.get("resource", [])
143143 for cfg in resourceConfigs:
--- trunk/habu/server/__init__.py (revision 86)
+++ trunk/habu/server/__init__.py (revision 87)
@@ -10,13 +10,14 @@
1010 def start(self):
1111 reactor.listenTCP(self.port, self.factory, interface=self.addr)
1212
13-def setupWeb(config):
14- from habu.server import habuweb
15- factory = habuweb.createServerFactory(config)
13+
14+def _setup(mod, app, config):
1615 serverConfig = config.get("config", None)
1716 if not serverConfig:
1817 return None
1918
19+ factory = mod.createServerFactory(app, config)
20+
2021 addr = serverConfig.get("interface", "localhost")
2122 port = serverConfig.get("port", 0)
2223 if not factory or not port:
@@ -25,7 +26,16 @@
2526 return HabuServer(port, factory, addr)
2627
2728
29+def setupWeb(app, config):
30+ from habu.server import habuweb
31+ return _setup(habuweb, app, config)
2832
33+def setupShell(app, config):
34+ from habu.server import habushell
35+ return _setup(habushell, app, config)
36+
37+
2938 HABU_SERVER_SETUP_FACTORY_TAB = {
3039 "web": setupWeb,
40+ "shell": setupShell,
3141 }
--- trunk/habu/server/habushell.py (nonexistent)
+++ trunk/habu/server/habushell.py (revision 87)
@@ -0,0 +1,27 @@
1+from twisted.cred import portal, checkers
2+from twisted.conch import manhole, manhole_ssh
3+
4+def getManholeFactory(namespace, **passwords):
5+ realm = manhole_ssh.TerminalRealm()
6+ def getManhole(_):
7+ return manhole.Manhole(namespace)
8+ realm.chainedProtocolFactory.protocolFactory = getManhole
9+ p = portal.Portal(realm)
10+ p.registerChecker(
11+ checkers.InMemoryUsernamePasswordDatabaseDontUse(**passwords)
12+ )
13+ return manhole_ssh.ConchFactory(p)
14+
15+def createServerFactory(app, config):
16+ users = config.get("users", [])
17+ user_passwd = {}
18+ for up in users:
19+ user = up.get("userid")
20+ password = up.get("password")
21+ if user and password:
22+ user_passwd[user] = password
23+ namespace = globals()
24+ namespace["app"] = app
25+ return getManholeFactory(namespace, **user_passwd)
26+
27+
Show on old repository browser