-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Support setting ACLs on file paths longer than MAX_PATH
#92460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,6 +143,25 @@ public void SetAccessControl_FileInfo_FileSecurity_Success() | |
fileInfo.SetAccessControl(fileSecurity); | ||
} | ||
|
||
[Fact] | ||
public void SetAccessControl_FileInfo_FileSecurity_Success_NameLongerThanMaxShortPath() | ||
{ | ||
using var directory = new TempAclDirectory(); | ||
|
||
const int MaxShortPath = 260; | ||
int fileNameLength = Math.Max(MaxShortPath - directory.Path.Length, 1); | ||
|
||
string path = Path.Combine(directory.Path, new string('1', fileNameLength) + ".txt"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if I read right this is intended to be just ".txt" longer than 260? why not just make it 500 or something huge? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW: The path reported in the issue is 261, that's probably why just above 260 was chosen.
It doesn't hurt to test both 500 and > 260. |
||
using var file = new TempFile(path, 1); | ||
var fileInfo = new FileInfo(file.Path); | ||
FileSecurity fileSecurity = fileInfo.GetAccessControl(AccessControlSections.Access); | ||
|
||
var newAccessRule = new FileSystemAccessRule(Helpers.s_NetworkServiceNTAccount, FileSystemRights.Write, AccessControlType.Allow); | ||
fileSecurity.SetAccessRule(newAccessRule); | ||
|
||
fileInfo.SetAccessControl(fileSecurity); | ||
} | ||
|
||
[Fact] | ||
public void SetAccessControl_FileStream_FileSecurity_InvalidArguments() | ||
{ | ||
|
Uh oh!
There was an error while loading. Please reload this page.