Commit Graph
19 Commits
Author SHA1 Message Date
Alexander Köplinger b0032294da [Test] Cleaned up how a bunch of tests were ignored
Previously, many tests just had a return statement when the test shouldn't
be executed (e.g. Unix-only). This made it look like the test was successful
when in fact it wasn't executed at all.
Assert.Ignore() is now used instead to correctly exclude those tests.
2014-02-23 19:44:21 +01:00
Marek Safar afa79435aa Update for mobile profile 2013-02-07 16:34:21 +01:00
James Bellinger 2bcf31d55b This version of CommonObjectSecurityTest should not use AccessRule<T> or AuditRule<T>
(just included simple specializations accomplishing the same).
2012-07-09 10:03:02 -04:00
James Bellinger dcb1fa2e31 Fix ObjectSecurityTest on .NET 2.0. The test no longer uses AccessRule<T> and AuditRule<T>. 2012-07-08 14:33:39 -04:00
James Bellinger c577dd4bb4 RegistrySecurity now working! 2012-07-07 18:45:26 -04:00
James Bellinger c6f901c2cf Mutexes and event wait handles now work, with tests included. Fixed the exception on failure for MutexSecurity. 2012-07-07 18:45:26 -04:00
James Bellinger 9322e0d16b ACLs now work on Windows. Tests all the way up to DirectorySecurityTest and FileSecurityTest.
NativeObjectSecurity is implemented.
I've done it in such a way that, for OSes that do not have a unified API for all ACLs,
overrides can be done in subclasses such as FileSystemSecurity without trouble.

ObjectSecurity, CommonObjectSecurity, and DirectoryObjectSecurity all implemented.
MutexSecurity, PipeSecurity, etc. all just add type specialization and nothing else. Implemented all of these as well.

Access and Audit rules now correctly use NTAccount in their string overloads (see unit tests).
The constructors all provide correct AccessMasks now. In other words, these classes are all now un-broken/no longer stubs.

More unit tests for CommonSecurityDescriptor and fixes to pass them.
A few had checks that were redundant (implemented by (Authorization|Audit|Access)Rule) as well. These have been removed.
The Allow Everyone Full Access default for null DiscretionaryAcls in CommonSecurityDescriptor is, I think,
properly implemented. This required some changes to GenericSecurityDescriptor as well, but now Mono matches
MS.NET on GetSddl/GetBinaryForm for null DiscretionaryAcl including roundtrip.

What's still missing:
(1) CommonAcl's RemoveAccess/RemoveAudit. RemoveAll and RemoveSpecific work so it's not a big issue.
(2) CommonAcl merging will not yet try to merge a CommonAce together with an ObjectAce.
(3) The various *Security constructors. Get/SetAccessControl work on files and directories.
However, you still have to create and then set. I am not too familiar with Mono runtime internal
calls, but to someone who is: If the SECURITY_ATTRIBUTES parameter to Create*'s lpSecurityDescriptor
pointed to the output of GenericSecurityDescriptor's GetBinaryForm, that would be a complete
implementation.
2012-07-07 18:45:06 -04:00
James Bellinger 5817dada36 CommonSecurityDescriptor! 2012-07-07 18:45:06 -04:00
James Bellinger 3a7601b97c Implemented SystemAcl. Common shared functionality moved to CommonAcl. Only missing implementation now is RemoveAccess/RemoveAudit.
Unit tests included - for SystemAcl they are based on DiscretionaryAcl's mostly,
with one extra and one somewhat changed since AuditFlags merge together unlike Allow/Deny.

Anyway, it should be practical to implement CommonSecurityDescriptor and friends with these classes working.
2012-07-03 15:40:01 -04:00
James Bellinger 2d415e7a8f Implemented all of DiscretionaryAcl except for RemoveAccess. Unit tests are included.
Also fixed:
CommonAcl's merging now filters out AceFlags.InheritedFlags when !IsContainer.
For matching AccessMask, CommonAcl will now correctly merge ContainerInherit and ObjectInherit.
GenericAcl's SyncRoot is now virtual as per spec.
SecurityIdentifier.CompareTo throws ArgumentNullException, not NullReferenceException, on null parameter.

Miscellaneous unit tests:
Verify that RawAcl throws for negative capacity.
2012-07-03 13:56:55 -04:00
James Bellinger 0cc233ea17 Bug fix: Merging occurs after sorting ACE groups by SecurityIdentifier not before. Added a unit test for this behavior.
Also, fixed the namespace for the ObjectAce unit test.
2012-07-02 23:35:14 -04:00
James Bellinger 6cfe403fda CommonAcl is now essentially fully functional. Its descendants DiscretionaryAcl
and SystemAcl need work, but CommonAcl can be manipulated using RawAcls nicely
now and will test canonicity, merge ACEs, remove meaningless ACEs, sort explicit
deny/allow ACEs by SecurityIdentifier... all the nice things CommonAcl is supposed
to do.

Anyway, this patch... Off the top of my head...
Fixed CommonAce and ObjectAce deserialization/roundtripping with opaque data.
Fixed ObjectAce having the wrong BinaryLength depending on ObjectAceFlags.
GenericAce had two protected static SDDL methods which should be internal.

Added some unit tests for the above. One of the tests compares the binary
output with a blob I produced using the *same unit test* on MS.NET (with a
File.WriteAllText creating the byte array to paste in, naturally), and
happily, it produces identical binary output. Very nice.
2012-07-02 23:19:27 -04:00
James Bellinger 95db8e694e SecurityIdentifier's CompareTo now works like MS.Net. CommonAcl is supposed to sort groupings of canonical ACEs using SecurityIdentifier's CompareTo, so this was important to do.
I determined the behavior of CompareTo by first writing unit tests for
CommonAcl (instantiated as DiscretionaryAcl but using RawAcl instead of
DiscretionaryAcl methods to do the manipulation to keep DiscretionaryAcl
out of the loop). I developed and ran these unit tests on MS.NET using
MonoDevelop...

Anyway, CompareTo appears to compare authority, then the *number* of
subauthorities, and lastly the subauthorities. I'd be curious if there
is more detail, but so far this seems to cover it. It's definitely
*not* just a comparison of the string.

This patch also modifies CommonAcl to take advantage of this new sorting,
so now it should sort groups of explicit ACEs (access deny, access allow)
in canonical ACLs correctly.

With that down, I've got two unit tests that still fail on Mono.
2012-07-02 23:18:25 -04:00
James Bellinger bcad1d9688 Implemented much of CommonAcl.cs
Some tests still fail because sorting is not implemented yet.
I'll need to alter SecurityIdentifier CompareTo.
2012-07-02 23:18:24 -04:00
James Bellinger 188b3b9af6 Added a unit test for the bug this is fixing -- previously the constructor just crashed, always.
So, this constructs with valid MutexAccessRights, and also makes sure that the rights are correct.
2012-07-01 19:06:24 -04:00
Marek Safar 6f50e88ed1 Merge pull request #363 from JamesB7/system-security2
Implemented the .NET 4.0 generic versions of AccessRule and AuditRule.
2012-07-01 09:05:58 -07:00
James Bellinger a299db4b1e Added unit test.
Also added constructors to ObjectSecurity<T>.
It's supposed to have them (they just pass to NativeObjectSecurity),
but the only user in Mono is MemoryMappedFileSecurity so this is
just for completeness's sake. Also, this lets the test depend on neither
System.Core nor internal methods.
2012-07-01 11:15:59 -04:00
James Bellinger e83dc68dbf AuthorizationRule now accepts NTAccount like it should. Provided a unit test.
Many derived classes of AuthorizationRule have string overloads which pass
'new NTAccount (identity)'. The exception docs state "can be cast as a
SecurityIdentifier" not "is a SecurityIdentifier". Anyway, this fixes all the
string constructors in System.Security.AccessControl.

Also, I added checking for inheritanceFlags and propagationFlags parameters.

While building the unit test, I found accessMask == 0 throws ArgumentException,
not ArgumentOutOfRangeException, on MS.NET 4.0 (contrary to docs). So,
I've made this match.
2012-07-01 09:17:05 -04:00
Kenneth Bell 6cb0994257 Implement RawSecurityDescriptor.
* Marshals to/from SDDL and binary form.

 * Supports 'Common' ACEs and 'Object' ACEs
2011-01-26 18:00:29 -05:00