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

Side by Side Diff: services/shell/service_manager.cc

Issue 2338793003: services/shell: Turn on sandboxing for mojo apps.
Patch Set: . Created 4 years, 3 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 | « components/leveldb/manifest.json ('k') | services/ui/manifest.json » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "services/shell/service_manager.h" 5 #include "services/shell/service_manager.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 21 matching lines...) Expand all
32 32
33 namespace { 33 namespace {
34 34
35 const char kCatalogName[] = "mojo:catalog"; 35 const char kCatalogName[] = "mojo:catalog";
36 const char kServiceManagerName[] = "mojo:shell"; 36 const char kServiceManagerName[] = "mojo:shell";
37 const char kCapabilityClass_UserID[] = "shell:user_id"; 37 const char kCapabilityClass_UserID[] = "shell:user_id";
38 const char kCapabilityClass_ClientProcess[] = "shell:client_process"; 38 const char kCapabilityClass_ClientProcess[] = "shell:client_process";
39 const char kCapabilityClass_InstanceName[] = "shell:instance_name"; 39 const char kCapabilityClass_InstanceName[] = "shell:instance_name";
40 const char kCapabilityClass_AllUsers[] = "shell:all_users"; 40 const char kCapabilityClass_AllUsers[] = "shell:all_users";
41 const char kCapabilityClass_ExplicitClass[] = "shell:explicit_class"; 41 const char kCapabilityClass_ExplicitClass[] = "shell:explicit_class";
42 const char kCapabilityClass_Unsandboxed[] = "shell:unsandboxed";
42 43
43 } // namespace 44 } // namespace
44 45
45 Identity CreateServiceManagerIdentity() { 46 Identity CreateServiceManagerIdentity() {
46 return Identity(kServiceManagerName, mojom::kRootUserID); 47 return Identity(kServiceManagerName, mojom::kRootUserID);
47 } 48 }
48 49
49 Identity CreateCatalogIdentity() { 50 Identity CreateCatalogIdentity() {
50 return Identity(kCatalogName, mojom::kRootUserID); 51 return Identity(kCatalogName, mojom::kRootUserID);
51 } 52 }
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 void StartWithClientProcessConnection( 210 void StartWithClientProcessConnection(
210 mojom::ClientProcessConnectionPtr client_process_connection) { 211 mojom::ClientProcessConnectionPtr client_process_connection) {
211 mojom::ServicePtr service; 212 mojom::ServicePtr service;
212 service.Bind(mojom::ServicePtrInfo( 213 service.Bind(mojom::ServicePtrInfo(
213 std::move(client_process_connection->service), 0)); 214 std::move(client_process_connection->service), 0));
214 pid_receiver_binding_.Bind( 215 pid_receiver_binding_.Bind(
215 std::move(client_process_connection->pid_receiver_request)); 216 std::move(client_process_connection->pid_receiver_request));
216 StartWithService(std::move(service)); 217 StartWithService(std::move(service));
217 } 218 }
218 219
219 void StartWithFilePath(const base::FilePath& path) { 220 void StartWithFilePath(const base::FilePath& path, bool unsandboxed) {
220 CHECK(!service_); 221 CHECK(!service_);
221 runner_ = service_manager_->native_runner_factory_->Create(path); 222 runner_ = service_manager_->native_runner_factory_->Create(path);
222 bool start_sandboxed = false; 223 bool start_sandboxed = !unsandboxed;
223 mojom::ServicePtr service = runner_->Start( 224 mojom::ServicePtr service = runner_->Start(
224 path, identity_, start_sandboxed, 225 path, identity_, start_sandboxed,
225 base::Bind(&Instance::PIDAvailable, weak_factory_.GetWeakPtr()), 226 base::Bind(&Instance::PIDAvailable, weak_factory_.GetWeakPtr()),
226 base::Bind(&Instance::OnRunnerCompleted, weak_factory_.GetWeakPtr())); 227 base::Bind(&Instance::OnRunnerCompleted, weak_factory_.GetWeakPtr()));
227 StartWithService(std::move(service)); 228 StartWithService(std::move(service));
228 } 229 }
229 230
230 mojom::ServiceInfoPtr CreateServiceInfo() const { 231 mojom::ServiceInfoPtr CreateServiceInfo() const {
231 mojom::ServiceInfoPtr info(mojom::ServiceInfo::New()); 232 mojom::ServiceInfoPtr info(mojom::ServiceInfo::New());
232 info->id = id_; 233 info->id = id_;
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 // Otherwise we create a new Service pipe. 815 // Otherwise we create a new Service pipe.
815 mojom::ServiceRequest request = GetProxy(&service); 816 mojom::ServiceRequest request = GetProxy(&service);
816 CHECK(!result->package_path.empty() && result->capabilities.has_value()); 817 CHECK(!result->package_path.empty() && result->capabilities.has_value());
817 818
818 if (target.name() != result->resolved_name) { 819 if (target.name() != result->resolved_name) {
819 instance->StartWithService(std::move(service)); 820 instance->StartWithService(std::move(service));
820 Identity factory(result->resolved_name, target.user_id(), 821 Identity factory(result->resolved_name, target.user_id(),
821 instance_name); 822 instance_name);
822 CreateServiceWithFactory(factory, target.name(), std::move(request)); 823 CreateServiceWithFactory(factory, target.name(), std::move(request));
823 } else { 824 } else {
824 instance->StartWithFilePath(result->package_path); 825 bool unsandboxed = HasClass(capabilities, kCapabilityClass_Unsandboxed);
826 instance->StartWithFilePath(result->package_path, unsandboxed);
825 } 827 }
826 } 828 }
827 829
828 // Now that the instance has a Service, we can connect to it. 830 // Now that the instance has a Service, we can connect to it.
829 bool connected = instance->ConnectToService(&params); 831 bool connected = instance->ConnectToService(&params);
830 DCHECK(connected); 832 DCHECK(connected);
831 } 833 }
832 834
833 base::WeakPtr<ServiceManager> ServiceManager::GetWeakPtr() { 835 base::WeakPtr<ServiceManager> ServiceManager::GetWeakPtr() {
834 return weak_ptr_factory_.GetWeakPtr(); 836 return weak_ptr_factory_.GetWeakPtr();
835 } 837 }
836 838
837 } // namespace shell 839 } // namespace shell
OLDNEW
« no previous file with comments | « components/leveldb/manifest.json ('k') | services/ui/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698