From a163a1603cad00e8abe8c7432395a53e9921a74b Mon Sep 17 00:00:00 2001 From: Gerardo Grignoli Date: Wed, 30 Mar 2022 11:18:07 -0300 Subject: [PATCH 01/11] Update README.md Added shields.io badges --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 64116cfd..44fd3e84 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,10 @@ # gsudo - a sudo for Windows [![Join the chat at https://gitter.im/gsudo/community](https://badges.gitter.im/gsudo/community.svg)](https://gitter.im/gsudo/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[![Build status](https://ci.appveyor.com/api/projects/status/nkd11bifhnqaxay9/branch/master?svg=true)](https://ci.appveyor.com/project/gerardog/gsudo) +[![Build status](https://ci.appveyor.com/api/projects/status/nkd11bifhnqaxay9/branch/master?svg=true)](https://ci.appveyor.com/project/gerardog/gsudo) +[![Tests](https://img.shields.io/appveyor/tests/gerardog/gsudo/master)]() +[![Chocolatey Downloads](https://img.shields.io/chocolatey/dt/gsudo?label=Chocolatey%20Downloads)]() +[![GitHub Downloads](https://img.shields.io/github/downloads/gerardog/gsudo/total?label=GitHub%20Downloads)]() **gsudo** is a `sudo` equivalent for Windows, with a similar user-experience as the original *nix sudo. It allows to run commands with elevated permissions, or to elevate the current shell, in the current console window or a new one. From 48261ecc9a5d17dbaea0c67f778fcb559a3ee578 Mon Sep 17 00:00:00 2001 From: Gerardo Grignoli Date: Sun, 3 Apr 2022 20:56:36 -0300 Subject: [PATCH 02/11] Fix(VT mode): Send correct cursor pos on Vt init --- src/gsudo/ProcessRenderers/VTClientRenderer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gsudo/ProcessRenderers/VTClientRenderer.cs b/src/gsudo/ProcessRenderers/VTClientRenderer.cs index a971327b..642f4fd4 100644 --- a/src/gsudo/ProcessRenderers/VTClientRenderer.cs +++ b/src/gsudo/ProcessRenderers/VTClientRenderer.cs @@ -157,7 +157,7 @@ private async Task WriteToConsole(string s) int left, top; ConsoleHelper.GetConsoleInfo(out _, out _, out left, out top); - await _connection.DataStream.WriteAsync($"\x001B[{top};{left}R").ConfigureAwait(false); + await _connection.DataStream.WriteAsync($"\x001B[{top+1};{left}R").ConfigureAwait(false); return; } From 2f47f3eb987f3785dc8f85d5f4d200c45bbf0036 Mon Sep 17 00:00:00 2001 From: Gerardo Grignoli Date: Tue, 26 Apr 2022 00:22:47 -0300 Subject: [PATCH 03/11] Fix: Removed cmd commands that actually are `.EXE` --- src/gsudo/Helpers/ArgumentsHelper.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gsudo/Helpers/ArgumentsHelper.cs b/src/gsudo/Helpers/ArgumentsHelper.cs index eb6cf551..024ea3f8 100644 --- a/src/gsudo/Helpers/ArgumentsHelper.cs +++ b/src/gsudo/Helpers/ArgumentsHelper.cs @@ -11,7 +11,7 @@ namespace gsudo.Helpers { public static class ArgumentsHelper { - static readonly HashSet CmdCommands = new HashSet(StringComparer.OrdinalIgnoreCase) { "ASSOC", "ATTRIB", "BREAK", "BCDEDIT", "CACLS", "CALL", "CD", "CHCP", "CHDIR", "CHKDSK", "CHKNTFS", "CLS", /*"CMD",*/ "COLOR", "COMP", "COMPACT", "CONVERT", "COPY", "DATE", "DEL", "DIR", "DISKPART", "DOSKEY", "DRIVERQUERY", "ECHO", "ENDLOCAL", "ERASE", "EXIT", "FC", "FIND", "FINDSTR", "FOR", "FORMAT", "FSUTIL", "FTYPE", "GOTO", "GPRESULT", "GRAFTABL", "HELP", "ICACLS", "IF", "LABEL", "MD", "MKDIR", "MKLINK", "MODE", "MORE", "MOVE", "OPENFILES", "PATH", "PAUSE", "POPD", "PRINT", "PROMPT", "PUSHD", "RD", "RECOVER", "REM", "REN", "RENAME", "REPLACE", "RMDIR", "ROBOCOPY", "SET", "SETLOCAL", "SC", "SCHTASKS", "SHIFT", "SHUTDOWN", "SORT", "START", "SUBST", "SYSTEMINFO", "TASKLIST", "TASKKILL", "TIME", "TITLE", "TREE", "TYPE", "VER", "VERIFY", "VOL", "XCOPY", "WMIC" }; + static readonly HashSet CmdCommands = new HashSet(StringComparer.OrdinalIgnoreCase) { "ASSOC", "BREAK", "CALL", "CD", "CHDIR", "CLS", "COLOR", "COPY", "DATE", "DEL", "DIR", "ECHO", "ENDLOCAL", "ERASE", "EXIT", "FOR", "FTYPE", "GOTO", "IF", "MD", "MKDIR", "MKLINK", "MOVE", "PATH", "PAUSE", "POPD", "PROMPT", "PUSHD", "RD", "REM", "REN", "RENAME", "RMDIR", "SET", "SETLOCAL", "SHIFT", "START", "TIME", "TITLE", "TYPE", "VER", "VERIFY", "VOL" }; static readonly HashSet CreateProcessSupportedExtensions = new HashSet(StringComparer.OrdinalIgnoreCase) { ".CMD", ".EXE", ".BAT", ".COM" }; internal static string[] AugmentCommand(string[] args) @@ -151,7 +151,7 @@ Running ./gsudo {command} should elevate the powershell command. } else { - if (CmdCommands.Contains(args[0])) + if (CmdCommands.Contains(args[0])) // We want cmd commands to be run with CMD /c, not search for .EXE return new string[] { currentShellExeName, "/c" } .Concat(args).ToArray(); @@ -259,7 +259,7 @@ internal static ICommand ParseCommand(IEnumerable argsEnumerable) SetTrueIf(arg, () => InputArguments.RunAsSystem = true, "-s", "--system") || SetTrueIf(arg, () => InputArguments.Global = true, "--global") || SetTrueIf(arg, () => InputArguments.Direct = true, "-d", "--direct") || - SetTrueIf(arg, () => InputArguments.KillCache = true, "-k", "--reset-timestamp") + SetTrueIf(arg, () => InputArguments.RunAsSystem = InputArguments.TrustedInstaller = true, "--ti") ) { } else if (arg.In("-v", "--version")) From bf2403bd7dcaa0a93179f8e694ab7bf9c897fc74 Mon Sep 17 00:00:00 2001 From: Gerardo Grignoli Date: Fri, 15 Jul 2022 09:39:27 -0300 Subject: [PATCH 04/11] fix: Fix UnauthorizedAccessException when elevating as someone else twice from same parent process (eg, WT elevated tabs) --- src/gsudo/Rpc/NamedPipeServer.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gsudo/Rpc/NamedPipeServer.cs b/src/gsudo/Rpc/NamedPipeServer.cs index 6e5cb82d..d76b1738 100644 --- a/src/gsudo/Rpc/NamedPipeServer.cs +++ b/src/gsudo/Rpc/NamedPipeServer.cs @@ -57,11 +57,21 @@ public async Task Listen() { var ps = new PipeSecurity(); + // _allowedSid is the input argument saying who invoked this elevated instance. + // Needs access to connect to this pipe. ps.AddAccessRule(new PipeAccessRule( new SecurityIdentifier(_allowedSid), + PipeAccessRights.ReadWrite, + AccessControlType.Allow)); + + // WindowsIdentity.GetCurrent().User is our current elevated user. + // For UAC in admin-approval mode, it is the same as _allowedSid + // But when entering credentials (on the UAC Popup), it is not. + ps.AddAccessRule(new PipeAccessRule( + WindowsIdentity.GetCurrent().User, PipeAccessRights.ReadWrite | PipeAccessRights.CreateNewInstance, AccessControlType.Allow)); - + var networkSid = new SecurityIdentifier("S-1-5-2"); // deny remote connections. ps.AddAccessRule(new PipeAccessRule( From 0d99418ecb333c6a7f4055641d4a01fefbe5b9af Mon Sep 17 00:00:00 2001 From: Gerardo Grignoli Date: Fri, 15 Jul 2022 09:39:27 -0300 Subject: [PATCH 05/11] fix: Fix UnauthorizedAccessException when elevating as someone else twice from same parent process (eg, WT elevated tabs) #145 --- src/gsudo/Rpc/NamedPipeServer.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gsudo/Rpc/NamedPipeServer.cs b/src/gsudo/Rpc/NamedPipeServer.cs index 6e5cb82d..d76b1738 100644 --- a/src/gsudo/Rpc/NamedPipeServer.cs +++ b/src/gsudo/Rpc/NamedPipeServer.cs @@ -57,11 +57,21 @@ public async Task Listen() { var ps = new PipeSecurity(); + // _allowedSid is the input argument saying who invoked this elevated instance. + // Needs access to connect to this pipe. ps.AddAccessRule(new PipeAccessRule( new SecurityIdentifier(_allowedSid), + PipeAccessRights.ReadWrite, + AccessControlType.Allow)); + + // WindowsIdentity.GetCurrent().User is our current elevated user. + // For UAC in admin-approval mode, it is the same as _allowedSid + // But when entering credentials (on the UAC Popup), it is not. + ps.AddAccessRule(new PipeAccessRule( + WindowsIdentity.GetCurrent().User, PipeAccessRights.ReadWrite | PipeAccessRights.CreateNewInstance, AccessControlType.Allow)); - + var networkSid = new SecurityIdentifier("S-1-5-2"); // deny remote connections. ps.AddAccessRule(new PipeAccessRule( From e8e8252e781f2891cef614c84068c508a5df69cf Mon Sep 17 00:00:00 2001 From: Gerardo Grignoli Date: Fri, 15 Jul 2022 11:52:16 -0300 Subject: [PATCH 06/11] fix(Simultaneous elevations): Fix cache for simultaneous elevations from one parent process (eg. WT tabs) #145 --- src/gsudo/Commands/ServiceCommand.cs | 6 +++ src/gsudo/Helpers/ServiceHelper.cs | 49 +------------------ src/gsudo/ProcessHosts/AttachedConsoleHost.cs | 2 + src/gsudo/ProcessHosts/IProcessHost.cs | 2 + .../ProcessHosts/NewWindowProcessHost.cs | 2 + src/gsudo/ProcessHosts/PipedProcessHost.cs | 2 + src/gsudo/ProcessHosts/TokenSwitchHost.cs | 3 +- src/gsudo/ProcessHosts/VTProcessHost.cs | 2 + 8 files changed, 20 insertions(+), 48 deletions(-) diff --git a/src/gsudo/Commands/ServiceCommand.cs b/src/gsudo/Commands/ServiceCommand.cs index 4c45679c..6946e3e6 100644 --- a/src/gsudo/Commands/ServiceCommand.cs +++ b/src/gsudo/Commands/ServiceCommand.cs @@ -5,6 +5,7 @@ using gsudo.Rpc; using gsudo.ProcessHosts; using System.Runtime.Serialization.Formatters.Binary; +using gsudo.Helpers; namespace gsudo.Commands { @@ -72,6 +73,11 @@ private async Task AcceptConnection(Connection connection) IProcessHost applicationHost = CreateProcessHost(request); + if (!applicationHost.SupportsSimultaneousElevations && Settings.CacheMode.Value==Enums.CacheMode.Auto) + { + ServiceHelper.StartElevatedService(AllowedPid, CacheDuration, AllowedSid); + } + if (!string.IsNullOrEmpty(request.Prompt)) Environment.SetEnvironmentVariable("PROMPT", Environment.ExpandEnvironmentVariables(request.Prompt)); diff --git a/src/gsudo/Helpers/ServiceHelper.cs b/src/gsudo/Helpers/ServiceHelper.cs index 8398bf51..1ce9606e 100644 --- a/src/gsudo/Helpers/ServiceHelper.cs +++ b/src/gsudo/Helpers/ServiceHelper.cs @@ -54,9 +54,9 @@ internal static async Task ConnectStartElevatedService() return connection; } - internal static bool StartElevatedService(int? allowedPid, TimeSpan? cacheDuration = null) + internal static bool StartElevatedService(int? allowedPid, TimeSpan? cacheDuration = null, string allowedSid=null) { - var callingSid = System.Security.Principal.WindowsIdentity.GetCurrent().User.Value; + var callingSid = allowedSid ?? System.Security.Principal.WindowsIdentity.GetCurrent().User.Value; var callingPid = allowedPid ?? Process.GetCurrentProcess().GetCacheableRootProcessId(); string verb; @@ -112,50 +112,5 @@ internal static bool StartElevatedService(int? allowedPid, TimeSpan? cacheDurati Logger.Instance.Log("Elevated instance started.", LogLevel.Debug); return true; } - - internal static bool StartSingleUseElevatedService(int callingPid) - { - var @params = string.Empty; - - if (InputArguments.Debug) @params = "--debug "; - if (InputArguments.IntegrityLevel.HasValue) @params += $"-i {InputArguments.IntegrityLevel.Value} "; - if (InputArguments.RunAsSystem) @params += "-s "; - - bool isAdmin = ProcessHelper.IsHighIntegrity(); - string ownExe = ProcessHelper.GetOwnExeName(); - - string commandLine; - commandLine = $"{@params}gsudoelevate --pid {callingPid}"; - - Process p; - - try - { - p = ProcessFactory.StartElevatedDetached(ownExe, commandLine, !InputArguments.Debug); - } - catch (System.ComponentModel.Win32Exception ex) - { - Logger.Instance.Log(ex.Message, LogLevel.Error); - return false; - } - - if (p == null) - { - Logger.Instance.Log("Failed to start elevated instance.", LogLevel.Error); - return false; - } - - Logger.Instance.Log("Elevated instance started.", LogLevel.Debug); - - p.WaitForExit(); - - if (p.ExitCode == 0) - { - return true; - } - - return false; - } - } } diff --git a/src/gsudo/ProcessHosts/AttachedConsoleHost.cs b/src/gsudo/ProcessHosts/AttachedConsoleHost.cs index 99d67bd5..0524fb62 100644 --- a/src/gsudo/ProcessHosts/AttachedConsoleHost.cs +++ b/src/gsudo/ProcessHosts/AttachedConsoleHost.cs @@ -14,6 +14,8 @@ namespace gsudo.ProcessHosts // This mode is not enabled unless you use --attached. class AttachedConsoleHost : IProcessHost { + public bool SupportsSimultaneousElevations { get; } = false; + public async Task Start(Connection connection, ElevationRequest elevationRequest) { var exitCode = 0; diff --git a/src/gsudo/ProcessHosts/IProcessHost.cs b/src/gsudo/ProcessHosts/IProcessHost.cs index 51b2a740..707c126f 100644 --- a/src/gsudo/ProcessHosts/IProcessHost.cs +++ b/src/gsudo/ProcessHosts/IProcessHost.cs @@ -14,5 +14,7 @@ namespace gsudo.ProcessHosts interface IProcessHost { Task Start(Connection connection, ElevationRequest elevationRequest); + + bool SupportsSimultaneousElevations { get; } } } diff --git a/src/gsudo/ProcessHosts/NewWindowProcessHost.cs b/src/gsudo/ProcessHosts/NewWindowProcessHost.cs index 621282a1..c5360f8c 100644 --- a/src/gsudo/ProcessHosts/NewWindowProcessHost.cs +++ b/src/gsudo/ProcessHosts/NewWindowProcessHost.cs @@ -14,6 +14,8 @@ class NewWindowProcessHost : IProcessHost { private Process process; + public bool SupportsSimultaneousElevations { get; } = true; + public async Task Start(Connection connection, ElevationRequest request) { try diff --git a/src/gsudo/ProcessHosts/PipedProcessHost.cs b/src/gsudo/ProcessHosts/PipedProcessHost.cs index 590636a5..818b98b4 100644 --- a/src/gsudo/ProcessHosts/PipedProcessHost.cs +++ b/src/gsudo/ProcessHosts/PipedProcessHost.cs @@ -23,6 +23,8 @@ class PipedProcessHost : IProcessHost private ElevationRequest _request; private bool _errorStreamActive; + public bool SupportsSimultaneousElevations { get; } = false; + public async Task Start(Connection connection, ElevationRequest request) { Native.ConsoleApi.SetConsoleCtrlHandler(ConsoleHelper.IgnoreConsoleCancelKeyPress, true); diff --git a/src/gsudo/ProcessHosts/TokenSwitchHost.cs b/src/gsudo/ProcessHosts/TokenSwitchHost.cs index 97fb2e83..c1bdc0c6 100644 --- a/src/gsudo/ProcessHosts/TokenSwitchHost.cs +++ b/src/gsudo/ProcessHosts/TokenSwitchHost.cs @@ -12,6 +12,8 @@ namespace gsudo.ProcessHosts /// class TokenSwitchHost : IProcessHost { + public bool SupportsSimultaneousElevations { get; } = true; + public async Task Start(Connection connection, ElevationRequest elevationRequest) { if (Settings.SecurityEnforceUacIsolation && !elevationRequest.NewWindow) @@ -22,7 +24,6 @@ public async Task Start(Connection connection, ElevationRequest elevationRequest TokenSwitcher.ReplaceProcessToken(elevationRequest); await connection.ControlStream.WriteAsync(Constants.TOKEN_SUCCESS).ConfigureAwait(false); - connection.DisconnectedWaitHandle.WaitOne(); // Wait until client receives the response before closing. } catch (Exception ex) { diff --git a/src/gsudo/ProcessHosts/VTProcessHost.cs b/src/gsudo/ProcessHosts/VTProcessHost.cs index 77e29569..70e4f371 100644 --- a/src/gsudo/ProcessHosts/VTProcessHost.cs +++ b/src/gsudo/ProcessHosts/VTProcessHost.cs @@ -23,6 +23,8 @@ class VTProcessHost : IProcessHost private Connection _connection; private static Encoding PseudoConsoleEncoding = new System.Text.UTF8Encoding(false); + public bool SupportsSimultaneousElevations { get; } = false; + public async Task Start(Connection connection, ElevationRequest request) { if (Settings.SecurityEnforceUacIsolation) From 2bb4176f4678df8e028a2c12e2315415e0f9d77c Mon Sep 17 00:00:00 2001 From: Gerardo Grignoli Date: Sun, 17 Jul 2022 20:29:07 -0300 Subject: [PATCH 07/11] fix(cache): Fix `cache on` finishing before the cache is available. Fixes #144 --- src/gsudo/Commands/CacheCommand.cs | 7 ++++++- src/gsudo/Rpc/NamedPipeClient.cs | 13 +++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/gsudo/Commands/CacheCommand.cs b/src/gsudo/Commands/CacheCommand.cs index c364d6cb..8fc3defa 100644 --- a/src/gsudo/Commands/CacheCommand.cs +++ b/src/gsudo/Commands/CacheCommand.cs @@ -66,8 +66,9 @@ public async Task Execute() commandToRun.AddRange(new[] {"cache", "on", "--pid", AllowedPid.ToString()}); + InputArguments.Wait = true; InputArguments.Direct = true; - return await new RunCommand() {CommandToRun = commandToRun} + return await new RunCommand() {CommandToRun = commandToRun, } .Execute().ConfigureAwait(false); } else @@ -84,6 +85,10 @@ public async Task Execute() Logger.Instance.Log("Cache is a security risk. Use `gsudo cache off` (or `-k`) to go back to safety.", LogLevel.Warning); + + // wait until the cache service becomes available (2 seconds max) + for (int i=0; i<40 && !NamedPipeClient.IsServiceAvailable(AllowedPid); i++) + await Task.Delay(50).ConfigureAwait(false); } return 0; diff --git a/src/gsudo/Rpc/NamedPipeClient.cs b/src/gsudo/Rpc/NamedPipeClient.cs index da785dd6..e9bb2c42 100644 --- a/src/gsudo/Rpc/NamedPipeClient.cs +++ b/src/gsudo/Rpc/NamedPipeClient.cs @@ -72,20 +72,21 @@ public async Task Connect(int? clientPid, bool failFast) } } - public static bool IsServiceAvailable() + public static bool IsServiceAvailable(int? pid = null, string sid = null) { string pipeName = null; - var callerProcessId = Process.GetCurrentProcess().Id; - string user = System.Security.Principal.WindowsIdentity.GetCurrent().User.Value; - while (callerProcessId > 0) + pid = pid ?? ProcessHelper.GetParentProcessId(Process.GetCurrentProcess().Id); + sid = sid ?? System.Security.Principal.WindowsIdentity.GetCurrent().User.Value; + + while (pid.Value > 0) { - callerProcessId = ProcessHelper.GetParentProcessId(callerProcessId); - pipeName = NamedPipeNameFactory.GetPipeName(user, callerProcessId); + pipeName = NamedPipeNameFactory.GetPipeName(sid, pid.Value); // Does the pipe exists? if (NamedPipeUtils.ExistsNamedPipe(pipeName)) break; + pid = ProcessHelper.GetParentProcessId(pid.Value); pipeName = null; // try grandfather. } From 05aa3b4ffe642c6dc36f2d73f27057aac046ba89 Mon Sep 17 00:00:00 2001 From: Gerardo Grignoli Date: Thu, 28 Jul 2022 01:14:13 -0300 Subject: [PATCH 08/11] chore: Convert project file to SDK style --- src/KeyPressTester/KeyPressTester.csproj | 52 ++-------------- src/gsudo.Tests/gsudo.Tests.csproj | 78 +++--------------------- src/gsudo.Tests/packages.config | 5 -- 3 files changed, 12 insertions(+), 123 deletions(-) delete mode 100644 src/gsudo.Tests/packages.config diff --git a/src/KeyPressTester/KeyPressTester.csproj b/src/KeyPressTester/KeyPressTester.csproj index 5ffa5d66..3445fa0d 100644 --- a/src/KeyPressTester/KeyPressTester.csproj +++ b/src/KeyPressTester/KeyPressTester.csproj @@ -1,53 +1,11 @@ - - - + - Debug - AnyCPU - {FD3B76FD-E682-4C65-A936-84B9B2C6FB19} + net46 Exe - KeyPressTester - KeyPressTester - v4.6 - 512 - true - true + false - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - + + - \ No newline at end of file diff --git a/src/gsudo.Tests/gsudo.Tests.csproj b/src/gsudo.Tests/gsudo.Tests.csproj index 9673a72d..df8b9daf 100644 --- a/src/gsudo.Tests/gsudo.Tests.csproj +++ b/src/gsudo.Tests/gsudo.Tests.csproj @@ -1,78 +1,14 @@ - - - - + - Debug - AnyCPU - {B91748FC-950F-46AB-A037-7118BEA81FF7} - Library - Properties - gsudo.Tests - gsudo.Tests - v4.6 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 15.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - - + net46 + false - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll - - - ..\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll - - - - - - - - - - - - - + - - {9eebda90-12de-4780-b8b1-8bf86dfe71b3} - gsudo - + + + - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - \ No newline at end of file diff --git a/src/gsudo.Tests/packages.config b/src/gsudo.Tests/packages.config deleted file mode 100644 index fc09f95b..00000000 --- a/src/gsudo.Tests/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file From a76996335364c16464ee2d8017baaabc69bf4c03 Mon Sep 17 00:00:00 2001 From: Gerardo Grignoli Date: Fri, 26 Aug 2022 15:31:26 -0300 Subject: [PATCH 09/11] fix(hang): Limit recursion seeking parent pid --- src/gsudo/Rpc/NamedPipeClient.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gsudo/Rpc/NamedPipeClient.cs b/src/gsudo/Rpc/NamedPipeClient.cs index e9bb2c42..44c1cc30 100644 --- a/src/gsudo/Rpc/NamedPipeClient.cs +++ b/src/gsudo/Rpc/NamedPipeClient.cs @@ -32,7 +32,8 @@ public async Task Connect(int? clientPid, bool failFast) else { var callerProcessId = Process.GetCurrentProcess().Id; - while (callerProcessId > 0) + int maxRecursion = 20; + while (callerProcessId > 0 && maxRecursion-- > 0) { callerProcessId = ProcessHelper.GetParentProcessId(callerProcessId); pipeName = NamedPipeNameFactory.GetPipeName(user, callerProcessId); @@ -79,7 +80,8 @@ public static bool IsServiceAvailable(int? pid = null, string sid = null) pid = pid ?? ProcessHelper.GetParentProcessId(Process.GetCurrentProcess().Id); sid = sid ?? System.Security.Principal.WindowsIdentity.GetCurrent().User.Value; - while (pid.Value > 0) + int maxRecursion = 20; + while (pid.Value > 0 && maxRecursion-- > 0) { pipeName = NamedPipeNameFactory.GetPipeName(sid, pid.Value); // Does the pipe exists? From 3af7057ec519c6a2c39d66c87626e6176a1409cd Mon Sep 17 00:00:00 2001 From: Gerardo Grignoli Date: Fri, 26 Aug 2022 15:54:33 -0300 Subject: [PATCH 10/11] chore: fix wrong merge --- src/gsudo/Helpers/ArgumentsHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gsudo/Helpers/ArgumentsHelper.cs b/src/gsudo/Helpers/ArgumentsHelper.cs index 024ea3f8..3e1ac30e 100644 --- a/src/gsudo/Helpers/ArgumentsHelper.cs +++ b/src/gsudo/Helpers/ArgumentsHelper.cs @@ -259,7 +259,7 @@ internal static ICommand ParseCommand(IEnumerable argsEnumerable) SetTrueIf(arg, () => InputArguments.RunAsSystem = true, "-s", "--system") || SetTrueIf(arg, () => InputArguments.Global = true, "--global") || SetTrueIf(arg, () => InputArguments.Direct = true, "-d", "--direct") || - SetTrueIf(arg, () => InputArguments.RunAsSystem = InputArguments.TrustedInstaller = true, "--ti") + SetTrueIf(arg, () => InputArguments.KillCache = true, "-k", "--reset-timestamp") ) { } else if (arg.In("-v", "--version")) From 567bd6280d71e9abe98ef238a489e0160b11cfe8 Mon Sep 17 00:00:00 2001 From: Gerardo Grignoli Date: Fri, 26 Aug 2022 16:00:36 -0300 Subject: [PATCH 11/11] fix(build) --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index a4421610..0b03d871 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -17,7 +17,7 @@ after_build: test_script: - ps: $Env:Path+=";$($Env:APPVEYOR_BUILD_FOLDER)/src/gsudo/bin;"; - - vstest.console /logger:Appveyor %APPVEYOR_BUILD_FOLDER%\src\gsudo.Tests\bin\%CONFIGURATION%\gsudo.Tests.dll + - vstest.console /logger:Appveyor %APPVEYOR_BUILD_FOLDER%\src\gsudo.Tests\bin\%CONFIGURATION%\net46\gsudo.Tests.dll - powershell -c Invoke-Pester -EnableExit -OutputFile Powershell5Tests.xml -OutputFormat NUnitXml - pwsh -c Invoke-Pester -EnableExit -OutputFile PowershellCoreTests.xml -OutputFormat NUnitXml - ps: |