Store the host config in a per-host config file.

BUG=106795
TEST=Virtual Me2Me still works

Review URL: http://codereview.chromium.org/8863010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114066 0039d316-1c4b-4281-b951-d872f2087c98
parent 9b6e452c
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
import atexit import atexit
import getpass import getpass
import hashlib
import json import json
import logging import logging
import os import os
...@@ -29,6 +30,9 @@ import keygen ...@@ -29,6 +30,9 @@ import keygen
REMOTING_COMMAND = "remoting_me2me_host" REMOTING_COMMAND = "remoting_me2me_host"
# Command-line switch for passing the config path to remoting_me2me_host.
HOST_CONFIG_SWITCH_NAME = "host-config"
SCRIPT_PATH = os.path.dirname(sys.argv[0]) SCRIPT_PATH = os.path.dirname(sys.argv[0])
if not SCRIPT_PATH: if not SCRIPT_PATH:
SCRIPT_PATH = os.getcwd() SCRIPT_PATH = os.getcwd()
...@@ -260,10 +264,11 @@ class Desktop: ...@@ -260,10 +264,11 @@ class Desktop:
if not session_proc.pid: if not session_proc.pid:
raise Exception("Could not start X session") raise Exception("Could not start X session")
def launch_host(self): def launch_host(self, host):
# Start remoting host # Start remoting host
command = locate_executable(REMOTING_COMMAND) args = [locate_executable(REMOTING_COMMAND),
self.host_proc = subprocess.Popen(command, env=self.child_env) "--%s=%s" % (HOST_CONFIG_SWITCH_NAME, host.config_file)]
self.host_proc = subprocess.Popen(args, env=self.child_env)
if not self.host_proc.pid: if not self.host_proc.pid:
raise Exception("Could not start remoting host") raise Exception("Could not start remoting host")
...@@ -287,7 +292,8 @@ def main(): ...@@ -287,7 +292,8 @@ def main():
return 1 return 1
auth.save_config() auth.save_config()
host = Host(os.path.join(CONFIG_DIR, "host.json")) host_hash = hashlib.md5(socket.gethostname()).hexdigest()
host = Host(os.path.join(CONFIG_DIR, "host#%s.json" % host_hash))
if not host.load_config(): if not host.load_config():
host.create_config(auth) host.create_config(auth)
...@@ -298,7 +304,7 @@ def main(): ...@@ -298,7 +304,7 @@ def main():
desktop = Desktop() desktop = Desktop()
desktop.launch_x_server() desktop.launch_x_server()
desktop.launch_x_session() desktop.launch_x_session()
desktop.launch_host() desktop.launch_host(host)
while True: while True:
pid, status = os.wait() pid, status = os.wait()
...@@ -310,7 +316,7 @@ def main(): ...@@ -310,7 +316,7 @@ def main():
if pid == desktop.host_proc.pid: if pid == desktop.host_proc.pid:
logging.info("Host process terminated, relaunching") logging.info("Host process terminated, relaunching")
desktop.launch_host() desktop.launch_host(host)
if __name__ == "__main__": if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment