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

Unified 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: Addressing comments on earlier patch. 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 side-by-side diff with in-line comments
Download patch
Index: sandbox/win/src/sid.cc
diff --git a/sandbox/win/src/sid.cc b/sandbox/win/src/sid.cc
index 261605d547b99cf303913e72943125f71991dee6..279074e61305cbca2dd0f283bf4aa80347c7cfee 100644
--- a/sandbox/win/src/sid.cc
+++ b/sandbox/win/src/sid.cc
@@ -4,12 +4,16 @@
#include "sandbox/win/src/sid.h"
+#include <objbase.h>
rvargas (doing something else) 2015/02/24 01:01:49 ?
+#include <sddl.h>
+
#include "base/logging.h"
namespace sandbox {
Sid::Sid(const SID *sid) {
- ::CopySid(SECURITY_MAX_SID_SIZE, sid_, const_cast<SID*>(sid));
+ BOOL result = ::CopySid(SECURITY_MAX_SID_SIZE, sid_, const_cast<SID*>(sid));
+ DCHECK(result);
};
Sid::Sid(WELL_KNOWN_SID_TYPE type) {
@@ -23,4 +27,30 @@ const SID *Sid::GetPSID() const {
return reinterpret_cast<SID*>(const_cast<BYTE*>(sid_));
}
+std::wstring Sid::GenerateUniqueSubAuthoritySid() {
rvargas (doing something else) 2015/02/24 01:01:49 I don't think this code belongs here
+ SID_IDENTIFIER_AUTHORITY authority = SECURITY_APP_PACKAGE_AUTHORITY;
+ GUID guid = { 0 };
+ ::CoCreateGuid(&guid);
+ unsigned long* guid_long = reinterpret_cast<unsigned long*>(&guid);
+ PSID sid = NULL;
+ DWORD sub_auth = *GetSidSubAuthority(reinterpret_cast<SID*>(sid_), 0);
+ ::AllocateAndInitializeSid(&authority,
+ 8,
+ sub_auth,
+ guid_long[0],
+ guid_long[1],
+ guid_long[2],
+ guid_long[3],
+ 1,
+ 1,
+ 1,
+ &sid);
+ LPWSTR sid_string = NULL;
+ ::ConvertSidToStringSid(sid, &sid_string);
+ std::wstring unique_sid = sid_string;
+ ::FreeSid(sid);
+ ::LocalFree(sid_string);
+ return unique_sid;
+}
+
} // namespace sandbox

Powered by Google App Engine
This is Rietveld 408576698