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

Issue: Sudo is disabled on this machine. To enable it, go to the Developer Settings page in the Settings app - sudo alias don't work #387

Open
m4ss1m0g opened this issue Jan 9, 2025 · 7 comments

Comments

@m4ss1m0g
Copy link

m4ss1m0g commented Jan 9, 2025

Issue Description

With 24H2 sudo alias don't work.
I read and apply gsudo config PathPrecedence True from #346, but doesn't work.

Steps to Reproduce

  1. Win 24H2
  2. Execute gsudo config PathPrecedence True
  3. Close all terminal
  4. Start new terminal
  5. try sudo
  6. Error popup Sudo is disabled on this machine. To enable it, go to the Developer Settings page in the Settings app

Context:

  • Windows version: 24H2
  • gsudo version: v2.5.1
@gerardog
Copy link
Owner

gerardog commented Jan 9, 2025

Have you restarted your consoles after gsudo config PathPrecedence True? That would be enough, but if still no good you can try also to log-out and log-in again.
If still not working would you please then open cmd.exe and run path and paste the results here?
Thanks

@m4ss1m0g
Copy link
Author

I have restarted the pc but no luck, here is the path.

PATH=C:\Users\massimo\scoop\apps\gsudo\current;C:\Program Files (x86)\Common Files\Oracle\Java\java8path;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\Microsoft MPI\Bin;C:\Program Files (x86)\VMware\VMware Workstation\bin;C:\ProgramData\scoop\shims;C:\Program Files\shims;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\dotnet;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn;C:\Program Files (x86)\Microsoft SQL Server\150\Tools\Binn;C:\Program Files\Microsoft SQL Server\150\Tools\Binn;C:\Program Files\Microsoft SQL Server\150\DTS\Binn;C:\Program Files (x86)\dotnet-core-uninstall;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\PowerShell\7;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\Docker\Docker\resources\bin;C:\Users\massimo\scoop\apps\nodejs-lts\current\bin;C:\Users\massimo\scoop\apps\nodejs-lts\current;C:\Users\massimo\scoop\apps\vscode\current\bin;C:\Users\massimo\scoop\apps\openssl\current\bin;C:\Users\massimo\scoop\apps\gsudo\current;C:\Users\massimo\scoop\shims;C:\Users\massimo\AppData\Local\Microsoft\WindowsApps;C:\ProgramData\AppGet\bin;C:\Users\massimo.dotnet\tools;C:\Users\massimo.dotnet\tools;C:\msys64\ucrt64\bin;C:\Users\massimo\AppData\Local\Microsoft\WindowsApps

here is the gsudo config

# CacheMode: Defines how gsudo credentials cache works: Auto, Explicit (default), Disabled
# CacheDuration: Defines how long (HH:MM:SS) the credentials cache will be valid if idle. Use 'Infinite' for no expiration
# LogLevel: Defines the verbosity of the log. (Valid values: All, Debug, Info, Warning, Error, None)
# NewWindow.Force: Always elevate in new window. (Equivalent to --new)
# NewWindow.CloseBehaviour: When elevating in a new window, defines what happens when the process ends: OsDefault (let the window auto-close), KeepShellOpen or PressKeyToClose
# Prompt: CMD Prompt to be used when gsudo uses standard mode
# PipedPrompt: CMD Prompt to be used when gsudo uses piped mode
# ForceAttachedConsole: Forces gsudo to use Attached mode. Can fix some very specific problems. Same as --attached
# ForcePipedConsole: Forces gsudo to use legacy piped mode. Not recommended
# ForceVTConsole: Forces gsudo to use VT mode. Experimental. Same as --vt
# CopyEnvironmentVariables: Only applies to Attached Mode. Forces copying caller's env variables to the elevated context. Same as --CopyEv
# CopyNetworkShares: Reconnect network shares on the elevated context. Same as --CopyNs
# PowerShellLoadProfile: Loads the PowerShell profile when elevating PowerShell commands. Same as --LoadProfile
# SecurityEnforceUacIsolation: Elevates but with the input handle closed. More secure, but less convenient. Same as --disableInput
# ExceptionList: List of executables with some issues so they will be started with "cmd /c executable"
# PathPrecedence: Prioritize gsudo over Microsoft Sudo in the PATH environment variable

CacheMode = "Explicit"                            (default)
CacheDuration = "00:05:00"                        (default)
LogLevel = "Info"                                 (default)
NewWindow.Force = "False"                         (default)
NewWindow.CloseBehaviour = "OsDefault"            (default)
Prompt = "$p$e[1;31m# $e[0m"                      (default)
PipedPrompt = "$P# "                              (default)
ForceAttachedConsole = "False"                    (default)
ForcePipedConsole = "False"                       (default)
ForceVTConsole = "False"                          (default)
CopyEnvironmentVariables = "False"                (default)
CopyNetworkShares = "False"                       (default)
PowerShellLoadProfile = "False"                   (default)
SecurityEnforceUacIsolation = "False"             (default)
ExceptionList = "notepad.exe;powershell.exe;whoami.exe;vim.exe;nano.exe;" (default)
PathPrecedence = "True"                           (global)

@RuiNtD
Copy link

RuiNtD commented Jan 12, 2025

It doesn't work with Scoop because sudo.exe is in scoop\shims, but PathPrecedence puts scoop\apps\scoop\current at the start of PATH, which only contains gsudo.exe and not sudo.exe. Unless @gerardog changes the behavior of PathPrecendence to correctly handle Scoop, the easiest solution is to just reinstall gsudo with WinGet, which does create a symlink from sudo.exe to gsudo.exe
EDIT: You'll also have to scoop uninstall gsudo, since it's now the first in PATH. 😅

@m4ss1m0g
Copy link
Author

Thanks, @RuiNtD I created a symlink into gsudo\current dir with mklink sudo.exe gsudo.exe and it now works. The drawback is that at each update I must recreate the link, I hope Gerardo can fix this.

@RuiNtD
Copy link

RuiNtD commented Jan 13, 2025

An alternative is to make a folder somewhere on your drive containing only a symlink from sudo.exe to scoop\apps\gsudo\current\gsudo.exe and put that at the start of PATH.

As for adding a fix, gsudo should probably check for the existence of sudo.exe anyways when enabling PathPrecedence, since it's the whole point of the setting, and since it already asks for admin to change the PATH, it can create a symlink at that time as well.

@m4ss1m0g
Copy link
Author

m4ss1m0g commented Jan 13, 2025

Maybe @gerardog can add a File.CreateSymbolicLink when set PathPrecedence if path contains "scoop".

Another approach can be to modify the post_install on gsudo scoop script, but I think this is out of the control of @gerardog.

Another approach is to place scoop/shims as the first path, but I don't know if there are any counter-indications.

@dmuiX
Copy link

dmuiX commented Mar 5, 2025

Have you restarted your consoles after gsudo config PathPrecedence True? That would be enough, but if still no good you can try also to log-out and log-in again. If still not working would you please then open cmd.exe and run path and paste the results here? Thanks

Definitely Worked for me
Thanks.

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

No branches or pull requests

4 participants