зеркало из https://github.com/microsoft/BuildXL.git
Fix access control check with scrubbing in NetCore builds. (#1079)
This commit is contained in:
Родитель
b562aa0a98
Коммит
aef1d51c96
|
@ -1509,7 +1509,6 @@ namespace BuildXL.Native.IO.Windows
|
|||
Contract.Requires(!string.IsNullOrWhiteSpace(path));
|
||||
path = FileSystemWin.ToLongPathIfExceedMaxPath(path);
|
||||
|
||||
#if NET_FRAMEWORK
|
||||
FileSystemRights fileSystemRights =
|
||||
FileSystemRights.WriteData |
|
||||
FileSystemRights.AppendData |
|
||||
|
@ -1517,9 +1516,6 @@ namespace BuildXL.Native.IO.Windows
|
|||
FileSystemRights.WriteExtendedAttributes;
|
||||
|
||||
return CheckFileSystemRightsForPath(path, fileSystemRights);
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -1529,15 +1525,11 @@ namespace BuildXL.Native.IO.Windows
|
|||
Contract.Requires(!string.IsNullOrWhiteSpace(path));
|
||||
path = FileSystemWin.ToLongPathIfExceedMaxPath(path);
|
||||
|
||||
#if NET_FRAMEWORK
|
||||
FileSystemRights fileSystemRights =
|
||||
FileSystemRights.WriteAttributes |
|
||||
FileSystemRights.WriteExtendedAttributes;
|
||||
|
||||
return CheckFileSystemRightsForPath(path, fileSystemRights);
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
private bool CheckFileSystemRightsForPath(string path, FileSystemRights fileSystemRights)
|
||||
|
|
|
@ -7,6 +7,7 @@ using System.Diagnostics;
|
|||
using System.IO;
|
||||
using System.IO.MemoryMappedFiles;
|
||||
using System.Linq;
|
||||
using System.Security.AccessControl;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BuildXL.Cache.ContentStore.Interfaces.Extensions;
|
||||
|
@ -999,6 +1000,24 @@ namespace Test.BuildXL.Storage
|
|||
XAssert.IsFalse(FileUtilities.DirectoryExistsNoFollow(directorySymlinkPath));
|
||||
}
|
||||
|
||||
[FactIfSupported(requiresWindowsBasedOperatingSystem: true)]
|
||||
public void HasWritableAccessControlTest()
|
||||
{
|
||||
string testFilePath = Path.Combine(TemporaryDirectory, "testFile.txt");
|
||||
File.WriteAllText(testFilePath, "hello");
|
||||
|
||||
XAssert.IsTrue(FileUtilities.HasWritableAccessControl(testFilePath));
|
||||
XAssert.IsTrue(FileUtilities.HasWritableAttributeAccessControl(testFilePath));
|
||||
|
||||
FileUtilities.SetFileAccessControl(testFilePath, FileSystemRights.WriteData, false);
|
||||
XAssert.IsTrue(FileUtilities.HasWritableAttributeAccessControl(testFilePath));
|
||||
XAssert.IsFalse(FileUtilities.HasWritableAccessControl(testFilePath));
|
||||
|
||||
FileUtilities.SetFileAccessControl(testFilePath, FileSystemRights.WriteAttributes, false);
|
||||
XAssert.IsFalse(FileUtilities.HasWritableAccessControl(testFilePath));
|
||||
XAssert.IsFalse(FileUtilities.HasWritableAttributeAccessControl(testFilePath));
|
||||
}
|
||||
|
||||
private void AssertNonexistent(Possible<PathExistence, NativeFailure> maybeFileExistence)
|
||||
=> AssertPathExistence(PathExistence.Nonexistent, maybeFileExistence);
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ namespace Storage {
|
|||
importFrom("BuildXL.Utilities").Storage.dll,
|
||||
importFrom("BuildXL.Utilities.Instrumentation").Common.dll,
|
||||
importFrom("BuildXL.Utilities").Collections.dll,
|
||||
...importFrom("BuildXL.Utilities").Native.securityDlls,
|
||||
],
|
||||
runtimeContent: [
|
||||
dummyWaiterExe
|
||||
|
|
Загрузка…
Ссылка в новой задаче