You are not logged in.
My goal was to preserve neovim config `~/.config/neovim` when editing files with sudo.
I read the man page and also https://wiki.archlinux.org/title/sudo#, Also a good read - https://superuser.com/questions/785187/ … er-sudo-vi
From what i understand ->
1. `-E` will preserve all my env vareables, so neovim will be run as root using the config from my home directory.
2. `-e` will make a temp copy of the file with my user premission and open neovim with my home config. Downside is that changes won't be reflected until i save and exit the neovim.
But i am still confused which should be preffered for my usecase and the reasoning behind it.
Last edited by phoenix324 (2024-01-11 09:22:41)
Offline
Why not sudoedit?
When invoked as sudoedit, the -e option (described below), is implied.
Offline
These two options are completely unrelated to each other. There is no preference for one over another.
Only `sudo -e` (or sudoedit) can edit files and does that running as the invoking user.
Your other invocation does not edit any file. It elevates privileges to root, then runs a program with these privileges, while passing your user’s environment variables to that program. It happens, that the program you invoke is a text editor, but this is unrelated to sudo or the `-E` option.
Blanket passing all user’s environment variables to a program executed as another user, in particular root, may have negative implications. For security of the system, and for integrity of both invoking user’s and system. In the first case it may permit unwanted privilege escalation. In the other it may cause pollution or damage to data of either side.
Paperclips in avatars? | Sometimes I seem a bit harsh — don’t get offended too easily!
Offline
It happens, that the program you invoke is a text editor, but this is unrelated to sudo or the `-E` option.
That's why i got confused which method i should be using as both were in the end editing text.
Blanket passing all user’s environment variables to a program executed as another user, in particular root, may have negative implications. For security of the system, and for integrity of both invoking user’s and system. In the first case it may permit unwanted privilege escalation. In the other it may cause pollution or damage to data of either side.
This is what i wanted to know.
Thank you. I will go with `sudo -e`/`sudoedit` for editing files.
Offline