This rewrite fixes three bugs:
1) Fixes the case where AllDirectories is specified and searchPattern
is anything other than '*'. Now, every directory is searched
recursively, not just those which match the pattern.
2) Fully solves the issue that commit e09e64b tried to fix. Now
the check for hidden files occurs for every file, rather than
only the first.
3) Error handling is now performed at calls to both FindFirst and
FindNext, not just FindFirst.
The loop is happening between these calls:
https://github.com/mono/mono/blob/92d8961e0b244429d4d82176f4b33c8a4b3b064c/mcs/class/corlib/System.IO/Path.cs#L298
https://github.com/mono/mono/blob/3c39ac4586b4470703fb4af0208b5baf1de70e43/mcs/class/corlib/System.Security.Permissions/FileIOPermission.cs#L157
https://github.com/mono/mono/blob/9322e0d16b0edc054947279af34d3c7afb286c89/mcs/class/corlib/System.IO/Directory.cs#L248
Stack trace as follows:
The requested operation caused a stack overflow. at (wrapper managed-to-native) System.IO.MonoIO:GetCurrentDirectory (System.IO.MonoIOError&)
at System.IO.Directory.GetCurrentDirectory () [0x00000] in <filename unknown>:0
at System.IO.Path.WindowsDriveAdjustment (System.String path) [0x00000] in <filename unknown>:0
at System.IO.Path.InsecureGetFullPath (System.String path) [0x00000] in <filename unknown>:0
at System.Security.Permissions.FileIOPermission.AddPathInternal (FileIOPermissionAccess access, System.String path) [0x00000] in <filename unknown>:0
at System.Security.Permissions.FileIOPermission.AddPathList (FileIOPermissionAccess access, System.String path) [0x00000] in <filename unknown>:0
at System.Security.Permissions.FileIOPermission..ctor (FileIOPermissionAccess access, System.String path) [0x00000] in <filename unknown>:0
at System.IO.Directory.GetCurrentDirectory () [0x00000] in <filename unknown>:0
at System.IO.Path.WindowsDriveAdjustment (System.String path) [0x00000] in <filename unknown>:0
at System.IO.Path.InsecureGetFullPath (System.String path) [0x00000] in <filename unknown>:0
at System.Security.Permissions.FileIOPermission.AddPathInternal (FileIOPermissionAccess access, System.String path) [0x00000] in <filename unknown>:0
at System.Security.Permissions.FileIOPermission.AddPathList (FileIOPermissionAccess access, System.String path) [0x00000] in <filename unknown>:0
at System.Security.Permissions.FileIOPermission..ctor (FileIOPermissionAccess access, System.String path) [0x00000] in <filename unknown>:0
at System.IO.Directory.GetCurrentDirectory () [0x00000] in <filename unknown>:0
at System.IO.Path.WindowsDriveAdjustment (System.String path) [0x00000] in <filename unknown>:0
at System.IO.Path.InsecureGetFullPath (System.String path) [0x00000] in <filename unknown>:0
...Snip...
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.
* Directory.cs (ValidateDirectoryListing): Removing an unnecessary
Path.Combine call. Part of the fix for bug #580090.
Code is contributed under MIT/X11 license.
svn path=/trunk/mcs/; revision=159860
* Directory.cs: Ensure elevated trust when calling on
Moonlight.
* DirectoryInfo.cs: Ensure elevated trust when calling a .ctor
on Moonlight.
* File.cs: Ensure elevated trust when calling a .ctor on
Moonlight.
* FileInfo.cs: Ensure elevated trust when calling a .ctor on
Moonlight.
* FileStream.cs: Ensure elevated trust when calling a .ctor on
Moonlight. Name property returns "[Unknown]" unless a Moonlight
application is executed with elevated trust.
* Path.cs: Ensure elevated trust when calling a GetTempPath,
GetTempFileName or GetFullPath on Moonlight. Add a shared
internal method to validate paths to reduce code duplication.
svn path=/trunk/mcs/; revision=155643
* Directory.cs: a directory named ":" is legal in unix.
This gets rid of the annoying ":" folder when running
corlib tests.
svn path=/trunk/mcs/; revision=154189
* Directory.cs, DirectoryInfo.cs: Disble new NET_4_0 API used in
SL4 until we have elevated trust working correctly (since they
are *not* decorated as [SecurityCritical])
svn path=/trunk/mcs/; revision=153968
* Directory.cs: Added new IEnumerable methods to Directory.
* MonoIO.cs: Surface a high level FindFirst/FindNext API to
implement the various enumerable APIs.
svn path=/trunk/mcs/; revision=146698
* Directory.cs: Don't expose SearchOption in NET_2_1
* DirectoryInfo.cs: Don't expose SearchOption in NET_2_1
* MonoIO.cs: Don't throw a DriveNotFoundException under NET_2_1 -
an IOExpection will be thrown (like the 1.x profile)
svn path=/trunk/mcs/; revision=142479
indicates whether the original path should only container the last
part of the directory. Moved logic for determining the Name and
Parent to Initialize method, to allow it to be re-used on
deserialization. Renamed argument names to fix corcompare issues.
Added missing argument checks.
* Directory.cs (CreateDirectoriesInternal): Use internal ctor for
DirectoryInfo to ensure OriginalPath only contains last part of
the directory.
* File.cs: Removed redundant checks from Create. On 2.0 profile, pass
FileOptions to FileStream. Removed redundant directory check from
Delete and modified exceptions to more closely match MS.
* FileInfo.cs: Added argument check to ctor to match MS. Added missing
deserialization ctor. Modified argument checks in MoveTo, and removed
redundant checks. Added missing argument checks in CopyTo. Code
formatting.
* FileSystemInfo.cs: Modified argument checks in CheckPath to more
closely match MS.
* MonoIO.cs: Added msg that does not disclose filename for
ERROR_FILE_EXISTS.
* Path.cs: Use String.Length instead of comparing with String.Empty.
Removed exceptions argument names to match MS.
* File.cs: Added/improved tests for Create and Move.
* DirectoryInfoTest.cs: No longer derive from deprecated Assertion
class. Improved tests for ctor, Create, Name, Parent, ...
* FileInfoTest.cs: No longer derive from deprecated Assertion class.
Improved/added tests,
* PathTest.cs: Added tests for IsPathRooted and GetFullPath.
* FileSystemInfoTest.cs: Fixed test. Now passes on both Mono and MS.
svn path=/trunk/mcs/; revision=101006
* Directory.cs: Exception differs when deleting a directory if it
does not exists or if a file of the same name exists. Also don't
include path in exception if Delete fails.
svn path=/trunk/mcs/; revision=99230
used to move files, patch by Robert Jordan. Fixes bug #81912. Spaces
to tabs.
* DirectoryCas.cs: Changed Move to MoveDirectory to match the
method in DirectoryTest. Fixed line endings.
* DirectoryTest.cs: Added test for bug #81912. Added tests for Move
argument checks.
svn path=/trunk/mcs/; revision=81599