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.

224 lines
5.0 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name :
  4. admacl.hxx
  5. Abstract:
  6. This header file declares Admin API Access Check API
  7. Author:
  8. Philippe Choquier 26-Nov-1996
  9. --*/
  10. #if !defined(_ADMACL_H)
  11. #define _ADMACL_H
  12. class CInitAdmacl
  13. {
  14. public:
  15. CInitAdmacl();
  16. ~CInitAdmacl();
  17. };
  18. extern CInitAdmacl g_cinitadmacl;
  19. #define AAC_GETALL (DWORD)-1
  20. #define AAC_ENUM_KEYS (DWORD)-2
  21. #define AAC_COPYKEY (DWORD)-3
  22. #define AAC_DELETEKEY (DWORD)-4
  23. #define ISPATHDELIM(a) ((a)=='/' || (a)=='\\')
  24. #define ISPATHDELIMW(a) ((a)==(WCHAR)'/' || (a)==(WCHAR)'\\')
  25. #define ADMINACL_NONINIT_SIGN 0x4b6d2dc9
  26. #define ADMINACL_INIT_SIGN 0x5a6d2dc9
  27. #define ADMINACL_FREED_SIGN 0x676d2dc9
  28. class CAdminAcl
  29. {
  30. public:
  31. CAdminAcl()
  32. {
  33. m_cRef = 1;
  34. m_wchPath[0] = '\0';
  35. m_dwAclRef = 0;
  36. m_pAcl = NULL;
  37. m_pMDCom = NULL;
  38. m_dwSignature = ADMINACL_NONINIT_SIGN;
  39. }
  40. ~CAdminAcl();
  41. DWORD AddRef();
  42. DWORD Release();
  43. LPWSTR GetPath() { return m_wchPath; }
  44. BOOL Init( IMDCOM*,
  45. LPVOID pvAdmin,
  46. METADATA_HANDLE hAdminHandle,
  47. LPCWSTR pszPath,
  48. LPBYTE pAcl,
  49. DWORD dwAclRef,
  50. PBOOL pbIsPathCorrect );
  51. LPBYTE GetAcl() { return m_pAcl; }
  52. METADATA_HANDLE GetAdminHandle() { return m_hAdminHandle; }
  53. LPVOID GetAdminContext() { return m_pvAdmin; }
  54. public:
  55. DWORD m_dwSignature;
  56. private:
  57. WCHAR m_wchPath[MAX_PATH];
  58. METADATA_HANDLE m_hAdminHandle;
  59. LPBYTE m_pAcl;
  60. DWORD m_dwAclRef;
  61. LPVOID m_pvAdmin;
  62. IMDCOM* m_pMDCom;
  63. volatile DWORD m_cRef;
  64. };
  65. #define MAX_CACHED_ADMIN_ACL 256
  66. class CAdminAclCache
  67. {
  68. private:
  69. // Disable usage (no implementation)
  70. CAdminAclCache(const CAdminAclCache&);
  71. void operator=(const CAdminAclCache&);
  72. public:
  73. CAdminAclCache();
  74. ~CAdminAclCache();
  75. STDMETHODIMP Init();
  76. STDMETHODIMP IsEnabled();
  77. STDMETHODIMP IsEmpty();
  78. STDMETHODIMP Disable();
  79. STDMETHODIMP Enable();
  80. STDMETHODIMP Flush();
  81. STDMETHODIMP Remove(LPVOID pvAdmin, METADATA_HANDLE hAdminHandle);
  82. STDMETHODIMP Find(LPVOID pvAdmin, METADATA_HANDLE hAdminHandle,
  83. LPCWSTR pszRelPath, CAdminAcl **ppAdminAcl);
  84. STDMETHODIMP Add(CAdminAcl *pAdminAcl);
  85. private:
  86. STDMETHODIMP _Find(LPVOID pvAdmin, METADATA_HANDLE hAdminHandle,
  87. LPCWSTR pszRelPath, CAdminAcl **ppAdminAcl,
  88. DWORD *pdwIndex);
  89. STDMETHODIMP _MoveFirst(DWORD i);
  90. STDMETHODIMP _InsertFirst(CAdminAcl *pAdminAcl, CAdminAcl **ppAdminAclToRelease);
  91. volatile LONG m_fEnabled;
  92. volatile DWORD m_cAdminAclCache;
  93. CAdminAcl *m_rgpAdminAclCache[MAX_CACHED_ADMIN_ACL];
  94. CReaderWriterLock3 m_Lock;
  95. };
  96. extern CAdminAclCache g_AclCache;
  97. class COpenHandle
  98. {
  99. public:
  100. COpenHandle()
  101. : m_pszPath( NULL )
  102. {}
  103. ~COpenHandle()
  104. {
  105. if( m_pszPath )
  106. {
  107. LocalFree(m_pszPath);
  108. }
  109. }
  110. LPWSTR GetPath() { return m_pszPath; }
  111. HRESULT Init(METADATA_HANDLE hAdminHandle,
  112. LPCWSTR pszPath,
  113. LPCWSTR pszParentPath );
  114. METADATA_HANDLE GetAdminHandle() { return m_hAdminHandle; }
  115. BOOL GetAcl(
  116. IMDCOM* pMDCom,
  117. LPCWSTR pszPath,
  118. LPBYTE* pAcl,
  119. LPDWORD pdwRef );
  120. BOOL CheckSubAcls(
  121. IMDCOM *pMDCom,
  122. LPCWSTR pszPath,
  123. LPBOOL pfIsAnyAcl );
  124. VOID AddRef() {InterlockedIncrement(&m_lRefCount);}
  125. VOID Release(PVOID pvAdmin);
  126. private:
  127. LPWSTR m_pszPath;
  128. METADATA_HANDLE m_hAdminHandle;
  129. long m_lRefCount;
  130. } ;
  131. BOOL
  132. AdminAclNotifySetOrDeleteProp(
  133. METADATA_HANDLE hMB,
  134. DWORD dwId
  135. );
  136. BOOL
  137. AdminAclAccessCheck(
  138. IMDCOM* pMDCom,
  139. LPVOID pvAdmin,
  140. METADATA_HANDLE hMB,
  141. LPCWSTR pszPath,
  142. DWORD dwId, // check for MD_ADMIN_ACL, must have special right to write them
  143. DWORD dwAccess, // METADATA_PERMISSION_*
  144. COpenHandle* pohHandle,
  145. LPBOOL pfEnableSecureAccess = NULL
  146. );
  147. BOOL
  148. AdminAclNotifyOpen(
  149. LPVOID pvAdmin,
  150. METADATA_HANDLE hMB,
  151. LPCWSTR pszPath,
  152. BOOL fIsNse
  153. );
  154. BOOL
  155. AdminAclNotifyClose(
  156. LPVOID pvAdmin,
  157. METADATA_HANDLE hMB
  158. );
  159. BOOL
  160. AdminAclFlushCache(
  161. );
  162. void
  163. AdminAclDisableAclCache();
  164. void
  165. AdminAclEnableAclCache();
  166. #endif