Set ACL info in configure script

This commit is contained in:
Jordan Dominion
2023-06-25 12:34:33 -04:00
parent ebadd12cc4
commit 4f0d3876e3
@@ -3,6 +3,7 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Security.AccessControl;
using System.Threading;
using var process = new Process();
@@ -57,14 +58,27 @@ foreach (var installLogFile in Directory.EnumerateFiles(installDir, "*.log"))
File.Delete(installLogFile);
if (uninstall)
{
Directory.Delete(
Path.Combine(installDir, "lib"),
true);
}
if ((shortcut || (interactive && !uninstall)) && process.ExitCode == 0)
{
// try and lockdown the appsettings file
var fileInfo = new FileInfo("appsettings.Production.yml");
//get security access
FileSecurity fs = fileInfo.GetAccessControl();
//remove inherited access
fs.SetAccessRuleProtection(true, false);
// Explicitly grant admins and SYSTEM
fs.AddAccessRule(new FileSystemAccessRule("Administrators", FileSystemRights.FullControl, AccessControlType.Allow));
fs.AddAccessRule(new FileSystemAccessRule("SYSTEM", FileSystemRights.Read, AccessControlType.Allow));
fileInfo.SetAccessControl(fs);
var startServer = interactive;
if (shortcut)
{