OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "sandbox/win/src/restricted_token.h" | 5 #include "sandbox/win/src/restricted_token.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "sandbox/win/src/acl.h" | 10 #include "sandbox/win/src/acl.h" |
11 #include "sandbox/win/src/win_utils.h" | 11 #include "sandbox/win/src/win_utils.h" |
12 | 12 |
| 13 namespace sandbox { |
13 | 14 |
14 namespace sandbox { | 15 RestrictedToken::RestrictedToken() |
| 16 : init_(false), |
| 17 effective_token_(NULL), |
| 18 integrity_level_(INTEGRITY_LEVEL_LAST) { |
| 19 } |
| 20 |
| 21 RestrictedToken::~RestrictedToken() { |
| 22 if (effective_token_) |
| 23 CloseHandle(effective_token_); |
| 24 } |
15 | 25 |
16 unsigned RestrictedToken::Init(const HANDLE effective_token) { | 26 unsigned RestrictedToken::Init(const HANDLE effective_token) { |
17 if (init_) | 27 if (init_) |
18 return ERROR_ALREADY_INITIALIZED; | 28 return ERROR_ALREADY_INITIALIZED; |
19 | 29 |
20 if (effective_token) { | 30 if (effective_token) { |
21 // We duplicate the handle to be able to use it even if the original handle | 31 // We duplicate the handle to be able to use it even if the original handle |
22 // is closed. | 32 // is closed. |
23 HANDLE effective_token_dup; | 33 HANDLE effective_token_dup; |
24 if (::DuplicateHandle(::GetCurrentProcess(), | 34 if (::DuplicateHandle(::GetCurrentProcess(), |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 | 472 |
463 return ERROR_SUCCESS; | 473 return ERROR_SUCCESS; |
464 } | 474 } |
465 | 475 |
466 unsigned RestrictedToken::SetIntegrityLevel(IntegrityLevel integrity_level) { | 476 unsigned RestrictedToken::SetIntegrityLevel(IntegrityLevel integrity_level) { |
467 integrity_level_ = integrity_level; | 477 integrity_level_ = integrity_level; |
468 return ERROR_SUCCESS; | 478 return ERROR_SUCCESS; |
469 } | 479 } |
470 | 480 |
471 } // namespace sandbox | 481 } // namespace sandbox |
OLD | NEW |