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.

297 lines
10 KiB

  1. /*++
  2. Copyright (c) 1994-2000 Microsoft Corporation
  3. Module Name :
  4. restrictlist.h
  5. Abstract:
  6. IIS Object definitions
  7. Author:
  8. Aaron Lee (aaronl)
  9. Project:
  10. Internet Services Manager
  11. Revision History:
  12. --*/
  13. #ifndef __RESTRICT_LIST_H__
  14. #define __RESTRICT_LIST_H__
  15. extern INT g_iDebugOutputLevel;
  16. #define METABASE_PATH_FOR_RESTRICT_LIST _T("LM/W3SVC")
  17. #define EMPTY_GROUPID_KEY _T("$e$m$p$t$y$:")
  18. #define DEFAULTS_ISAPI "0,*.dll"
  19. #define DEFAULTS_CGI "0,*.exe"
  20. #define RESTRICTION_LIST_SEPARATOR _T(',')
  21. #define APPLICATION_DEPENDENCY_NAME_SEPARATOR _T(";")
  22. #define APPLICATION_DEPENDENCY_LIST_SEPARATOR _T(",")
  23. #define RESTRICTION_ENTRY_IS_ALLOW _T("1")
  24. #define RESTRICTION_ENTRY_IS_PROHIBIT _T("0")
  25. enum
  26. {
  27. WEBSVCEXT_TYPE_REGULAR,
  28. WEBSVCEXT_TYPE_ALL_UNKNOWN_ISAPI,
  29. WEBSVCEXT_TYPE_ALL_UNKNOWN_CGI,
  30. WEBSVCEXT_TYPE_FILENAME_EXTENSIONS_FILTER,
  31. /**/
  32. WEBSVCEXT_TYPE_TOTAL
  33. };
  34. enum
  35. {
  36. WEBSVCEXT_STATUS_ALLOWED,
  37. WEBSVCEXT_STATUS_PROHIBITED,
  38. WEBSVCEXT_STATUS_CUSTOM,
  39. WEBSVCEXT_STATUS_NOTINUSE,
  40. WEBSVCEXT_STATUS_INUSE,
  41. /**/
  42. WEBSVCEXT_STATUS_TOTAL
  43. };
  44. typedef struct _CApplicationDependEntry {
  45. CString strApplicationName;
  46. CStringListEx strlistGroupID;
  47. } CApplicationDependEntry, * pCApplicationDependEntry;
  48. typedef CMap<CString,LPCTSTR,CApplicationDependEntry*,CApplicationDependEntry*&> CApplicationDependList;
  49. typedef CMap<CString,LPCTSTR,CString,LPCTSTR> CMyMapStringToString;
  50. // CRestrictionUIList has many CRestrictionUIEntry
  51. // CRestrictionUIEntry has one CRestrictionList
  52. // CRestrictionList has many CRestrictionEntry
  53. // CRestrictionUIList->CRestrictionUIEntry->CRestrictionList->CRestrictionEntry
  54. typedef struct _CRestrictionEntry {
  55. CString strFileName;
  56. int iStatus;
  57. int iDeletable;
  58. CString strGroupID;
  59. CString strGroupDescription;
  60. int iType;
  61. } CRestrictionEntry, *pCRestrictionEntry;
  62. typedef CMap<CString,LPCTSTR,CRestrictionEntry*,CRestrictionEntry*&> CRestrictionList;
  63. typedef CList<CRestrictionEntry *, CRestrictionEntry *&> CRestrictionEntryList;
  64. typedef struct _CRestrictionUIEntry {
  65. int iType;
  66. CString strGroupID;
  67. CString strGroupDescription;
  68. CRestrictionList strlstRestrictionEntries;
  69. } CRestrictionUIEntry, * pCRestrictionUIEntry;
  70. typedef CMap<CString,LPCTSTR,CRestrictionUIEntry*,CRestrictionUIEntry*&> CRestrictionUIList;
  71. typedef CList<CRestrictionUIEntry *, CRestrictionUIEntry *&> CRestrictionUIEntryList;
  72. class CRestrictionListBox : public CListCtrl
  73. {
  74. DECLARE_DYNAMIC(CRestrictionListBox);
  75. public:
  76. CRestrictionListBox();
  77. public:
  78. BOOL Initialize(int iColumns);
  79. CRestrictionEntry * GetItem(UINT nIndex);
  80. int InsertItem(int idx, CRestrictionEntry * p);
  81. int AddItem(CRestrictionEntry * pItem);
  82. int SetListItem(int idx, CRestrictionEntry * pItem);
  83. void SelectItem(int idx, BOOL bSelect = TRUE);
  84. // void MoveSelectedItem(int direction);
  85. private:
  86. int m_iColsToDisplay;
  87. CString m_strAllowed;
  88. CString m_strProhibited;
  89. };
  90. void DumpRestrictionList(CRestrictionList * pMyList);
  91. void DumpRestrictionUIEntry(CRestrictionUIEntry * pMyEntry);
  92. // Restriction List stuff
  93. CRestrictionEntry * CreateRestrictionEntry(CString NewstrFileName,int NewiStatus,int NewiDeletable,CString NewstrGroupID,CString NewstrGroupDescription,int NewiType);
  94. HRESULT WriteSettingsRestrictionList(CMetaInterface * pInterface,CStringListEx * pstrlstWrite);
  95. BOOL AddRestrictEntryToRestrictList(CRestrictionList* pRestrictList, CRestrictionEntry * pAddEntry);
  96. HRESULT PrepRestictionListForWrite(CRestrictionList * pMyList,CStringListEx * pstrlstReturned);
  97. HRESULT LoadMasterRestrictListWithoutOldEntry(CMetaInterface * pInterface,CRestrictionList * pMasterRestrictionList,CRestrictionUIEntry * pOldEntry);
  98. BOOL AddRestrictListToRestrictList(CRestrictionList* pBigRestrictList, CRestrictionList * pAddEntry);
  99. BOOL RestrictionListCopy(CRestrictionList * pRestrictionListCopyTo, CRestrictionList * pRestrictionListCopyFrom);
  100. void CleanRestrictionList(CRestrictionList * pListToDelete);
  101. // UI Restriction list stuff
  102. HRESULT PrepRestictionUIListForWrite(CRestrictionUIList * pMyList,CStringListEx * pstrlstReturned);
  103. CRestrictionUIEntry * RestrictionUIEntryMakeCopy(CRestrictionUIEntry * pRestrictionUIEntry);
  104. HRESULT LoadMasterUIWithoutOldEntry(CMetaInterface * pInterface,CRestrictionUIList * pMasterRestrictionList,CRestrictionUIEntry * pOldEntry);
  105. BOOL AddRestrictUIEntryToRestrictUIList(CRestrictionUIList* pRestrictUIList, CRestrictionUIEntry * pAddEntry);
  106. void RestrictionUIEntryCopy(CRestrictionUIEntry * pRestrictionUIEntryCopyTo,CRestrictionUIEntry * pRestrictionUIEntryCopyFrom);
  107. void DeleteRestrictionUIEntry(CRestrictionUIEntry * pEntryToDelete);
  108. HRESULT RemoveRestrictionUIEntry(CMetaInterface * pInterface,CRestrictionUIEntry * pRestrictionUIEntry);
  109. HRESULT ChangeStateOfEntry(CMetaInterface * pInterface,INT iDesiredState,CRestrictionUIEntry * pRestrictionUIEntry);
  110. void CleanRestrictionUIEntry(CRestrictionUIEntry * pEntryToDelete);
  111. void CleanRestrictionUIList(CRestrictionUIList * pListToDelete);
  112. INT GetRestrictUIState(CRestrictionUIEntry * pRestrictionUIEntry);
  113. int UpdateItemFromItemInList(CRestrictionUIEntry * pMyItem,CRestrictionUIList * pMyList);
  114. void DeleteItemFromList(CRestrictionUIEntry * pMyItem,CRestrictionUIList * pMyList);
  115. // Application list stuff
  116. HRESULT LoadApplicationDependList(CMetaInterface * pInterface,CApplicationDependList * pMasterList,BOOL bAddOnlyIfFriendlyNameExists);
  117. HRESULT LoadApplicationFriendlyNames(CMetaInterface * pInterface,CMyMapStringToString * pMyList);
  118. BOOL ReturnDependentAppsList(CMetaInterface * pInterface,CString strGroupID,CStringListEx * pstrlstReturned,BOOL bAddOnlyIfFriendlyNameExists);
  119. // other
  120. BOOL IsFileUsedBySomeoneElse(CMetaInterface * pInterface,LPCTSTR lpName,LPCTSTR strGroupID,CString * strUser);
  121. BOOL IsGroupIDUsedBySomeoneElse(CMetaInterface * pInterface,LPCTSTR lpName);
  122. HBITMAP GetBitmapFromStrip(HBITMAP hbmStrip, int nPos, int cSize);
  123. #if defined(_DEBUG) || DBG
  124. #define DEBUG_PREPEND_STRING_RESTRICT _T("---")
  125. class CDebug_RestrictList
  126. {
  127. public:
  128. CDebug_RestrictList()
  129. {
  130. m_strClassName = _T("CDebug_RestrictList");
  131. };
  132. ~CDebug_RestrictList(){};
  133. public:
  134. CString m_strClassName;
  135. void Init()
  136. {
  137. DebugList_RestrictionEntryList.RemoveAll();
  138. DebugList_RestrictionUIEntryList.RemoveAll();
  139. }
  140. void Add(CRestrictionEntry * pItem)
  141. {
  142. if (g_iDebugOutputLevel & DEBUG_FLAG_CRESTRICTLIST)
  143. {
  144. DebugTrace(_T("%s%s>:Add:[%3d] %p\r\n"),m_strClassName,DEBUG_PREPEND_STRING_RESTRICT,DebugList_RestrictionEntryList.GetCount(),pItem);
  145. }
  146. DebugList_RestrictionEntryList.AddTail(pItem);
  147. }
  148. void Add(CRestrictionUIEntry * pItem)
  149. {
  150. if (g_iDebugOutputLevel & DEBUG_FLAG_CRESTRICTLIST)
  151. {
  152. DebugTrace(_T("%s%s>:Add:[%3d] %p\r\n"),m_strClassName,DEBUG_PREPEND_STRING_RESTRICT,DebugList_RestrictionUIEntryList.GetCount(),pItem);
  153. }
  154. DebugList_RestrictionUIEntryList.AddTail(pItem);
  155. }
  156. void Del(CRestrictionEntry * pItem)
  157. {
  158. INT_PTR iCount = DebugList_RestrictionEntryList.GetCount();
  159. iCount--;
  160. POSITION pos = DebugList_RestrictionEntryList.Find(pItem);
  161. if (pos)
  162. {
  163. DebugList_RestrictionEntryList.RemoveAt(pos);
  164. if (g_iDebugOutputLevel & DEBUG_FLAG_CRESTRICTLIST)
  165. {
  166. DebugTrace(_T("%s<%s:Del:[%3d] %p\r\n"),m_strClassName,DEBUG_PREPEND_STRING_RESTRICT,iCount,pItem);
  167. }
  168. }
  169. else
  170. {
  171. if (g_iDebugOutputLevel & DEBUG_FLAG_CRESTRICTLIST)
  172. {
  173. DebugTrace(_T("%s<%s:Del:[%3d] %p (not found)\r\n"),m_strClassName,DEBUG_PREPEND_STRING_RESTRICT,iCount,pItem);
  174. }
  175. }
  176. }
  177. void Del(CRestrictionUIEntry * pItem)
  178. {
  179. INT_PTR iCount = DebugList_RestrictionUIEntryList.GetCount();
  180. iCount--;
  181. POSITION pos = DebugList_RestrictionUIEntryList.Find(pItem);
  182. if (pos)
  183. {
  184. DebugList_RestrictionUIEntryList.RemoveAt(pos);
  185. if (g_iDebugOutputLevel & DEBUG_FLAG_CRESTRICTLIST)
  186. {
  187. DebugTrace(_T("%s<%s:Del:[%3d] %p\r\n"),m_strClassName,DEBUG_PREPEND_STRING_RESTRICT,iCount,pItem);
  188. }
  189. }
  190. else
  191. {
  192. if (g_iDebugOutputLevel & DEBUG_FLAG_CRESTRICTLIST)
  193. {
  194. DebugTrace(_T("%s<%s:Del:[%3d] %p (not found)\r\n"),m_strClassName,DEBUG_PREPEND_STRING_RESTRICT,iCount,pItem);
  195. }
  196. }
  197. }
  198. void Dump(BOOL bShouldBeEmpty)
  199. {
  200. int iCount = 0;
  201. CString strName;
  202. BOOL bDisplayDump = FALSE;
  203. if (!(g_iDebugOutputLevel & DEBUG_FLAG_CRESTRICTLIST))
  204. {
  205. return;
  206. }
  207. if (bShouldBeEmpty)
  208. {
  209. if (DebugList_RestrictionEntryList.GetCount() || DebugList_RestrictionUIEntryList.GetCount())
  210. {
  211. DebugTrace(_T("%s%s:Dump:SHOULD BE EMPTY, BUT IT'S NOT! [%d/%d]\r\n"),m_strClassName,DEBUG_PREPEND_STRING_RESTRICT,DebugList_RestrictionEntryList.GetCount(),DebugList_RestrictionUIEntryList.GetCount());
  212. bDisplayDump = TRUE;
  213. }
  214. }
  215. else
  216. {
  217. bDisplayDump = TRUE;
  218. }
  219. if (bDisplayDump)
  220. {
  221. DebugTrace(_T("%s%s:Dump:start\r\n"),m_strClassName,DEBUG_PREPEND_STRING_RESTRICT);
  222. CRestrictionEntry * pItemFromList1 = NULL;
  223. POSITION pos = DebugList_RestrictionEntryList.GetHeadPosition();
  224. while (pos)
  225. {
  226. pItemFromList1 = DebugList_RestrictionEntryList.GetNext(pos);
  227. if (pItemFromList1)
  228. {
  229. iCount++;
  230. DebugTrace(_T("%s%s:Dump:[%3d] %p (%s)\r\n"),m_strClassName,DEBUG_PREPEND_STRING_RESTRICT,iCount,pItemFromList1,pItemFromList1->strFileName);
  231. }
  232. }
  233. DebugTrace(_T("%s%s:Dump:--------------\r\n"),m_strClassName,DEBUG_PREPEND_STRING_RESTRICT);
  234. iCount = 0;
  235. CRestrictionUIEntry * pItemFromList2 = NULL;
  236. pos = DebugList_RestrictionUIEntryList.GetHeadPosition();
  237. while (pos)
  238. {
  239. pItemFromList2 = DebugList_RestrictionUIEntryList.GetNext(pos);
  240. if (pItemFromList2)
  241. {
  242. iCount++;
  243. DebugTrace(_T("%s%s:Dump:[%3d] %p (%s)\r\n"),m_strClassName,DEBUG_PREPEND_STRING_RESTRICT,iCount,pItemFromList2,pItemFromList2->strGroupID);
  244. }
  245. }
  246. DebugTrace(_T("%s%s:Dump:end\r\n"),m_strClassName,DEBUG_PREPEND_STRING_RESTRICT);
  247. }
  248. }
  249. private:
  250. CRestrictionEntryList DebugList_RestrictionEntryList;
  251. CRestrictionUIEntryList DebugList_RestrictionUIEntryList;
  252. };
  253. #endif //DEBUG
  254. #endif // __RESTRICT_LIST_H__