Repository navigation
MSI install - #473
MSI install#473Thomas Meckel (tmeckel) wants to merge 12 commits into
Conversation
…t to $(ProjectDir) in that case to ensure a non empty SolutionDir property is present if projects aren't build using Visual Studio.
…ll always exit on an error.
|
Heath Stewart (@heaths), can you help review the WIX files? Thanks! |
Heath Stewart (heaths)
left a comment
There was a problem hiding this comment.
It's a great start, but WiX can do a lot of this for you, including support major ugprades properly, even across different CPU architectures. THat's why it's vital you let WiX auto-GUID the ProductCode, use a per-arch + per-configuration UpgradeCode, and do not hardcode component GUIDs, which will create problems in some cases.
| - name: Install OpenSSH | ||
| win_package: | ||
| path: openssh.msi | ||
| product_id: '{0240359E-6A4C-4884-9E94-B397A02D893C}' |
There was a problem hiding this comment.
You should never hardcode ProductCode. These should be auto-generated by WiX (if using WiX) or your own GUID. Major upgrade servicing is the ideal servicing path for small-ish packages (MSPs are fraught with problems and should be avoided). See https://devblogs.microsoft.com/setup/serviceability/ for a primer, and links to more information. This is based on over 20 years with MSI, and 15 on the .NET and VS teams working on their installs.
There was a problem hiding this comment.
Heath Stewart (@heaths) That's the way Ansible works and I guess other Configuration Management frameworks as well (except SCCM because it's a Microsoft Product 😏😀 ). You can discuss that the people who implemented it this way did it wrong, but from my point of view it's only consequent to do it so because technically the ProductCode uniquely identifies a MSI installation package (and the product version implicitly) and as far that I understood it over the years it compares to the tuple (packagename,version) in APT or RPM. When I misunderstood this completely than it's likely that the Ansible guys did it as well and the concept of the Product Code in MSI is hard to explain and to grasp.
So, in addition I've to admit that I always wondered why WiX creates a new ProductCode (and why this should be a good thing) at every build even if the version (contents) of the product didn't change and you only needed to build a new MSI because you had to correct a spelling error in a MSI dialog for example. In that case the product code shouldn't change because the product, you deliver using the MSI, didn't change. From my experience in the field I know that you always make great friends telling everybody your MSI has now a new product code because you changed the GUI of the MSI 😁 😁 Don't get me wrong, I definitely have less experience with MSI than you as I can see, but the issue with those changing product codes and MSI was, and constantly is, always a pain.
That's the reason why I tried to elaborate in the README.md why I approached the subject a little different and added some code in the build-msi.ps1 script to generate the product code based on a seed value and the version string. This procedure is standardized in chapter 4.3: Algorithm for Creating a Name-Based UUID of RFC-4122. That way you’ll get the same product code for the same product version and the algorithm guarantees that you can calculate the product code offline by only knowing the seed value and the version. This makes the product code predicable for every party in the game who’s responsible in delivering software. I know that upgrading MSI installations is totally different beast but having the ability to calculate the product code in a foreseeable way has many advantages from my point of view (see the Ansible example).
I hope I didn't step on your toes with my statements, as we Germans are known to communicate rather directly.
There was a problem hiding this comment.
Because keeping the same ProductCode when bumping the ProductVersion constitutes a minor upgrade which you can't simply install over top of another, e.g. double click. This is all documented in the MSI docs.
If you have the product installed, you need to reinstall a minor upgrade, which can only be done from the command line (e.g. msiexec /i product.msi REINSTALL=ALL REINSTALLMODE=vomus). Obviously, that's less than ideal for customers who just want to install it. Using a chainer like WiX's burn can help simplify that story, though. That also increases size and build complexity, though, and burn was primarily meant for installing multiple projects as a single, cohesive product.
There was a problem hiding this comment.
Heath Stewart (@heaths) as I tried to explain above, when you create new new version (pass a new version to the RFC-4122 algorithm) the ProductCode will do change for sure. The only difference to your favorite solution allowing WiX to a create a new product code at every build, are two facts:
- The ProductCode is predictable. What is great from my experience. IT should be predictable, right? Randomness has definitely it's justification, but not here for my taste.
- The ProductCode will not change when you don't change the product version (e.g. fixing a type in the UI). WiX will ALWAYS create a new PrdoctCode on every run.
| if (-not (Test-Path -Path $msBuildPath)) { | ||
| $msBuildPath = Join-Path -Path $msBuildDir -ChildPath 'MSBuild\15.0\Bin\MSBuild.exe' | ||
| if (-not (Test-Path -Path $msBuildPath)) { | ||
| if ($env:CI) { |
There was a problem hiding this comment.
This pattern for CI logging is repeated. Recommend breaking it out into a separate function. Should make the script easier to review and maintain.
There was a problem hiding this comment.
I had a look at the packaging stuff in the PowerShell Github repo. Perhaps we should replace the code here with the stuff from Powershell entirely.
There was a problem hiding this comment.
As I said I had a look at the PowerShell Modules used in the the PowerShell repo, which support the CI build. And there you'll find numerous places with the same pattern:
Like this
if ($env:TF_BUILD)
{
Write-Host "##vso[artifact.upload containerfolder=wix;artifactname=wix]$newXmlFileName"
}
throw "Current files to not match {$FilesWxsPath}"So I'd consider my code not as bad as it might look.
|
Thomas Meckel (@tmeckel) if you'd like, I could help make some of these changes to your PR if you'd allow it. There's a lot of great scaffolding here for build scripts. Or, if easier and fine with Steve Lee (@SteveL-MSFT), this could be merged and I could work on it afterward before anything is released (i.e. before the scripts are invoked, so maybe they could be unhooked from the build till then). |
|
Heath Stewart (@heaths) I tried to follow all your advises and
The documentation has been updated accordingly. Travis Plunk (@TravisEz13) I introduced a new MSI feature which implements the firewall exception for SSH. The feature is disabled by default. |
…nstall\openssh-install.wixproj
…ib\win32\install\build\build-msi.ps1
| @@ -0,0 +1,43 @@ | |||
| # Windows OpenSSH - Build Scripts | |||
|
|
|||
| ## `build-openssh.ps1` | |||
There was a problem hiding this comment.
We already have openssh-build.ps1 which does the build and package.
Please modify this.
| [Parameter(Mandatory)] | ||
| [ValidateScript( { Test-Path -LiteralPath $_ -PathType Container })] | ||
| [string] | ||
| $SourceDirectory, |
There was a problem hiding this comment.
We already have a build pipeline which does compilation, sign all artifacts and finally creates a zip payload.
If I want to add one more task to create the MSI package then I just need to call this script with $projectpath as openssh-install.wixproj, $sourcedirectory as <artifact_bin_folder>, $destination as <dest_folder_for_final_msi>, $version is derived from the executables and platform/configuration?
Do I need to change any GUIDs? I saw there is some discussion about hardcoding GUID vs generating GUID automatically.
| @@ -0,0 +1,136 @@ | |||
| [CmdletBinding()] | |||
There was a problem hiding this comment.
We already have openssh-build.ps1 which does the build and package.
Please remove this.
| # escape=` | ||
|
|
||
| # Copyright (C) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT license. See LICENSE.txt in the project root for license information. |
There was a problem hiding this comment.
We also have docker based build.
This can be removed.
|
|
||
| #### x64 (64-bit) | ||
|
|
||
| * Preview version: `5a388d64-a109-4d85-bddc-7f46e1e1e520` |
There was a problem hiding this comment.
What's the importance of these GUIDs? Given these are hardcoded, is there a need for changing them when a new OpenSSH version is published?
| <Component Id="cmp_sshkeyscan.exe"> | ||
| <File Id="sshkeyscan.exe" KeyPath="yes" Source="$(var.SOURCEDIR)/ssh-keyscan.exe" Name="ssh-keyscan.exe" /> | ||
| </Component> | ||
| <Component Id="cmd_sshclient_env" KeyPath="yes" Guid="d71ba15b-3489-4b44-a89f-76b147c574a6"> |
There was a problem hiding this comment.
Can we make this optional? We can have it enabled by default but should give an option for end-user to uncheck the option if user don't want to alter the PATH.
| <util:EventManifest /> | ||
| </File> | ||
| <util:XmlFile | ||
| Id="xmlSetResourceFileName" |
There was a problem hiding this comment.
Can you educate me on what we are doing here?
There was a problem hiding this comment.
This modifies the resourceFileName to point at the actual installed executable since it's hardcoded in the manifest. It's a great catch, but the ResourceFile attibute of util:EventManifest will do that automatically:
The resource file (including path) of all the providers in the event manifest. Often the resource file path cannot be determined until setup time. Put your ResourceFile here and the resourceFileName attribute of the all the providers in the manifest will be updated with the path before it is registered.
| FirstFailureActionType="restart" | ||
| SecondFailureActionType="restart" | ||
| ThirdFailureActionType="restart" /> | ||
| <PermissionEx Sddl="D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)(A;;RP;;;AU)" /> |
There was a problem hiding this comment.
What's the reason for setting the ACLs for ssh-agent service but not for SSHD service?
There was a problem hiding this comment.
As for the SDDL, this is copied directly from install-sshd.ps1.
There was a problem hiding this comment.
Also, install-sshd.ps1 doesn't set the ACL on sshd. Should it?
There was a problem hiding this comment.
This is to allow non-admin users to start the ssh-agent. ssh-agent is used for storing the keys. It's part of both client and server components. Please note, non-admin users are not given permissions to stop the ssh-agent.
The same ACL is not present on sshd as we don't want the non-admin users to start the sshd.exe.
| </Component> | ||
| </ComponentGroup> | ||
| <ComponentGroup Id="CG_SERVER_SSHDSERVICE" Directory="INSTALLFOLDER"> | ||
| <Component Id="cmp_sshd.exe"> |
There was a problem hiding this comment.
Can you add a check to make sure the sshd.exe binary has "read & execute" permissions for the "authenticated users".
Not sure if you are setting the OpenSSH folder permissions explicitly. If not openssh bin folder inherits the folder permissions from it's parent folder.. If the parent folder doesn't have "read & execute" permissions for "authenticated users" then ssh connection will fail.
|
If I had realized how much work I've to put in this pull request, I would never have submitted it. I apologize for taking up your time. |
|
Thomas Meckel (@tmeckel) sad that you closed it a msi installer for openssh would be a great addition! |
|
I will consider it. Steve Lee (@SteveL-MSFT) what scenarios would this target, exactly? Is it only for standalone installs, or would this facilitate MU updates some day, potentially? (I.e. should this include a Burn installer.) Thomas Meckel (@tmeckel) I'm sorry you feel that way, but I'm happy to help more hands on if you want. MSI installations have a lot of rules not often understood, and they can have major ramifications that can potentially block servicing packages later. That is one major reason I architected them almost entirely out of the Visual Studio 2017 and newer installs. |
|
Heath Stewart (@heaths) no it's definitely not about MSI or something technically. Please don't make me out to be a little kid. It's about how this PR has been handled. I should've been warned from the outcome of the first PR I filed here and how this ended. Steve Lee (@SteveL-MSFT) Would be nice, if you guys would give me some credit, if you build your own stuff based on my contributions. |
|
Heath Stewart (@heaths) I think we only want to support this as standalone installs of preview versions of OpenSSH. Official installs will still be via feature-on-demand within Windows. Thomas Meckel (@tmeckel) I appreciate you starting this effort! Whether Heath builds upon this work or creates it from scratch, you do deserve credit for initiating this. |
| <Condition> | ||
| <![CDATA[NOT(DONT_START_SSHAGENT OR DONT_START_SERVICES)]]> | ||
| </Condition> | ||
| <ServiceControl |
There was a problem hiding this comment.
bagajjal Steve Lee (@SteveL-MSFT) any reason to conditionally start the service?
There was a problem hiding this comment.
Yes. sshd_config (sshd serer configuration) can be configured to be more secured based on the users need,
- changing default port from 22 to user specific port to avoid security attacks.
- An admin user can configure which users are allowed to login (Allowusers, DenyUsers)
- An admin user can configure the type of access like providing only sftp access and denying interactive shell, etc.
There was a problem hiding this comment.
They can edit the file and restart the service immediately after install. Is putting a condition on this something you think people will actually use? Does it need to be exposed in the UI that most admins will probably use?
There was a problem hiding this comment.
As part of MSI, I would give an option (disabled by default, to match existing install-sshd.ps1 behavior) to start the sshd, ssh-agent service. This gives control for admin users who want to first make changes to sshd_config before starting the sshd service.
|
What's disabled by default, exactly? The option or the services being started? IMO, starting the service by default makes sense - most people expect an installer to install the product fully on their machine in a working state. |
|
Sure. We should provide a checkbox for users. If the checkbox is checked then only we should start the service. |


This pull request contains the following components