def test_distribution_variant(self): is_Ubuntu() is_Debian() is_Raspbian() is_Fedora() is_Arch() is_CentOS() is_RedHat() is_WSL()
def OpenGL_safety_check(): #Ubuntu 12.04 will just crash on you if you try: from xpra.os_util import is_Ubuntu, getUbuntuVersion if is_Ubuntu(): rnum = getUbuntuVersion() if rnum <= [12, 4]: return "Ubuntu %s is too buggy" % rnum #try to detect VirtualBox: #based on the code found here: #http://spth.virii.lu/eof2/articles/WarGame/vboxdetect.html #because it used to cause hard VM crashes when we probe the GL driver! try: from ctypes import cdll if cdll.LoadLibrary("VBoxHook.dll"): return "VirtualBox is present (VBoxHook.dll)" except: pass try: try: f = None f = open("\\\\.\\VBoxMiniRdrDN", "r") finally: if f: f.close() return True, "VirtualBox is present (VBoxMiniRdrDN)" except Exception as e: import errno if e.args[0] == errno.EACCES: return "VirtualBox is present (VBoxMiniRdrDN)" return None
def OpenGL_safety_check(): #Ubuntu 12.04 will just crash on you if you try: from xpra.os_util import is_Ubuntu, getUbuntuVersion if is_Ubuntu(): rnum = getUbuntuVersion() if rnum<=[12, 4]: return "Ubuntu %s is too buggy" % rnum #try to detect VirtualBox: #based on the code found here: #http://spth.virii.lu/eof2/articles/WarGame/vboxdetect.html #because it used to cause hard VM crashes when we probe the GL driver! try: from ctypes import cdll if cdll.LoadLibrary("VBoxHook.dll"): return "VirtualBox is present (VBoxHook.dll)" except: pass try: try: f = None f = open("\\\\.\\VBoxMiniRdrDN", "r") finally: if f: f.close() return True, "VirtualBox is present (VBoxMiniRdrDN)" except Exception as e: import errno if e.args[0]==errno.EACCES: return "VirtualBox is present (VBoxMiniRdrDN)" return None
def detect_xvfb_command(conf_dir="/etc/xpra/", bin_dir=None, Xdummy_ENABLED=None, Xdummy_wrapper_ENABLED=None): #returns the xvfb command to use if WIN32: return "" if OSX: return get_Xvfb_command() if sys.platform.find("bsd")>=0 and Xdummy_ENABLED is None: warn("Warning: sorry, no support for Xdummy on %s" % sys.platform) return get_Xvfb_command() xorg_bin = get_xorg_bin() def Xorg_suid_check(): if Xdummy_wrapper_ENABLED is not None: #honour what was specified: use_wrapper = Xdummy_wrapper_ENABLED elif not xorg_bin: warn("Warning: Xorg binary not found, assuming the wrapper is needed!") use_wrapper = True else: #auto-detect import stat xorg_stat = os.stat(xorg_bin) if (xorg_stat.st_mode & stat.S_ISUID)!=0: if (xorg_stat.st_mode & stat.S_IROTH)==0: warn("%s is suid and not readable, Xdummy support unavailable" % xorg_bin) return get_Xvfb_command() debug("%s is suid and readable, using the xpra_Xdummy wrapper" % xorg_bin) use_wrapper = True else: use_wrapper = False xorg_conf = os.path.join(conf_dir, "xorg.conf") if use_wrapper: xorg_cmd = "xpra_Xdummy" else: xorg_cmd = xorg_bin or "Xorg" #so we can run from install dir: if bin_dir and os.path.exists(os.path.join(bin_dir, xorg_cmd)): if bin_dir not in os.environ.get("PATH", "/bin:/usr/bin:/usr/local/bin").split(os.pathsep): xorg_cmd = os.path.join(bin_dir, xorg_cmd) return get_Xdummy_command(xorg_cmd, xorg_conf=xorg_conf) if Xdummy_ENABLED is False: return get_Xvfb_command() elif Xdummy_ENABLED is True: return Xorg_suid_check() else: debug("Xdummy support unspecified, will try to detect") from xpra.os_util import is_Ubuntu, getUbuntuVersion if is_Ubuntu(): rnum = getUbuntuVersion() if rnum==[16, 10]: return Xorg_suid_check() debug("Warning: Ubuntu breaks Xorg/Xdummy usage - using Xvfb fallback") return get_Xvfb_command() return Xorg_suid_check()
def close_gtk_display(self): # Close our display(s) first, so the server dying won't kill us. # (if gtk has been loaded) gdk_mod = sys.modules.get("gtk.gdk") or sys.modules.get( "gi.repository.Gdk") #bug 2328: python3 shadow server segfault on Ubuntu 16.04 from xpra.os_util import getUbuntuVersion, is_Ubuntu, PYTHON2 safe_close = PYTHON2 or self.session_type != "shadow" or not is_Ubuntu( ) or getUbuntuVersion() > (16, 4) close = envbool("XPRA_CLOSE_GTK_DISPLAY", safe_close) if close and gdk_mod: if is_gtk3(): displays = gdk.DisplayManager.get().list_displays() else: displays = gdk.display_manager_get().list_displays() for d in displays: d.close()
# later version. See the file COPYING for details. #pylint: disable-msg=E1101 import os from xpra.util import engs, envbool from xpra.os_util import is_Ubuntu, is_Debian from xpra.log import Logger log = Logger("webcam") #on Debian and Ubuntu, the v4l2loopback device is created with exclusive_caps=1, #so we cannot check the devices caps for the "VIDEO_CAPTURE" flag. #see https://xpra.org/trac/ticket/1596 CHECK_VIRTUAL_CAPTURE = envbool("XPRA_CHECK_VIRTUAL_CAPTURE", not (is_Ubuntu() or is_Debian())) def _can_capture_video(dev_file, dev_info): if not dev_info: return False caps = dev_info.get("capabilities", []) if "DEVICE_CAPS" in caps: caps = dev_info.get("device_caps", []) if not "VIDEO_CAPTURE" in caps: log("device %s does not support video capture, capabilities=%s", dev_file, caps) return False return True
if is_X11(): try: from xpra.x11.bindings.xi2_bindings import X11XI2Bindings as _X11XI2Bindings #@UnresolvedImport X11XI2 = _X11XI2Bindings() except Exception: log.error("no XI2 bindings", exc_info=True) return X11XI2 device_bell = None GTK_MENUS = envbool("XPRA_GTK_MENUS", False) RANDR_DPI = envbool("XPRA_RANDR_DPI", True) XSETTINGS_DPI = envbool("XPRA_XSETTINGS_DPI", True) USE_NATIVE_TRAY = envbool( "XPRA_USE_NATIVE_TRAY", is_unity() or (is_Ubuntu() and is_gnome()) or (is_gnome() and not is_Fedora()) or is_kde()) XINPUT_WHEEL_DIV = envint("XPRA_XINPUT_WHEEL_DIV", 15) DBUS_SCREENSAVER = envbool("XPRA_DBUS_SCREENSAVER", False) def gl_check(): if not is_X11() and is_Wayland(): return "disabled under wayland with GTK3 (buggy)" return None def get_native_system_tray_classes(): return []
def detect_xvfb_command(conf_dir="/etc/xpra/", bin_dir=None, Xdummy_ENABLED=None, Xdummy_wrapper_ENABLED=None): #returns the xvfb command to use if WIN32: return "" if OSX: return get_Xvfb_command() if sys.platform.find("bsd") >= 0 and Xdummy_ENABLED is None: warn("Warning: sorry, no support for Xdummy on %s" % sys.platform) return get_Xvfb_command() xorg_bin = get_xorg_bin() def Xorg_suid_check(): if Xdummy_wrapper_ENABLED is not None: #honour what was specified: use_wrapper = Xdummy_wrapper_ENABLED elif not xorg_bin: warn( "Warning: Xorg binary not found, assuming the wrapper is needed!" ) use_wrapper = True else: #Fedora 21+ workaround: if os.path.exists("/usr/libexec/Xorg.wrap"): #we need our own wrapper to bypass all the scripts and wrappers Fedora uses use_wrapper = True else: #auto-detect import stat xorg_stat = os.stat(xorg_bin) if (xorg_stat.st_mode & stat.S_ISUID) != 0: if (xorg_stat.st_mode & stat.S_IROTH) == 0: warn( "%s is suid and not readable, Xdummy support unavailable" % xorg_bin) return get_Xvfb_command() debug( "%s is suid and readable, using the xpra_Xdummy wrapper" % xorg_bin) use_wrapper = True else: use_wrapper = False xorg_conf = os.path.join(conf_dir, "xorg.conf") if use_wrapper: xorg_cmd = "xpra_Xdummy" else: xorg_cmd = xorg_bin or "Xorg" #so we can run from install dir: if bin_dir and os.path.exists(os.path.join(bin_dir, xorg_cmd)): if bin_dir not in ("/usr/bin", "/bin"): xorg_cmd = os.path.join(bin_dir, xorg_cmd) return get_Xdummy_command(xorg_cmd, xorg_conf=xorg_conf) if Xdummy_ENABLED is False: return get_Xvfb_command() elif Xdummy_ENABLED is True: return Xorg_suid_check() else: debug("Xdummy support unspecified, will try to detect") from xpra.os_util import is_Ubuntu, getUbuntuVersion if is_Ubuntu(): rnum = getUbuntuVersion() if rnum == [16, 10]: return Xorg_suid_check() debug("Warning: Ubuntu breaks Xorg/Xdummy usage - using Xvfb fallback") return get_Xvfb_command() return Xorg_suid_check()
# This file is part of Xpra. # Copyright (C) 2016 Antoine Martin <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. import os from xpra.log import Logger log = Logger("webcam") from xpra.util import engs, envbool from xpra.os_util import is_Ubuntu, is_Debian #on Debian and Ubuntu, the v4l2loopback device is created with exclusive_caps=1, #so we cannot check the devices caps for the "VIDEO_CAPTURE" flag. #see http://xpra.org/trac/ticket/1596 CHECK_VIRTUAL_CAPTURE = envbool("XPRA_CHECK_VIRTUAL_CAPTURE", not (is_Ubuntu() or is_Debian())) def _can_capture_video(dev_file, dev_info): if not dev_info: return False caps = dev_info.get("capabilities", []) if "DEVICE_CAPS" in caps: caps = dev_info.get("device_caps", []) if not "VIDEO_CAPTURE" in caps: log("device %s does not support video capture, capabilities=%s", dev_file, caps) return False return True v4l2_virtual_dir = "/sys/devices/virtual/video4linux" def check_virtual_dir(warn=True):
# This file is part of Xpra. # Copyright (C) 2010 Nathaniel Smith <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. import sys #don't bother trying to forward system tray with Ubuntu's "unity": from xpra.os_util import is_unity, is_Ubuntu, is_Fedora SYSTEM_TRAY_SUPPORTED = not is_unity() #this is only our best guess #there is more logic in setup.py, but it requires more effort too: XDUMMY = not is_Ubuntu() #displayfd requires Xdummy, and we don't support servers with py3k: DISPLAYFD = XDUMMY and sys.version_info[0]<3 XDUMMY_WRAPPER = is_Fedora() DEFAULT_ENV = [ "#avoid Ubuntu's global menu, which is a mess and cannot be forwarded:", "UBUNTU_MENUPROXY=", "QT_X11_NO_NATIVE_MENUBAR=1", "#fix for MainSoft's MainWin buggy window management:", "MWNOCAPTURE=true", "MWNO_RIT=true", "MWWM=allwm", ] DEFAULT_SSH_CMD = "ssh" CLIPBOARDS=["CLIPBOARD", "PRIMARY", "SECONDARY"]
# This file is part of Xpra. # Copyright (C) 2010 Nathaniel Smith <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. import sys #don't bother trying to forward system tray with Ubuntu's "unity": from xpra.os_util import is_unity, is_Ubuntu, is_Fedora SYSTEM_TRAY_SUPPORTED = not is_unity() #this is only our best guess #there is more logic in setup.py, but it requires more effort too: XDUMMY = not is_Ubuntu() and not sys.platform.find("bsd") >= 0 #displayfd requires Xdummy, and we don't support servers with py3k: DISPLAYFD = XDUMMY and sys.version_info[0] < 3 XDUMMY_WRAPPER = is_Fedora() DEFAULT_ENV = [ "#avoid Ubuntu's global menu, which is a mess and cannot be forwarded:", "UBUNTU_MENUPROXY=", "QT_X11_NO_NATIVE_MENUBAR=1", "#fix for MainSoft's MainWin buggy window management:", "MWNOCAPTURE=true", "MWNO_RIT=true", "MWWM=allwm", "#force GTK3 applications to use X11 so we can intercept them:", "GDK_BACKEND=x11", ] DEFAULT_SSH_CMD = "ssh" CLIPBOARDS = ["CLIPBOARD", "PRIMARY", "SECONDARY"]
# This file is part of Xpra. # Copyright (C) 2010 Nathaniel Smith <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. import sys #don't bother trying to forward system tray with Ubuntu's "unity": from xpra.os_util import is_unity, is_Ubuntu, is_Fedora SYSTEM_TRAY_SUPPORTED = not is_unity() #this is only our best guess #there is more logic in setup.py, but it requires more effort too: XDUMMY = not is_Ubuntu() and not sys.platform.find("bsd")>=0 #displayfd requires Xdummy, and we don't support servers with py3k: DISPLAYFD = XDUMMY and sys.version_info[0]<3 XDUMMY_WRAPPER = is_Fedora() DEFAULT_ENV = [ "#avoid Ubuntu's global menu, which is a mess and cannot be forwarded:", "UBUNTU_MENUPROXY=", "QT_X11_NO_NATIVE_MENUBAR=1", "#fix for MainSoft's MainWin buggy window management:", "MWNOCAPTURE=true", "MWNO_RIT=true", "MWWM=allwm", "#force GTK3 applications to use X11 so we can intercept them:", "GDK_BACKEND=x11", ] DEFAULT_SSH_CMD = "ssh" CLIPBOARDS=["CLIPBOARD", "PRIMARY", "SECONDARY"]
def get_defaults(): global GLOBAL_DEFAULTS if GLOBAL_DEFAULTS is not None: return GLOBAL_DEFAULTS from xpra.platform.features import DEFAULT_SSH_COMMAND, OPEN_COMMAND, DEFAULT_PULSEAUDIO_CONFIGURE_COMMANDS, DEFAULT_PULSEAUDIO_COMMAND, \ DEFAULT_ENV, CAN_DAEMONIZE from xpra.platform.paths import get_download_dir, get_remote_run_xpra_scripts try: from xpra.platform.info import get_username username = get_username() except: username = "" conf_dirs = [os.environ.get("XPRA_CONF_DIR")] build_root = os.environ.get("RPM_BUILD_ROOT") if build_root: conf_dirs.append(os.path.join(build_root, "etc", "xpra")) xpra_cmd = sys.argv[0] bin_dir = None if len(sys.argv) > 0: for strip in ("/usr/bin", "/bin"): pos = xpra_cmd.find(strip) if pos >= 0: bin_dir = xpra_cmd[:pos + len(strip)] root = xpra_cmd[:pos] or "/" conf_dirs.append(os.path.join(root, "etc", "xpra")) break if sys.prefix == "/usr": conf_dirs.append("/etc/xpra") else: conf_dirs.append(os.path.join(sys.prefix, "etc", "xpra")) for conf_dir in [x for x in conf_dirs if x]: if os.path.exists(conf_dir): break xvfb = detect_xvfb_command(conf_dir, bin_dir) def addtrailingslash(v): if v.endswith("/"): return v return v + "/" if WIN32: bind_dirs = ["Main"] else: bind_dirs = ["auto"] ssl_protocol = "TLSv1_2" if sys.version_info < (2, 7, 9): ssl_protocol = "SSLv23" from xpra.os_util import is_Debian, is_Ubuntu GLOBAL_DEFAULTS = { "encoding": "", "title": "@title@ on @client-machine@", "username": username, "password": "", "auth": "", "vsock-auth": "", "tcp-auth": "", "ssl-auth": "", "wm-name": DEFAULT_NET_WM_NAME, "session-name": "", "dock-icon": "", "tray-icon": "", "window-icon": "", "password-file": "", "keyboard-raw": False, "keyboard-layout": "", "keyboard-layouts": [], "keyboard-variant": "", "keyboard-variants": [], "keyboard-options": "", "clipboard": "yes", "clipboard-direction": "both", "clipboard-filter-file": "", "remote-clipboard": "CLIPBOARD", "local-clipboard": "CLIPBOARD", "pulseaudio-command": " ".join(DEFAULT_PULSEAUDIO_COMMAND), "encryption": "", "tcp-encryption": "", "encryption-keyfile": "", "tcp-encryption-keyfile": "", "pidfile": "", "ssh": DEFAULT_SSH_COMMAND, "systemd-run": get_default_systemd_run(), "systemd-run-args": "", "xvfb": " ".join(xvfb), "socket-dir": "", "log-dir": "auto", "log-file": "$DISPLAY.log", "border": "auto,5:off", "window-close": "auto", "max-size": "", "desktop-scaling": "auto", "display": "", "tcp-proxy": "", "download-path": get_download_dir(), "open-command": OPEN_COMMAND, "remote-logging": "both", "lpadmin": "/usr/sbin/lpadmin", "lpinfo": "/usr/sbin/lpinfo", "add-printer-options": ["-E", "-o printer-is-shared=false", "-u allow:$USER"], "pdf-printer": "", "postscript-printer": DEFAULT_POSTSCRIPT_PRINTER, "debug": "", "input-method": "none", "sound-source": "", "html": "auto", "socket-permissions": "600", "exec-wrapper": "", "dbus-launch": "dbus-launch --close-stderr", "webcam": ["auto", "no"][OSX], #ssl options: "ssl": "auto", "ssl-key": "", "ssl-cert": "", "ssl-protocol": ssl_protocol, "ssl-ca-certs": "default", "ssl-ca-data": "", "ssl-ciphers": "DEFAULT", "ssl-client-verify-mode": "optional", "ssl-server-verify-mode": "required", "ssl-verify-flags": "X509_STRICT", "ssl-check-hostname": False, "ssl-server-hostname": "localhost", "ssl-options": "ALL,NO_COMPRESSION", "quality": 0, "min-quality": 30, "speed": 0, "min-speed": 30, "compression_level": 1, "dpi": 0, "video-scaling": 1, "file-size-limit": 100, "idle-timeout": 0, "server-idle-timeout": 0, "sync-xvfb": 0, "auto-refresh-delay": 0.15, "daemon": CAN_DAEMONIZE, "use-display": False, "fake-xinerama": not OSX and not WIN32 and not is_Debian() and not is_Ubuntu(), "resize-display": not OSX and not WIN32, "tray": True, "pulseaudio": not OSX and not WIN32, "dbus-proxy": not OSX and not WIN32, "mmap": ["no", "yes"][not OSX and not WIN32], "mmap-group": False, "speaker": ["disabled", "on"][has_sound_support()], "microphone": ["disabled", "off"][has_sound_support()], "readonly": False, "keyboard-sync": True, "pings": False, "cursors": True, "bell": True, "notifications": True, "xsettings": not OSX and not WIN32, "system-tray": True, "sharing": False, "delay-tray": False, "windows": True, "exit-with-children": False, "exit-with-client": False, "start-after-connect": False, "start-new-commands": False, "proxy-start-sessions": True, "av-sync": True, "exit-ssh": True, "dbus-control": not WIN32 and not OSX, "opengl": get_opengl_default(), "mdns": not WIN32, "file-transfer": True, "printing": True, "open-files": False, "swap-keys": OSX, #only used on osx "desktop-fullscreen": False, "global-menus": True, "pulseaudio-configure-commands": [" ".join(x) for x in DEFAULT_PULSEAUDIO_CONFIGURE_COMMANDS], "socket-dirs": [], "remote-xpra": get_remote_run_xpra_scripts(), "encodings": ["all"], "proxy-video-encoders": [], "video-encoders": ["all"], "csc-modules": ["all"], "video-decoders": ["all"], "speaker-codec": [], "microphone-codec": [], "compressors": ["all"], "packet-encoders": ["all"], "key-shortcut": get_default_key_shortcuts(), "bind": bind_dirs, "bind-vsock": [], "bind-tcp": [], "bind-ssl": [], "start": [], "start-child": [], "start-after-connect": [], "start-child-after-connect": [], "start-on-connect": [], "start-child-on-connect": [], "start-env": DEFAULT_ENV, "env": [], } return GLOBAL_DEFAULTS