From 3715f307a10ffa89fb8f8f057e12f3891c15a5b2 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 1 Apr 2016 11:40:01 +0200 Subject: [PATCH] Fix incorrect path for the X509 certificates on Windows refs #11449 --- agent/windows-setup-agent/Program.cs | 13 +++++++++++-- agent/windows-setup-agent/SetupWizard.cs | 12 ++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/agent/windows-setup-agent/Program.cs b/agent/windows-setup-agent/Program.cs index 3dcd3de75..e132bc1b1 100644 --- a/agent/windows-setup-agent/Program.cs +++ b/agent/windows-setup-agent/Program.cs @@ -45,7 +45,16 @@ namespace Icinga } } - public static void FatalError(Form owner, string message) + public static string Icinga2DataDir + { + get + { + return Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\icinga2"; + } + } + + + public static void FatalError(Form owner, string message) { MessageBox.Show(owner, message, "Icinga 2 Setup Wizard", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); @@ -69,7 +78,7 @@ namespace Icinga Form form; - if (File.Exists(installDir + "\\etc\\icinga2\\features-enabled\\api.conf")) + if (File.Exists(Program.Icinga2DataDir + "\\etc\\icinga2\\features-enabled\\api.conf")) form = new ServiceStatus(); else form = new SetupWizard(); diff --git a/agent/windows-setup-agent/SetupWizard.cs b/agent/windows-setup-agent/SetupWizard.cs index c34c7bd5a..f100cc64d 100644 --- a/agent/windows-setup-agent/SetupWizard.cs +++ b/agent/windows-setup-agent/SetupWizard.cs @@ -65,7 +65,7 @@ namespace Icinga { FileStream fp = null; try { - fp = File.Open(Program.Icinga2InstallDir + String.Format("\\etc\\icinga2\\features-enabled\\{0}.conf", feature), FileMode.Create); + fp = File.Open(Program.Icinga2DataDir + String.Format("\\etc\\icinga2\\features-enabled\\{0}.conf", feature), FileMode.Create); using (StreamWriter sw = new StreamWriter(fp, Encoding.ASCII)) { fp = null; sw.Write(String.Format("include \"../features-available/{0}.conf\"\n", feature)); @@ -144,7 +144,7 @@ namespace Icinga { SetRetrievalStatus(25); - string pathPrefix = Program.Icinga2InstallDir + "\\etc\\icinga2\\pki\\" + txtInstanceName.Text; + string pathPrefix = Program.Icinga2DataDir + "\\etc\\icinga2\\pki\\" + txtInstanceName.Text; string processArguments = "pki new-cert --cn \"" + txtInstanceName.Text + "\" --key \"" + pathPrefix + ".key\" --cert \"" + pathPrefix + ".crt\""; string output; @@ -356,8 +356,8 @@ namespace Icinga thread.Start(); } - /*if (tbcPages.SelectedTab == tabParameters && - !File.Exists(Icinga2InstallDir + "\\etc\\icinga2\\pki\\agent\\agent.crt")) { + /*if (tbcPages.SelectedTab == tabParameters && + !File.Exists(Icinga2DataDir + "\\etc\\icinga2\\pki\\agent\\agent.crt")) { byte[] bytes = Convert.FromBase64String(txtBundle.Text); MemoryStream ms = new MemoryStream(bytes); GZipStream gz = new GZipStream(ms, CompressionMode.Decompress); @@ -369,10 +369,10 @@ namespace Icinga ms2.Write(buffer, 0, rc); ms2.Position = 0; TarReader tr = new TarReader(ms2); - tr.ReadToEnd(Icinga2InstallDir + "\\etc\\icinga2\\pki\\agent"); + tr.ReadToEnd(Icinga2DataDir + "\\etc\\icinga2\\pki\\agent"); }*/ - if (tbcPages.SelectedTab == tabConfigure) { + if (tbcPages.SelectedTab == tabConfigure) { Thread thread = new Thread(ConfigureService); thread.Start(); }