|
Обмен данными между службой и IIS в Win2003Srv (FileMapping)
#32541310
Ссылка:
Ссылка на сообщение:
Ссылка с названием темы:
|
|
|
|
Windows 2003 Server. В IIS подключена ISAPI DLLка, которая должна обращаться к некоторой службе для обмена данными. Использовался FileMapping. Служба создает этот виртуальный файл, DLLка открывает и читает данные. Все работало пока не перешел на Windows 2003 Server. При попытке открыть виртуальный файл DLLкой получаю Access Denied.
Попробовал в IIS создать свой Application Pool, указать в нем Local System (с точки зрения безопасности это полный доступ ко всему) и прикрутить этот Application Pool к виртуальной папке Scripts где лежит ISAPI DLLка. Не помогло.
Попробовал в службе при создании FileMapping задать свой Security Descriptor с админскими правами, тоже не помогло :cry:
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88. 89. 90. 91. 92. 93. 94. 95.
PSID pEveryoneSID = NULL;
PSID pAdminSID = NULL;
PACL pACL = NULL;
PSECURITY_DESCRIPTOR pSD = NULL;
PSECURITY_DESCRIPTOR CreatingSecurityDescriptor(void)
{
DWORD dwRes, dwDisposition;
EXPLICIT_ACCESS ea[ 2 ];
SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_WORLD_SID_AUTHORITY;
SID_IDENTIFIER_AUTHORITY SIDAuthNT = SECURITY_NT_AUTHORITY;
// Create a well-known SID for the Everyone group.
if(! AllocateAndInitializeSid( &SIDAuthWorld, 1 ,
SECURITY_WORLD_RID,
0 , 0 , 0 , 0 , 0 , 0 , 0 ,
&pEveryoneSID) ){
return NULL;
}
// Initialize an EXPLICIT_ACCESS structure for an ACE.
// The ACE will allow Everyone read access to the key.
ZeroMemory(&ea, 2 * sizeof(EXPLICIT_ACCESS));
ea[ 0 ].grfAccessPermissions = KEY_READ;
ea[ 0 ].grfAccessMode = SET_ACCESS;
ea[ 0 ].grfInheritance= NO_INHERITANCE;
ea[ 0 ].Trustee.TrusteeForm = TRUSTEE_IS_SID;
ea[ 0 ].Trustee.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP;
ea[ 0 ].Trustee.ptstrName = (LPTSTR) pEveryoneSID;
// Create a SID for the BUILTIN\Administrators group.
if(! AllocateAndInitializeSid( &SIDAuthNT, 2 ,
SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS,
0 , 0 , 0 , 0 , 0 , 0 ,
&pAdminSID) ){
return NULL;
}
// Initialize an EXPLICIT_ACCESS structure for an ACE.
// The ACE will allow the Administrators group full access to the key.
ea[ 1 ].grfAccessPermissions = KEY_ALL_ACCESS;
ea[ 1 ].grfAccessMode = SET_ACCESS;
ea[ 1 ].grfInheritance= NO_INHERITANCE;
ea[ 1 ].Trustee.TrusteeForm = TRUSTEE_IS_SID;
ea[ 1 ].Trustee.TrusteeType = TRUSTEE_IS_GROUP;
ea[ 1 ].Trustee.ptstrName = (LPTSTR) pAdminSID;
// Create a new ACL that contains the new ACEs.
dwRes = SetEntriesInAcl( 2 , ea, NULL, &pACL);
if (ERROR_SUCCESS != dwRes){
return NULL;
}
// Initialize a security descriptor.
pSD = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR,
SECURITY_DESCRIPTOR_MIN_LENGTH);
if (pSD == NULL){
return NULL;
}
if( !InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION) ){
return NULL;
}
// Add the ACL to the security descriptor.
if( !SetSecurityDescriptorDacl(pSD,
TRUE, // fDaclPresent flag
pACL,
FALSE) ){ // not a default DACL
return NULL;
}
return pSD;
}
bool CreateShareSrv(void)
{
SECURITY_ATTRIBUTES sa;
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = CreatingSecurityDescriptor();
sa.bInheritHandle = TRUE;
MapHandle = CreateFileMapping(INVALID_HANDLE_VALUE, &sa, PAGE_READWRITE, 0 , sizeof(TShareInf), GlobMapID );
if( MapHandle != NULL ){
ShareInf = (PShareInf)MapViewOfFile( MapHandle, FILE_MAP_ALL_ACCESS, 0 , 0 , 0 );
}
return (ShareInf != NULL);
}
Как же побороть эту сверхбезопасность в Windows 2003 Server?
|
|
|