]> granicus.if.org Git - icinga2/commitdiff
Update the Windows agent wizard
authorGunnar Beutner <gunnar@beutner.name>
Tue, 21 Oct 2014 14:07:22 +0000 (16:07 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Tue, 21 Oct 2014 14:07:39 +0000 (16:07 +0200)
refs #7241

13 files changed:
agent/windows-setup-agent/AgentWizard.Designer.cs
agent/windows-setup-agent/AgentWizard.cs
agent/windows-setup-agent/AgentWizard.resx
agent/windows-setup-agent/Icinga2SetupAgent.csproj
agent/windows-setup-agent/tar-cs/COPYING [deleted file]
agent/windows-setup-agent/tar-cs/ITarHeader.cs [deleted file]
agent/windows-setup-agent/tar-cs/TarException.cs [deleted file]
agent/windows-setup-agent/tar-cs/TarHeader.cs [deleted file]
agent/windows-setup-agent/tar-cs/TarReader.cs [deleted file]
agent/windows-setup-agent/tar-cs/UsTarHeader.cs [deleted file]
icinga-app/icinga.cpp
lib/base/application.cpp
lib/cli/clicommand.cpp

index 694195774ce40220b0a3695dc33ef9f03fc11fa8..5f7eb5ead9c5331f63bdad3a6631afbc84ef160d 100644 (file)
                private void InitializeComponent()
                {
                        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AgentWizard));
-                       this.tbcPages = new System.Windows.Forms.TabControl();
-                       this.tabAgentKey = new System.Windows.Forms.TabPage();
-                       this.lblHostKey = new System.Windows.Forms.Label();
-                       this.prgHostKey = new System.Windows.Forms.ProgressBar();
-                       this.tabCSR = new System.Windows.Forms.TabPage();
-                       this.txtCSR = new System.Windows.Forms.TextBox();
-                       this.lblCSRPrompt = new System.Windows.Forms.Label();
-                       this.tabCertificateBundle = new System.Windows.Forms.TabPage();
-                       this.txtBundle = new System.Windows.Forms.TextBox();
-                       this.lblBundlePrompt = new System.Windows.Forms.Label();
+                       this.btnBack = new System.Windows.Forms.Button();
+                       this.btnNext = new System.Windows.Forms.Button();
+                       this.btnCancel = new System.Windows.Forms.Button();
+                       this.tabFinish = new System.Windows.Forms.TabPage();
+                       this.lblSetupCompleted = new System.Windows.Forms.Label();
+                       this.tabConfigure = new System.Windows.Forms.TabPage();
+                       this.lblConfigStatus = new System.Windows.Forms.Label();
+                       this.prgConfig = new System.Windows.Forms.ProgressBar();
                        this.tabParameters = new System.Windows.Forms.TabPage();
                        this.txtInstanceName = new System.Windows.Forms.TextBox();
-                       this.label5 = new System.Windows.Forms.Label();
-                       this.groupBox3 = new System.Windows.Forms.GroupBox();
-                       this.rdoNoConnect = new System.Windows.Forms.RadioButton();
-                       this.txtPeerPort = new System.Windows.Forms.TextBox();
-                       this.lblPeerPort = new System.Windows.Forms.Label();
-                       this.txtPeerHost = new System.Windows.Forms.TextBox();
-                       this.lblPeerHost = new System.Windows.Forms.Label();
-                       this.rdoConnect = new System.Windows.Forms.RadioButton();
+                       this.lblInstanceName = new System.Windows.Forms.Label();
                        this.groupBox2 = new System.Windows.Forms.GroupBox();
                        this.rdoNoListener = new System.Windows.Forms.RadioButton();
                        this.txtListenerPort = new System.Windows.Forms.TextBox();
                        this.lblListenerPort = new System.Windows.Forms.Label();
                        this.rdoListener = new System.Windows.Forms.RadioButton();
                        this.groupBox1 = new System.Windows.Forms.GroupBox();
-                       this.txtMasterInstance = new System.Windows.Forms.TextBox();
-                       this.lblMasterInstance = new System.Windows.Forms.Label();
+                       this.btnRemoveEndpoint = new System.Windows.Forms.Button();
+                       this.btnAddEndpoint = new System.Windows.Forms.Button();
+                       this.lvwEndpoints = new System.Windows.Forms.ListView();
+                       this.colHost = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+                       this.colPort = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
                        this.rdoNoMaster = new System.Windows.Forms.RadioButton();
                        this.rdoNewMaster = new System.Windows.Forms.RadioButton();
+                       this.tbcPages = new System.Windows.Forms.TabControl();
+                       this.tabRetrieveCertificate = new System.Windows.Forms.TabPage();
+                       this.tabVerifyCertificate = new System.Windows.Forms.TabPage();
+                       this.grpX509Fields = new System.Windows.Forms.GroupBox();
+                       this.txtX509Field = new System.Windows.Forms.TextBox();
+                       this.lvwX509Fields = new System.Windows.Forms.ListView();
+                       this.colField = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+                       this.colValue = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+                       this.txtX509Subject = new System.Windows.Forms.TextBox();
+                       this.txtX509Issuer = new System.Windows.Forms.TextBox();
+                       this.lblX509Subject = new System.Windows.Forms.Label();
+                       this.lblX509Issuer = new System.Windows.Forms.Label();
+                       this.lblX509Prompt = new System.Windows.Forms.Label();
                        this.picBanner = new System.Windows.Forms.PictureBox();
-                       this.btnBack = new System.Windows.Forms.Button();
-                       this.btnNext = new System.Windows.Forms.Button();
-                       this.btnCancel = new System.Windows.Forms.Button();
-                       this.tabConfigure = new System.Windows.Forms.TabPage();
-                       this.prgConfig = new System.Windows.Forms.ProgressBar();
-                       this.lblConfigStatus = new System.Windows.Forms.Label();
-                       this.tabFinish = new System.Windows.Forms.TabPage();
-                       this.label1 = new System.Windows.Forms.Label();
-                       this.tbcPages.SuspendLayout();
-                       this.tabAgentKey.SuspendLayout();
-                       this.tabCSR.SuspendLayout();
-                       this.tabCertificateBundle.SuspendLayout();
+                       this.lblRetrieveCertificate = new System.Windows.Forms.Label();
+                       this.prgRetrieveCertificate = new System.Windows.Forms.ProgressBar();
+                       this.tabFinish.SuspendLayout();
+                       this.tabConfigure.SuspendLayout();
                        this.tabParameters.SuspendLayout();
-                       this.groupBox3.SuspendLayout();
                        this.groupBox2.SuspendLayout();
                        this.groupBox1.SuspendLayout();
+                       this.tbcPages.SuspendLayout();
+                       this.tabRetrieveCertificate.SuspendLayout();
+                       this.tabVerifyCertificate.SuspendLayout();
+                       this.grpX509Fields.SuspendLayout();
                        ((System.ComponentModel.ISupportInitialize)(this.picBanner)).BeginInit();
-                       this.tabConfigure.SuspendLayout();
-                       this.tabFinish.SuspendLayout();
                        this.SuspendLayout();
                        // 
-                       // tbcPages
+                       // btnBack
                        // 
-                       this.tbcPages.Appearance = System.Windows.Forms.TabAppearance.FlatButtons;
-                       this.tbcPages.Controls.Add(this.tabAgentKey);
-                       this.tbcPages.Controls.Add(this.tabCSR);
-                       this.tbcPages.Controls.Add(this.tabCertificateBundle);
-                       this.tbcPages.Controls.Add(this.tabParameters);
-                       this.tbcPages.Controls.Add(this.tabConfigure);
-                       this.tbcPages.Controls.Add(this.tabFinish);
-                       this.tbcPages.ItemSize = new System.Drawing.Size(0, 1);
-                       this.tbcPages.Location = new System.Drawing.Point(0, 80);
-                       this.tbcPages.Margin = new System.Windows.Forms.Padding(0);
-                       this.tbcPages.Name = "tbcPages";
-                       this.tbcPages.SelectedIndex = 0;
-                       this.tbcPages.Size = new System.Drawing.Size(625, 509);
-                       this.tbcPages.SizeMode = System.Windows.Forms.TabSizeMode.Fixed;
-                       this.tbcPages.TabIndex = 0;
-                       this.tbcPages.SelectedIndexChanged += new System.EventHandler(this.tbcPages_SelectedIndexChanged);
+                       this.btnBack.Enabled = false;
+                       this.btnBack.Location = new System.Drawing.Point(367, 592);
+                       this.btnBack.Name = "btnBack";
+                       this.btnBack.Size = new System.Drawing.Size(75, 23);
+                       this.btnBack.TabIndex = 1;
+                       this.btnBack.Text = "< &Back";
+                       this.btnBack.UseVisualStyleBackColor = true;
+                       this.btnBack.Click += new System.EventHandler(this.btnBack_Click);
+                       // 
+                       // btnNext
+                       // 
+                       this.btnNext.Location = new System.Drawing.Point(448, 592);
+                       this.btnNext.Name = "btnNext";
+                       this.btnNext.Size = new System.Drawing.Size(75, 23);
+                       this.btnNext.TabIndex = 2;
+                       this.btnNext.Text = "&Next >";
+                       this.btnNext.UseVisualStyleBackColor = true;
+                       this.btnNext.Click += new System.EventHandler(this.btnNext_Click);
+                       // 
+                       // btnCancel
                        // 
-                       // tabAgentKey
-                       // 
-                       this.tabAgentKey.Controls.Add(this.lblHostKey);
-                       this.tabAgentKey.Controls.Add(this.prgHostKey);
-                       this.tabAgentKey.Location = new System.Drawing.Point(4, 5);
-                       this.tabAgentKey.Name = "tabAgentKey";
-                       this.tabAgentKey.Padding = new System.Windows.Forms.Padding(3);
-                       this.tabAgentKey.Size = new System.Drawing.Size(617, 500);
-                       this.tabAgentKey.TabIndex = 0;
-                       this.tabAgentKey.Text = "Agent Key";
-                       this.tabAgentKey.UseVisualStyleBackColor = true;
-                       // 
-                       // lblHostKey
-                       // 
-                       this.lblHostKey.AutoSize = true;
-                       this.lblHostKey.Location = new System.Drawing.Point(118, 222);
-                       this.lblHostKey.Name = "lblHostKey";
-                       this.lblHostKey.Size = new System.Drawing.Size(197, 13);
-                       this.lblHostKey.TabIndex = 1;
-                       this.lblHostKey.Text = "Generating a host key for this machine...";
-                       // 
-                       // prgHostKey
-                       // 
-                       this.prgHostKey.Location = new System.Drawing.Point(118, 254);
-                       this.prgHostKey.Name = "prgHostKey";
-                       this.prgHostKey.Size = new System.Drawing.Size(369, 23);
-                       this.prgHostKey.Style = System.Windows.Forms.ProgressBarStyle.Marquee;
-                       this.prgHostKey.TabIndex = 0;
-                       // 
-                       // tabCSR
-                       // 
-                       this.tabCSR.Controls.Add(this.txtCSR);
-                       this.tabCSR.Controls.Add(this.lblCSRPrompt);
-                       this.tabCSR.Location = new System.Drawing.Point(4, 5);
-                       this.tabCSR.Name = "tabCSR";
-                       this.tabCSR.Padding = new System.Windows.Forms.Padding(3);
-                       this.tabCSR.Size = new System.Drawing.Size(617, 500);
-                       this.tabCSR.TabIndex = 1;
-                       this.tabCSR.Text = "Certificate Signing Request";
-                       this.tabCSR.UseVisualStyleBackColor = true;
-                       // 
-                       // txtCSR
-                       // 
-                       this.txtCSR.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
-                       this.txtCSR.Location = new System.Drawing.Point(24, 42);
-                       this.txtCSR.Multiline = true;
-                       this.txtCSR.Name = "txtCSR";
-                       this.txtCSR.ReadOnly = true;
-                       this.txtCSR.Size = new System.Drawing.Size(564, 452);
-                       this.txtCSR.TabIndex = 1;
-                       // 
-                       // lblCSRPrompt
-                       // 
-                       this.lblCSRPrompt.AutoSize = true;
-                       this.lblCSRPrompt.Location = new System.Drawing.Point(21, 15);
-                       this.lblCSRPrompt.Name = "lblCSRPrompt";
-                       this.lblCSRPrompt.Size = new System.Drawing.Size(373, 13);
-                       this.lblCSRPrompt.TabIndex = 0;
-                       this.lblCSRPrompt.Text = "Please sign the following certificate signing request (CSR) using the agent CA:";
-                       // 
-                       // tabCertificateBundle
-                       // 
-                       this.tabCertificateBundle.Controls.Add(this.txtBundle);
-                       this.tabCertificateBundle.Controls.Add(this.lblBundlePrompt);
-                       this.tabCertificateBundle.Location = new System.Drawing.Point(4, 5);
-                       this.tabCertificateBundle.Name = "tabCertificateBundle";
-                       this.tabCertificateBundle.Padding = new System.Windows.Forms.Padding(3);
-                       this.tabCertificateBundle.Size = new System.Drawing.Size(617, 500);
-                       this.tabCertificateBundle.TabIndex = 2;
-                       this.tabCertificateBundle.Text = "Certificate Bundle";
-                       this.tabCertificateBundle.UseVisualStyleBackColor = true;
-                       // 
-                       // txtBundle
-                       // 
-                       this.txtBundle.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
-                       this.txtBundle.Location = new System.Drawing.Point(24, 42);
-                       this.txtBundle.Multiline = true;
-                       this.txtBundle.Name = "txtBundle";
-                       this.txtBundle.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
-                       this.txtBundle.Size = new System.Drawing.Size(564, 452);
-                       this.txtBundle.TabIndex = 1;
-                       // 
-                       // lblBundlePrompt
-                       // 
-                       this.lblBundlePrompt.AutoSize = true;
-                       this.lblBundlePrompt.Location = new System.Drawing.Point(21, 15);
-                       this.lblBundlePrompt.Name = "lblBundlePrompt";
-                       this.lblBundlePrompt.Size = new System.Drawing.Size(239, 13);
-                       this.lblBundlePrompt.TabIndex = 0;
-                       this.lblBundlePrompt.Text = "Paste the certificate bundle in the text box below:";
+                       this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+                       this.btnCancel.Location = new System.Drawing.Point(538, 592);
+                       this.btnCancel.Name = "btnCancel";
+                       this.btnCancel.Size = new System.Drawing.Size(75, 23);
+                       this.btnCancel.TabIndex = 3;
+                       this.btnCancel.Text = "Cancel";
+                       this.btnCancel.UseVisualStyleBackColor = true;
+                       this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
+                       // 
+                       // tabFinish
+                       // 
+                       this.tabFinish.Controls.Add(this.lblSetupCompleted);
+                       this.tabFinish.Location = new System.Drawing.Point(4, 5);
+                       this.tabFinish.Name = "tabFinish";
+                       this.tabFinish.Padding = new System.Windows.Forms.Padding(3);
+                       this.tabFinish.Size = new System.Drawing.Size(617, 500);
+                       this.tabFinish.TabIndex = 5;
+                       this.tabFinish.Text = "Finish";
+                       this.tabFinish.UseVisualStyleBackColor = true;
+                       // 
+                       // lblSetupCompleted
+                       // 
+                       this.lblSetupCompleted.AutoSize = true;
+                       this.lblSetupCompleted.Location = new System.Drawing.Point(34, 35);
+                       this.lblSetupCompleted.Name = "lblSetupCompleted";
+                       this.lblSetupCompleted.Size = new System.Drawing.Size(214, 13);
+                       this.lblSetupCompleted.TabIndex = 0;
+                       this.lblSetupCompleted.Text = "The Icinga 2 agent was set up successfully.";
+                       // 
+                       // tabConfigure
+                       // 
+                       this.tabConfigure.Controls.Add(this.lblConfigStatus);
+                       this.tabConfigure.Controls.Add(this.prgConfig);
+                       this.tabConfigure.Location = new System.Drawing.Point(4, 5);
+                       this.tabConfigure.Name = "tabConfigure";
+                       this.tabConfigure.Padding = new System.Windows.Forms.Padding(3);
+                       this.tabConfigure.Size = new System.Drawing.Size(617, 500);
+                       this.tabConfigure.TabIndex = 4;
+                       this.tabConfigure.Text = "Configure Icinga 2";
+                       this.tabConfigure.UseVisualStyleBackColor = true;
+                       // 
+                       // lblConfigStatus
+                       // 
+                       this.lblConfigStatus.AutoSize = true;
+                       this.lblConfigStatus.Location = new System.Drawing.Point(184, 204);
+                       this.lblConfigStatus.Name = "lblConfigStatus";
+                       this.lblConfigStatus.Size = new System.Drawing.Size(141, 13);
+                       this.lblConfigStatus.TabIndex = 1;
+                       this.lblConfigStatus.Text = "Updating the configuration...";
+                       // 
+                       // prgConfig
+                       // 
+                       this.prgConfig.Location = new System.Drawing.Point(184, 223);
+                       this.prgConfig.Name = "prgConfig";
+                       this.prgConfig.Size = new System.Drawing.Size(289, 23);
+                       this.prgConfig.TabIndex = 0;
                        // 
                        // tabParameters
                        // 
                        this.tabParameters.Controls.Add(this.txtInstanceName);
-                       this.tabParameters.Controls.Add(this.label5);
-                       this.tabParameters.Controls.Add(this.groupBox3);
+                       this.tabParameters.Controls.Add(this.lblInstanceName);
                        this.tabParameters.Controls.Add(this.groupBox2);
                        this.tabParameters.Controls.Add(this.groupBox1);
                        this.tabParameters.Location = new System.Drawing.Point(4, 5);
                        // 
                        this.txtInstanceName.Location = new System.Drawing.Point(98, 16);
                        this.txtInstanceName.Name = "txtInstanceName";
-                       this.txtInstanceName.ReadOnly = true;
                        this.txtInstanceName.Size = new System.Drawing.Size(240, 20);
                        this.txtInstanceName.TabIndex = 0;
                        // 
-                       // label5
-                       // 
-                       this.label5.AutoSize = true;
-                       this.label5.Location = new System.Drawing.Point(9, 20);
-                       this.label5.Name = "label5";
-                       this.label5.Size = new System.Drawing.Size(82, 13);
-                       this.label5.TabIndex = 3;
-                       this.label5.Text = "Instance Name:";
-                       // 
-                       // groupBox3
-                       // 
-                       this.groupBox3.Controls.Add(this.rdoNoConnect);
-                       this.groupBox3.Controls.Add(this.txtPeerPort);
-                       this.groupBox3.Controls.Add(this.lblPeerPort);
-                       this.groupBox3.Controls.Add(this.txtPeerHost);
-                       this.groupBox3.Controls.Add(this.lblPeerHost);
-                       this.groupBox3.Controls.Add(this.rdoConnect);
-                       this.groupBox3.Location = new System.Drawing.Point(8, 305);
-                       this.groupBox3.Name = "groupBox3";
-                       this.groupBox3.Size = new System.Drawing.Size(601, 140);
-                       this.groupBox3.TabIndex = 3;
-                       this.groupBox3.TabStop = false;
-                       this.groupBox3.Text = "TCP Connect";
-                       // 
-                       // rdoNoConnect
-                       // 
-                       this.rdoNoConnect.AutoSize = true;
-                       this.rdoNoConnect.Checked = true;
-                       this.rdoNoConnect.Location = new System.Drawing.Point(11, 108);
-                       this.rdoNoConnect.Name = "rdoNoConnect";
-                       this.rdoNoConnect.Size = new System.Drawing.Size(209, 17);
-                       this.rdoNoConnect.TabIndex = 3;
-                       this.rdoNoConnect.TabStop = true;
-                       this.rdoNoConnect.Text = "Do not connect to the master instance.";
-                       this.rdoNoConnect.UseVisualStyleBackColor = true;
-                       this.rdoNoConnect.CheckedChanged += new System.EventHandler(this.RadioConnect_CheckedChanged);
-                       // 
-                       // txtPeerPort
-                       // 
-                       this.txtPeerPort.Enabled = false;
-                       this.txtPeerPort.Location = new System.Drawing.Point(131, 79);
-                       this.txtPeerPort.Name = "txtPeerPort";
-                       this.txtPeerPort.Size = new System.Drawing.Size(84, 20);
-                       this.txtPeerPort.TabIndex = 2;
-                       this.txtPeerPort.Text = "5665";
-                       // 
-                       // lblPeerPort
-                       // 
-                       this.lblPeerPort.AutoSize = true;
-                       this.lblPeerPort.Location = new System.Drawing.Point(45, 82);
-                       this.lblPeerPort.Name = "lblPeerPort";
-                       this.lblPeerPort.Size = new System.Drawing.Size(29, 13);
-                       this.lblPeerPort.TabIndex = 6;
-                       this.lblPeerPort.Text = "Port:";
-                       // 
-                       // txtPeerHost
-                       // 
-                       this.txtPeerHost.Enabled = false;
-                       this.txtPeerHost.Location = new System.Drawing.Point(131, 53);
-                       this.txtPeerHost.Name = "txtPeerHost";
-                       this.txtPeerHost.Size = new System.Drawing.Size(240, 20);
-                       this.txtPeerHost.TabIndex = 1;
-                       // 
-                       // lblPeerHost
-                       // 
-                       this.lblPeerHost.AutoSize = true;
-                       this.lblPeerHost.Location = new System.Drawing.Point(45, 54);
-                       this.lblPeerHost.Name = "lblPeerHost";
-                       this.lblPeerHost.Size = new System.Drawing.Size(58, 13);
-                       this.lblPeerHost.TabIndex = 1;
-                       this.lblPeerHost.Text = "Hostname:";
-                       // 
-                       // rdoConnect
-                       // 
-                       this.rdoConnect.AutoSize = true;
-                       this.rdoConnect.Location = new System.Drawing.Point(11, 25);
-                       this.rdoConnect.Name = "rdoConnect";
-                       this.rdoConnect.Size = new System.Drawing.Size(175, 17);
-                       this.rdoConnect.TabIndex = 0;
-                       this.rdoConnect.Text = "Connect to the master instance:";
-                       this.rdoConnect.UseVisualStyleBackColor = true;
-                       this.rdoConnect.CheckedChanged += new System.EventHandler(this.RadioConnect_CheckedChanged);
+                       // lblInstanceName
+                       // 
+                       this.lblInstanceName.AutoSize = true;
+                       this.lblInstanceName.Location = new System.Drawing.Point(9, 20);
+                       this.lblInstanceName.Name = "lblInstanceName";
+                       this.lblInstanceName.Size = new System.Drawing.Size(82, 13);
+                       this.lblInstanceName.TabIndex = 3;
+                       this.lblInstanceName.Text = "Instance Name:";
                        // 
                        // groupBox2
                        // 
                        this.groupBox2.Controls.Add(this.txtListenerPort);
                        this.groupBox2.Controls.Add(this.lblListenerPort);
                        this.groupBox2.Controls.Add(this.rdoListener);
-                       this.groupBox2.Location = new System.Drawing.Point(8, 178);
+                       this.groupBox2.Location = new System.Drawing.Point(8, 330);
                        this.groupBox2.Name = "groupBox2";
                        this.groupBox2.Size = new System.Drawing.Size(601, 111);
                        this.groupBox2.TabIndex = 2;
                        // 
                        // groupBox1
                        // 
-                       this.groupBox1.Controls.Add(this.txtMasterInstance);
-                       this.groupBox1.Controls.Add(this.lblMasterInstance);
+                       this.groupBox1.Controls.Add(this.btnRemoveEndpoint);
+                       this.groupBox1.Controls.Add(this.btnAddEndpoint);
+                       this.groupBox1.Controls.Add(this.lvwEndpoints);
                        this.groupBox1.Controls.Add(this.rdoNoMaster);
                        this.groupBox1.Controls.Add(this.rdoNewMaster);
                        this.groupBox1.Location = new System.Drawing.Point(8, 48);
                        this.groupBox1.Name = "groupBox1";
-                       this.groupBox1.Size = new System.Drawing.Size(601, 112);
+                       this.groupBox1.Size = new System.Drawing.Size(601, 276);
                        this.groupBox1.TabIndex = 1;
                        this.groupBox1.TabStop = false;
                        this.groupBox1.Text = "Master Instance";
                        // 
-                       // txtMasterInstance
+                       // btnRemoveEndpoint
+                       // 
+                       this.btnRemoveEndpoint.Enabled = false;
+                       this.btnRemoveEndpoint.Location = new System.Drawing.Point(520, 112);
+                       this.btnRemoveEndpoint.Name = "btnRemoveEndpoint";
+                       this.btnRemoveEndpoint.Size = new System.Drawing.Size(75, 23);
+                       this.btnRemoveEndpoint.TabIndex = 4;
+                       this.btnRemoveEndpoint.Text = "Remove";
+                       this.btnRemoveEndpoint.UseVisualStyleBackColor = true;
+                       this.btnRemoveEndpoint.Click += new System.EventHandler(this.btnRemoveEndpoint_Click);
                        // 
-                       this.txtMasterInstance.Location = new System.Drawing.Point(132, 78);
-                       this.txtMasterInstance.Name = "txtMasterInstance";
-                       this.txtMasterInstance.Size = new System.Drawing.Size(240, 20);
-                       this.txtMasterInstance.TabIndex = 2;
+                       // btnAddEndpoint
                        // 
-                       // lblMasterInstance
+                       this.btnAddEndpoint.Location = new System.Drawing.Point(520, 83);
+                       this.btnAddEndpoint.Name = "btnAddEndpoint";
+                       this.btnAddEndpoint.Size = new System.Drawing.Size(75, 23);
+                       this.btnAddEndpoint.TabIndex = 3;
+                       this.btnAddEndpoint.Text = "Add";
+                       this.btnAddEndpoint.UseVisualStyleBackColor = true;
+                       this.btnAddEndpoint.Click += new System.EventHandler(this.btnAddEndpoint_Click);
                        // 
-                       this.lblMasterInstance.AutoSize = true;
-                       this.lblMasterInstance.Location = new System.Drawing.Point(40, 81);
-                       this.lblMasterInstance.Name = "lblMasterInstance";
-                       this.lblMasterInstance.Size = new System.Drawing.Size(86, 13);
-                       this.lblMasterInstance.TabIndex = 2;
-                       this.lblMasterInstance.Text = "Master Instance:";
+                       // lvwEndpoints
+                       // 
+                       this.lvwEndpoints.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
+            this.colHost,
+            this.colPort});
+                       this.lvwEndpoints.Location = new System.Drawing.Point(11, 83);
+                       this.lvwEndpoints.Name = "lvwEndpoints";
+                       this.lvwEndpoints.Size = new System.Drawing.Size(500, 176);
+                       this.lvwEndpoints.TabIndex = 2;
+                       this.lvwEndpoints.UseCompatibleStateImageBehavior = false;
+                       this.lvwEndpoints.View = System.Windows.Forms.View.Details;
+                       this.lvwEndpoints.SelectedIndexChanged += new System.EventHandler(this.lvwEndpoints_SelectedIndexChanged);
+                       // 
+                       // colHost
+                       // 
+                       this.colHost.Text = "Host";
+                       this.colHost.Width = 300;
+                       // 
+                       // colPort
+                       // 
+                       this.colPort.Text = "Port";
+                       this.colPort.Width = 120;
                        // 
                        // rdoNoMaster
                        // 
                        this.rdoNoMaster.Checked = true;
                        this.rdoNoMaster.Location = new System.Drawing.Point(11, 50);
                        this.rdoNoMaster.Name = "rdoNoMaster";
-                       this.rdoNoMaster.Size = new System.Drawing.Size(383, 17);
+                       this.rdoNoMaster.Size = new System.Drawing.Size(374, 17);
                        this.rdoNoMaster.TabIndex = 1;
                        this.rdoNoMaster.TabStop = true;
-                       this.rdoNoMaster.Text = "This instance should report its check results to an existing Icinga 2 instance:";
+                       this.rdoNoMaster.Text = "This instance should report its check results to an existing Icinga 2 master:";
                        this.rdoNoMaster.UseVisualStyleBackColor = true;
                        this.rdoNoMaster.CheckedChanged += new System.EventHandler(this.RadioMaster_CheckedChanged);
                        // 
                        this.rdoNewMaster.UseVisualStyleBackColor = true;
                        this.rdoNewMaster.CheckedChanged += new System.EventHandler(this.RadioMaster_CheckedChanged);
                        // 
+                       // tbcPages
+                       // 
+                       this.tbcPages.Appearance = System.Windows.Forms.TabAppearance.FlatButtons;
+                       this.tbcPages.Controls.Add(this.tabParameters);
+                       this.tbcPages.Controls.Add(this.tabRetrieveCertificate);
+                       this.tbcPages.Controls.Add(this.tabVerifyCertificate);
+                       this.tbcPages.Controls.Add(this.tabConfigure);
+                       this.tbcPages.Controls.Add(this.tabFinish);
+                       this.tbcPages.ItemSize = new System.Drawing.Size(0, 1);
+                       this.tbcPages.Location = new System.Drawing.Point(0, 80);
+                       this.tbcPages.Margin = new System.Windows.Forms.Padding(0);
+                       this.tbcPages.Name = "tbcPages";
+                       this.tbcPages.SelectedIndex = 0;
+                       this.tbcPages.Size = new System.Drawing.Size(625, 509);
+                       this.tbcPages.SizeMode = System.Windows.Forms.TabSizeMode.Fixed;
+                       this.tbcPages.TabIndex = 0;
+                       this.tbcPages.SelectedIndexChanged += new System.EventHandler(this.tbcPages_SelectedIndexChanged);
+                       // 
+                       // tabRetrieveCertificate
+                       // 
+                       this.tabRetrieveCertificate.Controls.Add(this.lblRetrieveCertificate);
+                       this.tabRetrieveCertificate.Controls.Add(this.prgRetrieveCertificate);
+                       this.tabRetrieveCertificate.Location = new System.Drawing.Point(4, 5);
+                       this.tabRetrieveCertificate.Name = "tabRetrieveCertificate";
+                       this.tabRetrieveCertificate.Padding = new System.Windows.Forms.Padding(3);
+                       this.tabRetrieveCertificate.Size = new System.Drawing.Size(617, 500);
+                       this.tabRetrieveCertificate.TabIndex = 7;
+                       this.tabRetrieveCertificate.Text = "Checking Certificate";
+                       this.tabRetrieveCertificate.UseVisualStyleBackColor = true;
+                       // 
+                       // tabVerifyCertificate
+                       // 
+                       this.tabVerifyCertificate.Controls.Add(this.grpX509Fields);
+                       this.tabVerifyCertificate.Controls.Add(this.txtX509Subject);
+                       this.tabVerifyCertificate.Controls.Add(this.txtX509Issuer);
+                       this.tabVerifyCertificate.Controls.Add(this.lblX509Subject);
+                       this.tabVerifyCertificate.Controls.Add(this.lblX509Issuer);
+                       this.tabVerifyCertificate.Controls.Add(this.lblX509Prompt);
+                       this.tabVerifyCertificate.Location = new System.Drawing.Point(4, 5);
+                       this.tabVerifyCertificate.Name = "tabVerifyCertificate";
+                       this.tabVerifyCertificate.Padding = new System.Windows.Forms.Padding(3);
+                       this.tabVerifyCertificate.Size = new System.Drawing.Size(617, 500);
+                       this.tabVerifyCertificate.TabIndex = 6;
+                       this.tabVerifyCertificate.Text = "Verify Certificate";
+                       this.tabVerifyCertificate.UseVisualStyleBackColor = true;
+                       // 
+                       // grpX509Fields
+                       // 
+                       this.grpX509Fields.Controls.Add(this.txtX509Field);
+                       this.grpX509Fields.Controls.Add(this.lvwX509Fields);
+                       this.grpX509Fields.Location = new System.Drawing.Point(11, 115);
+                       this.grpX509Fields.Name = "grpX509Fields";
+                       this.grpX509Fields.Size = new System.Drawing.Size(598, 369);
+                       this.grpX509Fields.TabIndex = 8;
+                       this.grpX509Fields.TabStop = false;
+                       this.grpX509Fields.Text = "X509 Fields";
+                       // 
+                       // txtX509Field
+                       // 
+                       this.txtX509Field.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+                       this.txtX509Field.Location = new System.Drawing.Point(6, 197);
+                       this.txtX509Field.Multiline = true;
+                       this.txtX509Field.Name = "txtX509Field";
+                       this.txtX509Field.ReadOnly = true;
+                       this.txtX509Field.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
+                       this.txtX509Field.Size = new System.Drawing.Size(586, 166);
+                       this.txtX509Field.TabIndex = 9;
+                       // 
+                       // lvwX509Fields
+                       // 
+                       this.lvwX509Fields.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
+            this.colField,
+            this.colValue});
+                       this.lvwX509Fields.Location = new System.Drawing.Point(6, 19);
+                       this.lvwX509Fields.Name = "lvwX509Fields";
+                       this.lvwX509Fields.Size = new System.Drawing.Size(586, 172);
+                       this.lvwX509Fields.TabIndex = 8;
+                       this.lvwX509Fields.UseCompatibleStateImageBehavior = false;
+                       this.lvwX509Fields.View = System.Windows.Forms.View.Details;
+                       this.lvwX509Fields.SelectedIndexChanged += new System.EventHandler(this.lvwX509Fields_SelectedIndexChanged);
+                       // 
+                       // colField
+                       // 
+                       this.colField.Text = "Field";
+                       this.colField.Width = 200;
+                       // 
+                       // colValue
+                       // 
+                       this.colValue.Text = "Value";
+                       this.colValue.Width = 350;
+                       // 
+                       // txtX509Subject
+                       // 
+                       this.txtX509Subject.Location = new System.Drawing.Point(71, 73);
+                       this.txtX509Subject.Name = "txtX509Subject";
+                       this.txtX509Subject.ReadOnly = true;
+                       this.txtX509Subject.Size = new System.Drawing.Size(532, 20);
+                       this.txtX509Subject.TabIndex = 4;
+                       // 
+                       // txtX509Issuer
+                       // 
+                       this.txtX509Issuer.Location = new System.Drawing.Point(71, 47);
+                       this.txtX509Issuer.Name = "txtX509Issuer";
+                       this.txtX509Issuer.ReadOnly = true;
+                       this.txtX509Issuer.Size = new System.Drawing.Size(532, 20);
+                       this.txtX509Issuer.TabIndex = 3;
+                       // 
+                       // lblX509Subject
+                       // 
+                       this.lblX509Subject.AutoSize = true;
+                       this.lblX509Subject.Location = new System.Drawing.Point(8, 77);
+                       this.lblX509Subject.Name = "lblX509Subject";
+                       this.lblX509Subject.Size = new System.Drawing.Size(46, 13);
+                       this.lblX509Subject.TabIndex = 2;
+                       this.lblX509Subject.Text = "Subject:";
+                       // 
+                       // lblX509Issuer
+                       // 
+                       this.lblX509Issuer.AutoSize = true;
+                       this.lblX509Issuer.Location = new System.Drawing.Point(8, 50);
+                       this.lblX509Issuer.Name = "lblX509Issuer";
+                       this.lblX509Issuer.Size = new System.Drawing.Size(38, 13);
+                       this.lblX509Issuer.TabIndex = 1;
+                       this.lblX509Issuer.Text = "Issuer:";
+                       // 
+                       // lblX509Prompt
+                       // 
+                       this.lblX509Prompt.AutoSize = true;
+                       this.lblX509Prompt.Location = new System.Drawing.Point(8, 15);
+                       this.lblX509Prompt.Name = "lblX509Prompt";
+                       this.lblX509Prompt.Size = new System.Drawing.Size(201, 13);
+                       this.lblX509Prompt.TabIndex = 0;
+                       this.lblX509Prompt.Text = "Please verify the master\'s SSL certificate:";
+                       // 
                        // picBanner
                        // 
                        this.picBanner.Image = global::Icinga.Properties.Resources.icinga_banner;
                        this.picBanner.TabIndex = 1;
                        this.picBanner.TabStop = false;
                        // 
-                       // btnBack
+                       // lblRetrieveCertificate
                        // 
-                       this.btnBack.Enabled = false;
-                       this.btnBack.Location = new System.Drawing.Point(367, 592);
-                       this.btnBack.Name = "btnBack";
-                       this.btnBack.Size = new System.Drawing.Size(75, 23);
-                       this.btnBack.TabIndex = 1;
-                       this.btnBack.Text = "< &Back";
-                       this.btnBack.UseVisualStyleBackColor = true;
-                       this.btnBack.Click += new System.EventHandler(this.btnBack_Click);
+                       this.lblRetrieveCertificate.AutoSize = true;
+                       this.lblRetrieveCertificate.Location = new System.Drawing.Point(164, 229);
+                       this.lblRetrieveCertificate.Name = "lblRetrieveCertificate";
+                       this.lblRetrieveCertificate.Size = new System.Drawing.Size(110, 13);
+                       this.lblRetrieveCertificate.TabIndex = 3;
+                       this.lblRetrieveCertificate.Text = "Checking certificate...";
                        // 
-                       // btnNext
+                       // prgRetrieveCertificate
                        // 
-                       this.btnNext.Enabled = false;
-                       this.btnNext.Location = new System.Drawing.Point(448, 592);
-                       this.btnNext.Name = "btnNext";
-                       this.btnNext.Size = new System.Drawing.Size(75, 23);
-                       this.btnNext.TabIndex = 2;
-                       this.btnNext.Text = "&Next >";
-                       this.btnNext.UseVisualStyleBackColor = true;
-                       this.btnNext.Click += new System.EventHandler(this.btnNext_Click);
-                       // 
-                       // btnCancel
-                       // 
-                       this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
-                       this.btnCancel.Location = new System.Drawing.Point(538, 592);
-                       this.btnCancel.Name = "btnCancel";
-                       this.btnCancel.Size = new System.Drawing.Size(75, 23);
-                       this.btnCancel.TabIndex = 3;
-                       this.btnCancel.Text = "Cancel";
-                       this.btnCancel.UseVisualStyleBackColor = true;
-                       this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
-                       // 
-                       // tabConfigure
-                       // 
-                       this.tabConfigure.Controls.Add(this.lblConfigStatus);
-                       this.tabConfigure.Controls.Add(this.prgConfig);
-                       this.tabConfigure.Location = new System.Drawing.Point(4, 5);
-                       this.tabConfigure.Name = "tabConfigure";
-                       this.tabConfigure.Padding = new System.Windows.Forms.Padding(3);
-                       this.tabConfigure.Size = new System.Drawing.Size(617, 500);
-                       this.tabConfigure.TabIndex = 4;
-                       this.tabConfigure.Text = "Configure Icinga 2";
-                       this.tabConfigure.UseVisualStyleBackColor = true;
-                       // 
-                       // prgConfig
-                       // 
-                       this.prgConfig.Location = new System.Drawing.Point(184, 223);
-                       this.prgConfig.Name = "prgConfig";
-                       this.prgConfig.Size = new System.Drawing.Size(289, 23);
-                       this.prgConfig.TabIndex = 0;
-                       // 
-                       // lblConfigStatus
-                       // 
-                       this.lblConfigStatus.AutoSize = true;
-                       this.lblConfigStatus.Location = new System.Drawing.Point(184, 204);
-                       this.lblConfigStatus.Name = "lblConfigStatus";
-                       this.lblConfigStatus.Size = new System.Drawing.Size(141, 13);
-                       this.lblConfigStatus.TabIndex = 1;
-                       this.lblConfigStatus.Text = "Updating the configuration...";
-                       // 
-                       // tabFinish
-                       // 
-                       this.tabFinish.Controls.Add(this.label1);
-                       this.tabFinish.Location = new System.Drawing.Point(4, 5);
-                       this.tabFinish.Name = "tabFinish";
-                       this.tabFinish.Padding = new System.Windows.Forms.Padding(3);
-                       this.tabFinish.Size = new System.Drawing.Size(617, 500);
-                       this.tabFinish.TabIndex = 5;
-                       this.tabFinish.Text = "Finish";
-                       this.tabFinish.UseVisualStyleBackColor = true;
-                       // 
-                       // label1
-                       // 
-                       this.label1.AutoSize = true;
-                       this.label1.Location = new System.Drawing.Point(34, 35);
-                       this.label1.Name = "label1";
-                       this.label1.Size = new System.Drawing.Size(214, 13);
-                       this.label1.TabIndex = 0;
-                       this.label1.Text = "The Icinga 2 agent was set up successfully.";
+                       this.prgRetrieveCertificate.Location = new System.Drawing.Point(164, 248);
+                       this.prgRetrieveCertificate.Name = "prgRetrieveCertificate";
+                       this.prgRetrieveCertificate.Size = new System.Drawing.Size(289, 23);
+                       this.prgRetrieveCertificate.TabIndex = 2;
                        // 
                        // AgentWizard
                        // 
+                       this.AcceptButton = this.btnNext;
                        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
                        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+                       this.CancelButton = this.btnCancel;
                        this.ClientSize = new System.Drawing.Size(625, 624);
                        this.Controls.Add(this.btnCancel);
                        this.Controls.Add(this.btnNext);
                        this.Name = "AgentWizard";
                        this.Text = "Icinga 2 Agent Wizard";
                        this.Shown += new System.EventHandler(this.AgentWizard_Shown);
-                       this.tbcPages.ResumeLayout(false);
-                       this.tabAgentKey.ResumeLayout(false);
-                       this.tabAgentKey.PerformLayout();
-                       this.tabCSR.ResumeLayout(false);
-                       this.tabCSR.PerformLayout();
-                       this.tabCertificateBundle.ResumeLayout(false);
-                       this.tabCertificateBundle.PerformLayout();
+                       this.tabFinish.ResumeLayout(false);
+                       this.tabFinish.PerformLayout();
+                       this.tabConfigure.ResumeLayout(false);
+                       this.tabConfigure.PerformLayout();
                        this.tabParameters.ResumeLayout(false);
                        this.tabParameters.PerformLayout();
-                       this.groupBox3.ResumeLayout(false);
-                       this.groupBox3.PerformLayout();
                        this.groupBox2.ResumeLayout(false);
                        this.groupBox2.PerformLayout();
                        this.groupBox1.ResumeLayout(false);
                        this.groupBox1.PerformLayout();
+                       this.tbcPages.ResumeLayout(false);
+                       this.tabRetrieveCertificate.ResumeLayout(false);
+                       this.tabRetrieveCertificate.PerformLayout();
+                       this.tabVerifyCertificate.ResumeLayout(false);
+                       this.tabVerifyCertificate.PerformLayout();
+                       this.grpX509Fields.ResumeLayout(false);
+                       this.grpX509Fields.PerformLayout();
                        ((System.ComponentModel.ISupportInitialize)(this.picBanner)).EndInit();
-                       this.tabConfigure.ResumeLayout(false);
-                       this.tabConfigure.PerformLayout();
-                       this.tabFinish.ResumeLayout(false);
-                       this.tabFinish.PerformLayout();
                        this.ResumeLayout(false);
 
                }
 
                #endregion
 
-               private System.Windows.Forms.TabControl tbcPages;
-               private System.Windows.Forms.TabPage tabAgentKey;
-               private System.Windows.Forms.TabPage tabCSR;
                private System.Windows.Forms.PictureBox picBanner;
                private System.Windows.Forms.Button btnBack;
                private System.Windows.Forms.Button btnNext;
                private System.Windows.Forms.Button btnCancel;
-               private System.Windows.Forms.Label lblHostKey;
-               private System.Windows.Forms.ProgressBar prgHostKey;
-               private System.Windows.Forms.TextBox txtCSR;
-               private System.Windows.Forms.Label lblCSRPrompt;
-               private System.Windows.Forms.TabPage tabCertificateBundle;
-               private System.Windows.Forms.TextBox txtBundle;
-               private System.Windows.Forms.Label lblBundlePrompt;
+               private System.Windows.Forms.TabPage tabFinish;
+               private System.Windows.Forms.Label lblSetupCompleted;
+               private System.Windows.Forms.TabPage tabConfigure;
+               private System.Windows.Forms.Label lblConfigStatus;
+               private System.Windows.Forms.ProgressBar prgConfig;
                private System.Windows.Forms.TabPage tabParameters;
-               private System.Windows.Forms.GroupBox groupBox1;
-               private System.Windows.Forms.TextBox txtMasterInstance;
-               private System.Windows.Forms.Label lblMasterInstance;
-               private System.Windows.Forms.RadioButton rdoNoMaster;
-               private System.Windows.Forms.RadioButton rdoNewMaster;
+               private System.Windows.Forms.TextBox txtInstanceName;
+               private System.Windows.Forms.Label lblInstanceName;
                private System.Windows.Forms.GroupBox groupBox2;
+               private System.Windows.Forms.RadioButton rdoNoListener;
                private System.Windows.Forms.TextBox txtListenerPort;
                private System.Windows.Forms.Label lblListenerPort;
                private System.Windows.Forms.RadioButton rdoListener;
-               private System.Windows.Forms.RadioButton rdoNoListener;
-               private System.Windows.Forms.GroupBox groupBox3;
-               private System.Windows.Forms.Label lblPeerHost;
-               private System.Windows.Forms.RadioButton rdoConnect;
-               private System.Windows.Forms.TextBox txtPeerPort;
-               private System.Windows.Forms.Label lblPeerPort;
-               private System.Windows.Forms.TextBox txtPeerHost;
-               private System.Windows.Forms.RadioButton rdoNoConnect;
-               private System.Windows.Forms.TextBox txtInstanceName;
-               private System.Windows.Forms.Label label5;
-               private System.Windows.Forms.TabPage tabConfigure;
-               private System.Windows.Forms.Label lblConfigStatus;
-               private System.Windows.Forms.ProgressBar prgConfig;
-               private System.Windows.Forms.TabPage tabFinish;
-               private System.Windows.Forms.Label label1;
+               private System.Windows.Forms.GroupBox groupBox1;
+               private System.Windows.Forms.Button btnRemoveEndpoint;
+               private System.Windows.Forms.Button btnAddEndpoint;
+               private System.Windows.Forms.ListView lvwEndpoints;
+               private System.Windows.Forms.ColumnHeader colHost;
+               private System.Windows.Forms.ColumnHeader colPort;
+               private System.Windows.Forms.RadioButton rdoNoMaster;
+               private System.Windows.Forms.RadioButton rdoNewMaster;
+               private System.Windows.Forms.TabControl tbcPages;
+               private System.Windows.Forms.TabPage tabVerifyCertificate;
+               private System.Windows.Forms.Label lblX509Prompt;
+               private System.Windows.Forms.TextBox txtX509Subject;
+               private System.Windows.Forms.TextBox txtX509Issuer;
+               private System.Windows.Forms.Label lblX509Subject;
+               private System.Windows.Forms.Label lblX509Issuer;
+               private System.Windows.Forms.GroupBox grpX509Fields;
+               private System.Windows.Forms.ListView lvwX509Fields;
+               private System.Windows.Forms.ColumnHeader colField;
+               private System.Windows.Forms.ColumnHeader colValue;
+               private System.Windows.Forms.TextBox txtX509Field;
+               private System.Windows.Forms.TabPage tabRetrieveCertificate;
+               private System.Windows.Forms.Label lblRetrieveCertificate;
+               private System.Windows.Forms.ProgressBar prgRetrieveCertificate;
        }
 }
 
index eb0a24a00f843051ec3bcf08ebe6be345e982eb2..79e716c8250ac2ddbc0b8ffe6b2b25749260a984 100644 (file)
@@ -5,6 +5,7 @@ using System.Collections.Generic;
 using System.ComponentModel;
 using System.Windows.Forms;
 using System.Runtime.InteropServices;
+using System.Security.Cryptography.X509Certificates;
 using System.Threading;
 using System.Net.NetworkInformation;
 using Microsoft.Win32;
@@ -12,17 +13,11 @@ using System.IO.Compression;
 using System.Diagnostics;
 using System.ServiceProcess;
 using System.Security.AccessControl;
-using tar_cs;
 
 namespace Icinga
 {
        public partial class AgentWizard : Form
        {
-               [DllImport("base", CallingConvention = CallingConvention.Cdecl)]
-               private extern static int MakeX509CSR(string cn, string keyfile, string csrfile);
-
-               delegate void FormCallback();
-
                public AgentWizard()
                {
                        InitializeComponent();
@@ -78,41 +73,20 @@ namespace Icinga
                        }
                }
 
-               private void GenerateHostKey()
-               {
-                       if (!File.Exists(Icinga2InstallDir + "\\etc\\icinga2\\pki\\agent\\agent.key") ||
-                           !File.Exists(Icinga2InstallDir + "\\etc\\icinga2\\pki\\agent\\agent.csr")) {
-                               try {
-                                       MakeX509CSR(Icinga2InstanceName,
-                                           Icinga2InstallDir + "\\etc\\icinga2\\pki\\agent\\agent.key",
-                                           Icinga2InstallDir + "\\etc\\icinga2\\pki\\agent\\agent.csr");
-                               } catch (Exception ex) {
-                                       FatalError("MakeX509CSR failed: " + ex.Message);
-                               }
-                       }
-
-                       FinishHostKey();
-               }
-
-               private void FinishHostKey()
+               private void SetRetrievalStatus(int pct)
                {
                        if (InvokeRequired) {
-                               Invoke(new FormCallback(FinishHostKey));
+                               Invoke((MethodInvoker)delegate { SetRetrievalStatus(pct); });
                                return;
                        }
 
-                       txtCSR.Text = File.ReadAllText(Icinga2InstallDir + "\\etc\\icinga2\\pki\\agent\\agent.csr").Replace("\n", "\r\n");
-
-                       if (!File.Exists(Icinga2InstallDir + "\\etc\\icinga2\\pki\\agent\\agent.crt"))
-                               tbcPages.SelectedTab = tabCSR;
-                       else
-                               tbcPages.SelectedTab = tabParameters;
+                       prgRetrieveCertificate.Value = pct;
                }
 
                private void SetConfigureStatus(int pct, string message)
                {
                        if (InvokeRequired) {
-                               Invoke(new FormCallback(() => SetConfigureStatus(pct, message)));
+                               Invoke((MethodInvoker)delegate { SetConfigureStatus(pct, message); });
                                return;
                        }
 
@@ -120,6 +94,56 @@ namespace Icinga
                        lblConfigStatus.Text = message;
                }
 
+               private void VerifyCertificate(string host, string port)
+               {
+                       SetRetrievalStatus(25);
+
+                       string pathPrefix = Icinga2InstallDir + "\\etc\\icinga2\\pki\\" + txtInstanceName.Text;
+
+                       ProcessStartInfo psi;
+
+                       if (!File.Exists(pathPrefix + ".crt")) {
+                               psi = new ProcessStartInfo();
+                               psi.FileName = Icinga2InstallDir + "\\sbin\\icinga2.exe";
+                               psi.Arguments = "pki new-cert --cn \"" + txtInstanceName.Text + "\" --keyfile \"" + pathPrefix + ".key\" --certfile \"" + pathPrefix + ".crt\"";
+                               psi.CreateNoWindow = true;
+                               psi.UseShellExecute = false;
+
+                               using (Process proc = Process.Start(psi)) {
+                                       proc.WaitForExit();
+
+                                       if (proc.ExitCode != 0) {
+                                               Invoke((MethodInvoker)delegate { FatalError("The Windows service could not be installed."); });
+                                               return;
+                                       }
+                               }
+                       }
+
+                       SetRetrievalStatus(50);
+
+                       string trustedfile = Path.GetTempFileName();
+
+                       psi = new ProcessStartInfo();
+                       psi.FileName = Icinga2InstallDir + "\\sbin\\icinga2.exe";
+                       psi.Arguments = "pki save-cert --host \"" + host + "\" --port \"" + port + "\" --keyfile \"" + pathPrefix + ".key\" --certfile \"" + pathPrefix + ".crt\" --trustedfile \"" + trustedfile + "\"";
+                       psi.CreateNoWindow = true;
+                       psi.UseShellExecute = false;
+
+                       using (Process proc = Process.Start(psi)) {
+                               proc.WaitForExit();
+
+                               if (proc.ExitCode != 0) {
+                                       Invoke((MethodInvoker)delegate { FatalError("Could not retrieve the master's X509 certificate."); });
+                                       return;
+                               }
+                       }
+
+                       SetRetrievalStatus(100);
+       
+                       X509Certificate2 cert = new X509Certificate2(trustedfile);
+                       Invoke((MethodInvoker)delegate { ShowCertificatePrompt(cert); });
+               }
+
                private void ConfigureService()
                {
                        SetConfigureStatus(0, "Updating configuration files...");
@@ -138,23 +162,23 @@ namespace Icinga
                                            "  ca_path = SysconfDir + \"/icinga2/pki/agent/ca.crt\"\n"
                                        );
 
-                                       if (rdoNoMaster.Checked)
-                                               sw.Write("  upstream_name = \"{0}\"\n", txtMasterInstance.Text);
+                                       /*if (rdoNoMaster.Checked)
+                                               sw.Write("  upstream_name = \"{0}\"\n", txtMasterInstance.Text);*/
 
                                        if (rdoListener.Checked)
                                                sw.Write("  bind_port = \"{0}\"\n", txtListenerPort.Text);
 
-                                       if (rdoConnect.Checked)
+                                       /*if (rdoConnect.Checked)
                                                sw.Write(
                                                    "  upstream_host = \"{0}\"\n" +
                                                    "  upstream_port = \"{1}\"\n", txtPeerHost.Text, txtPeerPort.Text
-                                               );
+                                               );*/
 
                                        sw.Write("}\n");
                                }
                        }
 
-                       EnableFeature("agent");
+                       EnableFeature("api");
                        EnableFeature("checker");
 
                        SetConfigureStatus(50, "Setting ACLs for the Icinga 2 directory...");
@@ -167,17 +191,30 @@ namespace Icinga
                        di.SetAccessControl(ds);
 
                        SetConfigureStatus(75, "Installing the Icinga 2 service...");
+
                        ProcessStartInfo psi = new ProcessStartInfo();
                        psi.FileName = Icinga2InstallDir + "\\sbin\\icinga2.exe";
-                       psi.Arguments = "--scm-install -c \"" + Icinga2InstallDir + "\\etc\\icinga2\\icinga2.conf\"";
+                       psi.Arguments = "--scm-uninstall";
                        psi.CreateNoWindow = true;
                        psi.UseShellExecute = false;
 
                        using (Process proc = Process.Start(psi)) {
                                proc.WaitForExit();
+                       }
+                       
+                       psi = new ProcessStartInfo();
+                       psi.FileName = Icinga2InstallDir + "\\sbin\\icinga2.exe";
+                       psi.Arguments = "--scm-install daemon";
+                       psi.CreateNoWindow = true;
+                       psi.UseShellExecute = false;
 
-                               if (proc.ExitCode != 0)
-                                       FatalError("The Windows service could not be installed.");
+                       using (Process proc = Process.Start(psi)) {
+                               proc.WaitForExit();
+
+                               if (proc.ExitCode != 0) {
+                                       Invoke((MethodInvoker)delegate { FatalError("The Windows service could not be installed."); });
+                                       return;
+                               }
                        }
 
                        SetConfigureStatus(100, "Finished.");
@@ -188,7 +225,7 @@ namespace Icinga
                private void FinishConfigure()
                {
                        if (InvokeRequired) {
-                               Invoke(new FormCallback(FinishConfigure));
+                               Invoke((MethodInvoker)FinishConfigure);
                                return;
                        }
 
@@ -214,26 +251,29 @@ namespace Icinga
 
                        Directory.CreateDirectory(installDir + "\\etc\\icinga2\\pki\\agent");
 
-                       Thread thread = new Thread(GenerateHostKey);
-                       thread.IsBackground = true;
-                       thread.Start();
+                       
                }
 
                private void btnBack_Click(object sender, EventArgs e)
                {
-                       tbcPages.SelectedIndex--;
+                       int offset = 1;
+
+                       if (tbcPages.SelectedTab == tabVerifyCertificate)
+                               offset++;
+
+                       tbcPages.SelectedIndex -= offset;
                }
 
                private void btnNext_Click(object sender, EventArgs e)
                {
                        if (tbcPages.SelectedTab == tabParameters) {
-                               if (rdoNoMaster.Checked && txtMasterInstance.Text == "") {
-                                       Warning("You need to enter the name of the master instance.");
+                               if (txtInstanceName.Text.Length == 0) {
+                                       Warning("Please enter an instance name.");
                                        return;
                                }
 
-                               if (rdoConnect.Checked && (txtPeerHost.Text == "" || txtPeerPort.Text == "")) {
-                                       Warning("You need to specify a host and port.");
+                               if (rdoNoMaster.Checked && lvwEndpoints.Items.Count == 0) {
+                                       Warning("You need to add at least one master endpoint.");
                                        return;
                                }
 
@@ -241,18 +281,12 @@ namespace Icinga
                                        Warning("You need to specify a listener port.");
                                        return;
                                }
-
-                               if (rdoNoListener.Checked && rdoNoConnect.Checked) {
-                                       Warning("You need to enable the listener or outbound connects.");
-                                       return;
-                               }
                        }
 
                        if (tbcPages.SelectedTab == tabFinish)
                                Application.Exit();
 
                        tbcPages.SelectedIndex++;
-                       btnBack.Enabled = true;
                }
 
                private void btnCancel_Click(object sender, EventArgs e)
@@ -264,15 +298,22 @@ namespace Icinga
                {
                        Refresh();
 
-                       btnBack.Enabled = (tbcPages.SelectedTab != tabCSR && tbcPages.SelectedTab != tabFinish);
-                       btnNext.Enabled = true;
+                       btnBack.Enabled = (tbcPages.SelectedTab == tabVerifyCertificate);
+                       btnNext.Enabled = (tbcPages.SelectedTab == tabParameters || tbcPages.SelectedTab == tabVerifyCertificate || tbcPages.SelectedTab == tabFinish);
 
                        if (tbcPages.SelectedTab == tabFinish) {
                                btnNext.Text = "&Finish >";
                                btnCancel.Enabled = false;
                        }
 
-                       if (tbcPages.SelectedTab == tabParameters &&
+                       if (tbcPages.SelectedTab == tabRetrieveCertificate) {
+                               ListViewItem lvi = lvwEndpoints.Items[0];
+
+                               Thread thread = new Thread((ThreadStart)delegate { VerifyCertificate(lvi.SubItems[0].Text, lvi.SubItems[1].Text); });
+                               thread.Start();
+                       }
+
+                       /*if (tbcPages.SelectedTab == tabParameters &&
                            !File.Exists(Icinga2InstallDir + "\\etc\\icinga2\\pki\\agent\\agent.crt")) {
                                byte[] bytes = Convert.FromBase64String(txtBundle.Text);
                                MemoryStream ms = new MemoryStream(bytes);
@@ -286,7 +327,7 @@ namespace Icinga
                                ms2.Position = 0;
                                TarReader tr = new TarReader(ms2);
                                tr.ReadToEnd(Icinga2InstallDir + "\\etc\\icinga2\\pki\\agent");
-                       }
+                       }*/
 
                        if (tbcPages.SelectedTab == tabConfigure) {
                                Thread thread = new Thread(ConfigureService);
@@ -296,7 +337,9 @@ namespace Icinga
 
                private void RadioMaster_CheckedChanged(object sender, EventArgs e)
                {
-                       txtMasterInstance.Enabled = !rdoNewMaster.Checked;
+                       lvwEndpoints.Enabled = !rdoNewMaster.Checked;
+                       btnAddEndpoint.Enabled = !rdoNewMaster.Checked;
+                       btnRemoveEndpoint.Enabled = !rdoNewMaster.Checked && lvwEndpoints.SelectedItems.Count > 0;
                }
 
                private void RadioListener_CheckedChanged(object sender, EventArgs e)
@@ -304,10 +347,88 @@ namespace Icinga
                        txtListenerPort.Enabled = rdoListener.Checked;
                }
 
-               private void RadioConnect_CheckedChanged(object sender, EventArgs e)
+               private void AddCertificateField(string name, string shortValue, string longValue = null)
+               {
+                       ListViewItem lvi = new ListViewItem();
+                       lvi.Text = name;
+                       lvi.SubItems.Add(shortValue);
+                       if (longValue == null)
+                               longValue = shortValue;
+                       lvi.Tag = longValue;
+                       lvwX509Fields.Items.Add(lvi);
+               }
+
+               private string PadText(string input)
                {
-                       txtPeerHost.Enabled = rdoConnect.Checked;
-                       txtPeerPort.Enabled = rdoConnect.Checked;
+                       string output = "";
+
+                       for (int i = 0; i < input.Length; i += 2) {
+                               if (output != "")
+                                       output += " ";
+
+                               int len = 2;
+                               if (input.Length - i < 2)
+                                       len = input.Length - i;
+                               output += input.Substring(i, len);
+                       }
+
+                       return output;
+               }
+
+               private void ShowCertificatePrompt(X509Certificate2 certificate)
+               {
+                       txtX509Issuer.Text = certificate.Issuer;
+                       txtX509Subject.Text = certificate.Subject;
+
+                       AddCertificateField("Version", "V" + certificate.Version.ToString());
+                       AddCertificateField("Serial number", certificate.SerialNumber);
+                       AddCertificateField("Signature algorithm", certificate.SignatureAlgorithm.FriendlyName);
+                       AddCertificateField("Valid from", certificate.NotBefore.ToString());
+                       AddCertificateField("Valid to", certificate.NotAfter.ToString());
+
+                       string pkey = BitConverter.ToString(certificate.PublicKey.EncodedKeyValue.RawData).Replace("-", " ");
+                       AddCertificateField("Public key", certificate.PublicKey.Oid.FriendlyName + " (" + certificate.PublicKey.Key.KeySize + " bits)", pkey);
+
+                       string thumbprint = PadText(certificate.Thumbprint);
+                       AddCertificateField("Thumbprint", thumbprint);
+
+                       tbcPages.SelectedTab = tabVerifyCertificate;
+               }
+
+               private void btnAddEndpoint_Click(object sender, EventArgs e)
+               {
+                       EndpointInputBox eib = new EndpointInputBox();
+
+                       if (eib.ShowDialog(this) == DialogResult.Cancel)
+                               return;
+
+                       ListViewItem lvi = new ListViewItem();
+                       lvi.Text = eib.txtHost.Text;
+                       lvi.SubItems.Add(eib.txtPort.Text);
+
+                       lvwEndpoints.Items.Add(lvi);
+               }
+
+               private void lvwEndpoints_SelectedIndexChanged(object sender, EventArgs e)
+               {
+                       btnRemoveEndpoint.Enabled = lvwEndpoints.SelectedItems.Count > 0;
+               }
+
+               private void lvwX509Fields_SelectedIndexChanged(object sender, EventArgs e)
+               {
+                       if (lvwX509Fields.SelectedItems.Count == 0)
+                               return;
+
+                       ListViewItem lvi = lvwX509Fields.SelectedItems[0];
+
+                       txtX509Field.Text = (string)lvi.Tag;
+               }
+
+               private void btnRemoveEndpoint_Click(object sender, EventArgs e)
+               {
+                       while (lvwEndpoints.SelectedItems.Count > 0) {
+                               lvwEndpoints.Items.Remove(lvwEndpoints.SelectedItems[0]);
+                       }
                }
        }
 }
index f17585dd26b5e08ea4a7cccb723d497345d3aa46..724f4a29298064f2327802bfadbb99eeda91091d 100644 (file)
     <value>2.0</value>
   </resheader>
   <resheader name="reader">
-    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
   <resheader name="writer">
-    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
-  <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+  <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
   <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>
         AAABAAEAICAQAAAABADoAgAAFgAAACgAAAAgAAAAQAAAAAEABAAAAAAAAAIAAAAAAAAAAAAAEAAAABAA
index 9e749508f5d49bfcb764c92acd112cd8bfce36c1..ca0921cb5692a18c9c4c6a5f13f5f054b850493b 100644 (file)
   </PropertyGroup>
   <ItemGroup>
     <Reference Include="System" />
+    <Reference Include="System.Data" />
     <Reference Include="System.Drawing" />
     <Reference Include="System.ServiceProcess" />
     <Reference Include="System.Windows.Forms" />
+    <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
     <Compile Include="AgentWizard.cs">
     <Compile Include="AgentWizard.Designer.cs">
       <DependentUpon>AgentWizard.cs</DependentUpon>
     </Compile>
+    <Compile Include="EndpointInputBox.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="EndpointInputBox.Designer.cs">
+      <DependentUpon>EndpointInputBox.cs</DependentUpon>
+    </Compile>
     <Compile Include="Program.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="tar-cs\ITarHeader.cs" />
-    <Compile Include="tar-cs\TarException.cs" />
-    <Compile Include="tar-cs\TarHeader.cs" />
-    <Compile Include="tar-cs\TarReader.cs" />
-    <Compile Include="tar-cs\UsTarHeader.cs" />
     <EmbeddedResource Include="AgentWizard.resx">
       <DependentUpon>AgentWizard.cs</DependentUpon>
     </EmbeddedResource>
+    <EmbeddedResource Include="EndpointInputBox.resx">
+      <DependentUpon>EndpointInputBox.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="Properties\Resources.resx">
       <Generator>ResXFileCodeGenerator</Generator>
       <LastGenOutput>Resources.Designer.cs</LastGenOutput>
diff --git a/agent/windows-setup-agent/tar-cs/COPYING b/agent/windows-setup-agent/tar-cs/COPYING
deleted file mode 100644 (file)
index 5425225..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-BSD License
-
-Copyright (c) 2009, Vladimir Vasiltsov All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
-    * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-    * Names of its contributors may not be used to endorse or promote products derived from this software without specific prior written permission. 
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
diff --git a/agent/windows-setup-agent/tar-cs/ITarHeader.cs b/agent/windows-setup-agent/tar-cs/ITarHeader.cs
deleted file mode 100644 (file)
index 9474f69..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-using System;
-
-namespace tar_cs
-{
-    public enum EntryType : byte
-    {
-        File = 0,
-        FileObsolete = 0x30,
-        HardLink = 0x31,
-        SymLink = 0x32,
-        CharDevice = 0x33,
-        BlockDevice = 0x34,
-        Directory = 0x35,
-        Fifo = 0x36,
-    }
-
-    public interface ITarHeader
-    {
-        string FileName { get; set; }
-        int Mode { get; set; }
-        int UserId { get; set; }
-        string UserName { get; set; }
-        int GroupId { get; set; }
-        string GroupName { get; set; }
-        long SizeInBytes { get; set; }
-        DateTime LastModification { get; set; }
-        int HeaderSize { get; }
-        EntryType EntryType { get; set; }
-    }
-}
\ No newline at end of file
diff --git a/agent/windows-setup-agent/tar-cs/TarException.cs b/agent/windows-setup-agent/tar-cs/TarException.cs
deleted file mode 100644 (file)
index 7ce62f3..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-using System;
-
-namespace tar_cs
-{
-    public class TarException : Exception
-    {
-        public TarException(string message) : base(message)
-        {
-        }
-    }
-}
\ No newline at end of file
diff --git a/agent/windows-setup-agent/tar-cs/TarHeader.cs b/agent/windows-setup-agent/tar-cs/TarHeader.cs
deleted file mode 100644 (file)
index eb95f29..0000000
+++ /dev/null
@@ -1,197 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.Net;
-using System.Text;
-using tar_cs;
-
-namespace tar_cs
-{
-    internal class TarHeader : ITarHeader
-    {
-        private readonly byte[] buffer = new byte[512];
-        private long headerChecksum;
-
-        public TarHeader()
-        {
-            // Default values
-            Mode = 511; // 0777 dec
-            UserId = 61; // 101 dec
-            GroupId = 61; // 101 dec
-        }
-
-        private string fileName;
-        protected readonly DateTime TheEpoch = new DateTime(1970, 1, 1, 0, 0, 0);
-        public EntryType EntryType { get; set; }
-        private static byte[] spaces = Encoding.ASCII.GetBytes("        ");
-
-        public virtual string FileName
-        {
-            get
-            {
-                return fileName.Replace("\0",string.Empty);
-            } 
-            set
-            {
-                if(value.Length > 100)
-                {
-                    throw new TarException("A file name can not be more than 100 chars long");
-                }
-                fileName = value;
-            }
-        }
-        public int Mode { get; set; }
-
-        public string ModeString
-        {
-            get { return Convert.ToString(Mode, 8).PadLeft(7, '0'); }
-        }
-
-        public int UserId { get; set; }
-        public virtual string UserName
-        {
-            get { return UserId.ToString(); }
-            set { UserId = Int32.Parse(value); }
-        }
-
-        public string UserIdString
-        {
-            get { return Convert.ToString(UserId, 8).PadLeft(7, '0'); }
-        }
-
-        public int GroupId { get; set; }
-        public virtual string GroupName
-        {
-            get { return GroupId.ToString(); }
-            set { GroupId = Int32.Parse(value); }
-        }
-
-        public string GroupIdString
-        {
-            get { return Convert.ToString(GroupId, 8).PadLeft(7, '0'); }
-        }
-
-        public long SizeInBytes { get; set; }
-
-        public string SizeString
-        {
-            get { return Convert.ToString(SizeInBytes, 8).PadLeft(11, '0'); }
-        }
-
-        public DateTime LastModification { get; set; }
-
-        public string LastModificationString
-        {
-            get
-            {
-                return Convert.ToString((long)(LastModification - TheEpoch).TotalSeconds, 8).PadLeft(11, '0');
-            }
-        }
-
-        public string HeaderChecksumString
-        {
-            get { return Convert.ToString(headerChecksum, 8).PadLeft(6, '0'); }
-        }
-
-
-        public virtual int HeaderSize
-        {
-            get { return 512; }
-        }
-
-        public byte[] GetBytes()
-        {
-            return buffer;
-        }
-
-        public virtual bool UpdateHeaderFromBytes()
-        {
-            FileName = Encoding.ASCII.GetString(buffer, 0, 100);
-            // thanks to Shasha Alperocivh. Trimming nulls.
-            Mode = Convert.ToInt32(Encoding.ASCII.GetString(buffer, 100, 7).Trim(), 8);
-            UserId = Convert.ToInt32(Encoding.ASCII.GetString(buffer, 108, 7).Trim(), 8);
-            GroupId = Convert.ToInt32(Encoding.ASCII.GetString(buffer, 116, 7).Trim(), 8);
-
-            EntryType = (EntryType)buffer[156];
-
-            if((buffer[124] & 0x80) == 0x80) // if size in binary
-            {
-                long sizeBigEndian = BitConverter.ToInt64(buffer,0x80);
-                SizeInBytes = IPAddress.NetworkToHostOrder(sizeBigEndian);
-            }
-            else
-            {
-                SizeInBytes = Convert.ToInt64(Encoding.ASCII.GetString(buffer, 124, 11), 8);
-            }
-            long unixTimeStamp = Convert.ToInt64(Encoding.ASCII.GetString(buffer,136,11),8);
-            LastModification = TheEpoch.AddSeconds(unixTimeStamp);
-
-            var storedChecksum = Convert.ToInt32(Encoding.ASCII.GetString(buffer,148,6));
-            RecalculateChecksum(buffer);
-            if (storedChecksum == headerChecksum)
-            {
-                return true;
-            }
-
-            RecalculateAltChecksum(buffer);
-            return storedChecksum == headerChecksum;
-        }
-
-        private void RecalculateAltChecksum(byte[] buf)
-        {
-            spaces.CopyTo(buf, 148);
-            headerChecksum = 0;
-            foreach(byte b in buf)
-            {
-                if((b & 0x80) == 0x80)
-                {
-                    headerChecksum -= b ^ 0x80;
-                }
-                else
-                {
-                    headerChecksum += b;
-                }
-            }
-        }
-
-        public virtual byte[] GetHeaderValue()
-        {
-            // Clean old values
-            Array.Clear(buffer,0, buffer.Length);
-
-            if (string.IsNullOrEmpty(FileName)) throw new TarException("FileName can not be empty.");
-            if (FileName.Length >= 100) throw new TarException("FileName is too long. It must be less than 100 bytes.");
-
-            // Fill header
-            Encoding.ASCII.GetBytes(FileName.PadRight(100, '\0')).CopyTo(buffer, 0);
-            Encoding.ASCII.GetBytes(ModeString).CopyTo(buffer, 100);
-            Encoding.ASCII.GetBytes(UserIdString).CopyTo(buffer, 108);
-            Encoding.ASCII.GetBytes(GroupIdString).CopyTo(buffer, 116);
-            Encoding.ASCII.GetBytes(SizeString).CopyTo(buffer, 124);
-            Encoding.ASCII.GetBytes(LastModificationString).CopyTo(buffer, 136);
-
-//            buffer[156] = 20;
-            buffer[156] = ((byte) EntryType);
-
-
-            RecalculateChecksum(buffer);
-
-            // Write checksum
-            Encoding.ASCII.GetBytes(HeaderChecksumString).CopyTo(buffer, 148);
-
-            return buffer;
-        }
-
-        protected virtual void RecalculateChecksum(byte[] buf)
-        {
-            // Set default value for checksum. That is 8 spaces.
-            spaces.CopyTo(buf, 148);
-
-            // Calculate checksum
-            headerChecksum = 0;
-            foreach (byte b in buf)
-            {
-                headerChecksum += b;
-            }
-        }
-    }
-}
\ No newline at end of file
diff --git a/agent/windows-setup-agent/tar-cs/TarReader.cs b/agent/windows-setup-agent/tar-cs/TarReader.cs
deleted file mode 100644 (file)
index 2e6b0c8..0000000
+++ /dev/null
@@ -1,224 +0,0 @@
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-
-namespace tar_cs
-{
-    /// <summary>
-    /// Extract contents of a tar file represented by a stream for the TarReader constructor
-    /// </summary>
-    public class TarReader
-    {
-        private readonly byte[] dataBuffer = new byte[512];
-        private readonly UsTarHeader header;
-        private readonly Stream inStream;
-        private long remainingBytesInFile;
-
-        /// <summary>
-        /// Constructs TarReader object to read data from `tarredData` stream
-        /// </summary>
-        /// <param name="tarredData">A stream to read tar archive from</param>
-        public TarReader(Stream tarredData)
-        {
-            inStream = tarredData;
-            header = new UsTarHeader();
-        }
-
-        public ITarHeader FileInfo
-        {
-            get { return header; }
-        }
-
-        /// <summary>
-        /// Read all files from an archive to a directory. It creates some child directories to
-        /// reproduce a file structure from the archive.
-        /// </summary>
-        /// <param name="destDirectory">The out directory.</param>
-        /// 
-        /// CAUTION! This method is not safe. It's not tar-bomb proof. 
-        /// {see http://en.wikipedia.org/wiki/Tar_(file_format) }
-        /// If you are not sure about the source of an archive you extracting,
-        /// then use MoveNext and Read and handle paths like ".." and "../.." according
-        /// to your business logic.
-        public void ReadToEnd(string destDirectory)
-        {
-            while (MoveNext(false))
-            {
-                string fileNameFromArchive = FileInfo.FileName;
-                string totalPath = destDirectory + Path.DirectorySeparatorChar + fileNameFromArchive;
-                if(UsTarHeader.IsPathSeparator(fileNameFromArchive[fileNameFromArchive.Length -1]) || FileInfo.EntryType == EntryType.Directory)
-                {
-                    // Record is a directory
-                    Directory.CreateDirectory(totalPath);
-                    continue;
-                }
-                // If record is a file
-                string fileName = Path.GetFileName(totalPath);
-                string directory = totalPath.Remove(totalPath.Length - fileName.Length);
-                Directory.CreateDirectory(directory);
-                using (FileStream file = File.Create(totalPath))
-                {
-                    Read(file);
-                }
-            }
-        }
-        
-        /// <summary>
-        /// Read data from a current file to a Stream.
-        /// </summary>
-        /// <param name="dataDestanation">A stream to read data to</param>
-        /// 
-        /// <seealso cref="MoveNext"/>
-        public void Read(Stream dataDestanation)
-        {
-            Debug.WriteLine("tar stream position Read in: " + inStream.Position);
-            int readBytes;
-            byte[] read;
-            while ((readBytes = Read(out read)) != -1)
-            {
-                Debug.WriteLine("tar stream position Read while(...) : " + inStream.Position);
-                dataDestanation.Write(read, 0, readBytes);
-            }
-            Debug.WriteLine("tar stream position Read out: " + inStream.Position);
-        }
-
-        protected int Read(out byte[] buffer)
-        {
-            if(remainingBytesInFile == 0)
-            {
-                buffer = null;
-                return -1;
-            }
-            int align512 = -1;
-            long toRead = remainingBytesInFile - 512;
-
-            if (toRead > 0) 
-                toRead = 512;
-            else
-            {
-                align512 = 512 - (int)remainingBytesInFile;
-                toRead = remainingBytesInFile;
-            }
-
-            int bytesRead = 0;
-            long bytesRemainingToRead = toRead;
-            do
-            {
-
-                bytesRead = inStream.Read(dataBuffer, (int)(toRead-bytesRemainingToRead), (int)bytesRemainingToRead);
-                bytesRemainingToRead -= bytesRead;
-                remainingBytesInFile -= bytesRead;
-            } while (bytesRead < toRead && bytesRemainingToRead > 0);
-            
-            if(inStream.CanSeek && align512 > 0)
-            {
-                inStream.Seek(align512, SeekOrigin.Current);
-            }
-            else
-                while(align512 > 0)
-                {
-                    inStream.ReadByte();
-                    --align512;
-                }
-                
-            buffer = dataBuffer;
-            return bytesRead;
-        }
-
-        /// <summary>
-        /// Check if all bytes in buffer are zeroes
-        /// </summary>
-        /// <param name="buffer">buffer to check</param>
-        /// <returns>true if all bytes are zeroes, otherwise false</returns>
-        private static bool IsEmpty(IEnumerable<byte> buffer)
-        {
-            foreach(byte b in buffer)
-            {
-                if (b != 0) return false;
-            }
-            return true;
-        }
-
-        /// <summary>
-        /// Move internal pointer to a next file in archive.
-        /// </summary>
-        /// <param name="skipData">Should be true if you want to read a header only, otherwise false</param>
-        /// <returns>false on End Of File otherwise true</returns>
-        /// 
-        /// Example:
-        /// while(MoveNext())
-        /// { 
-        ///     Read(dataDestStream); 
-        /// }
-        /// <seealso cref="Read(Stream)"/>
-        public bool MoveNext(bool skipData)
-        {
-            Debug.WriteLine("tar stream position MoveNext in: " + inStream.Position);
-            if (remainingBytesInFile > 0)
-            {
-                if (!skipData)
-                {
-                    throw new TarException(
-                        "You are trying to change file while not all the data from the previous one was read. If you do want to skip files use skipData parameter set to true.");
-                }
-                // Skip to the end of file.
-                if (inStream.CanSeek)
-                {
-                    long remainer = (remainingBytesInFile%512);
-                    inStream.Seek(remainingBytesInFile + (512 - (remainer == 0 ? 512 : remainer) ), SeekOrigin.Current);
-                }
-                else
-                {
-                    byte[] buffer;
-                    while (Read(out buffer) > 0)
-                    {
-                    }
-                }
-            }
-
-            byte[] bytes = header.GetBytes();
-            int headerRead;
-            int bytesRemaining = header.HeaderSize;
-            do
-            {
-                headerRead = inStream.Read(bytes, header.HeaderSize - bytesRemaining, bytesRemaining);
-                bytesRemaining -= headerRead;
-                if (headerRead <= 0 && bytesRemaining > 0)
-                {
-                    throw new TarException("Can not read header");
-                }
-            } while (bytesRemaining > 0);
-
-            if(IsEmpty(bytes))
-            {
-                bytesRemaining = header.HeaderSize;
-                do
-                {
-                    headerRead = inStream.Read(bytes, header.HeaderSize - bytesRemaining, bytesRemaining);
-                    bytesRemaining -= headerRead;
-                    if (headerRead <= 0 && bytesRemaining > 0)
-                    {
-                        throw new TarException("Broken archive");
-                    }
-                    
-                } while (bytesRemaining > 0);
-                if (bytesRemaining == 0 && IsEmpty(bytes))
-                {
-                    Debug.WriteLine("tar stream position MoveNext  out(false): " + inStream.Position);
-                    return false;
-                }
-                throw new TarException("Broken archive");
-            }
-
-            if (header.UpdateHeaderFromBytes())
-            {
-                throw new TarException("Checksum check failed");
-            }
-
-            remainingBytesInFile = header.SizeInBytes;
-
-            Debug.WriteLine("tar stream position MoveNext  out(true): " + inStream.Position);
-            return true;
-        }
-    }
-}
\ No newline at end of file
diff --git a/agent/windows-setup-agent/tar-cs/UsTarHeader.cs b/agent/windows-setup-agent/tar-cs/UsTarHeader.cs
deleted file mode 100644 (file)
index 4692e9a..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-using System;
-using System.Net;
-using System.Text;
-
-namespace tar_cs
-{
-    /// <summary>
-    /// UsTar header implementation.
-    /// </summary>
-    internal class UsTarHeader : TarHeader
-    {
-        private const string magic = "ustar";
-        private const string version = "  ";
-        private string groupName;
-
-        private string namePrefix = string.Empty;
-        private string userName;
-
-        public override string UserName
-        {
-            get { return userName.Replace("\0",string.Empty); }
-            set
-            {
-                if (value.Length > 32)
-                {
-                    throw new TarException("user name can not be longer than 32 chars");
-                }
-                userName = value;
-            }
-        }
-
-        public override string GroupName
-        {
-            get { return groupName.Replace("\0",string.Empty); }
-            set
-            {
-                if (value.Length > 32)
-                {
-                    throw new TarException("group name can not be longer than 32 chars");
-                }
-                groupName = value;
-            }
-        }
-
-        public override string FileName
-        {
-            get { return namePrefix.Replace("\0", string.Empty) + base.FileName.Replace("\0", string.Empty); }
-            set
-            {
-                if (value.Length > 100)
-                {
-                    if (value.Length > 255)
-                    {
-                        throw new TarException("UsTar fileName can not be longer thatn 255 chars");
-                    }
-                    int position = value.Length - 100;
-
-                    // Find first path separator in the remaining 100 chars of the file name
-                    while (!IsPathSeparator(value[position]))
-                    {
-                        ++position;
-                        if (position == value.Length)
-                        {
-                            break;
-                        }
-                    }
-                    if (position == value.Length)
-                        position = value.Length - 100;
-                    namePrefix = value.Substring(0, position);
-                    base.FileName = value.Substring(position, value.Length - position);
-                }
-                else
-                {
-                    base.FileName = value;
-                }
-            }
-        }
-
-        public override bool UpdateHeaderFromBytes()
-        {
-            byte[] bytes = GetBytes();
-            UserName = Encoding.ASCII.GetString(bytes, 0x109, 32);
-            GroupName = Encoding.ASCII.GetString(bytes, 0x129, 32);
-            namePrefix = Encoding.ASCII.GetString(bytes, 347, 157);
-            return base.UpdateHeaderFromBytes();
-        }
-
-        internal static bool IsPathSeparator(char ch)
-        {
-            return (ch == '\\' || ch == '/' || ch == '|'); // All the path separators I ever met.
-        }
-
-        public override byte[] GetHeaderValue()
-        {
-            byte[] header = base.GetHeaderValue();
-
-            Encoding.ASCII.GetBytes(magic).CopyTo(header, 0x101); // Mark header as ustar
-            Encoding.ASCII.GetBytes(version).CopyTo(header, 0x106);
-            Encoding.ASCII.GetBytes(UserName).CopyTo(header, 0x109);
-            Encoding.ASCII.GetBytes(GroupName).CopyTo(header, 0x129);
-            Encoding.ASCII.GetBytes(namePrefix).CopyTo(header, 347);
-
-            if (SizeInBytes >= 0x1FFFFFFFF)
-            {
-                byte[] bytes = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(SizeInBytes));
-                SetMarker(AlignTo12(bytes)).CopyTo(header, 124);
-            }
-
-            RecalculateChecksum(header);
-            Encoding.ASCII.GetBytes(HeaderChecksumString).CopyTo(header, 148);
-            return header;
-        }
-
-        private static byte[] SetMarker(byte[] bytes)
-        {
-            bytes[0] |= 0x80;
-            return bytes;
-        }
-
-        private static byte[] AlignTo12(byte[] bytes)
-        {
-            var retVal = new byte[12];
-            bytes.CopyTo(retVal, 12 - bytes.Length);
-            return retVal;
-        }
-    }
-}
\ No newline at end of file
index 479c09f2b2ce0b2cdeb50ed608fb456968efa90d..67e1994fcb4abdd5672832c5d60f403bfd45df5b 100644 (file)
@@ -178,7 +178,11 @@ int Main(void)
        po::options_description hiddenDesc("Hidden options");
 
        hiddenDesc.add_options()
+#ifndef _WIN32
+               ("no-stack-rlimit", "used internally, do not specify manually")
+#else /* _WIN32 */
                ("no-stack-rlimit", "used internally, do not specify manually")
+#endif /* _WIN32 */
                ("arg", po::value<std::vector<std::string> >(), "positional argument");
 
        po::positional_options_description positionalDesc;
index 24c48d0b409363f898dfbdeb104a3c5d975c3305..32b3c0162bcc24dbde87a8593dd197980976bab2 100644 (file)
@@ -62,18 +62,6 @@ void Application::OnConfigLoaded(void)
 {
        m_PidFile = NULL;
 
-#ifdef _WIN32
-       /* disable GUI-based error messages for LoadLibrary() */
-       SetErrorMode(SEM_FAILCRITICALERRORS);
-
-       WSADATA wsaData;
-       if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) {
-               BOOST_THROW_EXCEPTION(win32_error()
-                   << boost::errinfo_api_function("WSAStartup")
-                   << errinfo_win32_error(WSAGetLastError()));
-       }
-#endif /* _WIN32 */
-
        ASSERT(m_Instance == NULL);
        m_Instance = this;
 }
@@ -143,6 +131,18 @@ void Application::InitializeBase(void)
        }
 #endif /* _WIN32 */
 
+#ifdef _WIN32
+       /* disable GUI-based error messages for LoadLibrary() */
+       SetErrorMode(SEM_FAILCRITICALERRORS);
+
+       WSADATA wsaData;
+       if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) {
+               BOOST_THROW_EXCEPTION(win32_error()
+                       << boost::errinfo_api_function("WSAStartup")
+                       << errinfo_win32_error(WSAGetLastError()));
+       }
+#endif /* _WIN32 */
+
        Utility::ExecuteDeferredInitializers();
 }
 
index 3e5bdefad251a54f1102e39ba7626ca435cc74c4..f35ddb77df80222c27b7a06d918a70b79f516097 100644 (file)
@@ -165,7 +165,7 @@ bool CLICommand::ParseCommand(int argc, char **argv, po::options_description& vi
                const std::vector<String>& vname = kv.first;
 
                for (int i = 0, k = 1; i < vname.size() && k < argc; i++, k++) {
-                       if (strcmp(argv[k], "--no-stack-rlimit") == 0 || strcmp(argv[k], "--autocomplete") == 0) {
+                       if (strcmp(argv[k], "--no-stack-rlimit") == 0 || strcmp(argv[k], "--autocomplete") == 0 || strcmp(argv[k], "--scm") == 0) {
                                i--;
                                continue;
                        }
@@ -227,7 +227,7 @@ void CLICommand::ShowCommands(int argc, char **argv, po::options_description *vi
                arg_begin = 0;
 
                for (int i = 0, k = 1; i < vname.size() && k < argc; i++, k++) {
-                       if (strcmp(argv[k], "--no-stack-rlimit") == 0 || strcmp(argv[k], "--autocomplete") == 0) {
+                       if (strcmp(argv[k], "--no-stack-rlimit") == 0 || strcmp(argv[k], "--autocomplete") == 0 || strcmp(argv[k], "--scm") == 0) {
                                i--;
                                arg_begin++;
                                continue;