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/09/19 09:56:14 UTC

svn commit: r816868 - in /commons/sandbox/runtime/trunk/src/main/native: os/win32/signals.c test/testsuite.c

Author: mturk
Date: Sat Sep 19 07:56:13 2009
New Revision: 816868

URL: http://svn.apache.org/viewvc?rev=816868&view=rev
Log:
Drop the shared data segment for sharing the signal session keys. They cannot be shared amons different Windows sessions

Modified:
    commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c
    commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c?rev=816868&r1=816867&r2=816868&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/signals.c Sat Sep 19 07:56:13 2009
@@ -51,19 +51,6 @@
 #define PIPE_TIMEOUT    1000
 
 
-/* Shared DLL data segment across
- * all ACR loaders.
- * Within the same box we share the
- * same random session.
- */
-#pragma data_seg(".shared$sig")
-volatile int  sig_session_ini     = 0;
-unsigned char sig_session_key[32] = {
-    0xde, 0xad, 0xbe, 0xef, 0xba, 0xbe
-};
-#pragma data_seg()
-#pragma comment(linker, "/SECTION:.shared,RWS")
-
 static CRITICAL_SECTION signal_lock;
 static sigset_t current_signal_mask;
 static sigset_t current_signal_queue;
@@ -116,11 +103,13 @@
         ACR_SHA1Update(&sha, salt, ACR_SHA1_DIGEST_LENGTH);
     }
     else {
+        HW_PROFILE_INFOW hw;
+        GetCurrentHwProfileW(&hw);
         /* No security set.
          * In most of the cases setting security is not needed if
          * the system is propery secured against malitious software.
          */
-        ACR_SHA1Update(&sha, sig_session_key, sizeof(sig_session_key));
+        ACR_SHA1UpdateW(&sha, hw.szHwProfileGuid, HW_PROFILE_GUIDLEN);
     }
     ACR_SHA1Update(&sha, (unsigned char *)&sn, sizeof(acr_uint32_t));
     ACR_SHA1Update(&sha, (unsigned char *)&me, sizeof(acr_uint32_t));
@@ -150,8 +139,15 @@
     }
 
     ACR_SHA1Init(&sha);
-    if (sig_pipe_local)
-        ACR_SHA1Update(&sha, sig_session_key, sizeof(sig_session_key));
+    if (sig_pipe_local) {
+        HW_PROFILE_INFOW hw;
+        GetCurrentHwProfileW(&hw);
+        /* No security set.
+         * In most of the cases setting security is not needed if
+         * the system is propery secured against malitious software.
+         */
+        ACR_SHA1UpdateW(&sha, hw.szHwProfileGuid, HW_PROFILE_GUIDLEN);
+    }
     else
         ACR_SHA1Update(&sha, sig_session_sha, ACR_SHA1_DIGEST_LENGTH);
     ACR_SHA1Update(&sha, (unsigned char *)&(msg->signal), sizeof(acr_uint32_t));
@@ -558,27 +554,6 @@
     return 0;
 }
 
-static int new_sig_session_key()
-{
-    HCRYPTPROV hProv;
-    int rc = 0;
-
-    if (!CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL,
-                             CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
-    	return ACR_GET_OS_ERROR();
-    }
-    /* XXX: An ugly hack for Win64, randomness is such that noone should
-     * ever expect > 2^31 bytes of data at once without the prng
-     * coming to a complete halt.
-     */
-    if (!CryptGenRandom(hProv, (DWORD)sizeof(sig_session_key),
-                        sig_session_key)) {
-    	rc = ACR_GET_OS_ERROR();
-    }
-    CryptReleaseContext(hProv, 0);
-    return rc;
-}
-
 int acr_SignalsInit()
 {
     HANDLE h;
@@ -597,25 +572,13 @@
             return ACR_GET_OS_ERROR();
         return 0;
     }
-    if (sig_session_ini++ == 0) {
-        /* Generate the random session key since
-         * we are the first process loaded dll.
-         * There's a potential race condition here
-         * but at the end even if two processes are
-         * updating the key, they will all end up
-         * using the same one.
-         */
-        int rc = new_sig_session_key();
-        if (rc) {
-            return rc;
-        }
-    }
     if (!InitializeCriticalSectionAndSpinCount(&signal_lock, ACR_SPINCOUNT)) {
         return ACR_GET_OS_ERROR();
     }
     sigemptyset(&current_signal_queue);
     sigemptyset(&current_signal_mask);
 
+    memset(sig_session_sha, 0, sizeof(sig_session_sha));
     /*
      * Create a simple unnamed signaling event.
      * We use auto-reset event meaning that if multiple

Modified: commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c?rev=816868&r1=816867&r2=816868&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c Sat Sep 19 07:56:13 2009
@@ -555,12 +555,11 @@
             rc = ACR_RaiseSignal(NULL, SIGSTOP, ppid);
             rc = ACR_RaiseSignal(NULL, SIGCONT, ppid);
             rc = ACR_RaiseSignal(NULL, SIGQUIT, ppid);
-            rc = ACR_RaiseSignal(NULL, SIGBUS,  ppid);
         }
         if (rc) {
             char buf[256];
-            fprintf(stderr, ACR_GetErrorString(rc, buf, sizeof(buf)));
-            fputc('\n', stderr);
+            fprintf(stderr, "Error %d : %s\n", rc,
+                   ACR_GetErrorString(rc, buf, sizeof(buf)));
         }
     }
     return 0;