xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #611: xpra_setup_remove_xorg_setuid.patch

File xpra_setup_remove_xorg_setuid.patch, 4.2 KB (added by pyther, 7 years ago)
  • setup.py

     
    614614
    615615
    616616#*******************************************************************************
    617 xorg_version = None
    618617def get_xorg_version():
    619     global xorg_version
    620     if xorg_version:
    621         return xorg_version
     618    # Detect Xorg Binary
     619    xorg_bin = None
     620    xorg_version = None   
     621 
    622622    #fedora rawhide binary:
    623     if os.path.exists("/usr/libexec/Xorg.bin"):
    624         cmd = ["/usr/libexec/Xorg.bin", "-version"]
     623    if os.path.exists('/usr/libexec/Xorg.bin'):
     624        xorg_bin = '/usr/libexec/Xorg.bin'
    625625    else:
    626         cmd = ["Xorg", "-version"]
     626        paths = os.environ.get("PATH").split(os.pathsep)
     627        for x in paths:
     628            xorg = os.path.join(x, "Xorg")
     629            if os.path.isfile(xorg):
     630                xorg_bin = xorg
     631                break
     632
     633    # can't detect version if there is no binary
     634    if not xorg_bin:
     635        return xorg_version
     636
     637    cmd = [xorg_bin, '-version']
     638
    627639    if verbose_ENABLED:
    628640        print("detecting Xorg version using: %s" % str(cmd))
    629641    try:
     
    644656def detect_xorg_setup():
    645657    if not server_ENABLED or WIN32:
    646658        return ("", False, False)
     659   
    647660    #do live detection
    648661    xorg_version = get_xorg_version()
    649662
    650663    # detect displayfd
    651     if not xorg_version:
    652         has_displayfd = False
     664    # if Xdummy support is enabled, then the X server is new enough to support
     665    # displayfd
     666    if Xdummy_ENABLED is True:
     667        has_displayfd = True
    653668    elif xorg_version >= [1, 12]:
    654669        has_displayfd = True
    655670    else:
     
    658673    def Xvfb():
    659674        return ("Xvfb +extension Composite -screen 0 3840x2560x24+32 -nolisten tcp -noreset -auth $XAUTHORITY", has_displayfd, False)
    660675
     676    def Xdummy():
     677        return ("xpra_Xdummy -dpi 96 -noreset -nolisten tcp +extension GLX +extension RANDR +extension RENDER -logfile ${HOME}/.xpra/Xorg.${DISPLAY}.log -config /etc/xpra/xorg.conf", has_displayfd, True)
     678
    661679    if sys.platform.find("bsd")>=0:
    662680        print("Warning: sorry, no support for Xdummy on %s" % sys.platform)
    663681        return Xvfb()
    664682
    665     XORG_BIN = None
    666     PATHS = os.environ.get("PATH").split(os.pathsep)
    667     for x in PATHS:
    668         xorg = os.path.join(x, "Xorg")
    669         if os.path.isfile(xorg):
    670             XORG_BIN = xorg
    671             break
    672     if not XORG_BIN:
    673         print("Xorg not found, cannot detect version or Xdummy support")
    674         return Xvfb()
    675 
    676     def Xorg_suid_check():
    677         xorg_stat = os.stat(XORG_BIN)
    678         if (xorg_stat.st_mode & stat.S_ISUID)!=0:
    679             if (xorg_stat.st_mode & stat.S_IROTH)==0:
    680                 print("Xorg is suid and not readable, Xdummy support unavailable")
    681                 return Xvfb()
    682             print("%s is suid and readable, using the xpra_Xdummy wrapper" % XORG_BIN)
    683             return ("xpra_Xdummy -dpi 96 -noreset -nolisten tcp +extension GLX +extension RANDR +extension RENDER -logfile ${HOME}/.xpra/Xorg.${DISPLAY}.log -config /etc/xpra/xorg.conf", has_displayfd, True)
    684         else:
    685             print("using Xdummy config file")
    686             return ("Xorg -dpi 96 -noreset -nolisten tcp +extension GLX +extension RANDR +extension RENDER -logfile ${HOME}/.xpra/Xorg.${DISPLAY}.log -config /etc/xpra/xorg.conf", has_displayfd, False)
    687 
     683    # if xdummy support is explicitly enabled or disabled do as user wishes,
     684    # otherwise try to autodetect
    688685    if Xdummy_ENABLED is False:
    689686        return Xvfb()
    690687    elif Xdummy_ENABLED is True:
    691         print("Xdummy support specified as 'enabled', will detect suid mode")
    692         return Xorg_suid_check()
     688        print("Xdummy support specified as 'enabled'")
     689        return Xdummy()
    693690    else:
    694691        print("Xdummy support unspecified, will try to detect")
    695692
     
    714711        print("Xorg version %s is too old (1.12 or later required), Xdummy support not available" % str(xorg_version))
    715712        return Xvfb()
    716713    print("found valid recent version of Xorg server: %s" % str(xorg_version))
    717     return Xorg_suid_check()
     714    return Xdummy()
    718715
    719716def build_xpra_conf(build_base):
    720717    #generates an actual config file from the template