Skip to content

Commit

Permalink
- Rearrange service location check in RunCommand.cs for better error …
Browse files Browse the repository at this point in the history
…handling.
  • Loading branch information
gerardog committed Dec 18, 2023
1 parent 9d3fafc commit fd523ce
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/gsudo/Commands/RunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ private async Task<int> RunUsingService(ElevationRequest elevationRequest)
serviceLocation = await ServiceHelper.WaitForNewService(callingPid).ConfigureAwait(false);
}

if (serviceLocation==null)
throw new ApplicationException("Unable to connect to the elevated service.");

if (!InputArguments.IntegrityLevel.HasValue)
{
// This is the edge case where user does `gsudo -u SomeOne` and we dont know if SomeOne can elevate or not.
elevationRequest.IntegrityLevel = serviceLocation.IsHighIntegrity ? IntegrityLevel.High : IntegrityLevel.Medium;
}

if (serviceLocation==null)
throw new ApplicationException("Unable to connect to the elevated service.");

connection = await ServiceHelper.Connect(serviceLocation).ConfigureAwait(false);
if (connection == null) // service is not running or listening.
{
Expand Down

0 comments on commit fd523ce

Please sign in to comment.