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.

172 lines
4.5 KiB

  1. /*****************************************************************************/
  2. /* Copyright (c) 1999-2001 Microsoft Corporation, All Rights Reserved /
  3. /*****************************************************************************/
  4. /*
  5. * CSACL.h - header file for CSACL class.
  6. *
  7. * Created: 12-14-1997 by Sanjeev Surati
  8. * (based on classes from Windows NT Security by Nik Okuntseff)
  9. */
  10. #if !defined __CSACL_H__
  11. #define __CSACL_H__
  12. #include "AccessEntryList.h"
  13. enum SACL_Types
  14. {
  15. ENUM_SYSTEM_AUDIT_OBJECT_ACE_TYPE = 0,
  16. /********************************* type not yet supported under w2k ********************************************
  17. ENUM_SYSTEM_ALARM_OBJECT_ACE_TYPE,
  18. /**************************************************************************************************************/
  19. ENUM_SYSTEM_AUDIT_ACE_TYPE,
  20. /********************************* type not yet supported under w2k ********************************************
  21. ENUM_SYSTEM_ALARM_ACE_TYPE,
  22. /**************************************************************************************************************/
  23. // Keep this as the last entry in this enum:
  24. NUM_SACL_TYPES
  25. };
  26. #define SACLTYPE short
  27. //////////////////////////////////////////////////////////////////
  28. //
  29. // Class: CSACL
  30. //
  31. // Class encapsulates a Win32 SACL, by providing public methods
  32. // for manipulating System Auditing entries only.
  33. //
  34. //////////////////////////////////////////////////////////////////
  35. class CSACL
  36. {
  37. // Constructors and destructor
  38. public:
  39. CSACL();
  40. ~CSACL( void );
  41. DWORD Init(PACL pSACL);
  42. bool AddSACLEntry( PSID psid,
  43. SACLTYPE SaclType,
  44. DWORD dwAccessMask,
  45. BYTE bAceFlags,
  46. GUID *pguidObjGuid,
  47. GUID *pguidInhObjGuid );
  48. bool RemoveSACLEntry( CSid& sid, SACLTYPE SaclType, DWORD dwIndex = 0 );
  49. bool RemoveSACLEntry( CSid& sid, SACLTYPE SaclType, DWORD dwAccessMask, BYTE bAceFlags, GUID *pguidObjGuid, GUID *pguidInhObjGuid );
  50. bool RemoveSACLEntry( CSid& sid, SACLTYPE SaclType, BYTE bAceFlags, GUID *pguidObjGuid, GUID *pguidInhObjGuid );
  51. bool CopySACL ( CSACL & dacl );
  52. bool AppendSACL ( CSACL & dacl );
  53. bool IsEmpty();
  54. bool GetMergedACL(CAccessEntryList& a_aclIn);
  55. DWORD ConfigureSACL( PACL& pSACL );
  56. DWORD FillSACL( PACL pSACL );
  57. BOOL CalculateSACLSize( LPDWORD pdwSACLLength );
  58. // Override of functions of same name from CAccessEntry
  59. virtual bool Find( const CSid& sid, BYTE bACEType, BYTE bACEFlags, GUID *pguidObjGuid, GUID *pguidInhObjGuid, DWORD dwAccessMask, CAccessEntry& ace );
  60. virtual bool Find( PSID psid, BYTE bACEType, BYTE bACEFlags, GUID *pguidObjGuid, GUID *pguidInhObjGuid, DWORD dwAccessMask, CAccessEntry& ace );
  61. void Clear();
  62. void DumpSACL(LPCWSTR wstrFilename = NULL);
  63. private:
  64. CAccessEntryList* m_SACLSections; // at the moment, sacl's only have one section, so this is not an array as it is in DACL.CPP
  65. };
  66. inline bool CSACL::CopySACL ( CSACL& sacl )
  67. {
  68. bool fRet = true;
  69. if(m_SACLSections != NULL)
  70. {
  71. delete m_SACLSections;
  72. m_SACLSections = NULL;
  73. }
  74. try
  75. {
  76. m_SACLSections = new CAccessEntryList;
  77. }
  78. catch(...)
  79. {
  80. if(m_SACLSections != NULL)
  81. {
  82. delete m_SACLSections;
  83. m_SACLSections = NULL;
  84. }
  85. throw;
  86. }
  87. if(m_SACLSections != NULL)
  88. {
  89. fRet = m_SACLSections->Copy(*(sacl.m_SACLSections));
  90. }
  91. else
  92. {
  93. fRet = false;
  94. }
  95. return fRet;
  96. }
  97. inline bool CSACL::AppendSACL ( CSACL& sacl )
  98. {
  99. bool fRet = FALSE;
  100. if(m_SACLSections == NULL)
  101. {
  102. try
  103. {
  104. m_SACLSections = new CAccessEntryList;
  105. }
  106. catch(...)
  107. {
  108. if(m_SACLSections != NULL)
  109. {
  110. delete m_SACLSections;
  111. m_SACLSections = NULL;
  112. }
  113. throw;
  114. }
  115. }
  116. if(m_SACLSections != NULL)
  117. {
  118. fRet = m_SACLSections->AppendList(*(sacl.m_SACLSections));
  119. }
  120. else
  121. {
  122. fRet = false;
  123. }
  124. return fRet;
  125. }
  126. inline bool CSACL::IsEmpty()
  127. {
  128. bool fIsEmpty = true;
  129. if(m_SACLSections != NULL)
  130. {
  131. fIsEmpty = m_SACLSections->IsEmpty();
  132. }
  133. return fIsEmpty;
  134. }
  135. #endif // __CAccessEntry_H__