mirror of
https://github.com/Icinga/icinga2.git
synced 2025-09-24 10:17:59 +02:00
Windows agent wizard: apply permissions also to Icinga's data dir
refs #7998
This commit is contained in:
parent
a65f2d6b41
commit
5bb929c2e8
@ -238,14 +238,12 @@ namespace Icinga
|
|||||||
|
|
||||||
string serviceUser = txtUser.Text.Trim();
|
string serviceUser = txtUser.Text.Trim();
|
||||||
|
|
||||||
DirectoryInfo di = new DirectoryInfo(Program.Icinga2InstallDir);
|
|
||||||
DirectorySecurity ds = di.GetAccessControl();
|
|
||||||
FileSystemAccessRule rule = new FileSystemAccessRule(serviceUser,
|
FileSystemAccessRule rule = new FileSystemAccessRule(serviceUser,
|
||||||
FileSystemRights.Modify,
|
FileSystemRights.Modify,
|
||||||
InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.None, AccessControlType.Allow);
|
InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.None, AccessControlType.Allow);
|
||||||
try {
|
try {
|
||||||
ds.AddAccessRule(rule);
|
AddAccessRuleToDir(rule, Program.Icinga2InstallDir);
|
||||||
di.SetAccessControl(ds);
|
AddAccessRuleToDir(rule, Program.Icinga2DataDir);
|
||||||
} catch (System.Security.Principal.IdentityNotMappedException) {
|
} catch (System.Security.Principal.IdentityNotMappedException) {
|
||||||
ShowErrorText("Could not set ACLs for user \"" + serviceUser + "\". Identitiy is not mapped.\n");
|
ShowErrorText("Could not set ACLs for user \"" + serviceUser + "\". Identitiy is not mapped.\n");
|
||||||
return;
|
return;
|
||||||
@ -285,6 +283,14 @@ namespace Icinga
|
|||||||
FinishConfigure();
|
FinishConfigure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AddAccessRuleToDir(FileSystemAccessRule rule, string dir)
|
||||||
|
{
|
||||||
|
DirectoryInfo di = new DirectoryInfo(dir);
|
||||||
|
DirectorySecurity ds = di.GetAccessControl();
|
||||||
|
ds.AddAccessRule(rule);
|
||||||
|
di.SetAccessControl(ds);
|
||||||
|
}
|
||||||
|
|
||||||
private void FinishConfigure()
|
private void FinishConfigure()
|
||||||
{
|
{
|
||||||
if (InvokeRequired) {
|
if (InvokeRequired) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user