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

Side by Side Diff: remoting/host/curtain_mode_linux.cc

Issue 1954623005: Add Xorg+dummy as alternative for Xvfb (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address final comments Created 4 years, 7 months 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 | remoting/host/linux/linux_me2me_host.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/host/curtain_mode.h" 5 #include "remoting/host/curtain_mode.h"
6 6
7 #include <X11/extensions/XInput.h> 7 #include <X11/extensions/XInput.h>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "remoting/base/logging.h" 13 #include "remoting/base/logging.h"
14 #include "remoting/host/client_session_control.h" 14 #include "remoting/host/client_session_control.h"
15 15
16 namespace remoting { 16 namespace remoting {
17 17
18 class CurtainModeLinux : public CurtainMode { 18 class CurtainModeLinux : public CurtainMode {
19 public: 19 public:
20 CurtainModeLinux(); 20 CurtainModeLinux();
21 21
22 // Overriden from CurtainMode. 22 // Overriden from CurtainMode.
23 bool Activate() override; 23 bool Activate() override;
24 24
25 private: 25 private:
26 // Returns true if the host is running under an Xvfb session. 26 // Returns true if the host is running under a virtual session.
27 bool IsXvfbSession(); 27 bool IsVirtualSession();
28 28
29 DISALLOW_COPY_AND_ASSIGN(CurtainModeLinux); 29 DISALLOW_COPY_AND_ASSIGN(CurtainModeLinux);
30 }; 30 };
31 31
32 CurtainModeLinux::CurtainModeLinux() { 32 CurtainModeLinux::CurtainModeLinux() {
33 } 33 }
34 34
35 bool CurtainModeLinux::Activate() { 35 bool CurtainModeLinux::Activate() {
36 // We can't curtain the session in run-time in Linux. 36 // We can't curtain the session in run-time in Linux.
37 // Either the session is running on Xvfb (i.e. always curtained), or it is 37 // Either the session is running in a virtual session (i.e. always curtained),
38 // attached to the physical console (i.e. impossible to curtain). 38 // or it is attached to the physical console (i.e. impossible to curtain).
39 bool activated = IsXvfbSession(); 39 if (!IsVirtualSession()) {
40 if (!activated) { 40 LOG(ERROR) << "Curtain-mode is not supported when running on non-virtual "
41 LOG(ERROR) << "Curtain-mode is not supported when running on non-Xvfb "
42 "X server"; 41 "X server";
42 return false;
43 } 43 }
44 44
45 return activated; 45 return true;
46 } 46 }
47 47
48 bool CurtainModeLinux::IsXvfbSession() { 48 bool CurtainModeLinux::IsVirtualSession() {
49 // Try to identify an Xvfb session. There's no way to query what X server we 49 // Try to identify a virtual session. Since there's no way to tell from the
50 // are running under, so we check for the Xvfb input devices. 50 // vendor string, we check for known virtual input devices.
51 // TODO(rmsousa): Find a similar way to determine that the *output* is secure. 51 // TODO(rmsousa): Find a similar way to determine that the *output* is secure.
52 Display* display = XOpenDisplay(nullptr); 52 Display* display = XOpenDisplay(nullptr);
53 int opcode, event, error; 53 int opcode, event, error;
54 if (!XQueryExtension(display, "XInputExtension", &opcode, &event, &error)) { 54 if (!XQueryExtension(display, "XInputExtension", &opcode, &event, &error)) {
55 // If XInput is not available, assume it is not an Xvfb session. 55 // If XInput is not available, assume it is not a virtual session.
56 LOG(ERROR) << "X Input extension not available: " << error; 56 LOG(ERROR) << "X Input extension not available: " << error;
57 XCloseDisplay(display); 57 XCloseDisplay(display);
58 return false; 58 return false;
59 } 59 }
60 int num_devices; 60 int num_devices;
61 XDeviceInfo* devices; 61 XDeviceInfo* devices;
62 bool found_xvfb_mouse = false; 62 bool found_xvfb_mouse = false;
63 bool found_xvfb_keyboard = false; 63 bool found_xvfb_keyboard = false;
64 bool found_crd_void_input = false;
64 bool found_other_devices = false; 65 bool found_other_devices = false;
65 devices = XListInputDevices(display, &num_devices); 66 devices = XListInputDevices(display, &num_devices);
66 for (int i = 0; i < num_devices; i++) { 67 for (int i = 0; i < num_devices; i++) {
67 XDeviceInfo* device_info = &devices[i]; 68 XDeviceInfo* device_info = &devices[i];
68 if (device_info->use == IsXExtensionPointer) { 69 if (device_info->use == IsXExtensionPointer) {
69 if (strcmp(device_info->name, "Xvfb mouse") == 0) { 70 if (strcmp(device_info->name, "Xvfb mouse") == 0) {
70 found_xvfb_mouse = true; 71 found_xvfb_mouse = true;
72 } else if (strcmp(device_info->name,
73 "Chrome Remote Desktop Input") == 0) {
74 found_crd_void_input = true;
71 } else if (strcmp(device_info->name, "Virtual core XTEST pointer") != 0) { 75 } else if (strcmp(device_info->name, "Virtual core XTEST pointer") != 0) {
72 found_other_devices = true; 76 found_other_devices = true;
73 HOST_LOG << "Non Xvfb mouse found: " << device_info->name; 77 HOST_LOG << "Non-virtual mouse found: " << device_info->name;
74 } 78 }
75 } else if (device_info->use == IsXExtensionKeyboard) { 79 } else if (device_info->use == IsXExtensionKeyboard) {
76 if (strcmp(device_info->name, "Xvfb keyboard") == 0) { 80 if (strcmp(device_info->name, "Xvfb keyboard") == 0) {
77 found_xvfb_keyboard = true; 81 found_xvfb_keyboard = true;
78 } else if (strcmp(device_info->name, 82 } else if (strcmp(device_info->name,
79 "Virtual core XTEST keyboard") != 0) { 83 "Virtual core XTEST keyboard") != 0) {
80 found_other_devices = true; 84 found_other_devices = true;
81 HOST_LOG << "Non Xvfb keyboard found: " << device_info->name; 85 HOST_LOG << "Non-virtual keyboard found: " << device_info->name;
82 } 86 }
83 } else if (device_info->use == IsXPointer) { 87 } else if (device_info->use == IsXPointer) {
84 if (strcmp(device_info->name, "Virtual core pointer") != 0) { 88 if (strcmp(device_info->name, "Virtual core pointer") != 0) {
85 found_other_devices = true; 89 found_other_devices = true;
86 HOST_LOG << "Non Xvfb mouse found: " << device_info->name; 90 HOST_LOG << "Non-virtual mouse found: " << device_info->name;
87 } 91 }
88 } else if (device_info->use == IsXKeyboard) { 92 } else if (device_info->use == IsXKeyboard) {
89 if (strcmp(device_info->name, "Virtual core keyboard") != 0) { 93 if (strcmp(device_info->name, "Virtual core keyboard") != 0) {
90 found_other_devices = true; 94 found_other_devices = true;
91 HOST_LOG << "Non Xvfb keyboard found: " << device_info->name; 95 HOST_LOG << "Non-virtual keyboard found: " << device_info->name;
92 } 96 }
93 } else { 97 } else {
94 found_other_devices = true; 98 found_other_devices = true;
95 HOST_LOG << "Non Xvfb device found: " << device_info->name; 99 HOST_LOG << "Non-virtual device found: " << device_info->name;
96 } 100 }
97 } 101 }
98 XFreeDeviceList(devices); 102 XFreeDeviceList(devices);
99 XCloseDisplay(display); 103 XCloseDisplay(display);
100 return found_xvfb_mouse && found_xvfb_keyboard && !found_other_devices; 104 return ((found_xvfb_mouse && found_xvfb_keyboard) || found_crd_void_input)
105 && !found_other_devices;
101 } 106 }
102 107
103 // static 108 // static
104 std::unique_ptr<CurtainMode> CurtainMode::Create( 109 std::unique_ptr<CurtainMode> CurtainMode::Create(
105 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, 110 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
106 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, 111 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
107 base::WeakPtr<ClientSessionControl> client_session_control) { 112 base::WeakPtr<ClientSessionControl> client_session_control) {
108 return base::WrapUnique(new CurtainModeLinux()); 113 return base::WrapUnique(new CurtainModeLinux());
109 } 114 }
110 115
111 } // namespace remoting 116 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | remoting/host/linux/linux_me2me_host.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698