Exemple #1
0
 def __init__(self, sockdir=None, confdir=None, actual_username=""):
     from xpra.platform.paths import get_default_socket_dir, get_default_conf_dir
     self._confdir = osexpand(confdir or get_default_conf_dir(), actual_username)
     self._sockdir = osexpand(sockdir or get_default_socket_dir(), actual_username)
     if not os.path.exists(self._confdir):
         os.mkdir(self._confdir, o0700)
     if not os.path.exists(self._sockdir):
         os.mkdir(self._sockdir, o0700)
     self._prefix = "%s-" % (socket.gethostname(),)
Exemple #2
0
 def __init__(self, sockdir=None, confdir=None, actual_username=""):
     from xpra.platform.paths import get_default_socket_dir, get_default_conf_dir
     self._confdir = osexpand(confdir or get_default_conf_dir(), actual_username)
     self._sockdir = osexpand(sockdir or get_default_socket_dir(), actual_username)
     if not os.path.exists(self._confdir):
         os.mkdir(self._confdir, o0700)
     if not os.path.exists(self._sockdir):
         os.mkdir(self._sockdir, o0700)
     self._prefix = "%s-" % (socket.gethostname(),)
Exemple #3
0
 def __init__(self, sockdir=None, confdir=None, actual_username=""):
     from xpra.platform.paths import get_default_socket_dir, get_user_conf_dir
     self._confdir = osexpand(confdir or get_user_conf_dir(), actual_username)
     self._sockdir = osexpand(sockdir or get_default_socket_dir(), actual_username)
     if not os.path.exists(self._confdir):
         os.mkdir(self._confdir, 0o700)
     if not os.path.exists(self._sockdir):
         os.mkdir(self._sockdir, 0o700)
     hostname = os.environ.get("XPRA_SOCKET_HOSTNAME", socket.gethostname())
     self._prefix = "%s-" % (hostname,)
Exemple #4
0
 def __init__(self, sockdir=None, confdir=None):
     from xpra.platform.paths import get_default_socket_dir, get_default_conf_dir
     def expand(s):
         return os.path.expandvars(os.path.expanduser(s))
     self._confdir = expand(confdir or get_default_conf_dir())
     self._sockdir = expand(sockdir or get_default_socket_dir())
     if not os.path.exists(self._confdir):
         os.mkdir(self._confdir, o0700)
     if not os.path.exists(self._sockdir):
         os.mkdir(self._sockdir, o0700)
     self._prefix = "%s-" % (socket.gethostname(),)
Exemple #5
0
    def __init__(self, sockdir=None, confdir=None):
        from xpra.platform.paths import get_default_socket_dir, get_default_conf_dir

        def expand(s):
            return os.path.expandvars(os.path.expanduser(s))

        self._confdir = expand(confdir or get_default_conf_dir())
        self._sockdir = expand(sockdir or get_default_socket_dir())
        if not os.path.exists(self._confdir):
            os.mkdir(self._confdir, o0700)
        if not os.path.exists(self._sockdir):
            os.mkdir(self._sockdir, o0700)
        self._prefix = "%s-" % (socket.gethostname(), )
Exemple #6
0
def pick_display(parser, opts, extra_args):
    if len(extra_args) == 0:
        # Pick a default server
        sockdir = DotXpra(opts.socket_dir or get_default_socket_dir())
        servers = sockdir.sockets()
        live_servers = [
            display for (state, display) in servers if state is DotXpra.LIVE
        ]
        if len(live_servers) == 0:
            parser.error("cannot find a live server to connect to")
        elif len(live_servers) == 1:
            return parse_display_name(parser.error, opts, live_servers[0])
        else:
            parser.error("there are multiple servers running, please specify")
    elif len(extra_args) == 1:
        return parse_display_name(parser.error, opts, extra_args[0])
    else:
        parser.error("too many arguments")
Exemple #7
0
def pick_display(parser, opts, extra_args):
    if len(extra_args) == 0:
        # Pick a default server
        sockdir = DotXpra(opts.socket_dir or get_default_socket_dir())
        servers = sockdir.sockets()
        live_servers = [display
                        for (state, display) in servers
                        if state is DotXpra.LIVE]
        if len(live_servers) == 0:
            if not LOCAL_SERVERS_SUPPORTED:
                parser.error("this installation does not support local servers, you must specify a remote display")
            parser.error("cannot find a live server to connect to")
        elif len(live_servers) == 1:
            return parse_display_name(parser.error, opts, live_servers[0])
        else:
            parser.error("there are multiple servers running, please specify")
    elif len(extra_args) == 1:
        return parse_display_name(parser.error, opts, extra_args[0])
    else:
        parser.error("too many arguments")
Exemple #8
0
def pick_display(parser, opts, extra_args):
    if len(extra_args) == 0:
        # Pick a default server
        sockdir = DotXpra(opts.socket_dir or get_default_socket_dir())
        servers = sockdir.sockets()
        live_servers = [display
                        for (state, display) in servers
                        if state is DotXpra.LIVE]
        if len(live_servers) == 0:
            if not LOCAL_SERVERS_SUPPORTED:
                parser.error("this installation does not support local servers, you must specify a remote display")
            parser.error("cannot find a live server to connect to")
        elif len(live_servers) == 1:
            return parse_display_name(parser.error, opts, live_servers[0])
        else:
            parser.error("there are multiple servers running, please specify")
    elif len(extra_args) == 1:
        return parse_display_name(parser.error, opts, extra_args[0])
    else:
        parser.error("too many arguments")
Exemple #9
0
     if desc.get("password") is None and opts.password_file and os.path.exists(opts.password_file):
         try:
             try:
                 passwordFile = open(opts.password_file, "rb")
                 desc["password"] = passwordFile.read()
             finally:
                 passwordFile.close()
         except Exception, e:
             print("failed to read password file %s: %s", opts.password_file, e)
     return desc
 elif display_name.startswith(":"):
     desc["type"] = "unix-domain"
     desc["local"] = True
     desc["display"] = display_name
     opts.display = display_name
     desc["socket_dir"] = osexpand(opts.socket_dir or get_default_socket_dir(), opts.username)
     return desc
 elif display_name.startswith("tcp:") or display_name.startswith("tcp/"):
     separator = display_name[3] # ":" or "/"
     desc["type"] = "tcp"
     desc["local"] = False
     parts = display_name.split(separator)
     if len(parts) not in (3, 4):
         error_cb("invalid tcp connection string, use tcp/[username@]host/port[/display] or tcp:[username@]host:port[:display]")
     #display (optional):
     if len(parts)==4:
         display = parts[3]
         if display:
             try:
                 v = int(display)
                 display = ":%s" % v
Exemple #10
0
                 opts.password_file):
         try:
             try:
                 passwordFile = open(opts.password_file, "rb")
                 desc["password"] = passwordFile.read()
             finally:
                 passwordFile.close()
         except Exception, e:
             print("failed to read password file %s: %s",
                   opts.password_file, e)
     return desc
 elif display_name.startswith(":"):
     desc["type"] = "unix-domain"
     desc["local"] = True
     desc["display"] = display_name
     desc["socket_dir"] = opts.socket_dir or get_default_socket_dir()
     return desc
 elif display_name.startswith("tcp:") or display_name.startswith("tcp/"):
     separator = display_name[3]  # ":" or "/"
     desc["type"] = "tcp"
     desc["local"] = False
     parts = display_name.split(separator)
     if len(parts) != 3:
         error_cb(
             "invalid tcp connection string, use tcp/HOST/PORT or tcp:host:port"
         )
     port = int(parts[-1])
     if port <= 0 or port >= 65536:
         error_cb("invalid port number: %s" % port)
     desc["port"] = port
     desc["host"] = separator.join(parts[1:-1])
Exemple #11
0
     if desc.get("password") is None and opts.password_file and os.path.exists(opts.password_file):
         try:
             try:
                 passwordFile = open(opts.password_file, "rb")
                 desc["password"] = passwordFile.read()
             finally:
                 passwordFile.close()
         except Exception, e:
             print("failed to read password file %s: %s", opts.password_file, e)
     return desc
 elif display_name.startswith(":"):
     desc["type"] = "unix-domain"
     desc["local"] = True
     desc["display"] = display_name
     opts.display = display_name
     desc["socket_dir"] = osexpand(opts.socket_dir or get_default_socket_dir(), opts.username)
     return desc
 elif display_name.startswith("tcp:") or display_name.startswith("tcp/"):
     separator = display_name[3] # ":" or "/"
     desc["type"] = "tcp"
     desc["local"] = False
     parts = display_name.split(separator)
     if len(parts) not in (3, 4):
         error_cb("invalid tcp connection string, use tcp/[username@]host/port[/display] or tcp:[username@]host:port[:display]")
     #display (optional):
     if len(parts)==4:
         display = parts[3]
         if display:
             try:
                 v = int(display)
                 display = ":%s" % v