xpra icon
Bug tracker and wiki

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


Ticket #888: move-socket-v2.patch

File move-socket-v2.patch, 31.2 KB (added by Antoine Martin, 6 years ago)

updated patch, almost usable

  • tests/xpra/net/test_protocol_fakeserver.py

     
    1616if PLATFORM_INIT:
    1717    from xpra.platform.features import LOCAL_SERVERS_SUPPORTED, SHADOW_SUPPORTED
    1818    from xpra.platform.options import add_client_options
    19     from xpra.platform.paths import get_default_socket_dir
    2019    from xpra.platform import init as platform_init
    2120    platform_init()
    22     nones = [x for x in (LOCAL_SERVERS_SUPPORTED, SHADOW_SUPPORTED, add_client_options, get_default_socket_dir) if x is None]
     21    nones = [x for x in (LOCAL_SERVERS_SUPPORTED, SHADOW_SUPPORTED, add_client_options) if x is None]
    2322    assert len([])==0
    2423
    2524PLATFORM_GUI_INIT = PLATFORM_INIT and True
  • xpra/dotxpra.py

     
    2424
    2525
    2626class DotXpra(object):
    27     def __init__(self, sockdir=None, confdir=None, actual_username=""):
    28         from xpra.platform.paths import get_default_socket_dir, get_user_conf_dir
     27    def __init__(self, sockdir=None, sockdirs=[], confdir=None, logdir=None, actual_username=""):
     28        from xpra.platform.paths import get_user_conf_dir
     29        self._sockdir = osexpand(sockdir, actual_username)
     30        self._sockdirs = [osexpand(x) for x in sockdirs]
    2931        self._confdir = osexpand(confdir or get_user_conf_dir(), actual_username)
    30         self._sockdir = osexpand(sockdir or get_default_socket_dir(), actual_username)
    31         if not os.path.exists(self._confdir):
     32        self._logdir = osexpand(logdir or get_user_conf_dir(), actual_username)
     33        if self._confdir and not os.path.exists(self._confdir):
    3234            os.mkdir(self._confdir, 0o700)
    33         if not os.path.exists(self._sockdir):
     35        if self._sockdir and not os.path.exists(self._sockdir):
    3436            os.mkdir(self._sockdir, 0o700)
    3537        hostname = os.environ.get("XPRA_SOCKET_HOSTNAME", socket.gethostname())
    3638        self._prefix = "%s-" % (hostname,)
     
    5860        return self.norm_make_path(local_display_name[1:], self._sockdir)
    5961
    6062    def log_path(self, local_display_name):
    61         return self.norm_make_path(local_display_name[1:], self._confdir)
     63        return self.norm_make_path(local_display_name[1:], self._logdir)
    6264
    6365    LIVE = "LIVE"
    6466    DEAD = "DEAD"
     
    111113
    112114    def sockets(self, check_uid=0, matching_state=None):
    113115        results = []
    114         base = os.path.join(self._sockdir, self._prefix)
    115         potential_sockets = glob.glob(base + "*")
    116         for path in sorted(potential_sockets):
    117             s = os.stat(path)
    118             if stat.S_ISSOCK(s.st_mode):
    119                 if check_uid>0:
    120                     if s.st_uid!=check_uid:
    121                         #socket uid does not match
     116        for d in [self._sockdir]+self._sockdirs:
     117            if not d:
     118                continue
     119            base = os.path.join(d, self._prefix)
     120            potential_sockets = glob.glob(base + "*")
     121            for path in sorted(potential_sockets):
     122                s = os.stat(path)
     123                if stat.S_ISSOCK(s.st_mode):
     124                    if check_uid>0:
     125                        if s.st_uid!=check_uid:
     126                            #socket uid does not match
     127                            continue
     128                    state = self.get_server_state(path)
     129                    if matching_state and state!=matching_state:
    122130                        continue
    123                 state = self.get_server_state(path)
    124                 if matching_state and state!=matching_state:
    125                     continue
    126                 local_display = ":"+path[len(base):]
    127                 results.append((state, local_display))
     131                    local_display = ":"+path[len(base):]
     132                    results.append((state, local_display))
    128133        return results
  • xpra/platform/darwin/features.py

     
    33# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
    44# later version. See the file COPYING for details.
    55
    6 DEFAULT_SSH_CMD = "ssh"
    7 GOT_PASSWORD_PROMPT_SUGGESTION = "Perhaps you need to set up your ssh agent?\n"
    86SYSTEM_TRAY_SUPPORTED = True
     7
    98CLIPBOARDS=["CLIPBOARD"]
    109CLIPBOARD_WANT_TARGETS = True
    1110CLIPBOARD_GREEDY = True
    1211CLIPBOARD_NATIVE_CLASS = ("xpra.platform.darwin.osx_clipboard", "OSXClipboardProtocolHelper", {})
    13 SHADOW_SUPPORTED = True
    14 CAN_DAEMONIZE = True
     12
    1513UI_THREAD_POLLING = 500    #poll every 500 ms
     14
     15DEFAULT_SSH_CMD = "ssh"
     16GOT_PASSWORD_PROMPT_SUGGESTION = "Perhaps you need to set up your ssh agent?\n"
  • xpra/platform/darwin/paths.py

     
    7575    default_conf_dir = "/Library/Application Support/Xpra"
    7676    return os.environ.get("XPRA_SYSCONF_DIR", default_conf_dir)
    7777
     78def get_socket_dirs():
     79    return ["~/xpra"]
    7880
     81
    7982def get_sound_command():
    8083    cs = os.environ.get("XPRA_SOUND_COMMAND")
    8184    if cs:
  • xpra/platform/features.py

     
    44# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
    55# later version. See the file COPYING for details.
    66
    7 import os.path
    87import sys
    9 
    108#defaults which may be overriden by platform_import:
    119LOCAL_SERVERS_SUPPORTED = sys.version_info[0]<3
    12 SHADOW_SUPPORTED = False
    13 MMAP_SUPPORTED = False
     10SHADOW_SUPPORTED = True
     11CAN_DAEMONIZE = True
     12MMAP_SUPPORTED = True
    1413SYSTEM_TRAY_SUPPORTED = False
    15 DEFAULT_SSH_CMD = False
    16 GOT_PASSWORD_PROMPT_SUGGESTION = ""
     14
    1715CLIPBOARDS = []
    1816CLIPBOARD_WANT_TARGETS = False
    1917CLIPBOARD_GREEDY = False
    2018CLIPBOARD_NATIVE_CLASS = None
    21 CAN_DAEMONIZE = False
     19
    2220UI_THREAD_POLLING = 0
    2321OPEN_COMMAND = "xdg-open"
    24 DOWNLOAD_PATH = "~/Downloads"
    25 if not os.path.exists(os.path.expanduser(DOWNLOAD_PATH)):
    26     DOWNLOAD_PATH = "~"
    2722
    2823DEFAULT_PULSEAUDIO_COMMAND = "pulseaudio --start --daemonize=false --system=false " + \
    2924                                    "--exit-idle-time=-1 -n --load=module-suspend-on-idle " + \
     
    3025                                    "--load=module-null-sink --load=module-native-protocol-unix "+ \
    3126                                    "--log-level=2 --log-target=stderr"
    3227DEFAULT_XVFB_COMMAND = "Xvfb +extension Composite -screen 0 3840x2560x24+32 -nolisten tcp -noreset -auth $XAUTHORITY"
     28DEFAULT_SSH_CMD = False
     29GOT_PASSWORD_PROMPT_SUGGESTION = ""
    3330
    3431
    3532_features_list_ = ["LOCAL_SERVERS_SUPPORTED",
     
    4138                "DEFAULT_PULSEAUDIO_COMMAND",
    4239                "DEFAULT_XVFB_COMMAND",
    4340                "GOT_PASSWORD_PROMPT_SUGGESTION",
    44                 "DOWNLOAD_PATH",
    4541                "CLIPBOARDS",
    4642                "CLIPBOARD_WANT_TARGETS",
    4743                "CLIPBOARD_GREEDY",
  • xpra/platform/paths.py

     
    4141    return os.environ.get("XPRA_USER_CONF_DIR", "~/.xpra")
    4242
    4343
    44 def get_default_socket_dir():
    45     return os.environ.get("XPRA_SOCKET_DIR", "~/.xpra")
     44def get_socket_dirs():
     45    return [os.environ.get("XPRA_SOCKET_DIR", "~/.xpra")]
    4646
     47def get_default_log_dir():
     48    return "~/.xpra"
     49
     50def get_download_dir():
     51    d = "~/Downloads"
     52    if not os.path.exists(os.path.expanduser(d)):
     53        return "~"
     54    return d
     55
    4756#overriden in platform code:
    4857def get_app_dir():
    4958    return default_get_app_dir()
     
    144153                "get_default_conf_dir",
    145154                "get_system_conf_dir",
    146155                "get_user_conf_dir",
    147                 "get_default_socket_dir")
     156                "get_socket_dirs",
     157                "get_default_log_dir",
     158                "get_download_dir")
    148159
    149160def get_info():
    150161    return {
     
    152163            "default_conf.dir"  : get_default_conf_dir(),
    153164            "system_conf.dir"   : get_system_conf_dir(),
    154165            "user_conf.dir"     : get_user_conf_dir(),
    155             "socket"            : get_default_socket_dir(),
     166            "socket.dirs"       : get_socket_dirs(),
     167            "log.dir"           : get_default_log_dir(),
     168            "download.dir"      : get_download_dir(),
    156169            "app.dir"           : get_app_dir(),
    157170            "app.default.dir"   : default_get_app_dir(),
    158171            "resources"         : get_resources_dir(),
  • xpra/platform/win32/features.py

     
    44# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
    55# later version. See the file COPYING for details.
    66
    7 # Platform-specific code for Win32.
    8 import os
    9 
    10 def get_registry_value(key, reg_path, entry):
    11     import win32api             #@UnresolvedImport
    12     hKey = win32api.RegOpenKey(key, reg_path)
    13     value, _ = win32api.RegQueryValueEx(hKey, entry)
    14     win32api.RegCloseKey(hKey)
    15     return    value
    16 
    17 
     7# Platform-specific settings for Win32.
     8CAN_DAEMONIZE = False
     9MMAP_SUPPORTED = False
    1810SYSTEM_TRAY_SUPPORTED = True
    19 SHADOW_SUPPORTED = True
    20 os.environ["PLINK_PROTOCOL"] = "ssh"
    2111DEFAULT_SSH_CMD = "plink"
    22 PRINT_COMMAND = ""
    23 #TODO: use "FOLDERID_Downloads":
    24 # FOLDERID_Downloads = "{374DE290-123F-4565-9164-39C4925E467B}"
    25 # maybe like here:
    26 # https://gist.github.com/mkropat/7550097
    27 #from win32com.shell import shell, shellcon
    28 #shell.SHGetFolderPath(0, shellcon.CSIDL_MYDOCUMENTS, None, 0)
    29 try:
    30     #use the internet explorer registry key:
    31     #HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer
    32     import win32con             #@UnresolvedImport
    33     DOWNLOAD_PATH = get_registry_value(win32con.HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer", "Download Directory")
    34 except:
    35     #fallback to what the documentation says is the default:
    36     DOWNLOAD_PATH = os.path.join(os.environ.get("USERPROFILE", "~"), "My Documents", "Downloads")
    37     if not os.path.exists(DOWNLOAD_PATH):
    38         DOWNLOAD_PATH = os.path.join(os.environ.get("USERPROFILE", "~"), "Downloads")
     12
    3913GOT_PASSWORD_PROMPT_SUGGESTION = \
    4014   'Perhaps you need to set up Pageant, or (less secure) use --ssh="plink -pw YOUR-PASSWORD"?\n'
    4115CLIPBOARDS=["CLIPBOARD"]
     
    4519#these don't make sense on win32:
    4620DEFAULT_PULSEAUDIO_COMMAND = ""
    4721DEFAULT_XVFB_COMMAND = ""
     22PRINT_COMMAND = ""
  • xpra/platform/win32/paths.py

     
    5151    return os.environ.get("XPRA_CONF_DIR", _get_data_dir())
    5252
    5353
    54 def get_default_socket_dir():
     54def get_registry_value(key, reg_path, entry):
     55    import win32api             #@UnresolvedImport
     56    hKey = win32api.RegOpenKey(key, reg_path)
     57    value, _ = win32api.RegQueryValueEx(hKey, entry)
     58    win32api.RegCloseKey(hKey)
     59    return    value
     60
     61def get_download_dir():
     62    #TODO: use "FOLDERID_Downloads":
     63    # FOLDERID_Downloads = "{374DE290-123F-4565-9164-39C4925E467B}"
     64    # maybe like here:
     65    # https://gist.github.com/mkropat/7550097
     66    #from win32com.shell import shell, shellcon
     67    #shell.SHGetFolderPath(0, shellcon.CSIDL_MYDOCUMENTS, None, 0)
     68    try:
     69        #use the internet explorer registry key:
     70        #HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer
     71        import win32con             #@UnresolvedImport
     72        DOWNLOAD_PATH = get_registry_value(win32con.HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer", "Download Directory")
     73    except:
     74        #fallback to what the documentation says is the default:
     75        DOWNLOAD_PATH = os.path.join(os.environ.get("USERPROFILE", "~"), "My Documents", "Downloads")
     76        if not os.path.exists(DOWNLOAD_PATH):
     77            DOWNLOAD_PATH = os.path.join(os.environ.get("USERPROFILE", "~"), "Downloads")
     78
     79
     80def get_socket_dirs():
    5581    #ie: C:\Documents and Settings\Username\Application Data\Xpra
    56     return os.environ.get("XPRA_SOCKET_DIR", _get_data_dir())
     82    return [os.environ.get("XPRA_SOCKET_DIR", _get_data_dir())]
    5783
     84
    5885APP_DIR = None
    5986if hasattr(sys, 'frozen') and sys.frozen in (True, "windows_exe", "console_exe"):    #@UndefinedVariable
    6087    #cx_freeze = sys.frozen == True
  • xpra/platform/xposix/features.py

     
    44# later version. See the file COPYING for details.
    55
    66#don't bother trying to forward system tray with Ubuntu's "unity":
    7 SHADOW_SUPPORTED = True
    87from xpra.util import is_unity
    98SYSTEM_TRAY_SUPPORTED = not is_unity()
    10 MMAP_SUPPORTED = True
    11 CAN_DAEMONIZE = True
    129DEFAULT_SSH_CMD = "ssh"
    1310GOT_PASSWORD_PROMPT_SUGGESTION = "Perhaps you need to set up your ssh agent?\n"
    14 CLIPBOARDS=["CLIPBOARD", "PRIMARY", "SECONDARY"]
    15  No newline at end of file
     11CLIPBOARDS=["CLIPBOARD", "PRIMARY", "SECONDARY"]
  • xpra/platform/xposix/paths.py

     
    4343
    4444def get_icon_dir():
    4545    return os.path.join(get_app_dir(), "icons")
     46
     47def get_socket_dirs():
     48    SOCKET_DIRS = ["~/.xpra"]   #the old default
     49    #added in 0.16, support for /run:
     50    if os.path.exists("/run/user") and os.path.isdir("/run/user"):
     51        #private, per user: /run/user/1000/xpra
     52        SOCKET_DIRS.append("/run/user/$UID/xpra")
     53        #for shared sockets:
     54        SOCKET_DIRS.append("/run/xpra")
     55    return SOCKET_DIRS
  • xpra/scripts/config.py

     
    325325                    "remote-logging"    : bool,
    326326                    "av-sync"           : bool,
    327327                    #arrays of strings:
     328                    "socket-dirs"       : list,
    328329                    "encodings"         : list,
    329330                    "video-encoders"    : list,
    330331                    "csc-modules"       : list,
     
    347348    global GLOBAL_DEFAULTS
    348349    if GLOBAL_DEFAULTS is not None:
    349350        return GLOBAL_DEFAULTS
    350     from xpra.platform.features import DEFAULT_SSH_CMD, DOWNLOAD_PATH, OPEN_COMMAND, DEFAULT_PULSEAUDIO_COMMAND, DEFAULT_XVFB_COMMAND
     351    from xpra.platform.features import DEFAULT_SSH_CMD, OPEN_COMMAND, DEFAULT_PULSEAUDIO_COMMAND, DEFAULT_XVFB_COMMAND
     352    from xpra.platform.paths import get_download_dir, get_socket_dirs, get_default_log_dir
    351353    try:
    352354        from xpra.platform.info import get_username
    353355        username = get_username()
     
    375377                    "ssh"               : DEFAULT_SSH_CMD,
    376378                    "xvfb"              : DEFAULT_XVFB_COMMAND,
    377379                    "socket-dir"        : "",
     380                    "log-dir"           : get_default_log_dir(),
    378381                    "log-file"          : "$DISPLAY.log",
    379382                    "border"            : "auto,0",
    380383                    "max-size"          : "",
    381384                    "display"           : "",
    382385                    "tcp-proxy"         : "",
    383                     "download-path"     : DOWNLOAD_PATH,
     386                    "download-path"     : get_download_dir(),
    384387                    "open-command"      : OPEN_COMMAND,
    385388                    "lpadmin"           : "lpadmin",
    386389                    "debug"             : "",
     
    434437                    "printing"          : True,
    435438                    "open-files"        : False,
    436439                    "swap-keys"         : sys.platform.startswith("darwin"),    #only used on osx
     440                    "socket-dirs"       : get_socket_dirs(),
    437441                    "encodings"         : ["all"],
    438442                    "video-encoders"    : ["all"],
    439443                    "csc-modules"       : ["all"],
  • xpra/scripts/main.py

     
    2222from xpra.dotxpra import DotXpra, osexpand
    2323from xpra.platform.features import LOCAL_SERVERS_SUPPORTED, SHADOW_SUPPORTED, CAN_DAEMONIZE
    2424from xpra.platform.options import add_client_options
    25 from xpra.platform.paths import get_default_socket_dir
    2625from xpra.scripts.config import OPTION_TYPES, ENCRYPTION_CIPHERS, \
    2726    make_defaults_struct, parse_bool, print_bool, print_number, validate_config, has_sound_support, name_to_field
    2827
     
    357356        group.add_option("--daemon", action="store", metavar="yes|no",
    358357                          dest="daemon", default=defaults.daemon,
    359358                          help="Daemonize when running as a server (default: %s)" % enabled_str(defaults.daemon))
     359        group.add_option("--log-dir", action="store",
     360                      dest="log_dir", default=defaults.log_dir,
     361                      help="The directory where log files are placed"
     362                      )
    360363        group.add_option("--log-file", action="store",
    361364                      dest="log_file", default=defaults.log_file,
    362365                      help="When daemonizing, this is where the log messages will go. Default: '%default'."
    363                       + " If a relative filename is specified the it is relative to --socket-dir,"
     366                      + " If a relative filename is specified the it is relative to --log-dir,"
    364367                      + " the value of '$DISPLAY' will be substituted with the actual display used"
    365368                      )
    366369    else:
    367370        ignore({"daemon"    : False,
    368                 "log_file"  : defaults.log_file})
     371                "log_file"  : defaults.log_file,
     372                "log_dir"   : defaults.log_dir,
     373                })
    369374
    370375    #FIXME: file tranfer command line options:
    371376    legacy_bool_parse("printing")
     
    656661    group.add_option("--dpi", action="store",
    657662                      dest="dpi", default=defaults.dpi,
    658663                      help="The 'dots per inch' value that client applications should try to honour, from 10 to 1000 or 0 for automatic setting. Default: %s." % print_number(defaults.dpi))
    659     default_socket_dir_str = defaults.socket_dir or "$XPRA_SOCKET_DIR or '~/.xpra'"
     664    group.add_option("--socket-dirs", action="append",
     665                      dest="socket_dirs", default=defaults.socket_dirs,
     666                      help="Directories to look for the socket files in. Default: %s." % ", ".join("'%s'" % x for x in defaults.socket_dirs))
     667    default_socket_dir_str = defaults.socket_dir or "$XPRA_SOCKET_DIR or the first valid directory in socket-dirs"
    660668    group.add_option("--socket-dir", action="store",
    661669                      dest="socket_dir", default=defaults.socket_dir,
    662670                      help="Directory to place/look for the socket files in. Default: '%s'." % default_socket_dir_str)
     
    939947        elif mode == "initenv":
    940948            from xpra.scripts.server import xpra_runner_shell_script, write_runner_shell_script
    941949            script = xpra_runner_shell_script(script_file, os.getcwd(), options.socket_dir)
    942             dotxpra = DotXpra(options.socket_dir)
     950            dotxpra = DotXpra()
    943951            write_runner_shell_script(dotxpra, script, False)
    944952            return 0
    945953        else:
     
    10251033                error_cb("invalid ssh port specified: %s" % ssh_port)
    10261034            #grr why bother doing it different?
    10271035            if is_putty:
     1036                #special env used by plink:
     1037                env = os.environ.copy()
     1038                env["PLINK_PROTOCOL"] = "ssh"
     1039                desc["env"] = env
    10281040                full_ssh += ["-P", ssh_port]
    10291041            else:
    10301042                full_ssh += ["-p", ssh_port]
     
    10441056            except Exception as e:
    10451057                print("failed to read password file %s: %s", opts.password_file, e)
    10461058        return desc
     1059    elif display_name.startswith("socket:"):
     1060        desc["type"] = "unix-domain"
     1061        desc["local"] = True
     1062        desc["display"] = display_name
     1063        opts.display = display_name
     1064        desc["socket_path"] = display_name[len("socket:"):]
     1065        return desc
    10471066    elif display_name.startswith(":"):
    10481067        desc["type"] = "unix-domain"
    10491068        desc["local"] = True
    10501069        desc["display"] = display_name
    10511070        opts.display = display_name
    1052         desc["socket_dir"] = osexpand(opts.socket_dir or get_default_socket_dir(), opts.username)
     1071        from xpra.platform.paths import get_socket_dirs
     1072        desc["socket_dir"] = osexpand(opts.socket_dir or get_socket_dirs()[0], opts.username)
    10531073        return desc
    10541074    elif display_name.startswith("tcp:") or display_name.startswith("tcp/"):
    10551075        separator = display_name[3] # ":" or "/"
     
    10791099            error_cb("invalid port number: %s" % port)
    10801100        desc["port"] = port
    10811101        #host:
     1102       
    10821103        host = parts[1]
    10831104        if host.find("@")>0:
    10841105            username, host = host.split("@", 1)
     
    10951116def pick_display(error_cb, opts, extra_args):
    10961117    if len(extra_args) == 0:
    10971118        # Pick a default server
    1098         sockdir = DotXpra(opts.socket_dir or get_default_socket_dir())
     1119        sockdir = DotXpra(opts.socket_dir, opts.socket_dirs)
    10991120        servers = sockdir.sockets()
    11001121        live_servers = [display
    11011122                        for (state, display) in servers
     
    11431164            cmd = proxy_cmd
    11441165        try:
    11451166            kwargs = {}
     1167            if "env" in display_desc:
     1168                kwargs["env"] = display_desc["env"]
    11461169            kwargs["stderr"] = sys.stderr
    11471170            if not display_desc.get("exit_ssh", False) and os.name=="posix" and not sys.platform.startswith("darwin"):
    11481171                def setsid():
     
    12121235    elif dtype == "unix-domain":
    12131236        if not hasattr(socket, "AF_UNIX"):
    12141237            return False, "unix domain sockets are not available on this operating system"
    1215         sockdir = DotXpra(display_desc["socket_dir"])
     1238        #if the path was specified, use that:
     1239        sockfile = display_desc.get("socket_path")
     1240        if not sockfile:
     1241            #find the socket using the display:
     1242            dotxpra = DotXpra(display_desc["socket_dir"])
     1243            sockfile = dotxpra.socket_path(display_desc["display"])
    12161244        sock = socket.socket(socket.AF_UNIX)
    12171245        sock.settimeout(SOCKET_TIMEOUT)
    1218         sockfile = sockdir.socket_path(display_desc["display"])
    12191246        conn = _socket_connect(sock, sockfile, display_name, dtype)
    12201247        conn.timeout = SOCKET_TIMEOUT
    12211248
     
    13081335            app.setup_connection(conn)
    13091336        except Exception as e:
    13101337            app.cleanup()
    1311             raise e
     1338            raise
    13121339    return do_run_client(app)
    13131340
    13141341def make_client(error_cb, opts):
     
    14181445        raise InitException("too many existing xpra servers found, cannot guess which one to use")
    14191446    return live[0]
    14201447
    1421 def guess_X11_display(socket_dir):
     1448def guess_X11_display(socket_dir, socket_dirs):
    14221449    displays = [":%s" % x for x in find_X11_displays()]
    14231450    assert len(displays)!=0, "could not detect any live X11 displays"
    14241451    if len(displays)>1:
     
    14251452        #since we are here to shadow,
    14261453        #assume we want to shadow a real X11 server,
    14271454        #so remove xpra's own displays to narrow things down:
    1428         sockdir = DotXpra(socket_dir)
     1455        sockdir = DotXpra(socket_dir, socket_dir)
    14291456        results = sockdir.sockets()
    14301457        xpra_displays = [display for _, display in results]
    14311458        displays = list(set(displays)-set(xpra_displays))
     
    14371464    from xpra.server.proxy import XpraProxy
    14381465    assert "gtk" not in sys.modules
    14391466    if mode in ("_proxy_start", "_shadow_start"):
    1440         dotxpra = DotXpra()
     1467        dotxpra = DotXpra(opts.socket_dir, opts.socket_dirs)
    14411468        #we must use a subprocess to avoid messing things up - yuk
    14421469        cmd = [script_file]
    14431470        if mode=="_proxy_start":
     
    14611488                #display_name was provided:
    14621489                display_name = args[0]
    14631490            else:
    1464                 display_name = guess_X11_display(opts.socket_dir)
     1491                display_name = guess_X11_display(opts.socket_dir, opts.socket_dirs)
    14651492                #we now know the display name, so add it:
    14661493                args = [display_name]
    14671494        #adds the display to proxy start command:
     
    15371564def run_stopexit(mode, error_cb, opts, extra_args):
    15381565    assert "gtk" not in sys.modules
    15391566
    1540     def show_final_state(display):
    1541         sockdir = DotXpra(opts.socket_dir)
     1567    def show_final_state(display_desc):
     1568        display = display_desc["display"]
     1569        sockdir = display_desc["socket_dir"]
     1570        sockdir = DotXpra(sockdir)
    15421571        for _ in range(6):
    15431572            final_state = sockdir.server_state(display)
    15441573            if final_state is DotXpra.LIVE:
     
    15741603        if app:
    15751604            app.cleanup()
    15761605    if display_desc["local"]:
    1577         show_final_state(display_desc["display"])
     1606        show_final_state(display_desc)
    15781607    else:
    15791608        print("Sent shutdown command")
    15801609    return  e
    15811610
    15821611
    1583 def may_cleanup_socket(sockdir, state, display, clean_states=[DotXpra.DEAD]):
     1612def may_cleanup_socket(dotxpra, state, display, clean_states=[DotXpra.DEAD]):
    15841613    sys.stdout.write("\t%s session at %s" % (state, display))
    15851614    if state in clean_states:
    15861615        try:
    1587             os.unlink(sockdir.socket_path(display))
     1616            os.unlink(dotxpra.socket_path(display))
    15881617        except OSError:
    15891618            pass
    15901619        else:
     
    15951624    assert "gtk" not in sys.modules
    15961625    if extra_args:
    15971626        error_cb("too many arguments for mode")
    1598     sockdir = DotXpra(opts.socket_dir)
    1599     results = sockdir.sockets()
     1627    dotxpra = DotXpra(opts.socket_dir, opts.socket_dirs)
     1628    results = dotxpra.sockets()
    16001629    if not results:
    16011630        error_cb("No xpra sessions found")
    16021631    sys.stdout.write("Found the following xpra sessions:\n")
    16031632    for state, display in results:
    1604         may_cleanup_socket(sockdir, state, display)
     1633        may_cleanup_socket(dotxpra, state, display)
    16051634    #now, re-probe the "unknown" ones:
    16061635    unknown = [display for state, display in results if state==DotXpra.UNKNOWN]
    16071636    if len(unknown)>0:
     
    16131642        probe_list = list(unknown)
    16141643        unknown = []
    16151644        for display in probe_list:
    1616             state = sockdir.server_state(display)
     1645            state = dotxpra.server_state(display)
    16171646            if state is DotXpra.DEAD:
    1618                 may_cleanup_socket(sockdir, state, display)
     1647                may_cleanup_socket(dotxpra, state, display)
    16191648            elif state is DotXpra.UNKNOWN:
    16201649                unknown.append(display)
    16211650            else:
     
    16231652    #now cleanup those still unknown:
    16241653    clean_states = [DotXpra.DEAD, DotXpra.UNKNOWN]
    16251654    for display in unknown:
    1626         state = sockdir.server_state(display)
    1627         may_cleanup_socket(sockdir, state, display, clean_states=clean_states)
     1655        state = dotxpra.server_state(display)
     1656        may_cleanup_socket(dotxpra, state, display, clean_states=clean_states)
    16281657    return 0
    16291658
    16301659
  • xpra/scripts/server.py

     
    625625    log = Logger("server")
    626626    log.error("")
    627627    log.error("Xvfb command has terminated! xpra cannot continue")
     628    log.error(" if the display is already running, try a different one,")
     629    log.error(" or use the --use-display flag")
    628630    log.error("")
    629631    return False
    630632
     
    741743    signal.signal(signal.SIGINT, deadly_signal)
    742744    signal.signal(signal.SIGTERM, deadly_signal)
    743745
    744     dotxpra = DotXpra(opts.socket_dir)
     746    from xpra.platform.paths import get_socket_dirs
     747    dotxpra = DotXpra(opts.socket_dir or get_socket_dirs()[0])
    745748
    746749    # Generate the script text now, because os.getcwd() will
    747750    # change if/when we daemonize:
  • xpra/server/auth/file_auth.py

     
    2323
    2424password_file = None
    2525socket_dir = None
     26socket_dirs = None
    2627def init(opts):
    27     global password_file, socket_dir
     28    global password_file, socket_dir, socket_dirs
    2829    password_file = opts.password_file
    2930    socket_dir = opts.socket_dir
     31    socket_dirs = opts.socket_dirs
    3032
    3133
    3234def parseOptions(s):
     
    4648auth_data = None
    4749auth_data_time = None
    4850def load_auth_file():
    49     global auth_data, auth_data_time, password_file, socket_dir
     51    global auth_data, auth_data_time, password_file, socket_dir, socket_dirs
    5052    ptime = 0
    5153    if password_file:
    5254        if not os.path.exists(password_file):
     
    8082            if line.find("|")<0:
    8183                #assume old style file with just the password
    8284                #get all the displays for the current user:
    83                 sockdir = DotXpra(socket_dir)
     85                sockdir = DotXpra(socket_dir, socket_dirs)
    8486                results = sockdir.sockets()
    8587                displays = [display for state, display in results if state==DotXpra.LIVE]
    8688                auth_data[""] = line, os.getuid(), os.getgid(), displays, {}, {}
  • xpra/server/auth/sys_auth_base.py

     
    1111
    1212
    1313socket_dir = None
     14socket_dirs = None
    1415def init(opts):
    15     global socket_dir
     16    global socket_dir, socket_dirs
    1617    socket_dir = opts.socket_dir
     18    socket_dirs = opts.socket_dirs
    1719
    1820
    1921class SysAuthenticator(object):
     
    7981        uid = self.get_uid()
    8082        gid = self.get_gid()
    8183        try:
    82             sockdir = DotXpra(socket_dir, actual_username=self.username)
     84            sockdir = DotXpra(socket_dir, socket_dirs, actual_username=self.username)
    8385            results = sockdir.sockets(check_uid=uid)
    8486            displays = [display for state, display in results if state==DotXpra.LIVE]
    8587        except Exception as e:
  • xpra/server/source.py

     
    14381438            location = "on %s (via xpra)" % self.hostname
    14391439        #expand it here so the xpraforwarder doesn't need to import anything xpra:
    14401440        from xpra.dotxpra import osexpand
    1441         from xpra.platform.paths import get_default_socket_dir
    1442         socket_dir = osexpand(self.socket_dir or get_default_socket_dir())
    14431441        attributes = {"display"         : os.environ.get("DISPLAY"),
    14441442                      "source"          : self.uuid,
    1445                       "socket-dir"      : socket_dir}
     1443                      "socket-dir"      : osexpand(self.socket_dir)}
    14461444        for k,v in printers.items():
    14471445            if k in self.printers:
    14481446                #remove existing definition: