News for hackers. Stuff that matters.
Re:GNU ed ate my homework by mont on Sunday April 03, 2022 @08:29AM (#30896359)
Why is this?
Re:GNU ed ate my homework by hvdijk on Sunday April 03, 2022 @09:32AM (#30896782)
sudo $EDITOR launches the editor itself as root, sudo -e launches the editor as a regular user on a temporary copy of the original file, and copies the contents back over to the original file when you are done. The less done as root, the less opportunity to mess things up.
Re:GNU ed ate my homework by stardenburden on Sunday April 03, 2022 @11:32AM (#30897672)
Couldn't a malicious actor edit the temporary file without the user who invoked sudo -e noticing?
Re:GNU ed ate my homework by daptaq on Sunday April 03, 2022 @01:01PM (#30898451)
Perhaps, but you will still overwrite it when you exit the editor and let sudo copy the contents back (that being said, there might be a race condition between closing the editor and sudo noticing that the process has terminated). Not sure if this would work, but a possible workaround could be to use /dev/shm (https://www.kernel.org/doc/gorman/html/understand/understand...).
Re:GNU ed ate my homework by hvdijk on Sunday April 03, 2022 @02:57PM (#30899607)
The temporary file should be created in such a way that other users cannot modify it. If that does not happen, if other users can modify it, I would regard that as a bug.

Malicious processes running as the same user could potentially modify the file, but if you have malicious processes running as a user with sudo privileges you have probably already lost.

Re:GNU ed ate my homework by lysium on Wednesday April 06, 2022 @12:46AM (#30928583)
Yes, I think she can. I think this is better than running the whole editor as root.