this post was submitted on 13 Jun 2025
70 points (97.3% liked)

Rust

7083 readers
2 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] trevor@lemmy.blahaj.zone 6 points 1 week ago* (last edited 1 week ago) (1 children)

I don't think it's that simple. The challenge is that you need to still behave as if it's invoked as the user so that the editor uses their configurations instead of simply execing it as root.

I could be wrong though ¯\_(ツ)_/¯

[–] sugar_in_your_tea@sh.itjust.works 2 points 1 week ago (1 children)

Sudo uses the setuid bit or whatever, so it still has access to the user's environment variables and whatnot. So figuring out which editor to run shouldn't be an issue.

[–] trevor@lemmy.blahaj.zone 6 points 1 week ago (1 children)

That's not what I mean. Yeah, getting the environment variables are simple enough, but if you simply exec something as the root user, whatever you exec will naturally be looking for configs in /root/.config and not your ~/.config dir, so any configurations to things like your text editor won't be read.

Ah, makes sense. It's easy enough to duplicate the outer ENV for the sub-process, but I don't know what that means for security and whatnot.