Skip to content

MSI install - #473

Closed
Thomas Meckel (tmeckel) wants to merge 12 commits into
PowerShell:latestw_allfrom
tmeckel:msi-install
Closed

Thomas Meckel (tmeckel) wants to merge 12 commits into
PowerShell:latestw_allfrom
tmeckel:msi-install

Conversation

@tmeckel

Copy link
Copy Markdown

This pull request contains the following components

  • an MSI package definition based on the WiX Toolset to create an MSI package for OpenSSH (README.md)
  • Build scripts that can be used standalone or a in CI/CD pipeline to build OpenSSH and/or the MSI Package (README.md)
  • Dockerfiles for creating docker images to build OpenSSH and/or the MSI Package (README.md)

@SteveL-MSFT

Copy link
Copy Markdown
Member

Heath Stewart (@heaths), can you help review the WIX files? Thanks!

@heaths Heath Stewart (heaths) left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@tmeckel Thomas Meckel (tmeckel) Feb 18, 2021 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. 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.
  2. 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) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pattern for CI logging is repeated. Recommend breaking it out into a separate function. Should make the script easier to review and maintain.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread contrib/win32/install/install/README.md Resolved
Comment thread contrib/win32/install/install/README.md Resolved
@heaths

Copy link
Copy Markdown

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).

@tmeckel

Thomas Meckel (tmeckel) commented Feb 28, 2021 •

Copy link
Copy Markdown
Author

Heath Stewart (@heaths) I tried to follow all your advises and

  • replaced the conditionals by features
  • the Version is now a required input to product.wxs and I removed the default values from product.wxs and openssh-install.wixproj
  • each file is now in a component
  • introduced upgradecodes for x86 and x64 (including the possibility to build preview versions)
  • replaced the include files with "normal" Wix <Fragments> which will be liked together by light
  • completely removed the handling of debug versions

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.

image

@@ -0,0 +1,43 @@
# Windows OpenSSH - Build Scripts

## `build-openssh.ps1`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also have docker based build.

This can be removed.


#### x64 (64-bit)

* Preview version: `5a388d64-a109-4d85-bddc-7f46e1e1e520`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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">

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"

@bagajjal bagajjal Apr 13, 2021 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you educate me on what we are doing here?

@heaths Heath Stewart (heaths) May 22, 2021 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)" />

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for providing "WriteExtendedAttributes" permissions for the "NT AUTHORITY\Authenticated Users"?
"NT AUTHORITY\SYSTEM" - doesn't have all permissions. any reason why?
"BUILTIN\Administrators" - is it the full control?

image

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for setting the ACLs for ssh-agent service but not for SSHD service?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for the SDDL, this is copied directly from install-sshd.ps1.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, install-sshd.ps1 doesn't set the ACL on sshd. Should it?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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">

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@tmeckel

Copy link
Copy Markdown
Author

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.

@floh96

Copy link
Copy Markdown

Thomas Meckel (@tmeckel) sad that you closed it a msi installer for openssh would be a great addition!
Heath Stewart (@heaths) bagajjal would you consider continuing this pr?

@heaths

Copy link
Copy Markdown

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.

@tmeckel

Copy link
Copy Markdown
Author

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.

#399

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.

@SteveL-MSFT

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bagajjal Steve Lee (@SteveL-MSFT) any reason to conditionally start the service?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. sshd_config (sshd serer configuration) can be configured to be more secured based on the users need,

  1. changing default port from 22 to user specific port to avoid security attacks.
  2. An admin user can configure which users are allowed to login (Allowusers, DenyUsers)
  3. An admin user can configure the type of access like providing only sftp access and denying interactive shell, etc.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

/cc Steve Lee (@SteveL-MSFT)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@heaths

Copy link
Copy Markdown

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.

@bagajjal

Copy link
Copy Markdown

Sure. We should provide a checkbox for users. If the checkbox is checked then only we should start the service.
The checkbox can be checked by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants