Specification for denoting elevated privileges
Currently, terminals such as Ptyxis and Console show some window dressing at the top to denote when the terminal is in elevated privileges (sudo, su, etc).
The tracking for this isn't great. In Ptyxis, it uses tcgetpgrp()
to get the foreground leader and then checks with access()
looking for UID 0. In console I believe it parses a process tree looking for something similar.
Both of these are fallible anyway because you could be SSH'd into another machine and sudo (false negative) or SSH'd into another machine not as root (false positive). Additionally, tooling like tmux
, screen
, podman
, and run0
can get in the way with additional PTY between you and the "true" foreground leader.
One thought, since this stuff is mostly opportunistic anyway and lacks any sort of real accuracy, is to use a terminal property instead which can be emitted by sub-shells or tooling.
VTE 0.78 gained "termprops" through OSC escape sequences which allow for either notifications (termprops w/ no value) or typed values (string, double, etc). https://gitlab.gnome.org/GNOME/vte/-/blob/d99a527cd408d53ca8104b2be50da79dde7c3162/src/vtegtk.cc?page=4#L3072 has some information on it.
This issue is to discuss the possibility for creating a specification to denote this type of behavior.
It could define behavior for:
- enter/leaving containers
- entering a privileged level (and whether you should be allowed to clear that bit and how)
- denote password entry
- denote current machine address and/or if we are a remote session
One hope I would have for this is that we could avoid run0 doing background modification which can really mess up terminal rendering.