Changeset 2748 for package_branches


Ignore:
Timestamp:
Dec 21, 2009, 1:10:18 AM (14 years ago)
Author:
broder
Message:

Allow passing a different command for each ajaxterm invocation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • package_branches/invirt-web/ajaxterm-rebased/code/ajaxterm.py

    r2747 r2748  
    368368
    369369class Multiplex:
    370         def __init__(self,cmd=None):
     370        def __init__(self):
    371371                signal.signal(signal.SIGCHLD, signal.SIG_IGN)
    372                 self.cmd=cmd
    373372                self.proc={}
    374373                self.lock=threading.RLock()
     
    380379                        setattr(self,name,SynchronizedMethod(self.lock,orig))
    381380                self.thread.start()
    382         def create(self,w=80,h=25):
     381        def create(self,cmd,w=80,h=25):
    383382                pid,fd=pty.fork()
    384383                if pid==0:
     
    392391                                except OSError:
    393392                                        pass
    394                         if self.cmd:
    395                                 cmd=['/bin/sh','-c',self.cmd]
    396                         elif os.getuid()==0:
    397                                 cmd=['/bin/login']
    398                         else:
    399                                 sys.stdout.write("Login: ")
    400                                 login=sys.stdin.readline().strip()
    401                                 if re.match('^[0-9A-Za-z-_. ]+$',login):
    402                                         cmd=['ssh']
    403                                         cmd+=['-oPreferredAuthentications=keyboard-interactive,password']
    404                                         cmd+=['-oNoHostAuthenticationForLocalhost=yes']
    405                                         cmd+=['-oLogLevel=FATAL']
    406                                         cmd+=['-F/dev/null','-l',login,'localhost']
    407                                 else:
    408                                         os._exit(0)
    409393                        env={}
    410394                        env["COLUMNS"]=str(w)
Note: See TracChangeset for help on using the changeset viewer.