Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add background elevated process for setup flow #59

Merged
merged 20 commits into from
Mar 31, 2023
Merged

Add background elevated process for setup flow #59

merged 20 commits into from
Mar 31, 2023

Conversation

florelis
Copy link
Member

@florelis florelis commented Mar 18, 2023

Summary of the pull request

Added a process that runs elevated in the background during the setup flow to execute any tasks that require admin permissions. Having this background process to offload work to lets us have a single UAC prompt when starting the setup.

References and relevant issues

Detailed description of the pull request / Additional comments

When starting the setup, if any of the tasks to execute requires admin, we start this process and establish communication with it by having an object on the background process and a proxy for it on the main app process. The interface for this object can be extended as needed for all the tasks that need admin (install apps, create dev drive). See the comment at the top of IPCSetup.cs for details of how this is set up.

Extended the ISetupTask interface with an ExecuteAsAdmin() method. This method takes the remote factory as a parameter. To implement it, one would add a new type to the elevated component to handle the required steps, add a corresponding Create*() method on the factory interface to create an object of that type, and then use that in the ExecuteAsAdmin() method.

Validation steps performed

As there are no current implementations for tasks that run as admin, I temporarily modified the code to always launch the elevated process when starting the setup and added a test method to print a string. Manually verified that the process was started, and that calling the test method from the main app would print the message on the elevated process' windows.

Added a test that starts the process, calls this test method to print something, then checks the process output.

PR checklist

  • Closes #xxx No related issue
  • Tests added/passed - Added test
  • Documentation updated

@florelis florelis marked this pull request as ready for review March 21, 2023 14:41
@florelis

This comment was marked as outdated.

@azure-pipelines

This comment was marked as resolved.

# Conflicts:
#	tools/SetupFlow/DevHome.SetupFlow.RepoConfig/Models/CloneRepoTask.cs
#	tools/SetupFlow/DevHome.SetupFlow.Summary/ViewModels/SummaryViewModel.cs
#	tools/SetupFlow/DevHome.SetupFlow.UnitTest/ViewModels/SearchViewModelTest.cs
@florelis

This comment was marked as outdated.

@azure-pipelines

This comment was marked as outdated.

@florelis

This comment was marked as outdated.

@azure-pipelines

This comment was marked as outdated.

@florelis

This comment was marked as outdated.

@azure-pipelines

This comment was marked as outdated.

# Conflicts:
#	src/DevHome.csproj
#	tools/SetupFlow/DevHome.SetupFlow.Common/Services/SetupFlowOrchestrator.cs
#	tools/SetupFlow/DevHome.SetupFlow.Common/ViewModels/SetupPageViewModelBase.cs
#	tools/SetupFlow/DevHome.SetupFlow.Summary/ViewModels/SummaryViewModel.cs
#	tools/SetupFlow/DevHome.SetupFlow/ViewModels/SetupFlowViewModel.cs
# Conflicts:
#	DevHome.sln
#	tools/SetupFlow/DevHome.SetupFlow.AppManagement/Models/InstallPackageTask.cs
# Conflicts:
#	DevHome.sln
#	src/DevHome.csproj
@florelis
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
Copy link
Member

Choose a reason for hiding this comment

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

Given this is its own exe, you are probably going to have to make this self-contained too similar to the main dev home app via a publish profile.

@bbonaby
Copy link
Contributor

bbonaby commented Mar 30, 2023

I've tested this and worked with Flor to confirm it works as intended to create dev drives. @AmelBawa-msft I believe you should be able to install apps with this as well, but you'll have to test it out. I'm sure if there are any runtime problems we'll continue to iterate on this. As currently constructed I have no problems. @manodasanW are you able to take a look again? For me I can approve once the merge conflicts are solved

# Conflicts:
#	tools/SetupFlow/DevHome.SetupFlow.AppManagement/Models/InstallPackageTask.cs
#	tools/SetupFlow/DevHome.SetupFlow.Common/Models/ISetupTask.cs
#	tools/SetupFlow/DevHome.SetupFlow.Loading/ViewModels/LoadingViewModel.cs
#	tools/SetupFlow/DevHome.SetupFlow.RepoConfig/Models/CloneRepoTask.cs
@florelis
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@florelis florelis merged commit 1f13e79 into microsoft:main Mar 31, 2023
@florelis florelis deleted the elevatedProcess branch March 31, 2023 00:20
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.

4 participants