Allow passing a different command for each ajaxterm invocation
authorQuentin Smith <quentin@mit.edu>
Tue, 11 Aug 2009 04:54:06 +0000 (00:54 -0400)
committerQuentin Smith <quentin@mit.edu>
Tue, 11 Aug 2009 04:54:06 +0000 (00:54 -0400)
svn path=/package_branches/invirt-web/ajaxterm-rebased/; revision=2748

code/ajaxterm.py

index 8b3af37..2b4ff44 100644 (file)
@@ -367,9 +367,8 @@ class SynchronizedMethod:
                return r
 
 class Multiplex:
-       def __init__(self,cmd=None):
+       def __init__(self):
                signal.signal(signal.SIGCHLD, signal.SIG_IGN)
-               self.cmd=cmd
                self.proc={}
                self.lock=threading.RLock()
                self.thread=threading.Thread(target=self.loop)
@@ -379,7 +378,7 @@ class Multiplex:
                        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)