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 2011/04/18 21:19:08 UTC

svn commit: r1094698 - in /commons/sandbox/runtime/trunk/src/main: java/org/apache/commons/runtime/platform/windows/ native/ native/include/acr/ native/os/win32/

Author: mturk
Date: Mon Apr 18 19:19:08 2011
New Revision: 1094698

URL: http://svn.apache.org/viewvc?rev=1094698&view=rev
Log:
More Win32 API

Added:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WellKnownSidType.java   (with props)
    commons/sandbox/runtime/trunk/src/main/native/os/win32/security.c   (with props)
Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Win32.java
    commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in
    commons/sandbox/runtime/trunk/src/main/native/include/acr/stddefs.h
    commons/sandbox/runtime/trunk/src/main/native/os/win32/arch_defs.h
    commons/sandbox/runtime/trunk/src/main/native/os/win32/arch_opts.h
    commons/sandbox/runtime/trunk/src/main/native/os/win32/procmutex.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/shmem.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/winapi.c

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WellKnownSidType.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WellKnownSidType.java?rev=1094698&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WellKnownSidType.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WellKnownSidType.java Mon Apr 18 19:19:08 2011
@@ -0,0 +1,108 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.runtime.platform.windows;
+
+
+/**
+ * Type of the {@code WellKnownSidType} value.
+ */
+public enum WellKnownSidType
+{
+    WinNullSid(                                   0),
+    WinWorldSid(                                  1),
+    WinLocalSid(                                  2),
+    WinCreatorOwnerSid(                           3),
+    WinCreatorGroupSid(                           4),
+    WinCreatorOwnerServerSid(                     5),
+    WinCreatorGroupServerSid(                     6),
+    WinNtAuthoritySid(                            7),
+    WinDialupSid(                                 8),
+    WinNetworkSid(                                9),
+    WinBatchSid(                                  10),
+    WinInteractiveSid(                            11),
+    WinServiceSid(                                12),
+    WinAnonymousSid(                              13),
+    WinProxySid(                                  14),
+    WinEnterpriseControllersSid(                  15),
+    WinSelfSid(                                   16),
+    WinAuthenticatedUserSid(                      17),
+    WinRestrictedCodeSid(                         18),
+    WinTerminalServerSid(                         19),
+    WinRemoteLogonIdSid(                          20),
+    WinLogonIdsSid(                               21),
+    WinLocalSystemSid(                            22),
+    WinLocalServiceSid(                           23),
+    WinNetworkServiceSid(                         24),
+    WinBuiltinDomainSid(                          25),
+    WinBuiltinAdministratorsSid(                  26),
+    WinBuiltinUsersSid(                           27),
+    WinBuiltinGuestsSid(                          28),
+    WinBuiltinPowerUsersSid(                      29),
+    WinBuiltinAccountOperatorsSid(                30),
+    WinBuiltinSystemOperatorsSid(                 31),
+    WinBuiltinPrintOperatorsSid(                  32),
+    WinBuiltinBackupOperatorsSid(                 33),
+    WinBuiltinReplicatorSid(                      34),
+    WinBuiltinPreWindows2000CompatibleAccessSid(  35),
+    WinBuiltinRemoteDesktopUsersSid(              36),
+    WinBuiltinNetworkConfigurationOperatorsSid(   37),
+    WinAccountAdministratorSid(                   38),
+    WinAccountGuestSid(                           39),
+    WinAccountKrbtgtSid(                          40),
+    WinAccountDomainAdminsSid(                    41),
+    WinAccountDomainUsersSid(                     42),
+    WinAccountDomainGuestsSid(                    43),
+    WinAccountComputersSid(                       44),
+    WinAccountControllersSid(                     45),
+    WinAccountCertAdminsSid(                      46),
+    WinAccountSchemaAdminsSid(                    47),
+    WinAccountEnterpriseAdminsSid(                48),
+    WinAccountPolicyAdminsSid(                    49),
+    WinAccountRasAndIasServersSid(                50),
+    WinNTLMAuthenticationSid(                     51),
+    WinDigestAuthenticationSid(                   52),
+    WinSChannelAuthenticationSid(                 53),
+    WinThisOrganizationSid(                       54),
+    WinOtherOrganizationSid(                      55),
+    WinBuiltinIncomingForestTrustBuildersSid(     56),
+    WinBuiltinPerfMonitoringUsersSid(             57),
+    WinBuiltinPerfLoggingUsersSid(                58),
+    WinBuiltinAuthorizationAccessSid(             59),
+    WinBuiltinTerminalServerLicenseServersSid(    60),
+    WinBuiltinDCOMUsersSid(                       61);
+
+    private int value;
+    private WellKnownSidType(int v)
+    {
+        value = v;
+    }
+
+    public int valueOf()
+    {
+        return value;
+    }
+
+    public static WellKnownSidType valueOf(int value)
+    {
+        for (WellKnownSidType e : values()) {
+            if (e.value == value)
+                return e;
+        }
+        return WinNullSid;
+    }
+
+}

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WellKnownSidType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Win32.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Win32.java?rev=1094698&r1=1094697&r2=1094698&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Win32.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Win32.java Mon Apr 18 19:19:08 2011
@@ -35,28 +35,37 @@ final class Win32
         // No instance.
     }
 
+    public static final int         FPROT_USETID            = 0x8000; /**< Set user id */
+    public static final int         FPROT_UREAD             = 0x0400; /**< Read by user */
+    public static final int         FPROT_UWRITE            = 0x0200; /**< Write by user */
+    public static final int         FPROT_UEXECUTE          = 0x0100; /**< Execute by user */
+    public static final int         FPROT_URW               = 0x0600; /**< User Read/Write access */
+    public static final int         FPROT_URWX              = 0x0700; /**< User all access */
+
+    public static final int         FPROT_GSETID            = 0x4000; /**< Set group id */
+    public static final int         FPROT_GREAD             = 0x0040; /**< Read by group */
+    public static final int         FPROT_GWRITE            = 0x0020; /**< Write by group */
+    public static final int         FPROT_GEXECUTE          = 0x0010; /**< Execute by group */
+    public static final int         FPROT_GRW               = 0x0060; /**< Group Read/Write access */
+    public static final int         FPROT_GRWX              = 0x0070; /**< Group all access */
+
+    public static final int         FPROT_WSTICKY           = 0x2000; /**< Sticky bit */
+    public static final int         FPROT_WREAD             = 0x0004; /**< Read by others */
+    public static final int         FPROT_WWRITE            = 0x0002; /**< Write by others */
+    public static final int         FPROT_WEXECUTE          = 0x0001; /**< Execute by others */
+    public static final int         FPROT_WRW               = 0x0006; /**< Read/Write by others */
+    public static final int         FPROT_WRWX              = 0x0007; /**< All access by others */
+
+    public static final int         FPROT_OS_DEFAULT        = 0x0FFF; /**< use OS's default permissions */
+
+
     public static final int         INFINITE                = 0xFFFFFFFF;
 
     public static final int         WAIT_FAILED             = 0xFFFFFFFF;
     public static final int         WAIT_OBJECT_O           = 0;
     public static final int         WAIT_ABANDONED          = 0x00000080;
 
-    public static final int         SDDL_REVISION_1         = 1;
-
-
     public static native int        CloseHandle(long handle);
     public static native int        LocalFree(long ptr);
-
-
-    public static native long       GetCurrentProcessToken()
-        throws SystemException;
-    public static native long       AllocateWellKnownSid(int sidType)
-        throws SystemException;
-    public static native long       ConvertStringSecurityDescriptorToSecurityDescriptor(String securityDescriptor, int revision)
-        throws SystemException;
-    public static native long       GetNullDacl()
-        throws OutOfMemoryError, SystemException;
-    public static native long       GetSaWithNullDacl(boolean inherit)
-        throws OutOfMemoryError, SystemException;
     public static native int        WaitForSingleObject(long handle, int timeout);
 }

Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in?rev=1094698&r1=1094697&r2=1094698&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in Mon Apr 18 19:19:08 2011
@@ -81,6 +81,7 @@ WIN32_SOURCES=\
 	$(TOPDIR)\os\win32\os.c \
 	$(TOPDIR)\os\win32\platform.c \
 	$(TOPDIR)\os\win32\procmutex.c \
+	$(TOPDIR)\os\win32\security.c \
 	$(TOPDIR)\os\win32\semaphore.c \
 	$(TOPDIR)\os\win32\shmem.c \
 	$(TOPDIR)\os\win32\time.c \

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr/stddefs.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr/stddefs.h?rev=1094698&r1=1094697&r2=1094698&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr/stddefs.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr/stddefs.h Mon Apr 18 19:19:08 2011
@@ -286,6 +286,12 @@
 #define ACR_BEGIN_MACRO         if (1) {
 #define ACR_END_MACRO           } else (void)(0)
 
+#define ACR_SET(o, f)           do { (o) |=  (f); } while (0)
+#define ACR_CLR(o, f)           do { (o) &= ~(f); } while (0)
+#define ACR_HAS(o, f)           ((o) & (f))
+#define ACR_NOT(o, f)           (((o) & (f)) == 0)
+#define ACR_ISSET(o, f)         (((o) & (f)) == (f))
+
 #define UNUSED_SOURCE_FILE(F)   \
 const char __provided_##F [] = "Using system provided " #F "()"
 

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/arch_defs.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/arch_defs.h?rev=1094698&r1=1094697&r2=1094698&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/arch_defs.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/arch_defs.h Mon Apr 18 19:19:08 2011
@@ -145,7 +145,7 @@ typedef struct _REPARSE_DATA_BUFFER {
  * ---------------------------------------------------------------------
  */
 
-ACR_INLINE(int) isblank(int c)
+static __inline int isblank(int c)
 {
     return c == ' ' || c == '\t';
 }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/arch_opts.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/arch_opts.h?rev=1094698&r1=1094697&r2=1094698&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/arch_opts.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/arch_opts.h Mon Apr 18 19:19:08 2011
@@ -17,6 +17,36 @@
 #ifndef _ACR_ARCH_OPTS_H_
 #define _ACR_ARCH_OPTS_H_
 
+/**
+ * @defgroup file_permissions File Permissions flags
+ * @{
+ */
+
+#define ACR_FPROT_USETID      0x8000 /**< Set user id */
+#define ACR_FPROT_UREAD       0x0400 /**< Read by user */
+#define ACR_FPROT_UWRITE      0x0200 /**< Write by user */
+#define ACR_FPROT_UEXECUTE    0x0100 /**< Execute by user */
+#define ACR_FPROT_URW         0x0600 /**< User Read/Write access */
+#define ACR_FPROT_URWX        0x0700 /**< User all access */
+
+#define ACR_FPROT_GSETID      0x4000 /**< Set group id */
+#define ACR_FPROT_GREAD       0x0040 /**< Read by group */
+#define ACR_FPROT_GWRITE      0x0020 /**< Write by group */
+#define ACR_FPROT_GEXECUTE    0x0010 /**< Execute by group */
+#define ACR_FPROT_GRW         0x0060 /**< Group Read/Write access */
+#define ACR_FPROT_GRWX        0x0070 /**< Group all access */
+
+#define ACR_FPROT_WSTICKY     0x2000 /**< Sticky bit */
+#define ACR_FPROT_WREAD       0x0004 /**< Read by others */
+#define ACR_FPROT_WWRITE      0x0002 /**< Write by others */
+#define ACR_FPROT_WEXECUTE    0x0001 /**< Execute by others */
+#define ACR_FPROT_WRW         0x0006 /**< Read/Write by others */
+#define ACR_FPROT_WRWX        0x0007 /**< All access by others */
+
+#define ACR_FPROT_OS_DEFAULT  0x0FFF /**< use OS's default permissions */
+
+/* additional permission flags for apr_file_copy  and apr_file_append */
+#define ACR_FPROT_SOURCE      0x1000 /**< Copy source file's permissions */
 
 typedef enum {
     SYSDLL_KERNEL32     =  0,    /* kernel32 From WinBase.h              */

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/procmutex.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/procmutex.c?rev=1094698&r1=1094697&r2=1094698&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/procmutex.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/procmutex.c Mon Apr 18 19:19:08 2011
@@ -19,3 +19,17 @@
 #include "acr/port.h"
 #include "arch_opts.h"
 
+J_DECLARE_CLAZZ = {
+    INVALID_FIELD_OFFSET,
+    0,
+    0,
+    0,
+    ACR_WIN_CP "WindowsMutexImpl"
+};
+
+J_DECLARE_M_ID(0000) = {
+    0,
+    "<init>",
+    "(I)V"
+};
+

Added: commons/sandbox/runtime/trunk/src/main/native/os/win32/security.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/security.c?rev=1094698&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/security.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/security.c Mon Apr 18 19:19:08 2011
@@ -0,0 +1,296 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "acr/string.h"
+#include "acr/debug.h"
+#include "acr/memory.h"
+#include "acr/jniapi.h"
+#include "acr/port.h"
+#include "acr/clazz.h"
+#include "acr/misc.h"
+#include "arch_opts.h"
+
+#include <aclapi.h>
+#include <sddl.h>
+
+static PSECURITY_ATTRIBUTES _null_SA[2] = { 0, 0 };
+static SECURITY_ATTRIBUTES  _zero_SA[2];
+
+static struct {
+    SE_OBJECT_TYPE krnl;
+    DWORD          a;
+    DWORD          x;
+    DWORD          w;
+    DWORD          r;
+} prot_types [] = {
+    { /* File */
+      SE_FILE_OBJECT,
+      FILE_ALL_ACCESS,
+      FILE_GENERIC_EXECUTE,
+      FILE_GENERIC_WRITE,
+      FILE_GENERIC_READ
+    },
+    { /* Mutex */
+      SE_KERNEL_OBJECT,
+      MUTEX_ALL_ACCESS,
+      MUTEX_ALL_ACCESS,
+      MUTEX_ALL_ACCESS,
+      MUTEX_MODIFY_STATE
+    },
+    { /* Shmem */
+      SE_KERNEL_OBJECT,
+      FILE_MAP_ALL_ACCESS | FILE_MAP_EXECUTE,
+      FILE_MAP_EXECUTE,
+      FILE_MAP_WRITE | FILE_MAP_COPY,
+      FILE_MAP_READ  | FILE_MAP_COPY
+    },
+    { /* Semaphore */
+      SE_KERNEL_OBJECT,
+      SEMAPHORE_ALL_ACCESS,
+      SEMAPHORE_ALL_ACCESS,
+      SEMAPHORE_ALL_ACCESS,
+      SEMAPHORE_MODIFY_STATE
+    },
+    {
+      0,
+      0,
+      0,
+      0,
+      0
+    }
+};
+
+static struct {
+    SE_OBJECT_TYPE krnl;
+    DWORD          x;
+    DWORD          w;
+    DWORD          r;
+} accm_types [] = {
+    { /* File */
+      SE_FILE_OBJECT,
+      FILE_EXECUTE    | GENERIC_EXECUTE,
+      FILE_WRITE_DATA | GENERIC_WRITE,
+      FILE_READ_DATA  | GENERIC_READ
+    },
+    { /* Mutex */
+      SE_KERNEL_OBJECT,
+      MUTEX_ALL_ACCESS   | GENERIC_EXECUTE,
+      MUTEX_ALL_ACCESS   | GENERIC_WRITE,
+      MUTEX_MODIFY_STATE | GENERIC_READ
+    },
+    { /* Shmem */
+      SE_KERNEL_OBJECT,
+      FILE_MAP_EXECUTE | GENERIC_EXECUTE,
+      FILE_MAP_WRITE | FILE_MAP_COPY | GENERIC_WRITE,
+      FILE_MAP_READ  | FILE_MAP_COPY | GENERIC_READ
+    },
+    { /* Semaphore */
+      SE_KERNEL_OBJECT,
+      SEMAPHORE_ALL_ACCESS   | GENERIC_EXECUTE,
+      SEMAPHORE_ALL_ACCESS   | GENERIC_WRITE,
+      SEMAPHORE_MODIFY_STATE | GENERIC_READ
+    },
+    {
+      0,
+      0,
+      0,
+      0
+    }
+};
+
+#define PROT_SCOPE_WORLD    0
+#define PROT_SCOPE_GROUP    4
+#define PROT_SCOPE_USER     8
+
+static ACCESS_MASK convert_acc(int prot, int type, int scope)
+{
+    int i = type;
+    /* These choices are based on the single filesystem bit that controls
+     * the given behavior.  They are -not- recommended for any set protection
+     * function, such a function should -set- use GENERIC_READ/WRITE/EXECUTE
+     */
+    ACCESS_MASK acc = 0;
+    prot = (prot >> scope) & 0x0F;
+
+    if (ACR_HAS(prot, ACR_FPROT_WEXECUTE))
+        acc |= GENERIC_EXECUTE;
+    if (ACR_HAS(prot, ACR_FPROT_WWRITE))
+        acc |= GENERIC_WRITE;
+    if (ACR_HAS(prot, ACR_FPROT_WREAD))
+        acc |= GENERIC_READ;
+
+    if ((prot & 0x07) == (ACR_FPROT_WEXECUTE | ACR_FPROT_WWRITE | ACR_FPROT_WREAD)) {
+        acc |= prot_types[i].a;
+    }
+    else {
+        if (ACR_HAS(prot, ACR_FPROT_WEXECUTE))
+            acc |= prot_types[i].x;
+        if (ACR_HAS(prot, ACR_FPROT_WWRITE))
+            acc |= prot_types[i].w;
+        if (ACR_HAS(prot, ACR_FPROT_WREAD))
+            acc |= prot_types[i].r;
+    }
+    return acc;
+}
+
+static int convert_prot(ACCESS_MASK acc, int type, int scope)
+{
+    int i    = type;
+    int prot = 0;
+
+    /* These choices are based on the single filesystem bit that controls
+     * the given behavior.  They are -not- recommended for any set protection
+     * function, such a function should -set- use GENERIC_READ/WRITE/EXECUTE
+     */
+    if (ACR_HAS(acc, accm_types[i].x))
+        prot |= ACR_FPROT_WEXECUTE;
+    if (ACR_HAS(acc, accm_types[i].w))
+        prot |= ACR_FPROT_WWRITE;
+    if (ACR_HAS(acc, accm_types[i].r))
+        prot |= ACR_FPROT_WREAD;
+
+    return (prot << scope);
+}
+
+ACR_WIN_EXPORT(jint, Security, GetAccessMask)(JNI_STDARGS, jint type, jint scope, jint prot)
+{
+    return convert_acc(prot, type, scope);
+}
+
+ACR_WIN_EXPORT(jlong, Security, AllocateWellKnownSid)(JNI_STDARGS, jint type)
+{
+    DWORD ss = SECURITY_MAX_SID_SIZE;
+    PSID sid;
+
+    if ((sid = (PSID)malloc(ss)) == 0) {
+        ACR_THROW(ACR_EX_ENOMEM, 0);
+        return 0;
+    }
+    if (!CreateWellKnownSid(type, 0, sid, &ss)) {
+        ACR_SAVE_OS_ERROR();
+        AcrFree(sid);
+        sid = 0;
+    }
+    return P2J(sid);
+}
+
+static PSECURITY_ATTRIBUTES GetSaWithNullDacl(JNI_STDENV, jboolean inherit)
+{
+    DWORD rc = 0;
+    PSECURITY_DESCRIPTOR pSD = 0;
+    int   si = inherit ? 1 : 0;
+
+    if (_null_SA[si] != 0) {
+        /* Return cached entry */
+        return _null_SA[si];
+    }
+    else {
+        _zero_SA[si].nLength = TSIZEOF(DWORD, SECURITY_ATTRIBUTES);
+        _zero_SA[si].lpSecurityDescriptor = 0;
+    }
+
+    if (!(_null_SA[si] = calloc(1, sizeof(SECURITY_ATTRIBUTES)))) {
+        rc = ACR_ENOMEM;
+        ACR_THROW(ACR_EX_ENOMEM, 0);
+        goto cleanup;
+    }
+    _null_SA[si]->nLength = TSIZEOF(DWORD, SECURITY_ATTRIBUTES);
+
+    pSD = calloc(1, SECURITY_DESCRIPTOR_MIN_LENGTH);
+    if (pSD == 0) {
+        rc = ACR_ENOMEM;
+        ACR_THROW(ACR_EX_ENOMEM, 0);
+        goto cleanup;
+    }
+    _null_SA[si]->lpSecurityDescriptor = pSD;
+    if (!InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION)) {
+        rc = GetLastError();
+        goto cleanup;
+    }
+    if (!SetSecurityDescriptorDacl(pSD, TRUE, (PACL)0, FALSE)) {
+        rc = GetLastError();
+        goto cleanup;
+    }
+    _null_SA[si]->lpSecurityDescriptor = pSD;
+    _null_SA[si]->bInheritHandle       = inherit;
+
+    return _null_SA[si];
+
+cleanup:
+    AcrFree(pSD);
+    AcrFree(_null_SA[si]);
+    _null_SA[si] = &_zero_SA[si];
+    _null_SA[si]->bInheritHandle = inherit;
+
+    SetLastError(rc);
+    return _null_SA[si];
+}
+
+ACR_WIN_EXPORT(jlong, Security, GetCurrentProcessToken)(JNI_STDARGS)
+{
+    HANDLE ptoken = 0;
+    HANDLE dtoken = 0;
+
+    if (!OpenProcessToken(GetCurrentProcess(),
+                          MAXIMUM_ALLOWED,
+                          &ptoken)) {
+        ACR_SAVE_OS_ERROR();
+        return 0;
+    }
+    if (!DuplicateTokenEx(ptoken,
+                          MAXIMUM_ALLOWED,
+                          GetSaWithNullDacl(env, JNI_FALSE),
+                          SecurityIdentification,
+                          TokenPrimary,
+                          &dtoken)) {
+        ACR_SAVE_OS_ERROR();
+        return 0;
+    }
+    CloseHandle(ptoken);
+    return P2J(dtoken);
+}
+
+ACR_WIN_EXPORT(jlong, Security, GetNullDacl)(JNI_STDARGS)
+{
+    PSECURITY_ATTRIBUTES pSA = GetSaWithNullDacl(env, JNI_FALSE);
+    if (pSA != 0)
+        return P2J(pSA->lpSecurityDescriptor);
+    else {
+        ACR_SAVE_OS_ERROR();
+        return 0;
+    }
+}
+
+ACR_WIN_EXPORT(jlong, Security, GetSaWithNullDacl)(JNI_STDARGS, jboolean inherit)
+{
+    PSECURITY_ATTRIBUTES pSA = GetSaWithNullDacl(env, inherit);
+    return P2J(pSA);
+}
+
+ACR_WIN_EXPORT(jlong, Security, ConvertStringSecurityDescriptorToSecurityDescriptor)
+              (JNI_STDARGS, jstring desc, jint rev)
+{
+    PSECURITY_DESCRIPTOR pSD = 0;
+
+    WITH_WSTR(desc) {
+        if (!ConvertStringSecurityDescriptorToSecurityDescriptorW(J2S(desc), rev, &pSD, 0)) {
+            ACR_SAVE_OS_ERROR();
+            pSD = 0;
+        }
+    } DONE_WITH_STR(desc);
+
+    return P2J(pSD);
+}

Propchange: commons/sandbox/runtime/trunk/src/main/native/os/win32/security.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/shmem.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/shmem.c?rev=1094698&r1=1094697&r2=1094698&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/shmem.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/shmem.c Mon Apr 18 19:19:08 2011
@@ -21,8 +21,8 @@
 #include "arch_opts.h"
 
 typedef struct shmblock_t {
-    acr_uint32_t   magic;       /* Is this our memory      */
-    pid_t          creator;     /* Creator's process ID    */
+    DWORD          magic;       /* Is this our memory      */
+    DWORD          creator;     /* Creator's process ID    */
     acr_uint64_t   length;      /* Shared memory size      */
 } shmblock_t;
 

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/winapi.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/winapi.c?rev=1094698&r1=1094697&r2=1094698&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/winapi.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/winapi.c Mon Apr 18 19:19:08 2011
@@ -30,93 +30,6 @@
 
 volatile LONG acr_signal_waiters = 0;
 
-static PSECURITY_ATTRIBUTES _null_SA[2] = { 0, 0 };
-static SECURITY_ATTRIBUTES  _zero_SA[2];
-
-static PSECURITY_ATTRIBUTES GetSaWithNullDacl(JNI_STDENV, jboolean inherit)
-{
-    DWORD rc = 0;
-    PSECURITY_DESCRIPTOR pSD = 0;
-    int   si = inherit ? 1 : 0;
-
-    if (_null_SA[si] != 0) {
-        /* Return cached entry */
-        return _null_SA[si];
-    }
-    else {
-        _zero_SA[si].nLength = TSIZEOF(DWORD, SECURITY_ATTRIBUTES);
-        _zero_SA[si].lpSecurityDescriptor = 0;
-    }
-
-    if (!(_null_SA[si] = calloc(1, sizeof(SECURITY_ATTRIBUTES)))) {
-        rc = ACR_ENOMEM;
-        ACR_THROW(ACR_EX_ENOMEM, 0);
-        goto cleanup;
-    }
-    _null_SA[si]->nLength = TSIZEOF(DWORD, SECURITY_ATTRIBUTES);
-
-    pSD = calloc(1, SECURITY_DESCRIPTOR_MIN_LENGTH);
-    if (pSD == 0) {
-        rc = ACR_ENOMEM;
-        ACR_THROW(ACR_EX_ENOMEM, 0);
-        goto cleanup;
-    }
-    _null_SA[si]->lpSecurityDescriptor = pSD;
-    if (!InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION)) {
-        rc = GetLastError();
-        goto cleanup;
-    }
-    if (!SetSecurityDescriptorDacl(pSD, TRUE, (PACL)0, FALSE)) {
-        rc = GetLastError();
-        goto cleanup;
-    }
-    _null_SA[si]->lpSecurityDescriptor = pSD;
-    _null_SA[si]->bInheritHandle       = inherit;
-
-    return _null_SA[si];
-
-cleanup:
-    AcrFree(pSD);
-    AcrFree(_null_SA[si]);
-    _null_SA[si] = &_zero_SA[si];
-    _null_SA[si]->bInheritHandle = inherit;
-
-    SetLastError(rc);
-    return _null_SA[si];
-}
-
-ACR_WIN_EXPORT(jlong, Win32, GetNullDacl)(JNI_STDARGS)
-{
-    PSECURITY_ATTRIBUTES pSA = GetSaWithNullDacl(env, JNI_FALSE);
-    if (pSA != 0)
-        return P2J(pSA->lpSecurityDescriptor);
-    else {
-        ACR_SAVE_OS_ERROR();
-        return 0;
-    }
-}
-
-ACR_WIN_EXPORT(jlong, Win32, GetSaWithNullDacl)(JNI_STDARGS, jboolean inherit)
-{
-    PSECURITY_ATTRIBUTES pSA = GetSaWithNullDacl(env, inherit);
-    return P2J(pSA);
-}
-
-ACR_WIN_EXPORT(jlong, Win32, ConvertStringSecurityDescriptorToSecurityDescriptor)
-              (JNI_STDARGS, jstring desc, jint rev)
-{
-    PSECURITY_DESCRIPTOR pSD = 0;
-
-    WITH_WSTR(desc) {
-        if (!ConvertStringSecurityDescriptorToSecurityDescriptorW(J2S(desc), rev, &pSD, 0)) {
-            ACR_SAVE_OS_ERROR();
-            pSD = 0;
-        }
-    } DONE_WITH_STR(desc);
-
-    return P2J(pSD);
-}
-
 ACR_WIN_EXPORT(jint, Win32, CloseHandle)(JNI_STDARGS, jlong handle)
 {
     if (CloseHandle(J2P(handle, HANDLE)))
@@ -131,47 +44,6 @@ ACR_WIN_EXPORT(void, Win32, LocalFree)(J
         LocalFree(J2P(ptr, LPVOID));
 }
 
-ACR_WIN_EXPORT(jlong, Win32, GetCurrentProcessToken)(JNI_STDARGS)
-{
-    HANDLE ptoken = 0;
-    HANDLE dtoken = 0;
-
-    if (!OpenProcessToken(GetCurrentProcess(),
-                          MAXIMUM_ALLOWED,
-                          &ptoken)) {
-        ACR_SAVE_OS_ERROR();
-        return 0;
-    }
-    if (!DuplicateTokenEx(ptoken,
-                          MAXIMUM_ALLOWED,
-                          GetSaWithNullDacl(env, JNI_FALSE),
-                          SecurityIdentification,
-                          TokenPrimary,
-                          &dtoken)) {
-        ACR_SAVE_OS_ERROR();
-        return 0;
-    }
-    CloseHandle(ptoken);
-    return P2J(dtoken);
-}
-
-ACR_WIN_EXPORT(jlong, Win32, AllocateWellKnownSid)(JNI_STDARGS, jint type)
-{
-    DWORD ss = SECURITY_MAX_SID_SIZE;
-    PSID sid;
-
-    if ((sid = (PSID)malloc(ss)) == 0) {
-        ACR_THROW(ACR_EX_ENOMEM, 0);
-        return 0;
-    }
-    if (!CreateWellKnownSid(type, 0, sid, &ss)) {
-        ACR_SAVE_OS_ERROR();
-        AcrFree(sid);
-        sid = 0;
-    }
-    return P2J(sid);
-}
-
 ACR_WIN_EXPORT(jint, Win32, WaitForSingleObject)(JNI_STDARGS, jlong handle, jint timeout)
 {
     DWORD ws = WaitForSingleObject(J2P(handle, HANDLE), (DWORD)timeout);