All pastes #419835 Raw Edit

vitamin

public text v1 · immutable
·published 2007-04-01 17:46 UTC
rendered paste body
commit ba8b7d52f32d2d7212e0cf0af78f59de716c906e
Author: Vitaliy Margolen <wine-patches@kievinfo.com>
Date:   Tue Feb 6 20:25:50 2007 -0700

    kernel32: Set object security on process object in CreateProcess.
    
    Tests showed that only DACL can be set this way. Owner and group
    are taken from the token.

diff --git a/dlls/advapi32/tests/security.c b/dlls/advapi32/tests/security.c
index 9aba94b..f7505a6 100644
--- a/dlls/advapi32/tests/security.c
+++ b/dlls/advapi32/tests/security.c
@@ -1558,7 +1558,6 @@ static void test_process_security_child(
     ret = DuplicateHandle( GetCurrentProcess(), handle, GetCurrentProcess(),
                            &handle1, PROCESS_ALL_ACCESS, TRUE, 0 );
     err = GetLastError();
-    todo_wine
     ok(!ret && err == ERROR_ACCESS_DENIED, "duplicating handle should have failed "
        "with STATUS_ACCESS_DENIED, instead of err:%d\n", err);
 
@@ -1566,10 +1565,8 @@ static void test_process_security_child(
 
     /* These two should fail - they are denied by ACL */
     handle = OpenProcess( PROCESS_VM_READ, FALSE, GetCurrentProcessId() );
-    todo_wine
     ok(handle == NULL, "OpenProcess(PROCESS_VM_READ) should have failed\n");
     handle = OpenProcess( PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId() );
-    todo_wine
     ok(handle == NULL, "OpenProcess(PROCESS_ALL_ACCESS) should have failed\n");
 
     /* Documented privilege elevation */
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c
index 8b8bd3c..f71d864 100644
--- a/dlls/kernel32/process.c
+++ b/dlls/kernel32/process.c
@@ -1319,6 +1319,18 @@ static BOOL create_process( HANDLE hFile
 
     if (!env) RtlReleasePebLock();
     RtlDestroyProcessParameters( params );
+
+    /* set process security */
+    if (ret && psa && psa->lpSecurityDescriptor)
+    {
+        NTSTATUS status;
+
+        status = NtSetSecurityObject( info->hProcess, DACL_SECURITY_INFORMATION,
+                                      psa->lpSecurityDescriptor );
+        ret = status == STATUS_SUCCESS;
+        if (!ret) SetLastError( RtlNtStatusToDosError( status ) );
+    }
+
     if (!ret)
     {
         close( socketfd[0] );