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.

384 lines
12 KiB

  1. #include "stdafx.h"
  2. #include "iadmw.h"
  3. #include "iiscnfg.h"
  4. #include "mdkey.h"
  5. #include "mdentry.h"
  6. #include "mdacl.h"
  7. #include "helper.h"
  8. INT Register_iis_common()
  9. {
  10. int iCount = 0;
  11. int iTemp = TRUE;
  12. TCHAR szTempSection[255];
  13. ProcessSection(g_pTheApp->m_hInfHandle, _T("register_iis_common__before"));
  14. while(TRUE == iTemp && iCount < 10)
  15. {
  16. iCount++;
  17. _stprintf(szTempSection, _T("register_iis_common_%d"),iCount);
  18. // this will return false if the section does not exist
  19. iTemp = ProcessSection(g_pTheApp->m_hInfHandle, szTempSection);
  20. AdvanceProgressBarTickGauge();
  21. }
  22. ProcessSection(g_pTheApp->m_hInfHandle, _T("register_iis_common_after"));
  23. return (0);
  24. }
  25. INT Unregister_iis_common()
  26. {
  27. int iCount = 0;
  28. int iTemp = TRUE;
  29. TCHAR szTempSection[255];
  30. ProcessSection(g_pTheApp->m_hInfHandle, _T("unregister_iis_common__before"));
  31. while(TRUE == iTemp && iCount < 10)
  32. {
  33. iCount++;
  34. _stprintf(szTempSection, _T("unregister_iis_common_%d"),iCount);
  35. // this will return false if the section does not exist
  36. iTemp = ProcessSection(g_pTheApp->m_hInfHandle, szTempSection);
  37. AdvanceProgressBarTickGauge();
  38. }
  39. ProcessSection(g_pTheApp->m_hInfHandle, _T("unregister_iis_common_after"));
  40. return (0);
  41. }
  42. INT Register_iis_inetmgr()
  43. {
  44. int iCount = 0;
  45. int iTemp = TRUE;
  46. TCHAR szTempSection[255];
  47. ACTION_TYPE atINETMGR = GetSubcompAction(_T("iis_inetmgr"), TRUE);
  48. ProcessSection(g_pTheApp->m_hInfHandle, _T("register_iis_inetmgr_before"));
  49. while(TRUE == iTemp && iCount < 10)
  50. {
  51. iCount++;
  52. _stprintf(szTempSection, _T("register_iis_inetmgr_%d"),iCount);
  53. // this will return false if the section does not exist
  54. iTemp = ProcessSection(g_pTheApp->m_hInfHandle, szTempSection);
  55. AdvanceProgressBarTickGauge();
  56. }
  57. ProcessSection(g_pTheApp->m_hInfHandle, _T("register_iis_inetmgr_after"));
  58. return (0);
  59. }
  60. INT Unregister_iis_inetmgr()
  61. {
  62. int iCount = 0;
  63. int iTemp = TRUE;
  64. TCHAR szTempSection[255];
  65. ProcessSection(g_pTheApp->m_hInfHandle, _T("unregister_iis_inetmgr_before"));
  66. while(TRUE == iTemp && iCount < 10)
  67. {
  68. iCount++;
  69. _stprintf(szTempSection, _T("unregister_iis_inetmgr_%d"),iCount);
  70. // this will return false if the section does not exist
  71. iTemp = ProcessSection(g_pTheApp->m_hInfHandle, szTempSection);
  72. AdvanceProgressBarTickGauge();
  73. }
  74. ProcessSection(g_pTheApp->m_hInfHandle, _T("unregister_iis_inetmgr_after"));
  75. return (0);
  76. }
  77. INT Register_iis_doc()
  78. {
  79. int iCount = 0;
  80. int iTemp = TRUE;
  81. TCHAR szTempSection[255];
  82. ProcessSection(g_pTheApp->m_hInfHandle, _T("register_iis_doc__before"));
  83. while(TRUE == iTemp && iCount < 10)
  84. {
  85. iCount++;
  86. _stprintf(szTempSection, _T("register_iis_doc_%d"),iCount);
  87. // this will return false if the section does not exist
  88. iTemp = ProcessSection(g_pTheApp->m_hInfHandle, szTempSection);
  89. AdvanceProgressBarTickGauge();
  90. }
  91. ProcessSection(g_pTheApp->m_hInfHandle, _T("register_iis_doc_after"));
  92. return (0);
  93. return 0;
  94. }
  95. // for backward compat
  96. #define PWS_TRAY_WINDOW_CLASS _T("PWS_TRAY_WINDOW")
  97. INT Register_iis_pwmgr()
  98. {
  99. int iCount = 0;
  100. int iTemp = TRUE;
  101. TCHAR szTempSection[255];
  102. ACTION_TYPE atPWMGR = GetSubcompAction(_T("iis_pwmgr"),TRUE);
  103. ProcessSection(g_pTheApp->m_hInfHandle, _T("register_iis_pwmgr_before"));
  104. while(TRUE == iTemp && iCount < 10)
  105. {
  106. iCount++;
  107. _stprintf(szTempSection, _T("register_iis_pwmgr_%d"),iCount);
  108. // this will return false if the section does not exist
  109. iTemp = ProcessSection(g_pTheApp->m_hInfHandle, szTempSection);
  110. AdvanceProgressBarTickGauge();
  111. }
  112. ProcessSection(g_pTheApp->m_hInfHandle, _T("register_iis_pwmgr_after"));
  113. return (0);
  114. return (0);
  115. }
  116. INT Unregister_iis_pwmgr()
  117. {
  118. int iCount = 0;
  119. int iTemp = TRUE;
  120. TCHAR szTempSection[255];
  121. ProcessSection(g_pTheApp->m_hInfHandle, _T("unregister_iis_pwmgr_before"));
  122. // kill pwstray.exe
  123. HWND hwndTray = NULL;
  124. hwndTray = FindWindow(PWS_TRAY_WINDOW_CLASS, NULL);
  125. if ( hwndTray ){::PostMessage( hwndTray, WM_CLOSE, 0, 0 );}
  126. while(TRUE == iTemp && iCount < 10)
  127. {
  128. iCount++;
  129. _stprintf(szTempSection, _T("unregister_iis_pwmgr_%d"),iCount);
  130. // this will return false if the section does not exist
  131. iTemp = ProcessSection(g_pTheApp->m_hInfHandle, szTempSection);
  132. AdvanceProgressBarTickGauge();
  133. }
  134. ProcessSection(g_pTheApp->m_hInfHandle, _T("unregister_iis_pwmgr_after"));
  135. return (0);
  136. }
  137. //
  138. // (un)register-Order is important here
  139. //
  140. #define Register_iis_core_log _T("Register_iis_core")
  141. INT Register_iis_core()
  142. {
  143. INT err = 0;
  144. int iTempFlag = FALSE;
  145. INT iUserWasNewlyCreated = 0;
  146. int iCount = 0;
  147. int iTemp = TRUE;
  148. TCHAR szTempSection[255];
  149. iisDebugOut_Start(Register_iis_core_log, LOG_TYPE_PROGRAM_FLOW);
  150. ACTION_TYPE atCORE = GetIISCoreAction(TRUE);
  151. ACTION_TYPE atFTP = GetSubcompAction(_T("iis_ftp"), FALSE);
  152. ACTION_TYPE atWWW = GetSubcompAction(_T("iis_www"), FALSE);
  153. ProcessSection(g_pTheApp->m_hInfHandle, _T("register_iis_core_before"));
  154. AdvanceProgressBarTickGauge();
  155. #ifndef _CHICAGO_
  156. if ( atCORE == AT_INSTALL_FRESH || g_pTheApp->m_bWin95Migration || (atCORE == AT_INSTALL_REINSTALL && g_pTheApp->m_bRefreshSettings) )
  157. {
  158. int iSomethingWasSet = FALSE;
  159. g_pTheApp->m_csWWWAnonyName = g_pTheApp->m_csGuestName;
  160. g_pTheApp->m_csWWWAnonyPassword = g_pTheApp->m_csGuestPassword;
  161. g_pTheApp->m_csFTPAnonyName = g_pTheApp->m_csGuestName;
  162. g_pTheApp->m_csFTPAnonyPassword = g_pTheApp->m_csGuestPassword;
  163. // Check if there were any specified unattended users
  164. // if they specified a www user, then we'll try to use that one.
  165. // if www was specified to be install, then check for that specified name...
  166. if (atWWW == AT_INSTALL_FRESH)
  167. {
  168. if (g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_WWW_USER_NAME)
  169. {
  170. if (_tcsicmp(g_pTheApp->m_csWWWAnonyName_Unattend,_T("")) != 0)
  171. {
  172. g_pTheApp->m_csWWWAnonyName = g_pTheApp->m_csWWWAnonyName_Unattend;
  173. iSomethingWasSet = TRUE;
  174. }
  175. }
  176. if (g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_WWW_USER_PASS)
  177. {
  178. g_pTheApp->m_csWWWAnonyPassword = g_pTheApp->m_csWWWAnonyPassword_Unattend;
  179. iSomethingWasSet = TRUE;
  180. }
  181. }
  182. if (TRUE == iSomethingWasSet)
  183. {
  184. CreateIUSRAccount(g_pTheApp->m_csWWWAnonyName, g_pTheApp->m_csWWWAnonyPassword,&iUserWasNewlyCreated);
  185. if (1 == iUserWasNewlyCreated)
  186. {
  187. // Add to the list
  188. g_pTheApp->UnInstallList_Add(_T("IUSR_WWW"),g_pTheApp->m_csWWWAnonyName);
  189. }
  190. }
  191. else
  192. {
  193. // check if we're setting up ftp
  194. // if ftp was specified to be install, then check for that specified name...
  195. if (atFTP == AT_INSTALL_FRESH)
  196. {
  197. if (g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_FTP_USER_NAME)
  198. {
  199. if (_tcsicmp(g_pTheApp->m_csFTPAnonyName_Unattend,_T("")) != 0)
  200. {
  201. g_pTheApp->m_csFTPAnonyName = g_pTheApp->m_csFTPAnonyName_Unattend;
  202. iSomethingWasSet = TRUE;
  203. }
  204. }
  205. if (g_pTheApp->dwUnattendConfig & USER_SPECIFIED_INFO_FTP_USER_PASS)
  206. {
  207. g_pTheApp->m_csFTPAnonyPassword = g_pTheApp->m_csFTPAnonyPassword_Unattend;
  208. iSomethingWasSet = TRUE;
  209. }
  210. }
  211. if (TRUE == iSomethingWasSet)
  212. {
  213. CreateIUSRAccount(g_pTheApp->m_csFTPAnonyName, g_pTheApp->m_csFTPAnonyPassword,&iUserWasNewlyCreated);
  214. if (1 == iUserWasNewlyCreated)
  215. {
  216. // Add to the list
  217. g_pTheApp->UnInstallList_Add(_T("IUSR_FTP"),g_pTheApp->m_csFTPAnonyName);
  218. }
  219. }
  220. else
  221. {
  222. // Ah, nothing specified by user.
  223. // just Create IUSR_ account, with defaults!
  224. CreateIUSRAccount(g_pTheApp->m_csGuestName, g_pTheApp->m_csGuestPassword,&iUserWasNewlyCreated);
  225. }
  226. }
  227. AdvanceProgressBarTickGauge();
  228. }
  229. #endif // _CHICAGO_
  230. SetupSetStringId_Wrapper(g_pTheApp->m_hInfHandle, 33000, g_pTheApp->m_csGuestName);
  231. iCount = 0;
  232. while(TRUE == iTemp && iCount < 10)
  233. {
  234. iCount++;
  235. _stprintf(szTempSection, _T("register_iis_core_%d"),iCount);
  236. // this will return false if the section does not exist
  237. iTemp = ProcessSection(g_pTheApp->m_hInfHandle, szTempSection);
  238. AdvanceProgressBarTickGauge();
  239. }
  240. // Add special property registry key
  241. WriteToMD_IDRegistration(_T("LM/IISADMIN/PROPERTYREGISTRATION"));
  242. ProcessSection(g_pTheApp->m_hInfHandle, _T("register_iis_core_after"));
  243. iisDebugOut_End(Register_iis_core_log, LOG_TYPE_PROGRAM_FLOW);
  244. return (err);
  245. }
  246. #define Unregister_iis_core_log _T("Unregister_iis_core")
  247. INT Unregister_iis_core()
  248. {
  249. int iCount = 0;
  250. int iTemp = TRUE;
  251. TCHAR szTempSection[255];
  252. iisDebugOut_Start(Unregister_iis_core_log, LOG_TYPE_PROGRAM_FLOW);
  253. ProcessSection(g_pTheApp->m_hInfHandle, _T("unregister_iis_core_before"));
  254. AdvanceProgressBarTickGauge();
  255. while(TRUE == iTemp && iCount < 10)
  256. {
  257. iCount++;
  258. _stprintf(szTempSection, _T("unregister_iis_core_%d"),iCount);
  259. // this will return false if the section does not exist
  260. iTemp = ProcessSection(g_pTheApp->m_hInfHandle, szTempSection);
  261. AdvanceProgressBarTickGauge();
  262. }
  263. ProcessSection(g_pTheApp->m_hInfHandle, _T("unregister_iis_core_after"));
  264. AdvanceProgressBarTickGauge();
  265. ShowIfModuleUsedForGroupOfSections(g_pTheApp->m_hInfHandle, TRUE);
  266. AdvanceProgressBarTickGauge();
  267. iisDebugOut_End(Unregister_iis_core_log, LOG_TYPE_PROGRAM_FLOW);
  268. return 0;
  269. }
  270. #define Unregister_old_asp_log _T("Unregister_old_asp")
  271. INT Unregister_old_asp()
  272. {
  273. //_tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T("Unreg_old_asp:"));
  274. iisDebugOut_Start(Unregister_old_asp_log, LOG_TYPE_TRACE);
  275. CRegKey regASPUninstall(HKEY_LOCAL_MACHINE, REG_ASP_UNINSTALL, KEY_READ);
  276. if ((HKEY)regASPUninstall)
  277. {
  278. // old asp exists
  279. ProcessSection(g_pTheApp->m_hInfHandle, _T("Unregister_old_asp"));
  280. // do not remove these dirs, aaronl
  281. //RecRemoveDir(g_pTheApp->m_csPathAdvWorks);
  282. //RecRemoveDir(g_pTheApp->m_csPathASPSamp);
  283. CRegKey regWWWVRoots( HKEY_LOCAL_MACHINE, REG_WWWVROOTS);
  284. if ((HKEY)regWWWVRoots)
  285. {
  286. regWWWVRoots.DeleteValue(_T("/IASDocs"));
  287. // delete "/IASDocs," or "/IASDocs,<ip>"
  288. CRegValueIter regEnum( regWWWVRoots );
  289. CString csName, csValue;
  290. while ( regEnum.Next( &csName, &csValue ) == ERROR_SUCCESS )
  291. {
  292. csName.MakeUpper();
  293. if (csName.Left(9) == _T("/IASDOCS,"))
  294. {
  295. regWWWVRoots.DeleteValue((LPCTSTR)csName);
  296. // tell the iterator to account for the item we just deleted
  297. regEnum.Decrement();
  298. }
  299. }
  300. // do not remove these vroots,aaronl
  301. //regWWWVRoots.DeleteValue(_T("/AdvWorks"));
  302. //regWWWVRoots.DeleteValue(_T("/ASPSamp"));
  303. }
  304. }
  305. iisDebugOut_End(Unregister_old_asp_log, LOG_TYPE_TRACE);
  306. //_tcscpy(g_MyLogFile.m_szLogPreLineInfo2, _T(""));
  307. return 0;
  308. }