Commit bed2a3f6 authored by Oksana Zhuravlova's avatar Oksana Zhuravlova Committed by Commit Bot

Convert "instance_name" to "can_connect_to_other_services_with_any_instance_name"

This change updates the service_manager::Instance code to reference its
options_.can_connect_to_other_services_with_any_instance_name value
instead of "service_manager:instance_name" in the "required" section
of its interface provider specs.
Tests and existing manifests were updated accordingly.

Bug: 866967
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: I7811919f86470cb098d588710e9aa3f2dd497e32
Reviewed-on: https://chromium-review.googlesource.com/1208710Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@chromium.org>
Commit-Queue: Oksana Zhuravlova <oksamyt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589428}
parent 3e67ba41
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
"name": "chrome", "name": "chrome",
"display_name": "Chrome", "display_name": "Chrome",
"options" : { "options" : {
"instance_sharing" : "shared_instance_across_users" "instance_sharing": "shared_instance_across_users",
"can_connect_to_other_services_with_any_instance_name": true
}, },
"interface_provider_specs": { "interface_provider_specs": {
"service_manager:connector": { "service_manager:connector": {
...@@ -24,8 +25,7 @@ ...@@ -24,8 +25,7 @@
"requires": { "requires": {
"chrome_renderer": [ "browser" ], "chrome_renderer": [ "browser" ],
"service_manager": [ "service_manager": [
"service_manager:client_process", "service_manager:client_process"
"service_manager:instance_name"
] ]
} }
} }
......
{ {
"name": "content_browser", "name": "content_browser",
"display_name": "Content (browser process)", "display_name": "Content (browser process)",
"options": { "can_connect_to_other_services_as_any_user": true }, "options": {
"can_connect_to_other_services_as_any_user": true,
"can_connect_to_other_services_with_any_instance_name": true
},
"interface_provider_specs": { "interface_provider_specs": {
"service_manager:connector": { "service_manager:connector": {
"provides": { "provides": {
...@@ -126,7 +129,6 @@ ...@@ -126,7 +129,6 @@
], ],
"service_manager": [ "service_manager": [
"service_manager:client_process", "service_manager:client_process",
"service_manager:instance_name",
"service_manager:service_manager" "service_manager:service_manager"
], ],
"shape_detection": [ "shape_detection": [
......
{ {
"name": "web_browser", "name": "web_browser",
"display_name": "Web", "display_name": "Web",
"options": { "can_connect_to_other_services_as_any_user": true }, "options": {
"can_connect_to_other_services_as_any_user": true,
"can_connect_to_other_services_with_any_instance_name": true
},
"interface_provider_specs": { "interface_provider_specs": {
"service_manager:connector": { "service_manager:connector": {
"provides": { "provides": {
...@@ -13,7 +16,6 @@ ...@@ -13,7 +16,6 @@
"*": [ "app" ], "*": [ "app" ],
"service_manager": [ "service_manager": [
"service_manager:client_process", "service_manager:client_process",
"service_manager:instance_name",
"service_manager:service_manager" "service_manager:service_manager"
] ]
} }
......
...@@ -189,10 +189,12 @@ std::unique_ptr<Entry> Entry::Deserialize(const base::Value& manifest_root) { ...@@ -189,10 +189,12 @@ std::unique_ptr<Entry> Entry::Deserialize(const base::Value& manifest_root) {
options_struct.can_connect_to_other_services_as_any_user = options_struct.can_connect_to_other_services_as_any_user =
can_connect_to_other_services_as_any_user_value->GetBool(); can_connect_to_other_services_as_any_user_value->GetBool();
if (const base::Value* allow_other_instance_names_value = if (const base::Value*
options->FindKey("allow_other_instance_names")) can_connect_to_other_services_with_any_instance_name_value =
options_struct.allow_other_instance_names = options->FindKey(
allow_other_instance_names_value->GetBool(); "can_connect_to_other_services_with_any_instance_name"))
options_struct.can_connect_to_other_services_with_any_instance_name =
can_connect_to_other_services_with_any_instance_name_value->GetBool();
if (const base::Value* instance_for_client_process_value = if (const base::Value* instance_for_client_process_value =
options->FindKey("instance_for_client_process")) options->FindKey("instance_for_client_process"))
......
...@@ -76,7 +76,8 @@ TEST_F(EntryTest, Options) { ...@@ -76,7 +76,8 @@ TEST_F(EntryTest, Options) {
EXPECT_EQ(ServiceOptions::InstanceSharingType::SINGLETON, EXPECT_EQ(ServiceOptions::InstanceSharingType::SINGLETON,
entry->options().instance_sharing); entry->options().instance_sharing);
EXPECT_TRUE(entry->options().can_connect_to_other_services_as_any_user); EXPECT_TRUE(entry->options().can_connect_to_other_services_as_any_user);
EXPECT_TRUE(entry->options().allow_other_instance_names); EXPECT_TRUE(
entry->options().can_connect_to_other_services_with_any_instance_name);
EXPECT_TRUE(entry->options().instance_for_client_process); EXPECT_TRUE(entry->options().instance_for_client_process);
EXPECT_EQ("", entry->sandbox_type()); EXPECT_EQ("", entry->sandbox_type());
......
...@@ -16,7 +16,7 @@ struct ServiceOptions { ...@@ -16,7 +16,7 @@ struct ServiceOptions {
InstanceSharingType instance_sharing = InstanceSharingType::NONE; InstanceSharingType instance_sharing = InstanceSharingType::NONE;
bool can_connect_to_other_services_as_any_user = false; bool can_connect_to_other_services_as_any_user = false;
bool allow_other_instance_names = false; bool can_connect_to_other_services_with_any_instance_name = false;
bool instance_for_client_process = false; bool instance_for_client_process = false;
}; };
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"options": { "options": {
"instance_sharing": "singleton", "instance_sharing": "singleton",
"can_connect_to_other_services_as_any_user": true, "can_connect_to_other_services_as_any_user": true,
"allow_other_instance_names": true, "can_connect_to_other_services_with_any_instance_name": true,
"instance_for_client_process": true "instance_for_client_process": true
}, },
"interface_provider_specs": { } "interface_provider_specs": { }
......
...@@ -13,9 +13,6 @@ ...@@ -13,9 +13,6 @@
// Clients requesting this class are allowed to register clients for // Clients requesting this class are allowed to register clients for
// processes they launch themselves. // processes they launch themselves.
"service_manager:client_process": [ ], "service_manager:client_process": [ ],
// Clients requesting this class are allowed to connect to other clients
// in specific process instance groups.
"service_manager:instance_name": [ ],
"service_manager:block_wildcard": [ ], "service_manager:block_wildcard": [ ],
"service_manager:service_manager": [ "service_manager:service_manager": [
......
...@@ -48,7 +48,6 @@ namespace service_manager { ...@@ -48,7 +48,6 @@ namespace service_manager {
namespace { namespace {
const char kCapability_ClientProcess[] = "service_manager:client_process"; const char kCapability_ClientProcess[] = "service_manager:client_process";
const char kCapability_InstanceName[] = "service_manager:instance_name";
const char kCapability_ServiceManager[] = "service_manager:service_manager"; const char kCapability_ServiceManager[] = "service_manager:service_manager";
bool Succeeded(mojom::ConnectResult result) { bool Succeeded(mojom::ConnectResult result) {
...@@ -621,17 +620,16 @@ class ServiceManager::Instance ...@@ -621,17 +620,16 @@ class ServiceManager::Instance
<< " running as: " << identity_.user_id() << " running as: " << identity_.user_id()
<< " attempting to connect to: " << target.name() << " attempting to connect to: " << target.name()
<< " as: " << target.user_id() << " without " << " as: " << target.user_id() << " without "
<< " the service:service_manager{user_id} capability."; << " the 'can_connect_to_other_services_as_any_user' option.";
return mojom::ConnectResult::ACCESS_DENIED; return mojom::ConnectResult::ACCESS_DENIED;
} }
if (!target.instance().empty() && if (!target.instance().empty() && target.instance() != target.name() &&
target.instance() != target.name() && !options_.can_connect_to_other_services_with_any_instance_name) {
!HasCapability(connection_spec, kCapability_InstanceName)) { LOG(ERROR)
LOG(ERROR) << "Instance: " << identity_.name() << " attempting to " << "Instance: " << identity_.name() << " attempting to "
<< "connect to " << target.name() << "connect to " << target.name()
<< " using Instance name: " << target.instance() << " using Instance name: " << target.instance() << " without the "
<< " without the " << " 'can_connect_to_other_services_with_any_instance_name' option.";
<< "service_manager{instance_name} capability.";
return mojom::ConnectResult::ACCESS_DENIED; return mojom::ConnectResult::ACCESS_DENIED;
} }
......
{ {
"name": "connect_unittests", "name": "connect_unittests",
"display_name": "Connect Unittests", "display_name": "Connect Unittests",
"options": { "can_connect_to_other_services_as_any_user": true }, "options": {
"can_connect_to_other_services_as_any_user": true,
"can_connect_to_other_services_with_any_instance_name": true
},
"interface_provider_specs": { "interface_provider_specs": {
"service_manager:connector": { "service_manager:connector": {
"provides": { "provides": {
...@@ -26,10 +29,7 @@ ...@@ -26,10 +29,7 @@
"connect_unittests:standalone_app", "connect_unittests:standalone_app",
"connect_unittests:user_id_test" "connect_unittests:user_id_test"
], ],
"connect_test_singleton_app": [], "connect_test_singleton_app": []
"service_manager": [
"service_manager:instance_name"
]
} }
} }
} }
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
"lifecycle_unittest_parent": [ "lifecycle_unittest:parent" ], "lifecycle_unittest_parent": [ "lifecycle_unittest:parent" ],
"service_manager": [ "service_manager": [
"service_manager:service_manager", "service_manager:service_manager",
"service_manager:instance_name",
"service_manager:client_process" "service_manager:client_process"
] ]
} }
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
"name": "service_manager_unittest", "name": "service_manager_unittest",
"display_name": "Service Manager Unittest", "display_name": "Service Manager Unittest",
"options": { "options": {
"instance_sharing" : "singleton" "instance_sharing": "singleton",
"can_connect_to_other_services_with_any_instance_name": true
}, },
"interface_provider_specs": { "interface_provider_specs": {
"service_manager:connector": { "service_manager:connector": {
...@@ -14,8 +15,7 @@ ...@@ -14,8 +15,7 @@
"requires": { "requires": {
"service_manager": [ "service_manager": [
"service_manager:service_manager", "service_manager:service_manager",
"service_manager:client_process", "service_manager:client_process"
"service_manager:instance_name"
], ],
"service_manager_unittest_embedder": [ "service_manager_unittest_embedder": [
"service_manager_unittest:embedder" "service_manager_unittest:embedder"
......
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