示例#1
0
 def do_process_challenge_prompt(self, packet, prompt="password"):
     authlog("do_process_challenge_prompt() use_tty=%s", use_tty())
     if use_tty():
         import getpass
         authlog("stdin isatty, using password prompt")
         password = getpass.getpass("%s :" %
                                    self.get_challenge_prompt(prompt))
         authlog("password read from tty via getpass: %s", obsc(password))
         self.send_challenge_reply(packet, password)
         return True
     else:
         from xpra.platform.paths import get_nodock_command
         cmd = get_nodock_command() + ["_pass", prompt]
         try:
             from subprocess import Popen, PIPE
             proc = Popen(cmd, stdout=PIPE)
             getChildReaper().add_process(proc, "password-prompt", cmd,
                                          True, True)
             out, err = proc.communicate(None, 60)
             authlog("err(%s)=%s", cmd, err)
             password = out.decode()
             self.send_challenge_reply(packet, password)
             return True
         except Exception:
             log("Error: failed to show GUi for password prompt",
                 exc_info=True)
     return False
示例#2
0
 def update_loop(self):
     while self.exit_code is None:
         self.update_screen()
         curses.halfdelay(50)
         v = self.stdscr.getch()
         #print("v=%s" % (v,))
         if v in EXIT_KEYS:
             self.exit_code = 0
         elif v == 258:  #down arrow
             self.position += 1
         elif v == 259:  #up arrow
             self.position = max(self.position - 1, 0)
         elif v == 10 and self.selected_session:
             #show this session:
             cmd = get_nodock_command() + ["top", self.selected_session]
             try:
                 self.cleanup()
                 proc = Popen(cmd)
                 exit_code = proc.wait()
                 #TODO: show exit code, especially if non-zero
             finally:
                 self.stdscr = curses_init()
         elif v in (ord("s"), ord("S")):
             self.run_subcommand("stop")
         elif v in (ord("a"), ord("A")):
             self.run_subcommand("attach")
         elif v in (ord("d"), ord("D")):
             self.run_subcommand("detach")
示例#3
0
 def get_session_info(self, sockpath):
     #the lazy way using a subprocess
     cmd = get_nodock_command()+["id", "socket:%s" % sockpath]
     p = subprocess.Popen(cmd, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     stdout, _ = p.communicate()
     log("get_sessions_info(%s) returncode(%s)=%s", sockpath, cmd, p.returncode)
     if p.returncode!=0:
         return None
     out = bytestostr(stdout)
     info = {}
     for line in out.splitlines():
         parts = line.split("=", 1)
         if len(parts)==2:
             info[parts[0]] = parts[1]
     log("get_sessions_info(%s)=%s", sockpath, info)
     return info
示例#4
0
 def get_display_id_info(self, path):
     d = {}
     try:
         cmd = get_nodock_command() + ["id", "socket://%s" % path]
         proc = Popen(cmd, stdout=PIPE, stderr=PIPE)
         out, err = proc.communicate()
         for line in bytestostr(out or err).splitlines():
             try:
                 k, v = line.split("=", 1)
                 d[k] = v
             except ValueError:
                 continue
         return d
     except Exception as e:
         d["error"] = str(e)
     return d
示例#5
0
 def do_run_subcommand(self, subcommand, **kwargs):
     cmd = get_nodock_command() + [subcommand, self.selected_session]
     try:
         return Popen(cmd, **kwargs)
     except Exception:
         return None
示例#6
0
 def run_subcommand(self, subcommand):
     cmd = get_nodock_command() + [subcommand, self.selected_session]
     try:
         Popen(cmd, stdout=DEVNULL, stderr=DEVNULL)
     except:
         pass