Merge pull request #5730 from Icinga/fix/trim-form-fields-to-avoid-hidden-crlf-characters-from-linux-5705

Add missing trims to GetMasterHostPort and remove Convert.ToString from variables that are strings already
This commit is contained in:
Gunnar Beutner 2017-11-09 09:29:11 +01:00 committed by GitHub
commit bcf6739d9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 12 deletions

View File

@ -54,8 +54,8 @@ namespace Icinga
{ {
foreach (ListViewItem lvi in lvwEndpoints.Items) { foreach (ListViewItem lvi in lvwEndpoints.Items) {
if (lvi.SubItems.Count > 1) { if (lvi.SubItems.Count > 1) {
host = lvi.SubItems[1].Text; host = lvi.SubItems[1].Text.Trim();
port = lvi.SubItems[2].Text; port = lvi.SubItems[2].Text.Trim();
return true; return true;
} }
} }
@ -194,21 +194,21 @@ namespace Icinga
string master_host, master_port; string master_host, master_port;
GetMasterHostPort(out master_host, out master_port); GetMasterHostPort(out master_host, out master_port);
args += " --master_host " + Convert.ToString(master_host).Trim() args += " --master_host " + master_host
+ "," + Convert.ToString(master_port).Trim(); + "," + master_port;
foreach (ListViewItem lvi in lvwEndpoints.Items) { foreach (ListViewItem lvi in lvwEndpoints.Items) {
args += " --endpoint " + Convert.ToString(lvi.SubItems[0].Text).Trim(); args += " --endpoint " + lvi.SubItems[0].Text.Trim();
if (lvi.SubItems.Count > 1) { if (lvi.SubItems.Count > 1) {
args += "," + Convert.ToString(lvi.SubItems[1].Text).Trim() args += "," + lvi.SubItems[1].Text.Trim()
+ "," + Convert.ToString(lvi.SubItems[2].Text).Trim(); + "," + lvi.SubItems[2].Text.Trim();
} }
} }
}); });
if (rdoListener.Checked) if (rdoListener.Checked)
args += " --listen ::," + Convert.ToString(txtListenerPort.Text).Trim(); args += " --listen ::," + txtListenerPort.Text.Trim();
if (chkAcceptConfig.Checked) if (chkAcceptConfig.Checked)
args += " --accept-config"; args += " --accept-config";
@ -216,14 +216,14 @@ namespace Icinga
if (chkAcceptCommands.Checked) if (chkAcceptCommands.Checked)
args += " --accept-commands"; args += " --accept-commands";
string ticket = Convert.ToString(txtTicket.Text).Trim(); string ticket = txtTicket.Text.Trim();
if (ticket.Length > 0) if (ticket.Length > 0)
args += " --ticket \"" + ticket + "\""; args += " --ticket \"" + ticket + "\"";
args += " --trustedcert \"" + _TrustedFile + "\""; args += " --trustedcert \"" + _TrustedFile + "\"";
args += " --cn \"" + Convert.ToString(txtInstanceName.Text).Trim() + "\""; args += " --cn \"" + txtInstanceName.Text.Trim() + "\"";
args += " --zone \"" + Convert.ToString(txtInstanceName.Text) + "\""; args += " --zone \"" + txtInstanceName.Text.Trim() + "\"";
if (!RunProcess(Program.Icinga2InstallDir + "\\sbin\\icinga2.exe", if (!RunProcess(Program.Icinga2InstallDir + "\\sbin\\icinga2.exe",
"node setup" + args, "node setup" + args,
@ -234,7 +234,7 @@ namespace Icinga
SetConfigureStatus(50, "Setting ACLs for the Icinga 2 directory..."); SetConfigureStatus(50, "Setting ACLs for the Icinga 2 directory...");
string serviceUser = Convert.ToString(txtUser.Text).Trim(); string serviceUser = txtUser.Text.Trim();
DirectoryInfo di = new DirectoryInfo(Program.Icinga2InstallDir); DirectoryInfo di = new DirectoryInfo(Program.Icinga2InstallDir);
DirectorySecurity ds = di.GetAccessControl(); DirectorySecurity ds = di.GetAccessControl();