Commit 2b332320 authored by Gary Kacmarcik's avatar Gary Kacmarcik Committed by Chromium LUCI CQ

[Chromoting] Check in alternate path for CGSession

The final release of macOS Big Sur removed CGSession, which we need to
enable curtain mode on Mac hosts.

This change adds an alternate search path for CGSession so that admins
can copy the binary there and have Mac hosts with with curtain mode.

Change-Id: Icd4e2d6c60b351c705197730341067caa41d8f09

Bug: 1169841
Change-Id: Icd4e2d6c60b351c705197730341067caa41d8f09
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2645293
Commit-Queue: Gary Kacmarcik <garykac@chromium.org>
Reviewed-by: default avatarJoe Downing <joedow@chromium.org>
Auto-Submit: Gary Kacmarcik <garykac@chromium.org>
Cr-Commit-Position: refs/heads/master@{#846342}
parent 7669c4b5
...@@ -23,10 +23,19 @@ namespace remoting { ...@@ -23,10 +23,19 @@ namespace remoting {
namespace { namespace {
// Standard path to CGSession (pre-Big Sur).
// Note: This binary was removed for the official Big Sur release.
// See tracking issues crbug://1169841 and rdar://8977508.
const char* kCGSessionPath = const char* kCGSessionPath =
"/System/Library/CoreServices/Menu Extras/User.menu/Contents/Resources/" "/System/Library/CoreServices/Menu Extras/User.menu/Contents/Resources/"
"CGSession"; "CGSession";
// Alternate path to search for CGSession.
// Admins can copy the CGSession binary here to get curtain mode to work again
// on Mac hosts. This is a temporary workaround for CGSession being removed
// on Big Sur.
const char* kCGSessionAltPath = "/usr/local/sbin/CGSession";
// Most machines will have < 4 displays but a larger upper bound won't hurt. // Most machines will have < 4 displays but a larger upper bound won't hurt.
const UInt32 kMaxDisplaysToQuery = 32; const UInt32 kMaxDisplaysToQuery = 32;
...@@ -179,9 +188,24 @@ void SessionWatcher::ActivateCurtain() { ...@@ -179,9 +188,24 @@ void SessionWatcher::ActivateCurtain() {
// could try reconnecting in that case (until we had a real fix deployed). // could try reconnecting in that case (until we had a real fix deployed).
// Issue is tracked via: rdar://42733382 // Issue is tracked via: rdar://42733382
bool is_headless = IsRunningHeadless(); bool is_headless = IsRunningHeadless();
// Check to see if the CGSession binary is available. If we cannot find it,
// then we can't enable curtain mode and need to disconnect the session.
const char* cgsession_path = NULL;
if (access(kCGSessionPath, X_OK) == 0) {
cgsession_path = kCGSessionPath;
} else if (access(kCGSessionAltPath, X_OK) == 0) {
cgsession_path = kCGSessionAltPath;
} else {
// Disconnect the session since we are unable to enter curtain mode.
LOG(ERROR) << "Can't find CGSession - unable to enter curtain mode.";
DisconnectSession(protocol::ErrorCode::HOST_CONFIGURATION_ERROR);
return;
}
pid_t child = fork(); pid_t child = fork();
if (child == 0) { if (child == 0) {
execl(kCGSessionPath, kCGSessionPath, "-suspend", nullptr); execl(cgsession_path, cgsession_path, "-suspend", nullptr);
_exit(1); _exit(1);
} else if (child > 0) { } else if (child > 0) {
int status = 0; int status = 0;
......
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