From 19df9bf25b6abde7fcf8744c7dbdac330d1588a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C5=91rik=20Levente?= <33373714+Levminer@users.noreply.github.com> Date: Sat, 29 Jun 2024 12:50:02 +0200 Subject: [PATCH] Fix settings folder permissions --- platforms/windows/lib/Settings.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/platforms/windows/lib/Settings.cs b/platforms/windows/lib/Settings.cs index 20cfc7e..73002a5 100644 --- a/platforms/windows/lib/Settings.cs +++ b/platforms/windows/lib/Settings.cs @@ -1,4 +1,6 @@ -using System.Text.Json; +using System.Security.AccessControl; +using System.Security.Principal; +using System.Text.Json; namespace lib; @@ -39,6 +41,16 @@ public void CheckIfSettingsExists() { Directory.CreateDirectory(Path.Join(prorgamData, "Cores")); } + // set folder permissions + var folderInfo = new DirectoryInfo(Path.Join(prorgamData, "Cores")); + var folderSecurity = folderInfo.GetAccessControl(); + folderSecurity.AddAccessRule(new FileSystemAccessRule(new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null), + FileSystemRights.FullControl, + InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, + PropagationFlags.None, + AccessControlType.Allow)); + folderInfo.SetAccessControl(folderSecurity); + // check if settings.json exists if (!File.Exists(Path.Join(prorgamData, "Cores", "settings.json"))) { // create settings.json