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

Unified Diff: sandbox/win/src/restricted_token_utils.cc

Issue 1240793004: Revert of Sandbox: Make CreateRestrictedToken return a ScopedHandle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sandbox/win/src/restricted_token_utils.h ('k') | sandbox/win/src/sandbox_policy_base.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/win/src/restricted_token_utils.cc
diff --git a/sandbox/win/src/restricted_token_utils.cc b/sandbox/win/src/restricted_token_utils.cc
index 5f9719210341a0ab2f5c7a7fd71577aadbf802ab..17452362da16dd1e26b7bfe507b36cab1c393f54 100644
--- a/sandbox/win/src/restricted_token_utils.cc
+++ b/sandbox/win/src/restricted_token_utils.cc
@@ -19,10 +19,13 @@
namespace sandbox {
-DWORD CreateRestrictedToken(TokenLevel security_level,
+DWORD CreateRestrictedToken(HANDLE *token_handle,
+ TokenLevel security_level,
IntegrityLevel integrity_level,
- TokenType token_type,
- base::win::ScopedHandle* token) {
+ TokenType token_type) {
+ if (!token_handle)
+ return ERROR_BAD_ARGUMENTS;
+
RestrictedToken restricted_token;
restricted_token.Init(NULL); // Initialized with the current process token
@@ -120,11 +123,12 @@
switch (token_type) {
case PRIMARY: {
- err_code = restricted_token.GetRestrictedToken(token);
+ err_code = restricted_token.GetRestrictedTokenHandle(token_handle);
break;
}
case IMPERSONATION: {
- err_code = restricted_token.GetRestrictedTokenForImpersonation(token);
+ err_code = restricted_token.GetRestrictedTokenHandleForImpersonation(
+ token_handle);
break;
}
default: {
@@ -155,20 +159,27 @@
}
// Create the primary (restricted) token for the process
- base::win::ScopedHandle primary_token;
- err_code = CreateRestrictedToken(primary_level, INTEGRITY_LEVEL_LAST,
- PRIMARY, &primary_token);
- if (ERROR_SUCCESS != err_code)
+ HANDLE primary_token_handle = NULL;
+ err_code = CreateRestrictedToken(&primary_token_handle,
+ primary_level,
+ INTEGRITY_LEVEL_LAST,
+ PRIMARY);
+ if (ERROR_SUCCESS != err_code) {
return err_code;
-
+ }
+ base::win::ScopedHandle primary_token(primary_token_handle);
// Create the impersonation token (restricted) to be able to start the
// process.
- base::win::ScopedHandle impersonation_token;
- err_code = CreateRestrictedToken(impersonation_level, INTEGRITY_LEVEL_LAST,
- IMPERSONATION, &impersonation_token);
- if (ERROR_SUCCESS != err_code)
+ HANDLE impersonation_token_handle;
+ err_code = CreateRestrictedToken(&impersonation_token_handle,
+ impersonation_level,
+ INTEGRITY_LEVEL_LAST,
+ IMPERSONATION);
+ if (ERROR_SUCCESS != err_code) {
return err_code;
+ }
+ base::win::ScopedHandle impersonation_token(impersonation_token_handle);
// Start the process
STARTUPINFO startup_info = {0};
« no previous file with comments | « sandbox/win/src/restricted_token_utils.h ('k') | sandbox/win/src/sandbox_policy_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698