Commit Graph
38 Commits
Author SHA1 Message Date
Marek Safar c45375b4c8 Fix types signature 2012-07-27 12:25:43 +01: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 acf2873408 MutexAccessRule... previously entirely broken as it passed 0 for accessMask.
Now, accessMask matches the MutexRules passed in. The MutexRules enum is a bitmask
corresponding to Win32 ACE accessMasks and the two match.

I verified that accessMask corresponds directly to the MutexRules passed in the
constructor on Win32 using Reflection. It stands to reason, and it turns out to be
the case. System.Security.AccessControl is still mostly broken but this at least
corrects MutexAccessRule.
2012-07-01 18:46:10 -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
James Bellinger 4fb4aa1120 Implemented the .NET 4.0 generic versions of AccessRule and AuditRule.
Details worth being aware of, that aren't well documented in MS.NET:

(1) The Rights property is just a casted AccessMask.
I've checked this by testing with MS.NET -- if you use AccessRule<Test>
with an arbitrary struct Test { }, MS.NET has an InvalidCastException
on the Rights getter if you create with ObjectSecurity's factory method
(which is passed an int), and in the constructor if you use AccessRule's
constructor.

(2) The string constructor overloads call 'new NTAccount(identity)'.
What these methods do for AccessRule is not documented by MS.NET,
but this *is* documented for SemaphoreAccessRule, and my testing
with C# shows AccessRule does the same thing. So, I've implemented
this behavior to match.

I will submit a separate patch afterwards to make AuthorizationRule's
accept NTAccount, which is required for the string overloads to work.
Contrary to the MS.NET *documentation* (which Mono follows), AuthorizationRule
actually accepts NTAccount as well as (the documented) SecurityIdentifier.
I verified this by deriving a class from AuthorizationRule.
2012-06-30 13:21:46 -04:00
TalAloni 5ae8462066 Make sure a proper 'Not Implemented' exception is thrown instead of an 'Out of Range' exception. 2012-03-19 20:17:31 -03:00
Kenneth Bell df73c40c3a Fix bug 213 - interpret string identity in RegistryAccessRule constructor as account name.
Previously the string was treated as a SID in string form.  Note Mono can only convert well-known accounts to SID form.
2011-08-07 12:29:04 -07:00
Kenneth Bell f838a86122 Fix infinite loop parsing some SDDL strings
Attempting to parse ACLs containing flags would cause an infinite loop.
2011-08-07 12:29:04 -07: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
Marek Safar d84d7c7eb9 Remove no longer used BOOTSTRAP conditionals 2010-12-29 12:41:12 +00:00
Marek Safar bd05c6c836 Some .net 4.0 api compatibility fixes 2010-12-15 11:12:07 +00:00
Miguel de Icaza 3c39ac4586 Jumbo patch for NET_2_0, mscorlib is now clean
svn path=/trunk/mcs/; revision=145621
2009-11-06 22:23:59 +00:00
Zoltan Varga 6854adc9c7 2009-08-29 Zoltan Varga <[email protected]>
* ObjectSecurity_T.cs: New file, empty stub for new net 4.0 class.

svn path=/trunk/mcs/; revision=140928
2009-08-29 23:58:51 +00:00
Marek Safar cc9c53a109 Warnings cleanup
svn path=/trunk/mcs/; revision=111713
2008-08-27 15:40:13 +00:00
Andreas N 22240ad0a0 2008-07-02 Andreas Nahr <[email protected]>
* MutexAccessRule.cs:
	* MutexAuditRule.cs: Fix parameter names

svn path=/trunk/mcs/; revision=107103
2008-07-02 21:44:34 +00:00
Andreas N 774797f4d0 2008-04-02 Andreas Nahr <[email protected]>
* CompoundAce.cs: Fix parameter names

svn path=/trunk/mcs/; revision=99617
2008-04-02 07:43:42 +00:00
Atsushi Eno 001d97de25 2007-09-21 Atsushi Enomoto <[email protected]>
* AccessRule.cs AceEnumerator.cs AuditRule.cs AuthorizationRule.cs
	  AuthorizationRuleCollection.cs CommonAce.cs CommonAcl.cs
	  CommonObjectSecurity.cs CompoundAce.cs CryptoKeyAccessRule.cs
	  CryptoKeyAuditRule.cs CryptoKeySecurity.cs CustomAce.cs
	  DirectoryObjectSecurity.cs DirectorySecurity.cs
	  DiscretionaryAcl.cs EventWaitHandleAccessRule.cs
	  EventWaitHandleAuditRule.cs EventWaitHandleSecurity.cs
	  FileSecurity.cs FileSystemAccessRule.cs FileSystemAuditRule.cs
	  FileSystemSecurity.cs GenericAce.cs GenericAcl.cs KnownAce.cs
	  MutexAccessRule.cs MutexAuditRule.cs MutexSecurity.cs
	  NativeObjectSecurity.cs ObjectAccessRule.cs ObjectAce.cs
	  ObjectAuditRule.cs ObjectSecurity.cs QualifiedAce.cs
	  RawAcl.cs RegistryAccessRule.cs RegistryAuditRule.cs
	  RegistrySecurity.cs SystemAcl.cs :
	  they are not still functional, but being implemented.


svn path=/trunk/mcs/; revision=86129
2007-09-21 09:19:42 +00:00
Sebastien Pouliot f990319586 2006-10-31 Sebastien Pouliot <[email protected]>
* AccessRule.cs, AceEnumerator.cs, AuditRule.cs, 
	AuthorizationRuleCollection.cs, AuthorizationRule.cs, CommonAcl.cs,
	CommonObjectSecurity.cs, FileSystemSecurity.cs, GenericAce.cs,
	KnownAce.cs, NativeObjectSecurity.cs, ObjectSecurity.cs, 
	QualifiedAce.cs: Hide extraneous public empty .ctor.


svn path=/trunk/mcs/; revision=67199
2006-11-01 00:17:14 +00:00
Sebastien Pouliot 5e0563d728 2006-10-30 Sebastien Pouliot <[email protected]>
* PrivilegeNotHeldException.cs: Fix namespace.


svn path=/trunk/mcs/; revision=67152
2006-10-30 21:56:27 +00:00
Dick Porter e046a41d7d 2006-07-06 Dick Porter <[email protected]>
* corlib.dll.sources: Added
          System.Security.AccessControl/AccessControlModification.cs
          System.Security.AccessControl/AccessControlType.cs
          System.Security.AccessControl/AccessRule.cs
          System.Security.AccessControl/AceEnumerator.cs
          System.Security.AccessControl/AceFlags.cs
          System.Security.AccessControl/AceQualifier.cs
          System.Security.AccessControl/AceType.cs
          System.Security.AccessControl/AuditFlags.cs
          System.Security.AccessControl/AuditRule.cs
          System.Security.AccessControl/AuthorizationRule.cs
          System.Security.AccessControl/AuthorizationRuleCollection.cs
          System.Security.AccessControl/CommonAce.cs
          System.Security.AccessControl/CommonAcl.cs
          System.Security.AccessControl/CommonSecurityDescriptor.cs
          System.Security.AccessControl/CompoundAce.cs
          System.Security.AccessControl/CompoundAceType.cs
          System.Security.AccessControl/ControlFlags.cs
          System.Security.AccessControl/CryptoKeyAccessRule.cs
          System.Security.AccessControl/CryptoKeyAuditRule.cs
          System.Security.AccessControl/CryptoKeyRights.cs
          System.Security.AccessControl/CustomAce.cs
          System.Security.AccessControl/DirectoryObjectSecurity.cs
          System.Security.AccessControl/DiscretionaryAcl.cs
          System.Security.AccessControl/EventWaitHandleAccessRule.cs
          System.Security.AccessControl/EventWaitHandleAuditRule.cs
          System.Security.AccessControl/FileSecurity.cs
          System.Security.AccessControl/FileSystemAccessRule.cs
          System.Security.AccessControl/FileSystemAuditRule.cs
          System.Security.AccessControl/FileSystemRights.cs
          System.Security.AccessControl/FileSystemSecurity.cs
          System.Security.AccessControl/GenericAce.cs
          System.Security.AccessControl/GenericAcl.cs
          System.Security.AccessControl/GenericSecurityDescriptor.cs
          System.Security.AccessControl/InheritanceFlags.cs
          System.Security.AccessControl/KnownAce.cs
          System.Security.AccessControl/MutexAccessRule.cs
          System.Security.AccessControl/MutexAuditRule.cs
          System.Security.AccessControl/ObjectAccessRule.cs
          System.Security.AccessControl/ObjectAce.cs
          System.Security.AccessControl/ObjectAceFlags.cs
          System.Security.AccessControl/ObjectAuditRule.cs
          System.Security.AccessControl/PrivilegeNotHeldException.cs
          System.Security.AccessControl/PropagationFlags.cs
          System.Security.AccessControl/QualifiedAce.cs
          System.Security.AccessControl/RawAcl.cs
          System.Security.AccessControl/RawSecurityDescriptor.cs
          System.Security.AccessControl/RegistryAccessRule.cs
          System.Security.AccessControl/RegistryAuditRule.cs
          System.Security.AccessControl/RegistryRights.cs
          System.Security.AccessControl/RegistrySecurity.cs
          System.Security.AccessControl/ResourceType.cs
          System.Security.AccessControl/SecurityInfos.cs
          System.Security.AccessControl/SystemAcl.cs

2006-07-06  Dick Porter  <[email protected]>

        * System.dll.sources: Added
        System.Security.AccessControl/SemaphoreAccessRule.cs
        System.Security.AccessControl/SemaphoreAuditRule.cs


2006-07-06  Dick Porter  <[email protected]>

        * Completely stubbed the System.Security.AccessControl namespace
        for the 2.0 profile.




svn path=/trunk/mcs/; revision=62321
2006-07-06 15:35:13 +00:00
Dick Porter 8265935e1b 2005-12-23 Dick Porter <[email protected]>
* EventWaitHandle.cs: 
        * Mutex.cs: Implement OpenExisting

        * NativeEventCalls.cs: Add OpenEvent icall for OpenExisting in
        2.0.  Add a "created" boolean out parameter to CreateEvent icall.

        * ManualResetEvent.cs: 
        * AutoResetEvent.cs: Update CreateEvent icall signature (now has
        "created" boolean out parameter.)

2005-12-23  Dick Porter  <[email protected]>

        * Semaphore.cs: Implement OpenExisting

2005-12-23  Dick Porter  <[email protected]>

        * MutexRights.cs: New for 2.0 profile

2005-12-23  Dick Porter  <[email protected]>

        * SemaphoreRights.cs: Make the [Flags] enum more obvious

2005-12-23  Dick Porter  <[email protected]>

        * SemaphoreTest.cs: Enable another test

2005-12-23  Dick Porter  <[email protected]>

        * corlib.dll.sources: Added System.Security.AccessControl.MutexRights



svn path=/trunk/mcs/; revision=54801
2005-12-23 20:29:06 +00:00
Dick Porter f6ce484bf8 2005-12-17 Dick Porter <[email protected]>
* ThreadStartException.cs: 
        * EventWaitHandle.cs: 
        * EventResetMode.cs: 
        * AbandonedMutexException.cs: New for 2.0 profile

        * ThreadState.cs: 
        * Interlocked.cs: 
        * RegisteredWaitHandle.cs: 
        * Monitor.cs: 
        * ThreadPriority.cs: 
        * Mutex.cs: 
        * ManualResetEvent.cs: 
        * AutoResetEvent.cs: Updated for 2.0 profile

2005-12-17  Dick Porter  <[email protected]>

        * EventWaitHandleRights.cs: New for 2.0 profile

        * MutexSecurity.cs: 
        * EventWaitHandleSecurity.cs: 
        * CommonObjectSecurity.cs: 
        * NativeObjectSecurity.cs: 
        * ObjectSecurity.cs: New partial stub for 2.0 profile

2005-12-17  Dick Porter  <[email protected]>

        * corlib.dll.sources: Added in System.Security.AccessControl:
        CommonObjectSecurity.cs, EventWaitHandleRights.cs,
        EventWaitHandleSecurity.cs, ObjectSecurity.cs, MutexSecurity.cs,
        NativeObjectSecurity.cs.  Added in System.Threading:
        AbandonedMutexException.cs, EventResetMode.cs, EventWaitHandle.cs,
        ThreadStartException.cs



svn path=/trunk/mcs/; revision=54567
2005-12-17 18:17:58 +00:00
Sebastien Pouliot 7a037e0b59 2005-12-14 Sebastien Pouliot <[email protected]>
* AccessControlSections.cs: New (2.0). Enum required for DirectoryInfo
	* DirectorySecurity.cs: New (2.0). Partial stub for DirectoryInfo


svn path=/trunk/mcs/; revision=54392
2005-12-14 19:00:31 +00:00
Sebastien Pouliot 39188e9c6f 2005-04-22 Sebastien Pouliot <[email protected]>
* AccessControlActions.cs: Removed [ComVisible] and [Serializable] to
	match beta2.


svn path=/trunk/mcs/; revision=43465
2005-04-23 02:26:14 +00:00
Sebastien Pouliot 6cfedacdea 2005-01-10 Sebastien Pouliot <[email protected]>
* CryptoKeySecurity.cs: Class declaration to complete CspParameters 
	and CspKeyContainerInfo in System.Security.Cryptography.


svn path=/trunk/mcs/; revision=38665
2005-01-11 01:11:21 +00:00
Sebastien Pouliot fdb13aa520 2004-07-08 Sebastien Pouliot <[email protected]>
* AccessControlActions.cs: Fixed enum values. Added missing attributes.

svn path=/trunk/mcs/; revision=30891
2004-07-08 17:53:32 +00:00
Sebastien Pouliot 367427ab6f 2004-07-07 Sebastien Pouliot <[email protected]>
* AccessControlActions.cs: New enum in Fx 2.0. Required for new stuff
	in System.Security.Permissions. Will also "creates" the namespace for
	"corcompare".

svn path=/trunk/mcs/; revision=30849
2004-07-07 19:24:06 +00:00