OS_IpcClose(request->ipcFd, ! request->detached);
request->ipcFd = -1;
request->detached = 0;
+#ifdef _WIN32
+ } else {
+ OS_StopImpersonation();
+#endif
}
}
if (reqDataPtr->ipcFd < 0) {
return (errno > 0) ? (0 - errno) : -9999;
}
+#ifdef _WIN32
+ } else if (!OS_StartImpersonation()) {
+ FCGX_Free(reqDataPtr, 1);
+#endif
}
/*
* A connection is open. Read from the connection in order to
return 0;
}
+int OS_StartImpersonation(void)
+{
+ return (!bImpersonate ||
+ ((hListen != INVALID_HANDLE_VALUE) &&
+ !ImpersonateNamedPipeClient(hListen)));
+}
+
+void OS_StopImpersonation(void)
+{
+ if (bImpersonate) RevertToSelf();
+}
+
/*
*--------------------------------------------------------------
*
if (stdioHandles[0] != INVALID_HANDLE_VALUE) {
DisconnectNamedPipe(hListen);
CancelIo(hListen);
- if (bImpersonate) RevertToSelf();
+ OS_StopImpersonation();
}
WSACleanup();
//
// impersonate the client
//
- if(bImpersonate && !ImpersonateNamedPipeClient(hListen)) {
+ if(bImpersonate && OS_StartImpersonation()) {
DisconnectNamedPipe(hListen);
} else {
ipcFd = Win32NewDescriptor(FD_PIPE_SYNC, (int) hListen, -1);
if (ipcFd == -1)
{
DisconnectNamedPipe(hListen);
- if (bImpersonate) RevertToSelf();
+ OS_StopImpersonation();
}
}
if (! DisconnectNamedPipe(fdTable[ipcFd].fid.fileHandle)) return -1;
- if (bImpersonate) RevertToSelf();
+ OS_StopImpersonation();
/* fall through */
case FD_SOCKET_SYNC:
}
return;
}
-