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

Side by Side Diff: sandbox/win/src/sid.cc

Issue 937353002: Adding method to create process using LowBox token in sandbox code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed indent. Created 5 years, 10 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/sid.h" 5 #include "sandbox/win/src/sid.h"
6 6
7 #include <objbase.h>
8 #include <sddl.h>
9
7 #include "base/logging.h" 10 #include "base/logging.h"
8 11
9 namespace sandbox { 12 namespace sandbox {
10 13
11 Sid::Sid(const SID *sid) { 14 Sid::Sid(const SID *sid)
15 : unique_sub_auth_sid_(NULL) {
forshaw 2015/02/23 13:32:29 unique_sub_auth_sid_ never actually used.
Shrikant Kelkar 2015/02/23 17:54:01 Done.
12 ::CopySid(SECURITY_MAX_SID_SIZE, sid_, const_cast<SID*>(sid)); 16 ::CopySid(SECURITY_MAX_SID_SIZE, sid_, const_cast<SID*>(sid));
forshaw 2015/02/23 13:32:29 nit: Obviously the original code didn't check the
Shrikant Kelkar 2015/02/23 17:54:01 Done.
13 }; 17 };
14 18
15 Sid::Sid(WELL_KNOWN_SID_TYPE type) { 19 Sid::Sid(WELL_KNOWN_SID_TYPE type)
20 : unique_sub_auth_sid_(NULL) {
16 DWORD size_sid = SECURITY_MAX_SID_SIZE; 21 DWORD size_sid = SECURITY_MAX_SID_SIZE;
17 BOOL result = ::CreateWellKnownSid(type, NULL, sid_, &size_sid); 22 BOOL result = ::CreateWellKnownSid(type, NULL, sid_, &size_sid);
18 DCHECK(result); 23 DCHECK(result);
19 DBG_UNREFERENCED_LOCAL_VARIABLE(result); 24 DBG_UNREFERENCED_LOCAL_VARIABLE(result);
20 } 25 }
21 26
22 const SID *Sid::GetPSID() const { 27 const SID *Sid::GetPSID() const {
23 return reinterpret_cast<SID*>(const_cast<BYTE*>(sid_)); 28 return reinterpret_cast<SID*>(const_cast<BYTE*>(sid_));
24 } 29 }
25 30
31 void Sid::GenerateUniqueSubAuthoritySid(std::wstring* unique_sid) {
forshaw 2015/02/23 13:32:29 nit: Would it not make more sense to return the ws
Shrikant Kelkar 2015/02/23 17:54:01 Done.
32 SID_IDENTIFIER_AUTHORITY authority = SECURITY_APP_PACKAGE_AUTHORITY;
33 GUID guid = { 0 };
34 ::CoCreateGuid(&guid);
forshaw 2015/02/23 13:32:29 Not sure I like creating random SIDs too much, the
Shrikant Kelkar 2015/02/23 17:54:01 Yes, I see your point, will discuss with other rev
35 unsigned long* guid_long = reinterpret_cast<unsigned long*>(&guid);
36 PSID sid = NULL;
37 DWORD sub_auth = *GetSidSubAuthority(reinterpret_cast<SID*>(sid_), 0);
38 ::AllocateAndInitializeSid(&authority,
39 8,
40 sub_auth,
41 guid_long[0],
42 guid_long[1],
43 guid_long[2],
44 guid_long[3],
45 1,
46 1,
47 1,
48 &sid);
49 LPWSTR sid_string = NULL;
50 ::ConvertSidToStringSid(sid, &sid_string);
51 *unique_sid = sid_string;
52 ::FreeSid(sid);
53 ::LocalFree(sid_string);
54 }
55
26 } // namespace sandbox 56 } // namespace sandbox
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698