Commit f9eae99d authored by Yuwei Huang's avatar Yuwei Huang Committed by Commit Bot

[remoting][mac] Reimplement host service script as executable

Catalina starts making /bin/sh the responsible process of the host
service script even if we don't explicitly put sh in the launchd plist
file, which is bad since the user would be tempted to grant permissions
to sh and effectively all shell scripts.

This CL reimplements the old script as an executable so that it
(remoting_me2me_host_service) can become the responsible process and we
can fallback to the old script with disclaim_responsibility in the
future. We can technically launch host with disclaim_responsibility to
make remoting_me2me_host the responsible process, but both of them
still show up as ChromeRemoteDesktopHost on Preferences, while
disclaim_responsibility uses an undocumented private API, so I prefer
not doing so.

The new binary is a drop-in replacement for the old script. The only
change here is the removal of SIGKILL, SIGSTOP, and SIGCHLD from the
signal forwarding list, as they are either not catchable or make no
sense to forward.

Bug: 1013692
Change-Id: I56eae7116fdc03aeb9bf754164618bcb84ae5ce3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1857651
Commit-Queue: Yuwei Huang <yuweih@chromium.org>
Reviewed-by: default avatarLambros Lambrou <lambroslambrou@chromium.org>
Reviewed-by: default avatarJamie Walch <jamiewalch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705738}
parent faba093c
...@@ -66,6 +66,7 @@ source_set("base") { ...@@ -66,6 +66,7 @@ source_set("base") {
deps = [ deps = [
"//base/third_party/dynamic_annotations", "//base/third_party/dynamic_annotations",
"//google_apis", "//google_apis",
"//remoting/base/grpc_support",
"//third_party/libvpx", "//third_party/libvpx",
"//third_party/libyuv", "//third_party/libyuv",
"//third_party/webrtc/modules/desktop_capture:primitives", "//third_party/webrtc/modules/desktop_capture:primitives",
......
...@@ -20,15 +20,21 @@ struct NameMapElement { ...@@ -20,15 +20,21 @@ struct NameMapElement {
}; };
template <typename T, size_t N> template <typename T, size_t N>
const char* ValueToName(const NameMapElement<T> (&map)[N], T value) { const char* ValueToNameUnchecked(const NameMapElement<T> (&map)[N], T value) {
for (size_t i = 0; i < N; ++i) { for (size_t i = 0; i < N; ++i) {
if (map[i].value == value) if (map[i].value == value)
return map[i].name; return map[i].name;
} }
NOTREACHED();
return nullptr; return nullptr;
} }
template <typename T, size_t N>
const char* ValueToName(const NameMapElement<T> (&map)[N], T value) {
const char* result = ValueToNameUnchecked(map, value);
DCHECK_NE(nullptr, result);
return result;
}
template <typename T, size_t N> template <typename T, size_t N>
bool NameToValue(const NameMapElement<T> (&map)[N], bool NameToValue(const NameMapElement<T> (&map)[N],
const std::string& name, const std::string& name,
......
...@@ -54,6 +54,23 @@ source_set("host") { ...@@ -54,6 +54,23 @@ source_set("host") {
] ]
} }
source_set("base") {
sources = [
"host_exit_codes.cc",
"host_exit_codes.h",
"logging.h",
"logging_linux.cc",
"logging_mac.cc",
"logging_win.cc",
"username.cc",
"username.h",
]
deps = [
"//base",
"//remoting/base",
]
}
# This must be a static library instead of a source set because # This must be a static library instead of a source set because
# remoting_unittests requires that remoting_me2me_host.cc not be pulled in, # remoting_unittests requires that remoting_me2me_host.cc not be pulled in,
# which in turn depends on remoting_me2me_host_static which isn't part of that # which in turn depends on remoting_me2me_host_static which isn't part of that
...@@ -173,8 +190,6 @@ static_library("common") { ...@@ -173,8 +190,6 @@ static_library("common") {
"host_details.h", "host_details.h",
"host_event_logger.h", "host_event_logger.h",
"host_event_logger_win.cc", "host_event_logger_win.cc",
"host_exit_codes.cc",
"host_exit_codes.h",
"host_experiment_session_plugin.cc", "host_experiment_session_plugin.cc",
"host_experiment_session_plugin.h", "host_experiment_session_plugin.h",
"host_export.h", "host_export.h",
...@@ -221,10 +236,6 @@ static_library("common") { ...@@ -221,10 +236,6 @@ static_library("common") {
"ipc_video_frame_capturer.h", "ipc_video_frame_capturer.h",
"it2me_desktop_environment.cc", "it2me_desktop_environment.cc",
"it2me_desktop_environment.h", "it2me_desktop_environment.h",
"logging.h",
"logging_linux.cc",
"logging_mac.cc",
"logging_win.cc",
"me2me_desktop_environment.cc", "me2me_desktop_environment.cc",
"me2me_desktop_environment.h", "me2me_desktop_environment.h",
"mouse_cursor_monitor_proxy.cc", "mouse_cursor_monitor_proxy.cc",
...@@ -288,8 +299,6 @@ static_library("common") { ...@@ -288,8 +299,6 @@ static_library("common") {
"usage_stats_consent.h", "usage_stats_consent.h",
"usage_stats_consent_mac.cc", "usage_stats_consent_mac.cc",
"usage_stats_consent_win.cc", "usage_stats_consent_win.cc",
"username.cc",
"username.h",
"xmpp_register_support_host_request.cc", "xmpp_register_support_host_request.cc",
"xmpp_register_support_host_request.h", "xmpp_register_support_host_request.h",
"xsession_chooser_linux.cc", "xsession_chooser_linux.cc",
...@@ -306,6 +315,7 @@ static_library("common") { ...@@ -306,6 +315,7 @@ static_library("common") {
defines = [ "WEBRTC_CHROMIUM_BUILD" ] defines = [ "WEBRTC_CHROMIUM_BUILD" ]
deps = [ deps = [
":base",
"//base:i18n", "//base:i18n",
"//build:branding_buildflags", "//build:branding_buildflags",
"//components/policy/core/common", "//components/policy/core/common",
......
...@@ -25,4 +25,9 @@ const char* ExitCodeToString(HostExitCodes exit_code) { ...@@ -25,4 +25,9 @@ const char* ExitCodeToString(HostExitCodes exit_code) {
return ValueToName(kHostExitCodeStrings, exit_code); return ValueToName(kHostExitCodeStrings, exit_code);
} }
const char* ExitCodeToStringUnchecked(int exit_code) {
return ValueToNameUnchecked(kHostExitCodeStrings,
static_cast<HostExitCodes>(exit_code));
}
} // namespace remoting } // namespace remoting
...@@ -35,6 +35,10 @@ enum HostExitCodes { ...@@ -35,6 +35,10 @@ enum HostExitCodes {
}; };
const char* ExitCodeToString(HostExitCodes exit_code); const char* ExitCodeToString(HostExitCodes exit_code);
// Returns nullptr if |exit_code| is not a HostExitCodes.
const char* ExitCodeToStringUnchecked(int exit_code);
} // namespace remoting } // namespace remoting
#endif // REMOTING_HOST_HOST_EXIT_CODES_H_ #endif // REMOTING_HOST_HOST_EXIT_CODES_H_
...@@ -20,6 +20,31 @@ source_set("constants") { ...@@ -20,6 +20,31 @@ source_set("constants") {
] ]
} }
executable("remoting_me2me_host_service") {
sources = [
"host_service_main.cc",
]
configs += [ "//remoting/build/config:version" ]
deps = [
":constants",
"//base",
"//remoting/base",
"//remoting/host:base",
]
}
bundle_data("remoting_me2me_host_service_bundle_data") {
sources = [
"$root_out_dir/remoting_me2me_host_service",
]
outputs = [
"{{bundle_executable_dir}}/{{source_file_part}}",
]
public_deps = [
":remoting_me2me_host_service",
]
}
# remoting_me2me_host-InfoPlist.strings # remoting_me2me_host-InfoPlist.strings
foreach(locale, remoting_locales_with_underscores) { foreach(locale, remoting_locales_with_underscores) {
bundle_data("remoting_me2me_host_strings_${locale}_bundle_data") { bundle_data("remoting_me2me_host_strings_${locale}_bundle_data") {
...@@ -100,6 +125,7 @@ target("mac_app_bundle", "remoting_me2me_host") { ...@@ -100,6 +125,7 @@ target("mac_app_bundle", "remoting_me2me_host") {
} }
deps += [ deps += [
":remoting_host_resources", ":remoting_host_resources",
":remoting_me2me_host_service_bundle_data",
":remoting_me2me_script", ":remoting_me2me_script",
"//remoting/host:remoting_infoplist_strings", "//remoting/host:remoting_infoplist_strings",
"//remoting/resources:copy_locales", "//remoting/resources:copy_locales",
......
This diff is collapsed.
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