Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: remoting/host/linux/linux_me2me_host.py

Issue 2566363002: Don't include TMPDIR in X server environment (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 # Virtual Me2Me implementation. This script runs and manages the processes 6 # Virtual Me2Me implementation. This script runs and manages the processes
7 # required for a Virtual Me2Me desktop, which are: X server, X desktop 7 # required for a Virtual Me2Me desktop, which are: X server, X desktop
8 # session, and Host process. 8 # session, and Host process.
9 # This script is intended to run continuously as a background daemon 9 # This script is intended to run continuously as a background daemon
10 # process, running under an ordinary (non-root) user account. 10 # process, running under an ordinary (non-root) user account.
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 self.child_env["PULSE_STATE_PATH"] = pulse_path 463 self.child_env["PULSE_STATE_PATH"] = pulse_path
464 self.child_env["PULSE_SINK"] = sink_name 464 self.child_env["PULSE_SINK"] = sink_name
465 self.pulseaudio_pipe = pipe_name 465 self.pulseaudio_pipe = pipe_name
466 466
467 return True 467 return True
468 468
469 def _setup_gnubby(self): 469 def _setup_gnubby(self):
470 self.ssh_auth_sockname = ("/tmp/chromoting.%s.ssh_auth_sock" % 470 self.ssh_auth_sockname = ("/tmp/chromoting.%s.ssh_auth_sock" %
471 os.environ["USER"]) 471 os.environ["USER"])
472 472
473 # Returns child environment not containing TMPDIR.
474 # Certain values of TMPDIR can break the X server (crbug.com/672684), so we
475 # want to make sure it isn't set in the envirionment we use to start the
476 # server.
477 def _x_env(self):
478 if "TMPDIR" not in self.child_env:
479 return self.child_env
480 else:
481 env_copy = dict(self.child_env)
482 del env_copy["TMPDIR"]
483 return env_copy
484
473 def _wait_for_x(self): 485 def _wait_for_x(self):
474 # Wait for X to be active. 486 # Wait for X to be active.
475 with open(os.devnull, "r+") as devnull: 487 with open(os.devnull, "r+") as devnull:
476 for _test in range(20): 488 for _test in range(20):
477 exit_code = subprocess.call("xdpyinfo", env=self.child_env, 489 exit_code = subprocess.call("xdpyinfo", env=self.child_env,
478 stdout=devnull) 490 stdout=devnull)
479 if exit_code == 0: 491 if exit_code == 0:
480 break 492 break
481 time.sleep(0.5) 493 time.sleep(0.5)
482 if exit_code != 0: 494 if exit_code != 0:
(...skipping 10 matching lines...) Expand all
493 xvfb = "Xvfb" 505 xvfb = "Xvfb"
494 506
495 logging.info("Starting %s on display :%d" % (xvfb, display)) 507 logging.info("Starting %s on display :%d" % (xvfb, display))
496 screen_option = "%dx%dx24" % (max_width, max_height) 508 screen_option = "%dx%dx24" % (max_width, max_height)
497 self.x_proc = subprocess.Popen( 509 self.x_proc = subprocess.Popen(
498 [xvfb, ":%d" % display, 510 [xvfb, ":%d" % display,
499 "-auth", x_auth_file, 511 "-auth", x_auth_file,
500 "-nolisten", "tcp", 512 "-nolisten", "tcp",
501 "-noreset", 513 "-noreset",
502 "-screen", "0", screen_option 514 "-screen", "0", screen_option
503 ] + extra_x_args, env=self.child_env) 515 ] + extra_x_args, env=self._x_env())
504 if not self.x_proc.pid: 516 if not self.x_proc.pid:
505 raise Exception("Could not start Xvfb.") 517 raise Exception("Could not start Xvfb.")
506 518
507 self._wait_for_x() 519 self._wait_for_x()
508 520
509 with open(os.devnull, "r+") as devnull: 521 with open(os.devnull, "r+") as devnull:
510 exit_code = subprocess.call("xrandr", env=self.child_env, 522 exit_code = subprocess.call("xrandr", env=self.child_env,
511 stdout=devnull, stderr=devnull) 523 stdout=devnull, stderr=devnull)
512 if exit_code == 0: 524 if exit_code == 0:
513 # RandR is supported 525 # RandR is supported
(...skipping 22 matching lines...) Expand all
536 self.x_proc = subprocess.Popen( 548 self.x_proc = subprocess.Popen(
537 ["Xorg", ":%d" % display, 549 ["Xorg", ":%d" % display,
538 "-auth", x_auth_file, 550 "-auth", x_auth_file,
539 "-nolisten", "tcp", 551 "-nolisten", "tcp",
540 "-noreset", 552 "-noreset",
541 # Disable logging to a file and instead bump up the stderr verbosity 553 # Disable logging to a file and instead bump up the stderr verbosity
542 # so the equivalent information gets logged in our main log file. 554 # so the equivalent information gets logged in our main log file.
543 "-logfile", "/dev/null", 555 "-logfile", "/dev/null",
544 "-verbose", "3", 556 "-verbose", "3",
545 "-config", config_file.name 557 "-config", config_file.name
546 ] + extra_x_args, env=self.child_env) 558 ] + extra_x_args, env=self._x_env())
547 if not self.x_proc.pid: 559 if not self.x_proc.pid:
548 raise Exception("Could not start Xorg.") 560 raise Exception("Could not start Xorg.")
549 self._wait_for_x() 561 self._wait_for_x()
550 562
551 def _launch_x_server(self, extra_x_args): 563 def _launch_x_server(self, extra_x_args):
552 x_auth_file = os.path.expanduser("~/.Xauthority") 564 x_auth_file = os.path.expanduser("~/.Xauthority")
553 self.child_env["XAUTHORITY"] = x_auth_file 565 self.child_env["XAUTHORITY"] = x_auth_file
554 display = self.get_unused_display_number() 566 display = self.get_unused_display_number()
555 567
556 # Run "xauth add" with |child_env| so that it modifies the same XAUTHORITY 568 # Run "xauth add" with |child_env| so that it modifies the same XAUTHORITY
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 else: 1555 else:
1544 logging.info("Host exited with status %s." % os.WEXITSTATUS(status)) 1556 logging.info("Host exited with status %s." % os.WEXITSTATUS(status))
1545 elif os.WIFSIGNALED(status): 1557 elif os.WIFSIGNALED(status):
1546 logging.info("Host terminated by signal %s." % os.WTERMSIG(status)) 1558 logging.info("Host terminated by signal %s." % os.WTERMSIG(status))
1547 1559
1548 1560
1549 if __name__ == "__main__": 1561 if __name__ == "__main__":
1550 logging.basicConfig(level=logging.DEBUG, 1562 logging.basicConfig(level=logging.DEBUG,
1551 format="%(asctime)s:%(levelname)s:%(message)s") 1563 format="%(asctime)s:%(levelname)s:%(message)s")
1552 sys.exit(main()) 1564 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698