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

An error occurs when I attempt to execute "gsudo regedit" #36

Closed
septsea opened this issue May 26, 2020 · 5 comments
Closed

An error occurs when I attempt to execute "gsudo regedit" #36

septsea opened this issue May 26, 2020 · 5 comments

Comments

@septsea
Copy link

septsea commented May 26, 2020

(I set an alias for gsudo.)

test1

Error: System.ComponentModel.Win32Exception (0x80004005): The operation completed successfully
   at gsudo.Helpers.ProcessFactory.CreateProcessAsUserWithFlags(String lpApplicationName, String args, CreateProcessFlags dwCreationFlags, PROCESS_INFORMATION& pInfo)
   at gsudo.ProcessRenderers.TokenSwitchRenderer..ctor(Connection connection, ElevationRequest elevationRequest)
   at gsudo.Commands.RunCommand.GetRenderer(Connection connection, ElevationRequest elevationRequest)
   at gsudo.Commands.RunCommand.<RunUsingElevatedService>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at gsudo.Commands.RunCommand.<Execute>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at gsudo.Program.<Start>d__1.MoveNext()
@Tiebe
Copy link

Tiebe commented May 29, 2020

First of all, don't set an alias. It already support the sudo and gsudo commands. Or did you set the alias to something else than those 2?

Second, it works for me in PowerShell but doesn't seem to work in Command Prompt.

@septsea
Copy link
Author

septsea commented May 29, 2020

@Tiebe
First of all, don't set an alias. It already support the sudo and gsudo commands. Or did you set the alias to something else than those 2?

Second, it works for me in PowerShell but doesn't seem to work in Command Prompt.

First, I installed gsudo by directly downloading the GitHub release, so I manually set an alias, It does not depend on the alias.

Second, gsudo regedit works in PowerShell but not in Command Prompt.

Actually there is no need to type such a command, because Windows 10 automatically pops up a window for privilege elevation if the user simply types regedit.

@gerardog
Copy link
Owner

I was able to reproduce it on CMD. With or without an alias.

This happens with the new default TokenSwitch mode, where the elevated process is created by the non-elevated gsudo, and the elevated instance replaces it's token with an elevated one.

A few workarouds: Make gsudo elevate cmd which then runs regedit:
gsudo start regedit
gsudo cmd /c regedit

Use attached mode instead of TokenSwitch:
gsudo --attached regedit

I am not sure yet what's the root cause here, or why this does not happen with PowerShell. Thanks @Tiebe for finding that last piece of info. It may lead to finding the root cause...

@gerardog
Copy link
Owner

The first step for TokenSwitch method is to create the process with CreateProcess API and some special flags. That is failing with Regedit.Exe because it has a manifest file embedded requesting elevation. (Thanks @septsea for finding out).
And this is also happening with gsudo eventvwr.exe and probably with all this list

gerardog added a commit that referenced this issue Jun 11, 2020
gerardog added a commit that referenced this issue Jun 11, 2020
@gerardog
Copy link
Owner

The fix was released in v0.7.1.
Thanks for reporting the problem.

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

3 participants