Skip to content

Commit

Permalink
#1527 move login+exec code to a function, preserve debug logging flag…
Browse files Browse the repository at this point in the history
…s in new subprocess

git-svn-id: https://xpra.org/svn/Xpra/trunk@23608 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Aug 27, 2019
1 parent 28bc98b commit 4901488
Showing 1 changed file with 47 additions and 39 deletions.
86 changes: 47 additions & 39 deletions src/xpra/platform/win32/proxy_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,48 @@
import os

from xpra.server.proxy.proxy_server import ProxyServer as _ProxyServer
from xpra.platform.paths import get_app_dir
from xpra.log import Logger

log = Logger("proxy")
authlog = Logger("proxy", "auth")


def exec_command(username, command, env):
log("exec_command%s", (username, command, env))
from xpra.platform.win32.lsa_logon_lib import logon_msv1_s4u
logon_info = logon_msv1_s4u(username)
log("logon_msv1_s4u(%s)=%s", username, logon_info)
from xpra.platform.win32.create_process_lib import (
Popen,
CREATIONINFO, CREATION_TYPE_TOKEN,
LOGON_WITH_PROFILE, CREATE_NEW_PROCESS_GROUP, STARTUPINFO,
)
creation_info = CREATIONINFO()
creation_info.dwCreationType = CREATION_TYPE_TOKEN
creation_info.dwLogonFlags = LOGON_WITH_PROFILE
creation_info.dwCreationFlags = CREATE_NEW_PROCESS_GROUP
creation_info.hToken = logon_info.Token
log("creation_info=%s", creation_info)
startupinfo = STARTUPINFO()
startupinfo.lpDesktop = "WinSta0\\Default"
startupinfo.lpTitle = "Xpra-Shadow"
cwd = get_app_dir()
from subprocess import PIPE
log("env=%s", env)
proc = Popen(command, stdout=PIPE, stderr=PIPE, cwd=cwd, env=env,
startupinfo=startupinfo, creationinfo=creation_info)
log("Popen(%s)=%s", command, proc)
log("poll()=%s", proc.poll())
try:
log("stdout=%s", proc.stdout.read())
log("stderr=%s", proc.stderr.read())
except (OSError, IOError, AttributeError):
pass
if proc.poll() is not None:
return None
return proc

class ProxyServer(_ProxyServer):

def start_new_session(self, username, uid, gid, new_session_dict=None, displays=()):
Expand All @@ -20,51 +56,23 @@ def start_new_session(self, username, uid, gid, new_session_dict=None, displays=

def start_win32_shadow(self, username, new_session_dict):
log("start_win32_shadow%s", (username, new_session_dict))
from xpra.platform.paths import get_app_dir
from xpra.platform.win32.lsa_logon_lib import logon_msv1_s4u
logon_info = logon_msv1_s4u(username)
log("logon_msv1_s4u(%s)=%s", username, logon_info)
#hwinstaold = set_window_station("winsta0")
def exec_command(command):
log("exec_command(%s)", command)
from xpra.platform.win32.create_process_lib import (
Popen,
CREATIONINFO, CREATION_TYPE_TOKEN,
LOGON_WITH_PROFILE, CREATE_NEW_PROCESS_GROUP, STARTUPINFO,
)
creation_info = CREATIONINFO()
creation_info.dwCreationType = CREATION_TYPE_TOKEN
creation_info.dwLogonFlags = LOGON_WITH_PROFILE
creation_info.dwCreationFlags = CREATE_NEW_PROCESS_GROUP
creation_info.hToken = logon_info.Token
log("creation_info=%s", creation_info)
startupinfo = STARTUPINFO()
startupinfo.lpDesktop = "WinSta0\\Default"
startupinfo.lpTitle = "Xpra-Shadow"
cwd = get_app_dir()
from subprocess import PIPE
env = self.get_proxy_env()
log("env=%s", env)
proc = Popen(command, stdout=PIPE, stderr=PIPE, cwd=cwd, env=env,
startupinfo=startupinfo, creationinfo=creation_info)
log("Popen(%s)=%s", command, proc)
log("poll()=%s", proc.poll())
try:
log("stdout=%s", proc.stdout.read())
log("stderr=%s", proc.stderr.read())
except (OSError, IOError, AttributeError):
pass
if proc.poll() is not None:
return None
self.child_reaper.add_process(proc, "server-%s" % username, "xpra shadow", True, True)
return proc
#whoami = os.path.join(get_app_dir(), "whoami.exe")
#exec_command([whoami])
port = 10000
xpra_command = os.path.join(get_app_dir(), "xpra.exe")
command = [xpra_command, "shadow", "--bind-tcp=0.0.0.0:%i" % port, "-d", "win32"]
proc = exec_command(command)
command = [
xpra_command,
"shadow",
"--bind-tcp=0.0.0.0:%i" % port,
]
from xpra.log import debug_enabled_categories
if debug_enabled_categories:
command += ["-d", ",".join(tuple(debug_enabled_categories))]
env = self.get_proxy_env()
proc = exec_command(username, command, env)
if not proc:
return None, None
self.child_reaper.add_process(proc, "server-%s" % username, "xpra shadow", True, True)
#exec_command(["C:\\Windows\notepad.exe"])
return "tcp/localhost:%i" % port, proc

0 comments on commit 4901488

Please sign in to comment.