Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Persist() [8/8]

void System.Security.AccessControl.NativeObjectSecurity.Persist ( string name,
SafeHandle handle,
AccessControlSections includeSections,
object exceptionContext )
inlineprivate

Definition at line 128 of file NativeObjectSecurity.cs.

129 {
130 WriteLock();
131 try
132 {
133 SecurityInfos securityInfos = (SecurityInfos)0;
134 SecurityIdentifier owner = null;
135 SecurityIdentifier group = null;
136 SystemAcl sacl = null;
137 DiscretionaryAcl dacl = null;
138 if ((includeSections & AccessControlSections.Owner) != 0 && _securityDescriptor.Owner != null)
139 {
140 securityInfos |= SecurityInfos.Owner;
142 }
143 if ((includeSections & AccessControlSections.Group) != 0 && _securityDescriptor.Group != null)
144 {
145 securityInfos |= SecurityInfos.Group;
147 }
148 if ((includeSections & AccessControlSections.Audit) != 0)
149 {
150 securityInfos |= SecurityInfos.SystemAcl;
151 sacl = ((!_securityDescriptor.IsSystemAclPresent || _securityDescriptor.SystemAcl == null || _securityDescriptor.SystemAcl.Count <= 0) ? null : _securityDescriptor.SystemAcl);
152 securityInfos = (SecurityInfos)(((_securityDescriptor.ControlFlags & ControlFlags.SystemAclProtected) == 0) ? ((int)securityInfos | (int)UnprotectedSystemAcl) : ((int)securityInfos | (int)ProtectedSystemAcl));
153 }
154 if ((includeSections & AccessControlSections.Access) != 0 && _securityDescriptor.IsDiscretionaryAclPresent)
155 {
156 securityInfos |= SecurityInfos.DiscretionaryAcl;
158 securityInfos = (SecurityInfos)(((_securityDescriptor.ControlFlags & ControlFlags.DiscretionaryAclProtected) == 0) ? ((int)securityInfos | (int)UnprotectedDiscretionaryAcl) : ((int)securityInfos | (int)ProtectedDiscretionaryAcl));
159 }
160 if (securityInfos == (SecurityInfos)0)
161 {
162 return;
163 }
164 int num = Win32.SetSecurityInfo(_resourceType, name, handle, securityInfos, owner, group, sacl, dacl);
165 if (num != 0)
166 {
167 Exception ex = null;
168 if (_exceptionFromErrorCode != null)
169 {
170 ex = _exceptionFromErrorCode(num, name, handle, exceptionContext);
171 }
172 if (ex == null)
173 {
174 ex = num switch
175 {
176 5 => new UnauthorizedAccessException(),
179 123 => new ArgumentException(System.SR.Argument_InvalidName, "name"),
180 6 => new NotSupportedException(System.SR.AccessControl_InvalidHandle),
181 2 => new FileNotFoundException(),
182 1350 => new NotSupportedException(System.SR.AccessControl_NoAssociatedSecurity),
184 };
185 }
186 throw ex;
187 }
188 base.OwnerModified = false;
189 base.GroupModified = false;
190 base.AccessRulesModified = false;
191 base.AuditRulesModified = false;
192 }
193 finally
194 {
195 WriteUnlock();
196 }
197 }
static string AccessControl_UnexpectedError
Definition SR.cs:42
static string AccessControl_InvalidOwner
Definition SR.cs:20
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string Argument_InvalidName
Definition SR.cs:20
static string AccessControl_InvalidHandle
Definition SR.cs:14
static string AccessControl_InvalidGroup
Definition SR.cs:22
static string AccessControl_NoAssociatedSecurity
Definition SR.cs:40
Definition SR.cs:7
readonly CommonSecurityDescriptor _securityDescriptor

References System.Security.AccessControl.NativeObjectSecurity._exceptionFromErrorCode, System.Security.AccessControl.NativeObjectSecurity._resourceType, System.Security.AccessControl.ObjectSecurity< T >._securityDescriptor, System.SR.AccessControl_InvalidGroup, System.SR.AccessControl_InvalidHandle, System.SR.AccessControl_InvalidOwner, System.SR.AccessControl_NoAssociatedSecurity, System.SR.AccessControl_UnexpectedError, System.SR.Argument_InvalidName, System.Security.AccessControl.CommonSecurityDescriptor.ControlFlags, System.Security.AccessControl.CommonSecurityDescriptor.DiscretionaryAcl, System.Security.AccessControl.DiscretionaryAcl.EveryOneFullAccessForNullDacl, System.SR.Format(), System.Security.AccessControl.CommonSecurityDescriptor.Group, System.handle, System.Security.AccessControl.CommonSecurityDescriptor.IsDiscretionaryAclPresent, System.Security.AccessControl.CommonSecurityDescriptor.Owner, System.Security.AccessControl.NativeObjectSecurity.ProtectedDiscretionaryAcl, System.Security.AccessControl.NativeObjectSecurity.ProtectedSystemAcl, System.Security.AccessControl.Win32.SetSecurityInfo(), System.Security.AccessControl.CommonSecurityDescriptor.SystemAcl, System.Security.AccessControl.NativeObjectSecurity.UnprotectedDiscretionaryAcl, System.Security.AccessControl.NativeObjectSecurity.UnprotectedSystemAcl, System.Security.AccessControl.ObjectSecurity< T >.WriteLock(), and System.Security.AccessControl.ObjectSecurity< T >.WriteUnlock().

Referenced by System.Security.AccessControl.NativeObjectSecurity.Persist(), System.Security.AccessControl.NativeObjectSecurity.Persist(), System.Security.AccessControl.NativeObjectSecurity.Persist(), and System.Security.AccessControl.NativeObjectSecurity.Persist().