Beispiel #1
0
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
Beispiel #2
0
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
Beispiel #3
0
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()
Beispiel #4
0
 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()
Beispiel #5
0
def get_appindicator():
    global _appindicator
    if _appindicator is False:
        try:
            import sys
            if "gi" in sys.modules or sys.version_info[0]==3:
                if getUbuntuVersion()>=(18,4) and is_unity():
                    #causes segfaults just by importing it
                    #shambolic
                    pass
                else:
                    import gi
                    gi.require_version('AppIndicator3', '0.1')
                    from gi.repository import AppIndicator3 #@UnresolvedImport @Reimport
                    _appindicator = AppIndicator3
            else:
                import appindicator                     #@UnresolvedImport
                _appindicator = appindicator
        except ImportError:
            _appindicator = None
    return _appindicator
Beispiel #6
0
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()
Beispiel #7
0
required_extensions = ["GL_ARB_texture_rectangle", "GL_ARB_vertex_program"]


WHITELIST = {}
GREYLIST = {}
VERSION_REQ = {"nouveau" : [3, 0],      #older versions have issues
               }
BLACKLIST = {"vendor" : ["Humper", "VMware, Inc."],
             "renderer" : ["Software Rasterizer"]}

#the Intel driver causes too many problems:
GREYLIST.setdefault("vendor", []).append("Intel")
GREYLIST.setdefault("vendor", []).append("Intel Inc.")
GREYLIST.setdefault("vendor", []).append("Intel Open Source Technology Center")
from xpra.os_util import getUbuntuVersion
uv = getUbuntuVersion()
if uv and uv<[15]:
    #Ubuntu 14.x drivers are just too old
    GREYLIST.setdefault("vendor", []).append("X.Org")
if False:
    #for testing:
    BLACKLIST["vendor"].append("NVIDIA Corporation")
    WHITELIST["renderer"] = ["GeForce GTX 760/PCIe/SSE2"]

    if sys.platform.startswith("darwin"):
        #frequent crashes on osx with GT 650M: (see ticket #808)
        GREYLIST.setdefault("vendor", []).append("NVIDIA Corporation")


#alpha requires gtk3 or *nix only for gtk2:
DEFAULT_ALPHA = sys.version>'3' or (not sys.platform.startswith("win") and not sys.platform.startswith("darwin"))
Beispiel #8
0
required_extensions = ["GL_ARB_texture_rectangle", "GL_ARB_vertex_program"]

WHITELIST = {
    "renderer": ["Skylake", "Kabylake"],
}
GREYLIST = {"vendor": ["Intel", "Humper"]}
VERSION_REQ = {
    "nouveau": [3, 0],  #older versions have issues
}
BLACKLIST = {
    "renderer": ["Software Rasterizer", "Mesa DRI Intel(R) Ivybridge Desktop"],
    "vendor": ["VMware, Inc."]
}

from xpra.os_util import getUbuntuVersion
uv = getUbuntuVersion()
if uv and uv < [15]:
    #Ubuntu 14.x drivers are just too old
    GREYLIST.setdefault("vendor", []).append("X.Org")
if False:
    #for testing:
    GREYLIST["vendor"].append("NVIDIA Corporation")
    WHITELIST["renderer"] = ["GeForce GTX 760/PCIe/SSE2"]

    if OSX:
        #frequent crashes on osx with GT 650M: (see ticket #808)
        GREYLIST.setdefault("vendor", []).append("NVIDIA Corporation")

#alpha requires gtk3 or *nix only for gtk2:
DEFAULT_ALPHA = PYTHON3 or (not WIN32 and not OSX)
GL_ALPHA_SUPPORTED = envbool("XPRA_ALPHA", DEFAULT_ALPHA)