From 9675423249723ff876fd7b475f2f759cbe7db00e Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Thu, 31 Aug 2023 15:43:29 -0700 Subject: [PATCH 1/2] Impl --- common/settings.h | 4 ---- runtime/dart_isolate.cc | 1 - runtime/dart_service_isolate.cc | 5 ----- runtime/dart_service_isolate.h | 3 --- runtime/dart_vm.cc | 9 --------- shell/common/switches.cc | 5 ----- shell/common/switches.h | 4 ---- .../android/io/flutter/app/FlutterActivityDelegate.java | 3 --- .../io/flutter/embedding/engine/FlutterShellArgs.java | 5 ----- shell/platform/fuchsia/dart_runner/service_isolate.cc | 6 ------ shell/testing/observatory/launcher.dart | 1 - 11 files changed, 46 deletions(-) diff --git a/common/settings.h b/common/settings.h index d9df7e707b172..69fdf1002cedb 100644 --- a/common/settings.h +++ b/common/settings.h @@ -189,10 +189,6 @@ struct Settings { // target indicating the URL at which the VM service can be accessed. uint32_t vm_service_port = 0; - // Determines whether an authentication code is required to communicate with - // the VM service. - bool disable_service_auth_codes = true; - // Determine whether the vmservice should fallback to automatic port selection // after failing to bind to a specified port. bool enable_service_port_fallback = false; diff --git a/runtime/dart_isolate.cc b/runtime/dart_isolate.cc index 791ac03dbbf95..d8ce6eb2f84e8 100644 --- a/runtime/dart_isolate.cc +++ b/runtime/dart_isolate.cc @@ -805,7 +805,6 @@ Dart_Isolate DartIsolate::DartCreateAndStartServiceIsolate( settings.vm_service_port, // server VM service port tonic::DartState::HandleLibraryTag, // embedder library tag handler false, // disable websocket origin check - settings.disable_service_auth_codes, // disable VM service auth codes settings.enable_service_port_fallback, // enable fallback to port 0 // when bind fails. error // error (out) diff --git a/runtime/dart_service_isolate.cc b/runtime/dart_service_isolate.cc index 9f27e16d323b9..6b3c27540cb2c 100644 --- a/runtime/dart_service_isolate.cc +++ b/runtime/dart_service_isolate.cc @@ -130,7 +130,6 @@ bool DartServiceIsolate::Startup(const std::string& server_ip, intptr_t server_port, Dart_LibraryTagHandler embedder_tag_handler, bool disable_origin_check, - bool disable_service_auth_codes, bool enable_service_port_fallback, char** error) { Dart_Isolate isolate = Dart_CurrentIsolate(); @@ -182,10 +181,6 @@ bool DartServiceIsolate::Startup(const std::string& server_ip, Dart_SetField(library, Dart_NewStringFromCString("_originCheckDisabled"), Dart_NewBoolean(disable_origin_check)); SHUTDOWN_ON_ERROR(result); - result = - Dart_SetField(library, Dart_NewStringFromCString("_authCodesDisabled"), - Dart_NewBoolean(disable_service_auth_codes)); - SHUTDOWN_ON_ERROR(result); result = Dart_SetField( library, Dart_NewStringFromCString("_enableServicePortFallback"), Dart_NewBoolean(enable_service_port_fallback)); diff --git a/runtime/dart_service_isolate.h b/runtime/dart_service_isolate.h index 5078c28a78a83..f552ff6baa084 100644 --- a/runtime/dart_service_isolate.h +++ b/runtime/dart_service_isolate.h @@ -47,8 +47,6 @@ class DartServiceIsolate { /// @param[in] embedder_tag_handler The library tag handler. /// @param[in] disable_origin_check If websocket origin checks must /// be enabled. - /// @param[in] disable_service_auth_codes If service auth codes must be - /// enabled. /// @param[in] enable_service_port_fallback If fallback to port 0 must be /// enabled when the bind fails. /// @param error The error when this method @@ -63,7 +61,6 @@ class DartServiceIsolate { intptr_t server_port, Dart_LibraryTagHandler embedder_tag_handler, bool disable_origin_check, - bool disable_service_auth_codes, bool enable_service_port_fallback, char** error); diff --git a/runtime/dart_vm.cc b/runtime/dart_vm.cc index 9a61f6bb11fb1..fb1349214349a 100644 --- a/runtime/dart_vm.cc +++ b/runtime/dart_vm.cc @@ -90,10 +90,6 @@ static const char* kDartStartPausedArgs[]{ "--pause_isolates_on_start", }; -static const char* kDartDisableServiceAuthCodesArgs[]{ - "--disable-service-auth-codes", -}; - static const char* kDartEndlessTraceBufferArgs[]{ "--timeline_recorder=endless", }; @@ -380,11 +376,6 @@ DartVM::DartVM(const std::shared_ptr& vm_data, PushBackAll(&args, kDartStartPausedArgs, fml::size(kDartStartPausedArgs)); } - if (settings_.disable_service_auth_codes) { - PushBackAll(&args, kDartDisableServiceAuthCodesArgs, - fml::size(kDartDisableServiceAuthCodesArgs)); - } - if (settings_.endless_trace_buffer || settings_.trace_startup) { // If we are tracing startup, make sure the trace buffer is endless so we // don't lose early traces. diff --git a/shell/common/switches.cc b/shell/common/switches.cc index e0d4ae3d5826e..678b096b75333 100644 --- a/shell/common/switches.cc +++ b/shell/common/switches.cc @@ -293,11 +293,6 @@ Settings SettingsFromCommandLine(const fml::CommandLine& command_line) { command_line.GetOptionValue(FlagForSwitch(Switch::DomainNetworkPolicy), &settings.domain_network_policy); - // Disable need for authentication codes for VM service communication, if - // specified. - settings.disable_service_auth_codes = - command_line.HasOption(FlagForSwitch(Switch::DisableServiceAuthCodes)); - // Allow fallback to automatic port selection if binding to a specified port // fails. settings.enable_service_port_fallback = diff --git a/shell/common/switches.h b/shell/common/switches.h index c8a75f778664c..0d50b8df0401c 100644 --- a/shell/common/switches.h +++ b/shell/common/switches.h @@ -146,10 +146,6 @@ DEF_SWITCH(FlutterAssetsDir, "Path to the Flutter assets directory.") DEF_SWITCH(Help, "help", "Display this help text.") DEF_SWITCH(LogTag, "log-tag", "Tag associated with log messages.") -DEF_SWITCH(DisableServiceAuthCodes, - "disable-service-auth-codes", - "Disable the requirement for authentication codes for communicating" - " with the VM service.") DEF_SWITCH(EnableServicePortFallback, "enable-service-port-fallback", "Allow the VM service to fallback to automatic port selection if" diff --git a/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java b/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java index bcc54b1e9786f..21ef097e1f778 100644 --- a/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java +++ b/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java @@ -293,9 +293,6 @@ private static String[] getArgsFromIntent(Intent intent) { if (intent.getBooleanExtra("start-paused", false)) { args.add("--start-paused"); } - if (intent.getBooleanExtra("disable-service-auth-codes", false)) { - args.add("--disable-service-auth-codes"); - } if (intent.getBooleanExtra("use-test-fonts", false)) { args.add("--use-test-fonts"); } diff --git a/shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java b/shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java index e97eb66bfce05..1a34aad91b9f4 100644 --- a/shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java +++ b/shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java @@ -24,8 +24,6 @@ public class FlutterShellArgs { public static final String ARG_TRACE_STARTUP = "--trace-startup"; public static final String ARG_KEY_START_PAUSED = "start-paused"; public static final String ARG_START_PAUSED = "--start-paused"; - public static final String ARG_KEY_DISABLE_SERVICE_AUTH_CODES = "disable-service-auth-codes"; - public static final String ARG_DISABLE_SERVICE_AUTH_CODES = "--disable-service-auth-codes"; public static final String ARG_KEY_ENDLESS_TRACE_BUFFER = "endless-trace-buffer"; public static final String ARG_ENDLESS_TRACE_BUFFER = "--endless-trace-buffer"; public static final String ARG_KEY_USE_TEST_FONTS = "use-test-fonts"; @@ -92,9 +90,6 @@ public static FlutterShellArgs fromIntent(@NonNull Intent intent) { args.add(ARG_VM_SERVICE_PORT + Integer.toString(vmServicePort)); } } - if (intent.getBooleanExtra(ARG_KEY_DISABLE_SERVICE_AUTH_CODES, false)) { - args.add(ARG_DISABLE_SERVICE_AUTH_CODES); - } if (intent.getBooleanExtra(ARG_KEY_ENDLESS_TRACE_BUFFER, false)) { args.add(ARG_ENDLESS_TRACE_BUFFER); } diff --git a/shell/platform/fuchsia/dart_runner/service_isolate.cc b/shell/platform/fuchsia/dart_runner/service_isolate.cc index ea59ccec8fcc0..94699ae0f3163 100644 --- a/shell/platform/fuchsia/dart_runner/service_isolate.cc +++ b/shell/platform/fuchsia/dart_runner/service_isolate.cc @@ -186,12 +186,6 @@ Dart_Isolate CreateServiceIsolate( Dart_NewBoolean(false)); SHUTDOWN_ON_ERROR(result); - // _authCodesDisabled = false - result = - Dart_SetField(library, Dart_NewStringFromCString("_authCodesDisabled"), - Dart_NewBoolean(false)); - SHUTDOWN_ON_ERROR(result); - InitBuiltinLibrariesForIsolate(std::string(uri), nullptr, fileno(stdout), fileno(stderr), zx::channel(), true); diff --git a/shell/testing/observatory/launcher.dart b/shell/testing/observatory/launcher.dart index 0b4e91e3a5140..dac3f9db85e9e 100644 --- a/shell/testing/observatory/launcher.dart +++ b/shell/testing/observatory/launcher.dart @@ -48,7 +48,6 @@ class ShellLauncher { '--vm-service-port=0', '--non-interactive', '--run-forever', - '--disable-service-auth-codes', ]; final String shellExecutablePath; final String mainDartPath; From f0417dcf26cfa966074d2987cbf8ea3d4688f855 Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Fri, 1 Sep 2023 18:07:10 -0700 Subject: [PATCH 2/2] Revert most of the changes --- common/settings.h | 4 ++++ runtime/dart_isolate.cc | 1 + runtime/dart_service_isolate.cc | 5 +++++ runtime/dart_service_isolate.h | 3 +++ shell/common/switches.cc | 5 +++++ shell/common/switches.h | 4 ++++ .../android/io/flutter/app/FlutterActivityDelegate.java | 3 +++ .../io/flutter/embedding/engine/FlutterShellArgs.java | 5 +++++ shell/platform/fuchsia/dart_runner/service_isolate.cc | 6 ++++++ shell/testing/observatory/launcher.dart | 1 + 10 files changed, 37 insertions(+) diff --git a/common/settings.h b/common/settings.h index 69fdf1002cedb..d9df7e707b172 100644 --- a/common/settings.h +++ b/common/settings.h @@ -189,6 +189,10 @@ struct Settings { // target indicating the URL at which the VM service can be accessed. uint32_t vm_service_port = 0; + // Determines whether an authentication code is required to communicate with + // the VM service. + bool disable_service_auth_codes = true; + // Determine whether the vmservice should fallback to automatic port selection // after failing to bind to a specified port. bool enable_service_port_fallback = false; diff --git a/runtime/dart_isolate.cc b/runtime/dart_isolate.cc index d8ce6eb2f84e8..791ac03dbbf95 100644 --- a/runtime/dart_isolate.cc +++ b/runtime/dart_isolate.cc @@ -805,6 +805,7 @@ Dart_Isolate DartIsolate::DartCreateAndStartServiceIsolate( settings.vm_service_port, // server VM service port tonic::DartState::HandleLibraryTag, // embedder library tag handler false, // disable websocket origin check + settings.disable_service_auth_codes, // disable VM service auth codes settings.enable_service_port_fallback, // enable fallback to port 0 // when bind fails. error // error (out) diff --git a/runtime/dart_service_isolate.cc b/runtime/dart_service_isolate.cc index 6b3c27540cb2c..9f27e16d323b9 100644 --- a/runtime/dart_service_isolate.cc +++ b/runtime/dart_service_isolate.cc @@ -130,6 +130,7 @@ bool DartServiceIsolate::Startup(const std::string& server_ip, intptr_t server_port, Dart_LibraryTagHandler embedder_tag_handler, bool disable_origin_check, + bool disable_service_auth_codes, bool enable_service_port_fallback, char** error) { Dart_Isolate isolate = Dart_CurrentIsolate(); @@ -181,6 +182,10 @@ bool DartServiceIsolate::Startup(const std::string& server_ip, Dart_SetField(library, Dart_NewStringFromCString("_originCheckDisabled"), Dart_NewBoolean(disable_origin_check)); SHUTDOWN_ON_ERROR(result); + result = + Dart_SetField(library, Dart_NewStringFromCString("_authCodesDisabled"), + Dart_NewBoolean(disable_service_auth_codes)); + SHUTDOWN_ON_ERROR(result); result = Dart_SetField( library, Dart_NewStringFromCString("_enableServicePortFallback"), Dart_NewBoolean(enable_service_port_fallback)); diff --git a/runtime/dart_service_isolate.h b/runtime/dart_service_isolate.h index f552ff6baa084..5078c28a78a83 100644 --- a/runtime/dart_service_isolate.h +++ b/runtime/dart_service_isolate.h @@ -47,6 +47,8 @@ class DartServiceIsolate { /// @param[in] embedder_tag_handler The library tag handler. /// @param[in] disable_origin_check If websocket origin checks must /// be enabled. + /// @param[in] disable_service_auth_codes If service auth codes must be + /// enabled. /// @param[in] enable_service_port_fallback If fallback to port 0 must be /// enabled when the bind fails. /// @param error The error when this method @@ -61,6 +63,7 @@ class DartServiceIsolate { intptr_t server_port, Dart_LibraryTagHandler embedder_tag_handler, bool disable_origin_check, + bool disable_service_auth_codes, bool enable_service_port_fallback, char** error); diff --git a/shell/common/switches.cc b/shell/common/switches.cc index 678b096b75333..e0d4ae3d5826e 100644 --- a/shell/common/switches.cc +++ b/shell/common/switches.cc @@ -293,6 +293,11 @@ Settings SettingsFromCommandLine(const fml::CommandLine& command_line) { command_line.GetOptionValue(FlagForSwitch(Switch::DomainNetworkPolicy), &settings.domain_network_policy); + // Disable need for authentication codes for VM service communication, if + // specified. + settings.disable_service_auth_codes = + command_line.HasOption(FlagForSwitch(Switch::DisableServiceAuthCodes)); + // Allow fallback to automatic port selection if binding to a specified port // fails. settings.enable_service_port_fallback = diff --git a/shell/common/switches.h b/shell/common/switches.h index 0d50b8df0401c..c8a75f778664c 100644 --- a/shell/common/switches.h +++ b/shell/common/switches.h @@ -146,6 +146,10 @@ DEF_SWITCH(FlutterAssetsDir, "Path to the Flutter assets directory.") DEF_SWITCH(Help, "help", "Display this help text.") DEF_SWITCH(LogTag, "log-tag", "Tag associated with log messages.") +DEF_SWITCH(DisableServiceAuthCodes, + "disable-service-auth-codes", + "Disable the requirement for authentication codes for communicating" + " with the VM service.") DEF_SWITCH(EnableServicePortFallback, "enable-service-port-fallback", "Allow the VM service to fallback to automatic port selection if" diff --git a/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java b/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java index 21ef097e1f778..bcc54b1e9786f 100644 --- a/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java +++ b/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java @@ -293,6 +293,9 @@ private static String[] getArgsFromIntent(Intent intent) { if (intent.getBooleanExtra("start-paused", false)) { args.add("--start-paused"); } + if (intent.getBooleanExtra("disable-service-auth-codes", false)) { + args.add("--disable-service-auth-codes"); + } if (intent.getBooleanExtra("use-test-fonts", false)) { args.add("--use-test-fonts"); } diff --git a/shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java b/shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java index 1a34aad91b9f4..e97eb66bfce05 100644 --- a/shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java +++ b/shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java @@ -24,6 +24,8 @@ public class FlutterShellArgs { public static final String ARG_TRACE_STARTUP = "--trace-startup"; public static final String ARG_KEY_START_PAUSED = "start-paused"; public static final String ARG_START_PAUSED = "--start-paused"; + public static final String ARG_KEY_DISABLE_SERVICE_AUTH_CODES = "disable-service-auth-codes"; + public static final String ARG_DISABLE_SERVICE_AUTH_CODES = "--disable-service-auth-codes"; public static final String ARG_KEY_ENDLESS_TRACE_BUFFER = "endless-trace-buffer"; public static final String ARG_ENDLESS_TRACE_BUFFER = "--endless-trace-buffer"; public static final String ARG_KEY_USE_TEST_FONTS = "use-test-fonts"; @@ -90,6 +92,9 @@ public static FlutterShellArgs fromIntent(@NonNull Intent intent) { args.add(ARG_VM_SERVICE_PORT + Integer.toString(vmServicePort)); } } + if (intent.getBooleanExtra(ARG_KEY_DISABLE_SERVICE_AUTH_CODES, false)) { + args.add(ARG_DISABLE_SERVICE_AUTH_CODES); + } if (intent.getBooleanExtra(ARG_KEY_ENDLESS_TRACE_BUFFER, false)) { args.add(ARG_ENDLESS_TRACE_BUFFER); } diff --git a/shell/platform/fuchsia/dart_runner/service_isolate.cc b/shell/platform/fuchsia/dart_runner/service_isolate.cc index 94699ae0f3163..ea59ccec8fcc0 100644 --- a/shell/platform/fuchsia/dart_runner/service_isolate.cc +++ b/shell/platform/fuchsia/dart_runner/service_isolate.cc @@ -186,6 +186,12 @@ Dart_Isolate CreateServiceIsolate( Dart_NewBoolean(false)); SHUTDOWN_ON_ERROR(result); + // _authCodesDisabled = false + result = + Dart_SetField(library, Dart_NewStringFromCString("_authCodesDisabled"), + Dart_NewBoolean(false)); + SHUTDOWN_ON_ERROR(result); + InitBuiltinLibrariesForIsolate(std::string(uri), nullptr, fileno(stdout), fileno(stderr), zx::channel(), true); diff --git a/shell/testing/observatory/launcher.dart b/shell/testing/observatory/launcher.dart index dac3f9db85e9e..0b4e91e3a5140 100644 --- a/shell/testing/observatory/launcher.dart +++ b/shell/testing/observatory/launcher.dart @@ -48,6 +48,7 @@ class ShellLauncher { '--vm-service-port=0', '--non-interactive', '--run-forever', + '--disable-service-auth-codes', ]; final String shellExecutablePath; final String mainDartPath;