xpra icon
Bug tracker and wiki

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


Ticket #576: 0001-add-target-session-option-that-allow-client-select-a.patch

File 0001-add-target-session-option-that-allow-client-select-a.patch, 6.0 KB (added by Benoit Gschwind, 7 years ago)

patch that implement --target-session

  • src/xpra/client/client_base.py

    From 48151cd5ac077338b6b529d5f37b630e49c5d280 Mon Sep 17 00:00:00 2001
    From: Benoit Gschwind <gschwind@gnu-log.net>
    Date: Fri, 23 May 2014 22:25:03 +0200
    Subject: [PATCH] add --target-session option that allow client select any
     server
    
    The proxy can redirect session to any server if the client request it
    with the option --target-session, this work with PAM authetification and
    encryption enable.
    
    this patch also add an early option that ask password if no password
    file is sellected.
    ---
     src/xpra/client/client_base.py   | 18 +++++++++++++++---
     src/xpra/scripts/config.py       |  2 ++
     src/xpra/scripts/main.py         |  3 +++
     src/xpra/server/auth/pam_auth.py |  2 ++
     src/xpra/server/proxy_server.py  |  4 ++++
     5 files changed, 26 insertions(+), 3 deletions(-)
    
    diff --git a/src/xpra/client/client_base.py b/src/xpra/client/client_base.py
    index da3b9e4..9273f7f 100644
    a b class XpraClientBase(object): 
    7474        self.compression_level = 0
    7575        self.display = None
    7676        self.username = None
     77        self.target_session = None
    7778        self.password_file = None
    7879        self.password_sent = False
    7980        self.encryption = None
    class XpraClientBase(object): 
    106107        self.compression_level = opts.compression_level
    107108        self.display = opts.display
    108109        self.username = opts.username
     110        self.target_session = opts.target_session
    109111        self.password_file = opts.password_file
    110112        self.encryption = opts.encryption
    111113        self.encryption_keyfile = opts.encryption_keyfile
    class XpraClientBase(object): 
    229231                })
    230232        if self.display:
    231233            capabilities["display"] = self.display
     234        if self.target_session:
     235            capabilities["target_session"] = self.target_session
    232236        capabilities.update(get_platform_info("platform"))
    233237        capabilities.update(get_version_info("build"))
    234238        mid = get_machine_id()
    class XpraClientBase(object): 
    347351    def _process_challenge(self, packet):
    348352        log("processing challenge: %s", packet[1:])
    349353        if not self.password_file:
    350             self.warn_and_quit(EXIT_PASSWORD_REQUIRED, "server requires authentication, please provide a password")
    351             return
    352         password = self.load_password()
     354            ## TODO: use ssh-askpass when needed
     355            print "Not password file please enter the password:"
     356            password = sys.stdin.readline()
     357            password = password.strip("\n\r") # remove '\n'
     358            log("password read from stdin is %s", "".join(["*" for _ in password]))
     359            # HACK
     360            self.password_file = "/dev/null"
     361            #self.warn_and_quit(EXIT_PASSWORD_REQUIRED, "server requires authentication, please provide a password")
     362            #return
     363        else:
     364            password = self.load_password()
    353365        if not password:
    354366            self.warn_and_quit(EXIT_PASSWORD_FILE_ERROR, "failed to load password from file %s" % self.password_file)
    355367            return
  • src/xpra/scripts/config.py

    diff --git a/src/xpra/scripts/config.py b/src/xpra/scripts/config.py
    index 1198c34..83b3ba0 100644
    a b OPTION_TYPES = { 
    233233                    "border"            : str,
    234234                    "window-layout"     : str,
    235235                    "display"           : str,
     236                    "target-session"    : str,
    236237                    "tcp-proxy"         : str,
    237238                    "debug"             : str,
    238239                    #int options:
    def get_defaults(): 
    328329                    "border"            : "auto,0",
    329330                    "window-layout"     : "",
    330331                    "display"           : "",
     332                    "target-session"    : "",
    331333                    "tcp-proxy"         : "",
    332334                    "debug"             : "",
    333335                    "quality"           : -1,
  • src/xpra/scripts/main.py

    diff --git a/src/xpra/scripts/main.py b/src/xpra/scripts/main.py
    index fb393ea..15a9580 100644
    a b def parse_cmdline(cmdline): 
    438438    group.add_option("--username", action="store",
    439439                      dest="username", default=defaults.username,
    440440                      help="The username supplied by the client for authentication (default: '%default')")
     441    group.add_option("--target-session", action="store",
     442                      dest="target_session", default=defaults.target_session,
     443                      help="TODO")
    441444    group.add_option("--auth", action="store",
    442445                      dest="auth", default=defaults.auth,
    443446                      help="The authentication module (default: '%default')")
  • src/xpra/server/auth/pam_auth.py

    diff --git a/src/xpra/server/auth/pam_auth.py b/src/xpra/server/auth/pam_auth.py
    index 5abb478..c908a48 100644
    a b class Authenticator(SysAuthenticator): 
    7979    def __str__(self):
    8080        return "PAM Authenticator"
    8181
     82def init(opts):
     83    pass
    8284
    8385def main(args):
    8486    if len(args)!=3:
  • src/xpra/server/proxy_server.py

    diff --git a/src/xpra/server/proxy_server.py b/src/xpra/server/proxy_server.py
    index 2ed221a..c6c8564 100644
    a b class ProxyServer(ServerCore): 
    154154            disconnect("no displays found")
    155155            return
    156156        display = c.strget("display")
     157        target_session = c.strget("target_session")
    157158        proxy_virtual_display = os.environ["DISPLAY"]
    158159        #ensure we don't loop back to the proxy:
    159160        if proxy_virtual_display in displays:
    class ProxyServer(ServerCore): 
    165166            if display not in displays:
    166167                disconnect("display not found")
    167168                return
     169        elif target_session:
     170            display = target_session
     171            displays.append(target_session)
    168172        else:
    169173            if len(displays)!=1:
    170174                disconnect("please specify a display (more than one available)")