You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/05/02 17:56:14 UTC
svn commit: r770967 - in /commons/sandbox/runtime/trunk/src/main/native:
include/arch/windows/acr_arch_private.h os/win32/platform.c os/win32/wusec.c
Author: mturk
Date: Sat May 2 15:56:14 2009
New Revision: 770967
URL: http://svn.apache.org/viewvc?rev=770967&view=rev
Log:
Abstract common code to a separate function
Modified:
commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h
commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/wusec.c
Modified: commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h?rev=770967&r1=770966&r2=770967&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h Sat May 2 15:56:14 2009
@@ -68,6 +68,7 @@
LPVOID ACR_GetTokenInformation(JNIEnv *_E, HANDLE h, TOKEN_INFORMATION_CLASS ic);
void ACR_GetUserHomePath(LPWSTR buf, DWORD blen, PSID sid);
HANDLE ACR_GetCurrentAccessToken(JNIEnv *_E);
+PSID ACR_AllocateWellKnownSid(JNIEnv *_E, WELL_KNOWN_SID_TYPE type);
/**
* Heap allocation from main.c
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c?rev=770967&r1=770966&r2=770967&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c Sat May 2 15:56:14 2009
@@ -47,28 +47,10 @@
(*_E)->SetIntArrayRegion(_E, p, 0, 8, &ia[0]);
if (!acr_everyone_sid) {
- /* Create a well known SID for Everyone group. */
- DWORD ss = SECURITY_MAX_SID_SIZE;
- PSID sid = ACR_HeapMalloc(ss);
- if (sid) {
- if (!CreateWellKnownSid(WinWorldSid,
- NULL, sid, &ss))
- ACR_HeapFree(sid);
- else
- acr_everyone_sid = sid;
- }
+ acr_everyone_sid = ACR_AllocateWellKnownSid(_E, WinWorldSid);
}
if (!acr_adminsgr_sid) {
- /* Create a well known SID for BUILTIN\Administrators group. */
- DWORD ss = SECURITY_MAX_SID_SIZE;
- PSID sid = ACR_HeapMalloc(ss);
- if (sid) {
- if (!CreateWellKnownSid(WinBuiltinAdministratorsSid,
- NULL, sid, &ss))
- ACR_HeapFree(sid);
- else
- acr_adminsgr_sid = sid;
- }
+ acr_adminsgr_sid = ACR_AllocateWellKnownSid(_E, WinBuiltinAdministratorsSid);
}
}
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/wusec.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/wusec.c?rev=770967&r1=770966&r2=770967&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/wusec.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/wusec.c Sat May 2 15:56:14 2009
@@ -180,3 +180,29 @@
}
return token;
}
+
+PSID ACR_AllocateWellKnownSid(JNIEnv *_E, WELL_KNOWN_SID_TYPE type)
+{
+ DWORD ss = SECURITY_MAX_SID_SIZE;
+ PSID sid = ACR_HeapMalloc(ss);
+
+ if (sid) {
+ if (!CreateWellKnownSid(WinWorldSid,
+ NULL, sid, &ss)) {
+ int ec = ACR_GET_OS_ERROR();
+ ACR_HeapFree(sid);
+ sid = NULL;
+ if (_E) {
+ if (ACR_STATUS_IS_EACCES(ec))
+ ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
+ else
+ ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, ec);
+ }
+ }
+ }
+ else if (_E) {
+ ACR_ThrowException(_E, THROW_FMARK, ACR_EX_ENOMEM,
+ ACR_GET_OS_ERROR());
+ }
+ return sid;
+}