I've got a simple design I'm trying to implement.
A single C++ based server app creates a write-only named pipe. Multiple clients (C++ or C#) connect as read-only and listen for status messages.
I have this working for local processes, but I am unable to connect a client on a different host to the server.
The server is running on XP SP2 (maybe SP3). The client is running on Win7.
SECURITY_DESCRIPTOR sd;
SECURITY_ATTRIBUTES sa;
SID_IDENTIFIER_AUTHORITY siaWorldSidAuthority = SECURITY_WORLD_SID_AUTHORITY;
PSID psidWorldSid = (PSID) LocalAlloc (LPTR, GetSidLengthRequired(1));
InitializeSid(psidWorldSid, &siaWorldSidAuthority, 1);
*(GetSidSubAuthority(psidWorldSid, 0)) = SECURITY_WORLD_RID;
InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorGroup(&sd, psidWorldSid, TRUE);
ZeroMemory(&sa, sizeof(SECURITY_ATTRIBUTES));
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = &sd;
sa.bInheritHandle = FALSE;
HANDLE hPipe = CreateNamedPipe(
lpszPipename, // name
PIPE_ACCESS_OUTBOUND, // write access
PIPE_TYPE_MESSAGE | // message type pipe
PIPE_READMODE_MESSAGE | // message-read mode
PIPE_WAIT, // blocking mode
PIPE_UNLIMITED_INSTANCES, // max. instances
BUFSIZE, // output buffer size
BUFSIZE, // input buffer size
PIPE_TIMEOUT, // client time-out
NULL /*&sa*/); // no security attribute
replacing the NULL with &sa in the final param has no effect. The C# client code looks like this.
SafeFileHandle pipeHandle =
CreateFile(
pipeName,
GENERIC_READ,
0,
IntPtr.Zero,
OPEN_EXISTING,
0,
IntPtr.Zero);
What stupidly obvious thing am I missing here?