From 2a047eaab36d2d9d64ac6dcc55de4ac166ba32fb Mon Sep 17 00:00:00 2001 From: cmsilv Date: Thu, 18 Apr 2019 15:07:26 -0400 Subject: [PATCH] Fix issue where unable to access files in App_data (#8180) --- src/Orchard/FileSystems/AppData/AppDataFolder.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Orchard/FileSystems/AppData/AppDataFolder.cs b/src/Orchard/FileSystems/AppData/AppDataFolder.cs index 1c47b1119..bfb4dac67 100644 --- a/src/Orchard/FileSystems/AppData/AppDataFolder.cs +++ b/src/Orchard/FileSystems/AppData/AppDataFolder.cs @@ -141,6 +141,12 @@ namespace Orchard.FileSystems.AppData { // move to destination // will throw exception if destination exists File.Move(tempPath, path); + + // Modify file's access control to inherit permissions from parent directory. When files are moved they do not inherit + // permissions from the parent directory by default + System.Security.AccessControl.FileSecurity fileSecurity = File.GetAccessControl(path); + fileSecurity.SetAccessRuleProtection(false, false); + File.SetAccessControl(path, fileSecurity); } public Stream CreateFile(string path) { @@ -219,4 +225,4 @@ namespace Orchard.FileSystems.AppData { return CombineToPhysicalPath(path); } } -} \ No newline at end of file +}