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.

129 lines
3.6 KiB

  1. /*****************************************************************************/
  2. /* Copyright (c) 1999-2001 Microsoft Corporation, All Rights Reserved /
  3. /*****************************************************************************/
  4. /*
  5. * CDACL.h - header file for CAccessEntry 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 __CDACL_H__
  11. #define __CDACL_H__
  12. enum DACL_Types
  13. {
  14. ENUM_ACCESS_DENIED_OBJECT_ACE_TYPE = 0,
  15. ENUM_ACCESS_DENIED_ACE_TYPE,
  16. ENUM_ACCESS_ALLOWED_OBJECT_ACE_TYPE,
  17. ENUM_ACCESS_ALLOWED_COMPOUND_ACE_TYPE,
  18. ENUM_ACCESS_ALLOWED_ACE_TYPE,
  19. ENUM_INH_ACCESS_DENIED_OBJECT_ACE_TYPE,
  20. ENUM_INH_ACCESS_DENIED_ACE_TYPE,
  21. ENUM_INH_ACCESS_ALLOWED_OBJECT_ACE_TYPE,
  22. ENUM_INH_ACCESS_ALLOWED_COMPOUND_ACE_TYPE,
  23. ENUM_INH_ACCESS_ALLOWED_ACE_TYPE,
  24. // Keep this the last entry
  25. NUM_DACL_TYPES
  26. };
  27. #define DACLTYPE short
  28. #define STATUS_EMPTY_DACL 0x10000000
  29. #define STATUS_NULL_DACL 0x20000000
  30. //////////////////////////////////////////////////////////////////
  31. //
  32. // Class: CDACL
  33. //
  34. // Class encapsulates a Win32 DACL, by providing public methods
  35. // for manipulating Access Allowed/Denied entries only.
  36. //
  37. //////////////////////////////////////////////////////////////////
  38. class CDACL
  39. {
  40. // Constructors and destructor
  41. public:
  42. CDACL();
  43. ~CDACL( void );
  44. DWORD Init(PACL pDACL);
  45. bool AddDACLEntry( PSID psid,
  46. DACLTYPE DaclType,
  47. DWORD dwAccessMask,
  48. BYTE bAceFlags,
  49. GUID *pguidObjGuid,
  50. GUID *pguidInhObjGuid );
  51. bool RemoveDACLEntry( CSid& sid, DACLTYPE DaclType, DWORD dwIndex = 0 );
  52. bool RemoveDACLEntry( CSid& sid, DACLTYPE DaclType, DWORD dwAccessMask, BYTE bAceFlags, GUID *pguidObjGuid, GUID *pguidInhObjGuid );
  53. bool RemoveDACLEntry( CSid& sid, DACLTYPE DaclType, BYTE bAceFlags, GUID *pguidObjGuid, GUID *pguidInhObjGuid );
  54. bool CopyDACL ( CDACL & dacl );
  55. bool AppendDACL ( CDACL & dacl );
  56. void Clear();
  57. bool CreateNullDACL();
  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. DWORD ConfigureDACL( PACL& pDacl );
  62. BOOL CalculateDACLSize( LPDWORD pdwDaclLength );
  63. DWORD FillDACL( PACL pDacl );
  64. bool IsNULLDACL();
  65. bool IsEmpty();
  66. // Virtual function for returning all access value (default is GENERIC_ALL)
  67. virtual DWORD AllAccessMask();
  68. bool GetMergedACL(CAccessEntryList& a_aclIn);
  69. void DumpDACL(LPCWSTR wstrFilename = NULL);
  70. private:
  71. CAccessEntryList* m_rgDACLSections[NUM_DACL_TYPES];
  72. // Helper function for splitting aces by their cononical types
  73. bool SplitIntoCanonicalSections(CAccessEntryList& a_aclIn);
  74. // Helper to undo the damage done from the previous function!
  75. bool ReassembleFromCanonicalSections(CAccessEntryList& a_aclIn);
  76. // And for a real helper, here is one that takes a dacl that
  77. // might be in any fubar order and creates it afresh!
  78. bool PutInNT5CanonicalOrder();
  79. };
  80. #endif // __CAccessEntry_H__