xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #2041: ssh-2hop-v4.1.patch

File ssh-2hop-v4.1.patch, 6.9 KB (added by Nathan Hallquist, 3 years ago)
  • xpra/client/gtk_base/client_launcher.py

    diff -Nru xpra/client/gtk_base/client_launcher.py ../xpra.3.ant/xpra/client/gtk_base/client_launcher.py
    old new  
    7777                        "port"              : -1,
    7878                        "username"          : get_username(),
    7979                        "password"          : "",
    80                         "mode"              : "ssh -> ssh",    #tcp,ssh,..
     80                        "mode"              : "ssh",    #tcp,ssh,..
    8181                        "autoconnect"       : False,
    8282                        "ssh_port"          : 22,
    8383                        "proxy_host"        : "",
     
    283283
    284284        # Password
    285285        hbox = gtk.HBox(False, 5)
     286        self.proxy_password_hbox = hbox
    286287        self.proxy_password_entry = gtk.Entry()
    287288        self.proxy_password_entry.set_max_length(128)
    288289        self.proxy_password_entry.set_width_chars(30)
     
    291292        self.proxy_password_entry.connect("changed", self.password_ok)
    292293        self.proxy_password_entry.connect("changed", self.validate)
    293294        self.proxy_password_entry.connect("activate", self.connect_clicked)
    294         self.proxy_password_label = gtk.Label("Proxy Password")
    295         hbox.pack_start(self.proxy_password_label, False, False)
     295        hbox.pack_start(gtk.Label("Proxy Password"), False, False)
    296296        hbox.pack_start(self.proxy_password_entry, True, True)
    297297        vbox_proxy.pack_start(hbox)
    298298
     
    310310
    311311        # Check boxes
    312312        hbox = gtk.HBox(False, 5)
     313        self.check_boxes_hbox = hbox
    313314        self.password_scb = gtk.CheckButton("Server password same as proxy")
    314315        self.password_scb.set_mode(True)
    315316        self.password_scb.set_active(True)
     
    366367
    367368        # Password
    368369        hbox = gtk.HBox(False, 5)
     370        self.password_hbox = hbox
    369371        self.password_entry = gtk.Entry()
    370372        self.password_entry.set_max_length(128)
    371373        self.password_entry.set_width_chars(30)
     
    373375        self.password_entry.set_visibility(False)
    374376        self.password_entry.connect("changed", self.password_ok)
    375377        self.password_entry.connect("changed", self.validate)
    376         self.password_label = gtk.Label("Server Password:")
    377         hbox.pack_start(self.password_label, False, False)
     378        self.password_entry.connect("activate", self.connect_clicked)
     379        hbox.pack_start(gtk.Label("Server Password:"), False, False)
    378380        hbox.pack_start(self.password_entry, True, True)
    379381        vbox.pack_start(hbox)
    380382
     
    610612            if self.config.port>0:
    611613                self.port_entry.set_text("%s" % self.config.port)
    612614        can_use_password = True
     615        sshpass = False
    613616        if ssh or sshtossh:
    614617            if not self.is_putty:
    615618                self.proxy_key_entry.set_text("OpenSSH/Paramiko use ~/.ssh")
     
    623626                from xpra.platform.paths import get_sshpass_command
    624627                sshpass = get_sshpass_command()
    625628                can_use_password = bool(sshpass)
     629                sshpass = bool(sshpass)
    626630        if can_use_password:
    627             self.password_label.show()
    628             self.password_entry.show()
     631            self.password_hbox.show()
    629632            if sshtossh:
    630                 self.proxy_password_label.show()
    631                 self.proxy_password_entry.show()
     633                self.proxy_password_hbox.show()
     634                # sshpass cannot do different username/passwords for proxy and destination
     635                if not sshpass:
     636                    self.check_boxes_hbox.show()
     637                else:
     638                    self.check_boxes_hbox.hide()
     639                    self.password_scb.set_active(True)
     640                    self.username_scb.set_active(True)
    632641        else:
    633             self.password_label.hide()
    634             self.password_entry.hide()
     642            self.password_hbox.hide()
    635643            if sshtossh:
    636                 self.proxy_password_label.hide()
    637                 self.proxy_password_entry.hide()
     644                self.check_boxes_hbox.hide()
     645                self.proxy_password_hbox.hide()
    638646        self.validate()
    639647        if mode=="ssl" or (mode=="ssh" and not WIN32):
    640648            self.nostrict_host_check.show()
     
    778786            if self.config.ssh_port and self.config.ssh_port!=22:
    779787                params["ssh-port"] = self.config.ssh_port
    780788            ssh_cmd = parse_ssh_string(self.config.ssh)
    781             self.is_putty = ssh_cmd.endswith("plink") or ssh_cmd.endswith("plink.exe")
    782             self.is_paramiko = ssh_cmd=="paramiko"
     789            ssh_cmd_0 = ssh_cmd[0].strip().lower()
     790            self.is_putty = ssh_cmd_0.endswith("plink") or ssh_cmd_0.endswith("plink.exe")
     791            self.is_paramiko = ssh_cmd_0 =="paramiko"
    783792            full_ssh = ssh_cmd[:]
    784793            full_ssh += add_ssh_args(username, password, host, self.config.ssh_port, self.is_putty, self.is_paramiko)
    785794            if username:
  • xpra/net/ssh.py

    diff -Nru xpra/net/ssh.py ../xpra.3.ant/xpra/net/ssh.py
    old new  
    1818from xpra.platform import get_username
    1919from xpra.net.bytestreams import SocketConnection, SOCKET_TIMEOUT, ConnectionClosedException
    2020from xpra.exit_codes import EXIT_SSH_KEY_FAILURE, EXIT_SSH_FAILURE
    21 from xpra.os_util import bytestostr, osexpand, monotonic_time, setsid, nomodule_context, umask_context, WIN32, OSX, POSIX
     21from xpra.os_util import bytestostr, osexpand, monotonic_time, setsid, nomodule_context, umask_context, is_WSL, WIN32, OSX, POSIX
    2222from xpra.util import envint, envbool, nonl, engs
    2323
    2424INITENV_COMMAND = os.environ.get("XPRA_INITENV_COMMAND", "xpra initenv")
  • xpra/scripts/main.py

    diff -Nru xpra/scripts/main.py ../xpra.3.ant/xpra/scripts/main.py
    old new  
    527527    if is_putty:
    528528        args += ["-proxycmd", " ".join(proxyline)]
    529529    elif not is_paramiko:
    530         from xpra.platform.paths import get_sshpass_command
    531         if password:
    532             sshpass_command = get_sshpass_command()
    533             if sshpass_command:
    534                 proxyline.insert(0, sshpass_command)
    535                 # is -e forces proxy password to match destination password
    536                 proxyline.insert(1, "-e")
    537530        args += ["-o", "ProxyCommand " + " ".join(proxyline)]
    538531    return args
    539532
     
    561554            raise RuntimeError("bad format: missing host in '%s'" % hostport)
    562555        desc_tmp["proxy_host"] = host
    563556        if hostport_match.group("port"):
    564             desc_tmp["proxy_port"] = hostport_match.group("ssh_port")
     557            desc_tmp["proxy_port"] = hostport_match.group("port")
    565558        userpass = reout.group("userpass")
    566559        if userpass:
    567560            # The username ends at the first colon. This decision was not unique: I could have