Commit 7716becf authored by Erik Jensen's avatar Erik Jensen Committed by Commit Bot

remoting: Add CRD Xsession script.

The session chooser was previously hardcoded to call /etc/X11/Xsession.
However, it turns out that file is Debian specific, so this change
introduces an Xsession script in the CRD directory and updates the
session chooser to call that. On Debian, this file just delegates to
/etc/X11/Xsession, but it makes it possible to install CRD on other
distros by swapping in an appropriate replacement.

Change-Id: I50c9599c929b1875798ba04043762358024607f8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2436624
Commit-Queue: Erik Jensen <rkjnsn@chromium.org>
Reviewed-by: default avatarJamie Walch <jamiewalch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811945}
parent c41901b0
...@@ -41,6 +41,8 @@ install: ...@@ -41,6 +41,8 @@ install:
"$(INSTALL_DIR)/chrome-remote-desktop" "$(INSTALL_DIR)/chrome-remote-desktop"
install "$(SRC_DIR)/remoting/host/installer/linux/is-remoting-session" \ install "$(SRC_DIR)/remoting/host/installer/linux/is-remoting-session" \
"$(INSTALL_DIR)" "$(INSTALL_DIR)"
install "$(SRC_DIR)/remoting/host/installer/linux/Xsession" \
"$(INSTALL_DIR)"
install -m 0644 \ install -m 0644 \
"$(BUILD_DIR)/remoting/com.google.chrome.remote_desktop.json" \ "$(BUILD_DIR)/remoting/com.google.chrome.remote_desktop.json" \
......
#!/bin/bash
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This file is used by the session chooser to set up the environment and launch
# the session selected by the user.
# On Debian-based systems, just delegate to the distro-supplied Xsession script
# to launch the selected session.
exec /etc/X11/Xsession "$@"
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/message_loop/message_pump_type.h" #include "base/message_loop/message_pump_type.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/path_service.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/task/single_thread_task_executor.h" #include "base/task/single_thread_task_executor.h"
...@@ -47,8 +48,6 @@ namespace remoting { ...@@ -47,8 +48,6 @@ namespace remoting {
namespace { namespace {
const char XSESSION_SCRIPT[] = "/etc/X11/Xsession";
struct XSession { struct XSession {
std::string name; std::string name;
std::string comment; std::string comment;
...@@ -326,14 +325,22 @@ std::vector<XSession> CollectXSessions() { ...@@ -326,14 +325,22 @@ std::vector<XSession> CollectXSessions() {
} }
void ExecXSession(base::OnceClosure quit_closure, XSession session) { void ExecXSession(base::OnceClosure quit_closure, XSession session) {
LOG(INFO) << "Running " << XSESSION_SCRIPT << " " << session.exec; base::FilePath xsession_script;
if (!base::PathService::Get(base::DIR_EXE, &xsession_script)) {
PLOG(ERROR) << "Failed to get CRD install path";
std::move(quit_closure).Run();
return;
}
xsession_script = xsession_script.Append("Xsession");
LOG(INFO) << "Running " << xsession_script << " " << session.exec;
if (!session.desktop_names.empty()) { if (!session.desktop_names.empty()) {
std::unique_ptr<base::Environment> environment = std::unique_ptr<base::Environment> environment =
base::Environment::Create(); base::Environment::Create();
environment->SetVar("XDG_CURRENT_DESKTOP", environment->SetVar("XDG_CURRENT_DESKTOP",
base::JoinString(session.desktop_names, ":")); base::JoinString(session.desktop_names, ":"));
} }
execl(XSESSION_SCRIPT, XSESSION_SCRIPT, session.exec.c_str(), nullptr); execl(xsession_script.value().c_str(), xsession_script.value().c_str(),
session.exec.c_str(), nullptr);
PLOG(ERROR) << "Failed to exec XSession"; PLOG(ERROR) << "Failed to exec XSession";
std::move(quit_closure).Run(); std::move(quit_closure).Run();
} }
......
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