Skip to content

Commit

Permalink
make it possible to start from a deleted directory, default to home d…
Browse files Browse the repository at this point in the history
…ir after printing a warning

git-svn-id: https://xpra.org/svn/Xpra/trunk@11778 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jan 29, 2016
1 parent 38df910 commit 85607fb
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/xpra/scripts/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ def imsettings_env(disabled, gtk_im_module, qt_im_module, imsettings_module, xmo
os.environ.update(v)
return v

def start_Xvfb(xvfb_str, display_name):
def start_Xvfb(xvfb_str, display_name, cwd):
# We need to set up a new server environment
xauthority = os.environ.get("XAUTHORITY", os.path.expanduser("~/.Xauthority"))
if not os.path.exists(xauthority):
Expand All @@ -609,7 +609,7 @@ def start_Xvfb(xvfb_str, display_name):
"USER" : os.environ.get("USER", "unknown-user"),
"UID" : os.getuid(),
"GID" : os.getgid(),
"HOME" : os.environ.get("HOME", os.getcwd()),
"HOME" : os.environ.get("HOME", cwd),
"DISPLAY" : display_name}
xvfb_str = shellsub(xvfb_str, subs)

Expand Down Expand Up @@ -758,6 +758,11 @@ def guess_xpra_display(socket_dir, socket_dirs):


def run_server(error_cb, opts, mode, xpra_file, extra_args):
try:
cwd = os.getcwd()
except:
cwd = os.path.expanduser("~")
sys.stderr.write("current working directory does not exist, using '%s'\n" % cwd)
if opts.password_file and not (opts.auth or opts.tcp_auth):
raise InitException("when specifying a password-file, you must use auth or tcp-auth")
validate_encryption(opts)
Expand Down Expand Up @@ -841,7 +846,7 @@ def run_server(error_cb, opts, mode, xpra_file, extra_args):

# Generate the script text now, because os.getcwd() will
# change if/when we daemonize:
script = xpra_runner_shell_script(xpra_file, os.getcwd(), opts.socket_dir)
script = xpra_runner_shell_script(xpra_file, cwd, opts.socket_dir)

if start_vfb or opts.daemon:
#we will probably need a log dir
Expand Down Expand Up @@ -910,9 +915,11 @@ def run_server(error_cb, opts, mode, xpra_file, extra_args):
xvfb_pid = None
if start_vfb:
try:
xvfb, display_name = start_Xvfb(opts.xvfb, display_name)
xvfb, display_name = start_Xvfb(opts.xvfb, display_name, cwd)
except OSError as e:
log.error("Error starting Xvfb: %s\n", e)
log.error("Error starting Xvfb:")
log.error(" %s", e)
log("start_Xvfb error", exc_info=True)
return 1
xvfb_pid = xvfb.pid
#always update as we may now have the "real" display name:
Expand Down

0 comments on commit 85607fb

Please sign in to comment.