Most active commenters
  • withinboredom(4)
  • zamadatix(3)

←back to thread

466 points CoolCold | 30 comments | | HN request time: 1.277s | source | bottom
Show context
fn-mote ◴[] No.40212557[source]
Overall, this seems great.

However...

> [...] by default it will tint your terminal background in a reddish tone while you are operating with elevated privileges

?!! ouch ... seems orthogonal to the actual important parts.

Disclaimer: I didn't try it.

replies(4): >>40212686 #>>40215695 #>>40219040 #>>40225604 #
1. NekkoDroid ◴[] No.40212686[source]
I tried it a bit ago (when it was still called uid0, pre-release), I also wasn't a fan of the tinting.

I like the intent behind it, but some terminals already tint the header color when running sudo, I haven't tested if its done specifically for sudo or if its in a more generic way that could handle this as well.

replies(2): >>40212858 #>>40213006 #
2. Karellen ◴[] No.40212858[source]
> I also wasn't a fan of the tinting.

From the linked mastodon thread:

> For example, by default it will tint your terminal background in a reddish tone while you are operating with elevated privileges. That is supposed to act as a friendly reminder that you haven't given up the privileges yet, and marks the output of all commands that ran with privileges appropriately. (If you don't like this, you can easily turn it off via the --background= switch).

(emphasis mine)

replies(3): >>40215782 #>>40215796 #>>40217102 #
3. withinboredom ◴[] No.40213006[source]
I can think of a number of things this tinting would break.
replies(2): >>40213766 #>>40216548 #
4. lupire ◴[] No.40213766[source]
Can you name any?
replies(4): >>40216039 #>>40217253 #>>40217645 #>>40221935 #
5. gh02t ◴[] No.40215782[source]
It was a bit unclear to me from the thread, is there a persistent configuration option for this? I like the idea of tinting the terminal, but I also want to be able to turn it off with a global config option rather than having to type out a --background flag every invocation.
replies(1): >>40215811 #
6. zamadatix ◴[] No.40215796[source]
I think it's more that the default seems backwards than the lack of ability to change it.
replies(1): >>40216064 #
7. zamadatix ◴[] No.40215811{3}[source]
Aliasing the command as the command + your default arguments is the easiest general solution to this kind of problem. I'm not sure if there is a "systemd way" to permanently set it though.
replies(2): >>40216003 #>>40217458 #
8. gh02t ◴[] No.40216003{4}[source]
True, I was thinking a simple environment variable or systemd configurable would be fine but I guess an alias is a good idea.
9. dsr_ ◴[] No.40216039{3}[source]
The user's choice of color schemes.
10. dsr_ ◴[] No.40216064{3}[source]
It's three things:

* here is a feature which we are defaulting to on

* there's no persistent config for it

* we know better than you do about your preferences

replies(1): >>40216974 #
11. seanc ◴[] No.40216548[source]
It violates the principle of Least Surprise; if I'm invoking run0 I'm expecting it to run my program with a different UID and return the same stdout I'd have gotten if I had just run the program in my shell. Not inject a whole bunch of color control bytes in there. Which hopefully my terminal will handle. Unless it doesn't.

I'll give them the benefit of the doubt and assume they only do this if $TERM supports color. But still. That $TERM variable can surprise a poor programmer in all sorts of ways.

replies(2): >>40217545 #>>40217883 #
12. zamadatix ◴[] No.40216974{4}[source]
"Defaulting to on" is just a symlink to an existing binary so that's not really much a problem.
replies(1): >>40218213 #
13. deadbunny ◴[] No.40217102[source]
I for one love to type out 13 extra characters to a 4 character command to disable dumb choices by the developer.

On a more serious note, I wonder what random ASCII escape sequences we can send.

replies(2): >>40219371 #>>40221421 #
14. shiomiru ◴[] No.40217253{3}[source]
If the program you're running prints red text, then you get red bgcolor with red fgcolor. Good luck reading that.

(Also, users with the wrong color scheme get that experience by default. Though that is a niche use case enough that I'd be surprised if systemd devs cared about it.)

15. tolciho ◴[] No.40217458{4}[source]
I accidentally compile color support out of st, or set xterm*colorMode:false to avoid seeing the backside of a unicorn randomly rubbed all over the terminal, on account of git and other wares being bad at their inability to not spew color codes. A sensible default would be to set no colors, in the event that the colors are unreadable (due to colorblindness, etc) or distracting, but that ship sailed. Most of my vim config on RedHat linux was disabling wacky vendorisms, and back when I used linux I did have a "special terminal" for some NVIDIA installer that mandated colors to be usable. Maybe the terminal title was set to Fisher-Price, maybe not.
replies(1): >>40222748 #
16. 10000truths ◴[] No.40217545{3}[source]
Any sane command line program will only output color codes if isatty(STDOUT_FILENO) succeeds.
replies(1): >>40217597 #
17. withinboredom ◴[] No.40217597{4}[source]
That can succeed in a number of cases, where it actually isn't a tty with a user on the other end of it. There are a number of internal tools at work that only output logging if there is a tty and thus are run in their cronjobs with a tty. If there were unexpected color outputs in the logs, that would suck since the log aggregators probably wouldn't know what to do with it.
18. withinboredom ◴[] No.40217645{3}[source]
Containers run with a tty attached but no console on the other end and then trying to read the logs, for starters. Additionally, as mentioned, conflicts with the user's color scheme or even the program's. Further, it's possible to do this without the help of run0, so I suspect users already doing that are going to get their colors messed up and be annoyed. For example, prod machines are usually red, and running as root on a prod machine is royal purple. If this is used, seeing a red background instead of a purple one is likely non-desirable.
19. zeroimpl ◴[] No.40217883{3}[source]
But sudo already doesn’t do that either. Eg sudo may ask for a password, and output some control sequences which hide the text so your password is not visible.

This feels like much ado about nothing.

Edit: Also don’t forget the “with great power comes great responsibility” blurb that sudo likes to output. I know that doesn’t happen in scripts when output is redirected, but I’m sure run0 will figure that out too.

replies(2): >>40218131 #>>40220144 #
20. dijit ◴[] No.40218131{4}[source]
asking for a password to do an authenticated action is about as far away from surprising as I can legitimately reason about.

The contextual blurb does have a way of disabling it in a persistent config, which is easy enough to set. It also goes to stderr and not stdout and does nothing to alter the output of the command itself.

It also does not show if you have NOPASSWD: set in your sudoers. So even less surprising.

21. gpm ◴[] No.40218213{5}[source]
A symlink to a binary that I'm going to pass a password to seems like a security bug waiting to happen (just in the manner that any complexity around privilege escalation is a bad idea).
22. BenjiWiebe ◴[] No.40219371{3}[source]
'alias' is your friend.
replies(1): >>40222214 #
23. withinboredom ◴[] No.40220144{4}[source]
> sudo may ask for a password, and output some control sequences which hide the text so your password is not visible.

You can turn this off for certain users and/or programs.

24. Karellen ◴[] No.40221421{3}[source]
> I for one love to type out 13 extra characters

FWIW, systemd is normally pretty good at providing autocomplete suggestions, so even if you don't want to set up an alias you'll probably just have to type `--b<TAB> ` to set it.

> I wonder what random ASCII escape sequences we can send.

According to the man page source[0]:

> The color specified should be an ANSI X3.64 SGR background color, i.e. strings such as `40`, `41`, …, `47`, `48;2;…`, `48;5;…`

and a link to the relevant Wikipedia page[1]. Given systemd's generally decent track record wrt defects and security issues, and the simplicity of valid colour values, I expect there's a fairly robust parameter verifier in there.

In fact, given the focus on starting the elevated command in a highly controlled environment, I'd expect the colour codes to be output to the originating terminal, not forwarded to the secure pty. That way, the only thing malformed escapes can affect is your own process, which you already have full control over anyway.

(Happy to be shown if that's a mistaken expectation though.)

[0] https://github.com/systemd/systemd/blob/main/man/run0.xml

[1] https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_G...

25. snvzz ◴[] No.40221935{3}[source]
XMODEM and the like expect the terminal stream to not have garbage added by e.g. run0.

The terminal line should be clean between XMODEM at the terminal emulator and at the client end.

replies(1): >>40256515 #
26. deadbunny ◴[] No.40222214{4}[source]
I shouldn't need to alias behaviour that violates the principle of least surprise on every single machine I need to run elevated commands on.
replies(1): >>40222685 #
27. shrimp_emoji ◴[] No.40222685{5}[source]
Eh.

`alias grep='grep --color=auto'`

`alias ls='ls --color=auto'`

It's canon.

28. shrimp_emoji ◴[] No.40222748{5}[source]
Dang. I wish I had the autism to bristle at colors. Think about all the lost hours agonizing over themes! Not feeling the agonizing tension between the fact that cool-retro-term made your terminal into an awesome monochrome CRT but that it's monochrome green so your syntax highlighting is all messed up!

> back when I used linux

What do you use now? :0 BSD? Plan 9???

29. throwaway7356 ◴[] No.40256515{4}[source]
Is xmodem still used outside of computer museums (including private computer museums)?
replies(1): >>40262973 #
30. snvzz ◴[] No.40262973{5}[source]
It's e.g. still very popular with embedded development. One example: u-boot supports it.

It is the easiest way to upload an image to u-boot, as it does use the same terminal, thus there is no need to set up a secondary path; If you can talk with the u-boot CLI, you can also upload with xmodem.