Skip to content

Commit

Permalink
Merge pull request #268 from nurfed1/master
Browse files Browse the repository at this point in the history
Bugfix: Add quotes around network path
  • Loading branch information
gerardog committed Jun 4, 2023
2 parents 3438fb4 + 11a4ae5 commit b4d8502
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/gsudo/Helpers/CommandToRunAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,9 @@ internal void AddCopyEnvironment(ElevationRequest.ConsoleMode mode)
var error = FileApi.WNetGetConnection(drive.Name.Substring(0, 2), tmpSb, ref size);
if (error == 0)
{
sb.AppendLine($"{silent}ECHO Connecting {drive.Name.Substring(0, 2)} to {tmpSb.ToString()} 1>&2");
sb.AppendLine($"{silent}ECHO Connecting {drive.Name.Substring(0, 2)} to \"{tmpSb.ToString()}\" 1>&2");
sb.AppendLine($"{silent}NET USE /D {drive.Name.Substring(0, 2)} >NUL 2>NUL");
sb.AppendLine($"{silent}NET USE {drive.Name.Substring(0, 2)} {tmpSb.ToString()} 1>&2");
sb.AppendLine($"{silent}NET USE {drive.Name.Substring(0, 2)} \"{tmpSb.ToString()}\" 1>&2");
}
}
}
Expand Down

2 comments on commit b4d8502

@bcurran3
Copy link

Choose a reason for hiding this comment

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

This commit is majorly slowing down my system when I run gsudo in terminal from a network share.
It also hangs on one connection which I'm sure because that server is asking for credentials. When I notice this I hit enter and it then continues on.
SUGGESTION: add a check condition for https://learn.microsoft.com/en-US/troubleshoot/windows-client/networking/mapped-drives-not-available-from-elevated-command and only run NET USE if that is not enabled.

@bcurran3
Copy link

Choose a reason for hiding this comment

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

EXAMPLE: (Not 100% precise as I had to hit enter twice and type in exit to get the time)
image

So two minutes, minus maybe 30+ seconds or so of my inaction.

SECOND RUN where I hit enter at each mapping to avoid delays:
image

Please sign in to comment.