Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Add global registered install location to Linux and macOS#6124

Merged
vitek-karas merged 3 commits into
dotnet:masterfrom
vitek-karas:InstallLocation
May 3, 2019
Merged

Add global registered install location to Linux and macOS#6124
vitek-karas merged 3 commits into
dotnet:masterfrom
vitek-karas:InstallLocation

Conversation

@vitek-karas
Copy link
Copy Markdown
Member

The product now reads the /etc/dotnet/install_location file and use its first line as the path to the install location.

Implementation of design described in dotnet/designs#58

Adds test-only env. variables to be able to test the behavior around picking global install location.

Changes windows-only tests to run on Linux/macOS as well now.

Added some tests.
Improved the test infra around global registered location.

@vitek-karas vitek-karas added this to the 3.0 milestone Apr 26, 2019
@vitek-karas vitek-karas self-assigned this Apr 26, 2019
@vitek-karas vitek-karas changed the title Install location Add global registered install location to Linux and macOS Apr 28, 2019
@vitek-karas
Copy link
Copy Markdown
Member Author

/cc @jeffschwMSFT

The product now reads the /etc/dotnet/install_location file and use its first line as the path to the install location.

Adds test-only env. variables to be able to test the behavior around picking global install location.

Changes windows-only tests to run on Linux/macOS as well now.

Added some tests.
Improved the test infra around global registered location.

// ***Used only for testing***
pal::string_t environment_override;
if (pal::getenv(_X("_DOTNET_TEST_GLOBALLY_REGISTERED_PATH"), &environment_override))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I thought you were worried about a secutiry hole with this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes - but I didn't want to have one PR solving two separate issues... and I need a test-only thing for this feature. So I kept doing it the "old" way... will fix this in a separate PR for all cases where we do this.

[Theory]
[InlineData("{0}", true)]
[InlineData("{0}\n", true)]
[InlineData("{0}\nSome other text", true)]
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 is not clear why we should allow this case to be supported.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is for extensibility. If in the future we needed to add more stuff into the file, the "old" apphosts should not fail on it. So we intentionally only read the first line and ignore the rest.

Copy link
Copy Markdown

@sdmaclea sdmaclea left a comment

Choose a reason for hiding this comment

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

Looks fine to me.

  • Supporting multiple lines in the install location file seems suspicious.
  • I thought adding an environment variable for testing had security risks.
  • Using the registry and fiddling with the registry feels icky. Apparently it is required by the current design.
  • I wonder if running the tests in a container with full admin rights might offer a better alternative

Copy link
Copy Markdown
Member

@elinor-fung elinor-fung left a comment

Choose a reason for hiding this comment

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

Just the same question as @sdmaclea about the environment variables.

Comment thread src/corehost/common/pal.h
bool get_default_servicing_directory(string_t* recv);

//On Linux, there are no global locations
//On Windows there will be up to 2 global locations
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is still true, no?
Is it worth calling out the distinction between global / registered / default and how they are expected to be used for fxr / framework and sdk / shared store paths?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Even before this change Linux does have a global location, and now it also has the registered location.
I'm not sure we should have the full description in the header file - it's relatively complex as it stands right now...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh, I read this comment as referring to get_global_dotnet_dirs, which still does not return any directories on Linux. That seemed wrong to me (in my mind global would include the default and registered location), but then I realized that it was not used for fxr lookup and only multi-level framework/sdk/store - hence my thinking the distinction was unclear.

I guess I just found that name (get_global_dotnet_dirs) confusing, since it doesn't quite match what I think of as 'global'.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I added comments to the three functions which are confusing... The names are actually technically correct, but I understand the confusion. Maybe I'm just too "in this" to come up with better names... If you have better ideas please share...

Comment thread src/test/HostActivationTests/NativeHosting/Nethost.cs Outdated

using (RegisteredInstallLocationOverride registeredInstallLocationOverride = new RegisteredInstallLocationOverride())
{
File.WriteAllText(registeredInstallLocationOverride.PathValueOverride, string.Format(value, installLocation));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

registeredInstallLocationOverride.SetInstallLocation?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That would probably work, but I intentionally used the explicit file write here because this is testing values which are not just locations. So basically this should be the only test which does not use the SetInstallLocation.

@vitek-karas
Copy link
Copy Markdown
Member Author

@sdmaclea

Supporting multiple lines in the install location file seems suspicious.

Extensibility - if one day we need to add some more information into this file, we don't want for the old apphosts to break.

I thought adding an environment variable for testing had security risks.

Yes it is. I'm preparing a separate change to mitigate that, but I didn't want to combine it with this PR, would be too confusing. So I kept doing this the old way for now.

Using the registry and fiddling with the registry feels icky. Apparently it is required by the current design.

I agree it's not very nice. Most tests don't need that though as they use the env. variable which simply overrides what the registry returns. Unfortunately we need at least a couple tests which actually do run the registry reading code. I added this some time back when there was a bug in the registry reading code which ment it didn't work on downlevel Windows.

I wonder if running the tests in a container with full admin rights might offer a better alternative

I actually think it would be great to have a separate suite of tests which are more end-to-end and which would need to run in a container and with admin rights. Those could actually "install" the runtime and then try to run a real app and so on. I created #6262 to track this.

@vitek-karas vitek-karas merged commit 40aeca5 into dotnet:master May 3, 2019
@vitek-karas vitek-karas deleted the InstallLocation branch May 3, 2019 20:52
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…e-setup#6124)

The product now reads the /etc/dotnet/install_location file and use its first line as the path to the install location.

Adds test-only env. variables to be able to test the behavior around picking global install location.

Changes windows-only tests to run on Linux/macOS as well now.

Added some tests.
Improved the test infra around global registered location.


Commit migrated from dotnet/core-setup@40aeca5
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants