Skip to content

Commit

Permalink
#3196 hide password from uri
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Jul 13, 2021
1 parent 6eff228 commit 28fec4d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
9 changes: 9 additions & 0 deletions xpra/os_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ def memoryview_to_bytes(v) -> bytes:
return strtobytes(v)


def set_proc_title(title):
print("set_proc_title: %s" % os.getpid())
try:
import setproctitle
setproctitle.setproctitle(title) #@UndefinedVariable
except ImportError as e:
get_util_logger().error("setproctitle not installed: %s", e)


def getuid() -> int:
if POSIX:
return os.getuid()
Expand Down
12 changes: 12 additions & 0 deletions xpra/scripts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from xpra.os_util import (
get_util_logger, getuid, getgid, get_username_for_uid,
monotonic_time, bytestostr, use_tty,
set_proc_title,
WIN32, OSX, POSIX, SIGNAMES, is_Ubuntu,
)
from xpra.scripts.parsing import (
Expand Down Expand Up @@ -120,6 +121,9 @@ def debug_exc(msg="run_mode error"):
defaults = make_defaults_struct()
fixup_defaults(defaults)
options, args = do_parse_cmdline(cmdline, defaults)
#set_proc_title is here so we can override the cmdline later
#(don't ask me why this works)
set_proc_title(" ".join(cmdline))
if not args:
raise InitExit(-1, "xpra: need a mode")
mode = args.pop(0)
Expand Down Expand Up @@ -1798,6 +1802,14 @@ def get_client_app(error_cb, opts, extra_args, mode):
if mode!="listen":
app.show_progress(60, "connecting to server")
display_desc = do_pick_display(dotxpra, error_cb, opts, extra_args)
if len(extra_args)==1 and opts.password:
uri = extra_args[0]
if uri in sys.argv and opts.password in uri:
#hide the password from the URI:
i = sys.argv.index(uri)
#sys.argv[i] = uri.replace(opts.password, "*"*len(opts.password))
sys.argv[i] = uri.replace(opts.password, "********")
set_proc_title(" ".join(sys.argv))
connect_to_server(app, display_desc, opts)
except Exception:
app.cleanup()
Expand Down
8 changes: 1 addition & 7 deletions xpra/server/proxy/proxy_instance_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
SIGNAMES, POSIX,
bytestostr,
osexpand,
set_proc_title,
getuid, getgid, get_username_for_uid, setuidgid,
register_SIGUSR_signals,
)
Expand All @@ -41,13 +42,6 @@
MAX_CONCURRENT_CONNECTIONS = 20


def set_proc_title(title):
try:
import setproctitle
setproctitle.setproctitle(title) #@UndefinedVariable
except ImportError as e:
log("setproctitle not installed: %s", e)

def set_blocking(conn):
#Note: importing set_socket_timeout from xpra.net.bytestreams
#fails in mysterious ways, so we duplicate the code here instead
Expand Down

0 comments on commit 28fec4d

Please sign in to comment.