Xpra: Ticket #1259: ~/.xpra/run-xpra gets bigger and bigger during every start

In server.py::run_server() the shell script ~/.xpra/run_server is unconditionally newly written during every start. As PATH, LD_LIBRARY_PATH, and PYTHONPATH are written as

    PATH="curValue":$PATH"; export PATH

these definitions get longer after every start. During every start one set of default values is added to these definitions.

The same is true for all string escaping. E.g. after some few server restarts:

    SSH_CONNECTION="192.168.2.152\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 33114\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 192.168.2.115\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 22"; export SSH_CONNECTION


Tue, 19 Jul 2016 17:46:41 GMT - Antoine Martin: owner changed

This obviously only occurs when starting the server via the run-xpra script, ie: when starting over ssh.

r13040 fixes the paths accumulating duplicates. (will backport)


The other one is more tricky. This is not what I expected to see (with tcsh or bash without the "set"):

$ set SSH_CONNECTION="127.0.0.1\ 52958\ 127.0.0.1\ 22"
$ echo $SSH_CONNECTION
127.0.0.1\ 52958\ 127.0.0.1\ 22

Or more simply:

$ x="\ "
$ echo $x
\

Despite what I am reading here: Which characters need to be escaped in Bash? How do we know it?, it looks like the space character does not need escaping? Escaping it leads to the backslash ending up in the string... causing more trouble every time as it too gets escaped.

Suggestions welcome.


Wed, 20 Jul 2016 14:37:39 GMT - floemker:

Perhaps

def sh_quotemeta(s):
    return "'" + s.replace("'", "'\\''") + "'"

or something similar (untested)?


Wed, 20 Jul 2016 19:23:42 GMT - Antoine Martin: status changed; resolution set

Applied in r13057. Seems to work, but I won't be backporting this to older branches (seems too risky), at least not for now.


Mon, 14 Nov 2016 16:39:14 GMT - Antoine Martin:

Backported to v0.17.x branch in r14416 to fix #1357.


Sat, 23 Jan 2021 05:19:22 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/1259