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.

1413 lines
45 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name :
  4. smtpinst.hxx
  5. Abstract:
  6. This file contains type definitions for multiple instance
  7. support.
  8. Author:
  9. Johnson Apacible (JohnsonA) Jun-04-1996
  10. Revision History:
  11. Rohan Phillips (RohanP) Feb-05-1997 - modified for SMTP
  12. David Howell (Dhowell) May - 1997 - added Etrn Logic
  13. Nimish Khanolkar(NimishK) Jan - 1998 - modified for CAPI store cert
  14. --*/
  15. #ifndef _SMTPINST_H_
  16. #define _SMTPINST_H_
  17. #include <iiscert.hxx>
  18. #include <iisctl.hxx>
  19. #include <capiutil.hxx>
  20. #include <certnotf.hxx>
  21. #include <sslinfo.hxx>
  22. #include "dirnot.hxx"
  23. #include "conn.hxx"
  24. #include "shash.hxx"
  25. #include <asynccon.hxx>
  26. #include "asyncmx.hxx"
  27. #include <cdns.h>
  28. #include "smtpdns.hxx"
  29. #include <mapctxt.h>
  30. #include <smtpevent.h>
  31. #include "cpropbag.h"
  32. #include "seomgr.h"
  33. //
  34. // Service name to use for KERBEROS Authentication service names
  35. //
  36. #define SMTP_SERVICE_PRINCIPAL_PREFIX "SMTP"
  37. interface IEventRouter;
  38. interface IEventManager;
  39. class SMTP_ENDPOINT;
  40. class FILTER_LIST;
  41. class INSTANCE_INFO_LIST;
  42. //
  43. // Maximum IP address stored for the instance, 20 seems to be a commonly
  44. // used value both for DNS and remoteq
  45. //
  46. #define _MAX_HOSTENT_IP_ADDRESSES 20
  47. //
  48. // Callback function to use when SSL key info changes
  49. //
  50. extern SERVICE_MAPPING_CONTEXT g_SmtpSMC;
  51. typedef BOOL (*PFN_SF_NOTIFY)(DWORD dwNotificationCode, PVOID pvInstance);
  52. extern PFN_SF_NOTIFY g_pSslKeysNotify;
  53. #define CERT_STATUS_UNKNOWN 0
  54. #define CERT_STATUS_VALID 1
  55. #define CERT_STATUS_INVALID 2
  56. //
  57. // This is the SMTP version of the IIS_SERVER
  58. //
  59. static const CHAR *szConnectResponseDefault = "";
  60. typedef struct _SMTP_VROOT_ENTRY {
  61. char szVRoot[MAX_PATH];
  62. LIST_ENTRY list;
  63. } SMTP_VROOT_ENTRY, *PSMTP_VROOT_ENTRY;
  64. class SMTP_IIS_SERVICE : public IIS_SERVICE {
  65. public:
  66. //
  67. // Virtuals
  68. //
  69. virtual BOOL AddInstanceInfo(
  70. IN DWORD dwInstance,
  71. IN BOOL fMigrateRoots
  72. );
  73. virtual DWORD DisconnectUsersByInstance(
  74. IN IIS_SERVER_INSTANCE * pInstance
  75. );
  76. virtual VOID SMTP_IIS_SERVICE::MDChangeNotify(
  77. MD_CHANGE_OBJECT * pcoChangeList
  78. );
  79. virtual DWORD GetServiceConfigInfoSize(IN DWORD dwLevel);
  80. void AcquireServiceShareLock(void)
  81. {
  82. m_Lock.ShareLock();
  83. }
  84. void ReleaseServiceShareLock(void)
  85. {
  86. m_Lock.ShareUnlock();
  87. }
  88. void AcquireServiceExclusiveLock(void)
  89. {
  90. m_Lock.ExclusiveLock();
  91. }
  92. void ReleaseServiceExclusiveLock(void)
  93. {
  94. m_Lock.ExclusiveUnlock();
  95. }
  96. void StartHintFunction(void);
  97. SMTP_IIS_SERVICE(
  98. IN LPCTSTR lpszServiceName,
  99. IN LPCSTR lpszModuleName,
  100. IN LPCSTR lpszRegParamKey,
  101. IN DWORD dwServiceId,
  102. IN ULONGLONG SvcLocId,
  103. IN BOOL MultipleInstanceSupport,
  104. IN DWORD cbAcceptExRecvBuffer,
  105. IN ATQ_CONNECT_CALLBACK pfnConnect,
  106. IN ATQ_COMPLETION pfnConnectEx,
  107. IN ATQ_COMPLETION pfnIoCompletion
  108. );
  109. PLIST_ENTRY GetInfoList() {return &m_InstanceInfoList;}
  110. char * QueryTcpipName() {return m_szTcpipName;}
  111. void SetTcpipName(char * str) {lstrcpyn(m_szTcpipName, str, MAX_PATH);}
  112. void DecSystemRoutingThreads(void) {InterlockedDecrement(&m_cCurrentSystemRoutingThreads);}
  113. BOOL IncSystemRoutingThreads(void)
  114. {
  115. DWORD NewValue;
  116. NewValue = InterlockedIncrement(&m_cCurrentSystemRoutingThreads);
  117. if (NewValue > m_cMaxSystemRoutingThreads) {
  118. InterlockedDecrement(&m_cCurrentSystemRoutingThreads);
  119. return FALSE;
  120. }
  121. return TRUE;
  122. }
  123. BOOL AggregateStatistics(
  124. IN PCHAR pDestination,
  125. IN PCHAR pSource
  126. );
  127. BOOL ResetServicePrincipalNames()
  128. {
  129. m_Lock.ExclusiveLock();
  130. if (!m_fHaveResetPrincipalNames)
  131. m_fHaveResetPrincipalNames =
  132. CSecurityCtx::ResetServicePrincipalNames(SMTP_SERVICE_PRINCIPAL_PREFIX);
  133. m_Lock.ExclusiveUnlock();
  134. return (m_fHaveResetPrincipalNames);
  135. }
  136. APIERR LoadAdvancedQueueingDll();
  137. protected:
  138. virtual ~SMTP_IIS_SERVICE();
  139. CShareLockNH m_Lock;
  140. private:
  141. DWORD m_OldMaxPoolThreadValue;
  142. LONG m_cCurrentSystemRoutingThreads;
  143. DWORD m_cMaxSystemRoutingThreads;
  144. DWORD m_dwStartHint;
  145. //
  146. // List containing some useful info including id and
  147. // ptr to statistics for each Instance.
  148. //
  149. LIST_ENTRY m_InstanceInfoList;
  150. char m_szTcpipName[MAX_PATH + 1];
  151. BOOL m_fHaveResetPrincipalNames;
  152. BOOL m_fCreatingInstance; //An instance is just being created in the
  153. //metabase... we shouldn't start it.
  154. };
  155. typedef SMTP_IIS_SERVICE *PSMTP_IIS_SERVICE;
  156. typedef struct SMTP_INSTANCE_LIST_ENTRY {
  157. DWORD dwInstanceId;
  158. LPSMTP_SERVER_STATISTICS pSmtpServerStatsObj;
  159. LIST_ENTRY ListEntry;
  160. } SMTP_INSTANCE_LIST_ENTRY, *PSMTP_INSTANCE_LIST_ENTRY;
  161. #define PROVIDER_PACKAGES_SIG_VALID 'GKPP'
  162. #define PROVIDER_PACKAGES_SIG_INVALID 'GKP~'
  163. class CProviderPackagesInfo
  164. {
  165. private:
  166. DWORD m_dwSig;
  167. LONG m_cRefs;
  168. PAUTH_BLOCK m_ProviderPackages;
  169. char m_ProviderNames[MAX_PATH + 1];
  170. DWORD m_cProviderPackages;
  171. public:
  172. CProviderPackagesInfo()
  173. {
  174. m_cRefs = 1; // Already AddRef'ed
  175. m_ProviderPackages = NULL;
  176. m_cProviderPackages = 0;
  177. m_ProviderNames[0] = '\0';
  178. m_dwSig = PROVIDER_PACKAGES_SIG_VALID;
  179. }
  180. ~CProviderPackagesInfo()
  181. {
  182. m_dwSig = PROVIDER_PACKAGES_SIG_INVALID;
  183. LocalFree(m_ProviderPackages);
  184. m_ProviderPackages = NULL;
  185. m_cProviderPackages = 0;
  186. }
  187. void AddRef() { InterlockedIncrement(&m_cRefs); }
  188. void Release()
  189. {
  190. if(!InterlockedDecrement(&m_cRefs))
  191. delete this;
  192. }
  193. DWORD GetProviderPackagesCount(void) { return m_cProviderPackages; }
  194. void SetProviderPackagesCount(DWORD cProviderPackages)
  195. { m_cProviderPackages = cProviderPackages; }
  196. BOOL SetProviderPackages();
  197. PAUTH_BLOCK GetProviderPackages(void) { return m_ProviderPackages; }
  198. LPSTR GetProviderNames(void) { return m_ProviderNames; }
  199. };
  200. //
  201. // This is the SMTP version of the instance. Will contain all the
  202. // SMTP specific operations.
  203. //
  204. class SMTP_SERVER_INSTANCE : public IIS_SERVER_INSTANCE {
  205. friend DWORD EnumAllDomains(VOID *ptr);
  206. private:
  207. //
  208. // signature
  209. //
  210. DWORD m_signature;
  211. //
  212. // Should we use host name?
  213. //
  214. DWORD m_dwUseHostName;
  215. DWORD m_SmtpInitializeStatus;
  216. // Constants, defaults, mins, maxs, etc.
  217. //
  218. // Connections related data
  219. //
  220. // m_cMaxConnections: max connections permitted by config
  221. // m_cCurrentConnections: count of currently connected users
  222. // m_cMaxCurrentConnections: max connections seen in this session
  223. // Always m_cCurrentConnections
  224. // <= m_cMaxCurrentConnections
  225. // <= m_cMaxConnections;
  226. //
  227. // DWORD m_cMaxConnections;
  228. // replaced by TSVC_INFO::QueryMaxConnections()
  229. DWORD m_cCurrentConnections;
  230. DWORD m_cCurrentOutConnections;
  231. DWORD m_cMaxCurrentConnections;
  232. DWORD m_cMaxOutConnections;
  233. DWORD m_cMaxOutConnectionsPerDomain;
  234. DWORD m_dwNextInboundClientId;
  235. DWORD m_dwNextOutboundClientId;
  236. DWORD m_dwStopHint;
  237. // Connection protocol settings
  238. DWORD m_cMaxRemoteTimeOut;
  239. DWORD m_cMaxErrors;
  240. // Size information
  241. DWORD m_cbMaxMsgSize;
  242. DWORD m_cbMaxMsgSizeBeforeClose;
  243. DWORD m_cMaxRcpts;
  244. // DNS lookup
  245. DWORD m_dwNameResolution;
  246. // DWORD m_fEnableReverseLookup;
  247. // BOOL m_fDisconnectOnRDNSFail;
  248. DWORD m_RDNSOptions;
  249. // +3 for enclosing [] and NULL termination
  250. CHAR m_szPostDnsSmarthost[IP_ADDRESS_STRING_LENGTH+3];
  251. // CPool info
  252. DWORD m_cMaxAddressObjects;
  253. DWORD m_cMaxMailObjects;
  254. // Mail loop settings
  255. DWORD m_cMaxHopCount;
  256. // Delivery settings
  257. DWORD m_fShouldDelete;
  258. DWORD m_fRelayForAuthUsers;
  259. DWORD m_fShouldPickupMail;
  260. DWORD m_cMaxRoutingThreads;
  261. DWORD m_cMaxRemoteQThreads;
  262. DWORD m_cMaxLocalQThreads;
  263. LONG m_cCurrentRoutingThreads;
  264. DWORD m_cMaxDirBuffers;
  265. DWORD m_cMaxDirChangeIoSize;
  266. DWORD m_cMaxDirPendingIos;
  267. DWORD m_cRetryAttempts;
  268. DWORD m_cRetryMinutes;
  269. DWORD m_cRemoteRetryAttempts;
  270. DWORD m_cRemoteRetryMinutes;
  271. // Raid 174038
  272. DWORD m_fDisablePickupDotStuff;
  273. //Comma separated string of at most 4 numbers
  274. DWORD m_cbProgressiveRetryMinutes;
  275. char m_szProgressiveRetryMinutes[MAX_PATH + 1];
  276. // Pipelining info
  277. DWORD m_fShouldPipelineOut;
  278. DWORD m_fShouldPipelineIn;
  279. // Advertise Verify and Expand
  280. DWORD m_fAllowVerify;
  281. DWORD m_fAllowExpand;
  282. // Advertise DSN
  283. DWORD m_fDSN;
  284. //////
  285. //Flags that determine what commands anre supported at inbound and
  286. //under what circumstances
  287. DWORD m_InboundCmdOptions;
  288. DWORD m_OutboundCmdOptions;
  289. BOOL m_fAddNoHdrs;
  290. // Smart host settings
  291. DWORD m_fSmartHostType;
  292. DWORD m_fFlushMailFiles;
  293. //remote port to connect to
  294. DWORD m_RemoteSmtpPort;
  295. DWORD m_RemoteSmtpSecurePort;
  296. // Msgs to Admin
  297. DWORD m_fSendNDRToAdmin;
  298. DWORD m_fSendBadToAdmin;
  299. // Domain information
  300. DWORD m_fDefaultDomainExists;
  301. //number of connection objects
  302. //allocated per instance
  303. LONG m_cNumConnInObjsAlloced;
  304. LONG m_cNumConnOutObjsAlloced;
  305. LONG m_cNumCBufferObjsAlloced;
  306. LONG m_cNumAsyncObjsAlloced;
  307. LONG m_cNumAsyncDnsObjsAlloced;
  308. // Sizes, etc.
  309. DWORD m_cchConnectResponse;
  310. DWORD m_cchMailQueueDir;
  311. DWORD m_cchMailPickupDir;
  312. DWORD m_cchMailDropDir;
  313. DWORD m_cchMyHostName;
  314. //Msg batching
  315. DWORD m_fBatchMsgs;
  316. DWORD m_cMaxBatchLimit;
  317. //logging flags
  318. DWORD m_CmdLogFlags;
  319. //auth stuff
  320. DWORD m_dwAuth;
  321. BOOL m_dwDeniedIpAction;
  322. DWORD m_dwMaxLogonFailures;
  323. DWORD m_DefaultRouteAction;
  324. DWORD m_ConnectTimeout;
  325. DWORD m_MailFromTimeout;
  326. DWORD m_RcptToTimeout;
  327. DWORD m_DataTimeout;
  328. DWORD m_AuthTimeout;
  329. DWORD m_SaslTimeout;
  330. DWORD m_BdatTimeout;
  331. DWORD m_HeloTimeout;
  332. DWORD m_RSetTimeout;
  333. DWORD m_TurnTimeout;
  334. DWORD m_QuitTimeout;
  335. //
  336. // TRUE to use host name to build redirection indication
  337. //
  338. BOOL m_fUseHostName;
  339. BOOL m_dwDnsFlags;
  340. BOOL m_fHaveRegisteredPrincipalNames;
  341. //
  342. // Are there any secure filters loaded?
  343. //
  344. BOOL m_fAnySecureFilters;
  345. //retry queue variables
  346. BOOL m_fIgnoreTime;
  347. BOOL m_fStartRetry;
  348. //Require SSL / 128Bit SSL on client connections
  349. BOOL m_fRequiresSSL;
  350. BOOL m_fRequires128Bits;
  351. BOOL m_fRequiresCertVerifySubject;
  352. BOOL m_fRequiresCertVerifyIssuer;
  353. DWORD m_CertStatus;
  354. // Server certificate object
  355. IIS_SSL_INFO *m_pSSLInfo;
  356. //Require SASL on client connections
  357. BOOL m_fRequiresSASL;
  358. //use to limit remote connections
  359. BOOL m_fLimitRemoteConnections;
  360. BOOL m_fShutdownCalled;
  361. BOOL m_InstBooted;
  362. BOOL m_fStoreDrvStartEventCalled;
  363. BOOL m_fStoreDrvPrepShutDownEventCalled;
  364. BOOL m_fScheduledConnection;
  365. BOOL m_fIsRoutingTable;
  366. BOOL m_fIsRelayEnabled;
  367. BOOL m_fHelloNoDomain;
  368. BOOL m_fMailFromNoHello;
  369. BOOL m_fNagleIn;
  370. BOOL m_fNagleOut;
  371. //Internet address/domain validation
  372. BOOL m_fHelloNoValidate;
  373. BOOL m_fMailNoValidate;
  374. BOOL m_fRcptNoValidate;
  375. BOOL m_fEtrnNoValidate;
  376. BOOL m_fPickupNoValidate;
  377. HANDLE m_QStopEvent;
  378. HANDLE m_hEnumBuildQ;
  379. //The server bindings
  380. MULTISZ m_ServerBindings;
  381. TCP_AUTHENT_INFO m_TcpAuthentInfo ;
  382. //
  383. // SDK: SEO Configuration
  384. //
  385. CSMTPSeoMgr m_CSMTPSeoMgr;
  386. //
  387. // used to store instance info that we wish to make accessible via
  388. // a global linked list
  389. //
  390. PSMTP_INSTANCE_LIST_ENTRY m_pSmtpInfo;
  391. //
  392. // used to store statistics for SMTP instance
  393. //
  394. LPSMTP_SERVER_STATISTICS m_pSmtpStats;
  395. TIME_ZONE_INFORMATION m_tzInfo;
  396. PERSIST_QUEUE * m_RemoteQ;
  397. BOOL m_IsShuttingDown;
  398. BOOL m_QIsShuttingDown;
  399. BOOL m_RetryQIsShuttingDown;
  400. char m_AdminName[MAX_INTERNET_NAME + 1];
  401. char m_BadMailName[MAX_INTERNET_NAME + 1];
  402. //routing thread counter
  403. LONG m_cProcessClientThreads;
  404. BOOL m_fShouldStartAcceptingConnections;
  405. BOOL m_IsFileSystemNtfs;
  406. //Directory pickup
  407. SMTP_DIRNOT * SmtpDir;
  408. HANDLE DirPickupThreadHandle;
  409. HANDLE StopHandle;
  410. // Enum Domain Thread Handle
  411. HANDLE m_hEnumDomainThreadHandle;
  412. BOOL m_fEnumThreadStarted;
  413. ADDRESS_CHECK m_acCheck;
  414. //masquerade
  415. DWORD m_fMasquerade;
  416. CHAR m_szMasqueradeName [AB_MAX_DOMAIN + 1];
  417. //Turn Table
  418. CTURN_ACCESS_TABLE m_TurnAccessList;
  419. // support the Etrn @ extension. (on by default)
  420. BOOL m_fAllowEtrnSubDomains;
  421. //directory stuff
  422. CHAR m_szMailQueueDir[MAX_PATH + 1];
  423. CHAR m_szMailPickupDir[MAX_PATH + 1];
  424. CHAR m_szMailDropDir[MAX_PATH + 1];
  425. CHAR m_szBadMailDir[MAX_PATH + 1];
  426. CHAR m_szMyDomain[MAX_PATH + 1];
  427. CHAR m_szDefaultDomain[MAX_PATH + 1];
  428. CHAR m_szFQDomainName[MAX_PATH + 1];
  429. CHAR m_szConnectResponse[RESPONSE_BUFF_SIZE];
  430. CHAR m_szSmartHostName[MAX_PATH + 1];
  431. CHAR m_szDefaultLogonDomain[MAX_SERVER_NAME_LEN + 1]; // for clear-text auth
  432. CHAR m_DefaultRemoteUserName[MAX_INTERNET_NAME + 1];
  433. CHAR m_DefaultRemotePassword[MAX_PATH + 1];
  434. LIST_ENTRY m_ConnectionsList; // list of all connections
  435. LIST_ENTRY m_OutConnectionsList; // list of all connections
  436. LIST_ENTRY m_leVRoots; // list of vroots (used by admin)
  437. LIST_ENTRY m_AsynConnectList; // list of all Async connections
  438. LIST_ENTRY m_AsyncDnsList; // list of all Async Dnsconnections
  439. CRITICAL_SECTION m_csLock; // used for updating this object
  440. CRITICAL_SECTION m_critBoot; // used to synchronize start/stop
  441. CRITICAL_SECTION m_csAsyncDns; // used for updating async dns list
  442. CRITICAL_SECTION m_csAsyncConnect; // used for updating async connect list
  443. //
  444. // We use m_fInitAsyncCS to track whether the 2 previous critsecs (m_csAsyncDns
  445. // and m_csAsyncConnect) were intialized properly before deinitializing them
  446. // and vice versa. This is in an effort to track any bugs or erroneous assumptions
  447. // we make about the underlying IIS code which controls initializing and deinitializing
  448. // these variables (as part or initializing and deinitializing SMTP_SERVER_INSTANCE).
  449. //
  450. BOOL m_fInitAsyncCS;
  451. CShareLockNH m_OutLock;
  452. CShareLockNH m_GenLock;
  453. METADATA_REF_HANDLER m_rfAccessCheck;
  454. METADATA_REF_HANDLER m_RelayAccessCheck;
  455. //
  456. // Instance-specific cleartext auth package name
  457. //
  458. char m_szCleartextAuthPackage[MAX_PATH + 1];
  459. char m_szMembershipBroker[MAX_PATH + 1];
  460. DWORD m_cbCleartextAuthPackage;
  461. CProviderPackagesInfo *m_pProviderPackagesInfo;
  462. BOOL SetProviderPackages();
  463. // Save the pointer of change object
  464. MD_CHANGE_OBJECT *m_pChangeObject;
  465. BOOL m_fDefaultInRt;
  466. IAdvQueue *m_IAQ;
  467. PVOID m_pvAQInstanceContext;
  468. IAdvQueueConfig *m_pIAdvQueueConfig;
  469. IConnectionManager *m_ICM;
  470. BOOL fInitializedStoreDriver;
  471. BOOL fInitializedAQ;
  472. ISMTPServer *m_ComSmtpServer;
  473. // Protocol Events IServer
  474. CMailMsgLoggingPropertyBag m_InstancePropertyBag;
  475. // eventlog level
  476. DWORD m_dwEventlogLevel;
  477. //
  478. // We maintain separate lists of DNS servers to be used for alternate
  479. // networks. These lists are returned by the DNS sink when the DNS sink
  480. // event is fired. Once a list is added it cannot be removed, although
  481. // the servers in the list can be modified.
  482. //
  483. // Simple class to wrap GUID + DNS list
  484. class DNS_SERVER_LIST
  485. {
  486. public:
  487. DWORD m_dwSig;
  488. GUID m_guid;
  489. CTcpRegIpList m_TcpRegIpList;
  490. #define DNS_SERVER_LIST_VALID 'VLSD'
  491. #define DNS_SERVER_LIST_INVALID 'iLSD'
  492. DNS_SERVER_LIST() { m_dwSig = DNS_SERVER_LIST_VALID; }
  493. ~DNS_SERVER_LIST() { m_dwSig = DNS_SERVER_LIST_INVALID; }
  494. };
  495. #define MAX_DNS_SERVER_LISTS 5
  496. DWORD m_cServerList;
  497. DNS_SERVER_LIST *m_rgpServerList[MAX_DNS_SERVER_LISTS];
  498. CShareLockNH m_slServerList;
  499. public:
  500. SMTP_SERVER_INSTANCE(
  501. IN PSMTP_IIS_SERVICE pService,
  502. IN DWORD dwInstanceId,
  503. IN USHORT Port,
  504. IN LPCSTR lpszRegParamKey,
  505. IN LPWSTR lpwszAnonPasswordSecretName,
  506. IN LPWSTR lpwszVirtualRootsSecretName,
  507. IN BOOL fMigrateRoots = FALSE
  508. );
  509. virtual ~SMTP_SERVER_INSTANCE( );
  510. virtual DWORD StopInstance(void);
  511. virtual DWORD StartInstance(void);
  512. virtual DWORD PauseInstance(void);
  513. METADATA_REF_HANDLER* QueryMetaDataRefHandler() { return &m_rfAccessCheck;}
  514. METADATA_REF_HANDLER* QueryRelayMetaDataRefHandler() { return &m_RelayAccessCheck;}
  515. void ResetRelayIpSecList(void)
  516. {
  517. m_RelayAccessCheck.Reset( (IMDCOM*)g_pInetSvc->QueryMDObject() );
  518. }
  519. void SetRelayIpSecList(LPVOID pV, DWORD dwS, DWORD dwR )
  520. {
  521. if(m_RelayAccessCheck.GetPtr()) //can't leak memory
  522. {
  523. delete [] m_RelayAccessCheck.GetPtr();
  524. m_RelayAccessCheck.Set(NULL, 0, 0);
  525. }
  526. m_RelayAccessCheck.Set(pV, dwS, dwR);
  527. }
  528. // added by andreik
  529. IEventRouter * GetRouter() { return m_CSMTPSeoMgr.GetRouter(); }
  530. //
  531. // Protocol events
  532. //
  533. HRESULT HrSetWellKnownIServerProps();
  534. IUnknown *GetInstancePropertyBag() { return ((IUnknown *)(IMailMsgLoggingPropertyBag *)(&m_InstancePropertyBag));}
  535. //
  536. // read smtp parameters
  537. //
  538. void GetServerBindings(void);
  539. BOOL IsShuttingDown(void){return m_IsShuttingDown || g_IsShuttingDown;}
  540. BOOL QIsShuttingDown(void){return m_QIsShuttingDown;}
  541. BOOL IsRetryQShuttingDown(void) {return m_RetryQIsShuttingDown;}
  542. //
  543. // SSP security check
  544. //
  545. BOOL CheckSSPPackage(IN LPCSTR pszAuthString);
  546. //
  547. // Server-side SSL object
  548. //
  549. IIS_SSL_INFO* QueryAndReferenceSSLInfoObj();
  550. static VOID ResetSSLInfo( LPVOID pvParam );
  551. void LogCertStatus(void);
  552. void LogCTLStatus(void);
  553. BOOL InitQueues(void);
  554. BOOL IsFileSystemNtfs(void){ return m_IsFileSystemNtfs;}
  555. void SetShutdownFlag(void) {m_fShutdownCalled = TRUE;}
  556. SMTP_DIRNOT * QueryDirnotObj() { return SmtpDir;}
  557. PERSIST_QUEUE * QueryRemoteQObj() { return m_RemoteQ;}
  558. char * QueryAdminName(void) {return m_AdminName;}
  559. char * QueryBadMailName (void) {return m_BadMailName;}
  560. void SetAcceptConnBool(void) {m_fShouldStartAcceptingConnections = TRUE;}
  561. BOOL GetAcceptConnBool(void) { return m_fShouldStartAcceptingConnections; }
  562. //
  563. // Keep track of Statistics counters for this instance
  564. //
  565. LPSMTP_SERVER_STATISTICS QueryStatsObj() { return m_pSmtpStats;}
  566. ADDRESS_CHECK* QueryAccessCheck() { return &m_acCheck;}
  567. //
  568. // VIRTUALS for service specific params/RPC admin
  569. //
  570. virtual BOOL SetServiceConfig(IN PCHAR pConfig );
  571. virtual BOOL GetServiceConfig(IN OUT PCHAR pConfig,IN DWORD dwLevel);
  572. virtual BOOL GetStatistics( IN DWORD dwLevel, OUT PCHAR *pBuffer);
  573. virtual BOOL ClearStatistics( );
  574. virtual BOOL DisconnectUser( IN DWORD dwIdUser );
  575. virtual BOOL EnumerateUsers( OUT PCHAR* pBuffer, OUT PDWORD nRead );
  576. virtual VOID MDChangeNotify( MD_CHANGE_OBJECT * pco );
  577. DWORD QueryEncCaps(void);
  578. BOOL InitFromRegistry(void);
  579. void StopHint();
  580. void SetStopHint(DWORD StopHint) {m_dwStopHint = StopHint;}
  581. CAddr * AppendLocalDomain (CAddr * OldAddress);
  582. //Using 821 addr validation
  583. BOOL AppendLocalDomain (char * Address);
  584. BOOL MoveToBadMail ( IMailMsgProperties *pIMsg, BOOL fUseIMsg, char * MailFile, char * FilePath);
  585. VOID LockConfig( VOID) {EnterCriticalSection( &m_csLock);}
  586. VOID UnLockConfig( VOID) {LeaveCriticalSection( &m_csLock);}
  587. //these are excluse locks
  588. VOID ExclusiveLockGenCrit( VOID) {m_GenLock.ExclusiveLock();}
  589. VOID ExclusiveUnLockGenCrit( VOID) {m_GenLock.ExclusiveUnlock();}
  590. //these are shared locks
  591. VOID LockGenCrit( VOID) {m_GenLock.ShareLock();}
  592. VOID UnLockGenCrit( VOID) {m_GenLock.ShareUnlock();}
  593. DWORD GetMaxConnectionsPerDomain(void) const {return m_cMaxOutConnectionsPerDomain;}
  594. DWORD GetCurrentConnectionsCount(void) const {return m_cCurrentConnections;}
  595. PLIST_ENTRY GetConnectionList(void) {return &m_ConnectionsList;}
  596. DWORD GetMaxCurrentConnectionsCount(void) const {return m_cMaxCurrentConnections;}
  597. DWORD GetMaxRcpts(void) const { return m_cMaxRcpts;}
  598. CLIENT_CONNECTION * CreateNewConnection( IN CLIENT_CONN_PARAMS * pParams);
  599. VOID DisconnectAllConnections( VOID);
  600. VOID RemoveConnection( IN OUT CLIENT_CONNECTION * pcc);
  601. BOOL InsertNewOutboundConnection( IN OUT CLIENT_CONNECTION * pcc, BOOL ByPassLimitCheck = FALSE);
  602. VOID RemoveOutboundConnection( IN OUT CLIENT_CONNECTION * pConn);
  603. VOID DisconnectAllOutboundConnections( VOID);
  604. BOOL WriteRegParams(SMTP_CONFIG_INFO *pconfig);
  605. // Changed by KeithLau on 7/15/96 to remove the fInit flag
  606. BOOL ReadRegParams(FIELD_CONTROL fc, BOOL fRebuild, BOOL fShowEvents = TRUE);
  607. // Added by KeithLau on 7/15/96
  608. BOOL ReadStartupRegParams(VOID);
  609. BOOL RemoveRegParams(const char * DomainName);
  610. DWORD GetDnsFlags(void) const {return m_dwDnsFlags;}
  611. BOOL AllowVerify(DWORD dwConnectionStatus) const{
  612. if (m_InboundCmdOptions & SMTP_I_SUPPORT_VRFY)
  613. return TRUE;
  614. else if ((m_InboundCmdOptions & SMTP_I_SUPPORT_VRFY_ON_SSL) && (dwConnectionStatus & SMTP_IS_SSL_CONNECTION))
  615. return TRUE;
  616. else if ((m_InboundCmdOptions & SMTP_I_SUPPORT_VRFY_ON_AUTH) && (dwConnectionStatus & SMTP_IS_AUTH_CONNECTION))
  617. return TRUE;
  618. else return FALSE;
  619. }
  620. BOOL AllowExpand(DWORD dwConnectionStatus) const {
  621. if (m_InboundCmdOptions & SMTP_I_SUPPORT_EXPN)
  622. return TRUE;
  623. else if ((m_InboundCmdOptions & SMTP_I_SUPPORT_EXPN_ON_SSL) && (dwConnectionStatus & SMTP_IS_SSL_CONNECTION))
  624. return TRUE;
  625. else if ((m_InboundCmdOptions & SMTP_I_SUPPORT_EXPN_ON_AUTH) && (dwConnectionStatus & SMTP_IS_AUTH_CONNECTION))
  626. return TRUE;
  627. else return FALSE;
  628. }
  629. BOOL AllowLogin(DWORD dwConnectionStatus) const {
  630. if (!(m_dwAuth & INET_INFO_AUTH_CLEARTEXT))
  631. return FALSE;
  632. else if ((m_InboundCmdOptions & SMTP_I_SUPPORT_LOGIN) && !(m_InboundCmdOptions & SMTP_I_SUPPORT_LOGIN_ON_SSL))
  633. return TRUE;
  634. else if ((m_InboundCmdOptions & SMTP_I_SUPPORT_LOGIN_ON_SSL) && (dwConnectionStatus & SMTP_IS_SSL_CONNECTION))
  635. return TRUE;
  636. else return FALSE;
  637. }
  638. BOOL AllowEightBitMime() const {return (m_InboundCmdOptions & SMTP_I_SUPPORT_8BITMIME);}
  639. BOOL AllowDSN() const { return (m_InboundCmdOptions & SMTP_I_SUPPORT_DSN);}
  640. BOOL AllowBinaryMime() const {return (m_InboundCmdOptions & SMTP_I_SUPPORT_BMIME);}
  641. BOOL AllowChunking() const {return (m_InboundCmdOptions & SMTP_I_SUPPORT_CHUNK);}
  642. BOOL AllowETRN() const {return (m_InboundCmdOptions & SMTP_I_SUPPORT_ETRN);}
  643. BOOL AllowTURN() const {return (m_InboundCmdOptions & SMTP_I_SUPPORT_TURN);}
  644. BOOL AllowAuth() const {return (m_InboundCmdOptions & SMTP_I_SUPPORT_AUTH);}
  645. BOOL AllowEnhancedCodes() const {return (m_InboundCmdOptions & SMTP_I_SUPPORT_ECODES);}
  646. /*
  647. BOOL AllowSSL() const {
  648. CEncryptCtx EncryptCtx(FASLE);
  649. if(m_CertStatus == CERT_STATUS_UNKNOWN)
  650. {
  651. if (!EncryptCtx.CheckServerCert(
  652. (LPSTR) QueryLocalHostName(),
  653. (LPSTR) QueryLocalPortName(),
  654. (LPVOID) this,
  655. QueryInstanceId()))
  656. {
  657. m_CertStatus = CERT_STATUS_INVALID;
  658. }
  659. else
  660. {
  661. m_CertStatus = CERT_STATUS_VALID;
  662. }
  663. }
  664. if(m_CertStatus == CERT_STATUS_INVALID)
  665. return FALSE;
  666. else
  667. return TRUE;
  668. }
  669. */
  670. BOOL AllowOutboundDSN() const {return (m_OutboundCmdOptions & SMTP_0_SUPPORT_DSN);}
  671. BOOL AllowOutboundBMIME() const {return (m_OutboundCmdOptions & SMTP_0_SUPPORT_BMIME);}
  672. BOOL ShouldChunkOut() const {return (m_OutboundCmdOptions & SMTP_0_FORCE_CHUNK);}
  673. BOOL ShouldPipeLineIn(void) const { return m_fShouldPipelineIn;}
  674. BOOL ShouldPipeLineOut(void) const { return m_fShouldPipelineOut;}
  675. BOOL ShouldDelete(void) const { return m_fShouldDelete;}
  676. BOOL ShouldParseHdrs(void) const { return (!m_fAddNoHdrs);}
  677. DWORD GetMaxHopCount(void) const { return m_cMaxHopCount;}
  678. DWORD GetMaxAddrObjects(void) const { return m_cMaxAddressObjects;}
  679. DWORD GetMaxMailObjects(void) const { return m_cMaxMailObjects;}
  680. DWORD GetMaxOutConnections(void) const {return m_cMaxOutConnections;}
  681. DWORD GetRetryAttempts(void) const {return m_cRetryAttempts;}
  682. DWORD GetRetryMinutes(void) const {return m_cRetryMinutes;}
  683. DWORD GetRemoteSmtpPort(void) const {return m_RemoteSmtpPort;}
  684. DWORD GetRemoteSmtpSecurePort(void) const {return m_RemoteSmtpSecurePort;}
  685. DWORD GetRemoteRetryAttempts(void) const {return m_cRemoteRetryAttempts;}
  686. DWORD GetRemoteRetryMinutes(void) const {return m_cRemoteRetryMinutes;}
  687. DWORD GetMaxErrors(void) const {return m_cMaxErrors;}
  688. DWORD GetRemoteTimeOut(void) const {return m_cMaxRemoteTimeOut;}
  689. DWORD GetMaxMsgSize(void) const {return m_cbMaxMsgSize;}
  690. DWORD GetMailBagLimit(void) const {return m_cMaxBatchLimit;}
  691. DWORD GetMaxMsgSizeBeforeClose(void) const {return m_cbMaxMsgSizeBeforeClose;}
  692. DWORD GetConnectTimeout(void) const {return m_ConnectTimeout;}
  693. DWORD GetMailFromTimeout (void) const {return m_MailFromTimeout;}
  694. DWORD GetRcptToTimeout (void) const {return m_RcptToTimeout;}
  695. DWORD GetDataTimeout (void) const {return m_DataTimeout;}
  696. DWORD GetAuthTimeout (void) const {return m_AuthTimeout;}
  697. DWORD GetSaslTimeout (void) const {return m_SaslTimeout;}
  698. DWORD GetBdatTimeout (void) const {return m_BdatTimeout;}
  699. DWORD GetHeloTimeout (void) const {return m_HeloTimeout;}
  700. DWORD GetRSetTimeout (void) const {return m_RSetTimeout;}
  701. DWORD GetTurnTimeout (void) const {return m_TurnTimeout;}
  702. DWORD GetQuitTimeout (void) const {return m_QuitTimeout;}
  703. void DecRoutingThreads(void) {InterlockedDecrement(&m_cCurrentRoutingThreads);}
  704. BOOL IncRoutingThreads(void)
  705. {
  706. DWORD NewValue;
  707. NewValue = InterlockedIncrement(&m_cCurrentRoutingThreads);
  708. if (NewValue > m_cMaxRoutingThreads)
  709. {
  710. InterlockedDecrement(&m_cCurrentRoutingThreads);
  711. return FALSE;
  712. }
  713. return TRUE;
  714. }
  715. DWORD GetNumDirBuffers(void) const {return m_cMaxDirBuffers;}
  716. DWORD GetDirBufferSize(void) const {return m_cMaxDirChangeIoSize;}
  717. DWORD GetMaxPendingDirIos(void) const {return m_cMaxDirPendingIos;}
  718. CHAR * GetBadMailDir(void) const {return (CHAR *) m_szBadMailDir;}
  719. CHAR * GetMailQueueDir(void) const {return (CHAR *)m_szMailQueueDir;}
  720. CHAR * GetMailPickupDir(void) const {return (CHAR *)m_szMailPickupDir;}
  721. BOOL GetMailDropDir(char * OutputDropDir)
  722. {
  723. BOOL fRet = TRUE;
  724. m_GenLock.ShareLock();
  725. if (m_szMailDropDir[0] != '\0')
  726. lstrcpy(OutputDropDir,m_szMailDropDir);
  727. else
  728. fRet = FALSE;
  729. m_GenLock.ShareUnlock();
  730. if (!fRet)
  731. SetLastError(ERROR_DIRECTORY);
  732. return fRet;
  733. }
  734. DWORD GetNameResolution(void) const {return m_dwNameResolution;}
  735. DWORD GetMaxRemoteQThreads(void) const {return m_cMaxRemoteQThreads;}
  736. DWORD GetMaxLocalQThreads(void) const {return m_cMaxLocalQThreads;}
  737. DWORD GetMailQueueDirLength(void) const {return m_cchMailQueueDir;}
  738. DWORD GetMailPickupDirLength(void) const {return m_cchMailPickupDir;}
  739. DWORD GetMailDropDirLength(void) const {return m_cchMailDropDir;}
  740. CHAR * GetConnectResponse(void) const {return (char *) m_szConnectResponse;}
  741. DWORD GetConnRespSize(void) const {return m_cchConnectResponse;}
  742. BOOL IsReverseLookupEnabled(void) const {return (m_RDNSOptions & SMTP_I_HELOEHLO_RDNS);}
  743. BOOL fDisconnectOnRDNSFail(void) const {return (m_RDNSOptions & SMTP_I_HELOEHLO_RDNS_DISCONNECT);}
  744. BOOL IsRDNSEnabledForMAIL(void) const {return (m_RDNSOptions & SMTP_I_MAILFROM_RDNS);}
  745. void VerifyFQDNWithBindings(void);
  746. BOOL UseGetHostByName(void) const {return (m_dwNameResolution == RESOLUTION_GETHOSTBYNAME);}
  747. BOOL GetSendNDRToAdmin(void) const {return m_fSendNDRToAdmin;}
  748. BOOL GetSendBadToAdmin(void) const {return m_fSendBadToAdmin;}
  749. BOOL RelayForAuthUsers(void) const {return m_fRelayForAuthUsers;}
  750. BOOL ShouldMasquerade(void) const {return m_fMasquerade;}
  751. BOOL ShouldAcceptNoDomain (void) const {return m_fHelloNoDomain;}
  752. BOOL AllowMailFromNoHello (void) const {return m_fMailFromNoHello;}
  753. BOOL IsInboundNagleOn(void) const {return m_fNagleIn;}
  754. BOOL IsOutBoundNagleOn(void) const {return m_fNagleOut;}
  755. BOOL ShouldValidateHeloDomain(void){return !m_fHelloNoValidate;}
  756. CAddr * MasqueradeDomain (CAddr * OldAddress);
  757. BOOL MasqueradeDomain (char * Address, char * DomainPtr);
  758. // Removed by KeithLau on 7/23/96
  759. // BOOL ShouldRetry(void) const {return m_fShouldRetry;}
  760. // Changed by keithlau per rohanp
  761. BOOL BadMailExists(void) const {return (m_szBadMailDir[0] == '\0')?FALSE:TRUE;}
  762. BOOL FlushMailFiles(void) const {return m_fFlushMailFiles;}
  763. BOOL BatchMsgs(void) const {return m_fBatchMsgs;}
  764. BOOL ShouldPickupMail(void) const {return m_fShouldPickupMail;}
  765. BOOL AlwaysUseSmartHost(void) const {return (m_fSmartHostType == smarthostAlways);}
  766. BOOL UseSmartHostAfterFail(void) const {return (m_fSmartHostType == smarthostAfterFail);}
  767. DWORD GetSmartHostType(void) const {return m_fSmartHostType;}
  768. BOOL GetSmartHost(char *SmartHostBuffer)
  769. {
  770. BOOL fRet = FALSE;
  771. m_GenLock.ShareLock();
  772. if (m_szSmartHostName[0] != '\0') {
  773. lstrcpy(SmartHostBuffer, m_szSmartHostName);
  774. fRet = TRUE;
  775. }
  776. m_GenLock.ShareUnlock();
  777. return fRet;
  778. }
  779. BOOL GetPostDnsSmartHost(CHAR* pchSmartHostBuffer, DWORD cbSmartHostBuffer)
  780. {
  781. BOOL fRet = FALSE;
  782. if(m_szPostDnsSmarthost[0] == '\0')
  783. return FALSE;
  784. if(cbSmartHostBuffer < sizeof(m_szPostDnsSmarthost))
  785. return FALSE;
  786. m_GenLock.ShareLock();
  787. if(m_szPostDnsSmarthost[0] != '\0') {
  788. lstrcpy(pchSmartHostBuffer, m_szPostDnsSmarthost);
  789. fRet = TRUE;
  790. }
  791. m_GenLock.ShareUnlock();
  792. return fRet;
  793. }
  794. BOOL GetDefaultUserName(char *UserNameBuff)
  795. {
  796. BOOL fRet = FALSE;
  797. m_GenLock.ShareLock();
  798. if (m_DefaultRemoteUserName[0] != '\0') {
  799. lstrcpy(UserNameBuff, m_DefaultRemoteUserName);
  800. fRet = TRUE;
  801. }
  802. m_GenLock.ShareUnlock();
  803. return fRet;
  804. }
  805. BOOL GetDefaultPassword(char *PasswordBuff)
  806. {
  807. BOOL fRet = FALSE;
  808. m_GenLock.ShareLock();
  809. if (m_DefaultRemotePassword[0] != '\0') {
  810. lstrcpy(PasswordBuff, m_DefaultRemotePassword);
  811. fRet = TRUE;
  812. }
  813. m_GenLock.ShareUnlock();
  814. return fRet;
  815. }
  816. CHAR * GetFQDomainName(void) const {return (char *) m_szFQDomainName;}
  817. CHAR * GetDefaultDomain(void) const {return (char *)m_szDefaultDomain;}
  818. BOOL FDefaultDomainExists(void) const {return m_fDefaultDomainExists;}
  819. DWORD GetCmdLogFlags(VOID) const { return m_CmdLogFlags;}
  820. DWORD GetDefaultRouteAction(VOID) const { return m_DefaultRouteAction;}
  821. void FreeVRootList(PLIST_ENTRY pleHead);
  822. BOOL FindBestVRoot(LPSTR szVRoot);
  823. BOOL IsAddressMine(DWORD IpAddress, DWORD ConnectedPort = 25);
  824. //directory pickup
  825. void SetDirnotStopHandle (HANDLE SHandle) {StopHandle = SHandle;}
  826. HANDLE GetDirnotStopHandle(void) const {return StopHandle;}
  827. BOOL InitDirectoryNotification(void);
  828. void DestroyDirectoryNotification(void);
  829. //
  830. // TCP authent info
  831. //
  832. PTCP_AUTHENT_INFO QueryAuthentInfo()
  833. { return &m_TcpAuthentInfo;}
  834. LONG GetProcessClientThreads(void) const {return m_cProcessClientThreads;}
  835. void IncProcessClientThreads (void) {InterlockedIncrement(&m_cProcessClientThreads);}
  836. void DecProcessClientThreads (void) {InterlockedDecrement(&m_cProcessClientThreads);}
  837. LONG GetConnInAllocCount(void) const {return m_cNumConnInObjsAlloced;}
  838. void IncConnInObjs (void) {InterlockedIncrement(&m_cNumConnInObjsAlloced);}
  839. void DecConnInObjs (void) {InterlockedDecrement(&m_cNumConnInObjsAlloced);}
  840. LONG GetCBufferAllocCount(void) const {return m_cNumCBufferObjsAlloced;}
  841. void IncCBufferObjs (void) {InterlockedIncrement(&m_cNumCBufferObjsAlloced);}
  842. void DecCBufferObjs (void) {InterlockedDecrement(&m_cNumCBufferObjsAlloced);}
  843. LONG GetConnOutAllocCount(void) const {return m_cNumConnOutObjsAlloced;}
  844. void IncConnOutObjs (void) {InterlockedIncrement(&m_cNumConnOutObjsAlloced);}
  845. void DecConnOutObjs (void) {InterlockedDecrement(&m_cNumConnOutObjsAlloced);}
  846. LONG GetAsyncMxOutAllocCount(void) const {return m_cNumAsyncObjsAlloced;}
  847. void IncAsyncMxOutObjs (void) {InterlockedIncrement(&m_cNumAsyncObjsAlloced);}
  848. void DecAsyncMxOutObjs (void) {InterlockedDecrement(&m_cNumAsyncObjsAlloced);}
  849. LONG GetAsyncDnsAllocCount(void) const {return m_cNumAsyncDnsObjsAlloced;}
  850. void IncAsyncDnsObjs (void) {InterlockedIncrement(&m_cNumAsyncDnsObjsAlloced);}
  851. void DecAsyncDnsObjs (void) {InterlockedDecrement(&m_cNumAsyncDnsObjsAlloced);}
  852. // Allow Etrn Subdomains (the @ extension to Etrn)
  853. BOOL AllowEtrnSubDomains() { return m_fAllowEtrnSubDomains;}
  854. // Domain Info
  855. HRESULT HrGetDomainInfoFlags(
  856. IN LPSTR szDomainName,
  857. OUT DWORD *pdwDomainInfoFlags);
  858. BOOL IsALocalDomain(char * szDomainName)
  859. {
  860. BOOL fFound = FALSE;
  861. HRESULT hr = S_OK;
  862. DWORD dwDomainInfoFlags;
  863. hr = HrGetDomainInfoFlags(szDomainName, &dwDomainInfoFlags);
  864. if (SUCCEEDED(hr)) {
  865. if ( (dwDomainInfoFlags & DOMAIN_INFO_LOCAL_MAILBOX) ||
  866. (dwDomainInfoFlags & DOMAIN_INFO_ALIAS) ||
  867. (dwDomainInfoFlags & DOMAIN_INFO_LOCAL_DROP)) {
  868. fFound = TRUE;
  869. }
  870. }
  871. return fFound;
  872. }
  873. BOOL IsADefaultOrAliasDropDomain(char * szDomainName)
  874. {
  875. BOOL fFound = FALSE;
  876. HRESULT hr = S_OK;
  877. DWORD dwDomainInfoFlags;
  878. //If there is no default drop directory, then this domain cannot
  879. //be a default/alias drop domain
  880. if ('\0' == m_szMailDropDir[0])
  881. return FALSE;
  882. hr = HrGetDomainInfoFlags(szDomainName, &dwDomainInfoFlags);
  883. if (SUCCEEDED(hr)) {
  884. if ( (dwDomainInfoFlags & DOMAIN_INFO_LOCAL_DROP) ||
  885. (dwDomainInfoFlags & DOMAIN_INFO_ALIAS)) {
  886. fFound = TRUE;
  887. }
  888. }
  889. return fFound;
  890. }
  891. BOOL IsUserInTurnTable(const char * UserName, MULTISZ * pmsz)
  892. {
  893. BOOL Found = FALSE;
  894. CTurnData * pEntry = NULL;
  895. pEntry = (CTurnData *) m_TurnAccessList.FindHashData(UserName, TRUE, pmsz);
  896. if(pEntry)
  897. {
  898. pEntry->DecRefCount();
  899. Found = TRUE;
  900. }
  901. return Found;
  902. }
  903. BOOL Stop(void);
  904. BOOL IsRelayEnabled (void) const {return m_fIsRelayEnabled;}
  905. HANDLE GetQStopEvent (void) {return m_QStopEvent;}
  906. BOOL InitiateStartup(void);
  907. void InitiateShutDown(void);
  908. void InitializeClassVariables(void);
  909. BOOL RequiresSSL(void) const {return m_fRequiresSSL;}
  910. BOOL Requires128Bits(void) const {return m_fRequires128Bits;}
  911. BOOL RequiresSSLCertVerifySubject(void) const {return m_fRequiresCertVerifySubject; }
  912. BOOL RequiresSSLCertVerifyIssuer(void) const {return m_fRequiresCertVerifyIssuer; }
  913. BOOL CompareIpAddress(DWORD IpAddress);
  914. BOOL ReadIpSecList(void);
  915. void SetRouteDomainParameters(MB &mb,
  916. char *szDomainName,
  917. char *szRoutePath,
  918. char szActionType [MAX_PATH + 1],
  919. char szUserName [MAX_INTERNET_NAME + 1],
  920. char szEtrnDomain [MAX_INTERNET_NAME + 1],
  921. char szPassword [MAX_PATH + 1],
  922. char szTargetName [MAX_PATH + 1],
  923. DomainInfo *pLocalDomainInfo);
  924. BOOL AddDomainEntry(MB& CurrentMetabase, char * DomainName);
  925. BOOL DeleteDomainEntry(const char * DomainName);
  926. BOOL GetRouteDomains(MB& CurrentMetabase, char * DomainName, BOOL fRebuild);
  927. // Instance-specific cleartext authentication informaiton
  928. LPSTR GetCleartextAuthPackage(void) { return m_szCleartextAuthPackage; }
  929. LPSTR GetMembershipBroker(void) { return m_szMembershipBroker;}
  930. CProviderPackagesInfo *GetAddRefdProviderPackagesInfo(void)
  931. {
  932. if(m_pProviderPackagesInfo)
  933. m_pProviderPackagesInfo->AddRef();
  934. return m_pProviderPackagesInfo;
  935. }
  936. DWORD QueryAuthentication(void) { return m_dwAuth; }
  937. DWORD GetDeniedIpAction() { return m_dwDeniedIpAction; }
  938. BOOL RequiresSASL(void) const {return m_fRequiresSASL;}
  939. LPCSTR GetDefaultLogonDomain(void) const { return (LPCSTR) m_szDefaultLogonDomain; }
  940. DWORD GetMaxLogonFailures(void) const {return m_dwMaxLogonFailures;}
  941. BOOL IsScheduledConnection(void) const {return m_fScheduledConnection;}
  942. BOOL IsRoutingTable (void) const {return m_fIsRoutingTable;}
  943. void BuildTurnTable(MULTISZ& msz, char * szDomainName);
  944. BOOL ReadRouteDomainIpSecList(MB& mb);
  945. BOOL IsDefaultInRt(void) {return m_fDefaultInRt;}
  946. IAdvQueue * GetAdvQueuePtr(void) {return m_IAQ;}
  947. IConnectionManager * GetConnManPtr(void) {return m_ICM;}
  948. BOOL StartAdvancedQueueing(void);
  949. BOOL StopQDrivers(void);
  950. BOOL InsertAsyncObject( IN OUT CAsyncMx *pcc);
  951. VOID RemoveAsyncObject( IN OUT CAsyncMx *pcc);
  952. VOID DisconnectAllAsyncConnections( VOID);
  953. BOOL InsertAsyncDnsObject( IN OUT CAsyncSmtpDns *pcc);
  954. VOID RemoveAsyncDnsObject( IN OUT CAsyncSmtpDns *pcc);
  955. VOID DisconnectAllAsyncDnsConnections( VOID);
  956. BOOL RegisterServicePrincipalNames(BOOL fLock);
  957. PSMTP_INSTANCE_LIST_ENTRY GetSmtpInstanceInfo(void);
  958. BOOL AllocNewMessage(SMTP_ALLOC_PARAMS * Params);
  959. BOOL InsertIntoQueue(IMailMsgProperties * pImsg)
  960. {
  961. HRESULT hr = S_OK;
  962. MSG_TRACK_INFO msgTrackInfo;
  963. ZeroMemory( &msgTrackInfo, sizeof( msgTrackInfo ) );
  964. msgTrackInfo.dwEventId = MTE_SUBMIT_MESSAGE_TO_AQ;
  965. WriteLog( &msgTrackInfo, pImsg, NULL, NULL );
  966. hr = m_IAQ->SubmitMessage(pImsg);
  967. if(!FAILED(hr))
  968. {
  969. return TRUE;
  970. }
  971. else
  972. {
  973. return FALSE;
  974. }
  975. }
  976. BOOL SubmitFailedMessage(IMailMsgProperties * pImsg, DWORD dwFailedDesc, HRESULT hrFailureCode)
  977. {
  978. HRESULT hr = S_OK;
  979. hr = m_IAQ->HandleFailedMessage(pImsg, TRUE, NULL, dwFailedDesc, hrFailureCode);
  980. if(!FAILED(hr))
  981. {
  982. return TRUE;
  983. }
  984. else
  985. {
  986. return FALSE;
  987. }
  988. }
  989. HRESULT InsertIntoAdvQueue(IMailMsgProperties * pImsg)
  990. {
  991. HRESULT hr = S_OK;
  992. MSG_TRACK_INFO msgTrackInfo;
  993. ZeroMemory( &msgTrackInfo, sizeof( msgTrackInfo ) );
  994. msgTrackInfo.dwEventId = MTE_SUBMIT_MESSAGE_TO_AQ;
  995. WriteLog( &msgTrackInfo, pImsg, NULL, NULL );
  996. hr = m_IAQ->SubmitMessage(pImsg);
  997. return hr;
  998. }
  999. const char * GetInstancePath(void) const {return QueryMDPath();}
  1000. HRESULT TriggerLocalDelivery(IMailMsgProperties *pMsg, DWORD dwRecipientCount, DWORD * pdwRecipIndexes, IMailMsgNotify *pNotify);
  1001. HRESULT TriggerDirectoryDrop(IMailMsgProperties *pMsg,
  1002. DWORD dwRecipientCount,
  1003. DWORD * pdwRecipIndexes,
  1004. LPCSTR DropDirectory);
  1005. HRESULT TriggerDnsResolverEvent( LPSTR HostName,
  1006. LPSTR MyFQDNName,
  1007. DWORD dwVirtualServerId,
  1008. DNS_SERVER_INFO **ppDnsServerInfo,
  1009. IDnsResolverRecord **ppIDnsResolverRecord );
  1010. HRESULT TriggerMaxMsgSizeEvent( IUnknown *pIUnknown, IMailMsgProperties *pIMsg, BOOL *pfShouldImposeLimit );
  1011. HRESULT TriggerStoreServerEvent(DWORD EventType);
  1012. HRESULT TriggerServerEvent(DWORD dwEventType, PVOID pvContext);
  1013. void SinkSmtpServerStartHintFunc(void);
  1014. void SinkSmtpServerStopHintFunc(void);
  1015. HRESULT SinkReadMetabaseDword(DWORD MetabaseId, DWORD * dwValue);
  1016. void WriteLog( LPMSG_TRACK_INFO pMsgTrackInfo,
  1017. IMailMsgProperties *pMsgProps,
  1018. LPEVENT_LOG_INFO pEventLogInfo,
  1019. LPSTR pszProtocolLog );
  1020. HRESULT TriggerLogEvent(
  1021. IN DWORD idMessage,
  1022. IN WORD idCategory,
  1023. IN WORD cSubstrings,
  1024. IN LPCSTR *rgszSubstrings,
  1025. IN WORD wType,
  1026. IN DWORD errCode,
  1027. IN WORD iDebugLevel,
  1028. IN LPCSTR szKey,
  1029. IN DWORD dwOptions,
  1030. IN DWORD iMessageString,
  1031. IN HMODULE hModule);
  1032. HRESULT ResetLogEvent(
  1033. IN DWORD idMessage,
  1034. IN LPCSTR szKey);
  1035. HRESULT HrTriggerGetAuxDomainInfoFlagsEvent(
  1036. IN LPCSTR pszDomainName,
  1037. OUT DWORD *pdwDomainInfoFlags);
  1038. HRESULT SinkReadMetabaseString(DWORD MetabaseId, char * Buffer, DWORD * BufferSize, BOOL fSecure);
  1039. HRESULT SinkReadMetabaseData(DWORD MetabaseId, BYTE *Buffer, DWORD * BufferSize);
  1040. BOOL GetCatInfo(MB& mb, AQConfigInfo& AQConfig);
  1041. IAdvQueueConfig * QueryAqConfigPtr (void) { return m_pIAdvQueueConfig;}
  1042. BOOL IsDropDirQuotaCheckingEnabled()
  1043. {
  1044. return ((GetDefaultRouteAction() & SMTP_DISABLE_DROP_QUOTA) ? FALSE : TRUE);
  1045. }
  1046. BOOL IsDropDirQuotaExceeded();
  1047. // Raid 174038
  1048. BOOL DisablePickupDotStuff(void) const {return m_fDisablePickupDotStuff;}
  1049. CTcpRegIpList *UpdateDnsServerInfo(DNS_SERVER_INFO *pDnsServerInfo);
  1050. CTcpRegIpList *GetDnsServerInfo(GUID *pGuid);
  1051. };
  1052. typedef SMTP_SERVER_INSTANCE *PSMTP_SERVER_INSTANCE;
  1053. //
  1054. // signatures
  1055. //
  1056. #define SMTP_INSTANCE_SIGNATURE 'uSMT'
  1057. #define SMTP_INSTANCE_SIGNATURE_FREE 'fSMT'
  1058. //
  1059. // externs
  1060. //
  1061. DWORD
  1062. InitializeInstances(
  1063. PSMTP_IIS_SERVICE pService
  1064. );
  1065. DWORD
  1066. ActivateSmtpEndpoints(
  1067. VOID
  1068. );
  1069. #endif // _SMTPINST_H_