Dmitry Timoshkov : advapi32: Add named pipe access tests.

Alexandre Julliard julliard at winehq.org
Thu Apr 19 13:27:52 CDT 2012


Module: wine
Branch: master
Commit: 3bb0462165a89b72e4cdc65e8ba03bbce1611f8f
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=3bb0462165a89b72e4cdc65e8ba03bbce1611f8f

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Wed Apr 18 16:30:04 2012 +0900

advapi32: Add named pipe access tests.

---

 dlls/advapi32/tests/security.c |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/dlls/advapi32/tests/security.c b/dlls/advapi32/tests/security.c
index 40691ad..3fc9930 100644
--- a/dlls/advapi32/tests/security.c
+++ b/dlls/advapi32/tests/security.c
@@ -4053,7 +4053,7 @@ static void test_default_handle_security(HANDLE token, HANDLE handle, GENERIC_MA
     ret = GetKernelObjectSecurity(handle, OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION,
                                   sd, length, &needed);
     ok(ret, "GetKernelObjectSecurity error %d\n", GetLastError());
-    ok(needed == length, "GetKernelObjectSecurity should return %u instead of %u\n", length, needed);
+    ok(needed == length || needed == 0 /* file, pipe */, "GetKernelObjectSecurity should return %u instead of %u\n", length, needed);
 
     validate_default_security_descriptor(sd);
 
@@ -4164,6 +4164,36 @@ static void test_event_security(HANDLE token)
     CloseHandle(event);
 }
 
+#define WINE_TEST_PIPE "\\\\.\\pipe\\WineTestPipe"
+static void test_named_pipe_security(HANDLE token)
+{
+    HANDLE pipe, file;
+    GENERIC_MAPPING mapping = { FILE_GENERIC_READ,
+                                FILE_GENERIC_WRITE,
+                                FILE_GENERIC_EXECUTE,
+                                STANDARD_RIGHTS_ALL | FILE_ALL_ACCESS };
+
+    SetLastError(0xdeadbeef);
+    pipe = CreateNamedPipe(WINE_TEST_PIPE, PIPE_ACCESS_DUPLEX | FILE_FLAG_FIRST_PIPE_INSTANCE,
+                           PIPE_TYPE_BYTE | PIPE_NOWAIT, PIPE_UNLIMITED_INSTANCES,
+                           0, 0, NMPWAIT_USE_DEFAULT_WAIT, NULL);
+    ok(pipe != INVALID_HANDLE_VALUE, "CreateNamedPipe error %d\n", GetLastError());
+
+    test_default_handle_security(token, pipe, &mapping);
+
+    SetLastError(0xdeadbeef);
+    file = CreateFile(WINE_TEST_PIPE, FILE_ALL_ACCESS, 0, NULL, OPEN_EXISTING, 0, 0);
+    ok(file != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
+    CloseHandle(file);
+
+    CloseHandle(pipe);
+
+    SetLastError(0xdeadbeef);
+    file = CreateFile("\\\\.\\pipe\\", FILE_ALL_ACCESS, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0);
+    ok(file != INVALID_HANDLE_VALUE || broken(file == INVALID_HANDLE_VALUE) /* before Vista */, "CreateFile error %d\n", GetLastError());
+    CloseHandle(file);
+}
+
 static BOOL validate_impersonation_token(HANDLE token, DWORD *token_type)
 {
     DWORD ret, needed;
@@ -4236,6 +4266,7 @@ static void test_kernel_objects_security(void)
 
     test_mutex_security(token);
     test_event_security(token);
+    test_named_pipe_security(token);
     /* FIXME: test other kernel object types */
 
     CloseHandle(process_token);




More information about the wine-cvs mailing list