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

Side by Side Diff: tools/exception_port_tool.cc

Issue 727053002: Add DropPrivileges() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Rebase Created 6 years, 1 month 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 | « no previous file | util/posix/drop_privileges.h » ('j') | util/posix/drop_privileges.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 16 matching lines...) Expand all
27 27
28 #include "base/basictypes.h" 28 #include "base/basictypes.h"
29 #include "base/mac/mach_logging.h" 29 #include "base/mac/mach_logging.h"
30 #include "base/mac/scoped_mach_port.h" 30 #include "base/mac/scoped_mach_port.h"
31 #include "base/strings/stringprintf.h" 31 #include "base/strings/stringprintf.h"
32 #include "tools/tool_support.h" 32 #include "tools/tool_support.h"
33 #include "util/mach/exception_ports.h" 33 #include "util/mach/exception_ports.h"
34 #include "util/mach/mach_extensions.h" 34 #include "util/mach/mach_extensions.h"
35 #include "util/mach/symbolic_constants_mach.h" 35 #include "util/mach/symbolic_constants_mach.h"
36 #include "util/mach/task_for_pid.h" 36 #include "util/mach/task_for_pid.h"
37 #include "util/posix/drop_privileges.h"
37 #include "util/stdlib/string_number_conversion.h" 38 #include "util/stdlib/string_number_conversion.h"
38 39
39 namespace crashpad { 40 namespace crashpad {
40 namespace { 41 namespace {
41 42
42 //! \brief Manages a pool of Mach send rights, deallocating all send rights upon 43 //! \brief Manages a pool of Mach send rights, deallocating all send rights upon
43 //! destruction. 44 //! destruction.
44 //! 45 //!
45 //! This class effectively implements what a vector of 46 //! This class effectively implements what a vector of
46 //! base::mac::ScopedMachSendRight objects would be. 47 //! base::mac::ScopedMachSendRight objects would be.
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 return kExitFailure; 497 return kExitFailure;
497 } 498 }
498 499
499 options.alternate_task = TaskForPID(options.pid); 500 options.alternate_task = TaskForPID(options.pid);
500 if (options.alternate_task == TASK_NULL) { 501 if (options.alternate_task == TASK_NULL) {
501 return kExitFailure; 502 return kExitFailure;
502 } 503 }
503 alternate_task_owner.reset(options.alternate_task); 504 alternate_task_owner.reset(options.alternate_task);
504 } 505 }
505 506
507 // This tool may have been installed as a setuid binary so that TaskForPID()
508 // could succeed. Drop any privileges now that they’re no longer necessary.
509 DropPrivileges();
510
506 MachSendRightPool mach_send_right_pool; 511 MachSendRightPool mach_send_right_pool;
507 512
508 // Show bootstrap services requested. 513 // Show bootstrap services requested.
509 for (const char* service : options.show_bootstrap) { 514 for (const char* service : options.show_bootstrap) {
510 ShowBootstrapService(service, &mach_send_right_pool); 515 ShowBootstrapService(service, &mach_send_right_pool);
511 } 516 }
512 517
513 // Show the original exception ports. 518 // Show the original exception ports.
514 if (options.show_host) { 519 if (options.show_host) {
515 ShowExceptionPorts( 520 ShowExceptionPorts(
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 585
581 return kExitSuccess; 586 return kExitSuccess;
582 } 587 }
583 588
584 } // namespace 589 } // namespace
585 } // namespace crashpad 590 } // namespace crashpad
586 591
587 int main(int argc, char* argv[]) { 592 int main(int argc, char* argv[]) {
588 return crashpad::ExceptionPortToolMain(argc, argv); 593 return crashpad::ExceptionPortToolMain(argc, argv);
589 } 594 }
OLDNEW
« no previous file with comments | « no previous file | util/posix/drop_privileges.h » ('j') | util/posix/drop_privileges.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698