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.

243 lines
11 KiB

  1. /*===================================================================
  2. Microsoft Denali
  3. Microsoft Confidential.
  4. Copyright 1996 Microsoft Corporation. All Rights Reserved.
  5. Component: Globals
  6. File: AppCnfg.h
  7. Owner: AndrewS
  8. Useful globals
  9. ===================================================================*/
  10. #ifndef __APPCNFG_H
  11. #define __APPCNFG_H
  12. #include "util.h"
  13. #include <schnlsp.h>
  14. #include <wincrypt.h>
  15. #include <iadmw.h>
  16. extern "C" {
  17. #define SECURITY_WIN32
  18. #include <sspi.h> // Security Support Provider APIs
  19. }
  20. //
  21. // Defaults for registry values
  22. //
  23. #define DEFAULT_MAX_THREAD 100
  24. class CAppln; // forward declaration
  25. class CApplnMgr;
  26. //
  27. // BUGBUG:: We can have only one instance of CMDAppConfigSink.
  28. // ASP Just requires one instance of this object and because we signal a global variable
  29. // in its destructor. Having multiple instances will cause a bug. Evaluate a change of design, behaviour
  30. // in case it becomes absolutely necessary that this class needs more instances
  31. //
  32. class CMDAppConfigSink : public IMSAdminBaseSinkW
  33. {
  34. private:
  35. ULONG m_cRef;
  36. CApplnMgr *m_pApplnMgr;
  37. public:
  38. CMDAppConfigSink (CApplnMgr *pApplnMgr);
  39. ~CMDAppConfigSink();
  40. HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppv);
  41. ULONG STDMETHODCALLTYPE AddRef(void);
  42. ULONG STDMETHODCALLTYPE Release(void);
  43. HRESULT STDMETHODCALLTYPE SinkNotify(
  44. DWORD dwMDNumElements,
  45. MD_CHANGE_OBJECT __RPC_FAR pcoChangeList[]);
  46. HRESULT STDMETHODCALLTYPE ShutdownNotify( void)
  47. {
  48. return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
  49. }
  50. };
  51. // Index used in ReadPropsfromRegistry(). Also, we can use the same index to enable the global
  52. // data to be table-driven.
  53. #define IApp_AllowSessionState 0x0
  54. #define IApp_BufferingOn 0x1
  55. #define IApp_ScriptLanguage 0x2
  56. #define IApp_EnableParentPaths 0x3
  57. #define IApp_ScriptErrorMessage 0x4
  58. #define IApp_SessionTimeout 0x5
  59. #define IApp_CodePage 0x6
  60. #define IApp_ScriptTimeout 0x7
  61. #define IApp_ScriptErrorsSenttoBrowser 0x8
  62. #define IApp_AllowDebugging 0x9
  63. #define IApp_AllowClientDebug 0xa
  64. #define IApp_QueueTimeout 0xb
  65. #define IApp_EnableApplicationRestart 0xc
  66. #define IApp_QueueConnectionTestTime 0xd
  67. #define IApp_SessionMax 0xe
  68. #define IApp_ExecuteInMTA 0xf
  69. #define IApp_LCID 0x10
  70. #define IApp_KeepSessionIDSecure 0x11
  71. #define IApp_ServiceFlags 0x12
  72. #define IApp_PartitionGUID 0x13
  73. #define IApp_SxsName 0x14
  74. #define IApp_CalcLineNumber 0x15
  75. #define IApp_RunOnEndAsAnon 0x16
  76. #define IApp_BufferLimit 0x17
  77. #define IApp_RequestEntityLimit 0x18
  78. #define IApp_MAX 0x19
  79. // flags within IApp_ServiceFlags
  80. #define IFlag_SF_TrackerEnabled 1
  81. #define IFlag_SF_SxsEnabled 2
  82. #define IFlag_SF_UsePartition 4
  83. // Index to glob's szMessage array.
  84. #define IAppMsg_SCRIPTERROR 0
  85. #define IAppMsg_SCRIPTLANGUAGE 1
  86. #define IAppMsg_PARTITIONGUID 2
  87. #define IAppMsg_SXSNAME 3
  88. #define APP_CONFIG_MESSAGEMAX 4
  89. // Default limit for response buffering
  90. #define DEFAULT_BUFFER_LIMIT (4 * 1024 * 1024) // 4 M
  91. #define DEFAULT_REQUEST_ENTITY_LIMIT (200 * 1024) // 200K
  92. // Glob data object
  93. class CAppConfig
  94. {
  95. friend class CMDAppConfigSink;
  96. friend HRESULT ReadConfigFromMD(CIsapiReqInfo *pIReq, CAppConfig *pAppConfig, BOOL fLoadGlob);
  97. friend HRESULT SetConfigToDefaults(CAppConfig *pAppConfig, BOOL fLoadGlob);
  98. private:
  99. CAppln *m_pAppln;
  100. BOOL m_fNeedUpdate;
  101. BOOL m_fInited:1;
  102. BOOL m_fRestartEnabledUpdated:1;
  103. BOOL m_fIsValidProglangCLSID:1;
  104. BOOL m_fIsValidPartitionGUID:1;
  105. BOOL m_fCSInited:1;
  106. //
  107. // Configurable values from Metabase
  108. //
  109. BOOL m_fScriptErrorsSentToBrowser;
  110. BOOL m_fBufferingOn; // Is buffering on by default?
  111. BOOL m_fEnableParentPaths;
  112. BOOL m_fAllowSessionState;
  113. BOOL m_fAllowOutOfProcCmpnts;
  114. BOOL m_fAllowDebugging;
  115. BOOL m_fAllowClientDebug;
  116. BOOL m_fEnableApplicationRestart;
  117. BOOL m_fKeepSessionIDSecure;
  118. BOOL m_fCalcLineNumber;
  119. UINT m_uCodePage;
  120. DWORD m_dwScriptTimeout;
  121. DWORD m_dwSessionTimeout;
  122. DWORD m_dwQueueTimeout;
  123. CLSID m_DefaultScriptEngineProgID;
  124. DWORD m_dwQueueConnectionTestTime;
  125. DWORD m_dwSessionMax;
  126. BOOL m_fExecuteInMTA;
  127. LCID m_uLCID;
  128. CLSID m_PartitionGUID;
  129. BOOL m_fSxsEnabled;
  130. BOOL m_fTrackerEnabled;
  131. BOOL m_fUsePartition;
  132. BOOL m_fRunOnEndAsAnon;
  133. HANDLE m_hAnonToken;
  134. DWORD m_dwBufferLimit;
  135. DWORD m_dwRequestEntityLimit;
  136. //
  137. // Critical Section to provide locking during update
  138. //
  139. CRITICAL_SECTION m_csLock;
  140. LPSTR m_szString[APP_CONFIG_MESSAGEMAX];
  141. ULONG m_cRefs;
  142. //Private functions
  143. HRESULT SetValue(unsigned int index, BYTE *lpByte);
  144. public:
  145. CAppConfig();
  146. ~CAppConfig() { if (m_fCSInited) DeleteCriticalSection(&m_csLock); }
  147. HRESULT Init(CIsapiReqInfo *pIReq, CAppln *pAppln);
  148. HRESULT UnInit(void);
  149. ULONG STDMETHODCALLTYPE AddRef(void);
  150. ULONG STDMETHODCALLTYPE Release(void);
  151. void NotifyNeedUpdate(void);
  152. BOOL fNeedUpdate() {return m_fNeedUpdate;};
  153. BOOL fRestartEnabledUpdated() {return m_fRestartEnabledUpdated;};
  154. void NotifyRestartEnabledUpdated() { m_fRestartEnabledUpdated = TRUE;};
  155. HRESULT Update(CIsapiReqInfo *pIReq);
  156. UINT uCodePage() {return m_uCodePage;};
  157. DWORD dwSessionTimeout() {return m_dwSessionTimeout;};
  158. DWORD dwQueueTimeout() {return m_dwQueueTimeout;};
  159. DWORD dwScriptTimeout() {return m_dwScriptTimeout;};
  160. BOOL fScriptErrorsSentToBrowser() {return m_fScriptErrorsSentToBrowser;};
  161. BOOL fBufferingOn() {return m_fBufferingOn;};
  162. BOOL fEnableParentPaths() {return !m_fEnableParentPaths;};
  163. BOOL fAllowSessionState() {return m_fAllowSessionState;};
  164. BOOL fAllowOutOfProcCmpnts() {return m_fAllowOutOfProcCmpnts;};
  165. BOOL fAllowDebugging() {return m_fAllowDebugging;};
  166. BOOL fAllowClientDebug() {return m_fAllowClientDebug;};
  167. BOOL fInited() {return m_fInited;};
  168. BOOL fKeepSessionIDSecure() {return m_fKeepSessionIDSecure;};
  169. BOOL fCalcLineNumber() {return m_fCalcLineNumber;};
  170. BOOL fExecuteInMTA() {return m_fExecuteInMTA;};
  171. LCID uLCID() {return m_uLCID; };
  172. LPCSTR szScriptErrorMessage() {return (m_szString[IAppMsg_SCRIPTERROR]);};
  173. LPCSTR szScriptLanguage() {return (m_szString[IAppMsg_SCRIPTLANGUAGE]);};
  174. CLSID *pCLSIDDefaultEngine() {return m_fIsValidProglangCLSID? &m_DefaultScriptEngineProgID : NULL;};
  175. BOOL fSxsEnabled() {return m_fSxsEnabled;};
  176. BOOL fTrackerEnabled() {return m_fTrackerEnabled;};
  177. BOOL fUsePartition() {return m_fUsePartition;};
  178. CLSID *PPartitionGUID() {return m_fIsValidPartitionGUID ? & m_PartitionGUID : NULL;};
  179. LPCSTR szPartition() {return (m_szString[IAppMsg_PARTITIONGUID]);};
  180. LPCSTR szSxsName() {return (m_szString[IAppMsg_SXSNAME]);};
  181. BOOL fRunOnEndAsAnon() {return m_fRunOnEndAsAnon; };
  182. HANDLE AnonToken() {return m_hAnonToken; };
  183. DWORD dwBufferLimit() {return m_dwBufferLimit; };
  184. DWORD dwRequestEntityLimit() {return m_dwRequestEntityLimit; };
  185. BOOL fEnableApplicationRestart() { return m_fEnableApplicationRestart; }
  186. DWORD dwQueueConnectionTestTime() { return m_dwQueueConnectionTestTime; }
  187. DWORD dwSessionMax() { return m_dwSessionMax; }
  188. LPTSTR SzMDPath();
  189. void Lock() { Assert(m_fCSInited); EnterCriticalSection(&m_csLock); }
  190. void UnLock() { Assert(m_fCSInited); LeaveCriticalSection(&m_csLock); }
  191. HRESULT STDMETHODCALLTYPE SinkNotify(
  192. DWORD dwMDNumElements,
  193. MD_CHANGE_OBJECT __RPC_FAR pcoChangeList[]);
  194. };
  195. inline void CAppConfig::NotifyNeedUpdate(void)
  196. {
  197. InterlockedExchange((LPLONG)&m_fNeedUpdate, 1);
  198. }
  199. #endif // __APPCNFG_H