Skip to content
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

Support setting ACLs on file paths longer than MAX_PATH #92460

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ internal void Persist(string fullPath)
try
{
AccessControlSections persistRules = GetAccessControlSectionsFromChanges();
base.Persist(fullPath, persistRules);
base.Persist(PathInternal.EnsureExtendedPrefixIfNeeded(fullPath), persistRules);
OwnerModified = GroupModified = AuditRulesModified = AccessRulesModified = false;
}
finally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,25 @@ public void SetAccessControl_FileInfo_FileSecurity_Success()
fileInfo.SetAccessControl(fileSecurity);
}

[Fact]
public void SetAccessControl_FileInfo_FileSecurity_Success_NameLongerThanMaxShortPath()
karakasa marked this conversation as resolved.
Show resolved Hide resolved
{
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");
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()
{
Expand Down