Skip to content

Commit ee49a5a

Browse files
compholiojulliard
authored andcommitted
kernel32: Add support for security access parameters for named pipes.
1 parent 83c45ea commit ee49a5a

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

dlls/advapi32/tests/security.c

+29
Original file line numberDiff line numberDiff line change
@@ -4713,6 +4713,35 @@ static void test_named_pipe_security(HANDLE token)
47134713
{ 1, GENERIC_EXECUTE, FILE_GENERIC_EXECUTE },
47144714
{ 1, GENERIC_ALL, STANDARD_RIGHTS_ALL | FILE_ALL_ACCESS }
47154715
};
4716+
static const struct
4717+
{
4718+
DWORD open_mode;
4719+
DWORD access;
4720+
} creation_access[] =
4721+
{
4722+
{ PIPE_ACCESS_INBOUND, FILE_GENERIC_READ },
4723+
{ PIPE_ACCESS_OUTBOUND, FILE_GENERIC_WRITE },
4724+
{ PIPE_ACCESS_DUPLEX, FILE_GENERIC_READ|FILE_GENERIC_WRITE },
4725+
{ PIPE_ACCESS_INBOUND|WRITE_DAC, FILE_GENERIC_READ|WRITE_DAC },
4726+
{ PIPE_ACCESS_INBOUND|WRITE_OWNER, FILE_GENERIC_READ|WRITE_OWNER }
4727+
/* ACCESS_SYSTEM_SECURITY is also valid, but will fail with ERROR_PRIVILEGE_NOT_HELD */
4728+
};
4729+
4730+
/* Test the different security access options for pipes */
4731+
for (i = 0; i < sizeof(creation_access)/sizeof(creation_access[0]); i++)
4732+
{
4733+
SetLastError(0xdeadbeef);
4734+
pipe = CreateNamedPipeA(WINE_TEST_PIPE, creation_access[i].open_mode,
4735+
PIPE_TYPE_BYTE | PIPE_NOWAIT, PIPE_UNLIMITED_INSTANCES, 0, 0,
4736+
NMPWAIT_USE_DEFAULT_WAIT, NULL);
4737+
ok(pipe != INVALID_HANDLE_VALUE, "CreateNamedPipe(0x%x) error %d\n",
4738+
creation_access[i].open_mode, GetLastError());
4739+
access = get_obj_access(pipe);
4740+
ok(access == creation_access[i].access,
4741+
"CreateNamedPipeA(0x%x) pipe expected access 0x%x (got 0x%x)\n",
4742+
creation_access[i].open_mode, creation_access[i].access, access);
4743+
CloseHandle(pipe);
4744+
}
47164745

47174746
SetLastError(0xdeadbeef);
47184747
pipe = CreateNamedPipeA(WINE_TEST_PIPE, PIPE_ACCESS_DUPLEX | FILE_FLAG_FIRST_PIPE_INSTANCE,

dlls/kernel32/sync.c

+3
Original file line numberDiff line numberDiff line change
@@ -1395,6 +1395,9 @@ HANDLE WINAPI CreateNamedPipeW( LPCWSTR name, DWORD dwOpenMode,
13951395
}
13961396
access |= SYNCHRONIZE;
13971397
options = 0;
1398+
if (dwOpenMode & WRITE_DAC) access |= WRITE_DAC;
1399+
if (dwOpenMode & WRITE_OWNER) access |= WRITE_OWNER;
1400+
if (dwOpenMode & ACCESS_SYSTEM_SECURITY) access |= ACCESS_SYSTEM_SECURITY;
13981401
if (dwOpenMode & FILE_FLAG_WRITE_THROUGH) options |= FILE_WRITE_THROUGH;
13991402
if (!(dwOpenMode & FILE_FLAG_OVERLAPPED)) options |= FILE_SYNCHRONOUS_IO_NONALERT;
14001403
pipe_type = (dwPipeMode & PIPE_TYPE_MESSAGE) != 0;

0 commit comments

Comments
 (0)