Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into Fix.CacheWithShim
Browse files Browse the repository at this point in the history
  • Loading branch information
gerardog committed Mar 2, 2023
2 parents 624c1b3 + ec5d4b8 commit 7a54115
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,9 @@ How to use, very briefly:

No. `gsudo` reminds of the original sudo regarding user expectations. Many `sudo` features are `*nix` specific and could never have a `Windows` counterpart. Other features (such as `sudoers`) could potentially be implemented but are not at this point.

- Does it work in Windows 7/8?
- What are the requirements? Does it work in Windows 7/8?

Yes, it works from Win7 SP1 onwards, except the credentials cache.
It works on Win7 SP1 onwards. Some features may only work in Windows 10/11, like elevating as TrustedInstaller.

- How do I return to the previous security level after using gsudo?

Expand Down
1 change: 1 addition & 0 deletions installgsudo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ else
"PowerShell users: To use enhanced gsudo and Invoke-Gsudo cmdlet, add the following line to your `$PROFILE"
" Import-Module '${Env:ProgramFiles(x86)}\gsudo\gsudoModule.psd1'"
"Or run: "
" New-Item -Type Directory (`$PROFILE | Split-Path) -ErrorAction Ignore"
" Write-Output `"``nImport-Module '${Env:ProgramFiles(x86)}\gsudo\gsudoModule.psd1'`" | Add-Content `$PROFILE"

Remove-Item $fileName
Expand Down
34 changes: 18 additions & 16 deletions src/gsudo/Rpc/NamedPipeUtils.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System;
using System.Collections.Generic;
using System.IO;

using System.Linq;

namespace gsudo.Rpc
{
static class NamedPipeUtils
Expand Down Expand Up @@ -31,24 +32,25 @@ public static List<string> ListNamedPipes()

public static bool ExistsNamedPipe(string name)
{
var namedPipes = new List<string>();
Native.FileApi.WIN32_FIND_DATA lpFindFileData;

var ptr = Native.FileApi.FindFirstFile($@"\\.\pipe\{GetRootFolder(name)}*", out lpFindFileData);
do
{
if (lpFindFileData.cFileName.EndsWith(name, StringComparison.Ordinal))
{
Native.FileApi.FindClose(ptr);
Logger.Instance.Log($"Found Named Pipe \"{name}\".", LogLevel.Debug);
return true;
}
//Logger.Instance.Log($"Searching for {name}", LogLevel.Debug);
try
{
return System.IO.Directory.GetFiles("\\\\.\\\\pipe\\", name).Any();
}
catch
{
// Windows 7 workaround
foreach (var pipe in System.IO.Directory.GetFiles("\\\\.\\\\pipe\\"))
{
if (pipe.EndsWith(name, StringComparison.Ordinal))
{
//Logger.Instance.Log($"Found Named Pipe {name}", LogLevel.Debug);
return true;
}
}
}
while (Native.FileApi.FindNextFile(ptr, out lpFindFileData));

Native.FileApi.FindClose(ptr);
return false;

}

static string GetRootFolder(string path)
Expand Down

0 comments on commit 7a54115

Please sign in to comment.