sudo icon indicating copy to clipboard operation
sudo copied to clipboard

Support TTY mode

Open Brynyard opened this issue 1 year ago • 4 comments

The biggest problem with Windows's requirement to run some commands/operations/RPC in an "elevated" context is that it is not possible to run this in a TTY. Currently this tool is just a convenience script to make it a bit less painful to do elevated operations, it does not enable it to be used in a TTY setting, and as such does not have one of the most basic functionality of the *nix sudo tool.

I appreciate that Win32's checkered history in the TTY department makes this difficult to implement, but it should at least be clarified that this is a limitation since it's called "sudo", and anyone familiar with the *nix tool might reasonably assume it has this basic functionality.

Brynyard avatar Feb 09 '24 08:02 Brynyard

Yes, I agree with this. I spend a fair amount of time SSHed from my desk into WSL running on remote lab-bench computers. Sometimes I need to do things that require elevation, like binding USB devices to usbipd or modifying Hyper-v configurations. It's a pain to have to switch from SSH to remote-desktop everytime I need to run anything with elevated permissions, and I'd love to see sudo provide some alternative implementation.

nrclark avatar Feb 09 '24 11:02 nrclark

Wait, just so I'm sure - is this basically just the same as #7? "I want to be able to enter my creds straight away in the terminal"?

zadjii-msft avatar Feb 09 '24 18:02 zadjii-msft

Another interpretation of "TTY mode" would be, that sudo starts the program, that it is supposed to run, in a new pseudo TTY. That is what sudo on linux does. If I run tty && sudo tty on Linux, I get this output:

/dev/pts/0
/dev/pts/1

The man(ual) page of tty says: "tty - print the file name of the terminal connected to standard input". So the second instance of the tty program runs in a different pseudo TTY.

Windows also has pseudo TTYs. So sudo for Windows could do the same. But I don't know what the advantage is, of running the elevated command in a new pseudo TTY.

But I guess, the author of this feature request meant, what you said, @zadjii-msft:

Wait, just so I'm sure - is this basically just the same as #7? "I want to be able to enter my creds straight away in the terminal"?

j0le avatar Feb 14 '24 10:02 j0le

@j0le What I meant is what is discussed in #7. I didn't mean the command tty but the concept of a TTY (often just referred to as a PTY nowadays since we usually don't actually use a terminal connected through a RS-232 port).

The PTY on Windows is a fairly recent thing (unless you've delved into hacks like ConEmu), and it still has quite a few quirks. But it's getting to a point where it might be able to achieve feature parity with a 1970's terminal in the not too distant future (hopefully).

Brynyard avatar Feb 14 '24 12:02 Brynyard

Thanks for the suggestion! This is actually already being tracked by another issue on our repo - please refer to #7 for more discussion.

/dup #7

joadoumie avatar Feb 28 '24 20:02 joadoumie