Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

180 lines
4.5 KiB

  1. //#ifndef WIN32_LEAN_AND_MEAN
  2. //#define WIN32_LEAN_AND_MEAN
  3. //#endif
  4. #ifndef _WIN32_WINNT
  5. #define _WIN32_WINNT 0x0500
  6. #endif
  7. #include <windows.h>
  8. #include <tchar.h>
  9. #include <msi.h>
  10. #include <assert.h>
  11. #include <time.h>
  12. #include <msi.h>
  13. #include <msiquery.h>
  14. #include "webcaum.h"
  15. #include "..\..\shared\common.h"
  16. #include "..\..\shared\propertybag.h"
  17. #include "..\..\shared\apppool.h"
  18. HINSTANCE g_hinst;
  19. //--------------------------------------------------------------------------
  20. BOOL APIENTRY DllMain( HANDLE hModule,
  21. DWORD ul_reason_for_call,
  22. LPVOID lpReserved
  23. )
  24. {
  25. switch (ul_reason_for_call)
  26. {
  27. case DLL_PROCESS_ATTACH:
  28. {
  29. g_hinst = (HINSTANCE)hModule;
  30. break;
  31. }
  32. case DLL_THREAD_ATTACH:
  33. case DLL_THREAD_DETACH:
  34. case DLL_PROCESS_DETACH:
  35. break;
  36. }
  37. return TRUE;
  38. }
  39. //--------------------------------------------------------------------------
  40. //
  41. // This function is exported
  42. //
  43. UINT _stdcall Install(MSIHANDLE hInstall)
  44. {
  45. //::MessageBox( NULL, TEXT( "attach debugger" ), TEXT( "uddi" ), MB_OK );
  46. ENTER();
  47. TCHAR szCustomActionData[ 256 ];
  48. DWORD dwLen = sizeof( szCustomActionData ) / sizeof( szCustomActionData[0] );
  49. UINT iRet = MsiGetProperty( hInstall, TEXT( "CustomActionData" ), szCustomActionData, &dwLen);
  50. if( ERROR_SUCCESS != iRet )
  51. {
  52. LogError( TEXT( "Error getting custom action data in Web installer" ), iRet );
  53. return iRet;
  54. }
  55. //::MessageBox( NULL, TEXT( "got CustomActionaData" ), TEXT( "uddi" ), MB_OK );
  56. //
  57. // get rid of any lefover entries first...
  58. //
  59. RemoveIISUDDIMetabase();
  60. //::MessageBox( NULL, TEXT( "removed metabase" ), TEXT( "uddi" ), MB_OK );
  61. //
  62. // put our entries into the IIS metabase
  63. //
  64. TCHAR szUserName[CA_VALUE_LEN+1];
  65. TCHAR szPwd[CA_VALUE_LEN+1];
  66. TCHAR szTmpBuf[ 1024 ];
  67. TCHAR szTmpProperty[ 256 ];
  68. TCHAR szLogPath[ MAX_PATH + 1 ] = {0};
  69. ATOM at = 0;
  70. int poolidtype = 0;
  71. memset (szUserName, 0, sizeof szUserName);
  72. memset (szPwd, 0, sizeof szPwd);
  73. memset (szTmpProperty, 0, sizeof szTmpProperty );
  74. CPropertyBag pb;
  75. if( !pb.Parse( szCustomActionData, sizeof( szCustomActionData ) / sizeof( TCHAR ) ) )
  76. {
  77. return ERROR_INSTALL_FAILURE;
  78. }
  79. //::MessageBox( NULL, TEXT( "parsed properties" ), TEXT( "uddi" ), MB_OK );
  80. poolidtype = pb.GetValue( TEXT( "APPPOOL_IDENTITY_TYPE" ) );
  81. _tcsncpy( szUserName, pb.GetString( TEXT( "WAM_USER_NAME" ), szTmpBuf ), CA_VALUE_LEN );
  82. _tcsncpy( szTmpProperty, pb.GetString( TEXT( "C9E18" ), szTmpProperty ), CA_VALUE_LEN );
  83. _tcsncpy( szLogPath, pb.GetString( TEXT( "LOGDIR" ), szLogPath ), MAX_PATH );
  84. //::MessageBox( NULL, szTmpProperty, TEXT( "C9E18" ), MB_OK );
  85. if ( _tcslen( szTmpProperty ) )
  86. {
  87. at = (ATOM)_ttoi( szTmpProperty );
  88. GlobalGetAtomName( at, szPwd, CA_VALUE_LEN );
  89. }
  90. //::MessageBox( NULL, szPwd, TEXT( "C9E18 Atom value" ), MB_OK );
  91. iRet = SetupIISUDDIMetabase( poolidtype, szUserName, szPwd );
  92. //::MessageBox( NULL, TEXT( "metabase set up ok" ), TEXT( "uddi" ), MB_OK );
  93. //iRet = SetupIISUDDIMetabase( 3, TEXT( "A-MARKPA11\\Guest" ), TEXT( "" ) );
  94. if( ERROR_SUCCESS != iRet )
  95. {
  96. return iRet;
  97. }
  98. //
  99. // stop and start the app pool
  100. //
  101. CUDDIAppPool apppool;
  102. apppool.Recycle();
  103. //::MessageBox( NULL, TEXT( "app pool recycled" ), TEXT( "uddi" ), MB_OK );
  104. //
  105. // set permissions on the UDDI folders
  106. //
  107. if ( !SetUDDIFolderDacls( szUserName ) )
  108. {
  109. return ERROR_INSTALL_FAILURE;
  110. }
  111. //
  112. // now set permissions on the log folders
  113. //
  114. if ( _tcslen( szLogPath ) )
  115. {
  116. if ( !SetFolderAclRecurse( szLogPath, szUserName, GENERIC_READ | GENERIC_WRITE | DELETE ) )
  117. return ERROR_INSTALL_FAILURE;
  118. }
  119. //
  120. // Set permissions on the Windows TEMP folder; we need access to this directory because our code
  121. // does CLR serialization.
  122. if( !SetWindowsTempDacls( szUserName ) )
  123. {
  124. return ERROR_INSTALL_FAILURE;
  125. }
  126. //::MessageBox( NULL, TEXT( "finishing this part..." ), TEXT( "uddi" ), MB_OK );
  127. Log (_T("About to leave Install with retcode %d"), iRet);
  128. return iRet;
  129. }
  130. //--------------------------------------------------------------------------
  131. //
  132. // This function is exported
  133. //
  134. UINT _stdcall Uninstall(MSIHANDLE hInstall)
  135. {
  136. ENTER();
  137. //::MessageBox( NULL, TEXT( "attach debugger" ), TEXT( "uddi" ), MB_OK );
  138. RemoveIISUDDIMetabase();
  139. //
  140. // delete the app pool
  141. //
  142. CUDDIAppPool apppool;
  143. apppool.Delete();
  144. return ERROR_SUCCESS;
  145. }