From 3cd0756d48b8a6c910c1e041ebf1605ef777851c Mon Sep 17 00:00:00 2001 From: "lambroslambrou@chromium.org" Date: Fri, 4 Jan 2013 22:23:40 +0000 Subject: Improve xsession execution When running a custom xsession (such as ~/.xsession), execute it with /bin/sh -c, which copes better with scripts that have the executable permission set, but don't have a she-bang line, for example. BUG=167409 TEST=Verify with ~/.xsession executable but no she-bang. Also verify with default unity-2d session on Precise. NOTRY=true Review URL: https://chromiumcodereview.appspot.com/11715003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175212 0039d316-1c4b-4281-b951-d872f2087c98 --- remoting/tools/me2me_virtual_host.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'remoting') diff --git a/remoting/tools/me2me_virtual_host.py b/remoting/tools/me2me_virtual_host.py index 841599a..e0d7205 100755 --- a/remoting/tools/me2me_virtual_host.py +++ b/remoting/tools/me2me_virtual_host.py @@ -17,6 +17,7 @@ import json import logging import optparse import os +import pipes import signal import socket import subprocess @@ -349,7 +350,7 @@ class Desktop: devnull.close() def _launch_x_session(self): - # Start desktop session + # Start desktop session. # The /dev/null input redirection is necessary to prevent the X session # reading from stdin. If this code runs as a shell background job in a # terminal, any reading from stdin causes the job to be suspended. @@ -498,7 +499,10 @@ def choose_x_session(): # (see /etc/X11/Xsession.d/50x11-common_determine-startup), to determine # exactly how to run this file. if os.access(startup_file, os.X_OK): - return startup_file + # "/bin/sh -c" is smart about how to execute the session script and + # works in cases where plain exec() fails (for example, if the file is + # marked executable, but is a plain script with no shebang line). + return ["/bin/sh", "-c", pipes.quote(startup_file)] else: shell = os.environ.get("SHELL", "sh") return [shell, startup_file] -- cgit v1.1