Make ajaxterm play nicely with CherryPy
[invirt/packages/invirt-web.git] / code / ajaxterm.py
index 8b3af37..dd7e5b8 100644 (file)
@@ -367,19 +367,18 @@ class SynchronizedMethod:
                return r
 
 class Multiplex:
-       def __init__(self,cmd=None):
-               signal.signal(signal.SIGCHLD, signal.SIG_IGN)
-               self.cmd=cmd
+       def __init__(self):
                self.proc={}
                self.lock=threading.RLock()
                self.thread=threading.Thread(target=self.loop)
+               self.thread.daemon=True
                self.alive=1
                # synchronize methods
                for name in ['create','fds','proc_read','proc_write','dump','die','run']:
                        orig=getattr(self,name)
                        setattr(self,name,SynchronizedMethod(self.lock,orig))
                self.thread.start()
-       def create(self,w=80,h=25):
+       def create(self,cmd,w=80,h=25):
                pid,fd=pty.fork()
                if pid==0:
                        try:
@@ -391,21 +390,6 @@ class Multiplex:
                                        os.close(i)
                                except OSError:
                                        pass
-                       if self.cmd:
-                               cmd=['/bin/sh','-c',self.cmd]
-                       elif os.getuid()==0:
-                               cmd=['/bin/login']
-                       else:
-                               sys.stdout.write("Login: ")
-                               login=sys.stdin.readline().strip()
-                               if re.match('^[0-9A-Za-z-_. ]+$',login):
-                                       cmd=['ssh']
-                                       cmd+=['-oPreferredAuthentications=keyboard-interactive,password']
-                                       cmd+=['-oNoHostAuthenticationForLocalhost=yes']
-                                       cmd+=['-oLogLevel=FATAL']
-                                       cmd+=['-F/dev/null','-l',login,'localhost']
-                               else:
-                                       os._exit(0)
                        env={}
                        env["COLUMNS"]=str(w)
                        env["LINES"]=str(h)