00001
00002
00003 #ifndef _HEADER_security
00004 #define _HEADER_security
00005
00006 #define SEC_MASK_GENERIC ( 0xF0000000 )
00007 #define SEC_MASK_FLAGS ( 0x0F000000 )
00008 #define SEC_MASK_STANDARD ( 0x00FF0000 )
00009 #define SEC_MASK_SPECIFIC ( 0x0000FFFF )
00010 #define SEC_GENERIC_ALL ( 0x10000000 )
00011 #define SEC_GENERIC_EXECUTE ( 0x20000000 )
00012 #define SEC_GENERIC_WRITE ( 0x40000000 )
00013 #define SEC_GENERIC_READ ( 0x80000000 )
00014 #define SEC_FLAG_SYSTEM_SECURITY ( 0x01000000 )
00015 #define SEC_FLAG_MAXIMUM_ALLOWED ( 0x02000000 )
00016 #define SEC_STD_DELETE ( 0x00010000 )
00017 #define SEC_STD_READ_CONTROL ( 0x00020000 )
00018 #define SEC_STD_WRITE_DAC ( 0x00040000 )
00019 #define SEC_STD_WRITE_OWNER ( 0x00080000 )
00020 #define SEC_STD_SYNCHRONIZE ( 0x00100000 )
00021 #define SEC_STD_REQUIRED ( 0x000F0000 )
00022 #define SEC_STD_ALL ( 0x001F0000 )
00023 #define SEC_FILE_READ_DATA ( 0x00000001 )
00024 #define SEC_FILE_WRITE_DATA ( 0x00000002 )
00025 #define SEC_FILE_APPEND_DATA ( 0x00000004 )
00026 #define SEC_FILE_READ_EA ( 0x00000008 )
00027 #define SEC_FILE_WRITE_EA ( 0x00000010 )
00028 #define SEC_FILE_EXECUTE ( 0x00000020 )
00029 #define SEC_FILE_READ_ATTRIBUTE ( 0x00000080 )
00030 #define SEC_FILE_WRITE_ATTRIBUTE ( 0x00000100 )
00031 #define SEC_FILE_ALL ( 0x000001ff )
00032 #define SEC_DIR_LIST ( 0x00000001 )
00033 #define SEC_DIR_ADD_FILE ( 0x00000002 )
00034 #define SEC_DIR_ADD_SUBDIR ( 0x00000004 )
00035 #define SEC_DIR_READ_EA ( 0x00000008 )
00036 #define SEC_DIR_WRITE_EA ( 0x00000010 )
00037 #define SEC_DIR_TRAVERSE ( 0x00000020 )
00038 #define SEC_DIR_DELETE_CHILD ( 0x00000040 )
00039 #define SEC_DIR_READ_ATTRIBUTE ( 0x00000080 )
00040 #define SEC_DIR_WRITE_ATTRIBUTE ( 0x00000100 )
00041 #define SEC_REG_QUERY_VALUE ( 0x00000001 )
00042 #define SEC_REG_SET_VALUE ( 0x00000002 )
00043 #define SEC_REG_CREATE_SUBKEY ( 0x00000004 )
00044 #define SEC_REG_ENUM_SUBKEYS ( 0x00000008 )
00045 #define SEC_REG_NOTIFY ( 0x00000010 )
00046 #define SEC_REG_CREATE_LINK ( 0x00000020 )
00047 #define SEC_ADS_CREATE_CHILD ( 0x00000001 )
00048 #define SEC_ADS_DELETE_CHILD ( 0x00000002 )
00049 #define SEC_ADS_LIST ( 0x00000004 )
00050 #define SEC_ADS_SELF_WRITE ( 0x00000008 )
00051 #define SEC_ADS_READ_PROP ( 0x00000010 )
00052 #define SEC_ADS_WRITE_PROP ( 0x00000020 )
00053 #define SEC_ADS_DELETE_TREE ( 0x00000040 )
00054 #define SEC_ADS_LIST_OBJECT ( 0x00000080 )
00055 #define SEC_ADS_CONTROL_ACCESS ( 0x00000100 )
00056 #define SEC_RIGHTS_FILE_READ ( SEC_STD_READ_CONTROL|SEC_STD_SYNCHRONIZE|SEC_FILE_READ_DATA|SEC_FILE_READ_ATTRIBUTE|SEC_FILE_READ_EA )
00057 #define SEC_RIGHTS_FILE_WRITE ( SEC_STD_READ_CONTROL|SEC_STD_SYNCHRONIZE|SEC_FILE_WRITE_DATA|SEC_FILE_WRITE_ATTRIBUTE|SEC_FILE_WRITE_EA|SEC_FILE_APPEND_DATA )
00058 #define SEC_RIGHTS_FILE_EXECUTE ( SEC_STD_SYNCHRONIZE|SEC_STD_READ_CONTROL|SEC_FILE_READ_ATTRIBUTE|SEC_FILE_EXECUTE )
00059 #define SEC_RIGHTS_FILE_ALL ( SEC_STD_ALL|SEC_FILE_ALL )
00060 #define SEC_RIGHTS_DIR_READ ( SEC_RIGHTS_FILE_READ )
00061 #define SEC_RIGHTS_DIR_WRITE ( SEC_RIGHTS_FILE_WRITE )
00062 #define SEC_RIGHTS_DIR_EXECUTE ( SEC_RIGHTS_FILE_EXECUTE )
00063 #define SEC_RIGHTS_DIR_ALL ( SEC_RIGHTS_FILE_ALL )
00064 #define SID_NULL ( "S-1-0-0" )
00065 #define SID_WORLD_DOMAIN ( "S-1-1" )
00066 #define SID_WORLD ( "S-1-1-0" )
00067 #define SID_CREATOR_OWNER_DOMAIN ( "S-1-3" )
00068 #define SID_CREATOR_OWNER ( "S-1-3-0" )
00069 #define SID_CREATOR_GROUP ( "S-1-3-1" )
00070 #define SID_NT_AUTHORITY ( "S-1-5" )
00071 #define SID_NT_DIALUP ( "S-1-5-1" )
00072 #define SID_NT_NETWORK ( "S-1-5-2" )
00073 #define SID_NT_BATCH ( "S-1-5-3" )
00074 #define SID_NT_INTERACTIVE ( "S-1-5-4" )
00075 #define SID_NT_SERVICE ( "S-1-5-6" )
00076 #define SID_NT_ANONYMOUS ( "S-1-5-7" )
00077 #define SID_NT_PROXY ( "S-1-5-8" )
00078 #define SID_NT_ENTERPRISE_DCS ( "S-1-5-9" )
00079 #define SID_NT_SELF ( "S-1-5-10" )
00080 #define SID_NT_AUTHENTICATED_USERS ( "S-1-5-11" )
00081 #define SID_NT_RESTRICTED ( "S-1-5-12" )
00082 #define SID_NT_TERMINAL_SERVER_USERS ( "S-1-5-13" )
00083 #define SID_NT_REMOTE_INTERACTIVE ( "S-1-5-14" )
00084 #define SID_NT_THIS_ORGANISATION ( "S-1-5-15" )
00085 #define SID_NT_SYSTEM ( "S-1-5-18" )
00086 #define SID_NT_LOCAL_SERVICE ( "S-1-5-19" )
00087 #define SID_NT_NETWORK_SERVICE ( "S-1-5-20" )
00088 #define SID_BUILTIN ( "S-1-5-32" )
00089 #define SID_BUILTIN_ADMINISTRATORS ( "S-1-5-32-544" )
00090 #define SID_BUILTIN_USERS ( "S-1-5-32-545" )
00091 #define SID_BUILTIN_GUESTS ( "S-1-5-32-546" )
00092 #define SID_BUILTIN_POWER_USERS ( "S-1-5-32-547" )
00093 #define SID_BUILTIN_ACCOUNT_OPERATORS ( "S-1-5-32-548" )
00094 #define SID_BUILTIN_SERVER_OPERATORS ( "S-1-5-32-549" )
00095 #define SID_BUILTIN_PRINT_OPERATORS ( "S-1-5-32-550" )
00096 #define SID_BUILTIN_BACKUP_OPERATORS ( "S-1-5-32-551" )
00097 #define SID_BUILTIN_REPLICATOR ( "S-1-5-32-552" )
00098 #define SID_BUILTIN_RAS_SERVERS ( "S-1-5-32-553" )
00099 #define SID_BUILTIN_PREW2K ( "S-1-5-32-554" )
00100 #define DOMAIN_RID_LOGON ( 9 )
00101 #define DOMAIN_RID_ADMINISTRATOR ( 500 )
00102 #define DOMAIN_RID_GUEST ( 501 )
00103 #define DOMAIN_RID_ADMINS ( 512 )
00104 #define DOMAIN_RID_USERS ( 513 )
00105 #define DOMAIN_RID_DCS ( 516 )
00106 #define DOMAIN_RID_CERT_ADMINS ( 517 )
00107 #define DOMAIN_RID_SCHEMA_ADMINS ( 518 )
00108 #define DOMAIN_RID_ENTERPRISE_ADMINS ( 519 )
00109 #define NT4_ACL_REVISION ( SECURITY_ACL_REVISION_NT4 )
00110 #define SD_REVISION ( SECURITY_DESCRIPTOR_REVISION_1 )
00111 enum sec_privilege {
00112 SEC_PRIV_SECURITY=1,
00113 SEC_PRIV_BACKUP=2,
00114 SEC_PRIV_RESTORE=3,
00115 SEC_PRIV_SYSTEMTIME=4,
00116 SEC_PRIV_SHUTDOWN=5,
00117 SEC_PRIV_REMOTE_SHUTDOWN=6,
00118 SEC_PRIV_TAKE_OWNERSHIP=7,
00119 SEC_PRIV_DEBUG=8,
00120 SEC_PRIV_SYSTEM_ENVIRONMENT=9,
00121 SEC_PRIV_SYSTEM_PROFILE=10,
00122 SEC_PRIV_PROFILE_SINGLE_PROCESS=11,
00123 SEC_PRIV_INCREASE_BASE_PRIORITY=12,
00124 SEC_PRIV_LOAD_DRIVER=13,
00125 SEC_PRIV_CREATE_PAGEFILE=14,
00126 SEC_PRIV_INCREASE_QUOTA=15,
00127 SEC_PRIV_CHANGE_NOTIFY=16,
00128 SEC_PRIV_UNDOCK=17,
00129 SEC_PRIV_MANAGE_VOLUME=18,
00130 SEC_PRIV_IMPERSONATE=19,
00131 SEC_PRIV_CREATE_GLOBAL=20,
00132 SEC_PRIV_ENABLE_DELEGATION=21,
00133 SEC_PRIV_INTERACTIVE_LOGON=22,
00134 SEC_PRIV_NETWORK_LOGON=23,
00135 SEC_PRIV_REMOTE_INTERACTIVE_LOGON=24
00136 };
00137
00138
00139 #define SEC_ACE_FLAG_OBJECT_INHERIT ( 0x01 )
00140 #define SEC_ACE_FLAG_CONTAINER_INHERIT ( 0x02 )
00141 #define SEC_ACE_FLAG_NO_PROPAGATE_INHERIT ( 0x04 )
00142 #define SEC_ACE_FLAG_INHERIT_ONLY ( 0x08 )
00143 #define SEC_ACE_FLAG_INHERITED_ACE ( 0x10 )
00144 #define SEC_ACE_FLAG_VALID_INHERIT ( 0x0f )
00145 #define SEC_ACE_FLAG_SUCCESSFUL_ACCESS ( 0x40 )
00146 #define SEC_ACE_FLAG_FAILED_ACCESS ( 0x80 )
00147
00148 enum security_ace_type {
00149 SEC_ACE_TYPE_ACCESS_ALLOWED=0,
00150 SEC_ACE_TYPE_ACCESS_DENIED=1,
00151 SEC_ACE_TYPE_SYSTEM_AUDIT=2,
00152 SEC_ACE_TYPE_SYSTEM_ALARM=3,
00153 SEC_ACE_TYPE_ALLOWED_COMPOUND=4,
00154 SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT=5,
00155 SEC_ACE_TYPE_ACCESS_DENIED_OBJECT=6,
00156 SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT=7,
00157 SEC_ACE_TYPE_SYSTEM_ALARM_OBJECT=8
00158 };
00159
00160
00161 #define SEC_ACE_OBJECT_TYPE_PRESENT ( 0x00000001 )
00162 #define SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT ( 0x00000002 )
00163
00164 union security_ace_object_type {
00165 struct GUID type;
00166 };
00167
00168 union security_ace_object_inherited_type {
00169 struct GUID inherited_type;
00170 };
00171
00172 struct security_ace_object {
00173 uint32_t flags;
00174 union security_ace_object_type type;
00175 union security_ace_object_inherited_type inherited_type;
00176 };
00177
00178 union security_ace_object_ctr {
00179 struct security_ace_object object;
00180 };
00181
00182 struct security_ace {
00183 enum security_ace_type type;
00184 uint8_t flags;
00185 uint16_t size;
00186 uint32_t access_mask;
00187 union security_ace_object_ctr object;
00188 struct dom_sid trustee;
00189 };
00190
00191 enum security_acl_revision {
00192 SECURITY_ACL_REVISION_NT4=2,
00193 SECURITY_ACL_REVISION_ADS=4
00194 };
00195
00196 struct security_acl {
00197 enum security_acl_revision revision;
00198 uint16_t size;
00199 uint32_t num_aces;
00200 struct security_ace *aces;
00201 };
00202
00203 enum security_descriptor_revision {
00204 SECURITY_DESCRIPTOR_REVISION_1=1
00205 };
00206
00207
00208 #define SEC_DESC_OWNER_DEFAULTED ( 0x0001 )
00209 #define SEC_DESC_GROUP_DEFAULTED ( 0x0002 )
00210 #define SEC_DESC_DACL_PRESENT ( 0x0004 )
00211 #define SEC_DESC_DACL_DEFAULTED ( 0x0008 )
00212 #define SEC_DESC_SACL_PRESENT ( 0x0010 )
00213 #define SEC_DESC_SACL_DEFAULTED ( 0x0020 )
00214 #define SEC_DESC_DACL_TRUSTED ( 0x0040 )
00215 #define SEC_DESC_SERVER_SECURITY ( 0x0080 )
00216 #define SEC_DESC_DACL_AUTO_INHERIT_REQ ( 0x0100 )
00217 #define SEC_DESC_SACL_AUTO_INHERIT_REQ ( 0x0200 )
00218 #define SEC_DESC_DACL_AUTO_INHERITED ( 0x0400 )
00219 #define SEC_DESC_SACL_AUTO_INHERITED ( 0x0800 )
00220 #define SEC_DESC_DACL_PROTECTED ( 0x1000 )
00221 #define SEC_DESC_SACL_PROTECTED ( 0x2000 )
00222 #define SEC_DESC_RM_CONTROL_VALID ( 0x4000 )
00223 #define SEC_DESC_SELF_RELATIVE ( 0x8000 )
00224
00225 struct security_descriptor {
00226 enum security_descriptor_revision revision;
00227 uint16_t type;
00228 struct dom_sid *owner_sid;
00229 struct dom_sid *group_sid;
00230 struct security_acl *sacl;
00231 struct security_acl *dacl;
00232 };
00233
00234 struct sec_desc_buf {
00235 uint32_t sd_size;
00236 struct security_descriptor *sd;
00237 };
00238
00239 struct security_token {
00240 struct dom_sid *user_sid;
00241 struct dom_sid *group_sid;
00242 uint32_t num_sids;
00243 struct dom_sid **sids;
00244 uint64_t privilege_mask;
00245 };
00246
00247
00248 #define SECINFO_OWNER ( 0x00000001 )
00249 #define SECINFO_GROUP ( 0x00000002 )
00250 #define SECINFO_DACL ( 0x00000004 )
00251 #define SECINFO_SACL ( 0x00000008 )
00252
00253 #endif