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

Command doesn't execute #36

Closed
filips123 opened this issue May 13, 2019 · 7 comments
Closed

Command doesn't execute #36

filips123 opened this issue May 13, 2019 · 7 comments

Comments

@filips123
Copy link

When I try to execute a command with sudo, it doesn't execute. It shows UAC prompt but the command is never executed.

@niels-bosman
Copy link

Same for me. Although I do not get UAC prompt.

@chrisdjali-wrld3d
Copy link
Contributor

I was having the same issue. I've not fixed it, but when I change the line with the PowerShell command to

if ! powershell.exe "Start-Process \"$(cygpath -w /bin/)bash\" \"$backend\", \"$fifoid\" -Verb RunAs -WorkingDirectory \"\$PWD\" -Wait; (\$Error[0]).InvocationInfo.Line"; then

the Bash window that appears complains that /dev/cons1: No such device or address when running the $SHELL -c "$command_to_run" >"$stdout" 2>"$stderr" <"$stdin" & line of sudobackend.

Hopefully this is useful information rather than a new problem I've introduced with my meddling.

@chrisdjali-wrld3d
Copy link
Contributor

I think what's going on here is that the author was expecting -WindowStyle Hidden to work like -NoNewWindow where the process is spawned in the current console session, so then when the sudo script gets the filenames for its input and output, if it was connected up to the Cygwin pseudo device for the current console (e.g. /dev/cons1) the same device would be available from the sudobackend script. However, the backend script gets a fresh console, and can only see /dev/cons2 due to what Cygwin's Special Filenames docs describe as a restriction in Windows.

The solution would be to switch from -WindowStyle Hidden to -NoNewWindow, but that's not part of the same parameter set as -Verb, so can't be used at the same time, and -Verb RunAs is where all the magic happens.

As for why this works for some people and not others, I think there's a difference between the MinTTY console Git Bash uses by default and other Windows consoles. If the console is MinTTY (e.g. Git Bash has been started directly) sudo works just fine and the stdin, stdout, and stderr sudobackend uses are all /dev/pty0 (potentially with a different number). If the console is the Windows Command Host or VS Code's terminal is used, though, it doesn't work and they're all /dev/cons0 (potentially with a different number). Maybe some special handling can be added so when the outer sudo is connected to a /dev/consX it sets up a different file the sudobackend script can talk to and copies input and output to it itself.

@raymondmgeni
Copy link

install node js

@riedel
Copy link
Contributor

riedel commented Mar 4, 2023

Fixed in 5b2d65b ?

@chrisdjali-wrld3d
Copy link
Contributor

Seems to be, although the Windows install I was initially hitting this issue on no longer exists, so I'm not testing it under exactly the same conditions as when I originally hit the problem.

@purplesyringa
Copy link
Owner

Guess we won't really be able to check this in any other way, then. Feel free to open another issue if this still happens

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

6 participants